@bonesofspring/ai-rules 0.2.52 → 0.2.53
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 +24 -0
- package/README.md +27 -3
- package/bin/cli.js +551 -60
- package/bin/lib/engine-scripts.js +10 -0
- package/bin/lib/mcp/clients.js +168 -0
- package/bin/lib/mcp/credentials.js +298 -0
- package/bin/lib/mcp/doctor.js +394 -0
- package/bin/lib/mcp/prompt.js +115 -0
- package/bin/lib/mcp/registry.js +170 -0
- package/bin/lib/mcp/run.js +123 -0
- package/bin/lib/merged-config.js +45 -0
- package/bin/lib/seed-ai-local-team.js +5 -0
- package/bin/lib/tool-installs.js +27 -0
- package/docs/MCP-SETUP.md +62 -0
- package/docs/PRESET-CONTRIBUTION.md +3 -1
- package/docs/TEAM-DB.md +173 -0
- package/docs/openapi/team-db.v1.json +5085 -0
- package/mcp/gitlab.mjs +123 -0
- package/mcp/lib/envfile.mjs +126 -0
- package/mcp/lib/yandex.mjs +384 -0
- package/mcp/yandex-mcp-proxy.mjs +155 -0
- package/mcp/yandex-token-refresh.mjs +65 -0
- package/package.json +14 -1
- package/presets/_shared/ai-local/scripts/manifest.mjs +99 -0
- package/presets/_shared/ai-local/scripts/team-db-api.mjs +1275 -0
- package/presets/_shared/ai-local/scripts/team-db-dashboard.mjs +1067 -0
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +1301 -0
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +1506 -0
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +831 -0
- package/presets/_shared/ai-local/scripts/team-db.mjs +251 -0
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +109 -0
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/android-kotlin/team/README.md +10 -0
- package/presets/claude/go/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/go/team/README.md +10 -0
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/ios-swift/team/README.md +10 -0
- package/presets/claude/java/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/java/team/README.md +10 -0
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/mcp-ts/team/README.md +10 -0
- package/presets/claude/next/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/next/team/README.md +10 -0
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/nuxt/team/README.md +10 -0
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/php-hexagonal/team/README.md +10 -0
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/php-laravel/team/README.md +10 -0
- package/presets/claude/svelte/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/svelte/team/README.md +10 -0
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/android-kotlin/team/README.md +10 -0
- package/presets/cursor/go/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/go/team/README.md +10 -0
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/ios-swift/team/README.md +10 -0
- package/presets/cursor/java/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/java/team/README.md +10 -0
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/mcp-ts/team/README.md +10 -0
- package/presets/cursor/next/MCP.md +7 -0
- package/presets/cursor/next/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/next/team/README.md +10 -0
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/nuxt/team/README.md +10 -0
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/php-hexagonal/team/README.md +10 -0
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/php-laravel/team/README.md +10 -0
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/svelte/team/README.md +10 -0
- package/presets/mavis/android-kotlin/adapter-map.json +1 -1
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/android-kotlin/team/README.md +10 -0
- package/presets/mavis/go/adapter-map.json +1 -1
- package/presets/mavis/go/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/go/team/README.md +10 -0
- package/presets/mavis/ios-swift/adapter-map.json +1 -1
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/ios-swift/team/README.md +10 -0
- package/presets/mavis/java/adapter-map.json +1 -1
- package/presets/mavis/java/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/java/team/README.md +10 -0
- package/presets/mavis/mcp-ts/adapter-map.json +1 -1
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/mcp-ts/team/README.md +10 -0
- package/presets/mavis/next/MCP.md +7 -0
- package/presets/mavis/next/adapter-map.json +1 -1
- package/presets/mavis/next/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/next/team/README.md +10 -0
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/nuxt/team/README.md +10 -0
- package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/php-hexagonal/team/README.md +10 -0
- package/presets/mavis/php-laravel/adapter-map.json +1 -1
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/php-laravel/team/README.md +10 -0
- package/presets/mavis/svelte/adapter-map.json +1 -1
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/svelte/team/README.md +10 -0
- package/presets/opencode/android-kotlin/adapter-map.json +1 -1
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/android-kotlin/team/README.md +10 -0
- package/presets/opencode/go/adapter-map.json +1 -1
- package/presets/opencode/go/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/go/team/README.md +10 -0
- package/presets/opencode/ios-swift/adapter-map.json +1 -1
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/ios-swift/team/README.md +10 -0
- package/presets/opencode/java/adapter-map.json +1 -1
- package/presets/opencode/java/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/java/team/README.md +10 -0
- package/presets/opencode/mcp-ts/adapter-map.json +1 -1
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/mcp-ts/team/README.md +10 -0
- package/presets/opencode/next/MCP.md +7 -0
- package/presets/opencode/next/adapter-map.json +1 -1
- package/presets/opencode/next/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/next/team/README.md +10 -0
- package/presets/opencode/nuxt/adapter-map.json +1 -1
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/nuxt/team/README.md +10 -0
- package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/php-hexagonal/team/README.md +10 -0
- package/presets/opencode/php-laravel/adapter-map.json +1 -1
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/php-laravel/team/README.md +10 -0
- package/presets/opencode/svelte/adapter-map.json +1 -1
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/svelte/team/README.md +10 -0
|
@@ -2600,6 +2600,115 @@ if (!input || input.status !== 'completed') {
|
|
|
2600
2600
|
process.exit(0);
|
|
2601
2601
|
}
|
|
2602
2602
|
|
|
2603
|
+
// --- TEAM_DB_PROJECTION -------------------------------------------------------
|
|
2604
|
+
// The status, metrics, compaction and focus writes are already durable when this
|
|
2605
|
+
// postflight starts. The projection is a bounded child process: it must never
|
|
2606
|
+
// fail this stop, never change hook stdout/stderr beyond the capability line,
|
|
2607
|
+
// and never write a task file. A disabled switch, a missing script, or a
|
|
2608
|
+
// runtime without `node:sqlite` is a skip; a child failure is one log line.
|
|
2609
|
+
// This is a plain region marker, not a `hook-slot`: the block is identical in
|
|
2610
|
+
// all 40 rendered bodies and needs no per-stack fragment.
|
|
2611
|
+
// <<<team-db-projection>>>
|
|
2612
|
+
function teamDbTruthy(value) {
|
|
2613
|
+
if (typeof value !== 'string') return false;
|
|
2614
|
+
const normalized = value.trim().toLowerCase();
|
|
2615
|
+
return normalized === '1' || normalized === 'true' || normalized === 'yes';
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
function teamDbLogPath(env) {
|
|
2619
|
+
const override = typeof env.AI_RULES_TEAM_DB_LOG === 'string' ? env.AI_RULES_TEAM_DB_LOG.trim() : '';
|
|
2620
|
+
if (override) return path.resolve(override);
|
|
2621
|
+
return path.join(process.cwd(), '.ai.local', 'team', 'team-db-errors.log');
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
function teamDbLogPhase(env) {
|
|
2625
|
+
const value = typeof env.AI_RULES_TEAM_DB_SEAM === 'string' ? env.AI_RULES_TEAM_DB_SEAM.trim() : '';
|
|
2626
|
+
return value === 'hook' || value === 'receipt' || value === 'cli' || value === 'serve' ? value : 'hook';
|
|
2627
|
+
}
|
|
2628
|
+
|
|
2629
|
+
// One line per failure, newest 200 lines and at most 64 KiB. Never a prompt
|
|
2630
|
+
// body: only the code and the message this block owns.
|
|
2631
|
+
function teamDbLogFailure(env, code, message) {
|
|
2632
|
+
try {
|
|
2633
|
+
const target = teamDbLogPath(env);
|
|
2634
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
2635
|
+
const line = new Date().toISOString() + ' ' + code + ' ' + teamDbLogPhase(env) + ' ' + message;
|
|
2636
|
+
fs.appendFileSync(target, line + '\n');
|
|
2637
|
+
let content = fs.readFileSync(target, 'utf8');
|
|
2638
|
+
let lines = content.split('\n').filter(function (entry) { return entry.length > 0; });
|
|
2639
|
+
if (lines.length > 200) lines = lines.slice(lines.length - 200);
|
|
2640
|
+
while (Buffer.byteLength(lines.join('\n') + '\n', 'utf8') > 65536 && lines.length > 1) lines.shift();
|
|
2641
|
+
content = lines.join('\n') + (lines.length > 0 ? '\n' : '');
|
|
2642
|
+
fs.writeFileSync(target, content);
|
|
2643
|
+
} catch (error) {
|
|
2644
|
+
/* a log failure is not a stop failure */
|
|
2645
|
+
}
|
|
2646
|
+
}
|
|
2647
|
+
|
|
2648
|
+
function teamDbSqliteAvailable(env) {
|
|
2649
|
+
if (teamDbTruthy(env.AI_RULES_TEAM_DB_FORCE_FALLBACK)) return false;
|
|
2650
|
+
const match = /^(\d+)\.(\d+)\.(\d+)/.exec(String(process.versions.node || ''));
|
|
2651
|
+
if (!match) return false;
|
|
2652
|
+
const major = Number(match[1]);
|
|
2653
|
+
const minor = Number(match[2]);
|
|
2654
|
+
if (major < 22) return false;
|
|
2655
|
+
if (major === 22 && minor < 13) return false;
|
|
2656
|
+
try {
|
|
2657
|
+
const sqlite = require('node:sqlite');
|
|
2658
|
+
return typeof sqlite.DatabaseSync === 'function';
|
|
2659
|
+
} catch (error) {
|
|
2660
|
+
return false;
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2664
|
+
function teamDbProject() {
|
|
2665
|
+
try {
|
|
2666
|
+
const env = process.env;
|
|
2667
|
+
if (teamDbTruthy(env.AI_RULES_TEAM_DB_DISABLE)) return;
|
|
2668
|
+
// Same pattern as POSTFLIGHT_SLUG_RE above: the slug is re-derived from
|
|
2669
|
+
// `active-task.json` on this path too, so it cannot escape the tree.
|
|
2670
|
+
const slugPattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
2671
|
+
let slug = '';
|
|
2672
|
+
try {
|
|
2673
|
+
const active = JSON.parse(fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', 'active-task.json'), 'utf8'));
|
|
2674
|
+
slug = typeof active.slug === 'string' ? active.slug : '';
|
|
2675
|
+
} catch (error) {
|
|
2676
|
+
return;
|
|
2677
|
+
}
|
|
2678
|
+
if (!slug || slug.length > 48 || !slugPattern.test(slug)) return;
|
|
2679
|
+
const taskDir = path.join(process.cwd(), '.ai.local', 'team', 'tasks', slug);
|
|
2680
|
+
if (!fs.existsSync(path.join(taskDir, 'status.json'))) return;
|
|
2681
|
+
const script = path.join(process.cwd(), '.ai.local', 'scripts', 'team-db.mjs');
|
|
2682
|
+
if (!fs.existsSync(script)) return;
|
|
2683
|
+
if (!teamDbSqliteAvailable(env)) {
|
|
2684
|
+
process.stderr.write('team-db: projection skipped (node:sqlite unavailable); file-only mode\n');
|
|
2685
|
+
return;
|
|
2686
|
+
}
|
|
2687
|
+
const result = spawnSync(
|
|
2688
|
+
process.execPath,
|
|
2689
|
+
['.ai.local/scripts/team-db.mjs', 'sync', '--slug', slug, '--quiet', '--no-rebuild', '--deadline-ms', '4500'],
|
|
2690
|
+
{ cwd: process.cwd(), env: env, encoding: 'utf8', timeout: 5000, killSignal: 'SIGKILL', stdio: ['ignore', 'pipe', 'pipe'] },
|
|
2691
|
+
);
|
|
2692
|
+
if (result.error && result.error.code === 'ETIMEDOUT') {
|
|
2693
|
+
teamDbLogFailure(env, 'E_PROJECTION_TIMEOUT', 'projection exceeded 5000 ms and was killed');
|
|
2694
|
+
return;
|
|
2695
|
+
}
|
|
2696
|
+
if (result.error) {
|
|
2697
|
+
teamDbLogFailure(env, 'E_PROJECTION_FAILED', 'projection could not start: ' + String(result.error.code || 'unknown'));
|
|
2698
|
+
return;
|
|
2699
|
+
}
|
|
2700
|
+
if (typeof result.status === 'number' && result.status !== 0) {
|
|
2701
|
+
teamDbLogFailure(env, 'E_PROJECTION_FAILED', 'projection exited ' + result.status);
|
|
2702
|
+
}
|
|
2703
|
+
} catch (error) {
|
|
2704
|
+
/* the seam never fails the stop */
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
teamDbProject();
|
|
2709
|
+
// <<<team-db-projection-end>>>
|
|
2710
|
+
// --- end TEAM_DB_PROJECTION ---------------------------------------------------
|
|
2711
|
+
|
|
2603
2712
|
// Ratchet: off for `light` pipelines and `spike` intents. A policy skip is
|
|
2604
2713
|
// silent on purpose — a warning on every light receipt would make the
|
|
2605
2714
|
// containment warnings below unreadable.
|
|
@@ -102,6 +102,16 @@ Same JSON on Claude, Mavis, or OpenCode: `bash .<tool>/hooks/chain-team-phases.s
|
|
|
102
102
|
|
|
103
103
|
**Self-review / re-anchor:** each producing agent records a `## Self-review` block in the artifact it owns (`brief.md` / `implementation.md` / `debug-report.md` / `validation-report.md` / `review.md`) and, on detected context loss / excess, a re-anchor line in `.memlog.md` — `event:` (no plan change) or `decision: replan rev N → N+1` (plan change). No hook/lifecycle field is added.
|
|
104
104
|
|
|
105
|
+
## Database projection
|
|
106
|
+
|
|
107
|
+
`team-db.mjs` projects this tree into `.ai.local/team/team.db` (SQLite, WAL). The files remain authoritative: the database is rebuildable and git-ignored (`team.db`, `team.db-wal`, `team.db-shm`, `team-db-errors.log`).
|
|
108
|
+
|
|
109
|
+
- Write points: the chain hook after its file writes, and `manifest.mjs` after a receipt. Both run one bounded 5 s child; a failure logs one line and never fails the file write.
|
|
110
|
+
- No agent writes lifecycle fields through the database. `status.json` / `metrics.json` stay hook-owned.
|
|
111
|
+
- `AI_RULES_TEAM_DB_DISABLE=1` stops every write point and `serve`; a runtime without `node:sqlite` stays file-only with exit 0.
|
|
112
|
+
- Inspect: `node .ai.local/scripts/team-db.mjs sync`, then `check`; `serve` opens the read-only dashboard at `http://127.0.0.1:4178`.
|
|
113
|
+
- Never commit the database. Delete `team.db*` and run `sync` to rebuild.
|
|
114
|
+
|
|
105
115
|
## Contracts
|
|
106
116
|
|
|
107
117
|
- **Manifest field name:** receipts go in `artifacts[]`. Anything written under `entries` is ignored — the hook reads only `artifacts` and prints a dual-read warning naming the file. See `agent-team/agent-artifact-contracts.md` § Schema field name.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"platform": "opencode",
|
|
4
4
|
"stack": "java",
|
|
5
5
|
"semanticSource": "cursor/java",
|
|
6
|
-
"sourceRevision": "
|
|
6
|
+
"sourceRevision": "d6df64f6dc13f935bd2b8acfe17515d87480cf827612f85c60a2806a5c6c37bb",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
9
9
|
"source": "AGENTS.md",
|
|
@@ -2595,6 +2595,115 @@ if (!input || input.status !== 'completed') {
|
|
|
2595
2595
|
process.exit(0);
|
|
2596
2596
|
}
|
|
2597
2597
|
|
|
2598
|
+
// --- TEAM_DB_PROJECTION -------------------------------------------------------
|
|
2599
|
+
// The status, metrics, compaction and focus writes are already durable when this
|
|
2600
|
+
// postflight starts. The projection is a bounded child process: it must never
|
|
2601
|
+
// fail this stop, never change hook stdout/stderr beyond the capability line,
|
|
2602
|
+
// and never write a task file. A disabled switch, a missing script, or a
|
|
2603
|
+
// runtime without `node:sqlite` is a skip; a child failure is one log line.
|
|
2604
|
+
// This is a plain region marker, not a `hook-slot`: the block is identical in
|
|
2605
|
+
// all 40 rendered bodies and needs no per-stack fragment.
|
|
2606
|
+
// <<<team-db-projection>>>
|
|
2607
|
+
function teamDbTruthy(value) {
|
|
2608
|
+
if (typeof value !== 'string') return false;
|
|
2609
|
+
const normalized = value.trim().toLowerCase();
|
|
2610
|
+
return normalized === '1' || normalized === 'true' || normalized === 'yes';
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
function teamDbLogPath(env) {
|
|
2614
|
+
const override = typeof env.AI_RULES_TEAM_DB_LOG === 'string' ? env.AI_RULES_TEAM_DB_LOG.trim() : '';
|
|
2615
|
+
if (override) return path.resolve(override);
|
|
2616
|
+
return path.join(process.cwd(), '.ai.local', 'team', 'team-db-errors.log');
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2619
|
+
function teamDbLogPhase(env) {
|
|
2620
|
+
const value = typeof env.AI_RULES_TEAM_DB_SEAM === 'string' ? env.AI_RULES_TEAM_DB_SEAM.trim() : '';
|
|
2621
|
+
return value === 'hook' || value === 'receipt' || value === 'cli' || value === 'serve' ? value : 'hook';
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
// One line per failure, newest 200 lines and at most 64 KiB. Never a prompt
|
|
2625
|
+
// body: only the code and the message this block owns.
|
|
2626
|
+
function teamDbLogFailure(env, code, message) {
|
|
2627
|
+
try {
|
|
2628
|
+
const target = teamDbLogPath(env);
|
|
2629
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
2630
|
+
const line = new Date().toISOString() + ' ' + code + ' ' + teamDbLogPhase(env) + ' ' + message;
|
|
2631
|
+
fs.appendFileSync(target, line + '\n');
|
|
2632
|
+
let content = fs.readFileSync(target, 'utf8');
|
|
2633
|
+
let lines = content.split('\n').filter(function (entry) { return entry.length > 0; });
|
|
2634
|
+
if (lines.length > 200) lines = lines.slice(lines.length - 200);
|
|
2635
|
+
while (Buffer.byteLength(lines.join('\n') + '\n', 'utf8') > 65536 && lines.length > 1) lines.shift();
|
|
2636
|
+
content = lines.join('\n') + (lines.length > 0 ? '\n' : '');
|
|
2637
|
+
fs.writeFileSync(target, content);
|
|
2638
|
+
} catch (error) {
|
|
2639
|
+
/* a log failure is not a stop failure */
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2643
|
+
function teamDbSqliteAvailable(env) {
|
|
2644
|
+
if (teamDbTruthy(env.AI_RULES_TEAM_DB_FORCE_FALLBACK)) return false;
|
|
2645
|
+
const match = /^(\d+)\.(\d+)\.(\d+)/.exec(String(process.versions.node || ''));
|
|
2646
|
+
if (!match) return false;
|
|
2647
|
+
const major = Number(match[1]);
|
|
2648
|
+
const minor = Number(match[2]);
|
|
2649
|
+
if (major < 22) return false;
|
|
2650
|
+
if (major === 22 && minor < 13) return false;
|
|
2651
|
+
try {
|
|
2652
|
+
const sqlite = require('node:sqlite');
|
|
2653
|
+
return typeof sqlite.DatabaseSync === 'function';
|
|
2654
|
+
} catch (error) {
|
|
2655
|
+
return false;
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
function teamDbProject() {
|
|
2660
|
+
try {
|
|
2661
|
+
const env = process.env;
|
|
2662
|
+
if (teamDbTruthy(env.AI_RULES_TEAM_DB_DISABLE)) return;
|
|
2663
|
+
// Same pattern as POSTFLIGHT_SLUG_RE above: the slug is re-derived from
|
|
2664
|
+
// `active-task.json` on this path too, so it cannot escape the tree.
|
|
2665
|
+
const slugPattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
2666
|
+
let slug = '';
|
|
2667
|
+
try {
|
|
2668
|
+
const active = JSON.parse(fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', 'active-task.json'), 'utf8'));
|
|
2669
|
+
slug = typeof active.slug === 'string' ? active.slug : '';
|
|
2670
|
+
} catch (error) {
|
|
2671
|
+
return;
|
|
2672
|
+
}
|
|
2673
|
+
if (!slug || slug.length > 48 || !slugPattern.test(slug)) return;
|
|
2674
|
+
const taskDir = path.join(process.cwd(), '.ai.local', 'team', 'tasks', slug);
|
|
2675
|
+
if (!fs.existsSync(path.join(taskDir, 'status.json'))) return;
|
|
2676
|
+
const script = path.join(process.cwd(), '.ai.local', 'scripts', 'team-db.mjs');
|
|
2677
|
+
if (!fs.existsSync(script)) return;
|
|
2678
|
+
if (!teamDbSqliteAvailable(env)) {
|
|
2679
|
+
process.stderr.write('team-db: projection skipped (node:sqlite unavailable); file-only mode\n');
|
|
2680
|
+
return;
|
|
2681
|
+
}
|
|
2682
|
+
const result = spawnSync(
|
|
2683
|
+
process.execPath,
|
|
2684
|
+
['.ai.local/scripts/team-db.mjs', 'sync', '--slug', slug, '--quiet', '--no-rebuild', '--deadline-ms', '4500'],
|
|
2685
|
+
{ cwd: process.cwd(), env: env, encoding: 'utf8', timeout: 5000, killSignal: 'SIGKILL', stdio: ['ignore', 'pipe', 'pipe'] },
|
|
2686
|
+
);
|
|
2687
|
+
if (result.error && result.error.code === 'ETIMEDOUT') {
|
|
2688
|
+
teamDbLogFailure(env, 'E_PROJECTION_TIMEOUT', 'projection exceeded 5000 ms and was killed');
|
|
2689
|
+
return;
|
|
2690
|
+
}
|
|
2691
|
+
if (result.error) {
|
|
2692
|
+
teamDbLogFailure(env, 'E_PROJECTION_FAILED', 'projection could not start: ' + String(result.error.code || 'unknown'));
|
|
2693
|
+
return;
|
|
2694
|
+
}
|
|
2695
|
+
if (typeof result.status === 'number' && result.status !== 0) {
|
|
2696
|
+
teamDbLogFailure(env, 'E_PROJECTION_FAILED', 'projection exited ' + result.status);
|
|
2697
|
+
}
|
|
2698
|
+
} catch (error) {
|
|
2699
|
+
/* the seam never fails the stop */
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
teamDbProject();
|
|
2704
|
+
// <<<team-db-projection-end>>>
|
|
2705
|
+
// --- end TEAM_DB_PROJECTION ---------------------------------------------------
|
|
2706
|
+
|
|
2598
2707
|
// Ratchet: off for `light` pipelines and `spike` intents. A policy skip is
|
|
2599
2708
|
// silent on purpose — a warning on every light receipt would make the
|
|
2600
2709
|
// containment warnings below unreadable.
|
|
@@ -102,6 +102,16 @@ Same JSON on Claude, Mavis, or OpenCode: `bash .<tool>/hooks/chain-team-phases.s
|
|
|
102
102
|
|
|
103
103
|
**Self-review / re-anchor:** each producing agent records a `## Self-review` block in the artifact it owns (`brief.md` / `implementation.md` / `debug-report.md` / `validation-report.md` / `review.md`) and, on detected context loss / excess, a re-anchor line in `.memlog.md` — `event:` (no plan change) or `decision: replan rev N → N+1` (plan change). No hook/lifecycle field is added.
|
|
104
104
|
|
|
105
|
+
## Database projection
|
|
106
|
+
|
|
107
|
+
`team-db.mjs` projects this tree into `.ai.local/team/team.db` (SQLite, WAL). The files remain authoritative: the database is rebuildable and git-ignored (`team.db`, `team.db-wal`, `team.db-shm`, `team-db-errors.log`).
|
|
108
|
+
|
|
109
|
+
- Write points: the chain hook after its file writes, and `manifest.mjs` after a receipt. Both run one bounded 5 s child; a failure logs one line and never fails the file write.
|
|
110
|
+
- No agent writes lifecycle fields through the database. `status.json` / `metrics.json` stay hook-owned.
|
|
111
|
+
- `AI_RULES_TEAM_DB_DISABLE=1` stops every write point and `serve`; a runtime without `node:sqlite` stays file-only with exit 0.
|
|
112
|
+
- Inspect: `node .ai.local/scripts/team-db.mjs sync`, then `check`; `serve` opens the read-only dashboard at `http://127.0.0.1:4178`.
|
|
113
|
+
- Never commit the database. Delete `team.db*` and run `sync` to rebuild.
|
|
114
|
+
|
|
105
115
|
## Contracts
|
|
106
116
|
|
|
107
117
|
- **Manifest field name:** receipts go in `artifacts[]`. Anything written under `entries` is ignored — the hook reads only `artifacts` and prints a dual-read warning naming the file. See `agent-team/agent-artifact-contracts.md` § Schema field name.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"platform": "opencode",
|
|
4
4
|
"stack": "mcp-ts",
|
|
5
5
|
"semanticSource": "cursor/mcp-ts",
|
|
6
|
-
"sourceRevision": "
|
|
6
|
+
"sourceRevision": "2269c4a4370dd5825ce7bad9d99acf7fe7c6d80ab0f661debfb306238bd6ff51",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
9
9
|
"source": "AGENTS.md",
|
|
@@ -2542,6 +2542,115 @@ if (!input || input.status !== 'completed') {
|
|
|
2542
2542
|
process.exit(0);
|
|
2543
2543
|
}
|
|
2544
2544
|
|
|
2545
|
+
// --- TEAM_DB_PROJECTION -------------------------------------------------------
|
|
2546
|
+
// The status, metrics, compaction and focus writes are already durable when this
|
|
2547
|
+
// postflight starts. The projection is a bounded child process: it must never
|
|
2548
|
+
// fail this stop, never change hook stdout/stderr beyond the capability line,
|
|
2549
|
+
// and never write a task file. A disabled switch, a missing script, or a
|
|
2550
|
+
// runtime without `node:sqlite` is a skip; a child failure is one log line.
|
|
2551
|
+
// This is a plain region marker, not a `hook-slot`: the block is identical in
|
|
2552
|
+
// all 40 rendered bodies and needs no per-stack fragment.
|
|
2553
|
+
// <<<team-db-projection>>>
|
|
2554
|
+
function teamDbTruthy(value) {
|
|
2555
|
+
if (typeof value !== 'string') return false;
|
|
2556
|
+
const normalized = value.trim().toLowerCase();
|
|
2557
|
+
return normalized === '1' || normalized === 'true' || normalized === 'yes';
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2560
|
+
function teamDbLogPath(env) {
|
|
2561
|
+
const override = typeof env.AI_RULES_TEAM_DB_LOG === 'string' ? env.AI_RULES_TEAM_DB_LOG.trim() : '';
|
|
2562
|
+
if (override) return path.resolve(override);
|
|
2563
|
+
return path.join(process.cwd(), '.ai.local', 'team', 'team-db-errors.log');
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
function teamDbLogPhase(env) {
|
|
2567
|
+
const value = typeof env.AI_RULES_TEAM_DB_SEAM === 'string' ? env.AI_RULES_TEAM_DB_SEAM.trim() : '';
|
|
2568
|
+
return value === 'hook' || value === 'receipt' || value === 'cli' || value === 'serve' ? value : 'hook';
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2571
|
+
// One line per failure, newest 200 lines and at most 64 KiB. Never a prompt
|
|
2572
|
+
// body: only the code and the message this block owns.
|
|
2573
|
+
function teamDbLogFailure(env, code, message) {
|
|
2574
|
+
try {
|
|
2575
|
+
const target = teamDbLogPath(env);
|
|
2576
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
2577
|
+
const line = new Date().toISOString() + ' ' + code + ' ' + teamDbLogPhase(env) + ' ' + message;
|
|
2578
|
+
fs.appendFileSync(target, line + '\n');
|
|
2579
|
+
let content = fs.readFileSync(target, 'utf8');
|
|
2580
|
+
let lines = content.split('\n').filter(function (entry) { return entry.length > 0; });
|
|
2581
|
+
if (lines.length > 200) lines = lines.slice(lines.length - 200);
|
|
2582
|
+
while (Buffer.byteLength(lines.join('\n') + '\n', 'utf8') > 65536 && lines.length > 1) lines.shift();
|
|
2583
|
+
content = lines.join('\n') + (lines.length > 0 ? '\n' : '');
|
|
2584
|
+
fs.writeFileSync(target, content);
|
|
2585
|
+
} catch (error) {
|
|
2586
|
+
/* a log failure is not a stop failure */
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
function teamDbSqliteAvailable(env) {
|
|
2591
|
+
if (teamDbTruthy(env.AI_RULES_TEAM_DB_FORCE_FALLBACK)) return false;
|
|
2592
|
+
const match = /^(\d+)\.(\d+)\.(\d+)/.exec(String(process.versions.node || ''));
|
|
2593
|
+
if (!match) return false;
|
|
2594
|
+
const major = Number(match[1]);
|
|
2595
|
+
const minor = Number(match[2]);
|
|
2596
|
+
if (major < 22) return false;
|
|
2597
|
+
if (major === 22 && minor < 13) return false;
|
|
2598
|
+
try {
|
|
2599
|
+
const sqlite = require('node:sqlite');
|
|
2600
|
+
return typeof sqlite.DatabaseSync === 'function';
|
|
2601
|
+
} catch (error) {
|
|
2602
|
+
return false;
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2606
|
+
function teamDbProject() {
|
|
2607
|
+
try {
|
|
2608
|
+
const env = process.env;
|
|
2609
|
+
if (teamDbTruthy(env.AI_RULES_TEAM_DB_DISABLE)) return;
|
|
2610
|
+
// Same pattern as POSTFLIGHT_SLUG_RE above: the slug is re-derived from
|
|
2611
|
+
// `active-task.json` on this path too, so it cannot escape the tree.
|
|
2612
|
+
const slugPattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
2613
|
+
let slug = '';
|
|
2614
|
+
try {
|
|
2615
|
+
const active = JSON.parse(fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', 'active-task.json'), 'utf8'));
|
|
2616
|
+
slug = typeof active.slug === 'string' ? active.slug : '';
|
|
2617
|
+
} catch (error) {
|
|
2618
|
+
return;
|
|
2619
|
+
}
|
|
2620
|
+
if (!slug || slug.length > 48 || !slugPattern.test(slug)) return;
|
|
2621
|
+
const taskDir = path.join(process.cwd(), '.ai.local', 'team', 'tasks', slug);
|
|
2622
|
+
if (!fs.existsSync(path.join(taskDir, 'status.json'))) return;
|
|
2623
|
+
const script = path.join(process.cwd(), '.ai.local', 'scripts', 'team-db.mjs');
|
|
2624
|
+
if (!fs.existsSync(script)) return;
|
|
2625
|
+
if (!teamDbSqliteAvailable(env)) {
|
|
2626
|
+
process.stderr.write('team-db: projection skipped (node:sqlite unavailable); file-only mode\n');
|
|
2627
|
+
return;
|
|
2628
|
+
}
|
|
2629
|
+
const result = spawnSync(
|
|
2630
|
+
process.execPath,
|
|
2631
|
+
['.ai.local/scripts/team-db.mjs', 'sync', '--slug', slug, '--quiet', '--no-rebuild', '--deadline-ms', '4500'],
|
|
2632
|
+
{ cwd: process.cwd(), env: env, encoding: 'utf8', timeout: 5000, killSignal: 'SIGKILL', stdio: ['ignore', 'pipe', 'pipe'] },
|
|
2633
|
+
);
|
|
2634
|
+
if (result.error && result.error.code === 'ETIMEDOUT') {
|
|
2635
|
+
teamDbLogFailure(env, 'E_PROJECTION_TIMEOUT', 'projection exceeded 5000 ms and was killed');
|
|
2636
|
+
return;
|
|
2637
|
+
}
|
|
2638
|
+
if (result.error) {
|
|
2639
|
+
teamDbLogFailure(env, 'E_PROJECTION_FAILED', 'projection could not start: ' + String(result.error.code || 'unknown'));
|
|
2640
|
+
return;
|
|
2641
|
+
}
|
|
2642
|
+
if (typeof result.status === 'number' && result.status !== 0) {
|
|
2643
|
+
teamDbLogFailure(env, 'E_PROJECTION_FAILED', 'projection exited ' + result.status);
|
|
2644
|
+
}
|
|
2645
|
+
} catch (error) {
|
|
2646
|
+
/* the seam never fails the stop */
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
teamDbProject();
|
|
2651
|
+
// <<<team-db-projection-end>>>
|
|
2652
|
+
// --- end TEAM_DB_PROJECTION ---------------------------------------------------
|
|
2653
|
+
|
|
2545
2654
|
// Ratchet: off for `light` pipelines and `spike` intents. A policy skip is
|
|
2546
2655
|
// silent on purpose — a warning on every light receipt would make the
|
|
2547
2656
|
// containment warnings below unreadable.
|
|
@@ -102,6 +102,16 @@ Same JSON on Claude, Mavis, or OpenCode: `bash .<tool>/hooks/chain-team-phases.s
|
|
|
102
102
|
|
|
103
103
|
**Self-review / re-anchor:** each producing agent records a `## Self-review` block in the artifact it owns (`brief.md` / `implementation.md` / `debug-report.md` / `validation-report.md` / `review.md`) and, on detected context loss / excess, a re-anchor line in `.memlog.md` — `event:` (no plan change) or `decision: replan rev N → N+1` (plan change). No hook/lifecycle field is added.
|
|
104
104
|
|
|
105
|
+
## Database projection
|
|
106
|
+
|
|
107
|
+
`team-db.mjs` projects this tree into `.ai.local/team/team.db` (SQLite, WAL). The files remain authoritative: the database is rebuildable and git-ignored (`team.db`, `team.db-wal`, `team.db-shm`, `team-db-errors.log`).
|
|
108
|
+
|
|
109
|
+
- Write points: the chain hook after its file writes, and `manifest.mjs` after a receipt. Both run one bounded 5 s child; a failure logs one line and never fails the file write.
|
|
110
|
+
- No agent writes lifecycle fields through the database. `status.json` / `metrics.json` stay hook-owned.
|
|
111
|
+
- `AI_RULES_TEAM_DB_DISABLE=1` stops every write point and `serve`; a runtime without `node:sqlite` stays file-only with exit 0.
|
|
112
|
+
- Inspect: `node .ai.local/scripts/team-db.mjs sync`, then `check`; `serve` opens the read-only dashboard at `http://127.0.0.1:4178`.
|
|
113
|
+
- Never commit the database. Delete `team.db*` and run `sync` to rebuild.
|
|
114
|
+
|
|
105
115
|
## Contracts
|
|
106
116
|
|
|
107
117
|
- **Manifest field name:** receipts go in `artifacts[]`. Anything written under `entries` is ignored — the hook reads only `artifacts` and prints a dual-read warning naming the file. See `agent-team/agent-artifact-contracts.md` § Schema field name.
|
|
@@ -13,6 +13,13 @@ Merged into project `opencode.json` `mcp` on `ai-rules init opencode --preset ne
|
|
|
13
13
|
|
|
14
14
|
Do not put secrets in the file. Optional: `CONTEXT7_API_KEY` in the environment — higher Context7 rate limits. Figma — local desktop server (enable in Figma Desktop, Dev/Full seat).
|
|
15
15
|
|
|
16
|
+
## Managed pack (GitLab, Yandex Tracker, Yandex Wiki)
|
|
17
|
+
|
|
18
|
+
Not shipped by `init`: a credential-less server would fail in every consumer.
|
|
19
|
+
Run `npx -y @bonesofspring/ai-rules mcp setup <gitlab|yandex>` once per provider.
|
|
20
|
+
It stores credentials under `.ai-rules/mcp/` (ignored, `0600`), registers installed clients, and runs a doctor.
|
|
21
|
+
Guide: `docs/MCP-SETUP.md` in the package.
|
|
22
|
+
Remove with `npx -y @bonesofspring/ai-rules mcp remove <provider>`.
|
|
16
23
|
|
|
17
24
|
## Pin policy
|
|
18
25
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"platform": "opencode",
|
|
4
4
|
"stack": "next",
|
|
5
5
|
"semanticSource": "cursor/next",
|
|
6
|
-
"sourceRevision": "
|
|
6
|
+
"sourceRevision": "47860257b2b5b83625fd2d35c616d8d17365f0e072310319215a39d9b15ab8d8",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
9
9
|
"source": "AGENTS.md",
|
|
@@ -2598,6 +2598,115 @@ if (!input || input.status !== 'completed') {
|
|
|
2598
2598
|
process.exit(0);
|
|
2599
2599
|
}
|
|
2600
2600
|
|
|
2601
|
+
// --- TEAM_DB_PROJECTION -------------------------------------------------------
|
|
2602
|
+
// The status, metrics, compaction and focus writes are already durable when this
|
|
2603
|
+
// postflight starts. The projection is a bounded child process: it must never
|
|
2604
|
+
// fail this stop, never change hook stdout/stderr beyond the capability line,
|
|
2605
|
+
// and never write a task file. A disabled switch, a missing script, or a
|
|
2606
|
+
// runtime without `node:sqlite` is a skip; a child failure is one log line.
|
|
2607
|
+
// This is a plain region marker, not a `hook-slot`: the block is identical in
|
|
2608
|
+
// all 40 rendered bodies and needs no per-stack fragment.
|
|
2609
|
+
// <<<team-db-projection>>>
|
|
2610
|
+
function teamDbTruthy(value) {
|
|
2611
|
+
if (typeof value !== 'string') return false;
|
|
2612
|
+
const normalized = value.trim().toLowerCase();
|
|
2613
|
+
return normalized === '1' || normalized === 'true' || normalized === 'yes';
|
|
2614
|
+
}
|
|
2615
|
+
|
|
2616
|
+
function teamDbLogPath(env) {
|
|
2617
|
+
const override = typeof env.AI_RULES_TEAM_DB_LOG === 'string' ? env.AI_RULES_TEAM_DB_LOG.trim() : '';
|
|
2618
|
+
if (override) return path.resolve(override);
|
|
2619
|
+
return path.join(process.cwd(), '.ai.local', 'team', 'team-db-errors.log');
|
|
2620
|
+
}
|
|
2621
|
+
|
|
2622
|
+
function teamDbLogPhase(env) {
|
|
2623
|
+
const value = typeof env.AI_RULES_TEAM_DB_SEAM === 'string' ? env.AI_RULES_TEAM_DB_SEAM.trim() : '';
|
|
2624
|
+
return value === 'hook' || value === 'receipt' || value === 'cli' || value === 'serve' ? value : 'hook';
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
// One line per failure, newest 200 lines and at most 64 KiB. Never a prompt
|
|
2628
|
+
// body: only the code and the message this block owns.
|
|
2629
|
+
function teamDbLogFailure(env, code, message) {
|
|
2630
|
+
try {
|
|
2631
|
+
const target = teamDbLogPath(env);
|
|
2632
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
2633
|
+
const line = new Date().toISOString() + ' ' + code + ' ' + teamDbLogPhase(env) + ' ' + message;
|
|
2634
|
+
fs.appendFileSync(target, line + '\n');
|
|
2635
|
+
let content = fs.readFileSync(target, 'utf8');
|
|
2636
|
+
let lines = content.split('\n').filter(function (entry) { return entry.length > 0; });
|
|
2637
|
+
if (lines.length > 200) lines = lines.slice(lines.length - 200);
|
|
2638
|
+
while (Buffer.byteLength(lines.join('\n') + '\n', 'utf8') > 65536 && lines.length > 1) lines.shift();
|
|
2639
|
+
content = lines.join('\n') + (lines.length > 0 ? '\n' : '');
|
|
2640
|
+
fs.writeFileSync(target, content);
|
|
2641
|
+
} catch (error) {
|
|
2642
|
+
/* a log failure is not a stop failure */
|
|
2643
|
+
}
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
function teamDbSqliteAvailable(env) {
|
|
2647
|
+
if (teamDbTruthy(env.AI_RULES_TEAM_DB_FORCE_FALLBACK)) return false;
|
|
2648
|
+
const match = /^(\d+)\.(\d+)\.(\d+)/.exec(String(process.versions.node || ''));
|
|
2649
|
+
if (!match) return false;
|
|
2650
|
+
const major = Number(match[1]);
|
|
2651
|
+
const minor = Number(match[2]);
|
|
2652
|
+
if (major < 22) return false;
|
|
2653
|
+
if (major === 22 && minor < 13) return false;
|
|
2654
|
+
try {
|
|
2655
|
+
const sqlite = require('node:sqlite');
|
|
2656
|
+
return typeof sqlite.DatabaseSync === 'function';
|
|
2657
|
+
} catch (error) {
|
|
2658
|
+
return false;
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
|
|
2662
|
+
function teamDbProject() {
|
|
2663
|
+
try {
|
|
2664
|
+
const env = process.env;
|
|
2665
|
+
if (teamDbTruthy(env.AI_RULES_TEAM_DB_DISABLE)) return;
|
|
2666
|
+
// Same pattern as POSTFLIGHT_SLUG_RE above: the slug is re-derived from
|
|
2667
|
+
// `active-task.json` on this path too, so it cannot escape the tree.
|
|
2668
|
+
const slugPattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
2669
|
+
let slug = '';
|
|
2670
|
+
try {
|
|
2671
|
+
const active = JSON.parse(fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', 'active-task.json'), 'utf8'));
|
|
2672
|
+
slug = typeof active.slug === 'string' ? active.slug : '';
|
|
2673
|
+
} catch (error) {
|
|
2674
|
+
return;
|
|
2675
|
+
}
|
|
2676
|
+
if (!slug || slug.length > 48 || !slugPattern.test(slug)) return;
|
|
2677
|
+
const taskDir = path.join(process.cwd(), '.ai.local', 'team', 'tasks', slug);
|
|
2678
|
+
if (!fs.existsSync(path.join(taskDir, 'status.json'))) return;
|
|
2679
|
+
const script = path.join(process.cwd(), '.ai.local', 'scripts', 'team-db.mjs');
|
|
2680
|
+
if (!fs.existsSync(script)) return;
|
|
2681
|
+
if (!teamDbSqliteAvailable(env)) {
|
|
2682
|
+
process.stderr.write('team-db: projection skipped (node:sqlite unavailable); file-only mode\n');
|
|
2683
|
+
return;
|
|
2684
|
+
}
|
|
2685
|
+
const result = spawnSync(
|
|
2686
|
+
process.execPath,
|
|
2687
|
+
['.ai.local/scripts/team-db.mjs', 'sync', '--slug', slug, '--quiet', '--no-rebuild', '--deadline-ms', '4500'],
|
|
2688
|
+
{ cwd: process.cwd(), env: env, encoding: 'utf8', timeout: 5000, killSignal: 'SIGKILL', stdio: ['ignore', 'pipe', 'pipe'] },
|
|
2689
|
+
);
|
|
2690
|
+
if (result.error && result.error.code === 'ETIMEDOUT') {
|
|
2691
|
+
teamDbLogFailure(env, 'E_PROJECTION_TIMEOUT', 'projection exceeded 5000 ms and was killed');
|
|
2692
|
+
return;
|
|
2693
|
+
}
|
|
2694
|
+
if (result.error) {
|
|
2695
|
+
teamDbLogFailure(env, 'E_PROJECTION_FAILED', 'projection could not start: ' + String(result.error.code || 'unknown'));
|
|
2696
|
+
return;
|
|
2697
|
+
}
|
|
2698
|
+
if (typeof result.status === 'number' && result.status !== 0) {
|
|
2699
|
+
teamDbLogFailure(env, 'E_PROJECTION_FAILED', 'projection exited ' + result.status);
|
|
2700
|
+
}
|
|
2701
|
+
} catch (error) {
|
|
2702
|
+
/* the seam never fails the stop */
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
teamDbProject();
|
|
2707
|
+
// <<<team-db-projection-end>>>
|
|
2708
|
+
// --- end TEAM_DB_PROJECTION ---------------------------------------------------
|
|
2709
|
+
|
|
2601
2710
|
// Ratchet: off for `light` pipelines and `spike` intents. A policy skip is
|
|
2602
2711
|
// silent on purpose — a warning on every light receipt would make the
|
|
2603
2712
|
// containment warnings below unreadable.
|
|
@@ -114,6 +114,16 @@ Same JSON on Claude, Mavis, or OpenCode: `bash .<tool>/hooks/chain-team-phases.s
|
|
|
114
114
|
|
|
115
115
|
**Self-review / re-anchor:** each producing agent records a `## Self-review` block in the artifact it owns (`brief.md` / `implementation.md` / `debug-report.md` / `validation-report.md` / `review.md`) and, on detected context loss / excess, a re-anchor line in `.memlog.md` — `event:` (no plan change) or `decision: replan rev N → N+1` (plan change). No hook/lifecycle field is added.
|
|
116
116
|
|
|
117
|
+
## Database projection
|
|
118
|
+
|
|
119
|
+
`team-db.mjs` projects this tree into `.ai.local/team/team.db` (SQLite, WAL). The files remain authoritative: the database is rebuildable and git-ignored (`team.db`, `team.db-wal`, `team.db-shm`, `team-db-errors.log`).
|
|
120
|
+
|
|
121
|
+
- Write points: the chain hook after its file writes, and `manifest.mjs` after a receipt. Both run one bounded 5 s child; a failure logs one line and never fails the file write.
|
|
122
|
+
- No agent writes lifecycle fields through the database. `status.json` / `metrics.json` stay hook-owned.
|
|
123
|
+
- `AI_RULES_TEAM_DB_DISABLE=1` stops every write point and `serve`; a runtime without `node:sqlite` stays file-only with exit 0.
|
|
124
|
+
- Inspect: `node .ai.local/scripts/team-db.mjs sync`, then `check`; `serve` opens the read-only dashboard at `http://127.0.0.1:4178`.
|
|
125
|
+
- Never commit the database. Delete `team.db*` and run `sync` to rebuild.
|
|
126
|
+
|
|
117
127
|
## Contracts
|
|
118
128
|
|
|
119
129
|
- **Manifest field name:** receipts go in `artifacts[]`. Anything written under `entries` is ignored — the hook reads only `artifacts` and prints a dual-read warning naming the file. See `agent-team/agent-artifact-contracts.md` § Schema field name.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"platform": "opencode",
|
|
4
4
|
"stack": "nuxt",
|
|
5
5
|
"semanticSource": "cursor/nuxt",
|
|
6
|
-
"sourceRevision": "
|
|
6
|
+
"sourceRevision": "ac04affe9cd7fd447404ed70180a7f7f32e9ae841da56ea557099a7a0eeab99a",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
9
9
|
"source": "AGENTS.md",
|