@wrongstack/core 0.306.4 → 0.307.1

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 (113) 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 +1803 -1701
  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/agents/types.d.ts +6 -9
  14. package/dist/coordination/index.js +6051 -5880
  15. package/dist/coordination/mail-tools.d.ts +1 -1
  16. package/dist/coordination/mailbox-http-actor-query.d.ts +16 -0
  17. package/dist/coordination/mailbox-http-router.d.ts +0 -48
  18. package/dist/coordination/mailbox-http-sse.d.ts +12 -0
  19. package/dist/coordination/mailbox-message-types.d.ts +71 -0
  20. package/dist/coordination/mailbox-predicates.d.ts +13 -0
  21. package/dist/coordination/mailbox-project-server.js +1 -1
  22. package/dist/coordination/mailbox-session-sync.d.ts +8 -0
  23. package/dist/coordination/mailbox-types.d.ts +6 -793
  24. package/dist/core/agent-loop-context.d.ts +28 -0
  25. package/dist/core/agent-loop-detector.d.ts +25 -0
  26. package/dist/core/fallback-doctor.d.ts +72 -0
  27. package/dist/core/index.d.ts +1 -0
  28. package/dist/core/index.js +1859 -1335
  29. package/dist/defaults/index.js +3647 -3559
  30. package/dist/execution/autonomy-brain-llm.d.ts +55 -0
  31. package/dist/execution/autonomy-brain.d.ts +3 -156
  32. package/dist/execution/compaction-budget.d.ts +38 -0
  33. package/dist/execution/compaction-core.d.ts +3 -170
  34. package/dist/execution/compaction-elision.d.ts +58 -0
  35. package/dist/execution/council-orchestrator-helpers.d.ts +39 -0
  36. package/dist/execution/council-orchestrator.d.ts +3 -42
  37. package/dist/execution/council-response-parser.d.ts +56 -0
  38. package/dist/execution/index.js +2475 -2449
  39. package/dist/execution/prompt-enhancer.js +11 -3
  40. package/dist/execution/tool-executor-guard.d.ts +18 -0
  41. package/dist/execution/tool-executor-runner.d.ts +12 -0
  42. package/dist/execution/tool-executor.d.ts +0 -75
  43. package/dist/goal/index.js +19 -6
  44. package/dist/hq/index.js +8 -2
  45. package/dist/index.d.ts +1 -0
  46. package/dist/index.js +8021 -7405
  47. package/dist/infrastructure/index.js +3 -1
  48. package/dist/kernel/events/agent-events.d.ts +2 -0
  49. package/dist/kernel/events/provider-events.d.ts +13 -0
  50. package/dist/plugin/index.js +2590 -2561
  51. package/dist/plugins/auto-review-config.d.ts +53 -0
  52. package/dist/plugins/auto-review-git.d.ts +19 -0
  53. package/dist/plugins/auto-review-plugin.d.ts +2 -140
  54. package/dist/plugins/review-finding-verification.d.ts +7 -0
  55. package/dist/prompts/index.d.ts +1 -0
  56. package/dist/prompts/index.js +601 -0
  57. package/dist/prompts/prompt-journal.d.ts +103 -0
  58. package/dist/security/index.js +627 -652
  59. package/dist/security/permission-explain.d.ts +19 -0
  60. package/dist/security/permission-policy.d.ts +0 -101
  61. package/dist/security/yolo-risk.d.ts +5 -4
  62. package/dist/session-catalog/index.js +220 -212
  63. package/dist/session-catalog/project-server.js +227 -219
  64. package/dist/session-catalog/store-rebuild.d.ts +9 -0
  65. package/dist/session-catalog/store-schema.d.ts +48 -0
  66. package/dist/session-catalog/store.d.ts +0 -17
  67. package/dist/storage/director-state.d.ts +6 -0
  68. package/dist/storage/file-session-writer.d.ts +2 -58
  69. package/dist/storage/index.d.ts +2 -1
  70. package/dist/storage/index.js +2057 -1925
  71. package/dist/storage/orphan-lock-cleaner.d.ts +15 -0
  72. package/dist/storage/queue-store.d.ts +6 -0
  73. package/dist/storage/session-recovery.d.ts +9 -0
  74. package/dist/storage/session-store/rename-session.d.ts +16 -0
  75. package/dist/storage/session-store/resume-session.d.ts +26 -0
  76. package/dist/storage/session-store/session-store-clear.d.ts +11 -0
  77. package/dist/storage/session-store/session-store-index.d.ts +13 -0
  78. package/dist/storage/session-store.d.ts +1 -129
  79. package/dist/storage/session-summary-tracker.d.ts +39 -0
  80. package/dist/storage/session-write-buffer.d.ts +43 -0
  81. package/dist/storage/session-writer/session-writer-flush.d.ts +4 -0
  82. package/dist/storage/session-writer/session-writer-summary-tracker.d.ts +28 -0
  83. package/dist/tools/fallback-agent-model-assign-tool.d.ts +18 -0
  84. package/dist/tools/fallback-leader-model-set-tool.d.ts +18 -0
  85. package/dist/tools/fallback-manage-tools.d.ts +8 -45
  86. package/dist/tools/fallback-profile-manage-tool.d.ts +16 -0
  87. package/dist/tools/fallback-provider-key-set-tool.d.ts +17 -0
  88. package/dist/tools/fallback-provider-manage-tool.d.ts +26 -0
  89. package/dist/tools/index.js +5124 -5071
  90. package/dist/types/config/root.d.ts +7 -2
  91. package/dist/types/default-config.d.ts +1 -1
  92. package/dist/types/index.d.ts +54 -55
  93. package/dist/types/index.js +953 -932
  94. package/dist/types/runtime-capability-manifest.d.ts +5 -5
  95. package/dist/types/session-markers.d.ts +12 -0
  96. package/dist/types/session-markers.js +19 -0
  97. package/dist/worktree/worktree-manager.d.ts +1 -1
  98. package/instructions/agents/architect.md +2 -0
  99. package/instructions/agents/code-reviewer.md +1 -0
  100. package/instructions/agents/debugger.md +2 -0
  101. package/instructions/agents/executor.md +2 -0
  102. package/instructions/agents/explore.md +3 -1
  103. package/instructions/agents/refactor.md +2 -0
  104. package/instructions/agents/reviewer.md +1 -0
  105. package/instructions/coordination/subagent-baseline.md +68 -7
  106. package/instructions/llm/prompt-enhancer.md +2 -1
  107. package/instructions/sections/tool/common-patterns.md +30 -0
  108. package/instructions/sections/tool/delegation-compact.md +3 -1
  109. package/instructions/sections/tool/delegation-full.md +5 -1
  110. package/instructions/system-lite.md +32 -4
  111. package/instructions/system-pro.md +63 -9
  112. package/instructions/system.md +56 -11
  113. package/package.json +9 -5
@@ -192,18 +192,33 @@ No task-tracking tool is registered in this request. Keep multi-step work visibl
192
192
 
193
193
  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.
194
194
 
195
- <!--ws:if tool=read,edit,write,patch,replace,glob,grep,tree,diff,json,logs,codebase-search,codebase-incoming-calls,codebase-outgoing-calls-->
195
+ <!--ws:if tool=read,edit,write,patch,replace,glob,grep,tree,diff,json,logs,codebase-search,codebase-incoming-calls,codebase-outgoing-calls,codebase-skeleton,codebase-repo-map,codebase-ast-replace,codebase-impact-analysis,codebase-invariant-check-->
196
196
  ### Filesystem & Project insight
197
- {{tools:read,edit,write,patch,replace,glob,grep,tree,diff,json,logs}}
197
+ {{tools:read,edit,write,patch,replace,glob,grep,tree,diff,json,logs,codebase-ast-replace,codebase-impact-analysis,codebase-invariant-check}}
198
198
  <!--ws:if tool=codebase-search-->
199
- - Prefer `codebase-search` before broad text exploration for code understanding.
199
+ - Prefer `codebase-search` before broad `grep`/`glob`/`tree` exploration for code understanding.
200
200
  <!--ws:else-->
201
201
  <!--ws:if tool=grep,glob-->
202
202
  - Use the registered exact-text or path discovery tools above as appropriate.
203
203
  <!--ws:end-->
204
204
  <!--ws:end-->
205
+ <!--ws:if tool=codebase-skeleton-->
206
+ - `codebase-skeleton` to inspect signatures, types, and exports before a full `read`.
207
+ <!--ws:end-->
208
+ <!--ws:if tool=codebase-repo-map-->
209
+ - `codebase-repo-map` once at the start of an unfamiliar or repository-wide task.
210
+ <!--ws:end-->
211
+ <!--ws:if tool=codebase-ast-replace-->
212
+ - `codebase-ast-replace` for surgical function/method/class replacement without string-matching errors.
213
+ <!--ws:end-->
214
+ <!--ws:if tool=codebase-impact-analysis-->
215
+ - `codebase-impact-analysis` to map blast radius before changing a signature or type.
216
+ <!--ws:end-->
217
+ <!--ws:if tool=codebase-invariant-check-->
218
+ - `codebase-invariant-check` to verify a candidate mutation is backward-compatible before applying it.
219
+ <!--ws:end-->
205
220
  <!--ws:if tool=tree-->
206
- - `tree` for directory layout.
221
+ - `tree` for directory layout, not for finding symbols.
207
222
  <!--ws:end-->
208
223
  <!--ws:if tool=codebase-incoming-calls,codebase-outgoing-calls-->
209
224
  - Use `codebase-incoming-calls` to find all callers of a symbol before refactoring — instant, exact, no grep needed. Use `codebase-outgoing-calls` to see what a symbol depends on.
@@ -219,10 +234,13 @@ Your capabilities arrive as tool groups, each with a distinct purpose. The group
219
234
  <!--ws:end-->
220
235
  <!--ws:end-->
221
236
 
222
- <!--ws:if tool=lint,format,typecheck,test,e2e_plan,language,language_info,language_package-->
237
+ <!--ws:if tool=lint,format,typecheck,test,codebase-targeted-test,e2e_plan,language,language_info,language_package-->
223
238
  ### Code quality
224
- {{tools:lint,format,typecheck,test,e2e_plan,language,language_info,language_package}}
239
+ {{tools:lint,format,typecheck,test,codebase-targeted-test,e2e_plan,language,language_info,language_package}}
225
240
  - Run the narrowest appropriate verification from the tools above before calling changed code complete.
241
+ <!--ws:if tool=codebase-targeted-test-->
242
+ - `codebase-targeted-test` immediately after mutating a symbol or file — run only the covering suites.
243
+ <!--ws:end-->
226
244
  <!--ws:if tool=test-->
227
245
  - `test` with `files`/`grep` to scope to relevant tests.
228
246
  <!--ws:end-->
@@ -279,10 +297,12 @@ Your capabilities arrive as tool groups, each with a distinct purpose. The group
279
297
 
280
298
  **The blocking-vs-async distinction is the most important rule in this section:**
281
299
 
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.
300
+ - `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
301
  - `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
302
 
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).
303
+ **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).
304
+
305
+ 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
306
 
287
307
  <!--ws:else-->
288
308
  - `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.
@@ -395,9 +415,9 @@ Your capabilities arrive as tool groups, each with a distinct purpose. The group
395
415
  <!--ws:end-->
396
416
  <!--ws:end-->
397
417
 
398
- <!--ws:if tool=design,scaffold,codebase-index,codebase-search,codebase-incoming-calls,codebase-outgoing-calls,codebase-stats,e2e_plan-->
418
+ <!--ws:if tool=design,scaffold,codebase-index,codebase-search,codebase-skeleton,codebase-repo-map,codebase-incoming-calls,codebase-outgoing-calls,codebase-stats,e2e_plan-->
399
419
  ### Config & Project
400
- {{tools:design,scaffold,codebase-index,codebase-search,codebase-incoming-calls,codebase-outgoing-calls,codebase-stats,e2e_plan}}
420
+ {{tools:design,scaffold,codebase-index,codebase-search,codebase-skeleton,codebase-repo-map,codebase-incoming-calls,codebase-outgoing-calls,codebase-stats,e2e_plan}}
401
421
  <!--ws:if tool=design-->
402
422
  - `design` to load/pin UI design kits and extract token palettes.
403
423
  <!--ws:end-->
@@ -413,6 +433,12 @@ Your capabilities arrive as tool groups, each with a distinct purpose. The group
413
433
  <!--ws:if tool=codebase-search-->
414
434
  - `codebase-search` as the first search for indexed code symbols, concepts, definitions, and candidate modules.
415
435
  <!--ws:end-->
436
+ <!--ws:if tool=codebase-skeleton-->
437
+ - `codebase-skeleton` to extract signatures and types with bodies stripped before reading a large file.
438
+ <!--ws:end-->
439
+ <!--ws:if tool=codebase-repo-map-->
440
+ - `codebase-repo-map` to generate a token-budgeted architecture outline across key modules.
441
+ <!--ws:end-->
416
442
  <!--ws:if tool=codebase-incoming-calls-->
417
443
  - `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.
418
444
  <!--ws:end-->
@@ -460,6 +486,12 @@ Tools are not isolated — they form pipelines. Coordinate them with these princ
460
486
  When the request requires understanding or locating code:
461
487
  1. **Check once:** Call `codebase-stats` when live before broad exploration. `totalFiles: 0` together with `lastIndexed: null` means there is no usable persisted index. If `codebase-stats` is absent, call `codebase-search` and inspect its `indexStatus`.
462
488
  2. **Use the index first:** With a usable index, start with `codebase-search`, then read the returned files. Refine with its `kind`, `lang`, and `file` filters before widening the search.
489
+ <!--ws:if tool=codebase-repo-map-->
490
+ On an unfamiliar or repository-wide task, call `codebase-repo-map` once before walking directories.
491
+ <!--ws:end-->
492
+ <!--ws:if tool=codebase-skeleton-->
493
+ Prefer `codebase-skeleton` over a full `read` when you only need signatures, types, or exports.
494
+ <!--ws:end-->
463
495
  3. **Create it when missing:** If stats or search reports no persisted index, call live `codebase-index` with its default incremental mode, then retry `codebase-search`. Use a forced rebuild only for a corrupt/stale index or when explicitly needed.
464
496
  4. **Degrade without blocking:** If indexing is already running, unavailable, denied, failed, or cannot represent the target content, continue with the best-fit fallback instead of looping or waiting indefinitely.
465
497
  5. **Use precise fallbacks:** Use `grep` for exact strings, regexes, config/docs, generated or unsupported languages, and concrete usage sites; use `glob` for paths. Index hits are navigation hints, so read the source before editing.
@@ -469,10 +501,13 @@ When the request requires understanding or locating code:
469
501
  ### The read-edit loop (most common workflow)
470
502
  <!--ws:if tool=codebase-search-->
471
503
  ```
472
- codebase-stats/codebase-search → codebase-incoming-calls/outgoing-calls → grep/glob as needed → read → edit/write/patchread → verify
504
+ codebase-stats/codebase-search → codebase-incoming-calls/outgoing-calls → read → edit → verify
473
505
  ```
474
506
  1. **Locate** the target (`codebase-search` first for indexed code; otherwise the best-fit `grep` or `glob` fallback)
475
507
  2. **Assess impact** (`codebase-incoming-calls` to find all callers before editing; `codebase-outgoing-calls` to understand dependencies)
508
+ <!--ws:if tool=codebase-impact-analysis-->
509
+ Before changing a signature or type, run `codebase-impact-analysis`.
510
+ <!--ws:end-->
476
511
  <!--ws:else-->
477
512
  ```
478
513
  grep/glob → read → edit/write/patch → read → verify
@@ -482,11 +517,21 @@ grep/glob → read → edit/write/patch → read → verify
482
517
  <!--ws:end-->
483
518
  3. **Read** the relevant files before changing anything
484
519
  4. **Edit** surgically with `edit` (preferred) or `write` (new files only)
520
+ <!--ws:if tool=codebase-ast-replace-->
521
+ Prefer `codebase-ast-replace` when replacing an existing function, method, or class body.
522
+ <!--ws:end-->
523
+ <!--ws:if tool=codebase-invariant-check-->
524
+ Run `codebase-invariant-check` before a signature change if compatibility matters.
525
+ <!--ws:end-->
485
526
  5. **Read** the result back to confirm correctness
527
+ <!--ws:if tool=codebase-targeted-test-->
528
+ 6. **Verify** with `codebase-targeted-test` for the changed symbol or file, then {{tools:lint,typecheck,test}} as appropriate
529
+ <!--ws:else-->
486
530
  <!--ws:if tool=lint,typecheck,test-->
487
531
  6. **Verify** with {{tools:lint,typecheck,test}} as appropriate
488
532
  <!--ws:end-->
489
533
  <!--ws:end-->
534
+ <!--ws:end-->
490
535
 
491
536
  <!--ws:if tool=batch_tool_use,delegate,spawn_subagent,collab_debug-->
492
537
  ### Fan-out pattern (parallel work)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/core",
3
- "version": "0.306.4",
3
+ "version": "0.307.1",
4
4
  "license": "MIT",
5
5
  "description": "WrongStack core: kernel, types, defaults, and shared utilities for the WrongStack CLI agent.",
6
6
  "repository": {
@@ -145,6 +145,10 @@
145
145
  "types": "./dist/tasking/index.d.ts",
146
146
  "import": "./dist/tasking/index.js"
147
147
  },
148
+ "./prompts": {
149
+ "types": "./dist/prompts/index.d.ts",
150
+ "import": "./dist/prompts/index.js"
151
+ },
148
152
  "./chronicle": {
149
153
  "types": "./dist/chronicle/index.d.ts",
150
154
  "import": "./dist/chronicle/index.js"
@@ -177,18 +181,18 @@
177
181
  "wrongstackApiVersion": "0.1.10",
178
182
  "dependencies": {
179
183
  "zod": "4.4.3",
180
- "@wrongstack/kanban": "0.306.4",
181
- "@wrongstack/persistence": "0.306.4"
184
+ "@wrongstack/kanban": "0.307.1",
185
+ "@wrongstack/persistence": "0.307.1"
182
186
  },
183
187
  "devDependencies": {
184
- "@types/node": "^26.1.2",
188
+ "@types/node": "^26.2.0",
185
189
  "typescript": "^7.0.2"
186
190
  },
187
191
  "publishConfig": {
188
192
  "access": "public"
189
193
  },
190
194
  "optionalDependencies": {
191
- "@datadog/pprof": "5.17.0"
195
+ "@datadog/pprof": "5.18.0"
192
196
  },
193
197
  "scripts": {
194
198
  "build": "node ../../scripts/build-package.mjs",