@treeseed/dsh-chapters 0.1.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.
Files changed (119) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +644 -0
  3. package/cordis.patch.yml +88 -0
  4. package/docs/architecture.md +460 -0
  5. package/docs/contract.md +375 -0
  6. package/docs/development.md +437 -0
  7. package/docs/host-compaction-seam.md +117 -0
  8. package/docs/knowledge-repo.md +730 -0
  9. package/docs/provider.md +98 -0
  10. package/docs/verify.md +200 -0
  11. package/lib/archive.d.ts +88 -0
  12. package/lib/archive.js +114 -0
  13. package/lib/archive.js.map +1 -0
  14. package/lib/arrival.d.ts +23 -0
  15. package/lib/arrival.js +86 -0
  16. package/lib/arrival.js.map +1 -0
  17. package/lib/artifact-query.d.ts +53 -0
  18. package/lib/artifact-query.js +130 -0
  19. package/lib/artifact-query.js.map +1 -0
  20. package/lib/client.js +234 -0
  21. package/lib/client.js.map +1 -0
  22. package/lib/commands.d.ts +28 -0
  23. package/lib/commands.js +305 -0
  24. package/lib/commands.js.map +1 -0
  25. package/lib/compose.d.ts +30 -0
  26. package/lib/compose.js +131 -0
  27. package/lib/compose.js.map +1 -0
  28. package/lib/continue-core.d.ts +153 -0
  29. package/lib/continue-core.js +252 -0
  30. package/lib/continue-core.js.map +1 -0
  31. package/lib/engine-core.d.ts +219 -0
  32. package/lib/engine-core.js +405 -0
  33. package/lib/engine-core.js.map +1 -0
  34. package/lib/engine.d.ts +211 -0
  35. package/lib/engine.js +571 -0
  36. package/lib/engine.js.map +1 -0
  37. package/lib/enrich-queue.d.ts +66 -0
  38. package/lib/enrich-queue.js +100 -0
  39. package/lib/enrich-queue.js.map +1 -0
  40. package/lib/enrich-store.d.ts +31 -0
  41. package/lib/enrich-store.js +103 -0
  42. package/lib/enrich-store.js.map +1 -0
  43. package/lib/enrich-wire.d.ts +73 -0
  44. package/lib/enrich-wire.js +209 -0
  45. package/lib/enrich-wire.js.map +1 -0
  46. package/lib/enrich.d.ts +73 -0
  47. package/lib/enrich.js +150 -0
  48. package/lib/enrich.js.map +1 -0
  49. package/lib/gitops.d.ts +107 -0
  50. package/lib/gitops.js +539 -0
  51. package/lib/gitops.js.map +1 -0
  52. package/lib/index.d.ts +81 -0
  53. package/lib/index.js +305 -0
  54. package/lib/index.js.map +1 -0
  55. package/lib/indexing.d.ts +85 -0
  56. package/lib/indexing.js +212 -0
  57. package/lib/indexing.js.map +1 -0
  58. package/lib/injections.d.ts +66 -0
  59. package/lib/injections.js +83 -0
  60. package/lib/injections.js.map +1 -0
  61. package/lib/notice.d.ts +60 -0
  62. package/lib/notice.js +84 -0
  63. package/lib/notice.js.map +1 -0
  64. package/lib/provider.d.ts +44 -0
  65. package/lib/provider.js +66 -0
  66. package/lib/provider.js.map +1 -0
  67. package/lib/redact.d.ts +24 -0
  68. package/lib/redact.js +85 -0
  69. package/lib/redact.js.map +1 -0
  70. package/lib/registry.d.ts +120 -0
  71. package/lib/registry.js +130 -0
  72. package/lib/registry.js.map +1 -0
  73. package/lib/render.d.ts +40 -0
  74. package/lib/render.js +280 -0
  75. package/lib/render.js.map +1 -0
  76. package/lib/repo.d.ts +78 -0
  77. package/lib/repo.js +184 -0
  78. package/lib/repo.js.map +1 -0
  79. package/lib/rules-commands.d.ts +24 -0
  80. package/lib/rules-commands.js +138 -0
  81. package/lib/rules-commands.js.map +1 -0
  82. package/lib/rules.d.ts +90 -0
  83. package/lib/rules.js +185 -0
  84. package/lib/rules.js.map +1 -0
  85. package/lib/search.d.ts +48 -0
  86. package/lib/search.js +152 -0
  87. package/lib/search.js.map +1 -0
  88. package/lib/signature.d.ts +28 -0
  89. package/lib/signature.js +149 -0
  90. package/lib/signature.js.map +1 -0
  91. package/lib/store.d.ts +130 -0
  92. package/lib/store.js +235 -0
  93. package/lib/store.js.map +1 -0
  94. package/lib/sync.d.ts +183 -0
  95. package/lib/sync.js +719 -0
  96. package/lib/sync.js.map +1 -0
  97. package/lib/tools.d.ts +84 -0
  98. package/lib/tools.js +581 -0
  99. package/lib/tools.js.map +1 -0
  100. package/lib/treedx/client.d.ts +57 -0
  101. package/lib/treedx/client.js +82 -0
  102. package/lib/treedx/client.js.map +1 -0
  103. package/lib/treedx/provider.d.ts +39 -0
  104. package/lib/treedx/provider.js +479 -0
  105. package/lib/treedx/provider.js.map +1 -0
  106. package/lib/treedx/state.d.ts +27 -0
  107. package/lib/treedx/state.js +65 -0
  108. package/lib/treedx/state.js.map +1 -0
  109. package/lib/types.d.ts +100 -0
  110. package/lib/types.js +19 -0
  111. package/lib/types.js.map +1 -0
  112. package/lib/vocabulary.d.ts +41 -0
  113. package/lib/vocabulary.js +118 -0
  114. package/lib/vocabulary.js.map +1 -0
  115. package/package.json +132 -0
  116. package/presets/chapters/agent.cordis.yml +272 -0
  117. package/presets/chapters/preset.yml +3 -0
  118. package/presets/probe-roots/agent.cordis.yml +11 -0
  119. package/presets/probe-roots/preset.yml +3 -0
package/lib/gitops.js ADDED
@@ -0,0 +1,539 @@
1
+ /**
2
+ * Git operations over isomorphic-git (knowledge-repo.md §3.2): pure-JS, no
3
+ * git binary, no native deps. Every operation takes explicit dir/remote —
4
+ * no global state — and every failure comes back as `{ok, detail}` because
5
+ * the sync layer is best-effort by rule: a remote failure must never break
6
+ * the conversation path (record §5.3).
7
+ *
8
+ * Fast-forward ONLY (§3.3): append-only content means divergence is separate
9
+ * files and ff always succeeds; a non-ff state is an error, never a force.
10
+ * The local repo is the mirror (transport, not storage, §3.1) — the
11
+ * workspace store stays the read path's source of truth.
12
+ *
13
+ * API notes (isomorphic-git 1.42, verified against the installed types):
14
+ * `http` is a client object with a `request` fn (node default from
15
+ * `isomorphic-git/http/node`); the remote `url` is a SEPARATE argument;
16
+ * auth rides `onAuth`; statusMatrix rows are
17
+ * `[filepath, head, workdir, stage]` of numeric literals.
18
+ */
19
+ import * as git from 'isomorphic-git';
20
+ import { randomUUID } from 'node:crypto';
21
+ import nodeHttp from 'isomorphic-git/http/node';
22
+ import * as fs from 'node:fs';
23
+ import * as nodefs from 'node:fs/promises';
24
+ import os from 'node:os';
25
+ import path from 'node:path';
26
+ const authOf = (r) => r.token !== undefined ? () => ({ username: 'dsh-chapters', password: r.token }) : undefined;
27
+ /**
28
+ * Classify an isomorphic-git transport error. A rejected credential (HTTP
29
+ * 401/403, or the auth-phrase fallback) MUST come back as `auth`, not the
30
+ * generic `network` the catch blocks used to assume — otherwise /chapters-status
31
+ * tells the user "remote unreachable" when the truth is "your token is bad,
32
+ * re-link it". 404/401-on-repo maps to not_found (private-but-missing vs
33
+ * forbidden are genuinely ambiguous over smart HTTP; auth wins when a token
34
+ * was actually sent).
35
+ */
36
+ export function classifyGitTransportError(error) {
37
+ const e = error;
38
+ const status = e?.statusCode ?? e?.status ?? e?.data?.statusCode;
39
+ const msg = String(e?.message ?? error);
40
+ if (status === 404 || /HTTP Error: 404|repository not found/i.test(msg))
41
+ return { code: 'not_found', detail: msg };
42
+ if (status === 401 || status === 403 || /HTTP Error: 40[13]|authentication|could not read Username|invalid credentials|Unauthorized|Forbidden|access denied|Permission denied/i.test(msg)) {
43
+ return { code: 'auth', detail: msg };
44
+ }
45
+ return { code: 'network', detail: msg };
46
+ }
47
+ const headOf = (dir) => path.join(dir, '.git', 'HEAD');
48
+ const isRepo = async (dir) => {
49
+ try {
50
+ await nodefs.access(headOf(dir));
51
+ return true;
52
+ }
53
+ catch {
54
+ return false;
55
+ }
56
+ };
57
+ /**
58
+ * Ensure a clone exists at `dir` for `remote`. A non-repo dir is cloned
59
+ * (single branch, main); an existing repo is left alone — pull/ff is the
60
+ * caller's step. A non-empty non-repo dir is dead transport: moved aside
61
+ * (`<dir>.stale-<ts>`, contents preserved) and cloned fresh. The r39-era e2e
62
+ * failure class was exactly this residue making every later clone refuse;
63
+ * renaming aside is strictly weaker than what the diverged-rebuild path
64
+ * already does (removeMirror rm -rf) — the mirror is transport, the store
65
+ * is truth (§3.1).
66
+ */
67
+ export async function ensureClone(dir, remote, opts = {}) {
68
+ try {
69
+ if (await isRepo(dir)) {
70
+ const remotes = await git.listRemotes({ fs, dir }).catch(() => []);
71
+ const origin = remotes.find((r) => r.remote === 'origin');
72
+ if (origin !== undefined && origin.url !== remote.url) {
73
+ return { ok: false, code: 'origin-mismatch', detail: `mirror origin is ${origin.url}, the project's remote is ${remote.url}` };
74
+ }
75
+ if (origin === undefined && remote.url !== '')
76
+ await git.addRemote({ fs, dir, remote: 'origin', url: remote.url, force: true }).catch(() => undefined);
77
+ return { ok: true, detail: 'already a repo' };
78
+ }
79
+ const entries = await nodefs.readdir(dir).catch(() => []);
80
+ let movedAside = '';
81
+ if (entries.length > 0) {
82
+ const stamp = new Date().toISOString().replace(/[:.]/g, '-');
83
+ movedAside = `${path.basename(dir)}.stale-${stamp}`;
84
+ await nodefs.rename(dir, `${dir}.stale-${stamp}`);
85
+ await nodefs.mkdir(path.dirname(dir), { recursive: true });
86
+ }
87
+ await git.clone({ fs, http: nodeHttp, dir, url: remote.url, singleBranch: true, onAuth: authOf(remote) });
88
+ // Cloning an EMPTY remote leaves the clone on isomorphic-git's fallback
89
+ // branch ('master') — real finding from the first real-HTTP sync test.
90
+ // Align HEAD to the expected branch while it is still unborn (no commit
91
+ // to move); a born branch stays untouched.
92
+ const branch = opts.defaultBranch ?? 'main';
93
+ const current = await git.currentBranch({ fs, dir, fullname: false });
94
+ if (current !== branch && (await git.resolveRef({ fs, dir, ref: 'HEAD' }).catch(() => null)) === null) {
95
+ await nodefs.writeFile(headOf(dir), `ref: refs/heads/${branch}\n`);
96
+ }
97
+ return { ok: true, detail: 'cloned', changed: true };
98
+ }
99
+ catch (error) {
100
+ const cls = classifyGitTransportError(error);
101
+ return { ok: false, code: cls.code, detail: `clone: ${cls.detail}` };
102
+ }
103
+ }
104
+ /**
105
+ * Commit every workdir file whose content differs from HEAD. Does not trust
106
+ * `statusMatrix` — on isomorphic-git 1.42 it reports stale index state right
107
+ * after a commit (verified: a clean repo still reports [1,1,1]); the
108
+ * workdir-vs-HEAD content comparison is the honest diff. Untracked dotfiles
109
+ * and .git are out of scope (the mirror holds knowledge files only).
110
+ */
111
+ export async function stageAllAndCommit(dir, message, author) {
112
+ try {
113
+ const headFiles = await git.listFiles({ fs, dir, ref: 'HEAD' }).catch(() => []);
114
+ const headOid = await git.resolveRef({ fs, dir, ref: 'HEAD' }).catch(() => null);
115
+ const head = new Map();
116
+ for (const f of headFiles) {
117
+ // HEAD's OWN content — reading the workdir here (as an earlier cut did)
118
+ // compares the disk against itself, so modifications to TRACKED files
119
+ // are permanently invisible to the commit: P2 enrichment writes would
120
+ // never travel. Measured by the two-machine enrichment test (r37).
121
+ let text = null;
122
+ if (headOid !== null) {
123
+ const r = await git.readBlob({ fs, dir, oid: headOid, filepath: f }).catch(() => null);
124
+ if (r !== null)
125
+ text = Buffer.from(r.blob).toString('utf8');
126
+ }
127
+ head.set(f, text);
128
+ }
129
+ const changed = [];
130
+ const walk = (rel) => {
131
+ for (const e of fs.readdirSync(path.join(dir, rel), { withFileTypes: true })) {
132
+ if (e.name === '.git' || e.name.startsWith('.'))
133
+ continue;
134
+ const relPath = rel === '' ? e.name : path.join(rel, e.name);
135
+ if (e.isDirectory())
136
+ walk(relPath);
137
+ else {
138
+ const content = fs.readFileSync(path.join(dir, relPath), 'utf8');
139
+ const prev = head.get(relPath) ?? null;
140
+ if (prev === null || prev !== content)
141
+ changed.push(relPath);
142
+ }
143
+ }
144
+ };
145
+ walk('');
146
+ if (changed.length === 0)
147
+ return { ok: true, detail: 'nothing to commit' };
148
+ for (const f of changed) {
149
+ await git.add({ fs, dir, filepath: f });
150
+ }
151
+ await git.commit({ fs, dir, message, author, committer: author });
152
+ return { ok: true, detail: `committed ${changed.length} path(s)`, changed: true };
153
+ }
154
+ catch (error) {
155
+ return { ok: false, detail: `commit: ${String(error?.message ?? error)}` };
156
+ }
157
+ }
158
+ /** The branch HEAD points at (falls back to the expected default). */
159
+ async function branchOf(dir, fallback) {
160
+ return (await git.currentBranch({ fs, dir, fullname: false })) || fallback;
161
+ }
162
+ /** Fetch the remote and fast-forward the local branch. ff-only, always. */
163
+ export async function pullFastForward(dir, remote, opts = {}) {
164
+ const branch = await branchOf(dir, opts.defaultBranch ?? 'main');
165
+ const ref = `refs/heads/${branch}`;
166
+ try {
167
+ await git.fetch({ fs, http: nodeHttp, dir, url: remote.url, singleBranch: true, onAuth: authOf(remote) });
168
+ const remoteRef = await git.resolveRef({ fs, dir, ref: `refs/remotes/origin/${branch}` }).catch(() => null);
169
+ const localRef = await git.resolveRef({ fs, dir, ref }).catch(() => null);
170
+ if (remoteRef === null || localRef === null || remoteRef === localRef) {
171
+ return { ok: true, detail: 'up to date (nothing to fast-forward)' };
172
+ }
173
+ // ff-only guard, all three cases (the direction here was inverted once —
174
+ // isDescendent({oid, ancestor}) asks whether OID's history CONTAINS
175
+ // ancestor): remote ahead ⇒ fast-forward; local ahead ⇒ nothing to do
176
+ // (push will ship it); neither contains the other ⇒ genuine divergence.
177
+ const remoteAhead = await git.isDescendent({ fs, dir, oid: remoteRef, ancestor: localRef });
178
+ if (!remoteAhead) {
179
+ const localAhead = await git.isDescendent({ fs, dir, oid: localRef, ancestor: remoteRef });
180
+ if (localAhead)
181
+ return { ok: true, detail: 'nothing to fast-forward (local ahead; push will ship it)' };
182
+ return { ok: false, code: 'diverged', detail: 'diverged — fast-forward impossible (the mirror diverged from the remote; rebuild will recover)' };
183
+ }
184
+ await git.fastForward({ fs, http: nodeHttp, dir, url: remote.url, ref, onAuth: authOf(remote) });
185
+ return { ok: true, detail: 'fast-forwarded', changed: true };
186
+ }
187
+ catch (error) {
188
+ const cls = classifyGitTransportError(error);
189
+ return { ok: false, code: cls.code, detail: `pull failed: ${cls.detail}` };
190
+ }
191
+ }
192
+ // ------------------------------------------------------------- local-path upstreams
193
+ // A local-path upstream ('/srv/git/kb.git', '~/pools/kb.git', './kb.git') is a
194
+ // bare directory the user owns — no HTTP, no git binary, no credentials
195
+ // needed (record §2.1's loopback-of-the-filesystem). Transfer is isomorphic-
196
+ // git's OWN pack layer: packObjects (full closure of a commit set) into a
197
+ // temp file, indexPack into the target. ff-only rules identical to the HTTP
198
+ // path: push checks the remote head is an ancestor of ours before moving it.
199
+ export const isLocalUpstreamUrl = (url) => /^(?:file:\/\/\/|[/~]|\.\.{0,1}\/|[a-zA-Z]:\\)/.test(url) && !/^https?:\/\//.test(url);
200
+ /** file:///a/b -> /a/b ; ~ -> homedir ; relative resolved against `cwd`. */
201
+ export function resolveLocalUpstreamPath(url, cwd) {
202
+ let p = url.startsWith('file:///') ? decodeURIComponent(url.slice('file://'.length)) : url;
203
+ if (p === '~' || p.startsWith('~/'))
204
+ p = path.join(os.homedir(), p.slice(1));
205
+ if (!path.isAbsolute(p))
206
+ p = path.join(cwd, p);
207
+ return path.normalize(p);
208
+ }
209
+ /** The gitdir of a repo that may be bare (gitdir = the dir itself) or a
210
+ * working tree (gitdir = dir/.git); null when neither. */
211
+ function gitdirOf(repoDir) {
212
+ if (fs.existsSync(path.join(repoDir, 'HEAD')) && fs.existsSync(path.join(repoDir, 'objects')))
213
+ return repoDir;
214
+ if (fs.existsSync(path.join(repoDir, '.git', 'HEAD')))
215
+ return path.join(repoDir, '.git');
216
+ return null;
217
+ }
218
+ /** All objects reachable from the given commits (commit chain + trees +
219
+ * blobs). packObjects packs EXACTLY what it is given — the closure is ours
220
+ * to compute (measured the hard way: 'Could not find <oid>' on checkout). */
221
+ async function closureOids(fromDir, fromGit, commits) {
222
+ const oids = new Set();
223
+ for (const c of commits) {
224
+ const history = await git.log({ fs, dir: fromDir, gitdir: fromGit, ref: c });
225
+ for (const entry of history)
226
+ oids.add(entry.oid);
227
+ }
228
+ for (const co of [...oids]) {
229
+ const { object: commit } = (await git.readObject({ fs, dir: fromDir, gitdir: fromGit, oid: co }));
230
+ const stack = [commit.tree];
231
+ while (stack.length > 0) {
232
+ const t = stack.pop();
233
+ if (oids.has(t))
234
+ continue;
235
+ oids.add(t);
236
+ // measured in this isomorphic build: a tree readObject's `object` IS
237
+ // the entries array (keys '0','1',…), not an { entries } wrapper.
238
+ const { object: treeEntries } = (await git.readObject({ fs, dir: fromDir, gitdir: fromGit, oid: t }));
239
+ for (const e of treeEntries) {
240
+ if (e.type === 'tree')
241
+ stack.push(e.oid);
242
+ else
243
+ oids.add(e.oid);
244
+ }
245
+ }
246
+ }
247
+ return [...oids];
248
+ }
249
+ async function transferCommits(fromDir, toDir, commits) {
250
+ try {
251
+ const fromGit = gitdirOf(fromDir);
252
+ const toGit = gitdirOf(toDir);
253
+ if (fromGit === null)
254
+ return { ok: false, detail: `transfer source ${fromDir} is not a git repo` };
255
+ if (toGit === null)
256
+ return { ok: false, detail: `transfer target ${toDir} is not a git repo` };
257
+ const oids = await closureOids(fromDir, fromGit, commits);
258
+ const packed = await git.packObjects({ fs, dir: fromDir, gitdir: fromGit, oids, write: false });
259
+ if (packed.packfile === undefined)
260
+ return { ok: false, detail: 'packObjects returned no packfile' };
261
+ // indexPack resolves filepath RELATIVE TO dir and expects the pack where
262
+ // pushes put packs: inside the object store. So the incoming pack is
263
+ // written to <gitdir>/objects/pack/ first — where it then legitimately
264
+ // lives (this is literally how a git receive-pack lands objects).
265
+ const inTree = toGit !== toDir;
266
+ const relPack = path.posix.join(...(inTree ? ['.git', 'objects', 'pack'] : ['objects', 'pack']), `dsh-xfer-${randomUUID().slice(0, 8)}.pack`);
267
+ const absPack = path.join(toDir, ...(inTree ? ['.git', 'objects', 'pack'] : ['objects', 'pack']));
268
+ await nodefs.mkdir(absPack, { recursive: true });
269
+ const packFile = path.join(absPack, path.posix.basename(relPack));
270
+ await nodefs.writeFile(packFile, packed.packfile);
271
+ await git.indexPack({ fs, dir: toDir, gitdir: toGit, filepath: relPack });
272
+ return { ok: true, detail: `transferred ${commits.length} commit(s), ${oids.length} objects` };
273
+ }
274
+ catch (error) {
275
+ return { ok: false, detail: `transfer: ${String(error?.message ?? error)}` };
276
+ }
277
+ }
278
+ async function localHeadOf(repoDir, branch) {
279
+ const g = gitdirOf(repoDir);
280
+ if (g === null)
281
+ return null;
282
+ return await git.resolveRef({ fs, dir: repoDir, gitdir: g, ref: `refs/heads/${branch}` }).catch(() => null);
283
+ }
284
+ /** Materialize the mirror's workdir from its committed state (the local
285
+ * transport moves refs and transfers objects; HTTP clones materialize — keep
286
+ * the two transports behaving identically for the copy-out/search layers). */
287
+ async function checkoutMirror(mirrorDir, branch) {
288
+ // NOT caught: a mirror that failed to materialize must fail the pass
289
+ // loudly (the silent swallow here hid the closure bug for one whole round).
290
+ await git.checkout({ fs, dir: mirrorDir, ref: branch, force: true });
291
+ }
292
+ /** Create the upstream (bare, empty) when it does not exist — 'link a path'
293
+ * materializes the pool dir; never clobbers an existing repo. */
294
+ async function ensureUpstreamDir(upstream, branch) {
295
+ if (gitdirOf(upstream) !== null)
296
+ return { ok: true, detail: 'upstream exists' };
297
+ if (fs.existsSync(upstream) && fs.readdirSync(upstream).length > 0) {
298
+ return { ok: false, detail: `upstream path ${upstream} exists but is not a git repo` };
299
+ }
300
+ try {
301
+ await nodefs.mkdir(upstream, { recursive: true });
302
+ await git.init({ fs, dir: upstream, gitdir: upstream, bare: true, defaultBranch: branch });
303
+ return { ok: true, detail: 'upstream created (bare)', changed: true };
304
+ }
305
+ catch (error) {
306
+ return { ok: false, detail: `upstream init: ${String(error?.message ?? error)}` };
307
+ }
308
+ }
309
+ /** local-upstream ops take a url that is a resolved absolute path (sync.ts
310
+ * resolves before calling; the driver dispatches on the shape). */
311
+ export async function ensureCloneLocal(mirrorDir, upstreamPath, opts = {}) {
312
+ const branch = opts.defaultBranch ?? 'main';
313
+ try {
314
+ const up = await ensureUpstreamDir(upstreamPath, branch);
315
+ if (!up.ok)
316
+ return up;
317
+ if (await isRepo(mirrorDir))
318
+ return { ok: true, detail: 'already a repo' };
319
+ const entries = await nodefs.readdir(mirrorDir).catch(() => []);
320
+ if (entries.length > 0)
321
+ return { ok: false, detail: `clone target ${mirrorDir} exists and is not empty and not a git repo` };
322
+ await nodefs.mkdir(mirrorDir, { recursive: true });
323
+ await git.init({ fs, dir: mirrorDir, defaultBranch: branch });
324
+ const t = await localHeadOf(upstreamPath, branch);
325
+ if (t !== null) {
326
+ const tr = await transferCommits(upstreamPath, mirrorDir, [t]);
327
+ if (!tr.ok)
328
+ return tr;
329
+ const g = gitdirOf(mirrorDir) ?? path.join(mirrorDir, '.git');
330
+ await git.writeRef({ fs, dir: mirrorDir, gitdir: g, ref: `refs/heads/${branch}`, value: t, force: true });
331
+ await git.writeRef({ fs, dir: mirrorDir, gitdir: g, ref: `refs/remotes/origin/${branch}`, value: t, force: true });
332
+ await checkoutMirror(mirrorDir, branch);
333
+ return { ok: true, detail: 'cloned (local upstream)', changed: true };
334
+ }
335
+ return { ok: true, detail: `mirror initialized against ${up.ok === true ? 'new empty' : 'empty'} local upstream`, changed: true };
336
+ }
337
+ catch (error) {
338
+ return { ok: false, code: 'network', detail: `clone(local): ${String(error?.message ?? error)}` };
339
+ }
340
+ }
341
+ export async function pullLocal(mirrorDir, upstreamPath, opts = {}) {
342
+ const branch = opts.defaultBranch ?? 'main';
343
+ try {
344
+ const t = await localHeadOf(upstreamPath, branch);
345
+ if (t === null)
346
+ return { ok: true, detail: 'up-to-date (upstream has no branch yet)' };
347
+ const s = await localHeadOf(mirrorDir, branch);
348
+ const g = gitdirOf(mirrorDir);
349
+ if (g === null)
350
+ return { ok: false, detail: 'mirror is not a git repo' };
351
+ if (s === t)
352
+ return { ok: true, detail: 'up to date (nothing to fast-forward)' };
353
+ const tr = await transferCommits(upstreamPath, mirrorDir, [t]);
354
+ if (!tr.ok)
355
+ return tr;
356
+ if (s !== null) {
357
+ const remoteAhead = await git.isDescendent({ fs, dir: mirrorDir, gitdir: g, oid: t, ancestor: s });
358
+ if (!remoteAhead) {
359
+ const localAhead = await git.isDescendent({ fs, dir: mirrorDir, gitdir: g, oid: s, ancestor: t });
360
+ if (localAhead)
361
+ return { ok: true, detail: 'nothing to fast-forward (local ahead; push will ship it)' };
362
+ return { ok: false, code: 'diverged', detail: 'diverged — fast-forward impossible (local upstream)' };
363
+ }
364
+ }
365
+ await git.writeRef({ fs, dir: mirrorDir, gitdir: g, ref: `refs/heads/${branch}`, value: t, force: true });
366
+ await git.writeRef({ fs, dir: mirrorDir, gitdir: g, ref: `refs/remotes/origin/${branch}`, value: t, force: true });
367
+ await checkoutMirror(mirrorDir, branch);
368
+ return { ok: true, detail: 'fast-forwarded (local)', changed: true };
369
+ }
370
+ catch (error) {
371
+ return { ok: false, code: 'network', detail: `pull(local): ${String(error?.message ?? error)}` };
372
+ }
373
+ }
374
+ export async function pushLocal(mirrorDir, upstreamPath, opts = {}) {
375
+ const branch = opts.defaultBranch ?? 'main';
376
+ try {
377
+ const s = await localHeadOf(mirrorDir, branch);
378
+ if (s === null)
379
+ return { ok: true, detail: 'pushed (nothing new)' };
380
+ const up = await ensureUpstreamDir(upstreamPath, branch);
381
+ if (!up.ok)
382
+ return { ok: false, code: 'network', detail: up.detail };
383
+ const t = await localHeadOf(upstreamPath, branch);
384
+ const ug = gitdirOf(upstreamPath);
385
+ if (ug === null)
386
+ return { ok: false, detail: 'upstream lost its gitdir' };
387
+ if (s === t)
388
+ return { ok: true, detail: 'pushed (up to date)' };
389
+ const tr = await transferCommits(mirrorDir, upstreamPath, [s]);
390
+ if (!tr.ok)
391
+ return tr;
392
+ if (t !== null) {
393
+ const canFf = await git.isDescendent({ fs, dir: upstreamPath, gitdir: ug, oid: s, ancestor: t });
394
+ if (!canFf)
395
+ return { ok: false, code: 'diverged', detail: 'push rejected — upstream diverged (local)' };
396
+ }
397
+ await git.writeRef({ fs, dir: upstreamPath, gitdir: ug, ref: `refs/heads/${branch}`, value: s, force: true });
398
+ const g = gitdirOf(mirrorDir);
399
+ if (g !== null)
400
+ await git.writeRef({ fs, dir: mirrorDir, gitdir: g, ref: `refs/remotes/origin/${branch}`, value: s, force: true }).catch(() => undefined);
401
+ return { ok: true, detail: 'pushed (local)', changed: true };
402
+ }
403
+ catch (error) {
404
+ return { ok: false, code: 'network', detail: `push(local): ${String(error?.message ?? error)}` };
405
+ }
406
+ }
407
+ /** Mirror provenance: which upstream this mirror was last bound to (http OR
408
+ * local) — an origin change is detected on EVERY ensureClone, local or not. */
409
+ export const originSentinel = (mirrorDir) => path.join(mirrorDir, '.git', 'DSH-ORIGIN');
410
+ export async function recordOrigin(mirrorDir, url) {
411
+ await nodefs.mkdir(path.join(mirrorDir, '.git'), { recursive: true });
412
+ await nodefs.writeFile(originSentinel(mirrorDir), url);
413
+ }
414
+ export function readOrigin(mirrorDir) {
415
+ try {
416
+ return fs.readFileSync(originSentinel(mirrorDir), 'utf8').trim();
417
+ }
418
+ catch {
419
+ return null;
420
+ }
421
+ }
422
+ /**
423
+ * Initialize a local-only mirror (offline mode, record §5.3): the remote is
424
+ * unreachable, but the mirror is transport over truth we own — publish,
425
+ * index, commit, and search keep working; push waits for the remote.
426
+ */
427
+ export async function initLocal(dir, remote, opts = {}) {
428
+ try {
429
+ if (await isRepo(dir)) {
430
+ // even an existing repo needs its origin (offline mirrors init before
431
+ // the remote is reachable; recovery must be able to fetch)
432
+ if (remote !== undefined)
433
+ await git.addRemote({ fs, dir, remote: 'origin', url: remote.url, force: true }).catch(() => undefined);
434
+ return { ok: true, detail: 'already a repo' };
435
+ }
436
+ await nodefs.mkdir(dir, { recursive: true });
437
+ const entries = await nodefs.readdir(dir);
438
+ const strays = entries.filter((e) => e !== '.git');
439
+ if (strays.length > 0) {
440
+ // same policy as ensureClone: dead transport moved aside, never fatal
441
+ const stamp = new Date().toISOString().replace(/[:.]/g, '-');
442
+ await nodefs.rename(dir, `${dir}.stale-${stamp}`);
443
+ await nodefs.mkdir(dir, { recursive: true });
444
+ }
445
+ await git.init({ fs, dir, defaultBranch: opts.defaultBranch ?? 'main' });
446
+ if (remote !== undefined)
447
+ await git.addRemote({ fs, dir, remote: 'origin', url: remote.url });
448
+ return { ok: true, detail: 'local mirror initialized (offline mode)', changed: true };
449
+ }
450
+ catch (error) {
451
+ return { ok: false, detail: `init: ${String(error?.message ?? error)}` };
452
+ }
453
+ }
454
+ /** Delete the mirror working tree + git dir entirely. SAFE ONLY because the
455
+ * mirror is transport (§3.1): the workspace store holds the truth, and the
456
+ * rebuild republishes from it (the diverged-offline recovery, §5.3). */
457
+ export async function removeMirror(dir) {
458
+ try {
459
+ await nodefs.rm(dir, { recursive: true, force: true });
460
+ return { ok: true, detail: 'mirror removed for rebuild' };
461
+ }
462
+ catch (error) {
463
+ return { ok: false, detail: `remove: ${String(error?.message ?? error)}` };
464
+ }
465
+ }
466
+ /** Push the local branch; a rejected (non-ff) push comes back for the caller to ff-and-retry. */
467
+ export async function push(dir, remote, opts = {}) {
468
+ const ref = `refs/heads/${await branchOf(dir, opts.defaultBranch ?? 'main')}`;
469
+ // Nothing committed yet is NOT a push failure (measured 2026-09-25 by the
470
+ // hosted e2e: linking a pristine workspace to a fresh empty remote made
471
+ // the mirror's clone unborn-HEAD, the push of a nonexistent ref threw, and
472
+ // the honest state 'nothing to push yet' degraded to local-only — the
473
+ // status told the user the remote took nothing when there was literally
474
+ // nothing to take). A mirror without a local branch is up to date by
475
+ // definition; the archive's first commit re-arms the push.
476
+ try {
477
+ await git.resolveRef({ fs, dir, ref });
478
+ }
479
+ catch {
480
+ return { ok: true, detail: 'nothing to push (no local commits yet)' };
481
+ }
482
+ try {
483
+ await git.push({ fs, http: nodeHttp, dir, url: remote.url, ref, onAuth: authOf(remote) });
484
+ return { ok: true, detail: 'pushed' };
485
+ }
486
+ catch (error) {
487
+ const msg = String(error?.message ?? error);
488
+ if (/rejected|non-fast-forward|fetch first/i.test(msg)) {
489
+ return { ok: false, code: 'rejected', detail: 'push rejected (remote is ahead) — pull-and-retry' };
490
+ }
491
+ const cls = classifyGitTransportError(error);
492
+ return { ok: false, code: cls.code, detail: `push failed: ${cls.detail}` };
493
+ }
494
+ }
495
+ /** The real driver (isomorphic-git, https only — record §3.2). Sync takes a driver
496
+ * so tests can exercise the loop against a fake remote (the wire protocol is
497
+ * isomorphic-git's to own; our logic is what the fake exercises). */
498
+ const upstreamOf = (remote, dir) => isLocalUpstreamUrl(remote.url) ? resolveLocalUpstreamPath(remote.url, path.dirname(path.dirname(dir))) : undefined;
499
+ export const isomorphicDriver = {
500
+ async ensureClone(dir, remote, opts) {
501
+ const up = upstreamOf(remote, dir);
502
+ if (up !== undefined) {
503
+ const known = readOrigin(dir);
504
+ if (known !== null && known !== up) {
505
+ return { ok: false, code: 'origin-mismatch', detail: `mirror origin is ${known}, the project's upstream is ${up}` };
506
+ }
507
+ const res = await ensureCloneLocal(dir, up, opts);
508
+ if (res.ok)
509
+ await recordOrigin(dir, up);
510
+ return res;
511
+ }
512
+ if (await isRepo(dir)) {
513
+ const known = readOrigin(dir);
514
+ if (known !== null && known !== remote.url) {
515
+ return { ok: false, code: 'origin-mismatch', detail: `mirror origin is ${known}, the project's remote is ${remote.url}` };
516
+ }
517
+ const r = await ensureClone(dir, remote, opts);
518
+ if (r.ok && r.detail === 'already a repo')
519
+ await recordOrigin(dir, remote.url);
520
+ return r;
521
+ }
522
+ const r = await ensureClone(dir, remote, opts);
523
+ if (r.ok)
524
+ await recordOrigin(dir, remote.url);
525
+ return r;
526
+ },
527
+ initLocal,
528
+ removeMirror,
529
+ stageAllAndCommit,
530
+ async pullFastForward(dir, remote, opts) {
531
+ const up = upstreamOf(remote, dir);
532
+ return up !== undefined ? pullLocal(dir, up, opts) : pullFastForward(dir, remote, opts);
533
+ },
534
+ async push(dir, remote, opts) {
535
+ const up = upstreamOf(remote, dir);
536
+ return up !== undefined ? pushLocal(dir, up, opts) : push(dir, remote, opts);
537
+ },
538
+ };
539
+ //# sourceMappingURL=gitops.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitops.js","sourceRoot":"","sources":["../src/gitops.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa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