pantheon-opencode 1.6.0 → 1.6.1

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 CHANGED
@@ -10,6 +10,35 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
10
10
  <!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
11
11
  move this section to a versioned entry and reset the template below. -->
12
12
 
13
+ ## [v1.6.1] - 2026-10-24
14
+
15
+ ### Added
16
+
17
+ - **docs** — Corrected code-mode tool signatures and agent grants, polished 1.6.x docs with translations/evidence links, and fixed the docs-site entry point (#270).
18
+
19
+ ### Changed
20
+
21
+ - **plugin** — V2 wires the read guard and bridge and restores supported context, image-history, formatter, and delegation-audit behavior (#264–#267).
22
+ - **plugin** — V2 reports host gaps `idle-todo-enforcer`, `todo-restore`, `tool-ceiling`, and `board-transitions` instead of claiming full parity.
23
+ - **install** — V2 notices report the resolved state path and shared V1/V2 state, not database isolation or a service port; capability output distinguishes the static seed and includes it in `--json`.
24
+ - **install** — SIGINT during blocking `spawnSync` may still be swallowed; cancellation is deterministic during awaited phases.
25
+
26
+ ### Fixed
27
+
28
+ - **plugin** — V1/V2 Zeus read guards normalize paths, resolve symlink targets, deny resolution failures, and align code-root checks with `pantheon_bounded_read` (#282).
29
+ - **plugin** — `pantheon_cost` sums per-model prices for multi-model agents and reconciles partial/unpriced usage with model totals (#260).
30
+ - **install** — Cancel/decline names the stopped step and records the run; Ctrl-C exits 130 during awaited phases (#261, #262).
31
+ - **install** — Fresh V2 installs write options-bearing plugin entries; migration moves only loadable entries and warns about sibling `opencode.jsonc` (#268, #269).
32
+
33
+ ### Security
34
+
35
+ - **deps** — Patched `zod` 4.6.6, `fastmcp` 4.1.2, `undici` 6.29.1/8.12.3, and `fast-uri` 3.1.9 to clear reported advisories (#275; PR #283).
36
+ - The guard does not pin an inode or make check/open atomic, so concurrent workspace writers can race it; it is a policy boundary, not isolation from hostile local processes.
37
+
38
+ ### Deprecated
39
+
40
+ ### Removed
41
+
13
42
  ## [v1.6.0] - 2026-10-22
14
43
 
15
44
  ### Added
package/README.md CHANGED
@@ -90,6 +90,44 @@ contract and targets OpenCode 2 only.
90
90
  The support policy, the known-broken exception, and the verified-version
91
91
  evidence have exactly one home: [Compatibility](docs/COMPATIBILITY.md).
92
92
 
93
+ ### V2 plugin options (opt-in features)
94
+
95
+ The OpenCode V2 host hands a plugin its `options` only from the object form of
96
+ the entry, and two features — per-request context pruning and ambient memory
97
+ injection — read exactly that bag. `init` therefore writes the object form, so
98
+ enabling them is one edit away and nothing is on by default:
99
+
100
+ ```json
101
+ {
102
+ "plugins": [
103
+ {
104
+ "package": "/path/to/pantheon-opencode/src/plugin-v2",
105
+ "options": {
106
+ "context_pruner": { "enabled": true },
107
+ "memory_injection": { "enabled": true }
108
+ }
109
+ }
110
+ ]
111
+ }
112
+ ```
113
+
114
+ Keep the `package` value `init` wrote and add keys inside `options`; any key you
115
+ add by hand survives a re-run. Both features are off unless `enabled` is
116
+ literally `true`.
117
+
118
+ | Option | Default | Effect |
119
+ |---|---|---|
120
+ | `options.context_pruner.enabled` | `false` | Prune old turns from the request payload and at compaction. Off by default because per-request pruning invalidates the provider prompt cache. |
121
+ | `options.memory_injection.enabled` | `false` | Ride the most relevant memory entries along on the session's first request, bounded by `maxEntries`/`maxChars`. |
122
+
123
+ `context_pruner` also accepts `keepTurns`, `purgeAfterTurns`, `protectedTools`,
124
+ `minSavingsTokens` and `charsPerToken`; `memory_injection` accepts `maxEntries`,
125
+ `maxChars` and `namespace`. Unknown keys are ignored with a one-time warning in
126
+ the hook log, so a typo cannot silently change behaviour. Run
127
+ `npx pantheon-opencode doctor` to see whether the installed entry can receive
128
+ options at all. Full rules: [OpenCode V2](docs/opencode-v2.md) and
129
+ [Memory](docs/MEMORY.md).
130
+
93
131
  ## Delegation
94
132
 
95
133
  Pantheon delegates through the host's native child-session engine: `subagent`
@@ -125,6 +163,12 @@ in [Architecture](docs/ARCHITECTURE.md) and
125
163
  | [Model Routing](docs/reference/model-routing.md) | [Env Vars](docs/reference/env-vars.md) · [Code Mode](docs/reference/code-mode.md) |
126
164
  | [Contributing](CONTRIBUTING.md) | [Roadmap](ROADMAP.md) · [Changelog](CHANGELOG.md) |
127
165
 
166
+ The release install gate's tool canary loads the installed tarball's V2 plugin
167
+ entry under OpenCode 2.0.30 and verifies `hashline_edit` registration, Code Mode
168
+ visibility, and a bounded edit in an isolated project. It does not prove npm
169
+ publication or compatibility with untested host versions; details are in the
170
+ [release process](docs/RELEASING.md).
171
+
128
172
  ## Status
129
173
 
130
174
  The manifests in this checkout express the version being prepared, not a
@@ -136,7 +180,7 @@ latest published changes.
136
180
  ## What's new
137
181
 
138
182
  See the [GitHub release](https://github.com/ils15/pantheon-opencode/releases)
139
- and [CHANGELOG.md](CHANGELOG.md) for the changes in 1.6.0.
183
+ and [CHANGELOG.md](CHANGELOG.md) for the changes in 1.6.1.
140
184
 
141
185
  ## Contribute
142
186
 
@@ -11,24 +11,30 @@
11
11
  * under BOTH OpenCode V1 (`opencode` 1.18.x) and V2 (`opencode2`, OpenCode 2.x —
12
12
  * `opencode2 --version` prints "opencode v2.0.22"; an early 2.x prerelease
13
13
  * printed "0.0.0-next-17444", which is history and not a host observation).
14
- * V2 reads the same config locations and normalizes V1
15
- * fields in memory — no native V2 conversion. `--version v2` labels the
16
- * install for the operator; state isolation is a runtime concern
17
- * (OPENCODE_DB ~/.local/share/opencode/opencode-v2.db, service port 49375).
14
+ * V2 reads the same config locations and normalizes V1 fields in memory through
15
+ * migrateV1toV2() (scripts/install/config-migration.mjs), then writes the
16
+ * V2-native `plugins` list. `--version v2` selects that path.
17
+ *
18
+ * State is NOT isolated per generation: both host generations read one OpenCode
19
+ * store, so this CLI claims neither a separate database nor a service port. The
20
+ * installer prints the path an actual resolver returns
21
+ * (scripts/install/opencode-state.mjs).
18
22
  */
19
23
  import fs from 'node:fs'
20
24
  import os from 'node:os'
21
25
  import path from 'node:path'
22
26
  import { fileURLToPath } from 'node:url'
23
- import { configure as configureUi, tag } from '../scripts/install/cli-ui.mjs'
27
+ import { configure as configureUi, endGaugeLine, tag } from '../scripts/install/cli-ui.mjs'
24
28
  import { resolveComponentSelection } from '../scripts/install/component-selection.mjs'
25
29
  import { resolveInstallExitCode } from '../scripts/install/exit-codes.mjs'
30
+ import { createInterruptHandler } from '../scripts/install/interrupt.mjs'
26
31
  import {
27
32
  createPlanArtifact,
28
33
  loadPlanArtifact,
29
34
  savePlanArtifact,
30
35
  } from '../scripts/install/plan-artifact.mjs'
31
36
  import { PROMPT_CANCELED } from '../scripts/install/prompt-result.mjs'
37
+ import { buildRunRecord, readRunRecord, writeRunRecord } from '../scripts/install/run-record.mjs'
32
38
  import {
33
39
  isSupportedNodeVersion,
34
40
  unsupportedNodeVersionMessage,
@@ -484,16 +490,79 @@ async function main() {
484
490
  process.exit(1)
485
491
  }
486
492
 
493
+ // Version info (resolved BEFORE the authorization prompts: every
494
+ // termination path below has to name its reason from the same table).
495
+ const version = readVersion()
496
+ const { strings } = await import('../scripts/install/strings.mjs')
497
+ const S = strings()
498
+ // Declared before the authorization prompts so a cancel/decline can record
499
+ // what the run decided; filled by the apply below.
500
+ let result = null
501
+ // Where a run record goes when the installer never reports a target: the
502
+ // interactive prompts can cancel before a location is chosen. Mirrors the
503
+ // installer's own default (`~/.config/opencode`), so the record lands next
504
+ // to the config the next run will read.
505
+ const fallbackTarget = isProject
506
+ ? process.cwd()
507
+ : path.join(os.homedir(), '.config', 'opencode')
508
+ /**
509
+ * Persist the one-line record of this run. Bookkeeping is best-effort: a
510
+ * failure is reported, never fatal, and never changes the exit code.
511
+ *
512
+ * @param {{status: string, reason?: string|null, cancelPoint?: string|null, applied: boolean, target?: string}} outcome
513
+ */
514
+ const recordRun = (outcome) => {
515
+ const recordTarget = outcome.target ?? result?.target ?? fallbackTarget
516
+ const record = buildRunRecord({
517
+ status: outcome.status,
518
+ reason: outcome.reason ?? null,
519
+ cancelPoint: outcome.cancelPoint ?? null,
520
+ mode: 'apply',
521
+ applied: outcome.applied,
522
+ pantheonVersion: version,
523
+ })
524
+ const written = writeRunRecord(recordTarget, record)
525
+ if (!written.written) {
526
+ console.error(S.runRecordFailed(written.error ?? written.path))
527
+ }
528
+ }
529
+
530
+ // A previous run that applied nothing is worth one line on the next run:
531
+ // "canceled at the review prompt" is otherwise a thing the user has to
532
+ // rediscover. Only non-applied outcomes are surfaced; a normal re-install is
533
+ // not news.
534
+ if (!isDryRun && !isJson) {
535
+ const previous = readRunRecord(reviewedPlan ? reviewedPlan.target.path : fallbackTarget)
536
+ if (previous !== null && previous.applied === false && previous.status !== 'plan') {
537
+ console.log(` ${S.previousRun(previous.summary ?? previous.status)}`)
538
+ }
539
+ }
540
+
487
541
  if (reviewedPlan && !autoYes) {
488
542
  if (!forceHeadless && process.stdin.isTTY && process.stdout.isTTY) {
489
543
  const authorization = await authorizeReviewedPlan(reviewedPlan)
490
544
  if (authorization === PROMPT_CANCELED) {
491
- console.log('❌ Install canceled; no files were written.')
545
+ // The prompt already printed the single cancel line, naming the
546
+ // review point; only the exit code and the record are left.
547
+ recordRun({
548
+ status: 'canceled',
549
+ reason: 'canceled',
550
+ cancelPoint: 'review',
551
+ applied: false,
552
+ target: reviewedPlan.target.path,
553
+ })
492
554
  process.exitCode = 130
493
555
  return
494
556
  }
495
557
  if (!authorization) {
496
- console.log('❌ Install declined; no files were written.')
558
+ console.error(S.declinedAt(S.cancelPoints.review))
559
+ recordRun({
560
+ status: 'declined',
561
+ reason: 'declined',
562
+ cancelPoint: 'review',
563
+ applied: false,
564
+ target: reviewedPlan.target.path,
565
+ })
497
566
  return
498
567
  }
499
568
  } else {
@@ -503,11 +572,6 @@ async function main() {
503
572
  autoYes = true
504
573
  }
505
574
 
506
- // Version info
507
- const version = readVersion()
508
- const { strings } = await import('../scripts/install/strings.mjs')
509
- const S = strings()
510
-
511
575
  const planTimestamp = reviewedPlan?.planned_at ?? new Date().toISOString()
512
576
  const stdoutWrite = process.stdout.write
513
577
  if (isJson) process.stdout.write = () => true
@@ -519,7 +583,28 @@ async function main() {
519
583
  }
520
584
  }
521
585
 
522
- let result
586
+ // Ctrl-C was unhandled anywhere in bin/ or scripts/install/, so an
587
+ // interrupted install died without printing anything and without leaving a
588
+ // trace. The handler makes the interrupt behave like every other cancel:
589
+ // ONE explainable line, a record on disk, and exit 130. The prompt library
590
+ // consumes Ctrl-C in raw mode while a question is on screen (that path is
591
+ // the interactive cancel above), so this covers the rest of the run.
592
+ const onInterrupt = createInterruptHandler({
593
+ message: S.canceledAt(S.cancelPoints.interrupt),
594
+ json: isJson,
595
+ endGaugeLine,
596
+ onInterrupt: () => {
597
+ if (!isDryRun) {
598
+ recordRun({
599
+ status: 'canceled',
600
+ reason: 'canceled',
601
+ cancelPoint: 'interrupt',
602
+ applied: false,
603
+ })
604
+ }
605
+ },
606
+ })
607
+
523
608
  let installError = null
524
609
  try {
525
610
  const { installOpenCode } = await import('../scripts/install/opencode.mjs')
@@ -557,14 +642,13 @@ async function main() {
557
642
  })}\n`,
558
643
  )
559
644
  console.error(`❌ Init dry-run failed: ${installError.message}`)
560
- } else if (installError?.message === 'Canceled') {
561
- console.error(S.canceled)
562
- process.exit(130)
563
645
  } else {
564
646
  console.error(
565
647
  `${S.installFailed(installError.message)}\n${S.failHintNoMcp}\n${S.failHintForce}`,
566
648
  )
567
649
  }
650
+ // No record for a thrown failure: the error itself is the explanation,
651
+ // and a run that failed has nothing to remember beyond its message.
568
652
  process.exitCode = 1
569
653
  return
570
654
  }
@@ -624,12 +708,23 @@ async function main() {
624
708
  status: 'planned',
625
709
  target: result.target,
626
710
  open_code_version: result.openCodeVersion,
627
- advisories: result.versionAssumed
628
- ? [
629
- 'The OpenCode host generation could not be detected; this plan assumes V1 ' +
630
- 'and may diverge from the apply. Pass --opencode-version v1|v2 to pin it.',
631
- ]
632
- : [],
711
+ advisories: [
712
+ ...(result.versionAssumed
713
+ ? [
714
+ 'The OpenCode host generation could not be detected; this plan assumes V1 ' +
715
+ 'and may diverge from the apply. Pass --opencode-version v1|v2 to pin it.',
716
+ ]
717
+ : []),
718
+ // Warnings printed in text mode are suppressed by --quiet, so the
719
+ // machine-readable plan carries them too (e.g. a sibling
720
+ // opencode.jsonc the installer neither reads nor writes).
721
+ ...(result.configAdvisories ?? []),
722
+ ],
723
+ // A V2 plan carries the same capability facts the text notice prints:
724
+ // what the generation registers, what it does not (the static seed),
725
+ // and whether the written plugin entry can receive `options` at all.
726
+ v2_capabilities: result.v2Capabilities ?? null,
727
+ plugin_options: result.pluginOptions ?? null,
633
728
  totals,
634
729
  mcp_servers: mcpServers,
635
730
  mcp_server_count: mcpServers.length,
@@ -650,7 +745,25 @@ async function main() {
650
745
  // 130 canceled · 1 failure (thrown above).
651
746
  if (result?.applied === false) {
652
747
  if (!isDryRun) {
653
- if (result.reason === 'canceled') console.error(S.canceled)
748
+ // The installer already printed the ONE line for this outcome naming
749
+ // its reason (cancel point / decline / not-authorized). Printing
750
+ // another here is what made a cancel appear twice on two paths. All
751
+ // that is left is to make the DECISION survive the terminal.
752
+ //
753
+ // Gate refusals (`not-authorized`, `drift`) are deliberately NOT
754
+ // recorded: those runs are refused before anything is written, and
755
+ // "an unauthorized run writes nothing" is a guarantee of this
756
+ // installer, not an accident. They still print their own reason and
757
+ // their own exit code.
758
+ if (result.reason === 'canceled' || result.reason === 'declined') {
759
+ recordRun({
760
+ status: result.reason,
761
+ reason: result.reason,
762
+ cancelPoint: result.cancelPoint ?? null,
763
+ applied: false,
764
+ target: result.target,
765
+ })
766
+ }
654
767
  process.exit(resolveInstallExitCode(result, isDryRun))
655
768
  }
656
769
  // Dry-run preview: report honestly instead of the "installed!" banner.
@@ -659,6 +772,22 @@ async function main() {
659
772
  return
660
773
  }
661
774
 
775
+ // Applied: record it, so the next run can tell an apply from a cancel or a
776
+ // decline without reading install-state.json (written only on apply).
777
+ if (!isDryRun) {
778
+ recordRun({
779
+ status: 'applied',
780
+ reason: 'applied',
781
+ applied: true,
782
+ target: result?.target,
783
+ })
784
+ // The interrupt handler describes an install that was in flight. It must
785
+ // not outlive it: `--doctor` runs AFTER this point, and a Ctrl-C there
786
+ // would otherwise rewrite a completed install as canceled/applied:false
787
+ // and print "nothing was applied".
788
+ onInterrupt.deactivate()
789
+ }
790
+
662
791
  if (runDoctor && !isDryRun) {
663
792
  console.log('')
664
793
  console.log(` ${S.runningHealthCheck}`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantheon-opencode",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Multi-agent orchestration for OpenCode — 14 specialized agents, TDD, Themis review gates.",
5
5
  "type": "module",
6
6
  "workspaces": [
@@ -51,7 +51,7 @@
51
51
  "coverage:plugin-v2": "node scripts/check-plugin-v2-coverage.mjs",
52
52
  "test:ts": "for f in tests/pantheon/*.test.ts; do if [ \"$f\" = tests/pantheon/plugin-v2-contract.test.ts ]; then NODE_OPTIONS=--conditions=import tsx \"$f\"; else tsx \"$f\"; fi || exit 1; done",
53
53
  "test:hooks": "node scripts/run-node-tests.mjs --label 'test:hooks' 'tests/pantheon/plugin-v2-hook-canary.test.mjs'",
54
- "test:tool-canary": "node scripts/run-node-tests.mjs --label 'test:tool-canary' 'tests/canary/plugin-v2-tool-canary.test.mjs'",
54
+ "test:tool-canary": "node scripts/run-node-tests.mjs --label 'test:tool-canary' 'tests/canary/tool-canary-support.test.mjs' 'tests/canary/plugin-v2-tool-canary.test.mjs'",
55
55
  "test:all": "npm run test:ci && npm run test:node && npm run test:ts",
56
56
  "test": "npm run test:all",
57
57
  "test:ci": "python3 -m pytest -q --tb=short 2>&1"
@@ -107,7 +107,7 @@
107
107
  "@opencode-ai/plugin": "1.18.33",
108
108
  "@opencode-ai/sdk": "1.18.33",
109
109
  "js-yaml": "^5.4.2",
110
- "zod": "4.1.8"
110
+ "zod": "4.6.6"
111
111
  },
112
112
  "devDependencies": {
113
113
  "@biomejs/biome": "2.5.14",
@@ -123,9 +123,10 @@
123
123
  "seroval": "1.6.8",
124
124
  "solid-js": "1.9.12",
125
125
  "rolldown": "1.2.7",
126
- "toml": "5.0.1"
126
+ "toml": "5.0.1",
127
+ "zod": "4.6.6"
127
128
  },
128
- "//overrides": "TUI production advisory fixes: Babel >=7.29.6 and Seroval >=1.6.3; Solid stays at 1.9.12 to satisfy OpenTUI's exact peer. Remove only after upstream ranges include fixed versions; Seroval compatibility is covered by the Solid serializer regression test.",
129
+ "//overrides": "TUI production advisory fixes: Babel >=7.29.6 and Seroval >=1.6.3; zod >=4.6.6 for GHSA-mrhx-c7xc-m3w5 (@opencode-ai/plugin pins zod 4.1.8 exactly, so the override is the only way to move it, and the same entry is mirrored in src/plugins/tui/package.json for the shipped TUI lock); Solid stays at 1.9.12 to satisfy OpenTUI's exact peer. Remove only after upstream ranges include fixed versions; Seroval compatibility is covered by the Solid serializer regression test.",
129
130
  "repository": {
130
131
  "type": "git",
131
132
  "url": "https://github.com/ils15/pantheon-opencode.git"
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pantheon",
3
3
  "publisher": "ils15",
4
- "version": "1.6.0",
4
+ "version": "1.6.1",
5
5
  "displayName": "Pantheon",
6
6
  "description": "Conductor-Delegate orchestration platform with 14 specialized agents, 20 skills, and OpenCode support.",
7
7
  "agents": "./src/agents",
package/pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "setuptools.backends._legacy:_Backend"
4
4
 
5
5
  [project]
6
6
  name = "pantheon"
7
- version = "1.6.0"
7
+ version = "1.6.1"
8
8
  description = "Multi-agent orchestration framework"
9
9
  requires-python = ">=3.11"
10
10
  # Python sources under src/mcp/ import fastmcp/pydantic at runtime, but those
@@ -33,6 +33,7 @@ import { listV2UnsupportedFeatures } from '../src/pantheon/v2-unsupported.mjs'
33
33
  import { classifyFileInventory } from './install/file-inventory.mjs'
34
34
  import { staleTuiRefs } from './install/plugin.mjs'
35
35
  import { readState } from './install/state.mjs'
36
+ import { describePluginOptionsReachability } from './install/v2-capabilities.mjs'
36
37
  import { isSupportedNodeVersion, MIN_SUPPORTED_NODE_VERSION } from './node-engine-policy.mjs'
37
38
 
38
39
  // ---------------------------------------------------------------------------
@@ -1664,17 +1665,19 @@ export function describeV2Reduction({ registered, features }) {
1664
1665
  'Pantheon IS registered on the V2 plugin generation, but the shared ' +
1665
1666
  'unsupported-feature seed is empty, so the reduction cannot be reported. ' +
1666
1667
  "That is a fault in this installation's reporting, not an absence of " +
1667
- 'reduction: the V2 surface still drops the 3 goal tools and the ' +
1668
- 'caller/target delegation matrix.',
1668
+ 'reduction: the V2 surface still registers fewer tools than V1 (the three ' +
1669
+ 'goal tools are absent), so a clean report would be false.',
1669
1670
  }
1670
1671
  }
1671
1672
  return {
1672
1673
  status: 'reported',
1673
1674
  level: 'warn',
1674
1675
  message:
1675
- 'Pantheon is registered on the V2 plugin generation, which registers 3 tools ' +
1676
- "(hashline_edit, pantheon_cost, pantheon_model) instead of the V1 surface's 6 plus " +
1677
- `the BackgroundJobBoard and the caller/target delegation matrix. Unsupported: ${features.join(', ')}`,
1676
+ 'Pantheon is registered on the V2 plugin generation: 3 unconditional tools ' +
1677
+ '(hashline_edit, pantheon_cost, pantheon_model) plus the host-dependent ones, and a ' +
1678
+ "real hook/transform surface, against the V1 surface's 6 tools plus the " +
1679
+ 'BackgroundJobBoard. Not provided on V2 (static seed — a live host can add runtime ' +
1680
+ `markers on top): ${features.join(', ')}`,
1678
1681
  }
1679
1682
  }
1680
1683
 
@@ -1707,6 +1710,20 @@ export function checkV2UnsupportedFeatures(args) {
1707
1710
  if (verdict.level === 'info') info(verdict.message)
1708
1711
  else warn(verdict.message)
1709
1712
 
1713
+ // Whether the installed entry can receive plugin `options` at all: the host
1714
+ // passes them only from the object form, and `context_pruner` /
1715
+ // `memory_injection` read exactly that bag. A bare-string entry installs fine
1716
+ // and silently leaves both opt-ins unreachable, which is why this reports the
1717
+ // installed shape instead of trusting the installer to have got it right.
1718
+ if (registered) {
1719
+ const plugins = configs.flatMap((cfg) =>
1720
+ Array.isArray(cfg.data?.plugins) ? cfg.data.plugins : [],
1721
+ )
1722
+ const reach = describePluginOptionsReachability(plugins)
1723
+ if (reach.reachable) info(`Plugin options reachable: ${reach.detail}`)
1724
+ else warn(`Plugin options NOT reachable: ${reach.detail}`)
1725
+ }
1726
+
1710
1727
  return verdict.status
1711
1728
  }
1712
1729
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  import * as clack from '@clack/prompts'
4
4
  import { PROMPT_CANCELED } from './prompt-result.mjs'
5
+ import { strings } from './strings.mjs'
5
6
 
6
7
  export { PROMPT_CANCELED }
7
8
 
@@ -9,9 +10,21 @@ function isTerminal() {
9
10
  return Boolean(process.stdin.isTTY && process.stdout.isTTY)
10
11
  }
11
12
 
12
- function cancelPrompt(prompts, value) {
13
+ /**
14
+ * Print the ONE cancel line, naming where the user stopped.
15
+ *
16
+ * The point is a stable key from the string table (`cancelPoints`), so the same
17
+ * identifier can be persisted in the run record without parsing prose.
18
+ *
19
+ * @param {typeof clack} prompts
20
+ * @param {unknown} value a prompt result
21
+ * @param {string} point stable cancel-point key
22
+ * @returns {boolean} whether the prompt was canceled
23
+ */
24
+ function cancelPrompt(prompts, value, point) {
13
25
  if (!prompts.isCancel(value)) return false
14
- prompts.cancel('Installation canceled.')
26
+ const S = strings()
27
+ prompts.cancel(S.canceledAt(S.cancelPoints[point] ?? point))
15
28
  return true
16
29
  }
17
30
 
@@ -28,7 +41,7 @@ export async function promptReview(
28
41
  ) {
29
42
  if (!isTTY) return false
30
43
  const result = await prompts.confirm({ message: planSummary, initialValue: defaultValue })
31
- if (cancelPrompt(prompts, result)) return PROMPT_CANCELED
44
+ if (cancelPrompt(prompts, result, 'review')) return PROMPT_CANCELED
32
45
  return result === true
33
46
  }
34
47
 
@@ -36,7 +49,11 @@ export async function promptReview(
36
49
  * Collect interactive setup choices before the installer begins any writes.
37
50
  *
38
51
  * @param {{ components?: string[], defaultComponents?: string[], noMcp?: boolean, prompts?: typeof clack, isTTY?: boolean }} [options]
39
- * @returns {Promise<{ components?: Set<string>, target?: string, confirmed?: boolean, canceled?: boolean }>}
52
+ * @returns {Promise<{ components?: Set<string>, target?: string, confirmed?: boolean, canceled?: boolean, cancelPoint?: string }>}
53
+ *
54
+ * `cancelPoint` names the step the user stopped at (`components`, `target`,
55
+ * `confirmation`), so the caller can print one explainable line and persist the
56
+ * same stable key in the run record.
40
57
  */
41
58
  export async function runInteractiveInstall({
42
59
  components = [],
@@ -70,12 +87,14 @@ export async function runInteractiveInstall({
70
87
  initialValues: [...defaultSet],
71
88
  required: false,
72
89
  })
73
- if (cancelPrompt(prompts, chosen)) return { canceled: true }
90
+ if (cancelPrompt(prompts, chosen, 'components'))
91
+ return { canceled: true, cancelPoint: 'components' }
74
92
 
75
93
  const selectedComponents = new Set(chosen.filter(isAllowed))
76
94
  if (selectedComponents.size === 0) {
77
- prompts.cancel?.('No components selected. Installation canceled.')
78
- return { canceled: true }
95
+ const S = strings()
96
+ prompts.cancel?.(S.canceledAt(S.cancelPoints.components))
97
+ return { canceled: true, cancelPoint: 'components' }
79
98
  }
80
99
 
81
100
  const target = await prompts.select({
@@ -89,13 +108,15 @@ export async function runInteractiveInstall({
89
108
  { label: 'Current project', value: 'project', hint: './.opencode (scoped to this project)' },
90
109
  ],
91
110
  })
92
- if (cancelPrompt(prompts, target)) return { canceled: true }
111
+ if (cancelPrompt(prompts, target, 'target')) return { canceled: true, cancelPoint: 'target' }
93
112
 
94
113
  const confirmed = await prompts.confirm({
95
114
  message: `Install ${selectedComponents.size} component(s) in ${target === 'global' ? 'global config' : 'current project'}?`,
96
115
  initialValue: true,
97
116
  })
98
- if (cancelPrompt(prompts, confirmed)) return { canceled: true }
117
+ if (cancelPrompt(prompts, confirmed, 'confirmation')) {
118
+ return { canceled: true, cancelPoint: 'confirmation' }
119
+ }
99
120
 
100
121
  return { components: selectedComponents, target, confirmed }
101
122
  }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * interrupt.mjs — Ctrl-C behaves like every other cancel, for the window in
3
+ * which the installer is actually working.
4
+ *
5
+ * Before this existed, NOTHING under `bin/` or `scripts/install/` handled
6
+ * SIGINT: an interrupted install died by default action, printed no reason, and
7
+ * left no trace — the user could not tell an interrupt from a crash, and a
8
+ * re-run could not tell what the previous attempt did. The prompt library
9
+ * consumes Ctrl-C in raw mode while a question is on screen, so this covers the
10
+ * rest of the run (backup, copies, config write, state write).
11
+ *
12
+ * LIFETIME MATTERS AS MUCH AS THE MESSAGE: the handler is registered when the
13
+ * install starts and must be DEACTIVATED once the run has been recorded. Left
14
+ * registered, a Ctrl-C during the post-install `--doctor` step would rewrite a
15
+ * COMPLETED install as `canceled / applied:false` and claim nothing was
16
+ * applied. {@link createInterruptHandler} therefore owns its registration and
17
+ * exposes `deactivate()` for the caller to call at that point.
18
+ *
19
+ * Contract, all of it pinned by tests:
20
+ * - exactly ONE message is printed, and it names the interrupt as the point;
21
+ * - with `--json`, the message goes to stderr so stdout stays parsable;
22
+ * - the outcome is recorded once (a second Ctrl-C must not record twice);
23
+ * - the exit code is 130, the documented "canceled" code;
24
+ * - after `deactivate()`, the signal is no longer handled at all.
25
+ *
26
+ * Kept injectable rather than reading globals so the exit code, the streams,
27
+ * the emitter and the record call are all observable in a unit test.
28
+ *
29
+ * @module interrupt
30
+ */
31
+
32
+ /**
33
+ * Build and REGISTER a SIGINT handler.
34
+ *
35
+ * @param {{
36
+ * message: string,
37
+ * json?: boolean,
38
+ * onInterrupt?: () => void,
39
+ * endGaugeLine?: () => void,
40
+ * writeStderr?: (line: string) => void,
41
+ * logStderr?: (line: string) => void,
42
+ * exit?: (code: number) => void,
43
+ * emitter?: { once: (event: string, listener: () => void) => unknown, removeListener: (event: string, listener: () => void) => unknown },
44
+ * }} options
45
+ * @returns {(() => void) & { deactivate: () => void }} the registered handler
46
+ */
47
+ export function createInterruptHandler({
48
+ message,
49
+ json = false,
50
+ onInterrupt = () => {},
51
+ endGaugeLine = () => {},
52
+ writeStderr = (line) => process.stderr.write(`${line}\n`),
53
+ logStderr = (line) => console.error(line),
54
+ exit = (code) => process.exit(code),
55
+ emitter = process,
56
+ }) {
57
+ let handled = false
58
+ const handle = function handleInterrupt() {
59
+ if (handled) return
60
+ handled = true
61
+ try {
62
+ // The progress gauge owns the current terminal line; close it so the
63
+ // message is not appended to a half-drawn bar and then erased.
64
+ endGaugeLine()
65
+ if (json) writeStderr(message)
66
+ else logStderr(message)
67
+ onInterrupt()
68
+ } finally {
69
+ exit(130)
70
+ }
71
+ }
72
+ /** Stop handling SIGINT: the run this handler described is over. */
73
+ handle.deactivate = () => {
74
+ emitter.removeListener('SIGINT', handle)
75
+ }
76
+ emitter.once('SIGINT', handle)
77
+ return handle
78
+ }