@buildr-ai/buildr 0.1.0-rc.2 → 0.1.0-rc.21
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 +47 -5
- package/application-payload.json +595 -0
- package/bin/buildr.mjs +14 -0
- package/installation-origin.json +13 -0
- package/package.json +16 -45
- package/payload/licenses/dependencies/yaml-LICENSE +13 -0
- package/payload/product/LICENSE +21 -0
- package/payload/product/README.md +59 -0
- package/payload/product/package/README.md +42 -0
- package/{package → payload/product/package}/bootstrap/contract.yml +26 -11
- package/{package → payload/product/package}/bootstrap/guide.md +11 -11
- package/payload/product/package/launchers/assets/Buildr.icns +0 -0
- package/payload/product/package/launchers/assets/Buildr.ico +0 -0
- package/payload/product/package/manifest.yml +547 -0
- package/payload/product/package/targets/runtime/skills/buildr/SKILL.md +174 -0
- package/{package → payload/product/package}/targets/workspace/commands/buildr/openspec/manifest.yml +2 -2
- package/payload/product/package/targets/workspace/components/buildr/openspec/component.yml +79 -0
- package/payload/product/package/targets/workspace/components/buildr/openspec/contributions/openspec-apply-sidebar.md +21 -0
- package/payload/product/package/targets/workspace/components/buildr/openspec/contributions/openspec-archive-converge.md +5 -0
- package/payload/product/package/targets/workspace/components/buildr/openspec/contributions/openspec-explore-terminology.md +5 -0
- package/payload/product/package/targets/workspace/components/buildr/openspec/contributions/openspec-propose-sidebar.md +21 -0
- package/payload/product/package/targets/workspace/components/buildr/openspec/contributions/openspec-sync-converge.md +5 -0
- package/payload/product/package/targets/workspace/components/buildr/openspec/contributions/openspec-update-sidebar.md +13 -0
- package/payload/product/package/targets/workspace/gitattributes +1 -0
- package/payload/product/package/targets/workspace/gitignore +31 -0
- package/{package → payload/product/package}/targets/workspace/projects/AGENTS.project.md +1 -1
- package/payload/product/package/targets/workspace/rules/buildr/core.md +62 -0
- package/payload/product/package/targets/workspace/skills/buildr/capability-adaptation/SKILL.md +56 -0
- package/payload/product/package/targets/workspace/skills/buildr/capability-adaptation/agents/openai.yaml +4 -0
- package/payload/product/package/targets/workspace/skills/buildr/current-knowledge-maintenance/SKILL.md +103 -0
- package/payload/product/package/targets/workspace/skills/buildr/declaration-intake/SKILL.md +65 -0
- package/payload/product/package/targets/workspace/skills/buildr/git-operations/SKILL.md +100 -0
- package/payload/product/package/targets/workspace/skills/buildr/openspec-contract-guard/SKILL.md +65 -0
- package/payload/product/package/targets/workspace/skills/buildr/project-daily-progress/SKILL.md +52 -0
- package/payload/product/package/targets/workspace/skills/buildr/project-testing/SKILL.md +84 -0
- package/payload/product/package/targets/workspace/skills/buildr/project-testing/references/testing-model-v1.md +116 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-development/SKILL.md +108 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-environment/SKILL.md +42 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-environment/agents/openai.yaml +4 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-environment/references/project-environment-preparation-v1.md +14 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-environment/templates/project-preparation.yml +20 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-environment/templates/task-environment-plan-request.json +17 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-finish/SKILL.md +80 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-manager/SKILL.md +47 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-manager/agents/openai.yaml +4 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-retrospective/SKILL.md +101 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-retrospective/agents/openai.yaml +4 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-review/SKILL.md +60 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-review/agents/openai.yaml +4 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-triage/SKILL.md +119 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-verification/SKILL.md +142 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-verification/references/project-verification-v2.md +51 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-verification/templates/project-verification.yml +16 -0
- package/payload/product/package/targets/workspace/skills/buildr/task-worktree/SKILL.md +28 -0
- package/payload/product/package/targets/workspace/skills/buildr/terminology-governance/SKILL.md +60 -0
- package/payload/product/package/targets/workspace/skills/buildr/ui-preview/SKILL.md +74 -0
- package/payload/product/package/targets/workspace/skills/contracts/buildr/current-knowledge-maintenance/v1.md +36 -0
- package/payload/product/package/targets/workspace/skills/contracts/buildr/current-knowledge-maintenance/v2.md +45 -0
- package/payload/product/package/targets/workspace/skills/contracts/buildr/git-operations/v1.md +39 -0
- package/payload/product/package/targets/workspace/skills/contracts/buildr/git-worktree-provider/v1.md +35 -0
- package/payload/product/package/targets/workspace/skills/contracts/buildr/task-development/v2.md +61 -0
- package/payload/product/package/targets/workspace/skills/contracts/buildr/task-environment/v1.md +37 -0
- package/payload/product/package/targets/workspace/skills/contracts/buildr/task-finish/v1.md +59 -0
- package/payload/product/package/targets/workspace/skills/contracts/buildr/task-record/v2.md +35 -0
- package/payload/product/package/targets/workspace/skills/contracts/buildr/task-retrospective/v2.md +41 -0
- package/payload/product/package/targets/workspace/skills/contracts/buildr/task-review/v1.md +39 -0
- package/payload/product/package/targets/workspace/skills/contracts/buildr/task-verification/v3.md +63 -0
- package/payload/product/package/targets/workspace/skills/contracts/buildr/terminology-governance/v1.md +36 -0
- package/{package → payload/product/package}/targets/workspace/skills/openspec/openspec-apply-change/SKILL.md +4 -3
- package/{package → payload/product/package}/targets/workspace/skills/openspec/openspec-archive-change/SKILL.md +4 -3
- package/{package → payload/product/package}/targets/workspace/skills/openspec/openspec-explore/SKILL.md +4 -1
- package/{package → payload/product/package}/targets/workspace/skills/openspec/openspec-propose/SKILL.md +4 -1
- package/{package → payload/product/package}/targets/workspace/skills/openspec/openspec-sync-specs/SKILL.md +4 -3
- package/payload/product/package/targets/workspace/skills/openspec/openspec-update-change/SKILL.md +86 -0
- package/payload/product/package.json +33 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0000_create_migration_ledger.sql +16 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0001_create_task_store.sql +47 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0002_create_parent_task_relations.sql +7 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0003_inline_parent_task_column.sql +19 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0004_create_task_current_records.sql +16 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0005_create_task_retrospective_current.sql +4 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0006_create_task_lifecycle_current.sql +4 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0007_create_task_finish_current.sql +46 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0008_create_task_environment_current.sql +8 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0009_retire_task_lifecycle_current.sql +107 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0010_add_task_retrospective_disposition.sql +19 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0011_create_task_execution_records.sql +115 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0012_compact_task_finish_current.sql +261 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0013_add_todo_task_retrospective_sources.sql +56 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0014_add_task_execution_invocation_identity.sql +14 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0015_add_task_execution_unknown_outcome.sql +143 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0016_allow_terminal_task_finish_target_lease.sql +83 -0
- package/payload/product/src/infrastructure/sqlite/migrations/0017_expand_task_finish_repository_set.sql +111 -0
- package/payload/product/src/interfaces/local-app/web-dist/assets/antd-NAtxFWmu.js +394 -0
- package/payload/product/src/interfaces/local-app/web-dist/assets/index-BqoyfMSY.css +1 -0
- package/payload/product/src/interfaces/local-app/web-dist/assets/index-DTqvE0TF.js +39 -0
- package/payload/product/src/interfaces/local-app/web-dist/assets/react-9kRp7SbA.js +28 -0
- package/payload/product/src/interfaces/local-app/web-dist/index.html +19 -0
- package/payload/runtime/read-worker.cjs +45071 -0
- package/runtime/buildr.cjs +51533 -0
- package/scripts/postinstall.mjs +15 -0
- package/docs/agent-runtime-adapters.md +0 -94
- package/docs/cli-architecture.md +0 -65
- package/docs/cli-reference.md +0 -67
- package/docs/known-limitations.md +0 -15
- package/examples/minimal-workspace/README.md +0 -24
- package/package/README.md +0 -28
- package/package/manifest.yml +0 -150
- package/package/targets/runtime/skills/buildr/SKILL.md +0 -154
- package/package/targets/workspace/.buildr/workspace.yml +0 -5
- package/package/targets/workspace/commands/manifest.yml +0 -2
- package/package/targets/workspace/components/buildr/openspec/component.yml +0 -16
- package/package/targets/workspace/components/buildr/openspec/contributions/openspec-apply-sidebar.md +0 -3
- package/package/targets/workspace/components/buildr/openspec/contributions/openspec-archive-sidebar.md +0 -3
- package/package/targets/workspace/components/buildr/openspec/contributions/openspec-explore-sidebar.md +0 -3
- package/package/targets/workspace/components/buildr/openspec/contributions/openspec-propose-sidebar.md +0 -3
- package/package/targets/workspace/components/buildr/openspec/contributions/openspec-sync-sidebar.md +0 -3
- package/package/targets/workspace/components/buildr/openspec/contributions/task-finish-post-sync.md +0 -1
- package/package/targets/workspace/components/buildr/openspec/contributions/task-finish-pre-sync.md +0 -1
- package/package/targets/workspace/components/buildr/openspec/contributions/task-triage-change-ready.md +0 -10
- package/package/targets/workspace/components/manifest.yml +0 -2
- package/package/targets/workspace/gitignore +0 -16
- package/package/targets/workspace/projects/manifest.yml +0 -2
- package/package/targets/workspace/projects/services/manifest.yml +0 -3
- package/package/targets/workspace/projects/skills/manifest.yml +0 -2
- package/package/targets/workspace/rules/buildr/core.md +0 -65
- package/package/targets/workspace/rules/manifest.yml +0 -9
- package/package/targets/workspace/skills/buildr/git-ops/SKILL.md +0 -73
- package/package/targets/workspace/skills/buildr/openspec-contract-guard/SKILL.md +0 -67
- package/package/targets/workspace/skills/buildr/task-finish/SKILL.md +0 -104
- package/package/targets/workspace/skills/buildr/task-triage/SKILL.md +0 -103
- package/package/targets/workspace/skills/buildr/task-worktree/SKILL.md +0 -104
- package/package/targets/workspace/skills/manifest.yml +0 -38
- package/tools/buildr +0 -11
- package/tools/cli/application/cli-update.mjs +0 -219
- package/tools/cli/application/compose-runtime.mjs +0 -38
- package/tools/cli/application/doctor/runtime-diagnostics.mjs +0 -227
- package/tools/cli/application/doctor/scope-diagnostics.mjs +0 -440
- package/tools/cli/application/doctor/service-diagnostics.mjs +0 -184
- package/tools/cli/application/doctor.mjs +0 -201
- package/tools/cli/application/package-maintenance/builtin-receipts.mjs +0 -73
- package/tools/cli/application/package-maintenance/output.mjs +0 -148
- package/tools/cli/application/package-maintenance/smoke-checks.mjs +0 -463
- package/tools/cli/application/package-maintenance/static-validation.mjs +0 -680
- package/tools/cli/application/package-maintenance.mjs +0 -540
- package/tools/cli/application/runtime.mjs +0 -118
- package/tools/cli/application/workspace-operations.mjs +0 -311
- package/tools/cli/bootstrap.mjs +0 -6
- package/tools/cli/command/help.mjs +0 -296
- package/tools/cli/command/registry.mjs +0 -97
- package/tools/cli/domains/commands.mjs +0 -661
- package/tools/cli/domains/components.mjs +0 -922
- package/tools/cli/domains/openspec.mjs +0 -603
- package/tools/cli/domains/package-assets.mjs +0 -652
- package/tools/cli/domains/rules.mjs +0 -380
- package/tools/cli/domains/runtime.mjs +0 -87
- package/tools/cli/domains/skills.mjs +0 -647
- package/tools/cli/domains/workspace.mjs +0 -571
- package/tools/cli/shared/infrastructure.mjs +0 -411
- package/tools/cli/shared/json-contracts.mjs +0 -22
- package/tools/cli/shared/platform.mjs +0 -52
- package/tools/runtime/adapter-contract.mjs +0 -655
- package/tools/runtime/check-claude-code.mjs +0 -23
- package/tools/runtime/check-codex.mjs +0 -23
- package/tools/runtime/check-runtime.mjs +0 -98
- package/tools/runtime/projection.mjs +0 -375
- package/tools/runtime/render-claude-code-rules.mjs +0 -459
- package/tools/runtime/render-claude-code.mjs +0 -59
- package/tools/runtime/skills/arguments.mjs +0 -51
- package/tools/runtime/skills/contributions.mjs +0 -171
- package/tools/runtime/skills/manifests.mjs +0 -167
- package/tools/runtime/skills/primitives.mjs +0 -86
- package/tools/runtime/skills/render-plan.mjs +0 -243
- package/tools/runtime/skills/sources.mjs +0 -276
- package/tools/shared/fetch-remote-text.mjs +0 -78
- package/tools/verification/integrity/managed-data-integrity.mjs +0 -107
- package/tools/verification/integrity/managed-mutations.mjs +0 -72
- package/tools/verification/openspec/contract.mjs +0 -212
- package/tools/verification/runtime/adapter-contract.mjs +0 -218
- package/tools/verification/runtime/adapter-parity.mjs +0 -173
- /package/{package → payload/product/package}/targets/workspace/AGENTS.md +0 -0
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import process from 'node:process';
|
|
4
|
-
import { checkRuntimeAdapter, printRuntimeAdapterCheckReport } from './check-runtime.mjs';
|
|
5
|
-
import { repairCommands } from './projection.mjs';
|
|
6
|
-
|
|
7
|
-
export function claudeCodeRepairCommands(result) { return repairCommands(result, 'claude-code'); }
|
|
8
|
-
export function printRuntimeCheckReport(result) { printRuntimeAdapterCheckReport(result); }
|
|
9
|
-
|
|
10
|
-
export function checkClaudeCodeRuntime(argv, options = {}) {
|
|
11
|
-
return checkRuntimeAdapter(argv, { ...options, adapterId: 'claude-code', command: options.command ?? 'buildr runtime check claude-code' });
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
15
|
-
try {
|
|
16
|
-
const result = checkClaudeCodeRuntime(process.argv.slice(2), { command: 'node tools/runtime/check-claude-code.mjs' });
|
|
17
|
-
printRuntimeCheckReport(result);
|
|
18
|
-
process.exit(result.exitCode);
|
|
19
|
-
} catch (error) {
|
|
20
|
-
console.error(error.message);
|
|
21
|
-
process.exit(2);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import process from 'node:process';
|
|
4
|
-
import { checkRuntimeAdapter, printRuntimeAdapterCheckReport } from './check-runtime.mjs';
|
|
5
|
-
import { repairCommands } from './projection.mjs';
|
|
6
|
-
|
|
7
|
-
export function codexRepairCommands(result) { return repairCommands(result, 'codex'); }
|
|
8
|
-
export function printCodexRuntimeCheckReport(result) { printRuntimeAdapterCheckReport(result); }
|
|
9
|
-
|
|
10
|
-
export function checkCodexRuntime(argv, options = {}) {
|
|
11
|
-
return checkRuntimeAdapter(argv, { ...options, adapterId: 'codex', command: options.command ?? 'buildr runtime check codex' });
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
15
|
-
try {
|
|
16
|
-
const result = checkCodexRuntime(process.argv.slice(2), { command: 'node tools/runtime/check-codex.mjs' });
|
|
17
|
-
printCodexRuntimeCheckReport(result);
|
|
18
|
-
process.exit(result.exitCode);
|
|
19
|
-
} catch (error) {
|
|
20
|
-
console.error(error.message);
|
|
21
|
-
process.exit(2);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import process from 'node:process';
|
|
3
|
-
import { spawnSync } from 'node:child_process';
|
|
4
|
-
import { getRuntimeAdapter } from './adapter-contract.mjs';
|
|
5
|
-
import { checkRuntimeProjection, printRuntimeProjectionReport } from './projection.mjs';
|
|
6
|
-
import { parseRenderClaudeCodeArgs } from './render-claude-code.mjs';
|
|
7
|
-
|
|
8
|
-
function runEnvironmentProbe(probe) {
|
|
9
|
-
if (probe.kind === 'none') return { status: 'not-checked', probe: 'none' };
|
|
10
|
-
if (probe.kind === 'manual') return { status: 'manual', probe: 'manual', guidance: probe.guidance };
|
|
11
|
-
const result = spawnSync(probe.executable, probe.args, {
|
|
12
|
-
encoding: 'utf8',
|
|
13
|
-
timeout: probe.timeoutMs,
|
|
14
|
-
shell: false,
|
|
15
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
16
|
-
});
|
|
17
|
-
const evidence = [result.stdout, result.stderr].filter(Boolean).join('\n').trim();
|
|
18
|
-
if (result.error?.code === 'ENOENT') return { status: 'missing', probe: 'command', executable: probe.executable, args: probe.args, evidence: result.error.message };
|
|
19
|
-
if (result.error) return { status: 'missing', probe: 'command', executable: probe.executable, args: probe.args, evidence: result.error.message };
|
|
20
|
-
return {
|
|
21
|
-
status: result.status === 0 ? 'ok' : 'missing',
|
|
22
|
-
probe: 'command',
|
|
23
|
-
executable: probe.executable,
|
|
24
|
-
args: probe.args,
|
|
25
|
-
exitCode: result.status,
|
|
26
|
-
...(evidence ? { evidence } : {}),
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function prerequisiteFindings(adapter) {
|
|
31
|
-
return (adapter.traits.checker.prerequisites || []).map((item) => ({
|
|
32
|
-
status: 'warning',
|
|
33
|
-
path: '.',
|
|
34
|
-
adapter: adapter.id,
|
|
35
|
-
code: item.code,
|
|
36
|
-
message: item.message,
|
|
37
|
-
suggestion: item.guidance,
|
|
38
|
-
userActionRequired: true,
|
|
39
|
-
}));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function environmentFindings(adapter, checks) {
|
|
43
|
-
const findings = [];
|
|
44
|
-
if (checks.installation.status === 'missing') {
|
|
45
|
-
findings.push({
|
|
46
|
-
status: 'warning', path: '.', adapter: adapter.id,
|
|
47
|
-
code: `runtime.${adapter.id.replaceAll('-', '_')}_installation_missing`,
|
|
48
|
-
message: `${adapter.displayName} installation probe failed.`,
|
|
49
|
-
suggestion: checks.installation.evidence || `Install ${adapter.displayName} or verify its command/application path.`,
|
|
50
|
-
userActionRequired: true,
|
|
51
|
-
});
|
|
52
|
-
} else if (checks.installation.status === 'ok' && checks.version.status === 'missing') {
|
|
53
|
-
findings.push({
|
|
54
|
-
status: 'warning', path: '.', adapter: adapter.id,
|
|
55
|
-
code: `runtime.${adapter.id.replaceAll('-', '_')}_version_unavailable`,
|
|
56
|
-
message: `${adapter.displayName} version probe failed.`,
|
|
57
|
-
suggestion: checks.version.evidence || `Verify the installed ${adapter.displayName} version manually.`,
|
|
58
|
-
userActionRequired: true,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return findings;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function checkRuntimeAdapter(argv, options = {}) {
|
|
65
|
-
const adapterId = options.adapterId;
|
|
66
|
-
const adapter = getRuntimeAdapter(adapterId);
|
|
67
|
-
const repoRoot = options.repoRoot ?? process.cwd();
|
|
68
|
-
const args = parseRenderClaudeCodeArgs(argv, options.command ?? `buildr runtime check ${adapter.id}`);
|
|
69
|
-
const result = checkRuntimeProjection({ repoRoot, targetRoot: path.resolve(repoRoot, args.target), scope: args.scope, adapterId: adapter.id });
|
|
70
|
-
const environmentChecks = {
|
|
71
|
-
installation: runEnvironmentProbe(adapter.traits.checker.installationProbe),
|
|
72
|
-
version: runEnvironmentProbe(adapter.traits.checker.versionProbe),
|
|
73
|
-
};
|
|
74
|
-
const prerequisites = prerequisiteFindings(adapter);
|
|
75
|
-
const environment = environmentFindings(adapter, environmentChecks);
|
|
76
|
-
result.findings.push(...prerequisites, ...environment);
|
|
77
|
-
result.counts.warning += prerequisites.length + environment.length;
|
|
78
|
-
return {
|
|
79
|
-
...result,
|
|
80
|
-
environmentChecks,
|
|
81
|
-
activation: adapter.traits.activation,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function printRuntimeAdapterCheckReport(result) {
|
|
86
|
-
printRuntimeProjectionReport(result, getRuntimeAdapter(result.adapterId).displayName);
|
|
87
|
-
console.log('\nEnvironment:');
|
|
88
|
-
for (const [name, check] of Object.entries(result.environmentChecks)) {
|
|
89
|
-
const evidence = check.evidence ? ` - ${check.evidence.replaceAll('\n', ' | ')}` : '';
|
|
90
|
-
console.log(` ${name}: ${check.status} (${check.probe})${evidence}`);
|
|
91
|
-
if (check.guidance) console.log(` ${check.guidance}`);
|
|
92
|
-
}
|
|
93
|
-
console.log(`Activation: rules=${result.activation.rules} skills=${result.activation.skills}`);
|
|
94
|
-
if (result.activation.reloadGuidance) console.log(`Reload: ${result.activation.reloadGuidance}`);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export const RUNTIME_CHECKERS = Object.freeze({ projection: checkRuntimeAdapter });
|
|
98
|
-
export const RUNTIME_CHECK_PRINTERS = Object.freeze({ projection: printRuntimeAdapterCheckReport });
|
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import crypto from 'node:crypto';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import {
|
|
5
|
-
createRuntimeContext,
|
|
6
|
-
getRuntimeAdapter,
|
|
7
|
-
assertRuntimeTargetPath,
|
|
8
|
-
reconcileRuntimePlan,
|
|
9
|
-
selectAdapterImplementation,
|
|
10
|
-
} from './adapter-contract.mjs';
|
|
11
|
-
import {
|
|
12
|
-
buildSkillRenderPlan,
|
|
13
|
-
hasManagedSkillMarker,
|
|
14
|
-
resolvePackageAgentSkill,
|
|
15
|
-
resolveRenderSkills,
|
|
16
|
-
} from './render-claude-code.mjs';
|
|
17
|
-
import {
|
|
18
|
-
buildRuleDiscoveryPlan,
|
|
19
|
-
hasManagedRulesMarker,
|
|
20
|
-
planRulesRender,
|
|
21
|
-
resolveRuleScope,
|
|
22
|
-
} from './render-claude-code-rules.mjs';
|
|
23
|
-
|
|
24
|
-
const INSTALL_PLAN_MARKER = '<!-- Generated by Buildr. Agent action required.';
|
|
25
|
-
const ADAPTER_RULE_MARKER = '<!-- Generated by Buildr. Agent adapter:';
|
|
26
|
-
const VENDOR_DISCOVERY_EXCLUDED = new Set(['.git', '.hg', '.svn', '.worktrees', '.agents', '.claude', '.cursor', '.qoder', '.trae', '.codebuddy', '.workbuddy', 'node_modules', 'vendor', 'dist', 'build', 'coverage']);
|
|
27
|
-
|
|
28
|
-
export function runtimeSkillScope(scope) {
|
|
29
|
-
const parts = scope.split('/');
|
|
30
|
-
return parts[0] === 'projects' && parts[1] ? `projects/${parts[1]}` : '.';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function skillDiagnostic(item, product) {
|
|
34
|
-
const installPlan = item.targetFile.includes(`${path.sep}skill-install-plans${path.sep}`);
|
|
35
|
-
if (installPlan) {
|
|
36
|
-
return {
|
|
37
|
-
label: `workspace Skill install plan ${path.basename(item.targetFile, '.md')}`,
|
|
38
|
-
code: 'runtime.skill_agent_action_required',
|
|
39
|
-
repair: 'agent-install',
|
|
40
|
-
repairs: { missing: 'skills-render', stale: 'agent-install' },
|
|
41
|
-
currentStatus: 'warning',
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
const conflict = `Refusing to overwrite non-Buildr-managed file: ${item.targetFile}`;
|
|
45
|
-
return product
|
|
46
|
-
? { label: 'product Agent Skill buildr', codes: { ok: 'runtime.product_skill_ok', missing: 'runtime.product_skill_missing', stale: 'runtime.product_skill_stale', conflict: 'runtime.product_skill_conflict' }, messages: { conflict }, repair: 'skill-install' }
|
|
47
|
-
: { label: `workspace Skill ${path.basename(path.dirname(item.targetFile))}`, codes: { ok: 'runtime.skill_ok', missing: 'runtime.skill_missing', stale: 'runtime.skill_stale', conflict: 'runtime.skill_conflict' }, messages: { conflict }, repair: 'skills-render' };
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function decorateSkillWrites(items, product = false) {
|
|
51
|
-
return items.map((item) => ({
|
|
52
|
-
...item,
|
|
53
|
-
capability: product ? 'product-buildr-skill' : item.targetFile.includes(`${path.sep}skill-install-plans${path.sep}`) ? 'skill-install-plans' : 'workspace-project-skills',
|
|
54
|
-
isManaged: (content) => hasManagedSkillMarker(content) || content.includes(INSTALL_PLAN_MARKER),
|
|
55
|
-
diagnostic: skillDiagnostic(item, product),
|
|
56
|
-
}));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function ruleFinding(status, scope, message, metadata = {}) {
|
|
60
|
-
return { status, path: scope, message, userActionRequired: status !== 'info' && status !== 'ok', ...metadata };
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function liveReferenceBridge(current, targetFile, sourceFile) {
|
|
64
|
-
if (!hasManagedRulesMarker(current) || !current.includes('@AGENTS.md')) return false;
|
|
65
|
-
return path.resolve(path.dirname(targetFile), 'AGENTS.md') === path.resolve(sourceFile);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function referenceMetadataStale(current, sourceFile) {
|
|
69
|
-
const hash = current.match(/\bhash:\s*([a-f0-9]{64})\b/i)?.[1]?.toLowerCase();
|
|
70
|
-
if (!hash) return false;
|
|
71
|
-
return hash !== crypto.createHash('sha256').update(fs.readFileSync(sourceFile)).digest('hex');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function toPosixRelative(root, file) {
|
|
75
|
-
return path.relative(root, file).split(path.sep).join('/') || '.';
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function adapterRuleManaged(content) {
|
|
79
|
-
return typeof content === 'string' && content.includes(ADAPTER_RULE_MARKER);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function managedRuleSource(repoRoot, targetFile) {
|
|
83
|
-
const content = fs.readFileSync(targetFile, 'utf8');
|
|
84
|
-
const relative = content.match(/<!-- Generated by Buildr\. Agent adapter:[^\n]*; source: ([^;]+); scope:/)?.[1];
|
|
85
|
-
if (!relative) return null;
|
|
86
|
-
const sourceFile = path.resolve(repoRoot, relative);
|
|
87
|
-
return sourceFile === repoRoot || sourceFile.startsWith(`${repoRoot}${path.sep}`) ? sourceFile : null;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function sourceParticipatesInScope(repoRoot, scopeInfo, targetFile) {
|
|
91
|
-
if (scopeInfo.scope === '.') return true;
|
|
92
|
-
const sourceFile = managedRuleSource(repoRoot, targetFile);
|
|
93
|
-
if (!sourceFile) return false;
|
|
94
|
-
const sourceDirectory = path.dirname(sourceFile);
|
|
95
|
-
return sourceDirectory === scopeInfo.scopeRoot
|
|
96
|
-
|| sourceDirectory.startsWith(`${scopeInfo.scopeRoot}${path.sep}`)
|
|
97
|
-
|| scopeInfo.scopeRoot.startsWith(`${sourceDirectory}${path.sep}`);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function actionFor(targetRoot, targetFile, content) {
|
|
101
|
-
assertRuntimeTargetPath(targetRoot, targetFile, 'runtime rules target');
|
|
102
|
-
if (!fs.existsSync(targetFile)) return 'created';
|
|
103
|
-
return fs.readFileSync(targetFile, 'utf8') === content ? 'unchanged' : 'updated';
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function sourceScope(repoRoot, sourceFile) {
|
|
107
|
-
return toPosixRelative(repoRoot, path.dirname(sourceFile));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function sourceId(repoRoot, sourceFile) {
|
|
111
|
-
const relative = toPosixRelative(repoRoot, sourceFile);
|
|
112
|
-
const directory = path.posix.dirname(relative);
|
|
113
|
-
const depth = directory === '.' ? 0 : directory.split('/').length;
|
|
114
|
-
const slug = (directory === '.' ? 'root' : directory).replace(/[^A-Za-z0-9._-]+/g, '-').slice(0, 72);
|
|
115
|
-
const hash = crypto.createHash('sha256').update(relative).digest('hex').slice(0, 10);
|
|
116
|
-
return `${String(depth).padStart(3, '0')}-${slug}-${hash}`;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function vendorRuleTarget(repoRoot, targetRoot, sourceFile, rules) {
|
|
120
|
-
if (rules.format === 'cursor-mdc') {
|
|
121
|
-
const relativeDirectory = path.relative(repoRoot, path.dirname(sourceFile));
|
|
122
|
-
return path.join(targetRoot, relativeDirectory, '.cursor', 'rules', 'buildr.mdc');
|
|
123
|
-
}
|
|
124
|
-
if (rules.format === 'qoder-markdown') {
|
|
125
|
-
return path.join(targetRoot, '.qoder', 'rules', 'buildr', `${sourceId(repoRoot, sourceFile)}.md`);
|
|
126
|
-
}
|
|
127
|
-
const relativeDirectory = path.relative(repoRoot, path.dirname(sourceFile));
|
|
128
|
-
return path.join(targetRoot, relativeDirectory, '.trae', 'rules', 'buildr.md');
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function vendorRuleContent(repoRoot, sourceFile, rules, adapterId) {
|
|
132
|
-
const relative = toPosixRelative(repoRoot, sourceFile);
|
|
133
|
-
const scope = sourceScope(repoRoot, sourceFile);
|
|
134
|
-
const body = fs.readFileSync(sourceFile, 'utf8').trimEnd();
|
|
135
|
-
const marker = `${ADAPTER_RULE_MARKER} ${adapterId}; source: ${relative}; scope: ${scope}. Do not edit. -->`;
|
|
136
|
-
if (rules.format === 'cursor-mdc') {
|
|
137
|
-
const frontmatter = ['---', `description: ${JSON.stringify(scope === '.' ? 'Buildr workspace root rules' : `Buildr rules for ${scope}`)}`, 'globs:', 'alwaysApply: true', '---'];
|
|
138
|
-
return [...frontmatter, marker, '', body, ''].join('\n');
|
|
139
|
-
}
|
|
140
|
-
if (rules.format === 'qoder-markdown') {
|
|
141
|
-
const root = scope === '.';
|
|
142
|
-
const frontmatter = root
|
|
143
|
-
? ['---', 'trigger: always_on', '---']
|
|
144
|
-
: ['---', 'trigger: glob', `glob: ${JSON.stringify(`${scope}/**`)}`, '---'];
|
|
145
|
-
return [...frontmatter, marker, '', body, ''].join('\n');
|
|
146
|
-
}
|
|
147
|
-
return ['---', 'alwaysApply: true', '---', marker, '', `Source: \`${relative}\``, `Scope: \`${scope}\``, '', body, ''].join('\n');
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function discoverQoderManagedTargets(targetRoot) {
|
|
151
|
-
const directory = path.join(targetRoot, '.qoder', 'rules', 'buildr');
|
|
152
|
-
if (!fs.existsSync(directory) || fs.lstatSync(directory).isSymbolicLink() || !fs.lstatSync(directory).isDirectory()) return [];
|
|
153
|
-
return fs.readdirSync(directory, { withFileTypes: true })
|
|
154
|
-
.filter((entry) => entry.isFile() && entry.name.endsWith('.md'))
|
|
155
|
-
.map((entry) => path.join(directory, entry.name))
|
|
156
|
-
.filter((file) => adapterRuleManaged(fs.readFileSync(file, 'utf8')));
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function blockedRuntimeDirectories(targetRoot, discovery) {
|
|
160
|
-
return new Set((discovery.boundaries || []).map((boundary) => path.resolve(targetRoot, boundary.path)));
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function discoverCursorManagedTargets(targetRoot, discovery) {
|
|
164
|
-
const files = [];
|
|
165
|
-
const blocked = blockedRuntimeDirectories(targetRoot, discovery);
|
|
166
|
-
function walk(directory) {
|
|
167
|
-
const candidate = path.join(directory, '.cursor', 'rules', 'buildr.mdc');
|
|
168
|
-
if (fs.existsSync(candidate) && !fs.lstatSync(candidate).isSymbolicLink() && fs.lstatSync(candidate).isFile() && adapterRuleManaged(fs.readFileSync(candidate, 'utf8'))) files.push(candidate);
|
|
169
|
-
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
170
|
-
const child = path.join(directory, entry.name);
|
|
171
|
-
if (!entry.isDirectory() || entry.isSymbolicLink() || VENDOR_DISCOVERY_EXCLUDED.has(entry.name) || blocked.has(path.resolve(child))) continue;
|
|
172
|
-
walk(child);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
walk(targetRoot);
|
|
176
|
-
return files;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function discoverTraeManagedTargets(targetRoot, discovery) {
|
|
180
|
-
const files = [];
|
|
181
|
-
const blocked = blockedRuntimeDirectories(targetRoot, discovery);
|
|
182
|
-
function walk(directory) {
|
|
183
|
-
const candidate = path.join(directory, '.trae', 'rules', 'buildr.md');
|
|
184
|
-
if (fs.existsSync(candidate) && !fs.lstatSync(candidate).isSymbolicLink() && fs.lstatSync(candidate).isFile() && adapterRuleManaged(fs.readFileSync(candidate, 'utf8'))) files.push(candidate);
|
|
185
|
-
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
186
|
-
const child = path.join(directory, entry.name);
|
|
187
|
-
if (!entry.isDirectory() || entry.isSymbolicLink() || VENDOR_DISCOVERY_EXCLUDED.has(entry.name) || blocked.has(path.resolve(child))) continue;
|
|
188
|
-
walk(child);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
walk(targetRoot);
|
|
192
|
-
return files;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function rootIndexBridgeContent(repoRoot, discovery, adapter) {
|
|
196
|
-
const sources = discovery.files.map((source) => toPosixRelative(repoRoot, source));
|
|
197
|
-
const lines = [
|
|
198
|
-
`${ADAPTER_RULE_MARKER} ${adapter.id}; type: root-index-reference. Do not edit. -->`,
|
|
199
|
-
'# Buildr Rules Bridge',
|
|
200
|
-
'',
|
|
201
|
-
'执行任何 workspace 任务前,必须先读取并遵循根 `AGENTS.md`。',
|
|
202
|
-
'每当读取、分析或修改某个文件或目录时,必须再读取从 workspace root 到该路径之间所有存在的 `AGENTS.md`,按由宽到窄的顺序应用;不得读取不相关兄弟目录的规则。',
|
|
203
|
-
'下列索引仅用于发现规则文件,普通 Markdown 链接不代表内容已经自动加载:',
|
|
204
|
-
'',
|
|
205
|
-
...sources.map((source) => `- [${source}](${source})`),
|
|
206
|
-
'',
|
|
207
|
-
];
|
|
208
|
-
const content = lines.join('\n');
|
|
209
|
-
if (adapter.traits.rules.maxChars && content.length > adapter.traits.rules.maxChars) {
|
|
210
|
-
throw new Error(`${adapter.displayName} rules bridge exceeds ${adapter.traits.rules.maxChars} characters.`);
|
|
211
|
-
}
|
|
212
|
-
return content;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function rootIndexTarget(targetRoot, rules) {
|
|
216
|
-
const relative = rules.targetPattern.replace(/^<workspace-root>\//, '');
|
|
217
|
-
return path.join(targetRoot, relative);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function assembleNativeRecursiveRules({ repoRoot, discovery, findings, adapter }) {
|
|
221
|
-
const diagnostics = adapter.traits.rules.diagnostics;
|
|
222
|
-
return {
|
|
223
|
-
writes: [], removals: [], actions: [], findings, discovery,
|
|
224
|
-
nativeAssets: discovery.files.map((targetFile) => ({ targetFile, source: path.relative(repoRoot, targetFile), diagnostic: { label: diagnostics.label, code: diagnostics.okCode } })),
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
function assembleReferenceBridgeRules({ repoRoot, targetRoot, scopeInfo, discovery, findings, adapter }) {
|
|
229
|
-
if (adapter.traits.rules.placement === 'root-index') {
|
|
230
|
-
if (discovery.files.length === 0) {
|
|
231
|
-
const targetFile = rootIndexTarget(targetRoot, adapter.traits.rules);
|
|
232
|
-
const managed = fs.existsSync(targetFile) && fs.statSync(targetFile).isFile() && adapterRuleManaged(fs.readFileSync(targetFile, 'utf8'));
|
|
233
|
-
const diagnostic = { label: adapter.traits.rules.diagnostics.label, codes: adapter.traits.rules.diagnostics.codes, repair: 'rules-render' };
|
|
234
|
-
const removals = managed ? [{ targetFile, capability: 'rules-entry', isManaged: adapterRuleManaged, diagnostic }] : [];
|
|
235
|
-
return { writes: [], removals, nativeAssets: [], actions: removals.map(() => ({ action: 'removed', sourceFile: null, targetFile, content: null })), findings, discovery };
|
|
236
|
-
}
|
|
237
|
-
const content = rootIndexBridgeContent(repoRoot, discovery, adapter);
|
|
238
|
-
const targetFile = rootIndexTarget(targetRoot, adapter.traits.rules);
|
|
239
|
-
const diagnostic = { label: adapter.traits.rules.diagnostics.label, codes: adapter.traits.rules.diagnostics.codes, repair: 'rules-render' };
|
|
240
|
-
const item = { action: actionFor(targetRoot, targetFile, content), sourceFile: discovery.files[0], sourceFiles: discovery.files, targetFile, content };
|
|
241
|
-
return {
|
|
242
|
-
writes: [{ ...item, capability: 'rules-entry', isManaged: adapterRuleManaged, diagnostic }],
|
|
243
|
-
removals: [], nativeAssets: [], actions: [item], findings, discovery,
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
const planned = planRulesRender(repoRoot, targetRoot, scopeInfo);
|
|
247
|
-
for (const conflict of planned.conflicts) findings.push(ruleFinding('conflict', scopeInfo.scope, conflict, { code: 'runtime.rules_bridge_conflict' }));
|
|
248
|
-
const diagnostic = { label: adapter.traits.rules.diagnostics.label, codes: adapter.traits.rules.diagnostics.codes, repair: 'rules-render' };
|
|
249
|
-
for (const item of planned.actions) {
|
|
250
|
-
if (!item.sourceFile || !fs.existsSync(item.targetFile)) continue;
|
|
251
|
-
const current = fs.readFileSync(item.targetFile, 'utf8');
|
|
252
|
-
if (liveReferenceBridge(current, item.targetFile, item.sourceFile) && referenceMetadataStale(current, item.sourceFile)) {
|
|
253
|
-
findings.push(ruleFinding('info', path.relative(targetRoot, item.targetFile).split(path.sep).join('/'), `${path.relative(repoRoot, item.sourceFile).split(path.sep).join('/')} bridge metadata hash is stale, but AGENTS.md is referenced live.`, { code: 'runtime.reference_bridge_metadata_stale', bridgeType: 'reference', impact: 'none', userActionRequired: false, repair: 'optional-rules-render', suggestion: 'No action required. Source is referenced live. Run rules render only if you want to refresh metadata.' }));
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
return {
|
|
257
|
-
writes: planned.actions.filter((item) => item.content !== null).map((item) => ({ ...item, capability: 'rules-entry', isManaged: hasManagedRulesMarker, matchesCurrent: (current) => liveReferenceBridge(current, item.targetFile, item.sourceFile), diagnostic })),
|
|
258
|
-
removals: planned.actions.filter((item) => item.content === null).map((item) => ({ targetFile: item.targetFile, capability: 'rules-entry', isManaged: hasManagedRulesMarker, diagnostic })),
|
|
259
|
-
nativeAssets: [], actions: planned.actions, findings, discovery: planned.discovery,
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function assembleVendorRuleFiles({ repoRoot, targetRoot, scopeInfo, discovery, findings, adapter }) {
|
|
264
|
-
const rules = adapter.traits.rules;
|
|
265
|
-
const diagnostic = { label: rules.diagnostics.label, codes: rules.diagnostics.codes, repair: 'rules-render' };
|
|
266
|
-
const actions = discovery.files.map((sourceFile) => {
|
|
267
|
-
const targetFile = vendorRuleTarget(repoRoot, targetRoot, sourceFile, rules);
|
|
268
|
-
const content = vendorRuleContent(repoRoot, sourceFile, rules, adapter.id);
|
|
269
|
-
if (rules.maxChars && content.length > rules.maxChars) throw new Error(`${adapter.displayName} rule file exceeds ${rules.maxChars} characters: ${toPosixRelative(targetRoot, targetFile)}`);
|
|
270
|
-
return { action: actionFor(targetRoot, targetFile, content), sourceFile, targetFile, content };
|
|
271
|
-
});
|
|
272
|
-
if (rules.maxChars && actions.reduce((sum, item) => sum + item.content.length, 0) > rules.maxChars) {
|
|
273
|
-
throw new Error(`${adapter.displayName} active rule files exceed ${rules.maxChars} total characters.`);
|
|
274
|
-
}
|
|
275
|
-
const expected = new Set(actions.map((item) => path.resolve(item.targetFile)));
|
|
276
|
-
const existing = rules.format === 'cursor-mdc'
|
|
277
|
-
? discoverCursorManagedTargets(targetRoot, discovery)
|
|
278
|
-
: rules.format === 'qoder-markdown'
|
|
279
|
-
? discoverQoderManagedTargets(targetRoot)
|
|
280
|
-
: discoverTraeManagedTargets(targetRoot, discovery);
|
|
281
|
-
const removals = existing
|
|
282
|
-
.filter((targetFile) => sourceParticipatesInScope(repoRoot, scopeInfo, targetFile))
|
|
283
|
-
.filter((targetFile) => !expected.has(path.resolve(targetFile)))
|
|
284
|
-
.map((targetFile) => ({ targetFile, capability: 'rules-entry', isManaged: adapterRuleManaged, diagnostic }));
|
|
285
|
-
return {
|
|
286
|
-
writes: actions.map((item) => ({ ...item, capability: 'rules-entry', isManaged: adapterRuleManaged, diagnostic })),
|
|
287
|
-
removals,
|
|
288
|
-
nativeAssets: [], actions: [...actions, ...removals.map((item) => ({ action: 'removed', sourceFile: null, targetFile: item.targetFile, content: null }))], findings, discovery,
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const RULE_IMPLEMENTATIONS = Object.freeze({
|
|
293
|
-
'native-recursive': assembleNativeRecursiveRules,
|
|
294
|
-
'reference-bridge': assembleReferenceBridgeRules,
|
|
295
|
-
'vendor-rule-files': assembleVendorRuleFiles,
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
function assembleRules(repoRoot, targetRoot, scopeInfo, adapter) {
|
|
299
|
-
const discoveryScope = adapter.traits.rules.placement === 'root-index'
|
|
300
|
-
? resolveRuleScope(repoRoot, '.')
|
|
301
|
-
: scopeInfo;
|
|
302
|
-
const discovery = buildRuleDiscoveryPlan(repoRoot, discoveryScope);
|
|
303
|
-
const findings = [
|
|
304
|
-
...discovery.warnings.map((message) => ruleFinding('warning', scopeInfo.scope, message, { code: 'runtime.scope_legacy', canonicalScope: scopeInfo.scope })),
|
|
305
|
-
...discovery.boundaries.map((boundary) => ruleFinding('info', boundary.path, `Rules discovery skipped boundary: ${boundary.reason}.`, { code: 'runtime.rules_discovery_boundary', boundaryReason: boundary.reason, userActionRequired: false })),
|
|
306
|
-
];
|
|
307
|
-
const diagnostics = adapter.traits.rules.diagnostics;
|
|
308
|
-
if (discovery.files.length === 0) {
|
|
309
|
-
findings.push(ruleFinding(diagnostics.missingStatus, diagnostics.missingPath, `No AGENTS.md files found for scope: ${scopeInfo.scope}.`, { code: diagnostics.missingCode }));
|
|
310
|
-
}
|
|
311
|
-
const implementation = selectAdapterImplementation(adapter, 'rules', RULE_IMPLEMENTATIONS);
|
|
312
|
-
return implementation({ repoRoot, targetRoot, scopeInfo, discovery, findings, adapter });
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
export function assembleRuntimeProjection(options) {
|
|
316
|
-
const repoRoot = path.resolve(options.repoRoot);
|
|
317
|
-
const targetRoot = path.resolve(options.targetRoot ?? repoRoot);
|
|
318
|
-
if (!fs.existsSync(targetRoot) || !fs.statSync(targetRoot).isDirectory()) throw new Error(`Target directory does not exist: ${targetRoot}`);
|
|
319
|
-
const adapter = getRuntimeAdapter(options.adapterId);
|
|
320
|
-
const selection = { productSkill: false, rules: false, workspaceSkills: false, ...(options.selection || {}) };
|
|
321
|
-
const scopeInfo = resolveRuleScope(repoRoot, options.scope ?? '.');
|
|
322
|
-
const skillScope = runtimeSkillScope(scopeInfo.scope);
|
|
323
|
-
const skillConflicts = [];
|
|
324
|
-
const productWrites = selection.productSkill
|
|
325
|
-
? decorateSkillWrites(buildSkillRenderPlan(repoRoot, targetRoot, [resolvePackageAgentSkill(adapter.id, 'buildr')], adapter.id, { deferConflicts: true, conflicts: skillConflicts }), true)
|
|
326
|
-
: [];
|
|
327
|
-
const workspaceSkills = selection.workspaceSkills ? resolveRenderSkills(repoRoot, skillScope, adapter.id) : [];
|
|
328
|
-
const workspaceWrites = decorateSkillWrites(buildSkillRenderPlan(repoRoot, targetRoot, workspaceSkills, adapter.id, { deferConflicts: true, conflicts: skillConflicts }));
|
|
329
|
-
const rules = selection.rules ? assembleRules(repoRoot, targetRoot, scopeInfo, adapter) : { writes: [], removals: [], nativeAssets: [], actions: [], findings: [], discovery: { boundaries: [], warnings: [] } };
|
|
330
|
-
const warnings = workspaceSkills.filter((skill) => skill.resolved && !skill.resolved.integrity)
|
|
331
|
-
.map((skill) => `workspace Skill ${skill.id} uses a remote resolved source without integrity.`);
|
|
332
|
-
const context = createRuntimeContext({
|
|
333
|
-
adapterId: adapter.id, targetRoot, scope: scopeInfo.scope,
|
|
334
|
-
rules, skills: { writes: [...productWrites, ...workspaceWrites], removals: options.removals || [] },
|
|
335
|
-
findings: [...rules.findings, ...skillConflicts.map((message) => ({ status: 'conflict', path: skillScope, message, code: 'runtime.skill_conflict', userActionRequired: true }))], warnings,
|
|
336
|
-
});
|
|
337
|
-
return { plan: adapter.planRuntime(context), scopeInfo, discovery: rules.discovery, selection };
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
function summarize(findings) {
|
|
341
|
-
const counts = { ok: 0, info: 0, warning: 0, missing: 0, stale: 0, orphan: 0, conflict: 0 };
|
|
342
|
-
for (const finding of findings) counts[finding.status] = (counts[finding.status] ?? 0) + 1;
|
|
343
|
-
return counts;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
export function repairCommands(result, adapterId) {
|
|
347
|
-
const target = path.relative(process.cwd(), result.targetRoot).split(path.sep).join('/') || '.';
|
|
348
|
-
const has = (repair) => result.findings.some((item) => ['missing', 'stale', 'orphan'].includes(item.status) && item.repair === repair);
|
|
349
|
-
const commands = [];
|
|
350
|
-
if (has('skill-install')) commands.push(`buildr skill install ${adapterId} --target ${target}`);
|
|
351
|
-
if (has('rules-render')) commands.push(`buildr rules render ${adapterId} --scope ${result.scope} --target ${target}`);
|
|
352
|
-
if (has('skills-render')) commands.push(`buildr skills render ${adapterId} --scope ${runtimeSkillScope(result.scope)} --target ${target}`);
|
|
353
|
-
return commands;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
export function checkRuntimeProjection(options) {
|
|
357
|
-
const assembled = assembleRuntimeProjection({ ...options, selection: { productSkill: true, rules: true, workspaceSkills: true } });
|
|
358
|
-
const reconciled = reconcileRuntimePlan(assembled.plan, { compareOnly: true });
|
|
359
|
-
const counts = summarize(reconciled.findings);
|
|
360
|
-
const result = { ...reconciled, counts, exitCode: counts.conflict ? 2 : counts.missing || counts.stale || counts.orphan ? 1 : 0, requestedScope: assembled.scopeInfo.requestedScope, discoveryBoundaries: assembled.discovery.boundaries };
|
|
361
|
-
result.repairCommands = repairCommands(result, options.adapterId);
|
|
362
|
-
return result;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
export function printRuntimeProjectionReport(result, label) {
|
|
366
|
-
console.log(`${label} runtime check for ${result.scope}`);
|
|
367
|
-
console.log(`Target: ${result.targetRoot}`);
|
|
368
|
-
console.log(`Status: ${Object.entries(result.counts).map(([key, value]) => `${key}=${value}`).join(' ')}`);
|
|
369
|
-
console.log('');
|
|
370
|
-
for (const finding of result.findings) console.log(`[${finding.status}] ${finding.path} - ${finding.message}`);
|
|
371
|
-
if (result.repairCommands.length) {
|
|
372
|
-
console.log('\nSuggested commands:');
|
|
373
|
-
for (const command of result.repairCommands) console.log(` ${command}`);
|
|
374
|
-
}
|
|
375
|
-
}
|