@shardworks/nexus-stdlib 0.1.20

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 (48) hide show
  1. package/LICENSE +15 -0
  2. package/dist/engines/workshop-merge.d.ts +3 -0
  3. package/dist/engines/workshop-merge.d.ts.map +1 -0
  4. package/dist/engines/workshop-merge.js +91 -0
  5. package/dist/engines/workshop-merge.js.map +1 -0
  6. package/dist/engines/workshop-prepare.d.ts +3 -0
  7. package/dist/engines/workshop-prepare.d.ts.map +1 -0
  8. package/dist/engines/workshop-prepare.js +45 -0
  9. package/dist/engines/workshop-prepare.js.map +1 -0
  10. package/dist/engines.d.ts +5 -0
  11. package/dist/engines.d.ts.map +1 -0
  12. package/dist/engines.js +6 -0
  13. package/dist/engines.js.map +1 -0
  14. package/dist/tools/commission.d.ts +7 -0
  15. package/dist/tools/commission.d.ts.map +1 -0
  16. package/dist/tools/commission.js +22 -0
  17. package/dist/tools/commission.js.map +1 -0
  18. package/dist/tools/install.d.ts +9 -0
  19. package/dist/tools/install.d.ts.map +1 -0
  20. package/dist/tools/install.js +56 -0
  21. package/dist/tools/install.js.map +1 -0
  22. package/dist/tools/instantiate.d.ts +9 -0
  23. package/dist/tools/instantiate.d.ts.map +1 -0
  24. package/dist/tools/instantiate.js +24 -0
  25. package/dist/tools/instantiate.js.map +1 -0
  26. package/dist/tools/nexus-version.d.ts +6 -0
  27. package/dist/tools/nexus-version.d.ts.map +1 -0
  28. package/dist/tools/nexus-version.js +42 -0
  29. package/dist/tools/nexus-version.js.map +1 -0
  30. package/dist/tools/remove.d.ts +12 -0
  31. package/dist/tools/remove.d.ts.map +1 -0
  32. package/dist/tools/remove.js +23 -0
  33. package/dist/tools/remove.js.map +1 -0
  34. package/dist/tools/signal.d.ts +7 -0
  35. package/dist/tools/signal.d.ts.map +1 -0
  36. package/dist/tools/signal.js +26 -0
  37. package/dist/tools/signal.js.map +1 -0
  38. package/dist/tools.d.ts +35 -0
  39. package/dist/tools.d.ts.map +1 -0
  40. package/dist/tools.js +14 -0
  41. package/dist/tools.js.map +1 -0
  42. package/instructions/commission.md +21 -0
  43. package/instructions/install.md +44 -0
  44. package/instructions/instantiate.md +22 -0
  45. package/instructions/nexus-version.md +25 -0
  46. package/instructions/remove.md +18 -0
  47. package/instructions/signal.md +13 -0
  48. package/package.json +38 -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,3 @@
1
+ declare const _default: import("@shardworks/nexus-core").EngineDefinition;
2
+ export default _default;
3
+ //# sourceMappingURL=workshop-merge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workshop-merge.d.ts","sourceRoot":"","sources":["../../src/engines/workshop-merge.ts"],"names":[],"mappings":";AAqBA,wBAmFG"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Workshop Merge Engine (clockwork)
3
+ *
4
+ * Standing order handler for commission.session.ended events. Merges the
5
+ * commission branch back into main in the workshop bare repo, tears down
6
+ * the worktree, and signals the outcome.
7
+ *
8
+ * Event flow:
9
+ * commission.session.ended { commissionId, workshop, exitCode }
10
+ * → merges commission branch into main in bare repo
11
+ * → on success: teardown worktree, status → completed, signal commission.completed
12
+ * → on conflict: teardown worktree, status → failed, signal commission.failed
13
+ */
14
+ import { execFileSync } from 'node:child_process';
15
+ import { engine, signalEvent, updateCommissionStatus, workshopBarePath } from '@shardworks/nexus-core';
16
+ import { teardownWorktree } from '@shardworks/engine-worktree-setup';
17
+ function git(args, cwd) {
18
+ return execFileSync('git', args, { cwd, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
19
+ }
20
+ export default engine({
21
+ name: 'workshop-merge',
22
+ handler: async (event, { home }) => {
23
+ if (!event) {
24
+ throw new Error('workshop-merge requires an event (cannot be invoked directly).');
25
+ }
26
+ const payload = event.payload;
27
+ if (!payload || typeof payload.commissionId !== 'number' || typeof payload.workshop !== 'string') {
28
+ throw new Error(`workshop-merge expected payload with { commissionId, workshop }, got: ${JSON.stringify(payload)}`);
29
+ }
30
+ const commissionId = payload.commissionId;
31
+ const workshop = payload.workshop;
32
+ const branch = `commission-${commissionId}`;
33
+ const bareRepo = workshopBarePath(home, workshop);
34
+ try {
35
+ // Attempt to merge the commission branch into main.
36
+ // In a bare repo, we use a temporary index to do the merge.
37
+ // First check if the branch has any commits ahead of main.
38
+ const mergeBase = git(['merge-base', 'main', branch], bareRepo);
39
+ const branchTip = git(['rev-parse', branch], bareRepo);
40
+ if (mergeBase === branchTip) {
41
+ // No new commits on the branch — nothing to merge
42
+ teardownWorktree(home, workshop, commissionId);
43
+ updateCommissionStatus(home, commissionId, 'completed', 'no changes — nothing to merge');
44
+ signalEvent(home, 'commission.completed', { commissionId, workshop }, 'framework');
45
+ return;
46
+ }
47
+ // Try a fast-forward merge first
48
+ const mainTip = git(['rev-parse', 'main'], bareRepo);
49
+ if (mainTip === mergeBase) {
50
+ // Fast-forward: main hasn't moved since the branch was created
51
+ git(['update-ref', 'refs/heads/main', branchTip], bareRepo);
52
+ teardownWorktree(home, workshop, commissionId);
53
+ updateCommissionStatus(home, commissionId, 'completed', `merged to main (fast-forward to ${branchTip.slice(0, 7)})`);
54
+ signalEvent(home, 'commission.completed', { commissionId, workshop }, 'framework');
55
+ return;
56
+ }
57
+ // Non-fast-forward: main has diverged. Attempt a real merge.
58
+ // Use a temporary worktree for the merge operation since we can't
59
+ // merge directly in a bare repo.
60
+ //
61
+ // For now, fail on non-fast-forward merges. A real three-way merge
62
+ // in a bare repo requires a temporary index/worktree dance that adds
63
+ // significant complexity. This is the safe choice: the commission
64
+ // fails cleanly, and the patron can review and resolve manually.
65
+ teardownWorktree(home, workshop, commissionId);
66
+ updateCommissionStatus(home, commissionId, 'failed', `main has diverged — fast-forward merge not possible (main: ${mainTip.slice(0, 7)}, branch: ${branchTip.slice(0, 7)}, base: ${mergeBase.slice(0, 7)})`);
67
+ signalEvent(home, 'commission.failed', {
68
+ commissionId,
69
+ workshop,
70
+ error: 'main has diverged — fast-forward merge not possible',
71
+ }, 'framework');
72
+ }
73
+ catch (err) {
74
+ // Git operation failed — tear down worktree and fail the commission
75
+ try {
76
+ teardownWorktree(home, workshop, commissionId);
77
+ }
78
+ catch {
79
+ // Worktree may already be gone; ignore cleanup errors
80
+ }
81
+ const errorMsg = err instanceof Error ? err.message : String(err);
82
+ updateCommissionStatus(home, commissionId, 'failed', `merge error: ${errorMsg}`);
83
+ signalEvent(home, 'commission.failed', {
84
+ commissionId,
85
+ workshop,
86
+ error: errorMsg,
87
+ }, 'framework');
88
+ }
89
+ },
90
+ });
91
+ //# sourceMappingURL=workshop-merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workshop-merge.js","sourceRoot":"","sources":["../../src/engines/workshop-merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,C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aAAa,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CACvJ,CAAC;YACF,WAAW,CAAC,IAAI,EAAE,mBAAmB,EAAE;gBACrC,YAAY;gBACZ,QAAQ;gBACR,KAAK,EAAE,qDAAqD;aAC7D,EAAE,WAAW,CAAC,CAAC;QAClB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,oEAAoE;YACpE,IAAI,CAAC;gBACH,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;YACjD,CAAC;YAAC,MAAM,CAAC;gBACP,sDAAsD;YACxD,CAAC;YAED,MAAM,QAAQ,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAClE,sBAAsB,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,QAAQ,EAAE,CAAC,CAAC;YACjF,WAAW,CAAC,IAAI,EAAE,mBAAmB,EAAE;gBACrC,YAAY;gBACZ,QAAQ;gBACR,KAAK,EAAE,QAAQ;aAChB,EAAE,WAAW,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("@shardworks/nexus-core").EngineDefinition;
2
+ export default _default;
3
+ //# sourceMappingURL=workshop-prepare.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workshop-prepare.d.ts","sourceRoot":"","sources":["../../src/engines/workshop-prepare.ts"],"names":[],"mappings":";AAgBA,wBA8CG"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Workshop Prepare Engine (clockwork)
3
+ *
4
+ * Standing order handler for commission.posted events. Creates an isolated
5
+ * git worktree for the commission and signals commission.ready so the next
6
+ * standing order (summon artificer) can launch the session.
7
+ *
8
+ * Event flow:
9
+ * commission.posted { commissionId, workshop }
10
+ * → creates worktree from workshop bare repo
11
+ * → updates commission status → in_progress
12
+ * → signals commission.ready { commissionId, workshop, worktreePath }
13
+ */
14
+ import { engine, signalEvent, updateCommissionStatus, readCommission } from '@shardworks/nexus-core';
15
+ import { setupWorktree } from '@shardworks/engine-worktree-setup';
16
+ export default engine({
17
+ name: 'workshop-prepare',
18
+ handler: async (event, { home }) => {
19
+ if (!event) {
20
+ throw new Error('workshop-prepare requires an event (cannot be invoked directly).');
21
+ }
22
+ const payload = event.payload;
23
+ if (!payload || typeof payload.commissionId !== 'number' || typeof payload.workshop !== 'string') {
24
+ throw new Error(`workshop-prepare expected payload with { commissionId, workshop }, got: ${JSON.stringify(payload)}`);
25
+ }
26
+ const commissionId = payload.commissionId;
27
+ const workshop = payload.workshop;
28
+ // Verify commission exists
29
+ const commission = readCommission(home, commissionId);
30
+ if (!commission) {
31
+ throw new Error(`Commission #${commissionId} not found in the Ledger.`);
32
+ }
33
+ // Create the worktree
34
+ const worktree = setupWorktree({
35
+ home,
36
+ workshop,
37
+ commissionId,
38
+ });
39
+ // Update commission status
40
+ updateCommissionStatus(home, commissionId, 'in_progress', `worktree ready on branch ${worktree.branch}`);
41
+ // Signal ready for the next standing order (summon artificer)
42
+ signalEvent(home, 'commission.ready', { commissionId, workshop, worktreePath: worktree.path }, 'framework');
43
+ },
44
+ });
45
+ //# sourceMappingURL=workshop-prepare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workshop-prepare.js","sourceRoot":"","sources":["../../src/engines/workshop-prepare.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACrG,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,eAAe,MAAM,CAAC;IACpB,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QACjC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;QACtF,CAAC;QAED,MAAM,OAAO,GAAG,KAAK,CAAC,OAAyC,CAAC;QAChE,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,QAAQ,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACjG,MAAM,IAAI,KAAK,CACb,2EAA2E,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CACrG,CAAC;QACJ,CAAC;QAED,MAAM,YAAY,GAAG,OAAO,CAAC,YAAsB,CAAC;QACpD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAkB,CAAC;QAE5C,2BAA2B;QAC3B,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QACtD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,eAAe,YAAY,2BAA2B,CAAC,CAAC;QAC1E,CAAC;QAED,sBAAsB;QACtB,MAAM,QAAQ,GAAG,aAAa,CAAC;YAC7B,IAAI;YACJ,QAAQ;YACR,YAAY;SACb,CAAC,CAAC;QAEH,2BAA2B;QAC3B,sBAAsB,CACpB,IAAI,EACJ,YAAY,EACZ,aAAa,EACb,4BAA4B,QAAQ,CAAC,MAAM,EAAE,CAC9C,CAAC;QAEF,8DAA8D;QAC9D,WAAW,CACT,IAAI,EACJ,kBAAkB,EAClB,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,EACvD,WAAW,CACZ,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { default as workshopPrepare } from './engines/workshop-prepare.ts';
2
+ export { default as workshopMerge } from './engines/workshop-merge.ts';
3
+ declare const _default: import("@shardworks/nexus-core").EngineDefinition[];
4
+ export default _default;
5
+ //# sourceMappingURL=engines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engines.d.ts","sourceRoot":"","sources":["../src/engines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,6BAA6B,CAAC;;AAKvE,wBAAgD"}
@@ -0,0 +1,6 @@
1
+ export { default as workshopPrepare } from "./engines/workshop-prepare.js";
2
+ export { default as workshopMerge } from "./engines/workshop-merge.js";
3
+ import workshopPrepare from "./engines/workshop-prepare.js";
4
+ import workshopMerge from "./engines/workshop-merge.js";
5
+ export default [workshopPrepare, workshopMerge];
6
+ //# sourceMappingURL=engines.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engines.js","sourceRoot":"","sources":["../src/engines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEvE,OAAO,eAAe,MAAM,+BAA+B,CAAC;AAC5D,OAAO,aAAa,MAAM,6BAA6B,CAAC;AAExD,eAAe,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ declare const _default: import("@shardworks/nexus-core").ToolDefinition<{
3
+ spec: z.ZodString;
4
+ workshop: z.ZodString;
5
+ }>;
6
+ export default _default;
7
+ //# sourceMappingURL=commission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commission.d.ts","sourceRoot":"","sources":["../../src/tools/commission.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;;;;;AAExB,wBAWG"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * commission tool.
3
+ *
4
+ * Posts a commission to the guild and signals commission.posted for the
5
+ * Clockworks. Everything downstream (worktree setup, anima summoning,
6
+ * merge) is handled by standing orders.
7
+ */
8
+ import { tool, commission } from '@shardworks/nexus-core';
9
+ import { z } from 'zod';
10
+ export default tool({
11
+ name: 'commission',
12
+ description: 'Post a commission to the guild for an artificer to work on',
13
+ instructionsFile: './instructions/commission.md',
14
+ params: {
15
+ spec: z.string().describe('Commission specification — what needs to be done'),
16
+ workshop: z.string().describe('Target workshop for the commission'),
17
+ },
18
+ handler: (params, { home }) => {
19
+ return commission({ home, ...params });
20
+ },
21
+ });
22
+ //# sourceMappingURL=commission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commission.js","sourceRoot":"","sources":["../../src/tools/commission.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAe,IAAI,CAAC;IAClB,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,4DAA4D;IACzE,gBAAgB,EAAE,8BAA8B;IAChD,MAAM,EAAE;QACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kDAAkD,CAAC;QAC7E,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;KACpE;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QAC5B,OAAO,UAAU,CAAC,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ declare const _default: import("@shardworks/nexus-core").ToolDefinition<{
3
+ source: z.ZodString;
4
+ name: z.ZodOptional<z.ZodString>;
5
+ roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
6
+ link: z.ZodOptional<z.ZodBoolean>;
7
+ }>;
8
+ export default _default;
9
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/tools/install.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;;;;;;;AAuBxB,wBAqBG"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * install-tool tool.
3
+ *
4
+ * This is the canonical implementation — called by the MCP engine (for animas),
5
+ * the CLI (for humans), and importable by engines. All access paths execute
6
+ * the same logic.
7
+ *
8
+ * Detects bundles automatically: if the source package contains a
9
+ * nexus-bundle.json, delegates to installBundle instead of installTool.
10
+ */
11
+ import fs from 'node:fs';
12
+ import path from 'node:path';
13
+ import { execFileSync } from 'node:child_process';
14
+ import { tool, installTool, installBundle, classifySource, isBundleDir } from '@shardworks/nexus-core';
15
+ import { z } from 'zod';
16
+ /**
17
+ * For registry/git-url sources, npm-install the package (no-save) and check
18
+ * if it contains a bundle manifest. Returns the package dir if bundle, null otherwise.
19
+ */
20
+ function detectBundle(home, source) {
21
+ const sourceKind = classifySource(source, false);
22
+ if (sourceKind !== 'registry' && sourceKind !== 'git-url')
23
+ return null;
24
+ execFileSync('npm', ['install', '--no-save', source], { cwd: home, stdio: 'pipe' });
25
+ let packageName = source;
26
+ if (packageName.startsWith('@') && packageName.lastIndexOf('@') > 0) {
27
+ packageName = packageName.substring(0, packageName.lastIndexOf('@'));
28
+ }
29
+ else if (packageName.includes('@') && !packageName.startsWith('@')) {
30
+ packageName = packageName.split('@')[0];
31
+ }
32
+ const packageDir = path.join(home, 'node_modules', packageName);
33
+ return isBundleDir(packageDir) ? packageDir : null;
34
+ }
35
+ export default tool({
36
+ name: 'install-tool',
37
+ description: 'Install a tool, engine, curriculum, temperament, or bundle into the guild',
38
+ instructionsFile: './instructions/install.md',
39
+ params: {
40
+ source: z.string().describe('npm package specifier, git URL, workshop ref, tarball path, or bundle specifier'),
41
+ name: z.string().optional().describe('Override the tool name (defaults to package name or directory name)'),
42
+ roles: z.array(z.string()).optional().describe('Roles for tool access gating'),
43
+ link: z.boolean().optional().describe('Symlink local directory instead of copying (for active development)'),
44
+ },
45
+ handler: (params, { home }) => {
46
+ // Check if source is a bundle
47
+ if (!params.link) {
48
+ const bundleDir = detectBundle(home, params.source);
49
+ if (bundleDir) {
50
+ return installBundle({ home, bundleDir, bundleSource: params.source });
51
+ }
52
+ }
53
+ return installTool({ home, ...params });
54
+ },
55
+ });
56
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/tools/install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACvG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,SAAS,YAAY,CAAC,IAAY,EAAE,MAAc;IAChD,MAAM,UAAU,GAAG,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACjD,IAAI,UAAU,KAAK,UAAU,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAEvE,YAAY,CAAC,KAAK,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IAEpF,IAAI,WAAW,GAAG,MAAM,CAAC;IACzB,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACpE,WAAW,GAAG,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AAS,EAAE,CAAC;gBACd,OAAO,aAAa,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YACzE,CAAC;QACH,CAAC;QAED,OAAO,WAAW,CAAC,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ declare const _default: import("@shardworks/nexus-core").ToolDefinition<{
3
+ name: z.ZodString;
4
+ roles: z.ZodArray<z.ZodString>;
5
+ curriculum: z.ZodOptional<z.ZodString>;
6
+ temperament: z.ZodOptional<z.ZodString>;
7
+ }>;
8
+ export default _default;
9
+ //# sourceMappingURL=instantiate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instantiate.d.ts","sourceRoot":"","sources":["../../src/tools/instantiate.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;;;;;;;AAExB,wBAaG"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * instantiate tool.
3
+ *
4
+ * This is the canonical implementation — called by the MCP engine (for animas),
5
+ * the CLI (for humans), and importable by engines. All access paths execute
6
+ * the same logic.
7
+ */
8
+ import { tool, instantiate } from '@shardworks/nexus-core';
9
+ import { z } from 'zod';
10
+ export default tool({
11
+ name: 'instantiate',
12
+ description: 'Instantiate a new anima in the guild with assigned curriculum, temperament, and roles',
13
+ instructionsFile: './instructions/instantiate.md',
14
+ params: {
15
+ name: z.string().describe('Name for the new anima'),
16
+ roles: z.array(z.string()).describe('Roles the anima will hold (e.g. artificer, sage)'),
17
+ curriculum: z.string().optional().describe('Curriculum to assign (by name, must be registered in guild.json)'),
18
+ temperament: z.string().optional().describe('Temperament to assign (by name, must be registered in guild.json)'),
19
+ },
20
+ handler: (params, { home }) => {
21
+ return instantiate({ home, ...params });
22
+ },
23
+ });
24
+ //# sourceMappingURL=instantiate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instantiate.js","sourceRoot":"","sources":["../../src/tools/instantiate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAe,IAAI,CAAC;IAClB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,uFAAuF;IACpG,gBAAgB,EAAE,+BAA+B;IACjD,MAAM,EAAE;QACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;QACnD,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,kDAAkD,CAAC;QACvF,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kEAAkE,CAAC;QAC9G,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mEAAmE,CAAC;KACjH;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QAC5B,OAAO,WAAW,CAAC,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+ declare const _default: import("@shardworks/nexus-core").ToolDefinition<{
3
+ verbose: z.ZodOptional<z.ZodBoolean>;
4
+ }>;
5
+ export default _default;
6
+ //# sourceMappingURL=nexus-version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nexus-version.d.ts","sourceRoot":"","sources":["../../src/tools/nexus-version.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;;;;AAExB,wBA6CG"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * nexus-version tool.
3
+ *
4
+ * Reports the guild's Nexus framework version and the registered versions
5
+ * of all base tools and engines. Reads from guild.json to reflect
6
+ * what's actually installed, not just what the framework ships with.
7
+ */
8
+ import { tool, VERSION, readGuildConfig } from '@shardworks/nexus-core';
9
+ import { z } from 'zod';
10
+ export default tool({
11
+ name: 'nexus-version',
12
+ description: "Report version information for the guild's Nexus installation and base tools",
13
+ instructionsFile: './instructions/nexus-version.md',
14
+ params: {
15
+ verbose: z.boolean().optional().describe('Include full guild.json tool entries with timestamps'),
16
+ },
17
+ handler: (params, { home }) => {
18
+ const config = readGuildConfig(home);
19
+ /** Tools delivered by a @shardworks bundle are considered "base" (framework) tools. */
20
+ const isBase = (entry) => entry.bundle != null && entry.bundle.startsWith('@shardworks/');
21
+ // Collect base (framework) implement names
22
+ const baseTools = Object.keys(config.tools).filter(name => isBase(config.tools[name]));
23
+ // Collect base (framework) engine names
24
+ const baseEngines = Object.keys(config.engines).filter(name => isBase(config.engines[name]));
25
+ if (params.verbose) {
26
+ return {
27
+ nexus: VERSION,
28
+ model: config.model,
29
+ tools: Object.fromEntries(Object.entries(config.tools)
30
+ .filter(([, e]) => isBase(e))),
31
+ engines: Object.fromEntries(Object.entries(config.engines)
32
+ .filter(([, e]) => isBase(e))),
33
+ };
34
+ }
35
+ return {
36
+ nexus: VERSION,
37
+ tools: baseTools,
38
+ engines: baseEngines,
39
+ };
40
+ },
41
+ });
42
+ //# sourceMappingURL=nexus-version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nexus-version.js","sourceRoot":"","sources":["../../src/tools/nexus-version.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAe,IAAI,CAAC;IAClB,IAAI,EAAE,eAAe;IACrB,WAAW,EA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qBAC3B,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAChC;aACF,CAAC;QACJ,CAAC;QAED,OAAO;YACL,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,WAAW;SACrB,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { z } from 'zod';
2
+ declare const _default: import("@shardworks/nexus-core").ToolDefinition<{
3
+ name: z.ZodString;
4
+ category: z.ZodOptional<z.ZodEnum<{
5
+ tools: "tools";
6
+ engines: "engines";
7
+ curricula: "curricula";
8
+ temperaments: "temperaments";
9
+ }>>;
10
+ }>;
11
+ export default _default;
12
+ //# sourceMappingURL=remove.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../src/tools/remove.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;;;;;;;;;;AAExB,wBAYG"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * remove-tool tool.
3
+ *
4
+ * This is the canonical implementation — called by the MCP engine (for animas),
5
+ * the CLI (for humans), and importable by engines. All access paths execute
6
+ * the same logic.
7
+ */
8
+ import { tool, removeTool } from '@shardworks/nexus-core';
9
+ import { z } from 'zod';
10
+ export default tool({
11
+ name: 'remove-tool',
12
+ description: 'Remove a guild-managed tool, engine, curriculum, or temperament',
13
+ instructionsFile: './instructions/remove.md',
14
+ params: {
15
+ name: z.string().describe('Name of the tool to remove'),
16
+ category: z.enum(['tools', 'engines', 'curricula', 'temperaments']).optional()
17
+ .describe('Restrict to a specific category (searches all if omitted)'),
18
+ },
19
+ handler: (params, { home }) => {
20
+ return removeTool({ home, name: params.name, category: params.category });
21
+ },
22
+ });
23
+ //# sourceMappingURL=remove.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.js","sourceRoot":"","sources":["../../src/tools/remove.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAe,IAAI,CAAC;IAClB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,iEAAiE;IAC9E,gBAAgB,EAAE,0BAA0B;IAC5C,MAAM,EAAE;QACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;QACvD,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC,QAAQ,EAAE;aAC3E,QAAQ,CAAC,2DAA2D,CAAC;KACzE;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QAC5B,OAAO,UAAU,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC5E,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ declare const _default: import("@shardworks/nexus-core").ToolDefinition<{
3
+ name: z.ZodString;
4
+ payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
5
+ }>;
6
+ export default _default;
7
+ //# sourceMappingURL=signal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../src/tools/signal.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;;;;;AAExB,wBAiBG"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * signal tool.
3
+ *
4
+ * Signals a custom guild event. The event is persisted to the Ledger's events
5
+ * table and will be processed by the Clockworks runner. Validates that the
6
+ * event name is declared in guild.json and is not in a reserved namespace.
7
+ */
8
+ import { tool, validateCustomEvent, signalEvent } from '@shardworks/nexus-core';
9
+ import { z } from 'zod';
10
+ export default tool({
11
+ name: 'signal',
12
+ description: 'Signal a custom guild event for the Clockworks',
13
+ instructionsFile: './instructions/signal.md',
14
+ params: {
15
+ name: z.string().describe('Event name (must be declared in guild.json clockworks.events)'),
16
+ payload: z.record(z.string(), z.unknown()).optional().describe('Event payload (JSON object)'),
17
+ },
18
+ handler: (params, { home }) => {
19
+ // Validate the event name is declared and not reserved
20
+ validateCustomEvent(home, params.name);
21
+ // Persist the event
22
+ const eventId = signalEvent(home, params.name, params.payload ?? null, 'anima');
23
+ return { eventId, name: params.name };
24
+ },
25
+ });
26
+ //# sourceMappingURL=signal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signal.js","sourceRoot":"","sources":["../../src/tools/signal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAe,IAAI,CAAC;IAClB,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,gDAAgD;IAC7D,gBAAgB,EAAE,0BAA0B;IAC5C,MAAM,EAAE;QACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+DAA+D,CAAC;QAC1F,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;KAC9F;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QAC5B,uDAAuD;QACvD,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAEvC,oBAAoB;QACpB,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,IAAI,IAAI,EAAE,OAAO,CAAC,CAAC;QAEhF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IACxC,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,35 @@
1
+ export { default as commission } from './tools/commission.ts';
2
+ export { default as signal } from './tools/signal.ts';
3
+ export { default as install } from './tools/install.ts';
4
+ export { default as remove } from './tools/remove.ts';
5
+ export { default as instantiate } from './tools/instantiate.ts';
6
+ export { default as nexusVersion } from './tools/nexus-version.ts';
7
+ declare const _default: (import("@shardworks/nexus-core").ToolDefinition<{
8
+ spec: import("zod").ZodString;
9
+ workshop: import("zod").ZodString;
10
+ }> | import("@shardworks/nexus-core").ToolDefinition<{
11
+ name: import("zod").ZodString;
12
+ payload: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
13
+ }> | import("@shardworks/nexus-core").ToolDefinition<{
14
+ source: import("zod").ZodString;
15
+ name: import("zod").ZodOptional<import("zod").ZodString>;
16
+ roles: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
17
+ link: import("zod").ZodOptional<import("zod").ZodBoolean>;
18
+ }> | import("@shardworks/nexus-core").ToolDefinition<{
19
+ name: import("zod").ZodString;
20
+ category: import("zod").ZodOptional<import("zod").ZodEnum<{
21
+ tools: "tools";
22
+ engines: "engines";
23
+ curricula: "curricula";
24
+ temperaments: "temperaments";
25
+ }>>;
26
+ }> | import("@shardworks/nexus-core").ToolDefinition<{
27
+ name: import("zod").ZodString;
28
+ roles: import("zod").ZodArray<import("zod").ZodString>;
29
+ curriculum: import("zod").ZodOptional<import("zod").ZodString>;
30
+ temperament: import("zod").ZodOptional<import("zod").ZodString>;
31
+ }> | import("@shardworks/nexus-core").ToolDefinition<{
32
+ verbose: import("zod").ZodOptional<import("zod").ZodBoolean>;
33
+ }>)[];
34
+ export default _default;
35
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,0BAA0B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASnE,wBAAgF"}
package/dist/tools.js ADDED
@@ -0,0 +1,14 @@
1
+ export { default as commission } from "./tools/commission.js";
2
+ export { default as signal } from "./tools/signal.js";
3
+ export { default as install } from "./tools/install.js";
4
+ export { default as remove } from "./tools/remove.js";
5
+ export { default as instantiate } from "./tools/instantiate.js";
6
+ export { default as nexusVersion } from "./tools/nexus-version.js";
7
+ import commission from "./tools/commission.js";
8
+ import signal from "./tools/signal.js";
9
+ import install from "./tools/install.js";
10
+ import remove from "./tools/remove.js";
11
+ import instantiate from "./tools/instantiate.js";
12
+ import nexusVersion from "./tools/nexus-version.js";
13
+ export default [commission, signal, install, remove, instantiate, nexusVersion];
14
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,OAAO,MAAM,oBAAoB,CAAC;AACzC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,YAAY,MAAM,0BAA0B,CAAC;AAEpD,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ # commission
2
+
3
+ Post a commission to the guild. The Clockworks handles everything downstream — worktree setup, anima summoning, and post-session merge.
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ commission <spec> --workshop <workshop>
9
+ ```
10
+
11
+ ## Arguments
12
+
13
+ - `<spec>` — Commission specification describing what needs to be done. Include a clear problem statement and acceptance criteria.
14
+ - `--workshop <workshop>` — Target workshop where the work will be done.
15
+
16
+ ## Guidance
17
+
18
+ - Write clear, specific commission specs. The artificer receives this as their entire brief.
19
+ - Include acceptance criteria so the artificer knows when the work is done.
20
+ - After posting, use `nsg clock run` to process the commission through the Clockworks pipeline.
21
+ - The commission flows through standing orders: workshop-prepare → summon artificer → workshop-merge.
@@ -0,0 +1,44 @@
1
+ # install-tool
2
+
3
+ Install a new tool into the guild from a local directory, npm package, or tarball.
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ install-tool <source> [--name <name>] [--roles <roles>] [--link]
9
+ ```
10
+
11
+ ## Arguments
12
+
13
+ - `<source>` — Local directory path, npm package specifier (e.g. `foo@1.0`, `@scope/tool`), or tarball path (`.tgz`)
14
+ - `--name <name>` — Override the tool name (defaults to package name or directory basename)
15
+ - `--roles <roles>` — Comma-separated roles for tool access gating
16
+ - `--link` — Symlink a local directory instead of copying (for active development)
17
+
18
+ ## Source types
19
+
20
+ The source is automatically classified:
21
+
22
+ - **Local directory with `package.json`** — installed via `npm install` into the guild's `node_modules`. Dependencies are resolved automatically.
23
+ - **Local directory without `package.json`** — copied directly to the guild. No dependency resolution.
24
+ - **npm specifier** (e.g. `my-tool@1.0`, `@scope/tool`) — installed from the npm registry.
25
+ - **Tarball** (`.tgz`/`.tar.gz`) — installed via npm from a local archive.
26
+
27
+ ## Examples
28
+
29
+ Install a locally-built implement:
30
+ ```
31
+ install-tool ./path/to/my-tool --roles artificer
32
+ ```
33
+
34
+ Install from npm registry:
35
+ ```
36
+ install-tool some-published-tool@1.2.0 --roles herald
37
+ ```
38
+
39
+ Link a tool for active development (changes are live):
40
+ ```
41
+ install-tool ~/projects/my-tool --link --roles artificer
42
+ ```
43
+
44
+ The tool will detect the descriptor type (implement, engine, curriculum, or temperament), install it to the correct location, and register it in guild.json.
@@ -0,0 +1,22 @@
1
+ # instantiate
2
+
3
+ Create a new anima in the guild — recording its composition (curriculum, temperament, roles) in the Ledger so it can be manifested for sessions.
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ instantiate <name> --roles <roles> [--curriculum <curriculum>] [--temperament <temperament>]
9
+ ```
10
+
11
+ ## Arguments
12
+
13
+ - `<name>` — Name for the new anima
14
+ - `--roles <roles>` — Comma-separated roles the anima will hold (e.g. artificer, sage)
15
+ - `--curriculum <curriculum>` — Curriculum to assign (must be registered in guild.json)
16
+ - `--temperament <temperament>` — Temperament to assign (must be registered in guild.json)
17
+
18
+ ## Guidance
19
+
20
+ - The anima's name should be unique within the guild.
21
+ - Roles determine which implements the anima can access (via role gating).
22
+ - Curriculum and temperament must already be installed in the guild before they can be assigned.
@@ -0,0 +1,25 @@
1
+ # nexus-version
2
+
3
+ Report version information about the guild's Nexus installation.
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ nexus-version
9
+ ```
10
+
11
+ No arguments required. Returns the framework version and a list of all base tools and engines.
12
+
13
+ ## When to use
14
+
15
+ - When diagnosing compatibility issues or unexpected behavior
16
+ - When reporting bugs or requesting support
17
+ - When verifying that a guild upgrade completed successfully
18
+ - Before installing a tool that declares a `nexusVersion` requirement
19
+
20
+ ## Output
21
+
22
+ Returns a JSON object with:
23
+ - `nexus` — the framework version
24
+ - `implements` — base tool names
25
+ - `engines` — base engine names
@@ -0,0 +1,18 @@
1
+ # remove-tool
2
+
3
+ Remove a guild-managed tool — deregisters it from guild.json and removes its on-disk directory.
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ remove-tool <name>
9
+ ```
10
+
11
+ ## Arguments
12
+
13
+ - `<name>` — Name of the tool to remove
14
+
15
+ ## Constraints
16
+
17
+ - If the tool was installed via npm, the package is also removed from `node_modules`.
18
+ - Linked tools have their symlink removed.
@@ -0,0 +1,13 @@
1
+ # signal
2
+
3
+ Signal a custom guild event. The event is recorded in the Ledger and will be processed by the Clockworks runner when `nsg clock tick` or `nsg clock run` is invoked.
4
+
5
+ ## Usage
6
+
7
+ - The event name **must** be declared in `guild.json` under `clockworks.events`.
8
+ - You **cannot** signal framework events (`anima.*`, `commission.*`, `tool.*`, `migration.*`, `guild.*`, `standing-order.*`) — those are emitted automatically by the framework.
9
+ - The optional payload is a JSON object with event-specific data.
10
+
11
+ ## When to use
12
+
13
+ Signal an event when something meaningful has happened that other parts of the guild should know about. Standing orders in `guild.json` determine what happens in response.
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@shardworks/nexus-stdlib",
3
+ "version": "0.1.20",
4
+ "license": "ISC",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/shardworks/nexus-mk2",
8
+ "directory": "packages/stdlib"
9
+ },
10
+ "description": "Standard tools and engines for the Nexus guild system",
11
+ "type": "module",
12
+ "exports": {
13
+ "./tools": {
14
+ "types": "./dist/tools.d.ts",
15
+ "import": "./dist/tools.js"
16
+ },
17
+ "./engines": {
18
+ "types": "./dist/engines.d.ts",
19
+ "import": "./dist/engines.js"
20
+ }
21
+ },
22
+ "dependencies": {
23
+ "zod": "^4.0.0",
24
+ "@shardworks/nexus-core": "0.1.20",
25
+ "@shardworks/engine-worktree-setup": "0.1.20"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "25.5.0"
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "instructions"
33
+ ],
34
+ "scripts": {
35
+ "build": "tsc",
36
+ "typecheck": "tsc --noEmit"
37
+ }
38
+ }