@shardworks/codexes-apparatus 0.1.101
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/LICENSE +15 -0
- package/README.md +278 -0
- package/dist/git.d.ts +39 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +66 -0
- package/dist/git.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/scriptorium-core.d.ts +68 -0
- package/dist/scriptorium-core.d.ts.map +1 -0
- package/dist/scriptorium-core.js +488 -0
- package/dist/scriptorium-core.js.map +1 -0
- package/dist/scriptorium.d.ts +12 -0
- package/dist/scriptorium.d.ts.map +1 -0
- package/dist/scriptorium.js +41 -0
- package/dist/scriptorium.js.map +1 -0
- package/dist/tools/codex-add.d.ts +13 -0
- package/dist/tools/codex-add.d.ts.map +1 -0
- package/dist/tools/codex-add.js +23 -0
- package/dist/tools/codex-add.js.map +1 -0
- package/dist/tools/codex-list.d.ts +6 -0
- package/dist/tools/codex-list.d.ts.map +1 -0
- package/dist/tools/codex-list.js +17 -0
- package/dist/tools/codex-list.js.map +1 -0
- package/dist/tools/codex-push.d.ts +10 -0
- package/dist/tools/codex-push.d.ts.map +1 -0
- package/dist/tools/codex-push.js +20 -0
- package/dist/tools/codex-push.js.map +1 -0
- package/dist/tools/codex-remove.d.ts +12 -0
- package/dist/tools/codex-remove.d.ts.map +1 -0
- package/dist/tools/codex-remove.js +22 -0
- package/dist/tools/codex-remove.js.map +1 -0
- package/dist/tools/codex-show.d.ts +9 -0
- package/dist/tools/codex-show.d.ts.map +1 -0
- package/dist/tools/codex-show.js +19 -0
- package/dist/tools/codex-show.js.map +1 -0
- package/dist/tools/draft-abandon.d.ts +14 -0
- package/dist/tools/draft-abandon.d.ts.map +1 -0
- package/dist/tools/draft-abandon.js +24 -0
- package/dist/tools/draft-abandon.js.map +1 -0
- package/dist/tools/draft-list.d.ts +9 -0
- package/dist/tools/draft-list.d.ts.map +1 -0
- package/dist/tools/draft-list.js +19 -0
- package/dist/tools/draft-list.js.map +1 -0
- package/dist/tools/draft-open.d.ts +15 -0
- package/dist/tools/draft-open.d.ts.map +1 -0
- package/dist/tools/draft-open.js +25 -0
- package/dist/tools/draft-open.js.map +1 -0
- package/dist/tools/draft-seal.d.ts +17 -0
- package/dist/tools/draft-seal.d.ts.map +1 -0
- package/dist/tools/draft-seal.js +27 -0
- package/dist/tools/draft-seal.js.map +1 -0
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +13 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types.d.ts +180 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Scriptorium — core logic.
|
|
3
|
+
*
|
|
4
|
+
* Manages the codex registry (bare clones), draft binding lifecycle
|
|
5
|
+
* (worktrees), and sealing (ff-only merge or rebase+ff). All git
|
|
6
|
+
* operations go through the git helper for safety.
|
|
7
|
+
*
|
|
8
|
+
* Draft tracking is in-memory — drafts are reconstructed from
|
|
9
|
+
* filesystem state at startup and maintained in memory during the
|
|
10
|
+
* process lifetime.
|
|
11
|
+
*
|
|
12
|
+
* See: docs/architecture/apparatus/scriptorium.md
|
|
13
|
+
*/
|
|
14
|
+
import fs from 'node:fs';
|
|
15
|
+
import path from 'node:path';
|
|
16
|
+
import { guild, generateId } from '@shardworks/nexus-core';
|
|
17
|
+
import { git, resolveDefaultBranch, resolveRef, commitsAhead, GitError } from "./git.js";
|
|
18
|
+
// ── Core class ──────────────────────────────────────────────────────
|
|
19
|
+
export class ScriptoriumCore {
|
|
20
|
+
codexes = new Map();
|
|
21
|
+
drafts = new Map(); // keyed by `${codexName}/${branch}`
|
|
22
|
+
maxMergeRetries = 3;
|
|
23
|
+
draftRoot = '.nexus/worktrees';
|
|
24
|
+
// ── Paths ───────────────────────────────────────────────────────
|
|
25
|
+
get home() {
|
|
26
|
+
return guild().home;
|
|
27
|
+
}
|
|
28
|
+
codexesDir() {
|
|
29
|
+
return path.join(this.home, '.nexus', 'codexes');
|
|
30
|
+
}
|
|
31
|
+
bareClonePath(name) {
|
|
32
|
+
return path.join(this.codexesDir(), `${name}.git`);
|
|
33
|
+
}
|
|
34
|
+
draftWorktreePath(codexName, branch) {
|
|
35
|
+
return path.join(this.home, this.draftRoot, codexName, branch);
|
|
36
|
+
}
|
|
37
|
+
// ── Startup ─────────────────────────────────────────────────────
|
|
38
|
+
start() {
|
|
39
|
+
const config = guild().config('codexes');
|
|
40
|
+
// Apply settings
|
|
41
|
+
this.maxMergeRetries = config.settings?.maxMergeRetries ?? 3;
|
|
42
|
+
this.draftRoot = config.settings?.draftRoot ?? '.nexus/worktrees';
|
|
43
|
+
// Ensure infrastructure directories exist
|
|
44
|
+
fs.mkdirSync(this.codexesDir(), { recursive: true });
|
|
45
|
+
// Load registered codexes from config
|
|
46
|
+
const registered = config.registered ?? {};
|
|
47
|
+
for (const [name, entry] of Object.entries(registered)) {
|
|
48
|
+
this.loadCodex(name, entry);
|
|
49
|
+
}
|
|
50
|
+
// Reconcile drafts from filesystem
|
|
51
|
+
this.reconcileDrafts();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Load a codex from config. Checks for existing bare clone;
|
|
55
|
+
* initiates background clone if missing.
|
|
56
|
+
*/
|
|
57
|
+
loadCodex(name, entry) {
|
|
58
|
+
const clonePath = this.bareClonePath(name);
|
|
59
|
+
const exists = fs.existsSync(clonePath);
|
|
60
|
+
const state = {
|
|
61
|
+
name,
|
|
62
|
+
remoteUrl: entry.remoteUrl,
|
|
63
|
+
cloneStatus: exists ? 'ready' : 'cloning',
|
|
64
|
+
lastFetched: null,
|
|
65
|
+
};
|
|
66
|
+
if (!exists) {
|
|
67
|
+
// Background clone — doesn't block startup
|
|
68
|
+
state.clonePromise = this.performClone(name, entry.remoteUrl)
|
|
69
|
+
.then(() => { state.cloneStatus = 'ready'; })
|
|
70
|
+
.catch((err) => {
|
|
71
|
+
state.cloneStatus = 'error';
|
|
72
|
+
console.warn(`[scriptorium] Background clone of "${name}" failed: ${err instanceof Error ? err.message : err}`);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
this.codexes.set(name, state);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Reconcile in-memory draft tracking with filesystem state.
|
|
79
|
+
* Scans the worktree directories and rebuilds the draft map.
|
|
80
|
+
*/
|
|
81
|
+
reconcileDrafts() {
|
|
82
|
+
const worktreeRoot = path.join(this.home, this.draftRoot);
|
|
83
|
+
if (!fs.existsSync(worktreeRoot))
|
|
84
|
+
return;
|
|
85
|
+
for (const codexDir of fs.readdirSync(worktreeRoot, { withFileTypes: true })) {
|
|
86
|
+
if (!codexDir.isDirectory())
|
|
87
|
+
continue;
|
|
88
|
+
const codexName = codexDir.name;
|
|
89
|
+
// Only reconcile drafts for known codexes
|
|
90
|
+
if (!this.codexes.has(codexName))
|
|
91
|
+
continue;
|
|
92
|
+
const codexWorktreeDir = path.join(worktreeRoot, codexName);
|
|
93
|
+
for (const draftDir of fs.readdirSync(codexWorktreeDir, { withFileTypes: true })) {
|
|
94
|
+
if (!draftDir.isDirectory())
|
|
95
|
+
continue;
|
|
96
|
+
const branch = draftDir.name;
|
|
97
|
+
const draftPath = path.join(codexWorktreeDir, branch);
|
|
98
|
+
// Verify it's actually a git worktree (has .git file)
|
|
99
|
+
if (!fs.existsSync(path.join(draftPath, '.git')))
|
|
100
|
+
continue;
|
|
101
|
+
const key = `${codexName}/${branch}`;
|
|
102
|
+
if (!this.drafts.has(key)) {
|
|
103
|
+
this.drafts.set(key, {
|
|
104
|
+
id: generateId('draft', 4),
|
|
105
|
+
codexName,
|
|
106
|
+
branch,
|
|
107
|
+
path: draftPath,
|
|
108
|
+
createdAt: new Date().toISOString(), // approximate — we don't know the real time
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// ── Clone readiness ─────────────────────────────────────────────
|
|
115
|
+
/**
|
|
116
|
+
* Ensure a codex's bare clone is ready. Blocks if a background
|
|
117
|
+
* clone is in progress. Throws if the codex is unknown or clone failed.
|
|
118
|
+
*/
|
|
119
|
+
async ensureReady(name) {
|
|
120
|
+
const state = this.codexes.get(name);
|
|
121
|
+
if (!state) {
|
|
122
|
+
throw new Error(`Codex "${name}" is not registered. Use codex-add to register it.`);
|
|
123
|
+
}
|
|
124
|
+
if (state.clonePromise) {
|
|
125
|
+
await state.clonePromise;
|
|
126
|
+
state.clonePromise = undefined;
|
|
127
|
+
}
|
|
128
|
+
if (state.cloneStatus === 'error') {
|
|
129
|
+
throw new Error(`Codex "${name}" bare clone failed. Remove and re-add the codex, or check the remote URL.`);
|
|
130
|
+
}
|
|
131
|
+
return state;
|
|
132
|
+
}
|
|
133
|
+
// ── Git operations ──────────────────────────────────────────────
|
|
134
|
+
async performClone(name, remoteUrl) {
|
|
135
|
+
const clonePath = this.bareClonePath(name);
|
|
136
|
+
fs.mkdirSync(path.dirname(clonePath), { recursive: true });
|
|
137
|
+
await git(['clone', '--bare', remoteUrl, clonePath]);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Advance refs/heads/<branch> to the remote's position if the remote is
|
|
141
|
+
* strictly ahead of the local sealed binding.
|
|
142
|
+
*
|
|
143
|
+
* This handles commits pushed to the remote outside the Scriptorium:
|
|
144
|
+
* if the remote has advanced past the local sealed binding, sealing must
|
|
145
|
+
* rebase the draft onto the remote position — not the stale local one.
|
|
146
|
+
*
|
|
147
|
+
* If the local sealed binding is already ahead of (or equal to) the remote
|
|
148
|
+
* (e.g. contains unpushed seals from contention scenarios), it is kept.
|
|
149
|
+
*/
|
|
150
|
+
async advanceToRemote(codexName, branch) {
|
|
151
|
+
const clonePath = this.bareClonePath(codexName);
|
|
152
|
+
let remoteRef;
|
|
153
|
+
try {
|
|
154
|
+
remoteRef = await resolveRef(clonePath, `refs/remotes/origin/${branch}`);
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return; // No remote tracking ref (branch may not exist on remote yet)
|
|
158
|
+
}
|
|
159
|
+
const localRef = await resolveRef(clonePath, branch);
|
|
160
|
+
if (remoteRef === localRef)
|
|
161
|
+
return;
|
|
162
|
+
const { stdout: mergeBase } = await git(['merge-base', localRef, remoteRef], clonePath);
|
|
163
|
+
if (mergeBase === localRef) {
|
|
164
|
+
// Local is an ancestor of remote → remote is ahead → advance local
|
|
165
|
+
await git(['update-ref', `refs/heads/${branch}`, remoteRef], clonePath);
|
|
166
|
+
}
|
|
167
|
+
// If local is ahead of or diverged from remote: keep the local sealed binding
|
|
168
|
+
}
|
|
169
|
+
async performFetch(name) {
|
|
170
|
+
const clonePath = this.bareClonePath(name);
|
|
171
|
+
// Explicit refspec is required: git clone --bare does not configure a
|
|
172
|
+
// fetch refspec, so plain `git fetch origin` only updates FETCH_HEAD and
|
|
173
|
+
// leaves refs/heads/* stale.
|
|
174
|
+
//
|
|
175
|
+
// We fetch into refs/remotes/origin/* rather than refs/heads/* for two
|
|
176
|
+
// reasons:
|
|
177
|
+
// 1. It avoids force-overwriting local draft branches (which live in
|
|
178
|
+
// refs/heads/* but do not exist on the remote).
|
|
179
|
+
// 2. It separates the "remote position" (refs/remotes/origin/*) from
|
|
180
|
+
// the "local sealed binding" (refs/heads/*), letting seal() advance
|
|
181
|
+
// refs/heads/* only when the remote is strictly ahead.
|
|
182
|
+
await git(['fetch', '--prune', 'origin', '+refs/heads/*:refs/remotes/origin/*'], clonePath);
|
|
183
|
+
const state = this.codexes.get(name);
|
|
184
|
+
if (state) {
|
|
185
|
+
state.lastFetched = new Date().toISOString();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// ── API Implementation ────────────────────────────────────────
|
|
189
|
+
createApi() {
|
|
190
|
+
return {
|
|
191
|
+
add: (name, remoteUrl) => this.add(name, remoteUrl),
|
|
192
|
+
list: () => this.list(),
|
|
193
|
+
show: (name) => this.show(name),
|
|
194
|
+
remove: (name) => this.remove(name),
|
|
195
|
+
fetch: (name) => this.fetchCodex(name),
|
|
196
|
+
push: (request) => this.push(request),
|
|
197
|
+
openDraft: (request) => this.openDraft(request),
|
|
198
|
+
listDrafts: (codexName) => this.listDrafts(codexName),
|
|
199
|
+
abandonDraft: (request) => this.abandonDraft(request),
|
|
200
|
+
seal: (request) => this.seal(request),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
// ── Codex Registry ──────────────────────────────────────────────
|
|
204
|
+
async add(name, remoteUrl) {
|
|
205
|
+
if (this.codexes.has(name)) {
|
|
206
|
+
throw new Error(`Codex "${name}" is already registered.`);
|
|
207
|
+
}
|
|
208
|
+
// Clone bare repo (blocking)
|
|
209
|
+
const state = {
|
|
210
|
+
name,
|
|
211
|
+
remoteUrl,
|
|
212
|
+
cloneStatus: 'cloning',
|
|
213
|
+
lastFetched: null,
|
|
214
|
+
};
|
|
215
|
+
this.codexes.set(name, state);
|
|
216
|
+
try {
|
|
217
|
+
await this.performClone(name, remoteUrl);
|
|
218
|
+
state.cloneStatus = 'ready';
|
|
219
|
+
}
|
|
220
|
+
catch (err) {
|
|
221
|
+
state.cloneStatus = 'error';
|
|
222
|
+
this.codexes.delete(name);
|
|
223
|
+
throw new Error(`Failed to clone "${remoteUrl}" for codex "${name}": ${err instanceof Error ? err.message : err}`);
|
|
224
|
+
}
|
|
225
|
+
// Persist to guild.json
|
|
226
|
+
const config = guild().config('codexes');
|
|
227
|
+
const registered = config.registered ?? {};
|
|
228
|
+
registered[name] = { remoteUrl };
|
|
229
|
+
guild().writeConfig('codexes', { ...config, registered });
|
|
230
|
+
return this.toCodexRecord(state);
|
|
231
|
+
}
|
|
232
|
+
async list() {
|
|
233
|
+
const records = [];
|
|
234
|
+
for (const state of this.codexes.values()) {
|
|
235
|
+
records.push(this.toCodexRecord(state));
|
|
236
|
+
}
|
|
237
|
+
return records;
|
|
238
|
+
}
|
|
239
|
+
async show(name) {
|
|
240
|
+
const state = await this.ensureReady(name);
|
|
241
|
+
const clonePath = this.bareClonePath(name);
|
|
242
|
+
const defaultBranch = await resolveDefaultBranch(clonePath);
|
|
243
|
+
const drafts = this.draftsForCodex(name);
|
|
244
|
+
return {
|
|
245
|
+
name: state.name,
|
|
246
|
+
remoteUrl: state.remoteUrl,
|
|
247
|
+
cloneStatus: state.cloneStatus,
|
|
248
|
+
activeDrafts: drafts.length,
|
|
249
|
+
defaultBranch,
|
|
250
|
+
lastFetched: state.lastFetched,
|
|
251
|
+
drafts,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
async remove(name) {
|
|
255
|
+
const state = this.codexes.get(name);
|
|
256
|
+
if (!state) {
|
|
257
|
+
throw new Error(`Codex "${name}" is not registered.`);
|
|
258
|
+
}
|
|
259
|
+
// Abandon all drafts for this codex
|
|
260
|
+
const drafts = this.draftsForCodex(name);
|
|
261
|
+
for (const draft of drafts) {
|
|
262
|
+
await this.abandonDraft({ codexName: name, branch: draft.branch, force: true });
|
|
263
|
+
}
|
|
264
|
+
// Remove bare clone
|
|
265
|
+
const clonePath = this.bareClonePath(name);
|
|
266
|
+
if (fs.existsSync(clonePath)) {
|
|
267
|
+
fs.rmSync(clonePath, { recursive: true, force: true });
|
|
268
|
+
}
|
|
269
|
+
// Remove from in-memory state
|
|
270
|
+
this.codexes.delete(name);
|
|
271
|
+
// Remove from guild.json
|
|
272
|
+
const config = guild().config('codexes');
|
|
273
|
+
const registered = { ...(config.registered ?? {}) };
|
|
274
|
+
delete registered[name];
|
|
275
|
+
guild().writeConfig('codexes', { ...config, registered });
|
|
276
|
+
}
|
|
277
|
+
async fetchCodex(name) {
|
|
278
|
+
await this.ensureReady(name);
|
|
279
|
+
await this.performFetch(name);
|
|
280
|
+
}
|
|
281
|
+
async push(request) {
|
|
282
|
+
const state = await this.ensureReady(request.codexName);
|
|
283
|
+
const clonePath = this.bareClonePath(state.name);
|
|
284
|
+
const branch = request.branch ?? await resolveDefaultBranch(clonePath);
|
|
285
|
+
await git(['push', 'origin', branch], clonePath);
|
|
286
|
+
}
|
|
287
|
+
// ── Draft Binding Lifecycle ─────────────────────────────────────
|
|
288
|
+
async openDraft(request) {
|
|
289
|
+
const state = await this.ensureReady(request.codexName);
|
|
290
|
+
const clonePath = this.bareClonePath(state.name);
|
|
291
|
+
// Fetch before branching for freshness
|
|
292
|
+
await this.performFetch(state.name);
|
|
293
|
+
const branch = request.branch ?? generateId('draft', 4);
|
|
294
|
+
const key = `${request.codexName}/${branch}`;
|
|
295
|
+
// Reject if draft already exists
|
|
296
|
+
if (this.drafts.has(key)) {
|
|
297
|
+
throw new Error(`Draft with branch "${branch}" already exists for codex "${request.codexName}". ` +
|
|
298
|
+
`Choose a different branch name or abandon the existing draft.`);
|
|
299
|
+
}
|
|
300
|
+
const defaultBranch = await resolveDefaultBranch(clonePath);
|
|
301
|
+
const startPoint = request.startPoint ?? defaultBranch;
|
|
302
|
+
// Advance the start-point branch to the remote position if the remote
|
|
303
|
+
// has moved ahead. Ensures the draft branches from the latest state.
|
|
304
|
+
await this.advanceToRemote(state.name, startPoint);
|
|
305
|
+
const worktreePath = this.draftWorktreePath(request.codexName, branch);
|
|
306
|
+
fs.mkdirSync(path.dirname(worktreePath), { recursive: true });
|
|
307
|
+
// Create worktree with new branch from start point
|
|
308
|
+
await git(['worktree', 'add', worktreePath, '-b', branch, startPoint], clonePath);
|
|
309
|
+
const draft = {
|
|
310
|
+
id: generateId('draft', 4),
|
|
311
|
+
codexName: request.codexName,
|
|
312
|
+
branch,
|
|
313
|
+
path: worktreePath,
|
|
314
|
+
createdAt: new Date().toISOString(),
|
|
315
|
+
associatedWith: request.associatedWith,
|
|
316
|
+
};
|
|
317
|
+
this.drafts.set(key, draft);
|
|
318
|
+
return draft;
|
|
319
|
+
}
|
|
320
|
+
async listDrafts(codexName) {
|
|
321
|
+
if (codexName) {
|
|
322
|
+
return this.draftsForCodex(codexName);
|
|
323
|
+
}
|
|
324
|
+
return [...this.drafts.values()];
|
|
325
|
+
}
|
|
326
|
+
async abandonDraft(request) {
|
|
327
|
+
const key = `${request.codexName}/${request.branch}`;
|
|
328
|
+
const draft = this.drafts.get(key);
|
|
329
|
+
if (!draft) {
|
|
330
|
+
throw new Error(`No active draft with branch "${request.branch}" for codex "${request.codexName}".`);
|
|
331
|
+
}
|
|
332
|
+
// Check for unsealed inscriptions (commits ahead of the sealed binding)
|
|
333
|
+
if (!request.force) {
|
|
334
|
+
const state = await this.ensureReady(request.codexName);
|
|
335
|
+
const clonePath = this.bareClonePath(state.name);
|
|
336
|
+
try {
|
|
337
|
+
const defaultBranch = await resolveDefaultBranch(clonePath);
|
|
338
|
+
const ahead = await commitsAhead(clonePath, request.branch, defaultBranch);
|
|
339
|
+
if (ahead > 0) {
|
|
340
|
+
throw new Error(`Draft "${request.branch}" has ${ahead} unsealed inscription(s). ` +
|
|
341
|
+
`Use force: true to abandon anyway, or seal the draft first.`);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
catch (err) {
|
|
345
|
+
// If the branch doesn't exist in the bare clone (already cleaned up),
|
|
346
|
+
// that's fine — proceed with cleanup
|
|
347
|
+
if (err instanceof GitError && err.stderr.includes('unknown revision')) {
|
|
348
|
+
// Branch already gone — proceed with cleanup
|
|
349
|
+
}
|
|
350
|
+
else if (err instanceof Error && err.message.includes('unsealed inscription')) {
|
|
351
|
+
throw err;
|
|
352
|
+
}
|
|
353
|
+
// Other git errors during the check are non-fatal — proceed with cleanup
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
// Remove worktree
|
|
357
|
+
const clonePath = this.bareClonePath(request.codexName);
|
|
358
|
+
try {
|
|
359
|
+
await git(['worktree', 'remove', '--force', draft.path], clonePath);
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
// If worktree removal fails (e.g. already gone), try manual cleanup
|
|
363
|
+
if (fs.existsSync(draft.path)) {
|
|
364
|
+
fs.rmSync(draft.path, { recursive: true, force: true });
|
|
365
|
+
}
|
|
366
|
+
// Prune stale worktree references
|
|
367
|
+
try {
|
|
368
|
+
await git(['worktree', 'prune'], clonePath);
|
|
369
|
+
}
|
|
370
|
+
catch { /* best effort */ }
|
|
371
|
+
}
|
|
372
|
+
// Delete the branch from the bare clone
|
|
373
|
+
try {
|
|
374
|
+
await git(['branch', '-D', request.branch], clonePath);
|
|
375
|
+
}
|
|
376
|
+
catch {
|
|
377
|
+
// Branch may already be gone — that's fine
|
|
378
|
+
}
|
|
379
|
+
// Remove from in-memory tracking
|
|
380
|
+
this.drafts.delete(key);
|
|
381
|
+
}
|
|
382
|
+
async seal(request) {
|
|
383
|
+
const state = await this.ensureReady(request.codexName);
|
|
384
|
+
const clonePath = this.bareClonePath(state.name);
|
|
385
|
+
const maxRetries = request.maxRetries ?? this.maxMergeRetries;
|
|
386
|
+
const defaultBranch = await resolveDefaultBranch(clonePath);
|
|
387
|
+
const targetBranch = request.targetBranch ?? defaultBranch;
|
|
388
|
+
let strategy = 'fast-forward';
|
|
389
|
+
let retries = 0;
|
|
390
|
+
// Fetch before sealing for freshness
|
|
391
|
+
await this.performFetch(state.name);
|
|
392
|
+
// Advance the local sealed binding to the remote position if the remote
|
|
393
|
+
// has moved ahead (e.g. commits pushed outside the Scriptorium).
|
|
394
|
+
// This ensures seal compares against the latest remote ref, not a
|
|
395
|
+
// potentially stale local one — preventing push failures.
|
|
396
|
+
await this.advanceToRemote(state.name, targetBranch);
|
|
397
|
+
// Attempt ff-only merge, with rebase retry loop
|
|
398
|
+
while (retries <= maxRetries) {
|
|
399
|
+
try {
|
|
400
|
+
// Try fast-forward merge: update the target branch ref to point at the source
|
|
401
|
+
// In a bare repo, we use `git merge --ff-only` with the branch checked out,
|
|
402
|
+
// but bare repos don't have a checkout. Instead, we verify ancestry and
|
|
403
|
+
// update the ref directly.
|
|
404
|
+
const targetRef = await resolveRef(clonePath, targetBranch);
|
|
405
|
+
const sourceRef = await resolveRef(clonePath, request.sourceBranch);
|
|
406
|
+
// Check if source is already at target (nothing to seal)
|
|
407
|
+
if (targetRef === sourceRef) {
|
|
408
|
+
// Clean up draft unless keepDraft
|
|
409
|
+
if (!request.keepDraft) {
|
|
410
|
+
await this.abandonDraft({
|
|
411
|
+
codexName: request.codexName,
|
|
412
|
+
branch: request.sourceBranch,
|
|
413
|
+
force: true,
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
return { success: true, strategy, retries, sealedCommit: targetRef, inscriptionsSealed: 0 };
|
|
417
|
+
}
|
|
418
|
+
// Check if target is an ancestor of source (ff is possible)
|
|
419
|
+
const { stdout: mergeBase } = await git(['merge-base', targetBranch, request.sourceBranch], clonePath);
|
|
420
|
+
if (mergeBase === targetRef) {
|
|
421
|
+
// Fast-forward is possible — count and incorporate inscriptions
|
|
422
|
+
const inscriptionsSealed = await commitsAhead(clonePath, request.sourceBranch, targetBranch);
|
|
423
|
+
await git(['update-ref', `refs/heads/${targetBranch}`, sourceRef], clonePath);
|
|
424
|
+
// Clean up draft unless keepDraft
|
|
425
|
+
if (!request.keepDraft) {
|
|
426
|
+
await this.abandonDraft({
|
|
427
|
+
codexName: request.codexName,
|
|
428
|
+
branch: request.sourceBranch,
|
|
429
|
+
force: true,
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
return { success: true, strategy, retries, sealedCommit: sourceRef, inscriptionsSealed };
|
|
433
|
+
}
|
|
434
|
+
// FF not possible — rebase the source branch onto the target
|
|
435
|
+
strategy = 'rebase';
|
|
436
|
+
// Rebase needs a worktree (can't rebase in a bare repo).
|
|
437
|
+
// Use the draft's existing worktree.
|
|
438
|
+
const key = `${request.codexName}/${request.sourceBranch}`;
|
|
439
|
+
const draft = this.drafts.get(key);
|
|
440
|
+
if (!draft) {
|
|
441
|
+
throw new Error(`Cannot rebase: no active draft for branch "${request.sourceBranch}". ` +
|
|
442
|
+
`The draft worktree is needed for rebase operations.`);
|
|
443
|
+
}
|
|
444
|
+
try {
|
|
445
|
+
await git(['rebase', targetBranch], draft.path);
|
|
446
|
+
}
|
|
447
|
+
catch (err) {
|
|
448
|
+
// Rebase conflict — abort and fail
|
|
449
|
+
try {
|
|
450
|
+
await git(['rebase', '--abort'], draft.path);
|
|
451
|
+
}
|
|
452
|
+
catch { /* best effort */ }
|
|
453
|
+
throw new Error(`Sealing seized: rebase of "${request.sourceBranch}" onto "${targetBranch}" ` +
|
|
454
|
+
`produced conflicts. Manual reconciliation is needed.`);
|
|
455
|
+
}
|
|
456
|
+
// Rebase succeeded — re-fetch and retry the ff merge
|
|
457
|
+
retries++;
|
|
458
|
+
await this.performFetch(state.name);
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
catch (err) {
|
|
462
|
+
if (err instanceof Error && err.message.includes('Sealing seized')) {
|
|
463
|
+
throw err;
|
|
464
|
+
}
|
|
465
|
+
if (err instanceof Error && err.message.includes('Cannot rebase')) {
|
|
466
|
+
throw err;
|
|
467
|
+
}
|
|
468
|
+
// Unexpected error — don't retry
|
|
469
|
+
throw err;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
throw new Error(`Sealing failed after ${maxRetries} retries. Codex "${request.codexName}", ` +
|
|
473
|
+
`branch "${request.sourceBranch}" → "${targetBranch}".`);
|
|
474
|
+
}
|
|
475
|
+
// ── Helpers ───────────────────────────────────────────────────────
|
|
476
|
+
draftsForCodex(codexName) {
|
|
477
|
+
return [...this.drafts.values()].filter((d) => d.codexName === codexName);
|
|
478
|
+
}
|
|
479
|
+
toCodexRecord(state) {
|
|
480
|
+
return {
|
|
481
|
+
name: state.name,
|
|
482
|
+
remoteUrl: state.remoteUrl,
|
|
483
|
+
cloneStatus: state.cloneStatus,
|
|
484
|
+
activeDrafts: this.draftsForCodex(state.name).length,
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
//# sourceMappingURL=scriptorium-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,MAAM,GAAG,CAAC;gBACZ,CAAC;gBACD,IAAI,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;oBAClE,MAAM,GAAG,CAAC;gBACZ,CAAC;gBACD,iCAAiC;gBACjC,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC;QAED,MAAM,IAAI,KAAK,CACb,wBAAwB,UAAU,oBAAoB,OAAO,CAAC,SAAS,KAAK;YAC5E,WAAW,OAAO,CAAC,YAAY,QAAQ,YAAY,IAAI,CACxD,CAAC;IACJ,CAAC;IAED,qEAAqE;IAE7D,cAAc,CAAC,SAAiB;QACtC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;IAC5E,CAAC;IAEO,aAAa,CAAC,KAAiB;QACrC,OAAO;YACL,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM;SACrD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Scriptorium — apparatus implementation.
|
|
3
|
+
*
|
|
4
|
+
* Wires together the ScriptoriumCore (git operations, draft lifecycle)
|
|
5
|
+
* and exposes the ScriptoriumApi as the `provides` object. Tools are
|
|
6
|
+
* contributed via supportKit.
|
|
7
|
+
*
|
|
8
|
+
* See: docs/architecture/apparatus/scriptorium.md
|
|
9
|
+
*/
|
|
10
|
+
import type { Plugin } from '@shardworks/nexus-core';
|
|
11
|
+
export declare function createScriptorium(): Plugin;
|
|
12
|
+
//# sourceMappingURL=scriptorium.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scriptorium.d.ts","sourceRoot":"","sources":["../src/scriptorium.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,MAAM,EAEP,MAAM,wBAAwB,CAAC;AAmBhC,wBAAgB,iBAAiB,IAAI,MAAM,CA+B1C"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Scriptorium — apparatus implementation.
|
|
3
|
+
*
|
|
4
|
+
* Wires together the ScriptoriumCore (git operations, draft lifecycle)
|
|
5
|
+
* and exposes the ScriptoriumApi as the `provides` object. Tools are
|
|
6
|
+
* contributed via supportKit.
|
|
7
|
+
*
|
|
8
|
+
* See: docs/architecture/apparatus/scriptorium.md
|
|
9
|
+
*/
|
|
10
|
+
import { ScriptoriumCore } from "./scriptorium-core.js";
|
|
11
|
+
import { codexAdd, codexList, codexShow, codexRemove, codexPush, draftOpen, draftList, draftAbandon, draftSeal, } from "./tools/index.js";
|
|
12
|
+
// ── Apparatus export ──────────────────────────────────────────────────
|
|
13
|
+
export function createScriptorium() {
|
|
14
|
+
const core = new ScriptoriumCore();
|
|
15
|
+
let api;
|
|
16
|
+
return {
|
|
17
|
+
apparatus: {
|
|
18
|
+
requires: [],
|
|
19
|
+
consumes: [],
|
|
20
|
+
get provides() { return api; },
|
|
21
|
+
supportKit: {
|
|
22
|
+
tools: [
|
|
23
|
+
codexAdd,
|
|
24
|
+
codexList,
|
|
25
|
+
codexShow,
|
|
26
|
+
codexRemove,
|
|
27
|
+
codexPush,
|
|
28
|
+
draftOpen,
|
|
29
|
+
draftList,
|
|
30
|
+
draftAbandon,
|
|
31
|
+
draftSeal,
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
start(_ctx) {
|
|
35
|
+
core.start();
|
|
36
|
+
api = core.createApi();
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=scriptorium.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scriptorium.js","sourceRoot":"","sources":["../src/scriptorium.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EACL,QAAQ,EACR,SAAS,EACT,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,SAAS,EACT,YAAY,EACZ,SAAS,GACV,MAAM,kBAAkB,CAAC;AAE1B,yEAAyE;AAEzE,MAAM,UAAU,iBAAiB;IAC/B,MAAM,IAAI,GAAG,IAAI,eAAe,EAAE,CAAC;IACnC,IAAI,GAAmB,CAAC;IAExB,OAAO;QACL,SAAS,EAAE;YACT,QAAQ,EAAE,EAAE;YACZ,QAAQ,EAAE,EAAE;YAEZ,IAAI,QAAQ,KAAK,OAAO,GAAG,CAAC,CAAC,CAAC;YAE9B,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,QAAQ;oBACR,SAAS;oBACT,SAAS;oBACT,WAAW;oBACX,SAAS;oBACT,SAAS;oBACT,SAAS;oBACT,YAAY;oBACZ,SAAS;iBACV;aACF;YAED,KAAK,CAAC,IAAoB;gBACxB,IAAI,CAAC,KAAK,EAAE,CAAC;gBACb,GAAG,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YACzB,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* codex-add tool — register an existing git repository as a guild codex.
|
|
3
|
+
*
|
|
4
|
+
* Clones a bare copy to `.nexus/codexes/<name>.git` and adds the entry
|
|
5
|
+
* to guild.json. Blocks until the clone completes.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
declare const _default: import("@shardworks/tools-apparatus").ToolDefinition<{
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
remoteUrl: z.ZodString;
|
|
11
|
+
}>;
|
|
12
|
+
export default _default;
|
|
13
|
+
//# sourceMappingURL=codex-add.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-add.d.ts","sourceRoot":"","sources":["../../src/tools/codex-add.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;;;;;AAGxB,wBAYG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* codex-add tool — register an existing git repository as a guild codex.
|
|
3
|
+
*
|
|
4
|
+
* Clones a bare copy to `.nexus/codexes/<name>.git` and adds the entry
|
|
5
|
+
* to guild.json. Blocks until the clone completes.
|
|
6
|
+
*/
|
|
7
|
+
import { tool } from '@shardworks/tools-apparatus';
|
|
8
|
+
import { guild } from '@shardworks/nexus-core';
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
export default tool({
|
|
11
|
+
name: 'codex-add',
|
|
12
|
+
description: 'Register an existing git repository as a guild codex',
|
|
13
|
+
permission: 'write',
|
|
14
|
+
params: {
|
|
15
|
+
name: z.string().describe('Name for the codex (unique within the guild)'),
|
|
16
|
+
remoteUrl: z.string().describe('Git remote URL of the repository'),
|
|
17
|
+
},
|
|
18
|
+
handler: async ({ name, remoteUrl }) => {
|
|
19
|
+
const api = guild().apparatus('codexes');
|
|
20
|
+
return api.add(name, remoteUrl);
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=codex-add.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-add.js","sourceRoot":"","sources":["../../src/tools/codex-add.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAe,IAAI,CAAC;IAClB,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,sDAAsD;IACnE,UAAU,EAAE,OAAO;IACnB,MAAM,EAAE;QACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8CAA8C,CAAC;QACzE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;KACnE;IACD,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE;QACrC,MAAM,GAAG,GAAG,KAAK,EAAE,CAAC,SAAS,CAAiB,SAAS,CAAC,CAAC;QACzD,OAAO,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAClC,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-list.d.ts","sourceRoot":"","sources":["../../src/tools/codex-list.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAOH,wBASG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* codex-list tool — list all registered codexes.
|
|
3
|
+
*/
|
|
4
|
+
import { tool } from '@shardworks/tools-apparatus';
|
|
5
|
+
import { guild } from '@shardworks/nexus-core';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export default tool({
|
|
8
|
+
name: 'codex-list',
|
|
9
|
+
description: 'List all codexes registered with the guild',
|
|
10
|
+
permission: 'read',
|
|
11
|
+
params: {},
|
|
12
|
+
handler: async () => {
|
|
13
|
+
const api = guild().apparatus('codexes');
|
|
14
|
+
return api.list();
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=codex-list.js.map
|