@yemi33/minions 0.1.86 → 0.1.87
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/CHANGELOG.md +16 -0
- package/engine/consolidation.js +28 -35
- package/engine/dispatch.js +1 -8
- package/engine/lifecycle.js +95 -101
- package/engine/meeting.js +72 -8
- package/engine/playbook.js +21 -11
- package/engine/shared.js +36 -5
- package/engine.js +8 -16
- package/package.json +1 -1
- package/tools/generate-pixel-art.js +134 -0
- package/tools/pixel-robot.bmp +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.87 (2026-04-01)
|
|
4
|
+
|
|
5
|
+
### Engine
|
|
6
|
+
- engine.js
|
|
7
|
+
- engine/consolidation.js
|
|
8
|
+
- engine/dispatch.js
|
|
9
|
+
- engine/lifecycle.js
|
|
10
|
+
- engine/meeting.js
|
|
11
|
+
- engine/playbook.js
|
|
12
|
+
- engine/shared.js
|
|
13
|
+
|
|
14
|
+
### Other
|
|
15
|
+
- test/unit.test.js
|
|
16
|
+
- tools/generate-pixel-art.js
|
|
17
|
+
- tools/pixel-robot.bmp
|
|
18
|
+
|
|
3
19
|
## 0.1.86 (2026-03-31)
|
|
4
20
|
|
|
5
21
|
### Dashboard
|
package/engine/consolidation.js
CHANGED
|
@@ -8,39 +8,32 @@ const fs = require('fs');
|
|
|
8
8
|
const path = require('path');
|
|
9
9
|
const shared = require('./shared');
|
|
10
10
|
const { safeRead, safeWrite, safeUnlink, runFile, cleanChildEnv,
|
|
11
|
-
parseStreamJsonOutput, classifyInboxItem, KB_CATEGORIES } = shared;
|
|
11
|
+
parseStreamJsonOutput, classifyInboxItem, KB_CATEGORIES, log, dateStamp } = shared;
|
|
12
12
|
const { trackEngineUsage } = require('./llm');
|
|
13
13
|
const queries = require('./queries');
|
|
14
14
|
const { getInboxFiles, getNotes, INBOX_DIR, ENGINE_DIR, MINIONS_DIR,
|
|
15
15
|
NOTES_PATH, KNOWLEDGE_DIR, ARCHIVE_DIR } = queries;
|
|
16
16
|
|
|
17
|
-
// Lazy require — only for log() and dateStamp() which live on engine.js
|
|
18
|
-
let _engine = null;
|
|
19
|
-
function engine() {
|
|
20
|
-
if (!_engine) _engine = require('../engine');
|
|
21
|
-
return _engine;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
17
|
// Track in-flight LLM consolidation to prevent concurrent runs
|
|
25
18
|
let _consolidationInFlight = false;
|
|
26
19
|
let _consolidationStartedAt = 0;
|
|
27
20
|
const _processingFiles = new Set(); // files currently being consolidated (race guard)
|
|
28
21
|
|
|
29
22
|
function consolidateInbox(config) {
|
|
30
|
-
|
|
23
|
+
|
|
31
24
|
const { ENGINE_DEFAULTS } = shared;
|
|
32
25
|
const threshold = config.engine?.inboxConsolidateThreshold || ENGINE_DEFAULTS.inboxConsolidateThreshold;
|
|
33
26
|
const files = getInboxFiles().filter(f => !_processingFiles.has(f));
|
|
34
27
|
if (files.length < threshold) return;
|
|
35
28
|
// Auto-reset stale flag if consolidation has been running for >5 minutes (process died without cleanup)
|
|
36
29
|
if (_consolidationInFlight && (Date.now() - _consolidationStartedAt) > 300000) {
|
|
37
|
-
|
|
30
|
+
log('warn', 'Consolidation flag was stale (>5m) — resetting');
|
|
38
31
|
_consolidationInFlight = false;
|
|
39
32
|
_processingFiles.clear();
|
|
40
33
|
}
|
|
41
34
|
if (_consolidationInFlight) return;
|
|
42
35
|
|
|
43
|
-
|
|
36
|
+
log('info', `Consolidating ${files.length} inbox items into notes.md`);
|
|
44
37
|
|
|
45
38
|
const items = files.map(f => ({
|
|
46
39
|
name: f,
|
|
@@ -54,7 +47,7 @@ function consolidateInbox(config) {
|
|
|
54
47
|
// ─── LLM-Powered Consolidation ──────────────────────────────────────────────
|
|
55
48
|
|
|
56
49
|
function buildConsolidationPrompt(items, existingNotes, kbPaths) {
|
|
57
|
-
|
|
50
|
+
|
|
58
51
|
const kbRefBlock = kbPaths.map(p => `- \`${p.file}\` \u2192 \`${p.kbPath}\``).join('\n');
|
|
59
52
|
const notesBlock = items.map(item =>
|
|
60
53
|
`<note file="${item.name}">\n${(item.content || '').slice(0, 8000)}\n</note>`
|
|
@@ -114,11 +107,11 @@ Respond with ONLY the markdown below — no preamble, no explanation, no code fe
|
|
|
114
107
|
|
|
115
108
|
_Processed N notes, M insights extracted, K duplicates removed._
|
|
116
109
|
|
|
117
|
-
Use today's date: ${
|
|
110
|
+
Use today's date: ${dateStamp()}`;
|
|
118
111
|
}
|
|
119
112
|
|
|
120
113
|
function consolidateWithLLM(items, existingNotes, files, config) {
|
|
121
|
-
|
|
114
|
+
|
|
122
115
|
_consolidationInFlight = true;
|
|
123
116
|
_consolidationStartedAt = Date.now();
|
|
124
117
|
for (const f of files) _processingFiles.add(f);
|
|
@@ -129,7 +122,7 @@ function consolidateWithLLM(items, existingNotes, files, config) {
|
|
|
129
122
|
const agent = agentMatch ? agentMatch[1] : 'unknown';
|
|
130
123
|
const titleMatch = (item.content || '').match(/^#\s+(.+)/m);
|
|
131
124
|
const titleSlug = titleMatch ? titleMatch[1].toLowerCase().replace(/[^a-z0-9]+/g, '-').slice(0, 50) : item.name.replace(/\.md$/, '');
|
|
132
|
-
return { file: item.name, category: cat, kbPath: path.join('knowledge', cat, `${
|
|
125
|
+
return { file: item.name, category: cat, kbPath: path.join('knowledge', cat, `${dateStamp()}-${agent}-${titleSlug}.md`) };
|
|
133
126
|
});
|
|
134
127
|
|
|
135
128
|
const prompt = buildConsolidationPrompt(items, existingNotes, kbPaths);
|
|
@@ -152,7 +145,7 @@ function consolidateWithLLM(items, existingNotes, files, config) {
|
|
|
152
145
|
'--verbose',
|
|
153
146
|
];
|
|
154
147
|
|
|
155
|
-
|
|
148
|
+
log('info', 'Spawning Haiku for LLM consolidation...');
|
|
156
149
|
|
|
157
150
|
const proc = runFile(process.execPath, [spawnScript, promptPath, sysPromptPath, ...args], {
|
|
158
151
|
cwd: MINIONS_DIR,
|
|
@@ -166,7 +159,7 @@ function consolidateWithLLM(items, existingNotes, files, config) {
|
|
|
166
159
|
proc.stderr.on('data', d => { stderr += d.toString(); if (stderr.length > 50000) stderr = stderr.slice(-25000); });
|
|
167
160
|
|
|
168
161
|
const timeout = setTimeout(() => {
|
|
169
|
-
|
|
162
|
+
log('warn', 'LLM consolidation timed out after 3m — killing and falling back to regex');
|
|
170
163
|
try { proc.kill('SIGTERM'); } catch { /* process may be dead */ }
|
|
171
164
|
// Escalate to SIGKILL after 10s if process doesn't exit
|
|
172
165
|
setTimeout(() => {
|
|
@@ -174,7 +167,7 @@ function consolidateWithLLM(items, existingNotes, files, config) {
|
|
|
174
167
|
if (_consolidationInFlight) {
|
|
175
168
|
_consolidationInFlight = false;
|
|
176
169
|
_processingFiles.clear();
|
|
177
|
-
|
|
170
|
+
log('warn', 'Consolidation flag force-reset after SIGKILL');
|
|
178
171
|
}
|
|
179
172
|
}, 10000);
|
|
180
173
|
}, 180000);
|
|
@@ -202,7 +195,7 @@ function consolidateWithLLM(items, existingNotes, files, config) {
|
|
|
202
195
|
if (sectionIdx >= 0) {
|
|
203
196
|
digest = digest.slice(sectionIdx);
|
|
204
197
|
} else {
|
|
205
|
-
|
|
198
|
+
log('warn', 'LLM consolidation output missing expected format — falling back to regex');
|
|
206
199
|
consolidateWithRegex(items, files);
|
|
207
200
|
_clearProcessingState();
|
|
208
201
|
return;
|
|
@@ -219,17 +212,17 @@ function consolidateWithLLM(items, existingNotes, files, config) {
|
|
|
219
212
|
const header = sections[0];
|
|
220
213
|
const recent = sections.slice(-8);
|
|
221
214
|
newContent = header + '\n---\n\n### ' + recent.join('\n---\n\n### ');
|
|
222
|
-
|
|
215
|
+
log('info', `Pruned notes.md: removed ${sections.length - 9} old sections`);
|
|
223
216
|
}
|
|
224
217
|
}
|
|
225
218
|
|
|
226
219
|
safeWrite(NOTES_PATH, newContent);
|
|
227
220
|
classifyToKnowledgeBase(items);
|
|
228
221
|
archiveInboxFiles(files);
|
|
229
|
-
|
|
222
|
+
log('info', `LLM consolidation complete: ${files.length} notes processed by Haiku`);
|
|
230
223
|
} else {
|
|
231
|
-
|
|
232
|
-
if (stderr)
|
|
224
|
+
log('warn', `LLM consolidation failed (code=${code}) — falling back to regex`);
|
|
225
|
+
if (stderr) log('debug', `LLM stderr: ${stderr.slice(0, 500)}`);
|
|
233
226
|
consolidateWithRegex(items, files);
|
|
234
227
|
}
|
|
235
228
|
_clearProcessingState();
|
|
@@ -237,7 +230,7 @@ function consolidateWithLLM(items, existingNotes, files, config) {
|
|
|
237
230
|
|
|
238
231
|
proc.on('error', (err) => {
|
|
239
232
|
clearTimeout(timeout);
|
|
240
|
-
|
|
233
|
+
log('warn', `LLM consolidation spawn error: ${err.message} — falling back to regex`);
|
|
241
234
|
safeUnlink(promptPath);
|
|
242
235
|
safeUnlink(sysPromptPath);
|
|
243
236
|
consolidateWithRegex(items, files);
|
|
@@ -248,7 +241,7 @@ function consolidateWithLLM(items, existingNotes, files, config) {
|
|
|
248
241
|
// ─── Regex Fallback Consolidation ────────────────────────────────────────────
|
|
249
242
|
|
|
250
243
|
function consolidateWithRegex(items, files) {
|
|
251
|
-
|
|
244
|
+
|
|
252
245
|
const allInsights = [];
|
|
253
246
|
for (const item of items) {
|
|
254
247
|
const content = item.content || '';
|
|
@@ -327,7 +320,7 @@ function consolidateWithRegex(items, files) {
|
|
|
327
320
|
const grouped = {};
|
|
328
321
|
for (const item of deduped) { if (!grouped[item.category]) grouped[item.category] = []; grouped[item.category].push(item); }
|
|
329
322
|
|
|
330
|
-
let entry = `\n\n---\n\n### ${
|
|
323
|
+
let entry = `\n\n---\n\n### ${dateStamp()}: ${title}\n`;
|
|
331
324
|
entry += '**By:** Engine (regex fallback)\n\n';
|
|
332
325
|
for (const [cat, catItems] of Object.entries(grouped)) {
|
|
333
326
|
entry += `#### ${catLabels[cat] || cat} (${catItems.length})\n`;
|
|
@@ -349,13 +342,13 @@ function consolidateWithRegex(items, files) {
|
|
|
349
342
|
safeWrite(NOTES_PATH, newContent);
|
|
350
343
|
classifyToKnowledgeBase(items);
|
|
351
344
|
archiveInboxFiles(files);
|
|
352
|
-
|
|
345
|
+
log('info', `Regex fallback: consolidated ${files.length} notes \u2192 ${deduped.length} insights into notes.md`);
|
|
353
346
|
}
|
|
354
347
|
|
|
355
348
|
// ─── Knowledge Base Classification ───────────────────────────────────────────
|
|
356
349
|
|
|
357
350
|
function classifyToKnowledgeBase(items) {
|
|
358
|
-
|
|
351
|
+
|
|
359
352
|
if (!fs.existsSync(KNOWLEDGE_DIR)) fs.mkdirSync(KNOWLEDGE_DIR, { recursive: true });
|
|
360
353
|
|
|
361
354
|
const categoryDirs = {};
|
|
@@ -375,20 +368,20 @@ function classifyToKnowledgeBase(items) {
|
|
|
375
368
|
const titleSlug = titleMatch
|
|
376
369
|
? titleMatch[1].toLowerCase().replace(/[^a-z0-9]+/g, '-').slice(0, 50)
|
|
377
370
|
: item.name.replace(/\.md$/, '');
|
|
378
|
-
const kbFilename = `${
|
|
371
|
+
const kbFilename = `${dateStamp()}-${agent}-${titleSlug}.md`;
|
|
379
372
|
const kbPath = shared.uniquePath(path.join(categoryDirs[category], kbFilename));
|
|
380
373
|
|
|
381
|
-
const frontmatter = `---\nsource: ${item.name}\nagent: ${agent}\ncategory: ${category}\ndate: ${
|
|
374
|
+
const frontmatter = `---\nsource: ${item.name}\nagent: ${agent}\ncategory: ${category}\ndate: ${dateStamp()}\n---\n\n`;
|
|
382
375
|
try {
|
|
383
376
|
safeWrite(kbPath, frontmatter + content);
|
|
384
377
|
classified++;
|
|
385
378
|
} catch (err) {
|
|
386
|
-
|
|
379
|
+
log('warn', `Failed to classify ${item.name} to knowledge base: ${err.message}`);
|
|
387
380
|
}
|
|
388
381
|
}
|
|
389
382
|
|
|
390
383
|
if (classified > 0) {
|
|
391
|
-
|
|
384
|
+
log('info', `Knowledge base: classified ${classified} note(s) into knowledge/`);
|
|
392
385
|
}
|
|
393
386
|
|
|
394
387
|
// Save KB file count checkpoint so the watchdog can detect unexpected deletions
|
|
@@ -399,14 +392,14 @@ function classifyToKnowledgeBase(items) {
|
|
|
399
392
|
if (fs.existsSync(dir)) count += fs.readdirSync(dir).length;
|
|
400
393
|
}
|
|
401
394
|
safeWrite(path.join(ENGINE_DIR, 'kb-checkpoint.json'), JSON.stringify({ count, updatedAt: new Date().toISOString() }));
|
|
402
|
-
} catch (err) {
|
|
395
|
+
} catch (err) { log('warn', `KB checkpoint: ${err.message}`); }
|
|
403
396
|
}
|
|
404
397
|
|
|
405
398
|
function archiveInboxFiles(files) {
|
|
406
|
-
|
|
399
|
+
|
|
407
400
|
if (!fs.existsSync(ARCHIVE_DIR)) fs.mkdirSync(ARCHIVE_DIR, { recursive: true });
|
|
408
401
|
for (const f of files) {
|
|
409
|
-
try { fs.renameSync(path.join(INBOX_DIR, f), shared.uniquePath(path.join(ARCHIVE_DIR, `${
|
|
402
|
+
try { fs.renameSync(path.join(INBOX_DIR, f), shared.uniquePath(path.join(ARCHIVE_DIR, `${dateStamp()}-${f}`))); } catch (err) { log('warn', `Inbox archive: ${err.message}`); }
|
|
410
403
|
}
|
|
411
404
|
}
|
|
412
405
|
|
package/engine/dispatch.js
CHANGED
|
@@ -10,7 +10,7 @@ const queries = require('./queries');
|
|
|
10
10
|
const { setCooldownFailure } = require('./cooldown');
|
|
11
11
|
|
|
12
12
|
const { safeJson, safeWrite, safeReadDir, mutateJsonFileLocked,
|
|
13
|
-
getProjects, projectWorkItemsPath } = shared;
|
|
13
|
+
getProjects, projectWorkItemsPath, log, ts, dateStamp } = shared;
|
|
14
14
|
const { getConfig, getDispatch, DISPATCH_PATH, INBOX_DIR } = queries;
|
|
15
15
|
|
|
16
16
|
const MINIONS_DIR = shared.MINIONS_DIR;
|
|
@@ -19,13 +19,6 @@ const MINIONS_DIR = shared.MINIONS_DIR;
|
|
|
19
19
|
let _lifecycle = null;
|
|
20
20
|
function lifecycle() { if (!_lifecycle) _lifecycle = require('./lifecycle'); return _lifecycle; }
|
|
21
21
|
|
|
22
|
-
// ─── Engine utilities (lazy require to avoid circular deps) ──────────────────
|
|
23
|
-
let _engine = null;
|
|
24
|
-
function engine() { if (!_engine) _engine = require('../engine'); return _engine; }
|
|
25
|
-
function log(level, msg, meta) { return engine().log(level, msg, meta); }
|
|
26
|
-
function ts() { return engine().ts(); }
|
|
27
|
-
function dateStamp() { return new Date().toISOString().slice(0, 10); }
|
|
28
|
-
|
|
29
22
|
// ─── Dispatch Mutation ───────────────────────────────────────────────────────
|
|
30
23
|
|
|
31
24
|
function mutateDispatch(mutator) {
|