@nfinitmonkeys/clan-engine 0.1.1 → 0.3.0
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/README.md +62 -10
- package/dist/apply.js +7 -1
- package/dist/brain-build.d.ts +49 -0
- package/dist/brain-build.js +278 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +75 -8
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/inspect.js +102 -5
- package/dist/inventory.d.ts +3 -1
- package/dist/inventory.js +4 -2
- package/dist/mcp.d.ts +10 -0
- package/dist/mcp.js +11 -0
- package/dist/reconcile.js +24 -4
- package/dist/sanitize.d.ts +23 -0
- package/dist/sanitize.js +71 -0
- package/dist/templates.d.ts +4 -1
- package/dist/templates.js +244 -20
- package/dist/types.d.ts +24 -1
- package/dist/types.js +1 -1
- package/package.json +1 -1
package/dist/templates.js
CHANGED
|
@@ -85,13 +85,13 @@ This repo is a **${noun.toUpperCase()}** node in the Nfinit Monkeys geography
|
|
|
85
85
|
## Tool defaults
|
|
86
86
|
|
|
87
87
|
- Default MCP prefix: \`mcp__jungle-local__*\` (this node's voice).
|
|
88
|
-
- The Alpha's brain (persistent memory) lives under
|
|
89
|
-
session start by the SessionStart hook.
|
|
88
|
+
- The Alpha's brain (persistent memory) lives under \`${brainRoot(i)}/\` — hydrated
|
|
89
|
+
at session start by the SessionStart hook.
|
|
90
90
|
|
|
91
91
|
## Scope
|
|
92
92
|
|
|
93
93
|
Routine work here is node-local. Slash commands are tier-named:
|
|
94
|
-
\`/${noun}:status\` · \`/${noun}:inbox\` · \`/${noun}:log\` · \`/${noun}:policies\` · \`/${noun}:request\`.
|
|
94
|
+
\`/${noun}:status\` · \`/${noun}:inbox\` · \`/${noun}:log\` · \`/${noun}:policies\` · \`/${noun}:request\` · \`/${noun}:up\`.
|
|
95
95
|
`;
|
|
96
96
|
}
|
|
97
97
|
// ─── awareness skill (SKILL.md directory format — loadable) ─────────────────
|
|
@@ -100,14 +100,43 @@ function awarenessSkill(i) {
|
|
|
100
100
|
const modeLine = i.mode === 'connected'
|
|
101
101
|
? `- **Mode:** connected${i.jungle?.apiUrl ? ` to ${i.jungle.apiUrl}` : ''}${i.alphaId ? `\n- **Alpha ID:** \`${i.alphaId}\`` : ''}`
|
|
102
102
|
: `- **Mode:** standalone — no Jungle, no approval queue. The developer IS the Human Council.`;
|
|
103
|
-
const
|
|
104
|
-
? `##
|
|
103
|
+
const workingAs = noun === 'clan'
|
|
104
|
+
? `## Working *as* the Alpha
|
|
105
|
+
|
|
106
|
+
In this repo you act **as ${i.alphaName}**. But ${i.alphaName} is bigger than one
|
|
107
|
+
chat: it has a **brain** (\`npx -y @nfinitmonkeys/clan brain "…"\` — persistent
|
|
108
|
+
memory), an **inbox** (\`npx -y @nfinitmonkeys/clan talk "…"\`), and an
|
|
109
|
+
**autonomous loop** (\`npx -y @nfinitmonkeys/clan start\`). If the user says "I
|
|
110
|
+
want to talk to the Alpha," don't say "you already are" — point them to those.`
|
|
111
|
+
: noun === 'district'
|
|
112
|
+
? `## Working *as* the Alpha
|
|
113
|
+
|
|
114
|
+
In this repo you act **as ${i.alphaName}**. The district box (localhost:${i.boxPort ?? '7787'})
|
|
115
|
+
is the node's substrate — speak through \`mcp__jungle-local__*\` tools, not the
|
|
116
|
+
clan CLI.`
|
|
117
|
+
: `## Working *as* the Alpha
|
|
118
|
+
|
|
119
|
+
In this repo you act **as ${i.alphaName}** — the org hub's Alpha. Speak through
|
|
120
|
+
\`mcp__jungle-local__*\` (this repo's declared identity).`;
|
|
121
|
+
const governance = noun === 'district'
|
|
122
|
+
? `## Governance (district)
|
|
123
|
+
|
|
124
|
+
Be honest: **the district box has no policy engine yet**. Acts are ungated but
|
|
125
|
+
logged (see /district:log). The composing rule: *a parent sees a child only by
|
|
126
|
+
the child's consent; every child runs without its parent*.`
|
|
127
|
+
: noun === 'jungle'
|
|
128
|
+
? `## Governance (jungle)
|
|
129
|
+
|
|
130
|
+
The invariant: Alphas **propose**, humans **approve** — every sensitive act
|
|
131
|
+
routes through the approval queue (BOSS).`
|
|
132
|
+
: i.mode === 'connected'
|
|
133
|
+
? `## Governance (connected)
|
|
105
134
|
|
|
106
135
|
Alphas **propose**, humans **approve**. Sensitive actions go through a gated
|
|
107
136
|
approval flow (\`request_approval\` → Human Council reviews in BOSS → execute →
|
|
108
137
|
logged). To change this node's permissions, tell the user to message the Alpha
|
|
109
138
|
in natural language — it will propose the change for approval.`
|
|
110
|
-
|
|
139
|
+
: `## Governance (standalone)
|
|
111
140
|
|
|
112
141
|
There is no remote council. The developer at this terminal IS the council. When
|
|
113
142
|
they want to change a policy: confirm it, edit \`.jungle/config.yaml\`, restart
|
|
@@ -118,27 +147,24 @@ If the user already has agents, skills, or slash commands (e.g. from other
|
|
|
118
147
|
tools), PREFER them where they overlap instead of duplicating. The clan is a
|
|
119
148
|
teammate to the existing setup, not a replacement — check \`.clan/inventory.json\`
|
|
120
149
|
(written by the engine) for what's available, and route to it by name.`;
|
|
150
|
+
const runVia = noun === 'clan' ? ` run via \`@nfinitmonkeys/clan\`` : '';
|
|
121
151
|
return {
|
|
122
152
|
path: '.claude/skills/clan-awareness/SKILL.md',
|
|
123
153
|
managed: true,
|
|
124
154
|
content: `---
|
|
125
155
|
name: clan-awareness
|
|
126
|
-
description: This project is a ${noun} node (${i.alphaName} / ${i.name})
|
|
156
|
+
description: This project is a ${noun} node (${i.alphaName} / ${i.name}) — how to answer status, governance, and "talk to the Alpha" questions
|
|
127
157
|
${markerLines()}
|
|
128
158
|
---
|
|
129
159
|
|
|
130
|
-
#
|
|
131
|
-
|
|
132
|
-
You are inside a **${noun}** node run via \`@nfinitmonkeys/clan\`, with its own
|
|
133
|
-
Alpha (**${i.alphaName}**), policies, and accumulated memory (a "brain").
|
|
160
|
+
# Node Awareness — ${i.name}
|
|
134
161
|
|
|
135
|
-
|
|
162
|
+
This repo is a **${noun.toUpperCase()}** node in the Nfinit Monkeys geography
|
|
163
|
+
(Biome ⊃ Jungle ⊃ District ⊃ Clan)${runVia}, with its own Alpha
|
|
164
|
+
(**${i.alphaName}**), policies, and accumulated memory (a "brain"). Identity is
|
|
165
|
+
DECLARED here, never inferred.
|
|
136
166
|
|
|
137
|
-
|
|
138
|
-
chat: it has a **brain** (\`npx -y @nfinitmonkeys/clan brain "…"\` — persistent
|
|
139
|
-
memory), an **inbox** (\`npx -y @nfinitmonkeys/clan talk "…"\`), and an
|
|
140
|
-
**autonomous loop** (\`npx -y @nfinitmonkeys/clan start\`). If the user says "I
|
|
141
|
-
want to talk to the Alpha," don't say "you already are" — point them to those.
|
|
167
|
+
${workingAs}
|
|
142
168
|
|
|
143
169
|
## This node
|
|
144
170
|
|
|
@@ -149,10 +175,15 @@ ${modeLine}
|
|
|
149
175
|
|
|
150
176
|
## Slash commands (tier-named)
|
|
151
177
|
|
|
152
|
-
\`/${noun}:status\` · \`/${noun}:inbox\` · \`/${noun}:log\` · \`/${noun}:policies\` · \`/${noun}:request\`
|
|
178
|
+
\`/${noun}:status\` · \`/${noun}:inbox\` · \`/${noun}:log\` · \`/${noun}:policies\` · \`/${noun}:request\` · \`/${noun}:up\` (setup/repair wizard)
|
|
153
179
|
|
|
154
180
|
If the user types a different tier's command (e.g. \`/clan:status\` in a
|
|
155
|
-
district), point them to the right one — don't
|
|
181
|
+
district), point them to the right one — the correction teaches the tier; don't
|
|
182
|
+
silently alias.
|
|
183
|
+
|
|
184
|
+
The Alpha's brain (persistent memory) lives at \`${brainRoot(i)}\` — hydrated at
|
|
185
|
+
session start by the SessionStart hook. The anatomy is identical at every tier:
|
|
186
|
+
Alpha + brain + governance log + members + registry of children.
|
|
156
187
|
|
|
157
188
|
${usingExisting}
|
|
158
189
|
|
|
@@ -175,7 +206,127 @@ ${body}
|
|
|
175
206
|
`,
|
|
176
207
|
};
|
|
177
208
|
}
|
|
209
|
+
/** Every pack asserts the declared identity up front — the correction teaches the tier. */
|
|
210
|
+
function header(i) {
|
|
211
|
+
return `Assert the declaration in the output header: **${i.alphaName} · ${i.name} · ${i.tier.toUpperCase()}**.`;
|
|
212
|
+
}
|
|
178
213
|
function commandPack(i) {
|
|
214
|
+
if (i.tier === 'biome')
|
|
215
|
+
throw new Error('no pack template for tier biome yet — biome is unbuilt');
|
|
216
|
+
const pack = i.tier === 'district' ? districtPack(i) : i.tier === 'jungle' ? junglePack(i) : clanPack(i);
|
|
217
|
+
// /tier:up — the wizard door (design §4 Layer 2) renders at every built tier.
|
|
218
|
+
return [...pack, upCmd(i)];
|
|
219
|
+
}
|
|
220
|
+
/** Version-pinned engine invocation for generated wizard text. Unpinned
|
|
221
|
+
* `npx @nfinitmonkeys/clan-engine` would resolve to an OLDER published engine
|
|
222
|
+
* (no district/jungle packs, no existing-vault detection, no --json
|
|
223
|
+
* redaction) whose apply would overwrite the very pack that invoked it. */
|
|
224
|
+
const ENGINE_NPX = `npx -y @nfinitmonkeys/clan-engine@${ENGINE_VERSION.split('.').slice(0, 2).join('.')}`;
|
|
225
|
+
/** The /tier:up door — Claude Code IS the wizard; the engine does every write.
|
|
226
|
+
* Clan tier gets the full greenfield/convert/repair playbook; district/jungle
|
|
227
|
+
* get a short repair wizard (their identity is provisioned by node-up, never
|
|
228
|
+
* interviewed here). */
|
|
229
|
+
function upCmd(i) {
|
|
230
|
+
const t = i.tier;
|
|
231
|
+
if (t !== 'clan') {
|
|
232
|
+
return cmd(t, 'up', `Repair / update this ${t} node — engine inspect → plan → approval → apply → doctor`, `${header(i)}
|
|
233
|
+
|
|
234
|
+
Repair/update wizard for this already-provisioned ${t} node. **You improvise the
|
|
235
|
+
conversation; the engine does every write.** Never hand-author node files; never
|
|
236
|
+
print API keys or secrets — credentials flow via env, not argv (the engine's
|
|
237
|
+
--json output masks key values as \`[redacted]\`).
|
|
238
|
+
|
|
239
|
+
1. \`${ENGINE_NPX} inspect --json\` — classify state (fresh / partial / current / legacy / drifted) and confirm tier=${t}.
|
|
240
|
+
2. \`${ENGINE_NPX} plan --json\` — present the planned writes / merges / backups in plain language.
|
|
241
|
+
3. Only on the user's explicit approval: \`${ENGINE_NPX} apply\`.
|
|
242
|
+
4. \`${ENGINE_NPX} doctor\` — report honestly; a failing check is a finding, not noise.
|
|
243
|
+
|
|
244
|
+
Re-runs are repairs, not errors. Identity is DECLARED here — this wizard never
|
|
245
|
+
re-tiers or renames a node. Reverse any apply: \`${ENGINE_NPX} undo\`.
|
|
246
|
+
Day-to-day verbs are the tier-named commands: /${t}:status · /${t}:inbox · /${t}:log · /${t}:policies · /${t}:request.`);
|
|
247
|
+
}
|
|
248
|
+
return cmd(t, 'up', `The one door — conversational clan setup/repair wizard (the engine does every write)`, `You are the setup wizard for this repo's clan — the ONE door. Doctrine, non-negotiable:
|
|
249
|
+
|
|
250
|
+
- **You improvise the conversation; the engine does every write.** NEVER hand-author
|
|
251
|
+
clan files (the CLAUDE.md identity block, the .claude/ surface, .mcp.json, hooks,
|
|
252
|
+
brain pages).
|
|
253
|
+
- Every mutation = engine plan → show the user exactly what will be written, merged,
|
|
254
|
+
and left untouched → explicit user approval → engine apply. No approval, no apply.
|
|
255
|
+
- Never print API keys or secrets. Credentials flow via env vars, never argv
|
|
256
|
+
(the engine's --json output masks key values as \`[redacted]\`).
|
|
257
|
+
- Re-runs are repairs, not errors. This repo currently declares **${i.alphaName} of
|
|
258
|
+
${i.name}** — if that's still right, a re-run just repairs/updates the surface.
|
|
259
|
+
|
|
260
|
+
## 1 · Inspect
|
|
261
|
+
|
|
262
|
+
\`${ENGINE_NPX} inspect --json\`
|
|
263
|
+
|
|
264
|
+
Classify out loud: state (fresh / partial / current / legacy / drifted) ×
|
|
265
|
+
mode (connected / standalone) × tier. This decides everything downstream.
|
|
266
|
+
|
|
267
|
+
## 2 · What they already have
|
|
268
|
+
|
|
269
|
+
The inspect output inventories existing agents, skills, commands, and hooks.
|
|
270
|
+
TELL the user what's already here — and that the clan will USE those rather than
|
|
271
|
+
duplicate them (they're recorded in \`.clan/inventory.json\` for the Alpha).
|
|
272
|
+
|
|
273
|
+
## 3 · Identity — a first-class moment
|
|
274
|
+
|
|
275
|
+
Never silently derive the Alpha's name from the folder. Suggest a name with ONE
|
|
276
|
+
line of reasoning ("I'd suggest **Relay** — this project relays CRM events"),
|
|
277
|
+
then ask. Greenfield: interview first — "what is this clan for?" — the answer
|
|
278
|
+
becomes the description and, later, the brain's first pages.
|
|
279
|
+
|
|
280
|
+
## 4 · Plan
|
|
281
|
+
|
|
282
|
+
\`${ENGINE_NPX} plan --json --alpha <Alpha> --name <Clan>\`
|
|
283
|
+
|
|
284
|
+
Present it in plain language: what will be CREATED, what will be MERGED (their
|
|
285
|
+
existing .mcp.json servers and settings.json hooks survive), what gets a BACKUP,
|
|
286
|
+
and what stays UNTOUCHED.
|
|
287
|
+
|
|
288
|
+
## 5 · Apply — only on explicit OK
|
|
289
|
+
|
|
290
|
+
Only after the user explicitly approves the plan:
|
|
291
|
+
|
|
292
|
+
\`${ENGINE_NPX} apply --alpha <Alpha> --name <Clan>\`
|
|
293
|
+
|
|
294
|
+
Uniform backups + an undo journal are recorded automatically.
|
|
295
|
+
|
|
296
|
+
## 6 · Doctor
|
|
297
|
+
|
|
298
|
+
\`${ENGINE_NPX} doctor\`
|
|
299
|
+
|
|
300
|
+
Report honestly — a failing check is a finding to fix or explain, never to hide.
|
|
301
|
+
|
|
302
|
+
## 7 · Brain (offer, don't force)
|
|
303
|
+
|
|
304
|
+
Offer: \`npx -y @nfinitmonkeys/clan brain build\` (dry-run by default). Present
|
|
305
|
+
the result — "built N pages, M held back as sensitive" — and get consent BEFORE
|
|
306
|
+
re-running with \`--write\`.
|
|
307
|
+
|
|
308
|
+
## 8 · Registration
|
|
309
|
+
|
|
310
|
+
Three honest options — ask which fits:
|
|
311
|
+
|
|
312
|
+
1. **Standalone** — \`npx -y @nfinitmonkeys/clan wild --yes --alpha <Alpha> --name <Clan> --description "<one line>"\`
|
|
313
|
+
(the developer IS the council). ALWAYS pass \`--yes\` with the identity from
|
|
314
|
+
steps 3-4 — bare \`wild\` starts a TTY interview that dies silently (exit 0,
|
|
315
|
+
nothing written) in your non-TTY shell.
|
|
316
|
+
2. **Attach** — provisioned credentials in env (\`ALPHA_ID\` + \`JUNGLE_API_KEY\`),
|
|
317
|
+
then \`npx -y @nfinitmonkeys/clan attach\`. Never paste credentials into argv or chat.
|
|
318
|
+
3. **Not provisioned yet** — point them at their operator / Human Council.
|
|
319
|
+
|
|
320
|
+
After either flow, confirm \`.jungle/config.yaml\` exists — that file IS the
|
|
321
|
+
registration; without it the run failed regardless of exit code. Re-runs of any
|
|
322
|
+
of these are repairs, not errors.
|
|
323
|
+
|
|
324
|
+
## 9 · Epilogue
|
|
325
|
+
|
|
326
|
+
Recap exactly what was written (from the apply output), where the backups are,
|
|
327
|
+
and how to reverse it: \`${ENGINE_NPX} undo\`.`);
|
|
328
|
+
}
|
|
329
|
+
function clanPack(i) {
|
|
179
330
|
const t = i.tier;
|
|
180
331
|
const files = [
|
|
181
332
|
cmd(t, 'status', `Show this ${t}'s live status — identity, policies, inbox, telemetry`, `Run the clan status command and present it as a clean dashboard. If MCP is wired, you may also call \`mcp__jungle-local__jungle_whoami\` and \`mcp__jungle-local__jungle_get_self\`.
|
|
@@ -218,10 +369,83 @@ Probes come from \`.jungle/config.yaml\` under \`health:\`. Summarize each check
|
|
|
218
369
|
}
|
|
219
370
|
return files;
|
|
220
371
|
}
|
|
372
|
+
/** District pack — the box's MCP tools (jungle-local → localhost:<boxPort>) are
|
|
373
|
+
* the substrate, never the clan CLI. All 5 verbs render unconditionally.
|
|
374
|
+
* Box-down recovery names the district CLI by its jungle-repo checkout path —
|
|
375
|
+
* the bare npm name is a stranger's squattable package. */
|
|
376
|
+
function districtPack(i) {
|
|
377
|
+
const t = i.tier;
|
|
378
|
+
const port = i.boxPort ?? '7787';
|
|
379
|
+
const db = '.district/db/district.db';
|
|
380
|
+
return [
|
|
381
|
+
cmd(t, 'status', `Show this district's live status — identity, member clans, inbox, work, discussion points`, `This repo is a **district** (${i.name} / Alpha ${i.alphaName}) — status comes from the district box's MCP tools (server \`jungle-local\` → localhost:${port}), NOT \`npx -y @nfinitmonkeys/clan\`.
|
|
382
|
+
|
|
383
|
+
${header(i)}
|
|
384
|
+
|
|
385
|
+
Gather in parallel: \`jungle_whoami\`, \`jungle_get_children\` (member clans), \`jungle_check_inbox\` (unreadOnly), \`jungle_list_work\`, \`jungle_list_discussion_points\` — all via \`mcp__jungle-local__*\`.
|
|
386
|
+
|
|
387
|
+
Present one dashboard: identity header, member-clan roster with lastSeen, unread inbox, work by status, open discussion points.
|
|
388
|
+
|
|
389
|
+
If MCP calls fail with a connection error, the box is down — offer: \`DISTRICT_DATA_DIR=.district node <jungle-checkout>/packages/district/dist/cli.js start\` from this repo root (port ${port}; the district CLI lives in the jungle repo checkout — the bare npm name is a stranger's package; the env var is required — without it the CLI would create a fresh ./data dir and mint a DUPLICATE district identity).`),
|
|
390
|
+
cmd(t, 'inbox', `View recent messages in ${i.alphaName}'s district inbox`, `${header(i)}
|
|
391
|
+
|
|
392
|
+
Call \`mcp__jungle-local__jungle_check_inbox\` (unreadOnly first; if empty retry unreadOnly:false, limit 15). Show sender, subject, age. Threads via \`jungle_get_thread\`; mark read via \`jungle_mark_read\`; reply via \`jungle_send_message\` only after the user confirms content.`),
|
|
393
|
+
cmd(t, 'log', `Governance log — every recorded act on this district`, `${header(i)}
|
|
394
|
+
|
|
395
|
+
The box exposes no log tool yet — read the district's own sqlite directly (folder-rooted, ours):
|
|
396
|
+
|
|
397
|
+
\`\`\`bash
|
|
398
|
+
sqlite3 -header -column ${db} "SELECT ts, actor, action, target FROM governance_log ORDER BY ts DESC LIMIT 25;"
|
|
399
|
+
\`\`\`
|
|
400
|
+
|
|
401
|
+
Newest first, human timestamps. A short log is a young district, not an error.`),
|
|
402
|
+
cmd(t, 'policies', `This district's governance posture — honest about enforced vs. not yet built`, `${header(i)}
|
|
403
|
+
|
|
404
|
+
Be honest: **the district box has no policy engine yet** (Console P3 builds it). Show instead: (1) identity + posture from \`.district/district.config.yaml\` (never print apiKey lines); (2) the composing rule — *a parent sees a child only by the child's consent; every child runs without its parent*; (3) plainly: acts are ungated but logged (see /district:log).`),
|
|
405
|
+
cmd(t, 'request', `Raise a request or decision — discussion point, or escalate to the operating jungle`, `${header(i)}
|
|
406
|
+
|
|
407
|
+
Two real forms — ask which if unclear: (1) a decision for THIS district → \`mcp__jungle-local__jungle_create_discussion_point\` (title + context; lifecycle open→in_discussion→decided→resolved, +parked); (2) a request to the operating jungle → raise from the jungle repo as its Alpha, or record a DP here tagged for escalation. Never fabricate an approval flow that doesn't exist.`),
|
|
408
|
+
];
|
|
409
|
+
}
|
|
410
|
+
/** Jungle pack — the org hub. Registry-wide status via this repo's declared
|
|
411
|
+
* identity; all 5 verbs render unconditionally. */
|
|
412
|
+
function junglePack(i) {
|
|
413
|
+
const t = i.tier;
|
|
414
|
+
return [
|
|
415
|
+
cmd(t, 'status', `Show this jungle's live status — identity, council, districts + clans, inbox`, `This repo is a **jungle** (${i.name} / Alpha ${i.alphaName}) — the org hub. Status via \`mcp__jungle-local__*\` (this repo's declared identity).
|
|
416
|
+
|
|
417
|
+
${header(i)}
|
|
418
|
+
|
|
419
|
+
Gather in parallel: \`jungle_whoami\`, \`jungle_list_clans\` (the registry — group by geoTier: districts vs direct clans), \`jungle_check_inbox\` (unreadOnly), \`jungle_list_approvals\` (pending only).
|
|
420
|
+
|
|
421
|
+
Dashboard: identity header, council roster (permission-tier council members), districts with child counts, direct clans, unread inbox, pending approvals count.`),
|
|
422
|
+
cmd(t, 'inbox', `View recent messages in ${i.alphaName}'s inbox`, `${header(i)}
|
|
423
|
+
|
|
424
|
+
\`mcp__jungle-local__jungle_check_inbox\` (unreadOnly first, then all, limit 15). Sender, subject, age; threads via \`jungle_get_thread\`; reply via \`jungle_send_message\` only after the user confirms.`),
|
|
425
|
+
cmd(t, 'log', `Governance log for this jungle`, `${header(i)}
|
|
426
|
+
|
|
427
|
+
Use \`npx -y @nfinitmonkeys/clan status --json | jq '.self.governanceLog // [] | .[0:15]'\` (this repo is attached via .jungle/config.yaml). Timeline, newest first: who/what/when/why.`),
|
|
428
|
+
cmd(t, 'policies', `This jungle's policies + the governance invariant`, `${header(i)}
|
|
429
|
+
|
|
430
|
+
\`\`\`bash
|
|
431
|
+
npx -y @nfinitmonkeys/clan policies
|
|
432
|
+
\`\`\`
|
|
433
|
+
|
|
434
|
+
Explain the buckets, and the invariant: Alphas propose, humans approve — every sensitive act routes through the approval queue (BOSS).`),
|
|
435
|
+
cmd(t, 'request', `Propose a policy or governance change for this jungle`, `${header(i)}
|
|
436
|
+
|
|
437
|
+
Compose the change (actionType, bucket, rationale), confirm with the user, then send via \`npx -y @nfinitmonkeys/clan talk "..."\` or, for cross-clan governance acts, note that the human-council voice (\`mcp__jungle__*\`) is required and must be explicitly requested.`),
|
|
438
|
+
];
|
|
439
|
+
}
|
|
221
440
|
// ─── brain scaffold (canonical layout — <brainRoot>/wiki + .brain-meta.json) ─
|
|
222
441
|
/** Where the brain lives, per tier (matches the fleet's clan-ready layout so
|
|
223
|
-
* the engine never puts .brain/ where a district/jungle expects its vault).
|
|
442
|
+
* the engine never puts .brain/ where a district/jungle expects its vault).
|
|
443
|
+
* An EXISTING vault (i.brainRoot, set from inspect) wins over the tier
|
|
444
|
+
* default — applying to a repo with a vault elsewhere must never mint a
|
|
445
|
+
* duplicate. */
|
|
224
446
|
export function brainRoot(i) {
|
|
447
|
+
if (i.brainRoot)
|
|
448
|
+
return i.brainRoot;
|
|
225
449
|
if (i.tier === 'district')
|
|
226
450
|
return '.district/brain';
|
|
227
451
|
if (i.tier === 'jungle')
|
package/dist/types.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* file's marker so a future engine can tell "my old output" from "my current
|
|
7
7
|
* output" and run migrations. Bump LAYOUT_VERSION when the template SHAPE
|
|
8
8
|
* changes (a path moves, a format changes); bump ENGINE_VERSION freely. */
|
|
9
|
-
export declare const ENGINE_VERSION = "0.
|
|
9
|
+
export declare const ENGINE_VERSION = "0.3.0";
|
|
10
10
|
export declare const LAYOUT_VERSION = 1;
|
|
11
11
|
/** The marker key written into generated-file frontmatter / headers. */
|
|
12
12
|
export declare const GENERATED_BY = "clan-engine";
|
|
@@ -22,6 +22,12 @@ export interface ClanIdentity {
|
|
|
22
22
|
description: string;
|
|
23
23
|
tier: Tier;
|
|
24
24
|
mode: Mode;
|
|
25
|
+
/** district box HTTP port (from .district/district.config.yaml http.port). */
|
|
26
|
+
boxPort?: string;
|
|
27
|
+
/** EXISTING vault root (repo-relative) when one was detected at a non-default
|
|
28
|
+
* location — overrides the tier default so applying never mints a duplicate
|
|
29
|
+
* vault (e.g. the jungle repo's own .brain/ despite tier jungle). */
|
|
30
|
+
brainRoot?: string;
|
|
25
31
|
/** connected-mode credentials (drive .mcp.json). */
|
|
26
32
|
jungle?: {
|
|
27
33
|
apiUrl: string;
|
|
@@ -40,6 +46,19 @@ export interface GeneratedFile {
|
|
|
40
46
|
/** POSIX chmod to apply after write (e.g. 0o755 for scripts). */
|
|
41
47
|
chmod?: number;
|
|
42
48
|
}
|
|
49
|
+
/** Input handed to a brain-build curation hook. The engine stays zero-LLM —
|
|
50
|
+
* the hook is supplied by a caller that has one (e.g. @nfinitmonkeys/clan). */
|
|
51
|
+
export interface BrainCurateInput {
|
|
52
|
+
/** The mechanical candidate pages (already sanitized + create-only filtered). */
|
|
53
|
+
pages: GeneratedFile[];
|
|
54
|
+
identity: ClanIdentity;
|
|
55
|
+
/** Provenance, one line per candidate: "<page path> ← <source file>". */
|
|
56
|
+
sourceNotes: string[];
|
|
57
|
+
}
|
|
58
|
+
/** Returns the curated page set (replaces/augments the candidates). The engine
|
|
59
|
+
* re-gates EVERY curated body through scanSensitive + create-only regardless —
|
|
60
|
+
* an LLM echoing a secret from context is held back like a mined one. */
|
|
61
|
+
export type BrainCurator = (input: BrainCurateInput) => Promise<GeneratedFile[]>;
|
|
43
62
|
export type ActionKind = 'create' | 'update' | 'backup-replace' | 'merge' | 'append' | 'remove' | 'skip';
|
|
44
63
|
export interface PlanAction {
|
|
45
64
|
kind: ActionKind;
|
|
@@ -89,6 +108,10 @@ export interface InspectResult {
|
|
|
89
108
|
/** brain vault present + its layout version (from .brain-meta.json). */
|
|
90
109
|
hasBrain: boolean;
|
|
91
110
|
brainLayoutVersion?: number;
|
|
111
|
+
/** where an EXISTING vault lives (repo-relative), checked across every known
|
|
112
|
+
* root (.district/brain > .brain > .brains/*) — reconcile scaffolds THERE,
|
|
113
|
+
* never a tier-default duplicate. Unset when no vault exists yet. */
|
|
114
|
+
brainRoot?: string;
|
|
92
115
|
/** the reconciled state classification. */
|
|
93
116
|
state: NodeState;
|
|
94
117
|
/** actionable notes for the wizard / caller. */
|
package/dist/types.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* file's marker so a future engine can tell "my old output" from "my current
|
|
7
7
|
* output" and run migrations. Bump LAYOUT_VERSION when the template SHAPE
|
|
8
8
|
* changes (a path moves, a format changes); bump ENGINE_VERSION freely. */
|
|
9
|
-
export const ENGINE_VERSION = '0.
|
|
9
|
+
export const ENGINE_VERSION = '0.3.0';
|
|
10
10
|
export const LAYOUT_VERSION = 1;
|
|
11
11
|
/** The marker key written into generated-file frontmatter / headers. */
|
|
12
12
|
export const GENERATED_BY = 'clan-engine';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nfinitmonkeys/clan-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Deterministic setup engine for Nfinit Monkeys clans \u2014 the single template + reconciliation authority behind the published CLIs and the internal fleet tooling. Idempotent, dry-run-by-default, non-destructive.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|