opencode-agent-orchestration-kit 1.0.27

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 (236) hide show
  1. package/.github/CODEOWNERS +1 -0
  2. package/.github/ISSUE_TEMPLATE/bug_report.yml +65 -0
  3. package/.github/ISSUE_TEMPLATE/config.yml +11 -0
  4. package/.github/ISSUE_TEMPLATE/documentation.yml +22 -0
  5. package/.github/ISSUE_TEMPLATE/feature_request.yml +43 -0
  6. package/.github/PULL_REQUEST_TEMPLATE.md +25 -0
  7. package/.github/workflows/check.yml +47 -0
  8. package/CODE_OF_CONDUCT.md +24 -0
  9. package/CONTRIBUTING.md +52 -0
  10. package/LICENSE +201 -0
  11. package/NOTICE.md +23 -0
  12. package/README.md +806 -0
  13. package/SECURITY.md +17 -0
  14. package/docker/open-design/.env.example +6 -0
  15. package/docker/open-design/Dockerfile +50 -0
  16. package/docker/open-design/docker-compose.yml +18 -0
  17. package/docker/open-design/opencode-od/agents/od-worker.md +22 -0
  18. package/docker/open-design/opencode-od/opencode.json +24 -0
  19. package/docs/agents.md +21 -0
  20. package/docs/commands.md +16 -0
  21. package/docs/configuration.md +30 -0
  22. package/docs/docker-open-design.md +42 -0
  23. package/docs/impeccable.md +18 -0
  24. package/docs/installation.md +176 -0
  25. package/docs/models.md +17 -0
  26. package/docs/open-design.md +25 -0
  27. package/docs/quickstart.md +74 -0
  28. package/docs/releases/v1.0.10.md +46 -0
  29. package/docs/releases/v1.0.14.md +39 -0
  30. package/docs/releases/v1.0.27.md +66 -0
  31. package/docs/security.md +8 -0
  32. package/docs/superpowers/plans/2026-07-20-safe-installation-lifecycle.md +779 -0
  33. package/docs/superpowers/plans/2026-07-20-version-identity-and-releases.md +590 -0
  34. package/docs/superpowers/specs/2026-07-20-safe-installation-lifecycle-design.md +1350 -0
  35. package/docs/superpowers/specs/2026-07-20-version-identity-and-releases-design.md +557 -0
  36. package/docs/superpowers.md +34 -0
  37. package/docs/synology.md +30 -0
  38. package/docs/troubleshooting.md +54 -0
  39. package/docs/workflows.md +44 -0
  40. package/doctor.sh +5 -0
  41. package/env.example +15 -0
  42. package/install.sh +5 -0
  43. package/opencode/AGENTS.md +104 -0
  44. package/opencode/agents/debugger.md +41 -0
  45. package/opencode/agents/designer.md +93 -0
  46. package/opencode/agents/developer.md +180 -0
  47. package/opencode/agents/evaluator.md +35 -0
  48. package/opencode/agents/evolver.md +31 -0
  49. package/opencode/agents/lead.md +251 -0
  50. package/opencode/agents/researcher.md +76 -0
  51. package/opencode/agents/review_api.md +34 -0
  52. package/opencode/agents/review_coordinator.md +111 -0
  53. package/opencode/agents/review_quality.md +35 -0
  54. package/opencode/agents/review_security.md +35 -0
  55. package/opencode/agents/review_tests.md +37 -0
  56. package/opencode/agents/reviewer.md +116 -0
  57. package/opencode/agents/scoper.md +75 -0
  58. package/opencode/agents/specifier.md +116 -0
  59. package/opencode/commands/code-simplify.md +36 -0
  60. package/opencode/commands/design.md +27 -0
  61. package/opencode/commands/evolve.md +165 -0
  62. package/opencode/commands/feature.md +67 -0
  63. package/opencode/commands/implement.md +11 -0
  64. package/opencode/commands/init.md +34 -0
  65. package/opencode/commands/loop.md +145 -0
  66. package/opencode/commands/mvp-spec.md +20 -0
  67. package/opencode/commands/plan.md +74 -0
  68. package/opencode/commands/research.md +12 -0
  69. package/opencode/commands/review-orchestrated.md +47 -0
  70. package/opencode/commands/review-preflight.md +26 -0
  71. package/opencode/commands/review.md +18 -0
  72. package/opencode/commands/scope.md +36 -0
  73. package/opencode/commands/spec.md +12 -0
  74. package/opencode/commands/test.md +40 -0
  75. package/opencode/docs/ai/evolution/README.md +135 -0
  76. package/opencode/docs/ai/evolution/benchmarks/manual-scenarios.md +123 -0
  77. package/opencode/docs/ai/evolution/benchmarks/router-scenarios.jsonl +8 -0
  78. package/opencode/docs/ai/evolution/evolution_history.md +83 -0
  79. package/opencode/docs/ai/evolution/mechanisms.jsonl +7 -0
  80. package/opencode/docs/ai/evolution/rejected_mechanisms.jsonl +2 -0
  81. package/opencode/docs/ai/evolution/runs/README.md +15 -0
  82. package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/analysis/overview.md +12 -0
  83. package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/change_evaluation.json +108 -0
  84. package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/change_manifest.json +52 -0
  85. package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/evaluation.md +19 -0
  86. package/opencode/docs/ai/evolution/runs/iteration-001-sidecar/post_evaluation.md +12 -0
  87. package/opencode/docs/ai/evolution/runs/iteration-002-feature-flow-fix/analysis/overview.md +7 -0
  88. package/opencode/docs/ai/evolution/runs/iteration-002-feature-flow-fix/change_evaluation.json +31 -0
  89. package/opencode/docs/ai/evolution/runs/iteration-002-feature-flow-fix/evaluation.md +19 -0
  90. package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/analysis/overview.md +13 -0
  91. package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/change_evaluation.json +66 -0
  92. package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/change_manifest.json +82 -0
  93. package/opencode/docs/ai/evolution/runs/iteration-003-agent-readable-harness/evaluation.md +20 -0
  94. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/ahe-run-lifecycle-validator.md +40 -0
  95. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/evolve-evaluation-only-contract.md +15 -0
  96. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/open-design-tool-contract.md +14 -0
  97. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/detail/slash-command-contract-coverage.md +40 -0
  98. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/overview.md +17 -0
  99. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/analysis/pre_apply_approval.md +15 -0
  100. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/change_evaluation.json +252 -0
  101. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/change_manifest.json +210 -0
  102. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/evaluation.md +25 -0
  103. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/post_apply_evaluation.md +15 -0
  104. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/post_manifest_evaluation.md +14 -0
  105. package/opencode/docs/ai/evolution/runs/iteration-004-orchestration-audit/pre_apply_evaluation.md +15 -0
  106. package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/analysis/overview.md +13 -0
  107. package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/change_evaluation.json +14 -0
  108. package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/change_manifest.json +30 -0
  109. package/opencode/docs/ai/evolution/runs/iteration-005-harness-orchestration-audit/evaluation.md +25 -0
  110. package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/analysis/overview.md +13 -0
  111. package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/change_evaluation.json +14 -0
  112. package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/change_manifest.json +29 -0
  113. package/opencode/docs/ai/evolution/runs/iteration-006-lead-delegation-audit/evaluation.md +18 -0
  114. package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/analysis/overview.md +13 -0
  115. package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/change_evaluation.json +14 -0
  116. package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/change_manifest.json +34 -0
  117. package/opencode/docs/ai/evolution/runs/iteration-007-agent-skills-integration/evaluation.md +17 -0
  118. package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/analysis/overview.md +13 -0
  119. package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/change_evaluation.json +12 -0
  120. package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/change_manifest.json +28 -0
  121. package/opencode/docs/ai/evolution/runs/iteration-008-lead-readonly-shell-permissions/evaluation.md +17 -0
  122. package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/analysis/overview.md +9 -0
  123. package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/change_evaluation.json +14 -0
  124. package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/change_manifest.json +31 -0
  125. package/opencode/docs/ai/evolution/runs/iteration-009-lead-developer-ownership-loop/evaluation.md +18 -0
  126. package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/analysis/overview.md +12 -0
  127. package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/change_evaluation.json +14 -0
  128. package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/change_manifest.json +31 -0
  129. package/opencode/docs/ai/evolution/runs/iteration-010-token-plugin-sidebar-content/evaluation.md +17 -0
  130. package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/analysis/overview.md +10 -0
  131. package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/change_evaluation.json +14 -0
  132. package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/change_manifest.json +30 -0
  133. package/opencode/docs/ai/evolution/runs/iteration-011-lead-cd-which-permissions/evaluation.md +17 -0
  134. package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/analysis/overview.md +25 -0
  135. package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/change_evaluation.json +28 -0
  136. package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/change_manifest.json +31 -0
  137. package/opencode/docs/ai/evolution/runs/iteration-012-lead-shell-allowlist-boundaries/evaluation.md +22 -0
  138. package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/analysis/overview.md +27 -0
  139. package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/change_evaluation.json +32 -0
  140. package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/change_manifest.json +49 -0
  141. package/opencode/docs/ai/evolution/runs/iteration-013-doc-gardening-mechanical-checks/evaluation.md +92 -0
  142. package/opencode/docs/ai/evolution/runs/iteration-014-harness-baseline/analysis/detail/token-vs-semantic.md +31 -0
  143. package/opencode/docs/ai/evolution/runs/iteration-014-harness-baseline/analysis/overview.md +14 -0
  144. package/opencode/docs/ai/evolution/runs/iteration-014-harness-baseline/evaluation.md +36 -0
  145. package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/analysis/overview.md +13 -0
  146. package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/change_evaluation.json +31 -0
  147. package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/change_manifest.json +47 -0
  148. package/opencode/docs/ai/evolution/runs/iteration-015-semantic-checker/evaluation.md +27 -0
  149. package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/analysis/overview.md +32 -0
  150. package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/change_evaluation.json +31 -0
  151. package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/change_manifest.json +35 -0
  152. package/opencode/docs/ai/evolution/runs/iteration-016-contract-prompt-alignment/evaluation.md +31 -0
  153. package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/analysis/detail/pattern-1-feature-sidecar-false-positive.md +51 -0
  154. package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/analysis/detail/pattern-2-checker-time-budget.md +52 -0
  155. package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/analysis/overview.md +99 -0
  156. package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/change_evaluation.json +61 -0
  157. package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/change_manifest.json +61 -0
  158. package/opencode/docs/ai/evolution/runs/iteration-017-ahe-cycle/evaluation.md +448 -0
  159. package/opencode/docs/ai/evolution/runs/iteration-018-free-message-routing-audit/analysis/detail/intake-gray-zone.md +65 -0
  160. package/opencode/docs/ai/evolution/runs/iteration-018-free-message-routing-audit/analysis/overview.md +172 -0
  161. package/opencode/docs/ai/evolution/runs/iteration-018-free-message-routing-audit/evaluation.md +226 -0
  162. package/opencode/docs/ai/evolution/runs/iteration-019-handoff-routing-audit/analysis/detail/plan-only-gray-zone.md +62 -0
  163. package/opencode/docs/ai/evolution/runs/iteration-019-handoff-routing-audit/analysis/overview.md +167 -0
  164. package/opencode/docs/ai/evolution/runs/iteration-019-handoff-routing-audit/evaluation.md +163 -0
  165. package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/analysis/overview.md +42 -0
  166. package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/change_evaluation.json +46 -0
  167. package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/change_manifest.json +57 -0
  168. package/opencode/docs/ai/evolution/runs/iteration-020-loop-engineering-command/evaluation.md +48 -0
  169. package/opencode/docs/ai/evolution/runs/iteration-021/analysis/detail/contract-vs-runtime-gap.md +163 -0
  170. package/opencode/docs/ai/evolution/runs/iteration-021/analysis/detail/evidence-collection-blocker.md +134 -0
  171. package/opencode/docs/ai/evolution/runs/iteration-021/analysis/overview.md +111 -0
  172. package/opencode/docs/ai/evolution/runs/iteration-021/change_evaluation.json +52 -0
  173. package/opencode/docs/ai/evolution/runs/iteration-021/change_manifest.json +50 -0
  174. package/opencode/docs/ai/evolution/runs/iteration-021/evaluation.md +46 -0
  175. package/opencode/docs/ai/evolution/runs/iteration-021/manifest-justification.md +48 -0
  176. package/opencode/docs/ai/evolution/session-sources.md +91 -0
  177. package/opencode/docs/ai/harness/README.md +32 -0
  178. package/opencode/docs/ai/harness/agents.md +148 -0
  179. package/opencode/docs/ai/harness/checks.md +119 -0
  180. package/opencode/docs/ai/harness/commands.md +391 -0
  181. package/opencode/docs/ai/harness/evidence.md +85 -0
  182. package/opencode/docs/ai/harness/init-detection-rules.md +160 -0
  183. package/opencode/docs/ai/harness/orchestrated-review.md +131 -0
  184. package/opencode/docs/ai/harness/skill-metadata-schema.md +198 -0
  185. package/opencode/docs/ai/harness/skill-resolution.md +202 -0
  186. package/opencode/docs/ai/harness/skill_registry.json +443 -0
  187. package/opencode/docs/ai/harness/skill_registry.md +43 -0
  188. package/opencode/docs/ai/project-context-template.md +53 -0
  189. package/opencode/opencode.json +38 -0
  190. package/opencode/package-lock.json +1717 -0
  191. package/opencode/package.json +11 -0
  192. package/opencode/plugins/token-tree-usage.tsx +206 -0
  193. package/opencode/references/performance-checklist.md +153 -0
  194. package/opencode/references/security-checklist.md +134 -0
  195. package/opencode/references/testing-patterns.md +236 -0
  196. package/opencode/scripts/check-harness.mjs +1572 -0
  197. package/opencode/scripts/check-harness.test.mjs +820 -0
  198. package/opencode/scripts/collect-session-evidence.mjs +612 -0
  199. package/opencode/scripts/collect-session-evidence.test.mjs +443 -0
  200. package/opencode/scripts/preflight-audit.mjs +497 -0
  201. package/opencode/scripts/preflight-audit.test.mjs +363 -0
  202. package/opencode/scripts/project-capability-snapshot.mjs +407 -0
  203. package/opencode/scripts/project-capability-snapshot.test.mjs +382 -0
  204. package/opencode/scripts/review-orchestrated-prepare.mjs +547 -0
  205. package/opencode/scripts/review-orchestrated-prepare.test.mjs +516 -0
  206. package/opencode/scripts/skill-resolver.mjs +585 -0
  207. package/opencode/scripts/skill-resolver.test.mjs +781 -0
  208. package/opencode/scripts/update-skill-registry.mjs +380 -0
  209. package/opencode/skills/api-and-interface-design/SKILL.md +315 -0
  210. package/opencode/skills/autonomous-loops/SKILL.md +312 -0
  211. package/opencode/skills/code-review-and-quality/SKILL.md +365 -0
  212. package/opencode/skills/code-simplification/SKILL.md +345 -0
  213. package/opencode/skills/context-engineering/SKILL.md +252 -0
  214. package/opencode/skills/debugging-and-error-recovery/SKILL.md +316 -0
  215. package/opencode/skills/documentation-and-adrs/SKILL.md +298 -0
  216. package/opencode/skills/doubt-driven-development/SKILL.md +168 -0
  217. package/opencode/skills/iterative-retrieval/SKILL.md +232 -0
  218. package/opencode/skills/open-design/SKILL.md +123 -0
  219. package/opencode/skills/performance-optimization/SKILL.md +365 -0
  220. package/opencode/skills/security-and-hardening/SKILL.md +369 -0
  221. package/opencode/skills/source-driven-development/SKILL.md +210 -0
  222. package/opencode/skills/test-driven-development/SKILL.md +406 -0
  223. package/opencode/skills/using-agent-skills/SKILL.md +194 -0
  224. package/opencode/skills/verification-loop/SKILL.md +162 -0
  225. package/opencode/tools/open_design.ts +361 -0
  226. package/opencode/tui.json +5 -0
  227. package/package.json +20 -0
  228. package/rollback.sh +5 -0
  229. package/scripts/check.sh +184 -0
  230. package/scripts/install-smoke.sh +111 -0
  231. package/scripts/manage-installation.mjs +1498 -0
  232. package/scripts/manage-installation.test.mjs +1936 -0
  233. package/scripts/version.mjs +197 -0
  234. package/scripts/version.test.mjs +195 -0
  235. package/uninstall.sh +5 -0
  236. package/upgrade.sh +5 -0
@@ -0,0 +1,197 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ const PACKAGE_NAME = "opencode-agent-orchestration-kit";
8
+ const STABLE_VERSION = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
9
+ const CONCRETE_STABLE_VERSION = /(?<![0-9])(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?![0-9])/g;
10
+ const OPERATIONAL_VERSION_SURFACES = [
11
+ "scripts/version.mjs",
12
+ "scripts/manage-installation.mjs",
13
+ "install.sh",
14
+ "upgrade.sh",
15
+ "doctor.sh",
16
+ "uninstall.sh",
17
+ "rollback.sh",
18
+ "scripts/check.sh",
19
+ ".github/workflows/check.yml",
20
+ ];
21
+
22
+ function invalid(message) {
23
+ const error = new Error(message);
24
+ error.code = "INVALID_VERSION";
25
+ return error;
26
+ }
27
+
28
+ export function parseStableVersion(value) {
29
+ if (typeof value !== "string") throw invalid("version must be a string");
30
+ const match = STABLE_VERSION.exec(value);
31
+ if (!match) throw invalid("version must use canonical MAJOR.MINOR.PATCH syntax");
32
+ const components = match.slice(1).map(Number);
33
+ if (components.some((component) => !Number.isSafeInteger(component))) {
34
+ throw invalid("version component exceeds the safe integer range");
35
+ }
36
+ return {
37
+ major: components[0],
38
+ minor: components[1],
39
+ patch: components[2],
40
+ canonical: value,
41
+ };
42
+ }
43
+
44
+ export function compareStableVersions(left, right) {
45
+ const leftVersion = parseStableVersion(left);
46
+ const rightVersion = parseStableVersion(right);
47
+ for (const key of ["major", "minor", "patch"]) {
48
+ if (leftVersion[key] < rightVersion[key]) return -1;
49
+ if (leftVersion[key] > rightVersion[key]) return 1;
50
+ }
51
+ return 0;
52
+ }
53
+
54
+ export function readCanonicalVersion(repositoryRoot, fsOps = fs) {
55
+ const packagePath = path.join(repositoryRoot, "package.json");
56
+ const stat = fsOps.lstatSync(packagePath);
57
+ if (stat.isSymbolicLink() || !stat.isFile()) throw invalid("package.json must be a safe regular file");
58
+ const packageBytes = fsOps.readFileSync(packagePath, "utf8");
59
+ let packageJson;
60
+ try {
61
+ packageJson = JSON.parse(packageBytes);
62
+ } catch (error) {
63
+ throw invalid(`package.json is invalid: ${error.message}`);
64
+ }
65
+ if (packageJson.name !== PACKAGE_NAME) throw invalid("canonical package name is invalid");
66
+ return parseStableVersion(packageJson.version).canonical;
67
+ }
68
+
69
+ export function formatVersion(version) {
70
+ return `${PACKAGE_NAME} ${parseStableVersion(version).canonical}`;
71
+ }
72
+
73
+ function readRegularFile(fullPath, label, fsOps) {
74
+ let stat;
75
+ try {
76
+ stat = fsOps.lstatSync(fullPath);
77
+ } catch (error) {
78
+ if (error.code === "ENOENT") throw invalid(`${label} is missing`);
79
+ throw error;
80
+ }
81
+ if (stat.isSymbolicLink() || !stat.isFile()) throw invalid(`${label} must be a safe regular file`);
82
+ return fsOps.readFileSync(fullPath, "utf8");
83
+ }
84
+
85
+ function pathExists(fullPath, fsOps) {
86
+ try {
87
+ fsOps.lstatSync(fullPath);
88
+ return true;
89
+ } catch (error) {
90
+ if (error.code === "ENOENT") return false;
91
+ throw error;
92
+ }
93
+ }
94
+
95
+ function isDeclaredNonKitVersion(relative, line) {
96
+ return relative === "scripts/check.sh"
97
+ && (/opencodePackage\.(?:dependencies|overrides)/.test(line)
98
+ || /opencode\/package\.json must (?:pin|override)/.test(line));
99
+ }
100
+
101
+ export function checkVersionContract(options = {}) {
102
+ const repositoryRoot = options.repositoryRoot;
103
+ const fsOps = options.fsOps ?? fs;
104
+ if (typeof repositoryRoot !== "string" || repositoryRoot.length === 0) {
105
+ throw invalid("repositoryRoot is required");
106
+ }
107
+ const version = readCanonicalVersion(repositoryRoot, fsOps);
108
+ if (pathExists(path.join(repositoryRoot, "VERSION"), fsOps)) {
109
+ throw invalid("competing root VERSION declaration is forbidden");
110
+ }
111
+
112
+ const opencodePackageText = readRegularFile(path.join(repositoryRoot, "opencode", "package.json"), "opencode/package.json", fsOps);
113
+ let opencodePackage;
114
+ try {
115
+ opencodePackage = JSON.parse(opencodePackageText);
116
+ } catch (error) {
117
+ throw invalid(`opencode/package.json is invalid: ${error.message}`);
118
+ }
119
+ if (Object.hasOwn(opencodePackage, "version")) {
120
+ throw invalid("opencode/package.json must not declare a version");
121
+ }
122
+
123
+ for (const relative of OPERATIONAL_VERSION_SURFACES) {
124
+ const contents = readRegularFile(path.join(repositoryRoot, relative), relative, fsOps);
125
+ const competing = contents.split(/\r?\n/).flatMap((line) => (
126
+ isDeclaredNonKitVersion(relative, line)
127
+ ? []
128
+ : [...line.matchAll(CONCRETE_STABLE_VERSION)].map((match) => match[0])
129
+ ));
130
+ if (competing.length > 0) {
131
+ throw invalid(`${relative} contains a competing stable version declaration`);
132
+ }
133
+ }
134
+
135
+ const releaseNote = `docs/releases/v${version}.md`;
136
+ const note = readRegularFile(path.join(repositoryRoot, releaseNote), "current release note", fsOps);
137
+ const firstLine = note.split(/\r?\n/, 1)[0];
138
+ const expectedHeading = `# v${version} - Safe lifecycle and canonical release identity`;
139
+ if (firstLine !== expectedHeading) throw invalid("current release note heading is invalid");
140
+ const noteLines = new Set(note.split(/\r?\n/));
141
+ for (const heading of [
142
+ "## Highlights",
143
+ "## Installation or upgrade",
144
+ "## Migration",
145
+ "## Validation performed",
146
+ "## Public safety boundary",
147
+ ]) {
148
+ if (!noteLines.has(heading)) throw invalid(`current release note is missing required section: ${heading}`);
149
+ }
150
+
151
+ const identity = { name: PACKAGE_NAME, version, releaseNote };
152
+ if (options.tag !== undefined) {
153
+ if (typeof options.tag !== "string" || !options.tag.startsWith("v")) throw invalid("tag must use canonical vMAJOR.MINOR.PATCH syntax");
154
+ let taggedVersion;
155
+ try {
156
+ taggedVersion = parseStableVersion(options.tag.slice(1)).canonical;
157
+ } catch {
158
+ throw invalid("tag must use canonical vMAJOR.MINOR.PATCH syntax");
159
+ }
160
+ const expectedTag = `v${version}`;
161
+ if (options.tag !== expectedTag || taggedVersion !== version) {
162
+ throw invalid(`tag ${options.tag} does not match canonical version ${expectedTag}`);
163
+ }
164
+ identity.tag = options.tag;
165
+ }
166
+ return identity;
167
+ }
168
+
169
+ async function main(argv) {
170
+ const repositoryRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
171
+ if (argv[0] === "--check") {
172
+ if (argv.length !== 1) throw invalid("--check must be used alone");
173
+ const identity = checkVersionContract({ repositoryRoot });
174
+ process.stdout.write(`version contract ok: v${identity.version}\n`);
175
+ return;
176
+ }
177
+ if (argv[0] === "--check-tag") {
178
+ if (argv.length !== 2) throw invalid("--check-tag requires exactly one tag");
179
+ const identity = checkVersionContract({ repositoryRoot, tag: argv[1] });
180
+ process.stdout.write(`version tag ok: ${identity.tag}\n`);
181
+ return;
182
+ }
183
+ if (argv.length !== 0) throw invalid(`unknown version argument: ${argv[0]}`);
184
+ process.stdout.write(`${formatVersion(readCanonicalVersion(repositoryRoot))}\n`);
185
+ }
186
+
187
+ const isEntrypoint = process.argv[1]
188
+ && fileURLToPath(import.meta.url) === path.resolve(process.argv[1]);
189
+
190
+ if (isEntrypoint) {
191
+ try {
192
+ await main(process.argv.slice(2));
193
+ } catch (error) {
194
+ process.stderr.write(`${error.message}\n`);
195
+ process.exitCode = 2;
196
+ }
197
+ }
@@ -0,0 +1,195 @@
1
+ import assert from "node:assert/strict";
2
+ import fs from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { spawnSync } from "node:child_process";
6
+ import test from "node:test";
7
+ import { fileURLToPath } from "node:url";
8
+
9
+ import {
10
+ checkVersionContract,
11
+ compareStableVersions,
12
+ formatVersion,
13
+ parseStableVersion,
14
+ readCanonicalVersion,
15
+ } from "./version.mjs";
16
+
17
+ const REPOSITORY_ROOT = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
18
+
19
+ function makeRepository(t, packageOverrides = {}) {
20
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "oak-version-test-"));
21
+ t.after(() => fs.rmSync(root, { recursive: true, force: true }));
22
+ fs.writeFileSync(path.join(root, "package.json"), `${JSON.stringify({
23
+ name: "opencode-agent-orchestration-kit",
24
+ version: "1.0.27",
25
+ ...packageOverrides,
26
+ }, null, 2)}\n`);
27
+ return root;
28
+ }
29
+
30
+ const OPERATIONAL_VERSION_SURFACES = [
31
+ "scripts/version.mjs",
32
+ "scripts/manage-installation.mjs",
33
+ "install.sh",
34
+ "upgrade.sh",
35
+ "doctor.sh",
36
+ "uninstall.sh",
37
+ "rollback.sh",
38
+ "scripts/check.sh",
39
+ ".github/workflows/check.yml",
40
+ ];
41
+
42
+ function write(root, relative, contents) {
43
+ const fullPath = path.join(root, relative);
44
+ fs.mkdirSync(path.dirname(fullPath), { recursive: true });
45
+ fs.writeFileSync(fullPath, contents);
46
+ }
47
+
48
+ function makeContractRepository(t, overrides = {}) {
49
+ const root = makeRepository(t);
50
+ write(root, "docs/releases/v1.0.27.md", [
51
+ "# v1.0.27 - Safe lifecycle and canonical release identity",
52
+ "",
53
+ "## Highlights",
54
+ "",
55
+ "## Installation or upgrade",
56
+ "",
57
+ "## Migration",
58
+ "",
59
+ "## Validation performed",
60
+ "",
61
+ "## Public safety boundary",
62
+ "",
63
+ ].join("\n"));
64
+ write(root, "opencode/package.json", "{\"private\":true}\n");
65
+ for (const relative of OPERATIONAL_VERSION_SURFACES) write(root, relative, "canonical consumer\n");
66
+ for (const [relative, contents] of Object.entries(overrides)) {
67
+ const fullPath = path.join(root, relative);
68
+ if (contents === null) fs.rmSync(fullPath, { force: true });
69
+ else write(root, relative, contents);
70
+ }
71
+ return root;
72
+ }
73
+
74
+ test("[V001] canonical package identity is read and formatted", (t) => {
75
+ const root = makeRepository(t);
76
+ assert.equal(readCanonicalVersion(root), "1.0.27");
77
+ assert.equal(formatVersion("1.0.27"), "opencode-agent-orchestration-kit 1.0.27");
78
+ assert.throws(() => readCanonicalVersion(makeRepository(t, { name: "other" })), /package name/i);
79
+ });
80
+
81
+ test("[V002] non-canonical stable versions are rejected", () => {
82
+ for (const value of [
83
+ "v1.0.27", "01.0.27", "1.0", "1.0.0-rc.1", "1.0.0+build",
84
+ " 1.0.27", "1.0.27 ", "-1.0.0", "9007199254740992.0.0",
85
+ ]) {
86
+ assert.throws(() => parseStableVersion(value), /version/i, value);
87
+ }
88
+ });
89
+
90
+ test("[V003] stable version comparison is numeric", () => {
91
+ assert.equal(compareStableVersions("1.9.9", "1.10.0"), -1);
92
+ assert.equal(compareStableVersions("1.10.0", "1.9.9"), 1);
93
+ assert.equal(compareStableVersions("1.0.27", "1.0.27"), 0);
94
+ });
95
+
96
+ function run(command, args, env = {}) {
97
+ return spawnSync(command, args, {
98
+ cwd: REPOSITORY_ROOT,
99
+ encoding: "utf8",
100
+ env: { ...process.env, ...env },
101
+ });
102
+ }
103
+
104
+ test("[V004] direct version entrypoints are exact and mutation-free", (t) => {
105
+ const home = fs.mkdtempSync(path.join(os.tmpdir(), "oak-version-home-"));
106
+ t.after(() => fs.rmSync(home, { recursive: true, force: true }));
107
+ const target = path.join(home, ".config", "opencode");
108
+ for (const args of [["scripts/version.mjs"], ["scripts/manage-installation.mjs", "--version"]]) {
109
+ const result = run(process.execPath, args, { HOME: home });
110
+ assert.equal(result.status, 0, result.stderr);
111
+ assert.equal(result.stdout, "opencode-agent-orchestration-kit 1.0.27\n");
112
+ assert.equal(fs.existsSync(target), false);
113
+ }
114
+ });
115
+
116
+ test("[V005] all lifecycle wrappers expose the canonical version", () => {
117
+ for (const wrapper of ["install.sh", "upgrade.sh", "doctor.sh", "uninstall.sh", "rollback.sh"]) {
118
+ const result = run(path.join(REPOSITORY_ROOT, wrapper), ["--version"]);
119
+ assert.equal(result.status, 0, `${wrapper}: ${result.stderr}`);
120
+ assert.equal(result.stdout, "opencode-agent-orchestration-kit 1.0.27\n", wrapper);
121
+ }
122
+ });
123
+
124
+ test("[V006] version cannot be combined with lifecycle arguments", () => {
125
+ for (const args of [
126
+ ["scripts/manage-installation.mjs", "--version", "--target", "/tmp/x"],
127
+ ["scripts/manage-installation.mjs", "install", "--version", "--dry-run"],
128
+ ]) {
129
+ const result = run(process.execPath, args);
130
+ assert.equal(result.status, 2);
131
+ }
132
+ });
133
+
134
+ test("[V007] the current release note path and first heading are required", (t) => {
135
+ assert.equal(checkVersionContract({ repositoryRoot: makeContractRepository(t) }).version, "1.0.27");
136
+ assert.throws(() => checkVersionContract({
137
+ repositoryRoot: makeContractRepository(t, { "docs/releases/v1.0.27.md": null }),
138
+ }), /release note/i);
139
+ assert.throws(() => checkVersionContract({
140
+ repositoryRoot: makeContractRepository(t, { "docs/releases/v1.0.27.md": "# wrong\n" }),
141
+ }), /heading/i);
142
+ assert.throws(() => checkVersionContract({
143
+ repositoryRoot: makeContractRepository(t, {
144
+ "docs/releases/v1.0.27.md": "# v1.0.27 - Safe lifecycle and canonical release identity\n\n## Highlights\n",
145
+ }),
146
+ }), /required section/i);
147
+ const historicalGap = makeContractRepository(t);
148
+ write(historicalGap, "docs/releases/v1.0.25.md", "# historical\n");
149
+ assert.doesNotThrow(() => checkVersionContract({ repositoryRoot: historicalGap }));
150
+ });
151
+
152
+ test("[V008] competing declarations fail on every allowlisted operational surface", async (t) => {
153
+ const declarations = [
154
+ ["VERSION", "1.0.27\n"],
155
+ ["opencode/package.json", "{\"private\":true,\"version\":\"1.0.27\"}\n"],
156
+ ...OPERATIONAL_VERSION_SURFACES.map((relative) => [relative, "const duplicate = '1.0.27'\n"]),
157
+ ];
158
+ for (const [relative, contents] of declarations) {
159
+ await t.test(relative, (child) => {
160
+ const root = makeContractRepository(child, { [relative]: contents });
161
+ assert.throws(() => checkVersionContract({ repositoryRoot: root }), /version|declaration/i);
162
+ });
163
+ }
164
+ });
165
+
166
+ test("[V009] tag validation accepts only the matching canonical v-tag", (t) => {
167
+ const root = makeContractRepository(t);
168
+ assert.equal(checkVersionContract({ repositoryRoot: root, tag: "v1.0.27" }).tag, "v1.0.27");
169
+ for (const tag of ["v1.0.26", "1.0.27", "v01.0.27", "v1.0.27-rc.1"]) {
170
+ assert.throws(() => checkVersionContract({ repositoryRoot: root, tag }), /tag/i, tag);
171
+ }
172
+ });
173
+
174
+ test("[V010] CI keeps branch and PR checks and adds tag-only validation", () => {
175
+ const workflow = fs.readFileSync(path.join(REPOSITORY_ROOT, ".github", "workflows", "check.yml"), "utf8");
176
+ assert.match(workflow, /pull_request:/);
177
+ assert.match(workflow, /branches:\s*\n\s*- master/);
178
+ assert.match(workflow, /tags:\s*\n\s*- ["']v\*["']/);
179
+ assert.match(workflow, /startsWith\(github\.ref, 'refs\/tags\/'\)/);
180
+ assert.match(workflow, /version\.mjs --check-tag \"\$GITHUB_REF_NAME\"/);
181
+ });
182
+
183
+ test("[V011] workflow remains non-publishing and scenario IDs are unique", () => {
184
+ const workflow = fs.readFileSync(path.join(REPOSITORY_ROOT, ".github", "workflows", "check.yml"), "utf8");
185
+ for (const expected of ["Contract check", "Unit and script tests", "Install OpenCode tool dependencies", "Audit OpenCode tool dependencies", "Typecheck TUI token plugin", "Installation smoke"]) {
186
+ assert.match(workflow, new RegExp(`name: ${expected}`));
187
+ }
188
+ assert.doesNotMatch(workflow, /contents:\s*write|create-release|softprops|gh release|git push/i);
189
+
190
+ const sources = ["scripts/version.test.mjs", "scripts/manage-installation.test.mjs"]
191
+ .map((relative) => fs.readFileSync(path.join(REPOSITORY_ROOT, relative), "utf8"))
192
+ .join("\n");
193
+ const ids = [...sources.matchAll(/\[V(\d{3})\]/g)].map((match) => Number(match[1]));
194
+ assert.deepEqual(ids.sort((left, right) => left - right), Array.from({ length: 27 }, (_, index) => index + 1));
195
+ });
package/uninstall.sh ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ root="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
5
+ exec node "$root/scripts/manage-installation.mjs" uninstall "$@"
package/upgrade.sh ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ root="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
5
+ exec node "$root/scripts/manage-installation.mjs" upgrade "$@"