@shardworks/guild-starter-kit 0.1.23 → 0.1.25

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.
@@ -117,7 +117,7 @@ This deletes the bare clone, any commission worktrees for that workshop, and rem
117
117
 
118
118
  ### How Workshops Are Used in Commissions
119
119
 
120
- When a commission is dispatched to a workshop, the worktree-setup engine:
120
+ When a commission is dispatched to a workshop, the workshop-prepare engine:
121
121
 
122
122
  1. Creates a commission-specific branch from `main` in the workshop's bare clone
123
123
  2. Checks out a git worktree at `.nexus/worktrees/{workshop}/commission-{id}/`
@@ -142,44 +142,104 @@ The `remoteUrl` is the source of truth. The bare clone on disk is ephemeral and
142
142
 
143
143
  ## Commissions
144
144
 
145
- A commission is a unit of work posted by the patron and undertaken by the guild. The lifecycle:
145
+ A commission is a unit of work posted by the patron and undertaken by the guild. Commissions flow through an event-driven pipeline powered by standing orders:
146
146
 
147
- 1. **Posted** — the patron describes what needs to be built
148
- 2. **Assigned** — dispatched to an artificer (with sage consultation if a Master Sage is active)
149
- 3. **In progress** — the artificer works in a workshop worktree
150
- 4. **Completed** or **Failed** — work is delivered or the commission is marked as failed
147
+ ### Commission Lifecycle
151
148
 
152
- Use `nsg commission` to post commissions. The Clockworks handles the rest via standing orders.
149
+ 1. **Posted** — the patron runs `nsg commission <spec> --workshop <name>`. This creates the commission in the Ledger and signals `commission.posted`.
150
+ 2. **Worktree prepared** — the `workshop-prepare` engine (triggered by `commission.posted`) creates a commission branch and worktree, then signals `commission.ready`.
151
+ 3. **Assigned & In Progress** — the Clockworks summons an artificer (triggered by `commission.ready`), resolves a role to a specific anima, writes the assignment, and launches a session.
152
+ 4. **Session ended** — when the artificer's session finishes, the Clockworks signals `commission.session.ended`.
153
+ 5. **Merged or Failed** — the `workshop-merge` engine (triggered by `commission.session.ended`) merges the commission branch back to main. On success it signals `commission.completed`; on conflict it signals `commission.failed`.
153
154
 
154
- ## Tools
155
+ Each step is driven by a standing order in `guild.json`, making the pipeline configurable and extensible.
156
+
157
+ ### Commission Status Flow
158
+
159
+ ```
160
+ posted → in_progress → completed
161
+ → failed
162
+ ```
163
+
164
+ ## Sessions
165
+
166
+ A session is a single manifestation of an anima — the span during which an anima is alive and working. Every interaction with an anima happens through a session, whether it's consulting the advisor, summoning an artificer for a commission, or briefing an anima about an event.
167
+
168
+ ### Session Triggers
169
+
170
+ | Trigger | Meaning |
171
+ |---------|---------|
172
+ | **consult** | Interactive session with a standing anima (e.g., `nsg consult advisor`) |
173
+ | **summon** | The anima is summoned by a standing order to act on an event — autonomous, directive |
174
+ | **brief** | The anima is briefed by a standing order about an event — autonomous, informational |
175
+
176
+ ### The Session Funnel
177
+
178
+ All sessions flow through a single code path (`launchSession`) that provides unified lifecycle management:
155
179
 
156
- ### Tools
180
+ 1. **Workspace setup** — resolves where the anima will work (guildhall, or a worktree in a workshop)
181
+ 2. **Ledger recording** — writes a `session.started` row with the anima's identity, composition, and context
182
+ 3. **Event signaling** — signals `session.started` for the Clockworks
183
+ 4. **Provider launch** — delegates to the session provider (e.g., Claude Code) to run the actual AI session
184
+ 5. **Cleanup** — writes `session.ended` to the Ledger with metrics (tokens, cost, duration), writes a full session record to `.nexus/sessions/`, signals `session.ended`, and tears down temporary worktrees (for autonomous sessions only)
157
185
 
158
- Tools that animas wield during work. Each tool ships with instructions delivered to the anima at manifest time. Available tools:
186
+ ### Session Records
187
+
188
+ Every session produces a JSON record at `.nexus/sessions/{uuid}.json` containing:
189
+
190
+ - The anima's full composition at session time (curriculum, temperament, roles, codex, tool instructions)
191
+ - The assembled system prompt
192
+ - The user prompt
193
+ - Available and unavailable tools
194
+ - The raw conversation transcript
195
+
196
+ Session records are the guild's institutional memory of what each anima knew and did.
197
+
198
+ ### Session Tracking in the Ledger
199
+
200
+ The `sessions` table tracks every session with:
201
+
202
+ - Which anima ran the session and what composition they had
203
+ - Which provider and model were used
204
+ - What triggered the session (consult, summon, brief)
205
+ - Which workshop (if any) the session worked in
206
+ - Start/end times, exit code, token usage, cost, and duration
207
+ - A link to the full session record JSON on disk
208
+
209
+ For commissions, the `commission_sessions` join table links commissions to their sessions — a commission may involve multiple sessions (retries, sub-tasks).
210
+
211
+ ## Tools
212
+
213
+ Tools that animas wield during work. Each tool ships with instructions delivered to the anima at manifest time. All tools are packaged in `@shardworks/nexus-stdlib`:
159
214
 
160
215
  - **install-tool** — install new tools, engines, or bundles into the guild
161
216
  - **remove-tool** — remove installed tools
162
217
  - **commission** — post commissions to the guild
163
218
  - **instantiate** — create new animas with assigned training and roles
164
219
  - **nexus-version** — report the installed Nexus framework version
165
- - **signal** — signal a custom guild event for the Clockworks
220
+ - **signal** — signal a custom guild event for the Clockworks (not included in the default bundle — must be installed separately)
166
221
 
167
222
  ### Engines
168
223
 
169
- Automated mechanical processes with no AI involvement. Two kinds:
224
+ Engines are automated mechanical processes with no AI involvement. Two kinds:
170
225
 
171
- **Static engines** — bespoke APIs called by framework code. Not triggerable by standing orders.
226
+ **Core engines** — fundamental capabilities absorbed into the Nexus framework itself (`@shardworks/nexus-core`). These are not registered in `guild.json` as engines — they are framework internals that the system calls directly:
172
227
 
173
- - **manifest** — composes anima instructions from codex, training, and tool instructions at session start
174
- - **mcp-server** — runs the MCP server that exposes tools to animas during sessions
175
- - **worktree-setup** — creates and manages git worktrees for commissions
176
- - **ledger-migrate** — applies database migrations to the Ledger
228
+ - **manifest** — assembles an anima's identity for a session (codex, curriculum, temperament, tool instructions system prompt)
229
+ - **worktree** — creates and manages git worktrees for commissions and temporary sessions
230
+ - **migrate** — applies database migrations to the Ledger
177
231
 
178
- **Clockwork engines** — purpose-built to respond to events via standing orders. Use the `engine()` SDK factory from `@shardworks/nexus-core`. The Clockworks runner calls them automatically when matching events fire.
232
+ **Clockwork engines** — purpose-built to respond to events via standing orders. Use the `engine()` SDK factory from `@shardworks/nexus-core`. The Clockworks runner calls them automatically when matching events fire. Packaged in `@shardworks/nexus-stdlib`:
179
233
 
180
234
  - **workshop-prepare** — creates a worktree when a commission is posted (`commission.posted` → `commission.ready`)
181
235
  - **workshop-merge** — merges a commission branch after the session ends (`commission.session.ended` → `commission.completed` or `commission.failed`)
182
236
 
237
+ ### Session Providers
238
+
239
+ Session providers are the bridge between the Nexus session funnel and a specific AI runtime. They are not engines — they implement the `SessionProvider` interface and handle the mechanics of launching an AI session (spawning a process, connecting tools via MCP, collecting transcripts and metrics).
240
+
241
+ The current session provider is **Claude Code** (`@shardworks/claude-code-session-provider`), which spawns the Claude CLI with an MCP server that exposes the anima's tools.
242
+
183
243
  ## The Codex
184
244
 
185
245
  The guild's institutional body of policy and procedure — the employee handbook. Lives in `codex/` in the guildhall. Every anima receives the codex when manifested. The codex defines how the guild operates: standards, procedures, policies, and environmental facts.
@@ -188,7 +248,21 @@ Role-specific codex entries live in `codex/roles/` and are delivered only to ani
188
248
 
189
249
  ## The Ledger
190
250
 
191
- The guild's operational database (SQLite). Holds anima records, roster, commission history, compositions, events, and the audit trail. Lives at `.nexus/nexus.db` in the guildhall. Managed by the ledger-migrate engine.
251
+ The guild's operational database (SQLite). Holds anima records, roster, commission history, session history, compositions, events, and the audit trail. Lives at `.nexus/nexus.db` in the guildhall. Managed by the migrate engine in core.
252
+
253
+ ### Key Tables
254
+
255
+ | Table | What it holds |
256
+ |-------|--------------|
257
+ | `animas` | Every anima that has ever existed — name, status, composition |
258
+ | `roster` | Active role assignments (filtered view of active animas) |
259
+ | `commissions` | Commission records with status, content, and workshop |
260
+ | `commission_assignments` | Which anima was assigned to which commission |
261
+ | `sessions` | Every session — anima, provider, trigger, metrics, cost |
262
+ | `commission_sessions` | Links commissions to their sessions |
263
+ | `events` | The Clockworks event queue — every event signaled |
264
+ | `dispatches` | Standing order execution records |
265
+ | `audit_log` | Who did what, when |
192
266
 
193
267
  ## The Clockworks
194
268
 
@@ -200,9 +274,22 @@ An event is an immutable fact: *this happened*. Events are recorded in the Ledge
200
274
 
201
275
  Two kinds:
202
276
 
203
- - **Framework events** — signaled automatically by the system (`commission.sealed`, `tool.installed`, `anima.instantiated`, etc.). Animas cannot signal these.
277
+ - **Framework events** — signaled automatically by the system. Animas cannot signal these. Reserved namespaces: `anima.*`, `commission.*`, `tool.*`, `migration.*`, `guild.*`, `standing-order.*`, `session.*`.
204
278
  - **Custom events** — declared by the guild in `guild.json` under `clockworks.events`. Animas signal these using the `signal` tool.
205
279
 
280
+ ### Key Framework Events
281
+
282
+ | Event | When it fires | Typical standing order |
283
+ |-------|--------------|----------------------|
284
+ | `commission.posted` | A new commission is created | `run: workshop-prepare` |
285
+ | `commission.ready` | Worktree is set up, commission is ready for work | `summon: artificer` |
286
+ | `commission.session.ended` | An artificer's session finishes | `run: workshop-merge` |
287
+ | `commission.completed` | Commission branch merged to main | (guild-defined) |
288
+ | `commission.failed` | Commission failed (merge conflict, error) | (guild-defined) |
289
+ | `session.started` | Any session begins | (guild-defined) |
290
+ | `session.ended` | Any session ends (with metrics) | (guild-defined) |
291
+ | `standing-order.failed` | A standing order execution failed | (guild-defined) |
292
+
206
293
  ### Standing Orders
207
294
 
208
295
  A standing order is a registered response to an event — guild policy that says "when X happens, do Y." Standing orders live in `guild.json` under `clockworks.standingOrders`.
@@ -228,9 +315,11 @@ Example `guild.json` configuration:
228
315
  }
229
316
  },
230
317
  "standingOrders": [
231
- { "on": "commission.sealed", "run": "cleanup-worktree" },
232
- { "on": "commission.failed", "summon": "advisor" },
233
- { "on": "code.reviewed", "brief": "guildmaster" }
318
+ { "on": "commission.posted", "run": "workshop-prepare" },
319
+ { "on": "commission.ready", "summon": "artificer" },
320
+ { "on": "commission.session.ended", "run": "workshop-merge" },
321
+ { "on": "commission.failed", "brief": "advisor" },
322
+ { "on": "code.reviewed", "brief": "advisor" }
234
323
  ]
235
324
  }
236
325
  }
@@ -244,7 +333,7 @@ Use the **signal** tool to signal custom events:
244
333
  signal({ name: "code.reviewed", payload: { pr: 42, issues_found: 0 } })
245
334
  ```
246
335
 
247
- The event name must be declared in `guild.json clockworks.events`. Framework namespaces (`anima.*`, `commission.*`, `tool.*`, `migration.*`, `guild.*`, `standing-order.*`) are reserved.
336
+ The event name must be declared in `guild.json clockworks.events`. Framework namespaces (`anima.*`, `commission.*`, `tool.*`, `migration.*`, `guild.*`, `standing-order.*`, `session.*`) are reserved.
248
337
 
249
338
  ### Processing Events
250
339
 
@@ -258,7 +347,7 @@ Events are not processed automatically. The operator controls when the Clockwork
258
347
 
259
348
  ### Error Handling
260
349
 
261
- When a standing order fails, the system signals a `standing-order.failed` event. Guilds can respond to this with their own standing orders. A loop guard prevents cascading failures.
350
+ When a standing order fails, the system signals a `standing-order.failed` event. Guilds can respond to this with their own standing orders. A loop guard prevents cascading failures — `standing-order.failed` events triggered by other `standing-order.failed` events are skipped automatically.
262
351
 
263
352
  ### Hello World Walkthrough
264
353
 
@@ -360,7 +449,7 @@ The command is idempotent — safe to run at any time. If everything is already
360
449
 
361
450
  ### What Restore Does NOT Do
362
451
 
363
- - It does not create the Ledger (that's done by `nsg init` and the ledger-migrate engine)
452
+ - It does not create the Ledger (that's done by `nsg init` and the migrate engine)
364
453
  - It does not re-create animas or commissions — those live in the Ledger
365
454
  - It does not push or pull workshop repos — it only clones them fresh if missing
366
455
 
@@ -372,18 +461,18 @@ The primary interface is the `nsg` command:
372
461
  |---------|---------|
373
462
  | `nsg init` | Create a new guild |
374
463
  | `nsg commission <spec> --workshop <name>` | Post a commission |
375
- | `nsg tool install <source>` | Install a tool or bundle |
376
- | `nsg tool remove <name>` | Remove an installed tool |
464
+ | `nsg consult <name>` | Consult a standing anima (e.g., the advisor) |
465
+ | `nsg status` | Show guild status |
466
+ | `nsg signal <name>` | Signal a custom guild event |
467
+ | `nsg clock list` | Show pending events |
468
+ | `nsg clock tick [id]` | Process next pending event (or specific id) |
469
+ | `nsg clock run` | Process all pending events |
377
470
  | `nsg workshop add <url>` | Clone a remote repo and register it as a workshop |
378
471
  | `nsg workshop remove <name>` | Remove a workshop |
379
472
  | `nsg workshop list` | List workshops with status |
380
473
  | `nsg workshop create <org/name>` | Create a new GitHub repo and register as a workshop |
381
474
  | `nsg guild restore` | Restore runtime state after a fresh clone |
475
+ | `nsg tool install <source>` | Install a tool or bundle |
476
+ | `nsg tool remove <name>` | Remove an installed tool |
382
477
  | `nsg anima create` | Instantiate a new anima |
383
478
  | `nsg anima manifest <name>` | Generate an anima's full instructions |
384
- | `nsg status` | Show guild status |
385
- | `nsg consult <name>` | Consult a standing anima (e.g., the advisor) |
386
- | `nsg signal <name>` | Signal a custom guild event |
387
- | `nsg clock list` | Show pending events |
388
- | `nsg clock tick [id]` | Process next pending event (or specific id) |
389
- | `nsg clock run` | Process all pending events |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shardworks/guild-starter-kit",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "description": "Default bundle for new Nexus guilds — tools, training, and migrations",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,15 +9,27 @@ You are an artisan — methodical, resourceful, and focused on delivering solid
9
9
  - **Thorough.** Test your work. Check edge cases. Read the error messages. Don't declare something done until you've verified it works, not just that it compiles.
10
10
  - **Honest about problems.** If something isn't working, say so early. If the brief is unclear or contradictory, surface it rather than guessing. A well-timed question saves more time than a wrong assumption.
11
11
 
12
+ ## Your Work Environment
13
+
14
+ You work in an **autonomous session** — there is no human at the keyboard. Your session is launched by the Clockworks in response to a commission, and your commission spec arrives as the initial prompt. That spec is your entire brief. Read it carefully.
15
+
16
+ You work in an **isolated worktree** — a dedicated branch and working directory created just for your commission. Other commissions may be running concurrently in the same workshop, each in their own worktree. You cannot see or affect their work, and they cannot see or affect yours.
17
+
18
+ When your session ends, the **workshop-merge engine** automatically merges your commission branch back to main. This merge is a **fast-forward only** — if main has moved since your branch was created (because another commission merged first), your commission will fail. This means:
19
+
20
+ - **Commit early and often.** Small, atomic commits. If your session is interrupted, committed work survives.
21
+ - **Keep your changes focused.** Touching files outside your commission's scope increases the chance of merge conflicts with concurrent work.
22
+ - **Push the branch forward, not sideways.** Don't rewrite history or rebase within your worktree. The merge engine expects a clean, linear branch.
23
+
12
24
  ## Communication Style
13
25
 
14
26
  - Be concise. Commit messages and code comments are your primary output — make them clear and useful for the next anima who reads them.
15
- - When reporting status, lead with what's done and what's blocked. Skip the preamble.
16
- - If you encounter a design decision outside your brief, flag it and move on. Don't block on decisions that aren't yours to make.
27
+ - Write commit messages for other agents. Include enough context that another anima could pick up where you left off. Be precise about what changed and why.
28
+ - If you encounter a design decision outside your brief, flag it in a commit message or code comment and move on. Don't block on decisions that aren't yours to make.
17
29
 
18
30
  ## Work Ethic
19
31
 
20
- - Commit early and often. Small, atomic commits that tell a clear story.
21
32
  - Leave the workshop cleaner than you found it. No dead code, no dangling TODOs, no mystery files.
22
- - Respect the scope of your commission. Do the work you were asked to do. If you see adjacent improvements, note them — don't chase them.
23
- - When sage advice is provided, follow it. The sage planned the work; you execute the plan. If you believe the plan has a flaw, record your concern, but do not contradict it unilaterally.
33
+ - Respect the scope of your commission. Do the work you were asked to do. If you see adjacent improvements, note them in commit messages — don't chase them.
34
+ - When sage advice is provided, follow it. The sage planned the work; you execute the plan. If you believe the plan has a flaw, record your concern in a commit message, but do not contradict it unilaterally.
35
+ - Verify your work before finishing. Run the tests. Check that the build passes. The workshop-merge engine will merge whatever you committed — make sure it's ready.