bom-pi 0.0.0-stage → 0.0.2
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 +33 -2
- package/apps/README.md +7 -0
- package/apps/web/README.md +21 -0
- package/apps/web/pocket-adapter.mjs +323 -0
- package/apps/web/public/LICENSE.pocket +21 -0
- package/apps/web/public/activity-fold.js +28 -0
- package/apps/web/public/agent-now.js +37 -0
- package/apps/web/public/agent-tile.js +79 -0
- package/apps/web/public/app.js +975 -0
- package/apps/web/public/apple-touch-icon.png +0 -0
- package/apps/web/public/artifact-bridge.js +687 -0
- package/apps/web/public/avatar.js +87 -0
- package/apps/web/public/back.js +554 -0
- package/apps/web/public/box-keys.js +216 -0
- package/apps/web/public/browser-panel.js +1097 -0
- package/apps/web/public/browser.js +68 -0
- package/apps/web/public/calls.js +139 -0
- package/apps/web/public/chat.js +919 -0
- package/apps/web/public/clock.js +34 -0
- package/apps/web/public/commands.js +578 -0
- package/apps/web/public/composer.js +2068 -0
- package/apps/web/public/diff-parse.js +672 -0
- package/apps/web/public/diff.js +1646 -0
- package/apps/web/public/dock.js +299 -0
- package/apps/web/public/extension-ui.js +2734 -0
- package/apps/web/public/files-panel.js +775 -0
- package/apps/web/public/files.js +368 -0
- package/apps/web/public/fonts/FiraCode-VF.woff2 +0 -0
- package/apps/web/public/fonts/Geist.woff2 +0 -0
- package/apps/web/public/fonts/IBMPlexMono-Variable-Italic.woff2 +0 -0
- package/apps/web/public/fonts/IBMPlexMono-Variable.woff2 +0 -0
- package/apps/web/public/fonts/InterVariable-Italic.woff2 +0 -0
- package/apps/web/public/fonts/InterVariable.woff2 +0 -0
- package/apps/web/public/fonts/Iosevka-Bold.woff2 +0 -0
- package/apps/web/public/fonts/Iosevka-BoldItalic.woff2 +0 -0
- package/apps/web/public/fonts/Iosevka-Italic.woff2 +0 -0
- package/apps/web/public/fonts/Iosevka-Regular.woff2 +0 -0
- package/apps/web/public/fonts/Iosevka-SemiBold.woff2 +0 -0
- package/apps/web/public/fonts/Iosevka-SemiBoldItalic.woff2 +0 -0
- package/apps/web/public/fonts/JetBrainsMono-Italic.woff2 +0 -0
- package/apps/web/public/fonts/JetBrainsMono.woff2 +0 -0
- package/apps/web/public/fonts/NerdFontsSymbolsMono.woff2 +0 -0
- package/apps/web/public/fonts/SOURCES.md +69 -0
- package/apps/web/public/gestures.js +610 -0
- package/apps/web/public/highlight.js +480 -0
- package/apps/web/public/history.js +70 -0
- package/apps/web/public/home.js +169 -0
- package/apps/web/public/icon-192.png +0 -0
- package/apps/web/public/icon-512.png +0 -0
- package/apps/web/public/icon-maskable-512.png +0 -0
- package/apps/web/public/icon.svg +16 -0
- package/apps/web/public/index.html +71 -0
- package/apps/web/public/launcher.js +1293 -0
- package/apps/web/public/linked-sessions.js +55 -0
- package/apps/web/public/live.js +39 -0
- package/apps/web/public/manifest.webmanifest +32 -0
- package/apps/web/public/model-refresh.js +73 -0
- package/apps/web/public/notify.js +251 -0
- package/apps/web/public/peeks.js +920 -0
- package/apps/web/public/pip-attachments.js +182 -0
- package/apps/web/public/pip-window.js +141 -0
- package/apps/web/public/pip.js +1217 -0
- package/apps/web/public/quote-reply.js +109 -0
- package/apps/web/public/quote-text.js +31 -0
- package/apps/web/public/rich.js +403 -0
- package/apps/web/public/run-frame.js +106 -0
- package/apps/web/public/safe-mode.js +71 -0
- package/apps/web/public/seen.js +169 -0
- package/apps/web/public/session-tree.js +117 -0
- package/apps/web/public/sessions.js +2695 -0
- package/apps/web/public/share.js +126 -0
- package/apps/web/public/sheets/appearance.js +820 -0
- package/apps/web/public/sheets/branch.js +353 -0
- package/apps/web/public/sheets/extensions.js +818 -0
- package/apps/web/public/sheets/file.js +318 -0
- package/apps/web/public/sheets/find.js +250 -0
- package/apps/web/public/sheets/folder.js +680 -0
- package/apps/web/public/sheets/gallery.js +2340 -0
- package/apps/web/public/sheets/hooks.js +350 -0
- package/apps/web/public/sheets/memory.js +531 -0
- package/apps/web/public/sheets/menu.js +580 -0
- package/apps/web/public/sheets/message.js +220 -0
- package/apps/web/public/sheets/model.js +412 -0
- package/apps/web/public/sheets/people.js +414 -0
- package/apps/web/public/sheets/pi-sessions.js +264 -0
- package/apps/web/public/sheets/providers.js +525 -0
- package/apps/web/public/sheets/running.js +130 -0
- package/apps/web/public/sheets/schedules.js +71 -0
- package/apps/web/public/sheets/session.js +249 -0
- package/apps/web/public/sheets/shortcuts.js +101 -0
- package/apps/web/public/sheets/spend.js +150 -0
- package/apps/web/public/sheets/text.js +53 -0
- package/apps/web/public/sheets/viewers.js +363 -0
- package/apps/web/public/sheets/worktree.js +50 -0
- package/apps/web/public/sheets.js +410 -0
- package/apps/web/public/signin.js +57 -0
- package/apps/web/public/slots.js +208 -0
- package/apps/web/public/store.js +1760 -0
- package/apps/web/public/style.css +18625 -0
- package/apps/web/public/subagents-board.js +879 -0
- package/apps/web/public/subagents.js +273 -0
- package/apps/web/public/sw.js +169 -0
- package/apps/web/public/taps.js +26 -0
- package/apps/web/public/theme-surface.d.ts +4 -0
- package/apps/web/public/theme-surface.js +266 -0
- package/apps/web/public/theme.js +845 -0
- package/apps/web/public/themes/lantern/colors.toml +25 -0
- package/apps/web/public/themes/lantern/direction.css +60 -0
- package/apps/web/public/themes/lantern/frame.css +254 -0
- package/apps/web/public/themes/lantern/theme.css +10 -0
- package/apps/web/public/themes/lantern/theme.json +7 -0
- package/apps/web/public/themes/pocket/theme.css +189 -0
- package/apps/web/public/themes/pocket/theme.json +6 -0
- package/apps/web/public/themes.js +556 -0
- package/apps/web/public/transcript.js +3348 -0
- package/apps/web/public/trust.js +295 -0
- package/apps/web/public/turns.js +507 -0
- package/apps/web/public/ui.js +1910 -0
- package/apps/web/public/voice.js +345 -0
- package/apps/web/server.mjs +774 -0
- package/package.json +43 -4
- package/packages/cli/src/bom-pi.mjs +452 -0
- package/packages/cli/templates/blank.factory.json +7 -0
- package/packages/cli/templates/dev.factory.json +11 -0
- package/packages/cli/templates/docs.factory.json +12 -0
- package/packages/cli/templates/ops.factory.json +14 -0
- package/packages/cli/templates/triage.factory.json +10 -0
- package/packages/core/src/daemon.mjs +2047 -0
- package/packages/core/src/limit-gate.mjs +192 -0
- package/packages/core/src/rpc-client.mjs +66 -0
- package/systemd/README.md +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bom-pi",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "bom × pi — hệ sinh thái durable cho pi trên nền pi-durable: core daemon + web UI pocket + CLI",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=22.19.0"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"bom-pi": "packages/cli/src/bom-pi.mjs",
|
|
11
|
+
"bom-core": "packages/core/src/daemon.mjs",
|
|
12
|
+
"bom-web": "apps/web/server.mjs"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"packages/core/src",
|
|
16
|
+
"packages/cli/src",
|
|
17
|
+
"packages/cli/templates",
|
|
18
|
+
"apps/web/server.mjs",
|
|
19
|
+
"apps/web/pocket-adapter.mjs",
|
|
20
|
+
"apps/web/public",
|
|
21
|
+
"systemd",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@earendil-works/chord": "1.4.0",
|
|
26
|
+
"@earendil-works/pi-ai": "1.4.0",
|
|
27
|
+
"@earendil-works/pi-coding-agent": "1.4.0",
|
|
28
|
+
"@earendil-works/pi-durable": "1.4.0",
|
|
29
|
+
"dompurify": "^3.2.4",
|
|
30
|
+
"htm": "^3.1.1",
|
|
31
|
+
"marked": "^15.0.7",
|
|
32
|
+
"preact": "^10.29.8"
|
|
33
|
+
},
|
|
34
|
+
"workspaces": [
|
|
35
|
+
"packages/*",
|
|
36
|
+
"apps/*"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"core": "node packages/core/src/daemon.mjs",
|
|
40
|
+
"cli": "node packages/cli/src/bom-pi.mjs",
|
|
41
|
+
"check": "node --check packages/core/src/daemon.mjs && node --check packages/cli/src/bom-pi.mjs && node --check scripts/smoke.mjs",
|
|
42
|
+
"smoke": "node scripts/smoke.mjs",
|
|
43
|
+
"web": "node apps/web/server.mjs"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// bom-pi cli v0.4 — client mỏng của bom-core:
|
|
3
|
+
// hello | status | models | sessions | new | use <id> |
|
|
4
|
+
// submit <text...> [--model p/m] | reset [handoff...] | transcript | watch | shutdown
|
|
5
|
+
// Mọi lệnh conversation nhận --cid N (mặc định: conversation active của daemon).
|
|
6
|
+
import { connect } from 'node:net';
|
|
7
|
+
import { join, resolve } from 'node:path';
|
|
8
|
+
import { userInfo } from 'node:os';
|
|
9
|
+
import { readFile, writeFile, mkdir, stat } from 'node:fs/promises';
|
|
10
|
+
import { execFile } from 'node:child_process';
|
|
11
|
+
import { promisify } from 'node:util';
|
|
12
|
+
import process from 'node:process';
|
|
13
|
+
|
|
14
|
+
// Negotiate theo DECISIONS.md D-transport: từ chối khi daemon protocol LỚN HƠN của mình
|
|
15
|
+
const CLIENT_PROTOCOL = 1;
|
|
16
|
+
const RPC_TIMEOUT_MS = 8000;
|
|
17
|
+
|
|
18
|
+
const runtimeDir = process.env.XDG_RUNTIME_DIR || `/tmp/run-${userInfo().uid}`;
|
|
19
|
+
const DEFAULT_SOCKET = resolve(runtimeDir, 'bom-pi.sock');
|
|
20
|
+
|
|
21
|
+
function arg(name, fallback) {
|
|
22
|
+
const i = process.argv.indexOf(`--${name}`);
|
|
23
|
+
return i >= 0 && process.argv[i + 1] ? process.argv[i + 1] : fallback;
|
|
24
|
+
}
|
|
25
|
+
const socketPath = arg('socket', DEFAULT_SOCKET);
|
|
26
|
+
const cid = arg('cid', null); // conversation id cho submit/transcript/reset/watch
|
|
27
|
+
const cidParams = () => (cid ? { conversationId: Number(cid) } : {});
|
|
28
|
+
const cmd = process.argv[2] ?? 'status';
|
|
29
|
+
|
|
30
|
+
function rpc(method, params) {
|
|
31
|
+
return new Promise((done, fail) => {
|
|
32
|
+
const conn = connect(socketPath);
|
|
33
|
+
let buf = '';
|
|
34
|
+
let settled = false;
|
|
35
|
+
const timer = setTimeout(() => {
|
|
36
|
+
conn.destroy();
|
|
37
|
+
fail(new Error(`timeout after ${RPC_TIMEOUT_MS}ms waiting for bom-core at ${socketPath}`));
|
|
38
|
+
}, RPC_TIMEOUT_MS);
|
|
39
|
+
const settle = (fn, v) => { if (!settled) { settled = true; clearTimeout(timer); fn(v); } };
|
|
40
|
+
conn.on('connect', () => {
|
|
41
|
+
conn.write(JSON.stringify({ jsonrpc: '2.0', id: 1, method, params: params ?? {} }) + '\n');
|
|
42
|
+
});
|
|
43
|
+
conn.on('data', (c) => {
|
|
44
|
+
buf += c.toString('utf8');
|
|
45
|
+
const nl = buf.indexOf('\n');
|
|
46
|
+
if (nl >= 0) {
|
|
47
|
+
conn.end();
|
|
48
|
+
try {
|
|
49
|
+
const res = JSON.parse(buf.slice(0, nl));
|
|
50
|
+
// Daemon trả error ⇒ THẤT BẠI (exit 1) — không nuốt như result
|
|
51
|
+
if (res.error) settle(fail, new Error(`bom-core error ${res.error.code}: ${res.error.message}`));
|
|
52
|
+
else settle(done, res.result);
|
|
53
|
+
} catch (e) {
|
|
54
|
+
settle(fail, e);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
// Daemon chết giữa chừng / đóng connection không trả lời
|
|
59
|
+
conn.on('close', () => settle(fail, new Error('bom-core closed the connection without a reply')));
|
|
60
|
+
conn.on('error', (e) => settle(fail, new Error(`cannot reach bom-core at ${socketPath}: ${e.message}`)));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const pretty = (o) => console.log(JSON.stringify(o, null, 2));
|
|
65
|
+
|
|
66
|
+
// Kiểm protocol sau hello — mọi lệnh đều chạy qua đây
|
|
67
|
+
function checkProtocol(hello) {
|
|
68
|
+
if (typeof hello?.protocol === 'number' && hello.protocol > CLIENT_PROTOCOL) {
|
|
69
|
+
console.error(`bom-core speaks protocol ${hello.protocol} > client ${CLIENT_PROTOCOL} — upgrade bom-pi (client) and retry`);
|
|
70
|
+
process.exit(65); // EX_DATAERR
|
|
71
|
+
}
|
|
72
|
+
return hello;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ---- watch: mở 1 connection, subscribe, in transcript live đến khi Ctrl+C ----
|
|
76
|
+
function watch() {
|
|
77
|
+
const conn = connect(socketPath);
|
|
78
|
+
let gotReply = false;
|
|
79
|
+
conn.on('connect', () => {
|
|
80
|
+
conn.write(JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'events.subscribe', params: cidParams() }) + '\n');
|
|
81
|
+
});
|
|
82
|
+
conn.on('data', (c) => {
|
|
83
|
+
for (const raw of c.toString('utf8').split('\n')) {
|
|
84
|
+
if (!raw.trim()) continue;
|
|
85
|
+
let msg;
|
|
86
|
+
try { msg = JSON.parse(raw); } catch { continue; }
|
|
87
|
+
if (msg.id === 1 && !gotReply) {
|
|
88
|
+
gotReply = true;
|
|
89
|
+
if (msg.error) { console.error(`bom-core error ${msg.error.code}: ${msg.error.message}`); process.exit(1); }
|
|
90
|
+
const { conversationId, seq, snapshot } = msg.result;
|
|
91
|
+
console.error(`# conversation ${conversationId} @seq ${seq} — Ctrl+C để thoát`);
|
|
92
|
+
for (const e of snapshot) printEntry(e);
|
|
93
|
+
} else if (msg.method === 'events.update') {
|
|
94
|
+
const { conversationId, seq, entries } = msg.params;
|
|
95
|
+
console.error(`--- ${conversationId} seq ${seq}`);
|
|
96
|
+
for (const e of entries) printEntry(e);
|
|
97
|
+
} else if (msg.method === 'events.heartbeat') {
|
|
98
|
+
console.error(`· heartbeat seq ${msg.params.seq}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
conn.on('error', (e) => { console.error(`cannot reach bom-core at ${socketPath}: ${e.message}`); process.exit(1); });
|
|
103
|
+
conn.on('close', () => { if (!gotReply) { console.error('bom-core closed the connection without a reply'); process.exit(1); } process.exit(0); });
|
|
104
|
+
}
|
|
105
|
+
const printEntry = (e) => console.log(`[${e.kind}]${e.role ? ` ${e.role}:` : ''} ${e.text ?? ''}`);
|
|
106
|
+
|
|
107
|
+
const t0 = Date.now();
|
|
108
|
+
try {
|
|
109
|
+
if (cmd === 'hello') {
|
|
110
|
+
pretty(checkProtocol(await rpc('hello')));
|
|
111
|
+
} else if (cmd === 'status') {
|
|
112
|
+
const hello = checkProtocol(await rpc('hello'));
|
|
113
|
+
const status = await rpc('status');
|
|
114
|
+
pretty({ core: `${hello.name} v${hello.version} (protocol ${hello.protocol}, pi-durable ${hello.piDurable})`, fp: hello.fp, activeConversation: hello.activeConversationId, ms: Date.now() - t0, ...status });
|
|
115
|
+
} else if (cmd === 'agents') {
|
|
116
|
+
// Cây task-graph roles: ┌ root (conv-owned) / └ worker (owner = parent)
|
|
117
|
+
const r = await rpc('agents.list');
|
|
118
|
+
for (const conv of r.conversations) {
|
|
119
|
+
console.log(`${conv.active ? '*' : ' '} conv ${String(conv.id).padStart(4)}${conv.root ? ' (root)' : ''} model=${conv.model ? `${conv.model.provider}/${conv.model.modelId}` : '-'} ${conv.tasks.length} task(s)`);
|
|
120
|
+
for (const t of conv.tasks) {
|
|
121
|
+
console.log(` ${t.role === 'worker' ? '└─' : '┌─'} ${String(t.taskId).slice(0, 16).padEnd(16)} ${String(t.kind ?? '-').padEnd(10)} ${t.status ?? '-'}${t.phase ? `:${t.phase}` : ''}${t.fork ? ` fork→conv ${t.owns.join(',')}` : ''}${t.background ? ' [bg]' : ''}${t.blocked ? ` BLOCKED(${t.blocked})` : ''}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
for (const t of r.orphanTasks) console.log(` ? task ${t.taskId} conv ngoài danh sách — ${t.status ?? '-'}`);
|
|
125
|
+
for (const s of r.submissions) console.log(` submission ${s.id} conv ${s.conversationId} ${s.status}`);
|
|
126
|
+
console.error(`# ${r.conversations.length} conversation(s) — ┌ root / └ worker (owner=parent)`);
|
|
127
|
+
} else if (cmd === 'factory') {
|
|
128
|
+
// M5a — một lệnh mở xưởng: init (tạo factory.json từ template rồi mount) · list · sync · stop/start · rm
|
|
129
|
+
const sub = process.argv[3];
|
|
130
|
+
const rest = process.argv.slice(4);
|
|
131
|
+
if (sub === 'init') {
|
|
132
|
+
// G3/M7 — mở xưởng MỘT lệnh: template chọn line việc (blank|triage|dev|ops|docs);
|
|
133
|
+
// template dev tự `git init -b main` khi dir chưa phải repo (agent dev cần repo).
|
|
134
|
+
const dir = rest.find((a) => !a.startsWith('--'));
|
|
135
|
+
const template = arg('template', 'triage');
|
|
136
|
+
if (!dir) { console.error('usage: bom-pi factory init <dir> [--template blank|triage|dev|ops|docs]'); process.exit(64); }
|
|
137
|
+
checkProtocol(await rpc('hello'));
|
|
138
|
+
const dirAbs = resolve(dir);
|
|
139
|
+
const cfgPath = resolve(dirAbs, 'factory.json');
|
|
140
|
+
let configCreated = false;
|
|
141
|
+
try { await readFile(cfgPath, 'utf8'); } catch {
|
|
142
|
+
let tpl;
|
|
143
|
+
try {
|
|
144
|
+
tpl = await readFile(new URL(`../templates/${template}.factory.json`, import.meta.url), 'utf8');
|
|
145
|
+
} catch {
|
|
146
|
+
console.error(`unknown template "${template}" — blank | triage | dev | ops | docs`); process.exit(64);
|
|
147
|
+
}
|
|
148
|
+
await mkdir(dirAbs, { recursive: true });
|
|
149
|
+
await writeFile(cfgPath, tpl);
|
|
150
|
+
configCreated = true;
|
|
151
|
+
}
|
|
152
|
+
let gitInit = false;
|
|
153
|
+
if (template === 'dev') {
|
|
154
|
+
try { await stat(resolve(dirAbs, '.git')); } catch {
|
|
155
|
+
const git = (...a) => promisify(execFile)('git', ['-C', dirAbs, ...a]);
|
|
156
|
+
await git('init', '-b', 'main');
|
|
157
|
+
// commit base NGAY: repo mới chưa có ref ⇒ agent phải mò tạo orphan main (đã gặp
|
|
158
|
+
// real-test). Identity: dùng config sẵn của người, thiếu thì -c fallback cục bộ.
|
|
159
|
+
let identity = [];
|
|
160
|
+
try { await promisify(execFile)('git', ['-C', dirAbs, 'config', '--get', 'user.email']); } catch {
|
|
161
|
+
identity = ['-c', 'user.email=dev@bom-pi.factory', '-c', 'user.name=dev factory'];
|
|
162
|
+
}
|
|
163
|
+
await promisify(execFile)('git', ['-C', dirAbs, ...identity, 'commit', '--allow-empty', '-m', 'factory init']);
|
|
164
|
+
gitInit = true;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const r = await rpc('factory.mount', { dir: dirAbs });
|
|
168
|
+
console.log(JSON.stringify({ ...r.factory, configCreated, gitInit }, null, 2));
|
|
169
|
+
console.error(`# mount OK — schedules: 'bom-pi schedules' · stop/start/rm by id ${r.factory.id}${gitInit ? ' · git repo initialized (dev factory codes here)' : ''}`);
|
|
170
|
+
} else if (sub === 'list') {
|
|
171
|
+
const r = await rpc('factory.list');
|
|
172
|
+
if (!r.factories.length) console.error('# chưa có factory — bom-pi factory init <dir>');
|
|
173
|
+
for (const f of r.factories) {
|
|
174
|
+
console.log(`${f.status === 'mounted' ? '●' : '○'} ${f.id} ${(f.name ?? '?').padEnd(12)} conv ${String(f.conversationId).padEnd(4)} aut ${String(f.autonomy ?? 'L0').padEnd(2)} sched ${f.schedules.enabled}/${f.schedules.total} on pages ${String(f.pages).padEnd(3)} children ${f.childConversations} ${f.dir}`);
|
|
175
|
+
}
|
|
176
|
+
console.error(`# ${r.count} factory — ● mounted / ○ stopped · aut = autonomy (L0 phê mọi tool, L1+ chỉ bash)`);
|
|
177
|
+
} else if (sub === 'sync') {
|
|
178
|
+
if (!rest[0]) { console.error('usage: bom-pi factory sync <dir>'); process.exit(64); }
|
|
179
|
+
checkProtocol(await rpc('hello'));
|
|
180
|
+
pretty(await rpc('factory.mount', { dir: resolve(rest[0]) }));
|
|
181
|
+
} else if (sub === 'propose') {
|
|
182
|
+
// M6a: cổng merge — CHỜ người duyệt answer qua 'bom-pi approvals' hoặc web
|
|
183
|
+
const id = rest.find((a) => !a.startsWith('--'));
|
|
184
|
+
const summary = arg('summary', '');
|
|
185
|
+
const titleArgs = rest.slice(1).filter((a) => !a.startsWith('--'));
|
|
186
|
+
if (!id || rest.length < 3) { console.error('usage: bom-pi factory propose <id> <branch> <title...> [--summary "..."] — chờ duyệt qua approvals'); process.exit(64); }
|
|
187
|
+
checkProtocol(await rpc('hello'));
|
|
188
|
+
pretty(await rpc('factory.propose', { id, branch: rest[1], title: titleArgs.join(' '), ...(summary ? { summary } : {}) }));
|
|
189
|
+
} else if (sub === 'stop' || sub === 'start') {
|
|
190
|
+
if (!rest[0]) { console.error(`usage: bom-pi factory ${sub} <id> — xem factory list`); process.exit(64); }
|
|
191
|
+
checkProtocol(await rpc('hello'));
|
|
192
|
+
pretty(await rpc(`factory.${sub}`, { id: rest[0] }));
|
|
193
|
+
} else if (sub === 'rm') {
|
|
194
|
+
if (!rest[0]) { console.error('usage: bom-pi factory rm <id> — xem factory list'); process.exit(64); }
|
|
195
|
+
checkProtocol(await rpc('hello'));
|
|
196
|
+
pretty(await rpc('factory.remove', { id: rest[0] }));
|
|
197
|
+
} else {
|
|
198
|
+
console.error('usage: bom-pi factory <init|list|sync|propose|stop|start|rm> <dir|id> [--template blank|triage]');
|
|
199
|
+
process.exit(64);
|
|
200
|
+
}
|
|
201
|
+
} else if (cmd === 'pages') {
|
|
202
|
+
// M5c1: liệt kê pages của factory (nội dung: web render hoặc cat trực tiếp)
|
|
203
|
+
const id = process.argv[3];
|
|
204
|
+
if (!id) { console.error('usage: bom-pi pages <factoryId> — xem factory list'); process.exit(64); }
|
|
205
|
+
const r = await rpc('pages.list', { factoryId: id });
|
|
206
|
+
if (!r.pages.length) console.error('# chưa có page (agent viết bằng write tool vào pages/)');
|
|
207
|
+
for (const p of r.pages) {
|
|
208
|
+
console.log(`${p.name} ${String(p.bytes).padStart(7)}B ${p.title ?? '(no heading)'}`);
|
|
209
|
+
}
|
|
210
|
+
} else if (cmd === 'models') {
|
|
211
|
+
const r = await rpc('models.list');
|
|
212
|
+
for (const m of r.models) console.log(`${m.provider}/${m.id}${m.name ? ` — ${m.name}` : ''}`);
|
|
213
|
+
console.error(`# ${r.count} models${r.availableOnly ? '' : ' (TOÀN BỘ catalog — chưa xác thực available)'}`);
|
|
214
|
+
} else if (cmd === 'sessions') {
|
|
215
|
+
const r = await rpc('session.list');
|
|
216
|
+
for (const c of r.conversations) {
|
|
217
|
+
const mark = c.active ? '*' : ' ';
|
|
218
|
+
console.log(`${mark} ${String(c.id).padStart(4)}${c.root ? ' (root)' : ''} model=${c.model ? `${c.model.provider}/${c.model.modelId}` : '-'} cwd=${c.cwd ?? '-'}`);
|
|
219
|
+
}
|
|
220
|
+
console.error(`# ${r.count} conversations — * = active`);
|
|
221
|
+
} else if (cmd === 'new') {
|
|
222
|
+
const modelArg = arg('model', null);
|
|
223
|
+
const cwdArg = arg('cwd', null);
|
|
224
|
+
const parts = modelArg?.split('/');
|
|
225
|
+
checkProtocol(await rpc('hello'));
|
|
226
|
+
pretty(await rpc('session.new', {
|
|
227
|
+
...(parts?.length === 2 ? { model: { provider: parts[0], modelId: parts[1] } } : {}),
|
|
228
|
+
...(cwdArg ? { cwd: cwdArg } : {}),
|
|
229
|
+
}));
|
|
230
|
+
} else if (cmd === 'use') {
|
|
231
|
+
const id = Number(process.argv[3]);
|
|
232
|
+
if (!Number.isInteger(id)) { console.error('usage: bom-pi use <id> — xem sessions'); process.exit(64); }
|
|
233
|
+
checkProtocol(await rpc('hello'));
|
|
234
|
+
pretty(await rpc('session.switch', { id }));
|
|
235
|
+
} else if (cmd === 'submit') {
|
|
236
|
+
// bỏ mọi cờ --flag value khỏi text (--model p/m --cid N --socket P)
|
|
237
|
+
const VALUE_FLAGS = new Set(['--model', '--cid', '--socket']);
|
|
238
|
+
const rest = [];
|
|
239
|
+
const raw = process.argv.slice(3);
|
|
240
|
+
for (let i = 0; i < raw.length; i++) {
|
|
241
|
+
if (VALUE_FLAGS.has(raw[i])) { i++; continue; }
|
|
242
|
+
rest.push(raw[i]);
|
|
243
|
+
}
|
|
244
|
+
const mi = raw.indexOf('--model');
|
|
245
|
+
const model = mi >= 0 && raw[mi + 1] ? raw[mi + 1] : null;
|
|
246
|
+
const text = rest.join(' ').trim();
|
|
247
|
+
if (!text) { console.error('usage: bom-pi submit <text...> [--model provider/id] [--cid N]'); process.exit(64); }
|
|
248
|
+
const parts = model?.split('/');
|
|
249
|
+
checkProtocol(await rpc('hello'));
|
|
250
|
+
const r = await rpc('session.submit', {
|
|
251
|
+
text,
|
|
252
|
+
...cidParams(),
|
|
253
|
+
...(parts?.length === 2 ? { model: { provider: parts[0], modelId: parts[1] } } : {}),
|
|
254
|
+
requestId: `cli-${process.pid}-${Date.now()}`,
|
|
255
|
+
});
|
|
256
|
+
pretty({ ok: true, ...r, hint: 'bom-pi watch --cid N — xem live; bom-pi sessions — đổi active' });
|
|
257
|
+
} else if (cmd === 'reset') {
|
|
258
|
+
const handoff = process.argv.slice(3).join(' ').trim();
|
|
259
|
+
checkProtocol(await rpc('hello'));
|
|
260
|
+
pretty(await rpc('session.reset', { ...cidParams(), ...(handoff ? { handoff } : {}) }));
|
|
261
|
+
} else if (cmd === 'transcript') {
|
|
262
|
+
pretty(await rpc('transcript.get', { ...cidParams() }));
|
|
263
|
+
} else if (cmd === 'pair') {
|
|
264
|
+
// M8 + security: pairing 2 CHIỀU — thiết bị nhập code (chiều 1) ⇒ enrollment chờ;
|
|
265
|
+
// token chỉ cấp khi duyệt tại máy (chiều 2): pair approve <mã ghép>
|
|
266
|
+
const sub2 = process.argv[3];
|
|
267
|
+
if (!sub2) {
|
|
268
|
+
const r = await rpc('pair.code');
|
|
269
|
+
const nets = await import('node:os');
|
|
270
|
+
const lan = Object.values(nets.networkInterfaces() ?? {}).flat()
|
|
271
|
+
.filter((x) => x?.family === 'IPv4' && !x.internal).map((x) => x.address)[0] ?? '<lan-ip>';
|
|
272
|
+
// Offer (khuôn paseo/spin): cả gói JSON base64url trong fragment — device quét là
|
|
273
|
+
// biết nối AI, ở đâu, danh tính gì (fp + pubkey daemon). Fragment không lên server.
|
|
274
|
+
// publicUrl (daemon sau tunnel vd cloudflared) làm URL chính — QR dùng được cả
|
|
275
|
+
// trong lẫn ngoài LAN; IP LAN in tham khảo cho cùng-WiFi (nhanh hơn, khỏi vòng CF)
|
|
276
|
+
const base = r.publicUrl || `http://${lan}:8791`;
|
|
277
|
+
const offer = { v: 1, name: `bom@${nets.hostname()}`, url: base, code: r.code, fp: r.fp, pub: r.pub, exp: r.expiresAtMs };
|
|
278
|
+
const url = `${base}/pair#O=${Buffer.from(JSON.stringify(offer)).toString('base64url')}`;
|
|
279
|
+
const lanLine = r.publicUrl && lan !== '<lan-ip>' ? `\n lan: http://${lan}:8791/pair (cùng WiFi — nhanh hơn)` : '';
|
|
280
|
+
console.log(`\n code: ${r.code} (gõ tay vẫn được)\n máy: ${offer.name} · fp ${offer.fp} ← device sẽ hiện fp này — KHỚP máy thì mới duyệt\n url: ${url}${lanLine}\n hết hạn sau ${Math.round(r.ttlSec / 60)} phút, dùng MỘT lần.`);
|
|
281
|
+
try {
|
|
282
|
+
const qr = await promisify(execFile)('qrencode', ['-t', 'utf8', '-m', '2', url]);
|
|
283
|
+
console.log(qr.stdout);
|
|
284
|
+
} catch {
|
|
285
|
+
console.log(' (muốn QR trong terminal: sudo apt install qrencode — hoặc gửi link trên cho thiết bị)\n');
|
|
286
|
+
}
|
|
287
|
+
console.log(` 2 chiều: thiết bị quét QR/mở link ⇒ nhập tên ⇒ hiện mã ghép ⇒ 'bom-pi pair pending' xem ⇒ 'bom-pi pair approve <mã>' duyệt\n`);
|
|
288
|
+
} else if (sub2 === 'pending') {
|
|
289
|
+
const r = await rpc('pair.pending');
|
|
290
|
+
if (!r.pending.length) console.error('# không có thiết bị đang xin pair');
|
|
291
|
+
for (const e of r.pending) {
|
|
292
|
+
console.log(`${e.displayId} "${e.name}" còn ${Math.max(0, Math.round((e.expiresAtMs - Date.now()) / 1000))}s`);
|
|
293
|
+
}
|
|
294
|
+
if (r.pending.length) console.error(`# duyệt: bom-pi pair approve <mã ghép> · từ chối: bom-pi pair reject <mã ghép>`);
|
|
295
|
+
} else if (sub2 === 'approve' || sub2 === 'reject') {
|
|
296
|
+
const key = process.argv[4];
|
|
297
|
+
if (!key) { console.error(`usage: bom-pi pair ${sub2} <mã ghép|enrollId> — xem bom-pi pair pending`); process.exit(64); }
|
|
298
|
+
checkProtocol(await rpc('hello'));
|
|
299
|
+
pretty(await rpc(`pair.${sub2}`, { id: key }));
|
|
300
|
+
} else {
|
|
301
|
+
console.error('usage: bom-pi pair [pending|approve <mã>|reject <mã>]'); process.exit(64);
|
|
302
|
+
}
|
|
303
|
+
} else if (cmd === 'devices') {
|
|
304
|
+
const r = await rpc('devices.list');
|
|
305
|
+
if (!r.devices.length) console.error('# chưa có thiết bị nào pair — bom-pi pair');
|
|
306
|
+
for (const d of r.devices) {
|
|
307
|
+
const when = new Date(d.createdAtMs).toLocaleString();
|
|
308
|
+
console.log(`${d.revokedAtMs ? '○' : '●'} ${d.id} ${(d.name ?? '?').padEnd(18)} ${d.revokedAtMs ? 'revoked ' + new Date(d.revokedAtMs).toLocaleString() : 'paired ' + when} hash ${d.tokenHash8}`);
|
|
309
|
+
}
|
|
310
|
+
console.error(`# ${r.devices.filter((d) => !d.revokedAtMs).length} đang sống — thu hồi: bom-pi device rm <id>`);
|
|
311
|
+
} else if (cmd === 'setup') {
|
|
312
|
+
// Sinh systemd user units đúng đường dẫn cài (npm global HOẶC working tree) + enable.
|
|
313
|
+
// root = 3 cấp trên file CLI này: packages/cli/src → gốc package (cả hai kiểu cài đều đúng)
|
|
314
|
+
const { fileURLToPath } = await import('node:url');
|
|
315
|
+
const root = resolve(fileURLToPath(import.meta.url), '..', '..', '..');
|
|
316
|
+
const daemon = resolve(root, 'packages/core/src/daemon.mjs');
|
|
317
|
+
const web = resolve(root, 'apps/web/server.mjs');
|
|
318
|
+
for (const f of [daemon, web]) {
|
|
319
|
+
try { await stat(f); } catch { console.error(`thiếu ${f} — cài lại package`); process.exit(1); }
|
|
320
|
+
}
|
|
321
|
+
const unitDir = resolve(process.env.HOME ?? '~', '.config/systemd/user');
|
|
322
|
+
await mkdir(unitDir, { recursive: true });
|
|
323
|
+
const nodeBin = process.execPath;
|
|
324
|
+
const CORE = `[Unit]
|
|
325
|
+
Description=bom-core - durable pi daemon (bom-pi)
|
|
326
|
+
After=network.target
|
|
327
|
+
|
|
328
|
+
[Service]
|
|
329
|
+
Type=simple
|
|
330
|
+
ExecStart=${nodeBin} ${daemon}
|
|
331
|
+
Restart=on-failure
|
|
332
|
+
RestartSec=2
|
|
333
|
+
KillSignal=SIGTERM
|
|
334
|
+
TimeoutStopSec=15
|
|
335
|
+
|
|
336
|
+
[Install]
|
|
337
|
+
WantedBy=default.target
|
|
338
|
+
`;
|
|
339
|
+
const WEB = `[Unit]
|
|
340
|
+
Description=bom-web - pocket UI (bom-pi)
|
|
341
|
+
After=bom-core.service
|
|
342
|
+
Wants=bom-core.service
|
|
343
|
+
|
|
344
|
+
[Service]
|
|
345
|
+
Type=simple
|
|
346
|
+
ExecStart=${nodeBin} ${web} --port 8791
|
|
347
|
+
Restart=on-failure
|
|
348
|
+
RestartSec=3
|
|
349
|
+
# Set khi có tunnel (vd cloudflared): Environment=BOM_PI_PUBLIC_URL=https://bom.example.com
|
|
350
|
+
|
|
351
|
+
[Install]
|
|
352
|
+
WantedBy=default.target
|
|
353
|
+
`;
|
|
354
|
+
await writeFile(join(unitDir, 'bom-core.service'), CORE);
|
|
355
|
+
await writeFile(join(unitDir, 'bom-web.service'), WEB);
|
|
356
|
+
console.log(`✓ units: ${unitDir}/bom-core.service, bom-web.service (node: ${nodeBin})`);
|
|
357
|
+
await promisify(execFile)('systemctl', ['--user', 'daemon-reload']);
|
|
358
|
+
await promisify(execFile)('systemctl', ['--user', 'enable', '--now', 'bom-core.service', 'bom-web.service']);
|
|
359
|
+
console.log('✓ enabled: bom-core + bom-web (systemd user)');
|
|
360
|
+
console.log('\nTiếp theo: bom-pi pair → quét QR trên phone → bom-pi pair approve <mã ghép>');
|
|
361
|
+
console.log('Log: journalctl --user -u bom-core -f');
|
|
362
|
+
} else if (cmd === 'device') {
|
|
363
|
+
// bom-pi device rm <id>
|
|
364
|
+
const sub2 = process.argv[3];
|
|
365
|
+
const id = process.argv[4];
|
|
366
|
+
if (sub2 !== 'rm' || !id) { console.error('usage: bom-pi device rm <id> — xem devices'); process.exit(64); }
|
|
367
|
+
checkProtocol(await rpc('hello'));
|
|
368
|
+
pretty(await rpc('devices.remove', { id }));
|
|
369
|
+
} else if (cmd === 'metrics') {
|
|
370
|
+
// M6c: số đo trust ladder — merges/tuần (G2 mục tiêu ≥3), deny-rate, can thiệp, usage
|
|
371
|
+
const r = await rpc('metrics.summary');
|
|
372
|
+
const w = r.window7d;
|
|
373
|
+
const d = r.window24h;
|
|
374
|
+
const pct = (x) => `${(x * 100).toFixed(0)}%`;
|
|
375
|
+
console.log(`7 ngày merges ${w.merges.merged}/${w.merges.proposed} (mục tiêu ≥${w.merges.mergesPerWeekTarget}/tuần) · review ✓${w.merges.reviewApprove} ✗${w.merges.reviewRequestChanges}`);
|
|
376
|
+
console.log(` tool approvals ${w.approvals.total} · deny-rate ${pct(w.approvals.denyRate)} · can thiệp ${w.interventions.total} (abort ${w.interventions.aborts} · stop ${w.interventions.stops} · tự hạ ${w.interventions.demotions})`);
|
|
377
|
+
console.log(`24 giờ deny-rate ${pct(d.approvals.denyRate)} · can thiệp ${d.interventions.total}`);
|
|
378
|
+
for (const f of r.factories ?? []) {
|
|
379
|
+
console.log(`${f.id} ${(f.name ?? '?').padEnd(12)} aut ${f.autonomy} can-thiệp 24h ${f.interventions24h} / 7d ${f.interventions7d} merges-7d ${f.merges7d}`);
|
|
380
|
+
}
|
|
381
|
+
console.log('usage ' + JSON.stringify(r.usage));
|
|
382
|
+
} else if (cmd === 'approvals') {
|
|
383
|
+
const r = await rpc('approvals.list');
|
|
384
|
+
if (!r.pending.length) console.error('# không có approval đang chờ');
|
|
385
|
+
for (const a of r.pending) {
|
|
386
|
+
if (a.type === 'merge') {
|
|
387
|
+
// M6a: merge gate — duyệt 'bom-pi approve merge:…' (merge luôn cần người ở mọi autonomy)
|
|
388
|
+
// M6b: kèm verdict reviewer + page để đọc phê trước khi bấm
|
|
389
|
+
console.log(`${a.id}\n merge ${a.branch} → ${a.base} · conv ${a.conversationId}\n ${a.title}${a.summary ? `\n ${a.summary}` : ''}`);
|
|
390
|
+
if (a.review?.verdict) console.log(` review: ${a.review.verdict}${a.review.page ? ` · page ${a.review.page}` : ''}`);
|
|
391
|
+
for (const c of a.commits ?? []) console.log(` ${c}`);
|
|
392
|
+
} else {
|
|
393
|
+
console.log(`${a.id}\n conv ${a.conversationId} · tool ${a.tool}\n $ ${a.command}`);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
} else if (cmd === 'approve' || cmd === 'deny') {
|
|
397
|
+
const id = process.argv[3];
|
|
398
|
+
if (!id) { console.error(`usage: bom-pi ${cmd} <id> — xem approvals`); process.exit(64); }
|
|
399
|
+
checkProtocol(await rpc('hello'));
|
|
400
|
+
pretty(await rpc('approvals.answer', { id, allow: cmd === 'approve' }));
|
|
401
|
+
} else if (cmd === 'schedules') {
|
|
402
|
+
const r = await rpc('schedules.list');
|
|
403
|
+
if (!r.schedules.length) console.error('# không có schedule');
|
|
404
|
+
for (const s of r.schedules) {
|
|
405
|
+
const due = new Date(s.dueMs).toLocaleTimeString();
|
|
406
|
+
console.log(`${s.disabled ? 'off' : 'on '} ${s.id} every ${s.everySec}s next ${due}${s.conversationId ? ` cid ${s.conversationId}` : ''}`);
|
|
407
|
+
console.log(` ${s.prompt}`);
|
|
408
|
+
}
|
|
409
|
+
} else if (cmd === 'schedule') {
|
|
410
|
+
// bom-pi schedule <everySec> <prompt...> — lọc cờ value khỏi prompt
|
|
411
|
+
const VALUE_FLAGS = new Set(['--cid', '--socket', '--model']);
|
|
412
|
+
const raw = process.argv.slice(3);
|
|
413
|
+
const everySec = Number(raw[0]);
|
|
414
|
+
const promptWords = [];
|
|
415
|
+
for (let i = 1; i < raw.length; i++) {
|
|
416
|
+
if (VALUE_FLAGS.has(raw[i])) { i++; continue; }
|
|
417
|
+
promptWords.push(raw[i]);
|
|
418
|
+
}
|
|
419
|
+
const prompt = promptWords.join(' ').trim();
|
|
420
|
+
if (!Number.isFinite(everySec) || !prompt) { console.error('usage: bom-pi schedule <everySec≥10> <prompt...> [--cid N]'); process.exit(64); }
|
|
421
|
+
checkProtocol(await rpc('hello'));
|
|
422
|
+
pretty(await rpc('schedules.add', { everySec, prompt, ...cidParams() }));
|
|
423
|
+
} else if (cmd === 'unschedule') {
|
|
424
|
+
const id = process.argv[3];
|
|
425
|
+
if (!id) { console.error('usage: bom-pi unschedule <id> — xem schedules'); process.exit(64); }
|
|
426
|
+
pretty(await rpc('schedules.remove', { id }));
|
|
427
|
+
} else if (cmd === 'limits') {
|
|
428
|
+
const r = await rpc('limits.list');
|
|
429
|
+
if (!r.limits.length) console.error('# không có gate limit mở');
|
|
430
|
+
for (const l of r.limits) {
|
|
431
|
+
console.log(`${l.openMs > 0 ? 'CLOSED' : 'open '} ${l.key} còn ${Math.round(l.openMs / 1000)}s lần-thử ${l.tries}`);
|
|
432
|
+
}
|
|
433
|
+
} else if (cmd === 'limits-retry') {
|
|
434
|
+
const key = process.argv[3];
|
|
435
|
+
if (!key) { console.error('usage: bom-pi limits-retry <key> — xem limits'); process.exit(64); }
|
|
436
|
+
pretty(await rpc('limits.retry', { key }));
|
|
437
|
+
} else if (cmd === 'abort') {
|
|
438
|
+
checkProtocol(await rpc('hello'));
|
|
439
|
+
pretty(await rpc('session.abort', cidParams()));
|
|
440
|
+
} else if (cmd === 'watch') {
|
|
441
|
+
watch();
|
|
442
|
+
} else if (cmd === 'shutdown') {
|
|
443
|
+
pretty(await rpc('shutdown'));
|
|
444
|
+
} else {
|
|
445
|
+
console.error('usage: bom-pi <hello|status|models|agents|sessions|new|use|submit|reset|transcript|approvals|approve|deny|schedules|schedule|unschedule|factory|limits|abort|watch|shutdown> [--socket PATH] [--cid N]');
|
|
446
|
+
process.exit(64);
|
|
447
|
+
}
|
|
448
|
+
if (cmd !== 'watch') process.exit(0);
|
|
449
|
+
} catch (e) {
|
|
450
|
+
console.error('ERROR:', e.message);
|
|
451
|
+
process.exit(1);
|
|
452
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"__read_me": "Bom factory config (spec M5 §2.2 — docs/superpowers/specs/2026-11-02-tsf-factory-design.md). Fields: name (required, unique per factory dir) · instructions (system prompt of the factory's agent) · model {provider, modelId} optional — daemon default when omitted · cwd optional (relative to this dir) · pagesDir default 'pages' · autonomy L0|L1|L2 default L0 — trust ladder: L0 approves every write/run tool, L1+ only bash; merges always need approval · review {} optional — review gate: a reviewer agent reads the branch diff and writes pages/review-<branch>.md with a verdict before the merge approval (model = review.model or factory model; omit the field to disable) · schedules [{name unique in factory, everySec >= 10, prompt}] cap 10 · watch [{name, glob, debounceSec, prompt}] cap 10 — file triggers activate in M5d. Edit this file (human editor or agent write tool), then run: bom-pi factory sync <dir>. Registry lives with the daemon; this file is the source of truth.",
|
|
3
|
+
"name": "my-factory",
|
|
4
|
+
"instructions": "You are a focused worker agent. Do exactly what the prompt asks. Write reports as markdown pages under pages/. Keep answers short.",
|
|
5
|
+
"autonomy": "L0",
|
|
6
|
+
"schedules": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"__read_me": "Dev factory template (G3/M7) — the factory codes INSIDE its own git repo. `bom-pi factory init <dir> --template dev` auto-runs `git init -b main` if the dir is not a repo yet. Agent workflow: branch → work → commit → factory_propose; a reviewer agent writes pages/review-<branch>.md before the human merge gate (review {} = reviewer on, using this factory's model). Customize model/instructions, then: bom-pi factory sync <dir>.",
|
|
3
|
+
"name": "dev",
|
|
4
|
+
"instructions": "You are the dev agent of a tiny software factory. Your working directory is a git repo — that is your product. Workflow for every change: 1) create a branch (git checkout -b feat-<slug> or fix-<slug>), 2) make the change (prefer the write/edit tools over bash heredocs), 3) commit with a clear message (git add -A; git commit -m '...'), 4) checkout main, 5) call factory_propose with your branch and a one-line title. NEVER commit to main directly. A reviewer will comment on your diff and the operator decides the merge.",
|
|
5
|
+
"model": { "provider": "zai", "modelId": "glm-5.3-flash" },
|
|
6
|
+
"autonomy": "L0",
|
|
7
|
+
"review": {},
|
|
8
|
+
"pagesDir": "pages",
|
|
9
|
+
"watch": [],
|
|
10
|
+
"schedules": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"__read_me": "Docs factory template (G3/M7) — turns source changes into living documentation pages. Watches source files; every meaningful change updates a page under pages/. Point watch globs at your real source tree (relative to this dir), then: bom-pi factory sync <dir>.",
|
|
3
|
+
"name": "docs",
|
|
4
|
+
"instructions": "You are the docs agent of a tiny software factory. On every [watch] prompt: look at which files changed, read them, then update the matching page under pages/ — one page per topic, kebab-case file name, starting with a '# <Topic>' heading, then a short '## What changed' and '## How it works' section. Overwrite the existing page rather than creating endless new ones. Do not touch anything outside pages/.",
|
|
5
|
+
"model": { "provider": "zai", "modelId": "glm-5.3-flash" },
|
|
6
|
+
"autonomy": "L0",
|
|
7
|
+
"pagesDir": "pages",
|
|
8
|
+
"watch": [
|
|
9
|
+
{ "name": "src", "glob": "src/**/*", "debounceSec": 60, "prompt": "Source changed. Update the docs pages for it." }
|
|
10
|
+
],
|
|
11
|
+
"schedules": []
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"__read_me": "Ops factory template (G3/M7) — watches log files and a webhook inbox, keeps pages/status.md fresh, escalates anything that needs a code change to the operator. Triggers: POST http://<host>:8791/api/hook/<factoryId>?id=<uuid> (body = incident text), plus watch on logs/*.log. Point globs at your real logs, then: bom-pi factory sync <dir>.",
|
|
3
|
+
"name": "ops",
|
|
4
|
+
"instructions": "You are the ops agent of a tiny software factory. On every [watch] or [hook] prompt: read what changed, assess severity, then OVERWRITE pages/status.md with a short markdown status board: '# Ops status' heading, '## Now' (current incidents, newest first, each with source and time), '## Recent' (last 5 handled, marked resolved). For anything that clearly needs a CODE change, list it under '## Escalate' for the operator — do not edit code yourself. Do not touch anything else.",
|
|
5
|
+
"model": { "provider": "zai", "modelId": "glm-5.3-flash" },
|
|
6
|
+
"autonomy": "L0",
|
|
7
|
+
"pagesDir": "pages",
|
|
8
|
+
"watch": [
|
|
9
|
+
{ "name": "logs", "glob": "logs/**/*.log", "debounceSec": 30, "prompt": "Log files changed. Scan them and update pages/status.md." }
|
|
10
|
+
],
|
|
11
|
+
"schedules": [
|
|
12
|
+
{ "name": "heartbeat", "everySec": 3600, "prompt": "Heartbeat check: update pages/status.md even if nothing changed." }
|
|
13
|
+
]
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"__read_me": "Triage factory template (spec M5 §7) — scans inbox.md hourly and rewrites pages/report.md. Specialize by editing instructions/schedules, then: bom-pi factory sync <dir>.",
|
|
3
|
+
"name": "triage",
|
|
4
|
+
"instructions": "You are the triage agent of a tiny software factory. When prompted, read inbox.md in your working directory (create an empty one if missing). Classify each item into TODO / DOING / BLOCKED, then OVERWRITE pages/report.md with a short markdown summary: a '# Triage report' heading, one section per status, one bullet per item. Do not touch anything else.",
|
|
5
|
+
"model": { "provider": "zai", "modelId": "glm-5.3-flash" },
|
|
6
|
+
"pagesDir": "pages",
|
|
7
|
+
"schedules": [
|
|
8
|
+
{ "name": "morning-scan", "everySec": 3600, "prompt": "Run the triage scan now: read inbox.md and rewrite pages/report.md." }
|
|
9
|
+
]
|
|
10
|
+
}
|