instar 1.2.11 → 1.2.12

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.
@@ -0,0 +1,82 @@
1
+ # Upgrade Guide — v1.2.12 (hybrid wizard for Codex runtime)
2
+
3
+ <!-- bump: patch -->
4
+ <!-- patch = bug fixes, refactors, test additions, doc updates -->
5
+
6
+ ## What Changed
7
+
8
+ **New: hybrid setup wizard for Codex-runtime installs.**
9
+
10
+ `npx instar` → pick Codex CLI at the runtime prompt → now reaches
11
+ an actual conversational walkthrough. Before this release, Codex
12
+ ignored the wizard skill's behavioral contract and executed the
13
+ entire setup non-interactively, leaving the user with a generic
14
+ agent identity they never got to shape.
15
+
16
+ The fix is a two-layer architecture under
17
+ `src/commands/setup-wizard/`:
18
+
19
+ 1. **State machine** owns the conversation flow. Each state has a
20
+ structural prompt printed verbatim by instar, a deterministic
21
+ transition function, and (for action states) a side effect call
22
+ to existing CLI commands. Order is fixed in TypeScript code; no
23
+ LLM can drift it.
24
+
25
+ 2. **Codex driver** drives the state machine turn-by-turn. For each
26
+ conversational state, the driver runs `codex exec -s read-only
27
+ -m gpt-5.3-codex --ephemeral` with a tightly-constrained prompt
28
+ asking Codex to generate ONE warm 2-3 sentence intro paragraph.
29
+ The structural prompt is printed by instar; readline reads the
30
+ answer. Codex cannot use tools, cannot reword the question,
31
+ cannot decide to execute the setup itself.
32
+
33
+ 3. **Telegram setup phase** hands off to Codex as a full agentic
34
+ session (sandbox bypass + Playwright access) — driving the
35
+ browser is execution, which is Codex's strength.
36
+
37
+ Claude-runtime users see no change. The Claude path keeps the
38
+ existing `/setup-wizard` slash-command spawn.
39
+
40
+ Settings the user picks during the wizard (agent name, focus,
41
+ autonomy level, messaging channel) can all be changed later just
42
+ by chatting the agent. The farewell text and the autonomy step's
43
+ narrative both surface this affordance.
44
+
45
+ Spec: `specs/dev-infrastructure/hybrid-wizard.md`.
46
+ ELI16: `specs/dev-infrastructure/hybrid-wizard.eli16.md`.
47
+ Side-effects review: `upgrades/side-effects/feat-hybrid-wizard.md`.
48
+
49
+ ## What to Tell Your User
50
+
51
+ The setup wizard now walks you through identity, autonomy, and
52
+ messaging conversationally, regardless of which runtime you picked.
53
+ On Codex, the wizard runs as a state machine in instar itself with
54
+ Codex generating the warm narrative for each step; on Claude it
55
+ runs the same way it always has. Anything you set up can be
56
+ changed later just by chatting your agent — no need to re-run setup.
57
+
58
+ ## Summary of New Capabilities
59
+
60
+ - New module: `src/commands/setup-wizard/` (state machine + Codex
61
+ driver + model constants).
62
+ - New CLI behavior: `npx instar` → pick Codex CLI → conversational
63
+ wizard with per-step narrative from Codex.
64
+ - Existing CLI surface unchanged.
65
+
66
+ ## Evidence
67
+
68
+ Reproduction prior to fix: ran v1.2.11 install via bareword `npx
69
+ instar` → picked Codex. Codex received the wizard skill prompt and
70
+ executed the entire setup non-interactively. Full log captured at
71
+ `setup-logs.md` in the test project — 2940 lines, zero
72
+ conversational walkthrough.
73
+
74
+ After fix:
75
+ - 12 new state-machine unit tests cover the choice resolver, graph
76
+ integrity, identity-answer threading, messaging branching, and
77
+ the post-server completion chain.
78
+ - 5 updated canary tests cover the dispatch contract: setup.ts
79
+ imports `runCodexWizard` for codex-cli, no codex exec argv with
80
+ the wizard skill prompt remains in setup.ts, the driver's codex
81
+ exec spawns still pin `-m WIZARD_CODEX_MODEL`.
82
+ - End-to-end re-test on the Codex install path pending on publish.
@@ -0,0 +1,122 @@
1
+ # Side-effects review — Hybrid wizard
2
+
3
+ Per L6. Seven dimensions.
4
+
5
+ ## 1. Over-block / under-block
6
+
7
+ Before: UNDER for Codex-runtime users. The bareword runtime prompt
8
+ let users pick Codex, which then spawned Codex with the wizard skill.
9
+ Codex ignored the skill's conversational contract and executed setup
10
+ non-interactively. Generic agent identity, no walkthrough.
11
+
12
+ After: precisely targeted. instar's state machine owns the
13
+ conversation flow; Codex is restricted per-turn to narrative-only
14
+ generation. Claude users see zero change (they keep the existing
15
+ SKILL.md-driven spawn). API-key Codex users keep the same auth
16
+ posture they had before. The agentic Telegram phase still uses
17
+ Codex with full sandbox bypass — that's the right tool for browser
18
+ automation.
19
+
20
+ ## 2. Level-of-abstraction fit
21
+
22
+ A new directory `src/commands/setup-wizard/` holds three files:
23
+ - `state-machine.ts` — pure data + transition functions, no I/O.
24
+ - `codex-driver.ts` — I/O (codex spawn, readline, CLI subcommands).
25
+ - `model-constants.ts` — single constant import target.
26
+
27
+ setup.ts adds one dispatch branch (~12 LOC). It dynamically imports
28
+ the codex driver only when the user picks Codex, keeping the
29
+ setup.ts module load lightweight.
30
+
31
+ The state machine is intentionally a flat record of states; no
32
+ class hierarchy, no event emitters. Drivers consume it via simple
33
+ lookups. Adding a state is one edit.
34
+
35
+ ## 3. Signal vs Authority compliance
36
+
37
+ - The user's runtime choice from the bareword prompt remains an
38
+ operator-intent SIGNAL flowing into `enabledFrameworks` and the
39
+ wizard dispatch.
40
+ - The state graph's transition functions are deterministic AUTHORITIES
41
+ for "what state comes next" given a user answer. Codex never sees
42
+ the transition function and cannot influence routing.
43
+ - `WIZARD_CODEX_MODEL` is the AUTHORITY for which Codex model the
44
+ narrative spawns use, drawn from the existing empirically-probed
45
+ availability table at `src/providers/adapters/openai-codex/models.ts`.
46
+ - The agentic Telegram phase respects the existing AUTHORITY for
47
+ Telegram bot creation (BotFather / OpenAI Codex's tool access /
48
+ Playwright MCP).
49
+
50
+ ## 4. Interactions with adjacent systems
51
+
52
+ - **v1.2.1 runtime prompt** (`promptForFramework`): unchanged. Still
53
+ reads `1`/`2`/`codex` and returns the chosen runtime.
54
+ - **`checkFrameworkPrerequisite`**: unchanged. Still validates the
55
+ chosen runtime's binary is detected.
56
+ - **`ensureSecretBackend`** (Phase 2.5): unchanged in v1.2.12. Still
57
+ spawns the chosen framework with `/secret-setup` for the secret
58
+ backend choice. A future PR can route secret-setup through the
59
+ state machine too, but for v1.2.12 we keep that scope bounded.
60
+ - **Existing wizard SKILL.md**: unchanged. Still owned by the Claude
61
+ path; the Codex path uses it ONLY as a reference target for the
62
+ Telegram-agentic phase prompt.
63
+ - **CLI subcommands the wizard calls** (`init`, `user add`, `server
64
+ start`, `autostart install`): unchanged. The driver calls them via
65
+ `execFileSync('npx', ['instar', ...])` the same way the existing
66
+ SKILL.md tells Claude to call them.
67
+ - **PR #299's canary**: updated. Previously asserted every `codex exec`
68
+ in setup.ts carries `-m WIZARD_CODEX_MODEL`. v1.2.12 asserts setup.ts
69
+ no longer has codex exec spawns (they moved into codex-driver.ts),
70
+ setup.ts dispatches via `runCodexWizard`, and the driver's codex
71
+ exec spawns still carry `-m WIZARD_CODEX_MODEL`.
72
+
73
+ ## 5. Rollback cost
74
+
75
+ Low. Three new files in a new directory plus one ~12-LOC dispatch
76
+ branch in setup.ts. The old `codex exec` argv shape in setup.ts is
77
+ removed; reverting reintroduces it. Claude path untouched.
78
+
79
+ `git revert` restores the v1.2.11 broken-on-Codex behavior. No state
80
+ migration; no agent-installed-files changes; no `PostUpdateMigrator`
81
+ work needed.
82
+
83
+ ## 6. Backwards compatibility / drift surface
84
+
85
+ Fully backwards-compatible.
86
+
87
+ - Claude-runtime users: zero change.
88
+ - Codex-runtime users: now get a working conversational wizard
89
+ driven by instar with Codex-generated narrative. Previously got
90
+ broken non-interactive setup.
91
+ - API-key Codex users: auth posture unchanged. `CODEX_MODEL` env
92
+ still overrides the wizard's `-m` flag if they prefer a different
93
+ model.
94
+ - No config schema change. No agent file template change. No hook
95
+ change.
96
+
97
+ Drift surface: the state graph and per-turn narrative prompts. Both
98
+ are flat data structures, so drift is visible in PR diffs. The
99
+ canary covers the dispatch shape; manual review covers narrative
100
+ prompt quality.
101
+
102
+ ## 7. Authorization / Trust posture
103
+
104
+ No new authority. The per-turn narrative codex spawns use `-s
105
+ read-only` (a strictly lower-privilege sandbox than the
106
+ `--dangerously-bypass-approvals-and-sandbox` the existing wizard
107
+ spawn uses). The Telegram-agentic phase keeps the existing sandbox-
108
+ bypass posture so it can drive Playwright. The action states call
109
+ `execFileSync('npx', ...)` for `init`, `user add`, `server start`,
110
+ `autostart install` — the same CLI surface the existing wizard
111
+ calls.
112
+
113
+ No new auth, no new gate, no new privilege.
114
+
115
+ ## Outcome
116
+
117
+ Ship. Closes the broken-on-Codex install experience that the v1.2.11
118
+ instar-codey log surfaced. Per-framework specialization preserves
119
+ each runtime's strengths (Claude's reliable skill-following, Codex's
120
+ strong execution mode for agentic phases). Structure-as-guarantee
121
+ prevents the regression class. Canary in CI guards the dispatch
122
+ contract.