@nanonets/graft 0.22.0 → 0.23.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 +11 -10
- 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/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 +0 -3
- package/dist/ask/ask.d.ts.map +1 -1
- package/dist/ask/ask.js +1 -3
- package/dist/ask/ask.js.map +1 -1
- package/dist/brand.d.ts.map +1 -1
- package/dist/brand.js +4 -1
- package/dist/brand.js.map +1 -1
- 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/claude/format.d.ts +1 -9
- package/dist/claude/format.d.ts.map +1 -1
- package/dist/claude/format.js +6 -21
- package/dist/claude/format.js.map +1 -1
- package/dist/claude/hook-layers.d.ts.map +1 -1
- package/dist/claude/hook-layers.js +5 -3
- package/dist/claude/hook-layers.js.map +1 -1
- package/dist/claude/hooks.d.ts +6 -0
- package/dist/claude/hooks.d.ts.map +1 -1
- package/dist/claude/hooks.js +101 -14
- package/dist/claude/hooks.js.map +1 -1
- package/dist/claude/init.d.ts +38 -7
- package/dist/claude/init.d.ts.map +1 -1
- package/dist/claude/init.js +172 -33
- package/dist/claude/init.js.map +1 -1
- package/dist/claude/settings-merge.d.ts +23 -0
- package/dist/claude/settings-merge.d.ts.map +1 -1
- package/dist/claude/settings-merge.js +103 -7
- package/dist/claude/settings-merge.js.map +1 -1
- package/dist/claude/shim-template.d.ts.map +1 -1
- package/dist/claude/shim-template.js +39 -3
- package/dist/claude/shim-template.js.map +1 -1
- package/dist/claude/skill-template.d.ts +4 -3
- package/dist/claude/skill-template.d.ts.map +1 -1
- package/dist/claude/skill-template.js +25 -10
- package/dist/claude/skill-template.js.map +1 -1
- package/dist/claude/state.d.ts +1 -1
- package/dist/claude/state.d.ts.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 +33 -3
- package/dist/cli-picker.js.map +1 -1
- package/dist/cli.js +141 -60
- package/dist/cli.js.map +1 -1
- package/dist/cloud/diff.d.ts +2 -0
- package/dist/cloud/diff.d.ts.map +1 -1
- package/dist/cloud/diff.js +1 -0
- package/dist/cloud/diff.js.map +1 -1
- package/dist/context/map-dir.d.ts +13 -0
- package/dist/context/map-dir.d.ts.map +1 -0
- package/dist/context/map-dir.js +67 -0
- package/dist/context/map-dir.js.map +1 -0
- package/dist/context/node-file.d.ts +4 -3
- package/dist/context/node-file.d.ts.map +1 -1
- package/dist/context/node-file.js +18 -4
- package/dist/context/node-file.js.map +1 -1
- package/dist/hosts/claude-global.d.ts.map +1 -1
- package/dist/hosts/claude-global.js +31 -11
- package/dist/hosts/claude-global.js.map +1 -1
- package/dist/hosts/config-write.js +1 -1
- package/dist/hosts/config-write.js.map +1 -1
- package/dist/hosts/retract.d.ts.map +1 -1
- package/dist/hosts/retract.js +15 -6
- package/dist/hosts/retract.js.map +1 -1
- package/dist/notes/branches.d.ts +18 -1
- package/dist/notes/branches.d.ts.map +1 -1
- package/dist/notes/branches.js +73 -7
- package/dist/notes/branches.js.map +1 -1
- package/dist/notes/cold-start.d.ts +54 -4
- package/dist/notes/cold-start.d.ts.map +1 -1
- package/dist/notes/cold-start.js +97 -36
- package/dist/notes/cold-start.js.map +1 -1
- package/dist/notes/edit-overlap.d.ts +62 -0
- package/dist/notes/edit-overlap.d.ts.map +1 -0
- package/dist/notes/edit-overlap.js +202 -0
- package/dist/notes/edit-overlap.js.map +1 -0
- package/dist/notes/notes.d.ts +25 -4
- package/dist/notes/notes.d.ts.map +1 -1
- package/dist/notes/notes.js +65 -15
- package/dist/notes/notes.js.map +1 -1
- 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 +3 -1
- package/dist/notes/repo-trail.d.ts.map +1 -1
- package/dist/notes/repo-trail.js +40 -3
- package/dist/notes/repo-trail.js.map +1 -1
- package/dist/notes/session-cost.d.ts +16 -4
- package/dist/notes/session-cost.d.ts.map +1 -1
- package/dist/notes/session-cost.js +120 -11
- package/dist/notes/session-cost.js.map +1 -1
- package/dist/telemetry/contract.d.ts.map +1 -1
- package/dist/telemetry/contract.js +6 -5
- package/dist/telemetry/contract.js.map +1 -1
- package/dist/upkeep-run.d.ts.map +1 -1
- package/dist/upkeep-run.js +4 -2
- package/dist/upkeep-run.js.map +1 -1
- package/dist/upkeep.js +2 -2
- package/dist/upkeep.js.map +1 -1
- package/dist/util/state.d.ts.map +1 -1
- package/dist/util/state.js +2 -1
- package/dist/util/state.js.map +1 -1
- package/package.json +1 -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
|
@@ -1,35 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,56 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"brain-build-worker.js","sourceRoot":"","sources":["../../src/app/brain-build-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,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E;QACpB,IAAI,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC3G,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { 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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"brain-build.d.ts","sourceRoot":"","sources":["../../src/app/brain-build.ts"],"names":[],"mappings":"AAiBA,OAAO,EAML,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAkE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAc/G,sDAAsD;AACtD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;yEACqE;IACrE,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,cAAc,CAAC;IACtB,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,C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G;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAE5G;AAED;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA2G5H;AAED,6CAA6C;AAC7C,UAAU,QAAQ;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB"}
|
package/dist/app/brain-build.js
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Building one repository into a brain, on demand.
|
|
3
|
-
*
|
|
4
|
-
* The whole point of the onboarding flow this serves: someone pastes a
|
|
5
|
-
* repository URL, and a minute later they are looking at rules mined from their
|
|
6
|
-
* own history. Nothing is installed and nobody has signed up yet, so this has to
|
|
7
|
-
* work from the repository name alone.
|
|
8
|
-
*
|
|
9
|
-
* Runs in the app rather than in the platform because only the app has the
|
|
10
|
-
* GitHub App credentials, only it can clone, and only graft can build a symbol
|
|
11
|
-
* graph. What crosses back to the platform is a digest of messages and symbol
|
|
12
|
-
* ids — never source.
|
|
13
|
-
*/
|
|
14
|
-
import { buildGraph } from "../graph/build.js";
|
|
15
|
-
import { contextDirFor } from "../context/node-file.js";
|
|
16
|
-
import { loadGraphCached } from "../graph/load.js";
|
|
17
|
-
import { checkoutRepository } from "./checkout.js";
|
|
18
|
-
import { appJwt, ghHeaders, installationFor, publicReadInstallation, repoAccessGap, } from "./identity.js";
|
|
19
|
-
import { buildDigest, postDigest, readCommits, readSymbols, readThreads } from "./history.js";
|
|
20
|
-
import { budgetSources, readAgentInstructions, readBranchProtection, readCodeowners, readCodifiedRules, readDecisionDocs, readDeclinedIssues, readReverts, readTestNames, } from "./sources.js";
|
|
21
|
-
/** Raised when the App cannot see the repository. Distinct because the caller
|
|
22
|
-
* turns it into a specific answer — "install the app, or run it locally" — and
|
|
23
|
-
* not into a 500. */
|
|
24
|
-
export class RepoNotAccessibleError extends Error {
|
|
25
|
-
gap;
|
|
26
|
-
constructor(message,
|
|
27
|
-
/** Which gap it is, so the caller can send the user to the right place. */
|
|
28
|
-
gap = { reason: "not_installed", ownerId: null, installationId: null }) {
|
|
29
|
-
super(message);
|
|
30
|
-
this.gap = gap;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Can we read this repository at all?
|
|
35
|
-
*
|
|
36
|
-
* The cheap half of a build, on its own: an installation lookup and at most
|
|
37
|
-
* one repository lookup, about a second in total, with no clone and no graph.
|
|
38
|
-
*
|
|
39
|
-
* It exists as its own call because the answer decides which screen the user
|
|
40
|
-
* sees next, and the rest of the read takes minutes. Waiting for the whole
|
|
41
|
-
* build to find out means either holding the person there or guessing from a
|
|
42
|
-
* timer, and a guess is wrong exactly when the box is busy — which is when
|
|
43
|
-
* two people are onboarding at once.
|
|
44
|
-
*/
|
|
45
|
-
export async function checkRepoAccess(job, deps) {
|
|
46
|
-
const api = deps.api ?? "https://api.github.com";
|
|
47
|
-
const installationId = await installationFor(deps.creds, job.owner, job.repo, deps.fetch, (deps.now ?? Date.now)(), api);
|
|
48
|
-
if (installationId !== null) {
|
|
49
|
-
const token = await installationToken(deps, installationId, `${job.owner}/${job.repo}`, api);
|
|
50
|
-
const meta = await repoMeta(job.owner, job.repo, token, deps.fetch, api);
|
|
51
|
-
return { accessible: true, isPrivate: meta?.isPrivate ?? true, via: "installation" };
|
|
52
|
-
}
|
|
53
|
-
const meta = await repoMeta(job.owner, job.repo, await publicReadToken(deps, api), deps.fetch, api);
|
|
54
|
-
if (meta && !meta.isPrivate)
|
|
55
|
-
return { accessible: true, isPrivate: false, via: "public" };
|
|
56
|
-
const gap = await repoAccessGap(deps.creds, job.owner, deps.fetch, (deps.now ?? Date.now)(), api);
|
|
57
|
-
return {
|
|
58
|
-
accessible: false,
|
|
59
|
-
isPrivate: true,
|
|
60
|
-
via: "none",
|
|
61
|
-
reason: gap.reason === "repo_not_selected"
|
|
62
|
-
? `graft is installed on ${job.owner} but ${job.owner}/${job.repo} is not in the list of repositories it can see`
|
|
63
|
-
: `graft is not installed on ${job.owner}`,
|
|
64
|
-
gap,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Decide how this repository gets read, and mint the credential for it.
|
|
69
|
-
*
|
|
70
|
-
* The network half of a build, kept separate from the work: an installation
|
|
71
|
-
* lookup, a token, a repository lookup. About a second, none of it blocking.
|
|
72
|
-
*
|
|
73
|
-
* Throws RepoNotAccessibleError when there is no way in. That is the answer the
|
|
74
|
-
* onboarding UI turns into a choice, which is why it is raised here — before a
|
|
75
|
-
* single byte is cloned — rather than discovered somewhere inside the read.
|
|
76
|
-
*/
|
|
77
|
-
export async function resolveRepoRead(job, deps) {
|
|
78
|
-
const api = deps.api ?? "https://api.github.com";
|
|
79
|
-
const tag = `${job.owner}/${job.repo}`;
|
|
80
|
-
const installationId = await installationFor(deps.creds, job.owner, job.repo, deps.fetch, (deps.now ?? Date.now)(), api);
|
|
81
|
-
if (installationId !== null) {
|
|
82
|
-
const token = await installationToken(deps, installationId, tag, api);
|
|
83
|
-
const meta = await repoMeta(job.owner, job.repo, token, deps.fetch, api);
|
|
84
|
-
return { token, cloneToken: token, meta: meta ?? { isPrivate: true, defaultBranch: "" } };
|
|
85
|
-
}
|
|
86
|
-
// No installation on this repository. That rules out nothing yet: a public
|
|
87
|
-
// repo clones with no credential at all, and its API answers to any token we
|
|
88
|
-
// hold. So find a credential for the reading, then ask whether it is public.
|
|
89
|
-
const token = await publicReadToken(deps, api);
|
|
90
|
-
const meta = await repoMeta(job.owner, job.repo, token, deps.fetch, api);
|
|
91
|
-
if (!meta || meta.isPrivate) {
|
|
92
|
-
// Which of the two gaps it is decides what the UI can offer, so it is
|
|
93
|
-
// resolved here rather than guessed there.
|
|
94
|
-
const gap = await repoAccessGap(deps.creds, job.owner, deps.fetch, (deps.now ?? Date.now)(), api);
|
|
95
|
-
throw new RepoNotAccessibleError(gap.reason === "repo_not_selected"
|
|
96
|
-
? `graft is installed on ${job.owner} but ${tag} is not in the list of repositories it can see`
|
|
97
|
-
: `graft is not installed on ${job.owner}`, gap);
|
|
98
|
-
}
|
|
99
|
-
return { token, cloneToken: "", meta };
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Read the repository and hand its history to the brain.
|
|
103
|
-
*
|
|
104
|
-
* An installation is the preferred way in: it is the only way into a private
|
|
105
|
-
* repository, and it carries a rate limit worth having. It is not required for
|
|
106
|
-
* a public one, though — those clone anonymously and answer the API
|
|
107
|
-
* anonymously — so a failed installation lookup is a reason to try the open
|
|
108
|
-
* door, not a reason to stop. Only a repository that is private or unreadable
|
|
109
|
-
* both ways is one we genuinely cannot see, and that is the case the UI turns
|
|
110
|
-
* into "read it on your machine".
|
|
111
|
-
*/
|
|
112
|
-
export async function buildRepoIntoBrain(job, deps) {
|
|
113
|
-
return readRepository(job, deps, await resolveRepoRead(job, deps));
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* The heavy half: clone, graph, history, digest.
|
|
117
|
-
*
|
|
118
|
-
* Takes its credential rather than minting one, because this is the half that
|
|
119
|
-
* runs somewhere else. Every expensive thing in it is synchronous — the git
|
|
120
|
-
* calls are spawnSync, the parse is a loop of native tree-sitter calls, the
|
|
121
|
-
* graph is written with a blocking stringify — so in the server process it
|
|
122
|
-
* holds the event loop for the whole read, and a second person pasting a URL
|
|
123
|
-
* waits behind the first. See brain-build-process.ts.
|
|
124
|
-
*/
|
|
125
|
-
export async function readRepository(job, deps, auth) {
|
|
126
|
-
const rawLog = deps.log ?? (() => { });
|
|
127
|
-
const api = deps.api ?? "https://api.github.com";
|
|
128
|
-
const tag = `${job.owner}/${job.repo}`;
|
|
129
|
-
const { token, cloneToken, meta } = auth;
|
|
130
|
-
// Every line carries how long we have been at it. A read that feels slow is
|
|
131
|
-
// four things in a trench coat — the clone, the graph build, the
|
|
132
|
-
// pull-request walk, the digest — and without the elapsed time on each, the
|
|
133
|
-
// only observation anyone can make is "it took two minutes".
|
|
134
|
-
const startedAt = (deps.now ?? Date.now)();
|
|
135
|
-
const log = (msg) => rawLog(`[+${(((deps.now ?? Date.now)() - startedAt) / 1000).toFixed(1)}s] ${msg}`);
|
|
136
|
-
const phase = (name) => {
|
|
137
|
-
const at = (deps.now ?? Date.now)();
|
|
138
|
-
return () => log(`${tag}: ${name} took ${(((deps.now ?? Date.now)() - at) / 1000).toFixed(1)}s`);
|
|
139
|
-
};
|
|
140
|
-
const doneClone = phase("clone");
|
|
141
|
-
const checkout = checkoutRepository({
|
|
142
|
-
owner: job.owner,
|
|
143
|
-
repo: job.repo,
|
|
144
|
-
ref: job.ref || meta.defaultBranch,
|
|
145
|
-
token: cloneToken,
|
|
146
|
-
api: deps.githubHost,
|
|
147
|
-
log,
|
|
148
|
-
});
|
|
149
|
-
doneClone();
|
|
150
|
-
try {
|
|
151
|
-
// `graphOnly`: the symbol ids and their hashes are all the digest needs, and
|
|
152
|
-
// the markdown projections cost real time on a large repo.
|
|
153
|
-
const doneGraph = phase("symbol graph");
|
|
154
|
-
await buildGraph(checkout.dir, { graphOnly: true });
|
|
155
|
-
const graph = loadGraphCached(contextDirFor(checkout.dir));
|
|
156
|
-
doneGraph();
|
|
157
|
-
const commits = readCommits(checkout.dir);
|
|
158
|
-
const symbols = readSymbols(graph);
|
|
159
|
-
// The threads are the slow part (two API calls per pull request), and the
|
|
160
|
-
// one most likely to fail on a rate limit. A failure here degrades to a
|
|
161
|
-
// commits-only ingest rather than losing the whole build.
|
|
162
|
-
let threads = [];
|
|
163
|
-
const doneThreads = phase("pull-request discussion");
|
|
164
|
-
try {
|
|
165
|
-
threads = await readThreads(job.owner, job.repo, token, deps.fetch, api);
|
|
166
|
-
}
|
|
167
|
-
catch (e) {
|
|
168
|
-
log(`${tag}: pull-request discussion unavailable (${e instanceof Error ? e.message : e}); mining commits only`);
|
|
169
|
-
}
|
|
170
|
-
doneThreads();
|
|
171
|
-
// Everything the repo already states as a rule. All best-effort: the file
|
|
172
|
-
// readers cannot fail the build, and the two API readers swallow their own
|
|
173
|
-
// errors, so a repo with none of this still gets a brain from its history.
|
|
174
|
-
const doneSources = phase("stated sources");
|
|
175
|
-
const sources = budgetSources([
|
|
176
|
-
...readAgentInstructions(checkout.dir),
|
|
177
|
-
...readDecisionDocs(checkout.dir),
|
|
178
|
-
...readCodeowners(checkout.dir),
|
|
179
|
-
...readCodifiedRules(checkout.dir),
|
|
180
|
-
...readReverts(checkout.dir),
|
|
181
|
-
...readTestNames(symbols.map((s) => ({ name: s.name, path: s.path }))),
|
|
182
|
-
...(await readBranchProtection(job.owner, job.repo, meta.defaultBranch, token, deps.fetch, api)),
|
|
183
|
-
...(await readDeclinedIssues(job.owner, job.repo, token, deps.fetch, api)),
|
|
184
|
-
]);
|
|
185
|
-
doneSources();
|
|
186
|
-
log(`${tag}: read ${commits.length} commits, ${threads.length} threads, ${symbols.length} symbols, ${sources.length} stated sources`);
|
|
187
|
-
const digest = buildDigest({
|
|
188
|
-
owner: job.owner,
|
|
189
|
-
name: job.repo,
|
|
190
|
-
headSha: checkout.headSha,
|
|
191
|
-
defaultBranch: job.ref || meta.defaultBranch,
|
|
192
|
-
isPrivate: meta.isPrivate,
|
|
193
|
-
commits,
|
|
194
|
-
threads,
|
|
195
|
-
symbols,
|
|
196
|
-
sources,
|
|
197
|
-
autoApprove: job.autoApprove ?? false,
|
|
198
|
-
});
|
|
199
|
-
const counts = {
|
|
200
|
-
headSha: checkout.headSha,
|
|
201
|
-
commits: commits.length,
|
|
202
|
-
threads: threads.length,
|
|
203
|
-
symbols: symbols.length,
|
|
204
|
-
sources: sources.length,
|
|
205
|
-
};
|
|
206
|
-
if (!job.brainId || !job.brainToken) {
|
|
207
|
-
return { jobId: "", ...counts, digest };
|
|
208
|
-
}
|
|
209
|
-
const { jobId } = await postDigest(job.brainBaseUrl ?? "https://agents.nanonets.com", job.brainId, job.brainToken, digest, deps.fetch);
|
|
210
|
-
return { jobId, ...counts };
|
|
211
|
-
}
|
|
212
|
-
finally {
|
|
213
|
-
// Always: the clone was made with an installation token and is not something
|
|
214
|
-
// to leave in /tmp.
|
|
215
|
-
checkout.cleanup();
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* The repository's visibility and default branch, in one call.
|
|
220
|
-
*
|
|
221
|
-
* Null when the call did not answer, which is not the same as private and is
|
|
222
|
-
* why this does not fold the two together: with an installation, an unanswered
|
|
223
|
-
* call is a hiccup the read can carry on past; without one, it is the whole
|
|
224
|
-
* decision about whether we can see this repository at all. Callers that only
|
|
225
|
-
* need the fields treat null as private, because saying a repo is public when
|
|
226
|
-
* it is not would leak its name onto a pre-signup screen.
|
|
227
|
-
*/
|
|
228
|
-
async function repoMeta(owner, repo, token, fetchImpl, api) {
|
|
229
|
-
try {
|
|
230
|
-
const res = await fetchImpl(`${api}/repos/${owner}/${repo}`, { headers: ghHeaders(token) });
|
|
231
|
-
if (!res.ok)
|
|
232
|
-
return null;
|
|
233
|
-
const parsed = JSON.parse(await res.text());
|
|
234
|
-
return {
|
|
235
|
-
isPrivate: parsed.private !== false,
|
|
236
|
-
defaultBranch: (parsed.default_branch ?? "").trim(),
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
catch {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* A credential for reading a public repository we are not installed on.
|
|
245
|
-
*
|
|
246
|
-
* Order: a token configured for exactly this, then one of our own
|
|
247
|
-
* installation's, then nothing. Every step of that ladder works — the
|
|
248
|
-
* difference is only the rate limit, and the drop to anonymous is a factor of
|
|
249
|
-
* eighty, so it is worth two extra calls to avoid.
|
|
250
|
-
*/
|
|
251
|
-
async function publicReadToken(deps, api) {
|
|
252
|
-
if (deps.publicToken)
|
|
253
|
-
return deps.publicToken;
|
|
254
|
-
try {
|
|
255
|
-
const id = await publicReadInstallation(deps.creds, deps.publicOwner ?? "trailhq", deps.fetch, (deps.now ?? Date.now)(), api);
|
|
256
|
-
if (id === null)
|
|
257
|
-
return "";
|
|
258
|
-
return await installationToken(deps, id, "public read", api);
|
|
259
|
-
}
|
|
260
|
-
catch {
|
|
261
|
-
return "";
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
/** Mint an installation token, the credential every authenticated read uses. */
|
|
265
|
-
async function installationToken(deps, installationId, tag, api) {
|
|
266
|
-
const res = await deps.fetch(`${api}/app/installations/${installationId}/access_tokens`, {
|
|
267
|
-
method: "POST",
|
|
268
|
-
headers: {
|
|
269
|
-
authorization: `Bearer ${appJwt(deps.creds, (deps.now ?? Date.now)())}`,
|
|
270
|
-
accept: "application/vnd.github+json",
|
|
271
|
-
"user-agent": "graft-app",
|
|
272
|
-
},
|
|
273
|
-
});
|
|
274
|
-
if (!res.ok)
|
|
275
|
-
throw new Error(`installation token for ${tag} failed: ${res.status}`);
|
|
276
|
-
return JSON.parse(await res.text()).token;
|
|
277
|
-
}
|
|
278
|
-
//# sourceMappingURL=brain-build.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"brain-build.js","sourceRoot":"","sources":["../../src/app/brain-build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EACL,MAAM,EACN,SAAS,EACT,eAAe,EACf,sBAAsB,EACtB,aAAa,GAId,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAmB,M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