@shardworks/nexus-core 0.1.100 → 0.1.102

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 (166) hide show
  1. package/README.md +95 -166
  2. package/dist/guild-config.d.ts +14 -52
  3. package/dist/guild-config.d.ts.map +1 -1
  4. package/dist/guild-config.js +7 -10
  5. package/dist/guild-config.js.map +1 -1
  6. package/dist/guild.d.ts +83 -0
  7. package/dist/guild.d.ts.map +1 -0
  8. package/dist/guild.js +45 -0
  9. package/dist/guild.js.map +1 -0
  10. package/dist/id.d.ts +14 -0
  11. package/dist/id.d.ts.map +1 -0
  12. package/dist/id.js +19 -0
  13. package/dist/id.js.map +1 -0
  14. package/dist/index.d.ts +6 -30
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +7 -32
  17. package/dist/index.js.map +1 -1
  18. package/dist/nexus-home.d.ts +0 -4
  19. package/dist/nexus-home.d.ts.map +1 -1
  20. package/dist/nexus-home.js +1 -9
  21. package/dist/nexus-home.js.map +1 -1
  22. package/dist/plugin.d.ts +115 -0
  23. package/dist/plugin.d.ts.map +1 -0
  24. package/dist/plugin.js +39 -0
  25. package/dist/plugin.js.map +1 -0
  26. package/dist/resolve-package.d.ts +58 -0
  27. package/dist/resolve-package.d.ts.map +1 -0
  28. package/dist/resolve-package.js +123 -0
  29. package/dist/resolve-package.js.map +1 -0
  30. package/package.json +5 -14
  31. package/dist/book.d.ts +0 -110
  32. package/dist/book.d.ts.map +0 -1
  33. package/dist/book.js +0 -16
  34. package/dist/book.js.map +0 -1
  35. package/dist/legacy/1/anima.d.ts +0 -79
  36. package/dist/legacy/1/anima.d.ts.map +0 -1
  37. package/dist/legacy/1/anima.js +0 -285
  38. package/dist/legacy/1/anima.js.map +0 -1
  39. package/dist/legacy/1/audit.d.ts +0 -23
  40. package/dist/legacy/1/audit.d.ts.map +0 -1
  41. package/dist/legacy/1/audit.js +0 -61
  42. package/dist/legacy/1/audit.js.map +0 -1
  43. package/dist/legacy/1/bundle.d.ts +0 -111
  44. package/dist/legacy/1/bundle.d.ts.map +0 -1
  45. package/dist/legacy/1/bundle.js +0 -452
  46. package/dist/legacy/1/bundle.js.map +0 -1
  47. package/dist/legacy/1/clock-daemon.d.ts +0 -2
  48. package/dist/legacy/1/clock-daemon.d.ts.map +0 -1
  49. package/dist/legacy/1/clock-daemon.js +0 -72
  50. package/dist/legacy/1/clock-daemon.js.map +0 -1
  51. package/dist/legacy/1/clockworks.d.ts +0 -98
  52. package/dist/legacy/1/clockworks.d.ts.map +0 -1
  53. package/dist/legacy/1/clockworks.js +0 -359
  54. package/dist/legacy/1/clockworks.js.map +0 -1
  55. package/dist/legacy/1/conversation.d.ts +0 -165
  56. package/dist/legacy/1/conversation.d.ts.map +0 -1
  57. package/dist/legacy/1/conversation.js +0 -457
  58. package/dist/legacy/1/conversation.js.map +0 -1
  59. package/dist/legacy/1/engine.d.ts +0 -90
  60. package/dist/legacy/1/engine.d.ts.map +0 -1
  61. package/dist/legacy/1/engine.js +0 -89
  62. package/dist/legacy/1/engine.js.map +0 -1
  63. package/dist/legacy/1/events.d.ts +0 -88
  64. package/dist/legacy/1/events.d.ts.map +0 -1
  65. package/dist/legacy/1/events.js +0 -239
  66. package/dist/legacy/1/events.js.map +0 -1
  67. package/dist/legacy/1/guild-config.d.ts +0 -74
  68. package/dist/legacy/1/guild-config.d.ts.map +0 -1
  69. package/dist/legacy/1/guild-config.js +0 -51
  70. package/dist/legacy/1/guild-config.js.map +0 -1
  71. package/dist/legacy/1/id.d.ts +0 -8
  72. package/dist/legacy/1/id.d.ts.map +0 -1
  73. package/dist/legacy/1/id.js +0 -27
  74. package/dist/legacy/1/id.js.map +0 -1
  75. package/dist/legacy/1/index.d.ts +0 -28
  76. package/dist/legacy/1/index.d.ts.map +0 -1
  77. package/dist/legacy/1/index.js +0 -32
  78. package/dist/legacy/1/index.js.map +0 -1
  79. package/dist/legacy/1/init-guild.d.ts +0 -24
  80. package/dist/legacy/1/init-guild.d.ts.map +0 -1
  81. package/dist/legacy/1/init-guild.js +0 -230
  82. package/dist/legacy/1/init-guild.js.map +0 -1
  83. package/dist/legacy/1/install-tool.d.ts +0 -73
  84. package/dist/legacy/1/install-tool.d.ts.map +0 -1
  85. package/dist/legacy/1/install-tool.js +0 -436
  86. package/dist/legacy/1/install-tool.js.map +0 -1
  87. package/dist/legacy/1/instantiate.d.ts +0 -33
  88. package/dist/legacy/1/instantiate.d.ts.map +0 -1
  89. package/dist/legacy/1/instantiate.js +0 -137
  90. package/dist/legacy/1/instantiate.js.map +0 -1
  91. package/dist/legacy/1/manifest.d.ts +0 -132
  92. package/dist/legacy/1/manifest.d.ts.map +0 -1
  93. package/dist/legacy/1/manifest.js +0 -321
  94. package/dist/legacy/1/manifest.js.map +0 -1
  95. package/dist/legacy/1/migrate.d.ts +0 -84
  96. package/dist/legacy/1/migrate.d.ts.map +0 -1
  97. package/dist/legacy/1/migrate.js +0 -228
  98. package/dist/legacy/1/migrate.js.map +0 -1
  99. package/dist/legacy/1/nexus-home.d.ts +0 -11
  100. package/dist/legacy/1/nexus-home.d.ts.map +0 -1
  101. package/dist/legacy/1/nexus-home.js +0 -16
  102. package/dist/legacy/1/nexus-home.js.map +0 -1
  103. package/dist/legacy/1/plugin-descriptor.d.ts +0 -3
  104. package/dist/legacy/1/plugin-descriptor.d.ts.map +0 -1
  105. package/dist/legacy/1/plugin-descriptor.js +0 -2
  106. package/dist/legacy/1/plugin-descriptor.js.map +0 -1
  107. package/dist/legacy/1/preconditions.d.ts +0 -100
  108. package/dist/legacy/1/preconditions.d.ts.map +0 -1
  109. package/dist/legacy/1/preconditions.js +0 -189
  110. package/dist/legacy/1/preconditions.js.map +0 -1
  111. package/dist/legacy/1/rehydrate.d.ts +0 -22
  112. package/dist/legacy/1/rehydrate.d.ts.map +0 -1
  113. package/dist/legacy/1/rehydrate.js +0 -109
  114. package/dist/legacy/1/rehydrate.js.map +0 -1
  115. package/dist/legacy/1/remove-tool.d.ts +0 -19
  116. package/dist/legacy/1/remove-tool.d.ts.map +0 -1
  117. package/dist/legacy/1/remove-tool.js +0 -105
  118. package/dist/legacy/1/remove-tool.js.map +0 -1
  119. package/dist/legacy/1/session.d.ts +0 -343
  120. package/dist/legacy/1/session.d.ts.map +0 -1
  121. package/dist/legacy/1/session.js +0 -499
  122. package/dist/legacy/1/session.js.map +0 -1
  123. package/dist/legacy/1/tool-registry.d.ts +0 -12
  124. package/dist/legacy/1/tool-registry.d.ts.map +0 -1
  125. package/dist/legacy/1/tool-registry.js +0 -28
  126. package/dist/legacy/1/tool-registry.js.map +0 -1
  127. package/dist/legacy/1/tool.d.ts +0 -10
  128. package/dist/legacy/1/tool.d.ts.map +0 -1
  129. package/dist/legacy/1/tool.js +0 -2
  130. package/dist/legacy/1/tool.js.map +0 -1
  131. package/dist/legacy/1/upgrade.d.ts +0 -129
  132. package/dist/legacy/1/upgrade.d.ts.map +0 -1
  133. package/dist/legacy/1/upgrade.js +0 -355
  134. package/dist/legacy/1/upgrade.js.map +0 -1
  135. package/dist/legacy/1/workshop.d.ts +0 -95
  136. package/dist/legacy/1/workshop.d.ts.map +0 -1
  137. package/dist/legacy/1/workshop.js +0 -229
  138. package/dist/legacy/1/workshop.js.map +0 -1
  139. package/dist/legacy/1/worktree.d.ts +0 -67
  140. package/dist/legacy/1/worktree.d.ts.map +0 -1
  141. package/dist/legacy/1/worktree.js +0 -117
  142. package/dist/legacy/1/worktree.js.map +0 -1
  143. package/dist/legacy/1/writ.d.ts +0 -130
  144. package/dist/legacy/1/writ.d.ts.map +0 -1
  145. package/dist/legacy/1/writ.js +0 -599
  146. package/dist/legacy/1/writ.js.map +0 -1
  147. package/dist/rig-context.d.ts +0 -47
  148. package/dist/rig-context.d.ts.map +0 -1
  149. package/dist/rig-context.js +0 -11
  150. package/dist/rig-context.js.map +0 -1
  151. package/dist/rig-descriptor.d.ts +0 -39
  152. package/dist/rig-descriptor.d.ts.map +0 -1
  153. package/dist/rig-descriptor.js +0 -12
  154. package/dist/rig-descriptor.js.map +0 -1
  155. package/dist/rig.d.ts +0 -70
  156. package/dist/rig.d.ts.map +0 -1
  157. package/dist/rig.js +0 -14
  158. package/dist/rig.js.map +0 -1
  159. package/dist/tool.d.ts +0 -136
  160. package/dist/tool.d.ts.map +0 -1
  161. package/dist/tool.js +0 -135
  162. package/dist/tool.js.map +0 -1
  163. package/migrations/001-schema.sql +0 -177
  164. package/migrations/002-writs.sql +0 -44
  165. package/migrations/003-conversations.sql +0 -43
  166. package/migrations/004-remove-commissions.sql +0 -24
@@ -1,229 +0,0 @@
1
- /**
2
- * workshop — core logic for managing guild workshops.
3
- *
4
- * Workshops are repositories where the guild does its work. Each workshop
5
- * is stored as a bare git clone in .nexus/workshops/{name}.git, with
6
- * writ worktrees created from it by the workshop-prepare engine.
7
- *
8
- * This module provides:
9
- * - addWorkshop: clone a remote repo and register it in guild.json
10
- * - removeWorkshop: remove the bare clone, worktrees, and guild.json entry
11
- * - listWorkshops: return workshop entries with status info
12
- * - createWorkshop: create a new GitHub repo via `gh`, then add it
13
- */
14
- import { execFileSync } from 'node:child_process';
15
- import fs from 'node:fs';
16
- import path from 'node:path';
17
- import { readGuildConfig, writeGuildConfig } from "./guild-config.js";
18
- import { workshopBarePath, workshopsPath, worktreesPath } from "./nexus-home.js";
19
- // ── Helpers ────────────────────────────────────────────────────────────
20
- function git(args, cwd) {
21
- return execFileSync('git', args, {
22
- cwd,
23
- encoding: 'utf-8',
24
- stdio: ['pipe', 'pipe', 'pipe'],
25
- }).trim();
26
- }
27
- function gh(args) {
28
- return execFileSync('gh', args, {
29
- encoding: 'utf-8',
30
- stdio: ['pipe', 'pipe', 'pipe'],
31
- }).trim();
32
- }
33
- /**
34
- * Derive a workshop name from a remote URL or repo name.
35
- * "https://github.com/org/my-repo.git" → "my-repo"
36
- * "org/my-repo" → "my-repo"
37
- * "git@github.com:org/my-repo.git" → "my-repo"
38
- */
39
- export function deriveWorkshopName(input) {
40
- // Handle org/name format
41
- if (input.includes('/') && !input.includes(':') && !input.includes('.')) {
42
- return input.split('/').pop();
43
- }
44
- // Handle URLs — take the last path segment, strip .git
45
- const basename = input.split('/').pop() ?? input;
46
- return basename.replace(/\.git$/, '');
47
- }
48
- // ── Core operations ───────────────────────────────────────────────────
49
- /**
50
- * Add a workshop by cloning a remote repo as a bare clone and registering
51
- * it in guild.json.
52
- *
53
- * @throws If the workshop name already exists in guild.json.
54
- * @throws If the bare clone directory already exists on disk.
55
- * @throws If the git clone fails.
56
- */
57
- export function addWorkshop(opts) {
58
- const { home, name, remoteUrl } = opts;
59
- const config = readGuildConfig(home);
60
- if (name in config.workshops) {
61
- throw new Error(`Workshop "${name}" already exists in guild.json.`);
62
- }
63
- const barePath = workshopBarePath(home, name);
64
- if (fs.existsSync(barePath)) {
65
- throw new Error(`Bare clone already exists at ${barePath}. Remove it first or choose a different name.`);
66
- }
67
- // Ensure workshops directory exists
68
- fs.mkdirSync(workshopsPath(home), { recursive: true });
69
- // Clone as bare repo
70
- git(['clone', '--bare', remoteUrl, barePath]);
71
- // Register in guild.json
72
- const entry = {
73
- remoteUrl,
74
- addedAt: new Date().toISOString(),
75
- };
76
- config.workshops[name] = entry;
77
- writeGuildConfig(home, config);
78
- return { name, remoteUrl, barePath };
79
- }
80
- /**
81
- * Remove a workshop — deletes the bare clone, any writ worktrees,
82
- * and the guild.json entry.
83
- *
84
- * @throws If the workshop doesn't exist in guild.json.
85
- */
86
- export function removeWorkshop(opts) {
87
- const { home, name } = opts;
88
- const config = readGuildConfig(home);
89
- if (!(name in config.workshops)) {
90
- throw new Error(`Workshop "${name}" not found in guild.json. Available workshops: ${Object.keys(config.workshops).join(', ') || '(none)'}`);
91
- }
92
- // Remove writ worktrees for this workshop
93
- const wtDir = path.join(worktreesPath(home), name);
94
- if (fs.existsSync(wtDir)) {
95
- fs.rmSync(wtDir, { recursive: true, force: true });
96
- }
97
- // Remove the bare clone
98
- const barePath = workshopBarePath(home, name);
99
- if (fs.existsSync(barePath)) {
100
- fs.rmSync(barePath, { recursive: true, force: true });
101
- }
102
- // Remove from guild.json
103
- delete config.workshops[name];
104
- writeGuildConfig(home, config);
105
- }
106
- /**
107
- * List all workshops with status info.
108
- */
109
- export function listWorkshops(home) {
110
- const config = readGuildConfig(home);
111
- const results = [];
112
- for (const [name, entry] of Object.entries(config.workshops)) {
113
- const barePath = workshopBarePath(home, name);
114
- const cloned = fs.existsSync(barePath);
115
- // Count active worktrees
116
- let activeWorktrees = 0;
117
- const wtDir = path.join(worktreesPath(home), name);
118
- if (fs.existsSync(wtDir)) {
119
- activeWorktrees = fs.readdirSync(wtDir, { withFileTypes: true })
120
- .filter(e => e.isDirectory())
121
- .length;
122
- }
123
- results.push({
124
- name,
125
- remoteUrl: entry.remoteUrl,
126
- addedAt: entry.addedAt,
127
- cloned,
128
- activeWorktrees,
129
- });
130
- }
131
- return results;
132
- }
133
- /**
134
- * Show detailed info for a single workshop.
135
- */
136
- export function showWorkshop(home, name) {
137
- const config = readGuildConfig(home);
138
- const entry = config.workshops[name];
139
- if (!entry)
140
- return null;
141
- const barePath = workshopBarePath(home, name);
142
- const cloned = fs.existsSync(barePath);
143
- let activeWorktrees = 0;
144
- const wtDir = path.join(worktreesPath(home), name);
145
- if (fs.existsSync(wtDir)) {
146
- activeWorktrees = fs.readdirSync(wtDir, { withFileTypes: true })
147
- .filter(e => e.isDirectory())
148
- .length;
149
- }
150
- let defaultBranch = null;
151
- if (cloned) {
152
- try {
153
- defaultBranch = git(['symbolic-ref', '--short', 'HEAD'], barePath);
154
- }
155
- catch { /* bare repos may not have HEAD set */ }
156
- }
157
- return {
158
- name,
159
- remoteUrl: entry.remoteUrl,
160
- addedAt: entry.addedAt,
161
- cloned,
162
- activeWorktrees,
163
- barePath,
164
- defaultBranch,
165
- };
166
- }
167
- /**
168
- * Check whether `gh` is installed and authenticated.
169
- * Returns null if OK, or an error message if not.
170
- */
171
- export function checkGhAuth() {
172
- try {
173
- execFileSync('which', ['gh'], { stdio: 'pipe' });
174
- }
175
- catch {
176
- return 'GitHub CLI (gh) is not installed. Install from https://cli.github.com/';
177
- }
178
- try {
179
- const output = execFileSync('gh', ['auth', 'status'], {
180
- encoding: 'utf-8',
181
- stdio: ['pipe', 'pipe', 'pipe'],
182
- });
183
- // gh auth status exits 0 when authenticated
184
- return null;
185
- }
186
- catch (err) {
187
- // gh auth status may write to stderr even on success in some versions
188
- if (err && typeof err === 'object' && 'stderr' in err) {
189
- const stderr = err.stderr ?? '';
190
- if (stderr.includes('Logged in'))
191
- return null;
192
- }
193
- return 'GitHub CLI is not authenticated. Run: gh auth login';
194
- }
195
- }
196
- /**
197
- * Create a new GitHub repo and add it as a workshop.
198
- *
199
- * Precondition: `gh` must be installed and authenticated. Call checkGhAuth()
200
- * first to verify.
201
- *
202
- * @param opts.repoName - Repository name in "org/name" format.
203
- * @throws If gh auth check fails, repo creation fails, or add fails.
204
- */
205
- export function createWorkshop(opts) {
206
- const { home, repoName, private: isPrivate = true } = opts;
207
- // Verify gh is available and authenticated
208
- const authError = checkGhAuth();
209
- if (authError) {
210
- throw new Error(authError);
211
- }
212
- // Create the repo on GitHub
213
- const visibility = isPrivate ? '--private' : '--public';
214
- gh(['repo', 'create', repoName, visibility, '--confirm']);
215
- // Get the clone URL
216
- const remoteUrl = `https://github.com/${repoName}.git`;
217
- const name = deriveWorkshopName(repoName);
218
- // Bare-clone the empty repo, then seed it with an initial commit
219
- // using git plumbing so worktrees have a real 'main' ref to branch from.
220
- const result = addWorkshop({ home, name, remoteUrl });
221
- const bare = result.barePath;
222
- git(['symbolic-ref', 'HEAD', 'refs/heads/main'], bare);
223
- const emptyTree = git(['mktree'], bare); // reads empty stdin → empty tree
224
- const commit = git(['commit-tree', emptyTree, '-m', `Initial commit\n\n# ${name}`], bare);
225
- git(['update-ref', 'refs/heads/main', commit], bare);
226
- git(['push', 'origin', 'main'], bare);
227
- return result;
228
- }
229
- //# sourceMappingURL=workshop.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":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AAI,CAAC,CAAC,CAAE,iCAAiC;IAC3E,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,uBAAuB,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IAC1F,GAAG,CAAC,CAAC,YAAY,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;IACrD,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;IAEtC,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,67 +0,0 @@
1
- /**
2
- * Writ worktree management — creates isolated git worktrees for
3
- * writ sessions.
4
- *
5
- * When an anima is dispatched to work on a writ, this module:
6
- * 1. Creates a new git branch for the writ
7
- * 2. Sets up a git worktree pointing at that branch
8
- * 3. Returns the worktree path so the session can launch in the correct cwd
9
- *
10
- * Worktrees provide isolation — each writ gets its own working copy
11
- * of the repo, so multiple animas can work concurrently without conflicts
12
- * in the working directory.
13
- *
14
- * ## Directory layout
15
- *
16
- * Writ worktrees are created from workshop bare clones:
17
- *
18
- * GUILD_ROOT/
19
- * .nexus/
20
- * workshops/
21
- * workshop-a.git/ <- bare clone (source for worktrees)
22
- * worktrees/
23
- * workshop-a/
24
- * writ-42/ <- worktree for writ #42
25
- * workshop-b/
26
- * writ-17/ <- worktree for writ #17
27
- */
28
- export interface WorktreeConfig {
29
- /** Absolute path to the guild root. */
30
- home: string;
31
- /** Workshop name — the bare clone source for the worktree. */
32
- workshop: string;
33
- /** Writ ID — used to derive branch name and worktree directory. */
34
- writId: string;
35
- /** Base branch to create the worktree from (default: 'main'). */
36
- baseBranch?: string;
37
- }
38
- export interface WorktreeResult {
39
- /** Absolute path to the created worktree. */
40
- path: string;
41
- /** Branch name created for the worktree. */
42
- branch: string;
43
- /** Writ ID this worktree serves. */
44
- writId: string;
45
- }
46
- /**
47
- * Create a git worktree for a writ session.
48
- *
49
- * Creates a new branch from the base branch and sets up a worktree in
50
- * .nexus/worktrees/{workshop}/writ-{id}/.
51
- *
52
- * @throws If the worktree or branch already exists.
53
- */
54
- export declare function setupWorktree(config: WorktreeConfig): WorktreeResult;
55
- /**
56
- * Remove a worktree after a writ session completes.
57
- *
58
- * Removes the worktree directory and prunes it from git's tracking.
59
- * Does NOT delete the branch — the branch should be kept for history
60
- * until explicitly merged or pruned.
61
- */
62
- export declare function teardownWorktree(home: string, workshop: string, writId: string): void;
63
- /**
64
- * List active writ worktrees.
65
- */
66
- export declare function listWorktrees(home: string, workshop?: string): WorktreeResult[];
67
- //# sourceMappingURL=worktree.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../../../src/legacy/1/worktree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAOH,MAAM,WAAW,cAAc;IAC7B,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;CAChB;AAMD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAqBpE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAmBrF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,cAAc,EAAE,CAoC/E"}
@@ -1,117 +0,0 @@
1
- /**
2
- * Writ worktree management — creates isolated git worktrees for
3
- * writ sessions.
4
- *
5
- * When an anima is dispatched to work on a writ, this module:
6
- * 1. Creates a new git branch for the writ
7
- * 2. Sets up a git worktree pointing at that branch
8
- * 3. Returns the worktree path so the session can launch in the correct cwd
9
- *
10
- * Worktrees provide isolation — each writ gets its own working copy
11
- * of the repo, so multiple animas can work concurrently without conflicts
12
- * in the working directory.
13
- *
14
- * ## Directory layout
15
- *
16
- * Writ worktrees are created from workshop bare clones:
17
- *
18
- * GUILD_ROOT/
19
- * .nexus/
20
- * workshops/
21
- * workshop-a.git/ <- bare clone (source for worktrees)
22
- * worktrees/
23
- * workshop-a/
24
- * writ-42/ <- worktree for writ #42
25
- * workshop-b/
26
- * writ-17/ <- worktree for writ #17
27
- */
28
- import { execFileSync } from 'node:child_process';
29
- import fs from 'node:fs';
30
- import path from 'node:path';
31
- import { workshopBarePath, worktreesPath } from "./nexus-home.js";
32
- function git(args, cwd) {
33
- return execFileSync('git', args, { cwd, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
34
- }
35
- /**
36
- * Create a git worktree for a writ session.
37
- *
38
- * Creates a new branch from the base branch and sets up a worktree in
39
- * .nexus/worktrees/{workshop}/writ-{id}/.
40
- *
41
- * @throws If the worktree or branch already exists.
42
- */
43
- export function setupWorktree(config) {
44
- const { home, workshop, writId, baseBranch = 'main' } = config;
45
- const bareRepo = workshopBarePath(home, workshop);
46
- const branch = `writ-${writId}`;
47
- const worktreeDir = path.join(worktreesPath(home), workshop, branch);
48
- if (fs.existsSync(worktreeDir)) {
49
- throw new Error(`Worktree directory already exists: ${worktreeDir}. ` +
50
- `Writ ${writId} may already have an active worktree.`);
51
- }
52
- // Create parent directory
53
- fs.mkdirSync(path.dirname(worktreeDir), { recursive: true });
54
- // Create branch and worktree in one operation
55
- // git worktree add -b <branch> <path> <base>
56
- git(['worktree', 'add', '-b', branch, worktreeDir, baseBranch], bareRepo);
57
- return { path: worktreeDir, branch, writId };
58
- }
59
- /**
60
- * Remove a worktree after a writ session completes.
61
- *
62
- * Removes the worktree directory and prunes it from git's tracking.
63
- * Does NOT delete the branch — the branch should be kept for history
64
- * until explicitly merged or pruned.
65
- */
66
- export function teardownWorktree(home, workshop, writId) {
67
- const bareRepo = workshopBarePath(home, workshop);
68
- const branch = `writ-${writId}`;
69
- const worktreeDir = path.join(worktreesPath(home), workshop, branch);
70
- if (!fs.existsSync(worktreeDir)) {
71
- throw new Error(`Worktree not found: ${worktreeDir}. Writ ${writId} may not have an active worktree.`);
72
- }
73
- // Remove the worktree (--force handles untracked/modified files left by agents)
74
- git(['worktree', 'remove', '--force', worktreeDir], bareRepo);
75
- // Clean up the workshop worktree directory if empty
76
- const workshopDir = path.join(worktreesPath(home), workshop);
77
- if (fs.existsSync(workshopDir) && fs.readdirSync(workshopDir).length === 0) {
78
- fs.rmdirSync(workshopDir);
79
- }
80
- }
81
- /**
82
- * List active writ worktrees.
83
- */
84
- export function listWorktrees(home, workshop) {
85
- const wtRoot = worktreesPath(home);
86
- if (!fs.existsSync(wtRoot))
87
- return [];
88
- // If a specific workshop is given, only list worktrees for that workshop
89
- const workshopDirs = workshop
90
- ? [workshop]
91
- : fs.readdirSync(wtRoot, { withFileTypes: true })
92
- .filter(e => e.isDirectory())
93
- .map(e => e.name);
94
- const results = [];
95
- for (const ws of workshopDirs) {
96
- const wsDir = path.join(wtRoot, ws);
97
- if (!fs.existsSync(wsDir))
98
- continue;
99
- for (const entry of fs.readdirSync(wsDir, { withFileTypes: true })) {
100
- if (!entry.isDirectory())
101
- continue;
102
- // Match both new writ- and legacy commission- prefixes
103
- const writMatch = entry.name.match(/^writ-(.+)$/);
104
- const legacyMatch = entry.name.match(/^commission-(.+)$/);
105
- const match = writMatch ?? legacyMatch;
106
- if (!match)
107
- continue;
108
- results.push({
109
- path: path.join(wsDir, entry.name),
110
- branch: entry.name,
111
- writId: match[1],
112
- });
113
- }
114
- }
115
- return results;
116
- }
117
- //# sourceMappingURL=worktree.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worktree.js","sourceRoot":"","sources":["../../../src/legacy/1/worktree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAsBlE,SAAS,GAAG,CAAC,IAAc,EAAE,GAAW;IACtC,OAAO,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AACvG,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,MAAsB;IAClD,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;IAC/D,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,QAAQ,MAAM,EAAE,CAAC;IAChC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAErE,IAAI,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CACb,sCAAsC,WAAW,IAAI;YACrD,QAAQ,MAAM,uCAAuC,CACtD,CAAC;IACJ,CAAC;IAED,0BAA0B;IAC1B,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,C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I,CAAC;gBAClC,MAAM,EAAE,KAAK,CAAC,IAAI;gBAClB,MAAM,EAAE,KAAK,CAAC,CAAC,CAAE;aAClB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,130 +0,0 @@
1
- export type WritStatus = 'ready' | 'active' | 'pending' | 'completed' | 'failed' | 'cancelled';
2
- export interface WritRecord {
3
- id: string;
4
- type: string;
5
- title: string;
6
- description: string | null;
7
- status: WritStatus;
8
- parentId: string | null;
9
- sessionId: string | null;
10
- workshop: string | null;
11
- sourceType: 'patron' | 'anima' | 'engine';
12
- sourceId: string | null;
13
- createdAt: string;
14
- updatedAt: string;
15
- }
16
- export interface CreateWritOptions {
17
- type?: string;
18
- title: string;
19
- description?: string;
20
- parentId?: string;
21
- workshop?: string;
22
- sourceType?: 'patron' | 'anima' | 'engine';
23
- sourceId?: string;
24
- }
25
- export interface ListWritsOptions {
26
- parentId?: string;
27
- type?: string;
28
- status?: WritStatus;
29
- workshop?: string;
30
- }
31
- export interface WritChildSummary {
32
- id: string;
33
- type: string;
34
- title: string;
35
- status: WritStatus;
36
- childCount: number;
37
- completedCount: number;
38
- }
39
- /**
40
- * Built-in writ types that don't need guild.json declaration.
41
- * - 'writ' — the universal default for patron-posted and anima-created work
42
- * - 'summon' — internal tracking type for engine-synthesized sessions
43
- */
44
- export declare const BUILTIN_WRIT_TYPES: readonly ["writ", "summon"];
45
- /**
46
- * Validate that a writ type is declared in guild.json or is a built-in type.
47
- * Throws if the type is unknown.
48
- */
49
- export declare function validateWritType(home: string, type: string): void;
50
- /**
51
- * Create a writ. Validates type against guild.json. Fires `<type>.ready`.
52
- *
53
- * Type defaults to `'writ'` if omitted — the universal builtin type.
54
- *
55
- * Workshop inheritance: if `workshop` is omitted and `parentId` is provided,
56
- * the parent's workshop is copied. If both are omitted, workshop is null.
57
- *
58
- * Source defaults: `sourceType` defaults to `'engine'` if not provided.
59
- */
60
- export declare function createWrit(home: string, opts: CreateWritOptions): WritRecord;
61
- /**
62
- * Read a single writ by ID.
63
- */
64
- export declare function readWrit(home: string, writId: string): WritRecord | null;
65
- /**
66
- * List writs with optional filters.
67
- */
68
- export declare function listWrits(home: string, opts?: ListWritsOptions): WritRecord[];
69
- /**
70
- * Activate a writ: ready → active. Sets session_id. No event fired.
71
- */
72
- export declare function activateWrit(home: string, writId: string, sessionId: string): WritRecord;
73
- /**
74
- * Complete a writ. Called by complete-session.
75
- * - No children or all children complete → completed, fires <type>.completed, triggers rollup.
76
- * - Incomplete children exist → pending. No event fired.
77
- */
78
- export declare function completeWrit(home: string, writId: string): WritRecord;
79
- /**
80
- * Fail a writ. Terminal. Cascades cancellation to incomplete children.
81
- */
82
- export declare function failWrit(home: string, writId: string): WritRecord;
83
- /**
84
- * Cancel a writ. Cascades cancellation to incomplete children.
85
- */
86
- export declare function cancelWrit(home: string, writId: string): WritRecord;
87
- /**
88
- * Administratively complete a writ in pending or active state.
89
- * Fires <type>.completed (and writ.completed for custom types) and triggers
90
- * parent rollup, exactly as the normal completion path does.
91
- * Use case: unsticking a pending writ whose children were all cancelled.
92
- */
93
- export declare function adminCompleteWrit(home: string, writId: string): WritRecord;
94
- /**
95
- * Reopen a failed writ: failed → ready. Fires <type>.ready for re-dispatch.
96
- * Use case: recovering from a failed writ without having to cancel and recreate it.
97
- */
98
- export declare function reopenFailedWrit(home: string, writId: string): WritRecord;
99
- /**
100
- * Interrupt a writ: active → ready. Session ended without complete-session
101
- * or fail-writ. Fires <type>.ready for re-dispatch.
102
- */
103
- export declare function interruptWrit(home: string, writId: string): WritRecord;
104
- /**
105
- * Completion rollup. When a child completes, check the parent:
106
- * - Parent is pending and all siblings complete → parent transitions to ready
107
- * (if standing order exists for <type>.ready) or auto-completes (if not).
108
- * - Parent is pending and siblings remain incomplete → no action.
109
- */
110
- export declare function rollupParent(home: string, parentId: string): void;
111
- /**
112
- * Get direct children of a writ with nested child counts.
113
- */
114
- export declare function getWritChildren(home: string, writId: string): WritChildSummary[];
115
- /**
116
- * Build a markdown progress appendix for resumed sessions.
117
- * Returns null if the writ has no children.
118
- */
119
- export declare function buildProgressAppendix(home: string, writId: string): string | null;
120
- /**
121
- * Hydrate a prompt template by substituting variables from event payload
122
- * and writ fields. Returns null if no template provided.
123
- *
124
- * Scopes:
125
- * {{field}} — event payload
126
- * {{writ.field}} — bound writ (camelCase)
127
- * {{writ.parent.field}} — parent writ (one level up)
128
- */
129
- export declare function hydratePromptTemplate(home: string, template: string | undefined, payload: Record<string, unknown>, writId: string): string | null;
130
- //# sourceMappingURL=writ.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"writ.d.ts","sourceRoot":"","sources":["../../../src/legacy/1/writ.ts"],"names":[],"mappings":"AAuBA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE/F,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC1C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,E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