huaweicloud-devkit 2.0.0-next.3 → 2.0.0-next.5
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/README.md +3 -1
- package/package.json +3 -1
- package/plugins/huaweicloud-core/.claude-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.codex-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.hermes-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.mcp.json +55 -1
- package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/dist/agents/codex-config.js +374 -0
- package/plugins/huaweicloud-core/dist/agents/codex-desktop.js +8 -1
- package/plugins/huaweicloud-core/dist/agents/codex.js +9 -0
- package/plugins/huaweicloud-core/dist/agents/opencode-config.js +141 -86
- package/plugins/huaweicloud-core/dist/agents/opencode.js +106 -39
- package/plugins/huaweicloud-core/dist/approval-gate.js +1185 -0
- package/plugins/huaweicloud-core/dist/approval-ledger.js +2331 -0
- package/plugins/huaweicloud-core/dist/approval-roster.js +89 -0
- package/plugins/huaweicloud-core/dist/approval-types.js +1 -0
- package/plugins/huaweicloud-core/dist/approvals-cli.js +4 -4
- package/plugins/huaweicloud-core/dist/data/icons-manifest.v1.json +23 -5
- package/plugins/huaweicloud-core/dist/dep/receipts.js +65 -5
- package/plugins/huaweicloud-core/dist/explain-error.js +9 -1
- package/plugins/huaweicloud-core/dist/hcloud-cli.js +1 -1
- package/plugins/huaweicloud-core/dist/hcloud-plan.js +68 -62
- package/plugins/huaweicloud-core/dist/lib/approval-mode.js +7 -5
- package/plugins/huaweicloud-core/dist/lib/approval-tokens.js +18 -4
- package/plugins/huaweicloud-core/dist/lib/call-trace.js +7 -14
- package/plugins/huaweicloud-core/dist/lib/confirm-language.js +50 -0
- package/plugins/huaweicloud-core/dist/lib/credentials.js +9 -9
- package/plugins/huaweicloud-core/dist/lib/hdkit/hdkit-gate.js +1398 -0
- package/plugins/huaweicloud-core/dist/lib/hdkit/hdkitservice-api.js +371 -32
- package/plugins/huaweicloud-core/dist/lib/hdkit/sandbox-pool.js +6 -16
- package/plugins/huaweicloud-core/dist/lib/opencode-ask-rule.js +224 -78
- package/plugins/huaweicloud-core/dist/lib/opencode-saved-perms.js +282 -0
- package/plugins/huaweicloud-core/dist/lib/supplemental-redaction.js +116 -0
- package/plugins/huaweicloud-core/dist/lib/tool-schema-parts.js +31 -0
- package/plugins/huaweicloud-core/dist/lib/workspace-glob.js +442 -0
- package/plugins/huaweicloud-core/dist/mcp-config-io.js +28 -1
- package/plugins/huaweicloud-core/dist/mcp-protocol.js +68 -16
- package/plugins/huaweicloud-core/dist/mcp-server.js +6933 -1186
- package/plugins/huaweicloud-core/dist/mcp-server.js.map +4 -4
- package/plugins/huaweicloud-core/dist/mcp-stdio-transport.js +14 -4
- package/plugins/huaweicloud-core/dist/packs/auth/approval.js +249 -0
- package/plugins/huaweicloud-core/dist/packs/auth/tools.js +44 -44
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-cli/tools.js +85 -130
- package/plugins/huaweicloud-core/dist/packs/obs/approval.js +110 -0
- package/plugins/huaweicloud-core/dist/packs/obs/tools.js +7 -2
- package/plugins/huaweicloud-core/dist/packs/registry.js +20 -1
- package/plugins/huaweicloud-core/dist/packs/sandbox/approval.js +245 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/expose-task.js +71 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-account.js +180 -23
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-credentials.js +13 -1
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-hwexec.js +136 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-session.js +11 -1
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-tunnel.js +29 -3
- package/plugins/huaweicloud-core/dist/packs/sandbox/schemas.js +93 -9
- package/plugins/huaweicloud-core/dist/packs/sandbox/tools.js +37 -10
- package/plugins/huaweicloud-core/dist/packs/secrets/approval.js +46 -0
- package/plugins/huaweicloud-core/dist/packs/secrets/tools.js +4 -1
- package/plugins/huaweicloud-core/dist/packs/update/approval.js +79 -0
- package/plugins/huaweicloud-core/dist/packs/update/tools.js +8 -1
- package/plugins/huaweicloud-core/dist/packs/voucher/tools.js +1 -1
- package/plugins/huaweicloud-core/dist/packs-configure.js +74 -0
- package/plugins/huaweicloud-core/dist/risk-rule-engine.js +20 -4
- package/plugins/huaweicloud-core/dist/safety/classify-hcloud.js +6 -6
- package/plugins/huaweicloud-core/dist/safety/classify-text.js +36 -0
- package/plugins/huaweicloud-core/dist/safety/policy.js +2 -0
- package/plugins/huaweicloud-core/dist/safety/redact.js +21 -3
- package/plugins/huaweicloud-core/dist/safety/risk-merge.js +24 -4
- package/plugins/huaweicloud-core/dist/sandbox/deploy-check.js +1 -1
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-auth.js +65 -14
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-cleanup.js +422 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-expose-flow.js +66 -16
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-expose.js +13 -10
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-keepalive.js +42 -2
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-key.js +11 -3
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-tunnel.js +6 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-validation.js +10 -1
- package/plugins/huaweicloud-core/dist/sandbox/hwexec-task.js +244 -0
- package/plugins/huaweicloud-core/dist/setup-cli.js +36 -1
- package/plugins/huaweicloud-core/dist/tool-definitions.js +13 -1
- package/plugins/huaweicloud-core/dist/tool-schemas.js +32 -6
- package/plugins/huaweicloud-core/dist/tools.js +76 -9
- package/plugins/huaweicloud-core/dist/update-registry.js +358 -5
- package/plugins/huaweicloud-core/dist/update-upgrade.js +1083 -14
- package/plugins/huaweicloud-core/dist/vendor-gate.js +2 -2
- package/plugins/huaweicloud-core/hooks/huaweicloud-safety.mjs +150 -1
- package/plugins/huaweicloud-core/hooks/huaweicloud-safety.py +67 -4
- package/plugins/huaweicloud-core/openclaw.plugin.json +2 -2
- package/plugins/huaweicloud-core/safety/policy.json +18 -11
- package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +115 -11
- package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +198 -143
- package/plugins/huaweicloud-core/skills/huawei-sandbox/references/resource-pool.md +36 -12
- package/plugins/huaweicloud-core/skills/huawei-voucher/SKILL.md +2 -0
- package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +2 -2
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +11 -7
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/references/approvals.md +74 -29
- package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/SKILL.md +21 -19
- package/plugins/huaweicloud-core/src/agents/codex-config.ts +432 -0
- package/plugins/huaweicloud-core/src/agents/codex-desktop.ts +8 -1
- package/plugins/huaweicloud-core/src/agents/codex.ts +10 -0
- package/plugins/huaweicloud-core/src/agents/opencode-config.ts +176 -88
- package/plugins/huaweicloud-core/src/agents/opencode.ts +125 -54
- package/plugins/huaweicloud-core/src/approval-gate.ts +1306 -0
- package/plugins/huaweicloud-core/src/approval-ledger.ts +2446 -0
- package/plugins/huaweicloud-core/src/approval-roster.ts +127 -0
- package/plugins/huaweicloud-core/src/approval-types.ts +237 -0
- package/plugins/huaweicloud-core/src/approvals-cli.ts +4 -4
- package/plugins/huaweicloud-core/src/data/icons-manifest.v1.json +23 -5
- package/plugins/huaweicloud-core/src/dep/receipts.ts +84 -5
- package/plugins/huaweicloud-core/src/explain-error.ts +9 -1
- package/plugins/huaweicloud-core/src/hcloud-cli.ts +3 -0
- package/plugins/huaweicloud-core/src/hcloud-plan.ts +74 -71
- package/plugins/huaweicloud-core/src/lib/approval-mode.ts +7 -5
- package/plugins/huaweicloud-core/src/lib/approval-tokens.ts +19 -4
- package/plugins/huaweicloud-core/src/lib/call-trace.ts +7 -17
- package/plugins/huaweicloud-core/src/lib/confirm-language.ts +51 -0
- package/plugins/huaweicloud-core/src/lib/credentials.ts +9 -8
- package/plugins/huaweicloud-core/src/lib/hdkit/hdkit-gate.ts +1428 -0
- package/plugins/huaweicloud-core/src/lib/hdkit/hdkitservice-api.ts +408 -30
- package/plugins/huaweicloud-core/src/lib/hdkit/sandbox-pool.ts +8 -15
- package/plugins/huaweicloud-core/src/lib/opencode-ask-rule.ts +302 -83
- package/plugins/huaweicloud-core/src/lib/opencode-saved-perms.ts +354 -0
- package/plugins/huaweicloud-core/src/lib/supplemental-redaction.ts +129 -0
- package/plugins/huaweicloud-core/src/lib/tool-schema-parts.ts +40 -0
- package/plugins/huaweicloud-core/src/lib/workspace-glob.ts +414 -0
- package/plugins/huaweicloud-core/src/mcp-config-io.ts +27 -1
- package/plugins/huaweicloud-core/src/mcp-protocol.ts +81 -17
- package/plugins/huaweicloud-core/src/mcp-server.ts +7 -7
- package/plugins/huaweicloud-core/src/mcp-stdio-transport.ts +14 -4
- package/plugins/huaweicloud-core/src/packs/auth/approval.ts +302 -0
- package/plugins/huaweicloud-core/src/packs/auth/tools.ts +54 -45
- package/plugins/huaweicloud-core/src/packs/huaweicloud-cli/tools.ts +99 -137
- package/plugins/huaweicloud-core/src/packs/obs/approval.ts +122 -0
- package/plugins/huaweicloud-core/src/packs/obs/tools.ts +7 -2
- package/plugins/huaweicloud-core/src/packs/registry.ts +43 -1
- package/plugins/huaweicloud-core/src/packs/sandbox/approval.ts +296 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/expose-task.ts +105 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-account.ts +195 -23
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-credentials.ts +11 -1
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-hwexec.ts +228 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-session.ts +11 -1
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-tunnel.ts +41 -14
- package/plugins/huaweicloud-core/src/packs/sandbox/schemas.ts +120 -8
- package/plugins/huaweicloud-core/src/packs/sandbox/tools.ts +42 -9
- package/plugins/huaweicloud-core/src/packs/secrets/approval.ts +50 -0
- package/plugins/huaweicloud-core/src/packs/secrets/tools.ts +4 -1
- package/plugins/huaweicloud-core/src/packs/update/approval.ts +87 -0
- package/plugins/huaweicloud-core/src/packs/update/tools.ts +8 -1
- package/plugins/huaweicloud-core/src/packs/voucher/tools.ts +1 -1
- package/plugins/huaweicloud-core/src/packs-configure.ts +75 -0
- package/plugins/huaweicloud-core/src/risk-rule-engine.ts +20 -7
- package/plugins/huaweicloud-core/src/safety/classify-hcloud.ts +28 -16
- package/plugins/huaweicloud-core/src/safety/classify-text.ts +40 -0
- package/plugins/huaweicloud-core/src/safety/policy.ts +7 -0
- package/plugins/huaweicloud-core/src/safety/redact.ts +24 -6
- package/plugins/huaweicloud-core/src/safety/risk-merge.ts +26 -5
- package/plugins/huaweicloud-core/src/sandbox/deploy-check.ts +1 -1
- package/plugins/huaweicloud-core/src/sandbox/devbridge-auth.ts +74 -14
- package/plugins/huaweicloud-core/src/sandbox/devbridge-cleanup.ts +511 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-expose-flow.ts +70 -18
- package/plugins/huaweicloud-core/src/sandbox/devbridge-expose.ts +26 -10
- package/plugins/huaweicloud-core/src/sandbox/devbridge-keepalive.ts +41 -2
- package/plugins/huaweicloud-core/src/sandbox/devbridge-key.ts +9 -3
- package/plugins/huaweicloud-core/src/sandbox/devbridge-tunnel.ts +24 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-validation.ts +11 -1
- package/plugins/huaweicloud-core/src/sandbox/hwexec-task.ts +304 -0
- package/plugins/huaweicloud-core/src/setup-cli.ts +39 -1
- package/plugins/huaweicloud-core/src/tool-definitions.ts +13 -1
- package/plugins/huaweicloud-core/src/tool-schemas.ts +39 -6
- package/plugins/huaweicloud-core/src/tools.ts +124 -10
- package/plugins/huaweicloud-core/src/update-registry.ts +340 -5
- package/plugins/huaweicloud-core/src/update-upgrade.ts +1130 -14
- package/plugins/huaweicloud-core/src/vendor-gate.ts +2 -2
|
@@ -23,10 +23,13 @@ import {
|
|
|
23
23
|
skillTreePermissionGlobs,
|
|
24
24
|
} from '../lib/opencode-permission-seam.ts';
|
|
25
25
|
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
applyAllowPermissionRules,
|
|
27
|
+
applyAllowPermissionRulesV1,
|
|
28
|
+
askRuleShapeFor,
|
|
29
|
+
removeAllowPermissionRules,
|
|
30
|
+
removeAllowPermissionRulesV1,
|
|
31
|
+
removeAskPermissionRules,
|
|
32
|
+
removeAskPermissionRulesV1,
|
|
30
33
|
} from '../lib/opencode-ask-rule.ts';
|
|
31
34
|
import { asRecord } from '../lib/as-record.ts';
|
|
32
35
|
import { devkitOwnedSkillNames, tryCoreSkillNames } from '../install-payload.ts';
|
|
@@ -40,19 +43,28 @@ import { devkitOwnedSkillNames, tryCoreSkillNames } from '../install-payload.ts'
|
|
|
40
43
|
// an older version may reject the keys outright. A later update heals the
|
|
41
44
|
// skip: the seam is a third change source in updateOpenCodeConfig, so an
|
|
42
45
|
// unchanged mcp config no longer short-circuits.
|
|
46
|
+
// Spawned at most once per process: the seam gate, the ask gate, and the
|
|
47
|
+
// ask-shape probe under the 'on' override all ask the same question, and
|
|
48
|
+
// a second spawn in one process can only return the same answer.
|
|
43
49
|
function probeOpencodeVersion(): string | null {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
return probedVersion === undefined ? (probedVersion = probeOpencodeVersionUncached()) : probedVersion;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let probedVersion: string | null | undefined;
|
|
54
|
+
|
|
55
|
+
// The probe runs the agent's own binary, which initializes its config
|
|
56
|
+
// root on every run — so the probe must pin that root to a throwaway
|
|
57
|
+
// mkdtemp directory instead of inheriting the caller's XDG/HOME: a
|
|
58
|
+
// relative XDG_CONFIG_HOME makes opencode materialize dirs against its
|
|
59
|
+
// cwd (the known 1.19.0 divergence cross-platform-install.test.ts
|
|
60
|
+
// pins), and an inherited HOME would create legacy ~/.config/opencode
|
|
61
|
+
// roots in fake-home installs. A fixed shared name would be clippable
|
|
62
|
+
// on multi-user machines, so the root is per-run and best-effort
|
|
63
|
+
// cleaned. The version string never depends on the config root. The
|
|
64
|
+
// win32 retries cover npm-global .cmd shims (spawn cannot execute them
|
|
65
|
+
// without a shell — the hasCodexCLI precedent; the shell string is a
|
|
66
|
+
// fixed literal, no interpolation surface).
|
|
67
|
+
function probeOpencodeVersionUncached(): string | null {
|
|
56
68
|
let probeRoot: string;
|
|
57
69
|
try {
|
|
58
70
|
probeRoot = mkdtempSync(join(tmpdir(), 'devkit-opencode-probe-'));
|
|
@@ -98,41 +110,59 @@ export function openCodeSeamGate(): 'on' | 'off' {
|
|
|
98
110
|
return opencodeSeamVersionSupported(probeOpencodeVersion()) ? 'on' : 'off';
|
|
99
111
|
}
|
|
100
112
|
|
|
101
|
-
// The ask
|
|
102
|
-
// HUAWEICLOUD_OPENCODE_ASK_RULE
|
|
103
|
-
//
|
|
104
|
-
// the natural probe); unset runs the probe.
|
|
105
|
-
//
|
|
106
|
-
//
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
|
|
113
|
+
// The ask gate's version gate, same doctrine as the seam's:
|
|
114
|
+
// HUAWEICLOUD_OPENCODE_ASK_RULE is the deterministic override for the
|
|
115
|
+
// installer test suite (e2e strips it — the runner's install relies on
|
|
116
|
+
// the natural probe); unset runs the probe. Polarity:
|
|
117
|
+
// 'off' — neither half of the posture is written (token mode stays);
|
|
118
|
+
// the legacy ask rules are still migrated away.
|
|
119
|
+
// 'v1'/'v2' — force the rule SHAPE (the deterministic test matrix; the
|
|
120
|
+
// env halves are identical across shapes).
|
|
121
|
+
// 'on' — the probe decides the shape; an absent/unparsable
|
|
122
|
+
// opencode falls back to the documented V2 array — the
|
|
123
|
+
// override's contract since the posture landed.
|
|
124
|
+
// Unset with an unsupported opencode is 'off': the V2 array is measured on
|
|
125
|
+
// 2.2.7 and the V1 permission key is source-verified on 1.19.0, so a
|
|
126
|
+
// below-floor, absent, or unparsable opencode writes NEITHER half — the pair
|
|
127
|
+
// must move together.
|
|
128
|
+
export type OpenCodeAskGate = 'off' | 'v2-array' | 'v1-object';
|
|
129
|
+
|
|
130
|
+
export function openCodeAskGate(): OpenCodeAskGate {
|
|
110
131
|
const forced = process.env.HUAWEICLOUD_OPENCODE_ASK_RULE;
|
|
111
|
-
if (forced === '
|
|
112
|
-
|
|
132
|
+
if (forced === 'off') return 'off';
|
|
133
|
+
if (forced === 'v2') return 'v2-array';
|
|
134
|
+
if (forced === 'v1') return 'v1-object';
|
|
135
|
+
const shape = askRuleShapeFor(probeOpencodeVersion());
|
|
136
|
+
if (shape !== 'unsupported') return shape;
|
|
137
|
+
return forced === 'on' ? 'v2-array' : 'off';
|
|
113
138
|
}
|
|
114
139
|
|
|
115
140
|
// The server half of the ask posture: DEVKIT_APPROVAL_MODE=ask in the mcp
|
|
116
141
|
// entry's environment (the field OpenCode reads — the applyPacksToEntry
|
|
117
|
-
// 'environment' precedent).
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
|
|
142
|
+
// 'environment' precedent). Ask mode now means the SERVER-RUN gate: the
|
|
143
|
+
// confirmation is raised inside the tool call (elicit-first, the T3 chat
|
|
144
|
+
// round-trip on a client that cannot render a form), and the client allow
|
|
145
|
+
// rules only suppress the redundant client popup ahead of it. Add-only-if-
|
|
146
|
+
// absent with the packs-write doctrine: a user-set value other than 'ask' is
|
|
147
|
+
// theirs and wins with a one-line WARN — and then NO client rules are
|
|
148
|
+
// written, because their posture stays mechanical. 'ask' already present
|
|
149
|
+
// needs no write. An absent or empty environment object is created. No delete
|
|
150
|
+
// path: uninstall removes the whole mcp entry wholesale.
|
|
151
|
+
type ApprovalModeOutcome = 'established' | 'present' | 'user';
|
|
152
|
+
|
|
153
|
+
function applyApprovalModeToEntry(entry: Record<string, unknown>): ApprovalModeOutcome {
|
|
124
154
|
const env = asRecord(entry.environment);
|
|
125
155
|
const current = env.DEVKIT_APPROVAL_MODE;
|
|
126
|
-
if (current === 'ask') return
|
|
156
|
+
if (current === 'ask') return 'present';
|
|
127
157
|
if (current !== undefined) {
|
|
128
158
|
const shown = typeof current === 'string' ? current : JSON.stringify(current);
|
|
129
159
|
console.log(
|
|
130
|
-
` \x1b[33m[WARN]\x1b[0m OpenCode mcp entry already sets DEVKIT_APPROVAL_MODE=${shown} — keeping the user's value
|
|
160
|
+
` \x1b[33m[WARN]\x1b[0m OpenCode mcp entry already sets DEVKIT_APPROVAL_MODE=${shown} — keeping the user's value, so no client allow rules are kept (devkit-written ones are removed; see README, Harness permission notes).`,
|
|
131
161
|
);
|
|
132
|
-
return
|
|
162
|
+
return 'user';
|
|
133
163
|
}
|
|
134
164
|
entry.environment = { ...env, DEVKIT_APPROVAL_MODE: 'ask' };
|
|
135
|
-
return
|
|
165
|
+
return 'established';
|
|
136
166
|
}
|
|
137
167
|
|
|
138
168
|
// The glob set the seam covers: the plugin-dir tree actually deployed by
|
|
@@ -183,60 +213,110 @@ export function updateOpenCodeConfig(pluginDir: string): void {
|
|
|
183
213
|
' \x1b[33m[INFO]\x1b[0m opencode not verifiably at or above the measured permission floor — skipping the skills-tree permission write; see README (Harness permission notes) if direct skill reads prompt for approval.',
|
|
184
214
|
);
|
|
185
215
|
}
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
//
|
|
189
|
-
//
|
|
190
|
-
//
|
|
191
|
-
//
|
|
192
|
-
//
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
216
|
+
const askGate = openCodeAskGate();
|
|
217
|
+
const askOn = askGate !== 'off';
|
|
218
|
+
// The posture migration runs on EVERY path that touches the config, gate or
|
|
219
|
+
// no gate: the abandoned ask rules from any earlier install are removed
|
|
220
|
+
// value-exact in both generations, so the old posture never survives an
|
|
221
|
+
// install or update. Both shapes are attempted independently (a config can
|
|
222
|
+
// carry both, and the first removal must not short-circuit the second).
|
|
223
|
+
const migratedV2 = removeAskPermissionRules(config);
|
|
224
|
+
const migratedV1 = removeAskPermissionRulesV1(config);
|
|
225
|
+
const migrated = migratedV2 || migratedV1;
|
|
226
|
+
|
|
227
|
+
// The mcp entry's server half is resolved BEFORE the client rules: the
|
|
228
|
+
// allow set is written only when the server gate is established this run or
|
|
229
|
+
// already present, and a user-set mode value wins with no client rules.
|
|
230
|
+
const existing: unknown = asRecord(config.mcp)['huaweicloud-devkit'];
|
|
231
|
+
let entry: Record<string, unknown>;
|
|
232
|
+
let entryChanged = false;
|
|
233
|
+
let rebuilt = false;
|
|
234
|
+
let approvalMode: ApprovalModeOutcome | 'off' = 'off';
|
|
235
|
+
if (existing) {
|
|
236
|
+
const merged = mergeCommandStyle(existing, { mcpPath });
|
|
237
|
+
entry = merged.entry;
|
|
238
|
+
entryChanged = merged.changed;
|
|
239
|
+
if (applyPacksToEntry(entry, 'environment', 'OpenCode')) entryChanged = true;
|
|
240
|
+
if (askOn) {
|
|
241
|
+
approvalMode = applyApprovalModeToEntry(entry);
|
|
242
|
+
if (approvalMode === 'established') entryChanged = true;
|
|
243
|
+
}
|
|
244
|
+
} else {
|
|
245
|
+
entry = mergeCommandStyle(undefined, { mcpPath }).entry;
|
|
246
|
+
// Restore user fields saved by a previous uninstall (issue #615) before the
|
|
247
|
+
// packs write so a delta-carried DEVKIT_PACKS counts as the current value.
|
|
248
|
+
const delta = takeAgentDelta('opencode');
|
|
249
|
+
if (delta) entry = asRecord(applyUserDelta(entry, delta, 'command'));
|
|
250
|
+
applyPacksToEntry(entry, 'environment', 'OpenCode');
|
|
251
|
+
if (askOn) approvalMode = applyApprovalModeToEntry(entry);
|
|
252
|
+
rebuilt = true;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// The client half — one exact allow rule per roster tool, no wildcard. Its
|
|
256
|
+
// SHAPE rides the probed generation: the V2 permissions array on 2.0+, the
|
|
257
|
+
// V1 permission object on 1.19–1.x (the roster action is byte-identical
|
|
258
|
+
// across shapes, and the mcp env half is shared). It is a FOURTH change
|
|
259
|
+
// source, computed before the unchanged short-circuit for the same reason
|
|
260
|
+
// as the seam: an unchanged mcp entry is the dominant update shape, and
|
|
261
|
+
// every install made before the posture existed is the population this
|
|
262
|
+
// must heal.
|
|
263
|
+
let clientChanged = false;
|
|
264
|
+
let clientRemoved = false;
|
|
265
|
+
if (askOn && approvalMode === 'user') {
|
|
266
|
+
// The server half left the pair (the user's own mode value governs the
|
|
267
|
+
// posture), so the client half leaves with it: any allow rules a past
|
|
268
|
+
// install wrote are removed value-exact, both shapes independently (a
|
|
269
|
+
// config can carry both). Without this, the doctor's mixed-state WARN
|
|
270
|
+
// could never heal — re-running install would reproduce it forever.
|
|
271
|
+
// After the removal the user's posture (token mode) is fully mechanical.
|
|
272
|
+
const removedV2 = removeAllowPermissionRules(config);
|
|
273
|
+
const removedV1 = removeAllowPermissionRulesV1(config);
|
|
274
|
+
clientRemoved = removedV2 || removedV1;
|
|
275
|
+
} else if (askOn) {
|
|
276
|
+
const applied = askGate === 'v1-object' ? applyAllowPermissionRulesV1(config) : applyAllowPermissionRules(config);
|
|
277
|
+
clientChanged = applied.changed;
|
|
278
|
+
for (const action of applied.skipped) {
|
|
198
279
|
console.log(
|
|
199
|
-
|
|
280
|
+
askGate === 'v1-object'
|
|
281
|
+
? ` \x1b[33m[WARN]\x1b[0m opencode permission already has the ${action} key — keeping it as the user's, so no allow rule is written for it (see README, Harness permission notes).`
|
|
282
|
+
: ` \x1b[33m[WARN]\x1b[0m opencode permissions already has an entry for ${action} — keeping it as the user's, so no allow rule is written for it (see README, Harness permission notes).`,
|
|
200
283
|
);
|
|
201
284
|
}
|
|
202
|
-
|
|
285
|
+
if (applied.shapeUnreadable) {
|
|
286
|
+
console.log(
|
|
287
|
+
askGate === 'v1-object'
|
|
288
|
+
? ` \x1b[33m[WARN]\x1b[0m opencode permission is not object-shaped — keeping the user's global posture; add the client allow rules manually (see README, Harness permission notes).`
|
|
289
|
+
: ` \x1b[33m[WARN]\x1b[0m opencode permissions is not array-shaped — keeping the user's value; add the client allow rules manually (see README, Harness permission notes).`,
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
} else if (!askOn) {
|
|
203
293
|
console.log(
|
|
204
|
-
' \x1b[33m[INFO]\x1b[0m opencode not verifiably at or above
|
|
294
|
+
' \x1b[33m[INFO]\x1b[0m opencode not verifiably at or above 1.19.0 — keeping the terminal token approval gate; no client allow rules or DEVKIT_APPROVAL_MODE is written.',
|
|
205
295
|
);
|
|
206
296
|
}
|
|
207
|
-
|
|
208
|
-
if (existing) {
|
|
209
|
-
const { entry, changed } = mergeCommandStyle(existing, { mcpPath });
|
|
210
|
-
const packsChanged = applyPacksToEntry(entry, 'environment', 'OpenCode');
|
|
211
|
-
const askEnvChanged = askOn && applyApprovalModeToEntry(entry);
|
|
212
|
-
if (!changed && !packsChanged && !permChanged && !askRuleChanged && !askEnvChanged) {
|
|
213
|
-
console.log(` OpenCode MCP config unchanged: ${configPath}`);
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
297
|
+
if (rebuilt || entryChanged) {
|
|
216
298
|
const mcpMap = asRecord(config.mcp);
|
|
217
299
|
mcpMap['huaweicloud-devkit'] = entry;
|
|
218
300
|
config.mcp = mcpMap;
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
console.log(` ASK approval (permissions ask rule + DEVKIT_APPROVAL_MODE) -> ${configPath}`);
|
|
223
|
-
}
|
|
301
|
+
}
|
|
302
|
+
if (!rebuilt && !entryChanged && !permChanged && !clientChanged && !migrated && !clientRemoved) {
|
|
303
|
+
console.log(` OpenCode MCP config unchanged: ${configPath}`);
|
|
224
304
|
return;
|
|
225
305
|
}
|
|
226
|
-
const mcpMap: Record<string, unknown> = asRecord(config.mcp);
|
|
227
|
-
let entry = mergeCommandStyle(undefined, { mcpPath }).entry;
|
|
228
|
-
// Restore user fields saved by a previous uninstall (issue #615) before the
|
|
229
|
-
// packs write so a delta-carried DEVKIT_PACKS counts as the current value.
|
|
230
|
-
const delta = takeAgentDelta('opencode');
|
|
231
|
-
if (delta) entry = asRecord(applyUserDelta(entry, delta, 'command'));
|
|
232
|
-
applyPacksToEntry(entry, 'environment', 'OpenCode');
|
|
233
|
-
const askEnvChanged = askOn && applyApprovalModeToEntry(entry);
|
|
234
|
-
mcpMap['huaweicloud-devkit'] = entry;
|
|
235
|
-
config.mcp = mcpMap;
|
|
236
306
|
writeMcpSettingsFile(configPath, config);
|
|
237
|
-
console.log(
|
|
238
|
-
|
|
239
|
-
|
|
307
|
+
console.log(
|
|
308
|
+
rebuilt
|
|
309
|
+
? ` OpenCode config updated: ${configPath}`
|
|
310
|
+
: ` OpenCode MCP config merged (user fields preserved): ${configPath}`,
|
|
311
|
+
);
|
|
312
|
+
if (migrated) {
|
|
313
|
+
console.log(` ASK posture migrated (legacy ask rules removed) -> ${configPath}`);
|
|
314
|
+
}
|
|
315
|
+
if (clientRemoved) {
|
|
316
|
+
console.log(` ASK client allow rules removed (DEVKIT_APPROVAL_MODE is the user's own) -> ${configPath}`);
|
|
317
|
+
}
|
|
318
|
+
if (clientChanged) {
|
|
319
|
+
console.log(` ASK approval (client allow rules + DEVKIT_APPROVAL_MODE server gate) -> ${configPath}`);
|
|
240
320
|
}
|
|
241
321
|
}
|
|
242
322
|
|
|
@@ -262,16 +342,24 @@ export function removeOpenCodeConfig(): void {
|
|
|
262
342
|
// value-exact deletion keeps user-modified rules (the ownership contract
|
|
263
343
|
// lives in lib/opencode-permission-seam.ts).
|
|
264
344
|
const permCleaned = removeSkillTreePermissionSeam(config, openCodeSeamGlobs(opencodePluginsDir()));
|
|
265
|
-
// The
|
|
345
|
+
// The client-rule cleanup also runs unconditionally of the version gate: an
|
|
266
346
|
// uninstall must remove what any past install wrote — the opencode that
|
|
267
|
-
// gated the write may since have been upgraded, downgraded, or removed
|
|
268
|
-
//
|
|
269
|
-
//
|
|
270
|
-
//
|
|
271
|
-
|
|
272
|
-
|
|
347
|
+
// gated the write may since have been upgraded, downgraded, or removed from
|
|
348
|
+
// PATH, and the rule's shape rode the generation that was current then. All
|
|
349
|
+
// four shape/effect pairs are attempted independently (a config can carry
|
|
350
|
+
// both generations, and the legacy ask rules as well as the allow set), each
|
|
351
|
+
// value-exact so a user-modified rule survives — the ownership contract
|
|
352
|
+
// lives in lib/opencode-ask-rule.ts. The mcp entry (and its
|
|
353
|
+
// DEVKIT_APPROVAL_MODE env) is already gone wholesale above.
|
|
354
|
+
const allowCleanedV2 = removeAllowPermissionRules(config);
|
|
355
|
+
const allowCleanedV1 = removeAllowPermissionRulesV1(config);
|
|
356
|
+
const askCleanedV2 = removeAskPermissionRules(config);
|
|
357
|
+
const askCleanedV1 = removeAskPermissionRulesV1(config);
|
|
358
|
+
const allowCleaned = allowCleanedV2 || allowCleanedV1;
|
|
359
|
+
const askCleaned = askCleanedV2 || askCleanedV1;
|
|
360
|
+
if (!hadEntry && !permCleaned && !allowCleaned && !askCleaned) return;
|
|
273
361
|
writeMcpSettingsFile(configPath, config);
|
|
274
362
|
if (hadEntry) console.log(` OpenCode MCP config cleaned: ${configPath}`);
|
|
275
363
|
if (permCleaned) console.log(` Skills-tree permission rules removed: ${configPath}`);
|
|
276
|
-
if (askCleaned) console.log(` ASK permission
|
|
364
|
+
if (allowCleaned || askCleaned) console.log(` ASK client permission rules removed: ${configPath}`);
|
|
277
365
|
}
|
|
@@ -35,7 +35,8 @@ import {
|
|
|
35
35
|
openCodeSeamGlobs,
|
|
36
36
|
openCodeAskGate,
|
|
37
37
|
} from './opencode-config.ts';
|
|
38
|
-
import {
|
|
38
|
+
import { readPermissionRules, readPermissionRulesV1, type RosterRuleState } from '../lib/opencode-ask-rule.ts';
|
|
39
|
+
import { scanSavedAllowRows } from '../lib/opencode-saved-perms.ts';
|
|
39
40
|
import type { DoctorReporter } from '../doctor-report.ts';
|
|
40
41
|
import { asRecord } from '../lib/as-record.ts';
|
|
41
42
|
|
|
@@ -54,81 +55,151 @@ export function opencodeDoctorMcpConfigured(): string | null {
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
// Doctor: the ASK approval posture check — OpenCode installs only. The
|
|
57
|
-
// posture is a PAIR: the client half (
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
58
|
+
// posture is a PAIR the installer writes together: the client half (one exact
|
|
59
|
+
// allow rule per roster tool — a `permissions` array entry on 2.0+, a
|
|
60
|
+
// `permission` object key on 1.19–1.x, both naming the same actions) and the
|
|
61
|
+
// server half (DEVKIT_APPROVAL_MODE=ask in the mcp entry's env). Ask mode now
|
|
62
|
+
// means the SERVER-RUN gate: the confirmation is raised inside the tool call
|
|
63
|
+
// (elicitation form, or the T3 chat round-trip), so the client rules are
|
|
64
|
+
// yield-only — they suppress the redundant client popup — and a client allow
|
|
65
|
+
// rule can no longer fail anything open. The directions that survive the flip:
|
|
66
|
+
// - a deny rule bricks the call in the client, so it stays a FAIL;
|
|
67
|
+
// - a devkit-written ask rule is migration residue: FAIL, re-run install;
|
|
68
|
+
// - missing client coverage while the server gate is on is drift: FAIL;
|
|
69
|
+
// - allow rules without the server gate are the mixed state: WARN;
|
|
70
|
+
// - an unreadable shape with the gate on is a WARN, never silent (the
|
|
71
|
+
// verification's B2 invariant — the gate still holds server-side, so a
|
|
72
|
+
// WARN is honest, not a FAIL);
|
|
73
|
+
// - a user-owned rule on a roster action is surfaced by name with the skip
|
|
74
|
+
// recorded, never silently dropped.
|
|
75
|
+
// A gate-off opencode is a SKIP — token mode is that install's legitimate
|
|
76
|
+
// posture, and the migration still removes the legacy ask rules.
|
|
68
77
|
export function opencodeDoctorAskRule(ctx: DoctorReporter): void {
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
const gate = openCodeAskGate();
|
|
79
|
+
if (gate === 'off') {
|
|
80
|
+
ctx.skip('ASK approval posture (opencode not verifiably at or above 1.19.0)');
|
|
71
81
|
return;
|
|
72
82
|
}
|
|
83
|
+
askPostureCheck(ctx, gate);
|
|
84
|
+
savedAllowStoreCheck(ctx);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const ASK_POSTURE_LABEL = 'ASK approval posture (client allow rules + server gate)';
|
|
88
|
+
|
|
89
|
+
function askPostureCheck(ctx: DoctorReporter, gate: 'v2-array' | 'v1-object'): void {
|
|
90
|
+
const v1 = gate === 'v1-object';
|
|
73
91
|
let cfg: Record<string, unknown> | null;
|
|
74
92
|
try {
|
|
75
93
|
cfg = asRecord(JSON.parse(readFileSync(opencodeConfigFile(), 'utf8')));
|
|
76
94
|
} catch {
|
|
77
95
|
cfg = null;
|
|
78
96
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
'ASK approval posture: opencode config unreadable or permissions not array-shaped — the installer keeps it untouched; add the ask rule and DEVKIT_APPROVAL_MODE manually (see README, Harness permission notes)',
|
|
97
|
+
if (cfg === null) {
|
|
98
|
+
ctx.warn(
|
|
99
|
+
`${ASK_POSTURE_LABEL}: the opencode config is unreadable, so the client half cannot be verified — the server gate still confirms every roster call; fix the file and re-run: npx huaweicloud-devkit install --target opencode`,
|
|
83
100
|
);
|
|
84
101
|
return;
|
|
85
102
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const label = 'ASK approval posture (client prompt + server env)';
|
|
91
|
-
if (posture === 'ask') {
|
|
92
|
-
ctx.check(
|
|
93
|
-
label,
|
|
94
|
-
envAsk,
|
|
95
|
-
envAsk
|
|
96
|
-
? ''
|
|
97
|
-
: 'DEVKIT_APPROVAL_MODE=ask missing from the mcp entry — the client prompts AND the server still demands a token (re-run: npx huaweicloud-devkit install --target opencode)',
|
|
103
|
+
const reading = v1 ? readPermissionRulesV1(cfg) : readPermissionRules(cfg);
|
|
104
|
+
if (reading.sectionUnreadable) {
|
|
105
|
+
ctx.warn(
|
|
106
|
+
`${ASK_POSTURE_LABEL}: opencode ${v1 ? 'permission is not object-shaped' : 'permissions is not array-shaped'}, so the client half cannot be verified — the server gate still confirms every roster call; fix the shape and re-run: npx huaweicloud-devkit install --target opencode`,
|
|
98
107
|
);
|
|
99
108
|
return;
|
|
100
109
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
// The mcp entry carries the server half; a missing entry counts as no env.
|
|
111
|
+
const env = asRecord(asRecord(asRecord(cfg.mcp)['huaweicloud-devkit']).environment);
|
|
112
|
+
const gateOn = env.DEVKIT_APPROVAL_MODE === 'ask';
|
|
113
|
+
const actionsIn = (state: RosterRuleState): string[] =>
|
|
114
|
+
reading.rules.filter((rule) => rule.state === state).map((rule) => rule.action);
|
|
115
|
+
const allow = actionsIn('allow');
|
|
116
|
+
const absent = actionsIn('absent');
|
|
117
|
+
const deny = actionsIn('deny');
|
|
118
|
+
const foreign = actionsIn('foreign');
|
|
119
|
+
const userOther = actionsIn('user-other');
|
|
120
|
+
const residue = reading.rules.filter((rule) => rule.askResidue).map((rule) => rule.action);
|
|
121
|
+
|
|
122
|
+
// Token mode with no client rules at all is the legitimate default posture.
|
|
123
|
+
if (!gateOn && absent.length === reading.rules.length) {
|
|
124
|
+
ctx.check('ASK approval posture (token mode)', true, '');
|
|
111
125
|
return;
|
|
112
126
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
127
|
+
|
|
128
|
+
const fails: string[] = [];
|
|
129
|
+
const warns: string[] = [];
|
|
130
|
+
if (deny.length > 0) {
|
|
131
|
+
fails.push(
|
|
132
|
+
v1
|
|
133
|
+
? `the permission value on ${deny.join(', ')} is "deny" — the write tool is blocked outright in the client; delete that key`
|
|
134
|
+
: `a permissions rule on ${deny.join(', ')} is "deny" — the write tool is blocked outright in the client; delete that rule`,
|
|
118
135
|
);
|
|
119
|
-
return;
|
|
120
136
|
}
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
137
|
+
if (residue.length > 0) {
|
|
138
|
+
fails.push(
|
|
139
|
+
`the devkit-written ask ${v1 ? 'value' : 'rule'} is still present on ${residue.join(', ')} — the posture migration missed it (re-run: npx huaweicloud-devkit install --target opencode)`,
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
if (gateOn && absent.length > 0) {
|
|
143
|
+
fails.push(
|
|
144
|
+
`the client allow ${v1 ? 'value' : 'rule'} is missing on ${absent.join(', ')} while DEVKIT_APPROVAL_MODE=ask is set — the pair has drifted from what this installer writes (re-run: npx huaweicloud-devkit install --target opencode)`,
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
if (!gateOn && allow.length > 0) {
|
|
148
|
+
warns.push(
|
|
149
|
+
`client allow ${v1 ? 'values' : 'rules'} on ${allow.join(', ')} are present but DEVKIT_APPROVAL_MODE=ask is missing from the mcp entry — the mixed state suppresses the client prompt while the server runs the token gate (re-run: npx huaweicloud-devkit install --target opencode)`,
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
if (userOther.length > 0) {
|
|
153
|
+
warns.push(
|
|
154
|
+
`a user-owned ${v1 ? 'permission value' : 'rule'} on ${userOther.join(', ')} covers a different resource, so the installer keeps it (skip recorded) and no exact "*" allow rule is written there (see README, Harness permission notes)`,
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
if (foreign.length > 0) {
|
|
158
|
+
warns.push(
|
|
159
|
+
`the ${v1 ? 'permission value' : 'permissions rule'} on ${foreign.join(', ')} is not a readable effect, so the client half cannot be verified there`,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (fails.length > 0) {
|
|
163
|
+
ctx.check(ASK_POSTURE_LABEL, false, [...fails, ...warns].join(' '));
|
|
164
|
+
} else if (warns.length > 0) {
|
|
165
|
+
ctx.warn(`${ASK_POSTURE_LABEL}: ${warns.join(' ')}`);
|
|
166
|
+
} else {
|
|
167
|
+
ctx.check(ASK_POSTURE_LABEL, true, '');
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Doctor: the opencode saved-permission store, the client-side twin of the
|
|
172
|
+
// ask rule. One "Always allow" click on the client prompt persists an allow
|
|
173
|
+
// row that opencode evaluates AFTER the configured rules (findLast), so it
|
|
174
|
+
// silently converts every future call on the action into an unprompted
|
|
175
|
+
// execution of opencode's own permission layer. That no longer gates anything
|
|
176
|
+
// the devkit relies on: the confirmation runs on the server (the gate raises
|
|
177
|
+
// the form, or the T3 chat round-trip), inside the tool call and outside
|
|
178
|
+
// opencode's evaluation. The row is therefore a stale grant, reported as a
|
|
179
|
+
// WARN with the probe-measured removal commands, not a failing gate. Zero rows
|
|
180
|
+
// prints nothing at all (the healthy fresh state), so a clean install's
|
|
181
|
+
// doctor output stays byte-identical.
|
|
182
|
+
function savedAllowStoreCheck(ctx: DoctorReporter): void {
|
|
183
|
+
const scan = scanSavedAllowRows({ scope: 'all' });
|
|
184
|
+
if (scan.status === 'absent') return;
|
|
185
|
+
if (scan.status === 'unreadable') {
|
|
186
|
+
ctx.warn(
|
|
187
|
+
`ASK approval hygiene: opencode saved-permission store unreadable (${scan.dbPath}): ${scan.detail} — saved "always allow" rows cannot be listed`,
|
|
127
188
|
);
|
|
128
189
|
return;
|
|
129
190
|
}
|
|
130
|
-
|
|
131
|
-
|
|
191
|
+
if (scan.rows.length === 0) return;
|
|
192
|
+
// WARN, not FAIL (PR-1.5 demotion): the confirmation runs server-side, so a
|
|
193
|
+
// saved client-side allow row can no longer suppress it (the form is raised
|
|
194
|
+
// inside the tool call and never routes through opencode's permission
|
|
195
|
+
// evaluation). The row is a stale grant worth cleaning up, not a gate.
|
|
196
|
+
const actions = [...new Set(scan.rows.map((row) => row.action))].join(', ');
|
|
197
|
+
ctx.warn(
|
|
198
|
+
`ASK approval hygiene: opencode's permission store holds a saved "always allow" rule for ${actions} — the server-run confirmation ignores it, so calls are not fail-open; the row is still a stale grant. List them: opencode api GET /api/permission/saved. Remove one: opencode api DELETE /api/permission/saved/<id>. It lives in ${scan.dbPath}, table "permission".`,
|
|
199
|
+
);
|
|
200
|
+
for (const row of scan.rows) {
|
|
201
|
+
ctx.raw(` ${row.id} → ${row.projectWorktree ?? row.projectId} (action ${row.action})`);
|
|
202
|
+
}
|
|
132
203
|
}
|
|
133
204
|
|
|
134
205
|
// Doctor: the skills-tree permission seam check — OpenCode installs only
|