@nanonets/graft 0.21.1 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +549 -314
- package/dist/app/checkout.d.ts +0 -32
- package/dist/app/checkout.d.ts.map +1 -1
- package/dist/app/checkout.js +0 -45
- package/dist/app/checkout.js.map +1 -1
- package/dist/app/identity.d.ts +0 -56
- package/dist/app/identity.d.ts.map +1 -1
- package/dist/app/identity.js +0 -119
- package/dist/app/identity.js.map +1 -1
- package/dist/app/main.js +0 -8
- package/dist/app/main.js.map +1 -1
- package/dist/app/review-process.d.ts.map +1 -1
- package/dist/app/review-process.js +6 -5
- package/dist/app/review-process.js.map +1 -1
- package/dist/app/server.d.ts +0 -20
- package/dist/app/server.d.ts.map +1 -1
- package/dist/app/server.js +0 -121
- package/dist/app/server.js.map +1 -1
- package/dist/ask/ask.d.ts +12 -6
- package/dist/ask/ask.d.ts.map +1 -1
- package/dist/ask/ask.js +28 -38
- package/dist/ask/ask.js.map +1 -1
- package/dist/bin/graft.d.ts +3 -0
- package/dist/bin/graft.d.ts.map +1 -0
- package/dist/bin/graft.js +8 -0
- package/dist/bin/graft.js.map +1 -0
- package/dist/bin/trail.d.ts +3 -0
- package/dist/bin/trail.d.ts.map +1 -0
- package/dist/bin/trail.js +6 -0
- package/dist/bin/trail.js.map +1 -0
- package/dist/blast/blast-cli.d.ts.map +1 -1
- package/dist/blast/blast-cli.js +2 -1
- package/dist/blast/blast-cli.js.map +1 -1
- package/dist/blast/render.d.ts.map +1 -1
- package/dist/blast/render.js +3 -2
- package/dist/blast/render.js.map +1 -1
- package/dist/brand.d.ts +97 -0
- package/dist/brand.d.ts.map +1 -0
- package/dist/brand.js +254 -0
- package/dist/brand.js.map +1 -0
- package/dist/check/learning-edits.d.ts +9 -0
- package/dist/check/learning-edits.d.ts.map +1 -0
- package/dist/check/learning-edits.js +62 -0
- package/dist/check/learning-edits.js.map +1 -0
- package/dist/check/local-check.d.ts +104 -0
- package/dist/check/local-check.d.ts.map +1 -0
- package/dist/check/local-check.js +830 -0
- package/dist/check/local-check.js.map +1 -0
- package/dist/check/types.d.ts +31 -0
- package/dist/check/types.d.ts.map +1 -0
- package/dist/check/types.js +2 -0
- package/dist/check/types.js.map +1 -0
- package/dist/claude/format.d.ts +44 -1
- package/dist/claude/format.d.ts.map +1 -1
- package/dist/claude/format.js +113 -19
- package/dist/claude/format.js.map +1 -1
- package/dist/claude/hook-layers.d.ts +8 -0
- package/dist/claude/hook-layers.d.ts.map +1 -0
- package/dist/claude/hook-layers.js +72 -0
- package/dist/claude/hook-layers.js.map +1 -0
- package/dist/claude/hooks.d.ts +34 -0
- package/dist/claude/hooks.d.ts.map +1 -1
- package/dist/claude/hooks.js +220 -12
- package/dist/claude/hooks.js.map +1 -1
- package/dist/claude/init.d.ts +12 -1
- package/dist/claude/init.d.ts.map +1 -1
- package/dist/claude/init.js +48 -19
- package/dist/claude/init.js.map +1 -1
- package/dist/claude/session-metrics.d.ts +1 -1
- package/dist/claude/session-metrics.d.ts.map +1 -1
- package/dist/claude/session-metrics.js +11 -8
- package/dist/claude/session-metrics.js.map +1 -1
- package/dist/claude/settings-merge.d.ts +1 -0
- package/dist/claude/settings-merge.d.ts.map +1 -1
- package/dist/claude/settings-merge.js +21 -18
- package/dist/claude/settings-merge.js.map +1 -1
- package/dist/claude/shim-template.d.ts +17 -2
- package/dist/claude/shim-template.d.ts.map +1 -1
- package/dist/claude/shim-template.js +153 -23
- package/dist/claude/shim-template.js.map +1 -1
- package/dist/claude/skill-template.d.ts +10 -1
- package/dist/claude/skill-template.d.ts.map +1 -1
- package/dist/claude/skill-template.js +143 -1
- package/dist/claude/skill-template.js.map +1 -1
- package/dist/claude/state.d.ts +8 -0
- package/dist/claude/state.d.ts.map +1 -1
- package/dist/claude/state.js.map +1 -1
- package/dist/claude/statusline.d.ts.map +1 -1
- package/dist/claude/statusline.js +4 -1
- package/dist/claude/statusline.js.map +1 -1
- package/dist/claude/tally.js +1 -1
- package/dist/claude/tally.js.map +1 -1
- package/dist/cli-epilogue.d.ts +0 -6
- package/dist/cli-epilogue.d.ts.map +1 -1
- package/dist/cli-epilogue.js +5 -4
- package/dist/cli-epilogue.js.map +1 -1
- package/dist/cli-meta.d.ts +8 -0
- package/dist/cli-meta.d.ts.map +1 -1
- package/dist/cli-meta.js +28 -8
- package/dist/cli-meta.js.map +1 -1
- package/dist/cli-picker.d.ts +15 -0
- package/dist/cli-picker.d.ts.map +1 -1
- package/dist/cli-picker.js +44 -10
- package/dist/cli-picker.js.map +1 -1
- package/dist/cli.d.ts +0 -5
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1112 -559
- package/dist/cli.js.map +1 -1
- package/dist/cloud/diff.d.ts +20 -0
- package/dist/cloud/diff.d.ts.map +1 -0
- package/dist/cloud/diff.js +59 -0
- package/dist/cloud/diff.js.map +1 -0
- package/dist/cloud/nudge.d.ts +66 -0
- package/dist/cloud/nudge.d.ts.map +1 -0
- package/dist/cloud/nudge.js +269 -0
- package/dist/cloud/nudge.js.map +1 -0
- package/dist/cloud/workspace-sync.d.ts +58 -0
- package/dist/cloud/workspace-sync.d.ts.map +1 -0
- package/dist/cloud/workspace-sync.js +268 -0
- package/dist/cloud/workspace-sync.js.map +1 -0
- package/dist/cloud/workspace.d.ts +159 -0
- package/dist/cloud/workspace.d.ts.map +1 -0
- package/dist/cloud/workspace.js +134 -0
- package/dist/cloud/workspace.js.map +1 -0
- package/dist/context/check.d.ts +1 -1
- package/dist/context/check.d.ts.map +1 -1
- package/dist/context/check.js +9 -8
- package/dist/context/check.js.map +1 -1
- package/dist/context/node-file.js +1 -1
- package/dist/context/node-file.js.map +1 -1
- package/dist/context/savings.d.ts.map +1 -1
- package/dist/context/savings.js +10 -7
- package/dist/context/savings.js.map +1 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +3 -1
- package/dist/engine.js.map +1 -1
- package/dist/graph/build.d.ts +30 -0
- package/dist/graph/build.d.ts.map +1 -1
- package/dist/graph/build.js +65 -19
- package/dist/graph/build.js.map +1 -1
- package/dist/graph/cards.d.ts.map +1 -1
- package/dist/graph/cards.js +4 -2
- package/dist/graph/cards.js.map +1 -1
- package/dist/graph/check.d.ts.map +1 -1
- package/dist/graph/check.js +17 -18
- package/dist/graph/check.js.map +1 -1
- package/dist/graph/container.d.ts.map +1 -1
- package/dist/graph/container.js +7 -2
- package/dist/graph/container.js.map +1 -1
- package/dist/graph/extract-cache.d.ts +4 -0
- package/dist/graph/extract-cache.d.ts.map +1 -1
- package/dist/graph/extract-cache.js.map +1 -1
- package/dist/graph/extract.d.ts +2 -0
- package/dist/graph/extract.d.ts.map +1 -1
- package/dist/graph/extract.js +5 -32
- package/dist/graph/extract.js.map +1 -1
- package/dist/graph/generic.d.ts +7 -1
- package/dist/graph/generic.d.ts.map +1 -1
- package/dist/graph/generic.js +48 -8
- package/dist/graph/generic.js.map +1 -1
- package/dist/graph/native.d.ts +38 -0
- package/dist/graph/native.d.ts.map +1 -0
- package/dist/graph/native.js +169 -0
- package/dist/graph/native.js.map +1 -0
- package/dist/graph/refresh.d.ts.map +1 -1
- package/dist/graph/refresh.js +3 -2
- package/dist/graph/refresh.js.map +1 -1
- package/dist/graph/traverse-cli.d.ts.map +1 -1
- package/dist/graph/traverse-cli.js +4 -3
- package/dist/graph/traverse-cli.js.map +1 -1
- package/dist/graph/workspace-cli.d.ts +2 -0
- package/dist/graph/workspace-cli.d.ts.map +1 -1
- package/dist/graph/workspace-cli.js +13 -1
- package/dist/graph/workspace-cli.js.map +1 -1
- package/dist/graph/workspace.d.ts.map +1 -1
- package/dist/graph/workspace.js +6 -5
- package/dist/graph/workspace.js.map +1 -1
- package/dist/hosts/antigravity.d.ts +10 -3
- package/dist/hosts/antigravity.d.ts.map +1 -1
- package/dist/hosts/antigravity.js +27 -10
- package/dist/hosts/antigravity.js.map +1 -1
- package/dist/hosts/claude-global.d.ts +27 -4
- package/dist/hosts/claude-global.d.ts.map +1 -1
- package/dist/hosts/claude-global.js +90 -9
- package/dist/hosts/claude-global.js.map +1 -1
- package/dist/hosts/codex-hooks.d.ts.map +1 -1
- package/dist/hosts/codex-hooks.js +1 -2
- package/dist/hosts/codex-hooks.js.map +1 -1
- package/dist/hosts/config-write.d.ts.map +1 -1
- package/dist/hosts/config-write.js +2 -1
- package/dist/hosts/config-write.js.map +1 -1
- package/dist/hosts/cursor-hooks.d.ts +5 -2
- package/dist/hosts/cursor-hooks.d.ts.map +1 -1
- package/dist/hosts/cursor-hooks.js +14 -9
- package/dist/hosts/cursor-hooks.js.map +1 -1
- package/dist/hosts/init.d.ts +3 -0
- package/dist/hosts/init.d.ts.map +1 -1
- package/dist/hosts/init.js +32 -10
- package/dist/hosts/init.js.map +1 -1
- package/dist/hosts/instructions.d.ts +9 -4
- package/dist/hosts/instructions.d.ts.map +1 -1
- package/dist/hosts/instructions.js +19 -16
- package/dist/hosts/instructions.js.map +1 -1
- package/dist/hosts/mcp-config.d.ts +19 -4
- package/dist/hosts/mcp-config.d.ts.map +1 -1
- package/dist/hosts/mcp-config.js +81 -30
- package/dist/hosts/mcp-config.js.map +1 -1
- package/dist/hosts/plan.d.ts.map +1 -1
- package/dist/hosts/plan.js +11 -9
- package/dist/hosts/plan.js.map +1 -1
- package/dist/hosts/registry.d.ts +25 -2
- package/dist/hosts/registry.d.ts.map +1 -1
- package/dist/hosts/registry.js +53 -0
- package/dist/hosts/registry.js.map +1 -1
- package/dist/hosts/retract.d.ts.map +1 -1
- package/dist/hosts/retract.js +73 -33
- package/dist/hosts/retract.js.map +1 -1
- package/dist/hosts/sections.d.ts +17 -1
- package/dist/hosts/sections.d.ts.map +1 -1
- package/dist/hosts/sections.js +52 -2
- package/dist/hosts/sections.js.map +1 -1
- package/dist/mcp/instructions.d.ts +1 -25
- package/dist/mcp/instructions.d.ts.map +1 -1
- package/dist/mcp/instructions.js +6 -4
- package/dist/mcp/instructions.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +7 -3
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tool-names.d.ts +10 -3
- package/dist/mcp/tool-names.d.ts.map +1 -1
- package/dist/mcp/tool-names.js +13 -5
- package/dist/mcp/tool-names.js.map +1 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +6 -5
- package/dist/mcp/tools.js.map +1 -1
- package/dist/notes/ask-notes.d.ts +8 -0
- package/dist/notes/ask-notes.d.ts.map +1 -0
- package/dist/notes/ask-notes.js +18 -0
- package/dist/notes/ask-notes.js.map +1 -0
- package/dist/notes/branches.d.ts +85 -0
- package/dist/notes/branches.d.ts.map +1 -0
- package/dist/notes/branches.js +238 -0
- package/dist/notes/branches.js.map +1 -0
- package/dist/notes/cold-start.d.ts +177 -0
- package/dist/notes/cold-start.d.ts.map +1 -0
- package/dist/notes/cold-start.js +537 -0
- package/dist/notes/cold-start.js.map +1 -0
- package/dist/notes/git-facts.d.ts +17 -0
- package/dist/notes/git-facts.d.ts.map +1 -0
- package/dist/notes/git-facts.js +117 -0
- package/dist/notes/git-facts.js.map +1 -0
- package/dist/notes/home.d.ts +87 -0
- package/dist/notes/home.d.ts.map +1 -0
- package/dist/notes/home.js +423 -0
- package/dist/notes/home.js.map +1 -0
- package/dist/notes/notes.d.ts +193 -0
- package/dist/notes/notes.d.ts.map +1 -0
- package/dist/notes/notes.js +536 -0
- package/dist/notes/notes.js.map +1 -0
- package/dist/notes/pr-reviews.d.ts +108 -0
- package/dist/notes/pr-reviews.d.ts.map +1 -0
- package/dist/notes/pr-reviews.js +325 -0
- package/dist/notes/pr-reviews.js.map +1 -0
- package/dist/notes/repo-trail.d.ts +16 -0
- package/dist/notes/repo-trail.d.ts.map +1 -0
- package/dist/notes/repo-trail.js +74 -0
- package/dist/notes/repo-trail.js.map +1 -0
- package/dist/notes/session-cost.d.ts +21 -0
- package/dist/notes/session-cost.d.ts.map +1 -0
- package/dist/notes/session-cost.js +162 -0
- package/dist/notes/session-cost.js.map +1 -0
- package/dist/search/grep-cli.d.ts.map +1 -1
- package/dist/search/grep-cli.js +4 -3
- package/dist/search/grep-cli.js.map +1 -1
- package/dist/skills/skills.d.ts +118 -0
- package/dist/skills/skills.d.ts.map +1 -0
- package/dist/skills/skills.js +370 -0
- package/dist/skills/skills.js.map +1 -0
- package/dist/telemetry/contract.d.ts +2 -14
- package/dist/telemetry/contract.d.ts.map +1 -1
- package/dist/telemetry/contract.js +40 -24
- package/dist/telemetry/contract.js.map +1 -1
- package/dist/telemetry/gate.d.ts.map +1 -1
- package/dist/telemetry/gate.js +2 -1
- package/dist/telemetry/gate.js.map +1 -1
- package/dist/telemetry/notice.d.ts +1 -1
- package/dist/telemetry/notice.d.ts.map +1 -1
- package/dist/telemetry/notice.js +6 -5
- package/dist/telemetry/notice.js.map +1 -1
- package/dist/telemetry/track.d.ts.map +1 -1
- package/dist/telemetry/track.js +5 -0
- package/dist/telemetry/track.js.map +1 -1
- package/dist/upkeep-run.d.ts +7 -0
- package/dist/upkeep-run.d.ts.map +1 -1
- package/dist/upkeep-run.js +52 -12
- package/dist/upkeep-run.js.map +1 -1
- package/dist/upkeep.d.ts +9 -19
- package/dist/upkeep.d.ts.map +1 -1
- package/dist/upkeep.js +38 -59
- package/dist/upkeep.js.map +1 -1
- package/dist/util/browser.d.ts +3 -0
- package/dist/util/browser.d.ts.map +1 -0
- package/dist/util/browser.js +14 -0
- package/dist/util/browser.js.map +1 -0
- package/dist/util/front-matter.d.ts +19 -0
- package/dist/util/front-matter.d.ts.map +1 -0
- package/dist/util/front-matter.js +21 -0
- package/dist/util/front-matter.js.map +1 -0
- package/dist/util/state.d.ts +1 -18
- package/dist/util/state.d.ts.map +1 -1
- package/dist/util/state.js +4 -2
- package/dist/util/state.js.map +1 -1
- package/dist/viz/assemble.js +1 -1
- package/dist/viz/assemble.js.map +1 -1
- package/dist/viz/serve.d.ts.map +1 -1
- package/dist/viz/serve.js +4 -3
- package/dist/viz/serve.js.map +1 -1
- package/package.json +7 -7
- package/scripts/pack-trail.mjs +53 -0
- package/scripts/postinstall.mjs +17 -2
- package/scripts/run-tests.mjs +4 -1
- package/dist/app/brain-build-process.d.ts +0 -22
- package/dist/app/brain-build-process.d.ts.map +0 -1
- package/dist/app/brain-build-process.js +0 -129
- package/dist/app/brain-build-process.js.map +0 -1
- package/dist/app/brain-build-worker.d.ts +0 -35
- package/dist/app/brain-build-worker.d.ts.map +0 -1
- package/dist/app/brain-build-worker.js +0 -56
- package/dist/app/brain-build-worker.js.map +0 -1
- package/dist/app/brain-build.d.ts +0 -160
- package/dist/app/brain-build.d.ts.map +0 -1
- package/dist/app/brain-build.js +0 -278
- package/dist/app/brain-build.js.map +0 -1
- package/dist/app/history.d.ts +0 -163
- package/dist/app/history.d.ts.map +0 -1
- package/dist/app/history.js +0 -319
- package/dist/app/history.js.map +0 -1
- package/dist/app/sources.d.ts +0 -81
- package/dist/app/sources.d.ts.map +0 -1
- package/dist/app/sources.js +0 -470
- package/dist/app/sources.js.map +0 -1
- package/dist/brain/attach.d.ts +0 -44
- package/dist/brain/attach.d.ts.map +0 -1
- package/dist/brain/attach.js +0 -63
- package/dist/brain/attach.js.map +0 -1
- package/dist/brain/claude-md.d.ts +0 -61
- package/dist/brain/claude-md.d.ts.map +0 -1
- package/dist/brain/claude-md.js +0 -171
- package/dist/brain/claude-md.js.map +0 -1
- package/dist/brain/connect.d.ts +0 -59
- package/dist/brain/connect.d.ts.map +0 -1
- package/dist/brain/connect.js +0 -80
- package/dist/brain/connect.js.map +0 -1
- package/dist/brain/context-files.d.ts +0 -79
- package/dist/brain/context-files.d.ts.map +0 -1
- package/dist/brain/context-files.js +0 -245
- package/dist/brain/context-files.js.map +0 -1
- package/dist/brain/link.d.ts +0 -106
- package/dist/brain/link.d.ts.map +0 -1
- package/dist/brain/link.js +0 -167
- package/dist/brain/link.js.map +0 -1
- package/dist/brain/pull.d.ts +0 -48
- package/dist/brain/pull.d.ts.map +0 -1
- package/dist/brain/pull.js +0 -257
- package/dist/brain/pull.js.map +0 -1
- package/dist/brain/push.d.ts +0 -155
- package/dist/brain/push.d.ts.map +0 -1
- package/dist/brain/push.js +0 -304
- package/dist/brain/push.js.map +0 -1
- package/dist/brain/signup.d.ts +0 -117
- package/dist/brain/signup.d.ts.map +0 -1
- package/dist/brain/signup.js +0 -276
- package/dist/brain/signup.js.map +0 -1
- package/dist/brain/upload.d.ts +0 -61
- package/dist/brain/upload.d.ts.map +0 -1
- package/dist/brain/upload.js +0 -210
- package/dist/brain/upload.js.map +0 -1
- package/dist/brain/watch.d.ts +0 -209
- package/dist/brain/watch.d.ts.map +0 -1
- package/dist/brain/watch.js +0 -397
- package/dist/brain/watch.js.map +0 -1
- package/dist/brain/wire.d.ts +0 -38
- package/dist/brain/wire.d.ts.map +0 -1
- package/dist/brain/wire.js +0 -133
- package/dist/brain/wire.js.map +0 -1
- package/dist/legacy-args.d.ts +0 -12
- package/dist/legacy-args.d.ts.map +0 -1
- package/dist/legacy-args.js +0 -31
- package/dist/legacy-args.js.map +0 -1
package/dist/app/sources.js
DELETED
|
@@ -1,470 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Everything in a repository that is already a rule, or nearly one.
|
|
3
|
-
*
|
|
4
|
-
* Commit messages and pull-request discussion say what a team decided in
|
|
5
|
-
* passing. These are the places where they wrote it down on purpose: the
|
|
6
|
-
* instruction files they hand their own agents, the decision records, the linter
|
|
7
|
-
* config, the ownership rules. Higher precision per byte than any amount of
|
|
8
|
-
* history, and most of it is a file read.
|
|
9
|
-
*
|
|
10
|
-
* Every reader returns text, never source code, and every one is best-effort:
|
|
11
|
-
* a repo with none of these still builds a brain from its history.
|
|
12
|
-
*/
|
|
13
|
-
import { readFileSync, existsSync, readdirSync, statSync } from "node:fs";
|
|
14
|
-
import { join, relative } from "node:path";
|
|
15
|
-
import { spawnSync } from "node:child_process";
|
|
16
|
-
import { ghHeaders } from "./identity.js";
|
|
17
|
-
/** Per-file and total caps, so one enormous doc cannot crowd out everything. */
|
|
18
|
-
const MAX_FILE_CHARS = 24_000;
|
|
19
|
-
const MAX_TOTAL_CHARS = 300_000;
|
|
20
|
-
const MAX_SOURCES = 120;
|
|
21
|
-
function readText(root, rel) {
|
|
22
|
-
try {
|
|
23
|
-
const p = join(root, rel);
|
|
24
|
-
if (!existsSync(p) || !statSync(p).isFile())
|
|
25
|
-
return null;
|
|
26
|
-
const raw = readFileSync(p, "utf8");
|
|
27
|
-
const trimmed = raw.trim();
|
|
28
|
-
if (!trimmed)
|
|
29
|
-
return null;
|
|
30
|
-
return trimmed.length > MAX_FILE_CHARS ? `${trimmed.slice(0, MAX_FILE_CHARS)}\n[…truncated]` : trimmed;
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
/** Files directly under `rel`, one level deep, matching `test`. */
|
|
37
|
-
function filesIn(root, rel, test) {
|
|
38
|
-
try {
|
|
39
|
-
const dir = join(root, rel);
|
|
40
|
-
if (!existsSync(dir) || !statSync(dir).isDirectory())
|
|
41
|
-
return [];
|
|
42
|
-
return readdirSync(dir)
|
|
43
|
-
.filter(test)
|
|
44
|
-
.map((n) => join(rel, n))
|
|
45
|
-
.sort();
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
return [];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Instruction files the team already wrote for coding agents.
|
|
53
|
-
*
|
|
54
|
-
* The single highest-precision source in a repository: someone sat down and
|
|
55
|
-
* wrote imperative rules for a machine to follow. Nothing has to be inferred.
|
|
56
|
-
*
|
|
57
|
-
* Graft's own managed blocks are stripped first. Without that the brain reads
|
|
58
|
-
* back graft's instructions about using graft, and then graft carries them into
|
|
59
|
-
* the same file — a loop that fills the rulebook with itself.
|
|
60
|
-
*/
|
|
61
|
-
export function readAgentInstructions(root) {
|
|
62
|
-
const candidates = [
|
|
63
|
-
"CLAUDE.md",
|
|
64
|
-
"AGENTS.md",
|
|
65
|
-
"GEMINI.md",
|
|
66
|
-
".github/copilot-instructions.md",
|
|
67
|
-
".windsurf/rules/graft.md",
|
|
68
|
-
...filesIn(root, ".cursor/rules", (n) => n.endsWith(".mdc") || n.endsWith(".md")),
|
|
69
|
-
// The same files one folder down: a monorepo keeps its frontend's rules in
|
|
70
|
-
// web/CLAUDE.md, and those are as deliberate as the root's.
|
|
71
|
-
...folderInstructionFiles(root),
|
|
72
|
-
// Skills a team wrote for its agents. Graft's own is left out for the same
|
|
73
|
-
// reason its managed blocks are: the brain must not learn graft from graft.
|
|
74
|
-
...skillFiles(root),
|
|
75
|
-
];
|
|
76
|
-
const out = [];
|
|
77
|
-
const seen = new Set();
|
|
78
|
-
for (const rel of candidates) {
|
|
79
|
-
const key = rel.replace(/\\/g, "/");
|
|
80
|
-
if (seen.has(key))
|
|
81
|
-
continue;
|
|
82
|
-
seen.add(key);
|
|
83
|
-
const text = stripManagedBlocks(readText(root, rel) ?? "");
|
|
84
|
-
if (text.trim())
|
|
85
|
-
out.push({ kind: "agent_instructions", path: key, text });
|
|
86
|
-
}
|
|
87
|
-
return out;
|
|
88
|
-
}
|
|
89
|
-
/** Instruction files below the root that are worth reading as instructions. */
|
|
90
|
-
const FOLDER_INSTRUCTION_NAMES = new Set(["CLAUDE.md", "AGENTS.md"]);
|
|
91
|
-
/** How deep below the root a folder instruction file may sit (a/b/c/d/CLAUDE.md). */
|
|
92
|
-
const MAX_FOLDER_DEPTH = 4;
|
|
93
|
-
/** Most folder instruction files, and most skills, carried per push. */
|
|
94
|
-
export const MAX_FOLDER_FILES = 30;
|
|
95
|
-
export const MAX_SKILL_FILES = 30;
|
|
96
|
-
/** Directories never searched for instruction files: dependencies, build
|
|
97
|
-
* output, graft's own cache. Dot-directories are skipped as a class. */
|
|
98
|
-
const SKIP_INSTRUCTION_DIRS = new Set([
|
|
99
|
-
"node_modules",
|
|
100
|
-
"dist",
|
|
101
|
-
"build",
|
|
102
|
-
"out",
|
|
103
|
-
"vendor",
|
|
104
|
-
"graft",
|
|
105
|
-
"target",
|
|
106
|
-
"coverage",
|
|
107
|
-
"__pycache__",
|
|
108
|
-
"venv",
|
|
109
|
-
"bower_components",
|
|
110
|
-
]);
|
|
111
|
-
function skippedSegment(seg) {
|
|
112
|
-
return seg.startsWith(".") || SKIP_INSTRUCTION_DIRS.has(seg);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* `**\/CLAUDE.md` and `**\/AGENTS.md` below the root, shallowest first.
|
|
116
|
-
*
|
|
117
|
-
* Asked of git first, because git already knows what the repository ignores:
|
|
118
|
-
* a CLAUDE.md inside an ignored folder is someone's scratch, not the team's.
|
|
119
|
-
* The walk is the fallback for a checkout git cannot answer for.
|
|
120
|
-
*/
|
|
121
|
-
export function folderInstructionFiles(root, max = MAX_FOLDER_FILES) {
|
|
122
|
-
const keep = (rel) => {
|
|
123
|
-
const parts = rel.split("/");
|
|
124
|
-
const name = parts[parts.length - 1] ?? "";
|
|
125
|
-
const dirs = parts.slice(0, -1);
|
|
126
|
-
if (!FOLDER_INSTRUCTION_NAMES.has(name))
|
|
127
|
-
return false;
|
|
128
|
-
if (dirs.length === 0 || dirs.length > MAX_FOLDER_DEPTH)
|
|
129
|
-
return false;
|
|
130
|
-
return !dirs.some(skippedSegment);
|
|
131
|
-
};
|
|
132
|
-
let found = null;
|
|
133
|
-
const listed = git(root, ["ls-files", "-z", "--cached", "--others", "--exclude-standard", "--", "*CLAUDE.md", "*AGENTS.md"]);
|
|
134
|
-
if (listed !== null)
|
|
135
|
-
found = [...new Set(listed.split("\0").filter(Boolean))].filter(keep);
|
|
136
|
-
if (found === null)
|
|
137
|
-
found = walkFor(root, keep);
|
|
138
|
-
const depth = (p) => p.split("/").length;
|
|
139
|
-
return found
|
|
140
|
-
.filter((rel) => existsSync(join(root, rel)))
|
|
141
|
-
.sort((a, b) => depth(a) - depth(b) || a.localeCompare(b))
|
|
142
|
-
.slice(0, max);
|
|
143
|
-
}
|
|
144
|
-
/** The filesystem walk behind folderInstructionFiles, for a tree git cannot list. */
|
|
145
|
-
function walkFor(root, keep) {
|
|
146
|
-
const out = [];
|
|
147
|
-
const visit = (rel, depth) => {
|
|
148
|
-
if (depth > MAX_FOLDER_DEPTH)
|
|
149
|
-
return;
|
|
150
|
-
let names;
|
|
151
|
-
try {
|
|
152
|
-
names = readdirSync(join(root, rel));
|
|
153
|
-
}
|
|
154
|
-
catch {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
for (const name of names) {
|
|
158
|
-
const child = rel ? `${rel}/${name}` : name;
|
|
159
|
-
let isDir = false;
|
|
160
|
-
try {
|
|
161
|
-
isDir = statSync(join(root, child)).isDirectory();
|
|
162
|
-
}
|
|
163
|
-
catch {
|
|
164
|
-
continue;
|
|
165
|
-
}
|
|
166
|
-
if (isDir) {
|
|
167
|
-
if (!skippedSegment(name))
|
|
168
|
-
visit(child, depth + 1);
|
|
169
|
-
}
|
|
170
|
-
else if (depth > 0 && keep(child)) {
|
|
171
|
-
out.push(child);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
visit("", 0);
|
|
176
|
-
return out;
|
|
177
|
-
}
|
|
178
|
-
/** `.claude/skills/<name>/SKILL.md`, graft's own skill excluded. */
|
|
179
|
-
export function skillFiles(root, max = MAX_SKILL_FILES) {
|
|
180
|
-
const dir = join(root, ".claude", "skills");
|
|
181
|
-
let names;
|
|
182
|
-
try {
|
|
183
|
-
names = readdirSync(dir).sort();
|
|
184
|
-
}
|
|
185
|
-
catch {
|
|
186
|
-
return [];
|
|
187
|
-
}
|
|
188
|
-
const out = [];
|
|
189
|
-
for (const name of names) {
|
|
190
|
-
if (name === "graft" || name.startsWith("."))
|
|
191
|
-
continue;
|
|
192
|
-
const rel = `.claude/skills/${name}/SKILL.md`;
|
|
193
|
-
try {
|
|
194
|
-
if (!statSync(join(root, rel)).isFile())
|
|
195
|
-
continue;
|
|
196
|
-
}
|
|
197
|
-
catch {
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
out.push(rel);
|
|
201
|
-
if (out.length >= max)
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
return out;
|
|
205
|
-
}
|
|
206
|
-
/** Remove graft's own fenced regions, so the brain never learns graft from graft. */
|
|
207
|
-
function stripManagedBlocks(text) {
|
|
208
|
-
return text
|
|
209
|
-
.replace(/<!--\s*graft:(brain:)?start\s*-->[\s\S]*?<!--\s*graft:(brain:)?end\s*-->/g, "")
|
|
210
|
-
.trim();
|
|
211
|
-
}
|
|
212
|
-
/** Architecture decision records and the docs that read like them. */
|
|
213
|
-
export function readDecisionDocs(root) {
|
|
214
|
-
const mdIn = (dir) => filesIn(root, dir, (n) => n.endsWith(".md"));
|
|
215
|
-
const candidates = [
|
|
216
|
-
"ARCHITECTURE.md",
|
|
217
|
-
"CONTRIBUTING.md",
|
|
218
|
-
"docs/ARCHITECTURE.md",
|
|
219
|
-
"docs/CONTRIBUTING.md",
|
|
220
|
-
...mdIn("docs/adr"),
|
|
221
|
-
...mdIn("docs/decisions"),
|
|
222
|
-
...mdIn("adr"),
|
|
223
|
-
];
|
|
224
|
-
const out = [];
|
|
225
|
-
for (const rel of candidates) {
|
|
226
|
-
const text = readText(root, rel);
|
|
227
|
-
if (text)
|
|
228
|
-
out.push({ kind: "decision_doc", path: rel, text });
|
|
229
|
-
}
|
|
230
|
-
return out;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Rules the team already encoded for a machine: linters, formatters, and the
|
|
234
|
-
* checks CI insists on. Nothing to infer — extraction only has to phrase them.
|
|
235
|
-
*/
|
|
236
|
-
export function readCodifiedRules(root) {
|
|
237
|
-
const lint = [
|
|
238
|
-
".golangci.yml",
|
|
239
|
-
".golangci.yaml",
|
|
240
|
-
".eslintrc.json",
|
|
241
|
-
".eslintrc.js",
|
|
242
|
-
"eslint.config.js",
|
|
243
|
-
"eslint.config.mjs",
|
|
244
|
-
"ruff.toml",
|
|
245
|
-
".ruff.toml",
|
|
246
|
-
".prettierrc",
|
|
247
|
-
".prettierrc.json",
|
|
248
|
-
"commitlint.config.cjs",
|
|
249
|
-
"commitlint.config.js",
|
|
250
|
-
".editorconfig",
|
|
251
|
-
];
|
|
252
|
-
const out = [];
|
|
253
|
-
for (const rel of lint) {
|
|
254
|
-
const text = readText(root, rel);
|
|
255
|
-
if (text)
|
|
256
|
-
out.push({ kind: "lint_config", path: rel, text });
|
|
257
|
-
}
|
|
258
|
-
for (const rel of filesIn(root, ".github/workflows", (n) => n.endsWith(".yml") || n.endsWith(".yaml"))) {
|
|
259
|
-
const text = readText(root, rel);
|
|
260
|
-
if (text)
|
|
261
|
-
out.push({ kind: "ci_config", path: rel, text });
|
|
262
|
-
}
|
|
263
|
-
return out;
|
|
264
|
-
}
|
|
265
|
-
/** Who must approve what. A hard constraint, stated as a file. */
|
|
266
|
-
export function readCodeowners(root) {
|
|
267
|
-
for (const rel of [".github/CODEOWNERS", "CODEOWNERS", "docs/CODEOWNERS"]) {
|
|
268
|
-
const text = readText(root, rel);
|
|
269
|
-
if (text)
|
|
270
|
-
return [{ kind: "codeowners", path: rel, text }];
|
|
271
|
-
}
|
|
272
|
-
return [];
|
|
273
|
-
}
|
|
274
|
-
/** Run git in `root`, or null when it fails. */
|
|
275
|
-
function git(root, args) {
|
|
276
|
-
const res = spawnSync("git", ["-c", "core.quotePath=false", ...args], {
|
|
277
|
-
cwd: root,
|
|
278
|
-
encoding: "utf8",
|
|
279
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
280
|
-
maxBuffer: 64 * 1024 * 1024,
|
|
281
|
-
});
|
|
282
|
-
if (res.error || res.status !== 0 || typeof res.stdout !== "string")
|
|
283
|
-
return null;
|
|
284
|
-
return res.stdout;
|
|
285
|
-
}
|
|
286
|
-
/** How many reverts to carry. */
|
|
287
|
-
const MAX_REVERTS = 40;
|
|
288
|
-
/**
|
|
289
|
-
* Commits that undid another commit.
|
|
290
|
-
*
|
|
291
|
-
* "We tried this and took it back" is a rule available from nowhere else, and
|
|
292
|
-
* it is the one kind of history that says what NOT to do. The body of a revert
|
|
293
|
-
* usually names the commit it undoes and, when the author bothered, why.
|
|
294
|
-
*/
|
|
295
|
-
export function readReverts(root, max = MAX_REVERTS) {
|
|
296
|
-
const out = git(root, ["log", "--grep=^Revert", "-n", String(max), "--format=%H%x02%s%x02%b%x01"]);
|
|
297
|
-
if (!out)
|
|
298
|
-
return [];
|
|
299
|
-
const sources = [];
|
|
300
|
-
for (const record of out.split("\x01")) {
|
|
301
|
-
if (!record.trim())
|
|
302
|
-
continue;
|
|
303
|
-
const [sha = "", subject = "", body = ""] = record.split("\x02");
|
|
304
|
-
if (!sha.trim() || !subject.trim())
|
|
305
|
-
continue;
|
|
306
|
-
sources.push({
|
|
307
|
-
kind: "revert",
|
|
308
|
-
path: `revert ${sha.trim().slice(0, 12)}`,
|
|
309
|
-
text: [subject.trim(), body.trim()].filter(Boolean).join("\n"),
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
return sources;
|
|
313
|
-
}
|
|
314
|
-
/** How many test names to carry. */
|
|
315
|
-
const MAX_TEST_NAMES = 300;
|
|
316
|
-
/**
|
|
317
|
-
* Test names, which are invariants someone wrote deliberately.
|
|
318
|
-
*
|
|
319
|
-
* `never retries on a card decline` is a rule stated as an assertion. Read from
|
|
320
|
-
* the graph's own symbols rather than by re-parsing, so this costs nothing:
|
|
321
|
-
* a test function is already a node.
|
|
322
|
-
*
|
|
323
|
-
* Only names that read like a sentence are kept. `TestFoo` is a label;
|
|
324
|
-
* `rejects an expired token` is a claim about how the system must behave.
|
|
325
|
-
*/
|
|
326
|
-
export function readTestNames(symbolNames, max = MAX_TEST_NAMES) {
|
|
327
|
-
const out = [];
|
|
328
|
-
for (const s of symbolNames) {
|
|
329
|
-
if (!/(^|[/.])(test|spec)[s]?[/.]|_test\.|\.test\.|\.spec\./i.test(s.path))
|
|
330
|
-
continue;
|
|
331
|
-
const sentence = humanizeTestName(s.name);
|
|
332
|
-
if (!sentence)
|
|
333
|
-
continue;
|
|
334
|
-
out.push({ kind: "test_name", path: s.path, text: sentence });
|
|
335
|
-
if (out.length === max)
|
|
336
|
-
break;
|
|
337
|
-
}
|
|
338
|
-
return out;
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* A test's name as a claim, or null when it is only a label.
|
|
342
|
-
*
|
|
343
|
-
* Requires three words after the prefix is stripped: fewer than that
|
|
344
|
-
* ("TestParse", "handles errors") states no invariant worth a rule, and letting
|
|
345
|
-
* those through fills the brain with noise that reads like content.
|
|
346
|
-
*/
|
|
347
|
-
function humanizeTestName(name) {
|
|
348
|
-
let s = name.replace(/^(Test|it|test|should|describe)[_\s]*/i, "");
|
|
349
|
-
// TestRetriesThreeTimes → Retries Three Times
|
|
350
|
-
if (/^[A-Za-z]+$/.test(s) && /[a-z][A-Z]/.test(s))
|
|
351
|
-
s = s.replace(/([a-z0-9])([A-Z])/g, "$1 $2");
|
|
352
|
-
s = s.replace(/[_-]+/g, " ").replace(/\s+/g, " ").trim();
|
|
353
|
-
if (s.split(" ").length < 3)
|
|
354
|
-
return null;
|
|
355
|
-
return s.toLowerCase();
|
|
356
|
-
}
|
|
357
|
-
/** How many declined issues to carry. */
|
|
358
|
-
const MAX_DECLINED = 40;
|
|
359
|
-
/**
|
|
360
|
-
* Issues closed as not planned.
|
|
361
|
-
*
|
|
362
|
-
* A decision NOT to build something, which is half of what a codebase's rules
|
|
363
|
-
* are and is invisible everywhere else — nothing was committed, so no commit
|
|
364
|
-
* message records it.
|
|
365
|
-
*/
|
|
366
|
-
export async function readDeclinedIssues(owner, repo, token, fetchImpl, api = "https://api.github.com", max = MAX_DECLINED) {
|
|
367
|
-
try {
|
|
368
|
-
const res = await fetchImpl(`${api}/repos/${owner}/${repo}/issues?state=closed&per_page=100&sort=updated`, {
|
|
369
|
-
headers: ghHeaders(token),
|
|
370
|
-
});
|
|
371
|
-
if (!res.ok)
|
|
372
|
-
return [];
|
|
373
|
-
const items = JSON.parse(await res.text());
|
|
374
|
-
if (!Array.isArray(items))
|
|
375
|
-
return [];
|
|
376
|
-
const out = [];
|
|
377
|
-
for (const i of items) {
|
|
378
|
-
// The issues endpoint returns pull requests too; they are already mined as
|
|
379
|
-
// threads and would be counted twice.
|
|
380
|
-
if (i.pull_request)
|
|
381
|
-
continue;
|
|
382
|
-
if (i.state_reason !== "not_planned")
|
|
383
|
-
continue;
|
|
384
|
-
if (!i.title?.trim())
|
|
385
|
-
continue;
|
|
386
|
-
out.push({
|
|
387
|
-
kind: "declined_issue",
|
|
388
|
-
path: `issue #${i.number}`,
|
|
389
|
-
text: [i.title.trim(), (i.body ?? "").trim()].filter(Boolean).join("\n").slice(0, MAX_FILE_CHARS),
|
|
390
|
-
url: i.html_url,
|
|
391
|
-
});
|
|
392
|
-
if (out.length === max)
|
|
393
|
-
break;
|
|
394
|
-
}
|
|
395
|
-
return out;
|
|
396
|
-
}
|
|
397
|
-
catch {
|
|
398
|
-
return [];
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
/** Required checks and reviewers on the default branch. */
|
|
402
|
-
export async function readBranchProtection(owner, repo, branch, token, fetchImpl, api = "https://api.github.com") {
|
|
403
|
-
if (!branch)
|
|
404
|
-
return [];
|
|
405
|
-
try {
|
|
406
|
-
const res = await fetchImpl(`${api}/repos/${owner}/${repo}/branches/${encodeURIComponent(branch)}/protection`, {
|
|
407
|
-
headers: ghHeaders(token),
|
|
408
|
-
});
|
|
409
|
-
// 404 simply means the branch is not protected, which is not a failure.
|
|
410
|
-
if (!res.ok)
|
|
411
|
-
return [];
|
|
412
|
-
const p = JSON.parse(await res.text());
|
|
413
|
-
const lines = [];
|
|
414
|
-
const checks = p.required_status_checks?.contexts ?? [];
|
|
415
|
-
if (checks.length)
|
|
416
|
-
lines.push(`Checks that must pass before merging to ${branch}: ${checks.join(", ")}.`);
|
|
417
|
-
const reviews = p.required_pull_request_reviews;
|
|
418
|
-
if (reviews?.required_approving_review_count) {
|
|
419
|
-
lines.push(`${reviews.required_approving_review_count} approving review(s) required to merge to ${branch}.`);
|
|
420
|
-
}
|
|
421
|
-
if (reviews?.require_code_owner_reviews)
|
|
422
|
-
lines.push(`A code owner must approve changes to ${branch}.`);
|
|
423
|
-
if (p.allow_force_pushes?.enabled === false)
|
|
424
|
-
lines.push(`Force pushes to ${branch} are not allowed.`);
|
|
425
|
-
if (!lines.length)
|
|
426
|
-
return [];
|
|
427
|
-
return [{ kind: "branch_protection", path: `branch protection: ${branch}`, text: lines.join("\n") }];
|
|
428
|
-
}
|
|
429
|
-
catch {
|
|
430
|
-
return [];
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Trim the collected sources to a budget, best kinds first.
|
|
435
|
-
*
|
|
436
|
-
* The order is the argument of this whole module: a file the team wrote to
|
|
437
|
-
* instruct an agent outranks a decision doc, which outranks a config, which
|
|
438
|
-
* outranks anything inferred. When the budget runs out it should run out on the
|
|
439
|
-
* weakest evidence.
|
|
440
|
-
*/
|
|
441
|
-
const KIND_RANK = [
|
|
442
|
-
"agent_instructions",
|
|
443
|
-
"decision_doc",
|
|
444
|
-
"codeowners",
|
|
445
|
-
"branch_protection",
|
|
446
|
-
"lint_config",
|
|
447
|
-
"ci_config",
|
|
448
|
-
"revert",
|
|
449
|
-
"declined_issue",
|
|
450
|
-
"test_name",
|
|
451
|
-
];
|
|
452
|
-
export function budgetSources(sources, maxChars = MAX_TOTAL_CHARS, maxCount = MAX_SOURCES) {
|
|
453
|
-
const ranked = [...sources].sort((a, b) => KIND_RANK.indexOf(a.kind) - KIND_RANK.indexOf(b.kind));
|
|
454
|
-
const out = [];
|
|
455
|
-
let spent = 0;
|
|
456
|
-
for (const s of ranked) {
|
|
457
|
-
if (out.length >= maxCount)
|
|
458
|
-
break;
|
|
459
|
-
if (spent + s.text.length > maxChars)
|
|
460
|
-
continue;
|
|
461
|
-
out.push(s);
|
|
462
|
-
spent += s.text.length;
|
|
463
|
-
}
|
|
464
|
-
return out;
|
|
465
|
-
}
|
|
466
|
-
/** Repo-relative path, for readers handed an absolute one. */
|
|
467
|
-
export function relPath(root, abs) {
|
|
468
|
-
return relative(root, abs) || abs;
|
|
469
|
-
}
|
|
470
|
-
//# sourceMappingURL=sources.js.map
|
package/dist/app/sources.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sources.js","sourceRoot":"","sources":["../../src/app/sources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAc,MAAM,eAAe,CAAC;AAwBtD,gFAAgF;AAChF,MAAM,cAAc,GAAG,MAAM,CAAC;AAC9B,MAAM,eAAe,GAAG,OAAO,CAAC;AAChC,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,SAAS,QAAQ,CAAC,IAAY,EAAE,GAAW;IACzC,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE;YAAE,OAAO,IAAI,CAAC;QACzD,MAAM,GAAG,GAAG,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACpC,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QAC3B,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC;QAC1B,OAAO,OAAO,CAAC,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,cAA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CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,GAAW;IAC/C,OAAO,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC;AACpC,CAAC"}
|
package/dist/brain/attach.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Attach a brain's rules to an `ask` answer.
|
|
3
|
-
*
|
|
4
|
-
* The join is the symbol: a rule is mined against a graft node id, and an
|
|
5
|
-
* answer is a set of hits that point at spans. Resolving the hits back to node
|
|
6
|
-
* ids gives the rules that govern exactly what the agent is about to read.
|
|
7
|
-
*
|
|
8
|
-
* Staleness is decided HERE, on the machine that has the code: the rule carries
|
|
9
|
-
* the symbol's body hash from when it was mined, and the local graph carries
|
|
10
|
-
* the hash now. A mismatch means the code moved out from under the rule, which
|
|
11
|
-
* is worth saying rather than hiding — a rule that describes code that no
|
|
12
|
-
* longer exists is the failure mode this whole mechanism exists to catch.
|
|
13
|
-
*/
|
|
14
|
-
import type { GraphV1 } from '../graph/types.js';
|
|
15
|
-
import type { BrainRule } from './link.js';
|
|
16
|
-
/** One rule, resolved against the current graph. */
|
|
17
|
-
export interface AppliedRule {
|
|
18
|
-
rule: string;
|
|
19
|
-
/** The symbol it governs, as a `path:span` pointer the agent can open. */
|
|
20
|
-
pointer: string;
|
|
21
|
-
/** True when the symbol's body hash no longer matches what the rule was mined at. */
|
|
22
|
-
stale: boolean;
|
|
23
|
-
sourceUrl?: string;
|
|
24
|
-
}
|
|
25
|
-
/** Most rules to attach to one answer. */
|
|
26
|
-
export declare const MAX_ATTACHED_RULES = 6;
|
|
27
|
-
/**
|
|
28
|
-
* The rules governing the symbols in `pointers`, resolved against `graph`.
|
|
29
|
-
*
|
|
30
|
-
* Scoped to the answer, not the repo: attaching every rule a brain holds would
|
|
31
|
-
* turn a token-saving pack into a token-spending one, and `ask` prints the
|
|
32
|
-
* saving it claims. Capped for the same reason.
|
|
33
|
-
*/
|
|
34
|
-
export declare function rulesForPointers(pointers: string[], rules: BrainRule[], graph: GraphV1 | null): AppliedRule[];
|
|
35
|
-
/**
|
|
36
|
-
* Render the rules block appended to an `ask` pack.
|
|
37
|
-
*
|
|
38
|
-
* Deliberately terse. This rides along on every answer, so it has to earn its
|
|
39
|
-
* tokens: one line per rule, the pointer it governs, and a link only when there
|
|
40
|
-
* is one. The `[graft]` prefix is avoided — `sumSavingsFooters` scans for
|
|
41
|
-
* `[graft] tokens saved ≈` and nothing here should look like a savings line.
|
|
42
|
-
*/
|
|
43
|
-
export declare function formatRules(applied: AppliedRule[]): string[];
|
|
44
|
-
//# sourceMappingURL=attach.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attach.d.ts","sourceRoot":"","sources":["../../src/brain/attach.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,oDAAoD;AACpD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,0CAA0C;AAC1C,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAAE,EAClB,KAAK,EAAE,SAAS,EAAE,EAClB,KAAK,EAAE,OAAO,GAAG,IAAI,GACpB,WAAW,EAAE,CA+Bf;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,EAAE,CAS5D"}
|
package/dist/brain/attach.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/** Most rules to attach to one answer. */
|
|
2
|
-
export const MAX_ATTACHED_RULES = 6;
|
|
3
|
-
/**
|
|
4
|
-
* The rules governing the symbols in `pointers`, resolved against `graph`.
|
|
5
|
-
*
|
|
6
|
-
* Scoped to the answer, not the repo: attaching every rule a brain holds would
|
|
7
|
-
* turn a token-saving pack into a token-spending one, and `ask` prints the
|
|
8
|
-
* saving it claims. Capped for the same reason.
|
|
9
|
-
*/
|
|
10
|
-
export function rulesForPointers(pointers, rules, graph) {
|
|
11
|
-
if (!rules.length || !graph)
|
|
12
|
-
return [];
|
|
13
|
-
// node id → its current pointer and body hash. One pass over the graph; the
|
|
14
|
-
// caller does this once per ask, not once per hit.
|
|
15
|
-
const byId = new Map();
|
|
16
|
-
for (const n of graph.nodes) {
|
|
17
|
-
byId.set(n.id, { pointer: `${n.path}:${n.span}`, hash: n.body_hash });
|
|
18
|
-
}
|
|
19
|
-
const wanted = new Set(pointers);
|
|
20
|
-
const out = [];
|
|
21
|
-
const seen = new Set();
|
|
22
|
-
for (const r of rules) {
|
|
23
|
-
const node = byId.get(r.symbol);
|
|
24
|
-
if (!node || !wanted.has(node.pointer))
|
|
25
|
-
continue;
|
|
26
|
-
// The same rule can be mined against two symbols in one answer; show it once.
|
|
27
|
-
if (seen.has(r.rule))
|
|
28
|
-
continue;
|
|
29
|
-
seen.add(r.rule);
|
|
30
|
-
out.push({
|
|
31
|
-
rule: r.rule,
|
|
32
|
-
pointer: node.pointer,
|
|
33
|
-
// No recorded fingerprint means the rule was mined before hashing existed
|
|
34
|
-
// (or against a symbol graft could not hash). Unknown is not stale: a
|
|
35
|
-
// false "the code moved" is worse than saying nothing about freshness.
|
|
36
|
-
stale: r.fingerprint !== '' && r.fingerprint !== node.hash,
|
|
37
|
-
sourceUrl: r.sourceUrl,
|
|
38
|
-
});
|
|
39
|
-
if (out.length === MAX_ATTACHED_RULES)
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
return out;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Render the rules block appended to an `ask` pack.
|
|
46
|
-
*
|
|
47
|
-
* Deliberately terse. This rides along on every answer, so it has to earn its
|
|
48
|
-
* tokens: one line per rule, the pointer it governs, and a link only when there
|
|
49
|
-
* is one. The `[graft]` prefix is avoided — `sumSavingsFooters` scans for
|
|
50
|
-
* `[graft] tokens saved ≈` and nothing here should look like a savings line.
|
|
51
|
-
*/
|
|
52
|
-
export function formatRules(applied) {
|
|
53
|
-
if (!applied.length)
|
|
54
|
-
return [];
|
|
55
|
-
const lines = ['', 'rules that govern these symbols'];
|
|
56
|
-
for (const a of applied) {
|
|
57
|
-
const flag = a.stale ? ' (STALE — the code changed since this was decided)' : '';
|
|
58
|
-
lines.push(`- ${a.rule}${flag}`);
|
|
59
|
-
lines.push(` ${a.pointer}${a.sourceUrl ? ` · ${a.sourceUrl}` : ''}`);
|
|
60
|
-
}
|
|
61
|
-
return lines;
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=attach.js.map
|
package/dist/brain/attach.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attach.js","sourceRoot":"","sources":["../../src/brain/attach.ts"],"names":[],"mappings":"AA0BA,0CAA0C;AAC1C,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAAkB,EAClB,KAAkB,EAClB,KAAqB;IAErB,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IAEvC,4EAA4E;IAC5E,mDAAmD;IACnD,MAAM,IAAI,GAAG,IAAI,GAAG,EAA6C,CAAC;IAClE,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,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AM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,oDAAoD,CAAC,CAAC,CAAC,EAAE,CAAC;QACjF,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC;QACjC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The CLAUDE.md half of `graft trail pull` (and of `graft claude-md pull`, its
|
|
3
|
-
* old name): write the CLAUDE.md changes accepted in Trail into this checkout's
|
|
4
|
-
* instruction file.
|
|
5
|
-
*
|
|
6
|
-
* Trail compares the repository's CLAUDE.md with what its history says and
|
|
7
|
-
* suggests edits and new sections; a person accepts some of them on the brain's
|
|
8
|
-
* CLAUDE.md page. This fetches the accepted ones, applies them to the local
|
|
9
|
-
* file, and tells Trail which it wrote so the page stops listing them.
|
|
10
|
-
*
|
|
11
|
-
* The file is edited line by line, never regenerated, so everything a change
|
|
12
|
-
* does not touch comes back byte for byte. An edit whose text is no longer in
|
|
13
|
-
* its section means the local file has moved on since Trail read it; that
|
|
14
|
-
* change is reported and left, never guessed at. Same rules as Trail's own
|
|
15
|
-
* ComposeClaudeMd, which is what the page's preview shows.
|
|
16
|
-
*/
|
|
17
|
-
import { type BrainLink } from "./link.js";
|
|
18
|
-
/** One accepted change, as Trail sends it. */
|
|
19
|
-
export interface ClaudeMdChange {
|
|
20
|
-
id: string;
|
|
21
|
-
kind: "edit" | "add";
|
|
22
|
-
/** edit: the section it rewrites. add: the new section's heading. */
|
|
23
|
-
heading: string;
|
|
24
|
-
/** add: the section it goes after; "" = end of file. */
|
|
25
|
-
after_heading?: string;
|
|
26
|
-
/** edit: the text to replace; "" = append to the section. */
|
|
27
|
-
find?: string;
|
|
28
|
-
text: string;
|
|
29
|
-
reason?: string;
|
|
30
|
-
}
|
|
31
|
-
export interface ClaudeMdPull {
|
|
32
|
-
/** The file Trail read, e.g. "CLAUDE.md"; "" when the repo had none. */
|
|
33
|
-
path: string;
|
|
34
|
-
head_sha: string;
|
|
35
|
-
changes: ClaudeMdChange[];
|
|
36
|
-
}
|
|
37
|
-
export interface ApplyResult {
|
|
38
|
-
text: string;
|
|
39
|
-
/** Written by this pull. */
|
|
40
|
-
written: ClaudeMdChange[];
|
|
41
|
-
/** Already in the file (committed by someone else): nothing to write. */
|
|
42
|
-
present: ClaudeMdChange[];
|
|
43
|
-
/** Could not be placed; the file was left as it is for these. */
|
|
44
|
-
skipped: Array<{
|
|
45
|
-
change: ClaudeMdChange;
|
|
46
|
-
why: string;
|
|
47
|
-
}>;
|
|
48
|
-
}
|
|
49
|
-
/** GET /api/public/brains/:id/claude-md — the accepted changes. */
|
|
50
|
-
export declare function fetchAcceptedChanges(link: BrainLink, fetchImpl?: typeof fetch): Promise<ClaudeMdPull | {
|
|
51
|
-
error: string;
|
|
52
|
-
unsupported?: boolean;
|
|
53
|
-
}>;
|
|
54
|
-
/** POST /api/public/brains/:id/claude-md/applied — what this pull wrote. */
|
|
55
|
-
export declare function markApplied(link: BrainLink, ids: string[], fetchImpl?: typeof fetch): Promise<boolean>;
|
|
56
|
-
/**
|
|
57
|
-
* Apply accepted changes to the file's text. Pure: reads nothing, writes
|
|
58
|
-
* nothing, so the command and the tests share it.
|
|
59
|
-
*/
|
|
60
|
-
export declare function applyChanges(original: string, changes: ClaudeMdChange[]): ApplyResult;
|
|
61
|
-
//# sourceMappingURL=claude-md.d.ts.map
|