@nanonets/graft 0.16.0 → 0.19.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 +10 -3
- package/dist/app/brain-build-process.d.ts +22 -0
- package/dist/app/brain-build-process.d.ts.map +1 -0
- package/dist/app/brain-build-process.js +129 -0
- package/dist/app/brain-build-process.js.map +1 -0
- package/dist/app/brain-build-worker.d.ts +35 -0
- package/dist/app/brain-build-worker.d.ts.map +1 -0
- package/dist/app/brain-build-worker.js +56 -0
- package/dist/app/brain-build-worker.js.map +1 -0
- package/dist/app/brain-build.d.ts +160 -0
- package/dist/app/brain-build.d.ts.map +1 -0
- package/dist/app/brain-build.js +278 -0
- package/dist/app/brain-build.js.map +1 -0
- package/dist/app/checkout.d.ts +53 -3
- package/dist/app/checkout.d.ts.map +1 -1
- package/dist/app/checkout.js +195 -27
- package/dist/app/checkout.js.map +1 -1
- package/dist/app/events.d.ts +7 -0
- package/dist/app/events.d.ts.map +1 -1
- package/dist/app/events.js +7 -2
- package/dist/app/events.js.map +1 -1
- package/dist/app/history.d.ts +128 -0
- package/dist/app/history.d.ts.map +1 -0
- package/dist/app/history.js +266 -0
- package/dist/app/history.js.map +1 -0
- package/dist/app/identity.d.ts +56 -0
- package/dist/app/identity.d.ts.map +1 -1
- package/dist/app/identity.js +119 -0
- package/dist/app/identity.js.map +1 -1
- package/dist/app/main.js +14 -0
- package/dist/app/main.js.map +1 -1
- package/dist/app/pages.d.ts +17 -0
- package/dist/app/pages.d.ts.map +1 -1
- package/dist/app/pages.js +112 -5
- package/dist/app/pages.js.map +1 -1
- package/dist/app/review-process.d.ts +66 -0
- package/dist/app/review-process.d.ts.map +1 -0
- package/dist/app/review-process.js +199 -0
- package/dist/app/review-process.js.map +1 -0
- package/dist/app/review-worker.d.ts +2 -0
- package/dist/app/review-worker.d.ts.map +1 -0
- package/dist/app/review-worker.js +108 -0
- package/dist/app/review-worker.js.map +1 -0
- package/dist/app/review.d.ts.map +1 -1
- package/dist/app/review.js +4 -1
- package/dist/app/review.js.map +1 -1
- package/dist/app/server.d.ts +31 -2
- package/dist/app/server.d.ts.map +1 -1
- package/dist/app/server.js +130 -3
- package/dist/app/server.js.map +1 -1
- package/dist/app/sources.d.ts +68 -0
- package/dist/app/sources.d.ts.map +1 -0
- package/dist/app/sources.js +342 -0
- package/dist/app/sources.js.map +1 -0
- package/dist/ask/ask.d.ts +6 -0
- package/dist/ask/ask.d.ts.map +1 -1
- package/dist/ask/ask.js +30 -2
- package/dist/ask/ask.js.map +1 -1
- package/dist/brain/attach.d.ts +44 -0
- package/dist/brain/attach.d.ts.map +1 -0
- package/dist/brain/attach.js +63 -0
- package/dist/brain/attach.js.map +1 -0
- package/dist/brain/connect.d.ts +59 -0
- package/dist/brain/connect.d.ts.map +1 -0
- package/dist/brain/connect.js +80 -0
- package/dist/brain/connect.js.map +1 -0
- package/dist/brain/link.d.ts +89 -0
- package/dist/brain/link.d.ts.map +1 -0
- package/dist/brain/link.js +146 -0
- package/dist/brain/link.js.map +1 -0
- package/dist/brain/push.d.ts +72 -0
- package/dist/brain/push.d.ts.map +1 -0
- package/dist/brain/push.js +191 -0
- package/dist/brain/push.js.map +1 -0
- package/dist/brain/signup.d.ts +73 -0
- package/dist/brain/signup.d.ts.map +1 -0
- package/dist/brain/signup.js +186 -0
- package/dist/brain/signup.js.map +1 -0
- package/dist/brain/watch.d.ts +136 -0
- package/dist/brain/watch.d.ts.map +1 -0
- package/dist/brain/watch.js +172 -0
- package/dist/brain/watch.js.map +1 -0
- package/dist/brain/wire.d.ts +38 -0
- package/dist/brain/wire.d.ts.map +1 -0
- package/dist/brain/wire.js +133 -0
- package/dist/brain/wire.js.map +1 -0
- package/dist/claude/format.d.ts.map +1 -1
- package/dist/claude/format.js +10 -3
- package/dist/claude/format.js.map +1 -1
- package/dist/claude/hooks.d.ts.map +1 -1
- package/dist/claude/hooks.js +32 -1
- package/dist/claude/hooks.js.map +1 -1
- package/dist/claude/init.d.ts +5 -0
- package/dist/claude/init.d.ts.map +1 -1
- package/dist/claude/init.js +9 -1
- package/dist/claude/init.js.map +1 -1
- package/dist/claude/session-metrics.d.ts +10 -0
- package/dist/claude/session-metrics.d.ts.map +1 -1
- package/dist/claude/session-metrics.js +25 -0
- package/dist/claude/session-metrics.js.map +1 -1
- package/dist/claude/settings-merge.d.ts +18 -0
- package/dist/claude/settings-merge.d.ts.map +1 -1
- package/dist/claude/settings-merge.js +42 -8
- package/dist/claude/settings-merge.js.map +1 -1
- package/dist/claude/skill-template.d.ts.map +1 -1
- package/dist/claude/skill-template.js +6 -0
- package/dist/claude/skill-template.js.map +1 -1
- package/dist/claude/state.d.ts +14 -0
- package/dist/claude/state.d.ts.map +1 -1
- package/dist/claude/state.js.map +1 -1
- package/dist/claude/tally.d.ts +27 -0
- package/dist/claude/tally.d.ts.map +1 -1
- package/dist/claude/tally.js +74 -1
- package/dist/claude/tally.js.map +1 -1
- package/dist/cli.js +310 -3
- package/dist/cli.js.map +1 -1
- package/dist/context/node-file.d.ts +4 -10
- package/dist/context/node-file.d.ts.map +1 -1
- package/dist/context/node-file.js +6 -2
- package/dist/context/node-file.js.map +1 -1
- package/dist/context/price.d.ts +49 -0
- package/dist/context/price.d.ts.map +1 -0
- package/dist/context/price.js +83 -0
- package/dist/context/price.js.map +1 -0
- package/dist/context/savings.d.ts +13 -3
- package/dist/context/savings.d.ts.map +1 -1
- package/dist/context/savings.js +44 -5
- package/dist/context/savings.js.map +1 -1
- package/dist/hosts/claude-global.d.ts +33 -0
- package/dist/hosts/claude-global.d.ts.map +1 -0
- package/dist/hosts/claude-global.js +118 -0
- package/dist/hosts/claude-global.js.map +1 -0
- package/dist/hosts/plan.d.ts.map +1 -1
- package/dist/hosts/plan.js +5 -1
- package/dist/hosts/plan.js.map +1 -1
- package/dist/hosts/retract.d.ts.map +1 -1
- package/dist/hosts/retract.js +33 -13
- package/dist/hosts/retract.js.map +1 -1
- package/dist/hosts/sections.d.ts +23 -2
- package/dist/hosts/sections.d.ts.map +1 -1
- package/dist/hosts/sections.js +25 -9
- package/dist/hosts/sections.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +33 -4
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +5 -1
- package/dist/mcp/tools.js.map +1 -1
- package/dist/telemetry/contract.d.ts +12 -0
- package/dist/telemetry/contract.d.ts.map +1 -1
- package/dist/telemetry/contract.js +19 -0
- package/dist/telemetry/contract.js.map +1 -1
- package/dist/telemetry/gate.d.ts +14 -0
- package/dist/telemetry/gate.d.ts.map +1 -1
- package/dist/telemetry/gate.js +18 -2
- package/dist/telemetry/gate.js.map +1 -1
- package/dist/upkeep-run.d.ts.map +1 -1
- package/dist/upkeep-run.js +12 -2
- package/dist/upkeep-run.js.map +1 -1
- package/dist/upkeep.d.ts +18 -0
- package/dist/upkeep.d.ts.map +1 -1
- package/dist/upkeep.js +38 -0
- package/dist/upkeep.js.map +1 -1
- package/dist/util/state.d.ts +9 -0
- package/dist/util/state.d.ts.map +1 -1
- package/dist/util/state.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
<p>
|
|
10
10
|
<a href="https://github.com/NanoNets/Graft"><img src="https://img.shields.io/github/stars/NanoNets/Graft?style=for-the-badge&logo=github&logoColor=white&label=Star%20on%20GitHub&color=FFC83D" /></a>
|
|
11
|
-
<a href="https://graft
|
|
11
|
+
<a href="https://trailhq.com/graft"><img src="https://img.shields.io/badge/website-trailhq.com/graft-E5484D?style=for-the-badge" /></a>
|
|
12
12
|
<a href="https://discord.gg/zxmKweAA29"><img src="https://img.shields.io/badge/Discord-join-5865F2?style=for-the-badge&logo=discord&logoColor=white" /></a>
|
|
13
13
|
<a href="https://www.npmjs.com/package/@nanonets/graft"><img src="https://img.shields.io/npm/v/%40nanonets%2Fgraft?style=for-the-badge&logo=npm&logoColor=white&label=npm" /></a>
|
|
14
14
|
<a href="https://www.npmjs.com/package/@nanonets/graft"><img src="https://img.shields.io/npm/dm/%40nanonets%2Fgraft?style=for-the-badge&logo=npm&logoColor=white&label=downloads" /></a>
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
<img src="https://img.shields.io/badge/License-MIT-20C997?style=for-the-badge" />
|
|
18
18
|
<a href="TELEMETRY.md"><img src="https://img.shields.io/badge/telemetry-anonymous%2C%20opt--out-546FFF?style=for-the-badge" /></a>
|
|
19
19
|
<a href="https://scorecard.dev/viewer/?uri=github.com/NanoNets/Graft"><img src="https://img.shields.io/ossf-scorecard/github.com/NanoNets/Graft?style=for-the-badge&label=openssf%20scorecard" /></a>
|
|
20
|
-
<a href="https://
|
|
20
|
+
<a href="https://app.trailhq.com/get-started?step=pick"><img src="https://img.shields.io/badge/Trail%20Brain-try%20it-E5484D?style=for-the-badge&logoColor=white" /></a>
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
23
|
### Up to **4× cheaper** and **3× faster**, with better or no loss of correctness.
|
|
@@ -31,7 +31,14 @@
|
|
|
31
31
|
|
|
32
32
|
</div>
|
|
33
33
|
|
|
34
|
-
<p align="center"
|
|
34
|
+
<p align="center">
|
|
35
|
+
<b>This works beyond code too.</b><br/>
|
|
36
|
+
A living skill file that learns from every task and gets sharper the more your team works.
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
<p align="center">
|
|
40
|
+
<a href="https://app.trailhq.com/get-started?step=pick"><img src="https://img.shields.io/badge/Try%20Trail%20Brain%20%E2%86%92-E5484D?style=for-the-badge" alt="Try Trail Brain" height="34"/></a>
|
|
41
|
+
</p>
|
|
35
42
|
|
|
36
43
|
<p align="center">
|
|
37
44
|
<img src="assets/graft-comparison-demo.gif" alt="Side-by-side comparison of a coding agent working with and without graft" width="820"/>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type BrainBuildDeps, type BrainBuildJob, type BrainBuildResult } from "./brain-build.js";
|
|
2
|
+
export interface ChildBuilderOptions {
|
|
3
|
+
/** The module the child runs. Only tests pass this. */
|
|
4
|
+
entry?: string;
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The module a read runs in. `dist/app/brain-build-worker.js` when installed or
|
|
9
|
+
* containerised; the TypeScript source next door when run from a checkout,
|
|
10
|
+
* since `fork` inherits `process.execArgv` and a parent started through tsx
|
|
11
|
+
* hands the child the same loader.
|
|
12
|
+
*/
|
|
13
|
+
export declare function brainBuildWorkerEntry(): string;
|
|
14
|
+
/**
|
|
15
|
+
* A builder with buildRepoIntoBrain's signature that runs the heavy half in a
|
|
16
|
+
* child process. Same shape on purpose: server.ts swaps one for the other in a
|
|
17
|
+
* single line, and a test injecting its own builder keeps running in-process.
|
|
18
|
+
*/
|
|
19
|
+
export declare function childBuilder(opts?: ChildBuilderOptions): (job: BrainBuildJob, deps: BrainBuildDeps) => Promise<BrainBuildResult>;
|
|
20
|
+
/** The App's default builder. */
|
|
21
|
+
export declare const buildRepoInChildProcess: (job: BrainBuildJob, deps: BrainBuildDeps) => Promise<BrainBuildResult>;
|
|
22
|
+
//# sourceMappingURL=brain-build-process.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brain-build-process.d.ts","sourceRoot":"","sources":["../../src/app/brain-build-process.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAmB,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAanH,MAAM,WAAW,mBAAmB;IAClC,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAK9C;AAeD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,mBAAwB,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,cAAc,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAUpI;AAgED,iCAAiC;AACjC,eAAO,MAAM,uBAAuB,QA3EgC,aAAa,QAAQ,cAAc,KAAK,OAAO,CAAC,gBAAgB,CA2E/E,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Running a repository read somewhere it cannot stop the App answering.
|
|
3
|
+
*
|
|
4
|
+
* The same problem the reviewer had, and the same fix — see review-process.ts
|
|
5
|
+
* for the full reasoning and the production measurements behind it. In short:
|
|
6
|
+
* every expensive step of a read is synchronous (git through `spawnSync`, the
|
|
7
|
+
* parse a loop of native tree-sitter calls, the graph written with a blocking
|
|
8
|
+
* stringify), so in-process one read holds the event loop for its whole
|
|
9
|
+
* duration.
|
|
10
|
+
*
|
|
11
|
+
* Onboarding made that visible in a way reviews did not. Measured on
|
|
12
|
+
* NanoNets/assign: 0.7s to check access, 7s to clone, 81s to build the symbol
|
|
13
|
+
* graph, 21s to walk the pull requests. During those 81 seconds the App
|
|
14
|
+
* answered nothing at all — including the one-second question "can we see this
|
|
15
|
+
* other repository", asked by the next person to paste a URL, who then waited
|
|
16
|
+
* out someone else's clone before being told their repo is private. At a
|
|
17
|
+
* hundred signups there is nearly always a read in flight, so that is not an
|
|
18
|
+
* edge case, it is the normal case.
|
|
19
|
+
*
|
|
20
|
+
* The split is where the credential is: the parent resolves access and mints
|
|
21
|
+
* the token (network, never blocking), and the child does the work with it.
|
|
22
|
+
*/
|
|
23
|
+
import { fork } from "node:child_process";
|
|
24
|
+
import { existsSync } from "node:fs";
|
|
25
|
+
import { fileURLToPath } from "node:url";
|
|
26
|
+
import { resolveRepoRead } from "./brain-build.js";
|
|
27
|
+
/**
|
|
28
|
+
* How long one read may take before the process running it is killed.
|
|
29
|
+
*
|
|
30
|
+
* Well above the worst honest read seen (110s on a large monorepo) plus the
|
|
31
|
+
* clone budget checkout.ts allows itself, because the cost of being wrong is a
|
|
32
|
+
* read that never happens. It bounds a lost slot, not responsiveness — the
|
|
33
|
+
* server stopped caring how long a read takes the moment it left this process.
|
|
34
|
+
*/
|
|
35
|
+
const DEFAULT_TIMEOUT_MS = 15 * 60 * 1000;
|
|
36
|
+
/**
|
|
37
|
+
* The module a read runs in. `dist/app/brain-build-worker.js` when installed or
|
|
38
|
+
* containerised; the TypeScript source next door when run from a checkout,
|
|
39
|
+
* since `fork` inherits `process.execArgv` and a parent started through tsx
|
|
40
|
+
* hands the child the same loader.
|
|
41
|
+
*/
|
|
42
|
+
export function brainBuildWorkerEntry() {
|
|
43
|
+
const js = fileURLToPath(new URL("./brain-build-worker.js", import.meta.url));
|
|
44
|
+
if (existsSync(js))
|
|
45
|
+
return js;
|
|
46
|
+
const ts = js.replace(/\.js$/, ".ts");
|
|
47
|
+
return existsSync(ts) ? ts : js;
|
|
48
|
+
}
|
|
49
|
+
/** Reads in flight, so a shutdown does not leave a clone made with a token. */
|
|
50
|
+
const live = new Set();
|
|
51
|
+
let hooked = false;
|
|
52
|
+
function track(child) {
|
|
53
|
+
live.add(child);
|
|
54
|
+
if (hooked)
|
|
55
|
+
return;
|
|
56
|
+
hooked = true;
|
|
57
|
+
process.on("exit", () => {
|
|
58
|
+
for (const c of live)
|
|
59
|
+
c.kill("SIGKILL");
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A builder with buildRepoIntoBrain's signature that runs the heavy half in a
|
|
64
|
+
* child process. Same shape on purpose: server.ts swaps one for the other in a
|
|
65
|
+
* single line, and a test injecting its own builder keeps running in-process.
|
|
66
|
+
*/
|
|
67
|
+
export function childBuilder(opts = {}) {
|
|
68
|
+
const entry = opts.entry ?? brainBuildWorkerEntry();
|
|
69
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
70
|
+
return async (job, deps) => {
|
|
71
|
+
// In the parent, deliberately: it is pure network, it is what decides
|
|
72
|
+
// whether there is anything to fork for, and a RepoNotAccessibleError has
|
|
73
|
+
// to reach the caller as itself rather than as a dead child process.
|
|
74
|
+
const auth = await resolveRepoRead(job, deps);
|
|
75
|
+
return runInChild(job, deps, auth, entry, timeoutMs);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
async function runInChild(job, deps, auth, entry, timeoutMs) {
|
|
79
|
+
const log = deps.log ?? (() => { });
|
|
80
|
+
const tag = `${job.owner}/${job.repo}`;
|
|
81
|
+
// The repository as argv makes `ps` in a container say which read each
|
|
82
|
+
// process is; the token stays out of it.
|
|
83
|
+
const child = fork(entry, [tag], { stdio: ["ignore", "inherit", "inherit", "ipc"] });
|
|
84
|
+
track(child);
|
|
85
|
+
try {
|
|
86
|
+
return await new Promise((resolve, reject) => {
|
|
87
|
+
let settled = false;
|
|
88
|
+
const settle = (fn) => {
|
|
89
|
+
if (settled)
|
|
90
|
+
return;
|
|
91
|
+
settled = true;
|
|
92
|
+
clearTimeout(timer);
|
|
93
|
+
fn();
|
|
94
|
+
};
|
|
95
|
+
const timer = setTimeout(() => {
|
|
96
|
+
settle(() => reject(new Error(`read of ${tag} exceeded ${timeoutMs}ms and was killed`)));
|
|
97
|
+
}, timeoutMs);
|
|
98
|
+
timer.unref();
|
|
99
|
+
child.on("message", (raw) => {
|
|
100
|
+
const msg = raw;
|
|
101
|
+
if (msg.t === "log") {
|
|
102
|
+
log(msg.msg);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (msg.t === "done") {
|
|
106
|
+
settle(() => resolve(msg.result));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
settle(() => reject(new Error(msg.message)));
|
|
110
|
+
});
|
|
111
|
+
child.on("error", (err) => settle(() => reject(err)));
|
|
112
|
+
// The case that used to be an outage: a child that dies without
|
|
113
|
+
// reporting. An OOM kill on a large repository, a grammar segfault on a
|
|
114
|
+
// stranger's source. Now it costs one read, named, with the signal.
|
|
115
|
+
child.on("exit", (code, signal) => settle(() => reject(new Error(`read of ${tag} exited ${signal ? `on ${signal}` : `with code ${code}`} before reporting a result`))));
|
|
116
|
+
const start = { t: "start", job, auth, api: deps.api, githubHost: deps.githubHost };
|
|
117
|
+
if (child.connected)
|
|
118
|
+
child.send(start);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
live.delete(child);
|
|
123
|
+
if (child.exitCode === null && child.signalCode === null)
|
|
124
|
+
child.kill("SIGKILL");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/** The App's default builder. */
|
|
128
|
+
export const buildRepoInChildProcess = childBuilder();
|
|
129
|
+
//# sourceMappingURL=brain-build-process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brain-build-process.js","sourceRoot":"","sources":["../../src/app/brain-build-process.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,IAAI,EAAqB,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,eAAe,EAAkE,MAAM,kBAAkB,CAAC;AAGnH;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAQ1C;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,EAAE,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,yBAAyB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9E,IAAI,UAAU,CAAC,EAAE,CAAC;QAAE,OAAO,EAAE,CAAC;IAC9B,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACtC,OAAO,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAClC,CAAC;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,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAEtD,gEAAgE;YAChE,wEAAwE;YACxE,oEAAoE;YACpE,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAChC,MAAM,CAAC,GAAG,EAAE,CACV,MAAM,CAAC,IAAI,KAAK,CAAC,WAAW,GAAG,WAAW,MAAM,CAAC,CAAC,CAAC,MAAM,MAAM,EAAE,CAAC,CAAC,CAAC,aAAa,IAAI,EAAE,4BAA4B,CAAC,CAAC,CACtH,CACF,CAAC;YAEF,MAAM,KAAK,GAAiB,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;YAClG,IAAI,KAAK,CAAC,SAAS;gBAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnB,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,IAAI,KAAK,CAAC,UAAU,KAAK,IAAI;YAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAClF,CAAC;AACH,CAAC;AAED,iCAAiC;AACjC,MAAM,CAAC,MAAM,uBAAuB,GAAG,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The process one repository read runs in.
|
|
3
|
+
*
|
|
4
|
+
* Forked by brain-build-process.ts, one per read, and it exits when the read
|
|
5
|
+
* does. It receives the credential it needs rather than the App's private key,
|
|
6
|
+
* for the same reason the reviewer's worker does: `ps` and `/proc/<pid>/environ`
|
|
7
|
+
* are readable, and a key that never crosses the boundary cannot leak across it.
|
|
8
|
+
*
|
|
9
|
+
* Everything expensive happens here — the clone, the tree-sitter parse, the
|
|
10
|
+
* pull-request walk — and none of it can reach the server's event loop.
|
|
11
|
+
*/
|
|
12
|
+
import { readRepository, type BrainBuildJob, type RepoReadAuth } from "./brain-build.js";
|
|
13
|
+
/** Parent → child, once, immediately after the fork. */
|
|
14
|
+
export interface StartMessage {
|
|
15
|
+
t: "start";
|
|
16
|
+
job: BrainBuildJob;
|
|
17
|
+
auth: RepoReadAuth;
|
|
18
|
+
api?: string;
|
|
19
|
+
githubHost?: string;
|
|
20
|
+
}
|
|
21
|
+
/** Child → parent: a line for the App's log, so a read is still traceable. */
|
|
22
|
+
export interface LogMessage {
|
|
23
|
+
t: "log";
|
|
24
|
+
msg: string;
|
|
25
|
+
}
|
|
26
|
+
export interface DoneMessage {
|
|
27
|
+
t: "done";
|
|
28
|
+
result: Awaited<ReturnType<typeof readRepository>>;
|
|
29
|
+
}
|
|
30
|
+
export interface FailedMessage {
|
|
31
|
+
t: "failed";
|
|
32
|
+
message: string;
|
|
33
|
+
}
|
|
34
|
+
export type FromChild = LogMessage | DoneMessage | FailedMessage;
|
|
35
|
+
//# sourceMappingURL=brain-build-worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brain-build-worker.d.ts","sourceRoot":"","sources":["../../src/app/brain-build-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEzF,wDAAwD;AACxD,MAAM,WAAW,YAAY;IAC3B,CAAC,EAAE,OAAO,CAAC;IACX,GAAG,EAAE,aAAa,CAAC;IACnB,IAAI,EAAE,YAAY,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACzB,CAAC,EAAE,KAAK,CAAC;IACT,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,QAAQ,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,WAAW,GAAG,aAAa,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The process one repository read runs in.
|
|
3
|
+
*
|
|
4
|
+
* Forked by brain-build-process.ts, one per read, and it exits when the read
|
|
5
|
+
* does. It receives the credential it needs rather than the App's private key,
|
|
6
|
+
* for the same reason the reviewer's worker does: `ps` and `/proc/<pid>/environ`
|
|
7
|
+
* are readable, and a key that never crosses the boundary cannot leak across it.
|
|
8
|
+
*
|
|
9
|
+
* Everything expensive happens here — the clone, the tree-sitter parse, the
|
|
10
|
+
* pull-request walk — and none of it can reach the server's event loop.
|
|
11
|
+
*/
|
|
12
|
+
import { readRepository } from "./brain-build.js";
|
|
13
|
+
/**
|
|
14
|
+
* Send, and tell me when it has actually gone.
|
|
15
|
+
*
|
|
16
|
+
* `process.send` is asynchronous, and a digest of a large repository is several
|
|
17
|
+
* megabytes — a thousand commits, four thousand symbols. Disconnecting on the
|
|
18
|
+
* next line tears the channel down mid-write: the child exits 0, having done
|
|
19
|
+
* every bit of the work, and the parent reports "exited before reporting a
|
|
20
|
+
* result". It only shows on big repositories, because a small payload clears
|
|
21
|
+
* the pipe in one write and survives the race.
|
|
22
|
+
*/
|
|
23
|
+
function send(msg, done) {
|
|
24
|
+
if (!process.send) {
|
|
25
|
+
done?.();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
process.send(msg, undefined, undefined, () => done?.());
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
/* parent went away; the exit is the report */
|
|
33
|
+
done?.();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
process.on("message", (raw) => {
|
|
37
|
+
const msg = raw;
|
|
38
|
+
if (msg.t !== "start")
|
|
39
|
+
return;
|
|
40
|
+
void readRepository(msg.job, {
|
|
41
|
+
// No creds: this half needs none. resolveRepoRead already did every call
|
|
42
|
+
// that requires the App's identity, and its answer is in `auth`.
|
|
43
|
+
creds: { appId: "", privateKey: "" },
|
|
44
|
+
fetch: globalThis.fetch,
|
|
45
|
+
api: msg.api,
|
|
46
|
+
githubHost: msg.githubHost,
|
|
47
|
+
log: (line) => send({ t: "log", msg: line }),
|
|
48
|
+
}, msg.auth)
|
|
49
|
+
.then((result) => {
|
|
50
|
+
send({ t: "done", result }, () => process.disconnect?.());
|
|
51
|
+
})
|
|
52
|
+
.catch((e) => {
|
|
53
|
+
send({ t: "failed", message: e instanceof Error ? e.message : String(e) }, () => process.disconnect?.());
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=brain-build-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brain-build-worker.js","sourceRoot":"","sources":["../../src/app/brain-build-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,cAAc,EAAyC,MAAM,kBAAkB,CAAC;AA6BzF;;;;;;;;;GASG;AACH,SAAS,IAAI,CAAC,GAAc,EAAE,IAAiB;IAC7C,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAClB,IAAI,EAAE,EAAE,CAAC;QACT,OAAO;IACT,CAAC;IACD,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE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{ type AppCredentials, type Fetch, type RepoAccessGap } from "./identity.js";
|
|
2
|
+
import { type RepoDigest } from "./history.js";
|
|
3
|
+
/** One request to build a repository into a brain. */
|
|
4
|
+
export interface BrainBuildJob {
|
|
5
|
+
owner: string;
|
|
6
|
+
repo: string;
|
|
7
|
+
/** Branch to read; empty means the repository's default. */
|
|
8
|
+
ref?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The brain the rules land in, and the workspace key to write it with.
|
|
11
|
+
*
|
|
12
|
+
* Both optional, and omitting them changes the mode: with them, the digest is
|
|
13
|
+
* posted straight to the brain and only a job id comes back; without them the
|
|
14
|
+
* digest is RETURNED and the caller ingests it itself.
|
|
15
|
+
*
|
|
16
|
+
* The second mode is what the platform's own proxy uses. It already holds the
|
|
17
|
+
* user's session and can write to the brain directly, so handing graft a
|
|
18
|
+
* workspace key just to have it call back would mean minting a credential per
|
|
19
|
+
* build for no gain.
|
|
20
|
+
*/
|
|
21
|
+
brainId?: string;
|
|
22
|
+
brainToken?: string;
|
|
23
|
+
/** Platform base URL. Defaults to production. */
|
|
24
|
+
brainBaseUrl?: string;
|
|
25
|
+
/** File the rules as approved rather than as drafts. Onboarding sets it:
|
|
26
|
+
* a brain whose every rule is an invisible draft answers nothing. */
|
|
27
|
+
autoApprove?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface BrainBuildResult {
|
|
30
|
+
/** Set only when the digest was posted; empty in return-the-digest mode. */
|
|
31
|
+
jobId: string;
|
|
32
|
+
headSha: string;
|
|
33
|
+
commits: number;
|
|
34
|
+
threads: number;
|
|
35
|
+
symbols: number;
|
|
36
|
+
sources: number;
|
|
37
|
+
/** Set only in return-the-digest mode. */
|
|
38
|
+
digest?: RepoDigest;
|
|
39
|
+
}
|
|
40
|
+
export interface BrainBuildDeps {
|
|
41
|
+
creds: AppCredentials;
|
|
42
|
+
fetch: Fetch;
|
|
43
|
+
api?: string;
|
|
44
|
+
githubHost?: string;
|
|
45
|
+
log?: (msg: string) => void;
|
|
46
|
+
now?: () => number;
|
|
47
|
+
/**
|
|
48
|
+
* Token used for a public repository the App is not installed on.
|
|
49
|
+
*
|
|
50
|
+
* Optional. Without it the read borrows one of our own installation's tokens,
|
|
51
|
+
* which GitHub answers for any public resource, and falls back to anonymous
|
|
52
|
+
* if the App has no installations at all. Anonymous works but is 60 requests
|
|
53
|
+
* an hour for the whole box — one pull-request walk — so it is the last
|
|
54
|
+
* resort, not the plan.
|
|
55
|
+
*/
|
|
56
|
+
publicToken?: string;
|
|
57
|
+
/** Whose installation to borrow for those reads. Ours, so a public read
|
|
58
|
+
* spends our rate limit and not a customer's. */
|
|
59
|
+
publicOwner?: string;
|
|
60
|
+
}
|
|
61
|
+
/** Raised when the App cannot see the repository. Distinct because the caller
|
|
62
|
+
* turns it into a specific answer — "install the app, or run it locally" — and
|
|
63
|
+
* not into a 500. */
|
|
64
|
+
export declare class RepoNotAccessibleError extends Error {
|
|
65
|
+
/** Which gap it is, so the caller can send the user to the right place. */
|
|
66
|
+
readonly gap: RepoAccessGap;
|
|
67
|
+
constructor(message: string,
|
|
68
|
+
/** Which gap it is, so the caller can send the user to the right place. */
|
|
69
|
+
gap?: RepoAccessGap);
|
|
70
|
+
}
|
|
71
|
+
/** What a repository lets us do, before any of the work is started. */
|
|
72
|
+
export interface RepoAccess {
|
|
73
|
+
/** True when we can read it: installed on it, or it is public. */
|
|
74
|
+
accessible: boolean;
|
|
75
|
+
isPrivate: boolean;
|
|
76
|
+
/** How we would read it — for the log, and for deciding nothing else. */
|
|
77
|
+
via: "installation" | "public" | "none";
|
|
78
|
+
/** Set only when accessible is false: what to tell the user, and where to
|
|
79
|
+
* send them. Same shape RepoNotAccessibleError carries. */
|
|
80
|
+
reason?: string;
|
|
81
|
+
gap?: RepoAccessGap;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Can we read this repository at all?
|
|
85
|
+
*
|
|
86
|
+
* The cheap half of a build, on its own: an installation lookup and at most
|
|
87
|
+
* one repository lookup, about a second in total, with no clone and no graph.
|
|
88
|
+
*
|
|
89
|
+
* It exists as its own call because the answer decides which screen the user
|
|
90
|
+
* sees next, and the rest of the read takes minutes. Waiting for the whole
|
|
91
|
+
* build to find out means either holding the person there or guessing from a
|
|
92
|
+
* timer, and a guess is wrong exactly when the box is busy — which is when
|
|
93
|
+
* two people are onboarding at once.
|
|
94
|
+
*/
|
|
95
|
+
export declare function checkRepoAccess(job: {
|
|
96
|
+
owner: string;
|
|
97
|
+
repo: string;
|
|
98
|
+
}, deps: BrainBuildDeps): Promise<RepoAccess>;
|
|
99
|
+
/**
|
|
100
|
+
* Read the repository and hand its history to the brain.
|
|
101
|
+
*
|
|
102
|
+
* An installation is the preferred way in: it is the only way into a private
|
|
103
|
+
* repository, and it carries a rate limit worth having. It is not required for
|
|
104
|
+
* a public one, though — those clone anonymously and answer the API
|
|
105
|
+
* anonymously — so a failed installation lookup is a reason to try the open
|
|
106
|
+
* door, not a reason to stop. Only a repository that is private or unreadable
|
|
107
|
+
* both ways is one we genuinely cannot see, and that is the case the UI turns
|
|
108
|
+
* into "read it on your machine".
|
|
109
|
+
*/
|
|
110
|
+
/** Everything the heavy half needs, and nothing it could mint for itself. */
|
|
111
|
+
export interface RepoReadAuth {
|
|
112
|
+
/** Installation or public-read token, for the GitHub API calls. */
|
|
113
|
+
token: string;
|
|
114
|
+
/** Credential for the clone. Empty for a public repository we are not
|
|
115
|
+
* installed on: git serves those to anyone, and a token minted for another
|
|
116
|
+
* account is not promised to work on this one. */
|
|
117
|
+
cloneToken: string;
|
|
118
|
+
meta: RepoMeta;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Decide how this repository gets read, and mint the credential for it.
|
|
122
|
+
*
|
|
123
|
+
* The network half of a build, kept separate from the work: an installation
|
|
124
|
+
* lookup, a token, a repository lookup. About a second, none of it blocking.
|
|
125
|
+
*
|
|
126
|
+
* Throws RepoNotAccessibleError when there is no way in. That is the answer the
|
|
127
|
+
* onboarding UI turns into a choice, which is why it is raised here — before a
|
|
128
|
+
* single byte is cloned — rather than discovered somewhere inside the read.
|
|
129
|
+
*/
|
|
130
|
+
export declare function resolveRepoRead(job: BrainBuildJob, deps: BrainBuildDeps): Promise<RepoReadAuth>;
|
|
131
|
+
/**
|
|
132
|
+
* Read the repository and hand its history to the brain.
|
|
133
|
+
*
|
|
134
|
+
* An installation is the preferred way in: it is the only way into a private
|
|
135
|
+
* repository, and it carries a rate limit worth having. It is not required for
|
|
136
|
+
* a public one, though — those clone anonymously and answer the API
|
|
137
|
+
* anonymously — so a failed installation lookup is a reason to try the open
|
|
138
|
+
* door, not a reason to stop. Only a repository that is private or unreadable
|
|
139
|
+
* both ways is one we genuinely cannot see, and that is the case the UI turns
|
|
140
|
+
* into "read it on your machine".
|
|
141
|
+
*/
|
|
142
|
+
export declare function buildRepoIntoBrain(job: BrainBuildJob, deps: BrainBuildDeps): Promise<BrainBuildResult>;
|
|
143
|
+
/**
|
|
144
|
+
* The heavy half: clone, graph, history, digest.
|
|
145
|
+
*
|
|
146
|
+
* Takes its credential rather than minting one, because this is the half that
|
|
147
|
+
* runs somewhere else. Every expensive thing in it is synchronous — the git
|
|
148
|
+
* calls are spawnSync, the parse is a loop of native tree-sitter calls, the
|
|
149
|
+
* graph is written with a blocking stringify — so in the server process it
|
|
150
|
+
* holds the event loop for the whole read, and a second person pasting a URL
|
|
151
|
+
* waits behind the first. See brain-build-process.ts.
|
|
152
|
+
*/
|
|
153
|
+
export declare function readRepository(job: BrainBuildJob, deps: BrainBuildDeps, auth: RepoReadAuth): Promise<BrainBuildResult>;
|
|
154
|
+
/** What the repository says about itself. */
|
|
155
|
+
interface RepoMeta {
|
|
156
|
+
isPrivate: boolean;
|
|
157
|
+
defaultBranch: string;
|
|
158
|
+
}
|
|
159
|
+
export {};
|
|
160
|
+
//# sourceMappingURL=brain-build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brain-build.d.ts","sourceRoot":"","sources":["../../src/app/brain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