ma-agents 2.20.3 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.opencode/skills/.ma-agents.json +241 -0
- package/.opencode/skills/MANIFEST.yaml +254 -0
- package/.opencode/skills/ai-audit-trail/SKILL.md +23 -0
- package/.opencode/skills/auto-bug-detection/SKILL.md +169 -0
- package/.opencode/skills/cmake-best-practices/SKILL.md +64 -0
- package/.opencode/skills/cmake-best-practices/examples/cmake.md +59 -0
- package/.opencode/skills/code-documentation/SKILL.md +57 -0
- package/.opencode/skills/code-documentation/examples/cpp.md +29 -0
- package/.opencode/skills/code-documentation/examples/csharp.md +28 -0
- package/.opencode/skills/code-documentation/examples/javascript_typescript.md +28 -0
- package/.opencode/skills/code-documentation/examples/python.md +57 -0
- package/.opencode/skills/code-review/SKILL.md +43 -0
- package/.opencode/skills/commit-message/SKILL.md +79 -0
- package/.opencode/skills/cpp-best-practices/SKILL.md +234 -0
- package/.opencode/skills/cpp-best-practices/examples/modern-idioms.md +189 -0
- package/.opencode/skills/cpp-best-practices/examples/naming-and-organization.md +102 -0
- package/.opencode/skills/cpp-concurrency-safety/SKILL.md +60 -0
- package/.opencode/skills/cpp-concurrency-safety/examples/concurrency.md +73 -0
- package/.opencode/skills/cpp-const-correctness/SKILL.md +63 -0
- package/.opencode/skills/cpp-const-correctness/examples/const_correctness.md +54 -0
- package/.opencode/skills/cpp-memory-handling/SKILL.md +42 -0
- package/.opencode/skills/cpp-memory-handling/examples/modern-cpp.md +49 -0
- package/.opencode/skills/cpp-memory-handling/examples/smart-pointers.md +46 -0
- package/.opencode/skills/cpp-modern-composition/SKILL.md +64 -0
- package/.opencode/skills/cpp-modern-composition/examples/composition.md +51 -0
- package/.opencode/skills/cpp-robust-interfaces/SKILL.md +55 -0
- package/.opencode/skills/cpp-robust-interfaces/examples/interfaces.md +56 -0
- package/.opencode/skills/create-hardened-docker-skill/SKILL.md +637 -0
- package/.opencode/skills/create-hardened-docker-skill/scripts/create-all.sh +489 -0
- package/.opencode/skills/csharp-best-practices/SKILL.md +278 -0
- package/.opencode/skills/docker-hardening-verification/SKILL.md +28 -0
- package/.opencode/skills/docker-hardening-verification/scripts/verify-hardening.sh +39 -0
- package/.opencode/skills/docker-image-signing/SKILL.md +28 -0
- package/.opencode/skills/docker-image-signing/scripts/sign-image.sh +33 -0
- package/.opencode/skills/document-revision-history/SKILL.md +104 -0
- package/.opencode/skills/git-workflow-skill/SKILL.md +194 -0
- package/.opencode/skills/git-workflow-skill/hooks/commit-msg +61 -0
- package/.opencode/skills/git-workflow-skill/hooks/pre-commit +38 -0
- package/.opencode/skills/git-workflow-skill/hooks/prepare-commit-msg +56 -0
- package/.opencode/skills/git-workflow-skill/scripts/finish-feature.sh +192 -0
- package/.opencode/skills/git-workflow-skill/scripts/install-hooks.sh +55 -0
- package/.opencode/skills/git-workflow-skill/scripts/start-feature.sh +110 -0
- package/.opencode/skills/git-workflow-skill/scripts/validate-workflow.sh +229 -0
- package/.opencode/skills/js-ts-dependency-mgmt/SKILL.md +49 -0
- package/.opencode/skills/js-ts-dependency-mgmt/examples/dependency_mgmt.md +60 -0
- package/.opencode/skills/js-ts-security-skill/SKILL.md +64 -0
- package/.opencode/skills/js-ts-security-skill/scripts/verify-security.sh +136 -0
- package/.opencode/skills/logging-best-practices/SKILL.md +50 -0
- package/.opencode/skills/logging-best-practices/examples/cpp.md +36 -0
- package/.opencode/skills/logging-best-practices/examples/csharp.md +49 -0
- package/.opencode/skills/logging-best-practices/examples/javascript.md +77 -0
- package/.opencode/skills/logging-best-practices/examples/python.md +57 -0
- package/.opencode/skills/logging-best-practices/references/logging-standards.md +29 -0
- package/.opencode/skills/open-presentation/SKILL.md +35 -0
- package/.opencode/skills/opentelemetry-best-practices/SKILL.md +34 -0
- package/.opencode/skills/opentelemetry-best-practices/examples/go.md +32 -0
- package/.opencode/skills/opentelemetry-best-practices/examples/javascript.md +58 -0
- package/.opencode/skills/opentelemetry-best-practices/examples/python.md +37 -0
- package/.opencode/skills/opentelemetry-best-practices/references/otel-standards.md +37 -0
- package/.opencode/skills/python-best-practices/SKILL.md +385 -0
- package/.opencode/skills/python-dependency-mgmt/SKILL.md +42 -0
- package/.opencode/skills/python-dependency-mgmt/examples/dependency_mgmt.md +67 -0
- package/.opencode/skills/python-security-skill/SKILL.md +56 -0
- package/.opencode/skills/python-security-skill/examples/security.md +56 -0
- package/.opencode/skills/self-signed-cert/SKILL.md +42 -0
- package/.opencode/skills/self-signed-cert/scripts/generate-cert.ps1 +45 -0
- package/.opencode/skills/self-signed-cert/scripts/generate-cert.sh +43 -0
- package/.opencode/skills/skill-creator/SKILL.md +196 -0
- package/.opencode/skills/skill-creator/references/output-patterns.md +82 -0
- package/.opencode/skills/skill-creator/references/workflows.md +28 -0
- package/.opencode/skills/skill-creator/scripts/init_skill.py +208 -0
- package/.opencode/skills/skill-creator/scripts/package_skill.py +99 -0
- package/.opencode/skills/skill-creator/scripts/quick_validate.py +113 -0
- package/.opencode/skills/story-status-lookup/SKILL.md +78 -0
- package/.opencode/skills/test-accompanied-development/SKILL.md +50 -0
- package/.opencode/skills/test-generator/SKILL.md +65 -0
- package/.opencode/skills/vercel-react-best-practices/SKILL.md +109 -0
- package/.opencode/skills/verify-hardened-docker-skill/SKILL.md +442 -0
- package/.opencode/skills/verify-hardened-docker-skill/scripts/verify-docker-hardening.sh +439 -0
- package/AiAudit.md +5 -0
- package/QUICK_START.md +11 -5
- package/README.md +52 -1
- package/bin/cli.js +31 -4
- package/docs/BMAD_AI_Development_Training.pptx +0 -0
- package/docs/technical-notes/context-persistence-research.md +434 -0
- package/docs/technical-notes/enforcement-hooks-research.md +415 -0
- package/lib/agents.js +34 -0
- package/lib/bmad-extension/agents/bmm-architect.customize.yaml +5 -0
- package/lib/bmad-extension/agents/bmm-bmad-master.customize.yaml +5 -0
- package/lib/bmad-extension/agents/bmm-cyber.customize.yaml +30 -0
- package/lib/bmad-extension/agents/bmm-dev.customize.yaml +5 -0
- package/lib/bmad-extension/agents/bmm-devops.customize.yaml +30 -0
- package/lib/bmad-extension/agents/bmm-mil498.customize.yaml +42 -0
- package/lib/bmad-extension/agents/bmm-pm.customize.yaml +5 -0
- package/lib/bmad-extension/agents/bmm-qa.customize.yaml +5 -0
- package/lib/bmad-extension/agents/bmm-sm.customize.yaml +5 -0
- package/lib/bmad-extension/agents/bmm-sre.customize.yaml +30 -0
- package/lib/bmad-extension/agents/bmm-tech-writer.customize.yaml +5 -0
- package/lib/bmad-extension/agents/bmm-ux-designer.customize.yaml +5 -0
- package/lib/bmad-extension/module-help.csv +7 -0
- package/lib/bmad-extension/module.yaml +3 -0
- package/lib/bmad-extension/workflows/add-sprint/workflow.md +112 -0
- package/lib/bmad-extension/workflows/add-to-sprint/workflow.md +206 -0
- package/lib/bmad-extension/workflows/create-bug-story/workflow.md +186 -0
- package/lib/bmad-extension/workflows/modify-sprint/workflow.md +250 -0
- package/lib/bmad-extension/workflows/project-context-expansion/workflow.md +229 -0
- package/lib/bmad-extension/workflows/sprint-status-view/workflow.md +193 -0
- package/lib/bmad.js +168 -36
- package/lib/hooks/claude-code/verify-manifest.js +56 -0
- package/lib/installer.js +282 -1
- package/lib/methodology/BMAD_AI_Development_Training.pptx +0 -0
- package/lib/methodology/version.json +7 -0
- package/lib/skill-authoring.js +732 -0
- package/lib/templates/project-context.template.md +47 -0
- package/opencode.json +8 -0
- package/package.json +2 -2
- package/skills/auto-bug-detection/SKILL.md +165 -0
- package/skills/auto-bug-detection/skill.json +8 -0
- package/skills/code-review/SKILL.md +40 -0
- package/skills/cpp-best-practices/SKILL.md +230 -0
- package/skills/cpp-best-practices/examples/modern-idioms.md +189 -0
- package/skills/cpp-best-practices/examples/naming-and-organization.md +102 -0
- package/skills/cpp-best-practices/skill.json +25 -0
- package/skills/csharp-best-practices/SKILL.md +274 -0
- package/skills/csharp-best-practices/skill.json +23 -0
- package/skills/git-workflow-skill/skill.json +1 -1
- package/skills/open-presentation/SKILL.md +31 -0
- package/skills/open-presentation/skill.json +11 -0
- package/skills/python-best-practices/SKILL.md +381 -0
- package/skills/python-best-practices/skill.json +26 -0
- package/skills/story-status-lookup/SKILL.md +74 -0
- package/skills/story-status-lookup/skill.json +8 -0
- package/test/agent-injection-strategy.test.js +13 -7
- package/test/bmad-extension.test.js +237 -0
- package/test/bmad-output-policy.test.js +119 -0
- package/test/build-bmad-args.test.js +361 -0
- package/test/create-agent.test.js +232 -0
- package/test/enforcement-hooks.test.js +324 -0
- package/test/generate-project-context.test.js +337 -0
- package/test/integration-verification.test.js +402 -0
- package/test/opencode-agent.test.js +150 -0
- package/test/opencode-json-error.test.js +260 -0
- package/test/opencode-json-injection.test.js +256 -0
- package/test/opencode-json-merge.test.js +299 -0
- package/test/skill-authoring.test.js +272 -0
- package/test/skill-customize-agent.test.js +253 -0
- package/test/skill-mandatory.test.js +235 -0
- package/test/skill-validation.test.js +378 -0
- package/test/yes-flag.test.js +1 -1
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
# Context Persistence Research — Technical Note
|
|
2
|
+
|
|
3
|
+
**Story:** 8.6 — Research Context Persistence Strategies
|
|
4
|
+
**Date:** 2026-03-17
|
|
5
|
+
**Status:** Complete
|
|
6
|
+
|
|
7
|
+
## Executive Summary
|
|
8
|
+
|
|
9
|
+
This technical note researches how LLM context compression affects skill directive retention, evaluates the BMAD sidecar memory system as a persistence mechanism, and analyzes re-injection strategies to ensure skills survive long sessions.
|
|
10
|
+
|
|
11
|
+
**Key Finding:** Context loss is a real but manageable risk. The current multi-layer enforcement architecture (Stories 8.1-8.5) already provides strong resilience. The most practical persistence mechanism is the **SessionStart hook re-injection** pattern (already prototyped in Story 8.5), which fires on context compaction events. BMAD sidecar memory is not designed for skill state persistence and should not be repurposed for it.
|
|
12
|
+
|
|
13
|
+
**Recommendation:** **Defer** implementation of additional persistence mechanisms. The existing three-layer enforcement (instruction injection + critical_actions + SessionStart hook) is sufficient. Revisit when agents expose explicit context-loss callbacks or when measurable skill-drift is reported in production.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 1. Problem Statement
|
|
18
|
+
|
|
19
|
+
When users have long sessions with AI coding agents, the conversation context grows beyond the model's context window. Agents handle this through various compression strategies — summarizing earlier conversation, dropping older messages, or compacting the transcript. During compression, injected skill directives (the MA-AGENTS planning instruction block) risk being lost or weakened, potentially causing the agent to stop loading skills mid-session.
|
|
20
|
+
|
|
21
|
+
### What Must Persist
|
|
22
|
+
|
|
23
|
+
The critical content that must survive compression:
|
|
24
|
+
|
|
25
|
+
1. **Planning Instruction block** — The `<!-- MA-AGENTS-START -->` ... `<!-- MA-AGENTS-END -->` block injected at the top of agent instruction files (e.g., `.claude/CLAUDE.md`). Contains:
|
|
26
|
+
- Instruction to read `MANIFEST.yaml`
|
|
27
|
+
- Instruction to load `always_load: true` skills
|
|
28
|
+
- Instruction to select relevant skills per task
|
|
29
|
+
2. **BMAD critical_actions** — The 3-step skill loading sequence in `.customize.yaml` for all 11 BMAD agents
|
|
30
|
+
3. **Loaded skill content** — The actual skill file contents read into context during the session
|
|
31
|
+
|
|
32
|
+
### Risk Profile
|
|
33
|
+
|
|
34
|
+
| Content | Risk Level | Rationale |
|
|
35
|
+
|---------|-----------|-----------|
|
|
36
|
+
| System prompt / instruction files | **Low** | Re-read on every turn by most agents; survives compression |
|
|
37
|
+
| CLAUDE.md / instruction file content | **Low** | Treated as system-level by Claude Code; re-loaded on compaction |
|
|
38
|
+
| Planning Instruction block (in instruction file) | **Low** | Lives in instruction file, re-read with it |
|
|
39
|
+
| Skill file contents (read into conversation) | **High** | Conversation-level content; first to be compressed/dropped |
|
|
40
|
+
| BMAD critical_actions | **Low** | Part of agent activation; re-executed on agent load |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 2. Context Compression Behavior by Agent
|
|
45
|
+
|
|
46
|
+
### 2.1 Claude Code (Anthropic)
|
|
47
|
+
|
|
48
|
+
**Compression mechanism:** Automatic context compaction when conversation approaches context window limits.
|
|
49
|
+
|
|
50
|
+
**How it works:**
|
|
51
|
+
- The system prompt (including `CLAUDE.md` content) is **always retained** — it is re-loaded on every turn, not stored in the conversation transcript
|
|
52
|
+
- `CLAUDE.md` and other instruction files listed in project settings are read fresh on each interaction and placed in `<system-reminder>` tags
|
|
53
|
+
- When context is compacted, **earlier conversation messages** are summarized or dropped — but the system prompt persists in full
|
|
54
|
+
- The `SessionStart` hook fires on `compact` events (matcher: `"compact"`), providing a re-injection opportunity at compaction time
|
|
55
|
+
- Tools and their outputs in the conversation history are compressed, but the system prompt injections remain
|
|
56
|
+
|
|
57
|
+
**Key insight:** The MA-AGENTS planning instruction block lives in `CLAUDE.md`, which is a **system-level instruction file**. It is NOT part of the conversation history. Therefore, **it survives context compression automatically**. The risk is only to skill content that was read into the conversation via `Read` tool calls.
|
|
58
|
+
|
|
59
|
+
**Evidence:** Claude Code's `SessionStart` hook supports three matchers: `startup`, `resume`, and `compact`. The `compact` event specifically fires during context compaction, confirming that Anthropic designed the hook system with context-loss scenarios in mind.
|
|
60
|
+
|
|
61
|
+
### 2.2 Cursor (Anysphere)
|
|
62
|
+
|
|
63
|
+
**Compression mechanism:** Automatic context management with configurable long-context mode.
|
|
64
|
+
|
|
65
|
+
**How it works:**
|
|
66
|
+
- `.cursor/cursor.md` (and `.cursorrules`) are loaded as system-level context on every interaction
|
|
67
|
+
- Cursor v1.7+ supports "Long Context Mode" which extends the effective window before compression kicks in
|
|
68
|
+
- When the context window fills, Cursor summarizes earlier conversation turns
|
|
69
|
+
- System-level instruction files survive compression — they are re-read, not stored in conversation
|
|
70
|
+
- Cursor hooks (beta) can fire on agent execution stages but do not currently have a `compact` event
|
|
71
|
+
|
|
72
|
+
**Key insight:** Similar to Claude Code, the instruction file is system-level. Skill content read during conversation is at risk, but the planning instruction block persists.
|
|
73
|
+
|
|
74
|
+
### 2.3 GitHub Copilot (GitHub/Microsoft)
|
|
75
|
+
|
|
76
|
+
**Compression mechanism:** Reference-based retrieval with context window management.
|
|
77
|
+
|
|
78
|
+
**How it works:**
|
|
79
|
+
- `.github/copilot/copilot.md` is loaded as system context
|
|
80
|
+
- Copilot uses a retrieval-based approach — relevant code/docs are pulled in per-turn rather than accumulating in conversation
|
|
81
|
+
- For long conversations in agent mode, earlier turns are summarized
|
|
82
|
+
- Instruction files are treated as project-level directives that persist across turns
|
|
83
|
+
- `sessionStart` hook available (preview) for re-injection
|
|
84
|
+
|
|
85
|
+
**Key insight:** Copilot's retrieval-based model naturally handles context limits better than accumulative approaches. The planning instruction persists as a project-level directive.
|
|
86
|
+
|
|
87
|
+
### 2.4 Gemini CLI / Gemini Code Assist (Google)
|
|
88
|
+
|
|
89
|
+
**Compression mechanism:** Context window management with `PreCompress` hook event.
|
|
90
|
+
|
|
91
|
+
**How it works:**
|
|
92
|
+
- `.gemini/gemini.md` is loaded as system context
|
|
93
|
+
- Gemini CLI v0.26.0+ exposes a `PreCompress` hook event — this fires BEFORE context compression occurs
|
|
94
|
+
- This is the most explicit context-loss API of any agent: you can run logic just before compression happens
|
|
95
|
+
- System-level instruction files survive compression
|
|
96
|
+
|
|
97
|
+
**Key insight:** Gemini CLI's `PreCompress` hook is architecturally ideal for re-injection. It fires at exactly the right moment. However, the `gemini` agent in our registry targets the IDE extension (Gemini Code Assist), not the CLI, so this hook may not be available to our primary use case.
|
|
98
|
+
|
|
99
|
+
### 2.5 Cline (Saoud Rizwan)
|
|
100
|
+
|
|
101
|
+
**Compression mechanism:** Context truncation with `.clinerules` persistence.
|
|
102
|
+
|
|
103
|
+
**How it works:**
|
|
104
|
+
- `.clinerules` and `.cline/clinerules.md` are injected into the system prompt on every turn
|
|
105
|
+
- Cline manages context by truncating older conversation turns when approaching limits
|
|
106
|
+
- No explicit compaction event or hook exists
|
|
107
|
+
- MCP servers provide a channel for persistent tool state, but this requires server-side infrastructure
|
|
108
|
+
|
|
109
|
+
**Key insight:** Instruction files persist. No compaction hook exists for re-injection.
|
|
110
|
+
|
|
111
|
+
### 2.6 Kilocode (Kilo AI)
|
|
112
|
+
|
|
113
|
+
**Compression mechanism:** Context management via Mode system.
|
|
114
|
+
|
|
115
|
+
**How it works:**
|
|
116
|
+
- `.kilocode/kilocode.md` loaded as workspace instructions
|
|
117
|
+
- Kilocode's Mode system can reset context per-task (similar to starting a new conversation)
|
|
118
|
+
- No context compaction hooks or events documented
|
|
119
|
+
- AGENTS.md files are treated as persistent workspace instructions
|
|
120
|
+
|
|
121
|
+
**Key insight:** Instruction files persist. The Mode system may actually help by providing natural context boundaries.
|
|
122
|
+
|
|
123
|
+
### 2.7 Antigravity (Google DeepMind)
|
|
124
|
+
|
|
125
|
+
**Research status:** Limited — ToS restricts third-party agent integration (see Story 8.5). No public documentation on context compression behavior.
|
|
126
|
+
|
|
127
|
+
### 2.8 Summary: System vs. Conversation Content
|
|
128
|
+
|
|
129
|
+
| Content Type | Behavior During Compression | Risk |
|
|
130
|
+
|-------------|---------------------------|------|
|
|
131
|
+
| **System prompt** (instruction files) | **Re-read every turn** — survives compression | None |
|
|
132
|
+
| **Early conversation messages** | Summarized or dropped | High |
|
|
133
|
+
| **Tool call results** (file reads) | Summarized or dropped | High |
|
|
134
|
+
| **Recent conversation messages** | Retained (recency bias) | Low |
|
|
135
|
+
| **Hook-injected context** | Injected fresh on compaction | None (if hook fires) |
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 3. BMAD Sidecar Memory Analysis
|
|
140
|
+
|
|
141
|
+
### 3.1 How Sidecar Memory Works
|
|
142
|
+
|
|
143
|
+
BMAD's sidecar memory system is a **file-based persistence mechanism** for agents that need state across sessions.
|
|
144
|
+
|
|
145
|
+
**Configuration:**
|
|
146
|
+
- `hasSidecar: true` in agent `.agent.yaml` metadata declares an agent uses sidecar memory
|
|
147
|
+
- Memory files are stored at `{project-root}/_bmad/_memory/{skillName}-sidecar/`
|
|
148
|
+
- Agents load sidecar files via `critical_actions` at activation time
|
|
149
|
+
|
|
150
|
+
**File structure:**
|
|
151
|
+
```
|
|
152
|
+
_bmad/_memory/{skillName}-sidecar/
|
|
153
|
+
index.md # Primary context — loaded on every activation
|
|
154
|
+
access-boundaries.md # Read/write permissions — loaded on every activation
|
|
155
|
+
patterns.md # Learned preferences — loaded on demand
|
|
156
|
+
chronology.md # Timeline/history — loaded on demand
|
|
157
|
+
autonomous-log.md # Headless execution log
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Current usage:** Only one agent currently uses sidecar memory — Sophia (Storyteller) in the CIS module. She stores:
|
|
161
|
+
- `story-preferences.md` — User's storytelling style preferences
|
|
162
|
+
- `stories-told.md` — History of stories created
|
|
163
|
+
|
|
164
|
+
**Loading mechanism:**
|
|
165
|
+
```yaml
|
|
166
|
+
critical_actions:
|
|
167
|
+
- "Load COMPLETE file {project-root}/_bmad/_memory/storyteller-sidecar/story-preferences.md..."
|
|
168
|
+
- "Load COMPLETE file {project-root}/_bmad/_memory/storyteller-sidecar/stories-told.md..."
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 3.2 Can Sidecar Memory Store Skill State?
|
|
172
|
+
|
|
173
|
+
**Technical feasibility:** Yes, but it would be a misuse of the system.
|
|
174
|
+
|
|
175
|
+
**Analysis:**
|
|
176
|
+
- Sidecar memory is designed for **agent-specific persistent knowledge** (user preferences, history, learned patterns)
|
|
177
|
+
- Storing "skills loaded in this session" is **transient session state**, not persistent knowledge
|
|
178
|
+
- The memory system has no concept of "session" vs "persistent" — everything written persists until pruned
|
|
179
|
+
- Writing skill state to sidecar would create stale data across sessions (a skill loaded in session 1 may not be relevant in session 2)
|
|
180
|
+
- Each write to sidecar memory consumes tokens for both the write and subsequent reads
|
|
181
|
+
|
|
182
|
+
**Verdict:** Sidecar memory is architecturally wrong for skill state. It solves a different problem (cross-session knowledge) than what we need (within-session persistence).
|
|
183
|
+
|
|
184
|
+
### 3.3 Can Sidecar Memory Trigger Skill Re-Reads?
|
|
185
|
+
|
|
186
|
+
**Analysis:**
|
|
187
|
+
- Sidecar files are loaded at agent **activation** time (session start), not during context compression
|
|
188
|
+
- There is no mechanism for sidecar files to be re-read when context is compressed
|
|
189
|
+
- BMAD does not have a "context compaction" event or hook in its lifecycle
|
|
190
|
+
- Critical actions fire once at activation — they don't re-fire mid-session
|
|
191
|
+
|
|
192
|
+
**Verdict:** No. Sidecar memory cannot trigger mid-session re-reads. It operates at session boundaries, not context compression boundaries.
|
|
193
|
+
|
|
194
|
+
### 3.4 Sidecar Memory Limitations
|
|
195
|
+
|
|
196
|
+
| Limitation | Impact on Skill Persistence |
|
|
197
|
+
|-----------|---------------------------|
|
|
198
|
+
| Fires only at activation, not on compression | Cannot re-inject skills mid-session |
|
|
199
|
+
| Designed for cross-session state, not transient | Wrong abstraction level |
|
|
200
|
+
| Only available to BMAD agents | IDE agents (Claude Code, Cursor, etc.) have no sidecar |
|
|
201
|
+
| Adds token overhead per activation | Wasted if storing skills-loaded state |
|
|
202
|
+
| No TTL or session-scoping | Stale state accumulates |
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## 4. Re-Injection Strategies
|
|
207
|
+
|
|
208
|
+
### 4.1 MANIFEST Re-Read Pattern
|
|
209
|
+
|
|
210
|
+
**Concept:** Instruct agents to periodically re-read MANIFEST.yaml during long sessions.
|
|
211
|
+
|
|
212
|
+
**Feasibility:** Partially feasible via self-reinforcing directives.
|
|
213
|
+
|
|
214
|
+
**How it would work:**
|
|
215
|
+
- The planning instruction block in `CLAUDE.md` already says "Before starting any task, read the skill manifest"
|
|
216
|
+
- Since `CLAUDE.md` is re-read on every turn (system-level), this instruction persists
|
|
217
|
+
- The instruction itself is the re-read trigger — every new user task should cause the agent to re-consult the manifest
|
|
218
|
+
|
|
219
|
+
**Effectiveness:**
|
|
220
|
+
- Works well for **task boundaries** (user starts a new task = re-reads manifest)
|
|
221
|
+
- Does NOT help for **long single tasks** where skills are read once and then context is compressed mid-task
|
|
222
|
+
- Relies on agent compliance with the "before starting any task" instruction
|
|
223
|
+
|
|
224
|
+
**Verdict:** Already implemented by design. The planning instruction IS the re-read trigger. No additional work needed.
|
|
225
|
+
|
|
226
|
+
### 4.2 Hook-Based Re-Injection
|
|
227
|
+
|
|
228
|
+
**Concept:** Use agent hooks (Story 8.5) to re-inject skill awareness when context is compressed.
|
|
229
|
+
|
|
230
|
+
**Feasibility:** High — already prototyped for Claude Code.
|
|
231
|
+
|
|
232
|
+
**Current state:**
|
|
233
|
+
- Claude Code `SessionStart` hook (`lib/hooks/claude-code/verify-manifest.js`) fires on `startup`, `resume`, and `compact` events
|
|
234
|
+
- On `compact` (context compression), the hook injects: "SKILL ENFORCEMENT ACTIVE: This project uses ma-agents skills. Read the skill manifest..."
|
|
235
|
+
- This gives Claude a fresh reminder to re-read MANIFEST.yaml after every context compaction
|
|
236
|
+
|
|
237
|
+
**Agent coverage:**
|
|
238
|
+
|
|
239
|
+
| Agent | Hook Event for Compression | Feasibility |
|
|
240
|
+
|-------|---------------------------|-------------|
|
|
241
|
+
| Claude Code | `SessionStart` with `compact` matcher | **Implemented** (prototype) |
|
|
242
|
+
| Gemini CLI | `PreCompress` | High — fires before compression |
|
|
243
|
+
| GitHub Copilot | `sessionStart` | Moderate — unclear if fires on compaction |
|
|
244
|
+
| Cursor | Agent execution hooks (beta) | Low — no explicit compaction event |
|
|
245
|
+
| Cline | None | Not feasible |
|
|
246
|
+
| Kilocode | None | Not feasible |
|
|
247
|
+
|
|
248
|
+
**Verdict:** Most effective strategy for Claude Code (already done). Gemini CLI's `PreCompress` is architecturally superior but targets CLI, not IDE. Other agents lack compaction-specific hooks.
|
|
249
|
+
|
|
250
|
+
### 4.3 Self-Reinforcing Directives (always_load Skills)
|
|
251
|
+
|
|
252
|
+
**Concept:** Skills with `always_load: true` could include self-reinforcing text like "If you notice you've forgotten these rules, re-read this file."
|
|
253
|
+
|
|
254
|
+
**Feasibility:** Low effectiveness.
|
|
255
|
+
|
|
256
|
+
**Analysis:**
|
|
257
|
+
- Self-reinforcing directives are a form of **prompt engineering** — they rely on the LLM noticing it has forgotten something
|
|
258
|
+
- LLMs do not have reliable self-awareness of context loss — by definition, if content was compressed away, the model doesn't know it existed
|
|
259
|
+
- The directive itself would be in the compressed content, creating a chicken-and-egg problem
|
|
260
|
+
- Some models may respond to "check if you remember X" patterns, but this is unreliable and model-dependent
|
|
261
|
+
|
|
262
|
+
**Verdict:** Not recommended as a primary strategy. Self-reinforcing directives in skills may provide marginal benefit but cannot be relied upon.
|
|
263
|
+
|
|
264
|
+
### 4.4 Critical_Actions Reinforcement (BMAD Agents)
|
|
265
|
+
|
|
266
|
+
**Concept:** Research whether BMAD agents re-evaluate critical_actions during context compression.
|
|
267
|
+
|
|
268
|
+
**Finding:** No. Critical_actions fire once during agent activation. BMAD's runtime does not have context compression awareness.
|
|
269
|
+
|
|
270
|
+
**Analysis:**
|
|
271
|
+
- Critical_actions are defined in `.customize.yaml` and processed during the agent `<activation>` sequence
|
|
272
|
+
- The activation sequence runs when a user invokes a BMAD agent (e.g., `/bmad-agent-bmm-dev`)
|
|
273
|
+
- There is no BMAD lifecycle event for "context was compressed" — BMAD is not context-aware
|
|
274
|
+
- However, BMAD agents run inside IDE agents (primarily Claude Code), so the **IDE agent's compression handling** applies
|
|
275
|
+
- When Claude Code compacts context during a BMAD agent session, the `SessionStart` hook fires, providing the re-injection
|
|
276
|
+
|
|
277
|
+
**Verdict:** BMAD's own critical_actions don't re-fire, but this is acceptable because the IDE agent's hooks handle re-injection at the hosting layer.
|
|
278
|
+
|
|
279
|
+
### 4.5 Session Bookmarks
|
|
280
|
+
|
|
281
|
+
**Concept:** Some agents may support "bookmarking" key instructions to survive compression.
|
|
282
|
+
|
|
283
|
+
**Research findings:**
|
|
284
|
+
- **No agent currently supports explicit bookmarks.** This is a hypothetical feature.
|
|
285
|
+
- Claude Code's system prompt mechanism is the closest equivalent — instruction files are effectively "bookmarked" by being re-read every turn
|
|
286
|
+
- Gemini CLI's `PreCompress` hook allows injecting content just before compression — the closest to a "save before compress" pattern
|
|
287
|
+
- OpenAI's GPT-4 Turbo introduced "persistent memories" (user-level, not project-level), but this is not applicable to coding agents
|
|
288
|
+
- No standard emerged for per-project "pinned context" across agents
|
|
289
|
+
|
|
290
|
+
**Verdict:** Not available. The system-prompt mechanism (instruction files re-read every turn) is the de facto bookmark system.
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## 5. Comparison Matrix
|
|
295
|
+
|
|
296
|
+
| Strategy | Feasibility | Complexity | Agent Coverage | Reliability | Status |
|
|
297
|
+
|----------|------------|------------|----------------|-------------|--------|
|
|
298
|
+
| **Instruction file persistence** (system-level, re-read every turn) | High | None (existing) | All 7 IDE agents | Very High | **Already working** (Stories 8.1-8.2) |
|
|
299
|
+
| **BMAD critical_actions** (activation-time enforcement) | High | None (existing) | All 11 BMAD agents | High | **Already working** (Story 8.3) |
|
|
300
|
+
| **SessionStart hook re-injection** (fires on compact) | High | Low (implemented) | Claude Code only | High | **Prototype exists** (Story 8.5) |
|
|
301
|
+
| **Gemini PreCompress hook** | High | Low | Gemini CLI only | High | Deferred (CLI vs IDE) |
|
|
302
|
+
| **GitHub Copilot sessionStart** | Moderate | Low | Copilot only | Unknown | Deferred (preview) |
|
|
303
|
+
| **MANIFEST re-read instruction** (self-triggering) | High | None (existing) | All IDE agents | Moderate | **Already working** (by design) |
|
|
304
|
+
| **Self-reinforcing skill directives** | Low | Low | All agents | Low | Not recommended |
|
|
305
|
+
| **BMAD sidecar memory** | Technically feasible | Medium | BMAD agents only | Low | **Not recommended** (wrong abstraction) |
|
|
306
|
+
| **Session bookmarks** | N/A | N/A | None | N/A | Not available |
|
|
307
|
+
|
|
308
|
+
### Architecture Impact Assessment
|
|
309
|
+
|
|
310
|
+
| Strategy | Requires Code Changes | Requires MANIFEST.yaml Schema Changes | Requires Skill File Format Changes |
|
|
311
|
+
|----------|----------------------|--------------------------------------|-----------------------------------|
|
|
312
|
+
| Instruction file persistence | No | No | No |
|
|
313
|
+
| BMAD critical_actions | No | No | No |
|
|
314
|
+
| SessionStart hook | No (already implemented) | No | No |
|
|
315
|
+
| Gemini PreCompress hook | Yes (new hook script) | No | No |
|
|
316
|
+
| Copilot sessionStart hook | Yes (new hook script) | No | No |
|
|
317
|
+
| Self-reinforcing directives | No | No | Yes (add directives to skill files) |
|
|
318
|
+
| Sidecar memory for skills | Yes (new sidecar logic) | No | No |
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## 6. Recommendation
|
|
323
|
+
|
|
324
|
+
### Decision: **DEFER** Additional Persistence Mechanisms
|
|
325
|
+
|
|
326
|
+
**Rationale:**
|
|
327
|
+
|
|
328
|
+
The current three-layer enforcement architecture already provides strong resilience against context loss:
|
|
329
|
+
|
|
330
|
+
```
|
|
331
|
+
Layer 1: Instruction Injection (Stories 8.1-8.2)
|
|
332
|
+
- MA-AGENTS block at TOP of instruction files
|
|
333
|
+
- System-level content — re-read EVERY TURN
|
|
334
|
+
- Survives all context compression automatically
|
|
335
|
+
- Coverage: All 7 IDE agents
|
|
336
|
+
|
|
337
|
+
Layer 2: BMAD Critical Actions (Story 8.3)
|
|
338
|
+
- critical_actions in .customize.yaml
|
|
339
|
+
- Fires at agent activation
|
|
340
|
+
- Coverage: All 11 BMAD agents
|
|
341
|
+
|
|
342
|
+
Layer 3: SessionStart Hook (Story 8.5)
|
|
343
|
+
- Fires on startup, resume, AND compact events
|
|
344
|
+
- Re-injects skill awareness after context compression
|
|
345
|
+
- Coverage: Claude Code (prototype implemented)
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
**Why defer:**
|
|
349
|
+
|
|
350
|
+
1. **The highest-risk content (planning instruction) is already safe.** It lives in system-level instruction files that are re-read every turn. Context compression cannot touch it.
|
|
351
|
+
|
|
352
|
+
2. **The SessionStart hook already handles the compact event.** The one scenario where a reminder is needed after compression is already covered for Claude Code.
|
|
353
|
+
|
|
354
|
+
3. **Skill file content loss is acceptable.** If a skill's actual content is compressed away mid-session, the planning instruction persists and will trigger the agent to re-read the MANIFEST on the next task. The skill content will be re-loaded from disk.
|
|
355
|
+
|
|
356
|
+
4. **No production reports of skill drift.** There are no reported incidents of skills being forgotten during sessions. Implementing additional persistence would be premature optimization.
|
|
357
|
+
|
|
358
|
+
5. **BMAD sidecar is the wrong tool.** Repurposing cross-session memory for within-session state would add complexity without reliability.
|
|
359
|
+
|
|
360
|
+
### Conditions That Would Trigger Revisiting
|
|
361
|
+
|
|
362
|
+
Revisit this decision if any of the following occur:
|
|
363
|
+
|
|
364
|
+
1. **User reports of skill drift** — Documented cases where agents stop following skill directives mid-session
|
|
365
|
+
2. **Agent-exposed context-loss callbacks** — When agents (beyond Claude Code) provide explicit events for context compaction
|
|
366
|
+
3. **New agent with no system-prompt persistence** — If a future agent doesn't re-read instruction files every turn
|
|
367
|
+
4. **Quantitative context-loss metrics** — If agents expose APIs to measure how much context was dropped during compaction
|
|
368
|
+
5. **Multi-agent orchestration** — If skills need to persist across agent handoffs within a session (not currently a use case)
|
|
369
|
+
|
|
370
|
+
### If Implementation Were Needed
|
|
371
|
+
|
|
372
|
+
If the decision were to implement now, the recommended approach would be:
|
|
373
|
+
|
|
374
|
+
1. **Extend `SessionStart` hook** to support additional agents as they release compaction events (Gemini `PreCompress`, Copilot `sessionStart`)
|
|
375
|
+
2. **Scope:** One new story per agent hook (similar to Story 8.5's Claude Code hook)
|
|
376
|
+
3. **Do NOT use BMAD sidecar** — it solves a different problem
|
|
377
|
+
4. **Do NOT modify skill file format** — self-reinforcing directives are unreliable
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
## Appendix A: How the MA-AGENTS Block Survives Compression
|
|
382
|
+
|
|
383
|
+
Tracing the lifecycle of the planning instruction through a Claude Code session:
|
|
384
|
+
|
|
385
|
+
```
|
|
386
|
+
1. Install: npx ma-agents install <skill>
|
|
387
|
+
└── installer.js injects MA-AGENTS block into .claude/CLAUDE.md (top position)
|
|
388
|
+
|
|
389
|
+
2. Session Start: Claude Code launches
|
|
390
|
+
├── .claude/CLAUDE.md loaded as system-level instruction (re-read every turn)
|
|
391
|
+
├── SessionStart hook fires → injects "SKILL ENFORCEMENT ACTIVE" reminder
|
|
392
|
+
└── Agent reads MANIFEST.yaml per planning instruction
|
|
393
|
+
|
|
394
|
+
3. Mid-Session: User works, conversation grows
|
|
395
|
+
├── CLAUDE.md remains in system prompt (always present)
|
|
396
|
+
├── Skill content loaded via Read tool calls → enters conversation history
|
|
397
|
+
└── Skills active and enforced
|
|
398
|
+
|
|
399
|
+
4. Context Compression: Window limit reached
|
|
400
|
+
├── Earlier conversation messages summarized/dropped
|
|
401
|
+
├── Skill content from Read calls may be summarized/lost
|
|
402
|
+
├── CLAUDE.md PERSISTS (system-level, re-read fresh)
|
|
403
|
+
├── SessionStart hook fires with "compact" matcher
|
|
404
|
+
│ └── Injects fresh "Read the skill manifest" reminder
|
|
405
|
+
└── Planning instruction survives → triggers re-read of MANIFEST on next task
|
|
406
|
+
|
|
407
|
+
5. Post-Compression: Session continues
|
|
408
|
+
├── CLAUDE.md still present with MA-AGENTS block
|
|
409
|
+
├── Agent re-reads MANIFEST.yaml per planning instruction
|
|
410
|
+
├── Skills re-loaded from disk (not from compressed context)
|
|
411
|
+
└── Full skill enforcement restored
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
## Appendix B: BMAD Agent Context During Compression
|
|
415
|
+
|
|
416
|
+
BMAD agents (pm, architect, dev, qa, etc.) always run hosted inside an IDE agent (typically Claude Code). The compression behavior is determined by the host:
|
|
417
|
+
|
|
418
|
+
```
|
|
419
|
+
Claude Code (host)
|
|
420
|
+
├── System prompt: CLAUDE.md with MA-AGENTS block (persists)
|
|
421
|
+
├── SessionStart hook: verify-manifest.js (fires on compact)
|
|
422
|
+
└── Conversation: BMAD agent activation, persona, workflow
|
|
423
|
+
├── critical_actions: skill loading (in early conversation — at risk)
|
|
424
|
+
├── Agent persona and menu (in early conversation — at risk)
|
|
425
|
+
└── Workflow execution (recent — likely retained)
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
When compression occurs during a BMAD agent session:
|
|
429
|
+
- The agent's **persona and activation** may be summarized, but the agent is already running — its behavior is established
|
|
430
|
+
- The **critical_actions** fired at activation — skills were already loaded
|
|
431
|
+
- The **CLAUDE.md planning instruction** persists (system-level) and will trigger re-reads on the next task
|
|
432
|
+
- The **SessionStart hook** fires and injects a fresh reminder
|
|
433
|
+
|
|
434
|
+
**Net effect:** BMAD agent sessions are resilient to compression because the enforcement layers operate at different points in the lifecycle (system prompt > activation > hook re-injection).
|