@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.
Files changed (181) hide show
  1. package/README.md +47 -5
  2. package/application-payload.json +595 -0
  3. package/bin/buildr.mjs +14 -0
  4. package/installation-origin.json +13 -0
  5. package/package.json +16 -45
  6. package/payload/licenses/dependencies/yaml-LICENSE +13 -0
  7. package/payload/product/LICENSE +21 -0
  8. package/payload/product/README.md +59 -0
  9. package/payload/product/package/README.md +42 -0
  10. package/{package → payload/product/package}/bootstrap/contract.yml +26 -11
  11. package/{package → payload/product/package}/bootstrap/guide.md +11 -11
  12. package/payload/product/package/launchers/assets/Buildr.icns +0 -0
  13. package/payload/product/package/launchers/assets/Buildr.ico +0 -0
  14. package/payload/product/package/manifest.yml +547 -0
  15. package/payload/product/package/targets/runtime/skills/buildr/SKILL.md +174 -0
  16. package/{package → payload/product/package}/targets/workspace/commands/buildr/openspec/manifest.yml +2 -2
  17. package/payload/product/package/targets/workspace/components/buildr/openspec/component.yml +79 -0
  18. package/payload/product/package/targets/workspace/components/buildr/openspec/contributions/openspec-apply-sidebar.md +21 -0
  19. package/payload/product/package/targets/workspace/components/buildr/openspec/contributions/openspec-archive-converge.md +5 -0
  20. package/payload/product/package/targets/workspace/components/buildr/openspec/contributions/openspec-explore-terminology.md +5 -0
  21. package/payload/product/package/targets/workspace/components/buildr/openspec/contributions/openspec-propose-sidebar.md +21 -0
  22. package/payload/product/package/targets/workspace/components/buildr/openspec/contributions/openspec-sync-converge.md +5 -0
  23. package/payload/product/package/targets/workspace/components/buildr/openspec/contributions/openspec-update-sidebar.md +13 -0
  24. package/payload/product/package/targets/workspace/gitattributes +1 -0
  25. package/payload/product/package/targets/workspace/gitignore +31 -0
  26. package/{package → payload/product/package}/targets/workspace/projects/AGENTS.project.md +1 -1
  27. package/payload/product/package/targets/workspace/rules/buildr/core.md +62 -0
  28. package/payload/product/package/targets/workspace/skills/buildr/capability-adaptation/SKILL.md +56 -0
  29. package/payload/product/package/targets/workspace/skills/buildr/capability-adaptation/agents/openai.yaml +4 -0
  30. package/payload/product/package/targets/workspace/skills/buildr/current-knowledge-maintenance/SKILL.md +103 -0
  31. package/payload/product/package/targets/workspace/skills/buildr/declaration-intake/SKILL.md +65 -0
  32. package/payload/product/package/targets/workspace/skills/buildr/git-operations/SKILL.md +100 -0
  33. package/payload/product/package/targets/workspace/skills/buildr/openspec-contract-guard/SKILL.md +65 -0
  34. package/payload/product/package/targets/workspace/skills/buildr/project-daily-progress/SKILL.md +52 -0
  35. package/payload/product/package/targets/workspace/skills/buildr/project-testing/SKILL.md +84 -0
  36. package/payload/product/package/targets/workspace/skills/buildr/project-testing/references/testing-model-v1.md +116 -0
  37. package/payload/product/package/targets/workspace/skills/buildr/task-development/SKILL.md +108 -0
  38. package/payload/product/package/targets/workspace/skills/buildr/task-environment/SKILL.md +42 -0
  39. package/payload/product/package/targets/workspace/skills/buildr/task-environment/agents/openai.yaml +4 -0
  40. package/payload/product/package/targets/workspace/skills/buildr/task-environment/references/project-environment-preparation-v1.md +14 -0
  41. package/payload/product/package/targets/workspace/skills/buildr/task-environment/templates/project-preparation.yml +20 -0
  42. package/payload/product/package/targets/workspace/skills/buildr/task-environment/templates/task-environment-plan-request.json +17 -0
  43. package/payload/product/package/targets/workspace/skills/buildr/task-finish/SKILL.md +80 -0
  44. package/payload/product/package/targets/workspace/skills/buildr/task-manager/SKILL.md +47 -0
  45. package/payload/product/package/targets/workspace/skills/buildr/task-manager/agents/openai.yaml +4 -0
  46. package/payload/product/package/targets/workspace/skills/buildr/task-retrospective/SKILL.md +101 -0
  47. package/payload/product/package/targets/workspace/skills/buildr/task-retrospective/agents/openai.yaml +4 -0
  48. package/payload/product/package/targets/workspace/skills/buildr/task-review/SKILL.md +60 -0
  49. package/payload/product/package/targets/workspace/skills/buildr/task-review/agents/openai.yaml +4 -0
  50. package/payload/product/package/targets/workspace/skills/buildr/task-triage/SKILL.md +119 -0
  51. package/payload/product/package/targets/workspace/skills/buildr/task-verification/SKILL.md +142 -0
  52. package/payload/product/package/targets/workspace/skills/buildr/task-verification/references/project-verification-v2.md +51 -0
  53. package/payload/product/package/targets/workspace/skills/buildr/task-verification/templates/project-verification.yml +16 -0
  54. package/payload/product/package/targets/workspace/skills/buildr/task-worktree/SKILL.md +28 -0
  55. package/payload/product/package/targets/workspace/skills/buildr/terminology-governance/SKILL.md +60 -0
  56. package/payload/product/package/targets/workspace/skills/buildr/ui-preview/SKILL.md +74 -0
  57. package/payload/product/package/targets/workspace/skills/contracts/buildr/current-knowledge-maintenance/v1.md +36 -0
  58. package/payload/product/package/targets/workspace/skills/contracts/buildr/current-knowledge-maintenance/v2.md +45 -0
  59. package/payload/product/package/targets/workspace/skills/contracts/buildr/git-operations/v1.md +39 -0
  60. package/payload/product/package/targets/workspace/skills/contracts/buildr/git-worktree-provider/v1.md +35 -0
  61. package/payload/product/package/targets/workspace/skills/contracts/buildr/task-development/v2.md +61 -0
  62. package/payload/product/package/targets/workspace/skills/contracts/buildr/task-environment/v1.md +37 -0
  63. package/payload/product/package/targets/workspace/skills/contracts/buildr/task-finish/v1.md +59 -0
  64. package/payload/product/package/targets/workspace/skills/contracts/buildr/task-record/v2.md +35 -0
  65. package/payload/product/package/targets/workspace/skills/contracts/buildr/task-retrospective/v2.md +41 -0
  66. package/payload/product/package/targets/workspace/skills/contracts/buildr/task-review/v1.md +39 -0
  67. package/payload/product/package/targets/workspace/skills/contracts/buildr/task-verification/v3.md +63 -0
  68. package/payload/product/package/targets/workspace/skills/contracts/buildr/terminology-governance/v1.md +36 -0
  69. package/{package → payload/product/package}/targets/workspace/skills/openspec/openspec-apply-change/SKILL.md +4 -3
  70. package/{package → payload/product/package}/targets/workspace/skills/openspec/openspec-archive-change/SKILL.md +4 -3
  71. package/{package → payload/product/package}/targets/workspace/skills/openspec/openspec-explore/SKILL.md +4 -1
  72. package/{package → payload/product/package}/targets/workspace/skills/openspec/openspec-propose/SKILL.md +4 -1
  73. package/{package → payload/product/package}/targets/workspace/skills/openspec/openspec-sync-specs/SKILL.md +4 -3
  74. package/payload/product/package/targets/workspace/skills/openspec/openspec-update-change/SKILL.md +86 -0
  75. package/payload/product/package.json +33 -0
  76. package/payload/product/src/infrastructure/sqlite/migrations/0000_create_migration_ledger.sql +16 -0
  77. package/payload/product/src/infrastructure/sqlite/migrations/0001_create_task_store.sql +47 -0
  78. package/payload/product/src/infrastructure/sqlite/migrations/0002_create_parent_task_relations.sql +7 -0
  79. package/payload/product/src/infrastructure/sqlite/migrations/0003_inline_parent_task_column.sql +19 -0
  80. package/payload/product/src/infrastructure/sqlite/migrations/0004_create_task_current_records.sql +16 -0
  81. package/payload/product/src/infrastructure/sqlite/migrations/0005_create_task_retrospective_current.sql +4 -0
  82. package/payload/product/src/infrastructure/sqlite/migrations/0006_create_task_lifecycle_current.sql +4 -0
  83. package/payload/product/src/infrastructure/sqlite/migrations/0007_create_task_finish_current.sql +46 -0
  84. package/payload/product/src/infrastructure/sqlite/migrations/0008_create_task_environment_current.sql +8 -0
  85. package/payload/product/src/infrastructure/sqlite/migrations/0009_retire_task_lifecycle_current.sql +107 -0
  86. package/payload/product/src/infrastructure/sqlite/migrations/0010_add_task_retrospective_disposition.sql +19 -0
  87. package/payload/product/src/infrastructure/sqlite/migrations/0011_create_task_execution_records.sql +115 -0
  88. package/payload/product/src/infrastructure/sqlite/migrations/0012_compact_task_finish_current.sql +261 -0
  89. package/payload/product/src/infrastructure/sqlite/migrations/0013_add_todo_task_retrospective_sources.sql +56 -0
  90. package/payload/product/src/infrastructure/sqlite/migrations/0014_add_task_execution_invocation_identity.sql +14 -0
  91. package/payload/product/src/infrastructure/sqlite/migrations/0015_add_task_execution_unknown_outcome.sql +143 -0
  92. package/payload/product/src/infrastructure/sqlite/migrations/0016_allow_terminal_task_finish_target_lease.sql +83 -0
  93. package/payload/product/src/infrastructure/sqlite/migrations/0017_expand_task_finish_repository_set.sql +111 -0
  94. package/payload/product/src/interfaces/local-app/web-dist/assets/antd-NAtxFWmu.js +394 -0
  95. package/payload/product/src/interfaces/local-app/web-dist/assets/index-BqoyfMSY.css +1 -0
  96. package/payload/product/src/interfaces/local-app/web-dist/assets/index-DTqvE0TF.js +39 -0
  97. package/payload/product/src/interfaces/local-app/web-dist/assets/react-9kRp7SbA.js +28 -0
  98. package/payload/product/src/interfaces/local-app/web-dist/index.html +19 -0
  99. package/payload/runtime/read-worker.cjs +45071 -0
  100. package/runtime/buildr.cjs +51533 -0
  101. package/scripts/postinstall.mjs +15 -0
  102. package/docs/agent-runtime-adapters.md +0 -94
  103. package/docs/cli-architecture.md +0 -65
  104. package/docs/cli-reference.md +0 -67
  105. package/docs/known-limitations.md +0 -15
  106. package/examples/minimal-workspace/README.md +0 -24
  107. package/package/README.md +0 -28
  108. package/package/manifest.yml +0 -150
  109. package/package/targets/runtime/skills/buildr/SKILL.md +0 -154
  110. package/package/targets/workspace/.buildr/workspace.yml +0 -5
  111. package/package/targets/workspace/commands/manifest.yml +0 -2
  112. package/package/targets/workspace/components/buildr/openspec/component.yml +0 -16
  113. package/package/targets/workspace/components/buildr/openspec/contributions/openspec-apply-sidebar.md +0 -3
  114. package/package/targets/workspace/components/buildr/openspec/contributions/openspec-archive-sidebar.md +0 -3
  115. package/package/targets/workspace/components/buildr/openspec/contributions/openspec-explore-sidebar.md +0 -3
  116. package/package/targets/workspace/components/buildr/openspec/contributions/openspec-propose-sidebar.md +0 -3
  117. package/package/targets/workspace/components/buildr/openspec/contributions/openspec-sync-sidebar.md +0 -3
  118. package/package/targets/workspace/components/buildr/openspec/contributions/task-finish-post-sync.md +0 -1
  119. package/package/targets/workspace/components/buildr/openspec/contributions/task-finish-pre-sync.md +0 -1
  120. package/package/targets/workspace/components/buildr/openspec/contributions/task-triage-change-ready.md +0 -10
  121. package/package/targets/workspace/components/manifest.yml +0 -2
  122. package/package/targets/workspace/gitignore +0 -16
  123. package/package/targets/workspace/projects/manifest.yml +0 -2
  124. package/package/targets/workspace/projects/services/manifest.yml +0 -3
  125. package/package/targets/workspace/projects/skills/manifest.yml +0 -2
  126. package/package/targets/workspace/rules/buildr/core.md +0 -65
  127. package/package/targets/workspace/rules/manifest.yml +0 -9
  128. package/package/targets/workspace/skills/buildr/git-ops/SKILL.md +0 -73
  129. package/package/targets/workspace/skills/buildr/openspec-contract-guard/SKILL.md +0 -67
  130. package/package/targets/workspace/skills/buildr/task-finish/SKILL.md +0 -104
  131. package/package/targets/workspace/skills/buildr/task-triage/SKILL.md +0 -103
  132. package/package/targets/workspace/skills/buildr/task-worktree/SKILL.md +0 -104
  133. package/package/targets/workspace/skills/manifest.yml +0 -38
  134. package/tools/buildr +0 -11
  135. package/tools/cli/application/cli-update.mjs +0 -219
  136. package/tools/cli/application/compose-runtime.mjs +0 -38
  137. package/tools/cli/application/doctor/runtime-diagnostics.mjs +0 -227
  138. package/tools/cli/application/doctor/scope-diagnostics.mjs +0 -440
  139. package/tools/cli/application/doctor/service-diagnostics.mjs +0 -184
  140. package/tools/cli/application/doctor.mjs +0 -201
  141. package/tools/cli/application/package-maintenance/builtin-receipts.mjs +0 -73
  142. package/tools/cli/application/package-maintenance/output.mjs +0 -148
  143. package/tools/cli/application/package-maintenance/smoke-checks.mjs +0 -463
  144. package/tools/cli/application/package-maintenance/static-validation.mjs +0 -680
  145. package/tools/cli/application/package-maintenance.mjs +0 -540
  146. package/tools/cli/application/runtime.mjs +0 -118
  147. package/tools/cli/application/workspace-operations.mjs +0 -311
  148. package/tools/cli/bootstrap.mjs +0 -6
  149. package/tools/cli/command/help.mjs +0 -296
  150. package/tools/cli/command/registry.mjs +0 -97
  151. package/tools/cli/domains/commands.mjs +0 -661
  152. package/tools/cli/domains/components.mjs +0 -922
  153. package/tools/cli/domains/openspec.mjs +0 -603
  154. package/tools/cli/domains/package-assets.mjs +0 -652
  155. package/tools/cli/domains/rules.mjs +0 -380
  156. package/tools/cli/domains/runtime.mjs +0 -87
  157. package/tools/cli/domains/skills.mjs +0 -647
  158. package/tools/cli/domains/workspace.mjs +0 -571
  159. package/tools/cli/shared/infrastructure.mjs +0 -411
  160. package/tools/cli/shared/json-contracts.mjs +0 -22
  161. package/tools/cli/shared/platform.mjs +0 -52
  162. package/tools/runtime/adapter-contract.mjs +0 -655
  163. package/tools/runtime/check-claude-code.mjs +0 -23
  164. package/tools/runtime/check-codex.mjs +0 -23
  165. package/tools/runtime/check-runtime.mjs +0 -98
  166. package/tools/runtime/projection.mjs +0 -375
  167. package/tools/runtime/render-claude-code-rules.mjs +0 -459
  168. package/tools/runtime/render-claude-code.mjs +0 -59
  169. package/tools/runtime/skills/arguments.mjs +0 -51
  170. package/tools/runtime/skills/contributions.mjs +0 -171
  171. package/tools/runtime/skills/manifests.mjs +0 -167
  172. package/tools/runtime/skills/primitives.mjs +0 -86
  173. package/tools/runtime/skills/render-plan.mjs +0 -243
  174. package/tools/runtime/skills/sources.mjs +0 -276
  175. package/tools/shared/fetch-remote-text.mjs +0 -78
  176. package/tools/verification/integrity/managed-data-integrity.mjs +0 -107
  177. package/tools/verification/integrity/managed-mutations.mjs +0 -72
  178. package/tools/verification/openspec/contract.mjs +0 -212
  179. package/tools/verification/runtime/adapter-contract.mjs +0 -218
  180. package/tools/verification/runtime/adapter-parity.mjs +0 -173
  181. /package/{package → payload/product/package}/targets/workspace/AGENTS.md +0 -0
@@ -1,652 +0,0 @@
1
- import { fs, path, PACKAGE_BOOTSTRAP_CONTRACT, SUPPORTED_AGENT_IDS } from '../shared/platform.mjs';
2
-
3
- export function registerDomainsPackageAssets(runtime) {
4
- const readGitRemote = (...args) => runtime.readGitRemote(...args);
5
- const isPlainObject = (...args) => runtime.isPlainObject(...args);
6
- const readSkillManifest = (...args) => runtime.readSkillManifest(...args);
7
- const readSkillManifestSchemaVersion = (...args) => runtime.readSkillManifestSchemaVersion(...args);
8
- const renderSkillsManifestYaml = (...args) => runtime.renderSkillsManifestYaml(...args);
9
- const skillsManifestPath = (...args) => runtime.skillsManifestPath(...args);
10
- const parseYamlValue = (...args) => runtime.parseYamlValue(...args);
11
- const parseServicesYaml = (...args) => runtime.parseServicesYaml(...args);
12
- const parseServicesManifestYaml = (...args) => runtime.parseServicesManifestYaml(...args);
13
- const parseProjectsYaml = (...args) => runtime.parseProjectsYaml(...args);
14
- const renderProjectsYaml = (...args) => runtime.renderProjectsYaml(...args);
15
- const renderServicesManifestYaml = (...args) => runtime.renderServicesManifestYaml(...args);
16
- const writeProjectsRegistry = (...args) => runtime.writeProjectsRegistry(...args);
17
- const projectsManifestPath = (...args) => runtime.projectsManifestPath(...args);
18
- const servicesManifestPath = (...args) => runtime.servicesManifestPath(...args);
19
- const writeServicesManifest = (...args) => runtime.writeServicesManifest(...args);
20
- const gitDefaultBranch = (...args) => runtime.gitDefaultBranch(...args);
21
- const defaultAssetDescription = (...args) => runtime.defaultAssetDescription(...args);
22
- const inferRepoKind = (...args) => runtime.inferRepoKind(...args);
23
- const ensureGitBoundaries = (...args) => runtime.ensureGitBoundaries(...args);
24
- const ensureDirectory = (...args) => runtime.ensureDirectory(...args);
25
- const atomicWriteFile = (...args) => runtime.atomicWriteFile(...args);
26
- const parseYamlDocument = (...args) => runtime.parseYamlDocument(...args);
27
- const productRoot = (...args) => runtime.productRoot(...args);
28
- const packageRoot = (...args) => runtime.packageRoot(...args);
29
- const packageBootstrapContractPath = (...args) => runtime.packageBootstrapContractPath(...args);
30
- const writeMappedFileIfMissing = (...args) => runtime.writeMappedFileIfMissing(...args);
31
- const toPosixRelative = (...args) => runtime.toPosixRelative(...args);
32
- const existsDirectory = (...args) => runtime.existsDirectory(...args);
33
- const existsFile = (...args) => runtime.existsFile(...args);
34
- const writeFileIfChanged = (...args) => runtime.writeFileIfChanged(...args);
35
-
36
- function readPackageManifest() {
37
- const manifestPath = path.join(packageRoot(), 'manifest.yml');
38
- if (!existsFile(manifestPath)) {
39
- throw new Error(`Package manifest not found: ${manifestPath}`);
40
- }
41
-
42
- {
43
- const parsed = parseYamlDocument(fs.readFileSync(manifestPath, 'utf8'), 'package/manifest.yml');
44
- return {
45
- include: [],
46
- agentSkills: [],
47
- skillSources: [],
48
- builtins: { rules: [], skills: [], commands: [] },
49
- components: [],
50
- workspaceDirectories: [],
51
- workspaceFiles: [],
52
- projectDirectories: [],
53
- projectFiles: [],
54
- templateVariables: [],
55
- forbiddenPatterns: [],
56
- ...parsed,
57
- builtins: {
58
- rules: parsed.builtins?.rules || [],
59
- skills: parsed.builtins?.skills || [],
60
- commands: parsed.builtins?.commands || [],
61
- },
62
- };
63
- }
64
-
65
- const manifest = {
66
- include: [],
67
- agentSkills: [],
68
- skillSources: [],
69
- builtins: { rules: [], skills: [], commands: [] },
70
- components: [],
71
- workspaceDirectories: [],
72
- workspaceFiles: [],
73
- projectDirectories: [],
74
- projectFiles: [],
75
- templateVariables: [],
76
- forbiddenPatterns: [],
77
- };
78
- let currentList = null;
79
- let currentPackageSkill = null;
80
- let currentPackageSkillList = null;
81
- let inPackageSkillRuntimes = false;
82
-
83
- function finishPackageSkill() {
84
- if (!currentPackageSkill) return;
85
- manifest[currentPackageSkillList].push(currentPackageSkill);
86
- currentPackageSkill = null;
87
- currentPackageSkillList = null;
88
- inPackageSkillRuntimes = false;
89
- }
90
-
91
- for (const rawLine of fs.readFileSync(manifestPath, 'utf8').split(/\r?\n/)) {
92
- const line = rawLine.trimEnd();
93
- if (!line.trim() || line.trim().startsWith('#')) continue;
94
-
95
- const keyMatch = line.match(/^([A-Za-z][A-Za-z0-9_-]*):\s*$/);
96
- if (keyMatch) {
97
- finishPackageSkill();
98
- currentList = keyMatch[1] !== 'components' && Object.hasOwn(manifest, keyMatch[1]) && Array.isArray(manifest[keyMatch[1]]) ? keyMatch[1] : null;
99
- continue;
100
- }
101
-
102
- if (currentList === 'agentSkills' || currentList === 'skillSources') {
103
- const idMatch = line.trim().match(/^-\s+id:\s*(.+)$/);
104
- if (idMatch) {
105
- finishPackageSkill();
106
- currentPackageSkill = { id: parseYamlValue(idMatch[1].trim()), runtimes: [] };
107
- currentPackageSkillList = currentList;
108
- continue;
109
- }
110
- if (!currentPackageSkill) {
111
- throw new Error(`Invalid ${currentList} entry in package manifest: ${rawLine}`);
112
- }
113
- const pathMatch = line.trim().match(/^path:\s*(.+)$/);
114
- if (pathMatch) {
115
- currentPackageSkill.path = parseYamlValue(pathMatch[1].trim());
116
- inPackageSkillRuntimes = false;
117
- continue;
118
- }
119
- const runtimePathMatch = line.trim().match(/^runtimePath:\s*(.+)$/);
120
- if (runtimePathMatch && currentList === 'skillSources') {
121
- currentPackageSkill.runtimePath = parseYamlValue(runtimePathMatch[1].trim());
122
- inPackageSkillRuntimes = false;
123
- continue;
124
- }
125
- if (line.trim() === 'runtimes:') {
126
- inPackageSkillRuntimes = true;
127
- continue;
128
- }
129
- const runtimeMatch = line.trim().match(/^-\s+(.+)$/);
130
- if (runtimeMatch && inPackageSkillRuntimes) {
131
- currentPackageSkill.runtimes.push(parseYamlValue(runtimeMatch[1].trim()));
132
- continue;
133
- }
134
- throw new Error(`Unsupported ${currentList} syntax in package manifest: ${rawLine}`);
135
- }
136
-
137
- const itemMatch = line.match(/^\s*-\s+(.+)$/);
138
- if (itemMatch && currentList) {
139
- manifest[currentList].push(parseYamlValue(itemMatch[1].trim()));
140
- }
141
- }
142
- finishPackageSkill();
143
- manifest.builtins = readPackageBuiltinsManifest(manifestPath);
144
- manifest.components = readPackageComponentsManifest(manifestPath);
145
- return manifest;
146
- }
147
-
148
- function readPackageComponentsManifest(manifestPath) {
149
- const components = [];
150
- let inComponents = false;
151
- let current = null;
152
- function finish() {
153
- if (current) components.push(current);
154
- current = null;
155
- }
156
- for (const rawLine of fs.readFileSync(manifestPath, 'utf8').split(/\r?\n/)) {
157
- const line = rawLine.trimEnd();
158
- if (!line.trim() || line.trim().startsWith('#')) continue;
159
- if (/^[A-Za-z][A-Za-z0-9_-]*:\s*$/.test(line)) {
160
- finish();
161
- inComponents = line === 'components:';
162
- continue;
163
- }
164
- if (!inComponents) continue;
165
- const idMatch = line.match(/^ - id:\s*(.+)$/);
166
- if (idMatch) {
167
- finish();
168
- current = { id: parseYamlValue(idMatch[1].trim()) };
169
- continue;
170
- }
171
- const fieldMatch = line.match(/^ ([A-Za-z][A-Za-z0-9_-]*):\s*(.+)$/);
172
- if (fieldMatch && current) {
173
- current[fieldMatch[1]] = parseYamlValue(fieldMatch[2].trim());
174
- continue;
175
- }
176
- }
177
- finish();
178
- return components;
179
- }
180
-
181
- function readPackageBuiltinsManifest(manifestPath) {
182
- const builtins = { rules: [], skills: [], commands: [] };
183
- let inBuiltins = false;
184
- let currentKind = null;
185
- let currentEntry = null;
186
- let currentObject = null;
187
-
188
- function finishEntry() {
189
- if (!currentEntry || !currentKind) return;
190
- builtins[currentKind].push(currentEntry);
191
- currentEntry = null;
192
- currentObject = null;
193
- }
194
-
195
- for (const rawLine of fs.readFileSync(manifestPath, 'utf8').split(/\r?\n/)) {
196
- const line = rawLine.trimEnd();
197
- const trimmed = line.trim();
198
- if (!trimmed || trimmed.startsWith('#')) continue;
199
-
200
- if (/^[A-Za-z][A-Za-z0-9_-]*:\s*$/.test(line)) {
201
- finishEntry();
202
- inBuiltins = trimmed === 'builtins:';
203
- currentKind = null;
204
- continue;
205
- }
206
- if (!inBuiltins) continue;
207
-
208
- const kindMatch = line.match(/^ (rules|skills|commands):\s*(?:\[\s*\])?$/);
209
- if (kindMatch) {
210
- finishEntry();
211
- currentKind = kindMatch[1];
212
- continue;
213
- }
214
-
215
- const idMatch = line.match(/^ - id:\s*(.+)$/);
216
- if (idMatch && currentKind) {
217
- finishEntry();
218
- currentEntry = { id: parseYamlValue(idMatch[1].trim()) };
219
- continue;
220
- }
221
-
222
- const objectStartMatch = line.match(/^ ([A-Za-z][A-Za-z0-9_-]*):\s*$/);
223
- if (objectStartMatch && currentEntry) {
224
- currentObject = objectStartMatch[1];
225
- currentEntry[currentObject] = {};
226
- continue;
227
- }
228
-
229
- const nestedMatch = line.match(/^ ([A-Za-z][A-Za-z0-9_-]*):\s*(.+)$/);
230
- if (nestedMatch && currentEntry && currentObject) {
231
- currentEntry[currentObject][nestedMatch[1]] = parseYamlValue(nestedMatch[2].trim());
232
- continue;
233
- }
234
-
235
- const fieldMatch = line.match(/^ ([A-Za-z][A-Za-z0-9_-]*):\s*(.+)$/);
236
- if (fieldMatch && currentEntry) {
237
- currentObject = null;
238
- currentEntry[fieldMatch[1]] = parseYamlValue(fieldMatch[2].trim());
239
- continue;
240
- }
241
- }
242
- finishEntry();
243
-
244
- return builtins;
245
- }
246
-
247
- function parseManifestFileEntry(entry, section) {
248
- const match = entry.match(/^(.+?)\s*=>\s*(.+?)(?:\s+(copy|render))?$/);
249
- if (!match) {
250
- throw new Error(`Invalid ${section} entry: ${entry}`);
251
- }
252
- return {
253
- source: match[1].trim(),
254
- target: match[2].trim(),
255
- mode: match[3] ?? 'copy',
256
- raw: entry,
257
- };
258
- }
259
-
260
- function collectFiles(entryPath) {
261
- if (existsFile(entryPath)) return [entryPath];
262
- if (!existsDirectory(entryPath)) return [];
263
- const files = [];
264
- for (const entry of fs.readdirSync(entryPath).sort()) {
265
- files.push(...collectFiles(path.join(entryPath, entry)));
266
- }
267
- return files;
268
- }
269
-
270
- function readSimpleYaml(file, listKeys, scalarKeys = []) {
271
- const result = {
272
- ...Object.fromEntries(listKeys.map((key) => [key, []])),
273
- ...Object.fromEntries(scalarKeys.map((key) => [key, null])),
274
- };
275
- const allowedKeys = new Set([...listKeys, ...scalarKeys]);
276
- let currentKey = null;
277
- for (const rawLine of fs.readFileSync(file, 'utf8').split(/\r?\n/)) {
278
- const line = rawLine.trimEnd();
279
- const trimmed = line.trim();
280
- if (!trimmed || trimmed.startsWith('#')) continue;
281
-
282
- const scalarMatch = trimmed.match(/^([A-Za-z][A-Za-z0-9_-]*):\s+(.+)$/);
283
- if (scalarMatch && allowedKeys.has(scalarMatch[1])) {
284
- currentKey = null;
285
- result[scalarMatch[1]] = parseYamlValue(scalarMatch[2].trim());
286
- continue;
287
- }
288
-
289
- const keyMatch = trimmed.match(/^([A-Za-z][A-Za-z0-9_-]*):\s*$/);
290
- if (keyMatch) {
291
- currentKey = listKeys.includes(keyMatch[1]) ? keyMatch[1] : null;
292
- continue;
293
- }
294
-
295
- const itemMatch = trimmed.match(/^-\s+(.+)$/);
296
- if (itemMatch && currentKey) {
297
- result[currentKey].push(parseYamlValue(itemMatch[1].trim()));
298
- }
299
- }
300
- return result;
301
- }
302
-
303
- function validateBootstrapContract(root, files, problems) {
304
- const contractPath = packageBootstrapContractPath();
305
- if (!existsFile(contractPath)) {
306
- problems.push(`Bootstrap contract is missing: ${PACKAGE_BOOTSTRAP_CONTRACT}`);
307
- return;
308
- }
309
- files.push(contractPath);
310
-
311
- const contract = readSimpleYaml(
312
- contractPath,
313
- [
314
- 'bootstrapGuideRequiredText',
315
- 'bootstrapGuideForbiddenText',
316
- 'buildrSkillRequiredSections',
317
- 'buildrSkillRequiredText',
318
- 'buildrSkillForbiddenText',
319
- 'globalForbiddenText',
320
- 'generatedSkillRequiredText',
321
- ],
322
- ['bootstrapGuidePath', 'bootstrapGuideMaxLines', 'buildrSkillPath', 'buildrSkillMaxLines'],
323
- );
324
-
325
- function readArtifact(artifact, label) {
326
- if (!artifact) {
327
- problems.push(`Bootstrap contract must declare ${label}.`);
328
- return null;
329
- }
330
- if (path.isAbsolute(artifact) || artifact.startsWith('..')) {
331
- problems.push(`Bootstrap contract artifact must stay inside product root: ${artifact}`);
332
- return null;
333
- }
334
-
335
- const artifactPath = path.resolve(root, artifact);
336
- if (!existsFile(artifactPath)) {
337
- problems.push(`Bootstrap contract artifact does not exist: ${artifact}`);
338
- return null;
339
- }
340
- files.push(artifactPath);
341
- return fs.readFileSync(artifactPath, 'utf8');
342
- }
343
-
344
- function validateRequiredText(content, artifact, requiredText) {
345
- if (!content) return;
346
- for (const required of requiredText) {
347
- if (!content.includes(required)) {
348
- problems.push(`Bootstrap contract required text ${JSON.stringify(required)} missing from ${artifact}`);
349
- }
350
- }
351
- }
352
-
353
- function validateForbiddenText(content, artifact, forbiddenText) {
354
- if (!content) return;
355
- for (const forbidden of forbiddenText) {
356
- if (forbidden && content.includes(forbidden)) {
357
- problems.push(`Bootstrap contract forbidden text ${JSON.stringify(forbidden)} found in ${artifact}`);
358
- }
359
- }
360
- }
361
-
362
- function validateMaxLines(content, artifact, maxLines) {
363
- if (!content || !maxLines) return;
364
- const lineCount = content.split(/\r?\n/).length;
365
- if (lineCount > Number(maxLines)) {
366
- problems.push(`Bootstrap contract max lines exceeded in ${artifact}: ${lineCount} > ${maxLines}`);
367
- }
368
- }
369
-
370
- function validateSections(content, artifact, sections) {
371
- if (!content) return;
372
- for (const section of sections) {
373
- if (!content.includes(`## ${section}`)) {
374
- problems.push(`Bootstrap contract required section ${JSON.stringify(section)} missing from ${artifact}`);
375
- }
376
- }
377
- }
378
-
379
- const guideContent = readArtifact(contract.bootstrapGuidePath, 'bootstrapGuidePath');
380
- const skillContent = readArtifact(contract.buildrSkillPath, 'buildrSkillPath');
381
-
382
- validateMaxLines(guideContent, contract.bootstrapGuidePath, contract.bootstrapGuideMaxLines);
383
- validateRequiredText(guideContent, contract.bootstrapGuidePath, contract.bootstrapGuideRequiredText);
384
- validateForbiddenText(guideContent, contract.bootstrapGuidePath, [
385
- ...contract.globalForbiddenText,
386
- ...contract.bootstrapGuideForbiddenText,
387
- ]);
388
-
389
- validateMaxLines(skillContent, contract.buildrSkillPath, contract.buildrSkillMaxLines);
390
- validateSections(skillContent, contract.buildrSkillPath, contract.buildrSkillRequiredSections);
391
- validateRequiredText(skillContent, contract.buildrSkillPath, contract.buildrSkillRequiredText);
392
- validateForbiddenText(skillContent, contract.buildrSkillPath, [
393
- ...contract.globalForbiddenText,
394
- ...contract.buildrSkillForbiddenText,
395
- ]);
396
-
397
- return contract;
398
- }
399
-
400
- function builtinRuleEntry(builtin) {
401
- return {
402
- id: builtin.id,
403
- source: 'buildr',
404
- path: builtin.target,
405
- description: builtin.description,
406
- enabled: true,
407
- required: builtin.required === true,
408
- state: 'installed',
409
- };
410
- }
411
-
412
- function builtinSkillEntry(builtin) {
413
- return {
414
- id: builtin.id,
415
- source: builtin.target.startsWith('skills/openspec/') ? 'openspec' : 'buildr',
416
- path: builtin.target.replace(/^skills\//, ''),
417
- description: builtin.description,
418
- enabled: true,
419
- required: builtin.required === true,
420
- state: 'installed',
421
- runtimes: builtin.runtimes || [...SUPPORTED_AGENT_IDS],
422
- runtimePath: builtin.id,
423
- };
424
- }
425
-
426
- function builtinCommandEntry(builtin) {
427
- return {
428
- id: builtin.id,
429
- source: 'buildr',
430
- enabled: true,
431
- required: builtin.required === true,
432
- state: 'installed',
433
- ...(builtin.manifestEntry || {}),
434
- };
435
- }
436
-
437
- function sourcePathFromBuiltin(builtin) {
438
- return path.resolve(productRoot(), builtin.path);
439
- }
440
-
441
- function targetPathFromBuiltin(targetRoot, builtin) {
442
- return path.join(targetRoot, builtin.target);
443
- }
444
-
445
- function fileDiffStatus(sourceFile, targetFile) {
446
- if (!existsFile(targetFile)) return 'missing';
447
- return fs.readFileSync(sourceFile, 'utf8') === fs.readFileSync(targetFile, 'utf8') ? 'installed' : 'modified';
448
- }
449
-
450
- function directoryDiffStatus(sourceDir, targetDir) {
451
- if (!existsDirectory(targetDir)) return 'missing';
452
- for (const sourceFile of collectFiles(sourceDir)) {
453
- const relative = path.relative(sourceDir, sourceFile);
454
- const targetFile = path.join(targetDir, relative);
455
- if (!existsFile(targetFile) || fs.readFileSync(sourceFile, 'utf8') !== fs.readFileSync(targetFile, 'utf8')) {
456
- return 'modified';
457
- }
458
- }
459
- return 'installed';
460
- }
461
-
462
- function isValidAssetId(value) {
463
- return typeof value === 'string' && value !== '.' && value !== '..' && !/[\x00-\x1f\x7f]/.test(value) && /^[A-Za-z0-9._-]+$/.test(value);
464
- }
465
-
466
- function listManagedDirectories(parent) {
467
- if (!existsDirectory(parent)) return [];
468
- return fs.readdirSync(parent)
469
- .filter((entry) => isValidAssetId(entry) && existsDirectory(path.join(parent, entry)))
470
- .sort();
471
- }
472
-
473
- function normalizeProjectEntry(projectName, entry = {}, projectRoot = null) {
474
- const rawRepo = isPlainObject(entry.repo) ? entry.repo : {};
475
- const kind = rawRepo.kind === 'git' || rawRepo.kind === 'local'
476
- ? (rawRepo.url || (projectRoot && inferRepoKind(projectRoot) === 'git') ? 'git' : 'workspace')
477
- : ['workspace', 'git'].includes(rawRepo.kind) ? rawRepo.kind : projectRoot ? inferRepoKind(projectRoot) : 'workspace';
478
- const repo = { kind };
479
- if (kind === 'git') {
480
- if (rawRepo.url) repo.url = rawRepo.url;
481
- if (rawRepo.remote) repo.remote = rawRepo.remote;
482
- if (rawRepo.defaultBranch) repo.defaultBranch = rawRepo.defaultBranch;
483
- if (!repo.remote && projectRoot && existsDirectory(path.join(projectRoot, '.git'))) repo.remote = 'origin';
484
- if (!repo.defaultBranch && projectRoot && existsDirectory(path.join(projectRoot, '.git'))) repo.defaultBranch = gitDefaultBranch(projectRoot);
485
- }
486
- return {
487
- title: typeof entry.title === 'string' && entry.title ? entry.title : projectName,
488
- description: typeof entry.description === 'string' && entry.description ? entry.description : defaultAssetDescription('Project', projectName),
489
- path: `projects/${projectName}`,
490
- repo,
491
- };
492
- }
493
-
494
- function normalizeServiceEntry(serviceName, entry = {}, serviceRoot = null) {
495
- const rawRepo = isPlainObject(entry.repo) ? entry.repo : {};
496
- const kind = rawRepo.kind === 'git' || rawRepo.kind === 'local'
497
- ? (rawRepo.url || (serviceRoot && inferRepoKind(serviceRoot) === 'git') ? 'git' : 'workspace')
498
- : ['workspace', 'git'].includes(rawRepo.kind) ? rawRepo.kind : serviceRoot ? inferRepoKind(serviceRoot) : 'workspace';
499
- const repo = { kind };
500
- if (kind === 'git') {
501
- if (rawRepo.url) repo.url = rawRepo.url;
502
- if (rawRepo.remote) repo.remote = rawRepo.remote;
503
- if (rawRepo.defaultBranch) repo.defaultBranch = rawRepo.defaultBranch;
504
- if (rawRepo.branch) repo.branch = rawRepo.branch;
505
- if (!repo.remote && serviceRoot && existsDirectory(path.join(serviceRoot, '.git'))) repo.remote = 'origin';
506
- if (!repo.defaultBranch && serviceRoot && existsDirectory(path.join(serviceRoot, '.git'))) repo.defaultBranch = gitDefaultBranch(serviceRoot);
507
- if (!repo.url && serviceRoot && existsDirectory(path.join(serviceRoot, '.git'))) {
508
- const url = readGitRemote(serviceRoot, repo.remote || 'origin');
509
- if (url) repo.url = url;
510
- }
511
- }
512
- return {
513
- title: typeof entry.title === 'string' && entry.title ? entry.title : serviceName,
514
- description: typeof entry.description === 'string' && entry.description ? entry.description : defaultAssetDescription('Service', serviceName),
515
- type: typeof entry.type === 'string' && entry.type ? entry.type : 'service',
516
- path: `services/${serviceName}`,
517
- repo,
518
- };
519
- }
520
-
521
- function repairProjectBaseline(targetRoot, projectName, changed) {
522
- const manifest = readPackageManifest();
523
- const projectRoot = path.join(targetRoot, 'projects', projectName);
524
- ensureDirectory(projectRoot);
525
- for (const relativeDir of manifest.projectDirectories) ensureDirectory(path.join(projectRoot, relativeDir));
526
- const variables = { project: projectName };
527
- for (const rawEntry of manifest.projectFiles) {
528
- const entry = parseManifestFileEntry(rawEntry, 'projectFiles');
529
- if (entry.target === 'services/manifest.yml' && existsFile(path.join(projectRoot, 'services.yml'))) {
530
- continue;
531
- }
532
- const before = changed.length;
533
- writeMappedFileIfMissing(targetRoot, projectRoot, entry, variables, changed);
534
- if (changed.length > before) changed[changed.length - 1] = `projects/${projectName}/${entry.target}`;
535
- }
536
- const skillsFile = path.join(projectRoot, 'skills', 'manifest.yml');
537
- if (writeFileIfChanged(skillsFile, existsFile(skillsFile) ? renderSkillsManifestYaml(readSkillManifest(skillsFile)) : renderSkillsManifestYaml([]))) {
538
- changed.push(toPosixRelative(targetRoot, skillsFile));
539
- }
540
- const servicesFile = servicesManifestPath(projectRoot);
541
- if (!existsFile(servicesFile) && !existsFile(path.join(projectRoot, 'services.yml'))) {
542
- writeServicesManifest(projectRoot, { schemaVersion: 'buildr.services/v1', project: projectName, services: {} });
543
- changed.push(toPosixRelative(targetRoot, servicesFile));
544
- }
545
- }
546
-
547
- function convergeSkillsManifestSchema(targetRoot, scopeRoot, changed) {
548
- const file = skillsManifestPath(scopeRoot);
549
- if (!existsFile(file)) return;
550
- const schemaVersion = readSkillManifestSchemaVersion(file);
551
- if (schemaVersion === 'buildr.skills/v1') return;
552
- const skills = readSkillManifest(file);
553
- atomicWriteFile(file, renderSkillsManifestYaml(skills));
554
- changed.push(toPosixRelative(targetRoot, file));
555
- }
556
-
557
- function convergeServiceManifest(targetRoot, projectName, changed) {
558
- const projectRoot = path.join(targetRoot, 'projects', projectName);
559
- const servicesRoot = path.join(projectRoot, 'services');
560
- const manifestFile = servicesManifestPath(projectRoot);
561
- const legacyFile = path.join(projectRoot, 'services.yml');
562
- let manifest;
563
-
564
- ensureDirectory(servicesRoot);
565
- if (!existsFile(manifestFile) && existsFile(legacyFile)) {
566
- const legacyServices = parseServicesYaml(fs.readFileSync(legacyFile, 'utf8'));
567
- manifest = { schemaVersion: 'buildr.services/v1', project: projectName, services: {} };
568
- for (const [serviceName, service] of Object.entries(legacyServices)) {
569
- manifest.services[serviceName] = normalizeServiceEntry(serviceName, service, path.join(servicesRoot, serviceName));
570
- }
571
- } else if (existsFile(manifestFile)) {
572
- manifest = parseServicesManifestYaml(fs.readFileSync(manifestFile, 'utf8'));
573
- } else {
574
- manifest = { schemaVersion: 'buildr.services/v1', project: projectName, services: {} };
575
- }
576
-
577
- for (const serviceName of listManagedDirectories(servicesRoot)) {
578
- if (!manifest.services[serviceName]) {
579
- manifest.services[serviceName] = normalizeServiceEntry(serviceName, {}, path.join(servicesRoot, serviceName));
580
- }
581
- }
582
- for (const [serviceName, service] of Object.entries(manifest.services || {})) {
583
- manifest.services[serviceName] = normalizeServiceEntry(serviceName, service, path.join(servicesRoot, serviceName));
584
- }
585
- manifest.schemaVersion = 'buildr.services/v1';
586
- manifest.project = projectName;
587
-
588
- const nextContent = renderServicesManifestYaml(manifest);
589
- if (!existsFile(manifestFile) || fs.readFileSync(manifestFile, 'utf8') !== nextContent) {
590
- writeServicesManifest(projectRoot, manifest);
591
- changed.push(toPosixRelative(targetRoot, manifestFile));
592
- }
593
- if (existsFile(legacyFile)) {
594
- fs.rmSync(legacyFile, { force: true });
595
- changed.push(toPosixRelative(targetRoot, legacyFile));
596
- }
597
- convergeSkillsManifestSchema(targetRoot, projectRoot, changed);
598
- return manifest;
599
- }
600
-
601
- function convergeRegistryManifests(targetRoot) {
602
- const changed = [];
603
- const legacyProjectsFile = path.join(targetRoot, 'projects.yml');
604
- if (existsFile(legacyProjectsFile)) {
605
- fs.rmSync(legacyProjectsFile, { force: true });
606
- changed.push('projects.yml');
607
- }
608
-
609
- ensureDirectory(path.join(targetRoot, 'projects'));
610
- let registry = existsFile(projectsManifestPath(targetRoot))
611
- ? parseProjectsYaml(fs.readFileSync(projectsManifestPath(targetRoot), 'utf8'))
612
- : { schemaVersion: 'buildr.projects/v1', projects: {} };
613
- registry.projects = isPlainObject(registry.projects) ? registry.projects : {};
614
-
615
- for (const projectName of listManagedDirectories(path.join(targetRoot, 'projects'))) {
616
- const projectRoot = path.join(targetRoot, 'projects', projectName);
617
- if (!registry.projects[projectName]) registry.projects[projectName] = {};
618
- registry.projects[projectName] = normalizeProjectEntry(projectName, registry.projects[projectName], projectRoot);
619
- }
620
-
621
- for (const projectName of listManagedDirectories(path.join(targetRoot, 'projects'))) {
622
- const projectRoot = path.join(targetRoot, 'projects', projectName);
623
- repairProjectBaseline(targetRoot, projectName, changed);
624
- registry.projects[projectName] = normalizeProjectEntry(projectName, registry.projects[projectName], projectRoot);
625
- convergeServiceManifest(targetRoot, projectName, changed);
626
- }
627
- registry.schemaVersion = 'buildr.projects/v1';
628
- const nextContent = renderProjectsYaml(registry);
629
- const registryFile = projectsManifestPath(targetRoot);
630
- if (!existsFile(registryFile) || fs.readFileSync(registryFile, 'utf8') !== nextContent) {
631
- writeProjectsRegistry(targetRoot, registry);
632
- changed.push(toPosixRelative(targetRoot, registryFile));
633
- }
634
-
635
- convergeSkillsManifestSchema(targetRoot, targetRoot, changed);
636
-
637
- const boundaryItems = [];
638
- for (const projectName of Object.keys(registry.projects)) {
639
- const projectRoot = path.join(targetRoot, 'projects', projectName);
640
- boundaryItems.push({ type: 'project', project: projectName, assetRoot: projectRoot });
641
- const servicesRoot = path.join(projectRoot, 'services');
642
- for (const serviceName of listManagedDirectories(servicesRoot)) {
643
- boundaryItems.push({ type: 'service', project: projectName, service: serviceName, assetRoot: path.join(servicesRoot, serviceName) });
644
- }
645
- }
646
- changed.push(...ensureGitBoundaries(targetRoot, boundaryItems));
647
- return [...new Set(changed)];
648
- }
649
-
650
- Object.assign(runtime, { readPackageManifest, readPackageComponentsManifest, readPackageBuiltinsManifest, parseManifestFileEntry, collectFiles, readSimpleYaml, validateBootstrapContract, builtinRuleEntry, builtinSkillEntry, builtinCommandEntry, sourcePathFromBuiltin, targetPathFromBuiltin, fileDiffStatus, directoryDiffStatus, isValidAssetId, listManagedDirectories, normalizeProjectEntry, normalizeServiceEntry, repairProjectBaseline, convergeSkillsManifestSchema, convergeServiceManifest, convergeRegistryManifests });
651
- return runtime;
652
- }