@osovv/vv-opencode 2.0.0 → 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 +51 -0
- package/README.md +87 -85
- 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 -22
- package/dist/plugins/peak-hours/index.js +210 -178
- 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 -161
- 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 -95
- package/dist/plugins/peak-hours/v2.js.map +0 -1
- package/dist/plugins/secrets-redaction/v2.d.ts +0 -14
- package/dist/plugins/secrets-redaction/v2.js +0 -100
- 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 -58
- package/dist/plugins/workflow/v2.js +0 -181
- package/dist/plugins/workflow/v2.js.map +0 -1
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export interface WatcherRegistrationOptions {
|
|
2
|
-
/** Injectable nearest-project config-path resolver for deterministic tests. */
|
|
3
|
-
resolveProjectConfigPath?: (directory: string) => Promise<string | undefined>;
|
|
4
|
-
/** Debounce window in milliseconds; defaults to 200. */
|
|
5
|
-
debounceMs?: number;
|
|
6
|
-
/** Injectable logger for non-fatal watcher diagnostics. */
|
|
7
|
-
warn?: (message: string) => void;
|
|
8
|
-
/** Injectable filesystem watch factory for deterministic tests. */
|
|
9
|
-
createWatch?: (filePath: string, onEvent: () => void, onError: (error: unknown) => void) => {
|
|
10
|
-
close: () => void;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Watch the project vvoc config effective for one directory.
|
|
15
|
-
*
|
|
16
|
-
* Resolves the nearest project config root the same way the layer engine
|
|
17
|
-
* does, watches the config file's directory so atomic replace writes are
|
|
18
|
-
* observed, debounces bursts, and invokes every callback with the resolved
|
|
19
|
-
* config path. Callback errors are isolated per callback; watcher errors
|
|
20
|
-
* degrade to a logged warning and stop notification for that directory.
|
|
21
|
-
*
|
|
22
|
-
* Returns a stop function that is safe to call multiple times. The function
|
|
23
|
-
* itself never throws: a directory without a project config resolves to a
|
|
24
|
-
* no-op watcher with the provided warn hook informed.
|
|
25
|
-
*/
|
|
26
|
-
export declare function watchProjectVvocConfig(directory: string, onChange: (configPath: string) => void, options?: WatcherRegistrationOptions): Promise<() => void>;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
// FILE: src/plugins/v2-runtime/config-watcher.ts
|
|
2
|
-
// VERSION: 1.0.0
|
|
3
|
-
// START_MODULE_CONTRACT
|
|
4
|
-
// PURPOSE: Watch a project's effective vvoc config file for changes and notify registered reload callbacks without restarting the OpenCode v2 server.
|
|
5
|
-
// SCOPE: Watcher registration per directory with debounced change notification, callback error isolation, multiplexed subscriptions over one filesystem watch, and a returned stop function; never throws to the caller.
|
|
6
|
-
// DEPENDS: [node:fs/promises, node:fs, src/lib/config-layers.ts]
|
|
7
|
-
// LINKS: [M-PLUGIN-V2-RUNTIME, V-M-PLUGIN-V2-RUNTIME, M-CONFIG-LAYERS]
|
|
8
|
-
// ROLE: RUNTIME
|
|
9
|
-
// MAP_MODE: EXPORTS
|
|
10
|
-
// END_MODULE_CONTRACT
|
|
11
|
-
//
|
|
12
|
-
// START_MODULE_MAP
|
|
13
|
-
// WatcherRegistrationOptions - Injectable project-path resolution, debounce window, and logger for deterministic tests.
|
|
14
|
-
// watchProjectVvocConfig - Watch one directory's project vvoc config and invoke callbacks on debounced changes until stopped.
|
|
15
|
-
// END_MODULE_MAP
|
|
16
|
-
//
|
|
17
|
-
// START_CHANGE_SUMMARY
|
|
18
|
-
// LAST_CHANGE: [C-OPENCODE-V2-MIGRATION T-002 - Created the debounced config watcher powering restart-free preset switching.]
|
|
19
|
-
// END_CHANGE_SUMMARY
|
|
20
|
-
import { watch } from "node:fs";
|
|
21
|
-
import { basename, dirname } from "node:path";
|
|
22
|
-
import { access } from "node:fs/promises";
|
|
23
|
-
import { findNearestProjectConfigRoot } from "../../lib/config-layers.js";
|
|
24
|
-
import { getProjectVvocConfigPath } from "../../lib/vvoc-paths.js";
|
|
25
|
-
// END_BLOCK_WATCHER_OPTIONS
|
|
26
|
-
// START_BLOCK_WATCH_PROJECT_VVOC_CONFIG
|
|
27
|
-
/**
|
|
28
|
-
* Watch the project vvoc config effective for one directory.
|
|
29
|
-
*
|
|
30
|
-
* Resolves the nearest project config root the same way the layer engine
|
|
31
|
-
* does, watches the config file's directory so atomic replace writes are
|
|
32
|
-
* observed, debounces bursts, and invokes every callback with the resolved
|
|
33
|
-
* config path. Callback errors are isolated per callback; watcher errors
|
|
34
|
-
* degrade to a logged warning and stop notification for that directory.
|
|
35
|
-
*
|
|
36
|
-
* Returns a stop function that is safe to call multiple times. The function
|
|
37
|
-
* itself never throws: a directory without a project config resolves to a
|
|
38
|
-
* no-op watcher with the provided warn hook informed.
|
|
39
|
-
*/
|
|
40
|
-
export async function watchProjectVvocConfig(directory, onChange, options = {}) {
|
|
41
|
-
const debounceMs = options.debounceMs ?? 200;
|
|
42
|
-
const warn = options.warn ?? ((message) => console.warn(message));
|
|
43
|
-
const resolveProjectConfigPath = options.resolveProjectConfigPath ??
|
|
44
|
-
(async (dir) => {
|
|
45
|
-
const root = await findNearestProjectConfigRoot(dir);
|
|
46
|
-
if (root?.vvocConfigPath)
|
|
47
|
-
return root.vvocConfigPath;
|
|
48
|
-
// Watch the canonical project path even when absent so a later file
|
|
49
|
-
// creation is observed.
|
|
50
|
-
const canonical = getProjectVvocConfigPath(dir);
|
|
51
|
-
try {
|
|
52
|
-
await access(canonical);
|
|
53
|
-
return canonical;
|
|
54
|
-
}
|
|
55
|
-
catch {
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
const createWatch = options.createWatch ??
|
|
60
|
-
((filePath, onEvent, onError) => {
|
|
61
|
-
const watcher = watch(dirname(filePath), { persistent: false }, (_event, filename) => {
|
|
62
|
-
if (!filename || filename === basename(filePath)) {
|
|
63
|
-
onEvent();
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
watcher.on("error", onError);
|
|
67
|
-
return watcher;
|
|
68
|
-
});
|
|
69
|
-
const configPath = await resolveProjectConfigPath(directory);
|
|
70
|
-
if (!configPath) {
|
|
71
|
-
warn(`[vvoc][v2-runtime] no project vvoc config found for ${directory}; config watching disabled`);
|
|
72
|
-
return () => { };
|
|
73
|
-
}
|
|
74
|
-
let stopped = false;
|
|
75
|
-
let timer;
|
|
76
|
-
const watcher = createWatch(configPath, () => {
|
|
77
|
-
if (stopped)
|
|
78
|
-
return;
|
|
79
|
-
if (timer)
|
|
80
|
-
clearTimeout(timer);
|
|
81
|
-
timer = setTimeout(() => {
|
|
82
|
-
timer = undefined;
|
|
83
|
-
if (stopped)
|
|
84
|
-
return;
|
|
85
|
-
try {
|
|
86
|
-
onChange(configPath);
|
|
87
|
-
}
|
|
88
|
-
catch (error) {
|
|
89
|
-
warn(`[vvoc][v2-runtime] config change callback failed for ${configPath}: ${String(error)}`);
|
|
90
|
-
}
|
|
91
|
-
}, debounceMs);
|
|
92
|
-
}, (error) => {
|
|
93
|
-
warn(`[vvoc][v2-runtime] config watcher error for ${configPath}: ${String(error)}`);
|
|
94
|
-
});
|
|
95
|
-
return () => {
|
|
96
|
-
if (stopped)
|
|
97
|
-
return;
|
|
98
|
-
stopped = true;
|
|
99
|
-
if (timer)
|
|
100
|
-
clearTimeout(timer);
|
|
101
|
-
timer = undefined;
|
|
102
|
-
try {
|
|
103
|
-
watcher.close();
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
// Closing a dead watcher is not an error.
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
// END_BLOCK_WATCH_PROJECT_VVOC_CONFIG
|
|
111
|
-
//# sourceMappingURL=config-watcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-watcher.js","sourceRoot":"","s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AAC,CAAC;YACvB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CACF,wDAAwD,UAAU,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CACvF,CAAC;YACJ,CAAC;QACH,CAAC,EAAE,UAAU,CAAC,CAAC;IACjB,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;QACR,IAAI,CAAC,+CAA+C,UAAU,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACtF,CAAC,CACF,CAAC;IAEF,OAAO,GAAG,EAAE;QACV,IAAI,OAAO;YAAE,OAAO;QACpB,OAAO,GAAG,IAAI,CAAC;QACf,IAAI,KAAK;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAC/B,KAAK,GAAG,SAAS,CAAC;QAClB,IAAI,CAAC;YACH,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;QAAC,MAAM,CAAC;YACP,0CAA0C;QAC5C,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AACD,sCAAsC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Plugin as V2Plugin } from "@opencode/plugin";
|
|
2
|
-
import type { Hooks, Plugin as V1Plugin, PluginInput, PluginOptions } from "@opencode-ai/plugin";
|
|
3
|
-
/**
|
|
4
|
-
* The v2 setup signature, including an optional cleanup return.
|
|
5
|
-
*/
|
|
6
|
-
export type V2Setup = (context: V2Plugin.Context) => Promise<V2Plugin.Cleanup | void> | V2Plugin.Cleanup | void;
|
|
7
|
-
/**
|
|
8
|
-
* A dual-runtime plugin entrypoint: the v2 Plugin shape (id + setup) plus the
|
|
9
|
-
* v1 object-entrypoint server() member. OpenCode v1 (>= 1.18.29) detects the
|
|
10
|
-
* default export through its id/server members and calls only server(); OpenCode
|
|
11
|
-
* v2 reads id and setup() and ignores server(). Neither runtime loads the other
|
|
12
|
-
* path, so a package exposing exactly this default export registers once.
|
|
13
|
-
*/
|
|
14
|
-
export type DualPlugin = V2Plugin.Plugin & {
|
|
15
|
-
server: V1Plugin;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Build the dual entrypoint for one plugin.
|
|
19
|
-
*
|
|
20
|
-
* The v1 factory keeps its original single-argument or two-argument signature
|
|
21
|
-
* and is wrapped verbatim as the server() member. The v2 setup receives the v2
|
|
22
|
-
* plugin context and may return nothing yet; later migration tasks attach the
|
|
23
|
-
* domain registrations.
|
|
24
|
-
*/
|
|
25
|
-
export declare function defineDualPlugin(definition: {
|
|
26
|
-
id: string;
|
|
27
|
-
v1: V1Plugin;
|
|
28
|
-
v2: V2Setup;
|
|
29
|
-
}): DualPlugin;
|
|
30
|
-
/**
|
|
31
|
-
* Merge multiple v1 hook objects into one hook object.
|
|
32
|
-
*
|
|
33
|
-
* The v1 runtime triggers each hook key across plugin entries sequentially in
|
|
34
|
-
* registration order, and calls dispose() on every entry in registration order
|
|
35
|
-
* at shutdown. Producing one merged object that chains every key sequentially
|
|
36
|
-
* and forwards dispose in registration order reproduces that behavior exactly
|
|
37
|
-
* while presenting the aggregator as a single plugin entry.
|
|
38
|
-
*
|
|
39
|
-
* Children that returned undefined or an object without the requested key are
|
|
40
|
-
* skipped for that key. An empty list produces an object with no hook members.
|
|
41
|
-
*/
|
|
42
|
-
export declare function mergeV1Hooks(entries: Array<Hooks | undefined>): Hooks;
|
|
43
|
-
/**
|
|
44
|
-
* Run v1 plugin factories sequentially and merge their hook objects.
|
|
45
|
-
*
|
|
46
|
-
* A factory that throws is logged and skipped so one failing plugin cannot take
|
|
47
|
-
* the remaining plugins offline, matching how the v1 runtime isolates plugin
|
|
48
|
-
* load failures across separate package entries.
|
|
49
|
-
*/
|
|
50
|
-
export declare function aggregateV1Plugins(factories: Array<V1Plugin>, input: PluginInput, options?: PluginOptions, onError?: (error: unknown, index: number) => void): Promise<Hooks>;
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
// FILE: src/plugins/v2-runtime/index.ts
|
|
2
|
-
// VERSION: 1.0.0
|
|
3
|
-
// START_MODULE_CONTRACT
|
|
4
|
-
// PURPOSE: Provide the dual-runtime plugin foundation that lets one package entrypoint serve OpenCode v1 (server() object entrypoints, >= 1.18.29) and OpenCode v2 (Plugin.define setup, >= 2.0.18) without double registration.
|
|
5
|
-
// SCOPE: Dual entrypoint construction with stable plugin ids, sequential v1 plugin aggregation with per-plugin error isolation, hook-object merging that preserves v1 trigger and dispose ordering, and the typed seams later tasks use to attach v2 domain registrations.
|
|
6
|
-
// DEPENDS: [@opencode/plugin, @opencode-ai/plugin]
|
|
7
|
-
// LINKS: [M-PLUGIN-V2-RUNTIME, V-M-PLUGIN-V2-RUNTIME, M-PLUGIN-GUARDIAN, M-PLUGIN-WORKFLOW]
|
|
8
|
-
// ROLE: RUNTIME
|
|
9
|
-
// MAP_MODE: EXPORTS
|
|
10
|
-
// END_MODULE_CONTRACT
|
|
11
|
-
//
|
|
12
|
-
// START_MODULE_MAP
|
|
13
|
-
// defineDualPlugin - Build a dual entrypoint whose default export serves v2 via setup(ctx) and v1 via server(input, options).
|
|
14
|
-
// mergeV1Hooks - Merge v1 hook objects into one object that runs each hook key sequentially in registration order and disposes in the same order.
|
|
15
|
-
// aggregateV1Plugins - Run v1 plugin factories sequentially with per-factory error isolation and merge their hook objects.
|
|
16
|
-
// DualPlugin - Type of the dual entrypoint: v2 Plugin shape plus the v1 server() member.
|
|
17
|
-
// V2Setup - Signature of a v2 setup function receiving the v2 plugin Context.
|
|
18
|
-
// END_MODULE_MAP
|
|
19
|
-
//
|
|
20
|
-
// START_CHANGE_SUMMARY
|
|
21
|
-
// LAST_CHANGE: [C-OPENCODE-V2-MIGRATION - Created the dual-runtime foundation so every package entrypoint loads under both OpenCode runtimes.]
|
|
22
|
-
// END_CHANGE_SUMMARY
|
|
23
|
-
import { Plugin as V2Plugin } from "@opencode/plugin";
|
|
24
|
-
// END_BLOCK_DUAL_PLUGIN_TYPE
|
|
25
|
-
// START_BLOCK_DEFINE_DUAL_PLUGIN
|
|
26
|
-
/**
|
|
27
|
-
* Build the dual entrypoint for one plugin.
|
|
28
|
-
*
|
|
29
|
-
* The v1 factory keeps its original single-argument or two-argument signature
|
|
30
|
-
* and is wrapped verbatim as the server() member. The v2 setup receives the v2
|
|
31
|
-
* plugin context and may return nothing yet; later migration tasks attach the
|
|
32
|
-
* domain registrations.
|
|
33
|
-
*/
|
|
34
|
-
export function defineDualPlugin(definition) {
|
|
35
|
-
return {
|
|
36
|
-
...V2Plugin.define({
|
|
37
|
-
id: definition.id,
|
|
38
|
-
setup: definition.v2,
|
|
39
|
-
}),
|
|
40
|
-
server: definition.v1,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
// END_BLOCK_DEFINE_DUAL_PLUGIN
|
|
44
|
-
// START_BLOCK_MERGE_V1_HOOKS
|
|
45
|
-
/**
|
|
46
|
-
* Merge multiple v1 hook objects into one hook object.
|
|
47
|
-
*
|
|
48
|
-
* The v1 runtime triggers each hook key across plugin entries sequentially in
|
|
49
|
-
* registration order, and calls dispose() on every entry in registration order
|
|
50
|
-
* at shutdown. Producing one merged object that chains every key sequentially
|
|
51
|
-
* and forwards dispose in registration order reproduces that behavior exactly
|
|
52
|
-
* while presenting the aggregator as a single plugin entry.
|
|
53
|
-
*
|
|
54
|
-
* Children that returned undefined or an object without the requested key are
|
|
55
|
-
* skipped for that key. An empty list produces an object with no hook members.
|
|
56
|
-
*/
|
|
57
|
-
export function mergeV1Hooks(entries) {
|
|
58
|
-
const present = entries.filter((entry) => Boolean(entry));
|
|
59
|
-
const keys = new Set();
|
|
60
|
-
for (const entry of present) {
|
|
61
|
-
for (const key of Object.keys(entry)) {
|
|
62
|
-
keys.add(key);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const merged = {};
|
|
66
|
-
for (const key of keys) {
|
|
67
|
-
if (key === "dispose")
|
|
68
|
-
continue;
|
|
69
|
-
const handlers = present
|
|
70
|
-
.map((entry) => entry[key])
|
|
71
|
-
.filter((handler) => typeof handler === "function");
|
|
72
|
-
if (handlers.length === 0)
|
|
73
|
-
continue;
|
|
74
|
-
merged[key] = async (input, output) => {
|
|
75
|
-
for (const handler of handlers) {
|
|
76
|
-
await handler(input, output);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
const disposers = present
|
|
81
|
-
.map((entry) => entry.dispose)
|
|
82
|
-
.filter((disposer) => typeof disposer === "function");
|
|
83
|
-
if (disposers.length > 0) {
|
|
84
|
-
merged.dispose = async () => {
|
|
85
|
-
for (const disposer of disposers) {
|
|
86
|
-
await disposer();
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
return merged;
|
|
91
|
-
}
|
|
92
|
-
// END_BLOCK_MERGE_V1_HOOKS
|
|
93
|
-
// START_BLOCK_AGGREGATE_V1_PLUGINS
|
|
94
|
-
/**
|
|
95
|
-
* Run v1 plugin factories sequentially and merge their hook objects.
|
|
96
|
-
*
|
|
97
|
-
* A factory that throws is logged and skipped so one failing plugin cannot take
|
|
98
|
-
* the remaining plugins offline, matching how the v1 runtime isolates plugin
|
|
99
|
-
* load failures across separate package entries.
|
|
100
|
-
*/
|
|
101
|
-
export async function aggregateV1Plugins(factories, input, options, onError) {
|
|
102
|
-
const results = [];
|
|
103
|
-
for (const [index, factory] of factories.entries()) {
|
|
104
|
-
try {
|
|
105
|
-
results.push(await factory(input, options));
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
onError?.(error, index);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return mergeV1Hooks(results);
|
|
112
|
-
}
|
|
113
|
-
// END_BLOCK_AGGREGATE_V1_PLUGINS
|
|
114
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/v2-runtime/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,iBAAiB;AACjB,wBAAwB;AACxB,mOAAmO;AACn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OAAO,CAAC,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IACD,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC;AACD,iCAAiC"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { ConfigSource } from "../../lib/config-layers.js";
|
|
2
|
-
import type { VvocConfig } from "../../lib/vvoc-config.js";
|
|
3
|
-
/**
|
|
4
|
-
* Effective vvoc config resolved for one session location directory.
|
|
5
|
-
*/
|
|
6
|
-
export interface LocationConfigSnapshot {
|
|
7
|
-
readonly directory: string;
|
|
8
|
-
readonly config: VvocConfig;
|
|
9
|
-
readonly source: ConfigSource;
|
|
10
|
-
readonly warnings: readonly string[];
|
|
11
|
-
readonly loadedAt: number;
|
|
12
|
-
}
|
|
13
|
-
export interface LocationResolverOptions {
|
|
14
|
-
/**
|
|
15
|
-
* Injectable effective-config loader for one directory. Defaults to the
|
|
16
|
-
* layer engine with effective scope and default fallback, mirroring the v1
|
|
17
|
-
* startup snapshot semantics for that directory.
|
|
18
|
-
*/
|
|
19
|
-
loadForDirectory?: (directory: string) => Promise<Omit<LocationConfigSnapshot, "directory" | "loadedAt">>;
|
|
20
|
-
/** TTL in milliseconds for cached entries; defaults to 2000. */
|
|
21
|
-
ttlMs?: number;
|
|
22
|
-
/** Injectable logger receiving resolution failure warnings. */
|
|
23
|
-
warn?: (message: string) => void;
|
|
24
|
-
/** Injectable clock in milliseconds for deterministic tests. */
|
|
25
|
-
now?: () => number;
|
|
26
|
-
}
|
|
27
|
-
export interface LocationResolver {
|
|
28
|
-
/** Resolve the effective config for one directory, or undefined when it cannot be loaded (fail closed). */
|
|
29
|
-
forDirectory(directory: string): Promise<LocationConfigSnapshot | undefined>;
|
|
30
|
-
/** Resolve the effective config for a session through its persisted location directory. */
|
|
31
|
-
forSession(sessionID: string, sessionGet: (input: {
|
|
32
|
-
sessionID: string;
|
|
33
|
-
}) => Promise<{
|
|
34
|
-
location?: {
|
|
35
|
-
directory?: string;
|
|
36
|
-
};
|
|
37
|
-
} | undefined>): Promise<LocationConfigSnapshot | undefined>;
|
|
38
|
-
/** Drop the cached entry for one directory so the next read reloads from disk. */
|
|
39
|
-
invalidate(directory: string): void;
|
|
40
|
-
/** Number of directories currently cached; exposed for tests and diagnostics. */
|
|
41
|
-
readonly cachedDirectories: readonly string[];
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Build the per-location resolver.
|
|
45
|
-
*
|
|
46
|
-
* A directory whose config fails to load resolves to undefined after a logged
|
|
47
|
-
* warning, and that failure is cached for the TTL so a broken project does not
|
|
48
|
-
* hammer the filesystem from every hook invocation. Plugins treat undefined as
|
|
49
|
-
* disabled for that location, preserving the v1 fail-closed posture.
|
|
50
|
-
*/
|
|
51
|
-
export declare function createLocationResolver(options?: LocationResolverOptions): LocationResolver;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// FILE: src/plugins/v2-runtime/location-config.ts
|
|
2
|
-
// VERSION: 1.0.0
|
|
3
|
-
// START_MODULE_CONTRACT
|
|
4
|
-
// PURPOSE: Resolve the effective vvoc configuration per session location for the OpenCode v2 runtime, replacing the v1 startup-snapshot model.
|
|
5
|
-
// SCOPE: Per-directory effective config resolution through the existing layer engine with TTL caching, session-to-directory mapping through the v2 session API, watcher-driven invalidation, and fail-closed behavior for unresolvable locations.
|
|
6
|
-
// DEPENDS: [src/lib/config-layers.ts]
|
|
7
|
-
// LINKS: [M-PLUGIN-V2-RUNTIME, V-M-PLUGIN-V2-RUNTIME, M-CONFIG-LAYERS]
|
|
8
|
-
// ROLE: RUNTIME
|
|
9
|
-
// MAP_MODE: EXPORTS
|
|
10
|
-
// END_MODULE_CONTRACT
|
|
11
|
-
//
|
|
12
|
-
// START_MODULE_MAP
|
|
13
|
-
// LocationConfigSnapshot - Effective config resolved for one directory plus source metadata and load time.
|
|
14
|
-
// LocationResolver - Resolver interface with forDirectory, forSession, invalidate, and cachedDirectories.
|
|
15
|
-
// LocationResolverOptions - Injectable loader, logger, TTL, and clock for deterministic tests.
|
|
16
|
-
// createLocationResolver - Build a per-directory caching resolver with session mapping and invalidation.
|
|
17
|
-
// END_MODULE_MAP
|
|
18
|
-
//
|
|
19
|
-
// START_CHANGE_SUMMARY
|
|
20
|
-
// LAST_CHANGE: [C-OPENCODE-V2-MIGRATION T-002 - Created the per-location config resolver for the v2 runtime.]
|
|
21
|
-
// END_CHANGE_SUMMARY
|
|
22
|
-
import { loadVvocConfigForRead } from "../../lib/config-layers.js";
|
|
23
|
-
/**
|
|
24
|
-
* Build the per-location resolver.
|
|
25
|
-
*
|
|
26
|
-
* A directory whose config fails to load resolves to undefined after a logged
|
|
27
|
-
* warning, and that failure is cached for the TTL so a broken project does not
|
|
28
|
-
* hammer the filesystem from every hook invocation. Plugins treat undefined as
|
|
29
|
-
* disabled for that location, preserving the v1 fail-closed posture.
|
|
30
|
-
*/
|
|
31
|
-
export function createLocationResolver(options = {}) {
|
|
32
|
-
const ttlMs = options.ttlMs ?? 2000;
|
|
33
|
-
const warn = options.warn ?? ((message) => console.warn(message));
|
|
34
|
-
const now = options.now ?? Date.now;
|
|
35
|
-
const load = options.loadForDirectory ??
|
|
36
|
-
(async (directory) => {
|
|
37
|
-
const read = await loadVvocConfigForRead({
|
|
38
|
-
cwd: directory,
|
|
39
|
-
scope: "effective",
|
|
40
|
-
allowDefault: true,
|
|
41
|
-
});
|
|
42
|
-
return { config: read.config, source: read.source, warnings: read.warnings };
|
|
43
|
-
});
|
|
44
|
-
const cache = new Map();
|
|
45
|
-
async function resolve(directory) {
|
|
46
|
-
const key = directory;
|
|
47
|
-
const cached = cache.get(key);
|
|
48
|
-
if (cached && cached.expiresAt > now()) {
|
|
49
|
-
return cached.value;
|
|
50
|
-
}
|
|
51
|
-
let value;
|
|
52
|
-
try {
|
|
53
|
-
value = { directory, ...(await load(directory)), loadedAt: now() };
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
warn(`[vvoc][v2-runtime] config resolution failed for ${directory}: ${String(error)}; plugins stay disabled for this location`);
|
|
57
|
-
value = undefined;
|
|
58
|
-
}
|
|
59
|
-
cache.set(key, { value, expiresAt: now() + ttlMs });
|
|
60
|
-
return value;
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
async forDirectory(directory) {
|
|
64
|
-
return resolve(directory);
|
|
65
|
-
},
|
|
66
|
-
async forSession(sessionID, sessionGet) {
|
|
67
|
-
let directory;
|
|
68
|
-
try {
|
|
69
|
-
const session = await sessionGet({ sessionID });
|
|
70
|
-
directory = session?.location?.directory;
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
warn(`[vvoc][v2-runtime] session lookup failed for ${sessionID}: ${String(error)}; plugins stay disabled for this session`);
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
if (!directory) {
|
|
77
|
-
warn(`[vvoc][v2-runtime] session ${sessionID} has no location directory; plugins stay disabled for this session`);
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
return resolve(directory);
|
|
81
|
-
},
|
|
82
|
-
invalidate(directory) {
|
|
83
|
-
cache.delete(directory);
|
|
84
|
-
},
|
|
85
|
-
get cachedDirectories() {
|
|
86
|
-
return [...cache.keys()];
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
// END_BLOCK_CREATE_LOCATION_RESOLVER
|
|
91
|
-
//# sourceMappingURL=location-config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"location-config.js","sourceRoot":"","sources":["../../../src/plugins/v2-runtime/location-config.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,iBAAiB;AACjB,wBAAwB;AACxB,iJAAiJ;AACjJ,oPAAoP;AACpP,wCAAwC;AACxC,yEAAyE;AACzE,kBAAkB;AAClB,sBAAsB;AACtB,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B,CAAC;QACD,IAAI,iBAAiB;YACnB,OAAO,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAC3B,CAAC;KACF,CAAC;AACJ,CAAC;AACD,qCAAqC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { Plugin as V2Plugin } from "@opencode/plugin";
|
|
2
|
-
import { type LocationResolver } from "./location-config.js";
|
|
3
|
-
/**
|
|
4
|
-
* The context handed to every vvoc plugin v2 setup: the OpenCode v2 plugin
|
|
5
|
-
* context plus the shared location resolver and a multiplexed config watcher.
|
|
6
|
-
*/
|
|
7
|
-
export interface V2AdapterContext {
|
|
8
|
-
readonly ctx: V2Plugin.Context;
|
|
9
|
-
readonly resolver: LocationResolver;
|
|
10
|
-
/** Watch the project vvoc config effective for one directory; the returned stop function never throws. */
|
|
11
|
-
watchConfig(directory: string, onChange: () => void): Promise<() => void>;
|
|
12
|
-
}
|
|
13
|
-
type V2PluginSetup = (adapter: V2AdapterContext) => Promise<V2Plugin.Cleanup | void> | V2Plugin.Cleanup | void;
|
|
14
|
-
/**
|
|
15
|
-
* Per-plugin v2 setup functions in the canonical v1 plugin order. Migration
|
|
16
|
-
* tasks append entries as each plugin gains its v2 registration.
|
|
17
|
-
*/
|
|
18
|
-
export declare const V2_PLUGIN_SETUPS: Array<{
|
|
19
|
-
name: string;
|
|
20
|
-
setup: V2PluginSetup;
|
|
21
|
-
}>;
|
|
22
|
-
/**
|
|
23
|
-
* OpenCode v1 (>= 1.18.29) also invokes setup() on dual entrypoints through
|
|
24
|
-
* its reduced v2 bridge host, whose context only carries the agent, aisdk,
|
|
25
|
-
* catalog, command, integration, plugin, reference, and skill domains. The
|
|
26
|
-
* full OpenCode v2 context additionally carries app, location, event, model,
|
|
27
|
-
* provider, session, storage, tool, and the remaining runtime domains. Probe
|
|
28
|
-
* verified against OpenCode 1.18.32: the v1 bridge lacks tool, session, event,
|
|
29
|
-
* storage, app, and location, so their presence distinguishes the runtimes.
|
|
30
|
-
*/
|
|
31
|
-
export declare function isFullV2Context(context: V2Plugin.Context): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Build the shared adapter for one plugin context: a per-location config
|
|
34
|
-
* resolver and a config watcher multiplexer that keeps one filesystem watch
|
|
35
|
-
* per directory regardless of how many plugins subscribe to that directory.
|
|
36
|
-
*/
|
|
37
|
-
export declare function createV2Adapter(context: V2Plugin.Context): V2AdapterContext;
|
|
38
|
-
/**
|
|
39
|
-
* Run every registered v2 plugin setup against the adapter, isolating failures
|
|
40
|
-
* per plugin, and return one cleanup that disposes the successful cleanups in
|
|
41
|
-
* reverse registration order.
|
|
42
|
-
*
|
|
43
|
-
* Under the v1 v2-bridge host this returns without registering anything: the
|
|
44
|
-
* same entrypoint's server() member already provides the v1 behavior, so the
|
|
45
|
-
* package never registers twice inside one OpenCode v1 process.
|
|
46
|
-
*/
|
|
47
|
-
export declare function setupV2Plugins(context: V2Plugin.Context): Promise<V2Plugin.Cleanup | void>;
|
|
48
|
-
export {};
|