@aperant/framework 0.11.0 → 0.12.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.
- package/CHANGELOG.md +213 -30
- package/agents/apt-planner.md +15 -0
- package/agents/apt-verifier.md +15 -10
- package/bin/apt-proof-video.mjs +256 -76
- package/dist/cli/commands/apply-recipe.d.mts +6 -0
- package/dist/cli/commands/apply-recipe.d.mts.map +1 -0
- package/dist/cli/commands/apply-recipe.mjs +98 -0
- package/dist/cli/commands/apply-recipe.mjs.map +1 -0
- package/dist/cli/commands/mobile-prepare.d.mts +53 -0
- package/dist/cli/commands/mobile-prepare.d.mts.map +1 -0
- package/dist/cli/commands/mobile-prepare.mjs +139 -0
- package/dist/cli/commands/mobile-prepare.mjs.map +1 -0
- package/dist/cli/commands/recipe-diff.d.mts +6 -0
- package/dist/cli/commands/recipe-diff.d.mts.map +1 -0
- package/dist/cli/commands/recipe-diff.mjs +75 -0
- package/dist/cli/commands/recipe-diff.mjs.map +1 -0
- package/dist/cli/commands/roadmap.d.mts.map +1 -1
- package/dist/cli/commands/roadmap.mjs +53 -0
- package/dist/cli/commands/roadmap.mjs.map +1 -1
- package/dist/cli/commands/validate-evidence.d.mts +1 -1
- package/dist/cli/commands/verify-sandbox.d.mts +6 -0
- package/dist/cli/commands/verify-sandbox.d.mts.map +1 -0
- package/dist/cli/commands/verify-sandbox.mjs +200 -0
- package/dist/cli/commands/verify-sandbox.mjs.map +1 -0
- package/dist/cli/consistency/parse-qa.d.mts.map +1 -1
- package/dist/cli/consistency/parse-qa.mjs +18 -4
- package/dist/cli/consistency/parse-qa.mjs.map +1 -1
- package/dist/cli/consistency/rules/r5-verdict-consistency.d.mts.map +1 -1
- package/dist/cli/consistency/rules/r5-verdict-consistency.mjs +11 -10
- package/dist/cli/consistency/rules/r5-verdict-consistency.mjs.map +1 -1
- package/dist/cli/coverage-check/user-outcomes.d.mts +7 -2
- package/dist/cli/coverage-check/user-outcomes.d.mts.map +1 -1
- package/dist/cli/coverage-check/user-outcomes.mjs +50 -17
- package/dist/cli/coverage-check/user-outcomes.mjs.map +1 -1
- package/dist/cli/design/frontmatter-schema.d.mts +8 -8
- package/dist/cli/dispatch.d.mts.map +1 -1
- package/dist/cli/dispatch.mjs +28 -0
- package/dist/cli/dispatch.mjs.map +1 -1
- package/dist/cli/gate/gates/verify-approved.d.mts +0 -48
- package/dist/cli/gate/gates/verify-approved.d.mts.map +1 -1
- package/dist/cli/gate/gates/verify-approved.mjs +23 -80
- package/dist/cli/gate/gates/verify-approved.mjs.map +1 -1
- package/dist/cli/install/mcp-server-specs.d.mts +6 -5
- package/dist/cli/install/mcp-server-specs.d.mts.map +1 -1
- package/dist/cli/install/mcp-server-specs.mjs +22 -4
- package/dist/cli/install/mcp-server-specs.mjs.map +1 -1
- package/dist/cli/personas/sidecar.d.mts +1 -1
- package/dist/cli/roadmap/backend-adapter.d.mts +43 -0
- package/dist/cli/roadmap/backend-adapter.d.mts.map +1 -0
- package/dist/cli/roadmap/backend-adapter.mjs +222 -0
- package/dist/cli/roadmap/backend-adapter.mjs.map +1 -0
- package/dist/cli/roadmap/lifecycle.d.mts +1 -1
- package/dist/cli/roadmap/rollup.d.mts +2 -2
- package/dist/cli/util/runtime-capabilities.d.mts +7 -0
- package/dist/cli/util/runtime-capabilities.d.mts.map +1 -1
- package/dist/cli/util/runtime-capabilities.mjs +65 -0
- package/dist/cli/util/runtime-capabilities.mjs.map +1 -1
- package/dist/cli/verify-proof/manifest-validator.mjs +13 -0
- package/dist/cli/verify-proof/manifest-validator.mjs.map +1 -1
- package/dist/cli/verify-proof/resolver.d.mts +10 -7
- package/dist/cli/verify-proof/resolver.d.mts.map +1 -1
- package/dist/cli/verify-proof/resolver.mjs +28 -7
- package/dist/cli/verify-proof/resolver.mjs.map +1 -1
- package/dist/cli/verify-proof/sandbox/apply.d.mts +64 -0
- package/dist/cli/verify-proof/sandbox/apply.d.mts.map +1 -0
- package/dist/cli/verify-proof/sandbox/apply.mjs +379 -0
- package/dist/cli/verify-proof/sandbox/apply.mjs.map +1 -0
- package/dist/cli/verify-proof/sandbox/gate-predicate.d.mts +63 -0
- package/dist/cli/verify-proof/sandbox/gate-predicate.d.mts.map +1 -0
- package/dist/cli/verify-proof/sandbox/gate-predicate.mjs +115 -0
- package/dist/cli/verify-proof/sandbox/gate-predicate.mjs.map +1 -0
- package/dist/cli/verify-proof/sandbox/pattern-matcher.d.mts +57 -0
- package/dist/cli/verify-proof/sandbox/pattern-matcher.d.mts.map +1 -0
- package/dist/cli/verify-proof/sandbox/pattern-matcher.mjs +124 -0
- package/dist/cli/verify-proof/sandbox/pattern-matcher.mjs.map +1 -0
- package/dist/cli/verify-proof/sandbox/recipe-diff.d.mts +28 -0
- package/dist/cli/verify-proof/sandbox/recipe-diff.d.mts.map +1 -0
- package/dist/cli/verify-proof/sandbox/recipe-diff.mjs +190 -0
- package/dist/cli/verify-proof/sandbox/recipe-diff.mjs.map +1 -0
- package/dist/cli/verify-proof/sandbox/sandbox-config.d.mts +25 -0
- package/dist/cli/verify-proof/sandbox/sandbox-config.d.mts.map +1 -0
- package/dist/cli/verify-proof/sandbox/sandbox-config.mjs +85 -0
- package/dist/cli/verify-proof/sandbox/sandbox-config.mjs.map +1 -0
- package/dist/cli/verify-proof/sandbox/self-test.d.mts +39 -0
- package/dist/cli/verify-proof/sandbox/self-test.d.mts.map +1 -0
- package/dist/cli/verify-proof/sandbox/self-test.mjs +248 -0
- package/dist/cli/verify-proof/sandbox/self-test.mjs.map +1 -0
- package/dist/plugin/.claude-plugin/plugin.json +1 -1
- package/dist/plugin/agents/apt-planner.md +15 -0
- package/dist/plugin/agents/apt-verifier.md +15 -10
- package/dist/plugin/skills/apt-plan/SKILL.md +23 -0
- package/dist/plugin/skills/apt-run/SKILL.md +1 -1
- package/dist/plugin/skills/apt-setup/SKILL.md +56 -0
- package/dist/plugin/skills/apt-verify/SKILL.md +20 -15
- package/dist/plugin/skills/apt-verify-proof/SKILL.md +146 -11
- package/dist/proof-report.d.ts.map +1 -1
- package/dist/proof-report.js +4 -1
- package/dist/proof-report.js.map +1 -1
- package/dist/types/config.d.ts +42 -4
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/qa-scoring.d.ts +45 -9
- package/dist/types/qa-scoring.d.ts.map +1 -1
- package/dist/types/qa-scoring.js +34 -13
- package/dist/types/qa-scoring.js.map +1 -1
- package/dist/types/state.d.ts +7 -2
- package/dist/types/state.d.ts.map +1 -1
- package/dist/types/task-record.d.ts +10 -2
- package/dist/types/task-record.d.ts.map +1 -1
- package/drivers/mobile/README.md +40 -0
- package/drivers/mobile/driver.mjs +106 -0
- package/drivers/mobile/manifest.json +49 -0
- package/package.json +138 -138
- package/prompts/inbox-clarification.md +11 -0
- package/prompts/inbox-triage.md +20 -0
- package/prompts/qa_orchestrator_agentic.md +18 -17
- package/prompts/qa_reviewer.md +17 -15
- package/skills/apt-plan/SKILL.md +23 -0
- package/skills/apt-run/SKILL.md +1 -1
- package/skills/apt-setup/SKILL.md +56 -0
- package/skills/apt-verifier.md +7 -4
- package/skills/apt-verify/SKILL.md +20 -15
- package/skills/apt-verify-proof/SKILL.md +146 -11
- package/src/cli/commands/apply-recipe.mjs +105 -0
- package/src/cli/commands/mobile-prepare.mjs +151 -0
- package/src/cli/commands/recipe-diff.mjs +81 -0
- package/src/cli/commands/roadmap.mjs +54 -0
- package/src/cli/commands/verify-sandbox.mjs +231 -0
- package/src/cli/consistency/parse-qa.mjs +20 -4
- package/src/cli/consistency/rules/r5-verdict-consistency.mjs +11 -13
- package/src/cli/coverage-check/user-outcomes.mjs +52 -17
- package/src/cli/dispatch.mjs +27 -0
- package/src/cli/gate/gates/verify-approved.mjs +22 -81
- package/src/cli/install/mcp-server-specs.mjs +24 -4
- package/src/cli/roadmap/backend-adapter.mjs +231 -0
- package/src/cli/util/runtime-capabilities.mjs +67 -0
- package/src/cli/verify-proof/manifest-validator.mjs +15 -0
- package/src/cli/verify-proof/resolver.mjs +27 -7
- package/src/cli/verify-proof/sandbox/apply.mjs +401 -0
- package/src/cli/verify-proof/sandbox/gate-predicate.mjs +126 -0
- package/src/cli/verify-proof/sandbox/pattern-matcher.mjs +127 -0
- package/src/cli/verify-proof/sandbox/recipe-diff.mjs +208 -0
- package/src/cli/verify-proof/sandbox/sandbox-config.mjs +82 -0
- package/src/cli/verify-proof/sandbox/sandbox-schema.json +33 -0
- package/src/cli/verify-proof/sandbox/self-test.mjs +265 -0
- package/templates/config.json +10 -1
- package/templates/proof-verification.md +27 -8
- package/workflows/verify-proof.md +376 -302
package/skills/apt-plan/SKILL.md
CHANGED
|
@@ -209,6 +209,8 @@ see the gate table below.}
|
|
|
209
209
|
**Epic:** {one-sentence user-facing capability headline}
|
|
210
210
|
|
|
211
211
|
- **ON** [surface]: {user does X; system shows/does Y}
|
|
212
|
+
- {indented inferred sub-check derived by the planning LLM}
|
|
213
|
+
- {another inferred sub-check}
|
|
212
214
|
- **ON** [surface]: {user does X; system shows/does Y} *(requires ON 1)*
|
|
213
215
|
- **ON** [electron+web]: {cross-surface outcome — runs twice, once per surface}
|
|
214
216
|
|
|
@@ -246,6 +248,27 @@ ID. Subtasks reference these IDs via their per-subtask
|
|
|
246
248
|
plan-coverage-check input.}
|
|
247
249
|
```
|
|
248
250
|
|
|
251
|
+
### Inferred sub-checks (v0.9.0 — verify-proof-v2-outcome-walker)
|
|
252
|
+
|
|
253
|
+
Under each `**ON**` parent bullet, write indented child bullets (2-space
|
|
254
|
+
prefix + `- `) representing inferred sub-checks the planning LLM derives
|
|
255
|
+
from the outcome prose + surface. These are NOT user-written invariants;
|
|
256
|
+
they are the planner's judgment of "what else must be true for this
|
|
257
|
+
outcome to be approved." The verify-proof runner walks each inferred
|
|
258
|
+
child the same way it walks the parent.
|
|
259
|
+
|
|
260
|
+
Worked example (copy this shape verbatim into spec.md):
|
|
261
|
+
|
|
262
|
+
- **ON** [electron]: Clicking 'Settings' opens the settings modal.
|
|
263
|
+
- The modal traps focus on the close button.
|
|
264
|
+
- Clicking outside the modal closes it.
|
|
265
|
+
- Pressing Esc closes it and returns focus to the trigger.
|
|
266
|
+
|
|
267
|
+
**NO `patterns/` library, NO `surfaces/<name>/manifest.json` tree, NO
|
|
268
|
+
`OUTCOMES.md` file** — inferred bullets live IN spec.md. The author
|
|
269
|
+
edits spec.md once if the inferred list is wrong; the runner does not
|
|
270
|
+
re-derive them at proof time.
|
|
271
|
+
|
|
249
272
|
**`## User Outcomes` is the verify-proof input contract (STANDARD/DEEP
|
|
250
273
|
only — QUICK is hard-exempt per ID-05 / Fast Path Guarantee).** The
|
|
251
274
|
section sits between `## User Stories` (product motivation prose) and
|
package/skills/apt-run/SKILL.md
CHANGED
|
@@ -281,7 +281,7 @@ Execute the apt:verify workflow inline:
|
|
|
281
281
|
6. Score on 4 dimensions (completeness, correctness, quality, coverage)
|
|
282
282
|
7. Fix all issues found — every severity, not just critical (up to 4 iterations: first 2 discovery, last 2 verification-only)
|
|
283
283
|
8. Write qa_signoff.json
|
|
284
|
-
9. If `status` is `approved
|
|
284
|
+
9. If `status` is `approved`, flip lifecycle to `reviewing` so Stage 4 (or `/apt:ship` when review is skipped) finds the task in the correct from-state. Skip this step entirely on `rejected` (fix the code and re-run) or `needs_human` (install the missing driver transport and re-run /apt:verify-proof):
|
|
285
285
|
```bash
|
|
286
286
|
node packages/framework/bin/apt-tools.mjs task update . --id {task-id} --lifecycle-phase reviewing
|
|
287
287
|
```
|
|
@@ -307,6 +307,62 @@ AskUserQuestion([
|
|
|
307
307
|
])
|
|
308
308
|
```
|
|
309
309
|
|
|
310
|
+
### Sandbox-setup hook — parallel /apt:verify-proof (FRAMEWORK milestone fw-sandbox-parallel-verify-proof)
|
|
311
|
+
|
|
312
|
+
Gated on THREE conditions ALL true (ID-08):
|
|
313
|
+
|
|
314
|
+
1. `verification.sandbox` is ABSENT from `.aperant/config.json` (the
|
|
315
|
+
adopter has not opted in yet — once configured this hook never
|
|
316
|
+
fires again).
|
|
317
|
+
2. `host.capabilities.structured_prompts === true` (the host supports
|
|
318
|
+
native question dialogs — Claude Code, Gemini CLI, OpenCode).
|
|
319
|
+
3. `process.stdout.isTTY === true` (interactive shell — never block CI
|
|
320
|
+
or fan-out child terminals on a setup prompt).
|
|
321
|
+
|
|
322
|
+
When all three hold, ask one yes/no question:
|
|
323
|
+
|
|
324
|
+
```
|
|
325
|
+
AskUserQuestion([
|
|
326
|
+
{
|
|
327
|
+
question: "Parallel /apt:verify-proof is not configured. Run setup now?",
|
|
328
|
+
header: "Sandbox Setup",
|
|
329
|
+
multiSelect: false,
|
|
330
|
+
options: [
|
|
331
|
+
{ label: "Yes — set up parallel verify-proof", description: "Walk recipe-diff one change at a time, then apply-recipe with --confirm --accept-all once you've reviewed all four, then verify-sandbox" },
|
|
332
|
+
{ label: "Not now", description: "Skip; re-prompted on next /apt:setup if still unconfigured" }
|
|
333
|
+
]
|
|
334
|
+
}
|
|
335
|
+
])
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
On `Yes`, dispatch the three sandbox commands in order, surfacing the
|
|
339
|
+
output of each to the user before moving to the next. The CLI defaults
|
|
340
|
+
to skipping every change when `--confirm` is passed without
|
|
341
|
+
`--accept-all` (ID-02 fail-safe), so the interactive flow walks the
|
|
342
|
+
adopter through each change in the diff first, then applies once they
|
|
343
|
+
confirm:
|
|
344
|
+
|
|
345
|
+
```bash
|
|
346
|
+
apt-tools recipe-diff . # preview, no writes
|
|
347
|
+
# (host CLI shows each change in the Markdown diff to the user)
|
|
348
|
+
# (host CLI asks: "All four changes accepted? [y/N]")
|
|
349
|
+
apt-tools apply-recipe . --confirm --accept-all
|
|
350
|
+
apt-tools verify-sandbox .
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
On `Not now`, continue with the rest of /apt:setup unchanged.
|
|
354
|
+
|
|
355
|
+
**Non-interactive surfaces** (CI runs, fan-out child terminals, headless
|
|
356
|
+
agents — `host.capabilities.structured_prompts === false` OR
|
|
357
|
+
`process.stdout.isTTY === false`) SKIP this hook entirely. Print a
|
|
358
|
+
one-line stderr tip:
|
|
359
|
+
|
|
360
|
+
```
|
|
361
|
+
[apt] tip: run `/apt:verify-proof setup` from an interactive terminal to enable parallel verification
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
and continue. NEVER block on a setup prompt in a non-interactive context.
|
|
365
|
+
|
|
310
366
|
## 3. Present Settings (Batch 2: Pipeline)
|
|
311
367
|
|
|
312
368
|
```
|
package/skills/apt-verifier.md
CHANGED
|
@@ -50,10 +50,13 @@ Record pass/fail and details for each.
|
|
|
50
50
|
| **Code Quality** | Clean, idiomatic, lint-clean | Good, minor style issues | Acceptable, needs cleanup | Poor quality | Unacceptable |
|
|
51
51
|
| **Test Coverage** | Comprehensive, edge cases | Good main-path coverage | Basic tests exist | Minimal tests | No coverage |
|
|
52
52
|
|
|
53
|
-
## 4. Derive Verdict
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
## 4. Derive Verdict (v0.9.0 two-gate envelope)
|
|
54
|
+
|
|
55
|
+
Verdict is the closed set `{approved, rejected, needs_human}`. Derived from the two-gate envelope (`automation_gate` AND `proof_gate`); dimensions are informational rationale only.
|
|
56
|
+
|
|
57
|
+
- **approved:** `automation_gate: pass` AND `proof_gate: pass`.
|
|
58
|
+
- **needs_human:** `automation_gate: pass` AND `proof_gate: fail` (typically: a UI-surface outcome lacked driver transport — see `/apt:verify-proof`).
|
|
59
|
+
- **rejected:** `automation_gate: fail` (any of lint/typecheck/tests red) OR critical findings unresolved.
|
|
57
60
|
|
|
58
61
|
## 5. Write QA Sign-off
|
|
59
62
|
Write `{task_dir}/qa_signoff.json` with scores, checks, issues, and verdict.
|
|
@@ -211,15 +211,15 @@ Rate each of the 4 dimensions on a 1-10 scale using the rubrics below. Provide a
|
|
|
211
211
|
- **3-4:** Minimal tests, many untested paths
|
|
212
212
|
- **1-2:** No meaningful test coverage
|
|
213
213
|
|
|
214
|
-
### Verdict Derivation
|
|
214
|
+
### Verdict Derivation (v0.9.0 two-gate envelope)
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
Verdict is the closed set `{approved, rejected, needs_human}`. It derives from the two-gate envelope (`automation_gate` AND `proof_gate`); dimensions are informational rationale only.
|
|
217
217
|
|
|
218
|
-
- **approved** --
|
|
219
|
-
- **
|
|
220
|
-
- **rejected** --
|
|
218
|
+
- **approved** -- `automation_gate: pass` AND `proof_gate: pass` AND no critical issues
|
|
219
|
+
- **needs_human** -- `automation_gate: pass` AND `proof_gate: fail` (typically: UI-surface outcome lacked driver transport; the human must install it and re-run /apt:verify-proof)
|
|
220
|
+
- **rejected** -- `automation_gate: fail` (any of lint/typecheck/tests red) OR critical issues unresolved
|
|
221
221
|
|
|
222
|
-
|
|
222
|
+
The `deriveVerdict({automation_gate, proof_gate})` helper in `packages/framework/src/types/qa-scoring.ts` is the canonical mapping. The legacy `approved_with_notes` middle band is deleted in v0.9.0+; reading the legacy value from a stale `qa_signoff.json` crashes the consumer with a clear migration error.
|
|
223
223
|
|
|
224
224
|
## 6. Fix-Verify Loop (max 4 iterations)
|
|
225
225
|
|
|
@@ -272,7 +272,7 @@ Create `qa_signoff.json` using the `ScoredQASignoff` format (see `packages/frame
|
|
|
272
272
|
|
|
273
273
|
```json
|
|
274
274
|
{
|
|
275
|
-
"status": "approved|
|
|
275
|
+
"status": "approved|rejected|needs_human",
|
|
276
276
|
"timestamp": "{ISO date}",
|
|
277
277
|
"iterations": 1,
|
|
278
278
|
"dimensions": [
|
|
@@ -281,6 +281,10 @@ Create `qa_signoff.json` using the `ScoredQASignoff` format (see `packages/frame
|
|
|
281
281
|
{ "dimension": "code_quality", "score": 7, "rationale": "Clean code, follows conventions" },
|
|
282
282
|
{ "dimension": "test_coverage", "score": 7, "rationale": "Good coverage of main paths" }
|
|
283
283
|
],
|
|
284
|
+
"gates": {
|
|
285
|
+
"automation_gate": "pass",
|
|
286
|
+
"proof_gate": "pass"
|
|
287
|
+
},
|
|
284
288
|
"checks": {
|
|
285
289
|
"tests": { "status": "pass", "count": 42, "failures": [] },
|
|
286
290
|
"typecheck": { "status": "pass", "errors": [] },
|
|
@@ -293,10 +297,10 @@ Create `qa_signoff.json` using the `ScoredQASignoff` format (see `packages/frame
|
|
|
293
297
|
|
|
294
298
|
The `dimensions` array must contain exactly the 4 dimensions defined in `QA_DIMENSIONS`: `completeness`, `correctness`, `code_quality`, `test_coverage`. Each entry includes a numeric `score` (1-10) and a `rationale` string explaining the score.
|
|
295
299
|
|
|
296
|
-
The `status` field
|
|
297
|
-
-
|
|
298
|
-
-
|
|
299
|
-
-
|
|
300
|
+
The `status` field derives from the two gates:
|
|
301
|
+
- `automation_gate: pass` AND `proof_gate: pass`: `"approved"`
|
|
302
|
+
- `automation_gate: pass` AND `proof_gate: fail`: `"needs_human"`
|
|
303
|
+
- `automation_gate: fail` OR critical issues unresolved: `"rejected"`
|
|
300
304
|
|
|
301
305
|
```bash
|
|
302
306
|
node packages/framework/bin/apt-tools.mjs commit "qa: verification {status}" --files qa_signoff.json
|
|
@@ -304,10 +308,11 @@ node packages/framework/bin/apt-tools.mjs commit "qa: verification {status}" --f
|
|
|
304
308
|
|
|
305
309
|
### Mark lifecycle phase as `reviewing` (approved path only)
|
|
306
310
|
|
|
307
|
-
If `status` is `approved
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
`
|
|
311
|
+
If `status` is `approved`, flip the task's lifecycle phase so the next stage
|
|
312
|
+
(`/apt:review`, or `/apt:ship` if review is skipped) finds the task in the
|
|
313
|
+
correct from-state. Skip this transition on `rejected` (the task stays in
|
|
314
|
+
`verifying` until the user re-runs after fixes) or `needs_human` (re-run
|
|
315
|
+
/apt:verify-proof after installing the missing driver transport).
|
|
311
316
|
|
|
312
317
|
```bash
|
|
313
318
|
node packages/framework/bin/apt-tools.mjs task update . --id {task-id} --lifecycle-phase reviewing
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: apt:verify-proof
|
|
3
|
-
description: "
|
|
3
|
+
description: "Outcome walker — drives spec.md `## User Outcomes` one at a time, captures surface-appropriate evidence, derives a two-gate verdict ({approved, rejected, needs_human}). Fails closed on file-evidence for UI surfaces."
|
|
4
4
|
apt-skill-version: {{APT_VERSION}}
|
|
5
5
|
stage: verify
|
|
6
6
|
intent: ship
|
|
@@ -105,14 +105,58 @@ disable the walk entirely (root-only behaviour, backwards compat).
|
|
|
105
105
|
The `verification.runtimes[]` override stays the final escape hatch
|
|
106
106
|
and is now usually unnecessary because the walk runs by default.
|
|
107
107
|
|
|
108
|
-
### Bundled drivers (
|
|
108
|
+
### Bundled drivers (6)
|
|
109
109
|
|
|
110
110
|
- **browser** (priority=100, ga) — Next.js / vanilla web frontends.
|
|
111
111
|
- **electron** (priority=90, ga) — Electron desktop apps.
|
|
112
112
|
- **tauri** (priority=85, ga) — Tauri desktop apps.
|
|
113
|
+
- **mobile** (priority=80, ga) — iOS + Android (Expo / React Native / native) via `mobile-mcp`. App build/launch is owned by `apt-tools mobile prepare`, not the driver.
|
|
113
114
|
- **cli** (priority=60, ga) — headless CI, output-shape assertions.
|
|
114
115
|
- **api** (priority=50, ga) — HTTP / JSON-API regression tests.
|
|
115
116
|
|
|
117
|
+
> **Precondition.** When `--parallel` is requested, the sandbox gate at apt-verify-proof/SKILL.md Step 2c runs BEFORE this step. An unverified sandbox exits with `{status:"error", code:"E_SANDBOX_UNVERIFIED", verdict:"needs_human", reason:"sandbox_unverified"}` without loading any MCP driver tools or entering the outcome-walker loop. See `docs/verify-proof-sandbox-patterns.md` for setup.
|
|
118
|
+
|
|
119
|
+
### Deferred-tool discovery (Claude Code / OpenCode hosts) — A5 fix
|
|
120
|
+
|
|
121
|
+
On Claude Code and OpenCode hosts, MCP driver tools listed under
|
|
122
|
+
`drivers/<surface>/manifest.json :: transport.mcp_server_id` are
|
|
123
|
+
**deferred** — they live in the host's MCP server registry but their
|
|
124
|
+
schemas are NOT loaded by default. Before driving any UI-surface
|
|
125
|
+
outcome the workflow runner MUST load them via `ToolSearch(query='select:...')`.
|
|
126
|
+
|
|
127
|
+
**Worked example.** For the bundled `browser` driver (manifest field
|
|
128
|
+
`transport.mcp_server_id = "puppeteer"` → `mcp__puppeteer__*` tools):
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
ToolSearch(query='select:mcp__puppeteer__browser_navigate,mcp__puppeteer__browser_click,mcp__puppeteer__browser_screenshot,mcp__puppeteer__browser_type')
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
For the bundled `electron` driver (manifest field
|
|
135
|
+
`transport.mcp_server_id = "electron"` → `mcp__electron__*` tools):
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
ToolSearch(query='select:mcp__electron__app_launch,mcp__electron__app_click,mcp__electron__app_screenshot,mcp__electron__app_type')
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
For the bundled `mobile` driver (manifest field
|
|
142
|
+
`transport.mcp_server_id = "mobile-mcp"` → `mcp__mobile-mcp__*` tools):
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
ToolSearch(query='select:mcp__mobile-mcp__mobile_click_on_screen_at_coordinates,mcp__mobile-mcp__mobile_swipe_on_screen,mcp__mobile-mcp__mobile_save_screenshot,mcp__mobile-mcp__mobile_type_keys')
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
After the call, list the now-loaded tool names back to confirm they
|
|
149
|
+
appear in the active tool surface. If any required driver tool fails to
|
|
150
|
+
load, emit `result: "needs_human_with_transport"` on each affected
|
|
151
|
+
outcome — do NOT fall back to file-evidence. The legacy
|
|
152
|
+
"commit hash as proof" pattern is rejected by the proof_gate.
|
|
153
|
+
|
|
154
|
+
The manifest field is `transport.mcp_server_id` (and `transport.skill_id`
|
|
155
|
+
where applicable). The names `mcp_transport.tool_prefix` and
|
|
156
|
+
`transport.tool_prefix` are NOT real manifest fields — do not search
|
|
157
|
+
for them. This block is no-op on hosts whose entire MCP surface is
|
|
158
|
+
loaded eagerly (some Codex builds); `ToolSearch` is idempotent there.
|
|
159
|
+
|
|
116
160
|
### Install-time MCP provisioning (verification.provision_mcp)
|
|
117
161
|
|
|
118
162
|
`apt-tools init` (and `/apt:update`, which routes through the same path)
|
|
@@ -149,10 +193,99 @@ IDL types, error taxonomy, and conformance kit live inside the framework
|
|
|
149
193
|
itself under `packages/framework/src/driver-sdk/` — see that directory's
|
|
150
194
|
public-api-lock test for the surface contract.
|
|
151
195
|
|
|
152
|
-
##
|
|
196
|
+
## Step 1 — First-run sandbox-setup hook (interactive `--parallel` only)
|
|
197
|
+
|
|
198
|
+
When the user invokes `/apt:verify-proof --parallel` on a project where
|
|
199
|
+
`verification.sandbox` is ABSENT from `.aperant/config.json` AND
|
|
200
|
+
`host.capabilities.structured_prompts === true` AND
|
|
201
|
+
`process.stdout.isTTY === true`, prompt:
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
AskUserQuestion([
|
|
205
|
+
{
|
|
206
|
+
question: "Parallel /apt:verify-proof is not configured. Run setup now?",
|
|
207
|
+
header: "Sandbox Setup",
|
|
208
|
+
multiSelect: false,
|
|
209
|
+
options: [
|
|
210
|
+
{ label: "Yes — run sandbox setup", description: "Walk recipe-diff with you, then apply-recipe --confirm --accept-all (after you've reviewed each change), then verify-sandbox before continuing" },
|
|
211
|
+
{ label: "Cancel", description: "Exit; re-invoke without --parallel for single-instance verify-proof" }
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
])
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
On `Yes`, dispatch `/apt:verify-proof setup` (the setup-mode flow) before
|
|
218
|
+
returning to the walker. On `Cancel`, exit with the same envelope the
|
|
219
|
+
Step 2c gate would produce so the user sees the structured remediation.
|
|
220
|
+
|
|
221
|
+
Non-interactive surfaces (`structured_prompts:false` OR
|
|
222
|
+
`stdout.isTTY:false`) print the one-line stderr tip and proceed:
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
[apt] tip: run `/apt:verify-proof setup` to enable parallel verification
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
then exit at the Step 2c gate. Never block CI / fan-out children on
|
|
229
|
+
this prompt (ID-08).
|
|
230
|
+
|
|
231
|
+
## Step 2c — Sandbox gate (precondition for `--parallel`)
|
|
232
|
+
|
|
233
|
+
When `--parallel` is requested AND `.aperant/config.json :: verification.sandbox`
|
|
234
|
+
is present, this gate runs BEFORE Step 2.5 (Deferred-tool-load) and BEFORE
|
|
235
|
+
entering the Outcome Walker loop. It is a **precondition gate**, NOT a
|
|
236
|
+
per-outcome transport-failure gate.
|
|
237
|
+
|
|
238
|
+
**Dispatch on the state file** at
|
|
239
|
+
`.aperant/state/verify-proof-sandbox-verified.json`:
|
|
240
|
+
|
|
241
|
+
| condition | action |
|
|
242
|
+
|-----------|--------|
|
|
243
|
+
| `--parallel` requested + state file shows `verified:true` (verdict:`approved`) | **proceed** to Step 2.5; the parallel surface is now safe (each instance has its own SQLite path + userData dir + singleton-lock opt-out). |
|
|
244
|
+
| `--parallel` requested + state file missing OR `verified:false` | **exit BEFORE Step 2.5** with the JSON envelope below; do NOT load deferred MCP tools, do NOT initialize the outcome walker, do NOT write verification.json. |
|
|
245
|
+
| `--parallel` NOT requested | today's behavior unchanged — this gate is a no-op (Fast Path Guarantee ID-07). |
|
|
246
|
+
|
|
247
|
+
**Fail-loud envelope.** sandbox not verified — run `/apt:verify-proof setup` first:
|
|
248
|
+
|
|
249
|
+
```json
|
|
250
|
+
{
|
|
251
|
+
"status": "error",
|
|
252
|
+
"code": "E_SANDBOX_UNVERIFIED",
|
|
253
|
+
"verdict": "needs_human",
|
|
254
|
+
"reason": "sandbox_unverified",
|
|
255
|
+
"remediation": "/apt:verify-proof setup"
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
The single-line stderr message is: `sandbox not verified — run \`/apt:verify-proof setup\` first`.
|
|
260
|
+
|
|
261
|
+
**v2 vocabulary alignment.** The gate's failure envelope uses verify-proof
|
|
262
|
+
v2's existing `verdict:"needs_human"` vocabulary (ID-09) so reviewers,
|
|
263
|
+
downstream tools, and the e2e see one shape across both the per-run
|
|
264
|
+
envelope and per-outcome verification.json. We deliberately do NOT emit
|
|
265
|
+
per-outcome `needs_human_with_transport` rows for this case — sandbox
|
|
266
|
+
unverified is a precondition failure for the whole walker, not a
|
|
267
|
+
per-outcome transport failure for individual outcomes. Only the two
|
|
268
|
+
v2-shipped verdicts (`approved`, `needs_human`) appear in this gate's
|
|
269
|
+
envelope — the deprecated middle-band verdict v2 removed is not
|
|
270
|
+
referenced anywhere in this block (TD-07 grep guard locks this).
|
|
271
|
+
|
|
272
|
+
**Anti-queue invariant.** This gate fails loud rather than silently
|
|
273
|
+
serializing parallel invocations through a cooperative queue. The
|
|
274
|
+
`install/install-semaphore.mjs` queuing primitive is explicitly forbidden
|
|
275
|
+
in this code path (ID-01); a regression test grep-guards the invariant.
|
|
276
|
+
|
|
277
|
+
See `docs/verify-proof-sandbox-patterns.md` for the worked
|
|
278
|
+
electron-libsql adopter flow + the manual-integration template for
|
|
279
|
+
unrecognized runtimes.
|
|
280
|
+
|
|
281
|
+
## Execution — Outcome Walker (v0.9.0)
|
|
153
282
|
|
|
154
283
|
Execute the verify-proof workflow end-to-end using IDL verbs (the driver
|
|
155
|
-
maps verbs to its transport — MCP server, local command, HTTP)
|
|
284
|
+
maps verbs to its transport — MCP server, local command, HTTP). The
|
|
285
|
+
workflow is an **outcome walker**: iterate `spec.md ## User Outcomes`
|
|
286
|
+
parent bullets one at a time, drive the stated bullet AND each inferred
|
|
287
|
+
child, capture surface-appropriate evidence, fix-loop on red, advance on
|
|
288
|
+
green.
|
|
156
289
|
|
|
157
290
|
<execution_context>
|
|
158
291
|
@packages/framework/workflows/verify-proof.md
|
|
@@ -168,15 +301,17 @@ to adopt the adversarial QA mindset. You are not a helpful assistant during veri
|
|
|
168
301
|
you are trying to break things and prove they work.
|
|
169
302
|
|
|
170
303
|
Respect ALL workflow gates:
|
|
171
|
-
1. Pre-check gate — all subtasks completed
|
|
172
|
-
2.
|
|
173
|
-
3.
|
|
174
|
-
4.
|
|
175
|
-
5.
|
|
176
|
-
6.
|
|
304
|
+
1. **Pre-check gate** — all subtasks completed.
|
|
305
|
+
2. **User Outcomes gate** — spec.md MUST carry `## User Outcomes` with `body_kind ∈ {outcomes, empty-with-note}`. NO fallback to feature-registry-derived tests.
|
|
306
|
+
3. **Deferred-tool-load gate** — on Claude Code / OpenCode hosts, MCP driver tools under `drivers/<surface>/manifest.json :: transport.mcp_server_id` MUST be loaded via `ToolSearch(query='select:...')` BEFORE driving any UI-surface outcome.
|
|
307
|
+
4. **Automation gate** — `automated_checks.{tests,typecheck,lint}.status ∈ {pass, fail}` (closed set, no `"enforced_at_commit"` dodge).
|
|
308
|
+
5. **Outcome-walker gate** — every parent outcome AND every inferred child has its own test entry with evidence appropriate to its surface OR `result: "needs_human_with_transport"`.
|
|
309
|
+
6. **Proof gate** — UI-surface outcomes carrying `evidence: "file-evidence: ..."` are rejected as `needs_human_with_transport`. File-evidence is NEVER sufficient for any surface.
|
|
310
|
+
7. **Verdict gate** — verdict is exactly one of `{approved, rejected, needs_human}`. The legacy `approved_with_notes` middle band is DELETED.
|
|
311
|
+
8. **Design-lint gate (C11)** — for every UI-touching task, run `apt-tools design-lint` against the implementation's generated HTML + `{task_dir}/mockups/mockup_final.html` (when present). Violations contribute to the proof-gate evidence story but are NOT blocking on their own.
|
|
177
312
|
|
|
178
313
|
Use the proof-verification template (@packages/framework/templates/proof-verification.md)
|
|
179
|
-
for the
|
|
314
|
+
for the verification.json output schema.
|
|
180
315
|
|
|
181
316
|
**Design-lint invocation** (when the task touched UI):
|
|
182
317
|
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* commands/apply-recipe.mjs — `apt-tools apply-recipe <projectDir> [--confirm] [--accept-all] [--force]`.
|
|
3
|
+
*
|
|
4
|
+
* Wraps applyRecipe() at the CLI surface.
|
|
5
|
+
*
|
|
6
|
+
* --confirm switches from dry-run (the default) to live writes.
|
|
7
|
+
* --accept-all bypasses per-change confirmation (pipeline/scripted use).
|
|
8
|
+
* --force overrides the TOFU user_modified guard — overwrites files
|
|
9
|
+
* whose SHA diverges from the recipe's expected before value.
|
|
10
|
+
* Files containing the recipe's marker are still skipped.
|
|
11
|
+
*
|
|
12
|
+
* The two flags compose: `--confirm` alone enters live mode but defers
|
|
13
|
+
* per-change accept/skip to the caller — without `--accept-all` and
|
|
14
|
+
* without a stdin-driven prompt, every change is SKIPPED (fail-safe per
|
|
15
|
+
* ID-02). Adopters using the interactive apt-setup SKILL.md mini-flow
|
|
16
|
+
* walk each change one at a time before invoking the CLI with
|
|
17
|
+
* `--accept-all` once they've reviewed the diff. Adopters in CI /
|
|
18
|
+
* fan-out / scripted contexts pass both flags up front.
|
|
19
|
+
*
|
|
20
|
+
* Exit codes:
|
|
21
|
+
* 0 — applyRecipe completed (dry-run or confirmed)
|
|
22
|
+
* 1 — usage error / no-recipe-match / applyRecipe threw
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { parseFlags } from '../util/args.mjs'
|
|
26
|
+
import { err, exitWith, ok } from '../util/result.mjs'
|
|
27
|
+
import { loadRuntimeCapabilities } from '../util/runtime-capabilities.mjs'
|
|
28
|
+
import { applyRecipe } from '../verify-proof/sandbox/apply.mjs'
|
|
29
|
+
import { matchPatternForProject } from '../verify-proof/sandbox/pattern-matcher.mjs'
|
|
30
|
+
import { discoverBundledRecipes } from '../verify-proof/sandbox/sandbox-config.mjs'
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param {string} projectDir
|
|
34
|
+
* @param {string[]} [extra]
|
|
35
|
+
*/
|
|
36
|
+
export async function cmdApplyRecipe(projectDir, extra = []) {
|
|
37
|
+
if (!projectDir) {
|
|
38
|
+
return err('Usage: apt-tools apply-recipe <project-dir> [--confirm] [--accept-all]')
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const flags = parseFlags(extra)
|
|
42
|
+
const confirm = flags.has('confirm')
|
|
43
|
+
const acceptAll = flags.has('accept-all')
|
|
44
|
+
const force = flags.has('force')
|
|
45
|
+
|
|
46
|
+
const recipes = discoverBundledRecipes()
|
|
47
|
+
const runtime = loadRuntimeCapabilities(projectDir)
|
|
48
|
+
|
|
49
|
+
const explicitRecipeId = flags.get('recipe') ?? null
|
|
50
|
+
let recipeId
|
|
51
|
+
let matchReason
|
|
52
|
+
if (explicitRecipeId) {
|
|
53
|
+
recipeId = explicitRecipeId
|
|
54
|
+
matchReason = 'explicit'
|
|
55
|
+
} else {
|
|
56
|
+
const match = matchPatternForProject(projectDir, runtime, recipes)
|
|
57
|
+
recipeId = match.recipeId
|
|
58
|
+
matchReason = match.reason
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!recipeId) {
|
|
62
|
+
return exitWith(
|
|
63
|
+
{
|
|
64
|
+
status: 'error',
|
|
65
|
+
command: 'apply-recipe',
|
|
66
|
+
code: 'E_NO_RECIPE',
|
|
67
|
+
reason: matchReason,
|
|
68
|
+
runtime,
|
|
69
|
+
docs: 'docs/verify-proof-sandbox-patterns.md',
|
|
70
|
+
},
|
|
71
|
+
1,
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
const result = await applyRecipe({
|
|
77
|
+
projectDir,
|
|
78
|
+
recipeId,
|
|
79
|
+
recipes,
|
|
80
|
+
confirm,
|
|
81
|
+
// AC8 + ID-02 — only auto-accept when the caller passed
|
|
82
|
+
// --accept-all explicitly. Without the flag the underlying
|
|
83
|
+
// applyRecipe defaults to skip (every change recorded as
|
|
84
|
+
// `user_declined`); callers driving per-change UX wrap the
|
|
85
|
+
// applier directly with their own confirmer.
|
|
86
|
+
perChangeConfirm: acceptAll ? async () => 'accept' : undefined,
|
|
87
|
+
force,
|
|
88
|
+
})
|
|
89
|
+
return ok({
|
|
90
|
+
status: 'ok',
|
|
91
|
+
command: 'apply-recipe',
|
|
92
|
+
project_dir: projectDir,
|
|
93
|
+
recipe_id: recipeId,
|
|
94
|
+
recipe_version: result.recipe_version,
|
|
95
|
+
confirm,
|
|
96
|
+
accept_all: acceptAll,
|
|
97
|
+
aborted: result.aborted,
|
|
98
|
+
writes: result.writes,
|
|
99
|
+
skips: result.skips,
|
|
100
|
+
audit_path: result.audit_path,
|
|
101
|
+
})
|
|
102
|
+
} catch (e) {
|
|
103
|
+
return err(`apply-recipe: ${e?.message ?? String(e)}`)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* commands/mobile-prepare.mjs — `apt-tools mobile prepare`.
|
|
3
|
+
*
|
|
4
|
+
* Owns the mobile app lifecycle for the verify-proof mobile surface
|
|
5
|
+
* (decisions D-03/D-04): build → install → launch → Metro → launch-readiness
|
|
6
|
+
* gate. This is the home for multi-minute orchestration that CANNOT live in a
|
|
7
|
+
* driver PreflightCheck (those are ≤5s, shell-free, single LocalCommand).
|
|
8
|
+
*
|
|
9
|
+
* The command is PLAN-producing: it resolves the ordered launch sequence and
|
|
10
|
+
* the readiness-gate contract and returns them in the envelope. The
|
|
11
|
+
* verify-proof workflow runner (which holds the host tool surface) executes
|
|
12
|
+
* the sequence, gates on the readiness signals, THEN hands UI verbs to the
|
|
13
|
+
* mobile driver. This mirrors the driver pattern (driver.mjs are adapters;
|
|
14
|
+
* the runner dispatches).
|
|
15
|
+
*
|
|
16
|
+
* Pure, unit-testable seams: `planLaunchSequence` + `isAppReady`.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { loadRuntimeCapabilities } from '../util/runtime-capabilities.mjs'
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {{ binary: string, args: string[] }} LocalCommand
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Resolve the ordered launch sequence for a (platform, mode, device).
|
|
27
|
+
*
|
|
28
|
+
* - mode 'expo' — `npx expo run:ios|run:android` builds, installs, launches,
|
|
29
|
+
* and starts Metro in one step (the common Expo/RN path).
|
|
30
|
+
* - mode 'native' — device-prep only (`xcrun simctl boot` / `adb
|
|
31
|
+
* wait-for-device`); the native build+install+launch is delegated (gradle /
|
|
32
|
+
* the XcodeBuildMCP escalation per D-02), out of scope for v1's planner.
|
|
33
|
+
*
|
|
34
|
+
* @param {{ platform?: string, mode?: string, device?: string }} [opts]
|
|
35
|
+
* @returns {LocalCommand[]}
|
|
36
|
+
*/
|
|
37
|
+
export function planLaunchSequence(opts = {}) {
|
|
38
|
+
const { platform, mode = 'expo', device } = opts
|
|
39
|
+
if (platform !== 'ios' && platform !== 'android') {
|
|
40
|
+
throw new Error(`planLaunchSequence: platform must be 'ios' or 'android', got "${platform}"`)
|
|
41
|
+
}
|
|
42
|
+
if (mode !== 'expo' && mode !== 'native') {
|
|
43
|
+
throw new Error(`planLaunchSequence: mode must be 'expo' or 'native', got "${mode}"`)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (mode === 'expo') {
|
|
47
|
+
const expoArgs = ['expo', platform === 'ios' ? 'run:ios' : 'run:android']
|
|
48
|
+
if (device) expoArgs.push('--device', device)
|
|
49
|
+
return [{ binary: 'npx', args: expoArgs }]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// native — device prep only.
|
|
53
|
+
if (platform === 'ios') {
|
|
54
|
+
return [{ binary: 'xcrun', args: ['simctl', 'boot', device ?? 'booted'] }]
|
|
55
|
+
}
|
|
56
|
+
return [{ binary: 'adb', args: device ? ['-s', device, 'wait-for-device'] : ['wait-for-device'] }]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Launch-readiness predicate (D-04). A successful screenshot alone is NOT
|
|
61
|
+
* enough — for RN/Expo it can capture a native splash, an Expo loading
|
|
62
|
+
* overlay, a redbox, or the dev-client launcher. ALL signals must hold before
|
|
63
|
+
* UI driving starts. For a pure-native app (no JS bundle) the caller passes
|
|
64
|
+
* `bundleConnected: true` and `launcherState: false`.
|
|
65
|
+
*
|
|
66
|
+
* @param {{ foregrounded?: boolean, bundleConnected?: boolean, redbox?: boolean, launcherState?: boolean }} [signals]
|
|
67
|
+
* @returns {boolean}
|
|
68
|
+
*/
|
|
69
|
+
export function isAppReady(signals) {
|
|
70
|
+
const s = signals && typeof signals === 'object' ? signals : {}
|
|
71
|
+
return (
|
|
72
|
+
s.foregrounded === true &&
|
|
73
|
+
s.bundleConnected === true &&
|
|
74
|
+
s.redbox !== true &&
|
|
75
|
+
s.launcherState !== true
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The readiness-gate contract surfaced to the workflow runner. */
|
|
80
|
+
const READINESS_GATE = {
|
|
81
|
+
description:
|
|
82
|
+
'App-ready gate (D-04). All signals must hold before UI verbs are dispatched to the mobile driver.',
|
|
83
|
+
signals: ['foregrounded', 'bundleConnected', 'no-redbox', 'no-launcher-state'],
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** @param {string} message */
|
|
87
|
+
function errorEnvelope(message) {
|
|
88
|
+
return { envelope: { status: 'error', command: 'mobile-prepare', error: message }, exitCode: 1 }
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Parse `--platform <ios|android> [--mode <expo|native>] [--device <id>]`.
|
|
93
|
+
*
|
|
94
|
+
* @param {string[]} args
|
|
95
|
+
* @returns {{ platform?: string, mode?: string, device?: string }}
|
|
96
|
+
*/
|
|
97
|
+
function parseFlags(args) {
|
|
98
|
+
/** @type {{ platform?: string, mode?: string, device?: string }} */
|
|
99
|
+
const opts = {}
|
|
100
|
+
for (let i = 0; i < args.length; i++) {
|
|
101
|
+
if (args[i] === '--platform' && args[i + 1]) opts.platform = args[++i]
|
|
102
|
+
else if (args[i] === '--mode' && args[i + 1]) opts.mode = args[++i]
|
|
103
|
+
else if (args[i] === '--device' && args[i + 1]) opts.device = args[++i]
|
|
104
|
+
}
|
|
105
|
+
return opts
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* `apt-tools mobile prepare <project-dir> --platform <ios|android>
|
|
110
|
+
* [--mode <expo|native>] [--device <id>]`
|
|
111
|
+
*
|
|
112
|
+
* @param {string} projectDir
|
|
113
|
+
* @param {string[]} args
|
|
114
|
+
* @returns {{ envelope: object, exitCode: number }}
|
|
115
|
+
*/
|
|
116
|
+
export function cmdMobilePrepare(projectDir, args) {
|
|
117
|
+
const opts = parseFlags(args ?? [])
|
|
118
|
+
if (opts.platform !== 'ios' && opts.platform !== 'android') {
|
|
119
|
+
return errorEnvelope('--platform <ios|android> is required')
|
|
120
|
+
}
|
|
121
|
+
if (opts.mode && opts.mode !== 'expo' && opts.mode !== 'native') {
|
|
122
|
+
return errorEnvelope(`--mode must be 'expo' or 'native', got "${opts.mode}"`)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Infer mode from the project shape when not explicitly given (ties the
|
|
126
|
+
// detector to the launch story — an Expo/RN project launches via `expo run`).
|
|
127
|
+
let mode = opts.mode
|
|
128
|
+
if (!mode) {
|
|
129
|
+
const caps = loadRuntimeCapabilities(projectDir ?? '.')
|
|
130
|
+
mode = caps.is_expo || caps.is_react_native ? 'expo' : 'native'
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const launch_sequence = planLaunchSequence({ platform: opts.platform, mode, device: opts.device })
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
envelope: {
|
|
137
|
+
status: 'ok',
|
|
138
|
+
command: 'mobile-prepare',
|
|
139
|
+
platform: opts.platform,
|
|
140
|
+
mode,
|
|
141
|
+
device: opts.device ?? null,
|
|
142
|
+
launch_sequence,
|
|
143
|
+
readiness_gate: READINESS_GATE,
|
|
144
|
+
note:
|
|
145
|
+
'Plan only — the verify-proof workflow runner executes the launch sequence, gates on ' +
|
|
146
|
+
'the readiness signals, then hands UI verbs to the mobile driver. System prereqs ' +
|
|
147
|
+
'(idb/adb/Xcode/SDK) are validated by `apt-tools driver doctor` (D-09).',
|
|
148
|
+
},
|
|
149
|
+
exitCode: 0,
|
|
150
|
+
}
|
|
151
|
+
}
|