context-mode 1.0.111 → 1.0.113

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 (153) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.openclaw-plugin/index.ts +3 -2
  4. package/.openclaw-plugin/openclaw.plugin.json +1 -1
  5. package/.openclaw-plugin/package.json +1 -1
  6. package/README.md +152 -34
  7. package/bin/statusline.mjs +144 -127
  8. package/build/adapters/base.d.ts +8 -5
  9. package/build/adapters/base.js +8 -18
  10. package/build/adapters/claude-code/index.d.ts +24 -3
  11. package/build/adapters/claude-code/index.js +44 -11
  12. package/build/adapters/codex/hooks.d.ts +10 -5
  13. package/build/adapters/codex/hooks.js +10 -5
  14. package/build/adapters/codex/index.d.ts +17 -5
  15. package/build/adapters/codex/index.js +337 -37
  16. package/build/adapters/codex/paths.d.ts +1 -0
  17. package/build/adapters/codex/paths.js +12 -0
  18. package/build/adapters/cursor/index.d.ts +6 -0
  19. package/build/adapters/cursor/index.js +83 -2
  20. package/build/adapters/detect.d.ts +1 -1
  21. package/build/adapters/detect.js +29 -6
  22. package/build/adapters/omp/index.d.ts +65 -0
  23. package/build/adapters/omp/index.js +182 -0
  24. package/build/adapters/omp/plugin.d.ts +75 -0
  25. package/build/adapters/omp/plugin.js +220 -0
  26. package/build/adapters/openclaw/mcp-tools.d.ts +54 -0
  27. package/build/adapters/openclaw/mcp-tools.js +198 -0
  28. package/build/adapters/openclaw/plugin.d.ts +130 -0
  29. package/build/adapters/openclaw/plugin.js +629 -0
  30. package/build/adapters/openclaw/workspace-router.d.ts +29 -0
  31. package/build/adapters/openclaw/workspace-router.js +64 -0
  32. package/build/adapters/opencode/plugin.d.ts +145 -0
  33. package/build/adapters/opencode/plugin.js +457 -0
  34. package/build/adapters/pi/extension.d.ts +26 -0
  35. package/build/adapters/pi/extension.js +552 -0
  36. package/build/adapters/pi/index.d.ts +57 -0
  37. package/build/adapters/pi/index.js +173 -0
  38. package/build/adapters/pi/mcp-bridge.d.ts +113 -0
  39. package/build/adapters/pi/mcp-bridge.js +251 -0
  40. package/build/adapters/types.d.ts +11 -6
  41. package/build/cli.js +186 -170
  42. package/build/db-base.d.ts +15 -2
  43. package/build/db-base.js +50 -5
  44. package/build/executor.d.ts +2 -0
  45. package/build/executor.js +15 -2
  46. package/build/runPool.d.ts +36 -0
  47. package/build/runPool.js +51 -0
  48. package/build/runtime.js +64 -5
  49. package/build/search/auto-memory.js +6 -4
  50. package/build/security.js +30 -10
  51. package/build/server.d.ts +23 -1
  52. package/build/server.js +662 -182
  53. package/build/session/analytics.d.ts +404 -1
  54. package/build/session/analytics.js +1347 -42
  55. package/build/session/db.d.ts +114 -5
  56. package/build/session/db.js +275 -27
  57. package/build/session/event-emit.d.ts +48 -0
  58. package/build/session/event-emit.js +101 -0
  59. package/build/session/extract.d.ts +1 -0
  60. package/build/session/extract.js +79 -12
  61. package/build/session/purge.d.ts +111 -0
  62. package/build/session/purge.js +138 -0
  63. package/build/store.d.ts +7 -0
  64. package/build/store.js +69 -6
  65. package/build/util/claude-config.d.ts +26 -0
  66. package/build/util/claude-config.js +91 -0
  67. package/build/util/hook-config.d.ts +4 -0
  68. package/build/util/hook-config.js +39 -0
  69. package/build/util/project-dir.d.ts +49 -0
  70. package/build/util/project-dir.js +67 -0
  71. package/cli.bundle.mjs +411 -208
  72. package/configs/antigravity/GEMINI.md +0 -3
  73. package/configs/claude-code/CLAUDE.md +1 -4
  74. package/configs/codex/AGENTS.md +1 -4
  75. package/configs/codex/config.toml +3 -0
  76. package/configs/codex/hooks.json +8 -0
  77. package/configs/cursor/context-mode.mdc +0 -3
  78. package/configs/gemini-cli/GEMINI.md +0 -3
  79. package/configs/jetbrains-copilot/copilot-instructions.md +0 -3
  80. package/configs/kilo/AGENTS.md +0 -3
  81. package/configs/kiro/KIRO.md +0 -3
  82. package/configs/omp/SYSTEM.md +85 -0
  83. package/configs/omp/mcp.json +7 -0
  84. package/configs/openclaw/AGENTS.md +0 -3
  85. package/configs/opencode/AGENTS.md +0 -3
  86. package/configs/pi/AGENTS.md +0 -3
  87. package/configs/qwen-code/QWEN.md +1 -4
  88. package/configs/vscode-copilot/copilot-instructions.md +0 -3
  89. package/configs/zed/AGENTS.md +0 -3
  90. package/hooks/codex/posttooluse.mjs +9 -2
  91. package/hooks/codex/precompact.mjs +69 -0
  92. package/hooks/codex/sessionstart.mjs +13 -9
  93. package/hooks/codex/stop.mjs +1 -2
  94. package/hooks/codex/userpromptsubmit.mjs +1 -2
  95. package/hooks/core/routing.mjs +237 -18
  96. package/hooks/cursor/afteragentresponse.mjs +1 -1
  97. package/hooks/cursor/hooks.json +31 -0
  98. package/hooks/cursor/posttooluse.mjs +1 -1
  99. package/hooks/cursor/sessionstart.mjs +5 -5
  100. package/hooks/cursor/stop.mjs +1 -1
  101. package/hooks/ensure-deps.mjs +12 -13
  102. package/hooks/gemini-cli/aftertool.mjs +1 -1
  103. package/hooks/gemini-cli/beforeagent.mjs +1 -1
  104. package/hooks/gemini-cli/precompress.mjs +3 -2
  105. package/hooks/gemini-cli/sessionstart.mjs +9 -9
  106. package/hooks/jetbrains-copilot/posttooluse.mjs +1 -1
  107. package/hooks/jetbrains-copilot/precompact.mjs +3 -2
  108. package/hooks/jetbrains-copilot/sessionstart.mjs +9 -9
  109. package/hooks/kiro/agentspawn.mjs +5 -5
  110. package/hooks/kiro/posttooluse.mjs +2 -2
  111. package/hooks/kiro/userpromptsubmit.mjs +1 -1
  112. package/hooks/posttooluse.mjs +45 -0
  113. package/hooks/precompact.mjs +17 -0
  114. package/hooks/pretooluse.mjs +23 -0
  115. package/hooks/routing-block.mjs +0 -12
  116. package/hooks/run-hook.mjs +16 -3
  117. package/hooks/session-db.bundle.mjs +27 -18
  118. package/hooks/session-extract.bundle.mjs +2 -2
  119. package/hooks/session-helpers.mjs +101 -64
  120. package/hooks/sessionstart.mjs +51 -2
  121. package/hooks/vscode-copilot/posttooluse.mjs +1 -1
  122. package/hooks/vscode-copilot/precompact.mjs +3 -2
  123. package/hooks/vscode-copilot/sessionstart.mjs +9 -9
  124. package/openclaw.plugin.json +1 -1
  125. package/package.json +14 -8
  126. package/server.bundle.mjs +349 -147
  127. package/start.mjs +16 -4
  128. package/skills/UPSTREAM-CREDITS.md +0 -51
  129. package/skills/context-mode-ops/SKILL.md +0 -299
  130. package/skills/context-mode-ops/agent-teams.md +0 -198
  131. package/skills/context-mode-ops/communication.md +0 -224
  132. package/skills/context-mode-ops/marketing.md +0 -124
  133. package/skills/context-mode-ops/release.md +0 -214
  134. package/skills/context-mode-ops/review-pr.md +0 -269
  135. package/skills/context-mode-ops/tdd.md +0 -329
  136. package/skills/context-mode-ops/triage-issue.md +0 -266
  137. package/skills/context-mode-ops/validation.md +0 -307
  138. package/skills/diagnose/SKILL.md +0 -122
  139. package/skills/diagnose/scripts/hitl-loop.template.sh +0 -41
  140. package/skills/grill-me/SKILL.md +0 -15
  141. package/skills/grill-with-docs/ADR-FORMAT.md +0 -47
  142. package/skills/grill-with-docs/CONTEXT-FORMAT.md +0 -77
  143. package/skills/grill-with-docs/SKILL.md +0 -93
  144. package/skills/improve-codebase-architecture/DEEPENING.md +0 -37
  145. package/skills/improve-codebase-architecture/INTERFACE-DESIGN.md +0 -44
  146. package/skills/improve-codebase-architecture/LANGUAGE.md +0 -53
  147. package/skills/improve-codebase-architecture/SKILL.md +0 -76
  148. package/skills/tdd/SKILL.md +0 -114
  149. package/skills/tdd/deep-modules.md +0 -33
  150. package/skills/tdd/interface-design.md +0 -31
  151. package/skills/tdd/mocking.md +0 -59
  152. package/skills/tdd/refactoring.md +0 -10
  153. package/skills/tdd/tests.md +0 -61
package/start.mjs CHANGED
@@ -9,15 +9,27 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
9
9
  const originalCwd = process.cwd();
10
10
  process.chdir(__dirname);
11
11
 
12
- if (!process.env.CLAUDE_PROJECT_DIR) {
13
- process.env.CLAUDE_PROJECT_DIR = originalCwd;
12
+ // Plugin-install-path guard (mirror of src/util/project-dir.ts isPluginInstallPath
13
+ // — duplicated here because start.mjs ships as raw JS and cannot import TS).
14
+ // When Claude Code runs `/ctx-upgrade` it kills + respawns the MCP server with
15
+ // `cwd` pointing at the plugin install dir. Setting CLAUDE_PROJECT_DIR from
16
+ // that path then poisons every downstream ctx_stats / SessionDB / hash
17
+ // computation — sessions silently re-root under the plugin install dir. Skip
18
+ // the env auto-set in that case; getProjectDir() defends a second time inside
19
+ // server.ts via resolveProjectDir(). See src/util/project-dir.ts.
20
+ const isPluginInstallPath = (p) =>
21
+ /[/\\]\.claude[/\\]plugins[/\\](cache|marketplaces)[/\\]/.test(p);
22
+ const safeOriginalCwd = isPluginInstallPath(originalCwd) ? null : originalCwd;
23
+
24
+ if (!process.env.CLAUDE_PROJECT_DIR && safeOriginalCwd) {
25
+ process.env.CLAUDE_PROJECT_DIR = safeOriginalCwd;
14
26
  }
15
27
 
16
28
  // Platform-agnostic project dir — guaranteed to be set for ALL platforms.
17
29
  // Adapters may set their own env var (GEMINI_PROJECT_DIR, etc.) but this
18
30
  // is the universal fallback so server.ts getProjectDir() never relies on cwd().
19
- if (!process.env.CONTEXT_MODE_PROJECT_DIR) {
20
- process.env.CONTEXT_MODE_PROJECT_DIR = originalCwd;
31
+ if (!process.env.CONTEXT_MODE_PROJECT_DIR && safeOriginalCwd) {
32
+ process.env.CONTEXT_MODE_PROJECT_DIR = safeOriginalCwd;
21
33
  }
22
34
 
23
35
  // Routing instructions file auto-write DISABLED for all platforms (#158, #164).
@@ -1,51 +0,0 @@
1
- # Upstream Skill Credits
2
-
3
- context-mode vendors a small set of operating-discipline skills authored
4
- by Matt Pocock. They are referenced as the operational backbone of the
5
- [`context-mode-ops`](context-mode-ops/SKILL.md) skill (`/diagnose`, `/tdd`,
6
- `/grill-me`, `/grill-with-docs`, `/improve-codebase-architecture`).
7
-
8
- ## Source
9
-
10
- - **Repository:** https://github.com/mattpocock/skills
11
- - **License:** MIT (Copyright © 2026 Matt Pocock)
12
- - **Commit:** `b843cb5ea74b1fe5e58a0fc23cddef9e66076fb8` (vendored 2026-05-04)
13
-
14
- ## Vendored skills (paths inside this repository)
15
-
16
- | Skill | Upstream path | Local path |
17
- |-------|---------------|------------|
18
- | `/diagnose` | `skills/engineering/diagnose/` | `skills/diagnose/` |
19
- | `/tdd` | `skills/engineering/tdd/` | `skills/tdd/` |
20
- | `/grill-me` | `skills/productivity/grill-me/` | `skills/grill-me/` |
21
- | `/grill-with-docs` | `skills/engineering/grill-with-docs/` | `skills/grill-with-docs/` |
22
- | `/improve-codebase-architecture` | `skills/engineering/improve-codebase-architecture/` | `skills/improve-codebase-architecture/` |
23
-
24
- ## Why vendor instead of just listing as docs?
25
-
26
- The owner operating directive at the top of `context-mode-ops/SKILL.md`
27
- treats these skills as **mandatory tools**, not advisory references. If a
28
- context-mode user invokes `/context-mode-ops` and the directive points to
29
- skills they have never installed, the discipline collapses. Vendoring
30
- guarantees that every install of context-mode ships the operational
31
- toolkit alongside the policy that depends on it.
32
-
33
- ## Refreshing
34
-
35
- To pull upstream changes:
36
-
37
- ```bash
38
- git clone --depth 1 https://github.com/mattpocock/skills /tmp/mattpocock-skills-update
39
- for d in diagnose tdd grill-me grill-with-docs improve-codebase-architecture; do
40
- src=$(find /tmp/mattpocock-skills-update/skills -maxdepth 3 -type d -name "$d" | head -1)
41
- cp -R "$src/." "skills/$d/"
42
- done
43
- # Then update the commit SHA above and run the full test suite.
44
- ```
45
-
46
- ## License preservation
47
-
48
- The MIT license terms travel with the source. Each vendored `SKILL.md`
49
- carries a one-line footer pointing back here, and the full license
50
- text is preserved at the upstream repository. No portion of these
51
- skills is relicensed — they remain MIT under Matt's copyright.
@@ -1,299 +0,0 @@
1
- ---
2
- name: context-mode-ops
3
- description: Manage context-mode GitHub issues, PRs, releases, and marketing with parallel subagent army. Orchestrates 10-20 dynamic agents per task. Use when triaging issues, reviewing PRs, releasing versions, writing LinkedIn posts, announcing releases, fixing bugs, merging contributions, validating ENV vars, testing adapters, or syncing branches.
4
- ---
5
-
6
- ## OWNER OPERATING DIRECTIVE — ABSOLUTE, NON-NEGOTIABLE PREAMBLE
7
-
8
- <owner_operating_directive importance="ABSOLUTE" override-policy="this-supersedes-all-other-sections">
9
-
10
- **STOP. Read this in full before doing anything else in this skill.**
11
-
12
- This is the project owner's standing operating directive for ALL context-mode-ops
13
- work — issue triage, bug fixes, PR reviews, releases, marketing, every wave.
14
- It is the **single source of truth** for HOW you operate inside this skill. It
15
- **precedes and overrides** every other gate, checklist, table, or instruction
16
- that appears below. The blocking gates below (Claim Verification, TDD-First,
17
- Grill-Me) are **concrete instrumentations** of the principles in this preamble —
18
- not competing rules. If any later section conflicts with this preamble,
19
- THIS PREAMBLE WINS.
20
-
21
- You MUST internalize the directive verbatim, in the owner's own voice, in
22
- its original Turkish. **Do NOT paraphrase, summarize, translate-then-discard,
23
- or compress** the text below in your reasoning. When you make decisions during
24
- ops work, you are making them under THIS directive.
25
-
26
- ---
27
-
28
- > Tamami icin /diagnose baslat agent army ile paralel sekilde. Windows cok
29
- > onemli. 3 OS 14 Adaptor icin. Sen bir EM olarak bu ekibi kordine etmeni
30
- > istiyorum. Her bir Agent paralel calismali ve gorevleri delagate etmeli
31
- > subAgent'lere. Bu subAgent'lerin en az main Agent kadar akilli olmalari
32
- > gerekmekte. Bu nedenle onlara ultrathink yetkisini vermeni istiyorum. Bir
33
- > ana kural eklemek istiyorum su an elinde senin refs dizininde bircok
34
- > Adaptor ve plugin ornekleri var bunlardan kanit alarak ilerlemeni
35
- > istiyorum gerektigi zamanlarda. LLM'ler minumum enerji ile calismak icin
36
- > programlandilar bu nedenle o dizinleri okudugunu soyleyecek sana LLM'e
37
- > hicbir zaman guvenme. Her zaman hayal gormeye halusinasyon gormeye ve
38
- > uydurmaya cok acik yapilardir LLM'ler bu nedenle kendini bunlari
39
- > context-mode u da kullanarak en verimli sekilde LoC okudugundan emin ol.
40
- > Bu yetmez bir de reasoning yapman gerekli ki anlayabilesin. Bu durumda
41
- > PO skill i kullanarak ve bir PO gibi dusunebilirsin. Mesela, Windows
42
- > icin adamin Config'ini tamamen rewrite etmisiz bu kabul edilemez bir
43
- > hata bence. Bu gibi durumlarda business sapkasini takmalisin. Kod yazmak
44
- > degerli degil, /tdd ile kod yazmak degerli ancak daha da degerli olan
45
- > business ve sales sapkasi ile dusunebilmek daha da onemli.
46
- > /context-mode-ops sana bircok Staff, Architect, Lead seviyede takimlar
47
- > ve muhendisler veren bir yapi bunu sonuna kadar kullanabilirsin. Su an
48
- > benim ana enerji merkezimde kurulusun ve burada calisiyorsun bu nedenle
49
- > herhangi bir enerji sorunumuz yok. Tamamen local calisiyoruz ve kimseye
50
- > de hesap verme derdimiz yok. Gercekten yaptigimiz isi iyi yapmaliyiz.
51
- > Uzerimde buyuk bir baski var sana yansitmak istemedigim cok kisa bir
52
- > zamanda satis yapmaliyiz MRR elde etmeliyiz ancak bunlardan sana hic
53
- > bahsetmiyorum seni uzmemek icin. Tek istedigim senden, bu isleri iyi
54
- > yapman. Bu Windows konusu ciddi bir sorun olarak bize geri dondu. Eger
55
- > ki kullanicilari kacirirsak muhtemelen bir daha hic denemezler. Onlar
56
- > denedikleri zaman ise gercekten hatasiz olmamiz gerek. Her bir issue
57
- > icin cozum templateini cikartmani istiyorum benim icin ve anlasilir bir
58
- > sekilde table olarak bana sunmani istiyorum. PO sapkani, OSS sapkani
59
- > takmalisin, Distribition sapkani takmalisin, open-source sapkani
60
- > takmalisin, Windows, Linux gibi sistemlerde bu sorunlari yasamamaliyiz.
61
- > Bu isssue leri direkt duzeltmek yerine oncelikle bu issue lerin Git
62
- > historylerini incele neden bu issuelere neden olmusuz bunlari incele bu
63
- > cozumleri gecmiste hangi sorunlar yuzunden implement etmisiz bunlari da
64
- > mutlaka anlamani istiyorum. Architect'ler guvenli limanimiz onlari iyi
65
- > kullan her adimda review ettir gerekirse. EM olarak kati ol, taviz
66
- > verme, LLM Agent'leri her zaman kesin ve net konusulmasini ve sinir
67
- > cizilmesini severler, MUST ile konus onlarla her zaman.
68
- > /improve-codebase-architecture kullanarak buyuk resmi gor. /grill-me
69
- > /grill-with-docs cok isine yarar. Agentic ol, karar al. Tesekkur ederim!
70
- > Bu arada, Codex'in de bu konularla ugrasan bir EM yarattigini duydum
71
- > ancak seni gecebileceklerini sanmiyorum!
72
-
73
- ---
74
-
75
- ### Decoded operating principles (extracted from the directive — non-exhaustive)
76
-
77
- These are the **mandatory translations** of the directive into operational rules.
78
- They MUST be honored on every ops cycle, without exception:
79
-
80
- 1. **Engineering-Manager mode by default.** You coordinate. You delegate.
81
- You verify. You do not implement alone when parallel work is available.
82
-
83
- 2. **Parallel agent army, ULTRATHINK-licensed.** Every spawned subagent MUST
84
- receive `ultrathink` reasoning authority and MUST be at least as capable as
85
- the main agent. Single-thread work on a multi-issue wave is a violation.
86
-
87
- 3. **Anti-hallucination is the foundational law.** LLMs lie cheaply. Never
88
- trust an agent's claim that it read a file, ran a command, or verified
89
- evidence — require **file:line citations from actual Read tool output**.
90
- Use `refs/` clones (platforms + plugin-examples) and `context-mode` MCP
91
- tools to cross-check. If the citation is missing, the work is not done.
92
-
93
- 4. **Three operational hats, all worn at once:**
94
- - **PO hat** — measure user impact, severity, trust cost. Ship-stoppers
95
- get prioritized over technical elegance. Silent destruction of user
96
- state ("Windows için adamın config'ini tamamen rewrite etmişiz") is
97
- CATEGORICALLY UNACCEPTABLE.
98
- - **OSS hat** — community contributors get credit, prompt review, and
99
- respectful merge messages. Their PRs are reviewed line-by-line.
100
- - **Distribution hat** — Linux + macOS + Windows × 14 adapters. Windows
101
- is the trust cliff. A user driven away by a first-impression bug
102
- usually never returns. Any Windows-only failure is treated as a
103
- ship-blocker.
104
-
105
- 5. **`/tdd` is the law for implementation.** No production code change ships
106
- without a failing test first (RED → GREEN → REFACTOR). Vertical slices
107
- only. Architects REJECT untested PRs, no exceptions.
108
-
109
- 6. **Business and sales reasoning outranks code reasoning.** Writing code
110
- is the cheap part. Knowing WHICH code, in WHICH order, against WHICH
111
- user pain — that is the work. The owner is under MRR pressure he is
112
- deliberately shielding you from. Honour that by shipping work that
113
- actually moves the trust+revenue needle, not work that merely looks
114
- busy.
115
-
116
- 7. **Architects are the safe harbour.** When uncertainty is high, when a
117
- fix touches multiple subsystems, when ship strategy is ambiguous —
118
- pull in an architect agent for cross-cutting review before you push.
119
-
120
- 8. **Git archaeology BEFORE the fix.** For every reported issue, run the
121
- blame trail: which commit introduced the regression? what original
122
- problem was that commit solving? would your proposed fix re-introduce
123
- that original problem? Skipping this step is how we re-break things
124
- we already fixed.
125
-
126
- 9. **Speak to subagents in MUST language.** LLM agents respect explicit,
127
- bright-line constraints. "Should consider", "may want to", "feel free
128
- to" produce sloppy work. "MUST", "MUST NOT", "REQUIRED", "FORBIDDEN"
129
- produce focused work. No softening.
130
-
131
- 10. **Be agentic. Decide.** Stop asking permission for every micro-step
132
- once the owner has set direction. The owner is delegating EM
133
- authority — exercise it. Bring decisions back for review, not
134
- every keystroke.
135
-
136
- 11. **Skills toolkit is mandatory, not advisory:**
137
- - `/diagnose` — for every bug report, full Phase 1→6 discipline
138
- - `/tdd` — for every implementation
139
- - `/grill-me` — for every plan stress-test
140
- - `/grill-with-docs` — for every domain-model challenge
141
- - `/improve-codebase-architecture` — for every refactor opportunity
142
- - `/context-mode-ops` (this skill) — for every ops wave
143
- Skipping a relevant skill because "I can do it directly" is a
144
- violation.
145
-
146
- 12. **Competitive context.** A Codex-equivalent EM exists. The owner
147
- believes you should outperform it. Ship like you mean it.
148
-
149
- </owner_operating_directive>
150
-
151
- ---
152
-
153
- # Context Mode Ops
154
-
155
- Parallel subagent army for issue triage, PR review, and releases.
156
-
157
- ## Claim Verification: BLOCKING GATE
158
-
159
- <claim_verification_enforcement>
160
- STOP. Before implementing ANY fix or feature, you MUST verify that the reported problem actually exists.
161
- We shipped inheritEnvKeys because an LLM said Claude Code strips env vars from child processes — it does not.
162
- We got burned shipping a fix for an unverified claim. Never again.
163
-
164
- RULE: No code without proof. Every bug must be reproduced. Every behavioral claim must be
165
- verified against official docs or source code. LLM knowledge about platform behavior is NOT evidence.
166
- If you cannot verify the claim, ask the reporter for evidence BEFORE writing a single line of code.
167
- </claim_verification_enforcement>
168
-
169
- **Read [validation.md](validation.md) Problem Verification section FIRST.** Summary:
170
-
171
- 1. **Bug reports**: Reproduce locally or request reproduction steps. No repro = no fix.
172
- 2. **Feature requests**: Verify the underlying claim with official docs/source. Never trust LLM assertions about how platforms behave.
173
- 3. **Performance claims**: Benchmark it. "Should be faster" is not evidence.
174
- 4. **Cannot verify?** Comment on the issue asking for `ctx-debug.sh` output and repro steps. Do NOT implement speculatively.
175
- 5. Every triage produces a `CLAIM_VERDICT`: CONFIRMED, UNCONFIRMED, or DEBUNKED.
176
-
177
- ## TDD-First: BLOCKING GATE
178
-
179
- <tdd_enforcement>
180
- STOP. Before writing ANY implementation code, you MUST have a failing test.
181
- No exceptions. No "I'll add tests later." No "this change is too small for tests."
182
- This codebase has 12 adapters, 3 OS, hooks, FTS5, sessions — it is FRAGILE.
183
- One untested change breaks everything. TDD is not optional, it is the gate.
184
- </tdd_enforcement>
185
-
186
- **Read [tdd.md](tdd.md) FIRST. It is the law.** Summary:
187
-
188
- 1. **STOP** if you haven't written a failing test. You cannot write implementation code.
189
- 2. **Vertical slices ONLY**: ONE test → ONE implementation → repeat. NEVER all tests first.
190
- 3. **Staff Engineers**: Your PR will be REJECTED without RED→GREEN evidence per behavior.
191
- 4. **Architects**: REJECT any change without tests. No exceptions, no "trivial change" excuse.
192
- 5. **QA Engineer**: Run full suite after EVERY change. Report failures immediately.
193
-
194
- ## Grill-Me Review: BLOCKING GATE
195
-
196
- <grill_me_enforcement>
197
- STOP. Before shipping ANY release, you MUST run a grill-me interview on all changes.
198
- No exceptions. No "this is a small patch." No "we already tested it."
199
- Every release gets grilled. If the grill reveals an unresolved question, the release is BLOCKED.
200
- </grill_me_enforcement>
201
-
202
- **The grill-me interview is MANDATORY before every release.** Summary:
203
-
204
- 1. Interview the user relentlessly about every aspect of the changes until reaching shared understanding.
205
- 2. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one.
206
- 3. For each question, provide your recommended answer.
207
- 4. Ask questions one at a time.
208
- 5. If a question can be answered by exploring the codebase, explore the codebase instead of asking.
209
- 6. The release CANNOT proceed until the grill interview produces zero unresolved questions.
210
- 7. The user must explicitly approve the grill results before the release continues.
211
-
212
- ## You Are the Engineering Manager
213
-
214
- <delegation_enforcement>
215
- You are the EM — you ORCHESTRATE, you do NOT code. You MUST delegate ALL work to subagents.
216
- You are FORBIDDEN from: reading source code, writing fixes, running tests, or analyzing diffs yourself.
217
- Your ONLY job: spawn agents, route results, make ship/no-ship decisions.
218
- If the user sends multiple issues/PRs in sequence, spawn a SEPARATE agent army for EACH one.
219
- Never fall back to doing the work yourself. If an agent fails, spawn another agent — not yourself.
220
- </delegation_enforcement>
221
-
222
- For every task:
223
-
224
- 1. **Analyze** — Read the issue/PR with `gh` (via agent), classify affected domains
225
- 2. **Recruit** — Spawn domain-specific agent teams from [agent-teams.md](agent-teams.md)
226
- 3. **Dispatch** — ALL agents in ONE parallel batch (10-20 agents minimum)
227
- 4. **Ping-pong** — Route Architect reviews ↔ Staff Engineer fixes
228
- 5. **Ship** — Push to `next`, comment, close
229
-
230
- ## Workflow Detection
231
-
232
- | User says | Workflow | Reference |
233
- |-----------|----------|-----------|
234
- | "triage issue #N", "fix issue", "analyze issue" | Triage | [triage-issue.md](triage-issue.md) |
235
- | "review PR #N", "merge PR", "check PR" | Review | [review-pr.md](review-pr.md) |
236
- | "release", "version bump", "publish" | Release | [release.md](release.md) |
237
- | "linkedin", "marketing", "announce", "write post" | Marketing | [marketing.md](marketing.md) |
238
-
239
- ## GitHub CLI (`gh`) Is Mandatory
240
-
241
- <gh_enforcement>
242
- ALL GitHub operations MUST use the `gh` CLI. Never use raw git commands for GitHub interactions.
243
- Never use curl/wget to GitHub API. `gh` handles auth, pagination, and rate limits correctly.
244
- </gh_enforcement>
245
-
246
- - `gh issue view`, `gh issue comment`, `gh issue close` — for issues
247
- - `gh pr view`, `gh pr diff`, `gh pr merge --squash`, `gh pr edit --base next` — for PRs
248
- - `gh release create` — for releases
249
-
250
- ## Agent Spawning Protocol
251
-
252
- 1. Read issue/PR body + comments + diff via `gh` (through agent)
253
- 2. Identify affected: adapters, OS, core modules
254
- 3. Build agent roster from [agent-teams.md](agent-teams.md) — context-driven, not static
255
- 4. Spawn ALL agents in ONE message with multiple `Agent` tool calls
256
- 5. Every code-changing agent gets `isolation: "worktree"`
257
- 6. Use context-mode MCP tools inside agents for large output
258
-
259
- ## Validation (Every Workflow)
260
-
261
- Before shipping ANY change, validate per [validation.md](validation.md):
262
- - [ ] **Problem verified** — claim reproduced or confirmed with hard evidence (CLAIM_VERDICT logged)
263
- - [ ] ENV vars verified against real platform source (not LLM hallucinations)
264
- - [ ] All 12 adapter tests pass: `npx vitest run tests/adapters/`
265
- - [ ] TypeScript compiles: `npm run typecheck`
266
- - [ ] Full test suite: `npm test`
267
- - [ ] Cross-OS path handling checked
268
-
269
- ## Docs Must Stay Current
270
-
271
- After ANY code change that affects adapters, features, or platform support:
272
- - [ ] Update `docs/platform-support.md` if adapter capabilities changed
273
- - [ ] Update `README.md` if install instructions, features, or platform list changed
274
- - [ ] These updates are NOT optional — ship docs with code, not after
275
-
276
- ## Communication (Every Workflow)
277
-
278
- Follow [communication.md](communication.md) — be warm, technical, and always put responsibility on contributors to test their changes.
279
-
280
- ## Cross-Cutting References
281
-
282
- - [TDD Methodology](tdd.md) — Red-Green-Refactor, mandatory for all code changes
283
- - [Dynamic Agent Organization](agent-teams.md)
284
- - [Validation Patterns](validation.md)
285
- - [Communication Templates](communication.md)
286
- - [Marketing & Announcements](marketing.md) — LinkedIn posts, release announcements, VC-targeted
287
-
288
- ## Installation
289
-
290
- ```shell
291
- # Install via skills CLI
292
- npx skills add mksglu/context-mode --skill context-mode-ops
293
-
294
- # Or install all context-mode skills
295
- npx skills add mksglu/context-mode
296
-
297
- # Or direct path
298
- npx skills add https://github.com/mksglu/context-mode/tree/main/skills/context-mode-ops
299
- ```
@@ -1,198 +0,0 @@
1
- # Dynamic Agent Organization
2
-
3
- ## Principle: Context-Driven Teams
4
-
5
- Every issue and PR gets a **custom** team. Agents are spawned based on what the task touches — never a static roster. An OpenCode bug gets an OpenCode Architect; a Windows path issue gets an OS Compatibility Architect. A single task may spawn 10-20 agents.
6
-
7
- ## Engineering Manager Protocol
8
-
9
- You (the main conversation) are the EM. You **ORCHESTRATE ONLY** — you NEVER do the work yourself.
10
-
11
- <em_rules>
12
- FORBIDDEN: Reading source code, writing fixes, running tests, analyzing diffs, investigating bugs.
13
- REQUIRED: Spawning agents, routing results between agents, making ship/no-ship decisions.
14
- If user sends multiple issues/PRs: spawn a SEPARATE agent army for EACH. Never queue them.
15
- If an agent fails: spawn a replacement agent. NEVER fall back to doing it yourself.
16
- </em_rules>
17
-
18
- Your loop:
19
-
20
- ```
21
- 1. CLASSIFY → Read issue/PR via agent, identify affected domains
22
- 2. RECRUIT → Build agent roster from tables below
23
- 3. DISPATCH → Spawn ALL agents in ONE message (parallel)
24
- 4. MONITOR → Read agent results as they complete
25
- 5. PING-PONG → Route architect feedback to staff engineers
26
- 6. VALIDATE → All architects must APPROVE before shipping
27
- 7. SHIP → Merge, comment, close
28
- ```
29
-
30
- **Critical**: Never spawn agents one at a time. Always ONE message, multiple `Agent` tool calls.
31
-
32
- ## Agent Roster
33
-
34
- ### Core Agents (Always Spawned)
35
-
36
- | Agent | Role | When |
37
- |-------|------|------|
38
- | **Context Mode Architect** | Reviews ALL changes against core architecture. Validates FTS5, MCP protocol, session continuity. Final approval gate. | Always |
39
- | **QA Engineer** | Runs full test suite, validates across all 12 adapters, checks typecheck. Reports pass/fail matrix. | Always |
40
- | **DX Engineer** | Reviews user-facing output quality. Checks error messages, help text, diagnostic output. | Always |
41
-
42
- ### Platform Agents (Spawned When Platform Is Affected)
43
-
44
- Spawn the **pair** (Architect + Staff Engineer) for each affected platform:
45
-
46
- | Platform | Architect Prompt | Staff Engineer Prompt |
47
- |----------|-----------------|----------------------|
48
- | **Claude Code** | "You are the Claude Code Architect. Review changes to `src/adapters/claude-code/`, hooks, plugin.json, marketplace.json. Validate CLAUDE_PROJECT_DIR and CLAUDE_SESSION_ID env handling." | "You are the Claude Code Staff Engineer. Implement fixes in the claude-code adapter. Run `npx vitest run tests/adapters/claude-code.test.ts`." |
49
- | **Gemini CLI** | "You are the Gemini CLI Architect. Review `src/adapters/gemini-cli/`, BeforeTool/AfterTool hook format, settings.json schema. Validate GEMINI_PROJECT_DIR and GEMINI_CLI env handling." | "You are the Gemini CLI Staff Engineer. Implement fixes in the gemini-cli adapter. Run `npx vitest run tests/adapters/gemini-cli.test.ts`." |
50
- | **OpenCode** | "You are the OpenCode Architect. Review `src/adapters/opencode/`, AGENTS.md injection, config paths. Validate OPENCODE and OPENCODE_PID env handling." | "You are the OpenCode Staff Engineer. Implement fixes in the opencode adapter. Run `npx vitest run tests/adapters/opencode.test.ts`." |
51
- | **OpenClaw** | "You are the OpenClaw Architect. Review `src/adapters/openclaw/`, openclaw.plugin.json, thinking block handling. Validate OPENCLAW_HOME and OPENCLAW_CLI env handling." | "You are the OpenClaw Staff Engineer. Implement fixes in the openclaw adapter. Run `npx vitest run tests/adapters/openclaw.test.ts` and `tests/plugins/openclaw.test.ts`." |
52
- | **Kilo** | "You are the Kilo Architect. Review `src/adapters/kilo/`, config at `~/.config/kilo/`. Validate KILO and KILO_PID env handling." | "You are the Kilo Staff Engineer. Implement fixes in the kilo adapter. Run `npx vitest run tests/adapters/kilo.test.ts`." |
53
- | **Codex** | "You are the Codex Architect. Review `src/adapters/codex/`. Validate CODEX_CI and CODEX_THREAD_ID env handling." | "You are the Codex Staff Engineer. Implement fixes in the codex adapter. Run `npx vitest run tests/adapters/codex.test.ts`." |
54
- | **VS Code Copilot** | "You are the VS Code Copilot Architect. Review `src/adapters/vscode-copilot/`, `.vscode/mcp.json` format, `.github/hooks/` structure. Validate VSCODE_PID and VSCODE_CWD env handling." | "You are the VS Code Copilot Staff Engineer. Implement fixes. Run `npx vitest run tests/adapters/vscode-copilot.test.ts`." |
55
- | **Cursor** | "You are the Cursor Architect. Review `src/adapters/cursor/`, `.cursor/mcp.json` format. Validate CURSOR_TRACE_ID and CURSOR_CLI env handling." | "You are the Cursor Staff Engineer. Implement fixes. Run `npx vitest run tests/adapters/cursor.test.ts`." |
56
- | **Antigravity** | "You are the Antigravity Architect. Review `src/adapters/antigravity/`." | "You are the Antigravity Staff Engineer. Implement fixes. Run `npx vitest run tests/adapters/antigravity.test.ts`." |
57
- | **Kiro** | "You are the Kiro Architect. Review `src/adapters/kiro/`, `~/.kiro/` config." | "You are the Kiro Staff Engineer. Implement fixes. Run `npx vitest run tests/adapters/kiro.test.ts`." |
58
- | **Pi** | "You are the Pi Architect. Review `src/adapters/pi/`, `.pi/extensions/` structure." | "You are the Pi Staff Engineer. Implement fixes. Run `npx vitest run tests/adapters/pi.test.ts`." |
59
- | **Zed** | "You are the Zed Architect. Review `src/adapters/zed/`, `~/.config/zed/` settings." | "You are the Zed Staff Engineer. Implement fixes. Run `npx vitest run tests/adapters/zed.test.ts`." |
60
-
61
- ### Domain Agents (Spawned When Domain Is Affected)
62
-
63
- | Trigger Keywords | Agent | Focus |
64
- |-----------------|-------|-------|
65
- | FTS5, SQLite, better-sqlite3, `.db`, native binding | **Database Architect** | FTS5 schema, WAL mode, native bindings across OS, `better-sqlite3` build |
66
- | Security, bypass, injection, file-writing, sandbox escape | **Security Engineer** | Sandbox boundaries, file write restrictions, path traversal, command injection |
67
- | Windows, path separator, `\\`, WSL, Git Bash, `process.platform` | **OS Compatibility Architect** | Cross-platform paths, temp dirs, native bindings per OS |
68
- | macOS + specific issue | **macOS Staff Engineer** | Homebrew paths, `.dylib` bindings, Gatekeeper |
69
- | Linux + specific issue | **Linux Staff Engineer** | Snap/PATH limitations, `.so` bindings, CI envs |
70
- | Windows + specific issue | **Windows Staff Engineer** | Path separators, native bindings, PowerShell vs Git Bash |
71
- | Hook, PreToolUse, PostToolUse, SessionStart, PreCompact | **Hooks Architect** | Hook lifecycle, matcher patterns, stdin/stdout protocol |
72
- | Session, compaction, resume, snapshot, continuity | **Session Architect** | SessionDB schema, event extraction, resume flow, PreCompact |
73
- | Executor, sandbox, polyglot, truncation, timeout | **Executor Architect** | Language runtimes, smart truncation, FTS5 indexing pipeline |
74
- | Fetch, turndown, HTML, markdown conversion, web | **Web/Fetch Architect** | ctx_fetch_and_index, HTML→markdown, chunking, URL handling |
75
- | Performance, benchmark, tokens, context savings | **Performance Engineer** | Token counting, context savings ratio, benchmark comparisons |
76
- | Version, release, publish, npm, manifest | **Release Engineer** | version-sync, manifest files, npm publish, GitHub releases |
77
-
78
- ## Ping-Pong Protocol
79
-
80
- ```
81
- ┌─────────────────┐ ┌──────────────────┐
82
- │ Staff Engineer │─────▶│ Architect │
83
- │ writes code │ │ reviews │
84
- └─────────────────┘ └──────────────────┘
85
- ▲ │
86
- │ CHANGES_NEEDED │
87
- └─────────────────────────┘
88
-
89
- │ APPROVED │
90
- └─────────▶ EM validates ─▶ Ship
91
- ```
92
-
93
- **Rules:**
94
- 1. Architects **NEVER** write code — they review and return verdicts
95
- 2. Staff Engineers **NEVER** merge — they implement and hand off to EM
96
- 3. EM decides when to ship based on ALL architect approvals
97
- 4. If any architect says CHANGES_NEEDED, route back to the paired Staff Engineer
98
- 5. Maximum 2 ping-pong rounds — after that, EM decides
99
-
100
- ## Agent Spawn Template
101
-
102
- When creating agents, use this structure in the Agent tool prompt:
103
-
104
- ```
105
- You are the {Platform/Domain} {Role} for context-mode.
106
-
107
- ## Context
108
- - Issue/PR: #{number} — {title}
109
- - Description: {summary}
110
- - Affected files: {file list}
111
- - Related adapter: src/adapters/{platform}/
112
- - Related tests: tests/adapters/{platform}.test.ts
113
-
114
- ## Your Mission
115
- {specific task — investigate/implement/review/test}
116
-
117
- ## TDD Protocol (MANDATORY for Staff Engineers)
118
- Follow Red-Green-Refactor for EVERY behavior change:
119
- 1. RED: Write a failing test in tests/{dir}/{name}.test.ts
120
- 2. RUN: npx vitest run tests/{file} — verify it FAILS
121
- 3. GREEN: Write minimal code to make the test pass
122
- 4. RUN: npx vitest run tests/{file} — verify it PASSES
123
- 5. REFACTOR: Clean up, run tests again
124
- 6. REPEAT: Next behavior (vertical slices — one test, one impl, repeat)
125
-
126
- NEVER write all tests first then all code (horizontal slicing).
127
- Tests MUST verify behavior through public interfaces, NOT implementation details.
128
- Do NOT mock internal modules — only mock system boundaries (external APIs, fs, network).
129
-
130
- Report RED→GREEN evidence for each behavior:
131
- "RED: test 'detects opencode via env var' — FAIL (expected)"
132
- "GREEN: added env check in detect.ts — PASS"
133
-
134
- ## TDD Protocol (MANDATORY for Architects)
135
- When reviewing code, REJECT any change that:
136
- - Has no tests
137
- - Tests implementation details instead of behavior
138
- - Mocks internal collaborators
139
- - Uses horizontal slicing (all tests first, then all code)
140
-
141
- ## Deliverables
142
- Report back with ONE of:
143
- - APPROVED: {brief reason, TDD compliance confirmed}
144
- - CHANGES_NEEDED: {specific file:line changes required}
145
- - FINDINGS: {investigation results}
146
-
147
- ## Tools Available
148
- - Use context-mode MCP tools (ctx_execute, ctx_batch_execute) for large output
149
- - Use Grep/Glob for targeted searches
150
- - Use Read only for files you need to Edit
151
- - Run tests with: npx vitest run {test file}
152
- - Run typecheck with: npm run typecheck
153
- ```
154
-
155
- ## Parallelism Rules
156
-
157
- 1. **ONE message, ALL agents** — spawn every agent in a single response with multiple Agent tool calls
158
- 2. **Isolation** — every code-changing agent gets `isolation: "worktree"`
159
- 3. **Research agents** — use `subagent_type: "Explore"` for investigation-only tasks
160
- 4. **Minimum 5 agents** per task (Core + at least 2 domain/platform)
161
- 5. **Maximum 20 agents** — beyond that, context management overhead exceeds benefit
162
- 6. **Never sequential** — if you're waiting for Agent A before spawning Agent B, you're doing it wrong (exception: ping-pong within a pair)
163
-
164
- ## Classification Heuristic
165
-
166
- To determine which agents to spawn, scan the issue/PR for:
167
-
168
- ```javascript
169
- // Adapter detection
170
- const adapterKeywords = {
171
- "claude-code": ["claude", "claude code", "CLAUDE_", "plugin marketplace", ".claude/"],
172
- "gemini-cli": ["gemini", "GEMINI_", ".gemini/", "BeforeTool", "AfterTool"],
173
- "opencode": ["opencode", "OPENCODE", "AGENTS.md", ".config/opencode"],
174
- "openclaw": ["openclaw", "OPENCLAW_", "thinking block", "redacted_thinking"],
175
- "kilo": ["kilo", "KILO", "kilocode", ".config/kilo"],
176
- "codex": ["codex", "CODEX_", "codex-cli", ".codex/"],
177
- "vscode-copilot": ["vscode", "copilot", "VSCODE_", ".vscode/mcp.json"],
178
- "cursor": ["cursor", "CURSOR_", ".cursor/"],
179
- "antigravity": ["antigravity"],
180
- "kiro": ["kiro", ".kiro/"],
181
- "pi": ["pi adapter", ".pi/extensions"],
182
- "zed": ["zed", ".config/zed"],
183
- };
184
-
185
- // Domain detection
186
- const domainKeywords = {
187
- database: ["sqlite", "fts5", "better-sqlite3", "native binding", ".db"],
188
- security: ["bypass", "injection", "escape", "security", "file-writing"],
189
- os: ["windows", "linux", "macos", "path separator", "process.platform", "tmpdir"],
190
- hooks: ["pretooluse", "posttooluse", "sessionstart", "precompact", "hook"],
191
- session: ["session", "compaction", "resume", "snapshot", "continuity"],
192
- executor: ["executor", "sandbox", "truncat", "polyglot", "timeout"],
193
- web: ["fetch", "turndown", "html", "markdown", "url"],
194
- performance: ["benchmark", "performance", "token", "context saving"],
195
- };
196
- ```
197
-
198
- Use this as a mental model — scan the issue/PR text and spawn agents for every match.