feat: refactor work item file retrieval to use Python script for improved error handling and readability

This commit is contained in:
2026-05-04 09:45:28 -06:00
parent 541c9b43de
commit ff4ed6a759
12 changed files with 195 additions and 143 deletions

View File

@@ -9,40 +9,29 @@ OpenCode should treat this project as a persistent context layer used to:
- draft standups and Mattermost messages
- improve communication for the current manager or stakeholder in natural professional English
## Always-Loaded Context
## Hot Context
The detailed operating rules live in:
Keep the always-loaded context small. The hot set is:
- `project-knowledge/00-start/start-here.md`
- `agent-memory/README.md`
- `profiles/fidelity/profile.md`
- `agent-memory/behavior/agent-behavior.md`
- `agent-memory/behavior/learning-sessions.md`
- `agent-memory/behavior/self-maintenance.md`
- `agent-memory/memory/operational-memory.md`
- `agent-memory/memory/context-maintenance.md`
- `agent-memory/workflows/workspace-architecture.md`
- `agent-memory/memory/promotion-rules.md`
- `agent-memory/integrations/technical-verification.md`
- `agent-memory/workflows/ai-to-ai-prompting.md`
- `project-knowledge/00-start/start-here.md`
- `project-knowledge/01-current/current-work.md`
- `project-knowledge/01-current/work-items.md`
- `project-knowledge/03-context/project.md`
- `project-knowledge/03-context/ios/index.md`
- `project-knowledge/03-context/ios/current-practices.md`
- `project-knowledge/03-context/ios/project-swift-guidance.md`
- `project-knowledge/03-context/systems/index.md`
- `project-knowledge/03-context/workstreams/index.md`
- `project-knowledge/03-context/process/communication.md`
- `agent-memory/integrations/technical-verification.md`
- `agent-memory/workflows/ai-to-ai-prompting.md`
- `agent-memory/workflows/workspace-model.md`
- `agent-memory/memory/promotion-rules.md`
- `agent-memory/integrations/memory-interface.md`
- `agent-memory/integrations/obsidian.md`
- `agent-memory/integrations/communication-sources.md`
- `core/integrations/memory-vault-model.md`
- `project-knowledge/03-context/ios/index.md`
- `project-knowledge/03-context/ios/project-swift-guidance.md`
- `project-knowledge/04-people/manager.md`
- `project-knowledge/04-people/index.md`
- `project-knowledge/02-work-items/index.md`
These are also loaded through `opencode.json`.
Load everything else lazily when the task actually needs it.
Do not preemptively load broad context sets, all work-item files, or all process notes unless the current task clearly requires them.
## Required Behavior
@@ -53,6 +42,7 @@ These are also loaded through `opencode.json`.
- Keep Obsidian Bases clean: templates in `project-knowledge/09-templates/` must not be treated as real notes, and role mapping files such as `project-knowledge/04-people/manager.md` must not be typed as people.
- Maintain useful project-note properties when editing canonical notes, especially work-item relationships (`systems`, `workstreams`, `people`, `related`) and daily note fields (`focus`, `work-items`, `blockers`).
- Before answering questions that depend on current work state, inspect `project-knowledge/01-current/current-work.md` and the latest relevant daily note under `project-knowledge/06-daily/`.
- Prefer lazy loading over eager loading. Pull in only the smallest relevant files for the active task.
- If `ai/inbox/mattermost-latest.md` exists, inspect it for fresher communication context before answering standup, status, or manager-message prompts.
- If the user asks for the latest/last/recent Mattermost message, the latest message from Jeff/current manager, or what someone just said, synchronize Mattermost first instead of relying on existing inbox context.
- If automatic refresh is uncertain, use the explicit latest-message flow: run the Mattermost sync command, then answer from the refreshed inbox only.
@@ -62,6 +52,9 @@ These are also loaded through `opencode.json`.
- Ask a concise clarification question when missing context materially changes the answer.
- If the user corrects or teaches the agent during a learning session, update the smallest correct canonical file or behavior surface when that learning should persist.
- For any meaningful prompt, decide whether the interaction introduces or corrects project memory.
- For analysis, review, translation, or drafting requests, answer first unless a memory update is required to avoid losing a clear durable fact.
- Do not create new canonical notes before answering unless the user asked to save the information, the destination is obvious, and the write is small and non-blocking.
- Prefer updating existing canonical files over creating new files during the critical path of a user-facing answer.
- If a sync command, extraction script, or inbox refresh fails, do not update logs, state, or context files from that failed attempt.
- Treat sync failures as operational errors, not project context.
- `mattermost-sync` should automatically promote high-confidence project facts without asking what to promote.
@@ -76,6 +69,7 @@ These are also loaded through `opencode.json`.
- If a new prompt corrects prior understanding, update the canonical file directly instead of keeping both versions alive.
- Do not ask what should be saved when the correct destination is already clear.
- If the user provides durable new facts, update the appropriate context files instead of leaving the new information only in chat history.
- When the prompt is primarily asking for analysis of a screenshot, message, or document, do not interrupt the answer to perform proactive note creation unless that persistence is the explicit goal.
- When creating a new canonical note from a known type, prefer `scripts/memory/memory.sh create <type> <slug> [title]` so type-to-folder routing stays centralized.
- If the Obsidian CLI adapter fails, fall back to direct Markdown operations and treat the failure as tooling status, not project context.
- If a previous context file is now stale or inaccurate, update that file directly.