pantheon-opencode 1.6.0 → 1.6.2-beta.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/AGENTS.global.md +11 -11
- package/AGENTS.md +2 -2
- package/CHANGELOG.md +45 -0
- package/README.md +122 -6
- package/README.pt-BR.md +14 -9
- package/bin/pantheon-init.mjs +255 -39
- package/package.json +8 -6
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/build-agents-md.mjs +1 -1
- package/scripts/doctor.mjs +231 -46
- package/scripts/install/agents-md.mjs +2 -1
- package/scripts/install/config-migration.mjs +344 -393
- package/scripts/install/config-paths.mjs +15 -0
- package/scripts/install/interactive.mjs +30 -9
- package/scripts/install/interrupt.mjs +78 -0
- package/scripts/install/mcp-permissions.mjs +164 -0
- package/scripts/install/opencode-state.mjs +91 -0
- package/scripts/install/opencode-version.mjs +31 -13
- package/scripts/install/opencode-wildcard.mjs +106 -0
- package/scripts/install/opencode.mjs +508 -108
- package/scripts/install/plan-artifact.mjs +12 -1
- package/scripts/install/plugin.mjs +17 -1
- package/scripts/install/run-record.mjs +115 -0
- package/scripts/install/strings.mjs +35 -6
- package/scripts/install/v2-capabilities.mjs +204 -0
- package/scripts/package-evidence.mjs +1 -0
- package/scripts/release-gates.mjs +7 -2
- package/scripts/sandbox-env.sh +174 -0
- package/scripts/setup-v2-config.mjs +1703 -0
- package/scripts/setup.mjs +415 -0
- package/scripts/sync-tui.mjs +9 -1
- package/scripts/test-opencode-v2-sandbox.sh +438 -151
- package/scripts/update-skills-lock.mjs +30 -0
- package/skills-lock.json +10 -10
- package/src/agents/aphrodite.md +5 -2
- package/src/agents/apollo.md +5 -0
- package/src/agents/athena.md +6 -1
- package/src/agents/demeter.md +5 -1
- package/src/agents/gaia.md +4 -0
- package/src/agents/hephaestus.md +6 -1
- package/src/agents/hermes.md +6 -3
- package/src/agents/iris.md +5 -1
- package/src/agents/mnemosyne.md +20 -50
- package/src/agents/nyx.md +5 -1
- package/src/agents/prometheus.md +4 -0
- package/src/agents/talos.md +4 -0
- package/src/agents/themis.md +4 -0
- package/src/agents/zeus.md +9 -3
- package/src/instructions/agent-return-format.instructions.md +1 -1
- package/src/instructions/memory-protocol.instructions.md +3 -3
- package/src/instructions/test-economy.instructions.md +6 -6
- package/src/mcp/pantheon_vision.py +37 -36
- package/src/mcp/requirements-mcp.txt +1 -1
- package/src/mcp/requirements-vision.txt +1 -1
- package/src/pantheon/cost-command.ts +127 -40
- package/src/pantheon/delegation-enforce.ts +160 -23
- package/src/pantheon/guard-path.ts +162 -0
- package/src/pantheon/v2-bounded-read.ts +15 -1
- package/src/pantheon/v2-bridge.ts +27 -0
- package/src/pantheon/v2-shell-hooks.ts +260 -0
- package/src/pantheon/v2-unsupported.mjs +32 -4
- package/src/pantheon/v2-vision.ts +34 -29
- package/src/pantheon/vision.ts +49 -11
- package/src/plugin-v2.ts +413 -60
- package/src/plugin.ts +22 -2
- package/src/plugins/tui/dist/quota-adapters.d.ts +89 -0
- package/src/plugins/tui/dist/quota-adapters.d.ts.map +1 -0
- package/src/plugins/tui/dist/quota-adapters.js +1142 -0
- package/src/plugins/tui/dist/quota-adapters.js.map +1 -0
- package/src/plugins/tui/dist/quota-cli.d.ts +17 -0
- package/src/plugins/tui/dist/quota-cli.d.ts.map +1 -0
- package/src/plugins/tui/dist/quota-cli.js +184 -0
- package/src/plugins/tui/dist/quota-cli.js.map +1 -0
- package/src/plugins/tui/dist/quota-rpc-UL2HuFRJ.js +390 -0
- package/src/plugins/tui/dist/quota-rpc-UL2HuFRJ.js.map +1 -0
- package/src/plugins/tui/dist/server-v2.d.ts +14 -0
- package/src/plugins/tui/dist/server-v2.d.ts.map +1 -0
- package/src/plugins/tui/dist/server-v2.js +673 -0
- package/src/plugins/tui/dist/server-v2.js.map +1 -0
- package/src/plugins/tui/dist/tui-v2.d.ts +247 -52
- package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui-v2.js +2492 -529
- package/src/plugins/tui/dist/tui-v2.js.map +1 -1
- package/src/plugins/tui/dist/tui.js +1 -1
- package/src/plugins/tui/index-v2.ts +3 -6
- package/src/plugins/tui/package-lock.json +11 -11
- package/src/plugins/tui/package.json +6 -4
- package/src/plugins/tui/src/context-gauge.ts +59 -0
- package/src/plugins/tui/src/go-key-diagnostic-ui.ts +100 -0
- package/src/plugins/tui/src/go-key-diagnostic.ts +125 -0
- package/src/plugins/tui/src/index-v2.tsx +199 -240
- package/src/plugins/tui/src/model-usage-limits.ts +4 -0
- package/src/plugins/tui/src/quota-adapters.ts +1598 -0
- package/src/plugins/tui/src/quota-cli.ts +237 -0
- package/src/plugins/tui/src/quota-rpc.ts +209 -0
- package/src/plugins/tui/src/quota-v2-model.ts +1032 -0
- package/src/plugins/tui/src/quota-v2.tsx +986 -0
- package/src/plugins/tui/src/server-v2.ts +841 -0
- package/src/plugins/tui/src/sidebar-width.ts +129 -0
- package/src/plugins/tui/tsconfig.typecheck.json +1 -1
- package/src/plugins/tui/tsdown.config.ts +8 -1
- package/src/routing.yml +72 -13
- package/src/skills/README.md +4 -0
- package/src/skills/agent-coordination/SKILL.md +0 -3
- package/src/skills/artifact-management/SKILL.md +0 -3
- package/src/skills/auto-continue/SKILL.md +0 -3
- package/src/skills/code-review-checklist/SKILL.md +0 -3
- package/src/skills/context-compression/SKILL.md +0 -3
- package/src/skills/memory-bank/SKILL.md +6 -28
- package/src/skills/session-goal/SKILL.md +0 -3
- package/src/skills/simplify/SKILL.md +5 -4
- package/src/skills/tdd-with-agents/SKILL.md +0 -3
- package/src/skills/visual-review-pipeline/SKILL.md +0 -1
- package/src/pantheon/memory-context.ts +0 -1017
|
@@ -36,6 +36,11 @@ function hash(value) {
|
|
|
36
36
|
return createHash('sha256').update(value).digest('hex')
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/** Bind an in-memory reviewed plan to the exact JSON payload passed to init. */
|
|
40
|
+
export function planArtifactDigest(artifact) {
|
|
41
|
+
return hash(JSON.stringify(artifact))
|
|
42
|
+
}
|
|
43
|
+
|
|
39
44
|
function lstatOrNull(path) {
|
|
40
45
|
try {
|
|
41
46
|
return lstatSync(path)
|
|
@@ -471,7 +476,10 @@ export function loadPlanArtifact(path) {
|
|
|
471
476
|
}
|
|
472
477
|
|
|
473
478
|
/** Compare current inputs and destinations against a saved reviewed plan. */
|
|
474
|
-
export function findPlanDrift(
|
|
479
|
+
export function findPlanDrift(
|
|
480
|
+
artifact,
|
|
481
|
+
{ target, packageRoot, packageVersion, options, files, snapshots },
|
|
482
|
+
) {
|
|
475
483
|
validatePlanArtifact(artifact)
|
|
476
484
|
const root = resolve(target)
|
|
477
485
|
const reasons = []
|
|
@@ -485,6 +493,9 @@ export function findPlanDrift(artifact, { target, packageRoot, packageVersion, f
|
|
|
485
493
|
sourceFingerprint(packageRoot, [artifact.artifact_path]) !== artifact.package.source_fingerprint
|
|
486
494
|
)
|
|
487
495
|
reasons.push('source')
|
|
496
|
+
if (options !== undefined && JSON.stringify(options) !== JSON.stringify(artifact.options)) {
|
|
497
|
+
reasons.push('options')
|
|
498
|
+
}
|
|
488
499
|
|
|
489
500
|
const currentSnapshots = new Map(snapshots.map((item) => [resolve(item.path), item]))
|
|
490
501
|
for (const operation of artifact.operations) {
|
|
@@ -100,6 +100,15 @@ export function copyPluginFiles(
|
|
|
100
100
|
'plugin entrypoint that re-exports a missing bundle. Reinstall pantheon-opencode.',
|
|
101
101
|
)
|
|
102
102
|
}
|
|
103
|
+
const requiredServerBundle = join(srcDir, 'dist', 'server-v2.js')
|
|
104
|
+
const serverBundleAvailable = version !== 'v2' || existsSync(requiredServerBundle)
|
|
105
|
+
if (!serverBundleAvailable) {
|
|
106
|
+
result.errors++
|
|
107
|
+
result.problems.push(
|
|
108
|
+
`TUI server bundle not found in the package: ${requiredServerBundle} — refusing to install a ` +
|
|
109
|
+
'plugin entrypoint that re-exports a missing bundle. Reinstall pantheon-opencode.',
|
|
110
|
+
)
|
|
111
|
+
}
|
|
103
112
|
|
|
104
113
|
if (!dryRun) {
|
|
105
114
|
assertNoSymlinkAncestors(dstDir)
|
|
@@ -136,6 +145,13 @@ export function copyPluginFiles(
|
|
|
136
145
|
if (version === 'v2' && packageJson.exports?.['./tui-v2']) {
|
|
137
146
|
packageJson.exports['./tui'] = packageJson.exports['./tui-v2']
|
|
138
147
|
}
|
|
148
|
+
// The OpenCode host resolves the plugin server through the `./server` export.
|
|
149
|
+
// In the V2 copy it must point at the V2 server bundle so V2-only RPCs
|
|
150
|
+
// (pantheon.quota) are registered; otherwise the host loads the V1 server
|
|
151
|
+
// and the quota status stays "unavailable".
|
|
152
|
+
if (version === 'v2' && packageJson.exports?.['./server-v2']) {
|
|
153
|
+
packageJson.exports['./server'] = packageJson.exports['./server-v2']
|
|
154
|
+
}
|
|
139
155
|
const pkgStatus = writeIfChanged(
|
|
140
156
|
join(dstDir, 'package.json'),
|
|
141
157
|
`${JSON.stringify(packageJson, null, 2)}\n`,
|
|
@@ -166,7 +182,7 @@ export function copyPluginFiles(
|
|
|
166
182
|
|
|
167
183
|
const v2ServerEntry = join(srcDir, 'index-v2.ts')
|
|
168
184
|
const v2ServerDestination = join(dstDir, 'index.ts')
|
|
169
|
-
if (version === 'v2' && existsSync(v2ServerEntry)) {
|
|
185
|
+
if (version === 'v2' && serverBundleAvailable && existsSync(v2ServerEntry)) {
|
|
170
186
|
const entryStatus = writeIfChanged(
|
|
171
187
|
v2ServerDestination,
|
|
172
188
|
readFileSync(v2ServerEntry, 'utf8'),
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* run-record.mjs — the one-line record of what the LAST `init` run did.
|
|
3
|
+
*
|
|
4
|
+
* WHY A SEPARATE FILE, AND NOT `install-state.json`: that manifest is written
|
|
5
|
+
* only by an APPLY, so it answers "what is installed" and cannot answer "what
|
|
6
|
+
* did the previous run decide". A canceled or declined run previously left no
|
|
7
|
+
* trace at all: the user saw a line scroll past, and a re-run could not tell
|
|
8
|
+
* whether the last attempt was interrupted, refused at the review prompt, or
|
|
9
|
+
* never authorized. This record is written on every non-preview termination,
|
|
10
|
+
* including the ones that apply nothing, so the answer survives the terminal.
|
|
11
|
+
*
|
|
12
|
+
* It is deliberately NOT an install artifact:
|
|
13
|
+
* - it is never registered in the file inventory, so it is not "owned" and
|
|
14
|
+
* uninstall/reconcile do not treat it as installed content;
|
|
15
|
+
* - it never replaces, mirrors or edits `install-state.json`;
|
|
16
|
+
* - a failure to write it never changes the exit code (see the caller): an
|
|
17
|
+
* explanation is worth having, not worth failing a run for.
|
|
18
|
+
*
|
|
19
|
+
* No secrets and no config contents are recorded — status, reason, cancel
|
|
20
|
+
* point, mode, version, timestamp and target only.
|
|
21
|
+
*
|
|
22
|
+
* @module run-record
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { mkdirSync, readFileSync } from 'node:fs'
|
|
26
|
+
import { join } from 'node:path'
|
|
27
|
+
import { writeFileAtomically } from './verify.mjs'
|
|
28
|
+
|
|
29
|
+
/** Directory inside the install target that holds Pantheon bookkeeping. */
|
|
30
|
+
export const RUN_RECORD_DIR = '.pantheon'
|
|
31
|
+
|
|
32
|
+
/** File name of the last-run record. */
|
|
33
|
+
export const RUN_RECORD_FILENAME = 'last-run.json'
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Absolute path of the record for an install target.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} target
|
|
39
|
+
* @returns {string}
|
|
40
|
+
*/
|
|
41
|
+
export function runRecordPath(target) {
|
|
42
|
+
return join(target, RUN_RECORD_DIR, RUN_RECORD_FILENAME)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Build the record. Pure, so the shape is testable without touching disk.
|
|
47
|
+
*
|
|
48
|
+
* @param {{
|
|
49
|
+
* status: string,
|
|
50
|
+
* reason?: string|null,
|
|
51
|
+
* cancelPoint?: string|null,
|
|
52
|
+
* mode: 'apply'|'dry-run',
|
|
53
|
+
* applied: boolean,
|
|
54
|
+
* pantheonVersion?: string|null,
|
|
55
|
+
* at?: string,
|
|
56
|
+
* }} input
|
|
57
|
+
* @returns {object}
|
|
58
|
+
*/
|
|
59
|
+
export function buildRunRecord({
|
|
60
|
+
status,
|
|
61
|
+
reason = null,
|
|
62
|
+
cancelPoint = null,
|
|
63
|
+
mode,
|
|
64
|
+
applied,
|
|
65
|
+
pantheonVersion = null,
|
|
66
|
+
at = new Date().toISOString(),
|
|
67
|
+
}) {
|
|
68
|
+
const where = cancelPoint === null ? '' : ` at ${cancelPoint}`
|
|
69
|
+
return {
|
|
70
|
+
schema_version: 1,
|
|
71
|
+
command: 'init',
|
|
72
|
+
status,
|
|
73
|
+
reason,
|
|
74
|
+
cancel_point: cancelPoint,
|
|
75
|
+
mode,
|
|
76
|
+
applied,
|
|
77
|
+
pantheon_version: pantheonVersion,
|
|
78
|
+
at,
|
|
79
|
+
summary: `init ${status}${where} — ${applied ? 'changes were applied' : 'nothing was applied'} (${at})`,
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Persist the record. Never throws: a bookkeeping failure is reported to the
|
|
85
|
+
* caller, which prints it as a warning instead of hiding it.
|
|
86
|
+
*
|
|
87
|
+
* @param {string} target
|
|
88
|
+
* @param {object} record
|
|
89
|
+
* @returns {{written: boolean, path: string, error: string|null}}
|
|
90
|
+
*/
|
|
91
|
+
export function writeRunRecord(target, record) {
|
|
92
|
+
const path = runRecordPath(target)
|
|
93
|
+
try {
|
|
94
|
+
mkdirSync(join(target, RUN_RECORD_DIR), { recursive: true })
|
|
95
|
+
writeFileAtomically(path, `${JSON.stringify(record, null, 2)}\n`)
|
|
96
|
+
return { written: true, path, error: null }
|
|
97
|
+
} catch (err) {
|
|
98
|
+
return { written: false, path, error: err instanceof Error ? err.message : String(err) }
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Read the previous run's record, or null when there is none / it is unreadable.
|
|
104
|
+
*
|
|
105
|
+
* @param {string} target
|
|
106
|
+
* @returns {object|null}
|
|
107
|
+
*/
|
|
108
|
+
export function readRunRecord(target) {
|
|
109
|
+
try {
|
|
110
|
+
const parsed = JSON.parse(readFileSync(runRecordPath(target), 'utf8'))
|
|
111
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : null
|
|
112
|
+
} catch {
|
|
113
|
+
return null
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -14,8 +14,27 @@ const TABLE = {
|
|
|
14
14
|
en: {
|
|
15
15
|
installing: 'Installing...',
|
|
16
16
|
dryRun: 'DRY RUN',
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
// Every termination that applies nothing names WHERE it stopped and WHAT
|
|
18
|
+
// the consequence is. `cancelPoints` are stable machine keys: the same key
|
|
19
|
+
// goes into the on-disk run record, so a re-run can report the point
|
|
20
|
+
// without parsing prose.
|
|
21
|
+
cancelPoints: {
|
|
22
|
+
components: 'component selection',
|
|
23
|
+
target: 'install location',
|
|
24
|
+
confirmation: 'pre-install confirmation',
|
|
25
|
+
review: 'review prompt',
|
|
26
|
+
interrupt: 'interrupt (Ctrl-C)',
|
|
27
|
+
},
|
|
28
|
+
// "no configuration was changed", not "no files were written": a cancel
|
|
29
|
+
// does write `.pantheon/last-run.json` (that is the point of #262), so the
|
|
30
|
+
// stronger claim would be false.
|
|
31
|
+
canceledAt: (point) =>
|
|
32
|
+
`Installation canceled at ${point} — nothing was applied; no configuration was changed.`,
|
|
33
|
+
declinedAt: (point) =>
|
|
34
|
+
`Installation declined at ${point} — nothing was applied; no configuration was changed; ` +
|
|
35
|
+
're-run init to review the plan again.',
|
|
36
|
+
previousRun: (summary) => `Previous run recorded on disk: ${summary}`,
|
|
37
|
+
runRecordFailed: (msg) => `Could not write the run record: ${msg}`,
|
|
19
38
|
installFailed: (msg) => `Installation failed: ${msg}`,
|
|
20
39
|
failHintNoMcp:
|
|
21
40
|
' Run with --no-mcp to skip Python dependencies:\n npx pantheon-opencode init --no-mcp',
|
|
@@ -65,7 +84,6 @@ const TABLE = {
|
|
|
65
84
|
`the server's tools remain available and no permission prompt is shown. ` +
|
|
66
85
|
`Use "deny" with action "${server}_*" in "permissions", or disable the server in the host MCP config.`,
|
|
67
86
|
v2Migrating: 'Migrating config to V2 native format...',
|
|
68
|
-
nothingApplied: 'Nothing applied.',
|
|
69
87
|
planOnlyNoYes: 'Plan only — re-run with --yes to apply.',
|
|
70
88
|
driftHeader: 'State changed since preview — aborting before any write:',
|
|
71
89
|
driftAbort: 'No files were written. Re-run to re-review.',
|
|
@@ -90,8 +108,20 @@ const TABLE = {
|
|
|
90
108
|
pt: {
|
|
91
109
|
installing: 'Instalando...',
|
|
92
110
|
dryRun: 'SIMULAÇÃO',
|
|
93
|
-
|
|
94
|
-
|
|
111
|
+
cancelPoints: {
|
|
112
|
+
components: 'seleção de componentes',
|
|
113
|
+
target: 'local da instalação',
|
|
114
|
+
confirmation: 'confirmação antes de instalar',
|
|
115
|
+
review: 'prompt de revisão',
|
|
116
|
+
interrupt: 'interrupção (Ctrl-C)',
|
|
117
|
+
},
|
|
118
|
+
canceledAt: (point) =>
|
|
119
|
+
`Instalação cancelada em ${point} — nada foi aplicado; nenhuma configuração foi alterada.`,
|
|
120
|
+
declinedAt: (point) =>
|
|
121
|
+
`Instalação recusada em ${point} — nada foi aplicado; nenhuma configuração foi alterada; ` +
|
|
122
|
+
'rode init de novo para revisar o plano.',
|
|
123
|
+
previousRun: (summary) => `Execução anterior registrada em disco: ${summary}`,
|
|
124
|
+
runRecordFailed: (msg) => `Não foi possível gravar o registro da execução: ${msg}`,
|
|
95
125
|
installFailed: (msg) => `Instalação falhou: ${msg}`,
|
|
96
126
|
failHintNoMcp:
|
|
97
127
|
' Rode com --no-mcp para pular dependências Python:\n npx pantheon-opencode init --no-mcp',
|
|
@@ -141,7 +171,6 @@ const TABLE = {
|
|
|
141
171
|
`as tools do servidor continuam disponíveis e nenhum prompt de permissão é exibido. ` +
|
|
142
172
|
`Use "deny" com a action "${server}_*" em "permissions", ou desative o servidor na config de MCP do host.`,
|
|
143
173
|
v2Migrating: 'Migrando config para o formato nativo V2...',
|
|
144
|
-
nothingApplied: 'Nada foi aplicado.',
|
|
145
174
|
planOnlyNoYes: 'Apenas o plano — rode de novo com --yes para aplicar.',
|
|
146
175
|
driftHeader: 'O estado mudou desde o preview — abortando antes de qualquer escrita:',
|
|
147
176
|
driftAbort: 'Nenhum arquivo foi escrito. Rode de novo para revisar.',
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2-capabilities.mjs — what the OpenCode V2 plugin surface ACTUALLY is.
|
|
3
|
+
*
|
|
4
|
+
* Two reporting defects this module exists to prevent, both of them statements
|
|
5
|
+
* that were narrower than the truth:
|
|
6
|
+
*
|
|
7
|
+
* 1. The installer printed `listV2UnsupportedFeatures()` under the heading
|
|
8
|
+
* "Unsupported features", which reads like the complete list of what V2
|
|
9
|
+
* does. That list is a SEED: the live set is this seed PLUS markers the
|
|
10
|
+
* plugin appends at runtime when a host API turns out to be missing
|
|
11
|
+
* (`tool-transform`, `event-stream`, …), which cannot be known at install
|
|
12
|
+
* time. So the printed list must say what it is.
|
|
13
|
+
* 2. "Reduced surface" alone is misleading in the other direction: V2 is not
|
|
14
|
+
* a stub. It registers session `context`/`prompt`/`compaction` hooks, tool
|
|
15
|
+
* `execute.before`/`execute.after` hooks, a permission `evaluate` hook,
|
|
16
|
+
* `tool`/`agent`/`command`/`reference` transforms and five session events.
|
|
17
|
+
* A user deciding between generations is entitled to both halves.
|
|
18
|
+
*
|
|
19
|
+
* The registered surface below is derived from `src/plugin-v2.ts` (the
|
|
20
|
+
* registration sites, not the module header: the header still claims the
|
|
21
|
+
* caller/target matrix is enforced, while the enforcement guard's own docstring
|
|
22
|
+
* records that omitting the hierarchy wiring skips that branch — the gap is
|
|
23
|
+
* stated here as a gap).
|
|
24
|
+
*
|
|
25
|
+
* The seed itself is IMPORTED, never copied: an installer that restated these
|
|
26
|
+
* strings could drift from `src/pantheon/v2-unsupported.mjs`, and a test pins
|
|
27
|
+
* the two together.
|
|
28
|
+
*
|
|
29
|
+
* @module v2-capabilities
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import { listV2UnsupportedFeatures } from '../../src/pantheon/v2-unsupported.mjs'
|
|
33
|
+
|
|
34
|
+
/** Tools registered unconditionally through `ctx.tool.transform`. */
|
|
35
|
+
export const V2_REGISTERED_TOOLS = Object.freeze([
|
|
36
|
+
'hashline_edit',
|
|
37
|
+
'pantheon_cost',
|
|
38
|
+
'pantheon_model',
|
|
39
|
+
])
|
|
40
|
+
|
|
41
|
+
/** Tools registered only when the host exposes the API they need. */
|
|
42
|
+
export const V2_HOST_DEPENDENT_TOOLS = Object.freeze(['vision_describe', 'pantheon_bounded_read'])
|
|
43
|
+
|
|
44
|
+
/** Session hooks V2 registers. */
|
|
45
|
+
export const V2_SESSION_HOOKS = Object.freeze(['context', 'prompt', 'compaction'])
|
|
46
|
+
|
|
47
|
+
/** Tool hooks V2 registers. */
|
|
48
|
+
export const V2_TOOL_HOOKS = Object.freeze(['execute.before', 'execute.after'])
|
|
49
|
+
|
|
50
|
+
/** Permission hooks V2 registers. */
|
|
51
|
+
export const V2_PERMISSION_HOOKS = Object.freeze(['evaluate'])
|
|
52
|
+
|
|
53
|
+
/** Transform domains V2 registers. */
|
|
54
|
+
export const V2_TRANSFORMS = Object.freeze(['tool', 'agent', 'command', 'reference'])
|
|
55
|
+
|
|
56
|
+
/** Host events V2 subscribes to. */
|
|
57
|
+
export const V2_EVENTS = Object.freeze([
|
|
58
|
+
'session.created',
|
|
59
|
+
'session.idle',
|
|
60
|
+
'session.deleted',
|
|
61
|
+
'session.error',
|
|
62
|
+
'session.compacted',
|
|
63
|
+
])
|
|
64
|
+
|
|
65
|
+
/** Scope line that keeps the seed from reading as the complete list. */
|
|
66
|
+
export const V2_NOT_REGISTERED_SCOPE =
|
|
67
|
+
'statically known seed; the live plugin adds further markers at runtime when a host API is missing'
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Machine-readable capability description for the V2 generation.
|
|
71
|
+
*
|
|
72
|
+
* JSON-safe by construction: `--json` carries this object, so the same facts
|
|
73
|
+
* are available to a machine as to a reader.
|
|
74
|
+
*
|
|
75
|
+
* @returns {{
|
|
76
|
+
* generation: 'v2',
|
|
77
|
+
* registered: {
|
|
78
|
+
* tools: string[],
|
|
79
|
+
* host_dependent_tools: string[],
|
|
80
|
+
* session_hooks: string[],
|
|
81
|
+
* tool_hooks: string[],
|
|
82
|
+
* permission_hooks: string[],
|
|
83
|
+
* transforms: string[],
|
|
84
|
+
* events: string[],
|
|
85
|
+
* },
|
|
86
|
+
* not_registered: string[],
|
|
87
|
+
* not_registered_scope: string,
|
|
88
|
+
* }}
|
|
89
|
+
*/
|
|
90
|
+
export function v2Capabilities() {
|
|
91
|
+
return {
|
|
92
|
+
generation: 'v2',
|
|
93
|
+
registered: {
|
|
94
|
+
tools: [...V2_REGISTERED_TOOLS],
|
|
95
|
+
host_dependent_tools: [...V2_HOST_DEPENDENT_TOOLS],
|
|
96
|
+
session_hooks: [...V2_SESSION_HOOKS],
|
|
97
|
+
tool_hooks: [...V2_TOOL_HOOKS],
|
|
98
|
+
permission_hooks: [...V2_PERMISSION_HOOKS],
|
|
99
|
+
transforms: [...V2_TRANSFORMS],
|
|
100
|
+
events: [...V2_EVENTS],
|
|
101
|
+
},
|
|
102
|
+
not_registered: listV2UnsupportedFeatures(),
|
|
103
|
+
not_registered_scope: V2_NOT_REGISTERED_SCOPE,
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The human-readable capability notice.
|
|
109
|
+
*
|
|
110
|
+
* Deliberately multi-line: one wrapped paragraph of eleven facts is unreadable
|
|
111
|
+
* on a 60-column terminal. `notice()` prefixes only the first line, so the
|
|
112
|
+
* continuation lines are indented to align under the marker.
|
|
113
|
+
*
|
|
114
|
+
* @param {ReturnType<typeof v2Capabilities>} [capabilities]
|
|
115
|
+
* @returns {string}
|
|
116
|
+
*/
|
|
117
|
+
export function formatV2CapabilityNotice(capabilities = v2Capabilities()) {
|
|
118
|
+
const { registered, not_registered, not_registered_scope } = capabilities
|
|
119
|
+
const indent = ' '.repeat(7) // aligns under the `[INFO] ` prefix notice() adds
|
|
120
|
+
return [
|
|
121
|
+
'V2 plugin generation — what this install registers:',
|
|
122
|
+
`${indent}tools: ${registered.tools.join(', ')} (plus ${registered.host_dependent_tools.join(', ')} when the host exposes them)`,
|
|
123
|
+
`${indent}hooks: session ${registered.session_hooks.join('/')}; tool ${registered.tool_hooks.join('/')}; permission ${registered.permission_hooks.join('/')}`,
|
|
124
|
+
`${indent}transforms: ${registered.transforms.join(', ')}; events: ${registered.events.join(', ')}`,
|
|
125
|
+
`${indent}not registered (${not_registered_scope}): ${not_registered.join(', ')}`,
|
|
126
|
+
].join('\n')
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Whether a `plugins` list registers the Pantheon V2 entry.
|
|
131
|
+
*
|
|
132
|
+
* Matched on the `plugin-v2` marker so every real spelling counts: the
|
|
133
|
+
* canonical directory, an absolute path to it, and the package export.
|
|
134
|
+
*
|
|
135
|
+
* @param {unknown} ref
|
|
136
|
+
* @returns {boolean}
|
|
137
|
+
*/
|
|
138
|
+
export function isPantheonV2Reference(ref) {
|
|
139
|
+
const candidate =
|
|
140
|
+
typeof ref === 'string'
|
|
141
|
+
? ref
|
|
142
|
+
: ref && typeof ref === 'object'
|
|
143
|
+
? (ref.package ?? ref.path ?? ref.source ?? ref.id ?? ref.name)
|
|
144
|
+
: undefined
|
|
145
|
+
return typeof candidate === 'string' && candidate.includes('plugin-v2')
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Whether the installed Pantheon V2 entry can receive plugin `options`.
|
|
150
|
+
*
|
|
151
|
+
* The host hands a plugin its `options` only from the OBJECT form
|
|
152
|
+
* (`{ package, options }`); a bare string entry leaves `ctx.options` empty.
|
|
153
|
+
* `context_pruner` is the remaining opt-in that reads that object. A fresh
|
|
154
|
+
* install that emitted a bare string therefore had no reachable opt-in switch
|
|
155
|
+
* at all — this is the check that reports it after install.
|
|
156
|
+
*
|
|
157
|
+
* @param {unknown} plugins the `plugins` array from the config
|
|
158
|
+
* @returns {{registered: boolean, reachable: boolean, form: 'object'|'string'|'absent', detail: string}}
|
|
159
|
+
*/
|
|
160
|
+
export function describePluginOptionsReachability(plugins) {
|
|
161
|
+
const list = Array.isArray(plugins) ? plugins : []
|
|
162
|
+
const entries = list.filter((ref) => isPantheonV2Reference(ref))
|
|
163
|
+
if (entries.length === 0) {
|
|
164
|
+
return {
|
|
165
|
+
registered: false,
|
|
166
|
+
reachable: false,
|
|
167
|
+
form: 'absent',
|
|
168
|
+
detail: 'no Pantheon V2 entry is registered, so plugin options are not read at all',
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const forms = entries.map((entry) => {
|
|
172
|
+
if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) return 'string'
|
|
173
|
+
const options = entry.options
|
|
174
|
+
return typeof options === 'object' && options !== null && !Array.isArray(options)
|
|
175
|
+
? 'object-with-options'
|
|
176
|
+
: 'object-without-options'
|
|
177
|
+
})
|
|
178
|
+
const reachable = forms.includes('object-with-options')
|
|
179
|
+
if (reachable) {
|
|
180
|
+
const extra = forms.filter((form) => form !== 'object-with-options')
|
|
181
|
+
return {
|
|
182
|
+
registered: true,
|
|
183
|
+
reachable: true,
|
|
184
|
+
form: 'object',
|
|
185
|
+
detail:
|
|
186
|
+
'at least one Pantheon V2 entry carries an "options" object, so context_pruner can be configured there' +
|
|
187
|
+
(extra.length === 0
|
|
188
|
+
? ''
|
|
189
|
+
: `; ${extra.length} other Pantheon entr${extra.length === 1 ? 'y' : 'ies'} in the same list cannot carry options`),
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
const stringOnly = forms.every((form) => form === 'string')
|
|
193
|
+
return {
|
|
194
|
+
registered: true,
|
|
195
|
+
reachable: false,
|
|
196
|
+
form: stringOnly ? 'string' : 'object',
|
|
197
|
+
detail: stringOnly
|
|
198
|
+
? 'the Pantheon V2 entry is a bare string, so the host passes no options and ' +
|
|
199
|
+
'context_pruner cannot be enabled; the object form ' +
|
|
200
|
+
'{"package": …, "options": {…}} makes them reachable'
|
|
201
|
+
: 'the Pantheon V2 entry has no "options" object, so the host passes an empty ' +
|
|
202
|
+
'options bag and context_pruner stays at its default',
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -31,6 +31,7 @@ const REQUIRED_PAYLOAD = [
|
|
|
31
31
|
'package/src/pantheon/v2-bridge.ts',
|
|
32
32
|
'package/src/plugins/tui/dist/tui.js',
|
|
33
33
|
'package/src/plugins/tui/dist/server.js',
|
|
34
|
+
'package/src/plugins/tui/dist/server-v2.js',
|
|
34
35
|
'package/bin/pantheon-init.mjs',
|
|
35
36
|
'package/scripts/doctor.mjs',
|
|
36
37
|
'package/scripts/node-engine-policy.mjs',
|
|
@@ -71,7 +71,6 @@ const UNSUPPORTED_HOSTS = new Set(KNOWN_BROKEN_HOSTS)
|
|
|
71
71
|
* needs to exercise a different host.
|
|
72
72
|
*/
|
|
73
73
|
const DEFAULT_MATRIX = [
|
|
74
|
-
{ host: '1.19.4', line: '1.19.x', kind: 'v1-permission' },
|
|
75
74
|
{ host: '2.0.29', line: '2.x', kind: 'sandbox-v2' },
|
|
76
75
|
{ host: '2.0.30', line: '2.x', kind: 'sandbox-v2' },
|
|
77
76
|
{ host: '2.1.0', line: '2.x', kind: 'sandbox-v2' },
|
|
@@ -467,8 +466,14 @@ function installGate(options) {
|
|
|
467
466
|
}
|
|
468
467
|
|
|
469
468
|
const binary = join(root, 'home', '.npm-global', 'bin', 'opencode')
|
|
469
|
+
const packageRoot = join(root, 'home', '.npm-global', 'lib', 'node_modules', 'pantheon-opencode')
|
|
470
470
|
const canary = run('tool-canary', 'npm', ['run', 'test:tool-canary'], {
|
|
471
|
-
env: {
|
|
471
|
+
env: {
|
|
472
|
+
PANTHEON_TOOL_CANARY_BIN: binary,
|
|
473
|
+
PANTHEON_TOOL_CANARY_PACKAGE_ROOT: packageRoot,
|
|
474
|
+
PANTHEON_TOOL_CANARY_EXPECT_HOST: host,
|
|
475
|
+
PANTHEON_TOOL_CANARY_EXPECT_PACKAGE_VERSION: options.version,
|
|
476
|
+
},
|
|
472
477
|
})
|
|
473
478
|
// The canary itself skips when no binary is found. In release context that
|
|
474
479
|
// skip is not a PASS, so a skip marker fails the gate.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# Configure a Pantheon sandbox without inheriting host user-data paths.
|
|
4
|
+
pantheon_validate_sandbox_path() {
|
|
5
|
+
local path="$1"
|
|
6
|
+
local current="/"
|
|
7
|
+
local component
|
|
8
|
+
local -a components
|
|
9
|
+
local LC_ALL=C
|
|
10
|
+
|
|
11
|
+
if [[ "$path" =~ [[:cntrl:]] || "$path" != /* ]]; then
|
|
12
|
+
printf 'ERROR: sandbox path validation failed.\n' >&2
|
|
13
|
+
return 2
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
IFS='/' read -r -a components <<< "$path"
|
|
17
|
+
for component in "${components[@]}"; do
|
|
18
|
+
case "$component" in
|
|
19
|
+
'' | .) continue ;;
|
|
20
|
+
..)
|
|
21
|
+
printf 'ERROR: sandbox path validation failed.\n' >&2
|
|
22
|
+
return 2
|
|
23
|
+
;;
|
|
24
|
+
esac
|
|
25
|
+
|
|
26
|
+
if [[ "$current" == / ]]; then
|
|
27
|
+
current="/$component"
|
|
28
|
+
else
|
|
29
|
+
current="$current/$component"
|
|
30
|
+
fi
|
|
31
|
+
if [[ -L "$current" ]]; then
|
|
32
|
+
printf 'ERROR: sandbox path validation failed.\n' >&2
|
|
33
|
+
return 2
|
|
34
|
+
fi
|
|
35
|
+
done
|
|
36
|
+
return 0
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
pantheon_validate_sandbox_root() {
|
|
40
|
+
local sandbox_root="$1"
|
|
41
|
+
local LC_ALL=C
|
|
42
|
+
|
|
43
|
+
if [[ "$sandbox_root" =~ [[:cntrl:]] || "$sandbox_root" != /* ]]; then
|
|
44
|
+
printf 'ERROR: sandbox path validation failed.\n' >&2
|
|
45
|
+
return 2
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
if [[ "$(pantheon_normalize_sandbox_path "$sandbox_root")" == / ]]; then
|
|
49
|
+
printf 'ERROR: sandbox path validation failed.\n' >&2
|
|
50
|
+
return 2
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
pantheon_validate_sandbox_path "$sandbox_root"
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
pantheon_normalize_sandbox_path() {
|
|
57
|
+
local path="$1" component normalized=""
|
|
58
|
+
local -a components
|
|
59
|
+
|
|
60
|
+
IFS='/' read -r -a components <<< "$path"
|
|
61
|
+
for component in "${components[@]}"; do
|
|
62
|
+
case "$component" in
|
|
63
|
+
'' | .) continue ;;
|
|
64
|
+
esac
|
|
65
|
+
if [[ -z "$normalized" ]]; then
|
|
66
|
+
normalized="/$component"
|
|
67
|
+
else
|
|
68
|
+
normalized="$normalized/$component"
|
|
69
|
+
fi
|
|
70
|
+
done
|
|
71
|
+
printf '%s' "${normalized:-/}"
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
# Validate configurable file paths before a caller creates their parent
|
|
75
|
+
# directories or launches OpenCode. Reject traversal and symlink components
|
|
76
|
+
# first, then compare normalized absolute paths on complete component
|
|
77
|
+
# boundaries so a sibling such as sandbox-extra is not accepted.
|
|
78
|
+
pantheon_validate_sandbox_file_path() {
|
|
79
|
+
local sandbox_root="$1" file_path="$2" normalized_root normalized_file
|
|
80
|
+
local LC_ALL=C
|
|
81
|
+
|
|
82
|
+
if ! pantheon_validate_sandbox_root "$sandbox_root" >/dev/null 2>&1 \
|
|
83
|
+
|| ! pantheon_validate_sandbox_path "$file_path" >/dev/null 2>&1; then
|
|
84
|
+
printf 'ERROR: sandbox config/database path validation failed.\n' >&2
|
|
85
|
+
return 2
|
|
86
|
+
fi
|
|
87
|
+
|
|
88
|
+
normalized_root="$(pantheon_normalize_sandbox_path "$sandbox_root")"
|
|
89
|
+
normalized_file="$(pantheon_normalize_sandbox_path "$file_path")"
|
|
90
|
+
if [[ "$normalized_file" == "$normalized_root"/* ]]; then
|
|
91
|
+
return 0
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
printf 'ERROR: sandbox config/database path validation failed.\n' >&2
|
|
95
|
+
return 2
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
# The config's parent is passed as OPENCODE_CONFIG_DIR and may be used for
|
|
99
|
+
# reads/writes by OpenCode. Keep both the file and that parent strictly below
|
|
100
|
+
# the canonical sandbox root (not the root itself or its parent).
|
|
101
|
+
pantheon_validate_sandbox_config_path() {
|
|
102
|
+
local sandbox_root="$1" config_path="$2"
|
|
103
|
+
local normalized_root normalized_config normalized_parent config_parent
|
|
104
|
+
local LC_ALL=C
|
|
105
|
+
|
|
106
|
+
pantheon_validate_sandbox_file_path "$sandbox_root" "$config_path" || return $?
|
|
107
|
+
normalized_root="$(pantheon_normalize_sandbox_path "$sandbox_root")"
|
|
108
|
+
normalized_config="$(pantheon_normalize_sandbox_path "$config_path")"
|
|
109
|
+
config_parent="$(dirname "$config_path")"
|
|
110
|
+
normalized_parent="$(pantheon_normalize_sandbox_path "$config_parent")"
|
|
111
|
+
|
|
112
|
+
if [[ "$normalized_config" != "$normalized_root"/* \
|
|
113
|
+
|| "$normalized_parent" == "$normalized_root" \
|
|
114
|
+
|| "$normalized_parent" != "$normalized_root"/* ]]; then
|
|
115
|
+
printf 'ERROR: sandbox config/database path validation failed.\n' >&2
|
|
116
|
+
return 2
|
|
117
|
+
fi
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
pantheon_sandbox_env() {
|
|
121
|
+
local sandbox_root="$1"
|
|
122
|
+
local sandbox_home="$2"
|
|
123
|
+
local npm_prefix="$3"
|
|
124
|
+
local python_venv="$4"
|
|
125
|
+
local opencode_config_dir="$5"
|
|
126
|
+
|
|
127
|
+
pantheon_validate_sandbox_root "$sandbox_root" || return $?
|
|
128
|
+
|
|
129
|
+
export HOME="$sandbox_home"
|
|
130
|
+
export PATH="$npm_prefix/bin:$python_venv/bin:$PATH"
|
|
131
|
+
export npm_config_prefix="$npm_prefix"
|
|
132
|
+
export XDG_CONFIG_HOME="$sandbox_home/.config"
|
|
133
|
+
export XDG_CONFIG_DIRS="$sandbox_home/.config/xdg"
|
|
134
|
+
export XDG_DATA_HOME="$HOME/.local/share"
|
|
135
|
+
export XDG_DATA_DIRS="$sandbox_home/.local/share/xdg"
|
|
136
|
+
export XDG_STATE_HOME="$sandbox_home/.local/state"
|
|
137
|
+
export XDG_CACHE_HOME="$sandbox_home/.cache"
|
|
138
|
+
export XDG_RUNTIME_DIR="$sandbox_root/run"
|
|
139
|
+
export PANTHEON_HOME="$XDG_CONFIG_HOME/opencode"
|
|
140
|
+
export TMPDIR="$sandbox_root/tmp"
|
|
141
|
+
export TMP="$TMPDIR"
|
|
142
|
+
export TEMP="$TMPDIR"
|
|
143
|
+
export OPENCODE_CONFIG_DIR="$opencode_config_dir"
|
|
144
|
+
unset OPENCODE_CONFIG OPENCODE_CONFIG_CONTENT OPENCODE_CONFIG_PROJECT_DISABLE \
|
|
145
|
+
OPENCODE_DATA_DIR OPENCODE_STATE_DIR OPENCODE_CACHE_DIR OPENCODE_STORAGE_PATH
|
|
146
|
+
unset LOG_PATH
|
|
147
|
+
LOG_PATH="$XDG_DATA_HOME/opencode/log/opencode.log"
|
|
148
|
+
|
|
149
|
+
local path
|
|
150
|
+
local -a sandbox_paths=(
|
|
151
|
+
"$sandbox_root" "$sandbox_home" "$npm_prefix" "$python_venv" "$opencode_config_dir"
|
|
152
|
+
"$XDG_CONFIG_HOME" "$XDG_CONFIG_DIRS" "$XDG_DATA_HOME" "$XDG_DATA_DIRS"
|
|
153
|
+
"$XDG_STATE_HOME" "$XDG_CACHE_HOME" "$XDG_RUNTIME_DIR" "$PANTHEON_HOME" "$TMPDIR"
|
|
154
|
+
)
|
|
155
|
+
for path in "${sandbox_paths[@]}"; do
|
|
156
|
+
pantheon_validate_sandbox_path "$path" || return $?
|
|
157
|
+
done
|
|
158
|
+
|
|
159
|
+
(
|
|
160
|
+
umask 077
|
|
161
|
+
mkdir -p \
|
|
162
|
+
"$XDG_CONFIG_HOME" "$XDG_CONFIG_DIRS" \
|
|
163
|
+
"$XDG_DATA_HOME" "$XDG_DATA_DIRS" \
|
|
164
|
+
"$XDG_STATE_HOME" "$XDG_CACHE_HOME" \
|
|
165
|
+
"$PANTHEON_HOME" "$TMPDIR" "$XDG_RUNTIME_DIR"
|
|
166
|
+
) || return $?
|
|
167
|
+
|
|
168
|
+
# Re-check after mkdir before chmod, in case a path component changed while
|
|
169
|
+
# the sandbox directories were being created.
|
|
170
|
+
for path in "${sandbox_paths[@]}"; do
|
|
171
|
+
pantheon_validate_sandbox_path "$path" || return $?
|
|
172
|
+
done
|
|
173
|
+
chmod 700 "$TMPDIR" "$XDG_RUNTIME_DIR" || return $?
|
|
174
|
+
}
|