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,779 @@
1
+ # Safe Installation Lifecycle Implementation Plan
2
+
3
+ > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
4
+
5
+ **Goal:** Replace the copy/delete installers with a dependency-free, manifest-owned, dry-run-first installation manager supporting safe install, upgrade, doctor, uninstall, committed rollback, and interrupted-operation recovery.
6
+
7
+ **Architecture:** Keep all ownership, planning, validation, journaling, locking, durability, and recovery rules in one importable Node.js engine at `scripts/manage-installation.mjs`. Root shell scripts are executable argument-forwarding wrappers only. A single `node:test` suite drives the engine through injected clock, transaction ID, PID probe, failpoint, filesystem, and I/O seams, while smoke tests exercise the public wrappers against real temporary directories.
8
+
9
+ **Tech Stack:** Node.js 24 ESM, built-in `node:test`, `node:assert/strict`, `node:fs`, `node:crypto`, `node:path`, Bash wrappers, JSON state under `.oak/`, existing npm/CI scripts.
10
+
11
+ ---
12
+
13
+ ## Execution prerequisites and safety gate
14
+
15
+ The current public working tree contains approved but uncommitted Slice 1.1 changes plus the Slice 1.2 spec and this plan. Do not start implementation by staging whole shared files or by creating a worktree from `HEAD`, because either action can omit or accidentally bundle approved work.
16
+
17
+ - [ ] Obtain explicit approval for how the current Slice 1.1/spec/plan baseline will be committed or otherwise transferred.
18
+ - [ ] Create a dedicated `codex/` implementation branch and worktree from that approved baseline using `superpowers:using-git-worktrees`.
19
+ - [ ] Confirm the implementation worktree starts with `git status --short --branch` showing no unrelated changes.
20
+ - [ ] Re-run `npm run check` and expect `102` existing tests passing before adding manager tests.
21
+ - [ ] Keep the developer's live OpenCode configuration read-only throughout implementation; every lifecycle test uses a bounded temporary target.
22
+
23
+ ## File map
24
+
25
+ **Create**
26
+
27
+ - `scripts/manage-installation.mjs` — the only lifecycle engine and CLI dispatcher; exports pure validation/planning helpers plus an injected manager factory.
28
+ - `scripts/manage-installation.test.mjs` — scenarios `[S001]` through `[S136]`, unit fixtures, failpoints, and focused wrapper contracts.
29
+ - `upgrade.sh` — forwards to engine command `upgrade`.
30
+ - `doctor.sh` — forwards to `doctor`, including `--accept-preserved`.
31
+ - `rollback.sh` — forwards to engine command `rollback`.
32
+
33
+ **Replace with thin wrappers**
34
+
35
+ - `install.sh` — forwards to engine command `install`.
36
+ - `uninstall.sh` — forwards to engine command `uninstall`.
37
+
38
+ **Modify**
39
+
40
+ - `scripts/check.sh` — require the engine, tests, five wrappers, and executable modes.
41
+ - `scripts/install-smoke.sh` — run the complete clean-target lifecycle and validate the installed harness.
42
+ - `package.json` — include `scripts/*.test.mjs` in `unit-and-script-tests`.
43
+ - `README.md` — document dry-run, ownership, conflicts, protected files, doctor, uninstall, rollback, and recovery.
44
+ - `docs/installation.md` — detailed command and recovery reference.
45
+
46
+ **Verify, but normally do not modify**
47
+
48
+ - `.github/workflows/check.yml` — the existing `npm run unit-and-script-tests` and `npm run installation-smoke` steps pick up the new suite through `package.json`.
49
+ - `CONTRIBUTING.md` — the existing statement that `npm run check` runs every bundled `node:test` suite remains accurate.
50
+ - `docs/superpowers/specs/2026-07-20-safe-installation-lifecycle-design.md` — approved source of truth; no implementation edits unless a genuine contradiction is discovered and returned to the user.
51
+
52
+ ## Engine contract to preserve across tasks
53
+
54
+ Implement these named exports in `scripts/manage-installation.mjs` so tests do not shell out for engine behavior:
55
+
56
+ ```js
57
+ export const SCHEMA_VERSION = 1;
58
+ export const PROTECTED_ROOT_FILES = [
59
+ "AGENTS.md",
60
+ "opencode.json",
61
+ "package.json",
62
+ "package-lock.json",
63
+ "tui.json",
64
+ ];
65
+
66
+ export function canonicalManifestBytes(manifest) {}
67
+ export function validateManifest(manifest) {}
68
+ export function validateTransaction(transaction) {}
69
+ export function inventorySource(sourceRoot, deps) {}
70
+ export function inspectInstallation({ sourceRoot, targetRoot, deps }) {}
71
+ export function buildPlan({ command, inspection, options }) {}
72
+ export function createInstallationManager(options) {}
73
+ export async function main(argv, options = {}) {}
74
+ ```
75
+
76
+ `createInstallationManager` accepts explicit dependencies rather than secret flags:
77
+
78
+ ```js
79
+ {
80
+ sourceRoot,
81
+ clock: () => new Date(),
82
+ transactionId: () => crypto.randomUUID(),
83
+ pidProbe: (pid) => process.kill(pid, 0),
84
+ failpoint: () => {},
85
+ fsOps: realFsOps,
86
+ stdin: process.stdin,
87
+ stdout: process.stdout,
88
+ stderr: process.stderr,
89
+ }
90
+ ```
91
+
92
+ The production CLI calls the same exported manager used by tests. `fsOps` exists only to inject low-level failures and delegates to real `node:fs` operations by default; no public environment switch selects a test implementation.
93
+
94
+ Use scenario-prefixed names in the test suite:
95
+
96
+ ```js
97
+ test("[S001] clean install dry-run performs zero writes", async () => {
98
+ // fixture, action, exact assertions
99
+ });
100
+ ```
101
+
102
+ This makes the final scenario-coverage check mechanical.
103
+
104
+ ### Task 1: Test fixture, CLI skeleton, and target resolution
105
+
106
+ **Files:**
107
+ - Create: `scripts/manage-installation.test.mjs`
108
+ - Create: `scripts/manage-installation.mjs`
109
+
110
+ - [ ] **Step 1: Add fixture helpers and the first failing CLI tests**
111
+
112
+ Create helpers using `fs.mkdtempSync`, never caller-owned paths:
113
+
114
+ ```js
115
+ function makeFixture(t) {
116
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "oak-manager-test-"));
117
+ const sourceRoot = path.join(root, "repo", "opencode");
118
+ const targetRoot = path.join(root, "target");
119
+ fs.mkdirSync(sourceRoot, { recursive: true });
120
+ t.after(() => fs.rmSync(root, { recursive: true, force: true }));
121
+ return { root, sourceRoot, targetRoot };
122
+ }
123
+
124
+ function deterministicDeps(overrides = {}) {
125
+ return {
126
+ clock: () => new Date("2026-07-20T00:00:00.000Z"),
127
+ transactionId: () => "tx-0001",
128
+ pidProbe: () => ({ alive: false, code: "ESRCH" }),
129
+ failpoint: () => {},
130
+ ...overrides,
131
+ };
132
+ }
133
+ ```
134
+
135
+ Add focused tests for target precedence, missing `HOME`, empty environment values, `--help`, unknown flags, missing flag values, and command/flag compatibility from scenario `20`.
136
+
137
+ - [ ] **Step 2: Run the focused tests and verify RED**
138
+
139
+ Run:
140
+
141
+ ```bash
142
+ node --test --test-name-pattern='S020|target precedence|unknown flag' scripts/manage-installation.test.mjs
143
+ ```
144
+
145
+ Expected: FAIL because `main` and argument parsing are not implemented.
146
+
147
+ - [ ] **Step 3: Implement the minimal CLI dispatcher and target resolver**
148
+
149
+ Implement strict parsing for `install`, `upgrade`, `doctor`, `uninstall`, and `rollback`. Apply `--target` > non-empty `OPENCODE_CONFIG_DIR` > `$HOME/.config/opencode`; never expand `~`. Return structured exit codes from `main` and set `process.exitCode` only in the executable entrypoint.
150
+
151
+ - [ ] **Step 4: Re-run the focused tests and verify GREEN**
152
+
153
+ Run the command from Step 2.
154
+
155
+ Expected: PASS; no filesystem lifecycle behavior exists yet.
156
+
157
+ - [ ] **Step 5: Commit the skeleton**
158
+
159
+ ```bash
160
+ git add scripts/manage-installation.mjs scripts/manage-installation.test.mjs
161
+ git commit -m "feat: scaffold installation manager CLI"
162
+ ```
163
+
164
+ ### Task 2: Source inventory, reserved namespace, modes, and path safety
165
+
166
+ **Files:**
167
+ - Modify: `scripts/manage-installation.mjs`
168
+ - Modify: `scripts/manage-installation.test.mjs`
169
+
170
+ - [ ] **Step 1: Add failing inventory and path-safety scenarios**
171
+
172
+ Add scenarios `19`, `25-28`, `33`, `36-38`, `46`, `61-67`, and `81-89`. Fixtures must cover source/target symlinks, file-directory collisions, `.oak` as file/directory/symlink/payload path, repository/payload target equality and ancestor/descendant relationships, `..`, case-equivalent paths where supported, invalid modes, and unknown operation kinds.
173
+
174
+ - [ ] **Step 2: Verify the new scenarios fail**
175
+
176
+ ```bash
177
+ node --test --test-name-pattern='S019|S02[5-8]|S033|S03[6-8]|S046|S06[1-7]|S08[1-9]' scripts/manage-installation.test.mjs
178
+ ```
179
+
180
+ Expected: FAIL on missing inventory/path validators.
181
+
182
+ - [ ] **Step 3: Implement inventory and safe path primitives**
183
+
184
+ Implement sorted `lstat`-based traversal without following symlinks. Normalize POSIX relative paths, reject traversal/absolute/control paths and `.oak`, persist `stat.mode & 0o777`, hash regular-file bytes with SHA-256, and compare resolved target/repository/payload relationships before any mutation.
185
+
186
+ Keep helpers narrowly named, for example:
187
+
188
+ ```js
189
+ function normalizeManagedPath(value) {}
190
+ function assertSafeTarget({ targetRoot, repositoryRoot, sourceRoot, fsOps }) {}
191
+ function inspectRegularFile(fullPath, fsOps) {}
192
+ function inventorySource(sourceRoot, deps) {}
193
+ ```
194
+
195
+ - [ ] **Step 4: Run the focused scenarios**
196
+
197
+ Expected: every selected scenario passes and fixture cleanup removes only its own temporary root.
198
+
199
+ - [ ] **Step 5: Commit path safety**
200
+
201
+ ```bash
202
+ git add scripts/manage-installation.mjs scripts/manage-installation.test.mjs
203
+ git commit -m "feat: validate installation paths and source inventory"
204
+ ```
205
+
206
+ ### Task 3: Canonical manifest and journal schema validation
207
+
208
+ **Files:**
209
+ - Modify: `scripts/manage-installation.mjs`
210
+ - Modify: `scripts/manage-installation.test.mjs`
211
+
212
+ - [ ] **Step 1: Add failing schema tests**
213
+
214
+ Add scenarios `14`, `40`, `46`, `49`, `60`, `62`, `72-76`, `83`, `85-89`, `95-98`, `124-125`, and `128-136`. Include exact fixtures for valid install/upgrade/accept-preserved/uninstall presence pairs, canonical manifest bytes, null/object digest coupling, acknowledgement shape, status/origin transitions, operation before/after pairs, and backup-root selection.
215
+
216
+ - [ ] **Step 2: Verify schema tests fail**
217
+
218
+ ```bash
219
+ node --test --test-name-pattern='S014|S040|S049|S060|S062|S07[2-6]|S08[3-9]|S09[5-8]|S12[4-9]|S13[0-6]' scripts/manage-installation.test.mjs
220
+ ```
221
+
222
+ Expected: FAIL because validators and canonical serializer are incomplete.
223
+
224
+ - [ ] **Step 3: Implement canonical manifest bytes**
225
+
226
+ Serialize recursively sorted object keys with no insignificant whitespace, schema-sorted arrays, UTF-8 without BOM, and exactly one final LF. Use the same bytes for writing and hashing:
227
+
228
+ ```js
229
+ export function canonicalManifestBytes(manifest) {
230
+ const normalized = canonicalizeManifest(manifest);
231
+ return Buffer.from(`${JSON.stringify(normalized)}\n`, "utf8");
232
+ }
233
+ ```
234
+
235
+ Do not use plain `JSON.stringify` elsewhere for persisted manifest bytes.
236
+
237
+ - [ ] **Step 4: Implement strict manifest and transaction validators**
238
+
239
+ Validate complete manifests, stable preservation reasons, nullable/full `merge_acknowledgement`, `.oak` exclusions, sorted unique paths, manifest presence/digest pairs, command-specific pairs, lock identity, status/origin transitions, completed indexes, operation kinds, nullable `backup_path`, and root selection.
240
+
241
+ Return validated immutable data or throw a typed manager error carrying exit code `2`; never repair invalid state.
242
+
243
+ - [ ] **Step 5: Run schema tests and verify GREEN**
244
+
245
+ Run the Step 2 command, then:
246
+
247
+ ```bash
248
+ node --test --test-name-pattern='S128|S129|S130|S134|S135|S136' scripts/manage-installation.test.mjs
249
+ ```
250
+
251
+ Expected: PASS.
252
+
253
+ - [ ] **Step 6: Commit schema contracts**
254
+
255
+ ```bash
256
+ git add scripts/manage-installation.mjs scripts/manage-installation.test.mjs
257
+ git commit -m "feat: validate installation manifests and journals"
258
+ ```
259
+
260
+ ### Task 4: Inspection, ownership classification, and pure planning
261
+
262
+ **Files:**
263
+ - Modify: `scripts/manage-installation.mjs`
264
+ - Modify: `scripts/manage-installation.test.mjs`
265
+
266
+ - [ ] **Step 1: Add failing classification and dry-run scenarios**
267
+
268
+ Add scenarios `1-5`, `7-10`, `21-24`, `41-42`, `52`, `56-57`, `68`, `70`, `80`, `92`, `103-104`, `108-109`, `118-121`, `126-127`. Assert structured plans, sorted paths, reasons, fingerprints, blockers, warnings, exact ownership, and zero filesystem writes for dry-run.
269
+
270
+ - [ ] **Step 2: Verify planning is RED**
271
+
272
+ ```bash
273
+ node --test --test-name-pattern='S00[1-5]|S00[7-9]|S010|S02[1-4]|S04[1-2]|S052|S05[6-7]|S068|S070|S080|S092|S10[3-4]|S10[8-9]|S11[8-9]|S12[0-1]|S12[6-7]' scripts/manage-installation.test.mjs
274
+ ```
275
+
276
+ Expected: FAIL because classification and plan generation are missing.
277
+
278
+ - [ ] **Step 3: Implement inspection and classifications**
279
+
280
+ Produce explicit `owned-unchanged`, `owned-modified`, `owned-missing`, `preserved-user`, `unowned-match`, `unowned-conflict`, `new`, `obsolete-unchanged`, `obsolete-modified`, `obsolete-preserved-present`, and `obsolete-preserved-missing` records. Compute acknowledgement current/historical/absent state independently from preservation reason.
281
+
282
+ - [ ] **Step 4: Implement pure logical plans**
283
+
284
+ Return sorted entries with kinds `add`, `update`, `remove`, `adopt`, or `preserve`, exact before/after states, reasons, blockers, warnings, source/manifest/target fingerprint, and full previous/next manifests. Never write from `buildPlan`.
285
+
286
+ Ensure:
287
+
288
+ - initial exact matches may `adopt`;
289
+ - upgrade exact pre-existing paths stay preserved with `preexisting-exact-match`;
290
+ - source-removed preserved entries use logical `preserve` reason `source-removed` and are removed only from the next manifest;
291
+ - baseline-only no-op upgrade stays read-only;
292
+ - obsolete-preserved cleanup is real manifest work.
293
+
294
+ - [ ] **Step 5: Run focused planning tests**
295
+
296
+ Expected: PASS with byte-for-byte unchanged fixture trees for every dry-run/blocker.
297
+
298
+ - [ ] **Step 6: Commit planning**
299
+
300
+ ```bash
301
+ git add scripts/manage-installation.mjs scripts/manage-installation.test.mjs
302
+ git commit -m "feat: plan ownership-safe installation changes"
303
+ ```
304
+
305
+ ### Task 5: Durable state primitives, bootstrap cleanup, and conservative locks
306
+
307
+ **Files:**
308
+ - Modify: `scripts/manage-installation.mjs`
309
+ - Modify: `scripts/manage-installation.test.mjs`
310
+
311
+ - [ ] **Step 1: Add failing durability and lock scenarios**
312
+
313
+ Add scenarios `15`, `17-18`, `29-32`, `38-39`, `43-44`, `48-51`, `79`, `93-94`. Use injected failpoints before journal creation, after journal creation, after rename, before directory fsync, during bootstrap removal, during rollback-point publication, and during lock-holder refresh.
314
+
315
+ - [ ] **Step 2: Verify RED**
316
+
317
+ ```bash
318
+ node --test --test-name-pattern='S015|S01[7-8]|S02[9]|S03[0-2]|S03[8-9]|S04[3-4]|S04[8-9]|S05[0-1]|S079|S09[3-4]' scripts/manage-installation.test.mjs
319
+ ```
320
+
321
+ Expected: FAIL on absent state/lock primitives.
322
+
323
+ - [ ] **Step 3: Implement restrictive and durable state writes**
324
+
325
+ Create `.oak` directories as `0700` and files/temporaries as `0600` before writing. Implement complete-write loops, file fsync, atomic same-directory rename, required parent-directory fsync, durable unlink/rmdir, and platform-explicit directory fsync errors.
326
+
327
+ Call named failpoints at every tested boundary; failpoints are dependency callbacks, never environment variables.
328
+
329
+ - [ ] **Step 4: Implement bootstrap and lock protocol**
330
+
331
+ Record `target_created_by_invocation` and `oak_created_by_invocation`, clean only invocation-owned empty directories, and fsync parents after removal. Publish `lock.json` exclusively with transaction ID/PID/command/timestamp. Treat PID success and `EPERM` as alive, `ESRCH` as dead, and all other errors as fail-closed.
332
+
333
+ - [ ] **Step 5: Run durability tests**
334
+
335
+ Expected: PASS; every interruption leaves either exact pre-state, a valid recoverable active journal, or post-commit cleanup residue with one active rollback point.
336
+
337
+ - [ ] **Step 6: Commit durability primitives**
338
+
339
+ ```bash
340
+ git add scripts/manage-installation.mjs scripts/manage-installation.test.mjs
341
+ git commit -m "feat: add durable installation state and locking"
342
+ ```
343
+
344
+ ### Task 6: Transaction executor and initial install
345
+
346
+ **Files:**
347
+ - Modify: `scripts/manage-installation.mjs`
348
+ - Modify: `scripts/manage-installation.test.mjs`
349
+
350
+ - [ ] **Step 1: Add failing install/apply scenarios**
351
+
352
+ Complete scenarios `2-7`, `33`, `36-38`, `43`, `68-70`, and `95`. Assert exact bytes/modes, protected preservation, initial adoption without rewrite, `--force` backup durability, manifest-only install, previous manifest null, and rollback candidate contents.
353
+
354
+ - [ ] **Step 2: Verify RED**
355
+
356
+ ```bash
357
+ node --test --test-name-pattern='S00[2-7]|S033|S03[6-8]|S043|S06[8-9]|S070|S095' scripts/manage-installation.test.mjs
358
+ ```
359
+
360
+ - [ ] **Step 3: Implement the generic forward transaction executor**
361
+
362
+ Translate only logical `add/update/remove` entries into journal operations. Capture required update/remove backups under `rollback.next/files`, write `planned + none`, transition to applying, record each completed index durably, publish/remove the next manifest, materialize the committed candidate, remove the active journal as commit boundary, then clean residue and lock.
363
+
364
+ `adopt` and `preserve` affect only next manifest. An empty operations array still follows the whole journal/rollback protocol.
365
+
366
+ - [ ] **Step 4: Implement install policy**
367
+
368
+ Support clean/pre-existing targets, protected root preservation, exact-match adoption, collision blockers, and initial-only regular-file `--force`. Do not recreate the old sibling timestamp backup directory.
369
+
370
+ - [ ] **Step 5: Run install scenarios and full suite**
371
+
372
+ ```bash
373
+ node --test --test-name-pattern='S00[1-7]|S033|S03[6-8]|S068|S069|S070|S095' scripts/manage-installation.test.mjs
374
+ node --test scripts/manage-installation.test.mjs
375
+ ```
376
+
377
+ Expected: focused tests pass; remaining unimplemented command scenarios may still fail and should be listed, not weakened.
378
+
379
+ - [ ] **Step 6: Commit install execution**
380
+
381
+ ```bash
382
+ git add scripts/manage-installation.mjs scripts/manage-installation.test.mjs
383
+ git commit -m "feat: execute managed installations transactionally"
384
+ ```
385
+
386
+ ### Task 7: Upgrade and obsolete-preserved cleanup
387
+
388
+ **Files:**
389
+ - Modify: `scripts/manage-installation.mjs`
390
+ - Modify: `scripts/manage-installation.test.mjs`
391
+
392
+ - [ ] **Step 1: Add/finish failing upgrade scenarios**
393
+
394
+ Cover scenarios `8-10`, `22-24`, `34`, `42`, `53-57`, `92`, `103-109`, `126-127`, and `134`. Assert all-or-nothing blockers, exact-match non-adoption, executable modes, baseline policy, source removal, present/missing obsolete preservation, metadata-only rollback point, and no-op distinction.
395
+
396
+ - [ ] **Step 2: Verify RED**
397
+
398
+ ```bash
399
+ node --test --test-name-pattern='S00[8-9]|S010|S02[2-4]|S034|S042|S05[3-7]|S092|S10[3-9]|S12[6-7]|S134' scripts/manage-installation.test.mjs
400
+ ```
401
+
402
+ - [ ] **Step 3: Implement upgrade policy through the generic executor**
403
+
404
+ Require a valid active manifest. Abort the complete plan on owned/unowned/obsolete blockers. Add/update/remove only safe owned entries. Preserve new exact pre-existing files, keep all preserved paths user-owned, and remove obsolete-preserved metadata via manifest-only ownership work without touching targets.
405
+
406
+ - [ ] **Step 4: Run focused and install-regression tests**
407
+
408
+ ```bash
409
+ node --test --test-name-pattern='S00[1-9]|S010|S02[1-4]|S034|S042|S092|S10[3-9]|S126|S127|S134' scripts/manage-installation.test.mjs
410
+ ```
411
+
412
+ Expected: PASS.
413
+
414
+ - [ ] **Step 5: Commit upgrade**
415
+
416
+ ```bash
417
+ git add scripts/manage-installation.mjs scripts/manage-installation.test.mjs
418
+ git commit -m "feat: add conflict-safe managed upgrades"
419
+ ```
420
+
421
+ ### Task 8: Ordinary doctor and deterministic preserved acknowledgement
422
+
423
+ **Files:**
424
+ - Modify: `scripts/manage-installation.mjs`
425
+ - Modify: `scripts/manage-installation.test.mjs`
426
+
427
+ - [ ] **Step 1: Add/finish failing doctor and ACK scenarios**
428
+
429
+ Cover scenarios `21-23`, `41`, `52-57`, `78`, `80`, `90-92`, `108`, and `110-127`, plus `135`. Use `Readable.from()` for exact stdin and captured writable streams for canonical output.
430
+
431
+ Canonical test input must use full lowercase hashes and four-digit octal modes:
432
+
433
+ ```js
434
+ const ack = `ACK-PRESERVED opencode.json ${targetHash} 0644 ${sourceHash} 0644\n`;
435
+ ```
436
+
437
+ - [ ] **Step 2: Verify RED**
438
+
439
+ ```bash
440
+ node --test --test-name-pattern='S02[1-3]|S041|S05[2-7]|S078|S080|S09[0-2]|S108|S11[0-9]|S12[0-7]|S135' scripts/manage-installation.test.mjs
441
+ ```
442
+
443
+ - [ ] **Step 3: Implement ordinary doctor**
444
+
445
+ Keep it lock-free and read-only. Report classifications, locks, transactions, rollback availability, acknowledgement current/historical/absent state, obsolete-preserved cleanup, and exact exit `0/1/2` rules.
446
+
447
+ - [ ] **Step 4: Implement `doctor --accept-preserved`**
448
+
449
+ Print the exact ACK line, read one stdin line, strip only LF, compare byte-for-byte, build the global plan, block unrelated owned drift, allow unrelated preserved warnings, acquire lock, rescan tuple/fingerprint, and commit an `accept-preserved` manifest-only transaction. Preserve `reason`; set baselines and complete acknowledgement with injected clock.
450
+
451
+ - [ ] **Step 5: Run ACK tests**
452
+
453
+ Expected: `yes`, path-only, truncated hashes, EOF, stale tuples, invalid paths, and owned drift leave final state byte-for-byte unchanged; exact non-TTY stdin commits and is rollbackable.
454
+
455
+ - [ ] **Step 6: Commit doctor and acknowledgement**
456
+
457
+ ```bash
458
+ git add scripts/manage-installation.mjs scripts/manage-installation.test.mjs
459
+ git commit -m "feat: diagnose installs and acknowledge preserved merges"
460
+ ```
461
+
462
+ ### Task 9: Uninstall with user-change preservation
463
+
464
+ **Files:**
465
+ - Modify: `scripts/manage-installation.mjs`
466
+ - Modify: `scripts/manage-installation.test.mjs`
467
+
468
+ - [ ] **Step 1: Add/finish failing uninstall scenarios**
469
+
470
+ Cover scenarios `11`, `41`, `70-71`, `77`, `96`, `100`, and wrapper confirmation behavior from scenario `20`. Assert only `owned-unchanged` files are removed, modified/missing/preserved/unrelated files survive, directories are removed only when empty, next manifest is null, and `--yes` changes only prompting.
471
+
472
+ - [ ] **Step 2: Verify RED**
473
+
474
+ ```bash
475
+ node --test --test-name-pattern='S011|S041|S07[0-1]|S077|S096|S100' scripts/manage-installation.test.mjs
476
+ ```
477
+
478
+ - [ ] **Step 3: Implement uninstall planning and execution**
479
+
480
+ Use the same executor with a valid previous manifest and null next manifest. Back up every removed owned file durably, preserve all user states, durably unlink `manifest.json`, retain the committed rollback point, and leave `.oak` for rollback.
481
+
482
+ - [ ] **Step 4: Run uninstall plus upgrade regression tests**
483
+
484
+ Expected: PASS; no preserved or unrelated bytes are changed.
485
+
486
+ - [ ] **Step 5: Commit uninstall**
487
+
488
+ ```bash
489
+ git add scripts/manage-installation.mjs scripts/manage-installation.test.mjs
490
+ git commit -m "feat: uninstall only unchanged owned files"
491
+ ```
492
+
493
+ ### Task 10: Committed rollback and interrupted-operation recovery
494
+
495
+ **Files:**
496
+ - Modify: `scripts/manage-installation.mjs`
497
+ - Modify: `scripts/manage-installation.test.mjs`
498
+
499
+ - [ ] **Step 1: Add/finish rollback and recovery scenarios**
500
+
501
+ Cover scenarios `12-16`, `29-30`, `35`, `40`, `44-51`, `58-60`, `69`, `71`, `77-78`, `93`, `99-102`, `107`, `123`, and `131-133`. Include failpoints in forward apply, inverse apply, manifest publication/removal, rollback candidate transition, lock-holder refresh, and post-commit cleanup.
502
+
503
+ - [ ] **Step 2: Verify RED**
504
+
505
+ ```bash
506
+ node --test --test-name-pattern='S01[2-6]|S02[9]|S030|S035|S040|S04[4-9]|S05[0-1]|S05[8-9]|S060|S069|S071|S07[7-8]|S093|S09[9]|S10[0-2]|S107|S123|S13[1-3]' scripts/manage-installation.test.mjs
507
+ ```
508
+
509
+ - [ ] **Step 3: Implement interrupted-forward recovery**
510
+
511
+ Transition `planned|applying + none` to `rolling-back + interrupted-forward`, resolve backups only from `rollback.next`, validate forward/inverse progress and manifest presence/digest by phase, restore only completed work, retain the earlier committed rollback point, and resume idempotently after inverse interruption.
512
+
513
+ - [ ] **Step 4: Implement committed rollback**
514
+
515
+ Copy the committed journal to active state as `rolling-back + committed-operation`, publish a matching rollback lock, resolve only `rollback/files`, validate current next-manifest presence/digest and operation after-states, inverse operations, restore previous manifest presence, and consume the committed point only after durable completion.
516
+
517
+ Adopt/preserve/obsolete cleanup/acknowledgement rollback changes only manifest ownership metadata.
518
+
519
+ - [ ] **Step 5: Implement cleanup-residue handling**
520
+
521
+ With no active journal, treat `rollback` as the sole committed point and `rollback.next`/`rollback.previous` as doctor exit-`1` residue. Clean residue only under a valid lock after validating the active point; never select residue for rollback.
522
+
523
+ - [ ] **Step 6: Run all manager scenarios**
524
+
525
+ ```bash
526
+ node --test scripts/manage-installation.test.mjs
527
+ ```
528
+
529
+ Expected: all `[S001]` through `[S136]` pass.
530
+
531
+ - [ ] **Step 7: Verify scenario IDs are complete and unique**
532
+
533
+ ```bash
534
+ node - <<'NODE'
535
+ const fs = require('fs');
536
+ const text = fs.readFileSync('scripts/manage-installation.test.mjs', 'utf8');
537
+ const ids = [...text.matchAll(/\[S(\d{3})\]/g)].map((match) => Number(match[1]));
538
+ const expected = Array.from({ length: 136 }, (_, index) => index + 1);
539
+ const counts = new Map(expected.map((id) => [id, 0]));
540
+ for (const id of ids) counts.set(id, (counts.get(id) ?? 0) + 1);
541
+ const mismatches = [...counts].filter(([, count]) => count !== 1);
542
+ if (mismatches.length > 0 || ids.length !== expected.length) {
543
+ throw new Error(`scenario ID occurrence mismatch: ${JSON.stringify(mismatches)}`);
544
+ }
545
+ console.log('manager scenarios 1-136 present exactly once');
546
+ NODE
547
+ ```
548
+
549
+ Expected: `manager scenarios 1-136 present exactly once`.
550
+
551
+ - [ ] **Step 8: Commit rollback and recovery**
552
+
553
+ ```bash
554
+ git add scripts/manage-installation.mjs scripts/manage-installation.test.mjs
555
+ git commit -m "feat: add durable installation rollback and recovery"
556
+ ```
557
+
558
+ ### Task 11: Public shell wrappers and repository checks
559
+
560
+ **Files:**
561
+ - Modify: `install.sh`
562
+ - Modify: `uninstall.sh`
563
+ - Create: `upgrade.sh`
564
+ - Create: `doctor.sh`
565
+ - Create: `rollback.sh`
566
+ - Modify: `scripts/check.sh`
567
+ - Modify: `package.json`
568
+ - Test: `scripts/manage-installation.test.mjs`
569
+
570
+ - [ ] **Step 1: Add failing wrapper contract tests**
571
+
572
+ For each wrapper assert help, unknown arguments, missing values, target precedence, exit propagation, and absence of lifecycle logic. Execute wrappers only for this small contract set.
573
+
574
+ - [ ] **Step 2: Verify wrapper tests fail**
575
+
576
+ ```bash
577
+ node --test --test-name-pattern='wrapper|S020' scripts/manage-installation.test.mjs
578
+ ```
579
+
580
+ - [ ] **Step 3: Replace/create thin wrappers**
581
+
582
+ Each wrapper follows this exact shape, substituting its command:
583
+
584
+ ```bash
585
+ #!/usr/bin/env bash
586
+ set -euo pipefail
587
+
588
+ root="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
589
+ exec node "$root/scripts/manage-installation.mjs" install "$@"
590
+ ```
591
+
592
+ Set all five wrappers executable. No wrapper parses ownership, hashes, manifests, or paths.
593
+
594
+ - [ ] **Step 4: Update package and repository checks**
595
+
596
+ Change:
597
+
598
+ ```json
599
+ "unit-and-script-tests": "node --test scripts/*.test.mjs opencode/scripts/*.test.mjs"
600
+ ```
601
+
602
+ Add the engine, manager test, and wrappers to `required_files` in `scripts/check.sh`; require executable mode for all wrappers and `scripts/check.sh`. Do not require `.mjs` files to be executable.
603
+
604
+ - [ ] **Step 5: Run wrapper/static checks**
605
+
606
+ ```bash
607
+ bash -n install.sh uninstall.sh upgrade.sh doctor.sh rollback.sh scripts/check.sh scripts/install-smoke.sh
608
+ npm run contract-check
609
+ npm run unit-and-script-tests
610
+ ```
611
+
612
+ Expected: shell syntax clean, harness check passes, existing 102 tests plus all manager tests pass.
613
+
614
+ - [ ] **Step 6: Commit wrappers and checks**
615
+
616
+ ```bash
617
+ git add install.sh uninstall.sh upgrade.sh doctor.sh rollback.sh scripts/check.sh package.json scripts/manage-installation.test.mjs
618
+ git commit -m "feat: expose managed installation lifecycle commands"
619
+ ```
620
+
621
+ ### Task 12: Real temporary lifecycle smoke
622
+
623
+ **Files:**
624
+ - Modify: `scripts/install-smoke.sh`
625
+
626
+ - [ ] **Step 1: Extend the smoke script and verify initial failure**
627
+
628
+ Use separate source fixtures only when testing upgrade payload changes; never mutate the checked-out `opencode/` tree. The primary smoke sequence is:
629
+
630
+ ```text
631
+ install --target TMP/target
632
+ doctor --target TMP/target
633
+ upgrade --dry-run --target TMP/target
634
+ uninstall --yes --target TMP/target
635
+ rollback --target TMP/target
636
+ doctor --target TMP/target
637
+ ```
638
+
639
+ Keep the installed `npm ci`, `check-harness.mjs`, and `@opencode-ai/plugin` import checks.
640
+
641
+ - [ ] **Step 2: Run smoke before completing assertions**
642
+
643
+ ```bash
644
+ npm run installation-smoke
645
+ ```
646
+
647
+ Expected: FAIL until the lifecycle assertions and wrapper behavior agree.
648
+
649
+ - [ ] **Step 3: Finish bounded smoke assertions**
650
+
651
+ Assert manifest/rollback state at each phase, final restored managed installation, and no files outside the `mktemp` root. Cleanup must validate its explicit root before recursive removal.
652
+
653
+ - [ ] **Step 4: Run smoke and release-path checks**
654
+
655
+ ```bash
656
+ npm run installation-smoke
657
+ npm run check
658
+ ```
659
+
660
+ Expected: both pass.
661
+
662
+ - [ ] **Step 5: Commit smoke coverage**
663
+
664
+ ```bash
665
+ git add scripts/install-smoke.sh
666
+ git commit -m "test: cover complete installation lifecycle smoke"
667
+ ```
668
+
669
+ ### Task 13: User documentation
670
+
671
+ **Files:**
672
+ - Modify: `README.md:227-371`
673
+ - Modify: `README.md:515-600`
674
+ - Modify: `docs/installation.md:1-61`
675
+
676
+ - [ ] **Step 1: Update README lifecycle overview**
677
+
678
+ Document command examples, dry-run-first workflow, `.oak/manifest.json` ownership, protected-root behavior, exact-match adoption differences between install and upgrade, conflict resolution, `doctor --accept-preserved` ACK input, obsolete-preserved cleanup, uninstall preservation, one-generation rollback, and interrupted recovery.
679
+
680
+ - [ ] **Step 2: Rewrite the detailed installation guide**
681
+
682
+ Include exact syntax and exit semantics for all five wrappers, default target precedence, legacy installation handling, `--force` limits, doctor exit `0/1/2`, manifest-only operations, recovery steps, and a warning not to delete `.oak` manually.
683
+
684
+ - [ ] **Step 3: Check documentation against wrapper help**
685
+
686
+ ```bash
687
+ ./install.sh --help
688
+ ./upgrade.sh --help
689
+ ./doctor.sh --help
690
+ ./uninstall.sh --help
691
+ ./rollback.sh --help
692
+ ```
693
+
694
+ Expected: documented syntax matches output exactly.
695
+
696
+ - [ ] **Step 4: Run public leak and whitespace checks**
697
+
698
+ ```bash
699
+ git diff --check
700
+ bash scripts/check.sh
701
+ ```
702
+
703
+ Expected: no whitespace errors, the repository's canonical public-data scan reports no private data, and all harness contracts pass.
704
+
705
+ - [ ] **Step 5: Commit docs**
706
+
707
+ ```bash
708
+ git add README.md docs/installation.md
709
+ git commit -m "docs: explain safe installation lifecycle"
710
+ ```
711
+
712
+ ### Task 14: Full verification and independent reviews
713
+
714
+ **Files:**
715
+ - Review all Slice 1.2 implementation files; modify only to address confirmed findings.
716
+
717
+ - [ ] **Step 1: Run focused manager tests**
718
+
719
+ ```bash
720
+ node --test scripts/manage-installation.test.mjs
721
+ ```
722
+
723
+ Expected: scenarios `1-136` pass.
724
+
725
+ - [ ] **Step 2: Run repository validation**
726
+
727
+ ```bash
728
+ npm run check
729
+ ```
730
+
731
+ Expected: contract check, existing tests, and manager tests pass.
732
+
733
+ - [ ] **Step 3: Run release validation**
734
+
735
+ ```bash
736
+ npm run check:release
737
+ ```
738
+
739
+ Expected: clean dependency install, all tests, typecheck, dependency audit at the existing threshold, and lifecycle smoke pass.
740
+
741
+ - [ ] **Step 4: Run static safety checks**
742
+
743
+ ```bash
744
+ bash -n install.sh uninstall.sh upgrade.sh doctor.sh rollback.sh scripts/check.sh scripts/install-smoke.sh
745
+ git diff --check
746
+ git status --short
747
+ ```
748
+
749
+ Expected: syntax and whitespace clean; status lists only intentional Slice 1.2 changes plus any explicitly preserved baseline files.
750
+
751
+ - [ ] **Step 5: Prove a blocking conflict performs no writes**
752
+
753
+ Run the focused scenario for modified-owned upgrade and compare a recursive fixture snapshot before/after.
754
+
755
+ Expected: target bytes, modes, manifest, journal, rollback state, and directory entries are identical.
756
+
757
+ - [ ] **Step 6: Run public leak scan**
758
+
759
+ ```bash
760
+ bash scripts/check.sh
761
+ ```
762
+
763
+ Expected: the repository's canonical public-data scan reports no private data and all harness contracts pass.
764
+
765
+ - [ ] **Step 7: Request independent implementation review**
766
+
767
+ Use `superpowers:requesting-code-review`. Ask the reviewer to compare the complete diff against the approved spec, with focus on ownership, destructive-path safety, backup confidentiality, lock recovery, manifest presence/digests, and tests.
768
+
769
+ - [ ] **Step 8: Address confirmed review findings with focused RED/GREEN tests**
770
+
771
+ Do not broaden scope or weaken assertions. Re-run Steps 1-6 after every fix batch.
772
+
773
+ - [ ] **Step 9: Request final diff review**
774
+
775
+ Require an explicit ready/not-ready verdict and report any validation not run.
776
+
777
+ - [ ] **Step 10: Prepare the final handoff without publishing**
778
+
779
+ Report files, commits, tests, smoke evidence, review verdict, residual risks, and working-tree status. Do not push, tag, release, or modify private OpenCode configuration without a separate user request.