@geraldmaron/construct 1.0.12 → 1.0.14
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 +8 -2
- package/bin/construct +259 -11
- package/bin/construct-postinstall.mjs +23 -2
- package/lib/auto-docs.mjs +11 -7
- package/lib/dashboard-static.mjs +7 -4
- package/lib/doc-stamp.mjs +16 -0
- package/lib/docs-verify.mjs +1 -8
- package/lib/doctor/watchers/bd-watch.mjs +6 -2
- package/lib/embed/daemon.mjs +20 -0
- package/lib/embed/docs-lifecycle.mjs +19 -0
- package/lib/embed/inbox.mjs +85 -2
- package/lib/embed/recommendation-store.mjs +29 -0
- package/lib/gates-audit.mjs +18 -12
- package/lib/hooks/_lib/input.mjs +52 -0
- package/lib/hooks/adaptive-lint.mjs +4 -0
- package/lib/hooks/agent-tracker.mjs +59 -15
- package/lib/hooks/audit-reads.mjs +83 -42
- package/lib/hooks/audit-trail.mjs +28 -18
- package/lib/hooks/bash-output-logger.mjs +8 -2
- package/lib/hooks/block-no-verify.mjs +4 -0
- package/lib/hooks/ci-status-check.mjs +4 -0
- package/lib/hooks/comment-lint.mjs +6 -4
- package/lib/hooks/config-protection.mjs +4 -0
- package/lib/hooks/context-watch.mjs +4 -0
- package/lib/hooks/context-window-recovery.mjs +4 -0
- package/lib/hooks/dep-audit.mjs +12 -5
- package/lib/hooks/doc-coupling-check.mjs +5 -1
- package/lib/hooks/edit-accumulator.mjs +25 -10
- package/lib/hooks/edit-error-recovery.mjs +4 -0
- package/lib/hooks/edit-guard.mjs +4 -0
- package/lib/hooks/guard-bash.mjs +4 -0
- package/lib/hooks/mcp-audit.mjs +4 -0
- package/lib/hooks/mcp-health-check.mjs +4 -0
- package/lib/hooks/model-fallback.mjs +7 -11
- package/lib/hooks/policy-engine.mjs +4 -0
- package/lib/hooks/post-merge-docs-check.mjs +4 -0
- package/lib/hooks/post-merge-tracking.mjs +82 -0
- package/lib/hooks/pre-compact.mjs +4 -0
- package/lib/hooks/pre-push-gate.mjs +84 -231
- package/lib/hooks/proactive-activation.mjs +5 -2
- package/lib/hooks/readme-age-check.mjs +4 -0
- package/lib/hooks/registry-sync.mjs +35 -20
- package/lib/hooks/rule-verifier.mjs +3 -0
- package/lib/hooks/scan-secrets.mjs +4 -0
- package/lib/hooks/session-optimize.mjs +4 -0
- package/lib/hooks/session-reflect.mjs +4 -0
- package/lib/hooks/session-start.mjs +48 -1
- package/lib/hooks/session-tracking-refresh.mjs +70 -0
- package/lib/hooks/stop-notify.mjs +13 -2
- package/lib/hooks/stop-typecheck.mjs +4 -0
- package/lib/hooks/test-watch.mjs +8 -4
- package/lib/init-unified.mjs +90 -23
- package/lib/intake/attribution.mjs +77 -0
- package/lib/intake/intake-config.mjs +3 -0
- package/lib/intake/manifest.mjs +107 -0
- package/lib/intake/poll-lock.mjs +136 -0
- package/lib/intake/prepare.mjs +42 -4
- package/lib/logging/rotate.mjs +394 -0
- package/lib/mcp/tools/project.mjs +2 -2
- package/lib/mcp/tools/telemetry.mjs +1 -1
- package/lib/opencode-config.mjs +10 -3
- package/lib/orchestration/routing-tables.mjs +176 -0
- package/lib/orchestration-policy.mjs +18 -106
- package/lib/parity.mjs +48 -7
- package/lib/profiles/lifecycle.mjs +19 -1
- package/lib/project-init-shared.mjs +11 -5
- package/lib/project-root.mjs +104 -0
- package/lib/roles/catalog.mjs +1 -1
- package/lib/roles/event-bus.mjs +29 -9
- package/lib/roles/router.mjs +8 -7
- package/lib/server/index.mjs +31 -9
- package/lib/server/static/index.html +1 -15
- package/lib/specialist-contracts-enforce.mjs +24 -10
- package/lib/status.mjs +1 -1
- package/lib/storage/backup.mjs +2 -2
- package/lib/telemetry/intent-verifications.mjs +16 -3
- package/lib/telemetry/skill-calls.mjs +12 -3
- package/lib/tracking-surfaces.mjs +375 -0
- package/lib/worker/trace.mjs +19 -2
- package/package.json +6 -2
- package/platforms/claude/settings.template.json +28 -27
- package/scripts/sync-specialists.mjs +269 -75
- package/specialists/registry.json +158 -13
- package/lib/hooks/env-check.mjs +0 -83
- package/lib/hooks/read-tracker.mjs +0 -61
- package/lib/policy/unified-gates.mjs +0 -96
- package/lib/server/static/assets/index-ab25c707.js +0 -70
- package/lib/server/static/assets/index-f0c80a2b.css +0 -1
package/README.md
CHANGED
|
@@ -93,6 +93,12 @@ Every code mutation runs through enforcement. No secrets committed, tests green,
|
|
|
93
93
|
|
|
94
94
|
Construct gets smarter on its own. Every session ends with an automatic capture: tools used, files touched, what the final reply said. That goes into `.cx/observations/` and is searchable from the next session. See [`docs/concepts/learning-loops.mdx`](./docs/concepts/learning-loops.mdx) for what's wired, what's coming, and how to turn pieces off.
|
|
95
95
|
|
|
96
|
+
## `.cx/` is local-only runtime state
|
|
97
|
+
|
|
98
|
+
`construct init` writes a runtime state tree at `.cx/` inside the project root: observations, sessions, vector index, intake packets, task graphs, and traces. **It's local-only and must never be committed.** `construct init` adds `.cx/` to your project's `.gitignore` automatically (idempotent: it won't double-add if you already have it). Daily trace shards (`.cx/traces/<date>.jsonl`) cap at 100 MB and rotate to `<date>.<n>.jsonl` so a stray commit never crosses GitHub's single-file limit. Override the cap with `CONSTRUCT_TRACE_MAX_MB`.
|
|
99
|
+
|
|
100
|
+
The embed daemon writes its supervisor stdout log to `~/.cx/runtime/embed-daemon.log`. That log rotates every minute at 50 MB and keeps 5 gzipped segments by default; override via `CONSTRUCT_EMBED_LOG_MAX_MB` and `CONSTRUCT_EMBED_LOG_MAX_SEGMENTS`.
|
|
101
|
+
|
|
96
102
|
## Core commands
|
|
97
103
|
|
|
98
104
|
<!-- AUTO:commands -->
|
|
@@ -215,16 +221,16 @@ Construct gets smarter on its own. Every session ends with an automatic capture:
|
|
|
215
221
|
<!-- AUTO:structure -->
|
|
216
222
|
```text
|
|
217
223
|
construct/
|
|
218
|
-
├── apps User-facing apps shipped from this repo (e.g. apps/docs/, the
|
|
224
|
+
├── apps User-facing apps shipped from this repo (e.g. apps/docs/, the Next.js docs site)
|
|
219
225
|
├── bin CLI entrypoint (`construct`)
|
|
220
226
|
├── commands Command prompt assets
|
|
221
227
|
├── config
|
|
222
|
-
├── dashboard
|
|
223
228
|
├── db
|
|
224
229
|
├── deploy
|
|
225
230
|
├── docs Architecture notes, runbooks, and documentation contract
|
|
226
231
|
├── examples
|
|
227
232
|
├── lib Core runtime: CLI, hooks, MCP, status, sync, workflow
|
|
233
|
+
├── packages
|
|
228
234
|
├── personas Persona prompt definitions
|
|
229
235
|
├── platforms
|
|
230
236
|
├── profiles
|
package/bin/construct
CHANGED
|
@@ -416,11 +416,190 @@ async function cmdDoctor() {
|
|
|
416
416
|
return;
|
|
417
417
|
}
|
|
418
418
|
|
|
419
|
+
// --fix-* flags drive auto-remediation for legacy state left behind by
|
|
420
|
+
// pre-2.0 installs. Layer-2 update triggers (npm i -g postinstall, brew
|
|
421
|
+
// upgrade) normally handle this; --fix-* is the manual recovery path.
|
|
422
|
+
// --fix-all runs every available fix.
|
|
423
|
+
|
|
424
|
+
const wantsFixAll = args.includes('--fix-all') || args.includes('--fix');
|
|
425
|
+
const wantsFixGitignore = wantsFixAll || args.includes('--fix-gitignore');
|
|
426
|
+
const wantsFixLegacyAgents = wantsFixAll || args.includes('--fix-legacy-agents');
|
|
427
|
+
const wantsFixEmbedLog = wantsFixAll || args.includes('--fix-embed-log');
|
|
428
|
+
const wantsFixMigrateState = wantsFixAll || args.includes('--fix-migrate-state');
|
|
429
|
+
|
|
419
430
|
const checks = [];
|
|
420
431
|
const add = (label, pass, optional = false) => checks.push({ label, pass, optional });
|
|
421
432
|
add('registry.json exists', fs.existsSync(path.join(ROOT_DIR, 'specialists', 'registry.json')));
|
|
422
433
|
add('sync-specialists.mjs exists', fs.existsSync(path.join(ROOT_DIR, 'scripts', 'sync-specialists.mjs')));
|
|
423
434
|
|
|
435
|
+
// Dashboard static build output. The Next.js app under apps/dashboard
|
|
436
|
+
// emits a static export into lib/server/static/ via its postbuild script;
|
|
437
|
+
// an empty static dir means lib/server/index.mjs will serve 404s.
|
|
438
|
+
|
|
439
|
+
const dashboardIndex = path.join(ROOT_DIR, 'lib', 'server', 'static', 'index.html');
|
|
440
|
+
add('Dashboard built (lib/server/static/index.html)', fs.existsSync(dashboardIndex));
|
|
441
|
+
|
|
442
|
+
// Project .gitignore must cover .cx/. Auto-fix via --fix-gitignore.
|
|
443
|
+
// Only checks when cwd looks like a Construct project (has .cx/ or
|
|
444
|
+
// .construct/); non-project cwds get no warning.
|
|
445
|
+
|
|
446
|
+
const cwd = process.cwd();
|
|
447
|
+
const isProject = fs.existsSync(path.join(cwd, '.cx')) || fs.existsSync(path.join(cwd, '.construct'));
|
|
448
|
+
if (isProject) {
|
|
449
|
+
const giPath = path.join(cwd, '.gitignore');
|
|
450
|
+
const giContent = fs.existsSync(giPath) ? fs.readFileSync(giPath, 'utf8') : '';
|
|
451
|
+
const lines = giContent.split('\n').map((l) => l.trim());
|
|
452
|
+
const cxIgnored = lines.some((l) => l === '.cx' || l === '.cx/' || l === '.cx/**' || l === '*' || l === '**');
|
|
453
|
+
if (!cxIgnored && wantsFixGitignore) {
|
|
454
|
+
const prefix = giContent.length === 0 || giContent.endsWith('\n') ? '' : '\n';
|
|
455
|
+
fs.writeFileSync(giPath, giContent + `${prefix}\n# Construct runtime state — local-only, never source\n.cx/\n`, 'utf8');
|
|
456
|
+
println(` fix: appended .cx/ to ${path.relative(cwd, giPath)}`);
|
|
457
|
+
add('Project .gitignore covers .cx/', true);
|
|
458
|
+
} else {
|
|
459
|
+
add('Project .gitignore covers .cx/' + (cxIgnored ? '' : ' (run `construct doctor --fix-gitignore` to add)'), cxIgnored);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// Legacy cx-* files at user scope. Layer-2 (npm postinstall, brew
|
|
464
|
+
// upgrade) sweeps these via `construct sync --global`; this check is
|
|
465
|
+
// the manual safety net. Counts files matching a registered specialist
|
|
466
|
+
// name across Claude / Codex / Copilot user-scope dirs.
|
|
467
|
+
|
|
468
|
+
const userHome = HOME;
|
|
469
|
+
const registry = JSON.parse(fs.readFileSync(path.join(ROOT_DIR, 'specialists', 'registry.json'), 'utf8'));
|
|
470
|
+
const specialistSet = new Set((registry.specialists ?? []).map((s) => `cx-${s.name}`));
|
|
471
|
+
const legacyTargets = [
|
|
472
|
+
{ dir: path.join(userHome, '.claude', 'agents'), ext: '.md' },
|
|
473
|
+
{ dir: path.join(userHome, '.codex', 'agents'), ext: '.toml' },
|
|
474
|
+
{ dir: path.join(userHome, '.github', 'prompts'), ext: '.prompt.md' },
|
|
475
|
+
];
|
|
476
|
+
let legacyCount = 0;
|
|
477
|
+
for (const t of legacyTargets) {
|
|
478
|
+
if (!fs.existsSync(t.dir)) continue;
|
|
479
|
+
for (const f of fs.readdirSync(t.dir)) {
|
|
480
|
+
if (!f.endsWith(t.ext)) continue;
|
|
481
|
+
const base = f.slice(0, -t.ext.length);
|
|
482
|
+
if (specialistSet.has(base)) legacyCount++;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
if (legacyCount > 0 && wantsFixLegacyAgents) {
|
|
486
|
+
const syncScript = path.join(ROOT_DIR, 'scripts', 'sync-specialists.mjs');
|
|
487
|
+
const result = spawnSync(process.execPath, [syncScript, '--global'], { stdio: 'pipe', encoding: 'utf8' });
|
|
488
|
+
if (result.status === 0) {
|
|
489
|
+
println(` fix: swept ${legacyCount} legacy cx-* file(s) from user scope via construct sync --global`);
|
|
490
|
+
add('No legacy cx-* files at user scope', true);
|
|
491
|
+
} else {
|
|
492
|
+
add(`Legacy cx-* sweep failed: ${result.stderr?.substring(0, 200)}`, false);
|
|
493
|
+
}
|
|
494
|
+
} else {
|
|
495
|
+
// Soft-warn instead of hard-fail: legacy v1.0.10 cx-* files are an
|
|
496
|
+
// expected upgrade-state, not real drift. The hint is what matters;
|
|
497
|
+
// the fix is one --fix-legacy-agents run away and CI never sees this.
|
|
498
|
+
// Mirrors the parity check's legacy-install reclassification.
|
|
499
|
+
|
|
500
|
+
add(
|
|
501
|
+
legacyCount === 0
|
|
502
|
+
? 'No legacy cx-* files at user scope'
|
|
503
|
+
: `Legacy cx-* files at user scope: ${legacyCount} (run \`construct doctor --fix-legacy-agents\` to sweep)`,
|
|
504
|
+
true,
|
|
505
|
+
legacyCount !== 0,
|
|
506
|
+
);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// Pre-push bypass frequency. Every honored CONSTRUCT_SKIP_PREPUSH /
|
|
510
|
+
// CONSTRUCT_ALLOW_CLAUDE_PUSH / CONSTRUCT_SKIP_PR_LINT writes a JSONL
|
|
511
|
+
// entry to ~/.construct/audit/prepush-bypass.log. Surfacing frequent
|
|
512
|
+
// usage here is the early warning that the gate is the wrong shape —
|
|
513
|
+
// the alternative is letting the bypass quietly become the default.
|
|
514
|
+
|
|
515
|
+
const bypassLogPath = path.join(userHome, '.construct', 'audit', 'prepush-bypass.log');
|
|
516
|
+
if (fs.existsSync(bypassLogPath)) {
|
|
517
|
+
try {
|
|
518
|
+
const cutoff = Date.now() - 7 * 24 * 60 * 60 * 1000;
|
|
519
|
+
const recent = fs.readFileSync(bypassLogPath, 'utf8')
|
|
520
|
+
.split('\n')
|
|
521
|
+
.filter(Boolean)
|
|
522
|
+
.map((line) => { try { return JSON.parse(line); } catch { return null; } })
|
|
523
|
+
.filter((e) => e && Date.parse(e.ts) >= cutoff);
|
|
524
|
+
const BYPASS_WARN_THRESHOLD = Number(process.env.CONSTRUCT_DOCTOR_BYPASS_WARN) || 3;
|
|
525
|
+
if (recent.length >= BYPASS_WARN_THRESHOLD) {
|
|
526
|
+
add(
|
|
527
|
+
`Pre-push bypasses in last 7 days: ${recent.length} (gate may be wrong-sized — see ${bypassLogPath})`,
|
|
528
|
+
false,
|
|
529
|
+
true,
|
|
530
|
+
);
|
|
531
|
+
} else {
|
|
532
|
+
add(`Pre-push bypasses in last 7 days: ${recent.length}`, true);
|
|
533
|
+
}
|
|
534
|
+
} catch { /* audit log read is best-effort */ }
|
|
535
|
+
} else {
|
|
536
|
+
add('Pre-push bypass log not present (no bypasses honored yet)', true);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// Embed daemon log size. The daemon's own scheduler rotates every
|
|
540
|
+
// minute at 50MB, but a freshly-upgraded install with a 34GB legacy
|
|
541
|
+
// log shouldn't wait 60s. --fix-embed-log forces rotation now.
|
|
542
|
+
|
|
543
|
+
const embedLogPath = path.join(userHome, '.cx', 'runtime', 'embed-daemon.log');
|
|
544
|
+
if (fs.existsSync(embedLogPath)) {
|
|
545
|
+
const sizeMb = fs.statSync(embedLogPath).size / 1024 / 1024;
|
|
546
|
+
const FORCE_THRESHOLD_MB = Number(process.env.CONSTRUCT_DOCTOR_EMBED_LOG_FORCE_MB) || 500;
|
|
547
|
+
if (sizeMb > FORCE_THRESHOLD_MB && wantsFixEmbedLog) {
|
|
548
|
+
const { rotateIfOversized } = await import('../lib/logging/rotate.mjs');
|
|
549
|
+
println(` fix: rotating ${sizeMb.toFixed(0)}MB embed-daemon.log (gzipping may take a moment)…`);
|
|
550
|
+
const start = Date.now();
|
|
551
|
+
const seg = await rotateIfOversized(embedLogPath, { maxBytes: 1, maxSegments: 5, gzip: true });
|
|
552
|
+
const elapsed = ((Date.now() - start) / 1000).toFixed(0);
|
|
553
|
+
println(` fix: rotated to ${path.basename(seg)} in ${elapsed}s`);
|
|
554
|
+
add('Embed daemon log size sane', true);
|
|
555
|
+
} else {
|
|
556
|
+
const label = sizeMb > FORCE_THRESHOLD_MB
|
|
557
|
+
? `Embed daemon log oversized: ${sizeMb.toFixed(0)}MB (run \`construct doctor --fix-embed-log\` to rotate now)`
|
|
558
|
+
: `Embed daemon log size: ${sizeMb.toFixed(1)}MB`;
|
|
559
|
+
add(label, sizeMb <= FORCE_THRESHOLD_MB);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// Legacy ~/.cx/<project-scoped>.jsonl files left over from before the
|
|
564
|
+
// cross-project state isolation refactor. Four files moved from user
|
|
565
|
+
// scope to <project>/.cx/: contract-violations, audit-reads, agent-log,
|
|
566
|
+
// intent-verifications. Pre-refactor data still sits at ~/.cx/ where it
|
|
567
|
+
// mixed every project together. --fix-migrate-state archives them to
|
|
568
|
+
// ~/.cx/legacy/<name>.<ts>.jsonl so the new writers start fresh; the
|
|
569
|
+
// legacy data stays readable for forensics.
|
|
570
|
+
|
|
571
|
+
const projectScopedNames = [
|
|
572
|
+
'contract-violations.jsonl',
|
|
573
|
+
'audit-reads.jsonl',
|
|
574
|
+
'agent-log.jsonl',
|
|
575
|
+
'intent-verifications.jsonl',
|
|
576
|
+
];
|
|
577
|
+
const legacyState = projectScopedNames
|
|
578
|
+
.map((name) => ({ name, path: path.join(userHome, '.cx', name) }))
|
|
579
|
+
.filter((p) => fs.existsSync(p.path) && fs.statSync(p.path).size > 0);
|
|
580
|
+
|
|
581
|
+
if (legacyState.length > 0 && wantsFixMigrateState) {
|
|
582
|
+
const archiveDir = path.join(userHome, '.cx', 'legacy');
|
|
583
|
+
fs.mkdirSync(archiveDir, { recursive: true });
|
|
584
|
+
const ts = new Date().toISOString().replace(/[:.]/g, '-');
|
|
585
|
+
const moved = [];
|
|
586
|
+
for (const { name, path: src } of legacyState) {
|
|
587
|
+
const dest = path.join(archiveDir, `${name.replace('.jsonl', '')}.${ts}.jsonl`);
|
|
588
|
+
fs.renameSync(src, dest);
|
|
589
|
+
moved.push(path.basename(dest));
|
|
590
|
+
}
|
|
591
|
+
println(` fix: archived ${moved.length} legacy user-scope file(s) to ~/.cx/legacy/`);
|
|
592
|
+
for (const m of moved) println(` → ${m}`);
|
|
593
|
+
add('No legacy user-scope project-state files', true);
|
|
594
|
+
} else {
|
|
595
|
+
add(
|
|
596
|
+
legacyState.length === 0
|
|
597
|
+
? 'No legacy user-scope project-state files'
|
|
598
|
+
: `Legacy user-scope project-state files: ${legacyState.length} (run \`construct doctor --fix-migrate-state\` to archive)`,
|
|
599
|
+
legacyState.length === 0,
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
|
|
424
603
|
// Tier model selection. Construct ships with no default — at least
|
|
425
604
|
// one tier must be configured (registry.json primary OR CX_MODEL_*
|
|
426
605
|
// env override) before any LLM-backed workflow can run.
|
|
@@ -704,7 +883,11 @@ async function cmdDoctor() {
|
|
|
704
883
|
try {
|
|
705
884
|
const { checkParity } = await import('../lib/parity.mjs');
|
|
706
885
|
const parity = checkParity({ rootDir: ROOT_DIR, homeDir: HOME });
|
|
707
|
-
|
|
886
|
+
// Legacy-install rolls up to ok (so the gate doesn't hard-fail during
|
|
887
|
+
// a v1.0.10 → v1.0.13+ upgrade) but renders as a warning so the
|
|
888
|
+
// --fix-legacy-agents hint stays visible.
|
|
889
|
+
const hasLegacy = parity.surfaces.some((s) => s.status === 'legacy-install');
|
|
890
|
+
add(`Cross-surface adapter parity (${parity.summary.join(' · ')})`, parity.ok, hasLegacy);
|
|
708
891
|
} catch {
|
|
709
892
|
add('Cross-surface adapter parity', false);
|
|
710
893
|
}
|
|
@@ -1643,6 +1826,10 @@ async function printIntakeHelp() {
|
|
|
1643
1826
|
println(' construct intake done <id> [--notes=…] [--output=<path>] [--no-output=<rejected|deferred|merged>]');
|
|
1644
1827
|
println(' Mark a pending packet processed. --output stamps intake_id + confidence into the artifact frontmatter (provenance).');
|
|
1645
1828
|
println(' construct intake skip <id> [--reason=…] Mark a pending packet skipped (preserves audit trail).');
|
|
1829
|
+
println(' construct intake process [--dry-run] [--wait[=<sec>]]');
|
|
1830
|
+
println(' One-shot inbox sweep — same logic the daemon runs, exits when the queue is empty.');
|
|
1831
|
+
println(' Concurrency is controlled by a poll lock — fail-fast by default, --wait[=<sec>] blocks for up to N seconds.');
|
|
1832
|
+
println(' --dry-run lists candidate inboxes without ingesting.');
|
|
1646
1833
|
println(' construct intake reopen <id> Move a processed or skipped packet back to pending.');
|
|
1647
1834
|
println(' construct intake quarantine list List packets held for human review (low confidence or close margin).');
|
|
1648
1835
|
println(' construct intake quarantine show <id> Show a quarantined packet with top-3 candidate types and margins.');
|
|
@@ -1910,6 +2097,10 @@ async function cmdIntake(args) {
|
|
|
1910
2097
|
return await cmdIntakeIntegrate(id, args.slice(2), cwd);
|
|
1911
2098
|
}
|
|
1912
2099
|
|
|
2100
|
+
if (sub === 'process') {
|
|
2101
|
+
return await cmdIntakeProcess(args.slice(1), cwd);
|
|
2102
|
+
}
|
|
2103
|
+
|
|
1913
2104
|
if (sub === 'config') {
|
|
1914
2105
|
return await cmdIntakeConfig(args.slice(1));
|
|
1915
2106
|
}
|
|
@@ -1922,10 +2113,75 @@ async function cmdIntake(args) {
|
|
|
1922
2113
|
return await cmdIntakeNeedsAsr(args.slice(1));
|
|
1923
2114
|
}
|
|
1924
2115
|
|
|
1925
|
-
errorln(`Unknown intake subcommand: ${sub}. Available: list, show, done, skip, reopen, quarantine, reroute, integrate, config, extraction-warnings, needs-asr`);
|
|
2116
|
+
errorln(`Unknown intake subcommand: ${sub}. Available: list, show, done, skip, reopen, process, quarantine, reroute, integrate, config, extraction-warnings, needs-asr`);
|
|
1926
2117
|
process.exit(1);
|
|
1927
2118
|
}
|
|
1928
2119
|
|
|
2120
|
+
async function cmdIntakeProcess(args, cwd) {
|
|
2121
|
+
const dryRun = args.includes('--dry-run');
|
|
2122
|
+
const waitFlag = args.find((a) => a === '--wait' || a.startsWith('--wait='));
|
|
2123
|
+
const { InboxWatcher, resolveInboxDirs } = await import('../lib/embed/inbox.mjs');
|
|
2124
|
+
|
|
2125
|
+
if (dryRun) {
|
|
2126
|
+
const dirs = resolveInboxDirs(cwd, process.env);
|
|
2127
|
+
if (dirs.length === 0) {
|
|
2128
|
+
println('No inbox directories configured. Run `construct intake config` to add one.');
|
|
2129
|
+
return;
|
|
2130
|
+
}
|
|
2131
|
+
println('Would scan:');
|
|
2132
|
+
for (const d of dirs) println(` ${d}`);
|
|
2133
|
+
println('');
|
|
2134
|
+
println('(dry-run — no files processed; re-run without --dry-run to actually ingest.)');
|
|
2135
|
+
return;
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
// Concurrency is controlled by the intake poll lock inside
|
|
2139
|
+
// InboxWatcher.poll. Default behavior is fail-fast: if the daemon (or
|
|
2140
|
+
// another CLI invocation) is mid-poll, raise an actionable error rather
|
|
2141
|
+
// than serializing silently. --wait[=<seconds>] opts into blocking for
|
|
2142
|
+
// up to N seconds (default 30s when --wait is bare).
|
|
2143
|
+
|
|
2144
|
+
let waitMs = 0;
|
|
2145
|
+
if (waitFlag) {
|
|
2146
|
+
const m = /^--wait(?:=(\d+))?$/.exec(waitFlag);
|
|
2147
|
+
const seconds = m && m[1] ? Number(m[1]) : 30;
|
|
2148
|
+
waitMs = Math.max(0, seconds) * 1000;
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
const watcher = new InboxWatcher({ rootDir: cwd, env: process.env, cwd });
|
|
2152
|
+
let result;
|
|
2153
|
+
try {
|
|
2154
|
+
result = await watcher.poll({ waitMs, actor: 'construct intake process' });
|
|
2155
|
+
} catch (err) {
|
|
2156
|
+
const { POLL_LOCK_BUSY } = await import('../lib/intake/poll-lock.mjs');
|
|
2157
|
+
if (err && err.code === POLL_LOCK_BUSY) {
|
|
2158
|
+
const holder = err.holder || {};
|
|
2159
|
+
errorln('Another intake poll is in progress.');
|
|
2160
|
+
errorln(` holder: ${holder.actor || 'unknown'} (pid ${holder.pid})`);
|
|
2161
|
+
errorln(` started: ${holder.startedAt || 'unknown'}`);
|
|
2162
|
+
errorln('');
|
|
2163
|
+
errorln('Choose one:');
|
|
2164
|
+
errorln(' construct intake process --wait Block until the holder finishes (default 30s).');
|
|
2165
|
+
errorln(' construct intake process --wait=<sec> Block for a custom window.');
|
|
2166
|
+
errorln(' construct down Stop background services, then retry.');
|
|
2167
|
+
process.exit(2);
|
|
2168
|
+
}
|
|
2169
|
+
throw err;
|
|
2170
|
+
}
|
|
2171
|
+
|
|
2172
|
+
println(`Processed: ${result.processed.length}`);
|
|
2173
|
+
println(`Skipped (unchanged): ${result.skipped}`);
|
|
2174
|
+
if (result.errors.length) {
|
|
2175
|
+
println(`Errors: ${result.errors.length}`);
|
|
2176
|
+
for (const e of result.errors) println(` ${e.path}: ${e.error}`);
|
|
2177
|
+
}
|
|
2178
|
+
for (const item of result.processed) {
|
|
2179
|
+
const note = item.needsAsr ? ' (queued for ASR)' : '';
|
|
2180
|
+
println(` + ${item.path}${note}`);
|
|
2181
|
+
}
|
|
2182
|
+
if (result.errors.length) process.exitCode = 1;
|
|
2183
|
+
}
|
|
2184
|
+
|
|
1929
2185
|
async function cmdIntakeQuarantine(args, cwd) {
|
|
1930
2186
|
const action = args[0];
|
|
1931
2187
|
const { listQuarantine, readQuarantine } = await import('../lib/intake/quarantine.mjs');
|
|
@@ -4584,14 +4840,6 @@ const handlers = new Map([
|
|
|
4584
4840
|
process.exit(1);
|
|
4585
4841
|
}
|
|
4586
4842
|
}],
|
|
4587
|
-
['policy:list', async (args) => {
|
|
4588
|
-
const { listPolicies, formatPolicyList } = await import('../lib/policy/unified-gates.mjs');
|
|
4589
|
-
if (args.includes('--json')) {
|
|
4590
|
-
println(JSON.stringify(listPolicies(), null, 2));
|
|
4591
|
-
} else {
|
|
4592
|
-
process.stdout.write(formatPolicyList());
|
|
4593
|
-
}
|
|
4594
|
-
}],
|
|
4595
4843
|
['policy', async (args) => {
|
|
4596
4844
|
const sub = args[0];
|
|
4597
4845
|
if (!sub || sub === '--help' || sub === '-h') {
|
|
@@ -4602,7 +4850,7 @@ const handlers = new Map([
|
|
|
4602
4850
|
if (sub === 'show') {
|
|
4603
4851
|
const { readFileSync, existsSync } = await import('node:fs');
|
|
4604
4852
|
const { join } = await import('node:path');
|
|
4605
|
-
const inventoryPath = join(ROOT_DIR, '
|
|
4853
|
+
const inventoryPath = join(ROOT_DIR, 'specialists', 'policy-inventory.json');
|
|
4606
4854
|
if (!existsSync(inventoryPath)) {
|
|
4607
4855
|
errorln('specialists/policy-inventory.json not found');
|
|
4608
4856
|
process.exit(1);
|
|
@@ -58,8 +58,29 @@ try {
|
|
|
58
58
|
}
|
|
59
59
|
} catch { /* fall through */ }
|
|
60
60
|
|
|
61
|
-
//
|
|
62
|
-
//
|
|
61
|
+
// `npm i -g @geraldmaron/construct` runs the postinstall with
|
|
62
|
+
// npm_config_global=true. Wire the `construct` front-door agent into the
|
|
63
|
+
// user's home directories so it's reachable from every host (Claude Code,
|
|
64
|
+
// Codex, Copilot, OpenCode) immediately after a global install. Specialists
|
|
65
|
+
// stay project-only and land when the user runs `construct init` in a repo.
|
|
66
|
+
|
|
67
|
+
if (process.env.npm_config_global === 'true' || process.env.npm_config_global === true) {
|
|
68
|
+
const syncScript = path.join(PKG_ROOT, 'scripts', 'sync-specialists.mjs');
|
|
69
|
+
if (existsSync(syncScript)) {
|
|
70
|
+
log('global install detected; syncing front-door agent into ~/');
|
|
71
|
+
const result = spawnSync(process.execPath, [syncScript, '--global'], {
|
|
72
|
+
stdio: 'inherit',
|
|
73
|
+
});
|
|
74
|
+
if (result.status !== 0) {
|
|
75
|
+
log(`global sync failed (exit ${result.status}); run \`construct sync --global\` manually`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
process.exit(0);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Project install path: require a package.json at the install target so
|
|
82
|
+
// monorepo nested installs don't accidentally trigger staging in the wrong
|
|
83
|
+
// directory.
|
|
63
84
|
|
|
64
85
|
const consumerPkgPath = path.join(initCwd, 'package.json');
|
|
65
86
|
if (!existsSync(consumerPkgPath)) {
|
package/lib/auto-docs.mjs
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* anything would change without writing files — the mode CI uses to detect drift.
|
|
11
11
|
*
|
|
12
12
|
* buildSite() is retained for compatibility; the public site now renders docs/
|
|
13
|
-
* directly through
|
|
13
|
+
* directly through Next.js (apps/docs/) and buildFumadocsReference() emits
|
|
14
|
+
* generated reference Markdown into docs/reference/.
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
17
|
import fs from 'node:fs';
|
|
@@ -82,7 +83,7 @@ function buildCoreDocsContract() {
|
|
|
82
83
|
|
|
83
84
|
const DIR_DESCRIPTIONS = {
|
|
84
85
|
agents: 'Registry and generated platform adapter chains',
|
|
85
|
-
apps: 'User-facing apps shipped from this repo (e.g. apps/docs/, the
|
|
86
|
+
apps: 'User-facing apps shipped from this repo (e.g. apps/docs/, the Next.js docs site)',
|
|
86
87
|
bin: 'CLI entrypoint (`construct`)',
|
|
87
88
|
claude: 'Claude Code integration (agents, settings template)',
|
|
88
89
|
commands: 'Command prompt assets',
|
|
@@ -151,7 +152,7 @@ function buildHooksTable(rootDir) {
|
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
function buildAgentsTable(rootDir) {
|
|
154
|
-
const registryPath = path.join(rootDir, '
|
|
155
|
+
const registryPath = path.join(rootDir, 'specialists', 'registry.json');
|
|
155
156
|
let registry;
|
|
156
157
|
try { registry = JSON.parse(fs.readFileSync(registryPath, 'utf8')); } catch { return ''; }
|
|
157
158
|
|
|
@@ -303,7 +304,7 @@ export function checkDocsCoverage({ rootDir } = {}) {
|
|
|
303
304
|
return { covered, uncovered, total: covered.length + uncovered.length };
|
|
304
305
|
}
|
|
305
306
|
|
|
306
|
-
// Categories surfaced in the
|
|
307
|
+
// Categories surfaced in the generated CLI reference. Internal commands (e.g.,
|
|
307
308
|
// `construct hook <name>`) are not user-facing reference material.
|
|
308
309
|
const REFERENCE_CATEGORIES = [
|
|
309
310
|
'Core',
|
|
@@ -407,9 +408,12 @@ function renderAgentsPage(rootDir) {
|
|
|
407
408
|
}
|
|
408
409
|
|
|
409
410
|
/**
|
|
410
|
-
* Emit MDX reference pages into docs/reference/ for the
|
|
411
|
-
* Mirrors the data sources behind AUTO regions and buildSite()
|
|
412
|
-
* Markdown files
|
|
411
|
+
* Emit MDX reference pages into docs/reference/ for the Next.js docs site
|
|
412
|
+
* in apps/docs/. Mirrors the data sources behind AUTO regions and buildSite()
|
|
413
|
+
* but writes Markdown files the docs app can pull in directly (no MkDocs
|
|
414
|
+
* intermediate). Name kept for backwards compatibility with callers that
|
|
415
|
+
* still import buildFumadocsReference; the rendering layer is now plain
|
|
416
|
+
* Next.js + @next/mdx.
|
|
413
417
|
*/
|
|
414
418
|
export function buildFumadocsReference({ rootDir } = {}) {
|
|
415
419
|
rootDir = rootDir ?? process.cwd();
|
package/lib/dashboard-static.mjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* lib/dashboard-static.mjs — build and sync the dashboard static bundle.
|
|
3
3
|
*
|
|
4
|
-
* Keeps
|
|
5
|
-
*
|
|
4
|
+
* Keeps the Next.js static export at `apps/dashboard/out/` and the served
|
|
5
|
+
* tree at `lib/server/static/` aligned so the HTTP server picks up the
|
|
6
|
+
* current dashboard build without code changes. Pre-2.0 the dashboard
|
|
7
|
+
* lived at `dashboard/dist/`; the rebuild to Next.js (commit 84cd721)
|
|
8
|
+
* moved the source of truth into `apps/dashboard/out/`.
|
|
6
9
|
*/
|
|
7
10
|
|
|
8
11
|
import fs from 'node:fs';
|
|
@@ -78,8 +81,8 @@ function removeEmptyDirs(dirPath, stopAt) {
|
|
|
78
81
|
export function getDashboardPaths({ rootDir = process.cwd() } = {}) {
|
|
79
82
|
return {
|
|
80
83
|
rootDir,
|
|
81
|
-
dashboardDir: path.join(rootDir, 'dashboard'),
|
|
82
|
-
sourceDir: path.join(rootDir, 'dashboard', '
|
|
84
|
+
dashboardDir: path.join(rootDir, 'apps', 'dashboard'),
|
|
85
|
+
sourceDir: path.join(rootDir, 'apps', 'dashboard', 'out'),
|
|
83
86
|
targetDir: path.join(rootDir, 'lib', 'server', 'static'),
|
|
84
87
|
};
|
|
85
88
|
}
|
package/lib/doc-stamp.mjs
CHANGED
|
@@ -102,12 +102,17 @@ function splitStamp(content) {
|
|
|
102
102
|
* sessionId {string} - Construct session ID if available
|
|
103
103
|
* model {string} - Model name/version if available
|
|
104
104
|
* preserve_id {boolean} - Keep existing cx_doc_id if present (default: true)
|
|
105
|
+
* attribution {object} - Optional { createdBy, createdByAgent } pair. When
|
|
106
|
+
* provided, written into the stamp and (on stamp
|
|
107
|
+
* refresh) carried forward via existing_fields so a
|
|
108
|
+
* later write does not erase the original author.
|
|
105
109
|
*/
|
|
106
110
|
export function stampFrontmatter(content, {
|
|
107
111
|
generator = 'construct',
|
|
108
112
|
sessionId = null,
|
|
109
113
|
model = null,
|
|
110
114
|
preserve_id = true,
|
|
115
|
+
attribution = null,
|
|
111
116
|
} = {}) {
|
|
112
117
|
const existing = hasStamp(content) ? splitStamp(content) : null;
|
|
113
118
|
const existingFields = existing ? parseStamp(content) : {};
|
|
@@ -116,6 +121,11 @@ export function stampFrontmatter(content, {
|
|
|
116
121
|
const createdAt = existingFields.created_at || new Date().toISOString();
|
|
117
122
|
const updatedAt = new Date().toISOString();
|
|
118
123
|
|
|
124
|
+
const createdBy = existingFields.created_by ?? attribution?.createdBy ?? null;
|
|
125
|
+
const createdByAgent = existingFields.created_by_agent ?? attribution?.createdByAgent ?? null;
|
|
126
|
+
const lastModifiedBy = attribution?.createdBy ?? existingFields.last_modified_by ?? null;
|
|
127
|
+
const lastModifiedByAgent = attribution?.createdByAgent ?? existingFields.last_modified_by_agent ?? null;
|
|
128
|
+
|
|
119
129
|
// Body is everything after stamp (or all content if no prior stamp)
|
|
120
130
|
const body = existing ? existing.body : content;
|
|
121
131
|
const hash = bodyHash(body);
|
|
@@ -127,6 +137,12 @@ export function stampFrontmatter(content, {
|
|
|
127
137
|
`updated_at: ${updatedAt}`,
|
|
128
138
|
`generator: ${generator}`,
|
|
129
139
|
];
|
|
140
|
+
if (createdBy) lines.push(`created_by: ${createdBy}`);
|
|
141
|
+
if (createdByAgent) lines.push(`created_by_agent: ${createdByAgent}`);
|
|
142
|
+
if (lastModifiedBy && lastModifiedBy !== createdBy) lines.push(`last_modified_by: ${lastModifiedBy}`);
|
|
143
|
+
if (lastModifiedByAgent && lastModifiedByAgent !== createdByAgent) {
|
|
144
|
+
lines.push(`last_modified_by_agent: ${lastModifiedByAgent}`);
|
|
145
|
+
}
|
|
130
146
|
if (model) lines.push(`model: ${model}`);
|
|
131
147
|
if (sessionId) lines.push(`session_id: ${sessionId}`);
|
|
132
148
|
lines.push(`body_hash: ${hash}`);
|
package/lib/docs-verify.mjs
CHANGED
|
@@ -52,18 +52,11 @@ if (stagedMode) {
|
|
|
52
52
|
if (changedCode.length === 0) process.exit(0);
|
|
53
53
|
if (changedDocs.length > 0) process.exit(0);
|
|
54
54
|
|
|
55
|
-
if (process.env.CONSTRUCT_SKIP_DOCS === "1") {
|
|
56
|
-
process.stderr.write(
|
|
57
|
-
`[docs:verify --staged] CONSTRUCT_SKIP_DOCS=1 — skipping doc-coupling check for ${changedCode.length} code file(s).\n`,
|
|
58
|
-
);
|
|
59
|
-
process.exit(0);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
55
|
const sample = changedCode.slice(0, 6).map((f) => ` - ${f}`).join("\n");
|
|
63
56
|
process.stderr.write(
|
|
64
57
|
`[docs:verify --staged] ${changedCode.length} code file(s) staged but no CHANGELOG.md / docs/* / .cx/context.* updates.\n` +
|
|
65
58
|
`${sample}${changedCode.length > 6 ? `\n ... (${changedCode.length - 6} more)` : ""}\n` +
|
|
66
|
-
`Update docs in this commit
|
|
59
|
+
`Update docs in this commit before pushing.\n`,
|
|
67
60
|
);
|
|
68
61
|
process.exit(1);
|
|
69
62
|
}
|
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
* as a label, regardless of how it got there (manual, ai, automated).
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { existsSync, readFileSync, writeFileSync,
|
|
15
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
16
16
|
import { spawnSync } from 'node:child_process';
|
|
17
|
+
import { appendBounded } from '../../logging/rotate.mjs';
|
|
18
|
+
import { resolveProjectScope } from '../../project-root.mjs';
|
|
17
19
|
import { homedir } from 'node:os';
|
|
18
20
|
import { join } from 'node:path';
|
|
19
21
|
|
|
@@ -86,6 +88,7 @@ export async function tick() {
|
|
|
86
88
|
if (seen[key]) continue;
|
|
87
89
|
seen[key] = { ts: Date.now(), id: issue.id };
|
|
88
90
|
const manifest = loadManifest(personaId);
|
|
91
|
+
const scope = resolveProjectScope();
|
|
89
92
|
const entry = {
|
|
90
93
|
ts: Date.now(),
|
|
91
94
|
personaId,
|
|
@@ -96,8 +99,9 @@ export async function tick() {
|
|
|
96
99
|
summary: `bd ${issue.id} labeled next:cx-${personaId} — ${(issue.title || '').slice(0, 120)}`,
|
|
97
100
|
killSwitchEnv: manifest?.killSwitchEnv || '',
|
|
98
101
|
source: 'bd-watch',
|
|
102
|
+
...(scope?.projectId ? { projectId: scope.projectId } : {}),
|
|
99
103
|
};
|
|
100
|
-
|
|
104
|
+
appendBounded('role-pending', PENDING_PATH, JSON.stringify(entry) + '\n');
|
|
101
105
|
record({
|
|
102
106
|
kind: 'action',
|
|
103
107
|
watcher: name,
|
package/lib/embed/daemon.mjs
CHANGED
|
@@ -30,6 +30,7 @@ import { dirname, join } from 'node:path';
|
|
|
30
30
|
|
|
31
31
|
import { loadEmbedConfig } from './config.mjs';
|
|
32
32
|
import { Scheduler } from './scheduler.mjs';
|
|
33
|
+
import { rotateIfOversized } from '../logging/rotate.mjs';
|
|
33
34
|
import { SnapshotEngine, renderMarkdown } from './snapshot.mjs';
|
|
34
35
|
import { ApprovalQueue } from './approval-queue.mjs';
|
|
35
36
|
import { dispatchOutputs } from './output.mjs';
|
|
@@ -594,6 +595,25 @@ export class EmbedDaemon {
|
|
|
594
595
|
},
|
|
595
596
|
);
|
|
596
597
|
|
|
598
|
+
// ── Job 6: daemon-log-rotation ────────────────────────────────────────────
|
|
599
|
+
// OS supervisors (launchd/systemd/schtasks) redirect daemon stdout to
|
|
600
|
+
// ~/.cx/runtime/embed-daemon.log with no rotation. A stuck telemetry
|
|
601
|
+
// log line filled it to 34 GB on one local install; rotate proactively.
|
|
602
|
+
// CONSTRUCT_EMBED_LOG_MAX_MB overrides the default 50 MB cap.
|
|
603
|
+
|
|
604
|
+
this.#scheduler.register(
|
|
605
|
+
'daemon-log-rotation',
|
|
606
|
+
60_000,
|
|
607
|
+
async () => {
|
|
608
|
+
const logPath = join(homedir(), '.cx', 'runtime', 'embed-daemon.log');
|
|
609
|
+
const capMb = Number(process.env.CONSTRUCT_EMBED_LOG_MAX_MB) || 50;
|
|
610
|
+
const maxBytes = Math.floor(capMb * 1024 * 1024);
|
|
611
|
+
const maxSegments = Number(process.env.CONSTRUCT_EMBED_LOG_MAX_SEGMENTS) || 5;
|
|
612
|
+
await rotateIfOversized(logPath, { maxBytes, maxSegments, gzip: true });
|
|
613
|
+
},
|
|
614
|
+
{ runImmediately: true },
|
|
615
|
+
);
|
|
616
|
+
|
|
597
617
|
// ── Job 0: telemetry-setup ───────────────────────────────────────────────────
|
|
598
618
|
// On startup — ensure annotation queues and eval configs exist (idempotent)
|
|
599
619
|
this.#scheduler.register(
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Responsibilities:
|
|
5
5
|
* - Detect stale, missing, or outdated docs across targets
|
|
6
|
+
* - Emit document.stale lifecycle events for each stale gap surfaced
|
|
7
|
+
* (consumed by cx-docs-keeper and any project-bound subscribers)
|
|
6
8
|
* - Generate/update docs as artifacts in the appropriate docs lane
|
|
7
9
|
* - Route writes through the authority guard (direct-write for low-risk, approval-queued for high-risk)
|
|
8
10
|
* - Treat ALL doc types uniformly: adrs, prds, memos, notes, intake, roadmaps
|
|
@@ -23,6 +25,7 @@ import { WORKSPACE_DOCS_LANES } from './config.mjs';
|
|
|
23
25
|
import { recommendArtifacts } from './artifact.mjs';
|
|
24
26
|
import { createRecommendation, autoSuppressStale, recommendationStats, isRecommendationActive } from './recommendation-store.mjs';
|
|
25
27
|
import { detectConflicts } from './conflict-detection.mjs';
|
|
28
|
+
import { emitBestEffort as emitRoleEvent } from '../roles/event-bus.mjs';
|
|
26
29
|
|
|
27
30
|
/**
|
|
28
31
|
* Risk classification for doc operations.
|
|
@@ -232,6 +235,22 @@ export async function runDocsLifecycle(opts) {
|
|
|
232
235
|
const gaps = detectDocGaps(target, { snapshot, roleLens });
|
|
233
236
|
allGaps.push(...gaps.map((g) => ({ ...g, target: targetLabel(target) })));
|
|
234
237
|
|
|
238
|
+
// Surface staleness as lifecycle events for any specialist subscribed
|
|
239
|
+
// to document.stale (cx-docs-keeper by default).
|
|
240
|
+
|
|
241
|
+
for (const gap of gaps) {
|
|
242
|
+
if (gap.type !== 'stale') continue;
|
|
243
|
+
emitRoleEvent('document.stale', {
|
|
244
|
+
summary: gap.summary,
|
|
245
|
+
context: {
|
|
246
|
+
lane: gap.lane,
|
|
247
|
+
file: gap.file,
|
|
248
|
+
ageMs: gap.age,
|
|
249
|
+
target: targetLabel(target),
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
235
254
|
// Check intake patterns for artifact recommendations (uses recommendation store for dedup)
|
|
236
255
|
const intakeGaps = detectIntakeDocGaps(target.path);
|
|
237
256
|
for (const gap of intakeGaps) {
|