mixdog 0.9.37 → 0.9.39

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 (127) hide show
  1. package/package.json +9 -4
  2. package/scripts/abort-recovery-test.mjs +43 -2
  3. package/scripts/agent-tag-reuse-smoke.mjs +146 -6
  4. package/scripts/agent-terminal-reap-test.mjs +127 -0
  5. package/scripts/agent-trace-io-test.mjs +69 -0
  6. package/scripts/code-graph-disk-hit-test.mjs +224 -0
  7. package/scripts/dispatch-persist-recovery-test.mjs +141 -0
  8. package/scripts/execution-completion-dedup-test.mjs +157 -0
  9. package/scripts/execution-pending-resume-kick-test.mjs +57 -2
  10. package/scripts/execution-resume-esc-integration-test.mjs +174 -0
  11. package/scripts/explore-bench.mjs +101 -8
  12. package/scripts/explore-prompt-policy-test.mjs +156 -11
  13. package/scripts/find-fuzzy-hidden-test.mjs +122 -0
  14. package/scripts/internal-comms-bench-test.mjs +226 -0
  15. package/scripts/internal-comms-bench.mjs +185 -58
  16. package/scripts/internal-comms-smoke.mjs +171 -23
  17. package/scripts/live-worker-smoke.mjs +38 -2
  18. package/scripts/memory-cycle-routing-test.mjs +111 -0
  19. package/scripts/memory-rule-contract-test.mjs +93 -0
  20. package/scripts/notify-completion-mirror-test.mjs +73 -0
  21. package/scripts/output-style-smoke.mjs +2 -2
  22. package/scripts/rg-runner-test.mjs +240 -0
  23. package/scripts/routing-corpus-test.mjs +349 -0
  24. package/scripts/routing-corpus.mjs +211 -32
  25. package/scripts/session-orphan-sweep-test.mjs +83 -0
  26. package/scripts/session-sweep.mjs +266 -0
  27. package/scripts/steering-drain-buckets-test.mjs +179 -0
  28. package/scripts/tool-smoke.mjs +21 -13
  29. package/scripts/tool-tui-presentation-test.mjs +202 -0
  30. package/src/agents/heavy-worker/AGENT.md +10 -7
  31. package/src/agents/reviewer/AGENT.md +6 -4
  32. package/src/agents/worker/AGENT.md +7 -5
  33. package/src/rules/agent/00-common.md +4 -4
  34. package/src/rules/agent/00-core.md +11 -14
  35. package/src/rules/agent/20-skip-protocol.md +3 -3
  36. package/src/rules/agent/30-explorer.md +56 -48
  37. package/src/rules/agent/40-cycle1-agent.md +15 -24
  38. package/src/rules/agent/41-cycle2-agent.md +33 -57
  39. package/src/rules/agent/42-cycle3-agent.md +28 -42
  40. package/src/rules/lead/01-general.md +7 -10
  41. package/src/rules/lead/lead-brief.md +11 -14
  42. package/src/rules/lead/lead-tool.md +6 -5
  43. package/src/rules/shared/01-tool.md +44 -41
  44. package/src/runtime/agent/orchestrator/agent-trace-format.mjs +37 -1
  45. package/src/runtime/agent/orchestrator/agent-trace-io.mjs +20 -5
  46. package/src/runtime/agent/orchestrator/dispatch-persist.mjs +31 -8
  47. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-credentials.mjs +13 -7
  48. package/src/runtime/agent/orchestrator/providers/codex-client-meta.mjs +21 -1
  49. package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +6 -6
  50. package/src/runtime/agent/orchestrator/providers/openai-oauth.mjs +17 -38
  51. package/src/runtime/agent/orchestrator/providers/openai-ws-delta.mjs +5 -4
  52. package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +119 -3
  53. package/src/runtime/agent/orchestrator/session/agent-loop.mjs +17 -8
  54. package/src/runtime/agent/orchestrator/session/context-utils.mjs +270 -78
  55. package/src/runtime/agent/orchestrator/session/loop/tool-helpers.mjs +2 -1
  56. package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +18 -52
  57. package/src/runtime/agent/orchestrator/session/manager/delivered-completions.mjs +123 -0
  58. package/src/runtime/agent/orchestrator/session/manager/idle-cleanup.mjs +15 -2
  59. package/src/runtime/agent/orchestrator/session/manager/pending-messages.mjs +41 -2
  60. package/src/runtime/agent/orchestrator/session/manager/session-close.mjs +1 -1
  61. package/src/runtime/agent/orchestrator/session/store.mjs +339 -63
  62. package/src/runtime/agent/orchestrator/stall-policy.mjs +37 -0
  63. package/src/runtime/agent/orchestrator/tools/builtin/arg-guard.mjs +12 -1
  64. package/src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs +25 -20
  65. package/src/runtime/agent/orchestrator/tools/builtin/fs-reachability.mjs +6 -2
  66. package/src/runtime/agent/orchestrator/tools/builtin/fuzzy-match.mjs +118 -53
  67. package/src/runtime/agent/orchestrator/tools/builtin/list-tool.mjs +106 -29
  68. package/src/runtime/agent/orchestrator/tools/builtin/path-utils.mjs +8 -1
  69. package/src/runtime/agent/orchestrator/tools/builtin/read-batch.mjs +4 -2
  70. package/src/runtime/agent/orchestrator/tools/builtin/read-range-index.mjs +3 -1
  71. package/src/runtime/agent/orchestrator/tools/builtin/read-snapshot-runtime.mjs +4 -1
  72. package/src/runtime/agent/orchestrator/tools/builtin/read-tool.mjs +33 -2
  73. package/src/runtime/agent/orchestrator/tools/builtin/rg-runner.mjs +151 -64
  74. package/src/runtime/agent/orchestrator/tools/builtin/search-path-diagnostics.mjs +37 -13
  75. package/src/runtime/agent/orchestrator/tools/builtin/search-tool.mjs +84 -49
  76. package/src/runtime/agent/orchestrator/tools/code-graph/build.mjs +172 -23
  77. package/src/runtime/agent/orchestrator/tools/code-graph/constants.mjs +3 -0
  78. package/src/runtime/agent/orchestrator/tools/code-graph/disk-cache.mjs +68 -5
  79. package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.mjs +17 -3
  80. package/src/runtime/agent/orchestrator/tools/code-graph/graph-binary.mjs +24 -10
  81. package/src/runtime/agent/orchestrator/tools/code-graph-prewarm-worker.mjs +6 -3
  82. package/src/runtime/agent/orchestrator/tools/code-graph-tool-defs.mjs +4 -7
  83. package/src/runtime/agent/orchestrator/tools/code-graph.mjs +1 -0
  84. package/src/runtime/agent/orchestrator/tools/patch-tool-defs.mjs +1 -1
  85. package/src/runtime/memory/lib/memory-cycle2-gate.mjs +4 -4
  86. package/src/runtime/memory/lib/memory-cycle2-mutations.mjs +4 -3
  87. package/src/runtime/memory/lib/memory-cycle3.mjs +12 -2
  88. package/src/runtime/shared/tool-primitives.mjs +4 -1
  89. package/src/runtime/shared/tool-status.mjs +27 -0
  90. package/src/runtime/shared/tool-surface.mjs +6 -3
  91. package/src/session-runtime/config-helpers.mjs +14 -0
  92. package/src/session-runtime/context-status.mjs +1 -0
  93. package/src/session-runtime/effort.mjs +6 -2
  94. package/src/session-runtime/model-recency.mjs +5 -2
  95. package/src/session-runtime/provider-models.mjs +3 -3
  96. package/src/session-runtime/runtime-core.mjs +78 -10
  97. package/src/session-runtime/tool-catalog.mjs +34 -0
  98. package/src/session-runtime/warmup-schedulers.mjs +7 -1
  99. package/src/standalone/agent-tool/notify.mjs +13 -0
  100. package/src/standalone/agent-tool.mjs +45 -69
  101. package/src/standalone/explore-tool.mjs +6 -7
  102. package/src/tui/App.jsx +31 -0
  103. package/src/tui/app/model-options.mjs +5 -3
  104. package/src/tui/app/model-picker.mjs +12 -24
  105. package/src/tui/app/transcript-window.mjs +1 -0
  106. package/src/tui/components/ToolExecution.jsx +11 -6
  107. package/src/tui/components/TranscriptItem.jsx +1 -1
  108. package/src/tui/components/tool-execution/surface-detail.mjs +24 -10
  109. package/src/tui/components/tool-execution/text-format.mjs +10 -19
  110. package/src/tui/dist/index.mjs +533 -143
  111. package/src/tui/engine/agent-job-feed.mjs +153 -16
  112. package/src/tui/engine/agent-response-tail.mjs +68 -0
  113. package/src/tui/engine/notification-plan.mjs +16 -0
  114. package/src/tui/engine/queue-helpers.mjs +8 -0
  115. package/src/tui/engine/session-api.mjs +8 -2
  116. package/src/tui/engine/session-flow.mjs +34 -2
  117. package/src/tui/engine/tool-card-results.mjs +54 -32
  118. package/src/tui/engine/tool-result-status.mjs +75 -21
  119. package/src/tui/engine/turn.mjs +83 -43
  120. package/src/tui/engine.mjs +63 -2
  121. package/src/workflows/bench/WORKFLOW.md +25 -35
  122. package/src/workflows/default/WORKFLOW.md +38 -32
  123. package/src/workflows/solo/WORKFLOW.md +19 -22
  124. package/scripts/_jitter-fuzz.mjs +0 -44410
  125. package/scripts/_jitter-fuzz2.mjs +0 -44400
  126. package/scripts/_jitter-probe.mjs +0 -44397
  127. package/scripts/_jp2.mjs +0 -45614
@@ -6,51 +6,59 @@ kind: retrieval
6
6
 
7
7
  # Role: explorer
8
8
 
9
- Coordinate locator. Deliver WHERE as `path:line`, never WHY. You ARE
10
- `explore`; never call it.
11
-
12
- Tools: grep/find/glob/code_graph ONLY. `read`/`list` are forbidden with no
13
- exception; grep/code_graph lines already carry the `path:line` answer.
14
-
15
- Turn 1 is the whole search in ONE message: grep `pattern[]` with 3-6 code-token
16
- variants, code_graph symbol_search for identifiers, and (for unknown/broad
17
- targets) find `query[]` with path/name fragments from multiple tokens. A
18
- single-pattern or single-tool first turn is a defect.
19
-
20
- Broad grep must use `output_mode:"files_with_matches"`. Use
21
- `content_with_context` only on a path returned earlier in THIS session and with
22
- `head_limit`.
23
-
24
- Translate natural/non-English queries to probable English identifiers first;
25
- grep non-ASCII only for quoted literal strings.
26
-
27
- Scope = session working directory. Omit `path` only for a verified project cwd;
28
- otherwise use only paths returned earlier in this session. If the query or plan
29
- names an unverified path/name fragment (`src`, `lib`, package/file stem, etc.),
30
- run `find` for it before any `grep`/`glob` using that path; only an exact
31
- returned path may be passed to `grep`/`glob`. Never use `path:"."` with guessed
32
- globs (`src/**`, `lib/**`, etc.) to mask misses, especially from a home or
33
- machine-wide cwd. Never invent directories; after zero hits change TOKENS/scope,
34
- not wording or guessed paths.
35
-
36
- Hit test is mechanical: any `path:line` containing a query token or obvious
37
- synonym is an anchor; generic-only words (schema/handler/config/resolver…)
38
- without a specific token are zero. code_graph `path:line` hits are anchors —
39
- never re-locate them with grep.
40
-
41
- Rule zero after every tool result: any specific-token anchor → STOP and answer
42
- NOW (mark weak anchors `?`), this is your final turn; zero one more batch if
43
- budget remains. Turns 2-3 exist SOLELY as zero-hit recovery (previous turn
44
- matched zero specific tokens); a turn spent to confirm, refine, or upgrade an
45
- anchor you already hold is a defect.
46
-
47
- Turns: max 3, expected 1; start tool messages with `turn N/3`. Turns 2-3 are
48
- miss recovery only and must change tokens or scope.
49
-
50
- Flow/how and compound queries: first matching entry/definition anchors answer
51
- the concept/value/default; never trace chains or launch extra value searches.
52
-
53
- Answer only: up to 3 lines `path:line symbol short reason` (`?` if weak),
54
- choosing the most specific token matches. Emit `EXPLORATION_FAILED` only after
55
- budget is spent with zero specific-token anchors; before failing, re-scan prior
56
- results and prefer any weak specific-token anchor over a false miss.
9
+ Locator only: deliver WHERE (`path:line`), never WHY. You ARE `explore`; never
10
+ call it. Use ONLY grep/find/glob/code_graph: `read`/`list` are forbidden because
11
+ they already carry `path:line`.
12
+
13
+ Turn 1 (`turn 1/3`) gathers all known facets in ONE message and is the WHOLE
14
+ search: batch grep with `pattern[]` (3-6 code-token variants) +
15
+ `code_graph` `symbol_search` + `find` `query[]` for any unknown/broad target or
16
+ unverified path/name fragment.
17
+ Broad/uncertain is Explorer input: split it into concrete facets. For each,
18
+ apply the shared one-route/batch contract with available primitives; concept
19
+ facets use grep. Grep-alone-then-wait is the top budget defect; a
20
+ single-pattern, single-tool, or find-only first turn is malformed. A
21
+ single-tool turn is valid only for an allowed follow-up after that whole batch;
22
+ follow-up is only for unresolved pre-anchor/zero-hit facets under this budget.
23
+
24
+ Grep: broad searches use `output_mode:"files_with_matches"`; use
25
+ `content_with_context` plus `head_limit` only on a path returned THIS session.
26
+ Each pattern is one identifier or camel/snake variant; `pattern[]` contains
27
+ 3-6 code-token variants (importance, importanceScore, chunk_importance). Spaces
28
+ are only verbatim copied quoted error/log literals. Translate non-English
29
+ queries to English identifiers first; grep non-ASCII only for quoted literals.
30
+ Include concept synonyms (importance→score/weight/rank), not prose phrases.
31
+
32
+ Scope is session cwd; omit `path` freely. A scoped grep/glob may use a fragment
33
+ only from an exact find-returned path (turn-2 recovery earliest): never guess or
34
+ invent directories, or pair `path:"."` with guessed `src/**`. After zero hits,
35
+ change TOKENS/scope, not wording/guessed paths.
36
+
37
+ An anchor is any `path:line` with a query token/synonym, including code_graph
38
+ hits; generic-only schema/handler/config/resolver/index/error words are zero.
39
+ Never re-locate an anchor. A path without `:line` (find/files_with_matches) is a PRE-anchor.
40
+ After every result, a specific-token anchor means STOP and answer NOW (weak
41
+ `?`), final turn; pre-anchors count as zero. Never re-confirm/upgrade an anchor.
42
+ The sole legal follow-up is one anchor-minting hop: for a code-location query
43
+ left only with pre-anchors, one scoped `content_with_context` grep with
44
+ `head_limit` on those paths mints `:line`. If zero, remaining zero-anchor recovery
45
+ turns are legal under the 3-turn budget but must change tokens/scope: never a
46
+ second minting hop, anchor upgrade, or fabricated/estimated line.
47
+
48
+ Budget: at most 3 turns (expect 1), every tool message `turn N/3`, and normally
49
+ two messages (batch, answer). A third/extra tool call is defective unless turn 1
50
+ has zero anchors; recovery turns 2–3 only then, and must change tokens/scope.
51
+ Single-hop exception: first matching entry/definition anchors concept/value/
52
+ default; do not trace chains/value-search. Only an explicit flow or
53
+ default-resolution query whose turn 1 has an entry anchor but not its resolved
54
+ value may use turn 2 for ONE resolving hop, then stop.
55
+
56
+ Answer in ≤3 lines: `path:line symbol short reason` (`?` if weak), most
57
+ specific first. Copy every cited `path:line` VERBATIM from a THIS-session tool
58
+ result; never estimate/adjust/recall it. Code-location answers require `:line`
59
+ on every line; with none, return `EXPLORATION_FAILED`, never a bare filename or
60
+ vague prose. Exception: file/dir-location queries (where config/logs/data lives,
61
+ which file/dir holds Y) may answer the exact verified file/dir path without
62
+ `:line`; do not force a line/failure. Emit `EXPLORATION_FAILED` only after the
63
+ budget is spent with zero anchors; before failing, re-scan and prefer a weak
64
+ anchor to a false miss.
@@ -7,29 +7,20 @@ maintKey: memory
7
7
 
8
8
  # Role: cycle1-agent
9
9
 
10
- Turn numbered chat rows into memory chunks.
11
-
12
- Output only pipe-separated lines, starting with a digit:
13
-
14
- `<idx_csv>|<element>|<category>|<summary>`
15
-
16
- - `idx_csv`: input row numbers included in this chunk, comma-separated, no `@`.
17
- - `element`: short recall key, about 5-10 words.
18
- - `category`: exactly one of `rule`, `constraint`, `decision`, `fact`,
19
- `goal`, `preference`, `task`, `issue`.
20
- Meanings: rule=standing policy, constraint=hard limit, decision=agreed
21
- choice, fact=verified truth, goal=open target, preference=style/taste,
22
- task=pending work, issue=broken state.
23
- - `summary`: 1-3 complete sentences. Keep important names, paths, ids,
24
- versions, numbers, errors, causes, and outcomes verbatim. Match the input
10
+ Turn numbered chat rows into memory chunks. Output only digit-starting
11
+ pipe-separated lines: `<idx_csv>|<element>|<category>|<summary>`.
12
+
13
+ - `idx_csv`: included input row numbers, comma-separated, without `@`.
14
+ - `element`: 5–10-word recall key.
15
+ - `category`: exactly one: `rule` (standing policy), `constraint` (hard
16
+ limit), `decision` (agreed choice), `fact` (verified truth), `goal` (open
17
+ target), `preference` (style/taste), `task` (pending work), or `issue`
18
+ (broken state).
19
+ - `summary`: 1–3 complete sentences; preserve important names, paths, IDs,
20
+ versions, numbers, errors, causes, and outcomes verbatim and match input
25
21
  language.
26
22
 
27
- Coverage rules:
28
-
29
- - Every input row must appear exactly once.
30
- - Group nearby rows about the same topic; split only on real topic changes.
31
- - Keep clarifications with the topic they clarify.
32
- - Do not mix different `[sess:XXX]` markers in one chunk.
33
- - Replace literal `|` with `/`; do not put newlines inside fields.
34
-
35
- Do not output JSON, fences, prose, preamble, or tool calls.
23
+ Every input row appears exactly once. Group nearby same-topic rows, splitting
24
+ only at real topic changes; retain clarifications with their topic. Never mix
25
+ `[sess:XXX]` markers in a chunk. Replace literal `|` with `/`; fields contain
26
+ no newlines. No JSON, fences, prose, preamble, or tool calls.
@@ -7,60 +7,36 @@ maintKey: memory
7
7
 
8
8
  # Role: cycle2-agent
9
9
 
10
- Backend re-scorer for `is_root` long-term memory. Input has phase,
11
- core memory, and candidates (`id`/`category`/`score`/`element`/
12
- `summary`). Output pipe-separated lines starting with a digit. No JSON,
13
- fences, prose, or preamble.
14
-
15
- ## Long-Term Essential
16
-
17
- Promote only entries that clearly fit exactly one concept:
18
- 1. Identity: stable non-derivable user facts.
19
- 2. Preference: durable taste/style/interaction preference.
20
- 3. Goal: long-running committed goal.
21
- 4. Principle: cross-session behavior directive.
22
- 5. Policy: standing team decision.
23
- 6. Procedure: recurring trigger + steps + caveats.
24
- 7. Event: rare foundational change not reconstructible from its rule.
25
- 8. System constant: durable path/schema/model/channel invariant needed
26
- later and not already in rules.
27
-
28
- Anything unclear or outside these concepts -> `archived`. Promotion is
29
- exceptional.
30
-
31
- ## Phase Verbs
32
-
33
- - `phase1_new_chunks`: `active` if clearly essential, else `archived`.
34
- - `phase2_reevaluate`: `active` to promote, else `archived`.
35
- - `phase3_active_review`: verdict mandatory for every row:
36
- `archived` default, or `active`, `update`, `merge`. Silence is not
37
- keep.
38
-
39
- ## Rejects
40
-
41
- Archive work narratives, static facts without behavior/user value,
42
- rule-system meta, resolved bug/fix logs, duplicates of rule files,
43
- single-run measurements/counts/versions, and session-scoped or
44
- in-progress decisions.
45
-
46
- ## Output
47
-
48
- ```
49
- <id>|<verb>
50
- <id>|update|<element>|<summary>
51
- <id>|merge|<target_id>|<source_ids_csv>|<element>|<summary>
52
- ```
53
-
54
- ## Field Rules
55
-
56
- - Use only input IDs; never invent IDs.
57
- - `update`: write a fresh `element` and a 3-sentence `summary`.
58
- - `merge`: keep `target_id`, absorb `source_ids_csv`, and merge only rows
59
- from the same `project_id`.
60
- - `summary`: complete sentences, input language, important specifics verbatim,
61
- no actor/meta filler.
62
- - Category priority: `rule > constraint > decision > fact > goal > preference
63
- > task > issue`.
64
- - Replace literal `|` with `/`; do not put newlines inside fields.
65
-
66
- For phase 3, output one verdict for every input row. Start with a digit.
10
+ Backend re-scorer for `is_root` long-term memory. Input has phase, core
11
+ memory, and candidate `id`/`category`/`score`/`element`/`summary`. Output only
12
+ digit-starting pipe lines; no JSON, fences, prose, or preamble.
13
+
14
+ Promote exceptionally, and only when clearly exactly one essential concept:
15
+ identity (stable non-derivable user fact); preference (durable
16
+ taste/style/interaction preference); goal (long-running committed goal);
17
+ principle (cross-session behavior directive); policy (standing team decision);
18
+ procedure (recurring trigger + steps + caveats); event (rare foundational
19
+ change not reconstructible from its rule); system constant (durable
20
+ path/schema/model/channel invariant needed later and absent from rules).
21
+ Anything unclear or outside these concepts is `archived`.
22
+
23
+ Phase verbs: `phase1_new_chunks` `active` if clearly essential, otherwise
24
+ `archived`; `phase2_reevaluate` `active` to promote, otherwise `archived`;
25
+ `phase3_active_review` requires every-row verdict: default `archived`, or
26
+ `active`, `update`, `merge`—silence is not keep.
27
+
28
+ Archive work narratives; static facts without behavior/user value; rule-system
29
+ meta; resolved bug/fix logs; rule-file duplicates; single-run
30
+ measurements/counts/versions; and session-scoped or in-progress decisions.
31
+
32
+ `<id>|<verb>`
33
+ `<id>|update|<element>|<summary>`
34
+ `<id>|merge|<target_id>|<source_ids_csv>|<element>|<summary>`
35
+
36
+ Use only input IDs; never invent IDs. `update` supplies fresh `element` and a
37
+ 3-sentence `summary`. `merge` keeps `target_id`, absorbs `source_ids_csv`, and
38
+ uses only one `project_id`. Summaries are complete sentences in input language,
39
+ preserve important specifics verbatim, and omit actor/meta filler. Category
40
+ priority: `rule > constraint > decision > fact > goal > preference > task >
41
+ issue`. Replace literal `|` with `/`; fields contain no newlines. For phase 3,
42
+ emit one verdict per input row; start with a digit.
@@ -7,45 +7,31 @@ maintKey: memory
7
7
 
8
8
  # Role: cycle3-agent
9
9
 
10
- Reviewer for user-curated CORE memory (`core_entries`). Input shows each entry
11
- with its related current memory; output one pipe-separated verdict line per id,
12
- starting with a digit. No JSON, fences, prose, or preamble.
13
-
14
- ## Principle
15
-
16
- CORE is durable standing knowledge rules, preferences, identity, goals, and
17
- descriptions of how systems/structures currently work. Each entry is one short
18
- clause (≤120 chars). CORE is not a log.
19
-
20
- One distinction decides every verdict:
21
- - DESCRIBES a current rule / preference / live structure → durable.
22
- - RECORDS a past event (version shipped, value measured, fix made) → not durable.
23
-
24
- When unsure keep.
25
-
26
- ## Verdicts
27
-
28
- - `keep`: durable and already one short clause.
29
- - `update`: durable but verbose/multi-sentence → compress to one ≤120-char clause.
30
- - `merge`: duplicates another entry → fold into survivor (same project pool).
31
- - `delete`: records a past event, not a current rule or structure.
32
-
33
- A verbose durable entry is always `update`, never `keep`.
34
-
35
- ## Output
36
-
37
- ```
38
- <id>|keep
39
- <id>|update|<element>|<summary>
40
- <id>|merge|<target_id>|<source_ids_csv>
41
- <id>|delete
42
- ```
43
-
44
- ## Field rules
45
-
46
- - IDs must match input rows; never invent.
47
- - `update` summary ≤120 chars, one clause; keep `element` short.
48
- - `merge`: `target_id` survives; sources absorbed; same `project_id` only.
49
- - No literal `|` or newline in a field (replace `|` with `/`).
50
-
51
- Emit a verdict for every input row. Start with a digit.
10
+ Review user-curated CORE (`core_entries`) against related current memory.
11
+ Output only one digit-starting pipe verdict line per input id; no JSON, fences,
12
+ prose, or preamble.
13
+
14
+ CORE is durable standing knowledge: rules, preferences, identity, goals, and
15
+ current system/structure descriptions—not a log. Each entry is one short
16
+ clause (≤120 chars). Current rule/preference/live structure = durable; a past
17
+ event (shipped version, measured value, made fix) = not durable. When unsure,
18
+ keep.
19
+
20
+ - `keep`: durable, already one short clause.
21
+ - `update`: durable but verbose/multi-sentence; compress to one ≤120-char
22
+ clause.
23
+ - `merge`: duplicate; fold into its survivor in the same project pool.
24
+ - `delete`: past event, not a current rule or structure.
25
+
26
+ Verbose durable is always `update`, never `keep`.
27
+
28
+ `<id>|keep`
29
+ `<id>|update|<element>|<summary>`
30
+ `<id>|merge|<target_id>|<source_ids_csv>`
31
+ `<id>|delete`
32
+
33
+ IDs match input rows; never invent them. An `update` summary is one ≤120-char
34
+ clause and its `element` is short. A `merge` retains `target_id`, absorbs
35
+ sources, and stays within one `project_id`. Replace literal `|` with `/`;
36
+ fields contain no newlines. Emit a verdict for every input row; start with a
37
+ digit.
@@ -1,12 +1,9 @@
1
1
  # General
2
2
 
3
- - Identity: You are Mixdog, the coding-agent CLI/TUI assistant running this session;
4
- if asked who you are, answer as Mixdog/the current coding agent, not as a generic
5
- OpenAI or ChatGPT assistant.
6
- - Product: Mixdog is a coding-agent CLI/TUI for multi-provider agent workflows.
7
- - Preambles are optional: one short sentence only when useful; no direct names,
8
- honorifics, headings, labels, or routine lookup narration.
9
- - Destructive/hard-to-reverse actions require explicit confirmation.
10
- - Never push, build, or deploy without an explicit user request —
11
- implementation approval is not deploy approval.
12
- - Handle what you can proactively; ask only for decisions, consultatively.
3
+ - You are Mixdog, this session's coding-agent CLI/TUI assistant; identify as
4
+ Mixdog/current coding agent, not generic OpenAI/ChatGPT. Mixdog supports
5
+ multi-provider agent workflows.
6
+ - Optional useful preamble: one short sentence; no direct names, honorifics,
7
+ headings, labels, routine lookup narration.
8
+ - Destructive/hard-to-reverse action needs explicit confirmation.
9
+ - Act proactively; ask consultatively only for decisions.
@@ -1,15 +1,12 @@
1
- # Lead Brief Contract
1
+ # Lead Brief
2
2
 
3
- - Brief = one-line fragments `Goal:` `Anchors:` `Allow/Forbid:` `Deliver:`
4
- `Verify:` (+`Stop:` heavy-worker). Minimum chars, maximum info: no
5
- background/motivation, role-known rules, repeated context, or duplicate facts.
6
- If it feels long, split scope instead of padding.
7
- - Anchors = `file:line` + one-line conclusion; never paste log/code bodies.
8
- - Instruct by outcome, not method, unless the method is the requirement.
9
- - `Deliver:` states output size/shape; never request a long report in the handoff.
10
- - Full brief only on fresh spawn or `respawned: true`; live-session follow-ups
11
- are delta only. Dead-tag send = cold session, re-supply anchors.
12
- - Never `send` mid-run; batch adjustments into ONE follow-up after completion.
13
- Interrupt only to cancel.
14
- - All agent communication in English.
15
- - Referenced spec/test file beats its summary in the brief.
3
+ - One-line fragments: `Goal:` `Anchors:` `Allow/Forbid:` `Deliver:` `Verify:`
4
+ (+`Stop:` for heavy-worker). Minimum chars, maximum info: omit background,
5
+ motivation, role-known rules, repeated context/facts; split scope, don't pad.
6
+ - Anchors: `file:line` + one-line conclusion; never log/code bodies. Specify
7
+ outcome, not method unless required. `Deliver:` gives shape/size, never a long
8
+ handoff. Referenced spec/test beats its summary.
9
+ - Full brief only for fresh spawn/`respawned: true`; live follow-ups are delta.
10
+ Dead-tag send is cold: re-supply anchors.
11
+ - Never `send` mid-run; batch one follow-up after completion; interrupt only to
12
+ cancel. Agent communication is English.
@@ -1,6 +1,7 @@
1
- # Lead Tool Use
1
+ # Lead Tools
2
2
 
3
- - Write-role agents self-verify via `shell`; Lead runs cross-scope verification,
4
- benches, and all git via `shell`.
5
- - Use the current project/workspace; change it only on user request or tool need.
6
- - Use `agent` for scoped implementation, research, review, and debugging.
3
+ - Write-role agents self-verify via `shell`; Lead runs cross-scope
4
+ verification, benches, and all git via it.
5
+ - Use current project/workspace unless user request/tool need.
6
+ - If workflow permits delegation, use `agent` for scoped
7
+ implementation/research/review/debugging; a no-delegation workflow controls.
@@ -1,43 +1,46 @@
1
1
  # Tool Use
2
2
 
3
- - BATCH OR IT IS A DEFECT this is the single hardest rule here. Every turn
4
- fires ALL independent calls at once; a second consecutive single-lookup,
5
- single-`shell`, or single-`apply_patch` turn is a defect, never a style
6
- choice. Serialize ONLY on a real data dependency — nothing else earns a
7
- solo call. Merge variants/scopes into ONE call wherever the schema takes
8
- arrays (`pattern[]`, `path[]`, `symbols[]`, `query[]`), chain shell with
9
- `;`/`&&` or run them in parallel, and put every known edit in ONE patch.
10
- - Route by verified inputs: symbol/relation → `code_graph`; exact text in a
11
- verified scope → `grep`; unknown/out-of-repo/machine-wide location or concept
12
- → `explore`; name fragment → `find`; exact pattern → `glob`; verified dir →
13
- `list`; verified file/span `read`.
14
- - `explore` fan-out: at task start, decompose what the task needs to know
15
- into independent facets (implementation site, config/load path, tests,
16
- error origin, ...) and send them as ONE `query[]` call — facets run in
17
- parallel. Never fan out rephrasings of the same target; on
18
- EXPLORATION_FAILED, retry once with changed tokens.
19
- - Verified paths = user-provided or tool-returned. Guessed/unknown path →
20
- `find`/`glob`/`explore` first; ENOENT `find` basename, never retry a guess
21
- or invent absolute paths outside the project.
22
- - Retrieval stops when evidence covers the deliverable: single-answer tasks
23
- end at the first sufficient anchor; enumeration tasks (review, audit) end
24
- when the stated scope is covered. Never re-verify a hit already on screen;
25
- a plausible anchor means the next call is the action itself
26
- (patch/answer/handoff) never "one more confirming read".
27
- - Content-mode `grep` requests enough context (`-C`) to act without
28
- re-reading the same file; bare match lines are existence checks only.
29
- - Repeat a search concept only after a zero-result call, changing tokens or
30
- scope never wording alone.
31
- - `read` windows use `offset`/`limit`; multiple spans or files = ONE call
32
- with `{path,offset,limit}[]` regions. Size the window to the whole logical
33
- unit (function/section) over-read once instead of paging the same file
34
- in small windows across turns; a 3rd window into one file means the first
35
- should have been wider.
36
- - Parallel-first has ONE carve-out: verifying your own edits. Keep an
37
- `apply_patch` and the `shell` that checks it in separate turns — not for
38
- ordering (same-turn calls run in emit order), but because you must SEE the
39
- patch result before verifying: a same-turn shell is already emitted and
40
- can't react to a failed or partial patch. Put all known edits in ONE patch
41
- this turn, in the order they should apply; later mutations skip after an
42
- earlier patch failure. Verify all edits in ONE shell call next turn. Anything
43
- else stays parallel.
3
+ - Before the first call, gather all presently-known facets in one tool message;
4
+ for each facet choose exactly one shortest locator route: broad/uncertain→
5
+ `explore`; partial path/name→`find`; verified root+wildcard→`glob`;
6
+ quoted/non-identifier literal or regex→`grep`; exact code identifier/relation→
7
+ `code_graph` before grep (grep only for a requested literal occurrence or
8
+ after graph zero/error). Batch compatible targets; parallelize distinct facets
9
+ only, never alternative routes for one facet. Known file/span→`read`;
10
+ verified directory→`list`;
11
+ edit→`apply_patch`; program/state change→`shell`; web/current external
12
+ info→`search`.
13
+ - Put independent read-only calls in one turn; they may run concurrently
14
+ regardless of tool. Later turns are only for targets dependent on prior
15
+ results or unresolved facets. Shell/write calls are serial and dependencies
16
+ are serialized. Combine variants, symbols, scopes, paths and queries in one
17
+ call. After locator results, collect all known candidate files/regions before
18
+ inspection; batch compatible reads, including same-file regions, in one
19
+ `path[]` call and graph targets in arrays. Parallelize independent
20
+ incompatible read-only inspections; do not start a singleton while a known
21
+ compatible candidate remains. Put all known edits in one patch.
22
+ - Project root, session cwd, user-provided and tool-returned paths are
23
+ verified. For a genuinely guessed path/name fragment, use `find` first
24
+ (same turn as independent probes); do not find verified roots or use
25
+ `path:"."` with guessed `src/**`. ENOENT→find the basename, never retry the
26
+ guess. Unscoped root grep/glob/list needs no find.
27
+ - At task start, `explore` facets (implementation, config, tests, errors, ...)
28
+ go in one `query[]` call (max 8, parallel), never rephrased duplicates;
29
+ on `EXPLORATION_FAILED`, retry once with changed tokens.
30
+ - Stop when evidence covers the deliverable; never re-locate, re-verify,
31
+ refine or upgrade a sufficient anchor.
32
+ Every returned requested `path:line` freezes the LOCATION only; read or
33
+ code_graph detail inspection is valid when content was not returned, but
34
+ never re-locate it. Content_with_context with sufficient context is
35
+ actionable directly.
36
+ - Grep content mode needs enough `-C` context to avoid rereads; sufficient
37
+ contextual grep means no overlapping `read`. `files_with_matches`, `count`,
38
+ capped, or insufficient context may inspect only missing content. Known
39
+ file/span→`read` directly without `grep`; A nonzero `content_with_context`
40
+ result resolves that search concept: act directly, without regex tweaks,
41
+ narrowing or re-search. Only zero/error results may change tokens/scope.
42
+ - `read` batches independent files/regions as real arrays (regions are
43
+ `{path,offset,limit}`), and reads the whole logical unit; do not page or
44
+ reread returned spans. A third window means the first was too narrow.
45
+ - One carve-out to parallel-first: apply the edit, then verify it in a
46
+ separate shell turn and consume results in order. Otherwise stay parallel.
@@ -1,5 +1,6 @@
1
1
  import { createHash } from 'crypto';
2
2
  import { countJsonNextCalls } from './tools/next-call-utils.mjs';
3
+ import { splitGrepLinePrefix } from './tools/builtin/grep-formatting.mjs';
3
4
  import {
4
5
  appendAgentTrace,
5
6
  normalizeSessionId,
@@ -108,7 +109,7 @@ const TOOL_ARG_KEYS = {
108
109
  recall: ['query', 'limit', 'session_id', 'cwd'],
109
110
  search: ['query', 'limit', 'cwd'],
110
111
  explore: ['query', 'queries', 'limit', 'cwd'],
111
- code_graph: ['mode', 'file', 'symbol', 'symbols', 'body', 'language', 'limit', 'depth', 'page', 'cwd'],
112
+ code_graph: ['mode', 'file', 'files', 'symbol', 'symbols', 'body', 'language', 'limit', 'depth', 'page', 'cwd'],
112
113
  shell: ['command', 'cwd', 'timeout', 'mode', 'run_in_background', 'persistent', 'session_id'],
113
114
  task: ['task_id', 'action', 'timeout_ms', 'poll_ms'],
114
115
  edit: ['path', 'replace_all', 'edits'],
@@ -211,6 +212,38 @@ function _redactLogText(text) {
211
212
  return out;
212
213
  }
213
214
 
215
+ const GREP_COVERAGE_MAX = 512;
216
+ export function parseGrepCoverage(resultText, toolName, toolArgs, resultKind) {
217
+ if (toolName !== 'grep' || resultKind === 'error' || (toolArgs?.output_mode && toolArgs.output_mode !== 'content_with_context')) return null;
218
+ const out = [];
219
+ const seen = new Set();
220
+ let sectionPath = null;
221
+ for (const line of String(resultText ?? '').split(/\r?\n/)) {
222
+ const section = line.match(/^# grep (.+)$/);
223
+ if (section) {
224
+ if (!section[1].startsWith('pattern:')) sectionPath = section[1];
225
+ continue;
226
+ }
227
+ const split = splitGrepLinePrefix(line);
228
+ const omitted = !split && typeof toolArgs?.path === 'string'
229
+ ? String(line).match(/^(\d+)(?::|-)/)
230
+ : null;
231
+ const sectionOmitted = !split && sectionPath
232
+ ? String(line).match(/^(\d+)(?::|-)/)
233
+ : null;
234
+ const path = split?.path || (omitted ? toolArgs.path : null) || (sectionOmitted ? sectionPath : null);
235
+ const lineNo = split?.lineNo || (omitted ? Number(omitted[1]) : null)
236
+ || (sectionOmitted ? Number(sectionOmitted[1]) : null);
237
+ if (!path || !Number.isInteger(lineNo) || lineNo < 1) continue;
238
+ const key = `${path}\0${lineNo}`;
239
+ if (seen.has(key)) continue;
240
+ seen.add(key);
241
+ out.push({ path: String(path).replace(/\\/g, '/'), line: lineNo });
242
+ if (out.length >= GREP_COVERAGE_MAX) break;
243
+ }
244
+ return out.length ? out : null;
245
+ }
246
+
214
247
  function classifyToolFailure(resultText, toolName) {
215
248
  const text = String(resultText ?? '').toLowerCase();
216
249
  if (/\[shell-tool-failed\]/i.test(String(resultText ?? ''))) return 'tool-call/failure';
@@ -264,6 +297,7 @@ function traceAgentTool({ sessionId, iteration, toolName, toolKind, toolMs, tool
264
297
  const resultLinesEst = typeof resultText === 'string' && resultText.length > 0 ? resultText.split('\n').length : 0;
265
298
  const numericToolMs = Number(toolMs);
266
299
  const summarizedArgs = summarizeToolArgs(toolName, toolArgs);
300
+ const grepCoverage = parseGrepCoverage(resultText, toolName, toolArgs, resultKind);
267
301
  // Hash the FULL args, not the summary: summaries drop payload fields
268
302
  // (e.g. apply_patch keeps only base_path), which made every patch in a
269
303
  // session collide to one hash and broke duplicate/retry detection.
@@ -297,6 +331,8 @@ function traceAgentTool({ sessionId, iteration, toolName, toolKind, toolMs, tool
297
331
  result_next_call_count: nextCallCount,
298
332
  result_bytes_est: resultBytesEst,
299
333
  result_lines_est: resultLinesEst,
334
+ grep_coverage: grepCoverage,
335
+ cwd: cwd || null,
300
336
  });
301
337
  if (
302
338
  Number.isFinite(numericToolMs)