@nanonets/graft 0.24.0 → 0.25.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 +26 -21
- package/dist/ask/ask.d.ts +8 -0
- package/dist/ask/ask.d.ts.map +1 -1
- package/dist/ask/ask.js +33 -12
- package/dist/ask/ask.js.map +1 -1
- package/dist/blast/render.js +1 -1
- package/dist/blast/render.js.map +1 -1
- package/dist/brand.js +1 -1
- package/dist/brand.js.map +1 -1
- package/dist/check/learning-edits.d.ts +18 -3
- package/dist/check/learning-edits.d.ts.map +1 -1
- package/dist/check/learning-edits.js +54 -10
- package/dist/check/learning-edits.js.map +1 -1
- package/dist/check/local-check.d.ts +7 -3
- package/dist/check/local-check.d.ts.map +1 -1
- package/dist/check/local-check.js +55 -11
- package/dist/check/local-check.js.map +1 -1
- package/dist/check/types.d.ts +11 -2
- package/dist/check/types.d.ts.map +1 -1
- package/dist/claude/format.d.ts +11 -7
- package/dist/claude/format.d.ts.map +1 -1
- package/dist/claude/format.js +50 -28
- package/dist/claude/format.js.map +1 -1
- package/dist/claude/hook-io.d.ts +44 -0
- package/dist/claude/hook-io.d.ts.map +1 -0
- package/dist/claude/hook-io.js +144 -0
- package/dist/claude/hook-io.js.map +1 -0
- package/dist/claude/hook-layers.d.ts +4 -2
- package/dist/claude/hook-layers.d.ts.map +1 -1
- package/dist/claude/hook-layers.js +21 -4
- package/dist/claude/hook-layers.js.map +1 -1
- package/dist/claude/hooks.d.ts +9 -32
- package/dist/claude/hooks.d.ts.map +1 -1
- package/dist/claude/hooks.js +154 -350
- package/dist/claude/hooks.js.map +1 -1
- package/dist/claude/init.d.ts.map +1 -1
- package/dist/claude/init.js +56 -18
- package/dist/claude/init.js.map +1 -1
- package/dist/claude/note-signals.d.ts +6 -0
- package/dist/claude/note-signals.d.ts.map +1 -1
- package/dist/claude/note-signals.js +14 -3
- package/dist/claude/note-signals.js.map +1 -1
- package/dist/claude/post-bash.d.ts +26 -0
- package/dist/claude/post-bash.d.ts.map +1 -0
- package/dist/claude/post-bash.js +191 -0
- package/dist/claude/post-bash.js.map +1 -0
- package/dist/claude/pre-bash-skills.d.ts +21 -0
- package/dist/claude/pre-bash-skills.d.ts.map +1 -0
- package/dist/claude/pre-bash-skills.js +253 -0
- package/dist/claude/pre-bash-skills.js.map +1 -0
- package/dist/claude/pre-bash.d.ts +50 -0
- package/dist/claude/pre-bash.d.ts.map +1 -0
- package/dist/claude/pre-bash.js +245 -0
- package/dist/claude/pre-bash.js.map +1 -0
- package/dist/claude/prompt-consent.d.ts +19 -0
- package/dist/claude/prompt-consent.d.ts.map +1 -0
- package/dist/claude/prompt-consent.js +14 -0
- package/dist/claude/prompt-consent.js.map +1 -0
- package/dist/claude/prompt-hook.d.ts +76 -0
- package/dist/claude/prompt-hook.d.ts.map +1 -0
- package/dist/claude/prompt-hook.js +303 -0
- package/dist/claude/prompt-hook.js.map +1 -0
- package/dist/claude/prompt-skills.d.ts +19 -0
- package/dist/claude/prompt-skills.d.ts.map +1 -0
- package/dist/claude/prompt-skills.js +305 -0
- package/dist/claude/prompt-skills.js.map +1 -0
- package/dist/claude/session-metrics.js +4 -4
- package/dist/claude/session-metrics.js.map +1 -1
- package/dist/claude/settings-merge.d.ts +10 -0
- package/dist/claude/settings-merge.d.ts.map +1 -1
- package/dist/claude/settings-merge.js +46 -17
- package/dist/claude/settings-merge.js.map +1 -1
- package/dist/claude/shim-template.d.ts.map +1 -1
- package/dist/claude/shim-template.js +86 -28
- package/dist/claude/shim-template.js.map +1 -1
- package/dist/claude/skill-template.d.ts +2 -0
- package/dist/claude/skill-template.d.ts.map +1 -1
- package/dist/claude/skill-template.js +53 -34
- package/dist/claude/skill-template.js.map +1 -1
- package/dist/claude/skill-use.d.ts +16 -0
- package/dist/claude/skill-use.d.ts.map +1 -0
- package/dist/claude/skill-use.js +78 -0
- package/dist/claude/skill-use.js.map +1 -0
- package/dist/claude/skills-hook-util.d.ts +25 -0
- package/dist/claude/skills-hook-util.d.ts.map +1 -0
- package/dist/claude/skills-hook-util.js +71 -0
- package/dist/claude/skills-hook-util.js.map +1 -0
- package/dist/claude/skills-wiring.d.ts +26 -0
- package/dist/claude/skills-wiring.d.ts.map +1 -0
- package/dist/claude/skills-wiring.js +110 -0
- package/dist/claude/skills-wiring.js.map +1 -0
- package/dist/claude/start-init.d.ts +13 -0
- package/dist/claude/start-init.d.ts.map +1 -0
- package/dist/claude/start-init.js +75 -0
- package/dist/claude/start-init.js.map +1 -0
- package/dist/claude/start-skills.d.ts +31 -0
- package/dist/claude/start-skills.d.ts.map +1 -0
- package/dist/claude/start-skills.js +274 -0
- package/dist/claude/start-skills.js.map +1 -0
- package/dist/claude/state.d.ts +19 -7
- package/dist/claude/state.d.ts.map +1 -1
- package/dist/claude/state.js +59 -4
- package/dist/claude/state.js.map +1 -1
- package/dist/claude/stop-skills.d.ts +23 -0
- package/dist/claude/stop-skills.d.ts.map +1 -0
- package/dist/claude/stop-skills.js +233 -0
- package/dist/claude/stop-skills.js.map +1 -0
- package/dist/claude/stop.d.ts +23 -0
- package/dist/claude/stop.d.ts.map +1 -0
- package/dist/claude/stop.js +219 -0
- package/dist/claude/stop.js.map +1 -0
- package/dist/claude/tally.d.ts +29 -41
- package/dist/claude/tally.d.ts.map +1 -1
- package/dist/claude/tally.js +111 -165
- package/dist/claude/tally.js.map +1 -1
- package/dist/claude/walls-hook.d.ts +52 -0
- package/dist/claude/walls-hook.d.ts.map +1 -0
- package/dist/claude/walls-hook.js +279 -0
- package/dist/claude/walls-hook.js.map +1 -0
- package/dist/cli-epilogue.d.ts.map +1 -1
- package/dist/cli-epilogue.js +24 -14
- package/dist/cli-epilogue.js.map +1 -1
- package/dist/cli-meta.js +3 -3
- package/dist/cli-meta.js.map +1 -1
- package/dist/cli-picker.d.ts +24 -0
- package/dist/cli-picker.d.ts.map +1 -1
- package/dist/cli-picker.js +44 -11
- package/dist/cli-picker.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +475 -390
- package/dist/cli.js.map +1 -1
- package/dist/cloud/head-learnings.d.ts +13 -0
- package/dist/cloud/head-learnings.d.ts.map +1 -0
- package/dist/cloud/head-learnings.js +84 -0
- package/dist/cloud/head-learnings.js.map +1 -0
- package/dist/cloud/lookup-activity.d.ts +18 -0
- package/dist/cloud/lookup-activity.d.ts.map +1 -0
- package/dist/cloud/lookup-activity.js +56 -0
- package/dist/cloud/lookup-activity.js.map +1 -0
- package/dist/cloud/nudge.d.ts +15 -7
- package/dist/cloud/nudge.d.ts.map +1 -1
- package/dist/cloud/nudge.js +45 -33
- package/dist/cloud/nudge.js.map +1 -1
- package/dist/cloud/onboarding.d.ts +273 -0
- package/dist/cloud/onboarding.d.ts.map +1 -0
- package/dist/cloud/onboarding.js +612 -0
- package/dist/cloud/onboarding.js.map +1 -0
- package/dist/cloud/other-repos.d.ts +39 -0
- package/dist/cloud/other-repos.d.ts.map +1 -0
- package/dist/cloud/other-repos.js +137 -0
- package/dist/cloud/other-repos.js.map +1 -0
- package/dist/cloud/pair.d.ts +86 -0
- package/dist/cloud/pair.d.ts.map +1 -0
- package/dist/cloud/pair.js +270 -0
- package/dist/cloud/pair.js.map +1 -0
- package/dist/cloud/workspace-sync.d.ts +75 -11
- package/dist/cloud/workspace-sync.d.ts.map +1 -1
- package/dist/cloud/workspace-sync.js +409 -53
- package/dist/cloud/workspace-sync.js.map +1 -1
- package/dist/cloud/workspace.d.ts +95 -10
- package/dist/cloud/workspace.d.ts.map +1 -1
- package/dist/cloud/workspace.js +112 -9
- package/dist/cloud/workspace.js.map +1 -1
- package/dist/graph/native.d.ts +2 -0
- package/dist/graph/native.d.ts.map +1 -1
- package/dist/graph/native.js +29 -4
- package/dist/graph/native.js.map +1 -1
- package/dist/hosts/claude-global.d.ts +14 -0
- package/dist/hosts/claude-global.d.ts.map +1 -1
- package/dist/hosts/claude-global.js +39 -4
- package/dist/hosts/claude-global.js.map +1 -1
- package/dist/hosts/codex-hooks.d.ts +6 -0
- package/dist/hosts/codex-hooks.d.ts.map +1 -1
- package/dist/hosts/codex-hooks.js +89 -16
- package/dist/hosts/codex-hooks.js.map +1 -1
- package/dist/hosts/codex-trust.d.ts +28 -0
- package/dist/hosts/codex-trust.d.ts.map +1 -0
- package/dist/hosts/codex-trust.js +280 -0
- package/dist/hosts/codex-trust.js.map +1 -0
- package/dist/hosts/cursor-hooks.d.ts.map +1 -1
- package/dist/hosts/cursor-hooks.js +3 -1
- package/dist/hosts/cursor-hooks.js.map +1 -1
- package/dist/init/candidates.d.ts +60 -0
- package/dist/init/candidates.d.ts.map +1 -0
- package/dist/init/candidates.js +202 -0
- package/dist/init/candidates.js.map +1 -0
- package/dist/init/claude-call.d.ts +51 -0
- package/dist/init/claude-call.d.ts.map +1 -0
- package/dist/init/claude-call.js +199 -0
- package/dist/init/claude-call.js.map +1 -0
- package/dist/init/discover-worker.d.ts +18 -0
- package/dist/init/discover-worker.d.ts.map +1 -0
- package/dist/init/discover-worker.js +111 -0
- package/dist/init/discover-worker.js.map +1 -0
- package/dist/init/handover.d.ts +16 -0
- package/dist/init/handover.d.ts.map +1 -0
- package/dist/init/handover.js +92 -0
- package/dist/init/handover.js.map +1 -0
- package/dist/init/howtos.d.ts +20 -0
- package/dist/init/howtos.d.ts.map +1 -0
- package/dist/init/howtos.js +90 -0
- package/dist/init/howtos.js.map +1 -0
- package/dist/init/init-record.d.ts +134 -0
- package/dist/init/init-record.d.ts.map +1 -0
- package/dist/init/init-record.js +339 -0
- package/dist/init/init-record.js.map +1 -0
- package/dist/init/install-paths.d.ts +6 -0
- package/dist/init/install-paths.d.ts.map +1 -0
- package/dist/init/install-paths.js +87 -0
- package/dist/init/install-paths.js.map +1 -0
- package/dist/init/install-record.d.ts +21 -0
- package/dist/init/install-record.d.ts.map +1 -0
- package/dist/init/install-record.js +144 -0
- package/dist/init/install-record.js.map +1 -0
- package/dist/init/keep-answer.d.ts +43 -0
- package/dist/init/keep-answer.d.ts.map +1 -0
- package/dist/init/keep-answer.js +118 -0
- package/dist/init/keep-answer.js.map +1 -0
- package/dist/init/keep-gate.d.ts +30 -0
- package/dist/init/keep-gate.d.ts.map +1 -0
- package/dist/init/keep-gate.js +178 -0
- package/dist/init/keep-gate.js.map +1 -0
- package/dist/init/keep-list.d.ts +67 -0
- package/dist/init/keep-list.d.ts.map +1 -0
- package/dist/init/keep-list.js +232 -0
- package/dist/init/keep-list.js.map +1 -0
- package/dist/init/keep.d.ts +52 -0
- package/dist/init/keep.d.ts.map +1 -0
- package/dist/init/keep.js +393 -0
- package/dist/init/keep.js.map +1 -0
- package/dist/init/look-back-mine.d.ts +37 -0
- package/dist/init/look-back-mine.d.ts.map +1 -0
- package/dist/init/look-back-mine.js +215 -0
- package/dist/init/look-back-mine.js.map +1 -0
- package/dist/init/look-back.d.ts +81 -0
- package/dist/init/look-back.d.ts.map +1 -0
- package/dist/init/look-back.js +170 -0
- package/dist/init/look-back.js.map +1 -0
- package/dist/init/miners.d.ts +46 -0
- package/dist/init/miners.d.ts.map +1 -0
- package/dist/init/miners.js +141 -0
- package/dist/init/miners.js.map +1 -0
- package/dist/init/name-call.d.ts +37 -0
- package/dist/init/name-call.d.ts.map +1 -0
- package/dist/init/name-call.js +151 -0
- package/dist/init/name-call.js.map +1 -0
- package/dist/init/plain-file.d.ts +11 -0
- package/dist/init/plain-file.d.ts.map +1 -0
- package/dist/init/plain-file.js +83 -0
- package/dist/init/plain-file.js.map +1 -0
- package/dist/init/prefs.d.ts +70 -0
- package/dist/init/prefs.d.ts.map +1 -0
- package/dist/init/prefs.js +282 -0
- package/dist/init/prefs.js.map +1 -0
- package/dist/init/relay.d.ts +15 -0
- package/dist/init/relay.d.ts.map +1 -0
- package/dist/init/relay.js +15 -0
- package/dist/init/relay.js.map +1 -0
- package/dist/init/replay-runs.d.ts +121 -0
- package/dist/init/replay-runs.d.ts.map +1 -0
- package/dist/init/replay-runs.js +457 -0
- package/dist/init/replay-runs.js.map +1 -0
- package/dist/init/replay-tamper.d.ts +18 -0
- package/dist/init/replay-tamper.d.ts.map +1 -0
- package/dist/init/replay-tamper.js +87 -0
- package/dist/init/replay-tamper.js.map +1 -0
- package/dist/init/review-screen.d.ts +74 -0
- package/dist/init/review-screen.d.ts.map +1 -0
- package/dist/init/review-screen.js +258 -0
- package/dist/init/review-screen.js.map +1 -0
- package/dist/init/review-tty.d.ts +29 -0
- package/dist/init/review-tty.d.ts.map +1 -0
- package/dist/init/review-tty.js +218 -0
- package/dist/init/review-tty.js.map +1 -0
- package/dist/init/review.d.ts +12 -0
- package/dist/init/review.d.ts.map +1 -0
- package/dist/init/review.js +12 -0
- package/dist/init/review.js.map +1 -0
- package/dist/init/run.d.ts +87 -0
- package/dist/init/run.d.ts.map +1 -0
- package/dist/init/run.js +347 -0
- package/dist/init/run.js.map +1 -0
- package/dist/init/sessions.d.ts +63 -0
- package/dist/init/sessions.d.ts.map +1 -0
- package/dist/init/sessions.js +377 -0
- package/dist/init/sessions.js.map +1 -0
- package/dist/init/transcript.d.ts +81 -0
- package/dist/init/transcript.d.ts.map +1 -0
- package/dist/init/transcript.js +216 -0
- package/dist/init/transcript.js.map +1 -0
- package/dist/init/types.d.ts +139 -0
- package/dist/init/types.d.ts.map +1 -0
- package/dist/init/types.js +2 -0
- package/dist/init/types.js.map +1 -0
- package/dist/mcp/brains.d.ts +72 -0
- package/dist/mcp/brains.d.ts.map +1 -0
- package/dist/mcp/brains.js +220 -0
- package/dist/mcp/brains.js.map +1 -0
- package/dist/mcp/server.d.ts +3 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +40 -5
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +7 -2
- package/dist/mcp/tools.js.map +1 -1
- package/dist/notes/cold-start.d.ts +5 -184
- package/dist/notes/cold-start.d.ts.map +1 -1
- package/dist/notes/cold-start.js +5 -575
- package/dist/notes/cold-start.js.map +1 -1
- package/dist/notes/edit-overlap.d.ts.map +1 -1
- package/dist/notes/edit-overlap.js +4 -1
- package/dist/notes/edit-overlap.js.map +1 -1
- package/dist/notes/every-repo.d.ts +18 -0
- package/dist/notes/every-repo.d.ts.map +1 -0
- package/dist/notes/every-repo.js +86 -0
- package/dist/notes/every-repo.js.map +1 -0
- package/dist/notes/guardrails.d.ts +8 -0
- package/dist/notes/guardrails.d.ts.map +1 -0
- package/dist/notes/guardrails.js +38 -0
- package/dist/notes/guardrails.js.map +1 -0
- package/dist/notes/lesson-index.d.ts +13 -0
- package/dist/notes/lesson-index.d.ts.map +1 -0
- package/dist/notes/lesson-index.js +135 -0
- package/dist/notes/lesson-index.js.map +1 -0
- package/dist/notes/linked-learnings.d.ts +8 -0
- package/dist/notes/linked-learnings.d.ts.map +1 -0
- package/dist/notes/linked-learnings.js +113 -0
- package/dist/notes/linked-learnings.js.map +1 -0
- package/dist/notes/notes.d.ts +8 -4
- package/dist/notes/notes.d.ts.map +1 -1
- package/dist/notes/notes.js +9 -7
- package/dist/notes/notes.js.map +1 -1
- package/dist/notes/pr-reviews.d.ts +4 -0
- package/dist/notes/pr-reviews.d.ts.map +1 -1
- package/dist/notes/pr-reviews.js +6 -5
- package/dist/notes/pr-reviews.js.map +1 -1
- package/dist/notes/replace.d.ts +14 -0
- package/dist/notes/replace.d.ts.map +1 -0
- package/dist/notes/replace.js +38 -0
- package/dist/notes/replace.js.map +1 -0
- package/dist/notes/repo-notes-dir.d.ts +2 -0
- package/dist/notes/repo-notes-dir.d.ts.map +1 -0
- package/dist/notes/repo-notes-dir.js +16 -0
- package/dist/notes/repo-notes-dir.js.map +1 -0
- package/dist/notes/repo-trail.d.ts +1 -1
- package/dist/notes/repo-trail.d.ts.map +1 -1
- package/dist/notes/repo-trail.js +24 -4
- package/dist/notes/repo-trail.js.map +1 -1
- package/dist/search/grep.d.ts.map +1 -1
- package/dist/search/grep.js +4 -2
- package/dist/search/grep.js.map +1 -1
- package/dist/search/user-regexp.d.ts +26 -0
- package/dist/search/user-regexp.d.ts.map +1 -0
- package/dist/search/user-regexp.js +150 -0
- package/dist/search/user-regexp.js.map +1 -0
- package/dist/skills/anchors-cli.d.ts +38 -0
- package/dist/skills/anchors-cli.d.ts.map +1 -0
- package/dist/skills/anchors-cli.js +279 -0
- package/dist/skills/anchors-cli.js.map +1 -0
- package/dist/skills/anchors-git.d.ts +29 -0
- package/dist/skills/anchors-git.d.ts.map +1 -0
- package/dist/skills/anchors-git.js +241 -0
- package/dist/skills/anchors-git.js.map +1 -0
- package/dist/skills/anchors-wide.d.ts +25 -0
- package/dist/skills/anchors-wide.d.ts.map +1 -0
- package/dist/skills/anchors-wide.js +481 -0
- package/dist/skills/anchors-wide.js.map +1 -0
- package/dist/skills/anchors.d.ts +32 -0
- package/dist/skills/anchors.d.ts.map +1 -0
- package/dist/skills/anchors.js +485 -0
- package/dist/skills/anchors.js.map +1 -0
- package/dist/skills/check-result.d.ts +26 -0
- package/dist/skills/check-result.d.ts.map +1 -0
- package/dist/skills/check-result.js +46 -0
- package/dist/skills/check-result.js.map +1 -0
- package/dist/skills/cli-skills-1b.d.ts +17 -0
- package/dist/skills/cli-skills-1b.d.ts.map +1 -0
- package/dist/skills/cli-skills-1b.js +166 -0
- package/dist/skills/cli-skills-1b.js.map +1 -0
- package/dist/skills/cli-skills-2.d.ts +35 -0
- package/dist/skills/cli-skills-2.d.ts.map +1 -0
- package/dist/skills/cli-skills-2.js +129 -0
- package/dist/skills/cli-skills-2.js.map +1 -0
- package/dist/skills/cli-skills-report-1b.d.ts +49 -0
- package/dist/skills/cli-skills-report-1b.d.ts.map +1 -0
- package/dist/skills/cli-skills-report-1b.js +191 -0
- package/dist/skills/cli-skills-report-1b.js.map +1 -0
- package/dist/skills/cli-skills-report.d.ts +86 -0
- package/dist/skills/cli-skills-report.d.ts.map +1 -0
- package/dist/skills/cli-skills-report.js +121 -0
- package/dist/skills/cli-skills-report.js.map +1 -0
- package/dist/skills/cli-skills.d.ts +30 -0
- package/dist/skills/cli-skills.d.ts.map +1 -0
- package/dist/skills/cli-skills.js +379 -0
- package/dist/skills/cli-skills.js.map +1 -0
- package/dist/skills/codex-sandbox.d.ts +6 -0
- package/dist/skills/codex-sandbox.d.ts.map +1 -0
- package/dist/skills/codex-sandbox.js +55 -0
- package/dist/skills/codex-sandbox.js.map +1 -0
- package/dist/skills/compile-split.d.ts +57 -0
- package/dist/skills/compile-split.d.ts.map +1 -0
- package/dist/skills/compile-split.js +550 -0
- package/dist/skills/compile-split.js.map +1 -0
- package/dist/skills/compile-version.d.ts +37 -0
- package/dist/skills/compile-version.d.ts.map +1 -0
- package/dist/skills/compile-version.js +56 -0
- package/dist/skills/compile-version.js.map +1 -0
- package/dist/skills/compile-waits.d.ts +12 -0
- package/dist/skills/compile-waits.d.ts.map +1 -0
- package/dist/skills/compile-waits.js +52 -0
- package/dist/skills/compile-waits.js.map +1 -0
- package/dist/skills/compile-words.d.ts +85 -0
- package/dist/skills/compile-words.d.ts.map +1 -0
- package/dist/skills/compile-words.js +445 -0
- package/dist/skills/compile-words.js.map +1 -0
- package/dist/skills/compile.d.ts +42 -0
- package/dist/skills/compile.d.ts.map +1 -0
- package/dist/skills/compile.js +505 -0
- package/dist/skills/compile.js.map +1 -0
- package/dist/skills/credit-facts.d.ts +8 -0
- package/dist/skills/credit-facts.d.ts.map +1 -0
- package/dist/skills/credit-facts.js +32 -0
- package/dist/skills/credit-facts.js.map +1 -0
- package/dist/skills/credit.d.ts +86 -0
- package/dist/skills/credit.d.ts.map +1 -0
- package/dist/skills/credit.js +259 -0
- package/dist/skills/credit.js.map +1 -0
- package/dist/skills/directive-words.d.ts +11 -0
- package/dist/skills/directive-words.d.ts.map +1 -0
- package/dist/skills/directive-words.js +33 -0
- package/dist/skills/directive-words.js.map +1 -0
- package/dist/skills/fidelity.d.ts +42 -0
- package/dist/skills/fidelity.d.ts.map +1 -0
- package/dist/skills/fidelity.js +138 -0
- package/dist/skills/fidelity.js.map +1 -0
- package/dist/skills/fold-gated.d.ts +3 -0
- package/dist/skills/fold-gated.d.ts.map +1 -0
- package/dist/skills/fold-gated.js +78 -0
- package/dist/skills/fold-gated.js.map +1 -0
- package/dist/skills/fold.d.ts +87 -0
- package/dist/skills/fold.d.ts.map +1 -0
- package/dist/skills/fold.js +348 -0
- package/dist/skills/fold.js.map +1 -0
- package/dist/skills/follow-learnings.d.ts +128 -0
- package/dist/skills/follow-learnings.d.ts.map +1 -0
- package/dist/skills/follow-learnings.js +278 -0
- package/dist/skills/follow-learnings.js.map +1 -0
- package/dist/skills/forget-notice.d.ts +44 -0
- package/dist/skills/forget-notice.d.ts.map +1 -0
- package/dist/skills/forget-notice.js +131 -0
- package/dist/skills/forget-notice.js.map +1 -0
- package/dist/skills/front-version.d.ts +12 -0
- package/dist/skills/front-version.d.ts.map +1 -0
- package/dist/skills/front-version.js +87 -0
- package/dist/skills/front-version.js.map +1 -0
- package/dist/skills/host-facts.d.ts +51 -0
- package/dist/skills/host-facts.d.ts.map +1 -0
- package/dist/skills/host-facts.js +134 -0
- package/dist/skills/host-facts.js.map +1 -0
- package/dist/skills/learning-steps.d.ts +43 -0
- package/dist/skills/learning-steps.d.ts.map +1 -0
- package/dist/skills/learning-steps.js +294 -0
- package/dist/skills/learning-steps.js.map +1 -0
- package/dist/skills/ledger.d.ts +43 -0
- package/dist/skills/ledger.d.ts.map +1 -0
- package/dist/skills/ledger.js +336 -0
- package/dist/skills/ledger.js.map +1 -0
- package/dist/skills/lesson-gate.d.ts +25 -0
- package/dist/skills/lesson-gate.d.ts.map +1 -0
- package/dist/skills/lesson-gate.js +316 -0
- package/dist/skills/lesson-gate.js.map +1 -0
- package/dist/skills/lessons.d.ts +60 -0
- package/dist/skills/lessons.d.ts.map +1 -0
- package/dist/skills/lessons.js +396 -0
- package/dist/skills/lessons.js.map +1 -0
- package/dist/skills/offer-answers.d.ts +20 -0
- package/dist/skills/offer-answers.d.ts.map +1 -0
- package/dist/skills/offer-answers.js +51 -0
- package/dist/skills/offer-answers.js.map +1 -0
- package/dist/skills/offer-drift.d.ts +35 -0
- package/dist/skills/offer-drift.d.ts.map +1 -0
- package/dist/skills/offer-drift.js +98 -0
- package/dist/skills/offer-drift.js.map +1 -0
- package/dist/skills/offer-lesson.d.ts +31 -0
- package/dist/skills/offer-lesson.d.ts.map +1 -0
- package/dist/skills/offer-lesson.js +123 -0
- package/dist/skills/offer-lesson.js.map +1 -0
- package/dist/skills/offer-lines.d.ts +40 -0
- package/dist/skills/offer-lines.d.ts.map +1 -0
- package/dist/skills/offer-lines.js +80 -0
- package/dist/skills/offer-lines.js.map +1 -0
- package/dist/skills/offer-moment.d.ts +102 -0
- package/dist/skills/offer-moment.d.ts.map +1 -0
- package/dist/skills/offer-moment.js +260 -0
- package/dist/skills/offer-moment.js.map +1 -0
- package/dist/skills/offer-repair.d.ts +36 -0
- package/dist/skills/offer-repair.d.ts.map +1 -0
- package/dist/skills/offer-repair.js +212 -0
- package/dist/skills/offer-repair.js.map +1 -0
- package/dist/skills/offer-retire.d.ts +53 -0
- package/dist/skills/offer-retire.d.ts.map +1 -0
- package/dist/skills/offer-retire.js +149 -0
- package/dist/skills/offer-retire.js.map +1 -0
- package/dist/skills/offer-update.d.ts +54 -0
- package/dist/skills/offer-update.d.ts.map +1 -0
- package/dist/skills/offer-update.js +115 -0
- package/dist/skills/offer-update.js.map +1 -0
- package/dist/skills/offer-words-1b.d.ts +32 -0
- package/dist/skills/offer-words-1b.d.ts.map +1 -0
- package/dist/skills/offer-words-1b.js +80 -0
- package/dist/skills/offer-words-1b.js.map +1 -0
- package/dist/skills/offer-words-2.d.ts +123 -0
- package/dist/skills/offer-words-2.d.ts.map +1 -0
- package/dist/skills/offer-words-2.js +194 -0
- package/dist/skills/offer-words-2.js.map +1 -0
- package/dist/skills/offer-words.d.ts +65 -0
- package/dist/skills/offer-words.d.ts.map +1 -0
- package/dist/skills/offer-words.js +205 -0
- package/dist/skills/offer-words.js.map +1 -0
- package/dist/skills/offers.d.ts +66 -0
- package/dist/skills/offers.d.ts.map +1 -0
- package/dist/skills/offers.js +284 -0
- package/dist/skills/offers.js.map +1 -0
- package/dist/skills/own-folder.d.ts +9 -0
- package/dist/skills/own-folder.d.ts.map +1 -0
- package/dist/skills/own-folder.js +36 -0
- package/dist/skills/own-folder.js.map +1 -0
- package/dist/skills/person.d.ts +34 -0
- package/dist/skills/person.d.ts.map +1 -0
- package/dist/skills/person.js +102 -0
- package/dist/skills/person.js.map +1 -0
- package/dist/skills/probe-clean.d.ts +9 -0
- package/dist/skills/probe-clean.d.ts.map +1 -0
- package/dist/skills/probe-clean.js +48 -0
- package/dist/skills/probe-clean.js.map +1 -0
- package/dist/skills/probes.d.ts +26 -0
- package/dist/skills/probes.d.ts.map +1 -0
- package/dist/skills/probes.js +225 -0
- package/dist/skills/probes.js.map +1 -0
- package/dist/skills/recall.d.ts +119 -0
- package/dist/skills/recall.d.ts.map +1 -0
- package/dist/skills/recall.js +370 -0
- package/dist/skills/recall.js.map +1 -0
- package/dist/skills/receipts.d.ts +44 -0
- package/dist/skills/receipts.d.ts.map +1 -0
- package/dist/skills/receipts.js +223 -0
- package/dist/skills/receipts.js.map +1 -0
- package/dist/skills/run-checkout.d.ts +4 -0
- package/dist/skills/run-checkout.d.ts.map +1 -0
- package/dist/skills/run-checkout.js +37 -0
- package/dist/skills/run-checkout.js.map +1 -0
- package/dist/skills/runblock.d.ts +47 -0
- package/dist/skills/runblock.d.ts.map +1 -0
- package/dist/skills/runblock.js +227 -0
- package/dist/skills/runblock.js.map +1 -0
- package/dist/skills/save-gate.d.ts +64 -0
- package/dist/skills/save-gate.d.ts.map +1 -0
- package/dist/skills/save-gate.js +354 -0
- package/dist/skills/save-gate.js.map +1 -0
- package/dist/skills/save-parse.d.ts +42 -0
- package/dist/skills/save-parse.d.ts.map +1 -0
- package/dist/skills/save-parse.js +172 -0
- package/dist/skills/save-parse.js.map +1 -0
- package/dist/skills/save-store.d.ts +12 -0
- package/dist/skills/save-store.d.ts.map +1 -0
- package/dist/skills/save-store.js +22 -0
- package/dist/skills/save-store.js.map +1 -0
- package/dist/skills/save-verify.d.ts +59 -0
- package/dist/skills/save-verify.d.ts.map +1 -0
- package/dist/skills/save-verify.js +390 -0
- package/dist/skills/save-verify.js.map +1 -0
- package/dist/skills/settings.d.ts +48 -0
- package/dist/skills/settings.d.ts.map +1 -0
- package/dist/skills/settings.js +155 -0
- package/dist/skills/settings.js.map +1 -0
- package/dist/skills/skill-diff.d.ts +40 -0
- package/dist/skills/skill-diff.d.ts.map +1 -0
- package/dist/skills/skill-diff.js +191 -0
- package/dist/skills/skill-diff.js.map +1 -0
- package/dist/skills/skill-file.d.ts +24 -0
- package/dist/skills/skill-file.d.ts.map +1 -0
- package/dist/skills/skill-file.js +97 -0
- package/dist/skills/skill-file.js.map +1 -0
- package/dist/skills/skill-rebuild.d.ts +27 -0
- package/dist/skills/skill-rebuild.d.ts.map +1 -0
- package/dist/skills/skill-rebuild.js +85 -0
- package/dist/skills/skill-rebuild.js.map +1 -0
- package/dist/skills/skillmd.d.ts +17 -0
- package/dist/skills/skillmd.d.ts.map +1 -0
- package/dist/skills/skillmd.js +219 -0
- package/dist/skills/skillmd.js.map +1 -0
- package/dist/skills/skills.d.ts +28 -8
- package/dist/skills/skills.d.ts.map +1 -1
- package/dist/skills/skills.js +106 -53
- package/dist/skills/skills.js.map +1 -1
- package/dist/skills/staleness.d.ts +27 -0
- package/dist/skills/staleness.d.ts.map +1 -0
- package/dist/skills/staleness.js +178 -0
- package/dist/skills/staleness.js.map +1 -0
- package/dist/skills/state.d.ts +36 -0
- package/dist/skills/state.d.ts.map +1 -0
- package/dist/skills/state.js +259 -0
- package/dist/skills/state.js.map +1 -0
- package/dist/skills/store-fs.d.ts +77 -0
- package/dist/skills/store-fs.d.ts.map +1 -0
- package/dist/skills/store-fs.js +194 -0
- package/dist/skills/store-fs.js.map +1 -0
- package/dist/skills/store-held.d.ts +44 -0
- package/dist/skills/store-held.d.ts.map +1 -0
- package/dist/skills/store-held.js +147 -0
- package/dist/skills/store-held.js.map +1 -0
- package/dist/skills/store.d.ts +73 -0
- package/dist/skills/store.d.ts.map +1 -0
- package/dist/skills/store.js +279 -0
- package/dist/skills/store.js.map +1 -0
- package/dist/skills/types.d.ts +8 -0
- package/dist/skills/types.d.ts.map +1 -1
- package/dist/skills/update-gate.d.ts +36 -0
- package/dist/skills/update-gate.d.ts.map +1 -0
- package/dist/skills/update-gate.js +357 -0
- package/dist/skills/update-gate.js.map +1 -0
- package/dist/skills/update-plan.d.ts +40 -0
- package/dist/skills/update-plan.d.ts.map +1 -0
- package/dist/skills/update-plan.js +196 -0
- package/dist/skills/update-plan.js.map +1 -0
- package/dist/skills/validate.d.ts +11 -0
- package/dist/skills/validate.d.ts.map +1 -0
- package/dist/skills/validate.js +112 -0
- package/dist/skills/validate.js.map +1 -0
- package/dist/skills/value-line.d.ts +94 -0
- package/dist/skills/value-line.d.ts.map +1 -0
- package/dist/skills/value-line.js +355 -0
- package/dist/skills/value-line.js.map +1 -0
- package/dist/skills/versions-fs.d.ts +45 -0
- package/dist/skills/versions-fs.d.ts.map +1 -0
- package/dist/skills/versions-fs.js +234 -0
- package/dist/skills/versions-fs.js.map +1 -0
- package/dist/skills/versions.d.ts +56 -0
- package/dist/skills/versions.d.ts.map +1 -0
- package/dist/skills/versions.js +351 -0
- package/dist/skills/versions.js.map +1 -0
- package/dist/telemetry/contract.d.ts +15 -1
- package/dist/telemetry/contract.d.ts.map +1 -1
- package/dist/telemetry/contract.js +80 -11
- package/dist/telemetry/contract.js.map +1 -1
- package/dist/telemetry/gate.js +4 -4
- package/dist/telemetry/gate.js.map +1 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +1 -1
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/notice.js +5 -5
- package/dist/telemetry/notice.js.map +1 -1
- package/dist/telemetry/queue.d.ts.map +1 -1
- package/dist/telemetry/queue.js +7 -7
- package/dist/telemetry/queue.js.map +1 -1
- package/dist/telemetry/track.d.ts.map +1 -1
- package/dist/telemetry/track.js +4 -3
- package/dist/telemetry/track.js.map +1 -1
- package/dist/trace/checks.d.ts +63 -0
- package/dist/trace/checks.d.ts.map +1 -0
- package/dist/trace/checks.js +495 -0
- package/dist/trace/checks.js.map +1 -0
- package/dist/trace/claude.d.ts +124 -0
- package/dist/trace/claude.d.ts.map +1 -0
- package/dist/trace/claude.js +303 -0
- package/dist/trace/claude.js.map +1 -0
- package/dist/trace/codex-exec.d.ts +22 -0
- package/dist/trace/codex-exec.d.ts.map +1 -0
- package/dist/trace/codex-exec.js +129 -0
- package/dist/trace/codex-exec.js.map +1 -0
- package/dist/trace/codex-meta.d.ts +23 -0
- package/dist/trace/codex-meta.d.ts.map +1 -0
- package/dist/trace/codex-meta.js +112 -0
- package/dist/trace/codex-meta.js.map +1 -0
- package/dist/trace/codex.d.ts +33 -0
- package/dist/trace/codex.d.ts.map +1 -0
- package/dist/trace/codex.js +485 -0
- package/dist/trace/codex.js.map +1 -0
- package/dist/trace/cursor.d.ts +16 -0
- package/dist/trace/cursor.d.ts.map +1 -0
- package/dist/trace/cursor.js +133 -0
- package/dist/trace/cursor.js.map +1 -0
- package/dist/trace/dialect.d.ts +43 -0
- package/dist/trace/dialect.d.ts.map +1 -0
- package/dist/trace/dialect.js +95 -0
- package/dist/trace/dialect.js.map +1 -0
- package/dist/trace/epochs.d.ts +10 -0
- package/dist/trace/epochs.d.ts.map +1 -0
- package/dist/trace/epochs.js +16 -0
- package/dist/trace/epochs.js.map +1 -0
- package/dist/trace/failure.d.ts +15 -0
- package/dist/trace/failure.d.ts.map +1 -0
- package/dist/trace/failure.js +69 -0
- package/dist/trace/failure.js.map +1 -0
- package/dist/trace/gate-file.d.ts +71 -0
- package/dist/trace/gate-file.d.ts.map +1 -0
- package/dist/trace/gate-file.js +329 -0
- package/dist/trace/gate-file.js.map +1 -0
- package/dist/trace/guard-fast.d.ts +22 -0
- package/dist/trace/guard-fast.d.ts.map +1 -0
- package/dist/trace/guard-fast.js +213 -0
- package/dist/trace/guard-fast.js.map +1 -0
- package/dist/trace/housekeeping.d.ts +5 -0
- package/dist/trace/housekeeping.d.ts.map +1 -0
- package/dist/trace/housekeeping.js +93 -0
- package/dist/trace/housekeeping.js.map +1 -0
- package/dist/trace/jobs.d.ts +52 -0
- package/dist/trace/jobs.d.ts.map +1 -0
- package/dist/trace/jobs.js +182 -0
- package/dist/trace/jobs.js.map +1 -0
- package/dist/trace/known-repo.d.ts +3 -0
- package/dist/trace/known-repo.d.ts.map +1 -0
- package/dist/trace/known-repo.js +55 -0
- package/dist/trace/known-repo.js.map +1 -0
- package/dist/trace/pool.d.ts +40 -0
- package/dist/trace/pool.d.ts.map +1 -0
- package/dist/trace/pool.js +154 -0
- package/dist/trace/pool.js.map +1 -0
- package/dist/trace/repairs.d.ts +27 -0
- package/dist/trace/repairs.d.ts.map +1 -0
- package/dist/trace/repairs.js +303 -0
- package/dist/trace/repairs.js.map +1 -0
- package/dist/trace/run-calls.d.ts +82 -0
- package/dist/trace/run-calls.d.ts.map +1 -0
- package/dist/trace/run-calls.js +331 -0
- package/dist/trace/run-calls.js.map +1 -0
- package/dist/trace/run-join.d.ts +20 -0
- package/dist/trace/run-join.d.ts.map +1 -0
- package/dist/trace/run-join.js +99 -0
- package/dist/trace/run-join.js.map +1 -0
- package/dist/trace/run-sheets.d.ts +26 -0
- package/dist/trace/run-sheets.d.ts.map +1 -0
- package/dist/trace/run-sheets.js +145 -0
- package/dist/trace/run-sheets.js.map +1 -0
- package/dist/trace/run-turns.d.ts +24 -0
- package/dist/trace/run-turns.d.ts.map +1 -0
- package/dist/trace/run-turns.js +67 -0
- package/dist/trace/run-turns.js.map +1 -0
- package/dist/trace/run-verdict.d.ts +24 -0
- package/dist/trace/run-verdict.d.ts.map +1 -0
- package/dist/trace/run-verdict.js +176 -0
- package/dist/trace/run-verdict.js.map +1 -0
- package/dist/trace/runs.d.ts +54 -0
- package/dist/trace/runs.d.ts.map +1 -0
- package/dist/trace/runs.js +501 -0
- package/dist/trace/runs.js.map +1 -0
- package/dist/trace/skill-session.d.ts +64 -0
- package/dist/trace/skill-session.d.ts.map +1 -0
- package/dist/trace/skill-session.js +232 -0
- package/dist/trace/skill-session.js.map +1 -0
- package/dist/trace/tamper.d.ts +12 -0
- package/dist/trace/tamper.d.ts.map +1 -0
- package/dist/trace/tamper.js +405 -0
- package/dist/trace/tamper.js.map +1 -0
- package/dist/trace/typed.d.ts +30 -0
- package/dist/trace/typed.d.ts.map +1 -0
- package/dist/trace/typed.js +132 -0
- package/dist/trace/typed.js.map +1 -0
- package/dist/trace/wall-state.d.ts +86 -0
- package/dist/trace/wall-state.d.ts.map +1 -0
- package/dist/trace/wall-state.js +279 -0
- package/dist/trace/wall-state.js.map +1 -0
- package/dist/trace/walls.d.ts +40 -0
- package/dist/trace/walls.d.ts.map +1 -0
- package/dist/trace/walls.js +318 -0
- package/dist/trace/walls.js.map +1 -0
- package/dist/upkeep-run.d.ts.map +1 -1
- package/dist/upkeep-run.js +2 -23
- package/dist/upkeep-run.js.map +1 -1
- package/dist/upkeep.d.ts.map +1 -1
- package/dist/upkeep.js +2 -3
- package/dist/upkeep.js.map +1 -1
- package/dist/util/private-fs.d.ts +6 -0
- package/dist/util/private-fs.d.ts.map +1 -1
- package/dist/util/private-fs.js +9 -1
- package/dist/util/private-fs.js.map +1 -1
- package/dist/util/state.d.ts.map +1 -1
- package/dist/util/state.js +17 -3
- package/dist/util/state.js.map +1 -1
- package/dist/vendor/tree-sitter-swift/LICENSE +21 -0
- package/dist/vendor/tree-sitter-swift/node-types.json +30694 -0
- package/dist/vendor/tree-sitter-swift/prebuilds/darwin-arm64/tree-sitter-swift.node +0 -0
- package/dist/vendor/tree-sitter-swift/prebuilds/darwin-x64/tree-sitter-swift.node +0 -0
- package/dist/vendor/tree-sitter-swift/prebuilds/linux-arm64/tree-sitter-swift.node +0 -0
- package/dist/vendor/tree-sitter-swift/prebuilds/linux-x64/tree-sitter-swift.node +0 -0
- package/dist/vendor/tree-sitter-swift/prebuilds/win32-arm64/tree-sitter-swift.node +0 -0
- package/dist/vendor/tree-sitter-swift/prebuilds/win32-x64/tree-sitter-swift.node +0 -0
- package/package.json +6 -3
- package/scripts/stamp-telemetry-key.mjs +8 -5
- package/scripts/vendor-grammars.mjs +35 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { currentRun, skillsGate, withSkillSession } from '../trace/skill-session.js';
|
|
2
|
+
import { checkedSuccess, costly, runHelpers, writeRunSheet } from '../trace/runs.js';
|
|
3
|
+
import { notePoolDay } from '../trace/pool.js';
|
|
4
|
+
import { repoKnown } from '../trace/known-repo.js';
|
|
5
|
+
import { OFFER_FAMILIES } from '../trace/jobs.js';
|
|
6
|
+
import { localDate } from '../skills/settings.js';
|
|
7
|
+
import { hostFacts } from '../skills/host-facts.js';
|
|
8
|
+
import { noteCorrectionLine, settleCredit } from '../skills/credit.js';
|
|
9
|
+
import { foldInputFor, replan } from '../skills/update-plan.js';
|
|
10
|
+
import { guardrailStopsIn, noteValue } from '../skills/value-line.js';
|
|
11
|
+
import { offerDue, offerEndsReply, offerRepo } from '../skills/offer-moment.js';
|
|
12
|
+
import { offerLinesOf } from '../skills/offer-lines.js';
|
|
13
|
+
import { noticeText, recordNotShown, recordShown, stopBlockReason } from '../skills/offers.js';
|
|
14
|
+
import { flatLine } from '../notes/flatten.js';
|
|
15
|
+
import { hookError, syncGate } from './skills-hook-util.js';
|
|
16
|
+
import { guardrailCounts, wallsAtStop } from './walls-hook.js';
|
|
17
|
+
import { refreshLessonIndex } from '../notes/lesson-index.js';
|
|
18
|
+
import { useFor } from '../trace/dialect.js';
|
|
19
|
+
/** c2's planner, which the update gate and `draft --print` replan with (P29, R14). */
|
|
20
|
+
const PLANNER = { foldInputFor, replan };
|
|
21
|
+
/** 3.5. Never throws. */
|
|
22
|
+
export function stopSkills(input, dir, env = process.env) {
|
|
23
|
+
return stopSkillsRun(input, dir, env).out;
|
|
24
|
+
}
|
|
25
|
+
/** 3.5, with the telemetry it collected inside the lock, for the caller to send after it. */
|
|
26
|
+
export function stopSkillsRun(input, dir, env = process.env) {
|
|
27
|
+
const sent = [];
|
|
28
|
+
try {
|
|
29
|
+
// 1.
|
|
30
|
+
const g = skillsGate(input, dir, env);
|
|
31
|
+
if (!g.ok || g.ctx.subagent || !g.ctx.fold)
|
|
32
|
+
return { out: {}, sent };
|
|
33
|
+
const ctx = g.ctx;
|
|
34
|
+
const p = input && typeof input === 'object' ? input : {};
|
|
35
|
+
const said = typeof p.last_assistant_message === 'string' && p.last_assistant_message.trim() ? p.last_assistant_message : null;
|
|
36
|
+
// 2. A lock that timed out is nothing: the next hook catches up.
|
|
37
|
+
const out = withSkillSession(ctx, { catchUp: true }, (st, fold) => inside(ctx, st, fold, said, p.stop_hook_active === true, sent));
|
|
38
|
+
return { out: out ?? {}, sent };
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
hookError('stop', e, env);
|
|
42
|
+
return { out: {}, sent: [] };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function inside(ctx, st, fold, said, active, sent) {
|
|
46
|
+
const { env, now } = ctx;
|
|
47
|
+
// 1b (4.14 step 1, D109): a correction line the fold met only now (written after the prompt hook ran) fills its offset.
|
|
48
|
+
if (fold)
|
|
49
|
+
noteCorrectionLine(st, fold.typed);
|
|
50
|
+
// 3. The reply's last words may reach the payload before the transcript.
|
|
51
|
+
const reply = said ?? (fold?.lastAssistant || null);
|
|
52
|
+
const offer = st.pendingOffer;
|
|
53
|
+
const run = currentRun(st);
|
|
54
|
+
// D133: the offer's lines are read through the host's dialect (a Codex correction line by its keyed hash).
|
|
55
|
+
const use = useFor(ctx.host, st);
|
|
56
|
+
const judged = withoutOffer(reply, offer, ctx.transcriptPath, use);
|
|
57
|
+
if (run)
|
|
58
|
+
run.end = checkedSuccess(run, judged).end;
|
|
59
|
+
// 1b (3.5 steps 1, 2 and 5): wall hits, repairs and lessons that worked into walls.json, before the offers read it;
|
|
60
|
+
// the guardrail's denies since the last Stop counted. Each part fails open on its own.
|
|
61
|
+
let wallFixes = 0;
|
|
62
|
+
if (ctx.learn) {
|
|
63
|
+
try {
|
|
64
|
+
wallFixes = wallsAtStop(st, ctx);
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
hookError('stop', e, env);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const before = sent.length;
|
|
71
|
+
try {
|
|
72
|
+
guardrailCounts(st, ctx, sent);
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
hookError('stop', e, env);
|
|
76
|
+
}
|
|
77
|
+
// Phase 2 (3.5, 4.14, learning half): this Stop's timeout guardrail stops and the known errors whose fix reached the
|
|
78
|
+
// model, counted for the weekly value line (a busy lock drops them, never waits).
|
|
79
|
+
if (ctx.learn && ctx.repoKey) {
|
|
80
|
+
try {
|
|
81
|
+
noteValue(ctx.repoKey, { guardrailStops: guardrailStopsIn(sent.slice(before)), wallFixes }, env, now);
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
hookError('stop', e, env);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// D117 (4): the lesson index the wall fix reads, brought up to date here (PostToolUseFailure writes nothing, R34).
|
|
88
|
+
refreshLessonIndex(ctx.repoKey, env);
|
|
89
|
+
// 5. Credit (the prompt hook settles a run the next ask closed, D57). 1b: a cue phrase dropped at the flush (4.19).
|
|
90
|
+
// Phase 2 (4.9): the firings the flush wrote, for the retire proposal.
|
|
91
|
+
let settled = [];
|
|
92
|
+
// c8 (4.9): with the firings the prompt hook's settle wrote since the last Stop (their run closed on the next ask).
|
|
93
|
+
const fired = ctx.learn ? [...(st.firedLater ?? [])] : [];
|
|
94
|
+
delete st.firedLater;
|
|
95
|
+
if (ctx.learn) {
|
|
96
|
+
settled = settleCredit(st, { host: ctx.host, env, now, sessionId: ctx.sessionId, cueDropped: () => sent.push(['skill_stale', { reason: 'unfollowed' }]), fired: (f) => fired.push(f) });
|
|
97
|
+
for (const s of settled)
|
|
98
|
+
sent.push(['skill_used', { outcome: s.outcome }]);
|
|
99
|
+
}
|
|
100
|
+
// 6. A post-tool offer counts as shown only when the reply ends with it.
|
|
101
|
+
let spent = false;
|
|
102
|
+
if (offer && offer.channel === 'post-tool' && offer.shownAt === null) {
|
|
103
|
+
if (offerEndsReply(offer, reply, ctx.transcriptPath, use)) {
|
|
104
|
+
offer.shownAt = now.toISOString();
|
|
105
|
+
recordShown(offer, offerRepo(offer), env, now);
|
|
106
|
+
st.offerUsed = true;
|
|
107
|
+
st.offerUsedBy = 'offer';
|
|
108
|
+
sent.push(['skill_offered', { moment: offer.moment }]);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
recordNotShown(offer, offerRepo(offer), env, now);
|
|
112
|
+
st.pendingOffer = null;
|
|
113
|
+
}
|
|
114
|
+
spent = true;
|
|
115
|
+
}
|
|
116
|
+
// 7. The turn a block continued: the offer the reply left out (or followed with words of its own) is not shown.
|
|
117
|
+
if (active) {
|
|
118
|
+
if (offer && offer.channel === 'stop' && blockedThisTurn(offer) && !offerEndsReply(offer, reply, ctx.transcriptPath, use)) {
|
|
119
|
+
recordNotShown(offer, offerRepo(offer), env, now);
|
|
120
|
+
st.pendingOffer = null;
|
|
121
|
+
}
|
|
122
|
+
syncGate(ctx, st);
|
|
123
|
+
return {};
|
|
124
|
+
}
|
|
125
|
+
// 8. Pool days.
|
|
126
|
+
if (ctx.learn)
|
|
127
|
+
for (const r of st.runs)
|
|
128
|
+
if (r.epoch === st.epoch)
|
|
129
|
+
notePool(r, ctx);
|
|
130
|
+
// 9. The open run's sheet when it checks out, then its pool day again, so the pool points at a sheet on disk.
|
|
131
|
+
let verdict = null;
|
|
132
|
+
let sheet = null;
|
|
133
|
+
if (run && run.stepCalls > 0 && run.calls.length) {
|
|
134
|
+
verdict = checkedSuccess(run, judged);
|
|
135
|
+
if (verdict.checked) {
|
|
136
|
+
sheet = writeRunSheet(run, verdict, { host: ctx.host, tier: ctx.tier, sessionHash: ctx.sessionHash, helpers: runHelpers(run) }, env);
|
|
137
|
+
if (ctx.learn)
|
|
138
|
+
notePool(run, ctx);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// 10. Moments 4, 6, 5, 3, 2, then the retire proposal, the first that is due (1b, 3.5 step 6; phase 2, 4.10). Moment
|
|
142
|
+
// 4 needs no checked run: the turn's last run (open, else the newest) carries the verdict on how the turn ended.
|
|
143
|
+
// Moments 5 and 6 plan through c2's `foldInputFor` and `replan`, so the offer pins what the update gate replans.
|
|
144
|
+
const channel = hostFacts(env, ctx.host).offerChannel;
|
|
145
|
+
const last = run ?? st.runs[st.runs.length - 1] ?? null;
|
|
146
|
+
if (ctx.learn && !spent && last && (channel === 'stop' || channel === 'notice')) {
|
|
147
|
+
const due = offerDue({ run: last, verdict: verdict ?? checkedSuccess(last, judged), sheet, st, ctx, channel, settled, fired, plan: PLANNER });
|
|
148
|
+
if (due.due) {
|
|
149
|
+
st.pendingOffer = due.offer;
|
|
150
|
+
recordShown(due.offer, offerRepo(due.offer) || last.repoKey, env, now);
|
|
151
|
+
st.offerUsed = true;
|
|
152
|
+
st.offerUsedBy = 'offer';
|
|
153
|
+
sent.push(['skill_offered', { moment: due.offer.moment }]);
|
|
154
|
+
endWatch(st);
|
|
155
|
+
syncGate(ctx, st);
|
|
156
|
+
return channel === 'stop' ? { block: stopBlockReason(due.offer, ctx.transcriptPath, use) } : { notice: noticeText(due.offer, ctx.transcriptPath, use) };
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// 11.
|
|
160
|
+
endWatch(st);
|
|
161
|
+
syncGate(ctx, st);
|
|
162
|
+
const notice = hostFacts(env, ctx.host).stopNotice ? useLine(settled) : '';
|
|
163
|
+
return notice ? { notice } : {};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* 1b: moment 4 is due at the Stop of the correction's turn only (4.14 step 4). Once the fold found the correction's
|
|
167
|
+
* line, the watch ends with this Stop, offered or not; the slot a correction freed (P18, R40) is for this Stop only.
|
|
168
|
+
*/
|
|
169
|
+
function endWatch(st) {
|
|
170
|
+
const w = st.lessonWatch;
|
|
171
|
+
if (w && st.credit.some((c) => c.useId === w.useId && c.corrected?.sha === w.typedSha && typeof c.corrected.offset === 'number'))
|
|
172
|
+
st.lessonWatch = null;
|
|
173
|
+
if (w && !st.credit.some((c) => c.useId === w.useId))
|
|
174
|
+
st.lessonWatch = null;
|
|
175
|
+
st.withdrewFor = null;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The reply as judged for the turn's end (4.3): without the offer's own 2 lines when it ends with them. Line 1
|
|
179
|
+
* counts what failed on the way ("17 commands this time, 3 failed"), which would read as a turn that failed, and
|
|
180
|
+
* the job was judged done before the offer was made. A reply that is only the offer reads as done.
|
|
181
|
+
*/
|
|
182
|
+
export function withoutOffer(reply, offer, transcriptPath = null, use) {
|
|
183
|
+
// 1b (R12): the lines through offerLinesOf; an offer with none (a correction whose line is gone) was never said.
|
|
184
|
+
const said = reply === null || !offer ? null : offerLinesOf(offer, transcriptPath, process.env, use);
|
|
185
|
+
if (reply === null || !said || !offerEndsReply(offer, reply, transcriptPath, use))
|
|
186
|
+
return reply;
|
|
187
|
+
// The words of each line, without what the agent may dress them in (a fence, a quote, bold, end punctuation).
|
|
188
|
+
const core = (t) => t.replace(/\s+/g, ' ').replace(/[*_`"'>\u2018\u2019\u201c\u201d]/gu, '').trim().replace(/[.\s]+$/u, '');
|
|
189
|
+
const [first, second] = [core(said[0]), core(said[1])];
|
|
190
|
+
const lines = reply.split(/\r?\n/);
|
|
191
|
+
let i = lines.length - 1;
|
|
192
|
+
while (i >= 0 && !core(lines[i]).includes(second))
|
|
193
|
+
i--;
|
|
194
|
+
if (i < 0)
|
|
195
|
+
return reply;
|
|
196
|
+
const cut = core(lines[i]).indexOf(first);
|
|
197
|
+
const kept = lines.slice(0, i);
|
|
198
|
+
if (first && cut > 0)
|
|
199
|
+
kept.push(lines[i].slice(0, lines[i].indexOf(said[0].slice(0, 12))));
|
|
200
|
+
else if (first && cut < 0) {
|
|
201
|
+
while (kept.length && !core(kept[kept.length - 1]))
|
|
202
|
+
kept.pop();
|
|
203
|
+
if (kept.length && core(kept[kept.length - 1]).includes(first))
|
|
204
|
+
kept.pop();
|
|
205
|
+
}
|
|
206
|
+
while (kept.length && !core(kept[kept.length - 1]))
|
|
207
|
+
kept.pop();
|
|
208
|
+
return kept.join('\n');
|
|
209
|
+
}
|
|
210
|
+
/** A stop offer shown by the block that started this continued turn: no answer of the person's since. */
|
|
211
|
+
function blockedThisTurn(o) {
|
|
212
|
+
return o.shownAt !== null && o.yes === null && !o.showMe && o.typedAfter.length === 0;
|
|
213
|
+
}
|
|
214
|
+
/** 3.5 step 8 for one run: a job of a moment-2 family with a step call; idempotent per (day, session), costly OR-ed. */
|
|
215
|
+
export function notePool(run, ctx) {
|
|
216
|
+
if (!run.job || !OFFER_FAMILIES[run.job] || run.stepCalls <= 0 || !run.repoKey)
|
|
217
|
+
return;
|
|
218
|
+
// D117 (3), J16: no pool for a repo Trail doesn't know.
|
|
219
|
+
if (!repoKnown(run.repoKey, run.checkout ?? (run.repoKey === ctx.repoKey ? ctx.checkout : ''), ctx.env))
|
|
220
|
+
return;
|
|
221
|
+
const day = { d: localDate(run.startedAt), s: ctx.sessionHash, costly: costly(run) };
|
|
222
|
+
if (notePoolDay(run.repoKey, { job: run.job, words: run.jobWords }, day, run.sheet === 'checked' ? run.id : null, ctx.env, ctx.now))
|
|
223
|
+
run.poolNoted = true;
|
|
224
|
+
}
|
|
225
|
+
/** The Stop use line (4.15), when the host shows a Stop notice and nothing else is said. */
|
|
226
|
+
function useLine(settled) {
|
|
227
|
+
return settled.map((s) => {
|
|
228
|
+
const src = s.state?.source;
|
|
229
|
+
const before = src ? ` (by hand last time: ${src.commands} commands, ${src.failed} failed)` : '';
|
|
230
|
+
return `trail: ${flatLine(s.name, 60)}, ${s.use.calls} commands, ${s.use.failed} failed${before}`;
|
|
231
|
+
}).join('\n');
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=stop-skills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stop-skills.js","sourceRoot":"","sources":["../../src/claude/stop-skills.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAgB,MAAM,2BAA2B,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAwC,MAAM,kBAAkB,CAAC;AAC3H,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAA4B,MAAM,qBAAqB,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,YAAY,EAAqB,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAa,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA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AK,EAAE,MAAM,CAAC;QAC5B,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,wBAAwB,GAAG,CAAC,QAAQ,cAAc,GAAG,CAAC,MAAM,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;QACjG,OAAO,UAAU,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,cAAc,CAAC,CAAC,GAAG,CAAC,MAAM,UAAU,MAAM,EAAE,CAAC;IACpG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { HookOut } from '../skills/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* #663's save ask: under trail, a sign in the transcript that the session
|
|
4
|
+
* found something the code won't tell the next person (a check that failed
|
|
5
|
+
* then passed after an edit, a correction, an undone edit, a picked option, a
|
|
6
|
+
* commit; see note-signals.ts) asks the agent to save a learning, by blocking
|
|
7
|
+
* the stop with the reason. Each sign is asked about once, and a session is
|
|
8
|
+
* asked at most NOTE_ASKS_PER_SESSION times; a saved learning starts the signs
|
|
9
|
+
* over. Never blocks twice in a row: Claude Code sets `stop_hook_active` on
|
|
10
|
+
* the stop that follows a block. The caller writes it only as the Stop's one
|
|
11
|
+
* answer, so a sign is marked asked only when it was. Never throws.
|
|
12
|
+
*/
|
|
13
|
+
export declare function askForNote(input: {
|
|
14
|
+
stop_hook_active?: unknown;
|
|
15
|
+
}, dir: string, id: string, transcript: string | null): HookOut;
|
|
16
|
+
/**
|
|
17
|
+
* The Stop event, for every host that sends one: the turn-end bookkeeping, then the skills part's one answer.
|
|
18
|
+
* `skills: false` for a caller whose payload is not a Stop's (`post-edit-sync` sends an edit's).
|
|
19
|
+
*/
|
|
20
|
+
export declare function handleStopEvent(input: unknown, dir: string, opts?: {
|
|
21
|
+
skills?: boolean;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
//# sourceMappingURL=stop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stop.d.ts","sourceRoot":"","sources":["../../src/claude/stop.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAqGlD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAc7H;AAuBD;;;GAGG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBjH"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one Stop handler: what happens when the agent's turn ends.
|
|
3
|
+
*
|
|
4
|
+
* Turn-end bookkeeping first: what the turn's input tokens cost, whether the
|
|
5
|
+
* reply said what graft saved, and one background graph sync when an edit
|
|
6
|
+
* left the graph dirty. Then the answer, one JSON object at most: the
|
|
7
|
+
* learned-skills part's (stop-skills.ts, loaded only when skills are on), a
|
|
8
|
+
* block (the repeated-job offer the agent says) or a notice, never both. When
|
|
9
|
+
* that part has nothing to say, under trail a sign in the transcript that the
|
|
10
|
+
* session found something the code won't tell the next person asks the agent
|
|
11
|
+
* to save a learning (note-signals.ts). An offer or notice that wins leaves
|
|
12
|
+
* the sign unasked, so the ask can come at a later Stop.
|
|
13
|
+
*/
|
|
14
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
15
|
+
import { join } from 'node:path';
|
|
16
|
+
import { createHash } from 'node:crypto';
|
|
17
|
+
import { spawn } from 'node:child_process';
|
|
18
|
+
import { claudeScriptPath } from './paths.js';
|
|
19
|
+
import { emitHook, payloadSessionId } from './hook-io.js';
|
|
20
|
+
import { stopPart } from './skills-wiring.js';
|
|
21
|
+
import { acquireLock, patchStats, readSession, readStats, writeSession } from './state.js';
|
|
22
|
+
import { catchUpTranscript, hasSavingsTally } from './tally.js';
|
|
23
|
+
import { detectHost } from '../trace/host.js';
|
|
24
|
+
import { hookCursorPath } from '../trace/state.js';
|
|
25
|
+
import { trailHome } from '../notes/trail-home.js';
|
|
26
|
+
import { keepsNotes } from '../notes/home.js';
|
|
27
|
+
import { maybeSyncInBackground } from '../cloud/workspace-sync.js';
|
|
28
|
+
import { brand } from '../brand.js';
|
|
29
|
+
import { NOTE_ASKS_PER_SESSION, noteAsk, noteSignals } from './note-signals.js';
|
|
30
|
+
function sessionId(input) {
|
|
31
|
+
return payloadSessionId(input);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* What the transcript gained since the last Stop, or null when there is no
|
|
35
|
+
* transcript Trail may read as Claude Code's: no path, another host's payload
|
|
36
|
+
* (Cursor and Copilot CLI run these hooks with transcripts of their own), or
|
|
37
|
+
* a subagent's.
|
|
38
|
+
*/
|
|
39
|
+
function readTurnEnd(input, s) {
|
|
40
|
+
const host = detectHost(input);
|
|
41
|
+
if (host.host !== 'claude' || host.subagent)
|
|
42
|
+
return null;
|
|
43
|
+
const path = input.transcript_path;
|
|
44
|
+
if (typeof path !== 'string' || !path)
|
|
45
|
+
return null;
|
|
46
|
+
// Billed up to this reply already, whatever the cursor says.
|
|
47
|
+
return catchUpTranscript(path, hookCursorPath(sessionId(input)), { billedThrough: s.lastBillingUuid });
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* What this turn's input tokens actually cost, added to the session's running
|
|
51
|
+
* pair.
|
|
52
|
+
*
|
|
53
|
+
* Deliberately ungated, unlike {@link countTallyTurn}: the blended rate has to
|
|
54
|
+
* describe the session, and graft turns are not a fair sample of it — they are
|
|
55
|
+
* the long, tool-heavy, cache-warm ones. Sampling only those would report a
|
|
56
|
+
* cheaper token than the session really pays.
|
|
57
|
+
*
|
|
58
|
+
* Accumulates the pair, never the ratio, so the rate re-blends every turn.
|
|
59
|
+
* Each response is billed once, by the read that first sees it; the last
|
|
60
|
+
* reply billed is kept beside the totals.
|
|
61
|
+
*/
|
|
62
|
+
function sampleTurnCost(s, read) {
|
|
63
|
+
if (!read?.lastUuid)
|
|
64
|
+
return false;
|
|
65
|
+
// Kept with the totals it guards: a read that has to start over (a lost
|
|
66
|
+
// cursor, a replaced transcript) bills nothing up to here again.
|
|
67
|
+
s.lastBillingUuid = read.lastUuid;
|
|
68
|
+
if (read.tokens > 0 && read.costMicros >= 0) {
|
|
69
|
+
s.inputCostMicros = (s.inputCostMicros ?? 0) + read.costMicros;
|
|
70
|
+
s.inputTokensBilled = (s.inputTokensBilled ?? 0) + read.tokens;
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* At turn end: did the reply the user just read say what graft saved?
|
|
76
|
+
*
|
|
77
|
+
* Judged only on turns the tool-savings hook flagged, so a conversational turn
|
|
78
|
+
* costs nothing. A turn we cannot observe — a host whose Stop hook names no
|
|
79
|
+
* transcript, another host's payload, an unreadable file, or a Stop with
|
|
80
|
+
* nothing new on disk since the last one — is counted in NEITHER total: the
|
|
81
|
+
* ratio these two numbers form has to mean "of the turns we could check", not
|
|
82
|
+
* "of the turns we tried to".
|
|
83
|
+
*/
|
|
84
|
+
function countTallyTurn(s, read, lastMessage) {
|
|
85
|
+
if (!s.turnUsedGraft)
|
|
86
|
+
return false;
|
|
87
|
+
s.turnUsedGraft = false;
|
|
88
|
+
if (!read?.fresh)
|
|
89
|
+
return true;
|
|
90
|
+
const said = typeof lastMessage === 'string' && lastMessage.trim() ? lastMessage : '';
|
|
91
|
+
// The reply's last words may reach the payload before the transcript: then
|
|
92
|
+
// they name the reply.
|
|
93
|
+
const uuid = read.turn.uuid ?? (said ? `said-${createHash('sha1').update(said).digest('hex').slice(0, 12)}` : null);
|
|
94
|
+
// Same reply as last time we looked: no new prose has landed, so this Stop
|
|
95
|
+
// is a duplicate or a race with the transcript write.
|
|
96
|
+
if (uuid === null || uuid === s.lastTallyUuid)
|
|
97
|
+
return true;
|
|
98
|
+
s.graftTurns = (s.graftTurns ?? 0) + 1;
|
|
99
|
+
if (read.turn.tally || hasSavingsTally(said))
|
|
100
|
+
s.reportedTurns = (s.reportedTurns ?? 0) + 1;
|
|
101
|
+
s.lastTallyUuid = uuid;
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The turn's cost and tally, from one read of the transcript and one write of
|
|
106
|
+
* the session. Returns the transcript's path when it is Claude Code's, for the
|
|
107
|
+
* learning ask, or null when there was none to read.
|
|
108
|
+
*/
|
|
109
|
+
function turnEnd(input, dir) {
|
|
110
|
+
try {
|
|
111
|
+
const id = sessionId(input);
|
|
112
|
+
const s = readSession(dir, id);
|
|
113
|
+
const read = readTurnEnd(input, s);
|
|
114
|
+
const billed = sampleTurnCost(s, read);
|
|
115
|
+
const counted = countTallyTurn(s, read, input.last_assistant_message);
|
|
116
|
+
if (billed || counted)
|
|
117
|
+
writeSession(dir, id, s);
|
|
118
|
+
return read && typeof input.transcript_path === 'string' ? input.transcript_path : null;
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
// A turn-end metric is never worth failing the graph sync over.
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* #663's save ask: under trail, a sign in the transcript that the session
|
|
127
|
+
* found something the code won't tell the next person (a check that failed
|
|
128
|
+
* then passed after an edit, a correction, an undone edit, a picked option, a
|
|
129
|
+
* commit; see note-signals.ts) asks the agent to save a learning, by blocking
|
|
130
|
+
* the stop with the reason. Each sign is asked about once, and a session is
|
|
131
|
+
* asked at most NOTE_ASKS_PER_SESSION times; a saved learning starts the signs
|
|
132
|
+
* over. Never blocks twice in a row: Claude Code sets `stop_hook_active` on
|
|
133
|
+
* the stop that follows a block. The caller writes it only as the Stop's one
|
|
134
|
+
* answer, so a sign is marked asked only when it was. Never throws.
|
|
135
|
+
*/
|
|
136
|
+
export function askForNote(input, dir, id, transcript) {
|
|
137
|
+
try {
|
|
138
|
+
if (!transcript || brand() !== 'trail' || input.stop_hook_active || !keepsNotes(dir))
|
|
139
|
+
return {};
|
|
140
|
+
const s = readSession(dir, id);
|
|
141
|
+
const asked = s.noteAsks ?? [];
|
|
142
|
+
if (asked.length >= NOTE_ASKS_PER_SESSION)
|
|
143
|
+
return {};
|
|
144
|
+
const sign = noteSignals(readFileSync(transcript, 'utf8'), dir).find((x) => !asked.includes(x.key));
|
|
145
|
+
if (!sign)
|
|
146
|
+
return {};
|
|
147
|
+
writeSession(dir, id, { ...s, noteAsks: [...asked, sign.key] });
|
|
148
|
+
return { block: noteAsk(sign) };
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
// A missed reminder costs one learning; a broken Stop hook costs the session.
|
|
152
|
+
return {};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/** One detached graph sync when an edit this turn left the graph dirty. */
|
|
156
|
+
function startSync(dir) {
|
|
157
|
+
try {
|
|
158
|
+
// sync-run.js ships next to this module inside the package, so it resolves in
|
|
159
|
+
// any repo that installs graft (not just graft's own). Defensive existsSync:
|
|
160
|
+
// if the package is somehow incomplete, skip rather than wedge on syncing:true.
|
|
161
|
+
// GRAFT_TEST_SYNC_RUN is a test seam (mirrors GRAFT_TEST_STDIN) so tests can point
|
|
162
|
+
// this at a stub file inside their own sandbox instead of writing into src/claude/.
|
|
163
|
+
const syncRun = process.env.GRAFT_TEST_SYNC_RUN ?? claudeScriptPath('sync-run.js');
|
|
164
|
+
if (!existsSync(syncRun))
|
|
165
|
+
return;
|
|
166
|
+
const stats = readStats(dir);
|
|
167
|
+
if (stats?.dirty && acquireLock(dir)) {
|
|
168
|
+
patchStats(dir, { syncing: true });
|
|
169
|
+
const child = spawn(process.execPath, [syncRun, dir], { detached: true, stdio: 'ignore', windowsHide: true });
|
|
170
|
+
child.unref();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
// The next Stop, or the next query, brings the graph up to date.
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The Stop event, for every host that sends one: the turn-end bookkeeping, then the skills part's one answer.
|
|
179
|
+
* `skills: false` for a caller whose payload is not a Stop's (`post-edit-sync` sends an edit's).
|
|
180
|
+
*/
|
|
181
|
+
export async function handleStopEvent(input, dir, opts = {}) {
|
|
182
|
+
const i = input && typeof input === 'object' && !Array.isArray(input) ? input : {};
|
|
183
|
+
const transcript = turnEnd(i, dir);
|
|
184
|
+
startSync(dir);
|
|
185
|
+
// A learning committed this turn, and the turn's skill runs and searches, reach the team now, not next session.
|
|
186
|
+
maybeSyncInBackground(dir);
|
|
187
|
+
if (opts.skills === false)
|
|
188
|
+
return;
|
|
189
|
+
let out = {};
|
|
190
|
+
try {
|
|
191
|
+
out = await stopPart(i, dir);
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
// A turn always ends; an offer can wait for the next one.
|
|
195
|
+
}
|
|
196
|
+
// The skills part's answer wins; with none, #663's save ask may be the answer.
|
|
197
|
+
if (!out.block && !out.notice && !out.context)
|
|
198
|
+
out = askForNote(i, dir, sessionId(i), transcript);
|
|
199
|
+
try {
|
|
200
|
+
out = await forgetNotice(i, out);
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
// The note waits for the next Stop.
|
|
204
|
+
}
|
|
205
|
+
emitHook('Stop', out);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* D117 (2), skills on or off: what an agent's `trail forget` dropped, told to the person once. One stat when there
|
|
209
|
+
* is nothing to tell; the module loads only when there is.
|
|
210
|
+
*/
|
|
211
|
+
async function forgetNotice(i, out, env = process.env) {
|
|
212
|
+
if (out.block || i.stop_hook_active === true)
|
|
213
|
+
return out;
|
|
214
|
+
if (detectHost(i).subagent || !existsSync(join(trailHome(env), 'state', 'forgot.jsonl')))
|
|
215
|
+
return out;
|
|
216
|
+
const { forgetNoticeAtStop } = await import('../skills/forget-notice.js');
|
|
217
|
+
return forgetNoticeAtStop(out, env, detectHost(i).host);
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=stop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stop.js","sourceRoot":"","sources":["../../src/claude/stop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAqB,MAAM,YAAY,CAAC;AAC9G,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAA0B,MAAM,YAAY,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,qBAAq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UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QAAE,OAAO,GAAG,CAAC;IACrG,MAAM,EAAE,kBAAkB,EAAE,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAC;IAC1E,OAAO,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAC1D,CAAC"}
|
package/dist/claude/tally.d.ts
CHANGED
|
@@ -1,50 +1,38 @@
|
|
|
1
|
+
import type { Memo } from '../trace/cursor.js';
|
|
1
2
|
/** Did this reply tell the user what graft saved? */
|
|
2
3
|
export declare function hasSavingsTally(text: string): boolean;
|
|
3
|
-
/**
|
|
4
|
-
export interface
|
|
5
|
-
/** `uuid` of
|
|
6
|
-
uuid: string;
|
|
7
|
-
/**
|
|
8
|
-
|
|
4
|
+
/** The reply since the person's last prompt, as far as the transcript has it. */
|
|
5
|
+
export interface OpenTurn {
|
|
6
|
+
/** `uuid` of its last assistant entry with text, so the same reply is never counted twice; null before any. */
|
|
7
|
+
uuid: string | null;
|
|
8
|
+
/** Whether any of its text carried the tally (it can land in any block, not only the last). */
|
|
9
|
+
tally: boolean;
|
|
9
10
|
}
|
|
10
|
-
/** What
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/** Micro-dollars this turn's input tokens cost, cache multipliers applied. */
|
|
11
|
+
/** What one read of the transcript brought. */
|
|
12
|
+
export interface TranscriptCatchUp {
|
|
13
|
+
/** Something was read: false for an unreadable file or nothing appended since the last read. */
|
|
14
|
+
fresh: boolean;
|
|
15
|
+
/** What the input tokens of each main-thread response first seen in this read cost, in micro-dollars, and how many there were. */
|
|
16
16
|
costMicros: number;
|
|
17
|
-
/** Input tokens billed this turn, cached and fresh alike. */
|
|
18
17
|
tokens: number;
|
|
18
|
+
/** The reply in progress after this read. */
|
|
19
|
+
turn: OpenTurn;
|
|
20
|
+
/** `uuid` of the last main-thread assistant line read: everything up to it is billed once this read's bill is kept. */
|
|
21
|
+
lastUuid: string | null;
|
|
19
22
|
}
|
|
20
23
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* is never what the user read.
|
|
24
|
+
* What a Claude Code transcript gained since the last read with the same
|
|
25
|
+
* cursor: the cost of each response seen for the first time, and the reply in
|
|
26
|
+
* progress. The first read of a session takes at most the transcript's last
|
|
27
|
+
* 8 MB and bills only the reply in progress (see {@link Bill});
|
|
28
|
+
* `billedThrough` is the last reply billed before (kept with the totals, so
|
|
29
|
+
* it outlives a lost cursor). `also` sees each line of the same read, with
|
|
30
|
+
* the same memo, for another turn-end reader (the learning ask) that keeps
|
|
31
|
+
* its state under a key of its own. Never throws; an unreadable file reads
|
|
32
|
+
* as nothing new.
|
|
31
33
|
*/
|
|
32
|
-
export declare function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*
|
|
37
|
-
* Costed per API response, not per turn, so a turn that switched models is
|
|
38
|
-
* priced correctly rather than labelled with whichever model happened to go
|
|
39
|
-
* last. Responses are deduped by `message.id`: one response is written to the
|
|
40
|
-
* transcript as several entries (a `thinking` block and a `tool_use` block land
|
|
41
|
-
* on their own lines) and every one of them repeats the same `usage`, so
|
|
42
|
-
* summing the lines would bill the turn two or three times over.
|
|
43
|
-
*
|
|
44
|
-
* Null when there is nothing to bill — no transcript path (a host whose Stop
|
|
45
|
-
* hook names none), an unreadable file, a turn whose entries carry no `usage`,
|
|
46
|
-
* or a model with no price in {@link inputUsdPerMtok}. As everywhere in this
|
|
47
|
-
* file, null means "not observed", never "zero".
|
|
48
|
-
*/
|
|
49
|
-
export declare function lastTurnBilling(transcriptPath: unknown): TurnBilling | null;
|
|
34
|
+
export declare function catchUpTranscript(transcriptPath: string, cursorPath: string, opts?: {
|
|
35
|
+
billedThrough?: string;
|
|
36
|
+
also?: (entry: Record<string, unknown>, memo: Memo) => void;
|
|
37
|
+
}): TranscriptCatchUp;
|
|
50
38
|
//# sourceMappingURL=tally.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tally.d.ts","sourceRoot":"","sources":["../../src/claude/tally.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tally.d.ts","sourceRoot":"","sources":["../../src/claude/tally.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAe/C,qDAAqD;AACrD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErD;AAED,iFAAiF;AACjF,MAAM,WAAW,QAAQ;IACvB,+GAA+G;IAC/G,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,+FAA+F;IAC/F,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,+CAA+C;AAC/C,MAAM,WAAW,iBAAiB;IAChC,gGAAgG;IAChG,KAAK,EAAE,OAAO,CAAC;IACf,kIAAkI;IAClI,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,IAAI,EAAE,QAAQ,CAAC;IACf,uHAAuH;IACvH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAyFD;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,IAAI,GAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;CAAO,GACjG,iBAAiB,CAiCnB"}
|