@nanonets/graft 0.21.0 → 0.22.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 +549 -315
- 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/sources.js +2 -2
- package/dist/app/sources.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/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 +116 -22
- 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 +132 -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.map +1 -1
- package/dist/cli-picker.js +11 -7
- 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 +1037 -595
- package/dist/cli.js.map +1 -1
- package/dist/cloud/diff.d.ts +18 -0
- package/dist/cloud/diff.d.ts.map +1 -0
- package/dist/cloud/diff.js +58 -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 +127 -0
- package/dist/notes/cold-start.d.ts.map +1 -0
- package/dist/notes/cold-start.js +476 -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 +178 -0
- package/dist/notes/notes.d.ts.map +1 -0
- package/dist/notes/notes.js +498 -0
- package/dist/notes/notes.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 +39 -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/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 -17
- package/dist/brain/pull.d.ts.map +0 -1
- package/dist/brain/pull.js +0 -172
- 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 -396
- 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/brain/push.d.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { type HistoryThread, type RepoDigest, type ThreadReadCache } from "../app/history.js";
|
|
2
|
-
import type { GraphV1 } from "../graph/types.js";
|
|
3
|
-
import { type BrainLink } from "./link.js";
|
|
4
|
-
import { type UploadCaps, type UploadOptions } from "./upload.js";
|
|
5
|
-
/** What a local ingest read, for the caller to print. */
|
|
6
|
-
export interface PushResult {
|
|
7
|
-
jobId: string;
|
|
8
|
-
repo: string;
|
|
9
|
-
commits: number;
|
|
10
|
-
threads: number;
|
|
11
|
-
symbols: number;
|
|
12
|
-
sources: number;
|
|
13
|
-
/** Set when discussion could not be read; the ingest still went ahead. */
|
|
14
|
-
warning?: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* owner/name for this checkout, from its origin remote.
|
|
18
|
-
*
|
|
19
|
-
* Only GitHub, because the discussion reader and the forge links are
|
|
20
|
-
* GitHub-shaped; another forge would need its own reader, not a looser regex
|
|
21
|
-
* here that produces links to nowhere.
|
|
22
|
-
*/
|
|
23
|
-
export declare function repoSlugFromGit(root: string): {
|
|
24
|
-
owner: string;
|
|
25
|
-
name: string;
|
|
26
|
-
} | null;
|
|
27
|
-
/**
|
|
28
|
-
* A GitHub token from wherever the user already keeps one.
|
|
29
|
-
*
|
|
30
|
-
* `gh auth token` first, because anyone who works with private repositories on
|
|
31
|
-
* the command line has it and it needs no setup at all. The env vars are the
|
|
32
|
-
* CI path. Absent, the ingest still runs on commits alone — pull-request
|
|
33
|
-
* discussion is the richest source, not a required one.
|
|
34
|
-
*/
|
|
35
|
-
export declare function githubToken(): string | null;
|
|
36
|
-
/** What the brain is waiting for, when it is waiting for something. */
|
|
37
|
-
export interface ExpectedRepo {
|
|
38
|
-
slug: string;
|
|
39
|
-
status: string;
|
|
40
|
-
brainName: string;
|
|
41
|
-
/** Rules the trail already holds; 0 before its first build. */
|
|
42
|
-
ruleCount: number;
|
|
43
|
-
/** The brain accepts an early upload (see pushEarlyDigest). */
|
|
44
|
-
earlyUpload: boolean;
|
|
45
|
-
/** POST /repo takes a gzipped body (`gzip_upload`). */
|
|
46
|
-
gzipUpload: boolean;
|
|
47
|
-
/** The chunked /repo/uploads routes exist (`chunked_upload`). */
|
|
48
|
-
chunkedUpload: boolean;
|
|
49
|
-
/** GET /events streams the build (`events`). */
|
|
50
|
-
events: boolean;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* The repository this brain expects, or null when it expects none.
|
|
54
|
-
*
|
|
55
|
-
* The website records it when the user chooses the local route, so this is how
|
|
56
|
-
* the CLI knows whether the directory it is standing in is the one they asked
|
|
57
|
-
* for. Mining the wrong repo into a brain is silent and very hard to notice
|
|
58
|
-
* afterwards — the rules simply describe someone else's codebase — so the round
|
|
59
|
-
* trip is worth it.
|
|
60
|
-
*
|
|
61
|
-
* The same read says what the server can take: gzip, chunks, a live event
|
|
62
|
-
* stream. Every flag defaults to off, so an older Trail gets exactly the
|
|
63
|
-
* requests it always did.
|
|
64
|
-
*
|
|
65
|
-
* Null on any failure, which keeps an older brain (or an unreachable one)
|
|
66
|
-
* working exactly as it did before this check existed.
|
|
67
|
-
*/
|
|
68
|
-
export declare function fetchExpectedRepo(link: BrainLink, fetchImpl?: typeof fetch): Promise<ExpectedRepo | null>;
|
|
69
|
-
/** The upload capabilities an expected-repo read advertised. */
|
|
70
|
-
export declare function uploadCaps(expected: ExpectedRepo | null): UploadCaps;
|
|
71
|
-
/** Whether two repo slugs name the same repository. GitHub is case-insensitive. */
|
|
72
|
-
export declare function sameRepo(a: string, b: string): boolean;
|
|
73
|
-
/** How many of the newest pull requests and commits the early upload carries —
|
|
74
|
-
* what Trail's quick CLAUDE.md pass reads, and no more. */
|
|
75
|
-
export declare const EARLY_THREADS = 30;
|
|
76
|
-
export declare const EARLY_COMMITS = 80;
|
|
77
|
-
/**
|
|
78
|
-
* What one push reads once and shares between its early and full digests: the
|
|
79
|
-
* repository's identity, the GitHub token, whether it is private, and every
|
|
80
|
-
* request already made to GitHub for its pull requests.
|
|
81
|
-
*/
|
|
82
|
-
export interface PushContext {
|
|
83
|
-
owner: string;
|
|
84
|
-
name: string;
|
|
85
|
-
token: string | null;
|
|
86
|
-
fetchImpl: typeof fetch;
|
|
87
|
-
headSha: string;
|
|
88
|
-
branch: string;
|
|
89
|
-
/** Asked once, when first needed. */
|
|
90
|
-
isPrivate: () => Promise<boolean>;
|
|
91
|
-
threads: ThreadReadCache;
|
|
92
|
-
}
|
|
93
|
-
/** The shared context for a push from `root`, or null without a GitHub origin. */
|
|
94
|
-
export declare function pushContext(root: string, opts?: {
|
|
95
|
-
fetchImpl?: typeof fetch;
|
|
96
|
-
}): PushContext | null;
|
|
97
|
-
/**
|
|
98
|
-
* The early upload: the instruction files, the newest pull requests and the
|
|
99
|
-
* newest commits, read before the rest of the history.
|
|
100
|
-
*
|
|
101
|
-
* Reading the history is most of a push's wait — up to 200 pull requests at two
|
|
102
|
-
* GitHub calls each — and Trail's first CLAUDE.md suggestions need none of it
|
|
103
|
-
* beyond the newest few. Sent first, they start while the full read is still
|
|
104
|
-
* going here, and the full upload that follows mines as before.
|
|
105
|
-
*
|
|
106
|
-
* Only the newest commits are read here, not the thousand the full read takes,
|
|
107
|
-
* so nothing but these few requests stands between the push starting and Trail
|
|
108
|
-
* starting. The pull requests go through the shared cache, so the full read
|
|
109
|
-
* asks GitHub for none of them again — not even one still in flight.
|
|
110
|
-
*
|
|
111
|
-
* Null when there is nothing worth sending early.
|
|
112
|
-
*/
|
|
113
|
-
export declare function buildEarlyDigest(root: string, opts?: {
|
|
114
|
-
fetchImpl?: typeof fetch;
|
|
115
|
-
context?: PushContext;
|
|
116
|
-
}): Promise<{
|
|
117
|
-
digest: RepoDigest;
|
|
118
|
-
threads: HistoryThread[];
|
|
119
|
-
} | null>;
|
|
120
|
-
/**
|
|
121
|
-
* The agents this repo is wired for — what `graft init` recorded plus what is on
|
|
122
|
-
* disk, the same set `graft trail pull` filters by — so Trail can show only the
|
|
123
|
-
* context files those agents read. Empty before the first init; Trail then
|
|
124
|
-
* shows every kind.
|
|
125
|
-
*/
|
|
126
|
-
export declare function pickedAgents(root: string): string[];
|
|
127
|
-
/** Send the early upload. Best-effort: false on any failure, and the full
|
|
128
|
-
* upload still does everything. Gzipped when the server takes it. */
|
|
129
|
-
export declare function pushEarlyDigest(link: BrainLink, digest: RepoDigest, fetchImpl?: typeof fetch, opts?: {
|
|
130
|
-
gzip?: boolean;
|
|
131
|
-
}): Promise<boolean>;
|
|
132
|
-
/** Build the digest for the checkout at `root`. Reads nothing but text. */
|
|
133
|
-
export declare function buildLocalDigest(root: string, graph: GraphV1 | null, opts?: {
|
|
134
|
-
autoApprove?: boolean;
|
|
135
|
-
fetchImpl?: typeof fetch;
|
|
136
|
-
knownThreads?: HistoryThread[];
|
|
137
|
-
context?: PushContext;
|
|
138
|
-
}): Promise<{
|
|
139
|
-
digest: RepoDigest;
|
|
140
|
-
warning?: string;
|
|
141
|
-
} | {
|
|
142
|
-
error: string;
|
|
143
|
-
}>;
|
|
144
|
-
/**
|
|
145
|
-
* Send a digest to the brain and return the job to poll.
|
|
146
|
-
*
|
|
147
|
-
* Chunked and gzipped when the server advertises both, gzipped in one POST when
|
|
148
|
-
* it advertises only gzip, and today's plain POST otherwise.
|
|
149
|
-
*/
|
|
150
|
-
export declare function pushDigest(link: BrainLink, digest: RepoDigest, fetchImpl?: typeof fetch, caps?: UploadCaps, opts?: Omit<UploadOptions, "fetchImpl">): Promise<{
|
|
151
|
-
jobId: string;
|
|
152
|
-
} | {
|
|
153
|
-
error: string;
|
|
154
|
-
}>;
|
|
155
|
-
//# sourceMappingURL=push.d.ts.map
|
package/dist/brain/push.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../src/brain/push.ts"],"names":[],"mappings":"AAiBA,OAAO,EAML,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAY3B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAgC,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAEhG,yDAAyD;AACzD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E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IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CA6DvE;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,UAAU,EAClB,SAAS,GAAE,OAAO,KAAa,EAC/B,IAAI,GAAE,UAAe,EACrB,IAAI,GAAE,IAAI,CAAC,aAAa,EAAE,WAAW,CAAM,GAC1C,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAEhD"}
|
package/dist/brain/push.js
DELETED
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Building a brain from the repository already on this machine.
|
|
3
|
-
*
|
|
4
|
-
* The server path needs graft's GitHub App installed on the repo, which is an
|
|
5
|
-
* admin action on someone else's org and the first thing asked of a person who
|
|
6
|
-
* has not seen a single rule yet. For a private repository it is often simply
|
|
7
|
-
* unavailable.
|
|
8
|
-
*
|
|
9
|
-
* This is the way round that: the clone is already here, and the user is
|
|
10
|
-
* already authenticated to GitHub for their own work. So read it locally and
|
|
11
|
-
* send up the same digest the server would have built.
|
|
12
|
-
*
|
|
13
|
-
* What leaves the machine is what people wrote — commit messages, pull-request
|
|
14
|
-
* comments, the docs and config already in the tree — plus symbol ids and
|
|
15
|
-
* hashes. No file contents, no diffs, no source.
|
|
16
|
-
*/
|
|
17
|
-
import { spawnSync } from "node:child_process";
|
|
18
|
-
import { buildDigest, newThreadReadCache, readCommits, readSymbols, readThreads, } from "../app/history.js";
|
|
19
|
-
import { budgetSources, readAgentInstructions, readBranchProtection, readCodeowners, readCodifiedRules, readDecisionDocs, readDeclinedIssues, readReverts, readTestNames, } from "../app/sources.js";
|
|
20
|
-
import { readStamp, wiredHostIds } from "../upkeep.js";
|
|
21
|
-
import { baseUrlFor } from "./link.js";
|
|
22
|
-
import { postDigestOnce, uploadDigest } from "./upload.js";
|
|
23
|
-
function git(root, args) {
|
|
24
|
-
const res = spawnSync("git", ["-c", "core.quotePath=false", ...args], {
|
|
25
|
-
cwd: root,
|
|
26
|
-
encoding: "utf8",
|
|
27
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
28
|
-
});
|
|
29
|
-
if (res.error || res.status !== 0 || typeof res.stdout !== "string")
|
|
30
|
-
return null;
|
|
31
|
-
return res.stdout.trim();
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* owner/name for this checkout, from its origin remote.
|
|
35
|
-
*
|
|
36
|
-
* Only GitHub, because the discussion reader and the forge links are
|
|
37
|
-
* GitHub-shaped; another forge would need its own reader, not a looser regex
|
|
38
|
-
* here that produces links to nowhere.
|
|
39
|
-
*/
|
|
40
|
-
export function repoSlugFromGit(root) {
|
|
41
|
-
const url = git(root, ["remote", "get-url", "origin"]);
|
|
42
|
-
if (!url)
|
|
43
|
-
return null;
|
|
44
|
-
const m = url.match(/github\.com[:/]+([^/]+)\/(.+?)(?:\.git)?\/?$/i);
|
|
45
|
-
if (!m)
|
|
46
|
-
return null;
|
|
47
|
-
return { owner: m[1], name: m[2] };
|
|
48
|
-
}
|
|
49
|
-
/** The branch to attribute the ingest to. */
|
|
50
|
-
function currentBranch(root) {
|
|
51
|
-
const head = git(root, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
52
|
-
return head && head !== "HEAD" ? head : "";
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* A GitHub token from wherever the user already keeps one.
|
|
56
|
-
*
|
|
57
|
-
* `gh auth token` first, because anyone who works with private repositories on
|
|
58
|
-
* the command line has it and it needs no setup at all. The env vars are the
|
|
59
|
-
* CI path. Absent, the ingest still runs on commits alone — pull-request
|
|
60
|
-
* discussion is the richest source, not a required one.
|
|
61
|
-
*/
|
|
62
|
-
export function githubToken() {
|
|
63
|
-
const env = process.env.GH_TOKEN || process.env.GITHUB_TOKEN;
|
|
64
|
-
if (env)
|
|
65
|
-
return env;
|
|
66
|
-
const res = spawnSync("gh", ["auth", "token"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
67
|
-
const out = typeof res.stdout === "string" ? res.stdout.trim() : "";
|
|
68
|
-
return res.status === 0 && out ? out : null;
|
|
69
|
-
}
|
|
70
|
-
/** Whether the repository is private, so the digest records it honestly. */
|
|
71
|
-
async function isPrivate(owner, name, token, fetchImpl) {
|
|
72
|
-
if (!token)
|
|
73
|
-
return true; // unknown counts as private
|
|
74
|
-
try {
|
|
75
|
-
const res = await fetchImpl(`https://api.github.com/repos/${owner}/${name}`, {
|
|
76
|
-
headers: { authorization: `Bearer ${token}`, accept: "application/vnd.github+json" },
|
|
77
|
-
});
|
|
78
|
-
if (!res.ok)
|
|
79
|
-
return true;
|
|
80
|
-
return (await res.json()).private !== false;
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* The repository this brain expects, or null when it expects none.
|
|
88
|
-
*
|
|
89
|
-
* The website records it when the user chooses the local route, so this is how
|
|
90
|
-
* the CLI knows whether the directory it is standing in is the one they asked
|
|
91
|
-
* for. Mining the wrong repo into a brain is silent and very hard to notice
|
|
92
|
-
* afterwards — the rules simply describe someone else's codebase — so the round
|
|
93
|
-
* trip is worth it.
|
|
94
|
-
*
|
|
95
|
-
* The same read says what the server can take: gzip, chunks, a live event
|
|
96
|
-
* stream. Every flag defaults to off, so an older Trail gets exactly the
|
|
97
|
-
* requests it always did.
|
|
98
|
-
*
|
|
99
|
-
* Null on any failure, which keeps an older brain (or an unreachable one)
|
|
100
|
-
* working exactly as it did before this check existed.
|
|
101
|
-
*/
|
|
102
|
-
export async function fetchExpectedRepo(link, fetchImpl = fetch) {
|
|
103
|
-
try {
|
|
104
|
-
const res = await fetchImpl(`${baseUrlFor(link)}/api/public/brains/${encodeURIComponent(link.brainId)}/repo`, {
|
|
105
|
-
headers: { authorization: `Bearer ${link.token}`, accept: "application/json" },
|
|
106
|
-
signal: AbortSignal.timeout(5000),
|
|
107
|
-
});
|
|
108
|
-
if (!res.ok)
|
|
109
|
-
return null;
|
|
110
|
-
const body = (await res.json());
|
|
111
|
-
if (!body.repo?.slug)
|
|
112
|
-
return null;
|
|
113
|
-
return {
|
|
114
|
-
slug: body.repo.slug,
|
|
115
|
-
status: String(body.repo.status ?? ""),
|
|
116
|
-
brainName: String(body.brain_name ?? ""),
|
|
117
|
-
ruleCount: typeof body.repo.rule_count === "number" && body.repo.rule_count > 0 ? body.repo.rule_count : 0,
|
|
118
|
-
earlyUpload: body.early_upload === true,
|
|
119
|
-
gzipUpload: body.gzip_upload === true,
|
|
120
|
-
chunkedUpload: body.chunked_upload === true,
|
|
121
|
-
events: body.events === true,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
catch {
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/** The upload capabilities an expected-repo read advertised. */
|
|
129
|
-
export function uploadCaps(expected) {
|
|
130
|
-
return { gzip: expected?.gzipUpload === true, chunked: expected?.chunkedUpload === true };
|
|
131
|
-
}
|
|
132
|
-
/** Whether two repo slugs name the same repository. GitHub is case-insensitive. */
|
|
133
|
-
export function sameRepo(a, b) {
|
|
134
|
-
return a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
135
|
-
}
|
|
136
|
-
/** How many of the newest pull requests and commits the early upload carries —
|
|
137
|
-
* what Trail's quick CLAUDE.md pass reads, and no more. */
|
|
138
|
-
export const EARLY_THREADS = 30;
|
|
139
|
-
export const EARLY_COMMITS = 80;
|
|
140
|
-
/** The shared context for a push from `root`, or null without a GitHub origin. */
|
|
141
|
-
export function pushContext(root, opts = {}) {
|
|
142
|
-
const slug = repoSlugFromGit(root);
|
|
143
|
-
if (!slug)
|
|
144
|
-
return null;
|
|
145
|
-
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
146
|
-
const token = githubToken();
|
|
147
|
-
let privacy = null;
|
|
148
|
-
return {
|
|
149
|
-
owner: slug.owner,
|
|
150
|
-
name: slug.name,
|
|
151
|
-
token,
|
|
152
|
-
fetchImpl,
|
|
153
|
-
headSha: git(root, ["rev-parse", "HEAD"]) ?? "",
|
|
154
|
-
branch: currentBranch(root),
|
|
155
|
-
isPrivate: () => (privacy ??= isPrivate(slug.owner, slug.name, token, fetchImpl)),
|
|
156
|
-
threads: newThreadReadCache(),
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* The early upload: the instruction files, the newest pull requests and the
|
|
161
|
-
* newest commits, read before the rest of the history.
|
|
162
|
-
*
|
|
163
|
-
* Reading the history is most of a push's wait — up to 200 pull requests at two
|
|
164
|
-
* GitHub calls each — and Trail's first CLAUDE.md suggestions need none of it
|
|
165
|
-
* beyond the newest few. Sent first, they start while the full read is still
|
|
166
|
-
* going here, and the full upload that follows mines as before.
|
|
167
|
-
*
|
|
168
|
-
* Only the newest commits are read here, not the thousand the full read takes,
|
|
169
|
-
* so nothing but these few requests stands between the push starting and Trail
|
|
170
|
-
* starting. The pull requests go through the shared cache, so the full read
|
|
171
|
-
* asks GitHub for none of them again — not even one still in flight.
|
|
172
|
-
*
|
|
173
|
-
* Null when there is nothing worth sending early.
|
|
174
|
-
*/
|
|
175
|
-
export async function buildEarlyDigest(root, opts = {}) {
|
|
176
|
-
const ctx = opts.context ?? pushContext(root, opts);
|
|
177
|
-
if (!ctx)
|
|
178
|
-
return null;
|
|
179
|
-
// Oldest first, like the full read, so the newest are the tail.
|
|
180
|
-
const commits = readCommits(root, EARLY_COMMITS);
|
|
181
|
-
if (commits.length === 0)
|
|
182
|
-
return null;
|
|
183
|
-
let threads = [];
|
|
184
|
-
if (ctx.token) {
|
|
185
|
-
try {
|
|
186
|
-
threads = await readThreads(ctx.owner, ctx.name, ctx.token, ctx.fetchImpl, undefined, EARLY_THREADS, undefined, ctx.threads);
|
|
187
|
-
}
|
|
188
|
-
catch {
|
|
189
|
-
threads = [];
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
const digest = buildDigest({
|
|
193
|
-
owner: ctx.owner,
|
|
194
|
-
name: ctx.name,
|
|
195
|
-
headSha: ctx.headSha,
|
|
196
|
-
defaultBranch: ctx.branch,
|
|
197
|
-
isPrivate: await ctx.isPrivate(),
|
|
198
|
-
commits,
|
|
199
|
-
threads,
|
|
200
|
-
symbols: [],
|
|
201
|
-
sources: budgetSources(readAgentInstructions(root)),
|
|
202
|
-
autoApprove: true,
|
|
203
|
-
agents: pickedAgents(root),
|
|
204
|
-
});
|
|
205
|
-
return { digest, threads };
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* The agents this repo is wired for — what `graft init` recorded plus what is on
|
|
209
|
-
* disk, the same set `graft trail pull` filters by — so Trail can show only the
|
|
210
|
-
* context files those agents read. Empty before the first init; Trail then
|
|
211
|
-
* shows every kind.
|
|
212
|
-
*/
|
|
213
|
-
export function pickedAgents(root) {
|
|
214
|
-
try {
|
|
215
|
-
return [...new Set([...(readStamp(root)?.hosts ?? []), ...wiredHostIds(root)])];
|
|
216
|
-
}
|
|
217
|
-
catch {
|
|
218
|
-
return [];
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
/** Send the early upload. Best-effort: false on any failure, and the full
|
|
222
|
-
* upload still does everything. Gzipped when the server takes it. */
|
|
223
|
-
export async function pushEarlyDigest(link, digest, fetchImpl = fetch, opts = {}) {
|
|
224
|
-
try {
|
|
225
|
-
const res = await postDigestOnce(link, digest, { gzip: opts.gzip, fetchImpl, query: "?stage=early", timeoutMs: 15_000 });
|
|
226
|
-
if (!res.ok)
|
|
227
|
-
return false;
|
|
228
|
-
return (await res.json()).early === true;
|
|
229
|
-
}
|
|
230
|
-
catch {
|
|
231
|
-
return false;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
/** Build the digest for the checkout at `root`. Reads nothing but text. */
|
|
235
|
-
export async function buildLocalDigest(root, graph, opts = {}) {
|
|
236
|
-
const ctx = opts.context ?? pushContext(root, opts);
|
|
237
|
-
if (!ctx) {
|
|
238
|
-
return { error: "this directory has no GitHub `origin` remote — graft can only push a GitHub repository today" };
|
|
239
|
-
}
|
|
240
|
-
const { token, fetchImpl } = ctx;
|
|
241
|
-
const commits = readCommits(root);
|
|
242
|
-
if (commits.length === 0) {
|
|
243
|
-
return { error: "no commits found here — is this a shallow clone with no history?" };
|
|
244
|
-
}
|
|
245
|
-
const symbols = readSymbols(graph);
|
|
246
|
-
let threads = [];
|
|
247
|
-
let warning;
|
|
248
|
-
// The GitHub-side sources start with the threads rather than after them:
|
|
249
|
-
// they are a request or two each, and waiting behind 400 is waiting for no reason.
|
|
250
|
-
const remote = token
|
|
251
|
-
? Promise.all([
|
|
252
|
-
readBranchProtection(ctx.owner, ctx.name, ctx.branch, token, fetchImpl),
|
|
253
|
-
readDeclinedIssues(ctx.owner, ctx.name, token, fetchImpl),
|
|
254
|
-
])
|
|
255
|
-
: Promise.resolve([[], []]);
|
|
256
|
-
if (token) {
|
|
257
|
-
try {
|
|
258
|
-
const known = new Map((opts.knownThreads ?? []).map((t) => [t.number, t]));
|
|
259
|
-
threads = await readThreads(ctx.owner, ctx.name, token, fetchImpl, undefined, undefined, known, ctx.threads);
|
|
260
|
-
}
|
|
261
|
-
catch {
|
|
262
|
-
warning = "could not read pull-request discussion; mining commits and repo files only";
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
warning =
|
|
267
|
-
"no GitHub token found (`gh auth login`, or GH_TOKEN) — mining commits and repo files only, without pull-request discussion";
|
|
268
|
-
}
|
|
269
|
-
const [protection, declined] = await remote;
|
|
270
|
-
const sources = budgetSources([
|
|
271
|
-
...readAgentInstructions(root),
|
|
272
|
-
...readDecisionDocs(root),
|
|
273
|
-
...readCodeowners(root),
|
|
274
|
-
...readCodifiedRules(root),
|
|
275
|
-
...readReverts(root),
|
|
276
|
-
...readTestNames(symbols.map((s) => ({ name: s.name, path: s.path }))),
|
|
277
|
-
...protection,
|
|
278
|
-
...declined,
|
|
279
|
-
]);
|
|
280
|
-
const digest = buildDigest({
|
|
281
|
-
owner: ctx.owner,
|
|
282
|
-
name: ctx.name,
|
|
283
|
-
headSha: ctx.headSha,
|
|
284
|
-
defaultBranch: ctx.branch,
|
|
285
|
-
isPrivate: await ctx.isPrivate(),
|
|
286
|
-
commits,
|
|
287
|
-
threads,
|
|
288
|
-
symbols,
|
|
289
|
-
sources,
|
|
290
|
-
autoApprove: opts.autoApprove ?? true,
|
|
291
|
-
agents: pickedAgents(root),
|
|
292
|
-
});
|
|
293
|
-
return { digest, warning };
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Send a digest to the brain and return the job to poll.
|
|
297
|
-
*
|
|
298
|
-
* Chunked and gzipped when the server advertises both, gzipped in one POST when
|
|
299
|
-
* it advertises only gzip, and today's plain POST otherwise.
|
|
300
|
-
*/
|
|
301
|
-
export async function pushDigest(link, digest, fetchImpl = fetch, caps = {}, opts = {}) {
|
|
302
|
-
return uploadDigest(link, digest, caps, { ...opts, fetchImpl });
|
|
303
|
-
}
|
|
304
|
-
//# sourceMappingURL=push.js.map
|
package/dist/brain/push.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"push.js","sourceRoot":"","sources":["../../src/brain/push.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,WAAW,GAIZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,SAAS,EAAE,YAAY,EA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AAO,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;AAClE,CAAC"}
|
package/dist/brain/signup.d.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import type { BrainLink } from "./link.js";
|
|
2
|
-
/** How long the listener waits for the browser before giving up. A signup can
|
|
3
|
-
* involve reading an email, so this is minutes rather than seconds. */
|
|
4
|
-
export declare const HANDOFF_TIMEOUT_MS: number;
|
|
5
|
-
/** The one path the listener answers on. */
|
|
6
|
-
export declare const CALLBACK_PATH = "/graft/callback";
|
|
7
|
-
/**
|
|
8
|
-
* What the browser sends back, or why it could not be accepted.
|
|
9
|
-
*
|
|
10
|
-
* `error` is the sentence printed to the user and `reason` is the same fact as a
|
|
11
|
-
* category. They are separate because the sentence names the repo and the link,
|
|
12
|
-
* so it can never be the thing telemetry reports — and matching on its text to
|
|
13
|
-
* recover the category would put a user-facing string in a position where
|
|
14
|
-
* rewording it silently changes what gets counted.
|
|
15
|
-
*/
|
|
16
|
-
export type HandoffFailure = "timed_out" | "bad_callback";
|
|
17
|
-
export type HandoffResult = {
|
|
18
|
-
link: BrainLink;
|
|
19
|
-
} | {
|
|
20
|
-
error: string;
|
|
21
|
-
reason: HandoffFailure;
|
|
22
|
-
};
|
|
23
|
-
export interface Handoff {
|
|
24
|
-
/** The loopback port Trail must redirect to. */
|
|
25
|
-
port: number;
|
|
26
|
-
/** The nonce Trail must echo back. */
|
|
27
|
-
state: string;
|
|
28
|
-
/** Resolves once the browser answers, or when `timeoutMs` passes. */
|
|
29
|
-
wait(timeoutMs?: number): Promise<HandoffResult>;
|
|
30
|
-
/** Stop listening. Safe to call more than once. */
|
|
31
|
-
close(): void;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Start listening for the browser's handoff.
|
|
35
|
-
*
|
|
36
|
-
* Port 0 so the OS picks a free one: a fixed port would collide with whatever
|
|
37
|
-
* else the developer is running, and a second graft in another terminal.
|
|
38
|
-
*/
|
|
39
|
-
export declare function startHandoff(): Promise<Handoff>;
|
|
40
|
-
/** The Trail front end this machine is pointed at, without a trailing slash.
|
|
41
|
-
*
|
|
42
|
-
* Read at the moment it is needed rather than captured once, matching the rest
|
|
43
|
-
* of the brain code: GRAFT_BRAIN_URL is free to move between calls. */
|
|
44
|
-
export declare function webBaseUrl(baseUrl?: string): string;
|
|
45
|
-
/** Where the browser is sent once the handoff has been accepted.
|
|
46
|
-
*
|
|
47
|
-
* Back into Trail, at the screen that shows the brain being built. The
|
|
48
|
-
* alternative — leaving the person on a local page that says "go back to your
|
|
49
|
-
* terminal" — ends the flow on a blank throwaway served by a port that is about
|
|
50
|
-
* to close, at exactly the moment there is something to watch.
|
|
51
|
-
*
|
|
52
|
-
* NOT `/brain/<id>`, which is where this pointed first. That route redirects to
|
|
53
|
-
* the brain's graph, and the redirect fires the instant the row exists — which
|
|
54
|
-
* is minutes before it has any rules in it. Every terminal signup therefore
|
|
55
|
-
* landed on an empty visualisation of a brain that was, at that moment, being
|
|
56
|
-
* built perfectly well. The build screen is the same wait the browser-first
|
|
57
|
-
* flow shows, and it leads to the graph once there is a graph. */
|
|
58
|
-
export declare function brainUrl(brainId: string, baseUrl?: string): string;
|
|
59
|
-
/** Where a trail's suggested context-file changes are reviewed and accepted:
|
|
60
|
-
* the Context files overview, which lists every file the repo's agents read
|
|
61
|
-
* (CLAUDE.md, AGENTS.md, Cursor rules, folder files, skills) with what waits
|
|
62
|
-
* on each. Needs a Trail that has the page (NanoNets/assign#2957). */
|
|
63
|
-
export declare function reviewUrl(brainId: string, baseUrl?: string): string;
|
|
64
|
-
/** Where to send the browser for a repo's brain.
|
|
65
|
-
*
|
|
66
|
-
* No port when an agent runs the push: nothing stays listening on loopback, so
|
|
67
|
-
* Trail keeps the trail it made under `state` and graft asks for it by that. */
|
|
68
|
-
export declare function signupUrl(opts: {
|
|
69
|
-
repo: string;
|
|
70
|
-
port?: number;
|
|
71
|
-
state: string;
|
|
72
|
-
baseUrl?: string;
|
|
73
|
-
}): string;
|
|
74
|
-
/** A fresh state for a sign-up link: 24 random bytes, which is what Trail
|
|
75
|
-
* accepts and what makes the link impossible to guess. */
|
|
76
|
-
export declare function newSignupState(): string;
|
|
77
|
-
/** How long one agent-run push waits for the sign-up. Under the two minutes an
|
|
78
|
-
* agent gives a command by default, so the wait ends with a message it can read
|
|
79
|
-
* rather than a killed process. */
|
|
80
|
-
export declare const AGENT_WAIT_MS: number;
|
|
81
|
-
/** How often it asks. */
|
|
82
|
-
export declare const AGENT_POLL_MS = 2000;
|
|
83
|
-
/** How long a saved state is worth asking about: a minute under the fifteen
|
|
84
|
-
* Trail keeps an unclaimed sign-up, so graft never waits on one Trail dropped. */
|
|
85
|
-
export declare const PENDING_SIGNUP_TTL_MS: number;
|
|
86
|
-
/** Why asking stopped short of a link. */
|
|
87
|
-
export type ClaimFailure = "expired" | "unsupported";
|
|
88
|
-
export type ClaimResult = {
|
|
89
|
-
link: BrainLink;
|
|
90
|
-
} | {
|
|
91
|
-
pending: true;
|
|
92
|
-
} | {
|
|
93
|
-
error: string;
|
|
94
|
-
reason: ClaimFailure;
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Ask Trail once whether the sign-up for `state` has finished.
|
|
98
|
-
*
|
|
99
|
-
* A network error or a server error counts as "not yet": one bad request in a
|
|
100
|
-
* ninety-second wait is not a reason to give up on it.
|
|
101
|
-
*/
|
|
102
|
-
export declare function claimSignup(state: string, apiBase: string, fetchImpl?: typeof fetch): Promise<ClaimResult>;
|
|
103
|
-
/** Ask until the sign-up finishes, Trail says it never will, or `timeoutMs`
|
|
104
|
-
* passes — which comes back as `{ pending: true }`. */
|
|
105
|
-
export declare function waitForSignup(state: string, apiBase: string, opts?: {
|
|
106
|
-
timeoutMs?: number;
|
|
107
|
-
intervalMs?: number;
|
|
108
|
-
fetchImpl?: typeof fetch;
|
|
109
|
-
}): Promise<ClaimResult>;
|
|
110
|
-
/** Open the user's browser, best effort. A machine with no opener is not an
|
|
111
|
-
* error: the URL is printed too, and that is the fallback everywhere.
|
|
112
|
-
*
|
|
113
|
-
* GRAFT_NO_BROWSER leaves the printed URL as the only route, which is what a
|
|
114
|
-
* test wants, and what someone on a machine whose `open` does something
|
|
115
|
-
* surprising wants too. */
|
|
116
|
-
export declare function openBrowser(url: string): void;
|
|
117
|
-
//# sourceMappingURL=signup.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signup.d.ts","sourceRoot":"","sources":["../../src/brain/signup.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAU3C;uEACuE;AACvE,eAAO,MAAM,kBAAkB,QAAgB,CAAC;AAEhD,4CAA4C;AAC5C,eAAO,MAAM,aAAa,oBAAoB,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,cAAc,CAAC;AAC1D,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,cAAc,CAAA;CAAE,CAAC;AAE5F,MAAM,WAAW,OAAO;IACtB,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACjD,mDAAmD;IACnD,KAAK,IAAI,IAAI,CAAC;CACf;AAoBD;;;;;GAKG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,CAwFrD;AAED;;;uEAGuE;AACvE,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;;;;;;;;;;kEAYkE;AAClE,wBAAgB,QAAQ,CAAC,OA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