@nanonets/graft 0.20.0 → 0.21.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/dist/app/history.d.ts +36 -1
- package/dist/app/history.d.ts.map +1 -1
- package/dist/app/history.js +72 -25
- package/dist/app/history.js.map +1 -1
- package/dist/app/sources.d.ts +13 -0
- package/dist/app/sources.d.ts.map +1 -1
- package/dist/app/sources.js +129 -1
- package/dist/app/sources.js.map +1 -1
- package/dist/brain/claude-md.d.ts +4 -2
- package/dist/brain/claude-md.d.ts.map +1 -1
- package/dist/brain/claude-md.js +4 -3
- package/dist/brain/claude-md.js.map +1 -1
- package/dist/brain/context-files.d.ts +79 -0
- package/dist/brain/context-files.d.ts.map +1 -0
- package/dist/brain/context-files.js +245 -0
- package/dist/brain/context-files.js.map +1 -0
- package/dist/brain/link.d.ts +17 -0
- package/dist/brain/link.d.ts.map +1 -1
- package/dist/brain/link.js +21 -0
- package/dist/brain/link.js.map +1 -1
- package/dist/brain/pull.d.ts +17 -0
- package/dist/brain/pull.d.ts.map +1 -0
- package/dist/brain/pull.js +172 -0
- package/dist/brain/pull.js.map +1 -0
- package/dist/brain/push.d.ts +62 -7
- package/dist/brain/push.d.ts.map +1 -1
- package/dist/brain/push.js +97 -62
- package/dist/brain/push.js.map +1 -1
- package/dist/brain/signup.d.ts +46 -2
- package/dist/brain/signup.d.ts.map +1 -1
- package/dist/brain/signup.js +101 -11
- package/dist/brain/signup.js.map +1 -1
- package/dist/brain/upload.d.ts +61 -0
- package/dist/brain/upload.d.ts.map +1 -0
- package/dist/brain/upload.js +210 -0
- package/dist/brain/upload.js.map +1 -0
- package/dist/brain/watch.d.ts +76 -3
- package/dist/brain/watch.d.ts.map +1 -1
- package/dist/brain/watch.js +263 -39
- package/dist/brain/watch.js.map +1 -1
- package/dist/claude/build-progress.d.ts +29 -0
- package/dist/claude/build-progress.d.ts.map +1 -0
- package/dist/claude/build-progress.js +76 -0
- package/dist/claude/build-progress.js.map +1 -0
- package/dist/cli-picker.d.ts +17 -2
- package/dist/cli-picker.d.ts.map +1 -1
- package/dist/cli-picker.js +103 -22
- package/dist/cli-picker.js.map +1 -1
- package/dist/cli.js +423 -187
- package/dist/cli.js.map +1 -1
- package/dist/telemetry/contract.d.ts +16 -3
- package/dist/telemetry/contract.d.ts.map +1 -1
- package/dist/telemetry/contract.js +23 -5
- package/dist/telemetry/contract.js.map +1 -1
- package/dist/util/spinner.d.ts +15 -0
- package/dist/util/spinner.d.ts.map +1 -0
- package/dist/util/spinner.js +52 -0
- package/dist/util/spinner.js.map +1 -0
- package/dist/util/state.d.ts +8 -0
- package/dist/util/state.d.ts.map +1 -1
- package/dist/util/state.js.map +1 -1
- package/package.json +1 -1
package/dist/brain/push.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type HistoryThread, type RepoDigest } from "../app/history.js";
|
|
1
|
+
import { type HistoryThread, type RepoDigest, type ThreadReadCache } from "../app/history.js";
|
|
2
2
|
import type { GraphV1 } from "../graph/types.js";
|
|
3
3
|
import { type BrainLink } from "./link.js";
|
|
4
|
+
import { type UploadCaps, type UploadOptions } from "./upload.js";
|
|
4
5
|
/** What a local ingest read, for the caller to print. */
|
|
5
6
|
export interface PushResult {
|
|
6
7
|
jobId: string;
|
|
@@ -37,8 +38,16 @@ export interface ExpectedRepo {
|
|
|
37
38
|
slug: string;
|
|
38
39
|
status: string;
|
|
39
40
|
brainName: string;
|
|
41
|
+
/** Rules the trail already holds; 0 before its first build. */
|
|
42
|
+
ruleCount: number;
|
|
40
43
|
/** The brain accepts an early upload (see pushEarlyDigest). */
|
|
41
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;
|
|
42
51
|
}
|
|
43
52
|
/**
|
|
44
53
|
* The repository this brain expects, or null when it expects none.
|
|
@@ -49,16 +58,42 @@ export interface ExpectedRepo {
|
|
|
49
58
|
* afterwards — the rules simply describe someone else's codebase — so the round
|
|
50
59
|
* trip is worth it.
|
|
51
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
|
+
*
|
|
52
65
|
* Null on any failure, which keeps an older brain (or an unreachable one)
|
|
53
66
|
* working exactly as it did before this check existed.
|
|
54
67
|
*/
|
|
55
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;
|
|
56
71
|
/** Whether two repo slugs name the same repository. GitHub is case-insensitive. */
|
|
57
72
|
export declare function sameRepo(a: string, b: string): boolean;
|
|
58
73
|
/** How many of the newest pull requests and commits the early upload carries —
|
|
59
74
|
* what Trail's quick CLAUDE.md pass reads, and no more. */
|
|
60
75
|
export declare const EARLY_THREADS = 30;
|
|
61
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;
|
|
62
97
|
/**
|
|
63
98
|
* The early upload: the instruction files, the newest pull requests and the
|
|
64
99
|
* newest commits, read before the rest of the history.
|
|
@@ -68,31 +103,51 @@ export declare const EARLY_COMMITS = 80;
|
|
|
68
103
|
* beyond the newest few. Sent first, they start while the full read is still
|
|
69
104
|
* going here, and the full upload that follows mines as before.
|
|
70
105
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
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.
|
|
73
112
|
*/
|
|
74
113
|
export declare function buildEarlyDigest(root: string, opts?: {
|
|
75
114
|
fetchImpl?: typeof fetch;
|
|
115
|
+
context?: PushContext;
|
|
76
116
|
}): Promise<{
|
|
77
117
|
digest: RepoDigest;
|
|
78
118
|
threads: HistoryThread[];
|
|
79
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[];
|
|
80
127
|
/** Send the early upload. Best-effort: false on any failure, and the full
|
|
81
|
-
* upload still does everything. */
|
|
82
|
-
export declare function pushEarlyDigest(link: BrainLink, digest: RepoDigest, fetchImpl?: typeof fetch
|
|
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>;
|
|
83
132
|
/** Build the digest for the checkout at `root`. Reads nothing but text. */
|
|
84
133
|
export declare function buildLocalDigest(root: string, graph: GraphV1 | null, opts?: {
|
|
85
134
|
autoApprove?: boolean;
|
|
86
135
|
fetchImpl?: typeof fetch;
|
|
87
136
|
knownThreads?: HistoryThread[];
|
|
137
|
+
context?: PushContext;
|
|
88
138
|
}): Promise<{
|
|
89
139
|
digest: RepoDigest;
|
|
90
140
|
warning?: string;
|
|
91
141
|
} | {
|
|
92
142
|
error: string;
|
|
93
143
|
}>;
|
|
94
|
-
/**
|
|
95
|
-
|
|
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<{
|
|
96
151
|
jobId: string;
|
|
97
152
|
} | {
|
|
98
153
|
error: string;
|
package/dist/brain/push.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../src/brain/push.ts"],"names":[],"mappings":"AAiBA,OAAO,
|
|
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,aAA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OAAO,GAAG,IAAI,EACrB,IAAI,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IAAC,YAAY,CAAC,EAAE,aAAa,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,WAAW,CAAA;CAAO,GACpH,OAAO,CAAC;IAAE,MAAM,EAAE,UAAU,CAAC;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
CHANGED
|
@@ -15,9 +15,11 @@
|
|
|
15
15
|
* hashes. No file contents, no diffs, no source.
|
|
16
16
|
*/
|
|
17
17
|
import { spawnSync } from "node:child_process";
|
|
18
|
-
import { buildDigest, readCommits, readSymbols, readThreads, } from "../app/history.js";
|
|
18
|
+
import { buildDigest, newThreadReadCache, readCommits, readSymbols, readThreads, } from "../app/history.js";
|
|
19
19
|
import { budgetSources, readAgentInstructions, readBranchProtection, readCodeowners, readCodifiedRules, readDecisionDocs, readDeclinedIssues, readReverts, readTestNames, } from "../app/sources.js";
|
|
20
|
+
import { readStamp, wiredHostIds } from "../upkeep.js";
|
|
20
21
|
import { baseUrlFor } from "./link.js";
|
|
22
|
+
import { postDigestOnce, uploadDigest } from "./upload.js";
|
|
21
23
|
function git(root, args) {
|
|
22
24
|
const res = spawnSync("git", ["-c", "core.quotePath=false", ...args], {
|
|
23
25
|
cwd: root,
|
|
@@ -90,6 +92,10 @@ async function isPrivate(owner, name, token, fetchImpl) {
|
|
|
90
92
|
* afterwards — the rules simply describe someone else's codebase — so the round
|
|
91
93
|
* trip is worth it.
|
|
92
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
|
+
*
|
|
93
99
|
* Null on any failure, which keeps an older brain (or an unreachable one)
|
|
94
100
|
* working exactly as it did before this check existed.
|
|
95
101
|
*/
|
|
@@ -108,13 +114,21 @@ export async function fetchExpectedRepo(link, fetchImpl = fetch) {
|
|
|
108
114
|
slug: body.repo.slug,
|
|
109
115
|
status: String(body.repo.status ?? ""),
|
|
110
116
|
brainName: String(body.brain_name ?? ""),
|
|
117
|
+
ruleCount: typeof body.repo.rule_count === "number" && body.repo.rule_count > 0 ? body.repo.rule_count : 0,
|
|
111
118
|
earlyUpload: body.early_upload === true,
|
|
119
|
+
gzipUpload: body.gzip_upload === true,
|
|
120
|
+
chunkedUpload: body.chunked_upload === true,
|
|
121
|
+
events: body.events === true,
|
|
112
122
|
};
|
|
113
123
|
}
|
|
114
124
|
catch {
|
|
115
125
|
return null;
|
|
116
126
|
}
|
|
117
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
|
+
}
|
|
118
132
|
/** Whether two repo slugs name the same repository. GitHub is case-insensitive. */
|
|
119
133
|
export function sameRepo(a, b) {
|
|
120
134
|
return a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
@@ -123,6 +137,25 @@ export function sameRepo(a, b) {
|
|
|
123
137
|
* what Trail's quick CLAUDE.md pass reads, and no more. */
|
|
124
138
|
export const EARLY_THREADS = 30;
|
|
125
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
|
+
}
|
|
126
159
|
/**
|
|
127
160
|
* The early upload: the instruction files, the newest pull requests and the
|
|
128
161
|
* newest commits, read before the rest of the history.
|
|
@@ -132,57 +165,64 @@ export const EARLY_COMMITS = 80;
|
|
|
132
165
|
* beyond the newest few. Sent first, they start while the full read is still
|
|
133
166
|
* going here, and the full upload that follows mines as before.
|
|
134
167
|
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
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.
|
|
137
174
|
*/
|
|
138
175
|
export async function buildEarlyDigest(root, opts = {}) {
|
|
139
|
-
const
|
|
140
|
-
if (!
|
|
176
|
+
const ctx = opts.context ?? pushContext(root, opts);
|
|
177
|
+
if (!ctx)
|
|
141
178
|
return null;
|
|
142
|
-
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
143
|
-
const token = githubToken();
|
|
144
179
|
// Oldest first, like the full read, so the newest are the tail.
|
|
145
|
-
const commits = readCommits(root
|
|
180
|
+
const commits = readCommits(root, EARLY_COMMITS);
|
|
146
181
|
if (commits.length === 0)
|
|
147
182
|
return null;
|
|
148
183
|
let threads = [];
|
|
149
|
-
if (token) {
|
|
184
|
+
if (ctx.token) {
|
|
150
185
|
try {
|
|
151
|
-
threads = await readThreads(
|
|
186
|
+
threads = await readThreads(ctx.owner, ctx.name, ctx.token, ctx.fetchImpl, undefined, EARLY_THREADS, undefined, ctx.threads);
|
|
152
187
|
}
|
|
153
188
|
catch {
|
|
154
189
|
threads = [];
|
|
155
190
|
}
|
|
156
191
|
}
|
|
157
192
|
const digest = buildDigest({
|
|
158
|
-
owner:
|
|
159
|
-
name:
|
|
160
|
-
headSha:
|
|
161
|
-
defaultBranch:
|
|
162
|
-
isPrivate: await isPrivate(
|
|
193
|
+
owner: ctx.owner,
|
|
194
|
+
name: ctx.name,
|
|
195
|
+
headSha: ctx.headSha,
|
|
196
|
+
defaultBranch: ctx.branch,
|
|
197
|
+
isPrivate: await ctx.isPrivate(),
|
|
163
198
|
commits,
|
|
164
199
|
threads,
|
|
165
200
|
symbols: [],
|
|
166
201
|
sources: budgetSources(readAgentInstructions(root)),
|
|
167
202
|
autoApprove: true,
|
|
203
|
+
agents: pickedAgents(root),
|
|
168
204
|
});
|
|
169
205
|
return { digest, threads };
|
|
170
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
|
+
}
|
|
171
221
|
/** Send the early upload. Best-effort: false on any failure, and the full
|
|
172
|
-
* upload still does everything. */
|
|
173
|
-
export async function pushEarlyDigest(link, digest, fetchImpl = fetch) {
|
|
174
|
-
const url = `${baseUrlFor(link)}/api/public/brains/${encodeURIComponent(link.brainId)}/repo?stage=early`;
|
|
222
|
+
* upload still does everything. Gzipped when the server takes it. */
|
|
223
|
+
export async function pushEarlyDigest(link, digest, fetchImpl = fetch, opts = {}) {
|
|
175
224
|
try {
|
|
176
|
-
const res = await
|
|
177
|
-
method: "POST",
|
|
178
|
-
headers: {
|
|
179
|
-
authorization: `Bearer ${link.token}`,
|
|
180
|
-
"content-type": "application/json",
|
|
181
|
-
accept: "application/json",
|
|
182
|
-
},
|
|
183
|
-
body: JSON.stringify(digest),
|
|
184
|
-
signal: AbortSignal.timeout(15_000),
|
|
185
|
-
});
|
|
225
|
+
const res = await postDigestOnce(link, digest, { gzip: opts.gzip, fetchImpl, query: "?stage=early", timeoutMs: 15_000 });
|
|
186
226
|
if (!res.ok)
|
|
187
227
|
return false;
|
|
188
228
|
return (await res.json()).early === true;
|
|
@@ -193,12 +233,11 @@ export async function pushEarlyDigest(link, digest, fetchImpl = fetch) {
|
|
|
193
233
|
}
|
|
194
234
|
/** Build the digest for the checkout at `root`. Reads nothing but text. */
|
|
195
235
|
export async function buildLocalDigest(root, graph, opts = {}) {
|
|
196
|
-
const
|
|
197
|
-
if (!
|
|
236
|
+
const ctx = opts.context ?? pushContext(root, opts);
|
|
237
|
+
if (!ctx) {
|
|
198
238
|
return { error: "this directory has no GitHub `origin` remote — graft can only push a GitHub repository today" };
|
|
199
239
|
}
|
|
200
|
-
const
|
|
201
|
-
const token = githubToken();
|
|
240
|
+
const { token, fetchImpl } = ctx;
|
|
202
241
|
const commits = readCommits(root);
|
|
203
242
|
if (commits.length === 0) {
|
|
204
243
|
return { error: "no commits found here — is this a shallow clone with no history?" };
|
|
@@ -206,10 +245,18 @@ export async function buildLocalDigest(root, graph, opts = {}) {
|
|
|
206
245
|
const symbols = readSymbols(graph);
|
|
207
246
|
let threads = [];
|
|
208
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([[], []]);
|
|
209
256
|
if (token) {
|
|
210
257
|
try {
|
|
211
258
|
const known = new Map((opts.knownThreads ?? []).map((t) => [t.number, t]));
|
|
212
|
-
threads = await readThreads(
|
|
259
|
+
threads = await readThreads(ctx.owner, ctx.name, token, fetchImpl, undefined, undefined, known, ctx.threads);
|
|
213
260
|
}
|
|
214
261
|
catch {
|
|
215
262
|
warning = "could not read pull-request discussion; mining commits and repo files only";
|
|
@@ -219,7 +266,7 @@ export async function buildLocalDigest(root, graph, opts = {}) {
|
|
|
219
266
|
warning =
|
|
220
267
|
"no GitHub token found (`gh auth login`, or GH_TOKEN) — mining commits and repo files only, without pull-request discussion";
|
|
221
268
|
}
|
|
222
|
-
const
|
|
269
|
+
const [protection, declined] = await remote;
|
|
223
270
|
const sources = budgetSources([
|
|
224
271
|
...readAgentInstructions(root),
|
|
225
272
|
...readDecisionDocs(root),
|
|
@@ -227,43 +274,31 @@ export async function buildLocalDigest(root, graph, opts = {}) {
|
|
|
227
274
|
...readCodifiedRules(root),
|
|
228
275
|
...readReverts(root),
|
|
229
276
|
...readTestNames(symbols.map((s) => ({ name: s.name, path: s.path }))),
|
|
230
|
-
...
|
|
231
|
-
...
|
|
277
|
+
...protection,
|
|
278
|
+
...declined,
|
|
232
279
|
]);
|
|
233
280
|
const digest = buildDigest({
|
|
234
|
-
owner:
|
|
235
|
-
name:
|
|
236
|
-
headSha:
|
|
237
|
-
defaultBranch: branch,
|
|
238
|
-
isPrivate: await isPrivate(
|
|
281
|
+
owner: ctx.owner,
|
|
282
|
+
name: ctx.name,
|
|
283
|
+
headSha: ctx.headSha,
|
|
284
|
+
defaultBranch: ctx.branch,
|
|
285
|
+
isPrivate: await ctx.isPrivate(),
|
|
239
286
|
commits,
|
|
240
287
|
threads,
|
|
241
288
|
symbols,
|
|
242
289
|
sources,
|
|
243
290
|
autoApprove: opts.autoApprove ?? true,
|
|
291
|
+
agents: pickedAgents(root),
|
|
244
292
|
});
|
|
245
293
|
return { digest, warning };
|
|
246
294
|
}
|
|
247
|
-
/**
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
"content-type": "application/json",
|
|
256
|
-
accept: "application/json",
|
|
257
|
-
},
|
|
258
|
-
body: JSON.stringify(digest),
|
|
259
|
-
});
|
|
260
|
-
const text = await res.text();
|
|
261
|
-
if (!res.ok)
|
|
262
|
-
return { error: `the brain refused the ingest: ${res.status} ${text.slice(0, 200)}` };
|
|
263
|
-
return { jobId: String(JSON.parse(text).job_id ?? "") };
|
|
264
|
-
}
|
|
265
|
-
catch (e) {
|
|
266
|
-
return { error: `could not reach the brain: ${e instanceof Error ? e.message : e}` };
|
|
267
|
-
}
|
|
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 });
|
|
268
303
|
}
|
|
269
304
|
//# sourceMappingURL=push.js.map
|
package/dist/brain/push.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.js","sourceRoot":"","sources":["../../src/brain/push.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;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AC;QACzB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,aAAa,EAAE,GAAG,CAAC,MAAM;QACzB,SAAS,EAAE,MAAM,GAAG,CAAC,SAAS,EAAE;QAChC,OAAO;QACP,OAAO;QACP,OAAO;QACP,OAAO;QACP,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,IAAI;QACrC,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC;KAC3B,CAAC,CAAC;IACH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC7B,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,IAAe,EACf,MAAkB,EAClB,YAA0B,KAAK,EAC/B,OAAmB,EAAE,EACrB,OAAyC,EAAE;IAE3C,OAAO,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;AAClE,CAAC"}
|
package/dist/brain/signup.d.ts
CHANGED
|
@@ -56,13 +56,57 @@ export declare function webBaseUrl(baseUrl?: string): string;
|
|
|
56
56
|
* built perfectly well. The build screen is the same wait the browser-first
|
|
57
57
|
* flow shows, and it leads to the graph once there is a graph. */
|
|
58
58
|
export declare function brainUrl(brainId: string, baseUrl?: string): string;
|
|
59
|
-
/** Where
|
|
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. */
|
|
60
68
|
export declare function signupUrl(opts: {
|
|
61
69
|
repo: string;
|
|
62
|
-
port
|
|
70
|
+
port?: number;
|
|
63
71
|
state: string;
|
|
64
72
|
baseUrl?: string;
|
|
65
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>;
|
|
66
110
|
/** Open the user's browser, best effort. A machine with no opener is not an
|
|
67
111
|
* error: the URL is printed too, and that is the fallback everywhere.
|
|
68
112
|
*
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,eAA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