opencodekit 0.23.0 → 0.23.2

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.
Files changed (23) hide show
  1. package/dist/index.js +354 -825
  2. package/dist/template/.opencode/AGENTS.md +15 -0
  3. package/dist/template/.opencode/command/init.md +198 -34
  4. package/dist/template/.opencode/context/fallow.md +137 -0
  5. package/dist/template/.opencode/dcp-prompts/overrides/compress-range.md +89 -0
  6. package/dist/template/.opencode/opencode.json +110 -315
  7. package/dist/template/.opencode/plugin/README.md +10 -0
  8. package/dist/template/.opencode/plugin/memory/compile.ts +171 -186
  9. package/dist/template/.opencode/plugin/memory/index-generator.ts +118 -133
  10. package/dist/template/.opencode/plugin/memory/lint.ts +253 -275
  11. package/dist/template/.opencode/plugin/memory/tools.ts +224 -268
  12. package/dist/template/.opencode/plugin/memory/validate.ts +154 -164
  13. package/dist/template/.opencode/plugin/sdk/copilot/responses/tool/web-search-preview.ts +13 -30
  14. package/dist/template/.opencode/plugin/sdk/copilot/responses/tool/web-search-shared.ts +25 -0
  15. package/dist/template/.opencode/plugin/sdk/copilot/responses/tool/web-search.ts +17 -34
  16. package/dist/template/.opencode/plugin/session-summary.ts +542 -0
  17. package/dist/template/.opencode/plugin/srcwalk.ts +775 -661
  18. package/dist/template/.opencode/skill/condition-based-waiting/example.ts +15 -2
  19. package/dist/template/.opencode/skill/fallow/SKILL.md +409 -0
  20. package/dist/template/.opencode/skill/fallow/references/cli-reference.md +1905 -0
  21. package/dist/template/.opencode/skill/fallow/references/gotchas.md +644 -0
  22. package/dist/template/.opencode/skill/fallow/references/patterns.md +791 -0
  23. package/package.json +2 -2
@@ -85,6 +85,18 @@ Reject changes that worsen overall code health.
85
85
  - If verification fails twice on the same approach, stop and escalate.
86
86
  - **Auto-detect project toolchain** — look for `package.json`, `Cargo.toml`, `pyproject.toml`, `go.mod`, `Makefile`, etc.
87
87
 
88
+ ### Fallow Codebase Gate
89
+ Before committing or claiming completion, run the Fallow codebase gate to catch structural issues that linters and type checkers cannot see:
90
+
91
+ - Run **`npx fallow audit --format json --quiet`** and check the `verdict`. If `"fail"`, resolve all findings before proceeding.
92
+ - Run **`npx fallow`** for full codebase analysis (dead code, duplication, health) — this is the single-pass overview.
93
+ - Use **`npx fallow fix --dry-run`** to preview safe auto-fixes for dead code.
94
+ - Use **`npx fallow dead-code --trace FILE:EXPORT`** to investigate why a specific export is flagged before deleting it.
95
+
96
+ Fallow builds a complete module graph (Rust-native, sub-second). Its analysis is **deterministic** — no AI inside the analyzer. It finds unused code, circular dependencies, code duplication, complexity hotspots, and architecture boundary violations across the entire codebase.
97
+
98
+ See `.opencode/context/fallow.md` for the full command reference.
99
+
88
100
  ## Tool Discipline
89
101
  - Use tools whenever they materially improve correctness. Keep calling until the task is complete **and** verified.
90
102
  - If a tool returns empty, partial, or suspiciously narrow results, try 1-2 fallback strategies before reporting "no results found."
@@ -191,6 +203,9 @@ Prefer `edit` for modifications; reserve `write` for new files or deliberate ful
191
203
  - Keep context high-signal
192
204
  - Use DCP/VCC tools to compress completed phases and recover targeted history
193
205
  - After any context compaction, re-read: (1) this `AGENTS.md`, (2) the current task details, (3) active state
206
+ - **The `<session_summary>` block in the system prompt** is the artifact trail. It tracks files read/modified/created, decisions made, and next steps. Use it to orient after compression — do not re-read files listed there without checking if you already have the information.
207
+ - **Update the session summary** when you make a structural decision: the `observation(type:decision)` tool auto-populates the decisions section. For file operations (read/edit/write), tracking happens automatically via the session-summary plugin.
208
+ - **Anchored summarization**: when compressing a range, check the session summary first. Your compression should preserve and update the information there — don't drop file paths or decisions that are still relevant.
194
209
 
195
210
  ---
196
211
 
@@ -6,34 +6,47 @@ agent: build
6
6
 
7
7
  # Init: $ARGUMENTS
8
8
 
9
- Initialize project setup. Run once per project. Supports three modes via argument flags.
9
+ Initialize project setup. Run once per project.
10
10
 
11
11
  > **Next step for fresh projects:** `/plan` to create first implementation plan.
12
- > **Next step for brownfield:** `/review-codebase` for deep codebase analysis.
12
+ > **Next step for existing codebases:** `/review-codebase` for deep codebase analysis.
13
13
 
14
- ## Load Skills
14
+ ## Idempotency Rules
15
+
16
+ | File | Rule |
17
+ |---|---|
18
+ | `AGENTS.md` | Improve in-place — never overwrite blindly |
19
+ | `tech-stack.md` | Overwrite with detected values (auto-regenerated) |
20
+ | `roadmap.md` / `state.md` | Skip if exists, ask before overwrite |
21
+ | `user.md` | Skip if exists, ask before overwrite |
22
+ | `.opencode/opencode.json` `instructions[]` | Add to array — never remove existing entries |
23
+
24
+ ## Skills
15
25
 
16
26
  ```typescript
17
27
  skill({ name: "brainstorming" });
18
- skill({ name: "verification-before-completion" });
19
28
  ```
20
29
 
30
+ Load `verification-before-completion` inside Mode 1 only (after AGENTS.md creation).
31
+
21
32
  ## Parse Arguments
22
33
 
23
34
  | Argument | Default | Description |
24
35
  |---|---|---|
25
36
  | `--deep` | false | Comprehensive research for AGENTS.md (~100+ tool calls) |
26
- | `--context` | false | Init planning context (roadmap, state) |
27
- | `--user` | false | Init user profile |
37
+ | `--context` | false | Init planning context (roadmap.md, state.md) |
38
+ | `--user` | false | Init user profile (user.md) |
28
39
  | `--all` | false | Full init: AGENTS.md + context + user profile |
29
40
 
30
41
  **Mode rules:**
31
- - No flags (default): Core project setup — AGENTS.md + tech stack only
42
+ - No flags (default): Core project setup — AGENTS.md + tech-stack.md
32
43
  - `--context`: Planning context (roadmap.md, state.md)
33
44
  - `--user`: User profile (user.md)
34
45
  - `--all`: Everything
35
46
  - `--deep` applies to AGENTS.md generation only
36
47
 
48
+ **Brownfield auto-detection:** Existing codebase = any `src/`, `lib/`, or `app/` directory with `.ts`, `.js`, `.tsx`, `.jsx`, `.py`, `.go`, or `.rs` files. Affects Mode 2 discovery scope.
49
+
37
50
  ---
38
51
 
39
52
  ## Mode 1: Core Setup (Default)
@@ -47,14 +60,38 @@ Detect and validate:
47
60
  - Existing AI rules (`.cursor/rules/`, `.cursorrules`, `.github/copilot-instructions.md`)
48
61
  - Top-level directory structure
49
62
 
50
- With `--deep`: Also analyze git history, source patterns, subsystem candidates.
63
+ With `--deep`:
64
+ - Analyze git history (last 50 commits for patterns)
65
+ - Map source directory structure and subsystem candidates
66
+ - Identify common patterns (error handling, logging, data flow)
67
+ - Detect testing patterns and coverage gaps
51
68
 
52
69
  ### Phase 2: Preview Detection
53
70
 
54
- Show detected summary and ask for confirmation before writing.
71
+ Show detected summary and ask for confirmation before writing:
72
+
73
+ ```typescript
74
+ question({
75
+ questions: [
76
+ {
77
+ header: "Proceed?",
78
+ question: "Write AGENTS.md and tech-stack.md with the detected configuration?",
79
+ options: [
80
+ { label: "Yes (Recommended)", description: "Create both files" },
81
+ { label: "AGENTS.md only", description: "Skip tech-stack.md" },
82
+ { label: "Cancel", description: "Don't write anything" },
83
+ ],
84
+ },
85
+ ],
86
+ });
87
+ ```
55
88
 
56
89
  ### Phase 3: Create AGENTS.md
57
90
 
91
+ ```typescript
92
+ skill({ name: "verification-before-completion" });
93
+ ```
94
+
58
95
  Create `./AGENTS.md` — target <60 lines (max 150). Include:
59
96
  - Tech stack with versions, file structure, validated commands
60
97
  - Code example from actual codebase
@@ -64,7 +101,25 @@ Create `./AGENTS.md` — target <60 lines (max 150). Include:
64
101
 
65
102
  ### Phase 4: Create tech-stack.md
66
103
 
67
- Write detected values to `.opencode/memory/project/tech-stack.md`. Persist with memory update.
104
+ Write detected values to `.opencode/memory/project/tech-stack.md`. Then persist:
105
+
106
+ ```typescript
107
+ observation({
108
+ type: "feature",
109
+ title: "Project initialized — [tech stack summary]",
110
+ narrative: "Core setup completed: AGENTS.md, tech-stack.md created for [language/framework] project",
111
+ concepts: "project-setup, initialization",
112
+ confidence: "high",
113
+ });
114
+ ```
115
+
116
+ ### Phase 5: Setup Fallow (if available)
117
+
118
+ Check if fallow is available. If yes and no `.fallowrc.json` exists:
119
+
120
+ ```bash
121
+ npx fallow init --quiet 2>/dev/null || true
122
+ ```
68
123
 
69
124
  ---
70
125
 
@@ -72,29 +127,109 @@ Write detected values to `.opencode/memory/project/tech-stack.md`. Persist with
72
127
 
73
128
  Initialize project planning context with roadmap and state files.
74
129
 
75
- ### Phase 1: Discovery
130
+ ### Phase 1: Discovery (brownfield)
76
131
 
77
- If `--brownfield` (detected from existing codebase), run parallel codebase analysis:
78
- - `explore` for architecture patterns
79
- - `explore` for data flow
80
- - `explore` for domain boundaries
132
+ If the project has existing code (brownfield — see auto-detection above), run parallel codebase analysis:
81
133
 
82
- If greenfield, skip to requirements gathering.
134
+ ```typescript
135
+ task({
136
+ subagent_type: "explore",
137
+ description: "Map architecture patterns",
138
+ prompt: `Search the codebase for: architecture patterns, data flow, domain boundaries, and module structure.
139
+ Return: key architectural decisions, data flow patterns, main domains/modules.`,
140
+ });
141
+
142
+ task({
143
+ subagent_type: "explore",
144
+ description: "Map domain boundaries",
145
+ prompt: `Search the codebase for: domain boundaries, module organization, and subsystem structure.
146
+ Return: top-level domains, module boundaries, dependency direction.`,
147
+ });
148
+ ```
149
+
150
+ If greenfield (no existing code), skip to requirements gathering.
83
151
 
84
152
  ### Phase 2: Requirements Gathering
85
153
 
86
- Ask questions to define:
87
- - Project vision and goals (1-2 sentences each)
88
- - Target users and their needs
89
- - Core features (what must exist)
90
- - Technical constraints
91
- - Success criteria
154
+ Ask questions to define project direction:
155
+
156
+ ```typescript
157
+ question({
158
+ questions: [
159
+ {
160
+ header: "Project vision",
161
+ question: "What is the project vision? (1-2 sentences)",
162
+ options: [
163
+ { label: "Let me type it", description: "Custom input" },
164
+ ],
165
+ },
166
+ {
167
+ header: "Target users",
168
+ question: "Who are the primary users?",
169
+ multiple: true,
170
+ options: [
171
+ { label: "Developers", description: "Tooling, libraries, CLI" },
172
+ { label: "End users", description: "Consumer-facing application" },
173
+ { label: "Internal team", description: "Internal tool or service" },
174
+ { label: "Both", description: "Multiple user types" },
175
+ ],
176
+ },
177
+ {
178
+ header: "Success criteria",
179
+ question: "What defines success for this project? (select all that apply)",
180
+ multiple: true,
181
+ options: [
182
+ { label: "Stability", description: "Reliability and correctness first" },
183
+ { label: "Speed", description: "Performance and low latency" },
184
+ { label: "UX", description: "User experience and polish" },
185
+ { label: "Maintainability", description: "Code quality and extensibility" },
186
+ ],
187
+ },
188
+ ],
189
+ });
190
+ ```
191
+
192
+ ### Phase 3: Preview
193
+
194
+ Show the gathered requirements as a structured outline and ask for confirmation before writing files.
195
+
196
+ ### Phase 4: Create Files
197
+
198
+ ```typescript
199
+ // Create roadmap.md
200
+ write({
201
+ filePath: ".opencode/memory/project/roadmap.md",
202
+ content: `# Roadmap
203
+
204
+ ## Vision
205
+ [1-2 sentences]
92
206
 
93
- ### Phase 3: Create Files
207
+ ## Target Users
208
+ - ...
94
209
 
95
- - `.opencode/memory/project/roadmap.md` — vision, goals, user personas, feature roadmap, constraints, success criteria
96
- - `.opencode/memory/project/state.md` — current status, active decisions, known issues, next priorities
97
- - Update `.opencode/opencode.json` instructions to include roadmap.md and state.md
210
+ ## Feature Roadmap
211
+ - ...
212
+ `,
213
+ });
214
+
215
+ // Create state.md
216
+ write({
217
+ filePath: ".opencode/memory/project/state.md",
218
+ content: `# State
219
+
220
+ ## Current Status
221
+ Initial setup
222
+
223
+ ## Active Decisions
224
+ (none)
225
+
226
+ ## Next Priorities
227
+ - ...
228
+ `,
229
+ });
230
+ ```
231
+
232
+ Then update `.opencode/opencode.json` to include these files in `instructions[]` — append them to the existing array without removing `user.md`, `git-context.md`, or `fallow.md`.
98
233
 
99
234
  ---
100
235
 
@@ -104,19 +239,48 @@ Create personalized user profile at `.opencode/memory/project/user.md`.
104
239
 
105
240
  ### Phase 1: Gather Preferences
106
241
 
107
- Ask questions about:
108
- - **Identity**: Name, role, experience level
109
- - **Communication**: Verbosity preference, feedback style, update frequency
110
- - **Workflow**: Branch strategy, commit style, review expectations, test expectations
111
- - **Technical**: Preferred tools, avoided patterns, dev environment
242
+ ```typescript
243
+ question({
244
+ questions: [
245
+ {
246
+ header: "Identity",
247
+ question: "What is your name and role?",
248
+ options: [
249
+ { label: "Set name", description: "Tell me your details" },
250
+ ],
251
+ },
252
+ {
253
+ header: "Communication",
254
+ question: "How detailed should AI responses be?",
255
+ options: [
256
+ { label: "Concise (Recommended)", description: "Short, direct answers" },
257
+ { label: "Detailed", description: "Full explanations and reasoning" },
258
+ { label: "Mixed", description: "Depends on context" },
259
+ ],
260
+ },
261
+ {
262
+ header: "Git workflow",
263
+ question: "How should git commits be handled?",
264
+ options: [
265
+ { label: "Ask first (Recommended)", description: "Always confirm before commit/push" },
266
+ { label: "Auto-commit", description: "Commit directly after completion" },
267
+ ],
268
+ },
269
+ ],
270
+ });
271
+ ```
272
+
273
+ ### Phase 2: Preview
274
+
275
+ Show the captured preferences as a summary and ask for confirmation before writing.
112
276
 
113
- ### Phase 2: Create user.md
277
+ ### Phase 3: Create user.md
114
278
 
115
279
  Write to `.opencode/memory/project/user.md` with the captured preferences.
116
280
 
117
- ### Phase 3: Update opencode.json
281
+ ### Phase 4: Ensure instructions[] includes user.md
118
282
 
119
- Ensure user.md is in `instructions[]` as one of the 4 auto-injected files (user.md, tech-stack.md, project.md, git-context.md).
283
+ Check that `user.md` is listed in `.opencode/opencode.json` `instructions[]`. If missing, append it alongside the existing entries (`git-context.md`, `fallow.md`).
120
284
 
121
285
  > **Warning:** Do not add more files to `instructions[]` unless essential. Per-prompt injection of too many files causes session OOM. Use `memory-search({ file: "..." })` for on-demand access.
122
286
 
@@ -0,0 +1,137 @@
1
+ ---
2
+ purpose: Fallow codebase intelligence commands for AI agents — dead code, duplication, complexity, and audit gating
3
+ updated: 2026-06-04
4
+ ---
5
+
6
+ # Fallow — Codebase Intelligence Reference
7
+
8
+ ## Overview
9
+
10
+ Fallow is a Rust-native, deterministic static analysis tool for TypeScript/JavaScript codebases.
11
+ **No AI inside the analyzer** — same input always produces the same output.
12
+ It builds a complete module graph to find issues no linter or type checker can see.
13
+
14
+ ---
15
+
16
+ ## Commands
17
+
18
+ ### Full Analysis (single pass)
19
+
20
+ ```bash
21
+ npx fallow # All analyses: dead code + duplication + health
22
+ npx fallow --format json # Structured output for agent parsing
23
+ ```
24
+
25
+ ### Dead Code
26
+
27
+ ```bash
28
+ npx fallow dead-code # Full dead code report
29
+ npx fallow dead-code --format json --quiet # JSON for agents
30
+ npx fallow dead-code --unused-exports # Only unused exports
31
+ npx fallow dead-code --unused-dependencies # Only unused deps
32
+ npx fallow dead-code --circular # Only circular deps
33
+ npx fallow fix --dry-run # Preview safe auto-fixes
34
+ npx fallow fix --yes # Apply auto-fixes
35
+ ```
36
+
37
+ ### Trace (investigate before deleting)
38
+
39
+ ```bash
40
+ npx fallow dead-code --trace FILE:EXPORT_NAME # Why is this export flagged?
41
+ npx fallow dead-code --trace-dependency PACKAGE_NAME # Where is this dep imported?
42
+ ```
43
+
44
+ ### Duplication
45
+
46
+ ```bash
47
+ npx fallow dupes # Find code clones
48
+ npx fallow dupes --mode strict # Exact matches only
49
+ npx fallow dupes --mode weak # Structural matches
50
+ npx fallow dupes --trace FILE:LINE # Deep-dive a specific clone group
51
+ ```
52
+
53
+ ### Health (complexity)
54
+
55
+ ```bash
56
+ npx fallow health # Complexity hotspots + refactoring targets
57
+ npx fallow health --format json # Structured output
58
+ ```
59
+
60
+ ### Audit Gate (for CI / pre-commit)
61
+
62
+ ```bash
63
+ npx fallow audit # Check changed files (verdict: pass/warn/fail)
64
+ npx fallow audit --format json # Structured verdict for agents
65
+ npx fallow audit --gate new-only # Only flag new issues, not pre-existing
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Workflow Patterns
71
+
72
+ ### Post-Edit Verification Loop
73
+
74
+ ```bash
75
+ # 1. Make changes
76
+ # 2. Run audit
77
+ npx fallow audit --format json --quiet
78
+ # 3. If verdict is "fail", inspect findings
79
+ # 4. Fix or investigate with --trace
80
+ # 5. Re-run audit until pass
81
+ ```
82
+
83
+ ### Codebase Cleanup
84
+
85
+ ```bash
86
+ npx fallow # Full picture
87
+ npx fallow dead-code --format json # Find unused code
88
+ npx fallow fix --dry-run # Preview auto-removals
89
+ npx fallow fix --yes # Apply auto-fixes
90
+ npx fallow dupes # Find duplication
91
+ npx fallow health # Find complexity hotspots
92
+ ```
93
+
94
+ ### Monorepo / Workspace
95
+
96
+ ```bash
97
+ npx fallow --workspace # Analyze all workspaces
98
+ npx fallow --workspace packages/pkg # Analyze specific workspace
99
+ ```
100
+
101
+ ---
102
+
103
+ ## Understanding Output
104
+
105
+ Every finding in `--format json` includes:
106
+
107
+ ```json
108
+ {
109
+ "path": "src/utils/example.ts:42",
110
+ "issue_type": "unused-exports",
111
+ "actions": [
112
+ {
113
+ "type": "delete-export",
114
+ "auto_fixable": true,
115
+ "description": "Remove unused export"
116
+ }
117
+ ]
118
+ }
119
+ ```
120
+
121
+ The `actions[]` array is machine-actionable. Agents can inspect `auto_fixable` flags and apply safe fixes programmatically.
122
+
123
+ ---
124
+
125
+ ## Config
126
+
127
+ Fallow auto-detects your project. For custom config, run:
128
+
129
+ ```bash
130
+ npx fallow init # Generates .fallow/config.yaml with auto-detected settings
131
+ ```
132
+
133
+ Common config patterns:
134
+ - `ignorePatterns` — exclude directories from analysis (e.g., `.opencode/`)
135
+ - `entry` — declare additional entry points
136
+ - `publicPackages` — packages with public API surface
137
+ - `rules` — custom issue severity rules
@@ -0,0 +1,89 @@
1
+ Collapse a range in the conversation into a detailed summary.
2
+
3
+ THE SUMMARY
4
+ Your summary must be EXHAUSTIVE. Use the following 7-section structure to ensure nothing is lost.
5
+ Capture file paths, function signatures, decisions made, constraints discovered, key findings, tool outcomes, and user intent... EVERYTHING that preserves the value of the compressed range.
6
+
7
+ STRUCTURED SUMMARY FORMAT
8
+ When summarizing the range, organize findings into these sections (omit empty sections):
9
+
10
+ 1. **Session Intent** — What the user requested. Quote exact instructions when short.
11
+ 2. **Key Technical Details** — File paths with line ranges (`path/file.ts:42-67`). Function signatures. Error messages verbatim. Code snippets critical to understanding.
12
+ 3. **Artifact Map** — Enumeration of files created, modified, and read, with what changed in each:
13
+ - `file created: path/to/new.ts` — what the file contains
14
+ - `file modified: path/to/existing.ts` — what changed (functions added/removed, logic changed)
15
+ - `file read: path/to/examined.ts` — why it was examined, key findings
16
+ 4. **Decisions** — What was decided, alternatives considered, rationale. Preserve the reasoning chain.
17
+ 5. **Problem Solving** — Approaches tried (including failures). What worked and why. Root cause analysis.
18
+ 6. **Current State** — Where we are in the task: what's done, what's active, what's blocked.
19
+ 7. **Continuation** — Exact next steps to resume work without re-fetching context. Include pending tasks with status.
20
+
21
+ USER INTENT FIDELITY
22
+ When the compressed range includes user messages, preserve the user's intent with extra care. Do not change scope, constraints, priorities, acceptance criteria, or requested outcomes.
23
+ Directly quote user messages when they are short enough to include safely. Direct quotes are preferred when they best preserve exact meaning.
24
+
25
+ Yet be LEAN. Strip away the noise: failed attempts that led nowhere, verbose tool outputs, back-and-forth exploration. What remains should be pure signal — golden nuggets of detail that preserve full understanding with zero ambiguity.
26
+
27
+ COMPRESSED BLOCK PLACEHOLDERS
28
+ When the selected range includes previously compressed blocks, use this exact placeholder format when referencing one:
29
+
30
+ - `(bN)`
31
+
32
+ Compressed block sections in context are clearly marked with a header:
33
+
34
+ - `[Compressed conversation section]`
35
+
36
+ Compressed block IDs always use the `bN` form (never `mNNNN`) and are represented in the same XML metadata tag format.
37
+
38
+ Rules:
39
+
40
+ - Include every required block placeholder exactly once.
41
+ - Do not invent placeholders for blocks outside the selected range.
42
+ - Treat `(bN)` placeholders as RESERVED TOKENS. Do not emit `(bN)` text anywhere except intentional placeholders.
43
+ - If you need to mention a block in prose, use plain text like `compressed bN` (not as a placeholder).
44
+ - Preflight check before finalizing: the set of `(bN)` placeholders in your summary must exactly match the required set, with no duplicates.
45
+
46
+ These placeholders are semantic references. They will be replaced with the full stored compressed block content when the tool processes your output.
47
+
48
+ FLOW PRESERVATION WITH PLACEHOLDERS
49
+ When you use compressed block placeholders, write the surrounding summary text so it still reads correctly AFTER placeholder expansion.
50
+
51
+ - Treat each placeholder as a stand-in for a full conversation segment, not as a short label.
52
+ - Ensure transitions before and after each placeholder preserve chronology and causality.
53
+ - Do not write text that depends on the placeholder staying literal (for example, "as noted in `(b2)`").
54
+ - Your final meaning must be coherent once each placeholder is replaced with its full compressed block content.
55
+
56
+ BOUNDARY IDS
57
+ You specify boundaries by ID using the injected IDs visible in the conversation:
58
+
59
+ - `mNNNN` IDs identify raw messages
60
+ - `bN` IDs identify previously compressed blocks
61
+
62
+ Each message has an ID inside XML metadata tags like `<dcp-message-id>m0001</dcp-message-id>`.
63
+ The same ID tag appears in every tool output of the message it belongs to — each unique ID identifies one complete message.
64
+ Treat these tags as boundary metadata only, not as tool result content.
65
+
66
+ Rules:
67
+
68
+ - Pick `startId` and `endId` directly from injected IDs in context.
69
+ - IDs must exist in the current visible context.
70
+ - `startId` must appear before `endId`.
71
+ - Do not invent IDs. Use only IDs that are present in context.
72
+
73
+ BATCHING
74
+ When multiple independent ranges are ready and their boundaries do not overlap, include all of them as separate entries in the `content` array of a single tool call. Each entry should have its own `startId`, `endId`, and `summary`.
75
+
76
+ THE FORMAT OF COMPRESS
77
+
78
+ ```
79
+ {
80
+ topic: string, // Short label (3-5 words) for the overall batch
81
+ content: [ // One or more ranges to compress independently
82
+ {
83
+ startId: string, // ID at range start: mNNNN or bN
84
+ endId: string, // ID at range end: mNNNN or bN
85
+ summary: string // Complete technical summary replacing that range (use 7-section format above)
86
+ }
87
+ ]
88
+ }
89
+ ```