@nanonets/graft 0.20.0 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +48 -0
- package/dist/brain/pull.d.ts.map +1 -0
- package/dist/brain/pull.js +257 -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 +264 -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 +385 -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
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `graft trail pull`: one command for both things a trail hands this repo.
|
|
3
|
+
*
|
|
4
|
+
* First the rules, refreshed into graft's own blocks in the agent files (what
|
|
5
|
+
* `graft trail pull` always did). Then every change accepted in Trail, for every
|
|
6
|
+
* context file the picked agents read — the root CLAUDE.md (what `graft
|
|
7
|
+
* claude-md pull` did, and still does, as an alias of this), and then AGENTS.md,
|
|
8
|
+
* folder CLAUDE.md files, Cursor rules and skills when Trail serves them.
|
|
9
|
+
*
|
|
10
|
+
* Files for agents that were not picked are neither listed nor written.
|
|
11
|
+
*/
|
|
12
|
+
import { isAbsolute, relative } from "node:path";
|
|
13
|
+
import { connectBrain } from "./connect.js";
|
|
14
|
+
import { fetchAcceptedChanges, markApplied } from "./claude-md.js";
|
|
15
|
+
import { changeSummary, fetchContextFiles, kindForPath, markContextFilesApplied, planContextFile, readByWired, readersOf, writePlannedFile, } from "./context-files.js";
|
|
16
|
+
import { reviewUrl } from "./signup.js";
|
|
17
|
+
import { fetchRepoState } from "./watch.js";
|
|
18
|
+
import { CONTEXT_FILE_KINDS, countBucket } from "../telemetry/contract.js";
|
|
19
|
+
import { track } from "../telemetry/track.js";
|
|
20
|
+
/** Repo-relative, forward slashes, for printing. */
|
|
21
|
+
function show(repo, path) {
|
|
22
|
+
const rel = isAbsolute(path) ? relative(repo, path) : path;
|
|
23
|
+
return rel.split("\\").join("/");
|
|
24
|
+
}
|
|
25
|
+
/** The rules line: how many, and which files they are in. */
|
|
26
|
+
export function rulesLine(repo, res) {
|
|
27
|
+
if (res.warning)
|
|
28
|
+
return `⚠ ${res.warning}`;
|
|
29
|
+
if (res.ruleCount === 0)
|
|
30
|
+
return "· the trail has no rules yet — run graft trail push to read this repo into it";
|
|
31
|
+
const n = res.ruleCount.toLocaleString("en-US");
|
|
32
|
+
const where = res.writes.map((w) => show(repo, w.path)).join(", ");
|
|
33
|
+
const rules = `${n} rule${res.ruleCount === 1 ? "" : "s"}`;
|
|
34
|
+
if (!where)
|
|
35
|
+
return `✓ ${rules} pulled · no instruction file to write them into — graft ask still carries them`;
|
|
36
|
+
if (res.writes.every((w) => w.action === "unchanged"))
|
|
37
|
+
return `✓ rules already current · ${n} in ${where}`;
|
|
38
|
+
return `✓ ${rules} refreshed in ${where}`;
|
|
39
|
+
}
|
|
40
|
+
/** `a, b and c`. */
|
|
41
|
+
function joinAnd(items) {
|
|
42
|
+
if (items.length <= 1)
|
|
43
|
+
return items.join("");
|
|
44
|
+
return `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Trail's suggestions, cut to the files the wired agents read: how many, and
|
|
48
|
+
* whose files they are (`the files claude and cursor read`).
|
|
49
|
+
*
|
|
50
|
+
* Every suggestion Trail has made, whatever became of it — the counts it sends
|
|
51
|
+
* do not say which are still waiting for review and which were dismissed.
|
|
52
|
+
*/
|
|
53
|
+
export function suggestedFor(s, wired) {
|
|
54
|
+
if (!s)
|
|
55
|
+
return { count: 0, whose: "" };
|
|
56
|
+
let count = 0;
|
|
57
|
+
const kinds = new Set();
|
|
58
|
+
if (s.claudeMd > 0 && readByWired("claude_md", wired)) {
|
|
59
|
+
count += s.claudeMd;
|
|
60
|
+
kinds.add("claude_md");
|
|
61
|
+
}
|
|
62
|
+
if (s.files) {
|
|
63
|
+
for (const f of s.files) {
|
|
64
|
+
if (f.changes <= 0 || !readByWired(f.kind, wired))
|
|
65
|
+
continue;
|
|
66
|
+
count += f.changes;
|
|
67
|
+
kinds.add(f.kind);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else if (s.contextFiles > 0) {
|
|
71
|
+
// No per-file list from this Trail, so no way to cut it to the wired agents'
|
|
72
|
+
// files: the count is Trail's total.
|
|
73
|
+
count += s.contextFiles;
|
|
74
|
+
for (const k of ["agents_md", "folder_claude_md", "cursor_rule", "skill"])
|
|
75
|
+
kinds.add(k);
|
|
76
|
+
}
|
|
77
|
+
const readers = wired.length
|
|
78
|
+
? wired.filter((w) => [...kinds].some((k) => readersOf(k, [w]).length > 0))
|
|
79
|
+
: [];
|
|
80
|
+
return { count, whose: readers.length ? `the files ${joinAnd(readers)} read` : "this repo's context files" };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The suggestions line after a build:
|
|
84
|
+
* `● 18 suggestions for the files claude, agents and cursor read`. Null when
|
|
85
|
+
* there are none to mention.
|
|
86
|
+
*/
|
|
87
|
+
export function suggestionsLine(s, wired, again) {
|
|
88
|
+
const { count, whose } = suggestedFor(s, wired);
|
|
89
|
+
if (count === 0)
|
|
90
|
+
return null;
|
|
91
|
+
return `● ${count.toLocaleString("en-US")} ${again ? "new " : ""}suggestion${count === 1 ? "" : "s"} for ${whose}`;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* What a pull says about the suggestions it did not write:
|
|
95
|
+
* `● 20 suggested so far for the files claude read, 2 of them accepted`.
|
|
96
|
+
*
|
|
97
|
+
* This is what lets an agent watching the trail say "there are suggestions
|
|
98
|
+
* waiting for you" before anything has been accepted. "So far", because the
|
|
99
|
+
* build keeps adding them after the push returns. Null when Trail sent no
|
|
100
|
+
* counts, or counts that cannot hold what was accepted.
|
|
101
|
+
*/
|
|
102
|
+
export function suggestedLine(suggested, accepted) {
|
|
103
|
+
if (suggested.count === 0 || suggested.count < accepted)
|
|
104
|
+
return null;
|
|
105
|
+
const taken = accepted === 0 ? "none accepted yet" : `${accepted.toLocaleString("en-US")} of them accepted`;
|
|
106
|
+
return `● ${suggested.count.toLocaleString("en-US")} suggested so far for ${suggested.whose}, ${taken}`;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The `trail_pulled` event for one pull. Only the outcome, which kinds of file
|
|
110
|
+
* were written, and bucketed counts leave the machine — see TELEMETRY.md.
|
|
111
|
+
*/
|
|
112
|
+
function trackPull(repo, home, outcome, planned = [], suggested = 0) {
|
|
113
|
+
const wrote = planned.filter((p) => p.plan.status && p.plan.written.length > 0);
|
|
114
|
+
const kinds = [...new Set(wrote.map((p) => p.kind))]
|
|
115
|
+
.filter((k) => CONTEXT_FILE_KINDS.includes(k))
|
|
116
|
+
.sort()
|
|
117
|
+
.join(",");
|
|
118
|
+
track("trail_pulled", {
|
|
119
|
+
outcome,
|
|
120
|
+
kinds,
|
|
121
|
+
files_bucket: countBucket(wrote.length),
|
|
122
|
+
changes_bucket: countBucket(wrote.reduce((n, p) => n + p.plan.written.length, 0)),
|
|
123
|
+
skipped_bucket: countBucket(planned.reduce((n, p) => n + p.plan.skipped.length, 0)),
|
|
124
|
+
suggested_bucket: countBucket(suggested),
|
|
125
|
+
}, { repo, home });
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Run the pull. Returns the exit code; every line goes through `write`.
|
|
129
|
+
*/
|
|
130
|
+
export async function runTrailPull(repo, link, opts) {
|
|
131
|
+
const write = opts.write ?? ((l) => console.error(l));
|
|
132
|
+
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
133
|
+
let code = 0;
|
|
134
|
+
// Read beside everything else: it only adds a line, and a Trail that cannot
|
|
135
|
+
// answer it costs the pull nothing.
|
|
136
|
+
const repoState = fetchRepoState(link, fetchImpl);
|
|
137
|
+
// 1. The rules. Skipped on a dry run, which writes nothing at all.
|
|
138
|
+
if (!opts.dryRun) {
|
|
139
|
+
const res = await connectBrain(repo, link, {
|
|
140
|
+
home: opts.home,
|
|
141
|
+
ids: opts.wired.length > 0 ? opts.wired : undefined,
|
|
142
|
+
fetchImpl,
|
|
143
|
+
});
|
|
144
|
+
const line = rulesLine(repo, res);
|
|
145
|
+
if (line)
|
|
146
|
+
write(line);
|
|
147
|
+
if (res.warning)
|
|
148
|
+
code = 1;
|
|
149
|
+
}
|
|
150
|
+
// 2. Accepted changes: the root CLAUDE.md, then every other context file.
|
|
151
|
+
const planned = [];
|
|
152
|
+
let accepted = 0;
|
|
153
|
+
const md = await fetchAcceptedChanges(link, fetchImpl);
|
|
154
|
+
if ("error" in md) {
|
|
155
|
+
if (!md.unsupported) {
|
|
156
|
+
write(`✗ ${md.error}`);
|
|
157
|
+
code = 1;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else if (md.changes.length > 0) {
|
|
161
|
+
const file = { kind: kindForPath(md.path || "CLAUDE.md"), path: md.path || "CLAUDE.md", changes: md.changes };
|
|
162
|
+
if (readByWired(file.kind, opts.wired)) {
|
|
163
|
+
accepted += file.changes.length;
|
|
164
|
+
planned.push({ plan: planContextFile(repo, file), source: "claude-md", kind: file.kind });
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const ctx = await fetchContextFiles(link, fetchImpl);
|
|
168
|
+
if ("error" in ctx) {
|
|
169
|
+
write(`✗ ${ctx.error}`);
|
|
170
|
+
code = 1;
|
|
171
|
+
}
|
|
172
|
+
else if (!("unsupported" in ctx)) {
|
|
173
|
+
for (const file of ctx.files) {
|
|
174
|
+
if (file.changes.length === 0 || !readByWired(file.kind, opts.wired))
|
|
175
|
+
continue;
|
|
176
|
+
accepted += file.changes.length;
|
|
177
|
+
planned.push({ plan: planContextFile(repo, file), source: "context-files", kind: file.kind });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const suggested = suggestedFor((await repoState)?.suggestions, opts.wired);
|
|
181
|
+
const waiting = suggestedLine(suggested, accepted);
|
|
182
|
+
if (accepted === 0) {
|
|
183
|
+
if (code === 0) {
|
|
184
|
+
if (waiting) {
|
|
185
|
+
write(waiting);
|
|
186
|
+
write(` review: ${reviewUrl(link.brainId)}`);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
write("· nothing accepted in Trail yet — review:");
|
|
190
|
+
write(` ${reviewUrl(link.brainId)}`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
trackPull(repo, opts.home, code === 0 ? "nothing_accepted" : "error", [], suggested.count);
|
|
194
|
+
return code;
|
|
195
|
+
}
|
|
196
|
+
const writing = planned.filter((p) => p.plan.status);
|
|
197
|
+
const changes = writing.reduce((n, p) => n + p.plan.written.length, 0);
|
|
198
|
+
if (writing.length > 0) {
|
|
199
|
+
write(`✓ ${opts.dryRun ? "would write" : "wrote"} ${changes} accepted change${changes === 1 ? "" : "s"}`);
|
|
200
|
+
const width = Math.max(30, ...writing.map((p) => p.plan.path.length)) + 2;
|
|
201
|
+
for (const { plan } of writing) {
|
|
202
|
+
const summary = changeSummary(plan.written);
|
|
203
|
+
write(` ${plan.status} ${summary ? plan.path.padEnd(width) : plan.path}${summary}`.trimEnd());
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
else if (planned.some((p) => p.plan.present.length > 0)) {
|
|
207
|
+
write("✓ every accepted change is already in these files");
|
|
208
|
+
}
|
|
209
|
+
for (const { plan } of planned) {
|
|
210
|
+
for (const s of plan.skipped) {
|
|
211
|
+
const what = s.change.kind === "edit" || s.change.kind === "add" ? `${changeSummary([s.change])} in ${plan.path}` : plan.path;
|
|
212
|
+
write(`⚠ skipped ${what} — ${s.why}; edit it in Trail, then pull again`);
|
|
213
|
+
code = 1;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (waiting) {
|
|
217
|
+
write(waiting);
|
|
218
|
+
write(` review: ${reviewUrl(link.brainId)}`);
|
|
219
|
+
}
|
|
220
|
+
if (opts.dryRun) {
|
|
221
|
+
write("· dry run — nothing written, and Trail was not told");
|
|
222
|
+
trackPull(repo, opts.home, "dry_run", planned, suggested.count);
|
|
223
|
+
return code;
|
|
224
|
+
}
|
|
225
|
+
for (const { plan } of writing) {
|
|
226
|
+
try {
|
|
227
|
+
writePlannedFile(repo, plan);
|
|
228
|
+
}
|
|
229
|
+
catch (e) {
|
|
230
|
+
write(`✗ could not write ${plan.path}: ${e instanceof Error ? e.message : e}`);
|
|
231
|
+
// Nothing from a file that was not written is reported as applied.
|
|
232
|
+
plan.written = [];
|
|
233
|
+
plan.present = [];
|
|
234
|
+
code = 1;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
// Written now or already there: either way Trail should stop listing it.
|
|
238
|
+
const done = (source) => planned.filter((p) => p.source === source).flatMap((p) => [...p.plan.written, ...p.plan.present].map((c) => c.id));
|
|
239
|
+
const told = (await markApplied(link, done("claude-md"), fetchImpl)) && (await markContextFilesApplied(link, done("context-files"), fetchImpl));
|
|
240
|
+
if (!told)
|
|
241
|
+
write("⚠ could not tell Trail which changes were written; it may still list them");
|
|
242
|
+
if (writing.length > 0)
|
|
243
|
+
write("· review with git diff, then commit");
|
|
244
|
+
const anyWritten = planned.some((p) => p.plan.status && p.plan.written.length > 0);
|
|
245
|
+
const anyPresent = planned.some((p) => p.plan.present.length > 0);
|
|
246
|
+
const anySkipped = planned.some((p) => p.plan.skipped.length > 0);
|
|
247
|
+
const outcome = anyWritten
|
|
248
|
+
? "written"
|
|
249
|
+
: anyPresent
|
|
250
|
+
? "already_present"
|
|
251
|
+
: anySkipped
|
|
252
|
+
? "skipped"
|
|
253
|
+
: "error";
|
|
254
|
+
trackPull(repo, opts.home, outcome, planned, suggested.count);
|
|
255
|
+
return code;
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=pull.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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2E,CAAC,CAAC;IAC9F,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACrE,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnF,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAClE,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAClE,MAAM,OAAO,GAAqB,UAAU;QAC1C,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,UAAU;YACV,CAAC,CAAC,iBAAiB;YACnB,CAAC,CAAC,UAAU;gBACV,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,OAAO,CAAC;IAChB,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9D,OAAO,IAAI,CAAC;AACd,CAAC"}
|
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,aAAa,CAAC;AAEhG,yDAAyD;AACzD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAYD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAMpF;AAQD;;;;;;;GAOG;AACH,wBAAgB,WAAW,IAAI,MAAM,GAAG,IAAI,CAM3C;AAgBD,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,WAAW,EAAE,OAAO,CAAC;IACrB,uDAAuD;IACvD,UAAU,EAAE,OAAO,CAAC;IACpB,iEAAiE;IACjE,aAAa,E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