@shardworks/spider-apparatus 0.1.115

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 (50) hide show
  1. package/LICENSE +15 -0
  2. package/dist/engines/draft.d.ts +10 -0
  3. package/dist/engines/draft.d.ts.map +1 -0
  4. package/dist/engines/draft.js +33 -0
  5. package/dist/engines/draft.js.map +1 -0
  6. package/dist/engines/implement.d.ts +12 -0
  7. package/dist/engines/implement.d.ts.map +1 -0
  8. package/dist/engines/implement.js +29 -0
  9. package/dist/engines/implement.js.map +1 -0
  10. package/dist/engines/index.d.ts +6 -0
  11. package/dist/engines/index.d.ts.map +1 -0
  12. package/dist/engines/index.js +6 -0
  13. package/dist/engines/index.js.map +1 -0
  14. package/dist/engines/review.d.ts +17 -0
  15. package/dist/engines/review.d.ts.map +1 -0
  16. package/dist/engines/review.js +140 -0
  17. package/dist/engines/review.js.map +1 -0
  18. package/dist/engines/revise.d.ts +15 -0
  19. package/dist/engines/revise.d.ts.map +1 -0
  20. package/dist/engines/revise.js +90 -0
  21. package/dist/engines/revise.js.map +1 -0
  22. package/dist/engines/seal.d.ts +11 -0
  23. package/dist/engines/seal.d.ts.map +1 -0
  24. package/dist/engines/seal.js +31 -0
  25. package/dist/engines/seal.js.map +1 -0
  26. package/dist/index.d.ts +13 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +13 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/spider.d.ts +20 -0
  31. package/dist/spider.d.ts.map +1 -0
  32. package/dist/spider.js +356 -0
  33. package/dist/spider.js.map +1 -0
  34. package/dist/tools/crawl-continual.d.ts +13 -0
  35. package/dist/tools/crawl-continual.d.ts.map +1 -0
  36. package/dist/tools/crawl-continual.js +63 -0
  37. package/dist/tools/crawl-continual.js.map +1 -0
  38. package/dist/tools/crawl.d.ts +9 -0
  39. package/dist/tools/crawl.d.ts.map +1 -0
  40. package/dist/tools/crawl.js +22 -0
  41. package/dist/tools/crawl.js.map +1 -0
  42. package/dist/tools/index.d.ts +3 -0
  43. package/dist/tools/index.d.ts.map +1 -0
  44. package/dist/tools/index.js +3 -0
  45. package/dist/tools/index.js.map +1 -0
  46. package/dist/types.d.ts +208 -0
  47. package/dist/types.d.ts.map +1 -0
  48. package/dist/types.js +9 -0
  49. package/dist/types.js.map +1 -0
  50. package/package.json +39 -0
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 Sean Boots
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Draft engine — clockwork.
3
+ *
4
+ * Opens a draft binding via the Scriptorium. Returns DraftYields
5
+ * containing the worktree path and branch name for downstream engines.
6
+ */
7
+ import type { EngineDesign } from '@shardworks/fabricator-apparatus';
8
+ declare const draftEngine: EngineDesign;
9
+ export default draftEngine;
10
+ //# sourceMappingURL=draft.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draft.d.ts","sourceRoot":"","sources":["../../src/engines/draft.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAKrE,QAAA,MAAM,WAAW,EAAE,YA8BlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Draft engine — clockwork.
3
+ *
4
+ * Opens a draft binding via the Scriptorium. Returns DraftYields
5
+ * containing the worktree path and branch name for downstream engines.
6
+ */
7
+ import { execSync } from 'node:child_process';
8
+ import { guild } from '@shardworks/nexus-core';
9
+ const draftEngine = {
10
+ id: 'draft',
11
+ async run(givens, _context) {
12
+ const scriptorium = guild().apparatus('codexes');
13
+ const writ = givens.writ;
14
+ if (!writ.codex) {
15
+ throw new Error(`Writ "${writ.id}" has no codex — cannot open a draft binding.`);
16
+ }
17
+ const draft = await scriptorium.openDraft({
18
+ codexName: writ.codex,
19
+ associatedWith: writ.id,
20
+ });
21
+ const baseSha = execSync('git rev-parse HEAD', { cwd: draft.path, encoding: 'utf-8' }).trim();
22
+ const yields = {
23
+ draftId: draft.id,
24
+ codexName: draft.codexName,
25
+ branch: draft.branch,
26
+ path: draft.path,
27
+ baseSha,
28
+ };
29
+ return { status: 'completed', yields };
30
+ },
31
+ };
32
+ export default draftEngine;
33
+ //# sourceMappingURL=draft.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draft.js","sourceRoot":"","sources":["../../src/engines/draft.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAM/C,MAAM,WAAW,GAAiB;IAChC,EAAE,EAAE,OAAO;IAEX,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ;QACxB,MAAM,WAAW,GAAG,KAAK,EAAE,CAAC,SAAS,CAAiB,SAAS,CAAC,CAAC;QACjE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAe,CAAC;QAEpC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CACb,SAAS,IAAI,CAAC,EAAE,+CAA+C,CAChE,CAAC;QACJ,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,SAAS,CAAC;YACxC,SAAS,EAAE,IAAI,CAAC,KAAK;YACrB,cAAc,EAAE,IAAI,CAAC,EAAE;SACxB,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,QAAQ,CAAC,oBAAoB,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAE9F,MAAM,MAAM,GAAgB;YAC1B,OAAO,EAAE,KAAK,CAAC,EAAE;YACjB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO;SACR,CAAC;QAEF,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;IACzC,CAAC;CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Implement engine — quick (Animator-backed).
3
+ *
4
+ * Summons an anima to do the commissioned work. Wraps the writ body with
5
+ * a commit instruction, then calls animator.summon() with the draft
6
+ * worktree as the working directory. Returns `{ status: 'launched', sessionId }`
7
+ * so the Spider's collect step can poll for completion on subsequent walks.
8
+ */
9
+ import type { EngineDesign } from '@shardworks/fabricator-apparatus';
10
+ declare const implementEngine: EngineDesign;
11
+ export default implementEngine;
12
+ //# sourceMappingURL=implement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"implement.d.ts","sourceRoot":"","sources":["../../src/engines/implement.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAKrE,QAAA,MAAM,eAAe,EAAE,YAqBtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Implement engine — quick (Animator-backed).
3
+ *
4
+ * Summons an anima to do the commissioned work. Wraps the writ body with
5
+ * a commit instruction, then calls animator.summon() with the draft
6
+ * worktree as the working directory. Returns `{ status: 'launched', sessionId }`
7
+ * so the Spider's collect step can poll for completion on subsequent walks.
8
+ */
9
+ import { guild } from '@shardworks/nexus-core';
10
+ const implementEngine = {
11
+ id: 'implement',
12
+ async run(givens, context) {
13
+ const animator = guild().apparatus('animator');
14
+ const writ = givens.writ;
15
+ const draft = context.upstream['draft'];
16
+ const prompt = `${writ.body}\n\nCommit all changes before ending your session.`;
17
+ const handle = animator.summon({
18
+ role: givens.role,
19
+ prompt,
20
+ cwd: draft.path,
21
+ environment: { GIT_AUTHOR_EMAIL: `${writ.id}@nexus.local` },
22
+ metadata: { engineId: context.engineId, writId: writ.id },
23
+ });
24
+ const sessionResult = await handle.result;
25
+ return { status: 'launched', sessionId: sessionResult.id };
26
+ },
27
+ };
28
+ export default implementEngine;
29
+ //# sourceMappingURL=implement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"implement.js","sourceRoot":"","sources":["../../src/engines/implement.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAM/C,MAAM,eAAe,GAAiB;IACpC,EAAE,EAAE,WAAW;IAEf,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO;QACvB,MAAM,QAAQ,GAAG,KAAK,EAAE,CAAC,SAAS,CAAc,UAAU,CAAC,CAAC;QAC5D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAe,CAAC;QACpC,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB,CAAC;QAEvD,MAAM,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,oDAAoD,CAAC;QAEhF,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;YAC7B,IAAI,EAAE,MAAM,CAAC,IAAc;YAC3B,MAAM;YACN,GAAG,EAAE,KAAK,CAAC,IAAI;YACf,WAAW,EAAE,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC,EAAE,cAAc,EAAE;YAC3D,QAAQ,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;SAC1D,CAAC,CAAC;QAEH,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;QAC1C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,CAAC,EAAE,EAAE,CAAC;IAC7D,CAAC;CACF,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { default as draftEngine } from './draft.ts';
2
+ export { default as implementEngine } from './implement.ts';
3
+ export { default as reviewEngine } from './review.ts';
4
+ export { default as reviseEngine } from './revise.ts';
5
+ export { default as sealEngine } from './seal.ts';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engines/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { default as draftEngine } from "./draft.js";
2
+ export { default as implementEngine } from "./implement.js";
3
+ export { default as reviewEngine } from "./review.js";
4
+ export { default as reviseEngine } from "./revise.js";
5
+ export { default as sealEngine } from "./seal.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/engines/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Review engine — quick (Animator-backed).
3
+ *
4
+ * Runs mechanical checks (build/test) synchronously in the draft worktree,
5
+ * then summons a reviewer anima to assess the implementation against the spec.
6
+ * Returns `{ status: 'launched', sessionId }` so the Spider's collect step
7
+ * can parse the reviewer's findings from session.output on subsequent walks.
8
+ *
9
+ * Collect step (Spider):
10
+ * - Reads session.output as the reviewer's structured markdown findings
11
+ * - Parses `passed` from /^###\s*Overall:\s*PASS/mi
12
+ * - Retrieves mechanicalChecks from session.metadata
13
+ */
14
+ import type { EngineDesign } from '@shardworks/fabricator-apparatus';
15
+ declare const reviewEngine: EngineDesign;
16
+ export default reviewEngine;
17
+ //# sourceMappingURL=review.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review.d.ts","sourceRoot":"","sources":["../../src/engines/review.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAgGrE,QAAA,MAAM,YAAY,EAAE,YAuCnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Review engine — quick (Animator-backed).
3
+ *
4
+ * Runs mechanical checks (build/test) synchronously in the draft worktree,
5
+ * then summons a reviewer anima to assess the implementation against the spec.
6
+ * Returns `{ status: 'launched', sessionId }` so the Spider's collect step
7
+ * can parse the reviewer's findings from session.output on subsequent walks.
8
+ *
9
+ * Collect step (Spider):
10
+ * - Reads session.output as the reviewer's structured markdown findings
11
+ * - Parses `passed` from /^###\s*Overall:\s*PASS/mi
12
+ * - Retrieves mechanicalChecks from session.metadata
13
+ */
14
+ import { execFile } from 'node:child_process';
15
+ import { promisify } from 'node:util';
16
+ import { guild } from '@shardworks/nexus-core';
17
+ const execFileAsync = promisify(execFile);
18
+ async function runCheck(name, command, cwd) {
19
+ const start = Date.now();
20
+ try {
21
+ const { stdout, stderr } = await execFileAsync('sh', ['-c', command], { cwd });
22
+ const output = (stdout + stderr).slice(0, 4096);
23
+ return { name, passed: true, output, durationMs: Date.now() - start };
24
+ }
25
+ catch (err) {
26
+ const execErr = err;
27
+ const output = ((execErr.stdout ?? '') + (execErr.stderr ?? '')).slice(0, 4096);
28
+ return { name, passed: false, output, durationMs: Date.now() - start };
29
+ }
30
+ }
31
+ async function gitDiff(cwd, baseSha) {
32
+ try {
33
+ const { stdout } = await execFileAsync('git', ['diff', `${baseSha}..HEAD`], { cwd });
34
+ return stdout;
35
+ }
36
+ catch {
37
+ return '';
38
+ }
39
+ }
40
+ async function gitStatus(cwd) {
41
+ try {
42
+ const { stdout } = await execFileAsync('git', ['status', '--porcelain'], { cwd });
43
+ return stdout;
44
+ }
45
+ catch {
46
+ return '';
47
+ }
48
+ }
49
+ function assembleReviewPrompt(writ, diff, status, checks) {
50
+ const checksSection = checks.length === 0
51
+ ? '(No mechanical checks configured.)'
52
+ : checks.map((c) => `### ${c.name}: ${c.passed ? 'PASSED' : 'FAILED'}\n\`\`\`\n${c.output}\n\`\`\``).join('\n\n');
53
+ return `# Code Review
54
+
55
+ You are reviewing work on a commission. Your job is to assess whether the
56
+ implementation satisfies the spec, identify any gaps or problems, and produce
57
+ a structured findings document.
58
+
59
+ ## The Commission (Spec)
60
+
61
+ ${writ.body}
62
+
63
+ ## Implementation Diff
64
+
65
+ Changes since the draft was opened:
66
+
67
+ \`\`\`diff
68
+ ${diff}
69
+ \`\`\`
70
+
71
+ ## Current Worktree State
72
+
73
+ \`\`\`
74
+ ${status}
75
+ \`\`\`
76
+
77
+ ## Mechanical Check Results
78
+
79
+ ${checksSection}
80
+
81
+ ## Instructions
82
+
83
+ Assess the implementation against the spec. Produce your findings in this format:
84
+
85
+ ### Overall: PASS or FAIL
86
+
87
+ ### Completeness
88
+ - Which spec requirements are addressed?
89
+ - Which are missing or partially addressed?
90
+
91
+ ### Correctness
92
+ - Are there bugs, logic errors, or regressions?
93
+ - Do the tests pass? If not, what fails?
94
+
95
+ ### Quality
96
+ - Code style consistent with the codebase?
97
+ - Appropriate test coverage for new code?
98
+ - Any concerns about the approach?
99
+
100
+ ### Required Changes (if FAIL)
101
+ Numbered list of specific changes needed, in priority order.
102
+
103
+ Produce your findings as your final message in the format above.`;
104
+ }
105
+ const reviewEngine = {
106
+ id: 'review',
107
+ async run(givens, context) {
108
+ const animator = guild().apparatus('animator');
109
+ const writ = givens.writ;
110
+ const draft = context.upstream['draft'];
111
+ // 1. Run mechanical checks synchronously before the reviewer session
112
+ const checks = [];
113
+ if (givens.buildCommand) {
114
+ checks.push(await runCheck('build', givens.buildCommand, draft.path));
115
+ }
116
+ if (givens.testCommand) {
117
+ checks.push(await runCheck('test', givens.testCommand, draft.path));
118
+ }
119
+ // 2. Compute diff since draft opened and current worktree state
120
+ const diff = await gitDiff(draft.path, draft.baseSha);
121
+ const status = await gitStatus(draft.path);
122
+ // 3. Assemble review prompt
123
+ const prompt = assembleReviewPrompt(writ, diff, status, checks);
124
+ // 4. Launch reviewer session — stash mechanicalChecks in metadata for collect step
125
+ const handle = animator.summon({
126
+ role: givens.role,
127
+ prompt,
128
+ cwd: draft.path,
129
+ metadata: {
130
+ engineId: context.engineId,
131
+ writId: writ.id,
132
+ mechanicalChecks: checks,
133
+ },
134
+ });
135
+ const sessionResult = await handle.result;
136
+ return { status: 'launched', sessionId: sessionResult.id };
137
+ },
138
+ };
139
+ export default reviewEngine;
140
+ //# sourceMappingURL=review.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review.js","sourceRoot":"","sources":["../../src/engines/review.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAM/C,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,KAAK,UAAU,QAAQ,CAAC,IAAsB,EAAE,OAAe,EAAE,GAAW;IAC1E,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QAC/E,MAAM,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAChD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;IACxE,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,MAAM,OAAO,GAAG,GAA2C,CAAC;QAC5D,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAChF,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,G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CAAC;QAEH,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;QAC1C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,CAAC,EAAE,EAAE,CAAC;IAC7D,CAAC;CACF,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Revise engine — quick (Animator-backed).
3
+ *
4
+ * Summons an anima to address review findings. If the review passed, the
5
+ * prompt instructs the anima to confirm and exit without unnecessary changes.
6
+ * If the review failed, the prompt directs the anima to address each item
7
+ * in the findings and commit the result.
8
+ *
9
+ * Returns `{ status: 'launched', sessionId }` so the Spider's collect step
10
+ * can store ReviseYields on completion.
11
+ */
12
+ import type { EngineDesign } from '@shardworks/fabricator-apparatus';
13
+ declare const reviseEngine: EngineDesign;
14
+ export default reviseEngine;
15
+ //# sourceMappingURL=revise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revise.d.ts","sourceRoot":"","sources":["../../src/engines/revise.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AA8DrE,QAAA,MAAM,YAAY,EAAE,YAwBnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Revise engine — quick (Animator-backed).
3
+ *
4
+ * Summons an anima to address review findings. If the review passed, the
5
+ * prompt instructs the anima to confirm and exit without unnecessary changes.
6
+ * If the review failed, the prompt directs the anima to address each item
7
+ * in the findings and commit the result.
8
+ *
9
+ * Returns `{ status: 'launched', sessionId }` so the Spider's collect step
10
+ * can store ReviseYields on completion.
11
+ */
12
+ import { execFile } from 'node:child_process';
13
+ import { promisify } from 'node:util';
14
+ import { guild } from '@shardworks/nexus-core';
15
+ const execFileAsync = promisify(execFile);
16
+ async function gitStatus(cwd) {
17
+ try {
18
+ const { stdout } = await execFileAsync('git', ['status', '--porcelain'], { cwd });
19
+ return stdout;
20
+ }
21
+ catch {
22
+ return '';
23
+ }
24
+ }
25
+ async function gitDiffUncommitted(cwd) {
26
+ try {
27
+ const { stdout } = await execFileAsync('git', ['diff', 'HEAD'], { cwd });
28
+ return stdout;
29
+ }
30
+ catch {
31
+ return '';
32
+ }
33
+ }
34
+ function assembleRevisionPrompt(writ, review, status, diff) {
35
+ const reviewResult = review.passed ? 'PASS' : 'FAIL';
36
+ const instructions = review.passed
37
+ ? `The review passed. No changes are required. Confirm the work looks correct\nand exit. Do not make unnecessary changes or spend unnecessary time reassessing.`
38
+ : `The review identified issues that need to be addressed. See "Required Changes"\nin the findings above. Address each item, then commit your changes.`;
39
+ const diffSection = diff.trim()
40
+ ? `\`\`\`diff\n${diff}\n\`\`\``
41
+ : '(No uncommitted changes.)';
42
+ return `# Revision Pass
43
+
44
+ You are revising prior work on a commission based on review findings.
45
+
46
+ ## The Commission (Spec)
47
+
48
+ ${writ.body}
49
+
50
+ ## Review Findings
51
+
52
+ ${review.findings}
53
+
54
+ ## Review Result: ${reviewResult}
55
+
56
+ ${instructions}
57
+
58
+ ## Current State
59
+
60
+ \`\`\`
61
+ ${status}
62
+ \`\`\`
63
+
64
+ ${diffSection}
65
+
66
+ Commit all changes before ending your session.`;
67
+ }
68
+ const reviseEngine = {
69
+ id: 'revise',
70
+ async run(givens, context) {
71
+ const animator = guild().apparatus('animator');
72
+ const writ = givens.writ;
73
+ const draft = context.upstream['draft'];
74
+ const review = context.upstream['review'];
75
+ const status = await gitStatus(draft.path);
76
+ const diff = await gitDiffUncommitted(draft.path);
77
+ const prompt = assembleRevisionPrompt(writ, review, status, diff);
78
+ const handle = animator.summon({
79
+ role: givens.role,
80
+ prompt,
81
+ cwd: draft.path,
82
+ environment: { GIT_AUTHOR_EMAIL: `${writ.id}@nexus.local` },
83
+ metadata: { engineId: context.engineId, writId: writ.id },
84
+ });
85
+ const sessionResult = await handle.result;
86
+ return { status: 'launched', sessionId: sessionResult.id };
87
+ },
88
+ };
89
+ export default reviseEngine;
90
+ //# sourceMappingURL=revise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revise.js","sourceRoot":"","sources":["../../src/engines/revise.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAM/C,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,KAAK,UAAU,SAAS,CAAC,GAAW;IAClC,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QAClF,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,KAAK,UAAU,kBAAkB,CAAC,GAAW;IAC3C,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QACzE,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAa,EAAE,MAAoB,EAAE,MAAc,EAAE,IAAY;IAC/F,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IACrD,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM;QAChC,CAAC,CAAC,8JAA8J;QAChK,CAAC,CAAC,qJAAqJ,CAAC;IAE1J,MAAM,WAAW,GAAG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AM,CAAC;QAC1C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,CAAC,EAAE,EAAE,CAAC;IAC7D,CAAC;CACF,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Seal engine — clockwork.
3
+ *
4
+ * Seals the draft binding via the Scriptorium. Reads the draft branch
5
+ * from context.upstream['draft'] (the DraftYields from the draft engine).
6
+ * Returns SealYields with the sealed commit info.
7
+ */
8
+ import type { EngineDesign } from '@shardworks/fabricator-apparatus';
9
+ declare const sealEngine: EngineDesign;
10
+ export default sealEngine;
11
+ //# sourceMappingURL=seal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["../../src/engines/seal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAIrE,QAAA,MAAM,UAAU,EAAE,YAyBjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Seal engine — clockwork.
3
+ *
4
+ * Seals the draft binding via the Scriptorium. Reads the draft branch
5
+ * from context.upstream['draft'] (the DraftYields from the draft engine).
6
+ * Returns SealYields with the sealed commit info.
7
+ */
8
+ import { guild } from '@shardworks/nexus-core';
9
+ const sealEngine = {
10
+ id: 'seal',
11
+ async run(_givens, context) {
12
+ const scriptorium = guild().apparatus('codexes');
13
+ const draftYields = context.upstream['draft'];
14
+ if (!draftYields) {
15
+ throw new Error('Seal engine requires draft yields in context.upstream but none found.');
16
+ }
17
+ const result = await scriptorium.seal({
18
+ codexName: draftYields.codexName,
19
+ sourceBranch: draftYields.branch,
20
+ });
21
+ const yields = {
22
+ sealedCommit: result.sealedCommit,
23
+ strategy: result.strategy,
24
+ retries: result.retries,
25
+ inscriptionsSealed: result.inscriptionsSealed,
26
+ };
27
+ return { status: 'completed', yields };
28
+ },
29
+ };
30
+ export default sealEngine;
31
+ //# sourceMappingURL=seal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seal.js","sourceRoot":"","sources":["../../src/engines/seal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAK/C,MAAM,UAAU,GAAiB;IAC/B,EAAE,EAAE,MAAM;IAEV,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO;QACxB,MAAM,WAAW,GAAG,KAAK,EAAE,CAAC,SAAS,CAAiB,SAAS,CAAC,CAAC;QACjE,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B,CAAC;QAEzE,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;QAC3F,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC;YACpC,SAAS,EAAE,WAAW,CAAC,SAAS;YAChC,YAAY,EAAE,WAAW,CAAC,MAAM;SACjC,CAAC,CAAC;QAEH,MAAM,MAAM,GAAe;YACzB,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;SAC9C,CAAC;QAEF,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;IACzC,CAAC;CACF,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @shardworks/spider-apparatus — The Spider.
3
+ *
4
+ * Rig execution engine: spawns rigs for ready writs, drives engine pipelines
5
+ * to completion, and transitions writs via the Clerk on rig completion/failure.
6
+ *
7
+ * Public types (RigDoc, EngineInstance, CrawlResult, SpiderApi, etc.) are
8
+ * re-exported for consumers that inspect walk results or rig state.
9
+ */
10
+ export type { EngineStatus, EngineInstance, RigStatus, RigDoc, CrawlResult, SpiderApi, SpiderConfig, DraftYields, SealYields, } from './types.ts';
11
+ declare const _default: import("@shardworks/nexus-core").Plugin;
12
+ export default _default;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,YAAY,EACV,YAAY,EACZ,cAAc,EACd,SAAS,EACT,MAAM,EACN,WAAW,EACX,SAAS,EACT,YAAY,EACZ,WAAW,EACX,UAAU,GACX,MAAM,YAAY,CAAC;;AAIpB,wBAA8B"}
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @shardworks/spider-apparatus — The Spider.
3
+ *
4
+ * Rig execution engine: spawns rigs for ready writs, drives engine pipelines
5
+ * to completion, and transitions writs via the Clerk on rig completion/failure.
6
+ *
7
+ * Public types (RigDoc, EngineInstance, CrawlResult, SpiderApi, etc.) are
8
+ * re-exported for consumers that inspect walk results or rig state.
9
+ */
10
+ import { createSpider } from "./spider.js";
11
+ // ── Default export: the apparatus plugin ──────────────────────────────
12
+ export default createSpider();
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAgB3C,yEAAyE;AAEzE,eAAe,YAAY,EAAE,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The Spider — rig execution engine apparatus.
3
+ *
4
+ * The Spider drives writ-to-completion by managing rigs: ordered pipelines
5
+ * of engine instances. Each crawl() call performs one unit of work:
6
+ *
7
+ * collect > run > spawn (priority order)
8
+ *
9
+ * collect — check running engines for terminal session results
10
+ * run — execute the next pending engine (clockwork inline, quick → launch)
11
+ * spawn — create a new rig for a ready writ with no existing rig
12
+ *
13
+ * CDC on the rigs book (Phase 1 cascade) transitions the associated writ
14
+ * when a rig reaches a terminal state (completed or failed).
15
+ *
16
+ * See: docs/architecture/apparatus/spider.md
17
+ */
18
+ import type { Plugin } from '@shardworks/nexus-core';
19
+ export declare function createSpider(): Plugin;
20
+ //# sourceMappingURL=spider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spider.d.ts","sourceRoot":"","sources":["../src/spider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,wBAAwB,CAAC;AA+FrE,wBAAgB,YAAY,IAAI,MAAM,CA8TrC"}