fapony 0.3.5 → 0.4.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.
package/README.md CHANGED
@@ -38,26 +38,9 @@ quietly counted as free.
38
38
 
39
39
  That is day one. Past that, fapony keeps what coding agents actually did — the frozen
40
40
  ledger of graded runs (rounds, pass/fail, cost per grade, readable via CLI, no new grades)
41
- plus the live mem log — through 3 MCP tools any agent can call. If you juggle more than
42
- one agent, this is the point: the numbers come from the same yardstick everywhere, so
43
- "which model earns its keep on which kind of task" becomes a data question instead of a
44
- vibe. On top of history it checks claims against git facts: handoff conformance and
45
- allowlisted evidence — with everything the agent claimed but couldn't prove marked as such.
46
-
47
- **What that question looks like answered, from one project's own (frozen — reads history,
48
- no new grades) ledger — the top of the `n≥5` frontier (`fapony stats --mode verdict --regime code`):**
49
-
50
- | model | tokens/pass | quality | n |
51
- |---|---|---|---|
52
- | `claude-opus-5` | 22.5M | 3.8 | 10 |
53
- | `claude-sonnet-5` | 5.6M | 3.5 | 11 |
54
- | `muse-spark-1.3-contributor-free` | 4.3M | 4.0 | 5 |
55
-
56
- Same quality band, an 8× token spread — the kind of answer a session log can't give (it has tokens,
57
- no grades) and a benchmark can't give either (it has grades, not your codebase). One caveat that's
58
- on you to hold: work isn't randomly assigned to models, so a gap this size is a strong prior, not a
59
- controlled trial — you likely route easy tasks to the cheap model already. `n≥5` is fapony's own
60
- floor before a model counts toward the frontier at all; below that it's a data point, not a pick.
41
+ plus the live mem log — through 3 MCP tools any agent can call. It checks claims against
42
+ git facts: handoff conformance and allowlisted evidence — with everything the agent claimed
43
+ but couldn't prove marked as such.
61
44
 
62
45
  **The reason to keep it running is the third layer: knowledge accumulation — and the thing it
63
46
  accumulates is pain.** An agent has no memory of pain across sessions: it writes the 37th
@@ -72,7 +55,7 @@ already decided on, that is the loop: notice the repeated cost, name the shared
72
55
  migration finish. Finding dead code and duplication is *not* part of it — knip and friends already
73
56
  do that better, and a convention with a `checker` is deliberately left to the checker.
74
57
 
75
- **The measurement layer underneath it:** Any single client already logs its own session — timing, tokens, tool calls. What none of them see is *across* runs, clients and task shapes: which model earns its keep on which kind of work **in this project**, at what token cost. The frozen ledger still answers that from history — every old verdict carries a `regime` (`code` / `fix` / `review` / `plan` / `inquiry` / `test`), and runs split by whether there was a plan at all — so "does planning beat diving in, and for which model" stays a table, not an argument. New accumulation goes to the mem log instead: decisions, bugs and notes with `files[]`, written by the agents doing the work.
58
+ **The measurement layer underneath it:** Any single client already logs its own session — timing, tokens, tool calls. What none of them see is *across* runs, clients and task shapes: what each model costs you, across clients, on one yardstick, in this project (`fapony usage-web`, above) — tokens and cost, nothing self-graded. The frozen ledger still has old verdict rows (`fapony stats`), but the tool that wrote them (`verdict_submit`) is gone from the MCP surface: no new rows, for anyone, ever again, so a count of old rows (`n`) means nothing without the grading that stopped. New accumulation goes to the mem log instead: decisions, bugs and notes with `files[]`, written by the agents doing the work.
76
59
 
77
60
  Three tiers, deliberately: **measurement ships today** and needs no per-project setup — raw facts nobody can call unfair. **Verification is the sharper edge** but stays beta until its evidence layer is hardened; fapony doesn't control your agent's flow, so it never promises "verified" as a headline. **Knowledge accumulation is the compounding one** — it's worthless on run 1 and gets more useful every run after, which is exactly why it's the layer competitors can't clone by copying a feature list.
78
61
 
@@ -381,6 +364,12 @@ at once. ZCode and Codex get the same skills linked into `~/.agents/skills`. A d
381
364
  that already exists and isn't a fapony link is reported and left alone — replace it by hand
382
365
  if you want fapony's version.
383
366
 
367
+ OpenCode is the one client whose hooks are generated files rather than `fapony hook-*`
368
+ commands, so `fapony update` also re-runs the installer in a fresh process to refresh them —
369
+ with `--plugins-only`, so a refresh touches fapony's plugin files and never your
370
+ `opencode.json`. A fapony-owned plugin is rewritten in place; a file that isn't fapony's is
371
+ reported and left alone, same as the skill links.
372
+
384
373
  `plan-with-pony` is vendor-neutral — the SKILL.md *is* the prompt, so pipe it to any agent:
385
374
 
386
375
  ```bash
@@ -434,9 +423,10 @@ years:
434
423
  - **There is no `MASTER.md`.** Every line above is derived from the plan files themselves, so it
435
424
  cannot drift; a hand-kept master file always does.
436
425
 
437
- `status` / `blocked_by` / `blocks` / `superseded_by` are read by people, not by a tool — the one
438
- that read them, `plan_list`, was removed in 2026-09 once `mem kickoff` answered the same
439
- question from the CLI, where a schema costs nothing until it runs.
426
+ `status` / `blocked_by` / `blocks` / `superseded_by` are read by `fapony mem plan-check`
427
+ (dangling refs, blocker shipped but dependent still blocked, waiter cycles, blocked with all
428
+ chunks ticked) and by `fapony mem plan-sweep` (blocked view + a `🔓` unblock hint on `--apply`).
429
+ Sentence values ("waiting on support email") carry no `PLAN-*.md` token and are never flagged.
440
430
 
441
431
  The layout, and why archiving is a plain `git mv`:
442
432
 
@@ -464,13 +454,13 @@ fapony price-scan # fetch model price table → prices.js
464
454
  fapony usage-web [port] # live usage comparison dashboard from cache
465
455
  fapony stats [--mode verdict [--regime code|fix|review|plan|inquiry|test]] # KPIs: pass/stall rate, by-model, by-grade — --mode verdict ranks by quality/tokens instead
466
456
  fapony digest [--since 7d|YYYY-MM-DD] [--format text|html] [--json] [--out FILE] # single-page summary: decisions, open bugs, in-flight plans, cost, pass/fail — from what's already on disk
467
- fapony plan-seed <name> [--spec] [--scope <path>]... # write PLAN (+SPEC): frontmatter, 8 empty sections, prior-art list, ledger context; SPEC chunks carry signatures, every section capped — the agent fills the judgment
457
+ fapony plan-seed <name> [--spec] [--scope <path>]... # write PLAN (+SPEC): frontmatter, 8 empty sections, prior-art list, mem-decision context + existing-in-scope; existing plans listed on stdout; SPEC chunks carry signatures, every section capped — the agent fills the judgment
468
458
  fapony review-seed [--staged|--commit <sha>|--range <a...b>|--files f1,f2,dir|--plan <PLAN.md>] # read-only scope facts for a review (changed files, importers, untested, signatures, plan cross-check)
469
459
 
470
460
  # Memory & convention debt
471
461
  fapony mem add <kind> "<text>" --files f1,f2 [spec.md] # append a mem row (decision/bug/note/next/hold)
472
462
  fapony mem close <id> "<msg>" # close a bug
473
- fapony mem find "<text>" # substring-search every row
463
+ fapony mem find ["<text>"] [--kind a,b] [--files f1,f2] [--since <N>d|YYYY-MM-DD] [--limit n] [--open] # search mem log
474
464
  fapony mem kickoff [<plan.md>] # open a session + a next-up list
475
465
  fapony mem where # show the resolved mem dir and which step won
476
466
  fapony mem done | stale # views
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fapony",
3
- "version": "0.3.5",
3
+ "version": "0.4.0",
4
4
  "description": "Token usage across Claude Code, OpenCode, Codex & ZCode on one yardstick — plus a project mem log and convention-debt tracker agents query via 3 MCP tools. No server, your data stays local",
5
5
  "license": "MIT",
6
6
  "author": "delamind (https://github.com/kire21b)",
@@ -35,6 +35,7 @@
35
35
  "check": "bun run lint && bun run typecheck && bun test --timeout 20000 --parallel",
36
36
  "prepublishOnly": "bash scripts/smoke-publish.sh",
37
37
  "release": "git checkout main && git pull --ff-only && npm version patch -m 'release v%s' && git push origin main --follow-tags",
38
+ "release:minor": "git checkout main && git pull --ff-only && npm version minor -m 'release v%s' && git push origin main --follow-tags",
38
39
  "overview": "bun fapony.ts report-web /tmp/fapony-overview.html && open /tmp/fapony-overview.html"
39
40
  },
40
41
  "devDependencies": {
@@ -21,7 +21,7 @@ You are about to move a PLAN that has been shipped to the archive.
21
21
  Say in the summary that you stamped it, so a wrong HEAD is visible and correctable.
22
22
  STOP only if there's no git repo / no commits to hash from.
23
23
 
24
- 1b. **A plan can also leave `plan/` without shipping** — it got absorbed into another plan, or the
24
+ 1b. **A plan can also leave `plan/` without shipping** — it got absorbed into another plan, or the
25
25
  redesign deleted the thing it planned. That is normal during a UI/UX sweep and is the main
26
26
  reason `plan/` grows forever: there is no state for "dead" so it just sits there. Archive it
27
27
  the same way, with two differences — header `> ⛔ **superseded by [PLAN-bar.md](PLAN-bar.md)**
@@ -37,12 +37,22 @@ You are about to move a PLAN that has been shipped to the archive.
37
37
  A plan that is merely *waiting* (on a person, a customer, a decision) is **not** dead and does
38
38
  not move — mark it `status: blocked` + `blocked_by: <what you are waiting for>` and leave it in
39
39
  `plan/` — the frontmatter is for the next person reading the folder, and the plan stays out
40
- of `done/`, which is what `plan-sweep` and `kickoff` go by.
40
+ of `done/`, which is what `plan-sweep` and `kickoff` go by. Never `--apply` a blocked file;
41
+ a blocked file with all chunks ticked is deferred doc debt — ask the user: ship it or keep
42
+ waiting.
43
+
44
+ 1c. **Check the dep graph before moving** — `fapony mem plan-check` reads `blocked_by`/`blocks`
45
+ and says what a human would miss: a `blocked_by` pointing at a file that is not in `plan/`
46
+ or `done/`, a blocker already in `done/` while the dependent is still `status: blocked`,
47
+ a waiter cycle, and a blocked plan with all chunks ticked. Fix its issues first — a move
48
+ on top of a broken graph just relocates the confusion.
41
49
 
42
50
  2. **Run `plan-sweep --apply`** — this does the `git mv`, rewrites markdown links inside the
43
51
  file and inbound links from every `.md` under `.fapony/` (`plan/`, `done/`, `spec/`),
44
52
  warns about plain-text mentions and about tracked files outside `.fapony/` that still
45
- name the file (both detect-only), and logs a decision row — all in one call:
53
+ name the file, prints a `🔓 <shipped> — <waiter> lists it as blocker` line when the ship
54
+ unblocks a waiting plan (copy that line into your summary — the waiter keeps
55
+ `status: blocked` until its owner clears it), and logs a decision row — all in one call:
46
56
  ```bash
47
57
  fapony mem plan-sweep <PLAN-foo.md> --apply
48
58
  ```
@@ -88,9 +88,13 @@ fapony plan-seed <feature> --spec --scope <path>
88
88
  One command, no MCP round trip. It writes `<planDir>/PLAN-<feature>.md` +
89
89
  `<specDir>/SPEC-<feature>.md` — the frontmatter, the 8 empty sections, a `## 8. References` list
90
90
  of shipped plans that already touched this scope, and a `## Context (fapony)` block under the
91
- TL;DR (recent mem decisions plus which model holds up per task shape here). SPEC chunks carry
91
+ TL;DR (recent mem decisions plus what is already in scope — one line per scope file with its
92
+ exports; needs `--scope` to list anything). No ledger-ranking line: the ledger is frozen and
93
+ cross-model ranking claims are off the table, so the seed does not point at them. SPEC chunks carry
92
94
  verbatim signatures, hard-capped (PLAN ≤ ~60 / SPEC ≤ 200 lines), and capped lines say what was
93
- cut. The CLI resolves plan-dir/spec-dir and refuses to overwrite (pick `-v2` — see Phase 2).
95
+ cut. Stdout ends with the existing plan list (active first, then shipped) — the seed that lands
96
+ next to a shipped decision without knowing it is the expensive mistake, and the file guard in §8
97
+ is not where the glance lands. The CLI resolves plan-dir/spec-dir and refuses to overwrite (pick `-v2` — see Phase 2).
94
98
 
95
99
  **§2/§5 arrive empty on purpose (2026-09-18).** They used to hold a repetition scan and analyze
96
100
  findings; measured over every plan that ever used them, §5 printed "no findings" 3 times out of 3
@@ -0,0 +1,50 @@
1
+ // src/adapters/hooks/bug-markers.ts — how fapony recognises "a bug was found".
2
+ //
3
+ // Split from stop.ts so the Stop hook (blocking, claude/cursor/codex) and the
4
+ // OpenCode commit hint (advisory) share one definition. A bug that lives only
5
+ // in a `note` row is not surfaced by anything, so the two signals are:
6
+ //
7
+ // 1. a structured commit-message token — `fix:` / `bugfix:` / `hotfix:`.
8
+ // Universal by construction: only the type token is English, so a Thai
9
+ // description on a conventional commit still reads as a bug
10
+ // (`fix(debt): ...`). This is the language-independent signal, and it is
11
+ // already how this repo commits (120/581 commits are fix-family).
12
+ // 2. free-text announcement phrases — inherently per-language. A substring
13
+ // list cannot be universal; keep it small and open instead. Add your
14
+ // language here — do NOT invent a new row kind for it (open/closed is
15
+ // derived from close rows already; a kind would just drift).
16
+ //
17
+ // Deliberately NOT matched: symptom words ("broken", "dies silently"). They
18
+ // appear in every bug report and would fire on any turn that reads one — the
19
+ // Stop hook blocks once per session on a match, so a false positive is costly.
20
+
21
+ /** Free-text announcement phrases ("I found a bug"), never symptom words. */
22
+ export const BUG_MARKERS: RegExp[] = [
23
+ /เจอบั๊ก/,
24
+ /พบบั๊ก/,
25
+ /\bfound (?:a |the )?bug\b/i,
26
+ /\b(?:this|that|it)(?:'s| is) a bug\b/i,
27
+ /\bbug\b\s*:/i,
28
+ ];
29
+
30
+ /**
31
+ * The matched marker phrase, or null. Returns the matched text so the caller
32
+ * can quote it back to the agent (stop.ts does, in its block reason).
33
+ */
34
+ export function hasBugMarker(text: string): string | null {
35
+ for (const re of BUG_MARKERS) {
36
+ const m = text.match(re);
37
+ if (m) return m[0];
38
+ }
39
+ return null;
40
+ }
41
+
42
+ // Conventional-commit bug types, anchored to the subject prefix — arbitrary
43
+ // prose containing "fix" ("pre-fix the cache") must not match. Language-free:
44
+ // the type token stays English even when the description is not.
45
+ const BUGFIX_COMMIT = /^(?:fix|bugfix|hotfix)(?:\([^)]*\))?!?:/;
46
+
47
+ /** True when a commit subject declares a fix (the universal bug token). */
48
+ export function isBugfixCommit(subject: string): boolean {
49
+ return BUGFIX_COMMIT.test(subject.trim());
50
+ }
@@ -3,15 +3,21 @@
3
3
  // Split from src/hook.ts (PLAN-lib-layer chunk 3). Reads hint log + re-runs
4
4
  // debt detection to count resolved vs unresolved hints.
5
5
 
6
- import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
7
- import { join } from "node:path";
6
+ import {
7
+ existsSync,
8
+ readdirSync,
9
+ readFileSync,
10
+ realpathSync,
11
+ statSync,
12
+ } from "node:fs";
13
+ import { dirname, join } from "node:path";
8
14
  import {
9
15
  type HintFireRow,
10
16
  type HintImpact,
11
17
  hintLogDir,
12
18
  worktreeKey,
13
19
  } from "../../core/hint-log.js";
14
- import { debtForFile, loadConventions } from "../../debt/index.js";
20
+ import { debtForFile, resolveDebtScope } from "../../debt/index.js";
15
21
 
16
22
  /**
17
23
  * Compute hint-fire impact from the log. `since` is an ISO date string;
@@ -80,14 +86,25 @@ export function computeHintImpact(
80
86
 
81
87
  for (const [key, ids] of debtByFile) {
82
88
  const [worktree, file] = key.split("\t");
83
- const absFile = join(worktree, file);
89
+ let absFile = join(worktree, file);
84
90
  let currentIds: Set<string>;
85
91
  try {
86
92
  if (!statSync(absFile).isFile()) {
87
93
  impact.debt.unknown += ids.length;
88
94
  continue;
89
95
  }
90
- const convs = debtForFile(worktree, absFile, loadConventions(worktree));
96
+ // The log stores the worktree lexically; scanRoot is physical —
97
+ // resolve so debtForFile compares like with like.
98
+ try {
99
+ absFile = realpathSync(absFile);
100
+ } catch {
101
+ // keep the lexical form
102
+ }
103
+ // Same scope as the hint itself — resolving at the git root would
104
+ // load zero conventions in a monorepo and count every shown id as
105
+ // resolved (precision stuck at 100%).
106
+ const scope = resolveDebtScope(dirname(absFile));
107
+ const convs = debtForFile(scope.scanRoot, absFile, scope.loaded);
91
108
  currentIds = new Set(convs.map((c) => c.id));
92
109
  } catch {
93
110
  impact.debt.unknown += ids.length;
@@ -4,9 +4,9 @@
4
4
  // edit-hint adapters to attach debt/mem lines when a file is open.
5
5
 
6
6
  import { realpathSync } from "node:fs";
7
- import { basename, join, relative } from "node:path";
7
+ import { basename, dirname, join, relative } from "node:path";
8
8
  import { collectSourceFiles, SCAN_EXTS } from "../../analyze.js";
9
- import { debtForFile, loadConventions } from "../../debt/index.js";
9
+ import { debtForFile, resolveDebtScope } from "../../debt/index.js";
10
10
  import { readMemLog } from "../../memory.js";
11
11
 
12
12
  const DEBT_HINT_MAX = 3;
@@ -44,21 +44,27 @@ export function readContextData(
44
44
  const debtLines: string[] = [];
45
45
  const memLines: string[] = [];
46
46
 
47
- // convention debt — source files only, fresh from the repo
47
+ // convention debt — source files only, fresh from the repo. The scope
48
+ // pairs the git root (repo-relative `where`) with the nearest
49
+ // conventions file — anchoring the load at the root goes silent in a
50
+ // monorepo with app-scoped conventions (bug mucvfaxk).
48
51
  const dot = rel.lastIndexOf(".");
49
52
  if (dot >= 0 && SCAN_EXTS.has(rel.slice(dot))) {
50
- for (const c of debtForFile(
51
- worktree,
52
- abs,
53
- loadConventions(worktree),
54
- ).slice(0, DEBT_HINT_MAX)) {
53
+ const scope = resolveDebtScope(dirname(abs));
54
+ for (const c of debtForFile(scope.scanRoot, abs, scope.loaded).slice(
55
+ 0,
56
+ DEBT_HINT_MAX,
57
+ )) {
55
58
  debtIds.push(c.id);
56
59
  debtLines.push(`fapony debt: [${c.id}] ${c.rule}`);
57
60
  }
58
61
  }
59
62
 
60
- // mem rows that are about this file
61
- const mem = readMemLog(worktree);
63
+ // mem rows that are about this file — resolve the log from the file's own
64
+ // directory, not the repo root. In a monorepo the log is app-scoped, so
65
+ // anchoring at the root sees only an out-of-scope candidate and goes silent
66
+ // even though the file being touched sits right under its log (bug muc9q47r).
67
+ const mem = readMemLog(dirname(abs));
62
68
  if (mem.rows.length > 0) {
63
69
  const base = basename(rel);
64
70
  const direct: typeof mem.rows = [];
@@ -15,6 +15,11 @@ export {
15
15
  sessionKey,
16
16
  utcStamp,
17
17
  } from "../../core/hook-helpers.js";
18
+ export {
19
+ BUG_MARKERS,
20
+ hasBugMarker,
21
+ isBugfixCommit,
22
+ } from "./bug-markers.js";
18
23
  export { computeHintImpact } from "./compute-hint-impact.js";
19
24
  export {
20
25
  type ContextLineData,
@@ -18,6 +18,7 @@ import { recordHintFire } from "../../core/hint-log.js";
18
18
  import { sessionKey } from "../../core/hook-helpers.js";
19
19
  import { readMemLog } from "../../memory.js";
20
20
  import { renderSeed } from "../../seed/review-seed.js";
21
+ import { hasBugMarker, isBugfixCommit } from "./bug-markers.js";
21
22
  import { readContextData } from "./context-data.js";
22
23
 
23
24
  // --- Read hint (size) ---
@@ -244,7 +245,9 @@ export function commitHintFor(opts: CommitHintInput): string | null {
244
245
 
245
246
  let memLastTs: string | null = null;
246
247
  try {
247
- memLastTs = readMemLog(worktree).rows[0]?.ts ?? null;
248
+ // Anchor at the dir the commit ran in, not the repo root: the log is
249
+ // app-scoped in a monorepo, and root resolution misses it (bug muc9q47r).
250
+ memLastTs = readMemLog(opts.cwd).rows[0]?.ts ?? null;
248
251
  } catch {
249
252
  memLastTs = null;
250
253
  }
@@ -258,6 +261,13 @@ export function commitHintFor(opts: CommitHintInput): string | null {
258
261
  const commitList = log ? log.split("\n").filter(Boolean) : [];
259
262
  if (commitList.length < COMMIT_HINT_MIN_COMMITS) return null;
260
263
 
264
+ // %h %s — strip the short hash to test the subject alone.
265
+ const subjectOf = (c: string) => c.replace(/^\S+\s+/, "");
266
+ const bugCommits = commitList.filter(
267
+ (c) =>
268
+ isBugfixCommit(subjectOf(c)) || hasBugMarker(subjectOf(c)) !== null,
269
+ );
270
+
261
271
  const lines: string[] = [
262
272
  `${commitList.length} commit(s) since last mem row (${memLastTs.slice(0, 10)}) — record a mem row for this work.`,
263
273
  ];
@@ -266,6 +276,12 @@ export function commitHintFor(opts: CommitHintInput): string | null {
266
276
  lines.push(
267
277
  `fapony mem add <decision|bug|note> "what happened" --files <files> ${worktree}/.fapony/plan/PLAN.md`,
268
278
  );
279
+ if (bugCommits.length > 0) {
280
+ lines.push(
281
+ `${bugCommits.length} of these read as a bug (fix-type commit or found-a-bug wording) — use kind:bug so it surfaces later, not note:`,
282
+ );
283
+ lines.push(` fapony mem add bug "what broke" --files <files>`);
284
+ }
269
285
 
270
286
  const prefixed = lines.map((l) => `fapony: ${l}`).join("\n");
271
287
  return prefixed;
@@ -69,12 +69,23 @@ export function sessionStartContext(
69
69
  cwd: string,
70
70
  faponyTs: string = Bun.main,
71
71
  ): string | null {
72
- if (!whereMemDir(cwd).dir) return null;
73
- const p = Bun.spawnSync([process.execPath, faponyTs, "mem", "kickoff"], {
74
- cwd,
75
- stdout: "pipe",
76
- stderr: "pipe",
77
- });
72
+ // Resolution shares one function with every reader. A bare monorepo root has
73
+ // no log at/above cwd, so the resolver reports the app-scoped log only as an
74
+ // out-of-scope candidate (SPEC §1). For a *read* at session start that is
75
+ // still recoverable: if the whole repo holds exactly one log, it is the
76
+ // project's memory — point kickoff at it with --mem-dir. Two or more is
77
+ // genuinely ambiguous (which app?), so refuse exactly as the resolver does.
78
+ const resolved = whereMemDir(cwd);
79
+ const memArgs: string[] = [];
80
+ if (!resolved.dir) {
81
+ const candidates = resolved.candidates ?? [];
82
+ if (candidates.length !== 1) return null;
83
+ memArgs.push("--mem-dir", candidates[0]);
84
+ }
85
+ const p = Bun.spawnSync(
86
+ [process.execPath, faponyTs, "mem", ...memArgs, "kickoff"],
87
+ { cwd, stdout: "pipe", stderr: "pipe" },
88
+ );
78
89
  const out = p.stdout.toString().trim();
79
90
  if (p.exitCode !== 0 || !out) return null;
80
91
  return capContext(out);
@@ -15,6 +15,7 @@ import { homedir } from "node:os";
15
15
  import { join } from "node:path";
16
16
  import { hookTsMs, sessionKey, utcStamp } from "../../core/hook-helpers.js";
17
17
  import { readMemLog, whereMemDir } from "../../memory.js";
18
+ import { hasBugMarker } from "./bug-markers.js";
18
19
 
19
20
  // --- Types ---
20
21
 
@@ -252,9 +253,6 @@ export function stopBlockedBefore(
252
253
 
253
254
  // --- Bug-signal detection ---
254
255
 
255
- /** Announcement words that indicate the agent found a bug — not symptom words. */
256
- const BUG_MARKERS: RegExp[] = [/เจอบั๊ก/];
257
-
258
256
  /**
259
257
  * Scan assistant text from a Claude transcript for bug markers. Reads only
260
258
  * the tail of the file (last 200KB) to avoid parsing the full transcript.
@@ -314,12 +312,8 @@ export function bugSignalFromTranscript(
314
312
  }
315
313
  for (const b of m.content) {
316
314
  if (b.type !== "text" || typeof b.text !== "string") continue;
317
- for (const re of BUG_MARKERS) {
318
- if (re.test(b.text)) {
319
- const match = b.text.match(re);
320
- return match?.[0] ?? null;
321
- }
322
- }
315
+ const hit = hasBugMarker(b.text);
316
+ if (hit) return hit;
323
317
  }
324
318
  }
325
319
  } catch {
@@ -3,7 +3,7 @@
3
3
  // Every schema here is paid as input tokens in *every* session of *every*
4
4
  // client that connects, whether or not the tool is called. Adding one is
5
5
  // buying attention with a standing charge; earning it back means the tool
6
- // saves more than it costs (see CLAUDE.md "จ่าย token อย่างฉลาด"). Keep
6
+ // saves more than it costs (see CLAUDE.md "Spend tokens smart"). Keep
7
7
  // descriptions imperative — say what to send, not why it matters.
8
8
 
9
9
  export { toolMemAdd, toolMemClose, toolMemFind } from "./mem.js";
@@ -59,6 +59,11 @@ export const TOOLS = [
59
59
  description:
60
60
  "Max rows returned (default 20) — total still counts all matches",
61
61
  },
62
+ open: {
63
+ type: "boolean",
64
+ description:
65
+ "true = unresolved work only: drops close/claim/release/synced rows and work rows already closed. Omit = every row. With kind:[bug] answers 'what bugs remain?'",
66
+ },
62
67
  },
63
68
  required: ["worktree"],
64
69
  },