@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,212 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
import os from 'node:os';
|
|
5
|
-
import path from 'node:path';
|
|
6
|
-
import process from 'node:process';
|
|
7
|
-
import { fileURLToPath } from 'node:url';
|
|
8
|
-
import { spawnSync } from 'node:child_process';
|
|
9
|
-
|
|
10
|
-
const productRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../..');
|
|
11
|
-
const buildr = path.join(productRoot, 'tools', 'buildr');
|
|
12
|
-
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'buildr-openspec-contract-'));
|
|
13
|
-
const project = 'demo';
|
|
14
|
-
const projectRoot = path.join(root, 'projects', project);
|
|
15
|
-
const specsRoot = path.join(projectRoot, 'openspec', 'specs');
|
|
16
|
-
const changesRoot = path.join(projectRoot, 'openspec', 'changes');
|
|
17
|
-
|
|
18
|
-
function fail(message) {
|
|
19
|
-
throw new Error(message);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function run(args, expected = 0) {
|
|
23
|
-
const result = spawnSync(process.execPath, [buildr, ...args], { cwd: productRoot, encoding: 'utf8' });
|
|
24
|
-
if (result.status !== expected) {
|
|
25
|
-
fail(`buildr ${args.join(' ')} exited ${result.status}, expected ${expected}: ${(result.stderr || result.stdout).trim()}`);
|
|
26
|
-
}
|
|
27
|
-
const payload = args.includes('--json') && result.stdout.trim() ? JSON.parse(result.stdout) : null;
|
|
28
|
-
if (payload && args[0] === 'openspec') {
|
|
29
|
-
const expectedSchema = args[1] === 'baseline' ? 'buildr.openspec-baseline/v1' : 'buildr.openspec-check/v1';
|
|
30
|
-
if (payload.schemaVersion !== expectedSchema) fail(`Expected ${expectedSchema}, got ${payload.schemaVersion}`);
|
|
31
|
-
}
|
|
32
|
-
return payload;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function write(file, content) {
|
|
36
|
-
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
37
|
-
fs.writeFileSync(file, content);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function requirement(title, detail) {
|
|
41
|
-
return [
|
|
42
|
-
`### Requirement: ${title}`,
|
|
43
|
-
`系统 MUST ${detail}。`,
|
|
44
|
-
'',
|
|
45
|
-
`#### Scenario: ${title} works`,
|
|
46
|
-
'- **WHEN** 条件满足',
|
|
47
|
-
'- **THEN** 结果成立',
|
|
48
|
-
'',
|
|
49
|
-
].join('\n');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function canonical(capability, blocks) {
|
|
53
|
-
write(path.join(specsRoot, capability, 'spec.md'), `# ${capability} Specification\n\n## Requirements\n${blocks.join('\n')}`);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function change(id, capability, kind, delta) {
|
|
57
|
-
const isNew = kind === 'new';
|
|
58
|
-
write(path.join(changesRoot, id, '.openspec.yaml'), 'schema: spec-driven\ncreated: 2026-07-11\n');
|
|
59
|
-
write(path.join(changesRoot, id, 'proposal.md'), [
|
|
60
|
-
'## Capabilities',
|
|
61
|
-
'',
|
|
62
|
-
'### New Capabilities',
|
|
63
|
-
...(isNew ? [`- \`${capability}\`: fixture`] : []),
|
|
64
|
-
'',
|
|
65
|
-
'### Modified Capabilities',
|
|
66
|
-
...(!isNew ? [`- \`${capability}\`: fixture`] : []),
|
|
67
|
-
'',
|
|
68
|
-
].join('\n'));
|
|
69
|
-
write(path.join(changesRoot, id, 'specs', capability, 'spec.md'), delta);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function removeChange(id) {
|
|
73
|
-
fs.rmSync(path.join(changesRoot, id), { recursive: true, force: true });
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function baseline(id, options = []) {
|
|
77
|
-
return run(['openspec', 'baseline', 'create', id, '--project', project, '--target', root, '--json', ...options]);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function check(id, stage, expected = 0) {
|
|
81
|
-
return run(['openspec', 'check', id, '--stage', stage, '--project', project, '--target', root, '--json'], expected);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function assertError(result, code) {
|
|
85
|
-
if (!result.findings.some((finding) => finding.code === code)) fail(`Expected finding ${code}: ${JSON.stringify(result.findings)}`);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
run(['init', '--target', root, '--name', 'contract-fixture', '--profile', 'team']);
|
|
90
|
-
run(['project', 'create', project, '--target', root]);
|
|
91
|
-
|
|
92
|
-
const existing = requirement('Existing', '保留既有行为');
|
|
93
|
-
const untouched = requirement('Untouched', '保持不变');
|
|
94
|
-
canonical('demo', [existing, untouched]);
|
|
95
|
-
|
|
96
|
-
const unknownProject = spawnSync(process.execPath, [buildr, 'openspec', 'check', 'missing', '--stage', 'proposal', '--project', 'missing', '--target', root, '--json'], { cwd: productRoot, encoding: 'utf8' });
|
|
97
|
-
if (unknownProject.status === 0 || !unknownProject.stderr.includes('Project is not registered')) fail('unknown Project must be rejected before OpenSpec sidecar access');
|
|
98
|
-
|
|
99
|
-
const modified = requirement('Existing', '使用更新后的行为');
|
|
100
|
-
change('safe-modified', 'demo', 'modified', `## MODIFIED Requirements\n\n${modified}`);
|
|
101
|
-
baseline('safe-modified');
|
|
102
|
-
if (!check('safe-modified', 'proposal').ok) fail('safe modified proposal check must pass');
|
|
103
|
-
if (!check('safe-modified', 'pre-sync').ok) fail('safe modified pre-sync check must pass');
|
|
104
|
-
canonical('demo', [modified, untouched]);
|
|
105
|
-
if (!check('safe-modified', 'post-sync').ok) fail('safe modified post-sync check must pass');
|
|
106
|
-
const safeModifiedReceipt = JSON.parse(fs.readFileSync(path.join(changesRoot, 'safe-modified', '.buildr', 'contract-pre-sync-receipt.json'), 'utf8'));
|
|
107
|
-
if (!safeModifiedReceipt.postSyncSpecIntegrities?.demo?.startsWith('sha256-')) fail('post-sync receipt must bind the resulting canonical spec integrity');
|
|
108
|
-
removeChange('safe-modified');
|
|
109
|
-
|
|
110
|
-
const added = requirement('Added', '提供新增能力');
|
|
111
|
-
change('safe-added', 'demo', 'modified', `## ADDED Requirements\n\n${added}`);
|
|
112
|
-
baseline('safe-added');
|
|
113
|
-
check('safe-added', 'pre-sync');
|
|
114
|
-
canonical('demo', [modified, untouched, added]);
|
|
115
|
-
if (!check('safe-added', 'post-sync').ok) fail('safe added post-sync check must pass');
|
|
116
|
-
removeChange('safe-added');
|
|
117
|
-
|
|
118
|
-
change('safe-removed', 'demo', 'modified', `## REMOVED Requirements\n\n${added}`);
|
|
119
|
-
baseline('safe-removed');
|
|
120
|
-
check('safe-removed', 'pre-sync');
|
|
121
|
-
canonical('demo', [modified, untouched]);
|
|
122
|
-
if (!check('safe-removed', 'post-sync').ok) fail('safe removed post-sync check must pass');
|
|
123
|
-
removeChange('safe-removed');
|
|
124
|
-
|
|
125
|
-
const legacy = requirement('Legacy', '保留名称前的内容');
|
|
126
|
-
canonical('demo', [legacy, untouched]);
|
|
127
|
-
change('safe-renamed', 'demo', 'modified', '## RENAMED Requirements\n\n- FROM: `### Requirement: Legacy`\n- TO: `### Requirement: Modern`\n');
|
|
128
|
-
baseline('safe-renamed');
|
|
129
|
-
check('safe-renamed', 'pre-sync');
|
|
130
|
-
canonical('demo', [legacy.replace('### Requirement: Legacy', '### Requirement: Modern'), untouched]);
|
|
131
|
-
if (!check('safe-renamed', 'post-sync').ok) fail('safe renamed post-sync check must pass');
|
|
132
|
-
removeChange('safe-renamed');
|
|
133
|
-
|
|
134
|
-
canonical('demo', [existing, untouched]);
|
|
135
|
-
change('proposal-mismatch', 'demo', 'modified', `## MODIFIED Requirements\n\n${modified}`);
|
|
136
|
-
baseline('proposal-mismatch');
|
|
137
|
-
write(path.join(changesRoot, 'proposal-mismatch', 'proposal.md'), '## Capabilities\n\n### New Capabilities\n\n### Modified Capabilities\n');
|
|
138
|
-
assertError(check('proposal-mismatch', 'proposal', 1), 'openspec_contract.proposal_delta_missing');
|
|
139
|
-
removeChange('proposal-mismatch');
|
|
140
|
-
|
|
141
|
-
change('incomplete-baseline', 'demo', 'modified', `## MODIFIED Requirements\n\n${modified}`);
|
|
142
|
-
baseline('incomplete-baseline');
|
|
143
|
-
fs.appendFileSync(path.join(changesRoot, 'incomplete-baseline', 'specs', 'demo', 'spec.md'), `\n## ADDED Requirements\n\n${requirement('Later', '在基线后新增')}`);
|
|
144
|
-
assertError(check('incomplete-baseline', 'proposal', 1), 'openspec_contract.baseline_incomplete');
|
|
145
|
-
removeChange('incomplete-baseline');
|
|
146
|
-
|
|
147
|
-
change('adopted', 'demo', 'modified', `## MODIFIED Requirements\n\n${modified}`);
|
|
148
|
-
const adopted = baseline('adopted', ['--adopt-current']);
|
|
149
|
-
if (adopted.adopted !== true) fail('explicit adopted baseline must be marked in JSON output');
|
|
150
|
-
removeChange('adopted');
|
|
151
|
-
|
|
152
|
-
change('corrupt-baseline', 'demo', 'modified', `## MODIFIED Requirements\n\n${modified}`);
|
|
153
|
-
baseline('corrupt-baseline');
|
|
154
|
-
fs.writeFileSync(path.join(changesRoot, 'corrupt-baseline', '.buildr', 'contract-baseline.json'), '{ invalid json\n');
|
|
155
|
-
assertError(check('corrupt-baseline', 'proposal', 1), 'openspec_contract.baseline_invalid');
|
|
156
|
-
removeChange('corrupt-baseline');
|
|
157
|
-
|
|
158
|
-
canonical('demo', [existing, untouched]);
|
|
159
|
-
change('conflict-a', 'demo', 'modified', `## MODIFIED Requirements\n\n${modified}`);
|
|
160
|
-
change('conflict-b', 'demo', 'modified', `## MODIFIED Requirements\n\n${modified}`);
|
|
161
|
-
baseline('conflict-a');
|
|
162
|
-
baseline('conflict-b');
|
|
163
|
-
assertError(check('conflict-a', 'pre-sync', 1), 'openspec_contract.active_conflict');
|
|
164
|
-
removeChange('conflict-a');
|
|
165
|
-
removeChange('conflict-b');
|
|
166
|
-
|
|
167
|
-
change('stale', 'demo', 'modified', `## MODIFIED Requirements\n\n${modified}`);
|
|
168
|
-
baseline('stale');
|
|
169
|
-
canonical('demo', [requirement('Existing', '已被前序 change 改变'), untouched]);
|
|
170
|
-
assertError(check('stale', 'pre-sync', 1), 'openspec_contract.baseline_stale');
|
|
171
|
-
removeChange('stale');
|
|
172
|
-
|
|
173
|
-
canonical('demo', [existing, untouched]);
|
|
174
|
-
change('occupied-added', 'demo', 'modified', `## ADDED Requirements\n\n${added}`);
|
|
175
|
-
baseline('occupied-added');
|
|
176
|
-
canonical('demo', [existing, untouched, added]);
|
|
177
|
-
assertError(check('occupied-added', 'pre-sync', 1), 'openspec_contract.baseline_stale');
|
|
178
|
-
removeChange('occupied-added');
|
|
179
|
-
|
|
180
|
-
canonical('demo', [existing, untouched]);
|
|
181
|
-
change('partial', 'demo', 'modified', `## MODIFIED Requirements\n\n${modified}`);
|
|
182
|
-
baseline('partial');
|
|
183
|
-
check('partial', 'pre-sync');
|
|
184
|
-
canonical('demo', [modified, requirement('Untouched', '被错误改写')]);
|
|
185
|
-
assertError(check('partial', 'post-sync', 1), 'openspec_contract.post_sync_untouched_changed');
|
|
186
|
-
removeChange('partial');
|
|
187
|
-
|
|
188
|
-
canonical('demo', [existing, untouched]);
|
|
189
|
-
change('receipt-changed', 'demo', 'modified', `## MODIFIED Requirements\n\n${modified}`);
|
|
190
|
-
baseline('receipt-changed');
|
|
191
|
-
check('receipt-changed', 'pre-sync');
|
|
192
|
-
fs.appendFileSync(path.join(changesRoot, 'receipt-changed', 'specs', 'demo', 'spec.md'), '\n<!-- fixture mutation -->\n');
|
|
193
|
-
assertError(check('receipt-changed', 'post-sync', 1), 'openspec_contract.receipt_delta_changed');
|
|
194
|
-
removeChange('receipt-changed');
|
|
195
|
-
|
|
196
|
-
change('missing-baseline', 'demo', 'modified', `## MODIFIED Requirements\n\n${modified}`);
|
|
197
|
-
assertError(check('missing-baseline', 'proposal', 1), 'openspec_contract.baseline_missing');
|
|
198
|
-
removeChange('missing-baseline');
|
|
199
|
-
|
|
200
|
-
const definition = path.join(root, 'components', 'buildr', 'openspec', 'component.yml');
|
|
201
|
-
const originalDefinition = fs.readFileSync(definition, 'utf8');
|
|
202
|
-
fs.writeFileSync(definition, originalDefinition.replace('version: "1.4.1"', 'version: "9.9.9"'));
|
|
203
|
-
change('unsupported-upstream', 'demo', 'modified', `## MODIFIED Requirements\n\n${modified}`);
|
|
204
|
-
const unsupported = spawnSync(process.execPath, [buildr, 'openspec', 'baseline', 'create', 'unsupported-upstream', '--project', project, '--target', root, '--json'], { cwd: productRoot, encoding: 'utf8' });
|
|
205
|
-
if (unsupported.status === 0 || !unsupported.stderr.includes('does not support upstream version')) fail('unsupported OpenSpec upstream version must fail closed');
|
|
206
|
-
fs.writeFileSync(definition, originalDefinition);
|
|
207
|
-
removeChange('unsupported-upstream');
|
|
208
|
-
|
|
209
|
-
console.log('OpenSpec contract fixtures passed.');
|
|
210
|
-
} finally {
|
|
211
|
-
fs.rmSync(root, { recursive: true, force: true });
|
|
212
|
-
}
|
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import assert from 'node:assert/strict';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
|
-
import fs from 'node:fs';
|
|
6
|
-
import os from 'node:os';
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
import { fileURLToPath } from 'node:url';
|
|
9
|
-
import {
|
|
10
|
-
ADAPTER_VERIFICATION_LEVELS,
|
|
11
|
-
ADAPTER_TRAIT_CATALOG,
|
|
12
|
-
REQUIRED_RENDER_CAPABILITIES,
|
|
13
|
-
RUNTIME_ADAPTERS,
|
|
14
|
-
SUPPORTED_AGENT_IDS,
|
|
15
|
-
createRuntimeAdapterDescriptor,
|
|
16
|
-
createRuntimeAdapterRegistry,
|
|
17
|
-
createRuntimeContext,
|
|
18
|
-
createRuntimePlan,
|
|
19
|
-
getRuntimeAdapter,
|
|
20
|
-
reconcileRuntimePlan,
|
|
21
|
-
runtimeDiscoveryPayload,
|
|
22
|
-
selectAdapterImplementation,
|
|
23
|
-
validateRuntimePlan,
|
|
24
|
-
} from '../../runtime/adapter-contract.mjs';
|
|
25
|
-
import { resolveSkillContributions } from '../../runtime/render-claude-code.mjs';
|
|
26
|
-
import { assembleRuntimeProjection } from '../../runtime/projection.mjs';
|
|
27
|
-
|
|
28
|
-
const productRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../..');
|
|
29
|
-
const repositoryRoot = path.resolve(productRoot, '../..');
|
|
30
|
-
|
|
31
|
-
assert.deepEqual(SUPPORTED_AGENT_IDS, ['claude-code', 'codex', 'cursor', 'qoder', 'trae', 'trae-work', 'workbuddy']);
|
|
32
|
-
assert.deepEqual(ADAPTER_VERIFICATION_LEVELS, ['documented', 'verified']);
|
|
33
|
-
assert.deepEqual(ADAPTER_TRAIT_CATALOG.rules, ['native-recursive', 'native-root', 'reference-bridge', 'vendor-rule-files']);
|
|
34
|
-
assert.equal(runtimeDiscoveryPayload().adapterTraitCatalog, ADAPTER_TRAIT_CATALOG);
|
|
35
|
-
for (const adapter of Object.values(RUNTIME_ADAPTERS)) {
|
|
36
|
-
assert.ok(adapter.traits);
|
|
37
|
-
assert.deepEqual(Object.keys(adapter.renderCapabilities), REQUIRED_RENDER_CAPABILITIES);
|
|
38
|
-
const root = path.join(os.tmpdir(), `buildr-adapter-${adapter.id}`);
|
|
39
|
-
const context = createRuntimeContext({
|
|
40
|
-
adapterId: adapter.id,
|
|
41
|
-
targetRoot: root,
|
|
42
|
-
scope: '.',
|
|
43
|
-
rules: { writes: [], nativeAssets: [path.join(root, 'AGENTS.md')], removals: [], actions: [] },
|
|
44
|
-
skills: { writes: [], removals: [] },
|
|
45
|
-
});
|
|
46
|
-
validateRuntimePlan(adapter.planRuntime(context), adapter);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const projectionRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'buildr-adapter-projection-contract-'));
|
|
50
|
-
fs.writeFileSync(path.join(projectionRoot, 'AGENTS.md'), '# Adapter projection contract\n');
|
|
51
|
-
const expectedRuleTargets = {
|
|
52
|
-
'claude-code': 'CLAUDE.md',
|
|
53
|
-
cursor: '.cursor/rules/buildr.mdc',
|
|
54
|
-
qoder: '.qoder/rules/buildr/',
|
|
55
|
-
trae: '.trae/rules/buildr.md',
|
|
56
|
-
'trae-work': 'CLAUDE.local.md',
|
|
57
|
-
workbuddy: 'CODEBUDDY.md',
|
|
58
|
-
};
|
|
59
|
-
for (const adapterId of SUPPORTED_AGENT_IDS) {
|
|
60
|
-
const adapter = RUNTIME_ADAPTERS[adapterId];
|
|
61
|
-
const assembled = assembleRuntimeProjection({
|
|
62
|
-
repoRoot: projectionRoot,
|
|
63
|
-
targetRoot: projectionRoot,
|
|
64
|
-
adapterId,
|
|
65
|
-
scope: '.',
|
|
66
|
-
selection: { productSkill: true, rules: true },
|
|
67
|
-
});
|
|
68
|
-
const targets = assembled.plan.writes.map((item) => path.relative(projectionRoot, item.targetFile).split(path.sep).join('/'));
|
|
69
|
-
assert.ok(targets.some((target) => target.startsWith(`${adapter.traits.skills.root}/skills/buildr/`)), `${adapterId} must plan its declared product Skill root`);
|
|
70
|
-
if (adapterId === 'codex') {
|
|
71
|
-
assert.ok(assembled.plan.nativeAssets.some((item) => item.targetFile === path.join(projectionRoot, 'AGENTS.md')));
|
|
72
|
-
} else {
|
|
73
|
-
assert.ok(targets.some((target) => target.includes(expectedRuleTargets[adapterId])), `${adapterId} must plan its declared Rules target`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
fs.rmSync(projectionRoot, { recursive: true, force: true });
|
|
77
|
-
|
|
78
|
-
for (const adapterId of ['cursor', 'qoder', 'trae', 'trae-work', 'workbuddy']) {
|
|
79
|
-
const adapter = RUNTIME_ADAPTERS[adapterId];
|
|
80
|
-
assert.ok(adapter.evidence.rules, `${adapterId} must retain runtime-specific Rules evidence`);
|
|
81
|
-
assert.ok(adapter.evidence.skills, `${adapterId} must retain runtime-specific Skills evidence`);
|
|
82
|
-
assert.equal(adapter.evidence.verificationLevel, adapterId === 'workbuddy' ? 'verified' : 'documented');
|
|
83
|
-
assert.equal(adapter.evidence.smokeStatus, adapterId === 'workbuddy' ? 'passed' : 'pending');
|
|
84
|
-
assert.deepEqual(adapter.planRuntime(createRuntimeContext({
|
|
85
|
-
adapterId,
|
|
86
|
-
targetRoot: path.join(os.tmpdir(), `buildr-${adapterId}-evidence`),
|
|
87
|
-
scope: '.',
|
|
88
|
-
rules: { writes: [], nativeAssets: [], removals: [], actions: [] },
|
|
89
|
-
skills: { writes: [], removals: [] },
|
|
90
|
-
})).capabilityEvidence.map((item) => item.adapterId), REQUIRED_RENDER_CAPABILITIES.map(() => adapterId));
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const adapterDocPath = path.join(productRoot, 'docs', 'agent-runtime-adapters.md');
|
|
94
|
-
const adapterDoc = fs.readFileSync(adapterDocPath, 'utf8');
|
|
95
|
-
for (const adapterId of SUPPORTED_AGENT_IDS) {
|
|
96
|
-
assert.ok(adapterDoc.includes(`(\`${adapterId}\`)`), `${adapterId} must have an adapter documentation section`);
|
|
97
|
-
}
|
|
98
|
-
for (const token of ['Rules 接入', 'Skills 接入', '生效/刷新', 'checker', '证据', 'smoke']) assert.ok(adapterDoc.includes(token), `adapter documentation must contain ${token}`);
|
|
99
|
-
for (const readmeName of ['README.md', 'README.en.md']) {
|
|
100
|
-
const readme = fs.readFileSync(path.join(repositoryRoot, readmeName), 'utf8');
|
|
101
|
-
assert.ok(readme.includes('projects/product/docs/agent-runtime-adapters.md'), `${readmeName} must link the authoritative adapter documentation`);
|
|
102
|
-
}
|
|
103
|
-
assert.equal(RUNTIME_ADAPTERS.cursor.traits.rules.kind, 'vendor-rule-files');
|
|
104
|
-
assert.equal(RUNTIME_ADAPTERS.qoder.traits.rules.format, 'qoder-markdown');
|
|
105
|
-
assert.equal(RUNTIME_ADAPTERS.trae.traits.rules.format, 'trae-markdown');
|
|
106
|
-
assert.equal(RUNTIME_ADAPTERS.trae.traits.checker.versionProbe.kind, 'manual');
|
|
107
|
-
assert.equal(RUNTIME_ADAPTERS.trae.traits.skills.root, '.agents');
|
|
108
|
-
assert.equal(RUNTIME_ADAPTERS.cursor.traits.rules.format, 'cursor-mdc');
|
|
109
|
-
assert.equal(RUNTIME_ADAPTERS['trae-work'].traits.rules.placement, 'root-index');
|
|
110
|
-
assert.equal(RUNTIME_ADAPTERS['trae-work'].traits.checker.prerequisites[0].code, 'runtime.trae_work_rules_import_unverified');
|
|
111
|
-
assert.equal(RUNTIME_ADAPTERS.workbuddy.traits.rules.maxChars, 8000);
|
|
112
|
-
assert.equal(RUNTIME_ADAPTERS.workbuddy.traits.skills.root, '.codebuddy');
|
|
113
|
-
assert.deepEqual(RUNTIME_ADAPTERS.workbuddy.traits.surfaces, [{ kind: 'desktop' }, { kind: 'cli', variant: 'desktop-bundled' }]);
|
|
114
|
-
assert.equal(RUNTIME_ADAPTERS.workbuddy.evidence.smoke.surface, 'desktop-bundled-cli');
|
|
115
|
-
assert.equal(RUNTIME_ADAPTERS.workbuddy.evidence.smoke.rules.siblingIsolated, 'pass');
|
|
116
|
-
assert.equal(RUNTIME_ADAPTERS.workbuddy.evidence.smoke.skill.result, 'SMOKE_SKILL_DISCOVERED_19AF');
|
|
117
|
-
assert.ok(adapterDoc.includes('`.codebuddy/skills`'));
|
|
118
|
-
|
|
119
|
-
assert.throws(() => getRuntimeAdapter('fake-runtime'), /Unsupported Agent runtime/);
|
|
120
|
-
assert.throws(() => createRuntimeAdapterRegistry([{ id: 'fake-runtime', runtimeTargets: [], renderCapabilities: {}, recommendedCommands: {} }], { testOnly: true }), /Invalid runtime adapter registry/);
|
|
121
|
-
|
|
122
|
-
const fakeImplementations = { rules: ['fake-rules'], skills: ['fake-skills'], checker: ['fake-checker'] };
|
|
123
|
-
const fakeDescriptor = createRuntimeAdapterDescriptor({
|
|
124
|
-
id: 'fake-runtime',
|
|
125
|
-
displayName: 'Fake Runtime',
|
|
126
|
-
traits: {
|
|
127
|
-
rules: { kind: 'vendor-rule-files', implementation: 'fake-rules', format: 'qoder-markdown', targetPattern: '.fake/rules/<source>.md' },
|
|
128
|
-
skills: { kind: 'vendor-root', implementation: 'fake-skills', root: '.fake' },
|
|
129
|
-
surfaces: [{ kind: 'ide', variant: 'test' }],
|
|
130
|
-
activation: { rules: 'explicit-reload', skills: 'explicit-reload', reloadGuidance: 'Reload Fake Runtime.' },
|
|
131
|
-
checker: {
|
|
132
|
-
kind: 'projection',
|
|
133
|
-
implementation: 'fake-checker',
|
|
134
|
-
installationProbe: { kind: 'manual', guidance: 'Confirm Fake Runtime is installed.' },
|
|
135
|
-
versionProbe: { kind: 'command', executable: 'fake-runtime', args: ['--version'], timeoutMs: 1000 },
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
recommendedCommands: {},
|
|
139
|
-
}, { implementations: fakeImplementations });
|
|
140
|
-
const fakeRegistry = createRuntimeAdapterRegistry([fakeDescriptor], { testOnly: true, implementations: fakeImplementations });
|
|
141
|
-
assert.equal(fakeRegistry['fake-runtime'].id, 'fake-runtime');
|
|
142
|
-
assert.equal(fakeRegistry['fake-runtime'].traits.skills.root, '.fake');
|
|
143
|
-
assert.equal(fakeRegistry['fake-runtime'].renderCapabilities['rules-entry'].projection.mode, 'rendered');
|
|
144
|
-
const fakeRulesPlanner = () => 'fake-plan';
|
|
145
|
-
assert.equal(selectAdapterImplementation(fakeRegistry['fake-runtime'], 'rules', { 'fake-rules': fakeRulesPlanner }), fakeRulesPlanner);
|
|
146
|
-
assert.throws(() => selectAdapterImplementation(fakeRegistry['fake-runtime'], 'rules', {}), /no registered rules implementation/);
|
|
147
|
-
assert.equal(RUNTIME_ADAPTERS['fake-runtime'], undefined);
|
|
148
|
-
|
|
149
|
-
const fakeValue = {
|
|
150
|
-
id: 'invalid-runtime',
|
|
151
|
-
displayName: 'Invalid Runtime',
|
|
152
|
-
recommendedCommands: {},
|
|
153
|
-
traits: {
|
|
154
|
-
rules: { kind: 'vendor-rule-files', implementation: 'fake-rules', format: 'qoder-markdown', targetPattern: '.fake/rules/<source>.md' },
|
|
155
|
-
skills: { kind: 'vendor-root', implementation: 'fake-skills', root: '.fake' },
|
|
156
|
-
surfaces: [{ kind: 'ide' }],
|
|
157
|
-
activation: { rules: 'session-start', skills: 'session-start' },
|
|
158
|
-
checker: { kind: 'projection', implementation: 'fake-checker', installationProbe: { kind: 'none' }, versionProbe: { kind: 'none' } },
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
assert.throws(() => createRuntimeAdapterDescriptor({ ...fakeValue, traits: { ...fakeValue.traits, rules: { ...fakeValue.traits.rules, kind: 'unknown' } } }, { implementations: fakeImplementations }), /rules trait is invalid/);
|
|
162
|
-
assert.throws(() => createRuntimeAdapterDescriptor({ ...fakeValue, traits: { ...fakeValue.traits, skills: { ...fakeValue.traits.skills, root: '../escape' } } }, { implementations: fakeImplementations }), /skills root is unsafe/);
|
|
163
|
-
assert.throws(() => createRuntimeAdapterDescriptor({ ...fakeValue, traits: { ...fakeValue.traits, rules: { kind: 'native-root', implementation: 'fake-rules' } } }, { implementations: fakeImplementations }), /do not cover recursive scope/);
|
|
164
|
-
assert.throws(() => createRuntimeAdapterDescriptor({ ...fakeValue, traits: { ...fakeValue.traits, rules: { ...fakeValue.traits.rules, implementation: 'missing' } } }, { implementations: fakeImplementations }), /no registered rules implementation/);
|
|
165
|
-
assert.throws(() => createRuntimeAdapterRegistry([fakeDescriptor, fakeDescriptor], { testOnly: true, implementations: fakeImplementations }), /duplicate adapter id/);
|
|
166
|
-
|
|
167
|
-
const codex = RUNTIME_ADAPTERS.codex;
|
|
168
|
-
const root = path.join(os.tmpdir(), 'buildr-invalid-plan');
|
|
169
|
-
const context = createRuntimeContext({ adapterId: 'codex', targetRoot: root, scope: '.', rules: { writes: [], nativeAssets: [], removals: [], actions: [] }, skills: { writes: [], removals: [] } });
|
|
170
|
-
const valid = codex.planRuntime(context);
|
|
171
|
-
assert.throws(() => validateRuntimePlan({ ...valid, writes: [{ targetFile: path.join(root, '..', 'escape'), content: 'bad' }] }, codex), /outside target root/);
|
|
172
|
-
assert.throws(() => validateRuntimePlan({ ...valid, capabilityEvidence: [] }, codex), /missing capability evidence/);
|
|
173
|
-
|
|
174
|
-
const symlinkPlanRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'buildr-runtime-plan-symlink-'));
|
|
175
|
-
const symlinkPlanOutside = fs.mkdtempSync(path.join(os.tmpdir(), 'buildr-runtime-plan-outside-'));
|
|
176
|
-
fs.mkdirSync(path.join(symlinkPlanRoot, '.agents'), { recursive: true });
|
|
177
|
-
fs.symlinkSync(symlinkPlanOutside, path.join(symlinkPlanRoot, '.agents', 'skills'), 'dir');
|
|
178
|
-
const symlinkPlanTarget = path.join(symlinkPlanRoot, '.agents', 'skills', 'demo', 'SKILL.md');
|
|
179
|
-
assert.throws(() => validateRuntimePlan({ ...valid, targetRoot: symlinkPlanRoot, writes: [{ targetFile: symlinkPlanTarget, content: 'bad' }] }, codex), /crosses a symbolic link/);
|
|
180
|
-
assert.throws(() => validateRuntimePlan({ ...valid, targetRoot: symlinkPlanRoot, removals: [{ targetFile: symlinkPlanTarget }] }, codex), /crosses a symbolic link/);
|
|
181
|
-
|
|
182
|
-
const reconcileRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'buildr-runtime-reconcile-'));
|
|
183
|
-
const targetFile = path.join(reconcileRoot, '.agents', 'skills', 'demo', 'SKILL.md');
|
|
184
|
-
const orphanFile = path.join(reconcileRoot, '.agents', 'buildr', 'skill-install-plans', 'orphan.md');
|
|
185
|
-
fs.mkdirSync(path.dirname(orphanFile), { recursive: true });
|
|
186
|
-
fs.writeFileSync(orphanFile, '<!-- Generated by Buildr. Agent action required. -->\n');
|
|
187
|
-
const evidence = REQUIRED_RENDER_CAPABILITIES.map((capability) => ({ capability, supported: true }));
|
|
188
|
-
const reconcilePlan = createRuntimePlan({ adapterId: 'codex', targetRoot: reconcileRoot, scope: '.', writes: [{ targetFile, content: 'managed\n', source: 'test', isManaged: (content) => content === 'managed\n' }], nativeAssets: [], removals: [{ targetFile: orphanFile, isManaged: (content) => content.includes('Generated by Buildr') }], capabilityEvidence: evidence });
|
|
189
|
-
assert.equal(reconcileRuntimePlan(reconcilePlan).changed.length, 1);
|
|
190
|
-
assert.equal(fs.existsSync(orphanFile), false);
|
|
191
|
-
assert.equal(reconcileRuntimePlan(reconcilePlan).changed.length, 0);
|
|
192
|
-
fs.writeFileSync(targetFile, 'raw source\n');
|
|
193
|
-
const adoptionPlan = createRuntimePlan({ adapterId: 'codex', targetRoot: reconcileRoot, scope: '.', writes: [{ targetFile, content: 'managed adoption\n', sourceContent: 'raw source\n', source: 'test', isManaged: () => false }], nativeAssets: [], removals: [], capabilityEvidence: evidence });
|
|
194
|
-
assert.equal(reconcileRuntimePlan(adoptionPlan).changed.length, 1);
|
|
195
|
-
fs.writeFileSync(targetFile, 'user content\n');
|
|
196
|
-
assert.throws(() => reconcileRuntimePlan(reconcilePlan), /no files were changed/);
|
|
197
|
-
assert.equal(fs.readFileSync(targetFile, 'utf8'), 'user content\n');
|
|
198
|
-
|
|
199
|
-
const componentRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'buildr-runtime-component-'));
|
|
200
|
-
const componentDir = path.join(componentRoot, 'components', 'workspace', 'demo');
|
|
201
|
-
const fragmentRelative = 'components/workspace/demo/contributions/demo.md';
|
|
202
|
-
const ruleRelative = 'rules/demo.md';
|
|
203
|
-
fs.mkdirSync(path.join(componentRoot, 'components'), { recursive: true });
|
|
204
|
-
fs.mkdirSync(path.dirname(path.join(componentRoot, fragmentRelative)), { recursive: true });
|
|
205
|
-
fs.mkdirSync(path.join(componentRoot, 'rules'), { recursive: true });
|
|
206
|
-
fs.writeFileSync(path.join(componentRoot, 'components', 'manifest.yml'), 'schemaVersion: buildr.components/v1\ncomponents:\n - id: demo\n path: components/workspace/demo\n enabled: true\n state: installed\n');
|
|
207
|
-
fs.writeFileSync(path.join(componentRoot, fragmentRelative), 'Contribution\n');
|
|
208
|
-
fs.writeFileSync(path.join(componentRoot, ruleRelative), 'Rule\n');
|
|
209
|
-
const integrity = (relative) => `sha256-${crypto.createHash('sha256').update(fs.readFileSync(path.join(componentRoot, relative))).digest('hex')}`;
|
|
210
|
-
const definition = (extra = '') => `schemaVersion: buildr.component/v1\nid: demo\nkind: addon\nversion: 1.0.0\nsource: workspace\n${extra}members:\n rules: [${JSON.stringify(ruleRelative)}]\n skills: []\n commandCollections: []\n skillContributions: [${JSON.stringify(fragmentRelative)}]\ncontributions:\n skillFragments: [${JSON.stringify(`buildr#slot=${fragmentRelative}`)}]\nintegrity: [${JSON.stringify(`${ruleRelative}=${integrity(ruleRelative)}`)}, ${JSON.stringify(`${fragmentRelative}=${integrity(fragmentRelative)}`)}]\n`;
|
|
211
|
-
fs.writeFileSync(path.join(componentDir, 'component.yml'), definition('adapter: ./adapter.mjs\n'));
|
|
212
|
-
assert.throws(() => resolveSkillContributions(componentRoot), /cannot extend runtime adapters/);
|
|
213
|
-
fs.writeFileSync(path.join(componentDir, 'component.yml'), definition());
|
|
214
|
-
assert.equal(resolveSkillContributions(componentRoot).length, 1);
|
|
215
|
-
fs.writeFileSync(path.join(componentRoot, ruleRelative), 'modified\n');
|
|
216
|
-
assert.throws(() => resolveSkillContributions(componentRoot), /Component member integrity mismatch/);
|
|
217
|
-
|
|
218
|
-
console.log('runtime adapter contract verification passed');
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import assert from 'node:assert/strict';
|
|
4
|
-
import crypto from 'node:crypto';
|
|
5
|
-
import fs from 'node:fs';
|
|
6
|
-
import os from 'node:os';
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
import { execFileSync, spawnSync } from 'node:child_process';
|
|
9
|
-
import { fileURLToPath } from 'node:url';
|
|
10
|
-
|
|
11
|
-
const productRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../..');
|
|
12
|
-
const buildr = path.join(productRoot, 'tools', 'buildr');
|
|
13
|
-
const workspace = fs.mkdtempSync(path.join(os.tmpdir(), 'buildr-runtime-parity-'));
|
|
14
|
-
|
|
15
|
-
function run(args, options = {}) {
|
|
16
|
-
const result = spawnSync(process.execPath, [buildr, ...args], { cwd: productRoot, encoding: 'utf8', env: { ...process.env, ...(options.env || {}) } });
|
|
17
|
-
if (!options.allowFailure && result.status !== 0) throw new Error(`${args.join(' ')} failed:\n${result.stdout}\n${result.stderr}`);
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function digestRuntime() {
|
|
22
|
-
const hash = crypto.createHash('sha256');
|
|
23
|
-
const visit = (directory) => {
|
|
24
|
-
if (!fs.existsSync(directory)) return;
|
|
25
|
-
for (const entry of fs.readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
26
|
-
const item = path.join(directory, entry.name);
|
|
27
|
-
if (entry.isDirectory()) visit(item);
|
|
28
|
-
else if (entry.isFile()) {
|
|
29
|
-
hash.update(path.relative(workspace, item));
|
|
30
|
-
hash.update('\0');
|
|
31
|
-
hash.update(fs.readFileSync(item));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
for (const directory of ['.agents', '.claude', '.cursor', '.qoder', '.trae', '.codebuddy']) visit(path.join(workspace, directory));
|
|
36
|
-
for (const file of ['CLAUDE.md', 'CLAUDE.local.md', 'CODEBUDDY.md', 'AGENTS.md']) if (fs.existsSync(path.join(workspace, file))) hash.update(fs.readFileSync(path.join(workspace, file)));
|
|
37
|
-
return hash.digest('hex');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
run(['init', '--target', workspace, '--name', 'runtime-parity']);
|
|
41
|
-
fs.appendFileSync(path.join(workspace, 'AGENTS.md'), '\nROOT_MARKER\n');
|
|
42
|
-
|
|
43
|
-
const symlinkWorkspace = fs.mkdtempSync(path.join(os.tmpdir(), 'buildr-runtime-symlink-'));
|
|
44
|
-
const symlinkOutside = fs.mkdtempSync(path.join(os.tmpdir(), 'buildr-runtime-outside-'));
|
|
45
|
-
run(['init', '--target', symlinkWorkspace, '--name', 'runtime-symlink']);
|
|
46
|
-
fs.mkdirSync(path.join(symlinkWorkspace, '.agents'), { recursive: true });
|
|
47
|
-
fs.symlinkSync(symlinkOutside, path.join(symlinkWorkspace, '.agents', 'skills'), 'dir');
|
|
48
|
-
const symlinkInstall = run(['skill', 'install', 'codex', '--target', symlinkWorkspace], { allowFailure: true });
|
|
49
|
-
assert.notEqual(symlinkInstall.status, 0, 'runtime install must reject a target path that crosses a symbolic link');
|
|
50
|
-
assert.equal(fs.existsSync(path.join(symlinkOutside, 'buildr', 'SKILL.md')), false, 'runtime install must not write outside the workspace through a symbolic link');
|
|
51
|
-
|
|
52
|
-
const rulesSymlinkWorkspace = fs.mkdtempSync(path.join(os.tmpdir(), 'buildr-runtime-rules-symlink-'));
|
|
53
|
-
const rulesSymlinkOutside = fs.mkdtempSync(path.join(os.tmpdir(), 'buildr-runtime-rules-outside-'));
|
|
54
|
-
run(['init', '--target', rulesSymlinkWorkspace, '--name', 'runtime-rules-symlink']);
|
|
55
|
-
fs.symlinkSync(rulesSymlinkOutside, path.join(rulesSymlinkWorkspace, '.cursor'), 'dir');
|
|
56
|
-
const symlinkRulesRender = run(['rules', 'render', 'cursor', '--scope', '.', '--target', rulesSymlinkWorkspace], { allowFailure: true });
|
|
57
|
-
assert.notEqual(symlinkRulesRender.status, 0, 'runtime rules render must reject a target path that crosses a symbolic link');
|
|
58
|
-
assert.equal(fs.existsSync(path.join(rulesSymlinkOutside, 'rules', 'buildr.mdc')), false, 'rules render must not write outside the workspace through a symbolic link');
|
|
59
|
-
|
|
60
|
-
run(['project', 'create', 'scope-alpha', '--target', workspace, '--description', 'scope alpha']);
|
|
61
|
-
run(['project', 'create', 'scope-beta', '--target', workspace, '--description', 'scope beta']);
|
|
62
|
-
fs.mkdirSync(path.join(workspace, 'projects', 'scope-alpha', 'services', 'api'), { recursive: true });
|
|
63
|
-
fs.mkdirSync(path.join(workspace, 'projects', 'scope-alpha', 'services', 'web'), { recursive: true });
|
|
64
|
-
fs.writeFileSync(path.join(workspace, 'projects', 'scope-alpha', 'services', 'api', 'AGENTS.md'), '# API rules\nAPI_MARKER\n');
|
|
65
|
-
fs.writeFileSync(path.join(workspace, 'projects', 'scope-alpha', 'services', 'web', 'AGENTS.md'), '# Web rules\nWEB_MARKER\n');
|
|
66
|
-
run(['skills', 'add', 'beta-remote', '--remote-source', 'https://example.com/beta-remote', '--scope', 'projects/scope-beta', '--target', workspace, '--description', 'beta remote']);
|
|
67
|
-
run(['skills', 'render', 'codex', '--scope', '.', '--target', workspace]);
|
|
68
|
-
const betaPlan = path.join(workspace, '.agents', 'buildr', 'skill-install-plans', 'beta-remote.md');
|
|
69
|
-
assert.ok(fs.existsSync(betaPlan));
|
|
70
|
-
const betaManifest = path.join(workspace, 'projects', 'scope-beta', 'skills', 'manifest.yml');
|
|
71
|
-
const betaManifestContent = fs.readFileSync(betaManifest, 'utf8');
|
|
72
|
-
fs.writeFileSync(betaManifest, 'schemaVersion: [invalid\n', 'utf8');
|
|
73
|
-
const scopedRender = run(['skills', 'render', 'codex', '--scope', 'projects/scope-alpha', '--target', workspace], { allowFailure: true });
|
|
74
|
-
assert.equal(scopedRender.status, 0, 'Project-scoped render must not fail because an unrelated Project manifest is invalid');
|
|
75
|
-
assert.ok(fs.existsSync(betaPlan), 'Project-scoped render must not remove an unrelated Project install plan');
|
|
76
|
-
fs.writeFileSync(betaManifest, betaManifestContent, 'utf8');
|
|
77
|
-
|
|
78
|
-
const lifecycleAdapters = ['cursor', 'qoder', 'workbuddy', 'claude-code', 'codex'];
|
|
79
|
-
for (const agent of lifecycleAdapters) {
|
|
80
|
-
run(['skill', 'install', agent, '--target', workspace]);
|
|
81
|
-
run(['render', agent, '--scope', '.', '--target', workspace]);
|
|
82
|
-
const check = run(['runtime', 'check', agent, '--scope', '.', '--target', workspace]);
|
|
83
|
-
assert.equal(check.status, 0, `${agent} runtime check should pass after render`);
|
|
84
|
-
assert.match(check.stdout, /Environment:/, `${agent} runtime check must report environment probes`);
|
|
85
|
-
assert.match(check.stdout, /Activation: rules=/, `${agent} runtime check must report activation`);
|
|
86
|
-
if (agent === 'cursor') assert.match(check.stdout, /installation: manual \(manual\)/);
|
|
87
|
-
if (agent === 'qoder') assert.match(check.stdout, /Reload: Run \/skills reload/);
|
|
88
|
-
if (agent === 'workbuddy') assert.doesNotMatch(check.stdout, /runtime\.workbuddy_reference_smoke_pending|reference traversal cannot be proven/);
|
|
89
|
-
}
|
|
90
|
-
const missingQoderEnvironment = run(['runtime', 'check', 'qoder', '--scope', '.', '--target', workspace], { env: { PATH: '' } });
|
|
91
|
-
assert.match(missingQoderEnvironment.stdout, /\[warning\] \. - Qoder installation probe failed\./);
|
|
92
|
-
assert.match(missingQoderEnvironment.stdout, /installation: missing \(command\)/);
|
|
93
|
-
|
|
94
|
-
assert.ok(fs.existsSync(path.join(workspace, '.agents', 'skills', 'buildr', 'SKILL.md')));
|
|
95
|
-
assert.ok(fs.existsSync(path.join(workspace, '.claude', 'skills', 'buildr', 'SKILL.md')));
|
|
96
|
-
assert.ok(fs.readFileSync(path.join(workspace, '.cursor', 'rules', 'buildr.mdc'), 'utf8').includes('ROOT_MARKER'));
|
|
97
|
-
assert.ok(fs.readFileSync(path.join(workspace, 'projects', 'scope-alpha', 'services', 'api', '.cursor', 'rules', 'buildr.mdc'), 'utf8').includes('API_MARKER'));
|
|
98
|
-
assert.ok(fs.readFileSync(path.join(workspace, 'projects', 'scope-alpha', 'services', 'web', '.cursor', 'rules', 'buildr.mdc'), 'utf8').includes('WEB_MARKER'));
|
|
99
|
-
assert.ok(fs.readdirSync(path.join(workspace, '.qoder', 'rules', 'buildr')).some((file) => file.endsWith('.md')));
|
|
100
|
-
assert.ok(fs.readFileSync(path.join(workspace, 'CODEBUDDY.md'), 'utf8').includes('不得读取不相关兄弟目录'));
|
|
101
|
-
assert.ok(fs.existsSync(path.join(workspace, '.qoder', 'skills', 'buildr', 'SKILL.md')));
|
|
102
|
-
assert.ok(fs.existsSync(path.join(workspace, '.codebuddy', 'skills', 'buildr', 'SKILL.md')));
|
|
103
|
-
assert.ok(fs.readFileSync(path.join(workspace, 'CLAUDE.md'), 'utf8').includes('@AGENTS.md'));
|
|
104
|
-
assert.ok(!fs.existsSync(path.join(workspace, '.agents', 'CLAUDE.md')));
|
|
105
|
-
|
|
106
|
-
const codexBuildr = fs.readFileSync(path.join(workspace, '.agents', 'skills', 'task-finish', 'SKILL.md'), 'utf8');
|
|
107
|
-
const claudeBuildr = fs.readFileSync(path.join(workspace, '.claude', 'skills', 'task-finish', 'SKILL.md'), 'utf8');
|
|
108
|
-
assert.ok(codexBuildr.includes('buildr:contribution openspec#pre-spec-sync'));
|
|
109
|
-
assert.ok(claudeBuildr.includes('buildr:contribution openspec#pre-spec-sync'));
|
|
110
|
-
|
|
111
|
-
const betaCursorRule = path.join(workspace, 'projects', 'scope-beta', '.cursor', 'rules', 'buildr.mdc');
|
|
112
|
-
const qoderDirectory = path.join(workspace, '.qoder', 'rules', 'buildr');
|
|
113
|
-
const betaQoderRule = fs.readdirSync(qoderDirectory)
|
|
114
|
-
.map((file) => path.join(qoderDirectory, file))
|
|
115
|
-
.find((file) => fs.readFileSync(file, 'utf8').includes('source: projects/scope-beta/AGENTS.md'));
|
|
116
|
-
assert.ok(betaQoderRule, 'Qoder must render a managed rule for scope-beta');
|
|
117
|
-
const betaProjectionSnapshot = new Map([
|
|
118
|
-
[betaCursorRule, fs.readFileSync(betaCursorRule, 'utf8')],
|
|
119
|
-
[betaQoderRule, fs.readFileSync(betaQoderRule, 'utf8')],
|
|
120
|
-
[path.join(workspace, 'CODEBUDDY.md'), fs.readFileSync(path.join(workspace, 'CODEBUDDY.md'), 'utf8')],
|
|
121
|
-
]);
|
|
122
|
-
for (const agent of ['cursor', 'qoder', 'workbuddy']) run(['rules', 'render', agent, '--scope', 'projects/scope-alpha', '--target', workspace]);
|
|
123
|
-
for (const [file, content] of betaProjectionSnapshot) {
|
|
124
|
-
assert.equal(fs.readFileSync(file, 'utf8'), content, `Project-scoped Rules render must preserve unrelated projection: ${file}`);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const orphan = path.join(workspace, '.agents', 'skills', 'runtime-orphan', 'SKILL.md');
|
|
128
|
-
fs.mkdirSync(path.dirname(orphan), { recursive: true });
|
|
129
|
-
fs.writeFileSync(orphan, '---\nname: runtime-orphan\n---\n<!-- Generated by Buildr. Hash: deadbeef. Do not edit. -->\n');
|
|
130
|
-
run(['render', 'codex', '--scope', '.', '--target', workspace]);
|
|
131
|
-
assert.equal(fs.existsSync(path.dirname(orphan)), false);
|
|
132
|
-
|
|
133
|
-
const before = digestRuntime();
|
|
134
|
-
for (const agent of lifecycleAdapters) run(['render', agent, '--scope', '.', '--target', workspace]);
|
|
135
|
-
assert.equal(digestRuntime(), before, 'repeated render must be idempotent');
|
|
136
|
-
|
|
137
|
-
const doctor = JSON.parse(execFileSync(process.execPath, [buildr, 'doctor', '--agent', 'codex', '--target', workspace, '--json'], { cwd: productRoot, encoding: 'utf8' }));
|
|
138
|
-
assert.equal(doctor.agentRuntime.requested, 'codex');
|
|
139
|
-
assert.equal(doctor.agentRuntime.supported, true);
|
|
140
|
-
assert.equal(doctor.runtime.claudeCode.length, 0);
|
|
141
|
-
assert.ok(doctor.runtime.codex.length > 0);
|
|
142
|
-
|
|
143
|
-
const rulesOrphanWorkspace = fs.mkdtempSync(path.join(os.tmpdir(), 'buildr-runtime-rules-orphan-'));
|
|
144
|
-
run(['init', '--target', rulesOrphanWorkspace, '--name', 'runtime-rules-orphan']);
|
|
145
|
-
for (const agent of ['cursor', 'qoder', 'workbuddy']) {
|
|
146
|
-
run(['rules', 'render', agent, '--scope', '.', '--target', rulesOrphanWorkspace]);
|
|
147
|
-
}
|
|
148
|
-
fs.rmSync(path.join(rulesOrphanWorkspace, 'AGENTS.md'));
|
|
149
|
-
for (const agent of ['cursor', 'qoder', 'workbuddy']) {
|
|
150
|
-
run(['rules', 'render', agent, '--scope', '.', '--target', rulesOrphanWorkspace]);
|
|
151
|
-
}
|
|
152
|
-
assert.equal(fs.existsSync(path.join(rulesOrphanWorkspace, '.cursor', 'rules', 'buildr.mdc')), false);
|
|
153
|
-
assert.deepEqual(fs.readdirSync(path.join(rulesOrphanWorkspace, '.qoder', 'rules', 'buildr')), []);
|
|
154
|
-
assert.equal(fs.existsSync(path.join(rulesOrphanWorkspace, 'CODEBUDDY.md')), false);
|
|
155
|
-
|
|
156
|
-
const boundaryWorkspace = fs.mkdtempSync(path.join(os.tmpdir(), 'buildr-runtime-boundary-orphan-'));
|
|
157
|
-
run(['init', '--target', boundaryWorkspace, '--name', 'runtime-boundary-orphan']);
|
|
158
|
-
const externalRepo = path.join(boundaryWorkspace, 'external-repo');
|
|
159
|
-
fs.mkdirSync(path.join(externalRepo, '.git'), { recursive: true });
|
|
160
|
-
fs.writeFileSync(path.join(externalRepo, '.git', 'HEAD'), 'ref: refs/heads/main\n');
|
|
161
|
-
fs.writeFileSync(path.join(externalRepo, 'AGENTS.md'), 'EXTERNAL_REPO_RULE_MUST_NOT_BE_DISCOVERED\n');
|
|
162
|
-
const externalCursorRule = path.join(externalRepo, '.cursor', 'rules', 'buildr.mdc');
|
|
163
|
-
const externalTraeRule = path.join(externalRepo, '.trae', 'rules', 'buildr.md');
|
|
164
|
-
fs.mkdirSync(path.dirname(externalCursorRule), { recursive: true });
|
|
165
|
-
fs.mkdirSync(path.dirname(externalTraeRule), { recursive: true });
|
|
166
|
-
fs.writeFileSync(externalCursorRule, '<!-- Generated by Buildr. Agent adapter: cursor; boundary fixture. -->\n');
|
|
167
|
-
fs.writeFileSync(externalTraeRule, '<!-- Generated by Buildr. Agent adapter: trae; boundary fixture. -->\n');
|
|
168
|
-
run(['rules', 'render', 'cursor', '--scope', '.', '--target', boundaryWorkspace]);
|
|
169
|
-
run(['rules', 'render', 'trae', '--scope', '.', '--target', boundaryWorkspace]);
|
|
170
|
-
assert.ok(fs.existsSync(externalCursorRule), 'orphan cleanup must not cross an unregistered nested Git boundary');
|
|
171
|
-
assert.ok(fs.existsSync(externalTraeRule), 'orphan cleanup must not cross an unregistered nested Git boundary');
|
|
172
|
-
|
|
173
|
-
console.log('runtime adapter parity verification passed');
|
|
File without changes
|