@codyn06/cboard 0.2.0 → 0.3.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/api.d.ts +29 -3
- package/dist/api.js +86 -27
- package/dist/cache.d.ts +28 -0
- package/dist/cache.js +101 -0
- package/dist/cli.js +2 -1
- package/dist/docs.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/issues.js +2 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type WakeOptions } from "./wake.js";
|
|
2
|
+
import { type HeadStore } from "./cache.js";
|
|
2
3
|
import type { Contribution, Receipt, Result, Snapshot } from "./model.js";
|
|
3
4
|
export declare class GraphHttpError extends Error {
|
|
4
5
|
readonly status: number;
|
|
@@ -9,13 +10,19 @@ export declare class GraphToolError extends Error {
|
|
|
9
10
|
readonly code: string;
|
|
10
11
|
constructor(tool: string, code: string);
|
|
11
12
|
}
|
|
13
|
+
export interface ContextApiOptions extends WakeOptions {
|
|
14
|
+
/** Mirror of the heads read at the previous sync; reconcile then fetches only what changed. */
|
|
15
|
+
heads?: HeadStore;
|
|
16
|
+
}
|
|
12
17
|
export declare class ContextApi {
|
|
13
18
|
private readonly project;
|
|
14
19
|
private readonly token;
|
|
15
20
|
private readonly base;
|
|
16
21
|
private readonly mcp;
|
|
17
22
|
private readonly wake;
|
|
18
|
-
|
|
23
|
+
private readonly heads;
|
|
24
|
+
private readonly server;
|
|
25
|
+
constructor(server: string, project: string, token: string, { heads, ...wake }?: ContextApiOptions);
|
|
19
26
|
/** Retries a request while the hosted service wakes; announces that once per client. */
|
|
20
27
|
private waking;
|
|
21
28
|
private request;
|
|
@@ -30,7 +37,23 @@ export declare class ContextApi {
|
|
|
30
37
|
all(filters: Record<string, string>): Promise<Result>;
|
|
31
38
|
submit(body: Contribution): Promise<Receipt>;
|
|
32
39
|
nodeEdges(id: string): Promise<Result["edges"]>;
|
|
33
|
-
|
|
40
|
+
/** Edges of a namespace: active ones, or with `since` every head written after that revision. */
|
|
41
|
+
allEdges(namespace: string, since?: number): Promise<{
|
|
42
|
+
edges: Result["edges"];
|
|
43
|
+
revision: number;
|
|
44
|
+
}>;
|
|
45
|
+
private headKey;
|
|
46
|
+
/** Active nodes of a namespace, refreshed from the head cache by revision when there is one. */
|
|
47
|
+
nodeHeads(namespace: string): Promise<{
|
|
48
|
+
rows: Result["nodes"];
|
|
49
|
+
steady: boolean;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Active edges of a namespace, refreshed from the head cache by revision when there is one.
|
|
53
|
+
* `fresh` reads them in full: a full read hides edges of inactive nodes, so once a node is
|
|
54
|
+
* revived its unchanged edges reappear without a newer revision for a delta to find.
|
|
55
|
+
*/
|
|
56
|
+
edgeHeads(namespace: string, fresh?: boolean): Promise<Result["edges"]>;
|
|
34
57
|
}
|
|
35
58
|
/**
|
|
36
59
|
* Each contribution is one SERIALIZABLE transaction with pairwise similarity() queries, so cost
|
|
@@ -47,7 +70,10 @@ export declare function submitBatch<T>(api: ContextApi, group: T[], make: (items
|
|
|
47
70
|
items: T[];
|
|
48
71
|
receipt: Receipt;
|
|
49
72
|
}[]>;
|
|
50
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* The head cache is a mirror refreshed from the server by revision, and the server stays
|
|
75
|
+
* authoritative: a doubtful cache is dropped for a full read, never trusted.
|
|
76
|
+
*/
|
|
51
77
|
export declare function reconcile(api: ContextApi, snapshot: Snapshot, namespace: string, supersede?: boolean,
|
|
52
78
|
/** Nodes outside the snapshot (other namespaces) that edges may point to, by client key. */
|
|
53
79
|
anchors?: Map<string, string>): Promise<{
|
package/dist/api.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import { WAKE_BUDGET_MS, retryWake } from "./wake.js";
|
|
3
|
+
import { readHeads } from "./cache.js";
|
|
3
4
|
export class GraphHttpError extends Error {
|
|
4
5
|
status;
|
|
5
6
|
constructor(status) {
|
|
@@ -23,9 +24,13 @@ export class ContextApi {
|
|
|
23
24
|
base;
|
|
24
25
|
mcp;
|
|
25
26
|
wake;
|
|
26
|
-
|
|
27
|
+
heads;
|
|
28
|
+
server;
|
|
29
|
+
constructor(server, project, token, { heads, ...wake } = {}) {
|
|
27
30
|
this.project = project;
|
|
28
31
|
this.token = token;
|
|
32
|
+
this.heads = heads;
|
|
33
|
+
this.server = server;
|
|
29
34
|
const url = new URL(server);
|
|
30
35
|
if (url.username ||
|
|
31
36
|
url.password ||
|
|
@@ -118,13 +123,14 @@ export class ContextApi {
|
|
|
118
123
|
const nodes = [];
|
|
119
124
|
const edges = new Map();
|
|
120
125
|
let cursor;
|
|
121
|
-
|
|
126
|
+
// Pages are separate snapshots: the oldest one is the revision the whole read is good for.
|
|
127
|
+
let revision = Number.POSITIVE_INFINITY;
|
|
122
128
|
const seen = new Set();
|
|
123
129
|
do {
|
|
124
130
|
const page = await this.query({ ...filters, limit: "300", ...(cursor ? { cursor } : {}) });
|
|
125
131
|
nodes.push(...page.nodes);
|
|
126
132
|
page.edges.forEach((e) => edges.set(e.id, e));
|
|
127
|
-
revision = page.revision;
|
|
133
|
+
revision = Math.min(revision, page.revision);
|
|
128
134
|
cursor = page.nextCursor;
|
|
129
135
|
if (page.truncated && !cursor)
|
|
130
136
|
throw new Error("Graph response truncated without continuation");
|
|
@@ -157,13 +163,21 @@ export class ContextApi {
|
|
|
157
163
|
} while (cursor);
|
|
158
164
|
return edges;
|
|
159
165
|
}
|
|
160
|
-
|
|
166
|
+
/** Edges of a namespace: active ones, or with `since` every head written after that revision. */
|
|
167
|
+
async allEdges(namespace, since) {
|
|
161
168
|
const edges = [];
|
|
162
169
|
let cursor;
|
|
170
|
+
let revision = Number.POSITIVE_INFINITY;
|
|
163
171
|
const seen = new Set();
|
|
164
172
|
do {
|
|
165
|
-
const page = await this.request(`/edges?${new URLSearchParams({
|
|
173
|
+
const page = await this.request(`/edges?${new URLSearchParams({
|
|
174
|
+
namespace,
|
|
175
|
+
limit: "300",
|
|
176
|
+
...(since === undefined ? {} : { include_inactive: "true", since: String(since) }),
|
|
177
|
+
...(cursor ? { cursor } : {}),
|
|
178
|
+
})}`);
|
|
166
179
|
edges.push(...page.edges);
|
|
180
|
+
revision = Math.min(revision, page.revision);
|
|
167
181
|
cursor = page.nextCursor;
|
|
168
182
|
if (page.truncated && !cursor)
|
|
169
183
|
throw new Error("Edge list truncated without continuation");
|
|
@@ -172,7 +186,31 @@ export class ContextApi {
|
|
|
172
186
|
if (cursor)
|
|
173
187
|
seen.add(cursor);
|
|
174
188
|
} while (cursor);
|
|
175
|
-
return edges;
|
|
189
|
+
return { edges, revision };
|
|
190
|
+
}
|
|
191
|
+
headKey(kind, namespace) {
|
|
192
|
+
return `${kind}|${this.server}|${this.project}|${namespace}`;
|
|
193
|
+
}
|
|
194
|
+
/** Active nodes of a namespace, refreshed from the head cache by revision when there is one. */
|
|
195
|
+
nodeHeads(namespace) {
|
|
196
|
+
return readHeads(this.heads, this.headKey("nodes", namespace), async (since) => {
|
|
197
|
+
const read = await this.all(since === undefined
|
|
198
|
+
? { namespace }
|
|
199
|
+
: { namespace, include_inactive: "true", since: String(since) });
|
|
200
|
+
return { rows: read.nodes, revision: read.revision };
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Active edges of a namespace, refreshed from the head cache by revision when there is one.
|
|
205
|
+
* `fresh` reads them in full: a full read hides edges of inactive nodes, so once a node is
|
|
206
|
+
* revived its unchanged edges reappear without a newer revision for a delta to find.
|
|
207
|
+
*/
|
|
208
|
+
async edgeHeads(namespace, fresh = false) {
|
|
209
|
+
const read = await readHeads(this.heads, this.headKey("edges", namespace), async (since) => {
|
|
210
|
+
const read = await this.allEdges(namespace, since);
|
|
211
|
+
return { rows: read.edges, revision: read.revision };
|
|
212
|
+
}, fresh);
|
|
213
|
+
return read.rows;
|
|
176
214
|
}
|
|
177
215
|
}
|
|
178
216
|
/**
|
|
@@ -254,13 +292,15 @@ function stable(value) {
|
|
|
254
292
|
: v;
|
|
255
293
|
return JSON.stringify(sort(value));
|
|
256
294
|
}
|
|
295
|
+
/** A commit-only change is not a content change (#145); the repository node keeps it for the lag brief. */
|
|
296
|
+
const withoutCommit = (locators) => locators.map((p) => ({ ...p, commit: undefined }));
|
|
257
297
|
const comparable = (n) => stable([
|
|
258
298
|
n.title,
|
|
259
299
|
n.body,
|
|
260
300
|
n.status ?? null,
|
|
261
301
|
n.properties,
|
|
262
302
|
n.derivation,
|
|
263
|
-
n.
|
|
303
|
+
n.type === "repository" ? n.provenance : withoutCommit(n.provenance),
|
|
264
304
|
]);
|
|
265
305
|
const edgeKey = (e) => stable([
|
|
266
306
|
e.type,
|
|
@@ -269,27 +309,43 @@ const edgeKey = (e) => stable([
|
|
|
269
309
|
e.properties.contextNamespace ?? null,
|
|
270
310
|
e.type === "amends" ? (e.properties.scope ?? null) : null,
|
|
271
311
|
]);
|
|
272
|
-
/**
|
|
312
|
+
/** Up to this many absent keys are looked up one by one; more use the project-wide types scan. */
|
|
313
|
+
const KEY_LOOKUP_MAX = 50;
|
|
314
|
+
/**
|
|
315
|
+
* The head cache is a mirror refreshed from the server by revision, and the server stays
|
|
316
|
+
* authoritative: a doubtful cache is dropped for a full read, never trusted.
|
|
317
|
+
*/
|
|
273
318
|
export async function reconcile(api, snapshot, namespace, supersede = true,
|
|
274
319
|
/** Nodes outside the snapshot (other namespaces) that edges may point to, by client key. */
|
|
275
320
|
anchors = new Map()) {
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
//
|
|
280
|
-
//
|
|
321
|
+
// Active heads only: history is not re-downloaded on every sync (#145).
|
|
322
|
+
const { rows: existing, steady } = await api.nodeHeads(namespace);
|
|
323
|
+
const byKey = new Map(existing.map((n) => [n.clientKey, n]));
|
|
324
|
+
// Absent keys are new, superseded/withdrawn in this namespace (revived below), or legacy nodes
|
|
325
|
+
// outside the namespace with the same client key. A few are looked up by key; many use one
|
|
326
|
+
// project-wide scan of the snapshot's node types, so a first sync costs pages, not N requests.
|
|
281
327
|
const absent = new Set(snapshot.nodes.filter((n) => !byKey.has(n.clientKey)).map((n) => n.clientKey));
|
|
282
328
|
if (absent.size) {
|
|
283
|
-
const
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
329
|
+
const candidates = new Map();
|
|
330
|
+
const offer = (n) => {
|
|
331
|
+
if (absent.has(n.clientKey))
|
|
332
|
+
candidates.set(n.clientKey, [...(candidates.get(n.clientKey) ?? []), n]);
|
|
333
|
+
};
|
|
334
|
+
if (absent.size <= KEY_LOOKUP_MAX)
|
|
335
|
+
for (const client_key of absent)
|
|
336
|
+
(await api.all({ client_key, include_inactive: "true" })).nodes.forEach(offer);
|
|
337
|
+
else {
|
|
338
|
+
const types = [...new Set(snapshot.nodes.map((n) => n.type))].join(",");
|
|
339
|
+
(await api.all({ types, include_inactive: "true" })).nodes.forEach(offer);
|
|
340
|
+
}
|
|
341
|
+
for (const [key, list] of candidates) {
|
|
342
|
+
const inside = list.filter((n) => n.namespace === namespace);
|
|
343
|
+
const pool = inside.length ? inside : list;
|
|
344
|
+
const [only] = pool;
|
|
345
|
+
if (pool.length > 1 || !only)
|
|
346
|
+
throw new Error(`Ambiguous client key ${key}`);
|
|
347
|
+
byKey.set(key, only);
|
|
348
|
+
}
|
|
293
349
|
}
|
|
294
350
|
const ids = new Map([...anchors, ...[...byKey].map(([key, n]) => [key, n.id])]);
|
|
295
351
|
const desired = new Set(snapshot.nodes.map((n) => n.clientKey));
|
|
@@ -311,7 +367,7 @@ anchors = new Map()) {
|
|
|
311
367
|
});
|
|
312
368
|
}
|
|
313
369
|
if (supersede)
|
|
314
|
-
for (const old of existing
|
|
370
|
+
for (const old of existing)
|
|
315
371
|
if (!desired.has(old.clientKey) && old.lifecycle === "active")
|
|
316
372
|
revisions.push({
|
|
317
373
|
nodeId: old.id,
|
|
@@ -347,7 +403,10 @@ anchors = new Map()) {
|
|
|
347
403
|
for (const batch of chunks(revisions, (revisions) => ({ ...empty(), revisions })))
|
|
348
404
|
contributions += (await submitBatch(api, batch, (revisions) => ({ ...empty(), revisions })))
|
|
349
405
|
.length;
|
|
350
|
-
|
|
406
|
+
// A revived node (here or elsewhere) can bring back edges no delta reports: read them in full.
|
|
407
|
+
const revived = !steady ||
|
|
408
|
+
snapshot.nodes.some((n) => (byKey.get(n.clientKey)?.lifecycle ?? "active") !== "active");
|
|
409
|
+
const currentEdges = new Map((await api.edgeHeads(namespace, revived)).map((e) => [e.id, e]));
|
|
351
410
|
const desiredEdges = snapshot.edges.map((e) => {
|
|
352
411
|
const from = ids.get(e.from), to = ids.get(e.to);
|
|
353
412
|
if (!from || !to)
|
|
@@ -404,8 +463,8 @@ anchors = new Map()) {
|
|
|
404
463
|
for (const edge of edges) {
|
|
405
464
|
const old = activeByKey.get(edgeKey(edge));
|
|
406
465
|
if (old &&
|
|
407
|
-
stable([old.provenance, old.derivation, old.properties]) !==
|
|
408
|
-
stable([edge.provenance, edge.derivation, edge.properties]))
|
|
466
|
+
stable([withoutCommit(old.provenance), old.derivation, old.properties]) !==
|
|
467
|
+
stable([withoutCommit(edge.provenance), edge.derivation, edge.properties]))
|
|
409
468
|
updated.push({
|
|
410
469
|
edgeId: old.id,
|
|
411
470
|
expectedRevision: old.revision,
|
package/dist/cache.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Key-value store for the heads read at the previous sync (#145). */
|
|
2
|
+
export interface HeadStore {
|
|
3
|
+
get(key: string): string | undefined;
|
|
4
|
+
set(key: string, value: string): void;
|
|
5
|
+
}
|
|
6
|
+
/** One file per key under the user cache directory; a missing or unreadable file is a cache miss. */
|
|
7
|
+
export declare function fileHeadStore(dir?: string): HeadStore;
|
|
8
|
+
interface Head {
|
|
9
|
+
id: string;
|
|
10
|
+
revision: number;
|
|
11
|
+
lifecycle: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Active heads for `key`. The stored copy is a mirror refreshed from the server by revision: only
|
|
15
|
+
* rows written after the stored revision are fetched and merged (higher row revision wins).
|
|
16
|
+
* Anything doubtful - no or invalid entry, a server that rejects `since`, a server revision
|
|
17
|
+
* behind the stored one, or `fresh` - reads everything again.
|
|
18
|
+
* `steady` is true only for a delta read that brought back no row: every active row it added is
|
|
19
|
+
* new at revision 1. Callers use it to tell when visibility that depends on these rows changed.
|
|
20
|
+
*/
|
|
21
|
+
export declare function readHeads<T extends Head>(store: HeadStore | undefined, key: string, fetch: (since?: number) => Promise<{
|
|
22
|
+
rows: T[];
|
|
23
|
+
revision: number;
|
|
24
|
+
}>, fresh?: boolean): Promise<{
|
|
25
|
+
rows: T[];
|
|
26
|
+
steady: boolean;
|
|
27
|
+
}>;
|
|
28
|
+
export {};
|
package/dist/cache.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
/** One file per key under the user cache directory; a missing or unreadable file is a cache miss. */
|
|
6
|
+
export function fileHeadStore(dir = join(process.env.XDG_CACHE_HOME || process.env.LOCALAPPDATA || join(homedir(), ".cache"), "cboard", "sync")) {
|
|
7
|
+
const file = (key) => join(dir, `${createHash("sha256").update(key).digest("hex")}.json`);
|
|
8
|
+
return {
|
|
9
|
+
get(key) {
|
|
10
|
+
try {
|
|
11
|
+
return readFileSync(file(key), "utf8");
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
set(key, value) {
|
|
18
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
19
|
+
const target = file(key);
|
|
20
|
+
const tmp = `${target}.${randomUUID()}.tmp`;
|
|
21
|
+
try {
|
|
22
|
+
writeFileSync(tmp, value, { mode: 0o600 });
|
|
23
|
+
renameSync(tmp, target);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
rmSync(tmp, { force: true });
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function parse(raw) {
|
|
33
|
+
if (raw === undefined)
|
|
34
|
+
return undefined;
|
|
35
|
+
try {
|
|
36
|
+
const value = JSON.parse(raw);
|
|
37
|
+
if (value?.v === 1 &&
|
|
38
|
+
typeof value.revision === "number" &&
|
|
39
|
+
Number.isInteger(value.revision) &&
|
|
40
|
+
value.revision >= 0 &&
|
|
41
|
+
Array.isArray(value.rows) &&
|
|
42
|
+
value.rows.every((r) => !!r &&
|
|
43
|
+
typeof r === "object" &&
|
|
44
|
+
typeof r.id === "string" &&
|
|
45
|
+
Number.isInteger(r.revision) &&
|
|
46
|
+
typeof r.lifecycle === "string"))
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
/* unparseable: read in full */
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
/** A 400 is how a server without `since` support answers (duck-typed: api.ts imports this module). */
|
|
55
|
+
const rejectsSince = (error) => error instanceof Error && error.status === 400;
|
|
56
|
+
/**
|
|
57
|
+
* Active heads for `key`. The stored copy is a mirror refreshed from the server by revision: only
|
|
58
|
+
* rows written after the stored revision are fetched and merged (higher row revision wins).
|
|
59
|
+
* Anything doubtful - no or invalid entry, a server that rejects `since`, a server revision
|
|
60
|
+
* behind the stored one, or `fresh` - reads everything again.
|
|
61
|
+
* `steady` is true only for a delta read that brought back no row: every active row it added is
|
|
62
|
+
* new at revision 1. Callers use it to tell when visibility that depends on these rows changed.
|
|
63
|
+
*/
|
|
64
|
+
export async function readHeads(store, key, fetch, fresh = false) {
|
|
65
|
+
const cached = fresh ? undefined : parse(store?.get(key));
|
|
66
|
+
let result;
|
|
67
|
+
let merged = new Map();
|
|
68
|
+
if (cached) {
|
|
69
|
+
try {
|
|
70
|
+
const delta = await fetch(cached.revision);
|
|
71
|
+
if (delta.revision >= cached.revision) {
|
|
72
|
+
result = delta;
|
|
73
|
+
merged = new Map(cached.rows.map((r) => [r.id, r]));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
if (!rejectsSince(error))
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
let steady = !!result;
|
|
82
|
+
result ??= await fetch();
|
|
83
|
+
for (const row of result.rows) {
|
|
84
|
+
const old = merged.get(row.id);
|
|
85
|
+
if (old && row.revision < old.revision)
|
|
86
|
+
continue;
|
|
87
|
+
// Active, unknown and past revision 1: revived (or never cached), so dependent reads may lag.
|
|
88
|
+
if (row.lifecycle === "active" && !old && row.revision > 1)
|
|
89
|
+
steady = false;
|
|
90
|
+
merged.set(row.id, row);
|
|
91
|
+
}
|
|
92
|
+
const rows = [...merged.values()].filter((r) => r.lifecycle === "active");
|
|
93
|
+
const entry = { v: 1, revision: result.revision, rows };
|
|
94
|
+
try {
|
|
95
|
+
store?.set(key, JSON.stringify(entry));
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
/* an unwritable cache only costs a full read next time */
|
|
99
|
+
}
|
|
100
|
+
return { rows, steady };
|
|
101
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -5,6 +5,7 @@ import { mkdir, writeFile, rename } from "node:fs/promises";
|
|
|
5
5
|
import { dirname, isAbsolute, posix, relative, resolve, sep, win32 } from "node:path";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
import { ContextApi, reconcile } from "./api.js";
|
|
8
|
+
import { fileHeadStore } from "./cache.js";
|
|
8
9
|
import { codeConfig, extract } from "./extract.js";
|
|
9
10
|
export function options(argv) {
|
|
10
11
|
const result = {};
|
|
@@ -136,7 +137,7 @@ export async function sync(argv) {
|
|
|
136
137
|
const args = options(argv);
|
|
137
138
|
const root = resolve(args.repo ?? process.cwd());
|
|
138
139
|
const { project, token, server } = resolveSync(args, root);
|
|
139
|
-
const api = new ContextApi(server, project, token);
|
|
140
|
+
const api = new ContextApi(server, project, token, { heads: fileHeadStore() });
|
|
140
141
|
const snapshot = await extract(root, [], codeConfig(root));
|
|
141
142
|
const result = await reconcile(api, snapshot, snapshot.namespace);
|
|
142
143
|
const state = args.state
|
package/dist/docs.js
CHANGED
|
@@ -2,6 +2,7 @@ import { execFileSync } from "node:child_process";
|
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { posix, resolve } from "node:path";
|
|
4
4
|
import { ContextApi, reconcile } from "./api.js";
|
|
5
|
+
import { fileHeadStore } from "./cache.js";
|
|
5
6
|
import { options, resolveSync } from "./cli.js";
|
|
6
7
|
import { repository } from "./extract.js";
|
|
7
8
|
import { globMatcher } from "./languages.js";
|
|
@@ -232,7 +233,7 @@ export async function docsSync(argv) {
|
|
|
232
233
|
const root = resolve(args.repo ?? process.cwd());
|
|
233
234
|
const { project, token, server } = resolveSync(args, root);
|
|
234
235
|
const snapshot = extractDocs(root, docsConfig(root));
|
|
235
|
-
const result = await reconcile(new ContextApi(server, project, token), snapshot, snapshot.namespace);
|
|
236
|
+
const result = await reconcile(new ContextApi(server, project, token, { heads: fileHeadStore() }), snapshot, snapshot.namespace);
|
|
236
237
|
console.log(JSON.stringify({
|
|
237
238
|
commit: snapshot.commit,
|
|
238
239
|
nodes: snapshot.nodes.length,
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/issues.js
CHANGED
|
@@ -3,6 +3,7 @@ import { createHash } from "node:crypto";
|
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import { promisify } from "node:util";
|
|
5
5
|
import { ContextApi, reconcile } from "./api.js";
|
|
6
|
+
import { fileHeadStore } from "./cache.js";
|
|
6
7
|
import { resolveSync } from "./cli.js";
|
|
7
8
|
import { repository } from "./extract.js";
|
|
8
9
|
const run = promisify(execFile);
|
|
@@ -133,6 +134,6 @@ export async function issuesSync(argv, source = githubSource) {
|
|
|
133
134
|
const args = issuesSyncOptions(argv);
|
|
134
135
|
const root = resolve(args.repo ?? process.cwd());
|
|
135
136
|
const { project, token, server } = resolveSync(args, root);
|
|
136
|
-
const result = await runIssuesSync(new ContextApi(server, project, token), repository(root), source, { state: args.state, limit: args.limit });
|
|
137
|
+
const result = await runIssuesSync(new ContextApi(server, project, token, { heads: fileHeadStore() }), repository(root), source, { state: args.state, limit: args.limit });
|
|
137
138
|
console.log(JSON.stringify(result));
|
|
138
139
|
}
|