@osovv/vv-opencode 2.0.1 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/README.md +88 -87
- 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 +18 -14
- 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,7 +1,6 @@
|
|
|
1
|
-
import { jsx as _jsx } from "@opentui/solid/jsx-runtime";
|
|
2
|
-
import { loadVvocConfigForRead } from "../../lib/config-layers.js";
|
|
3
|
-
import { isVvocPluginEnabled } from "../../lib/plugin-toggle-config.js";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "@opentui/solid/jsx-runtime";
|
|
4
2
|
import { findActivePeak, formatPeakEndTime, normalizeProviderId, parsePeakHoursEntry, suggestOffPeakProviders, } from "../../lib/peak-hours.js";
|
|
3
|
+
import { policyPeakHours } from "../policy.js";
|
|
5
4
|
// START_CONTRACT: buildPeakBannerText
|
|
6
5
|
// PURPOSE: Compose the one-line banner label with window end and suggestions.
|
|
7
6
|
// INPUTS: { providerID: string - peak provider id; peak: ActivePeak - active window hit; suggestions: readonly string[] - connected off-peak provider ids }
|
|
@@ -17,110 +16,79 @@ export function buildPeakBannerText(providerID, peak, suggestions) {
|
|
|
17
16
|
return `⚠ PEAK ${providerID} until ${until} · elevated pricing${suffix}`;
|
|
18
17
|
}
|
|
19
18
|
// START_CONTRACT: resolveBannerModelRef
|
|
20
|
-
// PURPOSE: Resolve the
|
|
21
|
-
// INPUTS: {
|
|
22
|
-
// OUTPUTS: { PeakBannerModelRef | undefined - provider id of the
|
|
19
|
+
// PURPOSE: Resolve the selected model provider, falling back to the most recent model-bearing message.
|
|
20
|
+
// INPUTS: { ctx: Plugin.Context - native TUI context }
|
|
21
|
+
// OUTPUTS: { PeakBannerModelRef | undefined - provider id of the selected model or the newest model-bearing message }
|
|
23
22
|
// SIDE_EFFECTS: none
|
|
24
|
-
// LINKS: currentSessionID
|
|
25
23
|
// END_CONTRACT: resolveBannerModelRef
|
|
26
|
-
export function resolveBannerModelRef(
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
24
|
+
export function resolveBannerModelRef(ctx) {
|
|
25
|
+
const selected = ctx.ui.model.current();
|
|
26
|
+
if (selected !== undefined && selected.providerID.length > 0) {
|
|
27
|
+
return { providerID: selected.providerID };
|
|
28
|
+
}
|
|
29
|
+
const route = ctx.ui.router.current();
|
|
30
|
+
if (route.type !== "session")
|
|
29
31
|
return undefined;
|
|
30
|
-
const messages =
|
|
32
|
+
const messages = ctx.data.session.message.list(route.sessionID);
|
|
31
33
|
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
32
34
|
const message = messages[index];
|
|
33
|
-
if (
|
|
35
|
+
if (message === undefined)
|
|
34
36
|
continue;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
if (typeof message.model?.providerID === "string") {
|
|
39
|
-
return { providerID: message.model.providerID };
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const configModel = api.state.config.model;
|
|
43
|
-
if (typeof configModel === "string" && configModel.includes("/")) {
|
|
44
|
-
const providerID = configModel.split("/")[0];
|
|
45
|
-
if (providerID)
|
|
37
|
+
const providerID = message.model?.providerID;
|
|
38
|
+
if (typeof providerID === "string" && providerID.length > 0)
|
|
46
39
|
return { providerID };
|
|
47
40
|
}
|
|
48
41
|
return undefined;
|
|
49
42
|
}
|
|
50
|
-
/** Reads the currently open sessionID from the TUI route, or "". */
|
|
51
|
-
function currentSessionID(api) {
|
|
52
|
-
const route = api.route.current;
|
|
53
|
-
if (route.name === "session" && "params" in route) {
|
|
54
|
-
const sessionID = route.params?.sessionID;
|
|
55
|
-
return typeof sessionID === "string" ? sessionID : "";
|
|
56
|
-
}
|
|
57
|
-
return "";
|
|
58
|
-
}
|
|
59
43
|
// START_BLOCK_REGISTER_BANNER
|
|
60
44
|
/**
|
|
61
|
-
*
|
|
45
|
+
* Claim the native `session.composer.top` slot and render the peak-hours banner.
|
|
62
46
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
47
|
+
* Placement note: the V1 banner lived in `app_bottom`; the native slot tree
|
|
48
|
+
* publishes no global bottom slot, so the visible warning now renders at the
|
|
49
|
+
* top of the session composer while the current model's provider is in peak.
|
|
50
|
+
* Disabled policy, missing slot API, or registration failure leave the TUI
|
|
51
|
+
* untouched.
|
|
67
52
|
*/
|
|
68
|
-
export
|
|
69
|
-
if (typeof api.slots?.register !== "function")
|
|
70
|
-
return;
|
|
71
|
-
// Populated by the default enabled() config read; kept for the sync entry().
|
|
72
|
-
let cachedEntry;
|
|
53
|
+
export function registerPeakHoursBanner(ctx, policy, dependencies = {}) {
|
|
73
54
|
const deps = {
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
allowDefault: true,
|
|
78
|
-
cwd: apiInstance.state.path.directory,
|
|
79
|
-
});
|
|
80
|
-
if (!isVvocPluginEnabled(vvoc.config, "peak-hours"))
|
|
81
|
-
return false;
|
|
82
|
-
const parsed = parsePeakHoursEntry(vvoc.config.plugins?.["peak-hours"]);
|
|
83
|
-
cachedEntry = parsed.entry;
|
|
84
|
-
return parsed.entry.enabled;
|
|
55
|
+
isEnabled: () => {
|
|
56
|
+
const peakHours = policyPeakHours(policy());
|
|
57
|
+
return peakHours !== undefined && peakHours.enabled;
|
|
85
58
|
},
|
|
86
59
|
now: () => new Date(),
|
|
87
|
-
entry: () =>
|
|
88
|
-
currentModel:
|
|
89
|
-
connectedProviders: (
|
|
60
|
+
entry: () => parsePeakHoursEntry(policyPeakHours(policy())).entry,
|
|
61
|
+
currentModel: resolveBannerModelRef,
|
|
62
|
+
connectedProviders: (context) => (context.data.location.provider.list() ?? [])
|
|
90
63
|
.map((provider) => provider.id)
|
|
91
64
|
.filter((id) => typeof id === "string"),
|
|
92
65
|
renderBanner: (text, color) => (_jsx("text", { children: _jsx("span", { style: { fg: color }, children: text }) })),
|
|
93
66
|
...dependencies,
|
|
94
67
|
};
|
|
95
|
-
if (!(await deps.enabled(api)))
|
|
96
|
-
return;
|
|
97
68
|
try {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const suggestions = suggestOffPeakProviders(now, entry.schedules, deps.connectedProviders(api)).filter((candidate) => normalizeProviderId(candidate) !== normalizeProviderId(modelRef.providerID));
|
|
116
|
-
return deps.renderBanner(buildPeakBannerText(modelRef.providerID, peak, suggestions), api.theme.current.warning);
|
|
117
|
-
},
|
|
69
|
+
return ctx.ui.slot({
|
|
70
|
+
append: "session.composer.top",
|
|
71
|
+
render: () => {
|
|
72
|
+
if (!deps.isEnabled())
|
|
73
|
+
return _jsx(_Fragment, {});
|
|
74
|
+
const entry = deps.entry();
|
|
75
|
+
if (!entry.enabled)
|
|
76
|
+
return _jsx(_Fragment, {});
|
|
77
|
+
const modelRef = deps.currentModel(ctx);
|
|
78
|
+
if (modelRef === undefined)
|
|
79
|
+
return _jsx(_Fragment, {});
|
|
80
|
+
const now = deps.now();
|
|
81
|
+
const peak = findActivePeak(now, entry.schedules, modelRef.providerID);
|
|
82
|
+
if (peak === undefined)
|
|
83
|
+
return _jsx(_Fragment, {});
|
|
84
|
+
const suggestions = suggestOffPeakProviders(now, entry.schedules, deps.connectedProviders(ctx)).filter((candidate) => normalizeProviderId(candidate) !== normalizeProviderId(modelRef.providerID));
|
|
85
|
+
return deps.renderBanner(buildPeakBannerText(modelRef.providerID, peak, suggestions), ctx.theme.text.feedback.warning.base);
|
|
118
86
|
},
|
|
119
|
-
};
|
|
120
|
-
api.slots.register(plugin);
|
|
87
|
+
});
|
|
121
88
|
}
|
|
122
89
|
catch {
|
|
123
90
|
// Fail-soft: no banner for this session.
|
|
91
|
+
return () => undefined;
|
|
124
92
|
}
|
|
125
93
|
}
|
|
126
94
|
//# sourceMappingURL=banner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../../../src/tui/peak-hours/banner.tsx"],"names":[],"mappings":";AA0BA,OAAO,
|
|
1
|
+
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../../../src/tui/peak-hours/banner.tsx"],"names":[],"mappings":";AA0BA,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,GAIxB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAe/C,sCAAsC;AACtC,gFAAgF;AAChF,8JAA8J;AAC9J,4CAA4C;AAC5C,uBAAuB;AACvB,6BAA6B;AAC7B,oCAAoC;AACpC,MAAM,UAAU,mBAAmB,CACjC,UAAkB,EAClB,IAAgB,EAChB,WAA8B;IAE9B,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,MAAM,GACV,WAAW,CAAC,MAAM,GAAG,CAAC;QACpB,CAAC,CAAC,oBAAoB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAC9C,CAAC,CAAC,uDAAuD,CAAC;IAC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CAAC,CAAC;gBACxC,IAAI,QAAQ,KAAK,SAAS;oBAAE,OAAO,mBAAK,CAAC;gBAEzC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;gBACvB,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;gBACvE,IAAI,IAAI,KAAK,SAAS;oBAAE,OAAO,mBAAK,CAAC;gBAErC,MAAM,WAAW,GAAG,uBAAuB,CACzC,GAAG,EACH,KAAK,CAAC,SAAS,EACf,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAC7B,CAAC,MAAM,CACN,CAAC,SAAS,EAAE,EAAE,CACZ,mBAAmB,CAAC,SAAS,CAAC,KAAK,mBAAmB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAC9E,CAAC;gBAEF,OAAO,IAAI,CAAC,YAAY,CACtB,mBAAmB,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,EAAE,WAAW,CAAC,EAC3D,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CACrC,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,yCAAyC;QACzC,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC;IACzB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type ContextInspectionPolicy, type ContextInspectionPeakHours } from "../runtime/context-inspection-contract.js";
|
|
2
|
+
/** Current session id and location directory the policy applies to. */
|
|
3
|
+
export type ContextPolicySelection = {
|
|
4
|
+
readonly sessionID?: string | undefined;
|
|
5
|
+
/** The selected session's current native directory; always required by the TUI. */
|
|
6
|
+
readonly directory: string;
|
|
7
|
+
};
|
|
8
|
+
/** Loading quarantine, an allowlisted policy, or undefined before the first refresh. */
|
|
9
|
+
export type ContextPolicySnapshot = {
|
|
10
|
+
readonly status: "loading";
|
|
11
|
+
readonly scope: "family" | "current-runtime";
|
|
12
|
+
} | ContextInspectionPolicy;
|
|
13
|
+
/** Injectable RPC fetch seam used by tests and production. */
|
|
14
|
+
export type ContextPolicyFetch = (selection: ContextPolicySelection) => Promise<ContextInspectionPolicy | undefined>;
|
|
15
|
+
/** Structural native inspection call used by the production policy fetch. */
|
|
16
|
+
export type ContextPolicyInspect = (input: {
|
|
17
|
+
readonly sessionID?: string;
|
|
18
|
+
readonly includeCatalog?: boolean;
|
|
19
|
+
}, options: {
|
|
20
|
+
readonly location: {
|
|
21
|
+
readonly directory: string;
|
|
22
|
+
};
|
|
23
|
+
}) => Promise<unknown>;
|
|
24
|
+
/**
|
|
25
|
+
* Build the production RPC policy fetch. A reply is accepted only when it is a
|
|
26
|
+
* strictly valid inspection result AND its serving `location.directory` matches
|
|
27
|
+
* the requested selected-session directory (the family capture origin may move,
|
|
28
|
+
* the serving location may not).
|
|
29
|
+
*/
|
|
30
|
+
export declare function createRpcPolicyFetch(inspect: ContextPolicyInspect): ContextPolicyFetch;
|
|
31
|
+
/** Shared selection-keyed refresh/dispose/listen controller. */
|
|
32
|
+
export interface ContextPolicyController {
|
|
33
|
+
/** The current accepted snapshot (undefined before the first refresh). */
|
|
34
|
+
current(): ContextPolicySnapshot | undefined;
|
|
35
|
+
/** Refetch for the selected session/location and accept only the newest reply for the newest key. */
|
|
36
|
+
refresh(selection: ContextPolicySelection): Promise<ContextPolicySnapshot | undefined>;
|
|
37
|
+
/** Notifies after each accepted snapshot or quarantine; returns an unsubscribe function. */
|
|
38
|
+
subscribe(listener: (snapshot: ContextPolicySnapshot | undefined) => void): () => void;
|
|
39
|
+
/** Stop accepting replies and release listeners. */
|
|
40
|
+
dispose(): void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Build a selection-keyed, generation-guarded policy controller. On a selection
|
|
44
|
+
* key change the previous snapshot is quarantined immediately (a `loading`
|
|
45
|
+
* snapshot is published) so a stale policy is never rendered while the new one
|
|
46
|
+
* loads. Replies whose selection key or generation is no longer current are
|
|
47
|
+
* discarded. A rejected fetch becomes an explicit unavailable snapshot.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createPolicyController(fetch: ContextPolicyFetch): ContextPolicyController;
|
|
50
|
+
/** Narrow a snapshot to an allowlisted available/preview/unavailable policy. */
|
|
51
|
+
export declare function isResolvedPolicy(policy: ContextPolicySnapshot | undefined): policy is ContextInspectionPolicy;
|
|
52
|
+
/**
|
|
53
|
+
* True only when an available or preview policy explicitly enables the context
|
|
54
|
+
* plugin. Disabled and unavailable policies both suppress the effect.
|
|
55
|
+
*/
|
|
56
|
+
export declare function policyContextEnabled(policy: ContextPolicySnapshot | undefined): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* True only when a resolved policy explicitly disables the context plugin.
|
|
59
|
+
* Loading, unavailable, and undefined snapshots are not "disabled": the
|
|
60
|
+
* /context command stays reachable so an unbound or empty session can show its
|
|
61
|
+
* unavailable policy and observations honestly instead of becoming empty.
|
|
62
|
+
*/
|
|
63
|
+
export declare function policyContextSuppressed(policy: ContextPolicySnapshot | undefined): boolean;
|
|
64
|
+
/** True only when an available or preview policy explicitly enables analytics. */
|
|
65
|
+
export declare function policyAnalyticsEnabled(policy: ContextPolicySnapshot | undefined): boolean;
|
|
66
|
+
/** Allowlisted peak-hours config, or undefined when the policy is unavailable/loading. */
|
|
67
|
+
export declare function policyPeakHours(policy: ContextPolicySnapshot | undefined): ContextInspectionPeakHours | undefined;
|
|
68
|
+
/** Stable error code when a resolved policy is unavailable. */
|
|
69
|
+
export declare function policyUnavailableReason(policy: ContextPolicySnapshot | undefined): string | undefined;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// FILE: src/tui/policy.ts
|
|
2
|
+
// VERSION: 2.0.0
|
|
3
|
+
// START_MODULE_CONTRACT
|
|
4
|
+
// PURPOSE: Own the shared TUI policy snapshot fetched from the native context-inspection RPC, quarantining the previous selection's snapshot as soon as the session/location key changes and discarding stale replies.
|
|
5
|
+
// SCOPE: Selection-keyed generation-guarded refresh, loading quarantine on key change, listener notification, disposal, and pure allowlisted policy predicates for the context/analytics/peak-hours consumers.
|
|
6
|
+
// DEPENDS: [src/runtime/context-inspection-contract.ts]
|
|
7
|
+
// LINKS: [M-PLUGIN-CONTEXT-TUI, M-PLUGIN-ANALYTICS, M-PLUGIN-PEAK-HOURS, DF-CONTEXT-INSPECTION, V-M-PLUGIN-CONTEXT-TUI]
|
|
8
|
+
// ROLE: RUNTIME
|
|
9
|
+
// MAP_MODE: EXPORTS
|
|
10
|
+
// END_MODULE_CONTRACT
|
|
11
|
+
//
|
|
12
|
+
// START_MODULE_MAP
|
|
13
|
+
// ContextPolicySelection - Current session id and location directory the policy applies to.
|
|
14
|
+
// ContextPolicySnapshot - Loading quarantine, an allowlisted policy, or undefined before the first refresh.
|
|
15
|
+
// ContextPolicyFetch - Injectable RPC fetch seam used by tests and production.
|
|
16
|
+
// ContextPolicyInspect - Structural native inspection call used by the production fetch.
|
|
17
|
+
// createRpcPolicyFetch - Build the location-checked production policy fetch.
|
|
18
|
+
// ContextPolicyController - Shared selection-keyed refresh/dispose/listen controller.
|
|
19
|
+
// createPolicyController - Build a selection-keyed, generation-guarded policy controller.
|
|
20
|
+
// isResolvedPolicy - Narrow a snapshot to an allowlisted available/preview/unavailable policy.
|
|
21
|
+
// policyContextEnabled - True only when an available/preview policy enables the context plugin.
|
|
22
|
+
// policyContextSuppressed - True only when a resolved policy explicitly disables the context plugin.
|
|
23
|
+
// policyAnalyticsEnabled - True only when an available/preview policy enables analytics.
|
|
24
|
+
// policyPeakHours - Allowlisted peak-hours config, or undefined when unavailable/loading.
|
|
25
|
+
// policyUnavailableReason - Stable error code when a resolved policy is unavailable.
|
|
26
|
+
// END_MODULE_MAP
|
|
27
|
+
//
|
|
28
|
+
// START_CHANGE_SUMMARY
|
|
29
|
+
// LAST_CHANGE: [C-OPENCODE-V2-NATIVE T-008 attempt 3 - Made the selection directory mandatory and added a serving-location-checked production RPC policy fetch.]
|
|
30
|
+
// END_CHANGE_SUMMARY
|
|
31
|
+
import { isContextInspectionResult, } from "../runtime/context-inspection-contract.js";
|
|
32
|
+
/**
|
|
33
|
+
* Build the production RPC policy fetch. A reply is accepted only when it is a
|
|
34
|
+
* strictly valid inspection result AND its serving `location.directory` matches
|
|
35
|
+
* the requested selected-session directory (the family capture origin may move,
|
|
36
|
+
* the serving location may not).
|
|
37
|
+
*/
|
|
38
|
+
export function createRpcPolicyFetch(inspect) {
|
|
39
|
+
return async (selection) => {
|
|
40
|
+
const result = await inspect({
|
|
41
|
+
...(selection.sessionID === undefined ? {} : { sessionID: selection.sessionID }),
|
|
42
|
+
includeCatalog: false,
|
|
43
|
+
}, { location: { directory: selection.directory } });
|
|
44
|
+
if (!isContextInspectionResult(result))
|
|
45
|
+
return undefined;
|
|
46
|
+
if (result.location.directory !== selection.directory)
|
|
47
|
+
return undefined;
|
|
48
|
+
return result.policy;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// START_BLOCK_POLICY_CONTROLLER
|
|
52
|
+
function selectionKey(selection) {
|
|
53
|
+
return `${selection.sessionID ?? ""}\u0000${selection.directory ?? ""}`;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Build a selection-keyed, generation-guarded policy controller. On a selection
|
|
57
|
+
* key change the previous snapshot is quarantined immediately (a `loading`
|
|
58
|
+
* snapshot is published) so a stale policy is never rendered while the new one
|
|
59
|
+
* loads. Replies whose selection key or generation is no longer current are
|
|
60
|
+
* discarded. A rejected fetch becomes an explicit unavailable snapshot.
|
|
61
|
+
*/
|
|
62
|
+
export function createPolicyController(fetch) {
|
|
63
|
+
const listeners = new Set();
|
|
64
|
+
let generation = 0;
|
|
65
|
+
let activeKey;
|
|
66
|
+
let current;
|
|
67
|
+
let disposed = false;
|
|
68
|
+
const publish = (snapshot) => {
|
|
69
|
+
current = snapshot;
|
|
70
|
+
for (const listener of listeners)
|
|
71
|
+
listener(snapshot);
|
|
72
|
+
};
|
|
73
|
+
return {
|
|
74
|
+
current: () => current,
|
|
75
|
+
async refresh(selection) {
|
|
76
|
+
if (disposed)
|
|
77
|
+
return current;
|
|
78
|
+
const key = selectionKey(selection);
|
|
79
|
+
const scope = selection.sessionID === undefined ? "current-runtime" : "family";
|
|
80
|
+
if (key !== activeKey) {
|
|
81
|
+
activeKey = key;
|
|
82
|
+
// Quarantine the previous selection's policy until the new one resolves.
|
|
83
|
+
publish({ status: "loading", scope });
|
|
84
|
+
}
|
|
85
|
+
const mine = (generation += 1);
|
|
86
|
+
let snapshot;
|
|
87
|
+
try {
|
|
88
|
+
const policy = await fetch(selection);
|
|
89
|
+
snapshot =
|
|
90
|
+
policy ??
|
|
91
|
+
{
|
|
92
|
+
status: "unavailable",
|
|
93
|
+
scope,
|
|
94
|
+
error: "policy_capture_missing",
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
snapshot = {
|
|
99
|
+
status: "unavailable",
|
|
100
|
+
scope,
|
|
101
|
+
error: "inspection_internal_error",
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
// Discard a stale reply: only the newest key/generation may publish.
|
|
105
|
+
if (disposed || mine !== generation || key !== activeKey)
|
|
106
|
+
return current;
|
|
107
|
+
publish(snapshot);
|
|
108
|
+
return current;
|
|
109
|
+
},
|
|
110
|
+
subscribe(listener) {
|
|
111
|
+
if (disposed)
|
|
112
|
+
return () => undefined;
|
|
113
|
+
listeners.add(listener);
|
|
114
|
+
return () => listeners.delete(listener);
|
|
115
|
+
},
|
|
116
|
+
dispose() {
|
|
117
|
+
disposed = true;
|
|
118
|
+
generation += 1;
|
|
119
|
+
listeners.clear();
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
// END_BLOCK_POLICY_CONTROLLER
|
|
124
|
+
// START_BLOCK_POLICY_PREDICATES
|
|
125
|
+
/** Narrow a snapshot to an allowlisted available/preview/unavailable policy. */
|
|
126
|
+
export function isResolvedPolicy(policy) {
|
|
127
|
+
return (policy !== undefined &&
|
|
128
|
+
(policy.status === "available" ||
|
|
129
|
+
policy.status === "preview" ||
|
|
130
|
+
policy.status === "unavailable"));
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* True only when an available or preview policy explicitly enables the context
|
|
134
|
+
* plugin. Disabled and unavailable policies both suppress the effect.
|
|
135
|
+
*/
|
|
136
|
+
export function policyContextEnabled(policy) {
|
|
137
|
+
if (!isResolvedPolicy(policy) || policy.status === "unavailable")
|
|
138
|
+
return false;
|
|
139
|
+
return policy.contextEnabled;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* True only when a resolved policy explicitly disables the context plugin.
|
|
143
|
+
* Loading, unavailable, and undefined snapshots are not "disabled": the
|
|
144
|
+
* /context command stays reachable so an unbound or empty session can show its
|
|
145
|
+
* unavailable policy and observations honestly instead of becoming empty.
|
|
146
|
+
*/
|
|
147
|
+
export function policyContextSuppressed(policy) {
|
|
148
|
+
if (!isResolvedPolicy(policy) || policy.status === "unavailable")
|
|
149
|
+
return false;
|
|
150
|
+
return policy.contextEnabled === false;
|
|
151
|
+
}
|
|
152
|
+
/** True only when an available or preview policy explicitly enables analytics. */
|
|
153
|
+
export function policyAnalyticsEnabled(policy) {
|
|
154
|
+
if (!isResolvedPolicy(policy) || policy.status === "unavailable")
|
|
155
|
+
return false;
|
|
156
|
+
return policy.analyticsEnabled;
|
|
157
|
+
}
|
|
158
|
+
/** Allowlisted peak-hours config, or undefined when the policy is unavailable/loading. */
|
|
159
|
+
export function policyPeakHours(policy) {
|
|
160
|
+
if (!isResolvedPolicy(policy) || policy.status === "unavailable")
|
|
161
|
+
return undefined;
|
|
162
|
+
return policy.peakHours;
|
|
163
|
+
}
|
|
164
|
+
/** Stable error code when a resolved policy is unavailable. */
|
|
165
|
+
export function policyUnavailableReason(policy) {
|
|
166
|
+
return isResolvedPolicy(policy) && policy.status === "unavailable" ? policy.error : undefined;
|
|
167
|
+
}
|
|
168
|
+
// END_BLOCK_POLICY_PREDICATES
|
|
169
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/tui/policy.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,iBAAiB;AACjB,wBAAwB;AACxB,yNAAyN;AACzN,iNAAiN;AACjN,0DAA0D;AAC1D,0HAA0H;AAC1H,kBAAkB;AAClB,sBAAsB;AACtB,sBAAsB;AACtB,EAAE;AACF,mBAAmB;AACnB,8FAA8F;AAC9F,8GAA8G;AAC9G,iFAAiF;AACjF,2FAA2F;AAC3F,+EAA+E;AAC/E,wFAAwF;AACxF,4FAA4F;AAC5F,iGAAiG;AACjG,kGAAkG;AAClG,uGAAuG;AACvG,2FAA2F;AAC3F,4FAA4F;AAC5F,uFAAuF;AACvF,iBAAiB;AACjB,EAAE;AACF,uBAAuB;AACvB,mKAAmK;AACnK,qBAAqB;AAErB,OAAO,EACL,yBAAyB,GAG1B,MAAM,2CAA2C,CAAC;AAyBnD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA6B;IAChE,OAAO,KAAK,EAAE,SAAS,EAAE,EAAE;QACzB,MAAM,MAAM,GAAG,MAAM,OAAO,CAC1B;YACE,GAAG,CAAC,SAAS,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC;YAChF,cAAc,EAAE,KAAK;SACtB,EACD,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,EAAE,CACjD,CAAC;QACF,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC;YAAE,OAAO,SAAS,CAAC;QACzD,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,KAAK,SAAS,CAAC,SAAS;YAAE,OAAO,SAAS,CAAC;QACxE,O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AAK,CAAC;IAC/E,OAAO,MAAM,CAAC,cAAc,CAAC;AAC/B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAyC;IAC/E,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,aAAa;QAAE,OAAO,KAAK,CAAC;IAC/E,OAAO,MAAM,CAAC,cAAc,KAAK,KAAK,CAAC;AACzC,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,sBAAsB,CAAC,MAAyC;IAC9E,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,aAAa;QAAE,OAAO,KAAK,CAAC;IAC/E,OAAO,MAAM,CAAC,gBAAgB,CAAC;AACjC,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,eAAe,CAC7B,MAAyC;IAEzC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,aAAa;QAAE,OAAO,SAAS,CAAC;IACnF,OAAO,MAAM,CAAC,SAAS,CAAC;AAC1B,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,uBAAuB,CACrC,MAAyC;IAEzC,OAAO,gBAAgB,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAChG,CAAC;AACD,8BAA8B"}
|
package/dist/tui.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
declare const plugin: TuiPluginModule & {
|
|
5
|
-
id: string;
|
|
6
|
-
setup?: (context: unknown) => Promise<void> | void;
|
|
7
|
-
};
|
|
8
|
-
export default plugin;
|
|
1
|
+
import { Plugin } from "@opencode/plugin/tui";
|
|
2
|
+
export declare const vvocContextTuiPlugin: Plugin.Definition;
|
|
3
|
+
export default vvocContextTuiPlugin;
|
package/dist/tui.js
CHANGED
|
@@ -1,87 +1,91 @@
|
|
|
1
1
|
// FILE: src/tui.tsx
|
|
2
|
-
// VERSION: 2.
|
|
2
|
+
// VERSION: 2.1.0
|
|
3
3
|
// START_MODULE_CONTRACT
|
|
4
|
-
// PURPOSE: Publish the
|
|
5
|
-
// SCOPE:
|
|
6
|
-
// DEPENDS: [@opencode
|
|
7
|
-
// LINKS: [M-PLUGIN-CONTEXT-TUI, M-TUI-ANALYTICS-INDICATOR, M-TUI-BRANDING-FOOTER, M-TUI-PEAK-HOURS-BANNER, V-M-PLUGIN-CONTEXT-TUI]
|
|
4
|
+
// PURPOSE: Publish the default @osovv/vv-opencode/tui native plugin module containing the /context inspector, analytics indicator, branding footer, and peak-hours banner.
|
|
5
|
+
// SCOPE: Native plugin definition (id/setup/cleanup), a shared selection-keyed policy controller over the context-inspection RPC that resolves the current selected session's native location, refresh on route and native policy-binding events, and lifecycle cleanup of every slot/keymap/effect/subscription. It performs no local filesystem config read.
|
|
6
|
+
// DEPENDS: [@opencode/plugin/tui, solid-js, src/runtime/context-inspection-contract.ts, src/tui/policy.ts, src/tui/context/collect.ts, src/tui/context/plugin.ts, src/tui/context/view.tsx, src/tui/analytics/indicator.tsx, src/tui/branding/footer.tsx, src/tui/peak-hours/banner.tsx]
|
|
7
|
+
// LINKS: [M-PLUGIN-CONTEXT-TUI, M-TUI-ANALYTICS-INDICATOR, M-TUI-BRANDING-FOOTER, M-TUI-PEAK-HOURS-BANNER, DF-CONTEXT-INSPECTION, V-M-PLUGIN-CONTEXT-TUI]
|
|
8
8
|
// ROLE: BARREL
|
|
9
9
|
// MAP_MODE: SUMMARY
|
|
10
10
|
// END_MODULE_CONTRACT
|
|
11
11
|
//
|
|
12
12
|
// START_MODULE_MAP
|
|
13
|
-
//
|
|
14
|
-
//
|
|
13
|
+
// vvocContextTuiPlugin - Named native TUI plugin definition for direct consumers and tests.
|
|
14
|
+
// default - Native OpenCode TUI plugin module registering /context, the analytics indicator, the branding footer, and the peak-hours banner.
|
|
15
15
|
// END_MODULE_MAP
|
|
16
16
|
//
|
|
17
17
|
// START_CHANGE_SUMMARY
|
|
18
|
-
// LAST_CHANGE: [C-OPENCODE-V2-
|
|
18
|
+
// LAST_CHANGE: [C-OPENCODE-V2-NATIVE T-008 attempt 3 - Location-checked RPC policy fetch and native step-boundary refresh so a freshly committed capture is picked up on the same session without a tab change.]
|
|
19
19
|
// END_CHANGE_SUMMARY
|
|
20
|
-
import {
|
|
20
|
+
import { Plugin } from "@opencode/plugin/tui";
|
|
21
|
+
import { createEffect, createSignal } from "solid-js";
|
|
22
|
+
import { contextInspectionRpc } from "./runtime/context-inspection-contract.js";
|
|
21
23
|
import { registerAnalyticsIndicator } from "./tui/analytics/indicator.js";
|
|
22
24
|
import { registerBrandingFooter } from "./tui/branding/footer.js";
|
|
25
|
+
import { collectContextAnalysis, createTuiCollectionDependencies } from "./tui/context/collect.js";
|
|
26
|
+
import { activeSessionID, registerContextTuiPlugin } from "./tui/context/plugin.js";
|
|
27
|
+
import { openContextDialog } from "./tui/context/view.js";
|
|
23
28
|
import { registerPeakHoursBanner } from "./tui/peak-hours/banner.js";
|
|
24
|
-
|
|
29
|
+
import { createPolicyController, createRpcPolicyFetch, policyContextSuppressed, } from "./tui/policy.js";
|
|
25
30
|
// START_BLOCK_TUI_MODULE
|
|
26
|
-
const
|
|
31
|
+
export const vvocContextTuiPlugin = Plugin.define({
|
|
27
32
|
id: "vvoc-context",
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
33
|
+
setup(ctx) {
|
|
34
|
+
const fallbackDirectory = () => ctx.location?.directory ?? ctx.data.location.default().directory;
|
|
35
|
+
// The policy must follow the SELECTED session's current native location, not
|
|
36
|
+
// a location captured once at plugin setup.
|
|
37
|
+
const sessionDirectory = (sessionID) => {
|
|
38
|
+
if (sessionID === undefined)
|
|
39
|
+
return fallbackDirectory();
|
|
40
|
+
const location = ctx.data.session.get(sessionID)?.location;
|
|
41
|
+
return location?.directory ?? fallbackDirectory();
|
|
42
|
+
};
|
|
43
|
+
const controller = createPolicyController(createRpcPolicyFetch((input, options) => ctx.client.rpc(contextInspectionRpc).inspect(input, options)));
|
|
44
|
+
const [policy, setPolicy] = createSignal(undefined);
|
|
45
|
+
const cleanups = [
|
|
46
|
+
controller.subscribe(setPolicy),
|
|
47
|
+
() => controller.dispose(),
|
|
48
|
+
];
|
|
49
|
+
const refreshActive = () => {
|
|
50
|
+
const sessionID = activeSessionID(ctx);
|
|
51
|
+
void controller.refresh({ sessionID, directory: sessionDirectory(sessionID) });
|
|
52
|
+
};
|
|
53
|
+
createEffect(refreshActive);
|
|
54
|
+
// An initially unbound/empty tab becomes captured without a tab change.
|
|
55
|
+
// The family capture is committed from accepted-event handling, which can
|
|
56
|
+
// lag the TUI's `session.inbox.enqueued`, so refresh again on native step
|
|
57
|
+
// boundaries: pinned `session.step.started` is published when request
|
|
58
|
+
// dispatch begins (after delivery) and `session.step.ended` after the step
|
|
59
|
+
// settles, both strictly later than the enqueue that triggers the commit.
|
|
60
|
+
cleanups.push(ctx.data.on("session.inbox.enqueued", (event) => {
|
|
61
|
+
if (activeSessionID(ctx) === event.data.sessionID)
|
|
62
|
+
refreshActive();
|
|
63
|
+
}), ctx.data.on("session.step.started", (event) => {
|
|
64
|
+
if (activeSessionID(ctx) === event.data.sessionID)
|
|
65
|
+
refreshActive();
|
|
66
|
+
}), ctx.data.on("session.step.ended", (event) => {
|
|
67
|
+
if (activeSessionID(ctx) === event.data.sessionID)
|
|
68
|
+
refreshActive();
|
|
69
|
+
}), ctx.data.on("session.model.selected", (event) => {
|
|
70
|
+
if (activeSessionID(ctx) === event.data.sessionID)
|
|
71
|
+
refreshActive();
|
|
72
|
+
}));
|
|
73
|
+
const collection = createTuiCollectionDependencies(ctx);
|
|
74
|
+
cleanups.push(registerContextTuiPlugin(ctx, ctx.options, {
|
|
75
|
+
isEnabled: () => !policyContextSuppressed(policy()),
|
|
76
|
+
revalidate: async (_context, sessionID) => {
|
|
77
|
+
await controller.refresh({ sessionID, directory: sessionDirectory(sessionID) });
|
|
78
|
+
return !policyContextSuppressed(controller.current());
|
|
79
|
+
},
|
|
80
|
+
collect: (_context, sessionID) => collectContextAnalysis(sessionID, collection),
|
|
81
|
+
open: (context, analysis) => openContextDialog(context, analysis),
|
|
82
|
+
}), registerAnalyticsIndicator(ctx, policy, ctx.options), registerBrandingFooter(ctx), registerPeakHoursBanner(ctx, policy));
|
|
83
|
+
return () => {
|
|
84
|
+
for (const cleanup of cleanups.reverse())
|
|
85
|
+
cleanup();
|
|
86
|
+
};
|
|
48
87
|
},
|
|
49
|
-
|
|
50
|
-
// OpenCode v2 loads the same entrypoint through setup() with the CLI plugin
|
|
51
|
-
// context. The v2 surface registers the /context slash command; the full
|
|
52
|
-
// inspector components port onto the v2 dialog and router surfaces in a
|
|
53
|
-
// follow-up release and this command keeps the entry point honest.
|
|
54
|
-
async setup(context) {
|
|
55
|
-
const ctx = context;
|
|
56
|
-
try {
|
|
57
|
-
ctx.keymap.layer(() => ({
|
|
58
|
-
mode: "global",
|
|
59
|
-
commands: [
|
|
60
|
-
{
|
|
61
|
-
id: "vvoc.context",
|
|
62
|
-
title: "vvoc context inspector",
|
|
63
|
-
slash: { name: "context" },
|
|
64
|
-
palette: true,
|
|
65
|
-
run: async () => {
|
|
66
|
-
const directory = ctx.data?.location?.default?.()?.directory ?? "unknown location";
|
|
67
|
-
await ctx.ui.dialog.alert({
|
|
68
|
-
title: "vvoc /context",
|
|
69
|
-
message: `OpenCode v2 runtime (host ${ctx.app?.version ?? "unknown"}).\n` +
|
|
70
|
-
`Location: ${directory}\n` +
|
|
71
|
-
"The full v2 context inspector ships in the next vvoc release; " +
|
|
72
|
-
"server-side analytics, model roles, and guidance stay active.",
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
}));
|
|
78
|
-
}
|
|
79
|
-
catch {
|
|
80
|
-
// Fail-soft: the v2 TUI host may not expose keymap layers yet.
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
// END_BLOCK_V2_TUI_SETUP
|
|
84
|
-
};
|
|
88
|
+
});
|
|
85
89
|
// END_BLOCK_TUI_MODULE
|
|
86
|
-
export default
|
|
90
|
+
export default vvocContextTuiPlugin;
|
|
87
91
|
//# sourceMappingURL=tui.js.map
|