feat: Enhance memory management and promotion rules for Mattermost context and user prompts
This commit is contained in:
@@ -12,6 +12,7 @@ Behavior rules:
|
||||
|
||||
- Treat `README.md`, `ai/context/`, `ai/state/`, `knowledge/`, and `ai/logs/` as the persistent memory of the project.
|
||||
- Before answering a prompt that depends on current state, verify the latest relevant files instead of relying only on conversation history.
|
||||
- For any meaningful prompt, decide whether the interaction adds, corrects, or sharpens project memory.
|
||||
- When the user provides new durable information, update the right workspace files before or while answering.
|
||||
- If existing context is stale, correct it directly instead of leaving conflicting versions.
|
||||
- Promote information carefully:
|
||||
@@ -20,5 +21,8 @@ Behavior rules:
|
||||
- durable project knowledge goes to `ai/context/project.md`
|
||||
- confirmed team or manager communication preferences go to `ai/context/people/jeff.md`
|
||||
- confirmed decisions go to `ai/context/decisions/`
|
||||
- Default to writing new same-day information to today's log unless a more durable destination is clearly better.
|
||||
- Update preexisting memory when a new prompt clarifies or corrects something already stored.
|
||||
- Do not wait for a dedicated sync command if the correct memory update is already obvious.
|
||||
- Do not over-promote uncertain information. Keep uncertain items in the daily log.
|
||||
- When drafting communication, preserve technical meaning and improve clarity in natural US English.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
description: Force a Mattermost sync using the configured local script
|
||||
description: Sync Mattermost context and automatically promote high-confidence project memory
|
||||
---
|
||||
|
||||
Use the configured Mattermost sync command to fetch fresh communication context into the inbox only.
|
||||
Use the configured Mattermost sync command to fetch fresh communication context and maintain workspace memory automatically.
|
||||
|
||||
Preferred command sources:
|
||||
|
||||
@@ -16,14 +16,17 @@ Run the command and use its output as fresh communication context:
|
||||
Then:
|
||||
|
||||
- if the command fails, stop there and do not edit any workspace files
|
||||
- if no `ai/inbox/mattermost-latest.md` exists after the sync attempt, do not update project memory
|
||||
- inspect `ai/inbox/mattermost-latest.md` if it exists
|
||||
- extract only project-relevant candidate facts
|
||||
- do not update `ai/logs/`, `ai/state/`, or `ai/context/` in this command
|
||||
- if important candidate facts are found, summarize them as promotion candidates for a later explicit command
|
||||
- use `ai/inbox/mattermost-latest.md` if it exists and is non-empty
|
||||
- otherwise use `scripts/mattermost/generated/mattermost_context.jsonl` if it exists and is non-empty
|
||||
- apply the memory promotion rules from `knowledge/memory-promotion-rules.md`
|
||||
- automatically promote explicit, project-relevant, high-confidence facts
|
||||
- default destination is `ai/logs/$(date +%F).md`
|
||||
- update `ai/state/current.md` only for facts that materially change the current work window
|
||||
- do not write tooling noise, sync status, or generic chat chatter into project memory
|
||||
- if a fact is ambiguous, skip it rather than asking the user what to do
|
||||
|
||||
Return:
|
||||
|
||||
1. What was synchronized
|
||||
2. Candidate project facts worth promoting
|
||||
3. What still needs human confirmation
|
||||
2. Which files were updated
|
||||
3. Which facts were promoted or intentionally skipped
|
||||
|
||||
@@ -11,6 +11,7 @@ Read:
|
||||
@ai/state/current.md
|
||||
@knowledge/workspace-model.md
|
||||
@knowledge/communication-rules.md
|
||||
@knowledge/memory-promotion-rules.md
|
||||
|
||||
Today's log, if present:
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
description: Update workspace memory from new facts, corrections, or Mattermost notes
|
||||
description: Update workspace memory from new facts, corrections, or contextual notes
|
||||
---
|
||||
|
||||
Use this command when new information should become part of the persistent workspace context.
|
||||
@@ -13,6 +13,8 @@ Read:
|
||||
@ai/state/current.md
|
||||
@knowledge/workspace-model.md
|
||||
@knowledge/communication-rules.md
|
||||
@knowledge/agent-memory-rules.md
|
||||
@knowledge/memory-promotion-rules.md
|
||||
|
||||
Today's existing log, if present:
|
||||
|
||||
@@ -34,6 +36,8 @@ Instructions:
|
||||
- If an existing statement became stale, replace or refine it
|
||||
- Do not invent missing facts
|
||||
- Keep uncertain information in the daily log instead of promoting it to stable context
|
||||
- Do not ask for promotion confirmation when the correct destination is already clear
|
||||
- Prefer correcting canonical memory over appending duplicate summaries
|
||||
|
||||
After editing, respond with:
|
||||
|
||||
|
||||
@@ -26,6 +26,15 @@ async function resolveSyncCommand(directory) {
|
||||
}
|
||||
}
|
||||
|
||||
async function resolveSyncContent(directory, stdoutText) {
|
||||
const cleaned = (stdoutText || "").trim()
|
||||
if (cleaned) return cleaned
|
||||
|
||||
const generatedPath = path.join(directory, "scripts/mattermost/generated/mattermost_context.jsonl")
|
||||
const generated = await safeRead(generatedPath)
|
||||
return (generated || "").trim()
|
||||
}
|
||||
|
||||
export const MattermostInbox = async ({ $, directory, client }) => {
|
||||
let lastSyncAt = 0
|
||||
|
||||
@@ -54,7 +63,8 @@ export const MattermostInbox = async ({ $, directory, client }) => {
|
||||
|
||||
try {
|
||||
await mkdir(inboxDir, { recursive: true })
|
||||
const output = (await $`bash -lc ${command}`.text()).trim()
|
||||
const stdoutText = await $`bash -lc ${command}`.text()
|
||||
const output = await resolveSyncContent(directory, stdoutText)
|
||||
const previous = await safeRead(latestPath)
|
||||
|
||||
if (output) {
|
||||
|
||||
Reference in New Issue
Block a user