@frankzhang2026/opencode-android-orchestrator 0.1.0 → 0.2.0

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 (124) hide show
  1. package/CHANGELOG.md +75 -2
  2. package/LICENSE +21 -0
  3. package/README.md +391 -6
  4. package/THIRD_PARTY_NOTICES.md +119 -0
  5. package/dist/cli.js +243 -1
  6. package/dist/cli.js.map +1 -1
  7. package/dist/compatibility/hooks.d.ts +23 -0
  8. package/dist/compatibility/hooks.d.ts.map +1 -0
  9. package/dist/compatibility/hooks.js +44 -0
  10. package/dist/compatibility/hooks.js.map +1 -0
  11. package/dist/compatibility/versions.d.ts +19 -0
  12. package/dist/compatibility/versions.d.ts.map +1 -1
  13. package/dist/compatibility/versions.js +116 -0
  14. package/dist/compatibility/versions.js.map +1 -1
  15. package/dist/doctor/index.d.ts +36 -0
  16. package/dist/doctor/index.d.ts.map +1 -0
  17. package/dist/doctor/index.js +289 -0
  18. package/dist/doctor/index.js.map +1 -0
  19. package/dist/doctor/installation.d.ts +4 -0
  20. package/dist/doctor/installation.d.ts.map +1 -0
  21. package/dist/doctor/installation.js +472 -0
  22. package/dist/doctor/installation.js.map +1 -0
  23. package/dist/index.d.ts +13 -2
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +13 -2
  26. package/dist/index.js.map +1 -1
  27. package/dist/installer/adaptive-templates.d.ts +56 -0
  28. package/dist/installer/adaptive-templates.d.ts.map +1 -0
  29. package/dist/installer/adaptive-templates.js +167 -0
  30. package/dist/installer/adaptive-templates.js.map +1 -0
  31. package/dist/installer/agents-config.d.ts +19 -0
  32. package/dist/installer/agents-config.d.ts.map +1 -0
  33. package/dist/installer/agents-config.js +147 -0
  34. package/dist/installer/agents-config.js.map +1 -0
  35. package/dist/installer/android-project.d.ts +36 -0
  36. package/dist/installer/android-project.d.ts.map +1 -0
  37. package/dist/installer/android-project.js +418 -0
  38. package/dist/installer/android-project.js.map +1 -0
  39. package/dist/installer/index.d.ts +8 -0
  40. package/dist/installer/index.d.ts.map +1 -1
  41. package/dist/installer/index.js +8 -1
  42. package/dist/installer/index.js.map +1 -1
  43. package/dist/installer/init.d.ts +67 -0
  44. package/dist/installer/init.d.ts.map +1 -0
  45. package/dist/installer/init.js +389 -0
  46. package/dist/installer/init.js.map +1 -0
  47. package/dist/installer/install-manifest.d.ts +132 -0
  48. package/dist/installer/install-manifest.d.ts.map +1 -0
  49. package/dist/installer/install-manifest.js +1047 -0
  50. package/dist/installer/install-manifest.js.map +1 -0
  51. package/dist/installer/opencode-config.d.ts +31 -0
  52. package/dist/installer/opencode-config.d.ts.map +1 -0
  53. package/dist/installer/opencode-config.js +296 -0
  54. package/dist/installer/opencode-config.js.map +1 -0
  55. package/dist/installer/uninstall.d.ts +70 -0
  56. package/dist/installer/uninstall.d.ts.map +1 -0
  57. package/dist/installer/uninstall.js +770 -0
  58. package/dist/installer/uninstall.js.map +1 -0
  59. package/dist/installer/upgrade.d.ts +96 -0
  60. package/dist/installer/upgrade.d.ts.map +1 -0
  61. package/dist/installer/upgrade.js +1106 -0
  62. package/dist/installer/upgrade.js.map +1 -0
  63. package/dist/opencode-plugin.d.ts +2 -0
  64. package/dist/opencode-plugin.d.ts.map +1 -0
  65. package/dist/opencode-plugin.js +4 -0
  66. package/dist/opencode-plugin.js.map +1 -0
  67. package/dist/plugin/index.d.ts +7 -2
  68. package/dist/plugin/index.d.ts.map +1 -1
  69. package/dist/plugin/index.js +23 -6
  70. package/dist/plugin/index.js.map +1 -1
  71. package/dist/tools/index.d.ts +35 -1
  72. package/dist/tools/index.d.ts.map +1 -1
  73. package/dist/tools/index.js +197 -1
  74. package/dist/tools/index.js.map +1 -1
  75. package/docs/MIGRATION.md +173 -0
  76. package/docs/SECURITY.md +212 -0
  77. package/docs/TROUBLESHOOTING.md +172 -0
  78. package/package.json +23 -5
  79. package/templates/.opencode/agents/scheduled-coder.md +115 -0
  80. package/templates/.opencode/agents/scheduled-planner.md +166 -0
  81. package/templates/.opencode/agents/scheduled-reviewer.md +88 -0
  82. package/templates/.opencode/commands/abort-task.md +20 -0
  83. package/templates/.opencode/commands/acceptance.md +20 -0
  84. package/templates/.opencode/commands/change.md +23 -0
  85. package/templates/.opencode/commands/resume-review.md +19 -0
  86. package/templates/.opencode/skills/scheduled-quality-coder/SKILL.md +93 -0
  87. package/templates/.opencode/skills/scheduled-quality-orchestrator/SKILL.md +216 -0
  88. package/templates/.opencode/skills/scheduled-quality-reviewer/SKILL.md +68 -0
  89. package/templates/AGENTS.md.fragment +19 -0
  90. package/templates/README.md +52 -9
  91. package/templates/automation/config.json +50 -0
  92. package/templates/automation/config.schema.json +163 -0
  93. package/templates/automation/task-contract.schema.json +71 -0
  94. package/templates/automation/tasks/TASK-TEMPLATE.json.example +53 -0
  95. package/templates/docs/plans/README.md +26 -0
  96. package/templates/installation-manifest.schema.json +201 -0
  97. package/templates/scripts/automation/abort-task.sh +171 -0
  98. package/templates/scripts/automation/accept-and-integrate.sh +263 -0
  99. package/templates/scripts/automation/acceptance-report.sh +132 -0
  100. package/templates/scripts/automation/approve-and-run.sh +175 -0
  101. package/templates/scripts/automation/begin-review.sh +18 -0
  102. package/templates/scripts/automation/block-task.sh +26 -0
  103. package/templates/scripts/automation/claim-task.sh +74 -0
  104. package/templates/scripts/automation/integration-scope-gate.sh +103 -0
  105. package/templates/scripts/automation/lib.sh +697 -0
  106. package/templates/scripts/automation/orchestrate-task.sh +119 -0
  107. package/templates/scripts/automation/preflight.sh +206 -0
  108. package/templates/scripts/automation/prepare-contract-review.sh +101 -0
  109. package/templates/scripts/automation/quality-gate.sh +72 -0
  110. package/templates/scripts/automation/queue-task.sh +35 -0
  111. package/templates/scripts/automation/record-red.sh +57 -0
  112. package/templates/scripts/automation/resume-review-fix.sh +32 -0
  113. package/templates/scripts/automation/resume-review.sh +120 -0
  114. package/templates/scripts/automation/scope-gate.sh +110 -0
  115. package/templates/scripts/automation/select-task.sh +34 -0
  116. package/templates/scripts/automation/shadow-run.sh +24 -0
  117. package/templates/scripts/automation/show-acceptance-review.sh +111 -0
  118. package/templates/scripts/automation/status.sh +125 -0
  119. package/templates/scripts/automation/submit-review.sh +73 -0
  120. package/templates/scripts/automation/tests/run-tests.sh +699 -0
  121. package/templates/scripts/automation/transition-state.sh +21 -0
  122. package/templates/scripts/automation/validate-contract.sh +87 -0
  123. package/templates/scripts/automation/verify-integration.sh +37 -0
  124. package/templates/scripts/automation/verify-task.sh +54 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,78 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ ## 0.2.0 - Unreleased
4
4
 
5
- - Create the initial private TypeScript/npm plugin scaffold.
5
+ - Add the complete MIT license, packaged third-party notices, public repository
6
+ metadata, draft release notes, and a fail-closed `0.2.0` authorization record.
7
+ - Keep the package root plugin-only for OpenCode's loader and expose lifecycle
8
+ and diagnostic APIs from the explicit `./api` subpath.
9
+ - Keep shadow-run diagnostics on stderr so stdout remains one strict JSON
10
+ document for installer verification and automation consumers.
11
+ - Restrict the plugin implementation to OpenCode APIs shared by `1.14.22` and
12
+ `1.15.13`.
13
+ - Add certified OpenCode version detection and a functional `doctor` command.
14
+ - Add Git, Android module, Gradle DSL, custom module directory, version catalog,
15
+ and Gradle Wrapper discovery.
16
+ - Add Kotlin DSL, Groovy DSL, compatibility, and doctor tests.
17
+ - Migrate the audited V3 agents, commands, and scheduled-quality skills as
18
+ project-independent installation templates.
19
+ - Migrate all 28 audited V3 automation Shell files while preserving their
20
+ executable modes and nested test-runner path.
21
+ - Migrate the remaining V3 configuration, Schemas, task example, and plan guide,
22
+ and add a bounded AGENTS managed-block template.
23
+ - Add a safe, idempotent OpenCode JSON/JSONC configuration merge planner that
24
+ retains comments, formatting, existing fields, plugin order, and options.
25
+ - Pin the installed Superpowers and orchestrator references, and reject
26
+ ambiguous files, symbolic links, malformed configuration, duplicates, and
27
+ managed-plugin version conflicts.
28
+ - Add a read-only adaptive template planner that derives the project name,
29
+ modules, namespaces/application IDs, protected Gradle files, source-set
30
+ paths, and focused-test placeholder without writing the target repository.
31
+ - Make agent permissions and deterministic scope gates work with detected
32
+ Android module directories, including custom `projectDir` mappings.
33
+ - Remove the legacy Scheduler dependency, project-specific identifiers, and
34
+ local absolute paths from all shipped templates.
35
+ - Treat absent legacy Scheduler tools as disabled during OpenCode discovery
36
+ while retaining explicit deny rules and rejecting any enabled tool.
37
+ - Add the installation transaction foundation with verified pre-install
38
+ backups, a portable versioned manifest Schema, per-file SHA-256/size/mode and
39
+ recovery metadata, fail-closed plan validation, integrity reporting,
40
+ installed-state completion, and guarded prepared-state rollback.
41
+ - Add read-only, structured managed-file conflict reporting and make
42
+ installation planning reject differing `copy`/`generate` content and all
43
+ requested changes to existing file modes before writing control state.
44
+ - Implement `init` with the complete 45-file project resource plan, adaptive
45
+ Kotlin/Groovy output, lossless OpenCode JSON/JSONC and bounded AGENTS merges,
46
+ executable-mode preservation, and unchanged-installation idempotence.
47
+ - Add pre-write OpenCode, Android, Gradle Wrapper, toolchain, Java, and SDK
48
+ gates, then require the 38 automation tests and a mutation-free shadow run
49
+ before completing the manifest; verification failures roll back originals.
50
+ - Complete the read-only installed-state `doctor` with command and SDK
51
+ discovery, exact manifest/package inventory validation, packaged-template
52
+ authentication, separate managed-content and permission checks, backup
53
+ integrity, semantic configuration checks, JSON output, and failure exit
54
+ codes.
55
+ - Implement `upgrade` with semantic-version and same-version guards, immutable
56
+ managed-file and original-backup checks, reconstruction of merged files from
57
+ first-install originals, immediate recovery snapshots, preserved recovery
58
+ lineage, obsolete-resource restoration, transactional manifest replacement,
59
+ upgrade history, idempotence, and automatic whole-version rollback when the
60
+ automation or shadow verification fails.
61
+ - Implement `uninstall` with read-only planning, exact content/size/mode guards,
62
+ verified restoration of first-install originals, removal of unchanged
63
+ plugin-created files, retention and reporting of user drift, cross-transaction
64
+ markers, recovery/history evidence, JSON output, and automatic pre-commit
65
+ rollback.
66
+ - Add project-bounded `android_orchestrator_status` and
67
+ `android_orchestrator_doctor` custom tools with strict task IDs, authenticated
68
+ fixed-script execution, bounded and validated JSON output, default-deny agent
69
+ permissions, and preflight discovery checks.
70
+ - Add packaged migration, troubleshooting, and security guides; expand the
71
+ README with fixed-version prerequisites, a post-release quick start, the
72
+ exact 45-resource installation inventory, workflow entry points, and links to
73
+ operational recovery guidance.
74
+
75
+ ## 0.1.0 - 2026-08-20
76
+
77
+ - Publish the initial TypeScript/npm scaffold. The lifecycle commands and V3
78
+ installation templates were not implemented in this release.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 frankzhang2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,24 +2,409 @@
2
2
 
3
3
  Reusable OpenCode orchestration for macOS Android projects.
4
4
 
5
+ > **Release warning:** `0.2.0` is still an unpublished development version.
6
+ > Do not run the `npx` examples against a production repository until the
7
+ > release and two-version acceptance gates are complete. Published `0.1.0` is
8
+ > an early scaffold without a working installer.
9
+
10
+ ## Documentation
11
+
12
+ - [Migration guide](docs/MIGRATION.md) — choose the correct path for the
13
+ `0.1.0` scaffold, a manually copied V3 setup, or a manifest-managed install.
14
+ - [Troubleshooting](docs/TROUBLESHOOTING.md) — diagnose CLI failures, resource
15
+ drift, OpenCode discovery, blocked tasks, and recovery evidence.
16
+ - [Security model](docs/SECURITY.md) — trust boundaries, approval guarantees,
17
+ file/Git protections, retained evidence, and residual risks.
18
+ - [Third-party notices](THIRD_PARTY_NOTICES.md) — runtime, peer, external
19
+ companion, and development-only dependency relationships and licenses.
20
+
21
+ ## Requirements
22
+
23
+ - macOS with Node.js/npm for `npx` or the packaged CLI;
24
+ - OpenCode `1.14.22` or `1.15.13` for a certified configuration (the declared
25
+ compatibility range is `>=1.14.22 <1.16.0`);
26
+ - a Git-backed Android Gradle project with `settings.gradle[.kts]` and an
27
+ executable `gradlew`;
28
+ - `git`, `jq`, `rg`, `shasum`, and Java on `PATH`;
29
+ - an Android SDK resolved from `ANDROID_HOME`, `ANDROID_SDK_ROOT`, or
30
+ `local.properties` `sdk.dir`.
31
+
32
+ Run lifecycle commands from the project root or a directory below it. Use a
33
+ clean branch and preserve an independent backup before the first installation,
34
+ even though the installer maintains its own verified recovery data.
35
+
36
+ ## Quick start after release
37
+
38
+ ```sh
39
+ npx @frankzhang2026/opencode-android-orchestrator@0.2.0 init .
40
+ npx @frankzhang2026/opencode-android-orchestrator@0.2.0 doctor .
41
+ opencode --agent scheduled-planner .
42
+ ```
43
+
44
+ If more than one Android application module is detected, select the intended
45
+ primary module explicitly:
46
+
47
+ ```sh
48
+ npx @frankzhang2026/opencode-android-orchestrator@0.2.0 init . \
49
+ --primary-module :mobile
50
+ ```
51
+
52
+ The install transaction manages 45 project-local paths:
53
+
54
+ | Resource group | Count | Installation behavior |
55
+ | --- | ---: | --- |
56
+ | Scheduled agents, commands, and skills | 10 | Copy exact audited templates. |
57
+ | Deterministic automation Shell files | 28 | Copy exact templates with `0755` modes. |
58
+ | Schemas and plan authoring guide | 3 | Copy fixed supporting resources. |
59
+ | Android automation config and task example | 2 | Generate from detected modules. |
60
+ | `AGENTS.md` and OpenCode JSON/JSONC | 2 | Merge bounded content without replacing unrelated settings. |
61
+
62
+ After installation, start the `scheduled-planner` and use its interactive flow.
63
+ The `/acceptance <TASK-ID>`, `/resume-review <TASK-ID>`, and
64
+ `/abort-task <TASK-ID>` commands are recovery/re-entry points; they do not
65
+ replace the required fresh approval controls. The workflow never pushes and
66
+ does not register Scheduler or launchd jobs.
67
+
5
68
  ## Status
6
69
 
7
- This repository currently contains only the TypeScript/npm scaffold. The
8
- installer lifecycle and the verified Android orchestration V3 templates have
9
- not been migrated yet. The package metadata is configured for public
10
- publication under the `@frankzhang2026` npm scope.
70
+ Version `0.1.0` was published as an early scaffold and does not provide a
71
+ working installer. Development now targets `0.2.0`; it must not be published
72
+ until the installer lifecycle and release gates are complete.
73
+
74
+ The cross-version plugin entry, OpenCode version doctor, Android/Gradle project
75
+ discovery, audited V3 resources, and all deterministic V3 Shell transactions
76
+ are implemented. Read-only planning now renders project-relative automation
77
+ configuration and a focused task example from the detected Android modules.
78
+ Safe, comment-preserving OpenCode JSON/JSONC merge planning is also implemented.
79
+ The installation transaction foundation now creates verified pre-install
80
+ backups and a versioned SHA-256 manifest. Read-only conflict analysis and the
81
+ installation-plan conflict gate are also implemented. The `init` command now
82
+ installs and verifies the complete project-local resource set. The read-only
83
+ `doctor` command now verifies the installed toolchain, manifest, resources,
84
+ permissions, backups, and configuration. The `upgrade` command now replaces
85
+ only unchanged managed resources, carries original pre-install backups
86
+ forward, and restores the complete previous installation if verification
87
+ fails. The `uninstall` command now restores unchanged original files, removes
88
+ unchanged plugin-created files, and retains any content, permission, or
89
+ deletion drift for manual review. Version `0.2.0` is still local-only and has
90
+ not passed the release gates.
91
+
92
+ Implemented checks include:
11
93
 
12
- ## Planned usage
94
+ - OpenCode `1.14.22` and `1.15.13` certification, with guarded support for
95
+ versions in the declared `>=1.14.22 <1.16.0` range
96
+ - Git root and Gradle settings discovery from the project root or a module
97
+ directory
98
+ - project name, Kotlin/Groovy DSL, Android namespace/application ID,
99
+ multi-module, custom `projectDir`, version-catalog plugin aliases, and Gradle
100
+ Wrapper detection
101
+ - a plugin compatibility boundary restricted to API fields and hooks shared
102
+ by both certified OpenCode versions
103
+ - project-independent templates for the three V3 agents, four commands, and
104
+ three scheduled-quality skills
105
+ - all 28 automation Bash files with their `0755` modes; scope and test-change
106
+ gates consume detected source-set paths instead of a fixed module name
107
+ - a portable automation configuration source, both Schemas, contract example,
108
+ plan guide, and bounded AGENTS managed block
109
+ - adaptive configuration for every detected Android module, an unambiguous or
110
+ explicitly selected primary module, exact protected build files, production
111
+ and test source sets, and a namespace-aware focused-test placeholder
112
+ - removal of the legacy Scheduler dependency and all local absolute paths from
113
+ shipped templates
114
+ - read-only `opencode.json`/`opencode.jsonc` merge planning that preserves
115
+ existing fields, comments, plugin order, and plugin options while adding
116
+ fixed Superpowers and orchestrator references
117
+ - conflict guards for malformed or ambiguous configuration, duplicate plugin
118
+ packages, different managed-plugin references, and symbolic links
119
+ - a fail-closed installation preparation transaction that records package
120
+ version, source, strategy, desired SHA-256/size/mode, and original-file
121
+ backup metadata in `.automation-plugin/manifest.json`
122
+ - backup-before-manifest publication, stale/tampered plan rejection, backup and
123
+ installed-file integrity reporting, installed-state completion, and guarded
124
+ rollback of a prepared transaction
125
+ - read-only conflict reports with existing and desired hashes, sizes, modes,
126
+ source, and strategy; installation planning fails closed before any write
127
+ when `copy`/`generate` content or an existing file mode would be changed
128
+ - a write-capable `init` transaction that installs 45 managed files, preserves
129
+ Shell executable modes, merges OpenCode JSON/JSONC and one bounded AGENTS
130
+ block, and is byte-idempotent for an unchanged installed version
131
+ - write-before-complete verification using the 38-case automation suite and a
132
+ read-only shadow run; any failure restores original files before reporting
133
+ the error
134
+ - an installation-aware, read-only doctor that authenticates the 45-file
135
+ inventory against packaged templates, separates content and permission
136
+ drift, verifies original-file backups, and semantically checks the OpenCode,
137
+ AGENTS, adaptive Android, and task-example configuration
138
+ - a fail-closed `upgrade` transaction that rejects managed-file or original
139
+ backup drift, preserves the first installation's recovery state, records an
140
+ immediate pre-upgrade snapshot and history, restores obsolete user files,
141
+ reruns both post-write verifiers, and rolls the whole old version back on
142
+ failure
143
+ - a transactional `uninstall` that validates the installed manifest, restores
144
+ verified first-install originals, removes only exact managed-file matches,
145
+ retains content, permission, and deletion drift, records recovery/history
146
+ evidence, and automatically restores the installed state on pre-commit
147
+ failure
148
+
149
+ The planners deliberately avoid filesystem writes. The adaptive planner also
150
+ blocks ambiguous primary modules, paths outside the Git root, and nested Gradle
151
+ roots that the current root-relative transaction scripts cannot safely run.
152
+ The transaction layer writes only installer control state and recovery
153
+ evidence until `init`, `upgrade`, or `uninstall` explicitly applies a validated
154
+ plan.
155
+
156
+ ## Adaptive template planning
157
+
158
+ ```js
159
+ import {
160
+ planAdaptiveProjectTemplates,
161
+ } from "@frankzhang2026/opencode-android-orchestrator";
162
+
163
+ const plan = planAdaptiveProjectTemplates("/path/to/android-project", {
164
+ primaryModule: ":mobile", // optional when exactly one application is found
165
+ });
166
+
167
+ console.log(plan.automationConfigContent);
168
+ console.log(plan.taskContractExampleContent);
169
+ ```
170
+
171
+ The returned JSON contains repository-relative paths only. This API plans
172
+ content in memory; it does not create or modify target-project files.
173
+
174
+ ## Conflict policy
175
+
176
+ `detectInstallationConflicts` is read-only and returns conflicts sorted by
177
+ target path. Missing files and files whose content and effective mode already
178
+ match are safe. Existing `copy`/`generate` files with different content are
179
+ conflicts, as is any requested mode change. `planInstallationPreparation`
180
+ enforces the same policy and throws `FILE_CONFLICT` before creating installer
181
+ control state; there is no silent-overwrite option.
182
+
183
+ The `merge` strategy permits a content difference only when the caller has
184
+ already produced the desired content with a structure-aware merge planner,
185
+ such as the OpenCode JSON/JSONC merger. It preserves the existing mode by
186
+ default, and an explicit mode change still conflicts. Backup preparation then
187
+ rechecks the planned original hash, size, and mode to close the gap between
188
+ conflict analysis and the first write.
189
+
190
+ ## Installation preparation transaction
191
+
192
+ `planInstallationPreparation` snapshots every managed path in memory.
193
+ `prepareInstallationBackup` then verifies that the plan is unchanged, writes
194
+ original files below `.automation-plugin/backups/<installation-id>/`, verifies
195
+ their hashes and modes, and only then publishes a `prepared` manifest. A caller
196
+ may mark it `installed` only after every desired file matches the manifest.
197
+ `rollbackPreparedInstallation` restores originals and removes newly created
198
+ files only when their hashes still match a safe prepared state.
199
+
200
+ This API is the transaction foundation used by `init`. Callers must not treat
201
+ preparation alone as resource installation;
202
+ `applyInstallationPlan` performs the guarded write and completion transaction.
203
+
204
+ ## Init
13
205
 
14
206
  ```sh
15
- npx @frankzhang2026/opencode-android-orchestrator@0.1.0 init .
207
+ npx @frankzhang2026/opencode-android-orchestrator@0.2.0 init .
16
208
  opencode --agent scheduled-planner .
17
209
  ```
18
210
 
211
+ For a multi-application project, select the primary module explicitly:
212
+
213
+ ```sh
214
+ opencode-android-orchestrator init . --primary-module :mobile
215
+ ```
216
+
217
+ Before writing, `init` requires a compatible OpenCode version, a Git-backed
218
+ Android Gradle project, an executable Gradle Wrapper, `git`, `jq`, `rg`,
219
+ `shasum`, Java, and an Android SDK directory from `ANDROID_HOME` or
220
+ `ANDROID_SDK_ROOT`. It then:
221
+
222
+ 1. renders project-specific configuration and plans both safe merges;
223
+ 2. rejects all unresolved content or mode conflicts;
224
+ 3. backs up every existing managed path and publishes a `prepared` manifest;
225
+ 4. writes missing or approved merged files with verified hashes and modes;
226
+ 5. runs the 38 automation tests and `shadow-run.sh`;
227
+ 6. marks the manifest `installed` only after both checks pass.
228
+
229
+ Verification failure automatically restores originals and records rollback
230
+ history; recovery backups remain below `.automation-plugin/backups/`. Repeating
231
+ `init` on an unchanged, healthy installation performs no managed-file writes.
232
+
233
+ Version `0.2.0` has not been published, so the `npx` example is the intended
234
+ post-release command rather than an instruction to publish or switch a live
235
+ project now.
236
+
237
+ ## Doctor
238
+
239
+ ```sh
240
+ opencode-android-orchestrator doctor /path/to/android-project
241
+ opencode-android-orchestrator doctor /path/to/android-project --json
242
+ ```
243
+
244
+ The command exits unsuccessfully when OpenCode is missing or incompatible,
245
+ the target is not a Git Android project, the Gradle Wrapper or a required
246
+ command is unavailable, the SDK cannot be resolved, or any installed state is
247
+ unhealthy. SDK lookup uses an explicit API option, `ANDROID_HOME`,
248
+ `ANDROID_SDK_ROOT`, then `local.properties` `sdk.dir`; an existing SDK root
249
+ without detectable `platforms` or `build-tools` is reported as a warning.
250
+
251
+ Installation checks are deliberately read-only and cover:
252
+
253
+ - manifest schema, installed state, fixed package version, `0600` mode, exact
254
+ 45-file inventory, sources, strategies, and packaged-template hashes;
255
+ - each managed file's SHA-256, size, and mode, including all 28 executable
256
+ automation scripts;
257
+ - every original-file backup required for future recovery;
258
+ - pinned OpenCode and Superpowers references, the exact bounded AGENTS block,
259
+ and adaptive automation/task configuration against the currently detected
260
+ Android modules.
261
+
262
+ Human output and `--json` expose the same checks. Exit code `0` means there are
263
+ no failures (`warn` is allowed), `1` means at least one check failed, and `2`
264
+ means the CLI arguments were invalid. Doctor reports drift but never repairs or
265
+ rewrites the project.
266
+
267
+ ## Read-only OpenCode tools
268
+
269
+ Loading the plugin registers two project-scoped custom tools:
270
+
271
+ - `android_orchestrator_status` accepts one required `taskId` matching
272
+ `TASK-[A-Z0-9-]+` and returns the task contract, runtime state, and evidence
273
+ as JSON;
274
+ - `android_orchestrator_doctor` accepts no arguments and returns the complete
275
+ project, dependency, SDK, and installation report as JSON.
276
+
277
+ Both tools reject a call whose runtime context is outside the worktree that
278
+ loaded the plugin. Before `status` invokes anything, it authenticates the
279
+ installed manifest, managed-resource hashes, and executable modes against the
280
+ packaged version. It then invokes only the fixed
281
+ `scripts/automation/status.sh` path, passes the validated task ID as a separate
282
+ shell expression, bounds the output to 1 MiB, and verifies that the returned
283
+ contract ID matches the request. Neither tool asks for permission or writes
284
+ project state. The installed planner, coder, and reviewer agents explicitly
285
+ allow these two tool names while retaining their default-deny policy; source
286
+ preflight verifies both resolved permissions and tool discovery.
287
+
288
+ ### Phase 2 mutating-tool decision
289
+
290
+ The 2026-08-25 evaluation is **NO-GO for mutating custom tools in `0.2.0`**.
291
+ The fixed Shell allowlist remains the only entry point for state transitions,
292
+ Git mutations, and agent launches. OpenCode custom tools provide typed arguments
293
+ and workspace context, but a normal permission prompt is not the workflow's
294
+ fresh semantic approval: permission requests can be approved for the rest of a
295
+ session and can be auto-approved unless explicitly denied. In addition, the
296
+ certified SDK declarations disagree on `ToolContext.ask` (`Effect.Effect<void>`
297
+ in `1.14.22`, `Promise<void>` in `1.15.13`), so it is not part of this plugin's
298
+ two-version common execution surface. See the OpenCode documentation for
299
+ [custom-tool context](https://opencode.ai/docs/custom-tools) and
300
+ [permission behavior](https://opencode.ai/docs/permissions/).
301
+
302
+ | Existing entry point | Material effects | Decision before a later phase |
303
+ | --- | --- | --- |
304
+ | `prepare-contract-review.sh` | Writes approval/origin evidence and initializes `CONTRACT_REVIEW` | Defer until a fresh proposal selection can produce a one-use receipt. |
305
+ | `approve-and-run.sh` | Acquires a repository lease, creates or switches a task branch/worktree, and launches agents | Do not wrap without a contract-approval receipt and cancellable long-running execution. |
306
+ | `show-acceptance-review.sh` | Reads sealed evidence but may regenerate `acceptance-report.json` | First split out a genuinely read-only, in-memory preview; that preview is the earliest suitable candidate. |
307
+ | `resume-review.sh` | Records a bounded resumption, changes `BLOCKED` to `REVIEWING`, and launches Reviewer | Consider only after command-bound authorization and subprocess cancellation are proven on both versions. |
308
+ | `accept-and-integrate.sh` | Creates the combined commit, fast-forwards the original branch, removes a worktree, and deletes the task branch | Do not wrap until final acceptance is bound to task ID, sealed diff, branch, session, and a consumed nonce. |
309
+ | `abort-task.sh` | Archives work, may create a recovery commit, switches/removes worktrees, and releases the lease | Do not wrap until an equally bound, one-use abort receipt exists. |
310
+
311
+ A future mutating tool must never accept an approval phrase as a model-provided
312
+ argument. It must atomically consume a machine-verifiable receipt created from
313
+ the immediately preceding `question` result and bind at least the approval
314
+ kind, task ID, session, message, relevant sealed SHA/branch, timestamp, and
315
+ nonce. It must also retain fixed-script authentication, strict state
316
+ preconditions, project/worktree bounds, abort propagation that terminates child
317
+ processes, bounded structured output, exact per-agent permissions, the 38-case
318
+ transaction suite, and real `1.14.22`/`1.15.13` integration tests. Internal
319
+ Coder/Reviewer transition scripts remain private orchestration details rather
320
+ than public tools.
321
+
322
+ ## Upgrade
323
+
324
+ ```sh
325
+ opencode-android-orchestrator upgrade /path/to/android-project
326
+ opencode-android-orchestrator upgrade . --primary-module :mobile --json
327
+ ```
328
+
329
+ `upgrade` accepts either the Git root or a directory below it. It first validates
330
+ the installed manifest, every managed file, and every original-file backup. It
331
+ refuses downgrades, user-modified managed resources, damaged backups, ambiguous
332
+ Android modules, same-version resource rewrites, and an unfinished upgrade
333
+ marker before creating recovery state.
334
+
335
+ For an older healthy installation, the command:
336
+
337
+ 1. reconstructs merged AGENTS and OpenCode configuration from the original
338
+ pre-install files rather than layering new output over an older merge;
339
+ 2. saves the exact old manifest and immediate pre-upgrade file snapshots below
340
+ `.automation-plugin/upgrades/<upgrade-id>/`;
341
+ 3. carries the first installation's original backups into a new verified
342
+ backup set;
343
+ 4. writes only changed managed resources and restores or removes resources no
344
+ longer managed by the new version;
345
+ 5. runs the 38 automation tests and a mutation-free shadow run before swapping
346
+ the active manifest;
347
+ 6. records upgrade history below `.automation-plugin/history/`.
348
+
349
+ A verification failure automatically restores the old manifest and all old
350
+ managed resources. Recovery evidence remains available for inspection. Running
351
+ the command again on the current, unchanged version is byte-idempotent: it
352
+ rechecks prerequisites and post-install verification without creating upgrade
353
+ history or recovery state.
354
+
355
+ Version `0.2.0` has not been published. These commands document the intended
356
+ post-release lifecycle and are not instructions to upgrade a live project yet.
357
+
358
+ ## Uninstall
359
+
360
+ ```sh
361
+ opencode-android-orchestrator uninstall /path/to/android-project
362
+ opencode-android-orchestrator uninstall . --json
363
+ ```
364
+
365
+ `uninstall` accepts the project root or a directory below it and does not
366
+ require the Android toolchain to remain healthy. It validates the installed
367
+ manifest and refuses another active upgrade or uninstall transaction before
368
+ creating recovery state. For every managed path it then applies one of these
369
+ rules:
370
+
371
+ 1. if the content, size, and mode still match the installed manifest, restore
372
+ the verified pre-install file or remove a plugin-created file;
373
+ 2. if the path already matches its original state or is already absent when no
374
+ original existed, leave it untouched;
375
+ 3. if content, permissions, or existence drifted, retain the current state and
376
+ list the path for manual review.
377
+
378
+ Before changing a file, the command records the active manifest and every
379
+ affected installed file below `.automation-plugin/uninstalls/<uninstall-id>/`
380
+ and publishes an uninstall marker. It verifies all final paths before removing
381
+ the active manifest and records completion below `.automation-plugin/history/`.
382
+ Any failure before that commit restores the complete installed state. Original
383
+ installation backups and uninstall evidence are intentionally retained for
384
+ audit and manual recovery; user-created or pre-existing empty directories are
385
+ never guessed at or recursively removed.
386
+
387
+ Version `0.2.0` has not been published. This command documents the intended
388
+ post-release lifecycle and is not an instruction to uninstall a live project
389
+ through the unpublished package.
390
+
19
391
  ## Development
20
392
 
393
+ The package root exports only the default OpenCode plugin factory because the
394
+ OpenCode loader treats each root export as a plugin. Programmatic lifecycle and
395
+ diagnostic APIs are available from
396
+ `@frankzhang2026/opencode-android-orchestrator/api`.
397
+
21
398
  ```sh
22
399
  npm run typecheck
23
400
  npm test
24
401
  npm run pack:check
25
402
  ```
403
+
404
+ ## License
405
+
406
+ This project is available under the [MIT License](LICENSE). Third-party
407
+ software is licensed by its respective owners; see
408
+ [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for dependency scope,
409
+ copyright notices, and license texts. Superpowers is referenced as a pinned
410
+ external plugin and is not bundled into this package.
@@ -0,0 +1,119 @@
1
+ # Third-Party Notices
2
+
3
+ Last reviewed for `0.2.0` on 2026-08-26.
4
+
5
+ The published package does not vendor `node_modules`, third-party binaries, or
6
+ third-party Skill source. Its compiled JavaScript imports the direct runtime
7
+ dependency below, declares the OpenCode plugin API as a peer dependency, and
8
+ installs a pinned external Superpowers reference into the target project's
9
+ OpenCode configuration. Those relationships and their upstream notices are
10
+ recorded here.
11
+
12
+ ## jsonc-parser 3.3.1
13
+
14
+ - Relationship: direct runtime dependency installed separately by npm; its
15
+ source is not bundled into this package tarball.
16
+ - Source: <https://github.com/microsoft/node-jsonc-parser/tree/v3.3.1>
17
+ - License: MIT
18
+ - Copyright: Microsoft
19
+
20
+ ```text
21
+ The MIT License (MIT)
22
+
23
+ Copyright (c) Microsoft
24
+
25
+ Permission is hereby granted, free of charge, to any person obtaining a copy
26
+ of this software and associated documentation files (the "Software"), to deal
27
+ in the Software without restriction, including without limitation the rights
28
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29
+ copies of the Software, and to permit persons to whom the Software is
30
+ furnished to do so, subject to the following conditions:
31
+
32
+ The above copyright notice and this permission notice shall be included in all
33
+ copies or substantial portions of the Software.
34
+
35
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41
+ SOFTWARE.
42
+ ```
43
+
44
+ ## @opencode-ai/plugin
45
+
46
+ - Relationship: peer dependency `>=1.14.22 <1.16.0` and development API
47
+ baseline `1.14.22`; it is not bundled into this package tarball.
48
+ - Source: <https://github.com/anomalyco/opencode>
49
+ - License: MIT
50
+ - Copyright: 2025 opencode
51
+
52
+ ```text
53
+ MIT License
54
+
55
+ Copyright (c) 2025 opencode
56
+
57
+ Permission is hereby granted, free of charge, to any person obtaining a copy
58
+ of this software and associated documentation files (the "Software"), to deal
59
+ in the Software without restriction, including without limitation the rights
60
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
61
+ copies of the Software, and to permit persons to whom the Software is
62
+ furnished to do so, subject to the following conditions:
63
+
64
+ The above copyright notice and this permission notice shall be included in all
65
+ copies or substantial portions of the Software.
66
+
67
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
68
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
69
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
70
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
71
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
72
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
73
+ SOFTWARE.
74
+ ```
75
+
76
+ ## Superpowers v6.2.0
77
+
78
+ - Relationship: external companion plugin pinned as
79
+ `superpowers@git+https://github.com/obra/superpowers.git#v6.2.0`. The
80
+ initializer writes only this reference; Superpowers files are fetched and
81
+ managed by OpenCode and are not copied into this package tarball.
82
+ - Source: <https://github.com/obra/superpowers/tree/v6.2.0>
83
+ - License: MIT
84
+ - Copyright: 2025 Jesse Vincent
85
+
86
+ ```text
87
+ MIT License
88
+
89
+ Copyright (c) 2025 Jesse Vincent
90
+
91
+ Permission is hereby granted, free of charge, to any person obtaining a copy
92
+ of this software and associated documentation files (the "Software"), to deal
93
+ in the Software without restriction, including without limitation the rights
94
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
95
+ copies of the Software, and to permit persons to whom the Software is
96
+ furnished to do so, subject to the following conditions:
97
+
98
+ The above copyright notice and this permission notice shall be included in all
99
+ copies or substantial portions of the Software.
100
+
101
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
102
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
103
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
104
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
105
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
106
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
107
+ SOFTWARE.
108
+ ```
109
+
110
+ ## Development-only dependencies
111
+
112
+ The source repository also directly uses TypeScript `5.8.2` (Apache-2.0) and
113
+ `@types/node` `22.13.9` (MIT) to build and type-check the project. They and the
114
+ transitive development dependency tree are excluded from this package tarball;
115
+ their installed packages retain their own upstream license files.
116
+
117
+ Command-line programs required by an initialized Android project, including
118
+ Git, `jq`, ripgrep, Java, Gradle, and the Android SDK, are discovered on the
119
+ host. This package neither distributes nor installs those programs.