@osovv/vv-opencode 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/README.md +87 -86
- package/dist/commands/completion.js +0 -1
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/doctor.js +6 -9
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/init.d.ts +2 -1
- package/dist/commands/init.js +7 -12
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/install.d.ts +4 -0
- package/dist/commands/install.js +40 -37
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/launch.d.ts +2 -1
- package/dist/commands/launch.js +18 -14
- package/dist/commands/launch.js.map +1 -1
- package/dist/commands/patch-provider.d.ts +225 -307
- package/dist/commands/patch-provider.js +92 -296
- package/dist/commands/patch-provider.js.map +1 -1
- package/dist/commands/status.js +7 -10
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/sync.d.ts +4 -0
- package/dist/commands/sync.js +38 -35
- package/dist/commands/sync.js.map +1 -1
- package/dist/index.d.ts +25 -5
- package/dist/index.js +73 -34
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-tool-catalog.d.ts +1 -1
- package/dist/lib/agent-tool-catalog.js +3 -6
- package/dist/lib/agent-tool-catalog.js.map +1 -1
- package/dist/lib/agent-tool-contract.d.ts +22 -13
- package/dist/lib/agent-tool-contract.js +20 -20
- package/dist/lib/agent-tool-contract.js.map +1 -1
- package/dist/lib/analytics/types.d.ts +7 -1
- package/dist/lib/analytics/types.js +2 -2
- package/dist/lib/analytics/types.js.map +1 -1
- package/dist/lib/config-layers.d.ts +28 -6
- package/dist/lib/config-layers.js +268 -73
- package/dist/lib/config-layers.js.map +1 -1
- package/dist/lib/managed-agents.d.ts +24 -2
- package/dist/lib/managed-agents.js +45 -15
- package/dist/lib/managed-agents.js.map +1 -1
- package/dist/lib/model-roles.d.ts +5 -0
- package/dist/lib/model-roles.js +22 -1
- package/dist/lib/model-roles.js.map +1 -1
- package/dist/lib/opencode/agent-registrations.d.ts +4 -4
- package/dist/lib/opencode/agent-registrations.js +386 -197
- package/dist/lib/opencode/agent-registrations.js.map +1 -1
- package/dist/lib/opencode/inspection.d.ts +13 -13
- package/dist/lib/opencode/inspection.js +69 -106
- package/dist/lib/opencode/inspection.js.map +1 -1
- package/dist/lib/opencode/model-overrides.d.ts +2 -2
- package/dist/lib/opencode/model-overrides.js +192 -47
- package/dist/lib/opencode/model-overrides.js.map +1 -1
- package/dist/lib/opencode/paths.d.ts +6 -2
- package/dist/lib/opencode/paths.js +12 -11
- package/dist/lib/opencode/paths.js.map +1 -1
- package/dist/lib/opencode/plugin-registration.d.ts +10 -11
- package/dist/lib/opencode/plugin-registration.js +76 -138
- package/dist/lib/opencode/plugin-registration.js.map +1 -1
- package/dist/lib/opencode/shared-utils.d.ts +47 -3
- package/dist/lib/opencode/shared-utils.js +346 -15
- package/dist/lib/opencode/shared-utils.js.map +1 -1
- package/dist/lib/opencode.d.ts +5 -6
- package/dist/lib/opencode.js +10 -10
- package/dist/lib/opencode.js.map +1 -1
- package/dist/lib/vvoc-config.js +4 -4
- package/dist/lib/vvoc-config.js.map +1 -1
- package/dist/lib/vvoc-paths.d.ts +7 -0
- package/dist/lib/vvoc-paths.js +15 -1
- package/dist/lib/vvoc-paths.js.map +1 -1
- package/dist/lib/vvoc-preset-registry.d.ts +38 -50
- package/dist/lib/vvoc-preset-registry.js +38 -48
- package/dist/lib/vvoc-preset-registry.js.map +1 -1
- package/dist/plugins/analytics/index.d.ts +20 -14
- package/dist/plugins/analytics/index.js +281 -133
- package/dist/plugins/analytics/index.js.map +1 -1
- package/dist/plugins/guardian/index.d.ts +63 -42
- package/dist/plugins/guardian/index.js +217 -759
- package/dist/plugins/guardian/index.js.map +1 -1
- package/dist/plugins/hashline-edit/index.d.ts +145 -31
- package/dist/plugins/hashline-edit/index.js +679 -244
- package/dist/plugins/hashline-edit/index.js.map +1 -1
- package/dist/plugins/hashline-edit/schemas.d.ts +1 -1
- package/dist/plugins/hashline-edit/schemas.js +3 -3
- package/dist/plugins/hashline-edit/schemas.js.map +1 -1
- package/dist/plugins/model-roles/index.d.ts +18 -4
- package/dist/plugins/model-roles/index.js +44 -181
- package/dist/plugins/model-roles/index.js.map +1 -1
- package/dist/plugins/peak-hours/index.d.ts +23 -23
- package/dist/plugins/peak-hours/index.js +211 -180
- package/dist/plugins/peak-hours/index.js.map +1 -1
- package/dist/plugins/secrets-redaction/deep.js +35 -51
- package/dist/plugins/secrets-redaction/deep.js.map +1 -1
- package/dist/plugins/secrets-redaction/index.d.ts +96 -8
- package/dist/plugins/secrets-redaction/index.js +290 -102
- package/dist/plugins/secrets-redaction/index.js.map +1 -1
- package/dist/plugins/secrets-redaction/session.d.ts +9 -0
- package/dist/plugins/secrets-redaction/session.js +21 -4
- package/dist/plugins/secrets-redaction/session.js.map +1 -1
- package/dist/plugins/secrets-redaction/stream.d.ts +92 -0
- package/dist/plugins/secrets-redaction/stream.js +772 -0
- package/dist/plugins/secrets-redaction/stream.js.map +1 -0
- package/dist/plugins/spec-guard/index.d.ts +49 -18
- package/dist/plugins/spec-guard/index.js +231 -129
- package/dist/plugins/spec-guard/index.js.map +1 -1
- package/dist/plugins/system-context-injection/index.d.ts +10 -4
- package/dist/plugins/system-context-injection/index.js +271 -78
- package/dist/plugins/system-context-injection/index.js.map +1 -1
- package/dist/plugins/tool-history-compaction/index.d.ts +26 -4
- package/dist/plugins/tool-history-compaction/index.js +170 -32
- package/dist/plugins/tool-history-compaction/index.js.map +1 -1
- package/dist/plugins/tool-history-compaction/transform.d.ts +47 -16
- package/dist/plugins/tool-history-compaction/transform.js +173 -55
- package/dist/plugins/tool-history-compaction/transform.js.map +1 -1
- package/dist/plugins/web-tools/fetch-service.d.ts +51 -13
- package/dist/plugins/web-tools/fetch-service.js +106 -75
- package/dist/plugins/web-tools/fetch-service.js.map +1 -1
- package/dist/plugins/web-tools/index.d.ts +58 -16
- package/dist/plugins/web-tools/index.js +202 -91
- package/dist/plugins/web-tools/index.js.map +1 -1
- package/dist/plugins/web-tools/media-loader.d.ts +3 -3
- package/dist/plugins/web-tools/media-loader.js +3 -3
- package/dist/plugins/web-tools/media-loader.js.map +1 -1
- package/dist/plugins/web-tools/providers/native-fetch.d.ts +2 -2
- package/dist/plugins/web-tools/providers/native-fetch.js +1 -1
- package/dist/plugins/web-tools/providers/native-fetch.js.map +1 -1
- package/dist/plugins/web-tools/providers/spider.d.ts +2 -2
- package/dist/plugins/web-tools/providers/spider.js +1 -1
- package/dist/plugins/web-tools/providers/spider.js.map +1 -1
- package/dist/plugins/web-tools/providers/zai.d.ts +2 -2
- package/dist/plugins/web-tools/providers/zai.js +1 -1
- package/dist/plugins/web-tools/providers/zai.js.map +1 -1
- package/dist/plugins/web-tools/schemas.d.ts +1 -1
- package/dist/plugins/web-tools/schemas.js +3 -3
- package/dist/plugins/web-tools/schemas.js.map +1 -1
- package/dist/plugins/web-tools/search-service.d.ts +81 -12
- package/dist/plugins/web-tools/search-service.js +104 -57
- package/dist/plugins/web-tools/search-service.js.map +1 -1
- package/dist/plugins/workflow/authorization.d.ts +44 -10
- package/dist/plugins/workflow/authorization.js +113 -73
- package/dist/plugins/workflow/authorization.js.map +1 -1
- package/dist/plugins/workflow/cancellation.d.ts +86 -0
- package/dist/plugins/workflow/cancellation.js +202 -0
- package/dist/plugins/workflow/cancellation.js.map +1 -0
- package/dist/plugins/workflow/checkpoints.d.ts +7 -1
- package/dist/plugins/workflow/checkpoints.js +141 -21
- package/dist/plugins/workflow/checkpoints.js.map +1 -1
- package/dist/plugins/workflow/delegated.d.ts +14 -0
- package/dist/plugins/workflow/delegated.js +6 -5
- package/dist/plugins/workflow/delegated.js.map +1 -1
- package/dist/plugins/workflow/host.d.ts +81 -0
- package/dist/plugins/workflow/host.js +189 -0
- package/dist/plugins/workflow/host.js.map +1 -0
- package/dist/plugins/workflow/index.d.ts +69 -4
- package/dist/plugins/workflow/index.js +1391 -1026
- package/dist/plugins/workflow/index.js.map +1 -1
- package/dist/plugins/workflow/recovery.d.ts +3 -5
- package/dist/plugins/workflow/recovery.js +18 -33
- package/dist/plugins/workflow/recovery.js.map +1 -1
- package/dist/plugins/workflow/repair.d.ts +31 -5
- package/dist/plugins/workflow/repair.js +116 -48
- package/dist/plugins/workflow/repair.js.map +1 -1
- package/dist/plugins/workflow/results.d.ts +31 -31
- package/dist/plugins/workflow/results.js +4 -4
- package/dist/plugins/workflow/results.js.map +1 -1
- package/dist/plugins/workflow/schemas.d.ts +3 -3
- package/dist/plugins/workflow/schemas.js +5 -5
- package/dist/plugins/workflow/schemas.js.map +1 -1
- package/dist/plugins/workflow/system-instruction.md +4 -0
- package/dist/plugins/workflow/tooling.d.ts +6 -0
- package/dist/plugins/workflow/tooling.js +3 -1
- package/dist/plugins/workflow/tooling.js.map +1 -1
- package/dist/runtime/auxiliary.d.ts +13 -0
- package/dist/runtime/auxiliary.js +108 -0
- package/dist/runtime/auxiliary.js.map +1 -0
- package/dist/runtime/client.d.ts +88 -0
- package/dist/runtime/client.js +174 -0
- package/dist/runtime/client.js.map +1 -0
- package/dist/runtime/context-inspection-contract.d.ts +397 -0
- package/dist/runtime/context-inspection-contract.js +622 -0
- package/dist/runtime/context-inspection-contract.js.map +1 -0
- package/dist/runtime/context-inspection.d.ts +52 -0
- package/dist/runtime/context-inspection.js +324 -0
- package/dist/runtime/context-inspection.js.map +1 -0
- package/dist/runtime/context.d.ts +192 -0
- package/dist/runtime/context.js +1246 -0
- package/dist/runtime/context.js.map +1 -0
- package/dist/runtime/coordination.d.ts +40 -0
- package/dist/runtime/coordination.js +87 -0
- package/dist/runtime/coordination.js.map +1 -0
- package/dist/runtime/model-registry.d.ts +34 -0
- package/dist/runtime/model-registry.js +227 -0
- package/dist/runtime/model-registry.js.map +1 -0
- package/dist/runtime/permissions.d.ts +20 -0
- package/dist/runtime/permissions.js +250 -0
- package/dist/runtime/permissions.js.map +1 -0
- package/dist/runtime/snapshot-config.d.ts +80 -0
- package/dist/runtime/snapshot-config.js +268 -0
- package/dist/runtime/snapshot-config.js.map +1 -0
- package/dist/runtime/snapshot-store.d.ts +25 -0
- package/dist/runtime/snapshot-store.js +519 -0
- package/dist/runtime/snapshot-store.js.map +1 -0
- package/dist/runtime/snapshots.d.ts +59 -0
- package/dist/runtime/snapshots.js +721 -0
- package/dist/runtime/snapshots.js.map +1 -0
- package/dist/runtime/types.d.ts +713 -0
- package/dist/runtime/types.js +190 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/tui/analytics/indicator.d.ts +25 -26
- package/dist/tui/analytics/indicator.js +66 -74
- package/dist/tui/analytics/indicator.js.map +1 -1
- package/dist/tui/branding/footer.d.ts +7 -12
- package/dist/tui/branding/footer.js +16 -24
- package/dist/tui/branding/footer.js.map +1 -1
- package/dist/tui/context/analyze.d.ts +20 -9
- package/dist/tui/context/analyze.js +295 -257
- package/dist/tui/context/analyze.js.map +1 -1
- package/dist/tui/context/collect.d.ts +29 -3
- package/dist/tui/context/collect.js +450 -66
- package/dist/tui/context/collect.js.map +1 -1
- package/dist/tui/context/plugin.d.ts +21 -7
- package/dist/tui/context/plugin.js +65 -70
- package/dist/tui/context/plugin.js.map +1 -1
- package/dist/tui/context/types.d.ts +174 -43
- package/dist/tui/context/types.js +25 -19
- package/dist/tui/context/types.js.map +1 -1
- package/dist/tui/context/view.d.ts +33 -7
- package/dist/tui/context/view.js +136 -81
- package/dist/tui/context/view.js.map +1 -1
- package/dist/tui/peak-hours/banner.d.ts +13 -11
- package/dist/tui/peak-hours/banner.js +48 -80
- package/dist/tui/peak-hours/banner.js.map +1 -1
- package/dist/tui/policy.d.ts +69 -0
- package/dist/tui/policy.js +169 -0
- package/dist/tui/policy.js.map +1 -0
- package/dist/tui.d.ts +3 -8
- package/dist/tui.js +72 -68
- package/dist/tui.js.map +1 -1
- package/package.json +19 -15
- package/schemas/vvoc/v3.json +1 -1
- package/server.js +3 -5
- package/templates/agents/enhancer.md +10 -5
- package/templates/agents/guardian.md +10 -4
- package/templates/agents/investigator.md +4 -2
- package/templates/agents/vv-code-reviewer.md +4 -2
- package/templates/agents/vv-spec-reviewer.md +4 -2
- package/templates/skills/vv-execute/references/tool-contracts.md +1 -1
- package/tui.js +3 -5
- package/dist/plugins/analytics/v2.d.ts +0 -21
- package/dist/plugins/analytics/v2.js +0 -133
- package/dist/plugins/analytics/v2.js.map +0 -1
- package/dist/plugins/guardian/v2.d.ts +0 -13
- package/dist/plugins/guardian/v2.js +0 -204
- package/dist/plugins/guardian/v2.js.map +0 -1
- package/dist/plugins/hashline-edit/v2.d.ts +0 -12
- package/dist/plugins/hashline-edit/v2.js +0 -145
- package/dist/plugins/hashline-edit/v2.js.map +0 -1
- package/dist/plugins/model-roles/v2.d.ts +0 -24
- package/dist/plugins/model-roles/v2.js +0 -274
- package/dist/plugins/model-roles/v2.js.map +0 -1
- package/dist/plugins/peak-hours/v2.d.ts +0 -12
- package/dist/plugins/peak-hours/v2.js +0 -99
- package/dist/plugins/peak-hours/v2.js.map +0 -1
- package/dist/plugins/secrets-redaction/v2.d.ts +0 -19
- package/dist/plugins/secrets-redaction/v2.js +0 -138
- package/dist/plugins/secrets-redaction/v2.js.map +0 -1
- package/dist/plugins/spec-guard/v2.d.ts +0 -12
- package/dist/plugins/spec-guard/v2.js +0 -139
- package/dist/plugins/spec-guard/v2.js.map +0 -1
- package/dist/plugins/system-context-injection/agent-contexts.d.ts +0 -5
- package/dist/plugins/system-context-injection/agent-contexts.js +0 -164
- package/dist/plugins/system-context-injection/agent-contexts.js.map +0 -1
- package/dist/plugins/system-context-injection/v2.d.ts +0 -13
- package/dist/plugins/system-context-injection/v2.js +0 -60
- package/dist/plugins/system-context-injection/v2.js.map +0 -1
- package/dist/plugins/tool-history-compaction/v2.d.ts +0 -11
- package/dist/plugins/tool-history-compaction/v2.js +0 -56
- package/dist/plugins/tool-history-compaction/v2.js.map +0 -1
- package/dist/plugins/v2-runtime/config-watcher.d.ts +0 -26
- package/dist/plugins/v2-runtime/config-watcher.js +0 -111
- package/dist/plugins/v2-runtime/config-watcher.js.map +0 -1
- package/dist/plugins/v2-runtime/index.d.ts +0 -50
- package/dist/plugins/v2-runtime/index.js +0 -114
- package/dist/plugins/v2-runtime/index.js.map +0 -1
- package/dist/plugins/v2-runtime/location-config.d.ts +0 -51
- package/dist/plugins/v2-runtime/location-config.js +0 -91
- package/dist/plugins/v2-runtime/location-config.js.map +0 -1
- package/dist/plugins/v2-runtime/setup.d.ts +0 -48
- package/dist/plugins/v2-runtime/setup.js +0 -174
- package/dist/plugins/v2-runtime/setup.js.map +0 -1
- package/dist/plugins/web-tools/v2.d.ts +0 -11
- package/dist/plugins/web-tools/v2.js +0 -99
- package/dist/plugins/web-tools/v2.js.map +0 -1
- package/dist/plugins/workflow/v2.d.ts +0 -76
- package/dist/plugins/workflow/v2.js +0 -283
- package/dist/plugins/workflow/v2.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// FILE: src/lib/opencode/plugin-registration.ts
|
|
2
|
-
// VERSION:
|
|
2
|
+
// VERSION: 2.0.0
|
|
3
3
|
// START_MODULE_CONTRACT
|
|
4
|
-
// PURPOSE: Conservative
|
|
5
|
-
// SCOPE:
|
|
4
|
+
// PURPOSE: Conservative native OpenCode plugin registration and host compatibility window for the pinned combined base package.
|
|
5
|
+
// SCOPE: Native `plugins` array parsing/normalization preserving `-target` removal directives, string entries, `{package, options}` objects and their options while upgrading the pinned vvoc package and migrating legacy `/tui` specs; exact supported native host window predicate; idempotent writes into opencode.json(c).
|
|
6
6
|
// DEPENDS: [jsonc-parser, src/lib/package.ts, src/lib/opencode/shared-utils.ts]
|
|
7
7
|
// LINKS: [M-CLI-CONFIG]
|
|
8
8
|
// ROLE: RUNTIME
|
|
@@ -10,43 +10,70 @@
|
|
|
10
10
|
// END_MODULE_CONTRACT
|
|
11
11
|
//
|
|
12
12
|
// START_MODULE_MAP
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
// ensurePackageInstalled - Writes the pinned vvoc
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
// isTuiPackageSpecifier - True when a TUI entry equals the pinned base package specifier.
|
|
24
|
-
// readTuiPluginName - Extracts the name from a TUI plugin entry.
|
|
13
|
+
// MIN_SUPPORTED_OPENCODE_VERSION - Lowest supported native OpenCode host version.
|
|
14
|
+
// MAX_SUPPORTED_OPENCODE_VERSION_EXCLUSIVE - First unsupported native OpenCode host version (exclusive upper bound).
|
|
15
|
+
// SUPPORTED_OPENCODE_VERSION_RANGE - Human-readable exact supported native OpenCode host window.
|
|
16
|
+
// TUI_PACKAGE_SPECIFIER - Pinned combined base package specifier used for TUI registration.
|
|
17
|
+
// isSupportedOpenCodeVersion - True only for the exact supported native OpenCode host window (no prereleases).
|
|
18
|
+
// ensurePackageConfigText - Ensures OpenCode config registers the pinned combined base package in the native `plugins` array.
|
|
19
|
+
// ensurePackageInstalled - Writes the pinned vvoc package into OpenCode config.
|
|
20
|
+
// isManagedPackageTarget - True when a plugin target is the vvoc base package or a legacy `/tui` subpath.
|
|
21
|
+
// normalizePluginEntries - Rewrites the managed vvoc entry to the requested specifier preserving options and order.
|
|
22
|
+
// JsonObject - Re-exported JSON object shape for native config documents.
|
|
25
23
|
// END_MODULE_MAP
|
|
26
24
|
//
|
|
27
25
|
// START_CHANGE_SUMMARY
|
|
28
|
-
// LAST_CHANGE: [C-OPENCODE-
|
|
26
|
+
// LAST_CHANGE: [C-OPENCODE-V2-NATIVE T-007 - Replaced the V1 `plugin` string tuple handling with the native `plugins` array of string and {package, options} entries; removed the dedicated tui.json writer.]
|
|
29
27
|
// END_CHANGE_SUMMARY
|
|
30
28
|
import { applyEdits, format, modify } from "jsonc-parser";
|
|
29
|
+
import { dirname } from "node:path";
|
|
31
30
|
import { getPinnedPackageSpecifier, PACKAGE_NAME, PACKAGE_VERSION } from "../package.js";
|
|
32
|
-
import {
|
|
31
|
+
import { assertNativeOpenCodeDocument, ensureTrailingNewline, OPENCODE_SCHEMA_URL, parseObjectDocument, readOptionalText, readPluginEntries, renderJson, writeText, } from "./shared-utils.js";
|
|
32
|
+
export const MIN_SUPPORTED_OPENCODE_VERSION = "2.0.18";
|
|
33
|
+
export const MAX_SUPPORTED_OPENCODE_VERSION_EXCLUSIVE = "2.0.19";
|
|
34
|
+
export const SUPPORTED_OPENCODE_VERSION_RANGE = `>=${MIN_SUPPORTED_OPENCODE_VERSION} <${MAX_SUPPORTED_OPENCODE_VERSION_EXCLUSIVE}`;
|
|
35
|
+
/** The combined base package is registered once in native `plugins` for both server and TUI consumption. */
|
|
33
36
|
export const TUI_PACKAGE_SPECIFIER = `${PACKAGE_NAME}@${PACKAGE_VERSION}`;
|
|
34
|
-
|
|
37
|
+
// START_CONTRACT: isSupportedOpenCodeVersion
|
|
38
|
+
// PURPOSE: Accept only the exact pinned native OpenCode host window, rejecting older, newer, and prerelease builds.
|
|
39
|
+
// INPUTS: { version: string - `opencode --version` semantic version, optionally v-prefixed. }
|
|
40
|
+
// OUTPUTS: { boolean - True only for 2.0.18 with no prerelease suffix. }
|
|
41
|
+
// SIDE_EFFECTS: none
|
|
42
|
+
// LINKS: [const-MIN_SUPPORTED_OPENCODE_VERSION]
|
|
43
|
+
// END_CONTRACT: isSupportedOpenCodeVersion
|
|
44
|
+
export function isSupportedOpenCodeVersion(version) {
|
|
45
|
+
const match = version
|
|
46
|
+
.trim()
|
|
47
|
+
.match(/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/);
|
|
48
|
+
if (!match)
|
|
49
|
+
return false;
|
|
50
|
+
// Prerelease builds are outside the supported stable window.
|
|
51
|
+
if (match[4] !== undefined)
|
|
52
|
+
return false;
|
|
53
|
+
const current = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
54
|
+
const minimum = [2, 0, 18];
|
|
55
|
+
const maximum = [2, 0, 19];
|
|
56
|
+
const compare = (left, right) => (left[0] ?? 0) - (right[0] ?? 0) ||
|
|
57
|
+
(left[1] ?? 0) - (right[1] ?? 0) ||
|
|
58
|
+
(left[2] ?? 0) - (right[2] ?? 0);
|
|
59
|
+
return compare(current, minimum) >= 0 && compare(current, maximum) < 0;
|
|
60
|
+
}
|
|
35
61
|
const JSON_FORMAT = {
|
|
36
62
|
insertSpaces: true,
|
|
37
63
|
tabSize: 2,
|
|
38
64
|
eol: "\n",
|
|
39
65
|
};
|
|
40
66
|
// START_BLOCK_ENSURE_OPENCODE_PLUGIN_CONFIG
|
|
41
|
-
export function ensurePackageConfigText(text, packageSpecifier = PACKAGE_NAME) {
|
|
67
|
+
export function ensurePackageConfigText(text, packageSpecifier = PACKAGE_NAME, context = {}) {
|
|
42
68
|
if (!text?.trim()) {
|
|
43
69
|
return renderJson({
|
|
44
70
|
$schema: OPENCODE_SCHEMA_URL,
|
|
45
|
-
|
|
71
|
+
plugins: [{ package: packageSpecifier }],
|
|
46
72
|
});
|
|
47
73
|
}
|
|
48
74
|
const document = parseObjectDocument(text, "OpenCode config");
|
|
49
|
-
|
|
75
|
+
assertNativeOpenCodeDocument(document, "OpenCode config", context);
|
|
76
|
+
const currentPlugins = readPluginEntries(document, "OpenCode config");
|
|
50
77
|
let nextText = text;
|
|
51
78
|
if (!Object.hasOwn(document, "$schema")) {
|
|
52
79
|
nextText = applyEdits(nextText, modify(nextText, ["$schema"], OPENCODE_SCHEMA_URL, {
|
|
@@ -54,57 +81,21 @@ export function ensurePackageConfigText(text, packageSpecifier = PACKAGE_NAME) {
|
|
|
54
81
|
getInsertionIndex: () => 0,
|
|
55
82
|
}));
|
|
56
83
|
}
|
|
57
|
-
const nextPlugins =
|
|
84
|
+
const nextPlugins = normalizePluginEntries(currentPlugins, packageSpecifier);
|
|
58
85
|
if (JSON.stringify(nextPlugins) !== JSON.stringify(currentPlugins)) {
|
|
59
|
-
nextText = applyEdits(nextText, modify(nextText, ["
|
|
86
|
+
nextText = applyEdits(nextText, modify(nextText, ["plugins"], nextPlugins, {
|
|
60
87
|
formattingOptions: JSON_FORMAT,
|
|
61
88
|
}));
|
|
62
89
|
}
|
|
63
90
|
return ensureTrailingNewline(applyEdits(nextText, format(nextText, undefined, JSON_FORMAT)));
|
|
64
91
|
}
|
|
65
92
|
// END_BLOCK_ENSURE_OPENCODE_PLUGIN_CONFIG
|
|
66
|
-
// START_BLOCK_ENSURE_TUI_PLUGIN_CONFIG
|
|
67
|
-
export function ensureTuiPackageConfigText(text, packageSpecifier = TUI_PACKAGE_SPECIFIER) {
|
|
68
|
-
if (!text?.trim()) {
|
|
69
|
-
return renderJson({
|
|
70
|
-
$schema: OPENCODE_TUI_SCHEMA_URL,
|
|
71
|
-
plugin: [packageSpecifier],
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
const document = parseObjectDocument(text, "OpenCode TUI config");
|
|
75
|
-
const currentPlugins = readTuiPluginList(document, "OpenCode TUI config");
|
|
76
|
-
let nextText = text;
|
|
77
|
-
if (!Object.hasOwn(document, "$schema")) {
|
|
78
|
-
nextText = applyEdits(nextText, modify(nextText, ["$schema"], OPENCODE_TUI_SCHEMA_URL, {
|
|
79
|
-
formattingOptions: JSON_FORMAT,
|
|
80
|
-
getInsertionIndex: () => 0,
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
const nextPlugins = normalizeTuiPluginList(currentPlugins, packageSpecifier);
|
|
84
|
-
if (JSON.stringify(nextPlugins) !== JSON.stringify(currentPlugins)) {
|
|
85
|
-
nextText = applyEdits(nextText, modify(nextText, ["plugin"], nextPlugins, {
|
|
86
|
-
formattingOptions: JSON_FORMAT,
|
|
87
|
-
}));
|
|
88
|
-
}
|
|
89
|
-
return ensureTrailingNewline(applyEdits(nextText, format(nextText, undefined, JSON_FORMAT)));
|
|
90
|
-
}
|
|
91
|
-
export async function ensureTuiPackageInstalled(paths) {
|
|
92
|
-
const currentText = await readOptionalText(paths.opencodeTuiConfigPath);
|
|
93
|
-
const nextText = ensureTuiPackageConfigText(currentText);
|
|
94
|
-
if ((currentText ?? "") === nextText) {
|
|
95
|
-
return { action: "kept", path: paths.opencodeTuiConfigPath };
|
|
96
|
-
}
|
|
97
|
-
await writeText(paths.opencodeTuiConfigPath, nextText);
|
|
98
|
-
return {
|
|
99
|
-
action: currentText ? "updated" : "created",
|
|
100
|
-
path: paths.opencodeTuiConfigPath,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
// END_BLOCK_ENSURE_TUI_PLUGIN_CONFIG
|
|
104
93
|
// START_BLOCK_INSTALL_PACKAGE_AND_GUARDIAN_CONFIG
|
|
105
94
|
export async function ensurePackageInstalled(paths) {
|
|
106
95
|
const currentText = await readOptionalText(paths.opencodeConfigPath);
|
|
107
|
-
const nextText = ensurePackageConfigText(currentText, await getPinnedPackageSpecifier()
|
|
96
|
+
const nextText = ensurePackageConfigText(currentText, await getPinnedPackageSpecifier(), {
|
|
97
|
+
configDir: dirname(paths.opencodeConfigPath),
|
|
98
|
+
});
|
|
108
99
|
if (currentText === nextText) {
|
|
109
100
|
return { path: paths.opencodeConfigPath, changed: false };
|
|
110
101
|
}
|
|
@@ -113,98 +104,45 @@ export async function ensurePackageInstalled(paths) {
|
|
|
113
104
|
}
|
|
114
105
|
// END_BLOCK_INSTALL_PACKAGE_AND_GUARDIAN_CONFIG
|
|
115
106
|
// START_BLOCK_PARSE_AND_NORMALIZE_CONFIG_VALUES
|
|
116
|
-
export function
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (!Array.isArray(raw) || raw.some((entry) => typeof entry !== "string")) {
|
|
121
|
-
throw new Error(`${label}: expected "plugin" to be an array of strings`);
|
|
122
|
-
}
|
|
123
|
-
return raw.slice();
|
|
124
|
-
}
|
|
125
|
-
export function readTuiPluginList(document, label) {
|
|
126
|
-
const raw = document.plugin;
|
|
127
|
-
if (raw === undefined)
|
|
128
|
-
return [];
|
|
129
|
-
if (!Array.isArray(raw)) {
|
|
130
|
-
throw new Error(`${label}: expected "plugin" to be an array`);
|
|
131
|
-
}
|
|
132
|
-
return raw.map((entry, index) => {
|
|
133
|
-
if (typeof entry === "string") {
|
|
134
|
-
return entry;
|
|
135
|
-
}
|
|
136
|
-
if (Array.isArray(entry) &&
|
|
137
|
-
entry.length === 2 &&
|
|
138
|
-
typeof entry[0] === "string" &&
|
|
139
|
-
isJsonObject(entry[1])) {
|
|
140
|
-
return [entry[0], entry[1]];
|
|
141
|
-
}
|
|
142
|
-
throw new Error(`${label}: expected "plugin[${index}]" to be a string or [string, options] tuple`);
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
function normalizePluginList(currentPlugins, packageSpecifier) {
|
|
146
|
-
const nextPlugins = [];
|
|
147
|
-
const seen = new Set();
|
|
148
|
-
let insertedPackage = false;
|
|
149
|
-
const push = (value) => {
|
|
150
|
-
if (!seen.has(value)) {
|
|
151
|
-
seen.add(value);
|
|
152
|
-
nextPlugins.push(value);
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
for (const plugin of currentPlugins) {
|
|
156
|
-
if (isPackagePluginSpecifier(plugin)) {
|
|
157
|
-
if (!insertedPackage) {
|
|
158
|
-
push(packageSpecifier);
|
|
159
|
-
insertedPackage = true;
|
|
160
|
-
}
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
push(plugin);
|
|
164
|
-
}
|
|
165
|
-
if (!insertedPackage) {
|
|
166
|
-
push(packageSpecifier);
|
|
167
|
-
}
|
|
168
|
-
return nextPlugins;
|
|
107
|
+
export function isManagedPackageTarget(value) {
|
|
108
|
+
return (isBasePackageSpecifier(value) ||
|
|
109
|
+
value === `${PACKAGE_NAME}/tui` ||
|
|
110
|
+
(value.startsWith(`${PACKAGE_NAME}@`) && value.endsWith("/tui")));
|
|
169
111
|
}
|
|
170
|
-
function
|
|
112
|
+
export function normalizePluginEntries(currentPlugins, packageSpecifier) {
|
|
171
113
|
const nextPlugins = [];
|
|
172
|
-
let
|
|
114
|
+
let managedIndex = -1;
|
|
173
115
|
for (const entry of currentPlugins) {
|
|
174
|
-
|
|
116
|
+
const target = typeof entry === "string" ? entry : entry.package;
|
|
117
|
+
if (!isManagedPackageTarget(target)) {
|
|
175
118
|
nextPlugins.push(entry);
|
|
176
119
|
continue;
|
|
177
120
|
}
|
|
178
|
-
|
|
121
|
+
const options = typeof entry === "string" ? undefined : entry.options;
|
|
122
|
+
if (managedIndex !== -1) {
|
|
123
|
+
// Multiple managed entries with divergent options are ambiguous; refuse
|
|
124
|
+
// instead of silently keeping the first and dropping the user's later one.
|
|
125
|
+
const existing = nextPlugins[managedIndex];
|
|
126
|
+
const existingOptions = typeof existing === "string" ? undefined : existing.options;
|
|
127
|
+
if (JSON.stringify(existingOptions) !== JSON.stringify(options)) {
|
|
128
|
+
throw new Error(`OpenCode config: conflicting managed plugin entries for ${PACKAGE_NAME}; keep exactly one`);
|
|
129
|
+
}
|
|
179
130
|
continue;
|
|
180
131
|
}
|
|
181
|
-
nextPlugins.
|
|
182
|
-
|
|
132
|
+
managedIndex = nextPlugins.length;
|
|
133
|
+
nextPlugins.push(options === undefined
|
|
134
|
+
? { package: packageSpecifier }
|
|
135
|
+
: { package: packageSpecifier, options });
|
|
183
136
|
}
|
|
184
|
-
if (
|
|
185
|
-
nextPlugins.push(packageSpecifier);
|
|
137
|
+
if (managedIndex === -1) {
|
|
138
|
+
nextPlugins.push({ package: packageSpecifier });
|
|
186
139
|
}
|
|
187
140
|
return nextPlugins;
|
|
188
141
|
}
|
|
189
|
-
export function isPackagePluginSpecifier(value) {
|
|
190
|
-
return value === PACKAGE_NAME || value.startsWith(`${PACKAGE_NAME}@`);
|
|
191
|
-
}
|
|
192
|
-
export function readTuiPluginName(entry) {
|
|
193
|
-
return typeof entry === "string" ? entry : entry[0];
|
|
194
|
-
}
|
|
195
|
-
function isManagedTuiPackageSpecifier(value) {
|
|
196
|
-
return (isBasePackageSpecifier(value) ||
|
|
197
|
-
value === `${PACKAGE_NAME}/tui` ||
|
|
198
|
-
(value.startsWith(`${PACKAGE_NAME}@`) && value.endsWith("/tui")));
|
|
199
|
-
}
|
|
200
|
-
export function isTuiPackageSpecifier(value) {
|
|
201
|
-
return value === TUI_PACKAGE_SPECIFIER;
|
|
202
|
-
}
|
|
203
142
|
function isBasePackageSpecifier(value) {
|
|
204
143
|
if (value === PACKAGE_NAME)
|
|
205
144
|
return true;
|
|
206
145
|
const prefix = `${PACKAGE_NAME}@`;
|
|
207
146
|
return value.startsWith(prefix) && !value.slice(prefix.length).includes("/");
|
|
208
147
|
}
|
|
209
|
-
// END_BLOCK_PARSE_AND_NORMALIZE_CONFIG_VALUES
|
|
210
148
|
//# sourceMappingURL=plugin-registration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-registration.js","sourceRoot":"","sources":["../../../src/lib/opencode/plugin-registration.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,iBAAiB;AACjB,wBAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"plugin-registration.js","sourceRoot":"","sources":["../../../src/lib/opencode/plugin-registration.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,iBAAiB;AACjB,wBAAwB;AACxB,kIAAkI;AAClI,kUAAkU;AAClU,kFAAkF;AAClF,0BAA0B;AAC1B,kBAAkB;AAClB,sBAAsB;AACtB,sBAAsB;AACtB,EAAE;AACF,mBAAmB;AACnB,oFAAoF;AACpF,uHAAuH;AACvH,mGAAmG;AACnG,8FAA8F;AAC9F,iHAAiH;AACjH,gIAAgI;AAChI,kFAAkF;AAClF,4GAA4G;AAC5G,sHAAsH;AACtH,4EAA4E;AAC5E,iBAAiB;AACjB,EAAE;AACF,uBAAuB;AACvB,gNAAgN;AAChN,qBAAqB;AAErB,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,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O,CAAC,EAAE,CAAC;gBAChE,MAAM,IAAI,KAAK,CACb,2DAA2D,YAAY,oBAAoB,CAC5F,CAAC;YACJ,CAAC;YACD,SAAS;QACX,CAAC;QACD,YAAY,GAAG,WAAW,CAAC,MAAM,CAAC;QAClC,WAAW,CAAC,IAAI,CACd,OAAO,KAAK,SAAS;YACnB,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE;YAC/B,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAC3C,CAAC;IACJ,CAAC;IAED,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE,CAAC;QACxB,WAAW,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,SAAS,sBAAsB,CAAC,KAAa;IAC3C,IAAI,KAAK,KAAK,YAAY;QAAE,OAAO,IAAI,CAAC;IACxC,MAAM,MAAM,GAAG,GAAG,YAAY,GAAG,CAAC;IAClC,OAAO,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -1,20 +1,63 @@
|
|
|
1
1
|
import { type VvocConfig } from "../vvoc-config.js";
|
|
2
2
|
export declare const CLI_NAME = "vvoc";
|
|
3
3
|
export declare const OPENCODE_SCHEMA_URL = "https://opencode.ai/config.json";
|
|
4
|
-
|
|
4
|
+
/** Option key on the vvoc `plugins` entry that carries root/agent/command role intent. */
|
|
5
|
+
export declare const MODEL_INTENT_OPTION_KEY = "modelIntent";
|
|
5
6
|
export type JsonObject = Record<string, unknown>;
|
|
6
7
|
export type WriteResult = {
|
|
7
|
-
action: "created" | "updated" | "kept" | "skipped";
|
|
8
|
+
action: "created" | "updated" | "kept" | "skipped" | "deleted";
|
|
8
9
|
path: string;
|
|
9
10
|
reason?: string;
|
|
10
11
|
};
|
|
11
12
|
export type OpenCodeAgentOverride = {
|
|
12
13
|
model?: string;
|
|
13
14
|
};
|
|
15
|
+
/** Native `plugins` entry: a package target string, a `-target` removal directive, or a package object with options. */
|
|
16
|
+
export type OpenCodePluginEntry = string | {
|
|
17
|
+
package: string;
|
|
18
|
+
options?: JsonObject;
|
|
19
|
+
};
|
|
14
20
|
export declare function parseObjectDocument(text: string, label: string): JsonObject;
|
|
21
|
+
/** True when a plugins target is the vvoc base package (including legacy `/tui`). */
|
|
22
|
+
export declare function isManagedPluginTarget(value: string): boolean;
|
|
23
|
+
/** Source context a native document may need to validate `{file:...}` tokens. */
|
|
24
|
+
export type NativeValidationContext = {
|
|
25
|
+
configDir?: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Normalizes a native model selection (string, or `{providerID, model, variant}`)
|
|
29
|
+
* to the canonical `provider/model#variant` form. Invalid selections are
|
|
30
|
+
* rejected rather than silently defaulted.
|
|
31
|
+
*/
|
|
32
|
+
export declare function normalizeNativeModelSelection(value: unknown, label?: string): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Refuse an existing OpenCode document that still uses V1 shapes or fields the
|
|
35
|
+
* pinned native host does not accept, or that the pinned native codec rejects.
|
|
36
|
+
* Called before any config or asset write so an unsupported document is never
|
|
37
|
+
* silently rewritten or migrated.
|
|
38
|
+
*/
|
|
39
|
+
export declare function assertNativeOpenCodeDocument(document: JsonObject, label: string, context?: NativeValidationContext): void;
|
|
40
|
+
export declare function readPluginEntries(document: JsonObject, label: string): OpenCodePluginEntry[];
|
|
41
|
+
export type ModelIntentPatch = {
|
|
42
|
+
model?: string | null;
|
|
43
|
+
smallModel?: string | null;
|
|
44
|
+
agents?: Record<string, string | null>;
|
|
45
|
+
commands?: Record<string, string | null>;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Applies a modelIntent patch to the vvoc-owned `plugins` entry, preserving its
|
|
49
|
+
* options, string-or-object entry form, ordered removal directives, and every
|
|
50
|
+
* unrelated entry. A string managed entry is upgraded in place to an object so
|
|
51
|
+
* a role write cannot append a conflicting duplicate.
|
|
52
|
+
*/
|
|
53
|
+
export declare function applyModelIntent(text: string, specifier: string, label: string, patch: ModelIntentPatch, context?: NativeValidationContext): string;
|
|
54
|
+
/** Reads the vvoc-owned modelIntent envelope, accepting string and object entries. */
|
|
55
|
+
export declare function readModelIntentEnvelope(document: JsonObject): JsonObject | undefined;
|
|
56
|
+
export declare function readSkillsArray(document: JsonObject, label: string): string[];
|
|
57
|
+
export declare function readNativeAgents(document: JsonObject, label: string): Record<string, JsonObject>;
|
|
15
58
|
export declare function readStringArray(value: unknown, label: string): string[];
|
|
16
59
|
export declare function updateAgentEntryText(text: string, agentName: string, entry: JsonObject): string;
|
|
17
|
-
export declare function ensureOpenCodeConfigText(text: string | undefined): string;
|
|
60
|
+
export declare function ensureOpenCodeConfigText(text: string | undefined, context?: NativeValidationContext): string;
|
|
18
61
|
export declare function readNonEmptyString(value: unknown, label: string): string;
|
|
19
62
|
export declare function isJsonObject(value: unknown): value is JsonObject;
|
|
20
63
|
export declare function mergeJsonObjects(current: JsonObject, patch: JsonObject): JsonObject;
|
|
@@ -28,3 +71,4 @@ export declare function ensureTrailingNewline(text: string): string;
|
|
|
28
71
|
export declare function writeResolvedVvocConfig(path: string, currentText: string | undefined, config: VvocConfig): Promise<WriteResult>;
|
|
29
72
|
export declare function readOptionalText(path: string): Promise<string | undefined>;
|
|
30
73
|
export declare function writeText(path: string, text: string): Promise<void>;
|
|
74
|
+
export declare function removeTextFile(path: string): Promise<boolean>;
|