@wrongstack/core 0.306.4 → 0.307.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/chronicle/index.js +957 -953
  2. package/dist/chronicle/metrics-ingest.d.ts +55 -0
  3. package/dist/chronicle/metrics-schema.d.ts +86 -0
  4. package/dist/chronicle/metrics-store.d.ts +5 -120
  5. package/dist/chronicle/project-server.js +1083 -1084
  6. package/dist/chronicle/sqlite-journal-quota.d.ts +39 -0
  7. package/dist/chronicle/sqlite-journal-schema.d.ts +25 -0
  8. package/dist/chronicle/sqlite-journal.d.ts +12 -177
  9. package/dist/coordination/agents/index.js +1738 -1690
  10. package/dist/coordination/agents/project-agent-capture.d.ts +48 -0
  11. package/dist/coordination/agents/project-agent-identity.d.ts +3 -129
  12. package/dist/coordination/agents/project-agent-roster.d.ts +17 -0
  13. package/dist/coordination/index.js +6011 -5894
  14. package/dist/coordination/mail-tools.d.ts +1 -1
  15. package/dist/coordination/mailbox-http-actor-query.d.ts +16 -0
  16. package/dist/coordination/mailbox-http-router.d.ts +0 -48
  17. package/dist/coordination/mailbox-http-sse.d.ts +12 -0
  18. package/dist/coordination/mailbox-message-types.d.ts +71 -0
  19. package/dist/coordination/mailbox-predicates.d.ts +13 -0
  20. package/dist/coordination/mailbox-project-server.js +1 -1
  21. package/dist/coordination/mailbox-session-sync.d.ts +8 -0
  22. package/dist/coordination/mailbox-types.d.ts +6 -793
  23. package/dist/core/agent-loop-context.d.ts +28 -0
  24. package/dist/core/agent-loop-detector.d.ts +25 -0
  25. package/dist/core/fallback-doctor.d.ts +72 -0
  26. package/dist/core/index.d.ts +1 -0
  27. package/dist/core/index.js +1159 -888
  28. package/dist/defaults/index.js +3579 -3545
  29. package/dist/execution/autonomy-brain-llm.d.ts +55 -0
  30. package/dist/execution/autonomy-brain.d.ts +3 -156
  31. package/dist/execution/compaction-budget.d.ts +38 -0
  32. package/dist/execution/compaction-core.d.ts +3 -170
  33. package/dist/execution/compaction-elision.d.ts +58 -0
  34. package/dist/execution/council-orchestrator-helpers.d.ts +39 -0
  35. package/dist/execution/council-orchestrator.d.ts +3 -42
  36. package/dist/execution/council-response-parser.d.ts +56 -0
  37. package/dist/execution/index.js +2415 -2443
  38. package/dist/execution/prompt-enhancer.js +11 -3
  39. package/dist/execution/tool-executor-guard.d.ts +18 -0
  40. package/dist/execution/tool-executor-runner.d.ts +12 -0
  41. package/dist/execution/tool-executor.d.ts +0 -75
  42. package/dist/goal/index.js +19 -6
  43. package/dist/hq/index.js +8 -2
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +7813 -7292
  46. package/dist/infrastructure/index.js +3 -1
  47. package/dist/kernel/events/agent-events.d.ts +2 -0
  48. package/dist/kernel/events/provider-events.d.ts +13 -0
  49. package/dist/plugin/index.js +2590 -2561
  50. package/dist/plugins/auto-review-config.d.ts +53 -0
  51. package/dist/plugins/auto-review-git.d.ts +19 -0
  52. package/dist/plugins/auto-review-plugin.d.ts +2 -140
  53. package/dist/plugins/review-finding-verification.d.ts +7 -0
  54. package/dist/prompts/index.d.ts +1 -0
  55. package/dist/prompts/prompt-journal.d.ts +94 -0
  56. package/dist/security/index.js +627 -652
  57. package/dist/security/permission-explain.d.ts +19 -0
  58. package/dist/security/permission-policy.d.ts +0 -101
  59. package/dist/security/yolo-risk.d.ts +5 -4
  60. package/dist/session-catalog/index.js +220 -212
  61. package/dist/session-catalog/project-server.js +227 -219
  62. package/dist/session-catalog/store-rebuild.d.ts +9 -0
  63. package/dist/session-catalog/store-schema.d.ts +48 -0
  64. package/dist/session-catalog/store.d.ts +0 -17
  65. package/dist/storage/director-state.d.ts +6 -0
  66. package/dist/storage/file-session-writer.d.ts +2 -58
  67. package/dist/storage/index.d.ts +2 -1
  68. package/dist/storage/index.js +2057 -1925
  69. package/dist/storage/orphan-lock-cleaner.d.ts +15 -0
  70. package/dist/storage/session-recovery.d.ts +9 -0
  71. package/dist/storage/session-store/rename-session.d.ts +16 -0
  72. package/dist/storage/session-store/resume-session.d.ts +26 -0
  73. package/dist/storage/session-store/session-store-clear.d.ts +11 -0
  74. package/dist/storage/session-store/session-store-index.d.ts +13 -0
  75. package/dist/storage/session-store.d.ts +1 -129
  76. package/dist/storage/session-summary-tracker.d.ts +39 -0
  77. package/dist/storage/session-write-buffer.d.ts +43 -0
  78. package/dist/storage/session-writer/session-writer-flush.d.ts +4 -0
  79. package/dist/storage/session-writer/session-writer-summary-tracker.d.ts +28 -0
  80. package/dist/tools/fallback-agent-model-assign-tool.d.ts +18 -0
  81. package/dist/tools/fallback-leader-model-set-tool.d.ts +18 -0
  82. package/dist/tools/fallback-manage-tools.d.ts +8 -45
  83. package/dist/tools/fallback-profile-manage-tool.d.ts +16 -0
  84. package/dist/tools/fallback-provider-key-set-tool.d.ts +17 -0
  85. package/dist/tools/fallback-provider-manage-tool.d.ts +26 -0
  86. package/dist/tools/index.js +5070 -5071
  87. package/dist/types/config/root.d.ts +7 -2
  88. package/dist/types/default-config.d.ts +1 -1
  89. package/dist/types/index.d.ts +54 -55
  90. package/dist/types/index.js +953 -932
  91. package/dist/types/runtime-capability-manifest.d.ts +5 -5
  92. package/dist/types/session-markers.d.ts +12 -0
  93. package/dist/types/session-markers.js +19 -0
  94. package/dist/worktree/worktree-manager.d.ts +1 -1
  95. package/instructions/coordination/subagent-baseline.md +2 -2
  96. package/instructions/llm/prompt-enhancer.md +2 -1
  97. package/instructions/sections/tool/common-patterns.md +21 -0
  98. package/instructions/sections/tool/delegation-compact.md +3 -1
  99. package/instructions/sections/tool/delegation-full.md +5 -1
  100. package/instructions/system-lite.md +28 -3
  101. package/instructions/system-pro.md +37 -8
  102. package/instructions/system.md +4 -2
  103. package/package.json +5 -5
@@ -24,12 +24,12 @@ export declare const RUNTIME_CAPABILITY_MANIFEST: readonly [{
24
24
  readonly id: 'code.inspect';
25
25
  readonly pack: 'core';
26
26
  readonly exposure: 'direct';
27
- readonly tools: readonly ["codebase-stats", "codebase-search", "codebase-incoming-calls", "codebase-outgoing-calls", "codebase-index", "dead-code-scan", "diff", "json", "logs"];
27
+ readonly tools: readonly ["codebase-stats", "codebase-search", "codebase-incoming-calls", "codebase-outgoing-calls", "codebase-index", "codebase-skeleton", "codebase-repo-map", "codebase-impact-analysis", "dead-code-scan", "diff", "json", "logs"];
28
28
  }, {
29
29
  readonly id: 'filesystem.write';
30
30
  readonly pack: 'development';
31
31
  readonly exposure: 'direct';
32
- readonly tools: readonly ["write", "edit", "replace", "patch"];
32
+ readonly tools: readonly ["write", "edit", "replace", "patch", "codebase-ast-replace"];
33
33
  }, {
34
34
  readonly id: 'execution.shell';
35
35
  readonly pack: 'development';
@@ -39,7 +39,7 @@ export declare const RUNTIME_CAPABILITY_MANIFEST: readonly [{
39
39
  readonly id: 'verification.run';
40
40
  readonly pack: 'development';
41
41
  readonly exposure: 'direct';
42
- readonly tools: readonly ["lint", "format", "typecheck", "test", "e2e_plan"];
42
+ readonly tools: readonly ["lint", "format", "typecheck", "test", "e2e_plan", "codebase-targeted-test"];
43
43
  }, {
44
44
  readonly id: 'version-control.manage';
45
45
  readonly pack: 'development';
@@ -127,7 +127,7 @@ export declare const RUNTIME_CAPABILITY_MANIFEST: readonly [{
127
127
  readonly id: 'quality.analyze';
128
128
  readonly pack: 'development';
129
129
  readonly exposure: 'on-demand';
130
- readonly tools: readonly ["dead_code_scan", "detect_duplicate_code", "secret_scanner_test", "error_lens_history"];
130
+ readonly tools: readonly ["dead_code_scan", "detect_duplicate_code", "secret_scanner_test", "error_lens_history", "security-ast-scan"];
131
131
  }, {
132
132
  readonly id: 'release.manage';
133
133
  readonly pack: 'development';
@@ -142,7 +142,7 @@ export declare const RUNTIME_CAPABILITY_MANIFEST: readonly [{
142
142
  readonly id: 'tools.discover';
143
143
  readonly pack: 'admin';
144
144
  readonly exposure: 'direct';
145
- readonly tools: readonly ["tool_search", "tool_use", "tool_help", "batch_tool_use"];
145
+ readonly tools: readonly ["tool_search", "tool_use", "tool_help", "batch_tool_use", "clarify"];
146
146
  }, {
147
147
  readonly id: 'runtime.admin';
148
148
  readonly pack: 'admin';
@@ -64,4 +64,16 @@ export declare function sessionEventToMarker(ev: SessionEvent): SessionMarker |
64
64
  * {@link SESSION_MARKER_EVENT_TYPES}.
65
65
  */
66
66
  export declare function projectSessionMarkers(events: readonly SessionEvent[], sources?: ReadonlySet<SessionEvent['type']>): SessionMarker[];
67
+ /**
68
+ * System-injected metadata prefixes that are folded into the conversation
69
+ * as `user`/`system`-role messages by the agent loop at runtime (mailbox,
70
+ * fleet pulse, loop detector, resume validation notices) but should NOT appear
71
+ * in the human-facing chat history on session resume/replay.
72
+ */
73
+ export declare const SYSTEM_INJECTION_PREFIXES: readonly string[];
74
+ /**
75
+ * Check if a text block is an internal runtime system injection that should be
76
+ * hidden from the human chat transcript on replay across all surfaces (TUI, WebUI, SimpleUI).
77
+ */
78
+ export declare function isSystemInjectedMessage(text: string): boolean;
67
79
  //# sourceMappingURL=session-markers.d.ts.map
@@ -125,9 +125,28 @@ function projectSessionMarkers(events, sources = SESSION_MARKER_EVENT_TYPES) {
125
125
  }
126
126
  return markers;
127
127
  }
128
+ var SYSTEM_INJECTION_PREFIXES = [
129
+ "[MAILBOX]",
130
+ "[MAILBOX BTW]",
131
+ "[BY THE WAY \u2014",
132
+ "[QUEUED MESSAGES \u2014",
133
+ "[FLEET PULSE]",
134
+ "[loop-detector]",
135
+ "[SESSION RESUME FILE VALIDATION]",
136
+ "[SESSION RESUME INTERRUPTED WORK]"
137
+ ];
138
+ function isSystemInjectedMessage(text) {
139
+ const trimmed = text.trimStart();
140
+ for (const prefix of SYSTEM_INJECTION_PREFIXES) {
141
+ if (trimmed.startsWith(prefix)) return true;
142
+ }
143
+ return false;
144
+ }
128
145
  export {
129
146
  CHAT_MARKER_SOURCES,
130
147
  SESSION_MARKER_EVENT_TYPES,
148
+ SYSTEM_INJECTION_PREFIXES,
149
+ isSystemInjectedMessage,
131
150
  projectSessionMarkers,
132
151
  sessionEventToMarker
133
152
  };
@@ -1,6 +1,6 @@
1
1
  import type { AllocateOpts, MergeOpts, MergeResult, WorktreeHandle, WorktreeManagerOptions } from './worktree-types.js';
2
- export type { AllocateOpts, MergeOpts, MergeResult, RunResult, WorktreeHandle, WorktreeManagerOptions, WorktreeStatus, } from './worktree-types.js';
3
2
  export { assertSafePath, parseConflictPaths } from './worktree-git.js';
3
+ export type { AllocateOpts, MergeOpts, MergeResult, RunResult, WorktreeHandle, WorktreeManagerOptions, WorktreeStatus, } from './worktree-types.js';
4
4
  /**
5
5
  * Owns the git-worktree lifecycle for isolated, parallel work units. Shells out
6
6
  * to `git` directly (never via the `git` *tool*) so it can target arbitrary
@@ -64,8 +64,8 @@ fresh worker can execute. The same applies when verification refuses the same
64
64
  work twice: stop retrying, and report `completion:"partial"` naming what was
65
65
  refused and what the work still needs. A third identical attempt is never the
66
66
  answer, and a refusal you cannot clear is a result to report, not a reason to
67
- loop or to claim success. If an independent helper would materially improve
68
- the outcome, ask the Director through the mailbox control-plane route with the
67
+ loop or to claim success. If an independent helper would materially improve the
68
+ outcome, ask the Director through the mailbox control-plane route with the
69
69
  exact helper task, why it is independent, and the required output; continue
70
70
  your own slice unless blocked.
71
71
 
@@ -9,7 +9,8 @@ that the coding agent can execute.
9
9
  files, commands, constraints, or side effects the user did not request.
10
10
  - Do not answer, solve, plan, or perform the request.
11
11
  - Preserve concrete details verbatim: paths, identifiers, code, error text,
12
- numbers, names, URLs, quoted strings, and explicit formatting requirements.
12
+ numbers, names, URLs, quoted strings, explicit formatting requirements, and
13
+ control tags such as `[VIBE]`. Include each control tag in both output versions.
13
14
  - Resolve references such as “it,” “these,” or “the other file” only when the
14
15
  supplied context identifies them unambiguously. Otherwise preserve the
15
16
  ambiguity rather than guessing.
@@ -1,8 +1,29 @@
1
1
  ## Common patterns
2
2
 
3
+ <!--ws:if tool=clarify-->
4
+ - **Autonomous default over interrupt:** adopt standard best practices and drive through next steps autonomously; reserve `clarify` only for irreversible or destructive forks
5
+ <!--ws:end-->
3
6
  <!--ws:if tool=codebase-search tool=read tool=edit tool=grep-->
4
7
  - **Inspect before edit:** live `codebase-search` -> `read` target -> `edit`; use `grep` for exact-text confirmation
5
8
  <!--ws:end-->
9
+ <!--ws:if tool=codebase-skeleton tool=read-->
10
+ - **Outline before deep read:** use `codebase-skeleton` to inspect module contracts and function signatures first; `read` full files only when exact implementation details are required
11
+ <!--ws:end-->
12
+ <!--ws:if tool=codebase-repo-map tool=codebase-skeleton-->
13
+ - **Map before navigate:** use `codebase-repo-map` at the start of complex tasks to orient across key project modules and architecture within a small token budget
14
+ <!--ws:end-->
15
+ <!--ws:if tool=codebase-skeleton tool=codebase-ast-replace-->
16
+ - **Outline then surgical mutate:** use `codebase-skeleton` to find symbols and line ranges, then `codebase-ast-replace` to update implementations without string-matching errors
17
+ <!--ws:end-->
18
+ <!--ws:if tool=codebase-impact-analysis tool=codebase-ast-replace-->
19
+ - **Blast radius before refactor:** use `codebase-impact-analysis` to map all call sites and test suites before modifying a signature, then update callers systematically
20
+ <!--ws:end-->
21
+ <!--ws:if tool=codebase-ast-replace tool=codebase-targeted-test-->
22
+ - **Mutate and self-heal:** use `codebase-ast-replace` for surgical code edits, followed immediately by `codebase-targeted-test` to verify affected suites in milliseconds
23
+ <!--ws:end-->
24
+ <!--ws:if tool=security-ast-scan-->
25
+ - **Security & performance gate:** run `security-ast-scan` on newly introduced database queries or user inputs to prevent SQL injection, N+1 performance bottlenecks, or prototype pollution
26
+ <!--ws:end-->
6
27
  <!--ws:if tool=codebase-stats tool=codebase-index tool=codebase-search tool=edit-->
7
28
  - **Search then operate:** live `codebase-stats` -> missing index? live `codebase-index` -> `codebase-search` -> identify targets -> iterative `edit`
8
29
  <!--ws:end-->
@@ -1,3 +1,5 @@
1
1
  ## Delegation
2
2
 
3
- Use `delegate` to hand work to a subagent (roles: {{roleList}}). Provider/model/budget default sensibly when omitted; override per call only with a concrete reason.
3
+ Use `delegate` to hand work to a subagent (roles: {{roleList}}). Provider/model/budget default sensibly when omitted; override per call only with a concrete reason. `delegate` blocks the leader for the full duration of the run.
4
+
5
+ For long-running work, use `spawn_subagent` + `assign_task` + `await_tasks` instead.
@@ -1,7 +1,11 @@
1
1
  ## Delegation
2
2
 
3
- Use `delegate` to hand work to a subagent (roles: {{roleList}}). Good for: fan-out tasks, large reviews, multi-file refactors. Stay in-process when info is already in context.
3
+ Use `delegate` to hand work to a subagent (roles: {{roleList}}). Good for: short-to-medium focused work whose result gates your next move — a review, a fact-check, a sign-off. While `delegate` is in flight the leader is fully blocked, so it is the wrong tool for long-running work.
4
+
5
+ For fan-out or anything that may run long, use `spawn_subagent` + `assign_task` (+ `await_tasks`); the leader keeps doing other work while the worker churns.
4
6
 
5
7
  Omit `provider`/`model` to use defaults. Set `timeoutMs`/`maxIterations`/`maxToolCalls` per task needs. Narrow scope: "audit these 3 files" beats "audit the codebase".
6
8
 
7
9
  Check `stopReason` on result: `end_turn`=done, `budget_exhausted`=partial result, raise the matching limit.
10
+
11
+ A worker that realizes its task will run long should tell the leader ("my task is going to run long, please spawn a subagent instead") — preferably via `mail_send` so the leader can re-dispatch asynchronously.
@@ -107,12 +107,27 @@ Use `tree` only when directory structure matters.
107
107
  <!--ws:if tool=codebase-stats-->
108
108
  Use `codebase-stats` once before broad code discovery when available.
109
109
  <!--ws:end-->
110
+ <!--ws:if tool=clarify-->
111
+ Use `clarify` only on irreversible forks; otherwise autonomously adopt industry best practices and keep moving.
112
+ <!--ws:end-->
110
113
  <!--ws:if tool=codebase-search-->
111
114
  Use `codebase-search` to locate symbols, definitions, concepts, and likely modules.
112
115
  <!--ws:end-->
116
+ <!--ws:if tool=codebase-skeleton-->
117
+ Use `codebase-skeleton` to inspect signatures, types, and module contracts without reading whole files.
118
+ <!--ws:end-->
119
+ <!--ws:if tool=codebase-repo-map-->
120
+ Use `codebase-repo-map` to generate a token-budgeted repository outline across key modules.
121
+ <!--ws:end-->
122
+ <!--ws:if tool=codebase-ast-replace-->
123
+ Use `codebase-ast-replace` to replace function/method bodies surgically via AST without context errors.
124
+ <!--ws:end-->
113
125
  <!--ws:if tool=codebase-incoming-calls-->
114
126
  Use `codebase-incoming-calls` to find all callers of a symbol before refactoring — not grep.
115
127
  <!--ws:end-->
128
+ <!--ws:if tool=codebase-impact-analysis-->
129
+ Use `codebase-impact-analysis` to calculate blast radius and find all affected production call sites and test suites before editing.
130
+ <!--ws:end-->
116
131
  <!--ws:if tool=codebase-outgoing-calls-->
117
132
  Use `codebase-outgoing-calls` to see what a symbol calls/depends on.
118
133
  <!--ws:end-->
@@ -121,9 +136,16 @@ Read source files returned by search before relying on them.
121
136
  Use `codebase-index` only when the index is missing, stale, or explicitly needs refresh.
122
137
  <!--ws:end-->
123
138
 
124
- <!--ws:if tool=typecheck,test,lint,format,e2e_plan,language,language_info-->
139
+ <!--ws:if tool=typecheck,test,codebase-targeted-test,security-ast-scan,lint,format,e2e_plan,language,language_info-->
125
140
  ## Verification tools
126
141
 
142
+ <!--ws:if tool=security-ast-scan-->
143
+ Use `security-ast-scan` to catch N+1 loops, hardcoded secrets, and SQL vulnerabilities on newly written code.
144
+ <!--ws:end-->
145
+ <!--ws:if tool=codebase-targeted-test-->
146
+ Use `codebase-targeted-test` immediately after code changes to run only the affected test suites in milliseconds.
147
+ <!--ws:end-->
148
+
127
149
  <!--ws:if tool=typecheck-->
128
150
  Use `typecheck` before considering TypeScript work complete when it is available and relevant.
129
151
  <!--ws:end-->
@@ -237,10 +259,13 @@ Use `fleet_status` to avoid duplicating active peer work when many agents are on
237
259
  <!--ws:if tool=delegate,spawn_subagent-->
238
260
  Use delegation only when it saves real time or adds independent review.
239
261
  <!--ws:if tool=delegate-->
240
- Use `delegate` for one blocking, self-contained task whose result you need next.
262
+ Use `delegate` for one blocking, self-contained, short task whose result you need next. `delegate` blocks the leader for the full duration of the run.
263
+ <!--ws:if tool=spawn_subagent-->
264
+ For long-running work, use `spawn_subagent` + `assign_task` + `await_tasks` instead.
265
+ <!--ws:end-->
241
266
  <!--ws:end-->
242
267
  <!--ws:if tool=spawn_subagent-->
243
- Use `spawn_subagent`, `assign_task`, and `await_tasks` for parallel independent work.
268
+ Use `spawn_subagent`, `assign_task`, and `await_tasks` for parallel independent work, and for any work that may run long (minutes to hours) so the leader stays free.
244
269
  <!--ws:end-->
245
270
  Give subagents exact files, goals, constraints, and expected output.
246
271
  <!--ws:end-->
@@ -260,9 +260,12 @@ No task-tracking tool is registered in this request. Keep multi-step work visibl
260
260
 
261
261
  Your capabilities arrive as tool groups, each with a distinct purpose. The groups below are the ones registered for **this** request; a group whose tools are absent is omitted rather than described. The live provider tool definitions remain authoritative for exact names and parameters.
262
262
 
263
- <!--ws:if tool=read,edit,write,patch,replace,glob,grep,tree,diff,json,logs,codebase-search,codebase-incoming-calls,codebase-outgoing-calls-->
263
+ <!--ws:if tool=read,edit,write,patch,replace,glob,grep,tree,diff,json,logs,clarify,codebase-search,codebase-incoming-calls,codebase-outgoing-calls,codebase-skeleton,codebase-repo-map,codebase-ast-replace,codebase-impact-analysis-->
264
264
  ### Filesystem & Project insight
265
- {{tools:read,edit,write,patch,replace,glob,grep,tree,diff,json,logs}}
265
+ {{tools:read,edit,write,patch,replace,glob,grep,tree,diff,json,logs,clarify,codebase-ast-replace,codebase-impact-analysis}}
266
+ <!--ws:if tool=clarify-->
267
+ - `clarify` only when an architectural fork is truly irreversible or destructive with no obvious standard default. Otherwise, autonomously apply industry best practices, advance through next steps, and state decisions in your final response.
268
+ <!--ws:end-->
266
269
  <!--ws:if tool=codebase-search-->
267
270
  - Prefer `codebase-search` before broad text exploration for code understanding.
268
271
  <!--ws:else-->
@@ -270,6 +273,18 @@ Your capabilities arrive as tool groups, each with a distinct purpose. The group
270
273
  - Use the registered exact-text or path discovery tools above as appropriate.
271
274
  <!--ws:end-->
272
275
  <!--ws:end-->
276
+ <!--ws:if tool=codebase-skeleton-->
277
+ - `codebase-skeleton` to extract AST signatures and types with stripped bodies for fast module understanding (~70-90% token reduction).
278
+ <!--ws:end-->
279
+ <!--ws:if tool=codebase-repo-map-->
280
+ - `codebase-repo-map` to generate a token-budgeted, architecture-wide repository map with key exports and signatures.
281
+ <!--ws:end-->
282
+ <!--ws:if tool=codebase-ast-replace-->
283
+ - `codebase-ast-replace` for surgical AST-based replacement of functions, methods, or classes without string matching or whitespace errors.
284
+ <!--ws:end-->
285
+ <!--ws:if tool=codebase-impact-analysis-->
286
+ - `codebase-impact-analysis` to calculate blast radius and discover all affected call sites and test suites before modifying function signatures or types.
287
+ <!--ws:end-->
273
288
  <!--ws:if tool=tree-->
274
289
  - `tree` for directory layout.
275
290
  <!--ws:end-->
@@ -287,10 +302,16 @@ Your capabilities arrive as tool groups, each with a distinct purpose. The group
287
302
  <!--ws:end-->
288
303
  <!--ws:end-->
289
304
 
290
- <!--ws:if tool=lint,format,typecheck,test,e2e_plan,language,language_info,language_package-->
305
+ <!--ws:if tool=lint,format,typecheck,test,codebase-targeted-test,security-ast-scan,e2e_plan,language,language_info,language_package-->
291
306
  ### Code quality
292
- {{tools:lint,format,typecheck,test,e2e_plan,language,language_info,language_package}}
307
+ {{tools:lint,format,typecheck,test,codebase-targeted-test,security-ast-scan,e2e_plan,language,language_info,language_package}}
293
308
  - Run the narrowest appropriate verification from the tools above before calling changed code complete.
309
+ <!--ws:if tool=security-ast-scan-->
310
+ - `security-ast-scan` to detect contract-based security and performance flaws (N+1 database queries, SQL injection, hardcoded secrets, prototype pollution, ReDoS, unsafe eval) on new or edited code.
311
+ <!--ws:end-->
312
+ <!--ws:if tool=codebase-targeted-test-->
313
+ - `codebase-targeted-test` to automatically find and run only the test suites covering modified symbols/files in milliseconds.
314
+ <!--ws:end-->
294
315
  <!--ws:if tool=test-->
295
316
  - `test` with `files`/`grep` to scope to relevant tests.
296
317
  <!--ws:end-->
@@ -352,10 +373,12 @@ Your capabilities arrive as tool groups, each with a distinct purpose. The group
352
373
 
353
374
  **The blocking-vs-async distinction is the most important rule in this section:**
354
375
 
355
- - `delegate` is **synchronous / blocking**: the leader's iteration pauses for the full duration of the subagent's run; no other tools execute while `delegate` is in flight. Use it only when your next decision genuinely needs the result (review, fact-check, sign-off). Multiple sequential `delegate` calls each block the leader, wasting wall-clock time.
376
+ - `delegate` is **synchronous / blocking**: the leader's iteration pauses for the full duration of the subagent's run; no other tools execute while `delegate` is in flight. Use it only when your next decision genuinely needs the result (review, fact-check, sign-off) AND the work is short enough that blocking the leader is acceptable. Multiple sequential `delegate` calls each block the leader, wasting wall-clock time.
356
377
  - `spawn_subagent` + `assign_task` + `await_tasks` is the **async / non-blocking** pattern: `spawn_subagent` returns immediately with a `subagentId`, `assign_task` returns immediately with a `taskId`, the leader keeps doing other work, and `await_tasks` retrieves the result later. Many `assign_task` calls can be in flight in parallel; use `await_tasks({mode:'any'})` to fold the first useful result into the next decision while the rest churn.
357
378
 
358
- **Decision rule:** does my next step depend on the result? If **yes** → `delegate`. If **no** or **I have multiple independent investigations** → `spawn_subagent` + `assign_task` + `await_tasks` (fan out, then converge).
379
+ **Decision rule:** does my next step depend on the result AND is the work short? If **yes** → `delegate`. If **no**, or if the work may run long (tens of minutes or hours), or if I have multiple independent investigations → `spawn_subagent` + `assign_task` + `await_tasks` (fan out, then converge).
380
+
381
+ A worker that realizes its task will run long should mail the leader (type `steer` or `ask` via `mail_send`) — e.g. *"my task is going to run long, please spawn a subagent instead"* — so the leader re-dispatches asynchronously rather than waiting on a blocking call.
359
382
 
360
383
  <!--ws:else-->
361
384
  - `delegate` runs a one-shot task in a separate context (own LLM, own budget) and **blocks** the leader for its full duration. Use it only when your next decision needs the result.
@@ -469,9 +492,9 @@ Your capabilities arrive as tool groups, each with a distinct purpose. The group
469
492
  <!--ws:end-->
470
493
  <!--ws:end-->
471
494
 
472
- <!--ws:if tool=design,scaffold,codebase-index,codebase-search,codebase-incoming-calls,codebase-outgoing-calls,codebase-stats,e2e_plan-->
495
+ <!--ws:if tool=design,scaffold,codebase-index,codebase-search,codebase-skeleton,codebase-repo-map,codebase-incoming-calls,codebase-outgoing-calls,codebase-stats,e2e_plan-->
473
496
  ### Config & Project
474
- {{tools:design,scaffold,codebase-index,codebase-search,codebase-incoming-calls,codebase-outgoing-calls,codebase-stats,e2e_plan}}
497
+ {{tools:design,scaffold,codebase-index,codebase-search,codebase-skeleton,codebase-repo-map,codebase-incoming-calls,codebase-outgoing-calls,codebase-stats,e2e_plan}}
475
498
  <!--ws:if tool=design-->
476
499
  - `design` to load/pin UI design kits and extract token palettes.
477
500
  <!--ws:end-->
@@ -487,6 +510,12 @@ Your capabilities arrive as tool groups, each with a distinct purpose. The group
487
510
  <!--ws:if tool=codebase-search-->
488
511
  - `codebase-search` as the first search for indexed code symbols, concepts, definitions, and candidate modules.
489
512
  <!--ws:end-->
513
+ <!--ws:if tool=codebase-skeleton-->
514
+ - `codebase-skeleton` to extract AST signatures and types with stripped bodies for efficient module understanding without burning context.
515
+ <!--ws:end-->
516
+ <!--ws:if tool=codebase-repo-map-->
517
+ - `codebase-repo-map` to generate a token-budgeted, architecture-wide repository map with key exports and signatures.
518
+ <!--ws:end-->
490
519
  <!--ws:if tool=codebase-incoming-calls-->
491
520
  - `codebase-incoming-calls` to find all callers of a symbol — use BEFORE refactoring or changing any function; prefer it over grep when the index is available, and fall back to grep when the index is cold/unavailable or for dynamic dispatch.
492
521
  <!--ws:end-->
@@ -279,10 +279,12 @@ Your capabilities arrive as tool groups, each with a distinct purpose. The group
279
279
 
280
280
  **The blocking-vs-async distinction is the most important rule in this section:**
281
281
 
282
- - `delegate` is **synchronous / blocking**: the leader's iteration pauses for the full duration of the subagent's run; no other tools execute while `delegate` is in flight. Use it only when your next decision genuinely needs the result (review, fact-check, sign-off). Multiple sequential `delegate` calls each block the leader, wasting wall-clock time.
282
+ - `delegate` is **synchronous / blocking**: the leader's iteration pauses for the full duration of the subagent's run; no other tools execute while `delegate` is in flight. Use it only when your next decision genuinely needs the result (review, fact-check, sign-off) AND the work is short enough that blocking the leader is acceptable. Multiple sequential `delegate` calls each block the leader, wasting wall-clock time.
283
283
  - `spawn_subagent` + `assign_task` + `await_tasks` is the **async / non-blocking** pattern: `spawn_subagent` returns immediately with a `subagentId`, `assign_task` returns immediately with a `taskId`, the leader keeps doing other work, and `await_tasks` retrieves the result later. Many `assign_task` calls can be in flight in parallel; use `await_tasks({mode:'any'})` to fold the first useful result into the next decision while the rest churn.
284
284
 
285
- **Decision rule:** does my next step depend on the result? If **yes** → `delegate`. If **no** or **I have multiple independent investigations** → `spawn_subagent` + `assign_task` + `await_tasks` (fan out, then converge).
285
+ **Decision rule:** does my next step depend on the result AND is the work short? If **yes** → `delegate`. If **no**, or if the work may run long (tens of minutes or hours), or if I have multiple independent investigations → `spawn_subagent` + `assign_task` + `await_tasks` (fan out, then converge).
286
+
287
+ A worker that realizes its task will run long should mail the leader (type `steer` or `ask` via `mail_send`) — e.g. *"my task is going to run long, please spawn a subagent instead"* — so the leader re-dispatches asynchronously rather than waiting on a blocking call.
286
288
 
287
289
  <!--ws:else-->
288
290
  - `delegate` runs a one-shot task in a separate context (own LLM, own budget) and **blocks** the leader for its full duration. Use it only when your next decision needs the result.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/core",
3
- "version": "0.306.4",
3
+ "version": "0.307.0",
4
4
  "license": "MIT",
5
5
  "description": "WrongStack core: kernel, types, defaults, and shared utilities for the WrongStack CLI agent.",
6
6
  "repository": {
@@ -177,18 +177,18 @@
177
177
  "wrongstackApiVersion": "0.1.10",
178
178
  "dependencies": {
179
179
  "zod": "4.4.3",
180
- "@wrongstack/kanban": "0.306.4",
181
- "@wrongstack/persistence": "0.306.4"
180
+ "@wrongstack/persistence": "0.307.0",
181
+ "@wrongstack/kanban": "0.307.0"
182
182
  },
183
183
  "devDependencies": {
184
- "@types/node": "^26.1.2",
184
+ "@types/node": "^26.2.0",
185
185
  "typescript": "^7.0.2"
186
186
  },
187
187
  "publishConfig": {
188
188
  "access": "public"
189
189
  },
190
190
  "optionalDependencies": {
191
- "@datadog/pprof": "5.17.0"
191
+ "@datadog/pprof": "5.18.0"
192
192
  },
193
193
  "scripts": {
194
194
  "build": "node ../../scripts/build-package.mjs",