@shardworks/nexus-core 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-tools.d.ts +27 -0
- package/dist/base-tools.d.ts.map +1 -0
- package/dist/base-tools.js +30 -0
- package/dist/base-tools.js.map +1 -0
- package/dist/bootstrap.d.ts +14 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +46 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/dispatch.d.ts +26 -0
- package/dist/dispatch.d.ts.map +1 -0
- package/dist/dispatch.js +55 -0
- package/dist/dispatch.js.map +1 -0
- package/dist/guild-config.d.ts +51 -0
- package/dist/guild-config.d.ts.map +1 -0
- package/dist/guild-config.js +33 -0
- package/dist/guild-config.js.map +1 -0
- package/dist/implement.d.ts +69 -0
- package/dist/implement.d.ts.map +1 -0
- package/dist/implement.js +47 -0
- package/dist/implement.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/init-guild.d.ts +20 -0
- package/dist/init-guild.d.ts.map +1 -0
- package/dist/init-guild.js +77 -0
- package/dist/init-guild.js.map +1 -0
- package/dist/install-tool.d.ts +34 -0
- package/dist/install-tool.d.ts.map +1 -0
- package/dist/install-tool.js +149 -0
- package/dist/install-tool.js.map +1 -0
- package/dist/instantiate.d.ts +28 -0
- package/dist/instantiate.d.ts.map +1 -0
- package/dist/instantiate.js +113 -0
- package/dist/instantiate.js.map +1 -0
- package/dist/ledger.d.ts +8 -0
- package/dist/ledger.d.ts.map +1 -0
- package/dist/ledger.js +75 -0
- package/dist/ledger.js.map +1 -0
- package/dist/nexus-home.d.ts +14 -0
- package/dist/nexus-home.d.ts.map +1 -0
- package/dist/nexus-home.js +29 -0
- package/dist/nexus-home.js.map +1 -0
- package/dist/publish.d.ts +20 -0
- package/dist/publish.d.ts.map +1 -0
- package/dist/publish.js +41 -0
- package/dist/publish.js.map +1 -0
- package/dist/remove-tool.d.ts +20 -0
- package/dist/remove-tool.d.ts.map +1 -0
- package/dist/remove-tool.js +64 -0
- package/dist/remove-tool.js.map +1 -0
- package/package.json +33 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base tools — the framework implements and engines that ship with Nexus.
|
|
3
|
+
*
|
|
4
|
+
* Each entry maps a tool name to the workspace package that contains it.
|
|
5
|
+
* The actual descriptors and instructions live in the packages themselves
|
|
6
|
+
* (nexus-implement.json / nexus-engine.json / instructions.md).
|
|
7
|
+
*
|
|
8
|
+
* During `nexus init`, these are installed into the guildhall via
|
|
9
|
+
* `installTool({ framework: true })` — the same code path used for all
|
|
10
|
+
* tool installation.
|
|
11
|
+
*/
|
|
12
|
+
/** Reference to a framework tool package. */
|
|
13
|
+
export interface BaseToolRef {
|
|
14
|
+
/** Tool name — becomes the directory name in nexus/{implements,engines}/. */
|
|
15
|
+
name: string;
|
|
16
|
+
/** Workspace package that contains the tool. */
|
|
17
|
+
packageName: string;
|
|
18
|
+
/** Roles for implements (omit for engines or all-role implements). */
|
|
19
|
+
roles?: string[];
|
|
20
|
+
}
|
|
21
|
+
/** Base implements that ship with the framework. */
|
|
22
|
+
export declare const BASE_IMPLEMENTS: BaseToolRef[];
|
|
23
|
+
/** Base engines that ship with the framework. */
|
|
24
|
+
export declare const BASE_ENGINES: BaseToolRef[];
|
|
25
|
+
/** All base tools (implements + engines). */
|
|
26
|
+
export declare const BASE_TOOLS: BaseToolRef[];
|
|
27
|
+
//# sourceMappingURL=base-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-tools.d.ts","sourceRoot":"","sources":["../src/base-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,6CAA6C;AAC7C,MAAM,WAAW,WAAW;IAC1B,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,oDAAoD;AACpD,eAAO,MAAM,eAAe,EAAE,WAAW,EAOxC,CAAC;AAEF,iDAAiD;AACjD,eAAO,MAAM,YAAY,EAAE,WAAW,EAKrC,CAAC;AAEF,6CAA6C;AAC7C,eAAO,MAAM,UAAU,EAAE,WAAW,EAA0C,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base tools — the framework implements and engines that ship with Nexus.
|
|
3
|
+
*
|
|
4
|
+
* Each entry maps a tool name to the workspace package that contains it.
|
|
5
|
+
* The actual descriptors and instructions live in the packages themselves
|
|
6
|
+
* (nexus-implement.json / nexus-engine.json / instructions.md).
|
|
7
|
+
*
|
|
8
|
+
* During `nexus init`, these are installed into the guildhall via
|
|
9
|
+
* `installTool({ framework: true })` — the same code path used for all
|
|
10
|
+
* tool installation.
|
|
11
|
+
*/
|
|
12
|
+
/** Base implements that ship with the framework. */
|
|
13
|
+
export const BASE_IMPLEMENTS = [
|
|
14
|
+
{ name: 'install-tool', packageName: '@shardworks/implement-install-tool' },
|
|
15
|
+
{ name: 'remove-tool', packageName: '@shardworks/implement-remove-tool' },
|
|
16
|
+
{ name: 'dispatch', packageName: '@shardworks/implement-dispatch' },
|
|
17
|
+
{ name: 'instantiate', packageName: '@shardworks/implement-instantiate' },
|
|
18
|
+
{ name: 'publish', packageName: '@shardworks/implement-publish' },
|
|
19
|
+
{ name: 'nexus-version', packageName: '@shardworks/implement-nexus-version' },
|
|
20
|
+
];
|
|
21
|
+
/** Base engines that ship with the framework. */
|
|
22
|
+
export const BASE_ENGINES = [
|
|
23
|
+
{ name: 'manifest', packageName: '@shardworks/engine-manifest' },
|
|
24
|
+
{ name: 'mcp-server', packageName: '@shardworks/engine-mcp-server' },
|
|
25
|
+
{ name: 'worktree-setup', packageName: '@shardworks/engine-worktree-setup' },
|
|
26
|
+
{ name: 'ledger-migrate', packageName: '@shardworks/engine-ledger-migrate' },
|
|
27
|
+
];
|
|
28
|
+
/** All base tools (implements + engines). */
|
|
29
|
+
export const BASE_TOOLS = [...BASE_IMPLEMENTS, ...BASE_ENGINES];
|
|
30
|
+
//# sourceMappingURL=base-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-tools.js","sourceRoot":"","sources":["../src/base-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAYH,oDAAoD;AACpD,MAAM,CAAC,MAAM,eAAe,GAAkB;IAC5C,EAAE,IAAI,EAAE,cAAc,EAAK,WAAW,EAAE,oCAAoC,EAAE;IAC9E,EAAE,IAAI,EAAE,aAAa,EAAM,WAAW,EAAE,mCAAmC,EAAE;IAC7E,EAAE,IAAI,EAAE,UAAU,EAAS,WAAW,EAAE,gCAAgC,EAAE;IAC1E,EAAE,IAAI,EAAE,aAAa,EAAM,WAAW,EAAE,mCAAmC,EAAE;IAC7E,EAAE,IAAI,EAAE,SAAS,EAAU,WAAW,EAAE,+BAA+B,EAAE;IACzE,EAAE,IAAI,EAAE,eAAe,EAAI,WAAW,EAAE,qCAAqC,EAAE;CAChF,CAAC;AAEF,iDAAiD;AACjD,MAAM,CAAC,MAAM,YAAY,GAAkB;IACzC,EAAE,IAAI,EAAE,UAAU,EAAS,WAAW,EAAE,6BAA6B,EAAE;IACvE,EAAE,IAAI,EAAE,YAAY,EAAO,WAAW,EAAE,+BAA+B,EAAE;IACzE,EAAE,IAAI,EAAE,gBAAgB,EAAG,WAAW,EAAE,mCAAmC,EAAE;IAC7E,EAAE,IAAI,EAAE,gBAAgB,EAAG,WAAW,EAAE,mCAAmC,EAAE;CAC9E,CAAC;AAEF,6CAA6C;AAC7C,MAAM,CAAC,MAAM,UAAU,GAAkB,CAAC,GAAG,eAAe,EAAE,GAAG,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Install all framework base tools into a freshly-initialized guild.
|
|
3
|
+
*
|
|
4
|
+
* Uses `installTool({ framework: true })` for every base implement and engine —
|
|
5
|
+
* the same code path used for all tool installation. Individual installs do not
|
|
6
|
+
* commit; a single "Bootstrap base tools" commit is created at the end.
|
|
7
|
+
*
|
|
8
|
+
* @param home - Absolute path to NEXUS_HOME.
|
|
9
|
+
* @param resolvePackage - Resolves a package name to its root directory on disk.
|
|
10
|
+
* The caller owns resolution because it depends on the runtime module system
|
|
11
|
+
* (workspace links, node_modules layout, etc.) which varies by context.
|
|
12
|
+
*/
|
|
13
|
+
export declare function bootstrapBaseTools(home: string, resolvePackage: (packageName: string) => string): void;
|
|
14
|
+
//# sourceMappingURL=bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,GAC9C,IAAI,CA8BN"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { guildhallWorktreePath } from "./nexus-home.js";
|
|
3
|
+
import { installTool } from "./install-tool.js";
|
|
4
|
+
import { BASE_IMPLEMENTS, BASE_ENGINES } from "./base-tools.js";
|
|
5
|
+
/**
|
|
6
|
+
* Install all framework base tools into a freshly-initialized guild.
|
|
7
|
+
*
|
|
8
|
+
* Uses `installTool({ framework: true })` for every base implement and engine —
|
|
9
|
+
* the same code path used for all tool installation. Individual installs do not
|
|
10
|
+
* commit; a single "Bootstrap base tools" commit is created at the end.
|
|
11
|
+
*
|
|
12
|
+
* @param home - Absolute path to NEXUS_HOME.
|
|
13
|
+
* @param resolvePackage - Resolves a package name to its root directory on disk.
|
|
14
|
+
* The caller owns resolution because it depends on the runtime module system
|
|
15
|
+
* (workspace links, node_modules layout, etc.) which varies by context.
|
|
16
|
+
*/
|
|
17
|
+
export function bootstrapBaseTools(home, resolvePackage) {
|
|
18
|
+
// Install base implements
|
|
19
|
+
for (const ref of BASE_IMPLEMENTS) {
|
|
20
|
+
const sourceDir = resolvePackage(ref.packageName);
|
|
21
|
+
installTool({
|
|
22
|
+
home,
|
|
23
|
+
source: sourceDir,
|
|
24
|
+
name: ref.name,
|
|
25
|
+
roles: ref.roles ?? ['*'],
|
|
26
|
+
framework: true,
|
|
27
|
+
commit: false,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// Install base engines
|
|
31
|
+
for (const ref of BASE_ENGINES) {
|
|
32
|
+
const sourceDir = resolvePackage(ref.packageName);
|
|
33
|
+
installTool({
|
|
34
|
+
home,
|
|
35
|
+
source: sourceDir,
|
|
36
|
+
name: ref.name,
|
|
37
|
+
framework: true,
|
|
38
|
+
commit: false,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
// Single commit for all bootstrap installs
|
|
42
|
+
const worktree = guildhallWorktreePath(home);
|
|
43
|
+
execFileSync('git', ['add', '-A'], { cwd: worktree, stdio: 'pipe' });
|
|
44
|
+
execFileSync('git', ['commit', '-m', 'Bootstrap base tools'], { cwd: worktree, stdio: 'pipe' });
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEhE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAY,EACZ,cAA+C;IAE/C,0BAA0B;IAC1B,KAAK,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QAClC,MAAM,SAAS,GAAG,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAClD,WAAW,CAAC;YACV,IAAI;YACJ,MAAM,EAAE,SAAS;YACjB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC;YACzB,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;IACL,CAAC;IAED,uBAAuB;IACvB,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QAC/B,MAAM,SAAS,GAAG,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAClD,WAAW,CAAC;YACV,IAAI;YACJ,MAAM,EAAE,SAAS;YACjB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;IACL,CAAC;IAED,2CAA2C;IAC3C,MAAM,QAAQ,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC7C,YAAY,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IACrE,YAAY,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,sBAAsB,CAAC,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;AAClG,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface DispatchOptions {
|
|
2
|
+
/** Absolute path to NEXUS_HOME. */
|
|
3
|
+
home: string;
|
|
4
|
+
/** Commission specification — what needs to be done. */
|
|
5
|
+
spec: string;
|
|
6
|
+
/** Target workshop for the commission. */
|
|
7
|
+
workshop: string;
|
|
8
|
+
/** Target anima name. If provided, the commission is assigned immediately. */
|
|
9
|
+
anima?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DispatchResult {
|
|
12
|
+
/** The ID of the created commission. */
|
|
13
|
+
commissionId: number;
|
|
14
|
+
/** Whether the commission was assigned to an anima. */
|
|
15
|
+
assigned: boolean;
|
|
16
|
+
/** The anima name if assigned. */
|
|
17
|
+
assignedTo?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Post a commission to the guild.
|
|
21
|
+
*
|
|
22
|
+
* Creates a commission in the Ledger. If an anima is specified, validates that
|
|
23
|
+
* the anima exists and is active, then creates an assignment record.
|
|
24
|
+
*/
|
|
25
|
+
export declare function dispatch(opts: DispatchOptions): DispatchResult;
|
|
26
|
+
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,eAAe;IAC9B,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,wCAAwC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,QAAQ,EAAE,OAAO,CAAC;IAClB,kCAAkC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,cAAc,CAgE9D"}
|
package/dist/dispatch.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dispatch — core logic for posting commissions to the guild.
|
|
3
|
+
*
|
|
4
|
+
* Creates a commission record in the Ledger and optionally assigns it to an anima.
|
|
5
|
+
* The dispatch implement and CLI both call this function.
|
|
6
|
+
*/
|
|
7
|
+
import Database from 'better-sqlite3';
|
|
8
|
+
import { ledgerPath } from "./nexus-home.js";
|
|
9
|
+
import { readGuildConfig } from "./guild-config.js";
|
|
10
|
+
/**
|
|
11
|
+
* Post a commission to the guild.
|
|
12
|
+
*
|
|
13
|
+
* Creates a commission in the Ledger. If an anima is specified, validates that
|
|
14
|
+
* the anima exists and is active, then creates an assignment record.
|
|
15
|
+
*/
|
|
16
|
+
export function dispatch(opts) {
|
|
17
|
+
const { home, spec, workshop, anima } = opts;
|
|
18
|
+
// Validate workshop exists in guild.json
|
|
19
|
+
const config = readGuildConfig(home);
|
|
20
|
+
if (!config.workshops.includes(workshop)) {
|
|
21
|
+
throw new Error(`Workshop "${workshop}" not found in guild.json. Available workshops: ${config.workshops.join(', ') || '(none)'}`);
|
|
22
|
+
}
|
|
23
|
+
const db = new Database(ledgerPath(home));
|
|
24
|
+
db.pragma('foreign_keys = ON');
|
|
25
|
+
try {
|
|
26
|
+
const initialStatus = anima ? 'assigned' : 'posted';
|
|
27
|
+
// Create commission
|
|
28
|
+
const insertCommission = db.prepare(`INSERT INTO commissions (content, status, workshop) VALUES (?, ?, ?)`);
|
|
29
|
+
const commissionResult = insertCommission.run(spec, initialStatus, workshop);
|
|
30
|
+
const commissionId = Number(commissionResult.lastInsertRowid);
|
|
31
|
+
let assigned = false;
|
|
32
|
+
let assignedTo;
|
|
33
|
+
if (anima) {
|
|
34
|
+
// Validate anima exists and is active
|
|
35
|
+
const animaRow = db.prepare(`SELECT id, status FROM animas WHERE name = ?`).get(anima);
|
|
36
|
+
if (!animaRow) {
|
|
37
|
+
throw new Error(`Anima "${anima}" not found in the Ledger.`);
|
|
38
|
+
}
|
|
39
|
+
if (animaRow.status !== 'active') {
|
|
40
|
+
throw new Error(`Anima "${anima}" is not active (status: ${animaRow.status}).`);
|
|
41
|
+
}
|
|
42
|
+
// Create assignment
|
|
43
|
+
db.prepare(`INSERT INTO commission_assignments (commission_id, anima_id) VALUES (?, ?)`).run(commissionId, animaRow.id);
|
|
44
|
+
assigned = true;
|
|
45
|
+
assignedTo = anima;
|
|
46
|
+
}
|
|
47
|
+
// Audit log
|
|
48
|
+
db.prepare(`INSERT INTO audit_log (actor, action, target_type, target_id, detail) VALUES (?, ?, ?, ?, ?)`).run('dispatch', assigned ? 'commission_dispatched_and_assigned' : 'commission_dispatched', 'commission', commissionId, JSON.stringify({ workshop, anima: assignedTo }));
|
|
49
|
+
return { commissionId, assigned, assignedTo };
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
db.close();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAsBpD;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAqB;IAC5C,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAE7C,yCAAyC;IACzC,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CACb,aAAa,QAAQ,mDAAmD,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,EAAE,CAClH,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,GAAG,IAAI,QAAQ,CAAC,UAAU,CAAC,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C,CAAC,uBAAuB,EACzE,YAAY,EACZ,YAAY,EACZ,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAChD,CAAC;QAEF,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;IAChD,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,KAAK,EAAE,CAAC;IACb,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** A reference to an implement or engine registered in guild.json. */
|
|
2
|
+
export interface ToolEntry {
|
|
3
|
+
/** Whether the tool is provided by the Nexus framework or authored by the guild. */
|
|
4
|
+
source: 'nexus' | 'guild';
|
|
5
|
+
/** Guild-local version slot — the directory name under {implements|engines}/{name}/. */
|
|
6
|
+
slot: string;
|
|
7
|
+
/** Upstream package identifier, e.g. "@shardworks/implement-dispatch@1.11.3". Null for locally-built tools. */
|
|
8
|
+
upstream: string | null;
|
|
9
|
+
/** ISO-8601 timestamp of when the tool was installed into this slot. */
|
|
10
|
+
installedAt: string;
|
|
11
|
+
/** Which roles have access (implements only). ["*"] means all roles. */
|
|
12
|
+
roles?: string[];
|
|
13
|
+
}
|
|
14
|
+
/** A reference to a curriculum or temperament registered in guild.json. */
|
|
15
|
+
export interface TrainingEntry {
|
|
16
|
+
/** Guild-local version slot — the directory name under training/{curricula|temperaments}/{name}/. */
|
|
17
|
+
slot: string;
|
|
18
|
+
/** Upstream package identifier, or null for locally-authored content. */
|
|
19
|
+
upstream: string | null;
|
|
20
|
+
/** ISO-8601 timestamp of when the content was installed into this slot. */
|
|
21
|
+
installedAt: string;
|
|
22
|
+
}
|
|
23
|
+
/** The guild's central configuration file shape (`guild.json`). */
|
|
24
|
+
export interface GuildConfig {
|
|
25
|
+
/** Installed Nexus framework version. */
|
|
26
|
+
nexus: string;
|
|
27
|
+
/** Default model for anima sessions. */
|
|
28
|
+
model: string;
|
|
29
|
+
/** Registered workshop names. */
|
|
30
|
+
workshops: string[];
|
|
31
|
+
/** Active implements indexed by name. */
|
|
32
|
+
implements: Record<string, ToolEntry>;
|
|
33
|
+
/** Active engines indexed by name. */
|
|
34
|
+
engines: Record<string, ToolEntry>;
|
|
35
|
+
/** Available curricula indexed by name. */
|
|
36
|
+
curricula: Record<string, TrainingEntry>;
|
|
37
|
+
/** Available temperaments indexed by name. */
|
|
38
|
+
temperaments: Record<string, TrainingEntry>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create the default guild.json content for a new guild.
|
|
42
|
+
* All registries (implements, engines, curricula, temperaments) start empty.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createInitialGuildConfig(nexusVersion: string, model: string): GuildConfig;
|
|
45
|
+
/** Resolve the path to guild.json in the standing worktree. */
|
|
46
|
+
export declare function guildConfigPath(home: string): string;
|
|
47
|
+
/** Read and parse guild.json from the standing worktree. */
|
|
48
|
+
export declare function readGuildConfig(home: string): GuildConfig;
|
|
49
|
+
/** Write guild.json to the standing worktree. */
|
|
50
|
+
export declare function writeGuildConfig(home: string, config: GuildConfig): void;
|
|
51
|
+
//# sourceMappingURL=guild-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guild-config.d.ts","sourceRoot":"","sources":["../src/guild-config.ts"],"names":[],"mappings":"AAIA,sEAAsE;AACtE,MAAM,WAAW,SAAS;IACxB,oFAAoF;IACpF,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC;IAC1B,wFAAwF;IACxF,IAAI,EAAE,MAAM,CAAC;IACb,+GAA+G;IAC/G,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,2EAA2E;AAC3E,MAAM,WAAW,aAAa;IAC5B,qGAAqG;IACrG,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,2EAA2E;IAC3E,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,mEAAmE;AACnE,MAAM,WAAW,WAAW;IAC1B,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACtC,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACnC,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACzC,8CAA8C;IAC9C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAC7C;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAUzF;AAED,+DAA+D;AAC/D,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,4DAA4D;AAC5D,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAGzD;AAED,iDAAiD;AACjD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAGxE"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { guildhallWorktreePath } from "./nexus-home.js";
|
|
4
|
+
/**
|
|
5
|
+
* Create the default guild.json content for a new guild.
|
|
6
|
+
* All registries (implements, engines, curricula, temperaments) start empty.
|
|
7
|
+
*/
|
|
8
|
+
export function createInitialGuildConfig(nexusVersion, model) {
|
|
9
|
+
return {
|
|
10
|
+
nexus: nexusVersion,
|
|
11
|
+
model,
|
|
12
|
+
workshops: [],
|
|
13
|
+
implements: {},
|
|
14
|
+
engines: {},
|
|
15
|
+
curricula: {},
|
|
16
|
+
temperaments: {},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** Resolve the path to guild.json in the standing worktree. */
|
|
20
|
+
export function guildConfigPath(home) {
|
|
21
|
+
return path.join(guildhallWorktreePath(home), 'guild.json');
|
|
22
|
+
}
|
|
23
|
+
/** Read and parse guild.json from the standing worktree. */
|
|
24
|
+
export function readGuildConfig(home) {
|
|
25
|
+
const configFile = guildConfigPath(home);
|
|
26
|
+
return JSON.parse(fs.readFileSync(configFile, 'utf-8'));
|
|
27
|
+
}
|
|
28
|
+
/** Write guild.json to the standing worktree. */
|
|
29
|
+
export function writeGuildConfig(home, config) {
|
|
30
|
+
const configFile = guildConfigPath(home);
|
|
31
|
+
fs.writeFileSync(configFile, JSON.stringify(config, null, 2) + '\n');
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=guild-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guild-config.js","sourceRoot":"","sources":["../src/guild-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AA4CxD;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,YAAoB,EAAE,KAAa;IAC1E,OAAO;QACL,KAAK,EAAE,YAAY;QACnB,KAAK;QACL,SAAS,EAAE,EAAE;QACb,UAAU,EAAE,EAAE;QACd,OAAO,EAAE,EAAE;QACX,SAAS,EAAE,EAAE;QACb,YAAY,EAAE,EAAE;KACjB,CAAC;AACJ,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC;AAC9D,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,MAAM,UAAU,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACzC,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAgB,CAAC;AACzE,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,MAAmB;IAChE,MAAM,UAAU,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACzC,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implement SDK — the primary authoring interface for module-based implements.
|
|
3
|
+
*
|
|
4
|
+
* Use `implement()` to define a typed implement with Zod parameter schemas.
|
|
5
|
+
* The returned definition is what the MCP engine imports and registers as a tool,
|
|
6
|
+
* what the CLI uses to auto-generate subcommands, and what engines import directly.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { implement } from '@shardworks/nexus-core';
|
|
11
|
+
* import { z } from 'zod';
|
|
12
|
+
*
|
|
13
|
+
* export default implement({
|
|
14
|
+
* description: 'Look up an anima by name',
|
|
15
|
+
* params: {
|
|
16
|
+
* name: z.string().describe('Anima name'),
|
|
17
|
+
* },
|
|
18
|
+
* handler: async ({ name }, { home }) => {
|
|
19
|
+
* // ... look up anima using home to find the guild ...
|
|
20
|
+
* return { found: true, status: 'active' };
|
|
21
|
+
* },
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
import { z } from 'zod';
|
|
26
|
+
type ZodShape = Record<string, z.ZodType>;
|
|
27
|
+
/**
|
|
28
|
+
* Framework-provided context injected into every implement handler call.
|
|
29
|
+
* The implement author doesn't construct this — the framework (MCP engine, CLI,
|
|
30
|
+
* or calling engine) provides it.
|
|
31
|
+
*/
|
|
32
|
+
export interface ImplementContext {
|
|
33
|
+
/** Absolute path to NEXUS_HOME. */
|
|
34
|
+
home: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A fully-defined implement — the return type of `implement()`.
|
|
38
|
+
*
|
|
39
|
+
* The MCP engine uses `.params.shape` to register the tool's input schema,
|
|
40
|
+
* `.description` for the tool description, and `.handler` to execute calls.
|
|
41
|
+
* The CLI uses `.params` to auto-generate Commander options.
|
|
42
|
+
* Engines call `.handler` directly.
|
|
43
|
+
*/
|
|
44
|
+
export interface ImplementDefinition<TShape extends ZodShape = ZodShape> {
|
|
45
|
+
readonly description: string;
|
|
46
|
+
readonly params: z.ZodObject<TShape>;
|
|
47
|
+
readonly handler: (params: z.infer<z.ZodObject<TShape>>, context: ImplementContext) => unknown | Promise<unknown>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Define a Nexus implement.
|
|
51
|
+
*
|
|
52
|
+
* This is the primary SDK entry point for module-based implements. Pass a
|
|
53
|
+
* description, a params object of Zod schemas, and a handler function.
|
|
54
|
+
* The framework handles the rest — MCP registration, CLI generation, validation.
|
|
55
|
+
*
|
|
56
|
+
* The handler receives two arguments:
|
|
57
|
+
* - `params` — the validated input, typed from your Zod schemas
|
|
58
|
+
* - `context` — framework-injected context (NEXUS_HOME path, etc.)
|
|
59
|
+
*
|
|
60
|
+
* Return any JSON-serializable value. The MCP engine wraps it as tool output;
|
|
61
|
+
* the CLI prints it; engines use it directly.
|
|
62
|
+
*/
|
|
63
|
+
export declare function implement<TShape extends ZodShape>(def: {
|
|
64
|
+
description: string;
|
|
65
|
+
params: TShape;
|
|
66
|
+
handler: (params: z.infer<z.ZodObject<TShape>>, context: ImplementContext) => unknown | Promise<unknown>;
|
|
67
|
+
}): ImplementDefinition<TShape>;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=implement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implement.d.ts","sourceRoot":"","sources":["../src/implement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;AAE1C;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB,CAAC,MAAM,SAAS,QAAQ,GAAG,QAAQ;IACrE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,CAChB,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EACpC,OAAO,EAAE,gBAAgB,KACtB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACjC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,MAAM,SAAS,QAAQ,EAAE,GAAG,EAAE;IACtD,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,CACP,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EACpC,OAAO,EAAE,gBAAgB,KACtB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACjC,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAM9B"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implement SDK — the primary authoring interface for module-based implements.
|
|
3
|
+
*
|
|
4
|
+
* Use `implement()` to define a typed implement with Zod parameter schemas.
|
|
5
|
+
* The returned definition is what the MCP engine imports and registers as a tool,
|
|
6
|
+
* what the CLI uses to auto-generate subcommands, and what engines import directly.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { implement } from '@shardworks/nexus-core';
|
|
11
|
+
* import { z } from 'zod';
|
|
12
|
+
*
|
|
13
|
+
* export default implement({
|
|
14
|
+
* description: 'Look up an anima by name',
|
|
15
|
+
* params: {
|
|
16
|
+
* name: z.string().describe('Anima name'),
|
|
17
|
+
* },
|
|
18
|
+
* handler: async ({ name }, { home }) => {
|
|
19
|
+
* // ... look up anima using home to find the guild ...
|
|
20
|
+
* return { found: true, status: 'active' };
|
|
21
|
+
* },
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
import { z } from 'zod';
|
|
26
|
+
/**
|
|
27
|
+
* Define a Nexus implement.
|
|
28
|
+
*
|
|
29
|
+
* This is the primary SDK entry point for module-based implements. Pass a
|
|
30
|
+
* description, a params object of Zod schemas, and a handler function.
|
|
31
|
+
* The framework handles the rest — MCP registration, CLI generation, validation.
|
|
32
|
+
*
|
|
33
|
+
* The handler receives two arguments:
|
|
34
|
+
* - `params` — the validated input, typed from your Zod schemas
|
|
35
|
+
* - `context` — framework-injected context (NEXUS_HOME path, etc.)
|
|
36
|
+
*
|
|
37
|
+
* Return any JSON-serializable value. The MCP engine wraps it as tool output;
|
|
38
|
+
* the CLI prints it; engines use it directly.
|
|
39
|
+
*/
|
|
40
|
+
export function implement(def) {
|
|
41
|
+
return {
|
|
42
|
+
description: def.description,
|
|
43
|
+
params: z.object(def.params),
|
|
44
|
+
handler: def.handler,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=implement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implement.js","sourceRoot":"","sources":["../src/implement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiCxB;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,SAAS,CAA0B,GAOlD;IACC,OAAO;QACL,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;QAC5B,OAAO,EAAE,GAAG,CAAC,OAAO;KACrB,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const VERSION = "0.1.0";
|
|
2
|
+
export { type ImplementContext, type ImplementDefinition, implement, } from './implement.ts';
|
|
3
|
+
export { createLedger, INITIAL_SCHEMA } from './ledger.ts';
|
|
4
|
+
export { type GuildConfig, type ToolEntry, type TrainingEntry, createInitialGuildConfig, guildConfigPath, readGuildConfig, writeGuildConfig, } from './guild-config.ts';
|
|
5
|
+
export { resolveNexusHome, guildhallBarePath, guildhallWorktreePath, ledgerPath, worktreesPath, } from './nexus-home.ts';
|
|
6
|
+
export { type InstallToolOptions, type InstallResult, installTool, } from './install-tool.ts';
|
|
7
|
+
export { type RemoveToolOptions, type RemoveResult, removeTool, } from './remove-tool.ts';
|
|
8
|
+
export { type DispatchOptions, type DispatchResult, dispatch, } from './dispatch.ts';
|
|
9
|
+
export { type PublishOptions, type PublishResult, publish, } from './publish.ts';
|
|
10
|
+
export { type InstantiateOptions, type InstantiateResult, instantiate, } from './instantiate.ts';
|
|
11
|
+
export { type BaseToolRef, BASE_IMPLEMENTS, BASE_ENGINES, BASE_TOOLS, } from './base-tools.ts';
|
|
12
|
+
export { initGuild } from './init-guild.ts';
|
|
13
|
+
export { bootstrapBaseTools } from './bootstrap.ts';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,SAAS,GACV,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,EACV,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,UAAU,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,QAAQ,GACT,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,OAAO,GACR,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,WAAW,EAChB,eAAe,EACf,YAAY,EACZ,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// @shardworks/nexus-core — shared infrastructure for the guild system
|
|
2
|
+
export const VERSION = '0.1.0';
|
|
3
|
+
export { implement, } from "./implement.js";
|
|
4
|
+
export { createLedger, INITIAL_SCHEMA } from "./ledger.js";
|
|
5
|
+
export { createInitialGuildConfig, guildConfigPath, readGuildConfig, writeGuildConfig, } from "./guild-config.js";
|
|
6
|
+
export { resolveNexusHome, guildhallBarePath, guildhallWorktreePath, ledgerPath, worktreesPath, } from "./nexus-home.js";
|
|
7
|
+
export { installTool, } from "./install-tool.js";
|
|
8
|
+
export { removeTool, } from "./remove-tool.js";
|
|
9
|
+
export { dispatch, } from "./dispatch.js";
|
|
10
|
+
export { publish, } from "./publish.js";
|
|
11
|
+
export { instantiate, } from "./instantiate.js";
|
|
12
|
+
export { BASE_IMPLEMENTS, BASE_ENGINES, BASE_TOOLS, } from "./base-tools.js";
|
|
13
|
+
export { initGuild } from "./init-guild.js";
|
|
14
|
+
export { bootstrapBaseTools } from "./bootstrap.js";
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,OAAO,EAGL,SAAS,GACV,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAIL,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,EACV,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAGL,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGL,UAAU,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,QAAQ,GACT,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,OAAO,GACR,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,eAAe,EACf,YAAY,EACZ,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a new guild skeleton at the given path.
|
|
3
|
+
*
|
|
4
|
+
* Sets up the NEXUS_HOME directory structure: bare guildhall repo,
|
|
5
|
+
* standing worktree with scaffolded directories, empty guild.json,
|
|
6
|
+
* the initial migration file, and an initial git commit.
|
|
7
|
+
*
|
|
8
|
+
* This is the first step of guild creation. After this, the caller
|
|
9
|
+
* should bootstrap base tools and apply migrations:
|
|
10
|
+
*
|
|
11
|
+
* initGuild(home, model) // skeleton
|
|
12
|
+
* bootstrapBaseTools(home, ...) // install framework tools via installTool
|
|
13
|
+
* applyMigrations(home) // create ledger via migration engine
|
|
14
|
+
*
|
|
15
|
+
* @param home - Absolute path for the new NEXUS_HOME directory.
|
|
16
|
+
* @param model - Default model identifier for anima sessions.
|
|
17
|
+
* @throws If `home` exists and is not empty.
|
|
18
|
+
*/
|
|
19
|
+
export declare function initGuild(home: string, model: string): void;
|
|
20
|
+
//# sourceMappingURL=init-guild.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-guild.d.ts","sourceRoot":"","sources":["../src/init-guild.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CA8D3D"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { execFileSync } from 'node:child_process';
|
|
4
|
+
import { VERSION } from "./index.js";
|
|
5
|
+
import { guildhallBarePath, guildhallWorktreePath } from "./nexus-home.js";
|
|
6
|
+
import { createInitialGuildConfig } from "./guild-config.js";
|
|
7
|
+
import { INITIAL_SCHEMA } from "./ledger.js";
|
|
8
|
+
function git(args, cwd) {
|
|
9
|
+
execFileSync('git', args, { cwd, stdio: 'pipe' });
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Create a new guild skeleton at the given path.
|
|
13
|
+
*
|
|
14
|
+
* Sets up the NEXUS_HOME directory structure: bare guildhall repo,
|
|
15
|
+
* standing worktree with scaffolded directories, empty guild.json,
|
|
16
|
+
* the initial migration file, and an initial git commit.
|
|
17
|
+
*
|
|
18
|
+
* This is the first step of guild creation. After this, the caller
|
|
19
|
+
* should bootstrap base tools and apply migrations:
|
|
20
|
+
*
|
|
21
|
+
* initGuild(home, model) // skeleton
|
|
22
|
+
* bootstrapBaseTools(home, ...) // install framework tools via installTool
|
|
23
|
+
* applyMigrations(home) // create ledger via migration engine
|
|
24
|
+
*
|
|
25
|
+
* @param home - Absolute path for the new NEXUS_HOME directory.
|
|
26
|
+
* @param model - Default model identifier for anima sessions.
|
|
27
|
+
* @throws If `home` exists and is not empty.
|
|
28
|
+
*/
|
|
29
|
+
export function initGuild(home, model) {
|
|
30
|
+
// Validate target
|
|
31
|
+
if (fs.existsSync(home)) {
|
|
32
|
+
const entries = fs.readdirSync(home);
|
|
33
|
+
if (entries.length > 0) {
|
|
34
|
+
throw new Error(`${home} exists and is not empty.`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Create NEXUS_HOME skeleton
|
|
38
|
+
const ghWorktree = guildhallWorktreePath(home);
|
|
39
|
+
fs.mkdirSync(path.dirname(ghWorktree), { recursive: true });
|
|
40
|
+
// Create guildhall bare repo
|
|
41
|
+
const ghBare = guildhallBarePath(home);
|
|
42
|
+
git(['init', '--bare', ghBare]);
|
|
43
|
+
// Create standing worktree
|
|
44
|
+
git(['-C', ghBare, 'worktree', 'add', '-b', 'main', ghWorktree]);
|
|
45
|
+
// Scaffold guildhall directory structure
|
|
46
|
+
const dirs = [
|
|
47
|
+
'nexus/implements',
|
|
48
|
+
'nexus/engines',
|
|
49
|
+
'nexus/migrations',
|
|
50
|
+
'implements',
|
|
51
|
+
'engines',
|
|
52
|
+
'codex/roles',
|
|
53
|
+
'training/curricula',
|
|
54
|
+
'training/temperaments',
|
|
55
|
+
];
|
|
56
|
+
for (const dir of dirs) {
|
|
57
|
+
const full = path.join(ghWorktree, dir);
|
|
58
|
+
fs.mkdirSync(full, { recursive: true });
|
|
59
|
+
fs.writeFileSync(path.join(full, '.gitkeep'), '');
|
|
60
|
+
}
|
|
61
|
+
// Write initial migration
|
|
62
|
+
fs.writeFileSync(path.join(ghWorktree, 'nexus/migrations/001-initial-schema.sql'), INITIAL_SCHEMA.trimStart());
|
|
63
|
+
// Remove .gitkeep from migrations since it now has a real file
|
|
64
|
+
const migrationsGitkeep = path.join(ghWorktree, 'nexus/migrations/.gitkeep');
|
|
65
|
+
if (fs.existsSync(migrationsGitkeep)) {
|
|
66
|
+
fs.unlinkSync(migrationsGitkeep);
|
|
67
|
+
}
|
|
68
|
+
// Write codex placeholder
|
|
69
|
+
fs.writeFileSync(path.join(ghWorktree, 'codex/all.md'), '');
|
|
70
|
+
// Write guild.json — empty registries, tools will be installed via bootstrapBaseTools
|
|
71
|
+
const config = createInitialGuildConfig(VERSION, model);
|
|
72
|
+
fs.writeFileSync(path.join(ghWorktree, 'guild.json'), JSON.stringify(config, null, 2) + '\n');
|
|
73
|
+
// Initial commit
|
|
74
|
+
git(['add', '-A'], ghWorktree);
|
|
75
|
+
git(['commit', '-m', 'Initialize guild'], ghWorktree);
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=init-guild.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-guild.js","sourceRoot":"","sources":["../src/init-guild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,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CACvC,CAAC;IAEF,iBAAiB;IACjB,GAAG,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC;IAC/B,GAAG,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,kBAAkB,CAAC,EAAE,UAAU,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface InstallToolOptions {
|
|
2
|
+
/** Absolute path to the NEXUS_HOME directory. */
|
|
3
|
+
home: string;
|
|
4
|
+
/** Source — currently only local directory paths. */
|
|
5
|
+
source: string;
|
|
6
|
+
/** Override the tool name (defaults to source directory name). */
|
|
7
|
+
name?: string;
|
|
8
|
+
/** Override the version slot. */
|
|
9
|
+
slot?: string;
|
|
10
|
+
/** Roles for implements (comma-separated or array). */
|
|
11
|
+
roles?: string[];
|
|
12
|
+
/**
|
|
13
|
+
* Install as a framework tool (`source: 'nexus'`).
|
|
14
|
+
* Installs to `nexus/implements/` or `nexus/engines/` instead of
|
|
15
|
+
* guild-managed directories. Framework tools cannot be removed via remove-tool.
|
|
16
|
+
*/
|
|
17
|
+
framework?: boolean;
|
|
18
|
+
/** Whether to create a git commit after installing. Defaults to true. */
|
|
19
|
+
commit?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface InstallResult {
|
|
22
|
+
category: 'implements' | 'engines' | 'curricula' | 'temperaments';
|
|
23
|
+
name: string;
|
|
24
|
+
slot: string;
|
|
25
|
+
installedTo: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Install a tool (implement, engine, curriculum, or temperament) into the guild.
|
|
29
|
+
*
|
|
30
|
+
* Currently supports local directory sources only. Detects the descriptor type,
|
|
31
|
+
* copies the directory to the correct slot, and registers in guild.json.
|
|
32
|
+
*/
|
|
33
|
+
export declare function installTool(opts: InstallToolOptions): InstallResult;
|
|
34
|
+
//# sourceMappingURL=install-tool.d.ts.map
|