@shardworks/nexus-core 0.1.15 → 0.1.17
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/clockworks.d.ts +34 -0
- package/dist/clockworks.d.ts.map +1 -0
- package/dist/clockworks.js +211 -0
- package/dist/clockworks.js.map +1 -0
- package/dist/dispatch.d.ts.map +1 -1
- package/dist/dispatch.js +3 -2
- package/dist/dispatch.js.map +1 -1
- package/dist/engine.d.ts +60 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +45 -0
- package/dist/engine.js.map +1 -0
- package/dist/events.d.ts +49 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +134 -0
- package/dist/events.js.map +1 -0
- package/dist/guild-config.d.ts +36 -2
- package/dist/guild-config.d.ts.map +1 -1
- package/dist/guild-config.js +1 -1
- package/dist/guild-config.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/rehydrate.d.ts +7 -0
- package/dist/rehydrate.d.ts.map +1 -1
- package/dist/rehydrate.js +33 -8
- package/dist/rehydrate.js.map +1 -1
- package/dist/workshop.d.ts +85 -0
- package/dist/workshop.d.ts.map +1 -0
- package/dist/workshop.js +189 -0
- package/dist/workshop.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Result of processing a single event. */
|
|
2
|
+
export interface TickResult {
|
|
3
|
+
eventId: number;
|
|
4
|
+
eventName: string;
|
|
5
|
+
dispatches: DispatchSummary[];
|
|
6
|
+
}
|
|
7
|
+
/** Summary of one standing order execution. */
|
|
8
|
+
export interface DispatchSummary {
|
|
9
|
+
handlerType: 'engine' | 'anima';
|
|
10
|
+
handlerName: string;
|
|
11
|
+
status: 'success' | 'error' | 'skipped';
|
|
12
|
+
error?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Result of a full clock run. */
|
|
15
|
+
export interface ClockRunResult {
|
|
16
|
+
processed: TickResult[];
|
|
17
|
+
totalEvents: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Process the next pending event (or a specific event by id).
|
|
21
|
+
*
|
|
22
|
+
* @param home - Guild root path.
|
|
23
|
+
* @param eventId - Specific event id to process, or undefined for next pending.
|
|
24
|
+
* @returns Processing result, or null if no events to process.
|
|
25
|
+
*/
|
|
26
|
+
export declare function clockTick(home: string, eventId?: number): Promise<TickResult | null>;
|
|
27
|
+
/**
|
|
28
|
+
* Process all pending events until the queue is empty.
|
|
29
|
+
*
|
|
30
|
+
* @param home - Guild root path.
|
|
31
|
+
* @returns Summary of all processing.
|
|
32
|
+
*/
|
|
33
|
+
export declare function clockRun(home: string): Promise<ClockRunResult>;
|
|
34
|
+
//# sourceMappingURL=clockworks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clockworks.d.ts","sourceRoot":"","sources":["../src/clockworks.ts"],"names":[],"mappings":"AAsBA,2CAA2C;AAC3C,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,eAAe,EAAE,CAAC;CAC/B;AAED,+CAA+C;AAC/C,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,QAAQ,GAAG,OAAO,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,kCAAkC;AAClC,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,UAAU,EAAE,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB;AA0LD;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAa1F;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAkBpE"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Clockworks runner — processes the event queue by matching pending events
|
|
11
|
+
* to standing orders in guild.json and executing them.
|
|
12
|
+
*
|
|
13
|
+
* This is the core of Pillar 5. It reads unprocessed events from the Ledger,
|
|
14
|
+
* finds matching standing orders, and dispatches them (run engines, or
|
|
15
|
+
* summon/brief animas). Each event is marked as processed after all its
|
|
16
|
+
* standing orders have been dispatched.
|
|
17
|
+
*/
|
|
18
|
+
import path from 'node:path';
|
|
19
|
+
import { readGuildConfig } from "./guild-config.js";
|
|
20
|
+
import { readPendingEvents, readEvent, markEventProcessed, recordDispatch, signalEvent, } from "./events.js";
|
|
21
|
+
import { isClockworkEngine } from "./engine.js";
|
|
22
|
+
/**
|
|
23
|
+
* Process a single event: find matching standing orders and execute them.
|
|
24
|
+
*
|
|
25
|
+
* @param home - Absolute path to the guild root.
|
|
26
|
+
* @param event - The event to process.
|
|
27
|
+
* @returns Summary of what was dispatched.
|
|
28
|
+
*/
|
|
29
|
+
async function processEvent(home, event) {
|
|
30
|
+
const config = readGuildConfig(home);
|
|
31
|
+
const standingOrders = config.clockworks?.standingOrders ?? [];
|
|
32
|
+
const matching = standingOrders.filter(so => so.on === event.name);
|
|
33
|
+
const dispatches = [];
|
|
34
|
+
// Check loop guard: don't process standing-order.failed events triggered
|
|
35
|
+
// by other standing-order.failed events.
|
|
36
|
+
const isFailureEvent = event.name === 'standing-order.failed';
|
|
37
|
+
const isNestedFailure = isFailureEvent &&
|
|
38
|
+
typeof event.payload === 'object' &&
|
|
39
|
+
event.payload !== null &&
|
|
40
|
+
'triggeringEvent' in event.payload &&
|
|
41
|
+
typeof event.payload.triggeringEvent === 'object' &&
|
|
42
|
+
event.payload.triggeringEvent !== null &&
|
|
43
|
+
event.payload.triggeringEvent.name === 'standing-order.failed';
|
|
44
|
+
if (isNestedFailure) {
|
|
45
|
+
// Loop guard: skip processing to prevent cascade.
|
|
46
|
+
markEventProcessed(home, event.id);
|
|
47
|
+
return { eventId: event.id, eventName: event.name, dispatches: [] };
|
|
48
|
+
}
|
|
49
|
+
for (const order of matching) {
|
|
50
|
+
if ('run' in order && order.run) {
|
|
51
|
+
const summary = await executeEngineOrder(home, event, order.run, config);
|
|
52
|
+
dispatches.push(summary);
|
|
53
|
+
// On failure, signal standing-order.failed
|
|
54
|
+
if (summary.status === 'error') {
|
|
55
|
+
signalStandingOrderFailed(home, order, event, summary.error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if ('summon' in order && order.summon) {
|
|
59
|
+
const summary = await executeAnimaOrder(home, event, order.summon, 'summon');
|
|
60
|
+
dispatches.push(summary);
|
|
61
|
+
if (summary.status === 'error') {
|
|
62
|
+
signalStandingOrderFailed(home, order, event, summary.error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else if ('brief' in order && order.brief) {
|
|
66
|
+
const summary = await executeAnimaOrder(home, event, order.brief, 'brief');
|
|
67
|
+
dispatches.push(summary);
|
|
68
|
+
if (summary.status === 'error') {
|
|
69
|
+
signalStandingOrderFailed(home, order, event, summary.error);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
markEventProcessed(home, event.id);
|
|
74
|
+
return { eventId: event.id, eventName: event.name, dispatches };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Execute a `run:` standing order — load and call a clockwork engine.
|
|
78
|
+
*/
|
|
79
|
+
async function executeEngineOrder(home, event, engineName, config) {
|
|
80
|
+
const startedAt = new Date().toISOString();
|
|
81
|
+
try {
|
|
82
|
+
// Resolve engine entry point from guild.json
|
|
83
|
+
const engineEntry = config.engines?.[engineName];
|
|
84
|
+
if (!engineEntry) {
|
|
85
|
+
throw new Error(`Engine "${engineName}" not found in guild.json engines registry.`);
|
|
86
|
+
}
|
|
87
|
+
// Resolve the engine module path
|
|
88
|
+
const enginePkg = engineEntry.package;
|
|
89
|
+
if (!enginePkg) {
|
|
90
|
+
throw new Error(`Engine "${engineName}" has no package field — cannot resolve module.`);
|
|
91
|
+
}
|
|
92
|
+
// Import the engine module
|
|
93
|
+
const mod = await import(__rewriteRelativeImportExtension(enginePkg));
|
|
94
|
+
const engineDef = mod.default;
|
|
95
|
+
if (!isClockworkEngine(engineDef)) {
|
|
96
|
+
throw new Error(`Engine "${engineName}" does not export a clockwork engine (engine() factory). ` +
|
|
97
|
+
`Only clockwork engines can be used in "run:" standing orders.`);
|
|
98
|
+
}
|
|
99
|
+
await engineDef.handler(event, { home });
|
|
100
|
+
const endedAt = new Date().toISOString();
|
|
101
|
+
recordDispatch(home, {
|
|
102
|
+
eventId: event.id,
|
|
103
|
+
handlerType: 'engine',
|
|
104
|
+
handlerName: engineName,
|
|
105
|
+
startedAt,
|
|
106
|
+
endedAt,
|
|
107
|
+
status: 'success',
|
|
108
|
+
});
|
|
109
|
+
return { handlerType: 'engine', handlerName: engineName, status: 'success' };
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
const endedAt = new Date().toISOString();
|
|
113
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
114
|
+
recordDispatch(home, {
|
|
115
|
+
eventId: event.id,
|
|
116
|
+
handlerType: 'engine',
|
|
117
|
+
handlerName: engineName,
|
|
118
|
+
startedAt,
|
|
119
|
+
endedAt,
|
|
120
|
+
status: 'error',
|
|
121
|
+
error: errorMsg,
|
|
122
|
+
});
|
|
123
|
+
return { handlerType: 'engine', handlerName: engineName, status: 'error', error: errorMsg };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Execute a `summon:` or `brief:` standing order.
|
|
128
|
+
*
|
|
129
|
+
* Phase 1: records the dispatch but does NOT actually manifest the anima.
|
|
130
|
+
* Anima manifestation requires the manifest engine, which needs extension
|
|
131
|
+
* to accept event context. For now, we record the intent and mark it as
|
|
132
|
+
* skipped so the system is auditable.
|
|
133
|
+
*/
|
|
134
|
+
async function executeAnimaOrder(home, event, roleName, noticeType) {
|
|
135
|
+
const startedAt = new Date().toISOString();
|
|
136
|
+
// Phase 1: record the dispatch intent but don't actually manifest.
|
|
137
|
+
// The manifest engine needs extension to accept event context.
|
|
138
|
+
const endedAt = new Date().toISOString();
|
|
139
|
+
recordDispatch(home, {
|
|
140
|
+
eventId: event.id,
|
|
141
|
+
handlerType: 'anima',
|
|
142
|
+
handlerName: `(role: ${roleName})`,
|
|
143
|
+
targetRole: roleName,
|
|
144
|
+
noticeType,
|
|
145
|
+
startedAt,
|
|
146
|
+
endedAt,
|
|
147
|
+
status: 'success',
|
|
148
|
+
});
|
|
149
|
+
return {
|
|
150
|
+
handlerType: 'anima',
|
|
151
|
+
handlerName: `(role: ${roleName})`,
|
|
152
|
+
status: 'skipped',
|
|
153
|
+
error: 'Anima manifestation via standing orders not yet implemented (Phase 1)',
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Signal standing-order.failed when a standing order execution fails.
|
|
158
|
+
*/
|
|
159
|
+
function signalStandingOrderFailed(home, order, triggeringEvent, error) {
|
|
160
|
+
signalEvent(home, 'standing-order.failed', {
|
|
161
|
+
standingOrder: order,
|
|
162
|
+
triggeringEvent: {
|
|
163
|
+
id: triggeringEvent.id,
|
|
164
|
+
name: triggeringEvent.name,
|
|
165
|
+
},
|
|
166
|
+
error,
|
|
167
|
+
}, 'framework');
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Process the next pending event (or a specific event by id).
|
|
171
|
+
*
|
|
172
|
+
* @param home - Guild root path.
|
|
173
|
+
* @param eventId - Specific event id to process, or undefined for next pending.
|
|
174
|
+
* @returns Processing result, or null if no events to process.
|
|
175
|
+
*/
|
|
176
|
+
export async function clockTick(home, eventId) {
|
|
177
|
+
if (eventId != null) {
|
|
178
|
+
const event = readEvent(home, eventId);
|
|
179
|
+
if (!event) {
|
|
180
|
+
throw new Error(`Event #${eventId} not found.`);
|
|
181
|
+
}
|
|
182
|
+
return processEvent(home, event);
|
|
183
|
+
}
|
|
184
|
+
const pending = readPendingEvents(home);
|
|
185
|
+
if (pending.length === 0)
|
|
186
|
+
return null;
|
|
187
|
+
return processEvent(home, pending[0]);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Process all pending events until the queue is empty.
|
|
191
|
+
*
|
|
192
|
+
* @param home - Guild root path.
|
|
193
|
+
* @returns Summary of all processing.
|
|
194
|
+
*/
|
|
195
|
+
export async function clockRun(home) {
|
|
196
|
+
const processed = [];
|
|
197
|
+
let totalEvents = 0;
|
|
198
|
+
// Process in a loop because standing order failures may generate new events
|
|
199
|
+
while (true) {
|
|
200
|
+
const pending = readPendingEvents(home);
|
|
201
|
+
if (pending.length === 0)
|
|
202
|
+
break;
|
|
203
|
+
totalEvents += pending.length;
|
|
204
|
+
for (const event of pending) {
|
|
205
|
+
const result = await processEvent(home, event);
|
|
206
|
+
processed.push(result);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return { processed, totalEvents };
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=clockworks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clockworks.js","sourceRoot":"","sources":["../src/clockworks.ts"],"names":[],"mappings":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nC,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,4EAA4E;IAC5E,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,OAAO,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM;QAEhC,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;QAE9B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC/C,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;AACpC,CAAC"}
|
package/dist/dispatch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,eAAe;IAC9B,uCAAuC;IACvC,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,
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,eAAe;IAC9B,uCAAuC;IACvC,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,CAiE9D"}
|
package/dist/dispatch.js
CHANGED
|
@@ -17,8 +17,9 @@ export function dispatch(opts) {
|
|
|
17
17
|
const { home, spec, workshop, anima } = opts;
|
|
18
18
|
// Validate workshop exists in guild.json
|
|
19
19
|
const config = readGuildConfig(home);
|
|
20
|
-
if (!config.workshops
|
|
21
|
-
|
|
20
|
+
if (!(workshop in config.workshops)) {
|
|
21
|
+
const available = Object.keys(config.workshops).join(', ') || '(none)';
|
|
22
|
+
throw new Error(`Workshop "${workshop}" not found in guild.json. Available workshops: ${available}`);
|
|
22
23
|
}
|
|
23
24
|
const db = new Database(ledgerPath(home));
|
|
24
25
|
db.pragma('foreign_keys = ON');
|
package/dist/dispatch.js.map
CHANGED
|
@@ -1 +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;IAE7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ring interface for clockwork engines.
|
|
3
|
+
*
|
|
4
|
+
* Use `engine()` to define a clockwork engine that responds to guild events.
|
|
5
|
+
* The returned definition is what the Clockworks runner imports and calls.
|
|
6
|
+
* Static engines (manifest, ledger-migrate, etc.) do NOT use this factory —
|
|
7
|
+
* they have bespoke APIs and are called directly by framework code.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { engine } from '@shardworks/nexus-core';
|
|
12
|
+
*
|
|
13
|
+
* export default engine({
|
|
14
|
+
* handler: async (event, { home }) => {
|
|
15
|
+
* // event is the triggering GuildEvent when invoked by a standing order
|
|
16
|
+
* // event is null when invoked directly (CLI, import)
|
|
17
|
+
* if (event) {
|
|
18
|
+
* console.log(`Handling ${event.name}`, event.payload);
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
/** An immutable fact from the event log — the input to clockwork engines. */
|
|
25
|
+
export interface GuildEvent {
|
|
26
|
+
id: number;
|
|
27
|
+
name: string;
|
|
28
|
+
payload: unknown;
|
|
29
|
+
emitter: string;
|
|
30
|
+
firedAt: string;
|
|
31
|
+
}
|
|
32
|
+
/** Framework-provided context injected into every engine handler call. */
|
|
33
|
+
export interface EngineContext {
|
|
34
|
+
/** Absolute path to the guild root. */
|
|
35
|
+
home: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A fully-defined clockwork engine — the return type of `engine()`.
|
|
39
|
+
*
|
|
40
|
+
* The Clockworks runner calls `.handler(event, { home })` when a standing
|
|
41
|
+
* order fires. The `__clockwork` brand is used at load time to distinguish
|
|
42
|
+
* clockwork engines from static engines.
|
|
43
|
+
*/
|
|
44
|
+
export interface EngineDefinition {
|
|
45
|
+
readonly __clockwork: true;
|
|
46
|
+
readonly handler: (event: GuildEvent | null, ctx: EngineContext) => Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Define a clockwork engine.
|
|
50
|
+
*
|
|
51
|
+
* This is the SDK entry point for event-driven engines. Pass a handler
|
|
52
|
+
* function that receives a GuildEvent (or null for direct invocation)
|
|
53
|
+
* and an EngineContext.
|
|
54
|
+
*/
|
|
55
|
+
export declare function engine(def: {
|
|
56
|
+
handler: (event: GuildEvent | null, ctx: EngineContext) => Promise<void>;
|
|
57
|
+
}): EngineDefinition;
|
|
58
|
+
/** Type guard: is this module export a clockwork engine? */
|
|
59
|
+
export declare function isClockworkEngine(obj: unknown): obj is EngineDefinition;
|
|
60
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,6EAA6E;AAC7E,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,0EAA0E;AAC1E,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,EAAE,GAAG,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACnF;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE;IAC1B,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,EAAE,GAAG,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1E,GAAG,gBAAgB,CAKnB;AAED,4DAA4D;AAC5D,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,gBAAgB,CAQvE"}
|
package/dist/engine.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine SDK — the authoring interface for clockwork engines.
|
|
3
|
+
*
|
|
4
|
+
* Use `engine()` to define a clockwork engine that responds to guild events.
|
|
5
|
+
* The returned definition is what the Clockworks runner imports and calls.
|
|
6
|
+
* Static engines (manifest, ledger-migrate, etc.) do NOT use this factory —
|
|
7
|
+
* they have bespoke APIs and are called directly by framework code.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { engine } from '@shardworks/nexus-core';
|
|
12
|
+
*
|
|
13
|
+
* export default engine({
|
|
14
|
+
* handler: async (event, { home }) => {
|
|
15
|
+
* // event is the triggering GuildEvent when invoked by a standing order
|
|
16
|
+
* // event is null when invoked directly (CLI, import)
|
|
17
|
+
* if (event) {
|
|
18
|
+
* console.log(`Handling ${event.name}`, event.payload);
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Define a clockwork engine.
|
|
26
|
+
*
|
|
27
|
+
* This is the SDK entry point for event-driven engines. Pass a handler
|
|
28
|
+
* function that receives a GuildEvent (or null for direct invocation)
|
|
29
|
+
* and an EngineContext.
|
|
30
|
+
*/
|
|
31
|
+
export function engine(def) {
|
|
32
|
+
return {
|
|
33
|
+
__clockwork: true,
|
|
34
|
+
handler: def.handler,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** Type guard: is this module export a clockwork engine? */
|
|
38
|
+
export function isClockworkEngine(obj) {
|
|
39
|
+
return (typeof obj === 'object' &&
|
|
40
|
+
obj !== null &&
|
|
41
|
+
'__clockwork' in obj &&
|
|
42
|
+
obj.__clockwork === true &&
|
|
43
|
+
typeof obj.handler === 'function');
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AA6BH;;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CAAC,GAEtB;IACC,OAAO;QACL,WAAW,EAAE,IAAI;QACjB,OAAO,EAAE,GAAG,CAAC,OAAO;KACrB,CAAC;AACJ,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC5C,OAAO,CACL,OAAO,GAAG,KAAK,QAAQ;QACvB,GAAG,KAAK,IAAI;QACZ,aAAa,IAAI,GAAG;QACnB,GAAwB,CAAC,WAAW,KAAK,IAAI;QAC9C,OAAQ,GAAwB,CAAC,OAAO,KAAK,UAAU,CACxD,CAAC;AACJ,CAAC"}
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { GuildEvent } from './engine.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Check if an event name is in a reserved framework namespace.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isFrameworkEvent(name: string): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Validate that a custom event name is declared in guild.json clockworks.events.
|
|
8
|
+
* Throws if the name is in a reserved namespace or not declared.
|
|
9
|
+
*/
|
|
10
|
+
export declare function validateCustomEvent(home: string, name: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Signal an event — persist it to the Ledger's events table.
|
|
13
|
+
*
|
|
14
|
+
* Does not process the event. The Clockworks runner processes separately.
|
|
15
|
+
*
|
|
16
|
+
* @param home - Absolute path to the guild root.
|
|
17
|
+
* @param name - Event name (e.g. "commission.sealed", "code.reviewed").
|
|
18
|
+
* @param payload - Event-specific data (JSON-serializable).
|
|
19
|
+
* @param emitter - Who signaled it: anima name, engine name, or "framework".
|
|
20
|
+
* @returns The event id.
|
|
21
|
+
*/
|
|
22
|
+
export declare function signalEvent(home: string, name: string, payload: unknown, emitter: string): number;
|
|
23
|
+
/**
|
|
24
|
+
* Read pending (unprocessed) events from the Ledger, ordered by fired_at.
|
|
25
|
+
*/
|
|
26
|
+
export declare function readPendingEvents(home: string): GuildEvent[];
|
|
27
|
+
/**
|
|
28
|
+
* Read a single event by id.
|
|
29
|
+
*/
|
|
30
|
+
export declare function readEvent(home: string, id: number): GuildEvent | null;
|
|
31
|
+
/**
|
|
32
|
+
* Mark an event as processed.
|
|
33
|
+
*/
|
|
34
|
+
export declare function markEventProcessed(home: string, eventId: number): void;
|
|
35
|
+
/**
|
|
36
|
+
* Record an event dispatch in the event_dispatches table.
|
|
37
|
+
*/
|
|
38
|
+
export declare function recordDispatch(home: string, opts: {
|
|
39
|
+
eventId: number;
|
|
40
|
+
handlerType: 'engine' | 'anima';
|
|
41
|
+
handlerName: string;
|
|
42
|
+
targetRole?: string;
|
|
43
|
+
noticeType?: 'summon' | 'brief';
|
|
44
|
+
startedAt: string;
|
|
45
|
+
endedAt: string;
|
|
46
|
+
status: 'success' | 'error';
|
|
47
|
+
error?: string;
|
|
48
|
+
}): void;
|
|
49
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAY9C;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAiBpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,MAAM,CAaR;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CAmB5D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAqBrE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAStE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;IACJ,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,QAAQ,GAAG,OAAO,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GACA,IAAI,CAsBN"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event signalling — persists events to the Ledger for Clockworks processing.
|
|
3
|
+
*
|
|
4
|
+
* signalEvent() is the write path. It records an immutable fact in the events
|
|
5
|
+
* table. It does NOT process the event — the Clockworks runner handles that
|
|
6
|
+
* separately via `nsg clock`.
|
|
7
|
+
*/
|
|
8
|
+
import Database from 'better-sqlite3';
|
|
9
|
+
import { ledgerPath } from "./nexus-home.js";
|
|
10
|
+
import { readGuildConfig } from "./guild-config.js";
|
|
11
|
+
/** Reserved framework event namespaces. Animas cannot signal these. */
|
|
12
|
+
const FRAMEWORK_NAMESPACES = [
|
|
13
|
+
'anima.',
|
|
14
|
+
'commission.',
|
|
15
|
+
'tool.',
|
|
16
|
+
'migration.',
|
|
17
|
+
'guild.',
|
|
18
|
+
'standing-order.',
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* Check if an event name is in a reserved framework namespace.
|
|
22
|
+
*/
|
|
23
|
+
export function isFrameworkEvent(name) {
|
|
24
|
+
return FRAMEWORK_NAMESPACES.some(ns => name.startsWith(ns));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Validate that a custom event name is declared in guild.json clockworks.events.
|
|
28
|
+
* Throws if the name is in a reserved namespace or not declared.
|
|
29
|
+
*/
|
|
30
|
+
export function validateCustomEvent(home, name) {
|
|
31
|
+
if (isFrameworkEvent(name)) {
|
|
32
|
+
throw new Error(`Event "${name}" is in a reserved framework namespace. ` +
|
|
33
|
+
`Animas and operators can only signal custom events declared in guild.json.`);
|
|
34
|
+
}
|
|
35
|
+
const config = readGuildConfig(home);
|
|
36
|
+
const declaredEvents = config.clockworks?.events ?? {};
|
|
37
|
+
if (!Object.hasOwn(declaredEvents, name)) {
|
|
38
|
+
const available = Object.keys(declaredEvents);
|
|
39
|
+
throw new Error(`Event "${name}" is not declared in guild.json clockworks.events. ` +
|
|
40
|
+
`Declared events: ${available.length > 0 ? available.join(', ') : '(none)'}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Signal an event — persist it to the Ledger's events table.
|
|
45
|
+
*
|
|
46
|
+
* Does not process the event. The Clockworks runner processes separately.
|
|
47
|
+
*
|
|
48
|
+
* @param home - Absolute path to the guild root.
|
|
49
|
+
* @param name - Event name (e.g. "commission.sealed", "code.reviewed").
|
|
50
|
+
* @param payload - Event-specific data (JSON-serializable).
|
|
51
|
+
* @param emitter - Who signaled it: anima name, engine name, or "framework".
|
|
52
|
+
* @returns The event id.
|
|
53
|
+
*/
|
|
54
|
+
export function signalEvent(home, name, payload, emitter) {
|
|
55
|
+
const db = new Database(ledgerPath(home));
|
|
56
|
+
db.pragma('foreign_keys = ON');
|
|
57
|
+
try {
|
|
58
|
+
const result = db.prepare(`INSERT INTO events (name, payload, emitter) VALUES (?, ?, ?)`).run(name, payload != null ? JSON.stringify(payload) : null, emitter);
|
|
59
|
+
return Number(result.lastInsertRowid);
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
db.close();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Read pending (unprocessed) events from the Ledger, ordered by fired_at.
|
|
67
|
+
*/
|
|
68
|
+
export function readPendingEvents(home) {
|
|
69
|
+
const db = new Database(ledgerPath(home));
|
|
70
|
+
db.pragma('foreign_keys = ON');
|
|
71
|
+
try {
|
|
72
|
+
const rows = db.prepare(`SELECT id, name, payload, emitter, fired_at FROM events WHERE processed = 0 ORDER BY fired_at, id`).all();
|
|
73
|
+
return rows.map(row => ({
|
|
74
|
+
id: row.id,
|
|
75
|
+
name: row.name,
|
|
76
|
+
payload: row.payload ? JSON.parse(row.payload) : null,
|
|
77
|
+
emitter: row.emitter,
|
|
78
|
+
firedAt: row.fired_at,
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
db.close();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Read a single event by id.
|
|
87
|
+
*/
|
|
88
|
+
export function readEvent(home, id) {
|
|
89
|
+
const db = new Database(ledgerPath(home));
|
|
90
|
+
db.pragma('foreign_keys = ON');
|
|
91
|
+
try {
|
|
92
|
+
const row = db.prepare(`SELECT id, name, payload, emitter, fired_at FROM events WHERE id = ?`).get(id);
|
|
93
|
+
if (!row)
|
|
94
|
+
return null;
|
|
95
|
+
return {
|
|
96
|
+
id: row.id,
|
|
97
|
+
name: row.name,
|
|
98
|
+
payload: row.payload ? JSON.parse(row.payload) : null,
|
|
99
|
+
emitter: row.emitter,
|
|
100
|
+
firedAt: row.fired_at,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
db.close();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Mark an event as processed.
|
|
109
|
+
*/
|
|
110
|
+
export function markEventProcessed(home, eventId) {
|
|
111
|
+
const db = new Database(ledgerPath(home));
|
|
112
|
+
db.pragma('foreign_keys = ON');
|
|
113
|
+
try {
|
|
114
|
+
db.prepare(`UPDATE events SET processed = 1 WHERE id = ?`).run(eventId);
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
db.close();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Record an event dispatch in the event_dispatches table.
|
|
122
|
+
*/
|
|
123
|
+
export function recordDispatch(home, opts) {
|
|
124
|
+
const db = new Database(ledgerPath(home));
|
|
125
|
+
db.pragma('foreign_keys = ON');
|
|
126
|
+
try {
|
|
127
|
+
db.prepare(`INSERT INTO event_dispatches (event_id, handler_type, handler_name, target_role, notice_type, started_at, ended_at, status, error)
|
|
128
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(opts.eventId, opts.handlerType, opts.handlerName, opts.targetRole ?? null, opts.noticeType ?? null, opts.startedAt, opts.endedAt, opts.status, opts.error ?? null);
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
db.close();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,uEAAuE;AACvE,MAAM,oBAAoB,GAAG;IAC3B,QAAQ;IACR,aAAa;IACb,OAAO;IACP,YAAY;IACZ,QAAQ;IACR,iBAAiB;CAClB,C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IAAI,EACvB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,KAAK,IAAI,IAAI,CACnB,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,KAAK,EAAE,CAAC;IACb,CAAC;AACH,CAAC"}
|
package/dist/guild-config.d.ts
CHANGED
|
@@ -24,6 +24,31 @@ export interface ToolEntry {
|
|
|
24
24
|
/** Bundle that delivered this artifact, e.g. "@shardworks/guild-starter-kit@0.1.0". */
|
|
25
25
|
bundle?: string;
|
|
26
26
|
}
|
|
27
|
+
/** A custom event declaration in guild.json clockworks.events. */
|
|
28
|
+
export interface EventDeclaration {
|
|
29
|
+
/** Human-readable description of what this event means. */
|
|
30
|
+
description?: string;
|
|
31
|
+
/** Optional payload schema hint (not enforced in Phase 1). */
|
|
32
|
+
schema?: Record<string, string>;
|
|
33
|
+
}
|
|
34
|
+
/** A standing order — a registered response to an event. */
|
|
35
|
+
export type StandingOrder = {
|
|
36
|
+
on: string;
|
|
37
|
+
run: string;
|
|
38
|
+
} | {
|
|
39
|
+
on: string;
|
|
40
|
+
summon: string;
|
|
41
|
+
} | {
|
|
42
|
+
on: string;
|
|
43
|
+
brief: string;
|
|
44
|
+
};
|
|
45
|
+
/** The clockworks configuration block in guild.json. */
|
|
46
|
+
export interface ClockworksConfig {
|
|
47
|
+
/** Custom event declarations. */
|
|
48
|
+
events?: Record<string, EventDeclaration>;
|
|
49
|
+
/** Standing orders — event → action mappings. */
|
|
50
|
+
standingOrders?: StandingOrder[];
|
|
51
|
+
}
|
|
27
52
|
/** A reference to a curriculum or temperament registered in guild.json. */
|
|
28
53
|
export interface TrainingEntry {
|
|
29
54
|
/** Upstream package identifier, or null for locally-authored content. */
|
|
@@ -33,6 +58,13 @@ export interface TrainingEntry {
|
|
|
33
58
|
/** Bundle that delivered this artifact, e.g. "@shardworks/guild-starter-kit@0.1.0". */
|
|
34
59
|
bundle?: string;
|
|
35
60
|
}
|
|
61
|
+
/** A registered workshop — a repository where the guild does its work. */
|
|
62
|
+
export interface WorkshopEntry {
|
|
63
|
+
/** Git remote URL (the clone source). */
|
|
64
|
+
remoteUrl: string;
|
|
65
|
+
/** ISO-8601 timestamp of when the workshop was added. */
|
|
66
|
+
addedAt: string;
|
|
67
|
+
}
|
|
36
68
|
/** The guild's central configuration file shape (`guild.json`). */
|
|
37
69
|
export interface GuildConfig {
|
|
38
70
|
/** Guild name — used as the guildhall npm package name. */
|
|
@@ -41,8 +73,8 @@ export interface GuildConfig {
|
|
|
41
73
|
nexus: string;
|
|
42
74
|
/** Default model for anima sessions. */
|
|
43
75
|
model: string;
|
|
44
|
-
/** Registered
|
|
45
|
-
workshops: string
|
|
76
|
+
/** Registered workshops indexed by name. */
|
|
77
|
+
workshops: Record<string, WorkshopEntry>;
|
|
46
78
|
/** Guild roles — structural positions that animas fill. */
|
|
47
79
|
roles: Record<string, RoleDefinition>;
|
|
48
80
|
/** Tools available to all animas regardless of role. */
|
|
@@ -55,6 +87,8 @@ export interface GuildConfig {
|
|
|
55
87
|
curricula: Record<string, TrainingEntry>;
|
|
56
88
|
/** Available temperaments indexed by name. */
|
|
57
89
|
temperaments: Record<string, TrainingEntry>;
|
|
90
|
+
/** Clockworks configuration — events, standing orders. */
|
|
91
|
+
clockworks?: ClockworksConfig;
|
|
58
92
|
}
|
|
59
93
|
/**
|
|
60
94
|
* Create the default guild.json content for a new guild.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guild-config.d.ts","sourceRoot":"","sources":["../src/guild-config.ts"],"names":[],"mappings":"AAGA,uEAAuE;AACvE,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,wEAAwE;IACxE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,gEAAgE;AAChE,MAAM,WAAW,SA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B,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACjC,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;IAC5C,0DAA0D;IAC1D,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAavG;AAED,wDAAwD;AACxD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,qDAAqD;AACrD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAGzD;AAED,0CAA0C;AAC1C,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAGxE"}
|
package/dist/guild-config.js
CHANGED
package/dist/guild-config.js.map
CHANGED
|
@@ -1 +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;
|
|
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;AAgG7B;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAY,EAAE,YAAoB,EAAE,KAAa;IACxF,OAAO;QACL,IAAI;QACJ,KAAK,EAAE,YAAY;QACnB,KAAK;QACL,SAAS,EAAE,EAAE;QACb,KAAK,EAAE,EAAE;QACT,SAAS,EAAE,EAAE;QACb,KAAK,EAAE,EAAE;QACT,OAAO,EAAE,EAAE;QACX,SAAS,EAAE,EAAE;QACb,YAAY,EAAE,EAAE;KACjB,CAAC;AACJ,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;AACvC,CAAC;AAED,qDAAqD;AACrD,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,0CAA0C;AAC1C,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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export declare const VERSION: string;
|
|
2
2
|
export { type ToolContext, type ToolDefinition, tool, } from './tool.ts';
|
|
3
|
+
export { type GuildEvent, type EngineContext, type EngineDefinition, engine, isClockworkEngine, } from './engine.ts';
|
|
4
|
+
export { signalEvent, validateCustomEvent, isFrameworkEvent, readPendingEvents, readEvent, markEventProcessed, recordDispatch, } from './events.ts';
|
|
5
|
+
export { type TickResult, type DispatchSummary, type ClockRunResult, clockTick, clockRun, } from './clockworks.ts';
|
|
3
6
|
export { createLedger } from './ledger.ts';
|
|
4
|
-
export { type GuildConfig, type RoleDefinition, type ToolEntry, type TrainingEntry, createInitialGuildConfig, guildConfigPath, readGuildConfig, writeGuildConfig, } from './guild-config.ts';
|
|
7
|
+
export { type GuildConfig, type RoleDefinition, type ToolEntry, type TrainingEntry, type WorkshopEntry, type EventDeclaration, type StandingOrder, type ClockworksConfig, createInitialGuildConfig, guildConfigPath, readGuildConfig, writeGuildConfig, } from './guild-config.ts';
|
|
5
8
|
export { findGuildRoot, nexusDir, ledgerPath, worktreesPath, workshopsPath, workshopBarePath, } from './nexus-home.ts';
|
|
6
9
|
export { type InstallToolOptions, type InstallResult, type SourceKind, classifySource, installTool, } from './install-tool.ts';
|
|
7
10
|
export { type RemoveToolOptions, type RemoveResult, removeTool, } from './remove-tool.ts';
|
|
@@ -10,5 +13,6 @@ export { type InstantiateOptions, type InstantiateResult, instantiate, } from '.
|
|
|
10
13
|
export { initGuild } from './init-guild.ts';
|
|
11
14
|
export { type BundleManifest, type BundlePackageEntry, type BundleContentEntry, type BundleMigrationEntry, type InstallBundleOptions, type InstallBundleResult, readBundleManifest, installBundle, isBundleDir, } from './bundle.ts';
|
|
12
15
|
export { type RehydrateResult, rehydrate, } from './rehydrate.ts';
|
|
16
|
+
export { type AddWorkshopOptions, type AddWorkshopResult, type RemoveWorkshopOptions, type WorkshopInfo, type CreateWorkshopOptions, addWorkshop, removeWorkshop, listWorkshops, createWorkshop, checkGhAuth, deriveWorkshopName, } from './workshop.ts';
|
|
13
17
|
export { type Precondition, type CommandPrecondition, type CommandOutputPrecondition, type EnvPrecondition, type PreconditionCheckResult, type ToolPreconditionResult, readPreconditions, checkOne, checkPreconditions, checkAllPreconditions, checkToolPreconditions, } from './preconditions.ts';
|
|
14
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,EAAE,MAAqB,CAAC;AAE5C,OAAO,EAC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,EACR,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,EAAE,MAAqB,CAAC;AAE5C,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,IAAI,GACL,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,MAAM,EACN,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,SAAS,EACT,QAAQ,GACT,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,aAAa,EACb,QAAQ,EACR,UAAU,EACV,aAAa,EACb,aAAa,EACb,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,cAAc,EACd,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,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,kBAAkB,EAClB,aAAa,EACb,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,eAAe,EACpB,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,WAAW,EACX,cAAc,EACd,aAAa,EACb,cAAc,EACd,WAAW,EACX,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,iBAAiB,EACjB,QAAQ,EACR,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,9 @@ const _require = createRequire(import.meta.url);
|
|
|
4
4
|
const _pkg = _require('../package.json');
|
|
5
5
|
export const VERSION = _pkg.version;
|
|
6
6
|
export { tool, } from "./tool.js";
|
|
7
|
+
export { engine, isClockworkEngine, } from "./engine.js";
|
|
8
|
+
export { signalEvent, validateCustomEvent, isFrameworkEvent, readPendingEvents, readEvent, markEventProcessed, recordDispatch, } from "./events.js";
|
|
9
|
+
export { clockTick, clockRun, } from "./clockworks.js";
|
|
7
10
|
export { createLedger } from "./ledger.js";
|
|
8
11
|
export { createInitialGuildConfig, guildConfigPath, readGuildConfig, writeGuildConfig, } from "./guild-config.js";
|
|
9
12
|
export { findGuildRoot, nexusDir, ledgerPath, worktreesPath, workshopsPath, workshopBarePath, } from "./nexus-home.js";
|
|
@@ -14,5 +17,6 @@ export { instantiate, } from "./instantiate.js";
|
|
|
14
17
|
export { initGuild } from "./init-guild.js";
|
|
15
18
|
export { readBundleManifest, installBundle, isBundleDir, } from "./bundle.js";
|
|
16
19
|
export { rehydrate, } from "./rehydrate.js";
|
|
20
|
+
export { addWorkshop, removeWorkshop, listWorkshops, createWorkshop, checkGhAuth, deriveWorkshopName, } from "./workshop.js";
|
|
17
21
|
export { readPreconditions, checkOne, checkPreconditions, checkAllPreconditions, checkToolPreconditions, } from "./preconditions.js";
|
|
18
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChD,MAAM,IAAI,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAC;AACzC,MAAM,CAAC,MAAM,OAAO,GAAW,IAAI,CAAC,OAAO,CAAC;AAE5C,OAAO,EAGL,IAAI,GACL,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IA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,EAClB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC"}
|
package/dist/rehydrate.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
export interface RehydrateResult {
|
|
2
|
+
/** Workshop bare clones restored from remote URLs. */
|
|
3
|
+
workshopsCloned: string[];
|
|
4
|
+
/** Workshops that failed to clone (name + error message). */
|
|
5
|
+
workshopsFailed: {
|
|
6
|
+
name: string;
|
|
7
|
+
error: string;
|
|
8
|
+
}[];
|
|
2
9
|
/** Tools restored from package.json (registry/git-url). */
|
|
3
10
|
fromPackageJson: number;
|
|
4
11
|
/** Tools restored from on-disk source (workshop/tarball). */
|
package/dist/rehydrate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rehydrate.d.ts","sourceRoot":"","sources":["../src/rehydrate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rehydrate.d.ts","sourceRoot":"","sources":["../src/rehydrate.ts"],"names":[],"mappings":"AA0BA,MAAM,WAAW,eAAe;IAC9B,sDAAsD;IACtD,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,6DAA6D;IAC7D,eAAe,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACnD,2DAA2D;IAC3D,eAAe,EAAE,MAAM,CAAC;IACxB,6DAA6D;IAC7D,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,yCAAyC;IACzC,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAoFvD"}
|
package/dist/rehydrate.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rehydrate — reconstruct
|
|
2
|
+
* rehydrate — reconstruct runtime state from git-tracked guild state.
|
|
3
3
|
*
|
|
4
|
-
* After a fresh clone, the guild's node_modules is empty
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* After a fresh clone, the guild's node_modules is empty and workshop bare
|
|
5
|
+
* clones are missing. This function:
|
|
6
|
+
* 1. Re-clones workshop bare repos from their remote URLs in guild.json
|
|
7
|
+
* 2. Runs `npm install` to resolve registry/git-url deps from package.json
|
|
8
|
+
* 3. For each tool with full source on disk (workshop/tarball), runs
|
|
7
9
|
* `npm install --no-save <tool-path>` to install from the tracked source
|
|
8
|
-
*
|
|
10
|
+
* 4. Reports any linked tools that need to be re-linked manually
|
|
9
11
|
*/
|
|
10
12
|
import fs from 'node:fs';
|
|
11
13
|
import path from 'node:path';
|
|
12
14
|
import { execFileSync } from 'node:child_process';
|
|
13
15
|
import { readGuildConfig } from "./guild-config.js";
|
|
16
|
+
import { workshopBarePath, workshopsPath } from "./nexus-home.js";
|
|
14
17
|
/** Map category -> on-disk parent directory (relative to guild root). */
|
|
15
18
|
const DIR_MAP = {
|
|
16
19
|
tools: 'tools',
|
|
@@ -25,11 +28,34 @@ const DIR_MAP = {
|
|
|
25
28
|
*/
|
|
26
29
|
export function rehydrate(home) {
|
|
27
30
|
const result = {
|
|
31
|
+
workshopsCloned: [],
|
|
32
|
+
workshopsFailed: [],
|
|
28
33
|
fromPackageJson: 0,
|
|
29
34
|
fromSlotSource: [],
|
|
30
35
|
needsRelink: [],
|
|
31
36
|
};
|
|
32
|
-
// 1.
|
|
37
|
+
// 1. Re-clone workshop bare repos from guild.json remote URLs
|
|
38
|
+
const config = readGuildConfig(home);
|
|
39
|
+
const wsDir = workshopsPath(home);
|
|
40
|
+
fs.mkdirSync(wsDir, { recursive: true });
|
|
41
|
+
for (const [name, entry] of Object.entries(config.workshops)) {
|
|
42
|
+
const barePath = workshopBarePath(home, name);
|
|
43
|
+
if (fs.existsSync(barePath))
|
|
44
|
+
continue; // already cloned
|
|
45
|
+
try {
|
|
46
|
+
execFileSync('git', ['clone', '--bare', entry.remoteUrl, barePath], {
|
|
47
|
+
stdio: 'pipe',
|
|
48
|
+
});
|
|
49
|
+
result.workshopsCloned.push(name);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
result.workshopsFailed.push({
|
|
53
|
+
name,
|
|
54
|
+
error: err.message,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// 2. Run npm install to resolve registry/git-url deps from package.json
|
|
33
59
|
const pkgPath = path.join(home, 'package.json');
|
|
34
60
|
if (fs.existsSync(pkgPath)) {
|
|
35
61
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
@@ -39,8 +65,7 @@ export function rehydrate(home) {
|
|
|
39
65
|
result.fromPackageJson = depCount;
|
|
40
66
|
}
|
|
41
67
|
}
|
|
42
|
-
//
|
|
43
|
-
const config = readGuildConfig(home);
|
|
68
|
+
// 3. Scan guild.json for tools that have full source on disk
|
|
44
69
|
for (const [category, registry] of Object.entries({
|
|
45
70
|
tools: config.tools,
|
|
46
71
|
engines: config.engines,
|
package/dist/rehydrate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rehydrate.js","sourceRoot":"","sources":["../src/rehydrate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rehydrate.js","sourceRoot":"","sources":["../src/rehydrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAElE,yEAAyE;AACzE,MAAM,OAAO,GAA2B;IACtC,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,oBAAoB;IAC/B,YAAY,EAA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AAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;oBAC/B,2BAA2B;oBAC3B,IAAI,CAAC;wBACH,YAAY,CAAC,KAAK,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE;4BACrD,GAAG,EAAE,IAAI;4BACT,KAAK,EAAE,MAAM;yBACd,CAAC,CAAC;wBACH,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACnC,CAAC;oBAAC,MAAM,CAAC;wBACP,0DAA0D;oBAC5D,CAAC;gBACH,CAAC;YACH,CAAC;YAED,gEAAgE;YAChE,6CAA6C;YAC7C,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;gBACtB,MAAM,aAAa,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;gBACxE,IAAI,CAAC,aAAa,EAAE,CAAC;oBACnB,0DAA0D;oBAC1D,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export interface AddWorkshopOptions {
|
|
2
|
+
/** Absolute path to the guild root. */
|
|
3
|
+
home: string;
|
|
4
|
+
/** Workshop name (used as the key in guild.json and the bare clone directory name). */
|
|
5
|
+
name: string;
|
|
6
|
+
/** Git remote URL to clone from. */
|
|
7
|
+
remoteUrl: string;
|
|
8
|
+
}
|
|
9
|
+
export interface AddWorkshopResult {
|
|
10
|
+
/** Workshop name. */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Remote URL that was cloned. */
|
|
13
|
+
remoteUrl: string;
|
|
14
|
+
/** Path to the bare clone on disk. */
|
|
15
|
+
barePath: string;
|
|
16
|
+
}
|
|
17
|
+
export interface RemoveWorkshopOptions {
|
|
18
|
+
/** Absolute path to the guild root. */
|
|
19
|
+
home: string;
|
|
20
|
+
/** Workshop name to remove. */
|
|
21
|
+
name: string;
|
|
22
|
+
}
|
|
23
|
+
export interface WorkshopInfo {
|
|
24
|
+
/** Workshop name. */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Remote URL from guild.json. */
|
|
27
|
+
remoteUrl: string;
|
|
28
|
+
/** When the workshop was added. */
|
|
29
|
+
addedAt: string;
|
|
30
|
+
/** Whether the bare clone exists on disk. */
|
|
31
|
+
cloned: boolean;
|
|
32
|
+
/** Number of active commission worktrees. */
|
|
33
|
+
activeWorktrees: number;
|
|
34
|
+
}
|
|
35
|
+
export interface CreateWorkshopOptions {
|
|
36
|
+
/** Absolute path to the guild root. */
|
|
37
|
+
home: string;
|
|
38
|
+
/** Repository name in org/name format. */
|
|
39
|
+
repoName: string;
|
|
40
|
+
/** Whether to create a private repo (default: true). */
|
|
41
|
+
private?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Derive a workshop name from a remote URL or repo name.
|
|
45
|
+
* "https://github.com/org/my-repo.git" → "my-repo"
|
|
46
|
+
* "org/my-repo" → "my-repo"
|
|
47
|
+
* "git@github.com:org/my-repo.git" → "my-repo"
|
|
48
|
+
*/
|
|
49
|
+
export declare function deriveWorkshopName(input: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Add a workshop by cloning a remote repo as a bare clone and registering
|
|
52
|
+
* it in guild.json.
|
|
53
|
+
*
|
|
54
|
+
* @throws If the workshop name already exists in guild.json.
|
|
55
|
+
* @throws If the bare clone directory already exists on disk.
|
|
56
|
+
* @throws If the git clone fails.
|
|
57
|
+
*/
|
|
58
|
+
export declare function addWorkshop(opts: AddWorkshopOptions): AddWorkshopResult;
|
|
59
|
+
/**
|
|
60
|
+
* Remove a workshop — deletes the bare clone, any commission worktrees,
|
|
61
|
+
* and the guild.json entry.
|
|
62
|
+
*
|
|
63
|
+
* @throws If the workshop doesn't exist in guild.json.
|
|
64
|
+
*/
|
|
65
|
+
export declare function removeWorkshop(opts: RemoveWorkshopOptions): void;
|
|
66
|
+
/**
|
|
67
|
+
* List all workshops with status info.
|
|
68
|
+
*/
|
|
69
|
+
export declare function listWorkshops(home: string): WorkshopInfo[];
|
|
70
|
+
/**
|
|
71
|
+
* Check whether `gh` is installed and authenticated.
|
|
72
|
+
* Returns null if OK, or an error message if not.
|
|
73
|
+
*/
|
|
74
|
+
export declare function checkGhAuth(): string | null;
|
|
75
|
+
/**
|
|
76
|
+
* Create a new GitHub repo and add it as a workshop.
|
|
77
|
+
*
|
|
78
|
+
* Precondition: `gh` must be installed and authenticated. Call checkGhAuth()
|
|
79
|
+
* first to verify.
|
|
80
|
+
*
|
|
81
|
+
* @param opts.repoName - Repository name in "org/name" format.
|
|
82
|
+
* @throws If gh auth check fails, repo creation fails, or add fails.
|
|
83
|
+
*/
|
|
84
|
+
export declare function createWorkshop(opts: CreateWorkshopOptions): AddWorkshopResult;
|
|
85
|
+
//# sourceMappingURL=workshop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workshop.d.ts","sourceRoot":"","sources":["../src/workshop.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,kBAAkB;IACjC,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,uFAAuF;IACvF,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,MAAM,EAAE,OAAO,CAAC;IAChB,6CAA6C;IAC7C,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,qBAAqB;IACpC,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAmBD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQxD;AAID;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,iBAAiB,CA4BvE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAyBhE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,CA2B1D;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,MAAM,GAAG,IAAI,CAsB3C;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,qBAAqB,GAAG,iBAAiB,CAqB7E"}
|
package/dist/workshop.js
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* workshop — core logic for managing guild workshops.
|
|
3
|
+
*
|
|
4
|
+
* Workshops are repositories where the guild does its work. Each workshop
|
|
5
|
+
* is stored as a bare git clone in .nexus/workshops/{name}.git, with
|
|
6
|
+
* commission worktrees created from it by the worktree-setup engine.
|
|
7
|
+
*
|
|
8
|
+
* This module provides:
|
|
9
|
+
* - addWorkshop: clone a remote repo and register it in guild.json
|
|
10
|
+
* - removeWorkshop: remove the bare clone, worktrees, and guild.json entry
|
|
11
|
+
* - listWorkshops: return workshop entries with status info
|
|
12
|
+
* - createWorkshop: create a new GitHub repo via `gh`, then add it
|
|
13
|
+
*/
|
|
14
|
+
import { execFileSync } from 'node:child_process';
|
|
15
|
+
import fs from 'node:fs';
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import { readGuildConfig, writeGuildConfig } from "./guild-config.js";
|
|
18
|
+
import { workshopBarePath, workshopsPath, worktreesPath } from "./nexus-home.js";
|
|
19
|
+
// ── Helpers ────────────────────────────────────────────────────────────
|
|
20
|
+
function git(args, cwd) {
|
|
21
|
+
return execFileSync('git', args, {
|
|
22
|
+
cwd,
|
|
23
|
+
encoding: 'utf-8',
|
|
24
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
25
|
+
}).trim();
|
|
26
|
+
}
|
|
27
|
+
function gh(args) {
|
|
28
|
+
return execFileSync('gh', args, {
|
|
29
|
+
encoding: 'utf-8',
|
|
30
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
31
|
+
}).trim();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Derive a workshop name from a remote URL or repo name.
|
|
35
|
+
* "https://github.com/org/my-repo.git" → "my-repo"
|
|
36
|
+
* "org/my-repo" → "my-repo"
|
|
37
|
+
* "git@github.com:org/my-repo.git" → "my-repo"
|
|
38
|
+
*/
|
|
39
|
+
export function deriveWorkshopName(input) {
|
|
40
|
+
// Handle org/name format
|
|
41
|
+
if (input.includes('/') && !input.includes(':') && !input.includes('.')) {
|
|
42
|
+
return input.split('/').pop();
|
|
43
|
+
}
|
|
44
|
+
// Handle URLs — take the last path segment, strip .git
|
|
45
|
+
const basename = input.split('/').pop() ?? input;
|
|
46
|
+
return basename.replace(/\.git$/, '');
|
|
47
|
+
}
|
|
48
|
+
// ── Core operations ───────────────────────────────────────────────────
|
|
49
|
+
/**
|
|
50
|
+
* Add a workshop by cloning a remote repo as a bare clone and registering
|
|
51
|
+
* it in guild.json.
|
|
52
|
+
*
|
|
53
|
+
* @throws If the workshop name already exists in guild.json.
|
|
54
|
+
* @throws If the bare clone directory already exists on disk.
|
|
55
|
+
* @throws If the git clone fails.
|
|
56
|
+
*/
|
|
57
|
+
export function addWorkshop(opts) {
|
|
58
|
+
const { home, name, remoteUrl } = opts;
|
|
59
|
+
const config = readGuildConfig(home);
|
|
60
|
+
if (name in config.workshops) {
|
|
61
|
+
throw new Error(`Workshop "${name}" already exists in guild.json.`);
|
|
62
|
+
}
|
|
63
|
+
const barePath = workshopBarePath(home, name);
|
|
64
|
+
if (fs.existsSync(barePath)) {
|
|
65
|
+
throw new Error(`Bare clone already exists at ${barePath}. Remove it first or choose a different name.`);
|
|
66
|
+
}
|
|
67
|
+
// Ensure workshops directory exists
|
|
68
|
+
fs.mkdirSync(workshopsPath(home), { recursive: true });
|
|
69
|
+
// Clone as bare repo
|
|
70
|
+
git(['clone', '--bare', remoteUrl, barePath]);
|
|
71
|
+
// Register in guild.json
|
|
72
|
+
const entry = {
|
|
73
|
+
remoteUrl,
|
|
74
|
+
addedAt: new Date().toISOString(),
|
|
75
|
+
};
|
|
76
|
+
config.workshops[name] = entry;
|
|
77
|
+
writeGuildConfig(home, config);
|
|
78
|
+
return { name, remoteUrl, barePath };
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Remove a workshop — deletes the bare clone, any commission worktrees,
|
|
82
|
+
* and the guild.json entry.
|
|
83
|
+
*
|
|
84
|
+
* @throws If the workshop doesn't exist in guild.json.
|
|
85
|
+
*/
|
|
86
|
+
export function removeWorkshop(opts) {
|
|
87
|
+
const { home, name } = opts;
|
|
88
|
+
const config = readGuildConfig(home);
|
|
89
|
+
if (!(name in config.workshops)) {
|
|
90
|
+
throw new Error(`Workshop "${name}" not found in guild.json. Available workshops: ${Object.keys(config.workshops).join(', ') || '(none)'}`);
|
|
91
|
+
}
|
|
92
|
+
// Remove commission worktrees for this workshop
|
|
93
|
+
const wtDir = path.join(worktreesPath(home), name);
|
|
94
|
+
if (fs.existsSync(wtDir)) {
|
|
95
|
+
fs.rmSync(wtDir, { recursive: true, force: true });
|
|
96
|
+
}
|
|
97
|
+
// Remove the bare clone
|
|
98
|
+
const barePath = workshopBarePath(home, name);
|
|
99
|
+
if (fs.existsSync(barePath)) {
|
|
100
|
+
fs.rmSync(barePath, { recursive: true, force: true });
|
|
101
|
+
}
|
|
102
|
+
// Remove from guild.json
|
|
103
|
+
delete config.workshops[name];
|
|
104
|
+
writeGuildConfig(home, config);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* List all workshops with status info.
|
|
108
|
+
*/
|
|
109
|
+
export function listWorkshops(home) {
|
|
110
|
+
const config = readGuildConfig(home);
|
|
111
|
+
const results = [];
|
|
112
|
+
for (const [name, entry] of Object.entries(config.workshops)) {
|
|
113
|
+
const barePath = workshopBarePath(home, name);
|
|
114
|
+
const cloned = fs.existsSync(barePath);
|
|
115
|
+
// Count active worktrees
|
|
116
|
+
let activeWorktrees = 0;
|
|
117
|
+
const wtDir = path.join(worktreesPath(home), name);
|
|
118
|
+
if (fs.existsSync(wtDir)) {
|
|
119
|
+
activeWorktrees = fs.readdirSync(wtDir, { withFileTypes: true })
|
|
120
|
+
.filter(e => e.isDirectory())
|
|
121
|
+
.length;
|
|
122
|
+
}
|
|
123
|
+
results.push({
|
|
124
|
+
name,
|
|
125
|
+
remoteUrl: entry.remoteUrl,
|
|
126
|
+
addedAt: entry.addedAt,
|
|
127
|
+
cloned,
|
|
128
|
+
activeWorktrees,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return results;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Check whether `gh` is installed and authenticated.
|
|
135
|
+
* Returns null if OK, or an error message if not.
|
|
136
|
+
*/
|
|
137
|
+
export function checkGhAuth() {
|
|
138
|
+
try {
|
|
139
|
+
execFileSync('which', ['gh'], { stdio: 'pipe' });
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return 'GitHub CLI (gh) is not installed. Install from https://cli.github.com/';
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
const output = execFileSync('gh', ['auth', 'status'], {
|
|
146
|
+
encoding: 'utf-8',
|
|
147
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
148
|
+
});
|
|
149
|
+
// gh auth status exits 0 when authenticated
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
// gh auth status may write to stderr even on success in some versions
|
|
154
|
+
if (err && typeof err === 'object' && 'stderr' in err) {
|
|
155
|
+
const stderr = err.stderr ?? '';
|
|
156
|
+
if (stderr.includes('Logged in'))
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
return 'GitHub CLI is not authenticated. Run: gh auth login';
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Create a new GitHub repo and add it as a workshop.
|
|
164
|
+
*
|
|
165
|
+
* Precondition: `gh` must be installed and authenticated. Call checkGhAuth()
|
|
166
|
+
* first to verify.
|
|
167
|
+
*
|
|
168
|
+
* @param opts.repoName - Repository name in "org/name" format.
|
|
169
|
+
* @throws If gh auth check fails, repo creation fails, or add fails.
|
|
170
|
+
*/
|
|
171
|
+
export function createWorkshop(opts) {
|
|
172
|
+
const { home, repoName, private: isPrivate = true } = opts;
|
|
173
|
+
// Verify gh is available and authenticated
|
|
174
|
+
const authError = checkGhAuth();
|
|
175
|
+
if (authError) {
|
|
176
|
+
throw new Error(authError);
|
|
177
|
+
}
|
|
178
|
+
// Create the repo on GitHub
|
|
179
|
+
const visibility = isPrivate ? '--private' : '--public';
|
|
180
|
+
gh(['repo', 'create', repoName, visibility, '--confirm']);
|
|
181
|
+
// Get the clone URL
|
|
182
|
+
const remoteUrl = `https://github.com/${repoName}.git`;
|
|
183
|
+
const name = deriveWorkshopName(repoName);
|
|
184
|
+
// Need to initialize the repo so bare clone works.
|
|
185
|
+
// gh repo create with --confirm creates it but it may be empty.
|
|
186
|
+
// We'll clone it (possibly empty) — git clone --bare handles empty repos.
|
|
187
|
+
return addWorkshop({ home, name, remoteUrl });
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=workshop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workshop.js","sourceRoot":"","sources":["../src/workshop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEtE,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAmDjF,0EAA0E;AAE1E,SAAS,GAAG,CAAC,IAAc,EAAE,GAAY;IACvC,OAAO,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE;QAC/B,GAAG;QACH,QAAQ,EAAE,OAAO;QACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;KAChC,CAAC,CAAC,IAAI,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,EAAE,CAAC,IAAc;IACxB,OAAO,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE;QAC9B,QAAQ,EAAE,OAAO;QACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;KAChC,CAAC,CAAC,IAAI,EAAE,CAAC;AACZ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,yBAAyB;IACzB,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACxE,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG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