@duckmind/dm-windows-x64 0.63.4 → 0.63.6

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 (32) hide show
  1. package/extensions/.dm-extensions.json +64 -4
  2. package/extensions/dm-context/package.json +1 -1
  3. package/extensions/dm-context/skills/context-management/SKILL.md +173 -223
  4. package/extensions/dm-context/skills/context-management/references/development-and-troubleshooting.md +75 -0
  5. package/extensions/dm-context/skills/context-management/references/interleaved-async-work.md +143 -0
  6. package/extensions/dm-context/skills/context-management/references/planning-and-execution.md +81 -0
  7. package/extensions/dm-context/skills/context-management/references/repeated-items-and-batch-work.md +69 -0
  8. package/extensions/dm-context/skills/context-management/references/retry-branch-and-pivot.md +80 -0
  9. package/extensions/dm-context/skills/context-management/references/search-research-and-reading.md +103 -0
  10. package/extensions/dm-context/skills/context-management/references/task-switching-and-cleanup.md +73 -0
  11. package/extensions/dm-context/src/context.js +3 -2
  12. package/extensions/dm-context/src/index.js +168 -84
  13. package/extensions/dm-skills-manager/THIRD_PARTY_NOTICES.md +27 -0
  14. package/extensions/dm-skills-manager/extensions/skills-manager/components.js +265 -0
  15. package/extensions/dm-skills-manager/extensions/skills-manager/constants.js +31 -0
  16. package/extensions/dm-skills-manager/extensions/skills-manager/creation-fallback.js +20 -0
  17. package/extensions/dm-skills-manager/extensions/skills-manager/creation.js +145 -0
  18. package/extensions/dm-skills-manager/extensions/skills-manager/dialog.js +738 -0
  19. package/extensions/dm-skills-manager/extensions/skills-manager/dm-ai-compat.js +15 -0
  20. package/extensions/dm-skills-manager/extensions/skills-manager/format.js +125 -0
  21. package/extensions/dm-skills-manager/extensions/skills-manager/glyphs.js +142 -0
  22. package/extensions/dm-skills-manager/extensions/skills-manager/layout.js +93 -0
  23. package/extensions/dm-skills-manager/extensions/skills-manager/paths.js +76 -0
  24. package/extensions/dm-skills-manager/extensions/skills-manager/registry.js +95 -0
  25. package/extensions/dm-skills-manager/extensions/skills-manager/settings.js +93 -0
  26. package/extensions/dm-skills-manager/extensions/skills-manager/startup.js +32 -0
  27. package/extensions/dm-skills-manager/extensions/skills-manager/toggle.js +54 -0
  28. package/extensions/dm-skills-manager/extensions/skills-manager/types.js +14 -0
  29. package/extensions/dm-skills-manager/extensions/skills-manager/ui.js +121 -0
  30. package/extensions/dm-skills-manager/extensions/skills-manager.js +111 -0
  31. package/extensions/dm-skills-manager/package.json +121 -0
  32. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "status": "ok",
3
- "prepared_at": "2026-08-31T16:25:06.094476+00:00",
3
+ "prepared_at": "2026-08-31T17:37:37.181676+00:00",
4
4
  "managed_entries": [
5
5
  {
6
6
  "id": "dm-context",
@@ -41,6 +41,11 @@
41
41
  "id": "dm-web-access",
42
42
  "target_dir": "extensions/dm-web-access",
43
43
  "bundle_mode": "source-package-with-runtime-deps"
44
+ },
45
+ {
46
+ "id": "dm-skills-manager",
47
+ "target_dir": "extensions/dm-skills-manager",
48
+ "bundle_mode": "source-package-with-runtime-deps"
44
49
  }
45
50
  ],
46
51
  "local_entries": [
@@ -82,8 +87,8 @@
82
87
  "src/utils.js"
83
88
  ],
84
89
  "file_count": 3,
85
- "before_bytes": 25960,
86
- "after_bytes": 20884,
90
+ "before_bytes": 32134,
91
+ "after_bytes": 25217,
87
92
  "runtime_specifier_rewrites": 0,
88
93
  "runtime_filename_rewrites": 3,
89
94
  "declaration_files_removed": 0
@@ -713,6 +718,61 @@
713
718
  "declaration_files_removed": 1
714
719
  }
715
720
  },
721
+ {
722
+ "id": "dm-skills-manager",
723
+ "staged_dir": "extensions/dm-skills-manager",
724
+ "bundle_mode": "source-package-with-runtime-deps",
725
+ "dependencies_installed": false,
726
+ "dependency_mode": "platform-package-dependency",
727
+ "dependencies_declared": [
728
+ "@duckmind/dm-ai",
729
+ "@duckmind/dm-coding-agent",
730
+ "@duckmind/dm-tui"
731
+ ],
732
+ "dependency_patches": [
733
+ "dm.extensions ts->js",
734
+ "drop-devDependencies",
735
+ "drop-peerDependencies",
736
+ "drop-repository",
737
+ "drop-bugs",
738
+ "drop-homepage",
739
+ "drop-scripts",
740
+ "drop-files"
741
+ ],
742
+ "stripped_documentation": [
743
+ "README.md",
744
+ "assets/skills-manager.png"
745
+ ],
746
+ "javascript_compile": {
747
+ "tool": "bun build --no-bundle",
748
+ "mode": "module-preserving-transpile",
749
+ "files": [
750
+ "extensions/skills-manager/components.js",
751
+ "extensions/skills-manager/constants.js",
752
+ "extensions/skills-manager/creation-fallback.js",
753
+ "extensions/skills-manager/creation.js",
754
+ "extensions/skills-manager/dialog.js",
755
+ "extensions/skills-manager/dm-ai-compat.js",
756
+ "extensions/skills-manager/format.js",
757
+ "extensions/skills-manager/glyphs.js",
758
+ "extensions/skills-manager/layout.js",
759
+ "extensions/skills-manager/paths.js",
760
+ "extensions/skills-manager/registry.js",
761
+ "extensions/skills-manager/settings.js",
762
+ "extensions/skills-manager/startup.js",
763
+ "extensions/skills-manager/toggle.js",
764
+ "extensions/skills-manager/types.js",
765
+ "extensions/skills-manager/ui.js",
766
+ "extensions/skills-manager.js"
767
+ ],
768
+ "file_count": 17,
769
+ "before_bytes": 95706,
770
+ "after_bytes": 85484,
771
+ "runtime_specifier_rewrites": 0,
772
+ "runtime_filename_rewrites": 17,
773
+ "declaration_files_removed": 0
774
+ }
775
+ },
716
776
  {
717
777
  "id": "dm-cua",
718
778
  "staged_dir": "extensions/dm-cua",
@@ -806,7 +866,7 @@
806
866
  },
807
867
  "runtime_loader": {
808
868
  "status": "verified",
809
- "entries": 11,
869
+ "entries": 12,
810
870
  "loader": "dm-coding-agent",
811
871
  "platform_dependencies": [
812
872
  "@mozilla/readability",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dm-context",
3
- "version": "1.1.3",
3
+ "version": "2.1.2",
4
4
  "description": "Agentic Context Management for DM",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,258 +1,208 @@
1
1
  ---
2
2
  name: context-management
3
- description: Strategies for efficient context management using context_log, context_tag, and context_checkout. Learn when to tag, how to visualize the graph, and safe ways to squash history. Use for complex refactoring, debugging, and long conversations.
3
+ description: "Use this skill for multi-turn, phased, or noisy work: research/reading, debugging, plan-then-execute, retries/pivots, background or asynchronous work, handoffs, user decisions, task switching, repeated items, or repeated progress checks. It keeps the conversation as a clean working set with checkpoints, timeline review, and compaction at continuation boundaries. Always use when resuming after context compaction or when a long phase reaches a decision, handoff, validation, or task-switch boundary. Usually skip simple one-shot tasks."
4
4
  ---
5
5
 
6
6
  # Context Management
7
7
 
8
- **CRITICAL: THIS SKILL MANAGES YOUR MEMORY. WITHOUT IT, YOU WILL FORGET.**
8
+ Use this skill to keep the active conversation as a useful **working set** for the next step. Keep raw only the context that still needs direct reasoning; carry the rest as compact task state when that is more efficient.
9
9
 
10
- Your context window is limited. As conversations grow, "pollution" (noise, failed attempts) degrades your reasoning.
10
+ Core rhythm:
11
11
 
12
- **YOU MUST PROACTIVELY MANAGE YOUR HISTORY.**
13
- Do not wait for the user to tell you.
12
+ - **checkpoint before mess**
13
+ - **review timeline when structure affects the next decision**
14
+ - **compact when a state summary is a better working set than the raw trail**
14
15
 
15
- ## The Core Philosophy: Build, Perceive, Navigate
16
+ Use only these tools:
16
17
 
17
- ```
18
- Context Window = RAM (Expensive, volatile, limited)
19
- Context Graph = Disk (Cheap, persistent, unlimited)
18
+ - `context_checkpoint`
19
+ - `context_timeline`
20
+ - `context_compact`
20
21
 
21
- → Move finished tasks from RAM to the Graph.
22
- ```
22
+ ## Working-set model
23
23
 
24
- Manage your context window like a Git repository. You are the maintainer.
24
+ Before choosing a tool, ask:
25
25
 
26
- 1. **BUILD the Skeleton (`context_tag`)**:
27
- * Raw conversation is a flat list. **Tags create structure.**
28
- * Without tags, `context_log` is just a list of IDs. With tags, it is a **Map**.
29
- 2. **PERCEIVE the State (`context_log`)**:
30
- * Check the HUD: Is "Segment Size" too big? You are drifting.
31
- * Check the Graph: Where are you? Are you in a deep branch?
32
- 3. **NAVIGATE & MERGE (`context_checkout`)**:
33
- * **Squash:** Convert a messy "feature branch" (thinking process) into a single "merge commit" (summary).
34
- * **Jump:** Move between tasks or retry paths without carrying baggage.
26
+ - What am I trying to do next?
27
+ - What facts, constraints, or artifacts must stay raw for that next action?
28
+ - What important data has a reliable external source I can re-check instead of carrying raw?
29
+ - What history is useful only as a conclusion, pointer, or state update?
30
+ - What history is process noise or stale baggage?
35
31
 
36
- ## Quick Start: The Loop
32
+ Classify context into:
37
33
 
38
- Follow this cycle for every major task:
34
+ - **Raw context:** user intent, constraints, code/log/error details, evidence, or plan text you expect to inspect directly soon.
35
+ - **State summary:** decisions, findings, lessons, changed files, validation status, source pointers, rejected leads, and next steps that can replace raw process.
36
+ - **Discardable process:** repetitive searches, verbose logs, abandoned hypotheses, false starts, and unrelated turns whose useful value is already captured or gone.
39
37
 
40
- 1. **CHECK:** Verify state.
41
- `context_log`
42
- 2. **START:** Tag the beginning with a semantic name.
43
- `context_tag({ name: "<task-slug>-start" })` // e.g., `auth-login-start`
44
- 3. **WORK:** Execute steps.
45
- 4. **MILESTONE:** Tag intermediate stable states.
46
- `context_tag({ name: "<task-slug>-plan" })` // e.g., `auth-login-plan`
47
- 5. **SQUASH (Autonomous):** If history becomes noisy or low-density, **Squash with Backup**.
48
- * *Action:* `context_checkout({ target: "<task-slug>-start", message: "...", backupTag: "<task-slug>-raw-history" })`
49
- * *Action (Optional):* `context_tag({ name: "<task-slug>-done" })`
50
- * *Safety:* If you need the details later, checkout the backup tag.
38
+ If the active context is already small, coherent, and directly useful for the next step, do not manage it just to be tidy.
51
39
 
52
- ## Tool Reference
40
+ ## When to use
53
41
 
54
- | Tool | Analog | Purpose | When to Use |
55
- | :--- | :--- | :--- | :--- |
56
- | `context_tag` | `git tag` | Bookmark a stable state. | Before risky changes. Before starting a new task. |
57
- | `context_log` | `git log` | See where you are. | When you feel lost. To find IDs for checkout. |
58
- | `context_checkout`| `git reset --soft` | **Time Travel / Squash.** | To undo mistakes. To compress history. |
42
+ Use this mode when the work may outgrow one clean thread:
59
43
 
60
- ## Critical Rules
44
+ - search, research, browser work, or reading many files/logs/pages/results
45
+ - investigate -> decide -> execute -> validate
46
+ - plan -> implement -> verify
47
+ - background or asynchronous work, handoffs, user decisions, or delayed results
48
+ - multiple approaches, retries, failed branches, comparisons, or pivots
49
+ - repeated similar cases, tickets, reviews, or batch items
50
+ - a main task that may be interrupted by side tasks
51
+ - repeated progress/status checks that indicate active state is hard to track
52
+ - scattered threads that need cleanup before continuing
53
+ - debugging, troubleshooting, refactoring, migration, or code-facing work that may get noisy
61
54
 
62
- ### Tag Wisely (Build The Skeleton)
55
+ If one of these clearly applies, take a structural action now, usually a checkpoint. Do not merely describe the workflow. If the user has not provided enough task details, still checkpoint the workflow shape before asking clarifying questions.
63
56
 
64
- Tags are the "Table of Contents". Name them so you can understand the history at a glance.
57
+ Usually skip this skill for one-shot reads, bounded summaries, direct rewrites, simple lookups, deterministic scripts, short tasks that can stay clean, or moments where the active context is already a good working set.
65
58
 
66
- **Naming Formula:** `<task-slug>-<phase>`
59
+ ## Start-of-turn check
67
60
 
68
- * **task-slug**: Short, kebab-case identifier for the task (e.g., `auth-login`, `db-migration`)
69
- * **phase**: The stage of work (`start`, `plan`, `impl`, `done`, `fail`, `backup`)
61
+ At the start of each new user message, classify it:
70
62
 
71
- | Bad (Generic) | Good (Semantic) | Why |
72
- | :--- | :--- | :--- |
73
- | `task-start` | `auth-oauth-start` | Describes WHAT task |
74
- | `pre-research` | `error-log-analysis-start` | Future-you knows the topic |
75
- | `phase-1-done` | `db-schema-plan-done` | Know which phase of which task |
76
- | `debug-retry` | `null-pointer-fix-retry` | What bug? |
63
+ - **Same task / next phase:** continue; if the previous phase is complete and noisy, compact before the next phase.
64
+ - **Correction, review, or feedback on recent work:** answer from the raw recent context; do not compact merely to respond. Questions about implementation choices, shortcuts, trade-offs, or known risks are exactly why the completed work should remain inspectable.
65
+ - **New task, explicit next step, or direction shift:** if the previous task left a complete noisy segment, inspect timeline when anchors are unclear, then compact to a continuation anchor that gives the now-known next work a clean working set.
77
66
 
78
- **Tag Categories:**
67
+ Think of the tools as a phase pipeline: checkpoint marks anchors, work happens, timeline shows structure, and compact creates a new branch from the chosen continuation anchor with a summary of what happened after it. The target is a working-set choice, not an age choice.
79
68
 
80
- | Category | Pattern | Examples |
81
- | :--- | :--- | :--- |
82
- | **Start** | `<task>-start` | `auth-jwt-start`, `docker-setup-start` |
83
- | **Plan** | `<task>-plan` | `api-v2-plan`, `migration-plan` |
84
- | **Milestone** | `<task>-<milestone>` | `auth-jwt-impl-done`, `tests-passed` |
85
- | **Backup** | `<task>-raw-history` | `auth-jwt-raw-history` |
86
- | **Failure** | `<task>-fail-<reason>` | `auth-jwt-fail-timeout` |
69
+ ## Main loop
87
70
 
88
- **How to generate:** Ask yourself "What is the task?" → Extract 1-3 keywords (e.g., "fix login timeout" → `login-timeout-fix-start`)
71
+ 1. Before noisy work, create a semantic checkpoint as the first context-management action. If the first job is orientation over existing history, run `context_timeline` before adding a new checkpoint.
72
+ 2. When the task shape is clear, read one matching scenario reference only if it will change tool timing, anchor choice, or summary content. Skip reference loading for obvious short applications where this main skill body is enough.
73
+ 3. Add checkpoints at meaningful milestones: phase boundaries, risky attempts, reusable batch methods, and interruptions.
74
+ 4. Use `context_timeline` when the active path structure affects the next decision or compact target.
75
+ 5. At continuation boundaries, run the compact gate before starting another known phase. If the whole requested task is complete, present the result and wait for feedback; delivery and a request for feedback are not themselves a continuation.
76
+ 6. After a successful compact, continue from the injected summary instead of dragging the full raw path forward.
89
77
 
90
- ### Squash Noise, Keep Signal, Focus on Goal (Context Hygiene)
91
- Think of your conversation as a "Feature Branch" full of messy thoughts.
92
- **You must distinguish Signal from Noise.**
78
+ ## Continuation boundaries
93
79
 
94
- * **Signal (High Value):** Design decisions, user constraints, final working code. -> **KEEP.**
95
- * **Noise (Low Value):** Failed attempts, long tool outputs, "thinking" steps. -> **SQUASH.**
96
- * **Focus on Goal:** Ask yourself: "Does this message help me achieve the current goal?" -> **KEEP.**
80
+ A continuation boundary is a point where the current phase has produced a stable result and the next action will use that result to start a different phase. It is not necessarily the end of the user's whole task.
97
81
 
98
- **When to Squash:**
99
- 1. **Task Done:** Convert the messy process into one clean summary.
100
- 2. **Low Density:** You read 2000 lines but only found 1 error.
82
+ Examples: investigation -> decision/plan/implementation, implementation -> validation, failed validation -> next approach, delayed result -> routing/action, received user decision -> execution, rejected branch -> replacement direction, side request -> pause/summarize mainline before switching.
101
83
 
102
- **Safety:** Squashing is **LOSSLESS**.
103
- By using `backupTag`, you save the "Messy Branch" forever. You can always checkout the backup tag if the summary isn't enough.
104
- * **Main Trunk:** Jump back to the summary.
105
- * **Backup Tag:** Jump back to the raw details.
84
+ Do not ask only "is the whole task done?" Ask "will the next action start a new phase using the stable result of this phase?" If yes, this is often a compaction boundary.
106
85
 
107
- ### Fail Fast, Revert Faster
108
- If you fail 3 times:
109
- 1. **STOP.** Don't try a 4th time.
110
- 2. `context_checkout` back to the last safe tag.
111
- 3. Summarize the failure in the checkout message ("Tried X, failed because Y").
112
- 4. Try a new approach from the clean state.
86
+ A response that presents completed work and asks the user for review, feedback, or a decision is **not** a continuation boundary: the next work is unknown, and the user may ask about details from the raw trail. Deliver the result and wait without compacting. Once feedback or an explicit next task arrives, decide whether the resulting known continuation benefits from compaction.
113
87
 
114
- ### After Checkout: Execute Next Step
115
-
116
- When `context_checkout` completes and injects a summary, you are in a **new context**.
117
-
118
- 1. **READ** the injected summary carefully
119
- 2. **EXECUTE** the `Next Step` from the summary - this is your new task.
88
+ An actual handoff to a known next actor, process, validation, or queued phase can be a boundary when the next action is defined and needs only stable state. Do not treat a merely possible later user response as that kind of handoff.
120
89
 
121
- ## Decision Matrix: When to Act
122
-
123
- | Situation | Action | Reason |
124
- | :--- | :--- | :--- |
125
- | **Starting Task** | `context_tag({ name: "<task-slug>-start" })` | Create a rollback point. |
126
- | **Research / Logs** | `context_checkout` (Squash) | **Process is Noise.** Read 2000 lines -> Keep result. |
127
- | **Messy Debugging** | **Squash w/ Backup** | **Cleanup.** The error logs are noise once fixed. |
128
- | **Task Done (Candidate)**| **Squash w/ Backup** | **Assume Success.** Summary is usually enough. Backup exists if not. |
129
- | **Goal Shift** | `context_checkout` (Squash) | Old context is irrelevant. |
130
- | **Drift (some steps w/o tag)** | **Tag (Milestone)** | Maintain the skeleton. Don't fly blind. |
131
-
132
- ## The "Context Health" Check
133
-
134
- If you cannot answer these, run `context_log`:
90
+ ## Read the right reference
135
91
 
136
- | Question | Answer Source |
137
- | :--- | :--- |
138
- | **Where is the skeleton?** | The sequence of `tag`s in the log. |
139
- | **Is this history useful?** | If "No" -> **SQUASH IT.** |
140
- | **Am I in a loop?** | Repeated entries in the graph. |
141
-
142
- ## Good Checkout Messages
143
-
144
- The `message` is your lifeline to your past self.
145
- A good message preserves critical context that would otherwise be lost.
146
-
147
- Structure: `[Key Finding/Status] + [Reason] + [Important Changes] + [Next Step]`
148
-
149
- * **Key Finding/Status**: What did you discover or complete? Include specific numbers, errors, or outcomes.
150
- * **Reason**: Why are you branching/moving? (e.g., "Task complete", "Approach failed", "Need raw logs")
151
- * **Important Changes**: What files or logic have been modified? (This checkout only resets *conversation history*, NOT disk files, so you must remember what changed.)
152
- * **Next Step**: What should you do immediately after this squash? Be specific. (e.g., "Wait for user feedback", "Implement the recommended fix", "Revert file X and try approach Y")
153
-
154
- Examples:
155
-
156
- * *Good (Resetting after failure)*: "Recursive parser hit stack overflow at depth 8000. Switching to iterative. **Reason**: Stack limit reached. **Important Changes**: Modified `utils/recursion.ts`. **Next Step**: Inform user of the failure and propose iterative approach."
157
- * *Good (Cleaning up)*: "Auth module complete: JWT + OAuth2 + RBAC. 23 tests passing. **Reason**: Task done, cleaning context. **Important Changes**: Created `auth/`, modified `routes.ts` and `middleware.ts`. **Next Step**: Report completion to user, ask if they want to review or test."
158
- * *Bad*: "Switching context." (Too vague - you will forget why)
159
- * *Bad*: "Done." (What is done? What should you do next?)
160
-
161
- ## Anti-Patterns
162
-
163
- | Don't | Do Instead |
164
- | :--- | :--- |
165
- | **Blind Tagging** (Tagging without looking) | **Check** (`context_log`) to avoid duplicates or tagging noise. |
166
- | **Over-Tagging** (Tagging every step) | **Tag** only major phase changes (`start`, `milestone`). |
167
- | **Hoard** (Keep all history "just in case") | **Squash** low-density history (research, logs). |
168
- | **Panic** (Apologize repeatedly for errors) | **Revert** (`context_checkout`) to before the error. |
169
- | **Blind Checkout** (Guessing IDs) | **Look** (`context_log`) first to get valid IDs. |
170
- | **Vague Summaries** ("Done", "Fixed") | **Detailed Summaries** ("Found bug in line 40. Fixed with patch X.") |
171
- | **Generic Tag Names** (`task-start`, `phase-1`) | **Semantic Names** (`auth-jwt-start`, `db-schema-plan`) |
172
- | **Missing Next Step** in checkout message | **Always specify** what to do after squash (e.g., "Wait for user", "Implement fix X") |
173
-
174
- ## Recipes (Copy-Paste)
175
-
176
- ### 1. The "Miner" (Immediate Squash)
177
- **Goal:** Pure information gathering (Reading files, Searching web).
178
- **Why:** The *process* of searching is irrelevant. Only the *result* matters.
179
-
180
- **Example Task:** Analyzing error logs to find root cause of timeout
181
-
182
- ```javascript
183
- // 1. Tag BEFORE starting the noisy work (use descriptive name)
184
- context_tag({ name: "timeout-analysis-start" });
185
-
186
- // ... (Read 5 log files, search 3 docs, find DB connection pool exhaustion) ...
187
-
188
- // 2. Squash IMMEDIATELY. Do not wait for user.
189
- context_checkout({
190
- target: "timeout-analysis-start",
191
- message: "Found DB connection pool exhaustion as root cause (pool size: 10, peak load: 1000 req/s). Recommended fix: increase to 50. **Reason**: Context cleanup after research. **Important Changes**: None (read-only). **Next Step**: Report findings to user and await approval to implement fix.",
192
- backupTag: "timeout-analysis-raw-history" // Safety backup
193
- });
194
- context_tag({ name: "timeout-analysis-done" });
195
- ```
196
-
197
- ### 2. The "Candidate" (Wait for Confirmation)
198
- **Goal:** You finished a complex task.
199
- **Why:** The history is noisy. The result is clean.
200
- **Safety:** We create a backup tag automatically.
201
-
202
- **Example Task:** Implementing OAuth login flow
203
-
204
- ```javascript
205
- // Squash to Summary (Optimistic Cleanup)
206
- context_checkout({
207
- target: "oauth-impl-start", // Squash range: Start -> Now
208
- message: "OAuth2 flow implemented with PKCE, Google + GitHub providers. All 12 tests passing. **Reason**: Task complete, cleaning up. **Important Changes**: Created `auth/oauth.ts`, modified `routes.ts`, `config.ts`. **Next Step**: Report completion to user, summarize what was implemented.",
209
- backupTag: "oauth-impl-raw-history"
210
- });
211
- context_tag({ name: "oauth-impl-candidate" });
212
- ```
213
-
214
- ### 3. The "Undo" (Revert Squash)
215
- **Goal:** User asks about a detail you squashed away.
216
- **Action:** Jump back to the backup tag.
217
-
218
- **Example Task:** Reviewing OAuth implementation details
219
-
220
- ```javascript
221
- // Jump back to the raw history
222
- context_checkout({
223
- target: "oauth-impl-raw-history",
224
- message: "Reviewing token refresh logic - user reports 401 after 15 min idle. Suspect refresh token not firing. **Reason**: Need raw logs to trace the bug. **Important Changes**: None. **Next Step**: Re-read token refresh implementation and identify the bug."
225
- });
226
- context_tag({ name: "oauth-review-start" });
227
- ```
228
-
229
- ### 4. Branching (Alternative Approach)
230
- **Scenario:** Method A failed (and was squashed). You want to try Method B from the clean state.
231
- **Action:** Checkout the start point.
232
-
233
- **Example Task:** Fixing memory leak - trying different approaches
234
-
235
- ```javascript
236
- // Method A (weak references) failed, trying Method B (object pooling)
237
- context_checkout({
238
- target: "memory-leak-fix-start",
239
- message: "WeakRef approach failed: objects GC'd within 30s (expected: 5min). Cache hit rate dropped from 95% to 12%. **Reason**: Switching to object pooling approach. **Important Changes**: `CacheManager.ts` modified (will revert). **Next Step**: Revert `CacheManager.ts` changes and implement object pooling strategy."
240
- });
241
- context_tag({ name: "memory-leak-pool-approach-start" });
242
- ```
243
-
244
- ### 5. The "Undo" (Failed Attempt)
245
- You tried to fix a bug but broke everything.
246
- **Goal:** Clean up a failed path.
247
-
248
- **Example Task:** Fixing race condition in async handler
249
-
250
- ```javascript
251
- // Attempted mutex-based fix, but introduced deadlock
252
- context_checkout({
253
- target: "race-condition-fix-start",
254
- message: "Mutex caused deadlock: Thread A holds mutex, awaits callback; callback needs mutex held by B; B waits for A. Circular wait detected. **Reason**: Trying lock-free CAS approach next. **Important Changes**: `AsyncQueue.ts` lines 70-90 modified (backup saved). **Next Step**: Revert `AsyncQueue.ts` and implement lock-free compare-and-swap approach.",
255
- backupTag: "race-condition-mutex-fail" // Save the failure for reference
256
- });
257
- context_tag({ name: "race-condition-lockfree-start" });
258
- ```
92
+ Read **one primary reference** only when the scenario pattern will affect tool timing, anchor choice, or summary content:
93
+
94
+ - search / research / reading-heavy work -> `references/search-research-and-reading.md`
95
+ - development / debugging / troubleshooting / refactoring / migration -> `references/development-and-troubleshooting.md`
96
+ - planning / staged execution / todo-driven work -> `references/planning-and-execution.md`
97
+ - repeated similar items / batch work -> `references/repeated-items-and-batch-work.md`
98
+ - task switching / pause-resume / interruptions / cleanup-and-continue -> `references/task-switching-and-cleanup.md`
99
+ - interleaved async work / overlapping fronts / background results / user decisions -> `references/interleaved-async-work.md`
100
+
101
+ Also read `references/retry-branch-and-pivot.md` when multiple approaches, failed branches, comparisons, retries, or pivots become central.
102
+
103
+ ## Tool policy
104
+
105
+ ### `context_checkpoint`
106
+
107
+ Use before noisy work, a new phase, a risky attempt, switching subtasks, or after a meaningful milestone. Use semantic names such as `<task>-start`, `<task>-<phase>`, `<task>-<attempt>`, or `<task>-<milestone>`. Avoid generic names like `start`, `checkpoint-1`, or `retry`.
108
+
109
+ ### `context_timeline`
110
+
111
+ Use it as the structural view of the active path:
112
+
113
+ - when the current path shape affects the next decision
114
+ - when several checkpoints, branches, or task switches exist
115
+ - before choosing a non-obvious compact target
116
+ - when the thread feels cluttered and you need to distinguish useful context from baggage
117
+
118
+ When reading the timeline, ask which raw messages are still needed for the immediate next action, which paths are now baggage, and which anchor gives the smallest sufficient working set after summary injection.
119
+
120
+ ### `context_compact`
121
+
122
+ Use it to replace raw history with a state summary when the next phase would benefit from a smaller working set.
123
+
124
+ Typical compact boundaries: investigation -> execution, diagnosis -> fix, implementation -> validation, failed attempt -> next attempt, representative item -> remaining batch, completed noisy task -> a newly received user task.
125
+
126
+ Strong signals to consider compaction:
127
+
128
+ - repeated progress/status checks
129
+ - inability to summarize current state, next action, and open risks in one short paragraph
130
+ - rejected, abandoned, or superseded branches
131
+ - stable result after many tool calls or long output
132
+ - returned background/asynchronous/delegated result
133
+ - material plan or approach change
134
+ - side question arriving while stale process history is active
135
+
136
+ Do not compact while exploration is still active, when the result is unstable, just because the skill triggered, or just because the user-visible task ended.
137
+
138
+ ## Compact gate
139
+
140
+ Before calling `context_compact`, require all three:
141
+
142
+ 1. The segment being left behind is noisy, stale, failed, low-value in raw form, or actively reducing focus.
143
+ 2. You can restore the useful task state in a clear summary.
144
+ 3. There is an immediate, known continuation that benefits from cleaner context—not merely a possible user response or feedback request.
145
+
146
+ If the compact is prompted by a new user message, a direction shift, or several possible checkpoint targets, run `context_timeline` first and choose the target from visible structure rather than memory.
147
+
148
+ If the whole task is done, present the result and wait. Do not compact before or while asking for feedback, review, approval, or the user's next instruction. Compact later only after that message establishes a concrete continuation and cleanup is useful.
149
+
150
+ Checkpoint-only failure mode: a checkpoint is useful because it gives you a clean anchor to compact back to later. After any checkpointed phase produces a stable result, ask what the phase settled, whether the next step is different, and whether a summary can replace the raw trail. If yes, compact; do not keep accumulating raw history just because the overall task is still active.
151
+
152
+ ## Choosing target and backup
153
+
154
+ Choose the continuation anchor by designing the next working set:
155
+
156
+ 1. Name the immediate next action.
157
+ 2. Decide what must remain raw: active user intent, current constraints, still-open evidence/code context, an approved plan being executed, or details you expect to inspect directly next.
158
+ 3. Decide what can become state summary or disappear: completed searches, verbose logs, failed attempts, stale branches, earlier unrelated tasks, externally recoverable data, and clear process details.
159
+ 4. Pick the anchor that leaves the new branch with the **smallest sufficient context** after summary injection.
160
+ 5. If an older anchor plus a stronger summary is cleaner than a recent anchor plus stale context, prefer the older anchor. When completed fronts fill the middle of the thread, it can be correct to compact to a much older anchor or even `root` if the summary restores the active front and source pointers.
161
+
162
+ Avoid targets that are too late, too early with a weak summary, or semantically wrong. If there are several checkpoints, a task switch, or uncertainty about the best working set, run `context_timeline` first.
163
+
164
+ Use `backupCheckpoint` when raw history may still matter later. A backup is a recovery safety net, not a substitute for the summary.
165
+
166
+ ## Compact summary contract
167
+
168
+ The summary is not a transcript recap. It is the state needed to resume work from the chosen anchor; older or cleaner anchors require stronger summaries.
169
+
170
+ Context tools change conversation state, not the outside world. Files, processes, browser state, tickets, databases, remote services, and other side effects stay current. If you compact to an anchor before those changes, the summary must bridge the gap between old conversation context and current external state.
171
+
172
+ A compact summary must restore:
173
+
174
+ 1. **Task state:** current task, user intent, constraints, decisions, assumptions, known result/progress/failure, and—when relevant—deliberate shortcuts, temporary workarounds, trade-offs, known limitations, and questions still awaiting user feedback.
175
+ 2. **External state:** changed files, created/deleted artifacts, running/stopped processes, browser actions, tickets/records, deployments, remote changes.
176
+ 3. **Verification state:** commands already run, validation status, notable outputs, and remaining risks or open questions.
177
+ 4. **Navigation state:** source anchors/evidence when needed, rejected leads worth avoiding, backup checkpoint guidance, and explicit next step.
178
+
179
+ If important data has a reliable external source, preserve the pointer and retrieval method rather than copying the raw data. Examples: file path and line/query, database table/query, task/job id, log path, URL, record id, branch/commit, or command to inspect status. Include raw values only when they are small, unstable, hard to retrieve, or needed for immediate reasoning.
180
+
181
+ For long-running work, shape the summary as a state capsule: goal, stable result, decisions, rejected paths, current artifacts/source pointers, active work, pending input, risks/open questions, and next action. Include why compacting is appropriate only when it helps future orientation. Avoid vague summaries like `Done`, `Investigated`, `Switching context`, or `Going back`.
182
+
183
+ Before compacting, quickly check: stable state? real continuation? smallest sufficient working set? summary restores state after the anchor? externally recoverable data represented by pointers? external side effects and validation captured? explicit next step?
184
+
185
+ ## After compact
186
+
187
+ 1. Read the injected summary carefully and treat it as the new active state.
188
+ 2. Verify it contains enough state for the next action.
189
+ 3. Remember that disk and external systems were not rolled back; inspect current files/tools/services when state matters.
190
+ 4. If a missing detail is cheap to reconstruct from disk, tools, or source anchors, retrieve it directly.
191
+ 5. Return to the backup checkpoint only when the missing raw context cannot be reconstructed cheaply.
192
+
193
+ ## Common mistakes
194
+
195
+ Avoid:
196
+
197
+ - checkpointing constantly without phase meaning
198
+ - checkpointing early but never compacting after a stable phase result
199
+ - compacting blindly without timeline when anchor choice is unclear
200
+ - preserving too much raw history because older anchors or `root` feel risky
201
+ - using an old anchor or `root` with a weak summary
202
+ - compacting before presenting a final deliverable or while awaiting user feedback, approval, or review
203
+ - compacting immediately after a final deliverable when no next user intent is known
204
+ - carrying completed noisy phases into a new task
205
+ - treating handoff or decision prompts as final answers when a continuation is expected
206
+ - writing summaries that recap history but fail to restore current task state
207
+ - assuming compact or branch navigation reverts files, processes, browser state, or remote services
208
+ - omitting decisions, constraints, external side effects, changed files, validation status, or next step