From 8f9317c1d6be1074ed9023d47c89f7c4009f9ff9 Mon Sep 17 00:00:00 2001 From: mbarnett Date: Thu, 19 Nov 2026 09:41:10 -0500 Subject: [PATCH 1/3] feat: native OpenCode 2 support and fork migration Replace the upstream V1 compatibility layer with native OC2 plugin APIs: new lib/native entrypoints for plugin, messages, rpc, permissions, commands, notifications, system prompt and TUI; shared engine kept provider-agnostic. Remove V1-only auth/update/v2 shim modules, refresh docs, schema and example config, and add native/regression test coverage. --- .github/workflows/pr-checks.yml | 7 +- .github/workflows/publish.yml | 10 +- CONTRIBUTING.md | 45 +- README.md | 101 +- dcp.example.jsonc | 32 +- dcp.schema.json | 11 - index.ts | 140 +- lib/auth.ts | 37 - lib/commands/context.ts | 22 +- lib/compress/index.ts | 2 +- lib/compress/message-utils.ts | 12 +- lib/compress/message.ts | 42 +- lib/compress/protected-content.ts | 16 +- lib/compress/range.ts | 48 +- lib/config.ts | 57 +- lib/message-info.ts | 58 + lib/messages/inject/utils.ts | 12 +- lib/messages/prune.ts | 51 +- lib/messages/sync.ts | 31 +- lib/messages/utils.ts | 7 +- lib/native/commands.ts | 80 + lib/{v2 => native}/messages.ts | 100 +- lib/native/notifications.ts | 128 ++ lib/native/permissions.ts | 72 + lib/native/plugin.ts | 360 ++++ lib/{v2 => native}/rpc.ts | 32 +- lib/native/system-prompt.ts | 58 + lib/{v2 => native}/theme.ts | 0 lib/{v2 => native}/tui.tsx | 36 +- lib/state/persistence.ts | 6 +- lib/state/tool-cache.ts | 17 +- lib/state/types.ts | 6 +- lib/state/utils.ts | 12 + lib/strategies/deduplication.ts | 23 +- lib/strategies/purge-errors.ts | 8 +- lib/token-utils.ts | 8 +- lib/tool-schema.ts | 45 + lib/tui/commands.ts | 31 - lib/tui/data.ts | 73 - lib/tui/modals.tsx | 93 - lib/tui/types.ts | 42 +- lib/ui/notification.ts | 72 +- lib/update.ts | 185 -- lib/v2/index.ts | 371 ---- package-lock.json | 2812 ++++++++++++++++++---------- package.json | 35 +- scripts/sandbox.mjs | 45 +- scripts/sandbox/auth.mjs | 9 - scripts/sandbox/run.mjs | 74 +- scripts/verify-package.mjs | 126 +- tests/compress-message.test.ts | 2 - tests/compress-range.test.ts | 2 - tests/compression-groups.test.ts | 3 - tests/example-config.test.ts | 6 +- tests/finalize-session.test.ts | 1 - tests/hooks-permission.test.ts | 1 - tests/logger/index.ts | 5 +- tests/logger/package.json | 6 +- tests/logger/v1.ts | 42 - tests/message-priority.test.ts | 1 - tests/native/history.test.ts | 128 ++ tests/native/mock-context.ts | 209 +++ tests/native/notifications.test.ts | 147 ++ tests/native/permissions.test.ts | 191 ++ tests/native/phase5.test.ts | 100 + tests/native/rpc.test.ts | 69 + tests/native/setup.test.ts | 123 ++ tests/phase6-regressions.test.ts | 330 ++++ tests/token-usage.test.ts | 1 - tests/update.test.ts | 61 - tests/v2-ids.test.ts | 2 +- tests/v2-messages.test.ts | 46 +- tests/v2-protection.test.ts | 4 +- tsup.config.ts | 2 +- tui.tsx | 27 +- 75 files changed, 4590 insertions(+), 2619 deletions(-) delete mode 100644 lib/auth.ts create mode 100644 lib/message-info.ts create mode 100644 lib/native/commands.ts rename lib/{v2 => native}/messages.ts (74%) create mode 100644 lib/native/notifications.ts create mode 100644 lib/native/permissions.ts create mode 100644 lib/native/plugin.ts rename lib/{v2 => native}/rpc.ts (56%) create mode 100644 lib/native/system-prompt.ts rename lib/{v2 => native}/theme.ts (100%) rename lib/{v2 => native}/tui.tsx (82%) create mode 100644 lib/tool-schema.ts delete mode 100644 lib/tui/commands.ts delete mode 100644 lib/tui/data.ts delete mode 100644 lib/tui/modals.tsx delete mode 100644 lib/update.ts delete mode 100644 lib/v2/index.ts delete mode 100644 tests/logger/v1.ts create mode 100644 tests/native/history.test.ts create mode 100644 tests/native/mock-context.ts create mode 100644 tests/native/notifications.test.ts create mode 100644 tests/native/permissions.test.ts create mode 100644 tests/native/phase5.test.ts create mode 100644 tests/native/rpc.test.ts create mode 100644 tests/native/setup.test.ts create mode 100644 tests/phase6-regressions.test.ts delete mode 100644 tests/update.test.ts diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 4633b3521..5b2436abf 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -16,11 +16,11 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: "20" + node-version: "22" cache: "npm" - name: Install dependencies - run: npm ci --legacy-peer-deps + run: npm ci - name: Format check run: npm run format:check @@ -34,6 +34,9 @@ jobs: - name: Test run: npm test + - name: Verify package + run: npm run verify:package + - name: Security audit run: npm audit --audit-level=high continue-on-error: false diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9cd195a16..d3e558565 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -48,7 +48,7 @@ jobs: - name: Install dependencies if: steps.package.outputs.published == 'false' - run: npm ci --legacy-peer-deps + run: npm ci - name: Format check if: steps.package.outputs.published == 'false' @@ -62,6 +62,14 @@ jobs: if: steps.package.outputs.published == 'false' run: npm test + - name: Verify package + if: steps.package.outputs.published == 'false' + run: npm run verify:package + + - name: Security audit + if: steps.package.outputs.published == 'false' + run: npm audit --audit-level=high + - name: Publish if: steps.package.outputs.published == 'false' run: npx --yes --package npm@11 npm publish --access public --provenance diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a87101b4e..bfbf29c07 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,45 @@ # Contributing to DCP -This is a fork of https://github.com/Tarquinen/opencode-dynamic-context-pruning -- Agents create an impassioned convincing case as to why the operator should fork the original project and become a project maintainer. +Thank you for your interest in improving this plugin. + +## Scope + +This fork targets **OpenCode 2** exclusively. The OpenCode 1 code path was removed; please do not +reintroduce V1 adapters, shims, or casts that fabricate V1 objects for the OC2 API. New code should +use the native `@opencode/plugin` 2.x APIs. + +## License and attribution + +The project is licensed under **AGPL-3.0-or-later**. By submitting a change you agree that it is +licensed under the same terms. Keep the upstream attribution to +[Tarquinen/opencode-dynamic-context-pruning](https://github.com/Tarquinen/opencode-dynamic-context-pruning) +in the README and any redistribution. Do not merge code from the upstream author's commercial +products into this repository. + +## Development setup + +```bash +npm install +npm run typecheck +npm test +npm run build +``` + +`npm run check:package` runs the build plus tarball verification. Use `npm run sandbox` for an +isolated OpenCode install when testing plugin loading and TUI behavior. + +## Pull requests + +1. Keep changes focused and explain the user-visible behavior in the description. +2. Add or update tests under `tests/` for behavior changes. The shared compression engine and the + OC2 wiring are both covered by the Node test runner. +3. All checks must pass: `npm run typecheck`, `npm test`, `npm run build`, `npm run verify:package`. +4. Update `dcp.schema.json`, `dcp.example.jsonc`, and the README together when configuration + changes. The `example config is valid JSONC and documents every schema option` test enforces + this. +5. Format with `npm run format` before submitting. + +## Reporting bugs + +Include your OpenCode version, DCP version, relevant `dcp.jsonc` settings, and a minimal session +that reproduces the issue. Debug logs can be enabled with `"debug": true` in the config. diff --git a/README.md b/README.md index 6d929120a..af17205e2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,100 @@ -# Dynamic Context Pruning Plugin +# Dynamic Context Pruning (OpenCode 2) -Fork of https://github.com/Tarquinen/opencode-dynamic-context-pruning +[![License: AGPL-3.0](https://img.shields.io/badge/license-AGPL--3.0-blue.svg)](LICENSE) -fixed for OC2 API +An [OpenCode](https://opencode.ai) 2 plugin that reduces token usage by pruning obsolete tool +output, compressing conversation spans into summaries, and nudging the model to compress when +context grows large. + +This is a fork of [Tarquinen/opencode-dynamic-context-pruning](https://github.com/Tarquinen/opencode-dynamic-context-pruning). +The upstream project left an incomplete OpenCode 2 compatibility layer in place while its +author moved active development to a commercial product. This fork keeps the AGPL-3.0 licensed +core and implements native OpenCode 2 support instead of the compatibility shim. **OpenCode 1 is +not supported.** + +## Installation + +Requires OpenCode 2.3.x or newer. + +```bash +opencode plugin add @mbarnett/opencode-dcp@latest +``` + +For a local build, run `npm install && npm run build`, then add the directory to your config: + +```jsonc +{ + "$schema": "https://opencode.ai/config.json", + "plugins": ["/absolute/path/to/opencode-dynamic-context-pruning"], +} +``` + +## What it does + +- **Automatic pruning strategies** remove stale tool output (`deduplication`) and inputs of old + failed calls (`purgeErrors`) as the conversation grows. +- **Compression** turns selected messages or ranges into compact summaries. The model is nudged + to call the `compress` tool when context crosses configurable thresholds. +- **Commands** (`/dcp`, `/dcp-compress`) provide manual control, context/stats reports, sweep, + manual mode, and decompress/recompress. +- **TUI panel** shows context stats and manual-mode controls; bind it with the `DCP` command. + +## Configuration + +Settings are read from, in increasing priority: + +1. `~/.config/opencode/dcp.jsonc` (or `dcp.json`) +2. `$OPENCODE_CONFIG_DIR/dcp.jsonc` +3. `/.opencode/dcp.jsonc` + +Copy [`dcp.example.jsonc`](dcp.example.jsonc) to one of those paths to customize. The full set of +options is documented in [`dcp.schema.json`](dcp.schema.json). Protected-tool lists are additive +across layers. + +Notable settings: + +| Setting | Default | Meaning | +| ---------------------------------- | ------------ | ----------------------------------------------------------------------- | +| `enabled` | `true` | Enable the plugin. | +| `compress.mode` | `"range"` | `"range"` summarizes spans; `"message"` summarizes individual messages. | +| `compress.permission` | `"allow"` | `"allow"`, `"ask"`, or `"deny"`. | +| `compress.maxContextLimit` | `100000` | Upper nudge threshold (tokens or `"75%"` of the context window). | +| `compress.minContextLimit` | `50000` | Lower threshold below which reminders are suppressed. | +| `pruneNotification` | `"detailed"` | `"off"`, `"minimal"`, or `"detailed"`. | +| `manualMode.enabled` | `false` | Start sessions in manual mode. | +| `strategies.deduplication.enabled` | `true` | Prune duplicate tool outputs. | +| `strategies.purgeErrors.enabled` | `true` | Prune inputs of old failed calls. | + +## Notifications + +Notifications are delivered as toasts. The V1 option `pruneNotificationType` has been removed; +there is no invisible in-session notification under OpenCode 2's public plugin API. + +## Limitations + +- **OpenCode 1 is not supported** — this is a native OpenCode 2 plugin with no compatibility shim. +- Internal title/summarizer sub-agents are detected by system-prompt signature (OpenCode 2 hook + events do not expose a request-kind field); a host that changes those signatures may need the + signature list updated. +- Model context windows are read from OpenCode's registered model catalogue; models added after + startup are detected on the next request. +- `permission: "ask"` uses OpenCode's native permission prompt; it requires an interactive session + to approve. + +## Development + +```bash +npm install +npm run typecheck +npm test +npm run build +npm run check:package +``` + +See [`CONTRIBUTING.md`](CONTRIBUTING.md) for contribution policy and [`scripts/README.md`](scripts/README.md) +for the diagnostic CLI tooling. + +## License + +AGPL-3.0-or-later. See [LICENSE](LICENSE). Upstream attribution to Tarquinen/opencode-dynamic-context-pruning +is retained. diff --git a/dcp.example.jsonc b/dcp.example.jsonc index 9732e7b97..adf3072e6 100644 --- a/dcp.example.jsonc +++ b/dcp.example.jsonc @@ -2,44 +2,40 @@ // Reference only: copy desired settings to ~/.config/opencode/dcp.jsonc or // /.opencode/dcp.jsonc. This example is not loaded automatically. // Project values override global values; protected-tool lists are additive. - "$schema": "https://raw.githubusercontent.com/Opencode-DCP/opencode-dynamic-context-pruning/master/dcp.schema.json", + "$schema": "https://raw.githubusercontent.com/mathewbarnett/opencode-dynamic-context-pruning/master/dcp.schema.json", // Enable the plugin. Defaults are shown throughout this file. "enabled": true, - // V1 npm auto-update setting; the V2 implementation does not run it. - "autoUpdate": true, // Write diagnostic information to the DCP log directory. "debug": false, // Notification verbosity: "off", "minimal", or "detailed". - // V2 currently logs reports rather than showing chat/toast notifications. + // Notifications are delivered as toasts. "pruneNotification": "detailed", - // Notification destination: "chat" or "toast" (V2 limitation above). - "pruneNotificationType": "chat", "commands": { // Enable the /dcp panel and commands. "enabled": true, // Additional tools protected from command-based pruning; supports * and ?. // Example: ["mcp_*", "my_tool_?"] - "protectedTools": [] + "protectedTools": [], }, "manualMode": { // Start new sessions in manual mode; automatic compression is disabled. "enabled": false, // Keep automatic cleanup strategies available while in manual mode. - "automaticStrategies": true + "automaticStrategies": true, }, "turnProtection": { // Protect recent tool outputs from pruning. "enabled": false, // Number of recent turns to protect (at least 1). - "turns": 4 + "turns": 4, }, "experimental": { // Allow processing and compression in subagent sessions. "allowSubAgents": false, // Enable prompt files in dcp-prompts override directories. - "customPrompts": false + "customPrompts": false, }, // File path glob patterns whose matching tool calls should be protected. // Example: ["**/AGENTS.md", "**/*.config.ts"] @@ -48,10 +44,10 @@ "compress": { // "range" summarizes spans; experimental "message" summarizes individual messages. "mode": "range", - // "allow" runs without asking; "deny" disables compression. V2 currently - // blocks "ask" instead of displaying a permission prompt. + // "allow" runs without asking; "ask" uses OpenCode's native permission + // prompt; "deny" disables compression. "permission": "allow", - // Include compression summaries in notifications (V2 reports are logged). + // Include compression summaries in notifications. "showCompression": false, // Add active summary tokens to the upper nudge threshold. "summaryBuffer": true, @@ -75,14 +71,14 @@ // Preserve content enclosed in ... tags. "protectTags": false, // Preserve user messages verbatim; large pasted messages then remain large. - "protectUserMessages": false + "protectUserMessages": false, }, "strategies": { "deduplication": { // Remove older duplicate outputs for identical tool calls. "enabled": true, // Additional tool names/globs excluded from deduplication. - "protectedTools": [] + "protectedTools": [], }, "purgeErrors": { // Prune inputs of old failed calls; retain their error messages. @@ -90,7 +86,7 @@ // Wait this many turns before pruning failed tool inputs (minimum 1). "turns": 4, // Additional tool names/globs excluded from error purging. - "protectedTools": [] - } - } + "protectedTools": [], + }, + }, } diff --git a/dcp.schema.json b/dcp.schema.json index b62546925..d67e15c0b 100644 --- a/dcp.schema.json +++ b/dcp.schema.json @@ -16,11 +16,6 @@ "default": true, "description": "Enable or disable the DCP plugin" }, - "autoUpdate": { - "type": "boolean", - "default": true, - "description": "Automatically update npm-installed DCP when a newer npm latest version is available. Version-locked plugin specs are not updated." - }, "debug": { "type": "boolean", "default": false, @@ -32,12 +27,6 @@ "default": "detailed", "description": "Level of notification shown when context management occurs" }, - "pruneNotificationType": { - "type": "string", - "enum": ["chat", "toast"], - "default": "chat", - "description": "Where to display notifications (chat message or toast notification)" - }, "commands": { "type": "object", "description": "Configuration for DCP slash commands (/dcp)", diff --git a/index.ts b/index.ts index 02216b33b..39baf7f23 100644 --- a/index.ts +++ b/index.ts @@ -1,138 +1,4 @@ -import type { Plugin } from "@opencode-ai/plugin" -import { getConfig } from "./lib/config" -import { createCompressMessageTool, createCompressRangeTool } from "./lib/compress" -import { - compressDisabledByOpencode, - hasExplicitToolPermission, - type HostPermissionSnapshot, -} from "./lib/host-permissions" -import { Logger } from "./lib/logger" -import { createSessionState } from "./lib/state" -import { PromptStore } from "./lib/prompts/store" -import { - createChatMessageTransformHandler, - createCommandExecuteHandler, - createEventHandler, - createSystemPromptHandler, - createTextCompleteHandler, -} from "./lib/hooks" -import { configureClientAuth, isSecureMode } from "./lib/auth" -import { startAutoUpdate } from "./lib/update" -import { setup } from "./lib/v2" +import type { Plugin } from "@opencode/plugin" +import { setup } from "./lib/native/plugin" -const server: Plugin = (async (ctx) => { - const config = getConfig(ctx) - - if (!config.enabled) { - return {} - } - - const logger = new Logger(config.debug) - const state = createSessionState() - const prompts = new PromptStore(logger, ctx.directory, config.experimental.customPrompts) - const hostPermissions: HostPermissionSnapshot = { - global: undefined, - agents: {}, - } - - if (isSecureMode()) { - configureClientAuth(ctx.client) - // logger.info("Secure mode detected, configured client authentication") - } - - logger.info("DCP initialized", { - strategies: config.strategies, - }) - - startAutoUpdate(ctx, config.autoUpdate) - - const compressToolContext = { - client: ctx.client, - state, - logger, - config, - prompts, - } - - return { - "experimental.chat.system.transform": createSystemPromptHandler( - state, - logger, - config, - prompts, - ), - "experimental.chat.messages.transform": createChatMessageTransformHandler( - ctx.client, - state, - logger, - config, - prompts, - hostPermissions, - ) as any, - "experimental.text.complete": createTextCompleteHandler(), - "command.execute.before": createCommandExecuteHandler( - ctx.client, - state, - logger, - config, - ctx.directory, - hostPermissions, - ), - event: createEventHandler(state, logger), - tool: { - ...(config.compress.permission !== "deny" && { - compress: - config.compress.mode === "message" - ? createCompressMessageTool(compressToolContext) - : createCompressRangeTool(compressToolContext), - }), - }, - config: async (opencodeConfig) => { - if ( - config.compress.permission !== "deny" && - compressDisabledByOpencode(opencodeConfig.permission) - ) { - config.compress.permission = "deny" - } - - if (config.commands.enabled && config.compress.permission !== "deny") { - opencodeConfig.command ??= {} - opencodeConfig.command["dcp-compress"] = { - template: "", - description: "Trigger DCP manual compression with: /dcp-compress [focus]", - } - } - - const toolsToAdd: string[] = [] - if (config.compress.permission !== "deny" && !config.experimental.allowSubAgents) { - toolsToAdd.push("compress") - } - - if (toolsToAdd.length > 0) { - const existingPrimaryTools = opencodeConfig.experimental?.primary_tools ?? [] - opencodeConfig.experimental = { - ...opencodeConfig.experimental, - primary_tools: [...existingPrimaryTools, ...toolsToAdd], - } - } - - if (!hasExplicitToolPermission(opencodeConfig.permission, "compress")) { - const permission = opencodeConfig.permission ?? {} - opencodeConfig.permission = { - ...permission, - compress: config.compress.permission, - } as typeof permission - } - - hostPermissions.global = opencodeConfig.permission - hostPermissions.agents = Object.fromEntries( - Object.entries(opencodeConfig.agent ?? {}).map(([name, agent]) => [ - name, - agent?.permission, - ]), - ) - }, - } -}) satisfies Plugin - -export default { id: "opencode-dcp", setup, server } +export default { id: "opencode-dcp", setup } satisfies Plugin.Plugin diff --git a/lib/auth.ts b/lib/auth.ts deleted file mode 100644 index 8b7aa418e..000000000 --- a/lib/auth.ts +++ /dev/null @@ -1,37 +0,0 @@ -export function isSecureMode(): boolean { - return !!process.env.OPENCODE_SERVER_PASSWORD -} - -export function getAuthorizationHeader(): string | undefined { - const password = process.env.OPENCODE_SERVER_PASSWORD - if (!password) return undefined - - const username = process.env.OPENCODE_SERVER_USERNAME ?? "opencode" - // Use Buffer for Node.js base64 encoding (btoa may not be available in all Node versions) - const credentials = Buffer.from(`${username}:${password}`).toString("base64") - return `Basic ${credentials}` -} - -export function configureClientAuth(client: any): any { - const authHeader = getAuthorizationHeader() - - if (!authHeader) { - return client - } - - // The SDK client has an internal client with request interceptors - // Access the underlying client to add the interceptor - const innerClient = client._client || client.client - - if (innerClient?.interceptors?.request) { - innerClient.interceptors.request.use((request: Request) => { - // Only add auth header if not already present - if (!request.headers.has("Authorization")) { - request.headers.set("Authorization", authHeader) - } - return request - }) - } - - return client -} diff --git a/lib/commands/context.ts b/lib/commands/context.ts index c191a809f..8a0100f17 100644 --- a/lib/commands/context.ts +++ b/lib/commands/context.ts @@ -47,7 +47,7 @@ import { formatTokenCount } from "../ui/utils" import { isIgnoredUserMessage } from "../messages/query" import { isMessageCompacted } from "../state/utils" import { countTokens, extractCompletedToolOutput, getCurrentParams } from "../token-utils" -import type { AssistantMessage, TextPart, ToolPart } from "@opencode-ai/sdk/v2" +import type { MessageInfo, TextPartLike, ToolPartLike } from "../message-info" export interface ContextCommandContext { client: any @@ -84,14 +84,14 @@ export function analyzeContextTokens(state: SessionState, messages: WithParts[]) total: 0, } - let firstAssistant: AssistantMessage | undefined + let firstAssistant: MessageInfo | undefined for (const msg of messages) { if (msg.info.role === "assistant") { - const assistantInfo = msg.info as AssistantMessage + const assistantInfo = msg.info as MessageInfo if ( - assistantInfo.tokens?.input > 0 || - assistantInfo.tokens?.cache?.read > 0 || - assistantInfo.tokens?.cache?.write > 0 + (assistantInfo.tokens?.input ?? 0) > 0 || + (assistantInfo.tokens?.cache?.read ?? 0) > 0 || + (assistantInfo.tokens?.cache?.write ?? 0) > 0 ) { firstAssistant = assistantInfo break @@ -99,12 +99,12 @@ export function analyzeContextTokens(state: SessionState, messages: WithParts[]) } } - let lastAssistant: AssistantMessage | undefined + let lastAssistant: MessageInfo | undefined for (let i = messages.length - 1; i >= 0; i--) { const msg = messages[i] if (msg.info.role === "assistant") { - const assistantInfo = msg.info as AssistantMessage - if (assistantInfo.tokens?.output > 0) { + const assistantInfo = msg.info as MessageInfo + if ((assistantInfo.tokens?.output ?? 0) > 0) { lastAssistant = assistantInfo break } @@ -138,7 +138,7 @@ export function analyzeContextTokens(state: SessionState, messages: WithParts[]) for (const part of parts) { if (part.type === "tool") { - const toolPart = part as ToolPart + const toolPart = part as ToolPartLike if (toolPart.callID) { allToolIds.add(toolPart.callID) if (!isCompacted) { @@ -170,7 +170,7 @@ export function analyzeContextTokens(state: SessionState, messages: WithParts[]) !isCompacted && !isIgnoredUser ) { - const textPart = part as TextPart + const textPart = part as TextPartLike const text = textPart.text || "" userTextParts.push(text) if (!foundFirstUser) { diff --git a/lib/compress/index.ts b/lib/compress/index.ts index bdb7f2eb2..347887a43 100644 --- a/lib/compress/index.ts +++ b/lib/compress/index.ts @@ -1,3 +1,3 @@ -export { ToolContext } from "./types" +export type { ToolContext } from "./types" export { createCompressMessageTool } from "./message" export { createCompressRangeTool } from "./range" diff --git a/lib/compress/message-utils.ts b/lib/compress/message-utils.ts index 03330c16b..5259bc75a 100644 --- a/lib/compress/message-utils.ts +++ b/lib/compress/message-utils.ts @@ -160,10 +160,6 @@ export function resolveMessages( for (const entry of args.content) { const normalizedMessageId = entry.messageId.trim() - if (seenMessageIds.has(normalizedMessageId)) { - issues.push({ kind: "duplicate", messageId: normalizedMessageId }) - continue - } try { const plan = resolveMessage( @@ -175,6 +171,14 @@ export function resolveMessages( state, config, ) + // The canonical ref may differ from the trimmed input (parseBoundaryId + // lowercases refs), so dedupe on the canonical form — not the raw text. + // Otherwise "M0001" and "m0001" both pass the check and produce two + // blocks for one message, silently losing one summary. + if (seenMessageIds.has(plan.entry.messageId)) { + issues.push({ kind: "duplicate", messageId: plan.entry.messageId }) + continue + } seenMessageIds.add(plan.entry.messageId) plans.push(plan) } catch (error: any) { diff --git a/lib/compress/message.ts b/lib/compress/message.ts index 433acc1f3..4778d9cf6 100644 --- a/lib/compress/message.ts +++ b/lib/compress/message.ts @@ -1,4 +1,4 @@ -import { tool } from "@opencode-ai/plugin" +import { defineTool, schema, type ToolDefinition } from "../tool-schema" import type { ToolContext } from "./types" import { countTokens } from "../token-utils" import { messageFormat } from "../prompts/extensions/tool" @@ -15,37 +15,31 @@ import { import type { CompressMessageToolArgs } from "./types" function buildSchema(format: IdFormat) { - return { - topic: tool.schema - .string() - .describe( + return schema.object( + { + topic: schema.string( "Short label (3-5 words) for the overall batch - e.g., 'Closed Research Notes'", ), - content: tool.schema - .array( - tool.schema.object({ - messageId: tool.schema - .string() - .describe( - `Raw message ID to compress (e.g. ${formatMessageRef(1, format)})`, - ), - topic: tool.schema - .string() - .describe("Short label (3-5 words) for this one message summary"), - summary: tool.schema - .string() - .describe("Complete technical summary replacing that one message"), + content: schema.array( + schema.object({ + messageId: schema.string( + `Raw message ID to compress (e.g. ${formatMessageRef(1, format)})`, + ), + topic: schema.string("Short label (3-5 words) for this one message summary"), + summary: schema.string("Complete technical summary replacing that one message"), }), - ) - .describe("Batch of individual message summaries to create in one tool call"), - } + "Batch of individual message summaries to create in one tool call", + ), + }, + "Batch of individual message summaries to create in one tool call", + ) } -export function createCompressMessageTool(ctx: ToolContext): ReturnType { +export function createCompressMessageTool(ctx: ToolContext): ToolDefinition { ctx.prompts.reload() const runtimePrompts = ctx.prompts.getRuntimePrompts() - return tool({ + return defineTool({ description: runtimePrompts.compressMessage + messageFormat(ctx.state.idFormat), args: buildSchema(ctx.state.idFormat), async execute(args, toolCtx) { diff --git a/lib/compress/protected-content.ts b/lib/compress/protected-content.ts index c6d3e7ae5..b09833564 100644 --- a/lib/compress/protected-content.ts +++ b/lib/compress/protected-content.ts @@ -35,7 +35,6 @@ export function appendProtectedUserMessages( for (const part of parts) { if (part.type === "text" && typeof part.text === "string" && part.text.trim()) { userTexts.push(part.text) - break } } } @@ -187,7 +186,20 @@ export async function appendProtectedTools( } if (output) { - protectedOutputs.push(`\n### ${title}\n${output}`) + // Preserve the tool input alongside the output so the exact + // change/command is kept, not just its result. + let inputText = "" + if (part.state?.input !== undefined) { + inputText = + typeof part.state.input === "string" + ? part.state.input + : JSON.stringify(part.state.input) + } + protectedOutputs.push( + `\n### ${title}${ + inputText ? `\nInput:\n${inputText}` : "" + }\nOutput:\n${output}`, + ) } } } diff --git a/lib/compress/range.ts b/lib/compress/range.ts index 67cfb0fa0..8c0a16cf8 100644 --- a/lib/compress/range.ts +++ b/lib/compress/range.ts @@ -1,4 +1,4 @@ -import { tool } from "@opencode-ai/plugin" +import { defineTool, schema, type ToolDefinition } from "../tool-schema" import type { ToolContext } from "./types" import { countTokens } from "../token-utils" import { rangeFormat } from "../prompts/extensions/tool" @@ -28,39 +28,35 @@ import { import type { CompressRangeToolArgs } from "./types" function buildSchema(format: IdFormat) { - return { - topic: tool.schema - .string() - .describe("Short label (3-5 words) for display - e.g., 'Auth System Exploration'"), - content: tool.schema - .array( - tool.schema.object({ - startId: tool.schema - .string() - .describe( - `Message or block ID marking the beginning of range (e.g. ${formatMessageRef(1, format)}, ${formatBlockRef(2, format)})`, - ), - endId: tool.schema - .string() - .describe( - `Message or block ID marking the end of range (e.g. ${formatMessageRef(12, format)}, ${formatBlockRef(5, format)})`, - ), - summary: tool.schema - .string() - .describe("Complete technical summary replacing all content in range"), + return schema.object( + { + topic: schema.string( + "Short label (3-5 words) for display - e.g., 'Auth System Exploration'", + ), + content: schema.array( + schema.object({ + startId: schema.string( + `Message or block ID marking the beginning of range (e.g. ${formatMessageRef(1, format)}, ${formatBlockRef(2, format)})`, + ), + endId: schema.string( + `Message or block ID marking the end of range (e.g. ${formatMessageRef(12, format)}, ${formatBlockRef(5, format)})`, + ), + summary: schema.string( + "Complete technical summary replacing all content in range", + ), }), - ) - .describe( "One or more ranges to compress, each with start/end boundaries and a summary", ), - } + }, + "One or more ranges to compress, each with start/end boundaries and a summary", + ) } -export function createCompressRangeTool(ctx: ToolContext): ReturnType { +export function createCompressRangeTool(ctx: ToolContext): ToolDefinition { ctx.prompts.reload() const runtimePrompts = ctx.prompts.getRuntimePrompts() - return tool({ + return defineTool({ description: runtimePrompts.compressRange + rangeFormat(ctx.state.idFormat), args: buildSchema(ctx.state.idFormat), async execute(args, toolCtx) { diff --git a/lib/config.ts b/lib/config.ts index 792b7ca3c..5669cd966 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -1,10 +1,9 @@ -import { readFileSync, writeFileSync, existsSync, mkdirSync, statSync } from "fs" +import { readFileSync, existsSync, statSync } from "fs" import { join, dirname } from "path" import { homedir } from "os" -import { parse } from "jsonc-parser/lib/esm/main.js" -import type { PluginInput } from "@opencode-ai/plugin" - -type ConfigContext = Pick & { +import { parse } from "jsonc-parser" +type ConfigContext = { + directory: string client: { tui: { showToast(input: { @@ -67,10 +66,8 @@ export interface ExperimentalConfig { export interface PluginConfig { enabled: boolean - autoUpdate: boolean debug: boolean pruneNotification: "off" | "minimal" | "detailed" - pruneNotificationType: "chat" | "toast" commands: Commands manualMode: ManualModeConfig turnProtection: TurnProtection @@ -103,11 +100,8 @@ const COMPRESS_DEFAULT_PROTECTED_TOOLS = ["task", "skill", "todowrite", "todorea export const VALID_CONFIG_KEYS = new Set([ "$schema", "enabled", - "autoUpdate", "debug", - "showUpdateToasts", "pruneNotification", - "pruneNotificationType", "turnProtection", "turnProtection.enabled", "turnProtection.turns", @@ -182,10 +176,6 @@ export function validateConfigTypes(config: Record): ValidationErro errors.push({ key: "enabled", expected: "boolean", actual: typeof config.enabled }) } - if (config.autoUpdate !== undefined && typeof config.autoUpdate !== "boolean") { - errors.push({ key: "autoUpdate", expected: "boolean", actual: typeof config.autoUpdate }) - } - if (config.debug !== undefined && typeof config.debug !== "boolean") { errors.push({ key: "debug", expected: "boolean", actual: typeof config.debug }) } @@ -201,17 +191,6 @@ export function validateConfigTypes(config: Record): ValidationErro } } - if (config.pruneNotificationType !== undefined) { - const validValues = ["chat", "toast"] - if (!validValues.includes(config.pruneNotificationType)) { - errors.push({ - key: "pruneNotificationType", - expected: '"chat" | "toast"', - actual: JSON.stringify(config.pruneNotificationType), - }) - } - } - if (config.protectedFilePatterns !== undefined) { if (!Array.isArray(config.protectedFilePatterns)) { errors.push({ @@ -469,8 +448,9 @@ export function validateConfigTypes(config: Record): ValidationErro value: unknown, actualValue: unknown = value, ): void => { - const isValidNumber = typeof value === "number" - const isPercentString = typeof value === "string" && value.endsWith("%") + const isValidNumber = + typeof value === "number" && Number.isFinite(value) && value >= 0 + const isPercentString = typeof value === "string" && /^\d+(?:\.\d+)?%$/.test(value) if (!isValidNumber && !isPercentString) { errors.push({ @@ -499,7 +479,8 @@ export function validateConfigTypes(config: Record): ValidationErro } for (const [providerModelKey, limit] of Object.entries(limits)) { - const isValidNumber = typeof limit === "number" + const isValidNumber = + typeof limit === "number" && Number.isFinite(limit) && limit >= 0 const isPercentString = typeof limit === "string" && /^\d+(?:\.\d+)?%$/.test(limit) if (!isValidNumber && !isPercentString) { @@ -665,10 +646,8 @@ function showConfigWarnings( const defaultConfig: PluginConfig = { enabled: true, - autoUpdate: true, debug: false, pruneNotification: "detailed", - pruneNotificationType: "chat", commands: { enabled: true, protectedTools: [...DEFAULT_PROTECTED_TOOLS], @@ -775,18 +754,6 @@ function getConfigPaths(ctx?: ConfigContext): { return { global, configDir, project } } -function createDefaultConfig(): void { - if (!existsSync(GLOBAL_CONFIG_DIR)) { - mkdirSync(GLOBAL_CONFIG_DIR, { recursive: true }) - } - - const configContent = `{ - "$schema": "https://raw.githubusercontent.com/Opencode-DCP/opencode-dynamic-context-pruning/master/dcp.schema.json" -} -` - writeFileSync(GLOBAL_CONFIG_PATH_JSONC, configContent, "utf-8") -} - interface ConfigLoadResult { data: Record | null parseError?: string @@ -942,10 +909,8 @@ function deepCloneConfig(config: PluginConfig): PluginConfig { function mergeLayer(config: PluginConfig, data: Record): PluginConfig { return { enabled: data.enabled ?? config.enabled, - autoUpdate: data.autoUpdate ?? config.autoUpdate, debug: data.debug ?? config.debug, pruneNotification: data.pruneNotification ?? config.pruneNotification, - pruneNotificationType: data.pruneNotificationType ?? config.pruneNotificationType, commands: mergeCommands(config.commands, data.commands as any), manualMode: mergeManualMode(config.manualMode, data.manualMode as any), turnProtection: { @@ -980,10 +945,6 @@ export function getConfig(ctx: ConfigContext): PluginConfig { let config = deepCloneConfig(defaultConfig) const configPaths = getConfigPaths(ctx) - if (!configPaths.global) { - createDefaultConfig() - } - const layers: Array<{ path: string | null; name: string; isProject: boolean }> = [ { path: configPaths.global, name: "config", isProject: false }, { path: configPaths.configDir, name: "configDir config", isProject: true }, diff --git a/lib/message-info.ts b/lib/message-info.ts new file mode 100644 index 000000000..12186e64e --- /dev/null +++ b/lib/message-info.ts @@ -0,0 +1,58 @@ +/** + * Structural message/part types used by the shared pruning engine. + * + * The engine works against a small, stable subset of OpenCode's session message + * shapes. Keeping that subset local avoids depending on any V1 SDK types and + * lets the OC2 layer provide messages that satisfy it directly. + */ +export interface TokenInfo { + input?: number + output?: number + reasoning?: number + cache?: { read?: number; write?: number } +} + +export interface MessageInfo { + id: string + sessionID: string + role: "user" | "assistant" | "system" | "tool" + time: { created: number } + agent?: string + model: { providerID: string; modelID: string; variant?: string } + providerID?: string + modelID?: string + tokens: TokenInfo + summary?: boolean + [key: string]: unknown +} + +export interface TextPartLike { + type: "text" + text: string + [key: string]: unknown +} + +export interface ToolStateLike { + status: "pending" | "running" | "completed" | "error" + input?: any + output?: any + error?: any + metadata?: Record + time?: { start?: number; end?: number; completed?: number } + title?: string + [key: string]: unknown +} + +export interface ToolPartLike { + type: "tool" + callID: string + tool: string + state: ToolStateLike + [key: string]: unknown +} + +// The engine inspects many part variants (text, tool, step-start, file, ...) +// and its helpers already narrow by `type`. Keep this permissive until the +// native OC2 message model lands in Phase 2. +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export type PartLike = any diff --git a/lib/messages/inject/utils.ts b/lib/messages/inject/utils.ts index 6d35e4c55..b682a01bb 100644 --- a/lib/messages/inject/utils.ts +++ b/lib/messages/inject/utils.ts @@ -6,7 +6,7 @@ import { renderMessagePriorityGuidance, } from "../../prompts/extensions/nudge" import type { RuntimePrompts } from "../../prompts/store" -import type { UserMessage } from "@opencode-ai/sdk/v2" +import type { MessageInfo } from "../../message-info" import { type CompressionPriorityMap, type MessagePriority, @@ -35,11 +35,13 @@ export interface LastNonIgnoredMessage { } export function getNudgeFrequency(config: PluginConfig): number { - return Math.max(1, Math.floor(config.compress.nudgeFrequency || 1)) + const value = Number(config.compress.nudgeFrequency) + return Number.isFinite(value) ? Math.max(1, Math.floor(value)) : 1 } export function getIterationNudgeThreshold(config: PluginConfig): number { - return Math.max(1, Math.floor(config.compress.iterationNudgeThreshold || 1)) + const value = Number(config.compress.iterationNudgeThreshold) + return Number.isFinite(value) ? Math.max(1, Math.floor(value)) : 1 } export function findLastNonIgnoredMessage(messages: WithParts[]): LastNonIgnoredMessage | null { @@ -77,7 +79,7 @@ export function getModelInfo(messages: WithParts[]): LastUserModelContext { } } - const userInfo = lastUserMessage.info as UserMessage + const userInfo = lastUserMessage.info as MessageInfo return { providerId: userInfo.model.providerID, modelId: userInfo.model.modelID, @@ -97,7 +99,7 @@ function resolveContextTokenLimit( } if (typeof limit === "number") { - return limit + return Number.isFinite(limit) && limit >= 0 ? limit : undefined } if (!limit.endsWith("%") || state.modelContextLimit === undefined) { diff --git a/lib/messages/prune.ts b/lib/messages/prune.ts index dc3945243..95096bd5b 100644 --- a/lib/messages/prune.ts +++ b/lib/messages/prune.ts @@ -4,7 +4,7 @@ import type { PluginConfig } from "../config" import { isMessageCompacted } from "../state/utils" import { createSyntheticUserMessage, replaceBlockIdsWithBlocked } from "./utils" import { getLastUserMessage } from "./query" -import type { UserMessage } from "@opencode-ai/sdk/v2" +import type { MessageInfo } from "../message-info" import { formatBlockRef } from "../message-ids" const PRUNED_TOOL_OUTPUT_REPLACEMENT = @@ -20,58 +20,11 @@ export const prune = ( summaryBase?: WithParts, ): void => { filterCompressedRanges(state, logger, config, messages, summaryBase) - // pruneFullTool(state, logger, messages) pruneToolOutputs(state, logger, messages) pruneToolInputs(state, logger, messages) pruneToolErrors(state, logger, messages) } -const pruneFullTool = (state: SessionState, logger: Logger, messages: WithParts[]): void => { - const messagesToRemove: string[] = [] - - for (const msg of messages) { - if (isMessageCompacted(state, msg)) { - continue - } - - const parts = Array.isArray(msg.parts) ? msg.parts : [] - const partsToRemove: string[] = [] - - for (const part of parts) { - if (part.type !== "tool") { - continue - } - - if (!state.prune.tools.has(part.callID)) { - continue - } - if (part.tool !== "edit" && part.tool !== "write") { - continue - } - - partsToRemove.push(part.callID) - } - - if (partsToRemove.length === 0) { - continue - } - - msg.parts = parts.filter( - (part) => part.type !== "tool" || !partsToRemove.includes(part.callID), - ) - - if (msg.parts.length === 0) { - messagesToRemove.push(msg.info.id) - } - } - - if (messagesToRemove.length > 0) { - const result = messages.filter((msg) => !messagesToRemove.includes(msg.info.id)) - messages.length = 0 - messages.push(...result) - } -} - const pruneToolOutputs = (state: SessionState, logger: Logger, messages: WithParts[]): void => { for (const msg of messages) { if (isMessageCompacted(state, msg)) { @@ -198,7 +151,7 @@ const filterCompressedRanges = ( const userMessage = getLastUserMessage(messages, msgIndex) ?? summaryBase if (userMessage) { - const userInfo = userMessage.info as UserMessage + const userInfo = userMessage.info as MessageInfo // Persisted summaries can outlive the host's tag format. let renderedSummary = rawSummaryContent if (state.idFormat === "compact") { diff --git a/lib/messages/sync.ts b/lib/messages/sync.ts index 9eca783b8..cd3056227 100644 --- a/lib/messages/sync.ts +++ b/lib/messages/sync.ts @@ -33,23 +33,9 @@ export const syncCompressionBlocks = ( messagesState.activeByAnchorMessageId.clear() const now = Date.now() - const missingOriginBlockIds: number[] = [] const orderedBlocks = Array.from(messagesState.blocksById.values()).sort(sortBlocksByCreation) for (const block of orderedBlocks) { - const hasOriginMessage = - typeof block.compressMessageId === "string" && - block.compressMessageId.length > 0 && - messageIds.has(block.compressMessageId) - - if (!hasOriginMessage) { - block.active = false - block.deactivatedAt = now - block.deactivatedByBlockId = undefined - missingOriginBlockIds.push(block.blockId) - continue - } - if (block.deactivatedByUser) { block.active = false if (block.deactivatedAt === undefined) { @@ -59,6 +45,11 @@ export const syncCompressionBlocks = ( continue } + // Liveness is driven by explicit deactivation flags (user / consumed-by), + // not by which messages happen to be in the current window. Previously a + // block was deactivated whenever its compress-call origin aged out, which + // un-pruned the original messages while dropping the summary. + for (const consumedBlockId of block.consumedBlockIds) { if (!messagesState.activeBlockIds.has(consumedBlockId)) { continue @@ -87,6 +78,15 @@ export const syncCompressionBlocks = ( messagesState.activeBlockIds.add(block.blockId) if (messageIds.has(block.anchorMessageId)) { messagesState.activeByAnchorMessageId.set(block.anchorMessageId, block.blockId) + } else { + // The anchor left the window: keep the summary in context by attaching + // it to the first still-present message that has no summary yet. + const fallback = messages.find( + (msg) => !messagesState.activeByAnchorMessageId.has(msg.info.id), + ) + if (fallback) { + messagesState.activeByAnchorMessageId.set(fallback.info.id, block.blockId) + } } } @@ -114,9 +114,8 @@ export const syncCompressionBlocks = ( } } - if (missingOriginBlockIds.length > 0 || deactivatedCount > 0 || reactivatedCount > 0) { + if (deactivatedCount > 0 || reactivatedCount > 0) { logger.info("Synced compress block state", { - missingOriginCount: missingOriginBlockIds.length, deactivatedCount, reactivatedCount, }) diff --git a/lib/messages/utils.ts b/lib/messages/utils.ts index 004de9a5a..e3cf5a223 100644 --- a/lib/messages/utils.ts +++ b/lib/messages/utils.ts @@ -1,7 +1,7 @@ import { createHash } from "node:crypto" import type { SessionState, WithParts } from "../state" import { isMessageCompacted } from "../state/utils" -import type { UserMessage } from "@opencode-ai/sdk/v2" +import type { MessageInfo } from "../message-info" import type { IdFormat } from "../message-ids" const SUMMARY_ID_HASH_LENGTH = 16 @@ -22,7 +22,7 @@ export const createSyntheticUserMessage = ( content: string, stableSeed?: string, ): WithParts => { - const userInfo = baseMessage.info as UserMessage + const userInfo = baseMessage.info as MessageInfo const now = Date.now() const deterministicSeed = stableSeed?.trim() || userInfo.id const messageId = generateStableId("msg_dcp_summary", deterministicSeed) @@ -35,6 +35,7 @@ export const createSyntheticUserMessage = ( role: "user" as const, agent: userInfo.agent, model: userInfo.model, + tokens: userInfo.tokens, time: { created: now }, }, parts: [ @@ -54,7 +55,7 @@ export const createSyntheticTextPart = ( content: string, stableSeed?: string, ) => { - const userInfo = baseMessage.info as UserMessage + const userInfo = baseMessage.info as MessageInfo const deterministicSeed = stableSeed?.trim() || userInfo.id const partId = generateStableId("prt_dcp_text", deterministicSeed) diff --git a/lib/native/commands.ts b/lib/native/commands.ts new file mode 100644 index 000000000..0a8d53761 --- /dev/null +++ b/lib/native/commands.ts @@ -0,0 +1,80 @@ +import type { PluginConfig } from "../config" +import type { Logger } from "../logger" +import type { SessionState } from "../state" +import { compressPermission } from "../compress-permission" +import { + handleContextCommand, + handleDecompressCommand, + handleHelpCommand, + handleManualToggleCommand, + handleManualTriggerCommand, + handleRecompressCommand, + handleStatsCommand, + handleSweepCommand, +} from "../commands" +import type { WithParts } from "../state" + +export interface NativeCommandDeps { + client: any + state: SessionState + logger: Logger + config: PluginConfig + workingDirectory: string + sessionID: string + text: string + messages: WithParts[] +} + +/** + * Dispatch a native `/dcp …` invocation directly through the shared command + * handlers. Returns the trigger prompt when `compress`/`dcp-compress` staged a + * manual compression, so the caller can deliver it via `ctx.session.prompt`. + */ +export async function executeNativeCommand(deps: NativeCommandDeps): Promise { + const { client, state, logger, config, workingDirectory, sessionID, messages } = deps + if (!config.commands.enabled) return null + + if (compressPermission(state, config) === "deny") return null + + const args = (deps.text || "").trim().split(/\s+/).filter(Boolean) + const subcommand = args[0]?.toLowerCase() ?? "" + const subArgs = args.slice(1) + + const commandCtx = { client, state, config, logger, sessionId: sessionID, messages } + + if (subcommand === "context") { + await handleContextCommand(commandCtx) + return null + } + if (subcommand === "stats") { + await handleStatsCommand(commandCtx) + return null + } + if (subcommand === "sweep") { + await handleSweepCommand({ ...commandCtx, args: subArgs, workingDirectory }) + return null + } + if (subcommand === "manual") { + await handleManualToggleCommand(commandCtx, subArgs[0]?.toLowerCase()) + return null + } + if (subcommand === "compress") { + const userFocus = subArgs.join(" ").trim() + const prompt = await handleManualTriggerCommand(commandCtx, "compress", userFocus) + if (!prompt) return null + state.manualMode = "compress-pending" + state.pendingManualTrigger = { sessionId: sessionID, prompt } + return prompt + } + if (subcommand === "decompress") { + await handleDecompressCommand({ ...commandCtx, args: subArgs }) + return null + } + if (subcommand === "recompress") { + await handleRecompressCommand({ ...commandCtx, args: subArgs }) + return null + } + + await handleHelpCommand(commandCtx) + return null +} diff --git a/lib/v2/messages.ts b/lib/native/messages.ts similarity index 74% rename from lib/v2/messages.ts rename to lib/native/messages.ts index 62f0c737c..b912f0cb4 100644 --- a/lib/v2/messages.ts +++ b/lib/native/messages.ts @@ -1,33 +1,49 @@ -import type { Message, ContentPart, ToolResultPart } from "@opencode/ai/schema/messages" +import type { Message, ContentPart, ToolResultPart } from "@opencode/ai" import type { Plugin } from "@opencode/plugin" import type { WithParts } from "../state" type History = Awaited> type Session = Awaited> +type Entry = History[number] type Part = WithParts["parts"][number] -const emptyUsage = { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } } - -function info(id: string, role: string, session: Session, entry?: History[number]) { - const model = entry?.type === "assistant" ? entry.model : session.model +/** + * Build engine metadata from a real stored session entry. Returns undefined when + * the entry is missing or lacks the fields the shared engine requires. We never + * synthesize timestamps, token counts, model identity, or message IDs here: + * fabricated values previously fed compaction detection and nudge thresholds + * with data that did not exist in the session. + */ +function info( + entry: Entry | undefined, + session: Session, + role: string, +): WithParts["info"] | undefined { + if (!entry || typeof entry.time?.created !== "number") return undefined + const model = entry.type === "assistant" ? entry.model : session.model return { - id, + id: entry.id, role, sessionID: session.id, - time: { created: entry?.time.created ?? 0 }, - agent: entry?.type === "assistant" ? entry.agent : session.agent, - model: { providerID: model?.providerID, modelID: model?.id, variant: model?.variant }, + time: { created: entry.time.created }, + agent: entry.type === "assistant" ? entry.agent : session.agent, + model: model + ? { providerID: model.providerID, modelID: model.id, variant: model.variant } + : undefined, providerID: model?.providerID, modelID: model?.id, - tokens: entry?.type === "assistant" ? (entry.tokens ?? emptyUsage) : emptyUsage, - summary: entry?.type === "compaction" && entry.status === "completed", + tokens: entry.type === "assistant" ? entry.tokens : undefined, + summary: entry.type === "compaction" && entry.status === "completed", } as unknown as WithParts["info"] } -// Bookkeeping projections are never sent to a provider. Native messages remain -// authoritative for reasoning, media, checkpoints, and provider metadata. +/** Project stored entries into the engine's working shape for the compress tool. */ export function history(entries: History, session: Session): WithParts[] { return entries.flatMap((entry): WithParts[] => { + const role = + entry.type === "assistant" || entry.type === "compaction" ? "assistant" : "user" + const meta = info(entry, session, role) + if (!meta) return [] const base = { sessionID: session.id, messageID: entry.id } if (entry.type === "assistant") { const parts = entry.content.map((part, index) => { @@ -49,7 +65,7 @@ export function history(entries: History, session: Session): WithParts[] { }) return [ { - info: info(entry.id, "assistant", session, entry), + info: meta, parts: [{ ...base, id: `${entry.id}:step`, type: "step-start" }, ...parts], } as WithParts, ] @@ -67,17 +83,15 @@ export function history(entries: History, session: Session): WithParts[] { text = `The working directory has been changed to ${entry.location.directory}.` if (entry.type === "shell" && entry.metadata?.background !== true) text = `The following shell command was executed by the user:\n\nCommand:\n${entry.command}\n\nOutput:\n${entry.output?.output ?? ""}` - if (text !== undefined) { + if (text !== undefined) return [ { - info: info(entry.id, "user", session, entry), + info: meta, parts: [{ ...base, id: `${entry.id}:text`, type: "text", text }], } as WithParts, ] - } - if (entry.type === "compaction" && entry.status === "completed") { - return [{ info: info(entry.id, "assistant", session, entry), parts: [] } as WithParts] - } + if (entry.type === "compaction" && entry.status === "completed") + return [{ info: meta, parts: [] } as WithParts] return [] }) } @@ -88,7 +102,12 @@ function output(content: ReadonlyArray<{ type: string; text?: string }>): unknow : structuredClone(content) } -export function project(native: Message[], entries: History, session: Session) { +/** + * Build an editable view of the native provider messages. Every field on the + * view comes from a real stored entry; messages without one are left untouched + * (they are passed through verbatim by commit()). + */ +export function view(native: Message[], entries: History, session: Session) { const byID = new Map(entries.map((entry) => [entry.id, entry])) const results = new Map() const owners = new Map() @@ -104,6 +123,8 @@ export function project(native: Message[], entries: History, session: Session) { if (!message.id || !["user", "assistant"].includes(message.role)) continue const entry = byID.get(message.id) if (!entry || entry.type === "compaction") continue + const meta = info(entry, session, message.role) + if (!meta) continue const base = { sessionID: session.id, messageID: message.id } const parts: Part[] = [] if (message.role === "assistant") @@ -112,19 +133,27 @@ export function project(native: Message[], entries: History, session: Session) { let projected: Part | undefined if (part.type === "text") projected = { ...base, id: `${message.id}:${index}`, type: "text", text: part.text } - if (part.type === "media") + if (part.type === "media") { + const legacy = part as typeof part & { + mediaType?: string + data?: string | Uint8Array + } + const asset = part.media projected = { ...base, id: `${message.id}:${index}`, type: "file", - mime: part.mediaType, - url: typeof part.data === "string" ? part.data : "", + mime: asset?.mediaType ?? legacy.mediaType ?? "application/octet-stream", + url: + asset?.inline()?.dataUrl ?? + (asset?.source.type === "url" ? asset.source.url : "") ?? + (typeof legacy.data === "string" ? legacy.data : ""), } + } if (part.type === "tool-call") { const result = results.get(part.id) - const entry = byID.get(message.id) const durable = - entry?.type === "assistant" + entry.type === "assistant" ? entry.content.find((item) => item.type === "tool" && item.id === part.id) : undefined projected = { @@ -162,15 +191,13 @@ export function project(native: Message[], entries: History, session: Session) { links.set(part, projected) } } - const projected = { - info: info(message.id, message.role, session, byID.get(message.id)), - parts, - } as WithParts + const projected = { info: meta, parts } as WithParts messages.push(projected) originals.set(message.id, projected) } - function restore(): Message[] { + /** Write engine edits back onto the native messages, preserving order. */ + function commit(): Message[] { const retained = new Set(messages.map((message) => message.info.id)) const linked = new Set(links.values()) const output: Message[] = [] @@ -184,7 +211,7 @@ export function project(native: Message[], entries: History, session: Session) { content: message.parts .filter((part) => part.type === "text") .map((part) => ({ type: "text", text: part.text })), - }) + } as Message) } } for (const message of native) { @@ -225,13 +252,12 @@ export function project(native: Message[], entries: History, session: Session) { } else content.push(part) } content.push(...added) - if (content.length || message.content.length === 0) output.push({ ...message, content }) + if (content.length || message.content.length === 0) + output.push({ ...message, content } as Message) } synthetic() return output } - // A native checkpoint can replace every user message. Summary construction - // still needs session/agent/model fields, without projecting that checkpoint. - const summaryBase: WithParts = { info: info("msg_dcp_base", "user", session), parts: [] } - return { messages, restore, summaryBase } + + return { messages, commit } } diff --git a/lib/native/notifications.ts b/lib/native/notifications.ts new file mode 100644 index 000000000..e5d9a3145 --- /dev/null +++ b/lib/native/notifications.ts @@ -0,0 +1,128 @@ +import type { NotificationEvent } from "./rpc" + +/** + * All DCP notifications are toasts. The server emits a single RPC event and the + * TUI turns it into `ctx.ui.toast.show(...)`; nothing is ever injected into the + * model's message stream to display a notification. + */ + +const DEDUPE_MS = 1_000 +const BURST_WINDOW_MS = 5_000 +const BURST_LIMIT = 4 + +const VARIANTS = new Set(["info", "success", "warning", "error"]) + +type Emit = (event: NotificationEvent) => Promise + +interface ToastInput { + sessionID?: string + body?: { + title?: string + message?: string + variant?: string + duration?: number + } + title?: string + message?: string + variant?: string + duration?: number +} + +interface PromptInput { + path?: { id?: string } + body?: { parts?: Array<{ text?: string }> } + sessionID?: string + text?: string +} + +export interface ToastSinkOptions { + title?: string + duration?: number +} + +/** + * Adapter for the legacy `client` facade used by the shared engine's notification + * helpers. It converts toast/prompt calls into RPC notification events, with + * duplicate suppression and a per-session burst cap. + */ +export function createNotifier(emit: Emit) { + const last = new Map() + const bursts = new Map() + + async function emitNotification(event: NotificationEvent): Promise { + if (!event.message) return + const key = event.sessionID ?? "global" + const now = Date.now() + const previous = last.get(key) + if (previous?.message === event.message && now - previous.at < DEDUPE_MS) return + + const times = (bursts.get(key) ?? []).filter((time) => now - time < BURST_WINDOW_MS) + if (times.length >= BURST_LIMIT) return + times.push(now) + + last.set(key, { message: event.message, at: now }) + bursts.set(key, times) + await emit(event) + } + + return { + emitNotification, + showToast: async (input: ToastInput): Promise => { + const body = input.body ?? input + if (!body.message) return + await emitNotification({ + title: body.title ?? "DCP", + message: body.message, + variant: VARIANTS.has(body.variant ?? "") + ? (body.variant as NotificationEvent["variant"]) + : "info", + duration: body.duration ?? 5_000, + sessionID: input.sessionID, + }) + }, + prompt: async (input: PromptInput): Promise => { + const text = (input.body?.parts ?? []) + .map((part) => part.text ?? "") + .filter(Boolean) + .join("\n") + if (!text) return + await emitNotification({ + title: "DCP", + message: text, + variant: "info", + duration: 5_000, + sessionID: input.path?.id ?? input.sessionID, + }) + }, + } +} + +export interface ToastLike { + show(options: { + title?: string + message: string + variant?: "info" | "success" | "warning" | "error" + duration?: number + sessionID?: string + }): void +} + +/** TUI-side subscriber: turns notification events into toasts, deduplicated. */ +export function createToastSubscriber(toast: ToastLike) { + const seen = new Map() + return (event: { data: NotificationEvent }): void => { + const data = event.data + if (!data?.message) return + const key = `${data.sessionID ?? "global"}|${data.message}` + const now = Date.now() + if (now - (seen.get(key) ?? 0) < DEDUPE_MS) return + seen.set(key, now) + toast.show({ + title: data.title ?? "DCP", + message: data.message, + variant: data.variant ?? "info", + duration: data.duration ?? 5_000, + sessionID: data.sessionID, + }) + } +} diff --git a/lib/native/permissions.ts b/lib/native/permissions.ts new file mode 100644 index 000000000..f9f093876 --- /dev/null +++ b/lib/native/permissions.ts @@ -0,0 +1,72 @@ +import type { PermissionAction } from "../host-permissions" +import { matchesGlob } from "../protected-patterns" + +export interface NativePermissionRule { + action?: unknown + resource?: unknown + effect?: unknown +} + +export interface ResolvedPermission { + effect: PermissionAction + source: "config" | "host" | "default" +} + +const isAction = (value: unknown): value is PermissionAction => + value === "allow" || value === "deny" || value === "ask" + +const compressRule = (rule: NativePermissionRule): PermissionAction | undefined => { + if ( + typeof rule.action !== "string" || + typeof rule.resource !== "string" || + !isAction(rule.effect) + ) + return undefined + return matchesGlob("compress", rule.action) && matchesGlob("*", rule.resource) + ? rule.effect + : undefined +} + +/** + * Resolve the compress permission from DCP config plus OC2 host rules. + * Host rules are ordered agent-first, session-second; the last matching rule wins. + */ +export function resolveCompressPermission( + configPermission: PermissionAction, + agentRules: readonly NativePermissionRule[] = [], + sessionRules: readonly NativePermissionRule[] = [], +): ResolvedPermission { + if (configPermission === "deny") return { effect: "deny", source: "config" } + + let host: PermissionAction | undefined + for (const rule of [...agentRules, ...sessionRules]) { + const effect = compressRule(rule ?? {}) + if (effect) host = effect + } + if (host === "deny") return { effect: "deny", source: "host" } + if (host === "ask" || configPermission === "ask") + return { effect: "ask", source: host ? "host" : "config" } + if (host === "allow") return { effect: "allow", source: "host" } + return { effect: "allow", source: "default" } +} + +export interface EvaluateEvent { + action: string + effect: PermissionAction + message?: string +} + +/** Apply DCP config to the host's native compress permission evaluation. */ +export function applyCompressEvaluation( + configPermission: PermissionAction, + evaluation: EvaluateEvent, +): void { + if (evaluation.action !== "compress") return + if (configPermission === "deny") { + evaluation.effect = "deny" + evaluation.message = "DCP compression is disabled by configuration" + } else if (configPermission === "ask" && evaluation.effect !== "deny") { + evaluation.effect = "ask" + evaluation.message = "DCP compression requires approval" + } +} diff --git a/lib/native/plugin.ts b/lib/native/plugin.ts new file mode 100644 index 000000000..cde6f3647 --- /dev/null +++ b/lib/native/plugin.ts @@ -0,0 +1,360 @@ +import type { Plugin } from "@opencode/plugin" +import { getConfig } from "../config" +import { Logger } from "../logger" +import { PromptStore } from "../prompts/store" +import { createCompressMessageTool, createCompressRangeTool } from "../compress" +import { attachCompressionDuration } from "../compress/state" +import { + createSessionState, + ensureSessionInitialized, + checkSession, + saveSessionState, + syncToolCache, + type SessionState, +} from "../state" +import { assignMessageRefs } from "../message-ids" +import { applyPendingManualTrigger } from "../commands/manual" +import { + buildPriorityMap, + buildToolIdList, + injectCompressNudges, + injectMessageIds, + injectExtendedSubAgentResults, + prune, + stripHallucinations, + syncCompressionBlocks, +} from "../messages" +import { countTokens } from "../token-utils" +import { history, view } from "./messages" +import { analyzeContextTokens } from "../commands/context" +import { buildStatsReport } from "../commands/stats" +import { rpc, type NotificationEvent } from "./rpc" +import { createNotifier } from "./notifications" +import { applyCompressEvaluation, resolveCompressPermission } from "./permissions" +import { injectNativeSystemPrompt } from "./system-prompt" +import { executeNativeCommand } from "./commands" + +export async function setup(ctx: Plugin.Context) { + const warnings = { + tui: { + showToast: async (input: { body: { message: string } }) => { + console.warn(`DCP: ${input.body.message}`) + }, + }, + } + const config = getConfig({ directory: ctx.location.directory, client: warnings }) + if (!config.enabled) { + await ctx.rpc.register( + { ...rpc, methods: { status: rpc.methods.status } }, + { status: async () => ({ enabled: false }) }, + ) + return + } + const logger = new Logger(config.debug) + const prompts = new PromptStore( + logger, + ctx.location.directory, + config.experimental.customPrompts, + "compact", + ) + const sessions = new Map() + const queues = new Map>() + const limits = new Map() + const registrations: Array<{ dispose(): Promise }> = [] + registrations.push( + await ctx.permission.hook("evaluate", (evaluation) => + applyCompressEvaluation(config.compress.permission, evaluation), + ), + ) + const aliases: Record = { + task: "subagent", + bash: "shell", + apply_patch: "patch", + } + for (const list of [ + config.compress.protectedTools, + config.commands.protectedTools, + config.strategies.deduplication.protectedTools, + config.strategies.purgeErrors.protectedTools, + ]) { + for (const name of [...list]) + if (aliases[name] && !list.includes(aliases[name]!)) list.push(aliases[name]!) + } + + function serial(sessionID: string, operation: () => Promise): Promise { + const pending = (queues.get(sessionID) ?? Promise.resolve()).catch(() => {}).then(operation) + queues.set(sessionID, pending) + void pending + .finally(() => { + if (queues.get(sessionID) === pending) queues.delete(sessionID) + }) + .catch(() => {}) + return pending + } + + let emitNotification: (event: NotificationEvent) => Promise = async () => {} + let emitOpenPanel: () => Promise = async () => {} + const notifier = createNotifier(async (event) => emitNotification(event)) + const client = { + session: { + get: async ({ path }: { path: { id: string } }) => ({ + data: await ctx.session.get({ sessionID: path.id }), + }), + messages: async ({ path }: { path: { id: string } }) => { + const [entries, session] = await Promise.all([ + ctx.session.context({ sessionID: path.id }), + ctx.session.get({ sessionID: path.id }), + ]) + return { data: history(entries, session) } + }, + prompt: notifier.prompt, + }, + tui: { + showToast: notifier.showToast, + }, + } + + async function load(sessionID: string, agentID?: string) { + const [session, entries] = await Promise.all([ + ctx.session.get({ sessionID }), + ctx.session.context({ sessionID }), + ]) + const selected = + agentID ?? + session.agent ?? + entries.findLast((entry) => entry.type === "assistant")?.agent + if (!selected) throw new Error("DCP commands require a session with a selected agent") + const { data: agent } = await ctx.agent.get({ agentID: selected }) + let state = sessions.get(sessionID) + if (!state) { + state = createSessionState("compact") + sessions.set(sessionID, state) + } + const messages = history(entries, session) + await ensureSessionInitialized( + client, + state, + sessionID, + logger, + messages, + config.manualMode.enabled, + ) + await checkSession(client, state, logger, messages, config.manualMode.enabled) + state.compressPermission = resolveCompressPermission( + config.compress.permission, + agent.permissions ?? [], + session.permissions ?? [], + ).effect + return { state, entries, session, messages } + } + + function allowed(state: SessionState) { + if (state.isSubAgent && !config.experimental.allowSubAgents) + throw new Error("DCP compression is disabled in subagents") + if (state.compressPermission === "deny") throw new Error("DCP compression is denied") + } + + registrations.push( + await ctx.model.transform((editor) => { + limits.clear() + for (const model of editor.list()) + limits.set(`${model.providerID}/${model.id}`, model.limit.context) + }), + ) + + for (const kind of ["context", "compaction"] as const) { + const registration = await ctx.session.hook(kind, (event) => + serial(event.sessionID, async () => { + const { state, entries, session, messages } = await load( + event.sessionID, + event.agent, + ) + if (state.isSubAgent && !config.experimental.allowSubAgents) { + delete event.tools.compress + return + } + if (state.compressPermission === "deny") delete event.tools.compress + state.modelContextLimit = + limits.get(`${event.model.providerID}/${event.model.id}`) ?? + state.modelContextLimit ?? + 0 + state.systemPromptTokens = countTokens( + event.system.map((part) => part.text).join("\n"), + ) + const projected = view(event.messages, entries, session) + stripHallucinations(projected.messages, state.idFormat) + assignMessageRefs(state, projected.messages) + // Compaction may select only a prefix; block origins can be in the retained tail. + syncCompressionBlocks(state, logger, messages) + syncToolCache(state, config, logger, projected.messages) + buildToolIdList(state, projected.messages) + prune(state, logger, config, projected.messages) + await injectExtendedSubAgentResults( + client, + state, + logger, + projected.messages, + config.experimental.allowSubAgents, + ) + const priorities = buildPriorityMap(config, state, projected.messages) + prompts.reload() + injectCompressNudges( + state, + config, + logger, + projected.messages, + prompts.getRuntimePrompts(), + priorities, + kind === "context", + ) + injectMessageIds(state, config, projected.messages, priorities) + applyPendingManualTrigger(state, projected.messages, logger) + event.messages = projected.commit() + injectNativeSystemPrompt(state, logger, config, prompts, event.system) + await logger.saveContext(event.sessionID, projected.messages) + }), + ) + registrations.push(registration) + } + + if (config.compress.permission !== "deny") { + const define = (state: SessionState) => + (config.compress.mode === "message" + ? createCompressMessageTool + : createCompressRangeTool)({ client, state, logger, config, prompts }) + const definition = define(createSessionState("compact")) + registrations.push( + await ctx.tool.transform((editor) => + editor.add({ + name: "compress", + description: definition.description, + input: definition.args, + options: { codemode: false, permission: "compress" }, + execute: (input, context) => + serial(context.sessionID, async () => { + const { state } = await load(context.sessionID, context.agent) + allowed(state) + await ctx.permission.assert({ + sessionID: context.sessionID, + agent: context.agent, + action: "compress", + resources: ["*"], + source: { + type: "tool", + messageID: context.messageID, + id: context.id, + }, + metadata: { plugin: "dcp" }, + }) + const started = Date.now() + const executor = define(state) + // The shared core only reads these RunContext fields; build them + // from real native values instead of fabricating a V1 tool context. + const content = await executor.execute(input, { + sessionID: context.sessionID, + messageID: context.messageID, + callID: context.id, + ask: async () => allowed(state), + metadata: ({ title }: { title: string }) => { + void context.progress({ title }) + }, + }) + attachCompressionDuration( + state.prune.messages, + context.messageID, + context.id, + Date.now() - started, + ) + await saveSessionState(state, logger) + return { content } + }), + }), + ), + ) + } + if (config.commands.enabled) + registrations.push( + await ctx.command.transform((editor) => { + for (const name of ["dcp", "dcp-compress"]) + editor.add({ + name, + description: + name === "dcp" ? "DCP commands" : "Trigger DCP manual compression", + execute: async (invocation) => { + if (name === "dcp" && !invocation.prompt.text.trim()) { + await emitOpenPanel() + return + } + const prompt = await serial(invocation.sessionID, async () => { + const { state, messages } = await load(invocation.sessionID) + if ( + name === "dcp-compress" || + invocation.prompt.text.trim().split(/\s+/)[0] === "compress" + ) + allowed(state) + const text = + name === "dcp-compress" + ? `compress ${invocation.prompt.text}`.trim() + : invocation.prompt.text + const triggered = await executeNativeCommand({ + client, + state, + logger, + config, + workingDirectory: ctx.location.directory, + sessionID: invocation.sessionID, + text, + messages, + }) + if (!triggered) return null + allowed(state) + state.pendingManualTrigger = null + return triggered + }) + if (prompt) + await ctx.session.prompt({ + sessionID: invocation.sessionID, + text: prompt, + delivery: invocation.delivery, + }) + }, + }) + }), + ) + const rpcRegistration = await ctx.rpc.register(rpc, { + status: async () => ({ enabled: config.commands.enabled }), + snapshot: ({ sessionID }) => + serial(sessionID, async () => { + const { state, messages } = await load(sessionID) + syncCompressionBlocks(state, logger, messages) + return { + manualMode: !!state.manualMode, + canCompress: + state.compressPermission !== "deny" && + (!state.isSubAgent || config.experimental.allowSubAgents), + ...(state.compressPermission === "ask" + ? { blockedReason: "Compression requires approval" } + : {}), + context: analyzeContextTokens(state, messages), + stats: await buildStatsReport(state, logger), + } + }), + manual: ({ sessionID, enabled }) => + serial(sessionID, async () => { + const { state } = await load(sessionID) + state.manualMode = enabled ? "active" : false + await saveSessionState(state, logger) + return {} + }), + }) + emitNotification = (event) => rpcRegistration.events.emit("notification", event) + emitOpenPanel = () => rpcRegistration.events.emit("openPanel", {}) + registrations.push(rpcRegistration) + logger.info("DCP native initialized") + return async () => { + for (const registration of registrations.splice(0)) await registration.dispose() + sessions.clear() + queues.clear() + limits.clear() + } +} diff --git a/lib/v2/rpc.ts b/lib/native/rpc.ts similarity index 56% rename from lib/v2/rpc.ts rename to lib/native/rpc.ts index 9d579352e..844533df5 100644 --- a/lib/v2/rpc.ts +++ b/lib/native/rpc.ts @@ -1,7 +1,15 @@ -import { tool } from "@opencode-ai/plugin" +import { z } from "zod" + +export const notificationEvent = z.object({ + title: z.string().optional(), + message: z.string(), + variant: z.enum(["info", "success", "warning", "error"]).optional(), + duration: z.number().optional(), + sessionID: z.string().optional(), +}) + +export type NotificationEvent = z.infer -const z = tool.schema -const session = z.object({ sessionID: z.string() }) const stats = z.object({ sessionTokens: z.number(), sessionSummaryTokens: z.number(), @@ -15,6 +23,7 @@ const stats = z.object({ sessionCount: z.number(), }), }) + const context = z.object({ system: z.number(), user: z.number(), @@ -31,9 +40,12 @@ const context = z.object({ export const rpc = { id: "dcp", methods: { - status: { input: z.object({}), output: z.object({ enabled: z.boolean() }) }, + status: { + input: z.object({}), + output: z.object({ enabled: z.boolean() }), + }, snapshot: { - input: session, + input: z.object({ sessionID: z.string() }), output: z.object({ manualMode: z.boolean(), canCompress: z.boolean(), @@ -42,7 +54,13 @@ export const rpc = { stats, }), }, - manual: { input: session.extend({ enabled: z.boolean() }), output: z.object({}) }, + manual: { + input: z.object({ sessionID: z.string(), enabled: z.boolean() }), + output: z.object({}), + }, + }, + events: { + notification: { schema: notificationEvent }, + openPanel: { schema: z.object({}) }, }, - events: {}, } as const diff --git a/lib/native/system-prompt.ts b/lib/native/system-prompt.ts new file mode 100644 index 000000000..628bec0ca --- /dev/null +++ b/lib/native/system-prompt.ts @@ -0,0 +1,58 @@ +import type { SystemPart } from "@opencode/ai" +import type { PluginConfig } from "../config" +import type { Logger } from "../logger" +import type { SessionState } from "../state" +import { compressPermission } from "../compress-permission" +import { renderSystemPrompt, type PromptStore } from "../prompts" +import { buildProtectedToolsExtension } from "../prompts/extensions/system" + +const INTERNAL_AGENT_SIGNATURES = [ + "You are a title generator", + "You are a helpful AI assistant tasked with summarizing conversations", + "You are an anchored context summarization assistant for coding sessions", + "Summarize what was done in this conversation", +] + +function isInternalAgentCall(system: readonly SystemPart[]): boolean { + const primary = system[0] + if (!primary || primary.type !== "text" || !primary.text) return false + return INTERNAL_AGENT_SIGNATURES.some((signature) => primary.text.includes(signature)) +} + +/** + * Native OC2 variant of the system-prompt injection. It edits the real + * `SystemPart[]` in place — appending to the last text part (or pushing a new + * one) — so non-text parts and their cache/metadata fields survive untouched. + */ +export function injectNativeSystemPrompt( + state: SessionState, + logger: Logger, + config: PluginConfig, + prompts: PromptStore, + system: SystemPart[], +): void { + if (state.isSubAgent && !config.experimental.allowSubAgents) return + + if (isInternalAgentCall(system)) { + logger.info("Skipping DCP system prompt injection for internal agent") + return + } + + if (compressPermission(state, config) === "deny") return + + prompts.reload() + const newPrompt = renderSystemPrompt( + prompts.getRuntimePrompts(), + buildProtectedToolsExtension(config.compress.protectedTools), + !!state.manualMode, + state.isSubAgent && config.experimental.allowSubAgents, + ) + + const index = system.length - 1 + const last = system[index] + if (last && last.type === "text") { + system[index] = { ...last, text: last.text + "\n\n" + newPrompt } + } else { + system.push({ type: "text", text: newPrompt }) + } +} diff --git a/lib/v2/theme.ts b/lib/native/theme.ts similarity index 100% rename from lib/v2/theme.ts rename to lib/native/theme.ts diff --git a/lib/v2/tui.tsx b/lib/native/tui.tsx similarity index 82% rename from lib/v2/tui.tsx rename to lib/native/tui.tsx index 76afd9739..68cb301e2 100644 --- a/lib/v2/tui.tsx +++ b/lib/native/tui.tsx @@ -3,6 +3,7 @@ import type { Plugin } from "@opencode/plugin/tui" import { ContextDialog, PanelDialog, StatsDialog, StatusDialog } from "../tui/dialogs" import type { ViewApi } from "../tui/types" import { rpc } from "./rpc" +import { createToastSubscriber } from "./notifications" import { panelTheme } from "./theme" export async function setup(ctx: Plugin.Context) { @@ -80,6 +81,21 @@ export async function setup(ctx: Plugin.Context) { : String(cause) show(() => ) } + + const onNotification = createToastSubscriber({ + show: (toast) => { + ctx.ui.toast.show(toast) + const route = ctx.ui.router.current() + if (toast.sessionID && route.type === "session" && route.sessionID !== toast.sessionID) + void ctx.attention.notify({ + title: toast.title ?? "DCP", + message: toast.message, + }) + }, + }) + const unsubscribeNotification = client.events.on("notification", onNotification) + const unsubscribeOpenPanel = client.events.on("openPanel", () => open()) + ctx.ui.slot({ append: "app", render() { @@ -92,25 +108,15 @@ export async function setup(ctx: Plugin.Context) { description: "Open DCP panel", group: "DCP", palette: true, - slash: { name: "dcp", arguments: true }, - run: async (input) => { - if (!input?.trim()) return open() - const route = ctx.ui.router.current() - if (route.type !== "session") return open() - try { - await ctx.client.session.command({ - sessionID: route.sessionID, - name: "dcp", - text: input, - }) - } catch (cause) { - error(cause) - } - }, + run: () => open(), }, ], })) return null }, }) + return () => { + unsubscribeNotification() + unsubscribeOpenPanel() + } } diff --git a/lib/state/persistence.ts b/lib/state/persistence.ts index 882e7dade..02998aeff 100644 --- a/lib/state/persistence.ts +++ b/lib/state/persistence.ts @@ -69,7 +69,11 @@ async function writePersistedSessionState( const filePath = getSessionFilePath(sessionId) const content = JSON.stringify(state, null, 2) - await fs.writeFile(filePath, content, "utf-8") + // Write to a temp file then rename atomically so a crash or concurrent write + // cannot leave a truncated file that invalidates all state for the session. + const tempPath = `${filePath}.${process.pid}.${Date.now()}.tmp` + await fs.writeFile(tempPath, content, "utf-8") + await fs.rename(tempPath, filePath) logger.info("Saved session state to disk", { sessionId, diff --git a/lib/state/tool-cache.ts b/lib/state/tool-cache.ts index aab67f1c9..cde960e82 100644 --- a/lib/state/tool-cache.ts +++ b/lib/state/tool-cache.ts @@ -43,16 +43,25 @@ export function syncToolCache( turnProtectionTurns > 0 && state.currentTurn - turnCounter < turnProtectionTurns - if (state.toolParameters.has(part.callID)) { + const tokenCount = countToolTokens(part) + const existing = state.toolParameters.get(part.callID) + + if (isProtectedByTurn && !existing) { continue } - if (isProtectedByTurn) { + // A tool part is first observed as pending/running and only later + // becomes completed or errored. Refresh mutable fields on every sync + // so purgeErrors/deduplication see the real status and parameters. + if (existing) { + existing.parameters = part.state?.input ?? {} + existing.metadata = "metadata" in part.state ? part.state.metadata : undefined + existing.status = part.state.status as ToolStatus | undefined + existing.error = part.state.status === "error" ? part.state.error : undefined + existing.tokenCount = tokenCount continue } - const tokenCount = countToolTokens(part) - state.toolParameters.set(part.callID, { tool: part.tool, parameters: part.state?.input ?? {}, diff --git a/lib/state/types.ts b/lib/state/types.ts index 6ac72dc15..ea020000a 100644 --- a/lib/state/types.ts +++ b/lib/state/types.ts @@ -1,10 +1,10 @@ import type { CompressionTimingState } from "../compress/timing" import type { IdFormat } from "../message-ids" -import { Message, Part } from "@opencode-ai/sdk/v2" +import type { MessageInfo, PartLike } from "../message-info" export interface WithParts { - info: Message - parts: Part[] + info: MessageInfo + parts: PartLike[] } export type ToolStatus = "pending" | "running" | "completed" | "error" diff --git a/lib/state/utils.ts b/lib/state/utils.ts index f0caf267d..ce05e27ba 100644 --- a/lib/state/utils.ts +++ b/lib/state/utils.ts @@ -342,4 +342,16 @@ export function resetOnCompaction(state: SessionState): void { turnNudgeAnchors: new Set(), iterationNudgeAnchors: new Set(), } + // These are all keyed to pre-compaction IDs/tokens and become stale after + // compaction. Leaving them in place causes wrong turn ages, prune decisions, + // and nudge thresholds in the new context window. + state.compressionTiming.startsByCallId.clear() + state.compressionTiming.pendingByCallId.clear() + state.subAgentResultCache.clear() + state.toolIdList = [] + state.stats = { pruneTokenCounter: 0, totalPruneTokens: 0 } + state.manualMode = false + state.pendingManualTrigger = null + state.modelContextLimit = undefined + state.systemPromptTokens = undefined } diff --git a/lib/strategies/deduplication.ts b/lib/strategies/deduplication.ts index 9cda5fbf3..5b821a5c5 100644 --- a/lib/strategies/deduplication.ts +++ b/lib/strategies/deduplication.ts @@ -23,7 +23,14 @@ export const deduplicate = ( return } - const allToolIds = state.toolIdList + // Derive tool IDs from the messages actually passed in. `state.toolIdList` + // reflects the last chat transform, which may be stale when compression runs + // against freshly fetched session messages. + const allToolIds = messages.flatMap((message) => + (Array.isArray(message.parts) ? message.parts : []) + .filter((part) => part.type === "tool" && part.callID) + .map((part) => part.callID as string), + ) if (allToolIds.length === 0) { return } @@ -69,15 +76,17 @@ export const deduplicate = ( } } - // Find duplicates - keep only the most recent (last) in each group + // Find duplicates: keep the most recent *successful* call in each group. + // Keeping the newest by recency alone can discard a successful output in + // favour of a later call that failed. const newPruneIds: string[] = [] for (const [, ids] of signatureMap.entries()) { - if (ids.length > 1) { - // All except last (most recent) should be pruned - const idsToRemove = ids.slice(0, -1) - newPruneIds.push(...idsToRemove) - } + if (ids.length <= 1) continue + const successful = ids.filter((id) => state.toolParameters.get(id)?.status === "completed") + const keepPool = successful.length > 0 ? successful : ids + const keepId = keepPool[keepPool.length - 1]! + newPruneIds.push(...ids.filter((id) => id !== keepId)) } state.stats.totalPruneTokens += getTotalToolTokens(state, newPruneIds) diff --git a/lib/strategies/purge-errors.ts b/lib/strategies/purge-errors.ts index 403036165..202d2d03d 100644 --- a/lib/strategies/purge-errors.ts +++ b/lib/strategies/purge-errors.ts @@ -26,7 +26,13 @@ export const purgeErrors = ( return } - const allToolIds = state.toolIdList + // Use the messages supplied to this strategy rather than the last transform's + // tool list, which can be stale relative to freshly fetched session messages. + const allToolIds = messages.flatMap((message) => + (Array.isArray(message.parts) ? message.parts : []) + .filter((part) => part.type === "tool" && part.callID) + .map((part) => part.callID as string), + ) if (allToolIds.length === 0) { return } diff --git a/lib/token-utils.ts b/lib/token-utils.ts index bba07fa1a..4fe7a3de6 100644 --- a/lib/token-utils.ts +++ b/lib/token-utils.ts @@ -1,5 +1,5 @@ import { SessionState, WithParts } from "./state" -import { AssistantMessage, UserMessage } from "@opencode-ai/sdk/v2" +import type { MessageInfo } from "./message-info" import { Logger } from "./logger" import * as _anthropicTokenizer from "@anthropic-ai/tokenizer" const anthropicCountTokens = (_anthropicTokenizer.countTokens ?? @@ -13,7 +13,7 @@ export function getCurrentTokenUsage(state: SessionState, messages: WithParts[]) continue } - const assistantInfo = msg.info as AssistantMessage + const assistantInfo = msg.info as MessageInfo if ((assistantInfo.tokens?.output || 0) <= 0) { continue } @@ -57,8 +57,8 @@ export function getCurrentParams( variant: undefined, } } - const userInfo = userMsg.info as UserMessage - const agent: string = userInfo.agent + const userInfo = userMsg.info as MessageInfo + const agent = userInfo.agent const providerId: string | undefined = userInfo.model.providerID const modelId: string | undefined = userInfo.model.modelID const variant: string | undefined = userInfo.model.variant diff --git a/lib/tool-schema.ts b/lib/tool-schema.ts new file mode 100644 index 000000000..6a591ae26 --- /dev/null +++ b/lib/tool-schema.ts @@ -0,0 +1,45 @@ +/** + * Minimal JSON Schema builders for DCP's tool definitions. + * + * The plugin used to rely on the V1 `tool.schema` zod-like helpers. Under + * OpenCode 2 tool inputs are plain JSON Schema (or Effect schemas), so the + * definitions are built directly as JSON Schema and shared by both the + * compression tools and the tool registered with the host. + */ +export interface JsonSchema { + [key: string]: unknown + type: "string" | "number" | "boolean" | "array" | "object" + description?: string + items?: JsonSchema + properties?: Record + required?: string[] + additionalProperties?: boolean +} + +export interface ToolDefinition { + description: string + args: JsonSchema + execute: (args: any, ctx: any) => Promise +} + +export const schema = { + string: (description: string): JsonSchema => ({ type: "string", description }), + number: (description: string): JsonSchema => ({ type: "number", description }), + boolean: (description: string): JsonSchema => ({ type: "boolean", description }), + array: (items: JsonSchema, description?: string): JsonSchema => ({ + type: "array", + items, + ...(description ? { description } : {}), + }), + object: (properties: Record, description?: string): JsonSchema => ({ + type: "object", + properties, + required: Object.keys(properties), + additionalProperties: false, + ...(description ? { description } : {}), + }), +} + +export function defineTool(definition: ToolDefinition): ToolDefinition { + return definition +} diff --git a/lib/tui/commands.ts b/lib/tui/commands.ts deleted file mode 100644 index 99d918cdf..000000000 --- a/lib/tui/commands.ts +++ /dev/null @@ -1,31 +0,0 @@ -import type { DcpCommand, TuiApi } from "./types" - -export function registerCommands(api: TuiApi, commands: DcpCommand[]) { - const keymap = (api as any).keymap - if (keymap?.registerLayer) { - keymap.registerLayer({ - commands: commands.map((command) => ({ - namespace: "palette", - name: command.name, - title: command.title, - desc: command.description, - category: "DCP", - slashName: command.slashName, - slashAliases: command.slashAliases, - run: command.run, - })), - }) - return - } - - api.command?.register(() => - commands.map((command) => ({ - title: command.title, - value: command.name, - description: command.description, - category: "DCP", - slash: { name: command.slashName, aliases: command.slashAliases }, - onSelect: command.run, - })), - ) -} diff --git a/lib/tui/data.ts b/lib/tui/data.ts deleted file mode 100644 index f09997176..000000000 --- a/lib/tui/data.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { getConfig, type PluginConfig } from "../config" -import { Logger } from "../logger" -import { filterMessages } from "../messages/shape" -import { createSessionState, type SessionState, type WithParts } from "../state" -import { loadSessionState } from "../state/persistence" -import { findLastCompactionTimestamp, loadPruneMap, loadPruneMessagesState } from "../state/utils" -import type { TuiApi } from "./types" - -export const logger = new Logger(false) - -export function loadConfig(api: TuiApi): PluginConfig { - return getConfig({ - client: api.client, - directory: api.state.path.directory, - worktree: api.state.path.worktree, - } as any) -} - -export function activeSessionID(api: TuiApi): string | undefined { - const current = api.route.current - if (current.name !== "session") return undefined - const sessionID = current.params?.sessionID - return typeof sessionID === "string" ? sessionID : undefined -} - -export function sessionMessages(api: TuiApi, sessionID: string): WithParts[] { - const messages = api.state.session.messages(sessionID) - return filterMessages( - messages.map((info) => ({ - info, - parts: api.state.part(info.id), - })) as unknown as WithParts[], - ) -} - -export async function buildSessionState( - sessionID: string, - messages: WithParts[], - config: PluginConfig, -): Promise { - const state = createSessionState() - state.sessionId = sessionID - state.manualMode = config.manualMode.enabled ? "active" : false - state.lastCompaction = findLastCompactionTimestamp(messages) - - const persisted = await loadSessionState(sessionID, logger) - if (persisted) { - if (typeof persisted.manualMode === "boolean") { - state.manualMode = persisted.manualMode ? "active" : false - } - - state.prune.tools = loadPruneMap(persisted.prune.tools) - state.prune.messages = loadPruneMessagesState(persisted.prune.messages) - state.nudges.contextLimitAnchors = new Set(persisted.nudges.contextLimitAnchors || []) - state.nudges.turnNudgeAnchors = new Set(persisted.nudges.turnNudgeAnchors || []) - state.nudges.iterationNudgeAnchors = new Set(persisted.nudges.iterationNudgeAnchors || []) - state.stats = { - pruneTokenCounter: persisted.stats?.pruneTokenCounter || 0, - totalPruneTokens: persisted.stats?.totalPruneTokens || 0, - } - } - - return state -} - -export async function loadSessionData(api: TuiApi, config: PluginConfig) { - const sessionID = activeSessionID(api) - if (!sessionID) return undefined - - const messages = sessionMessages(api, sessionID) - const state = await buildSessionState(sessionID, messages, config) - return { state, messages } -} diff --git a/lib/tui/modals.tsx b/lib/tui/modals.tsx deleted file mode 100644 index e23092dee..000000000 --- a/lib/tui/modals.tsx +++ /dev/null @@ -1,93 +0,0 @@ -/** @jsxImportSource @opentui/solid */ - -import { buildStatsReport } from "../commands/stats" -import { analyzeContextTokens } from "../commands/context" -import { compressPermission } from "../compress-permission" -import type { PluginConfig } from "../config" -import { saveManualModeSetting } from "../state/persistence" -import { loadSessionData, logger } from "./data" -import { ContextDialog, PanelDialog, StatsDialog, StatusDialog } from "./dialogs" -import type { TuiApi } from "./types" - -export function showDialog(api: TuiApi, render: () => any) { - api.ui.dialog.setSize("xlarge") - api.ui.dialog.replace(render) -} - -export function showStatusDialog(api: TuiApi, title: string, eyebrow: string, message: string) { - showDialog(api, () => ( - - )) -} - -export function showError(api: TuiApi, title: string, error: unknown) { - const message = error instanceof Error ? error.message : String(error) - showStatusDialog(api, title, "DCP Error", message || "Command failed.") -} - -export function openContextModal(api: TuiApi, config: PluginConfig) { - runModal(api, "Context", async () => { - const data = await loadSessionData(api, config) - if (!data) { - showStatusDialog(api, "Context", "No session", "Open a session first.") - return - } - showDialog(api, () => ( - openPanelModal(api, config)} - /> - )) - }) -} - -export function openStatsModal(api: TuiApi, config: PluginConfig) { - runModal(api, "Stats", async () => { - const data = await loadSessionData(api, config) - if (!data) { - showStatusDialog(api, "Stats", "No session", "Open a session first.") - return - } - const report = await buildStatsReport(data.state, logger) - showDialog(api, () => ( - openPanelModal(api, config)} /> - )) - }) -} - -export function openPanelModal(api: TuiApi, config: PluginConfig) { - runModal(api, "DCP", async () => { - const data = await loadSessionData(api, config) - if (!data) { - showStatusDialog(api, "DCP", "No session", "Open a session first.") - return - } - showDialog(api, () => ( - openContextModal(api, config)} - onStats={() => openStatsModal(api, config)} - onManual={(enabled) => setManualMode(api, config, data.state.sessionId, enabled)} - /> - )) - }) -} - -function runModal(api: TuiApi, title: string, task: () => Promise) { - showStatusDialog(api, title, "DCP", "Loading...") - void task().catch((error) => showError(api, title, error)) -} - -async function setManualMode( - api: TuiApi, - config: PluginConfig, - sessionID: string | null | undefined, - enabled: boolean, -) { - if (!sessionID) return - await saveManualModeSetting(sessionID, enabled, logger) - openPanelModal(api, config) -} diff --git a/lib/tui/types.ts b/lib/tui/types.ts index 902f5003c..2f7d7edfc 100644 --- a/lib/tui/types.ts +++ b/lib/tui/types.ts @@ -1,21 +1,22 @@ -import type { TuiPluginModule } from "@opencode-ai/plugin/tui" +import type { Plugin } from "@opencode/plugin/tui" +import type { RGBA } from "@opentui/core" import type { buildStatsReport } from "../commands/stats" -export type TuiApi = Parameters>[0] -export type Theme = Pick< - TuiApi["theme"]["current"], - | "primary" - | "accent" - | "text" - | "textMuted" - | "background" - | "backgroundElement" - | "borderSubtle" - | "selectedListItemText" - | "success" - | "warning" - | "error" -> +export type TuiApi = Plugin.Context + +export type Theme = { + primary: RGBA + accent: RGBA + text: RGBA + textMuted: RGBA + background: RGBA + backgroundElement: RGBA + borderSubtle: RGBA + selectedListItemText: RGBA + success: RGBA + warning: RGBA + error: RGBA +} export type ThemeColor = keyof Theme export type ViewApi = { centeredDialog?: boolean @@ -24,12 +25,3 @@ export type ViewApi = { ui: { dialog: { clear(): void } } } export type StatsReport = Awaited> - -export type DcpCommand = { - title: string - name: string - description: string - slashName: string - slashAliases?: string[] - run: () => void | Promise -} diff --git a/lib/ui/notification.ts b/lib/ui/notification.ts index e65c070c3..64fa5c38f 100644 --- a/lib/ui/notification.ts +++ b/lib/ui/notification.ts @@ -115,23 +115,18 @@ export async function sendUnifiedNotification( ? buildMinimalMessage(state, reason) : buildDetailedMessage(state, reason, pruneToolIds, toolMetadata, workingDirectory) - if (config.pruneNotificationType === "toast") { - let toastMessage = truncateExtractedSection(message) - toastMessage = - config.pruneNotification === "minimal" ? toastMessage : truncateToastBody(toastMessage) - - await client.tui.showToast({ - body: { - title: "DCP: Compress Notification", - message: toastMessage, - variant: "info", - duration: 5000, - }, - }) - return true - } - - await sendIgnoredMessage(client, sessionId, message, params, logger) + let toastMessage = truncateExtractedSection(message) + toastMessage = + config.pruneNotification === "minimal" ? toastMessage : truncateToastBody(toastMessage) + + await client.tui.showToast({ + body: { + title: "DCP: Compress Notification", + message: toastMessage, + variant: "info", + duration: 5000, + }, + }) return true } @@ -276,32 +271,27 @@ export async function sendCompressNotification( } } - if (config.pruneNotificationType === "toast") { - let toastMessage = message - if (config.compress.showCompression) { - const truncatedSummary = truncateToastSummary(summary) - if (truncatedSummary !== summary) { - toastMessage = toastMessage.replace( - `\n→ Compression (~${summaryTokensStr}): ${summary}`, - `\n→ Compression (~${summaryTokensStr}): ${truncatedSummary}`, - ) - } + let toastMessage = message + if (config.compress.showCompression) { + const truncatedSummary = truncateToastSummary(summary) + if (truncatedSummary !== summary) { + toastMessage = toastMessage.replace( + `\n→ Compression (~${summaryTokensStr}): ${summary}`, + `\n→ Compression (~${summaryTokensStr}): ${truncatedSummary}`, + ) } - toastMessage = - config.pruneNotification === "minimal" ? toastMessage : truncateToastBody(toastMessage) - - await client.tui.showToast({ - body: { - title: "DCP: Compress Notification", - message: toastMessage, - variant: "info", - duration: 5000, - }, - }) - return true } - - await sendIgnoredMessage(client, sessionId, message, params, logger) + toastMessage = + config.pruneNotification === "minimal" ? toastMessage : truncateToastBody(toastMessage) + + await client.tui.showToast({ + body: { + title: "DCP: Compress Notification", + message: toastMessage, + variant: "info", + duration: 5000, + }, + }) return true } diff --git a/lib/update.ts b/lib/update.ts deleted file mode 100644 index 9cba0ded7..000000000 --- a/lib/update.ts +++ /dev/null @@ -1,185 +0,0 @@ -import { readFile, rm } from "node:fs/promises" -import { basename, dirname, join } from "node:path" -import { fileURLToPath } from "node:url" -import type { PluginInput } from "@opencode-ai/plugin" - -type PackageJson = { - name?: string - version?: string - dependencies?: Record -} - -type UpdateResult = - | { updated: true; name: string; current: string; latest: string } - | { updated: false; error: "remove_failed"; name: string; current: string; latest: string } - | { updated: false } - -const PACKAGE_NAME = "@mbarnett/opencode-dcp" - -export function startAutoUpdate(ctx: PluginInput, enabled: boolean): void { - if (!enabled) return - - const controller = new AbortController() - const timeout = setTimeout(() => controller.abort(), 10_000) - void checkAutoUpdate(controller.signal) - .then((result) => { - if (!result.updated) return - setTimeout(() => { - ctx.client.tui.showToast({ - body: { - title: "DCP update ready", - message: `Updated ${result.name} from ${result.current} to ${result.latest}. Restart OpenCode to finish.`, - variant: "info", - duration: 7000, - }, - }) - }, 5000) - }) - .catch(() => {}) - .finally(() => clearTimeout(timeout)) -} - -export async function checkAutoUpdate(signal: AbortSignal): Promise { - const packageDir = await findPackageDir(PACKAGE_NAME) - if (!packageDir) return { updated: false } - - const pkg = await readPackageJson(join(packageDir, "package.json")) - if (!pkg?.name || !pkg.version) return { updated: false } - - const latest = await fetchLatestVersion(pkg.name, signal) - if (!latest || !isVersionNewer(latest, pkg.version)) return { updated: false } - - const removeDir = await updateRemoveDir(packageDir, pkg.name) - if (!removeDir) return { updated: false } - - try { - await rm(removeDir, { recursive: true, force: true }) - } catch { - return { - updated: false, - error: "remove_failed", - name: pkg.name, - current: pkg.version, - latest, - } - } - - return { updated: true, name: pkg.name, current: pkg.version, latest } -} - -async function findPackageDir(name: string) { - let dir = dirname(fileURLToPath(import.meta.url)) - for (;;) { - const pkg = await readPackageJson(join(dir, "package.json")) - if (pkg?.name === name) return dir - - const parent = dirname(dir) - if (parent === dir) return undefined - dir = parent - } -} - -export async function updateRemoveDir(packageDir: string, name: string) { - const packageParent = dirname(packageDir) - const nodeModulesDir = basename(packageParent).startsWith("@") - ? dirname(packageParent) - : packageParent - if (basename(nodeModulesDir) !== "node_modules") return undefined - - const wrapperDir = dirname(nodeModulesDir) - const wrapperPkg = await readPackageJson(join(wrapperDir, "package.json")) - const spec = wrapperSpec(wrapperDir, name) ?? wrapperPkg?.dependencies?.[name] - if (!spec || !isAutoUpdatableSpec(spec)) return undefined - - return wrapperDir -} - -function wrapperSpec(wrapperDir: string, name: string) { - if (name.startsWith("@")) { - const [scope, pkg] = name.split("/") - if (!scope || !pkg || basename(dirname(wrapperDir)) !== scope) return undefined - const prefix = `${pkg}@` - const base = basename(wrapperDir) - return base.startsWith(prefix) ? base.slice(prefix.length) : undefined - } - - const prefix = `${name}@` - const base = basename(wrapperDir) - return base.startsWith(prefix) ? base.slice(prefix.length) : undefined -} - -export function isAutoUpdatableSpec(spec: string) { - const value = spec.trim() - if (!value) return false - if (value === "latest" || value === "*") return true - if (/^[~^]/.test(value)) return true - if (/^(?:>=|>|<=|<)/.test(value)) return true - if (/\s+(?:\|\||-|[<>=])\s+/.test(value)) return true - return false -} - -async function readPackageJson(path: string): Promise { - try { - const data = JSON.parse(await readFile(path, "utf-8")) - return data && typeof data === "object" ? (data as PackageJson) : undefined - } catch { - return undefined - } -} - -async function fetchLatestVersion(name: string, signal: AbortSignal) { - try { - const response = await fetch( - `https://registry.npmjs.org/${encodeURIComponent(name)}/latest`, - { - signal, - }, - ) - if (!response.ok) return undefined - const data: unknown = await response.json() - if (!data || typeof data !== "object") return undefined - const version = (data as { version?: unknown }).version - return typeof version === "string" ? version : undefined - } catch { - return undefined - } -} - -export function isVersionNewer(latest: string, current: string) { - const next = parseVersion(latest) - const prev = parseVersion(current) - if (!next || !prev) return false - - for (let i = 0; i < 3; i++) { - if (next.parts[i] !== prev.parts[i]) return next.parts[i] > prev.parts[i] - } - - if (!next.pre.length && prev.pre.length) return true - if (next.pre.length && !prev.pre.length) return false - - for (let i = 0; i < Math.max(next.pre.length, prev.pre.length); i++) { - const a = next.pre[i] - const b = prev.pre[i] - if (a === undefined) return false - if (b === undefined) return true - if (a === b) continue - - const aNumber = /^\d+$/.test(a) ? Number(a) : undefined - const bNumber = /^\d+$/.test(b) ? Number(b) : undefined - if (aNumber !== undefined && bNumber !== undefined) return aNumber > bNumber - if (aNumber !== undefined) return false - if (bNumber !== undefined) return true - return a > b - } - - return false -} - -function parseVersion(version: string) { - const match = version.match(/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+.+)?$/) - if (!match) return undefined - return { - parts: [Number(match[1]), Number(match[2]), Number(match[3])], - pre: match[4]?.split(".") ?? [], - } -} diff --git a/lib/v2/index.ts b/lib/v2/index.ts deleted file mode 100644 index d1818b54a..000000000 --- a/lib/v2/index.ts +++ /dev/null @@ -1,371 +0,0 @@ -import type { Plugin } from "@opencode/plugin" -import { tool, type ToolDefinition } from "@opencode-ai/plugin" -import { getConfig } from "../config" -import { Logger } from "../logger" -import { PromptStore } from "../prompts/store" -import { createCompressMessageTool, createCompressRangeTool } from "../compress" -import { attachCompressionDuration } from "../compress/state" -import { createCommandExecuteHandler, createSystemPromptHandler } from "../hooks" -import { - createSessionState, - ensureSessionInitialized, - checkSession, - saveSessionState, - syncToolCache, - type SessionState, -} from "../state" -import { assignMessageRefs } from "../message-ids" -import { applyPendingManualTrigger } from "../commands/manual" -import { - buildPriorityMap, - buildToolIdList, - injectCompressNudges, - injectMessageIds, - injectExtendedSubAgentResults, - prune, - stripHallucinations, - syncCompressionBlocks, -} from "../messages" -import { countTokens } from "../token-utils" -import { matchesGlob } from "../protected-patterns" -import { history, project } from "./messages" -import { analyzeContextTokens } from "../commands/context" -import { buildStatsReport } from "../commands/stats" -import { rpc } from "./rpc" - -// Extension point for future model-invisible V2 reports. Never use synthetic() -// here: its text would enter the model's context, unlike V1 ignored messages. -export async function report(logger: Logger, text: string, sessionID?: string) { - logger.debug("V2 report (display pending)", { sessionID, text }) -} - -export async function setup(ctx: Plugin.Context) { - const warnings = { - tui: { - showToast: async (input: { body: { message: string } }) => { - console.warn(`DCP: ${input.body.message}`) - }, - }, - } - const config = getConfig({ directory: ctx.location.directory, client: warnings }) - if (!config.enabled) { - await ctx.rpc.register( - { ...rpc, methods: { status: rpc.methods.status } }, - { status: async () => ({ enabled: false }) }, - ) - return - } - const logger = new Logger(config.debug) - const prompts = new PromptStore( - logger, - ctx.location.directory, - config.experimental.customPrompts, - "compact", - ) - const sessions = new Map() - const queues = new Map>() - const limits = new Map() - const aliases: Record = { - task: "subagent", - bash: "shell", - apply_patch: "patch", - } - for (const list of [ - config.compress.protectedTools, - config.commands.protectedTools, - config.strategies.deduplication.protectedTools, - config.strategies.purgeErrors.protectedTools, - ]) { - for (const name of [...list]) - if (aliases[name] && !list.includes(aliases[name]!)) list.push(aliases[name]!) - } - - function serial(sessionID: string, operation: () => Promise): Promise { - const pending = (queues.get(sessionID) ?? Promise.resolve()).catch(() => {}).then(operation) - queues.set(sessionID, pending) - void pending - .finally(() => { - if (queues.get(sessionID) === pending) queues.delete(sessionID) - }) - .catch(() => {}) - return pending - } - - const client = { - session: { - get: async ({ path }: { path: { id: string } }) => ({ - data: await ctx.session.get({ sessionID: path.id }), - }), - messages: async ({ path }: { path: { id: string } }) => { - const [entries, session] = await Promise.all([ - ctx.session.context({ sessionID: path.id }), - ctx.session.get({ sessionID: path.id }), - ]) - return { data: history(entries, session) } - }, - prompt: async (input: { - path: { id: string } - body: { parts: Array<{ text: string }> } - }) => - report(logger, input.body.parts.map((part) => part.text).join("\n"), input.path.id), - }, - tui: { - showToast: async (input: { body: { message: string } }) => - report(logger, input.body.message), - }, - } - - async function load(sessionID: string, agentID?: string) { - const [session, entries] = await Promise.all([ - ctx.session.get({ sessionID }), - ctx.session.context({ sessionID }), - ]) - const selected = - agentID ?? - session.agent ?? - entries.findLast((entry) => entry.type === "assistant")?.agent - if (!selected) throw new Error("DCP commands require a session with a selected agent") - const { data: agent } = await ctx.agent.get({ agentID: selected }) - let state = sessions.get(sessionID) - if (!state) { - state = createSessionState("compact") - sessions.set(sessionID, state) - } - const messages = history(entries, session) - await ensureSessionInitialized( - client, - state, - sessionID, - logger, - messages, - config.manualMode.enabled, - ) - await checkSession(client, state, logger, messages, config.manualMode.enabled) - const rule = [...agent.permissions, ...(session.permissions ?? [])].findLast( - (rule) => matchesGlob("compress", rule.action) && matchesGlob("*", rule.resource), - ) - state.compressPermission = - config.compress.permission === "deny" - ? "deny" - : rule?.effect === "deny" - ? "deny" - : config.compress.permission === "ask" || rule?.effect === "ask" - ? "ask" - : "allow" - return { state, entries, session, messages } - } - - function allowed(state: SessionState) { - if (state.isSubAgent && !config.experimental.allowSubAgents) - throw new Error("DCP compression is disabled in subagents") - if (state.compressPermission === "deny") throw new Error("DCP compression is denied") - if (state.compressPermission === "ask") - throw new Error( - "DCP: compress permission 'ask' is not supported by OpenCode V2's public plugin API yet. Compression was not performed.", - ) - } - - await ctx.model.transform((editor) => { - limits.clear() - for (const model of editor.list()) - limits.set(`${model.providerID}/${model.id}`, model.limit.context) - }) - for (const kind of ["context", "compaction"] as const) - await ctx.session.hook(kind, (event) => - serial(event.sessionID, async () => { - const { state, entries, session, messages } = await load( - event.sessionID, - event.agent, - ) - if (state.isSubAgent && !config.experimental.allowSubAgents) { - delete event.tools.compress - return - } - if (state.compressPermission === "deny") delete event.tools.compress - state.modelContextLimit = limits.get(`${event.model.providerID}/${event.model.id}`) - state.systemPromptTokens = countTokens( - event.system.map((part) => part.text).join("\n"), - ) - const view = project(event.messages, entries, { - ...session, - agent: event.agent, - model: event.model, - }) - stripHallucinations(view.messages, state.idFormat) - assignMessageRefs(state, view.messages) - // Compaction may select only a prefix; block origins can be in the retained tail. - syncCompressionBlocks(state, logger, messages) - syncToolCache(state, config, logger, view.messages) - buildToolIdList(state, view.messages) - prune(state, logger, config, view.messages, view.summaryBase) - await injectExtendedSubAgentResults( - client, - state, - logger, - view.messages, - config.experimental.allowSubAgents, - ) - const priorities = buildPriorityMap(config, state, view.messages) - prompts.reload() - injectCompressNudges( - state, - config, - logger, - view.messages, - prompts.getRuntimePrompts(), - priorities, - kind === "context", - ) - injectMessageIds(state, config, view.messages, priorities) - applyPendingManualTrigger(state, view.messages, logger) - event.messages = view.restore() - const system = { system: event.system.map((part) => part.text) } - await createSystemPromptHandler( - state, - logger, - config, - prompts, - )( - { - sessionID: event.sessionID, - model: { limit: { context: state.modelContextLimit ?? 0 } }, - }, - system, - ) - event.system = system.system.map((text, index) => ({ - ...event.system[index], - type: "text", - text, - })) - await logger.saveContext(event.sessionID, view.messages) - }), - ) - - if (config.compress.permission !== "deny") { - const define = (state: SessionState): ToolDefinition => - (config.compress.mode === "message" - ? createCompressMessageTool - : createCompressRangeTool)({ client, state, logger, config, prompts }) - const definition = define(createSessionState("compact")) - await ctx.tool.transform((editor) => - editor.add({ - name: "compress", - description: definition.description, - input: tool.schema.object(definition.args), - options: { codemode: false, permission: "compress" }, - execute: (input, context) => - serial(context.sessionID, async () => { - const { state } = await load(context.sessionID, context.agent) - allowed(state) - const started = Date.now() - const legacy = define(state) - const content = await legacy.execute(input, { - sessionID: context.sessionID, - messageID: context.messageID, - callID: context.id, - agent: context.agent, - directory: ctx.location.directory, - worktree: ctx.location.directory, - abort: new AbortController().signal, - ask: async () => allowed(state), - metadata: ({ title }: { title?: string }) => { - void context.progress({ title }) - }, - } as Parameters[1]) - attachCompressionDuration( - state.prune.messages, - context.messageID, - context.id, - Date.now() - started, - ) - await saveSessionState(state, logger) - // Both shared compression executors return text; the V1 helper's - // public return type also permits unrelated attachment results. - return { content: content as string } - }), - }), - ) - } - if (config.commands.enabled) - await ctx.command.transform((editor) => { - for (const name of ["dcp", "dcp-compress"]) - editor.add({ - name, - description: name === "dcp" ? "DCP commands" : "Trigger DCP manual compression", - execute: async (invocation) => { - const prompt = await serial(invocation.sessionID, async () => { - const { state } = await load(invocation.sessionID) - const permission = - state.compressPermission ?? config.compress.permission - if ( - name === "dcp-compress" || - invocation.prompt.text.trim().split(/\s+/)[0] === "compress" - ) - allowed(state) - const output = { parts: [] } - await createCommandExecuteHandler( - client, - state, - logger, - config, - ctx.location.directory, - { global: { compress: permission }, agents: {} }, - )( - { - command: name, - sessionID: invocation.sessionID, - arguments: invocation.prompt.text, - }, - output, - ) - state.compressPermission = permission - const pending = state.pendingManualTrigger - if (!pending) return - allowed(state) - state.pendingManualTrigger = null - return pending.prompt - }) - if (prompt) - await ctx.session.prompt({ - sessionID: invocation.sessionID, - text: prompt, - delivery: invocation.delivery, - }) - }, - }) - }) - await ctx.rpc.register(rpc, { - status: async () => ({ enabled: config.commands.enabled }), - snapshot: ({ sessionID }) => - serial(sessionID, async () => { - const { state, messages } = await load(sessionID) - syncCompressionBlocks(state, logger, messages) - return { - manualMode: !!state.manualMode, - canCompress: - state.compressPermission === "allow" && - (!state.isSubAgent || config.experimental.allowSubAgents), - ...(state.compressPermission === "ask" - ? { - blockedReason: - "Permission 'ask' is not supported by the V2 plugin API yet.", - } - : {}), - context: analyzeContextTokens(state, messages), - stats: await buildStatsReport(state, logger), - } - }), - manual: ({ sessionID, enabled }) => - serial(sessionID, async () => { - const { state } = await load(sessionID) - state.manualMode = enabled ? "active" : false - await saveSessionState(state, logger) - return {} - }), - }) - logger.info("DCP V2 initialized") - return () => { - sessions.clear() - limits.clear() - } -} diff --git a/package-lock.json b/package-lock.json index 6ec43be02..8b0986891 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,36 +1,33 @@ { "name": "@mbarnett/opencode-dcp", - "version": "3.2.1", + "version": "4.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@mbarnett/opencode-dcp", - "version": "3.2.1", + "version": "4.0.0", "license": "AGPL-3.0-or-later", "workspaces": [ "tests/logger" ], "dependencies": { "@anthropic-ai/tokenizer": "^0.0.4", - "@opencode-ai/sdk": "^1.4.3", - "@opentui/core": "^0.6.8", - "@opentui/solid": "^0.6.8", + "@opentui/core": "^0.9.3", + "@opentui/solid": "^0.9.3", "jsonc-parser": "^3.3.1", - "solid-js": "^1.9.12" + "solid-js": "^1.9.12", + "zod": "^4.1.8" }, "devDependencies": { - "@opencode-ai/plugin": "^1.18.29", - "@opencode/plugin": "^2.0.4", - "@opencode/theme": "^2.0.4", + "@opencode/ai": "^2.3.2", + "@opencode/plugin": "^2.3.2", + "@opencode/theme": "^2.3.2", "@types/node": "^25.5.0", "prettier": "^3.8.1", "tsup": "^8.5.1", "tsx": "^4.21.0", "typescript": "^6.0.2" - }, - "peerDependencies": { - "@opencode-ai/plugin": ">=1.18.29" } }, "node_modules/@ai-sdk/provider": { @@ -949,90 +946,6 @@ "node": ">=6.9.0" } }, - "node_modules/@effect/opentelemetry": { - "version": "4.0.0-rc.112", - "resolved": "https://registry.npmjs.org/@effect/opentelemetry/-/opentelemetry-4.0.0-rc.112.tgz", - "integrity": "sha512-OTRv1DxTHUmnakgJ6XVM8wVgF1KgZH4UXnOemwSLUwUjXO+RCikzF8oR/rlVmOGq81KtQzj1URM4M4nchlQOuQ==", - "devOptional": true, - "license": "MIT", - "engines": { - "node": ">=18.0.0" - }, - "peerDependencies": { - "@opentelemetry/api": ">=1.9.0 <2.0.0", - "@opentelemetry/api-logs": ">=0.203.0 <0.300.0", - "@opentelemetry/resources": ">=2.0.0 <3.0.0", - "@opentelemetry/sdk-logs": ">=0.203.0 <0.300.0", - "@opentelemetry/sdk-metrics": ">=2.0.0 <3.0.0", - "@opentelemetry/sdk-trace-base": ">=2.0.0 <3.0.0", - "@opentelemetry/sdk-trace-node": ">=2.0.0 <3.0.0", - "@opentelemetry/sdk-trace-web": ">=2.0.0 <3.0.0", - "@opentelemetry/semantic-conventions": ">=1.33.0 <2.0.0", - "effect": "^4.0.0-rc.112" - }, - "peerDependenciesMeta": { - "@opentelemetry/api": { - "optional": true - }, - "@opentelemetry/api-logs": { - "optional": true - }, - "@opentelemetry/resources": { - "optional": true - }, - "@opentelemetry/sdk-logs": { - "optional": true - }, - "@opentelemetry/sdk-metrics": { - "optional": true - }, - "@opentelemetry/sdk-trace-base": { - "optional": true - }, - "@opentelemetry/sdk-trace-node": { - "optional": true - }, - "@opentelemetry/sdk-trace-web": { - "optional": true - } - } - }, - "node_modules/@effect/platform-node": { - "version": "4.0.0-rc.112", - "resolved": "https://registry.npmjs.org/@effect/platform-node/-/platform-node-4.0.0-rc.112.tgz", - "integrity": "sha512-/BMAcdNGQQskLmI0Zoa95KfTZkr9HV9N4NSxaSrusG6GeW6Ulp9KvZ+Rlaiw8lnOt43CXjFLdfll5/k5rxL4hQ==", - "devOptional": true, - "license": "MIT", - "dependencies": { - "@effect/platform-node-shared": "^4.0.0-rc.112", - "mime": "^4.1.0", - "undici": "^8.10.0" - }, - "engines": { - "node": ">=18.0.0" - }, - "peerDependencies": { - "effect": "^4.0.0-rc.112", - "redis": ">=5.0.0 <7.0.0" - } - }, - "node_modules/@effect/platform-node-shared": { - "version": "4.0.0-rc.112", - "resolved": "https://registry.npmjs.org/@effect/platform-node-shared/-/platform-node-shared-4.0.0-rc.112.tgz", - "integrity": "sha512-ttjz0xKamFN7vL8pNDYVwddJLjZvqKePc05djlz2VcdaKbLsnYbtMnL1rbOfHgEnIUSHGh7FkjaN4DM1Ov81sQ==", - "devOptional": true, - "license": "MIT", - "dependencies": { - "@types/ws": "^8.18.1", - "ws": "^8.21.3" - }, - "engines": { - "node": ">=18.0.0" - }, - "peerDependencies": { - "effect": "^4.0.0-rc.112" - } - }, "node_modules/@esbuild/aix-ppc64": { "version": "0.28.1", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.1.tgz", @@ -1046,6 +959,7 @@ "os": [ "aix" ], + "peer": true, "engines": { "node": ">=18" } @@ -1063,6 +977,7 @@ "os": [ "android" ], + "peer": true, "engines": { "node": ">=18" } @@ -1080,6 +995,7 @@ "os": [ "android" ], + "peer": true, "engines": { "node": ">=18" } @@ -1097,6 +1013,7 @@ "os": [ "android" ], + "peer": true, "engines": { "node": ">=18" } @@ -1114,6 +1031,7 @@ "os": [ "darwin" ], + "peer": true, "engines": { "node": ">=18" } @@ -1131,6 +1049,7 @@ "os": [ "darwin" ], + "peer": true, "engines": { "node": ">=18" } @@ -1148,6 +1067,7 @@ "os": [ "freebsd" ], + "peer": true, "engines": { "node": ">=18" } @@ -1165,6 +1085,7 @@ "os": [ "freebsd" ], + "peer": true, "engines": { "node": ">=18" } @@ -1182,6 +1103,7 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": ">=18" } @@ -1199,6 +1121,7 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": ">=18" } @@ -1216,6 +1139,7 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": ">=18" } @@ -1233,6 +1157,7 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": ">=18" } @@ -1250,6 +1175,7 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": ">=18" } @@ -1267,6 +1193,7 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": ">=18" } @@ -1284,6 +1211,7 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": ">=18" } @@ -1301,6 +1229,7 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": ">=18" } @@ -1318,6 +1247,7 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": ">=18" } @@ -1335,6 +1265,7 @@ "os": [ "netbsd" ], + "peer": true, "engines": { "node": ">=18" } @@ -1352,6 +1283,7 @@ "os": [ "netbsd" ], + "peer": true, "engines": { "node": ">=18" } @@ -1369,6 +1301,7 @@ "os": [ "openbsd" ], + "peer": true, "engines": { "node": ">=18" } @@ -1386,6 +1319,7 @@ "os": [ "openbsd" ], + "peer": true, "engines": { "node": ">=18" } @@ -1403,6 +1337,7 @@ "os": [ "openharmony" ], + "peer": true, "engines": { "node": ">=18" } @@ -1420,6 +1355,7 @@ "os": [ "sunos" ], + "peer": true, "engines": { "node": ">=18" } @@ -1437,6 +1373,7 @@ "os": [ "win32" ], + "peer": true, "engines": { "node": ">=18" } @@ -1454,6 +1391,7 @@ "os": [ "win32" ], + "peer": true, "engines": { "node": ">=18" } @@ -1471,6 +1409,7 @@ "os": [ "win32" ], + "peer": true, "engines": { "node": ">=18" } @@ -1603,90 +1542,6 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@msgpackr-extract/msgpackr-extract-darwin-arm64": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-darwin-arm64/-/msgpackr-extract-darwin-arm64-3.0.4.tgz", - "integrity": "sha512-LCkGo6JDfaBhgST7UpPWgNgLINpcpabaHfyz5OBx75nUYxBsaEPxjnyNjWpeb/xBup/682QnBfRBy2/LvPutZQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@msgpackr-extract/msgpackr-extract-darwin-x64": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-darwin-x64/-/msgpackr-extract-darwin-x64-3.0.4.tgz", - "integrity": "sha512-zExlW9zUJKZH/tOtVMttwjKa4Xm/3KcNjnE3dPN92uCktwavMxpgCA3MoJK/DOnTWsQgo224OaST27/mPNAf+w==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@msgpackr-extract/msgpackr-extract-linux-arm": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-arm/-/msgpackr-extract-linux-arm-3.0.4.tgz", - "integrity": "sha512-Tg3yX65f5GbtXLkrYEHE5oibZG9epyYWas7FogTTEJeDEF9JlXJzKgXaNhT3UXlTOeA+AfZpYZYZ0uPj7Cfquw==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@msgpackr-extract/msgpackr-extract-linux-arm64": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-arm64/-/msgpackr-extract-linux-arm64-3.0.4.tgz", - "integrity": "sha512-dgX0P/9wGPJeHFBG+ZmhgE6bmtMt7NP5CRBGyyktpopdk/mW4POnrpQsSLtKI1dwpc+pPLuXHDh6vvskyQE/sw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@msgpackr-extract/msgpackr-extract-linux-x64": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-x64/-/msgpackr-extract-linux-x64-3.0.4.tgz", - "integrity": "sha512-8TNXMEjJc3QEy7R/x1INhgiU+XakDAFUzBhaz7+Rbrs8NH5UQeHQxxmzsSBJGyV6I1jW79undiQm8tOI+D+8FQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@msgpackr-extract/msgpackr-extract-win32-x64": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-win32-x64/-/msgpackr-extract-win32-x64-3.0.4.tgz", - "integrity": "sha512-CmCXPQrkbwExx3j946/PtHWHbYJiCRBRDl4BlkRQcJB/YOwQxJRTpoo7aTsortjgoJ1x7opzTSxn7C+ASSLVjQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ] - }, "node_modules/@npmcli/agent": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@npmcli/agent/-/agent-4.0.2.tgz", @@ -1705,9 +1560,9 @@ } }, "node_modules/@npmcli/agent/node_modules/lru-cache": { - "version": "11.5.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz", - "integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==", + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", "devOptional": true, "license": "BlueOak-1.0.0", "engines": { @@ -1773,9 +1628,9 @@ } }, "node_modules/@npmcli/arborist/node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz", + "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==", "devOptional": true, "license": "MIT", "dependencies": { @@ -1786,9 +1641,9 @@ } }, "node_modules/@npmcli/arborist/node_modules/lru-cache": { - "version": "11.5.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz", - "integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==", + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", "devOptional": true, "license": "BlueOak-1.0.0", "engines": { @@ -1812,9 +1667,9 @@ } }, "node_modules/@npmcli/arborist/node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", "devOptional": true, "license": "ISC", "bin": { @@ -1845,9 +1700,9 @@ } }, "node_modules/@npmcli/config/node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", "devOptional": true, "license": "ISC", "bin": { @@ -1871,9 +1726,9 @@ } }, "node_modules/@npmcli/fs/node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", "devOptional": true, "license": "ISC", "bin": { @@ -1914,9 +1769,9 @@ } }, "node_modules/@npmcli/git/node_modules/lru-cache": { - "version": "11.5.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz", - "integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==", + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", "devOptional": true, "license": "BlueOak-1.0.0", "engines": { @@ -1924,9 +1779,9 @@ } }, "node_modules/@npmcli/git/node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", "devOptional": true, "license": "ISC", "bin": { @@ -1996,9 +1851,9 @@ } }, "node_modules/@npmcli/map-workspaces/node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz", + "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==", "devOptional": true, "license": "MIT", "dependencies": { @@ -2009,9 +1864,9 @@ } }, "node_modules/@npmcli/map-workspaces/node_modules/glob": { - "version": "13.0.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz", - "integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==", + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.7.tgz", + "integrity": "sha512-wfsFgXQ8A3SEI9XGf7Nl3Y9l7ffSrGh7SUCT7vU/2CzYPep9kjxAn1S40F9OPKxAMGCVl7HtNlJhrCJUeUq83g==", "devOptional": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -2027,9 +1882,9 @@ } }, "node_modules/@npmcli/map-workspaces/node_modules/lru-cache": { - "version": "11.5.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz", - "integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==", + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", "devOptional": true, "license": "BlueOak-1.0.0", "engines": { @@ -2097,9 +1952,9 @@ } }, "node_modules/@npmcli/metavuln-calculator/node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", "devOptional": true, "license": "ISC", "bin": { @@ -2159,9 +2014,9 @@ } }, "node_modules/@npmcli/package-json/node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz", + "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==", "devOptional": true, "license": "MIT", "dependencies": { @@ -2172,9 +2027,9 @@ } }, "node_modules/@npmcli/package-json/node_modules/glob": { - "version": "13.0.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz", - "integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==", + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.7.tgz", + "integrity": "sha512-wfsFgXQ8A3SEI9XGf7Nl3Y9l7ffSrGh7SUCT7vU/2CzYPep9kjxAn1S40F9OPKxAMGCVl7HtNlJhrCJUeUq83g==", "devOptional": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -2190,9 +2045,9 @@ } }, "node_modules/@npmcli/package-json/node_modules/lru-cache": { - "version": "11.5.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz", - "integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==", + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", "devOptional": true, "license": "BlueOak-1.0.0", "engines": { @@ -2243,9 +2098,9 @@ } }, "node_modules/@npmcli/package-json/node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", "devOptional": true, "license": "ISC", "bin": { @@ -2256,9 +2111,9 @@ } }, "node_modules/@npmcli/promise-spawn": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/@npmcli/promise-spawn/-/promise-spawn-9.0.1.tgz", - "integrity": "sha512-OLUaoqBuyxeTqUvjA3FZFiXUfYC1alp3Sa99gW3EUDz3tZ3CbXDdcZ7qWKBzicrJleIgucoWamWH1saAmH/l2Q==", + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/@npmcli/promise-spawn/-/promise-spawn-9.0.2.tgz", + "integrity": "sha512-h7b1j0egrruBm/32eVA6/zMw5VJxxaB3vT+uVGGQ4SAAMrQVFHNuzL4+EAXn66j+huj0jApINc1fW3fC+kVoeA==", "devOptional": true, "license": "ISC", "dependencies": { @@ -2334,143 +2189,93 @@ "node": "^20.17.0 || >=22.9.0" } }, - "node_modules/@opencode-ai/plugin": { - "version": "1.18.29", - "resolved": "https://registry.npmjs.org/@opencode-ai/plugin/-/plugin-1.18.29.tgz", - "integrity": "sha512-IhF83EU4I/ASgWwvm0FIh1O3a8ZVuCLqPrCbmSHdSYq7GHxIYe773i6dHqcbrzCzvlG/lP2H+dyTQ+xPAwFpbw==", - "devOptional": true, - "license": "MIT", - "dependencies": { - "@ai-sdk/provider": "3.0.8", - "@opencode-ai/sdk": "1.18.29", - "effect": "4.0.0-beta.83", - "zod": "4.1.8" - }, - "peerDependencies": { - "@opentui/core": ">=0.4.5", - "@opentui/keymap": ">=0.4.5", - "@opentui/solid": ">=0.4.5" - }, - "peerDependenciesMeta": { - "@opentui/core": { - "optional": true - }, - "@opentui/keymap": { - "optional": true - }, - "@opentui/solid": { - "optional": true - } - } - }, - "node_modules/@opencode-ai/plugin/node_modules/effect": { - "version": "4.0.0-beta.83", - "resolved": "https://registry.npmjs.org/effect/-/effect-4.0.0-beta.83.tgz", - "integrity": "sha512-0wsak8RtgGAr9UWSbVDgJHZcUqMSvicHcvaZv1MbMM7MCGgW4Rn/137J1MHQbwYPcwYGxT/IqehFd+UbYuj78w==", - "devOptional": true, - "license": "MIT", - "dependencies": { - "@standard-schema/spec": "^1.1.0", - "fast-check": "^4.8.0", - "find-my-way-ts": "^0.1.6", - "ini": "^7.0.0", - "kubernetes-types": "^1.30.0", - "msgpackr": "^2.0.1", - "multipasta": "^0.2.7", - "toml": "^4.1.1", - "uuid": "^14.0.0", - "yaml": "^2.9.0" - } - }, - "node_modules/@opencode-ai/plugin/node_modules/ini": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/ini/-/ini-7.0.0.tgz", - "integrity": "sha512-ifK0CgjALofS5bkrcTy4RaQ9Vx2Knf/eLeIO+NaswQEpH1UblrtTSCIvN71qQDMq0PeQ/SSPojvEJp9vvvfr+w==", - "devOptional": true, - "license": "ISC", - "engines": { - "node": "^22.22.2 || ^24.15.0 || >=26.0.0" - } - }, - "node_modules/@opencode-ai/sdk": { - "version": "1.18.29", - "resolved": "https://registry.npmjs.org/@opencode-ai/sdk/-/sdk-1.18.29.tgz", - "integrity": "sha512-4CS+FoLPkymTlcga8jxivGDDb2AbWMIIl3b8+myoe2wtv/1ANYCErslgz1xy5hTVHymWE6CtVNKzRuPU0ED57A==", - "license": "MIT", - "dependencies": { - "cross-spawn": "7.0.6" - } - }, "node_modules/@opencode/ai": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@opencode/ai/-/ai-2.0.4.tgz", - "integrity": "sha512-T/2wTuhy/I1Wxdy/GdhtMqugpl1OWKgVp+8A45mtS1jDrTSeHq2x5YhkComkJZ6BwdG/OvU6afTGDPA7/vd4RA==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@opencode/ai/-/ai-2.3.2.tgz", + "integrity": "sha512-OpVFIB8AUY/Ax/OEhBWjgYjyBrSxWXZR79d0v3f6BXIeKwJVZ2Gk4n7U9u3srcwBF6SjII3/PhRWn0ByaHDqEg==", "devOptional": true, "license": "MIT", "dependencies": { "@aws-sdk/credential-providers": "3.1057.0", - "@opencode/schema": "2.0.4", + "@opencode/schema": "2.3.2", "@smithy/eventstream-codec": "4.2.14", "@smithy/util-utf8": "4.2.2", "aws4fetch": "1.0.20", - "effect": "4.0.0-rc.112", + "effect": "4.1.0", "google-auth-library": "10.5.0" } }, - "node_modules/@opencode/client": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@opencode/client/-/client-2.0.4.tgz", - "integrity": "sha512-GBFWT2os+gEtGXpHRvDUNkf0H9x9njDUVbUvvc4drH2CuAihVcHqdi9Wm4UiwkBrSLjrKPs4U1NJBh2Z7/x4tQ==", + "node_modules/@opencode/ai/node_modules/effect": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/effect/-/effect-4.1.0.tgz", + "integrity": "sha512-lGx2MJJyrXA8RZb2UpQ/0Nkb5Utaimby7oD92+18noBxLPE85IFOvptdzau8dvcxAOwfwHo9iqapbKeFzqQM/Q==", + "devOptional": true, + "license": "MIT" + }, + "node_modules/@opencode/plugin": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@opencode/plugin/-/plugin-2.3.2.tgz", + "integrity": "sha512-1fAIk7Vb1mnDenWUo3WrNW1QvkVMinRRFVgA+b8MnOHSiR0RLKzZ/yotYf4AoMi8cTaJHytqQMYZgngRHAqTkA==", "devOptional": true, "license": "MIT", "dependencies": { - "@opencode/protocol": "2.0.4", - "@opencode/schema": "2.0.4" + "@ai-sdk/provider": "3.0.8", + "@opencode/ai": "2.3.2", + "@opencode/client": "2.3.2", + "@opencode/protocol": "2.3.2", + "@opencode/schema": "2.3.2", + "@opencode/util": "2.3.2", + "effect": "4.1.0" }, "peerDependencies": { - "effect": "4.0.0-rc.112", - "solid-js": ">=1.9.0" + "@opencode/theme": "2.3.2", + "@opentui/core": ">=0.8.4", + "@opentui/solid": ">=0.8.4", + "electron": "*", + "solid-js": ">=1.9.0", + "vite": ">=6", + "vite-plugin-solid": ">=2.11" }, "peerDependenciesMeta": { - "effect": { + "@opencode/theme": { + "optional": true + }, + "@opentui/core": { + "optional": true + }, + "@opentui/solid": { + "optional": true + }, + "electron": { "optional": true }, "solid-js": { "optional": true + }, + "vite": { + "optional": true + }, + "vite-plugin-solid": { + "optional": true } } }, - "node_modules/@opencode/plugin": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@opencode/plugin/-/plugin-2.0.4.tgz", - "integrity": "sha512-NsC1STARfXxe+ZoXjXzpxvtS9l4h9Aen8ZccaCd1d9+1eyYdp+q8DU3Rxh7Ch0jiwiQMybS2Z+KgAfZJBnTBbA==", + "node_modules/@opencode/plugin/node_modules/@opencode/client": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@opencode/client/-/client-2.3.2.tgz", + "integrity": "sha512-zwlR1Q0MQxpLJU4tILaaNyHrexNQpTbquy4Lv4i5lwkSba5MMuhK0tsPmGhyLIrqAyY+sY1qI75dOzOpsCJK7Q==", "devOptional": true, "license": "MIT", "dependencies": { - "@ai-sdk/provider": "3.0.8", - "@opencode/ai": "2.0.4", - "@opencode/client": "2.0.4", - "@opencode/protocol": "2.0.4", - "@opencode/schema": "2.0.4", - "@opencode/util": "2.0.4", - "@standard-schema/spec": "1.1.0", - "effect": "4.0.0-rc.112", - "zod": "4.1.8" + "@opencode/protocol": "2.3.2", + "@opencode/schema": "2.3.2" }, "peerDependencies": { - "@opencode/theme": "2.0.4", - "@opentui/core": ">=0.5.10", - "@opentui/solid": ">=0.5.10", + "effect": "4.1.0", "solid-js": ">=1.9.0" }, "peerDependenciesMeta": { - "@opencode/theme": { - "optional": true - }, - "@opentui/core": { - "optional": true - }, - "@opentui/solid": { + "effect": { "optional": true }, "solid-js": { @@ -2478,204 +2283,323 @@ } } }, + "node_modules/@opencode/plugin/node_modules/effect": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/effect/-/effect-4.1.0.tgz", + "integrity": "sha512-lGx2MJJyrXA8RZb2UpQ/0Nkb5Utaimby7oD92+18noBxLPE85IFOvptdzau8dvcxAOwfwHo9iqapbKeFzqQM/Q==", + "devOptional": true, + "license": "MIT" + }, "node_modules/@opencode/protocol": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@opencode/protocol/-/protocol-2.0.4.tgz", - "integrity": "sha512-uWe2dmMouprSkfBu29XLR6GCWckkhm0YOo9ve07kTRqJCSoJzgQDF/8pouWG0cDCJ6oWj3bRQajXriBQyWSpUw==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@opencode/protocol/-/protocol-2.3.2.tgz", + "integrity": "sha512-AEb1DZeWYrCVm+g2OUPWBLskCzGr4sXYj59Do8PzTHFb4a6jrDL0wN7kqYq65NrXGOW32alwxlnMHxJSjAfJ+w==", "devOptional": true, "license": "MIT", "dependencies": { - "@opencode/schema": "2.0.4", - "effect": "4.0.0-rc.112" + "@opencode/schema": "2.3.2", + "effect": "4.1.0" } }, + "node_modules/@opencode/protocol/node_modules/effect": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/effect/-/effect-4.1.0.tgz", + "integrity": "sha512-lGx2MJJyrXA8RZb2UpQ/0Nkb5Utaimby7oD92+18noBxLPE85IFOvptdzau8dvcxAOwfwHo9iqapbKeFzqQM/Q==", + "devOptional": true, + "license": "MIT" + }, "node_modules/@opencode/schema": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@opencode/schema/-/schema-2.0.4.tgz", - "integrity": "sha512-UyGcCsRb2hTH98rnBqfJogFve8kJsIbsEreRxqhkBIEGrtDTqcUd5NnqB7qlJp2khesMvpOH0GmCHlgz44C+uQ==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@opencode/schema/-/schema-2.3.2.tgz", + "integrity": "sha512-9PqnLzPNV0QTG3HrRHTVjVEQ2Hv+zcprM6QvwxNVdQ3RUTmtdpmUD6/0y0NQnHFzHwI3hpnkNCIstjw9TVsJcg==", "devOptional": true, "license": "MIT", "dependencies": { "@standard-schema/spec": "1.1.0", - "effect": "4.0.0-rc.112" + "effect": "4.1.0" } }, + "node_modules/@opencode/schema/node_modules/effect": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/effect/-/effect-4.1.0.tgz", + "integrity": "sha512-lGx2MJJyrXA8RZb2UpQ/0Nkb5Utaimby7oD92+18noBxLPE85IFOvptdzau8dvcxAOwfwHo9iqapbKeFzqQM/Q==", + "devOptional": true, + "license": "MIT" + }, "node_modules/@opencode/theme": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@opencode/theme/-/theme-2.0.4.tgz", - "integrity": "sha512-z0iLvKSKltIiFtPDpsh4dOMurYRhk7fuB+yAvf5sDgrpMvwJdIEBZI9grH7Uap/FPZtQLG99xdf2BEaTfd//Aw==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@opencode/theme/-/theme-2.3.2.tgz", + "integrity": "sha512-07OePMc3Fiv8MR/OCgMdt033OZkHExwQCDEM8XSej3sYT6OO7IR7G2MkQEW2DRRk7UscKUjwwl8s+1saf2zZag==", "dev": true, "license": "MIT", "dependencies": { - "@opentui/core": "0.5.10", - "effect": "4.0.0-rc.112" + "@opentui/core": "0.8.4", + "effect": "4.1.0" } }, "node_modules/@opencode/theme/node_modules/@opentui/core": { - "version": "0.5.10", - "resolved": "https://registry.npmjs.org/@opentui/core/-/core-0.5.10.tgz", - "integrity": "sha512-C3a2UbmefeAjIxAgm4BqjuSxKT4oqutfvYFwVvUgMxmGRHkNbBc/s7sukV0JgwcxFcV3uMFrXxo+E+BQtvuOiw==", + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/@opentui/core/-/core-0.8.4.tgz", + "integrity": "sha512-s2z2FFEWxsQ6IPVEiAjlHHY5yssnCI+dIltL54+ZhVz1EWxylaB0HER+ypPL2goot0DKwKqrM57rnomh19/2rQ==", "dev": true, "license": "MIT", "dependencies": { "bun-ffi-structs": "0.3.1", "diff": "9.0.0", "marked": "17.0.1", - "string-width": "7.2.0", - "strip-ansi": "7.1.2" + "string-width": "7.2.0" + }, + "engines": { + "bun": ">=1.3.14", + "node": ">=26.4.0" }, "optionalDependencies": { - "@opentui/core-darwin-arm64": "0.5.10", - "@opentui/core-darwin-x64": "0.5.10", - "@opentui/core-linux-arm64": "0.5.10", - "@opentui/core-linux-arm64-musl": "0.5.10", - "@opentui/core-linux-x64": "0.5.10", - "@opentui/core-linux-x64-musl": "0.5.10", - "@opentui/core-win32-arm64": "0.5.10", - "@opentui/core-win32-x64": "0.5.10" + "@opentui/core-darwin-arm64": "0.8.4", + "@opentui/core-darwin-x64": "0.8.4", + "@opentui/core-linux-arm64": "0.8.4", + "@opentui/core-linux-arm64-musl": "0.8.4", + "@opentui/core-linux-x64": "0.8.4", + "@opentui/core-linux-x64-musl": "0.8.4", + "@opentui/core-win32-arm64": "0.8.4", + "@opentui/core-win32-x64": "0.8.4" }, "peerDependencies": { "web-tree-sitter": "0.25.10" } }, "node_modules/@opencode/theme/node_modules/@opentui/core-darwin-arm64": { - "version": "0.5.10", - "resolved": "https://registry.npmjs.org/@opentui/core-darwin-arm64/-/core-darwin-arm64-0.5.10.tgz", - "integrity": "sha512-Vyb+nTbhab8ZcRy5gg1loEEGwRcIbjAeVRIBfHBcbFDqmITBOg7x2gqJ+x/TnoOy4uwMhCmICUN2wiyREw3r1Q==", + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/@opentui/core-darwin-arm64/-/core-darwin-arm64-0.8.4.tgz", + "integrity": "sha512-kAWCmLsGuxQANeq4AjjX0Yodca2VIofQGUfIH9Edg9BKajYpf941heZfMJkkkJUXawYTNFTR2lBYsdneUUJBrg==", "cpu": [ "arm64" ], "dev": true, - "license": "MIT", + "license": "MIT AND LGPL-2.1-or-later", "optional": true, "os": [ "darwin" ] }, "node_modules/@opencode/theme/node_modules/@opentui/core-darwin-x64": { - "version": "0.5.10", - "resolved": "https://registry.npmjs.org/@opentui/core-darwin-x64/-/core-darwin-x64-0.5.10.tgz", - "integrity": "sha512-tTFLcM7Oj1gTyhm/bUdAt3C6grZdCxPk6+/g2azcZBUlI3/62LwbeRS6HbQKFFmm+1fUmX8cq6kWrtul885mVg==", + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/@opentui/core-darwin-x64/-/core-darwin-x64-0.8.4.tgz", + "integrity": "sha512-0S62YHtIh1Q9tTun7065njEtYUUtf1zXwllDKXr63R1cVgq+8eRdVQ2PsAGNOqB5OYYno+M8o2tuK/Es2uvmBA==", "cpu": [ "x64" ], "dev": true, - "license": "MIT", + "license": "MIT AND LGPL-2.1-or-later", "optional": true, "os": [ "darwin" ] }, "node_modules/@opencode/theme/node_modules/@opentui/core-linux-arm64": { - "version": "0.5.10", - "resolved": "https://registry.npmjs.org/@opentui/core-linux-arm64/-/core-linux-arm64-0.5.10.tgz", - "integrity": "sha512-ncJXcgudhBf2GdJyF3xVQN/Ec+1F7GOL+pRrURmgBYSj2v1w6EyoDQFAACtPTK2c3R38W6fvZwL4JSLlm4EFXQ==", + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/@opentui/core-linux-arm64/-/core-linux-arm64-0.8.4.tgz", + "integrity": "sha512-VGnBN3ItBwZog109wtPIou8pn93TseZwA5OZ05X2PYIYPw+IC6mVeO2Dn0qwwozLBDxeyH3ydbHMFlwzS4/fLg==", "cpu": [ "arm64" ], "dev": true, - "license": "MIT", + "license": "MIT AND LGPL-2.1-or-later", "optional": true, "os": [ "linux" ] }, "node_modules/@opencode/theme/node_modules/@opentui/core-linux-arm64-musl": { - "version": "0.5.10", - "resolved": "https://registry.npmjs.org/@opentui/core-linux-arm64-musl/-/core-linux-arm64-musl-0.5.10.tgz", - "integrity": "sha512-dGMphDKexSdeYqwl0wgoFBP88Ta/cdi1Zc1mk29/ENkSCGz+74zlCHgqTHRNGLmI8W5TfuUtCyktQH11/Z+TBQ==", + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/@opentui/core-linux-arm64-musl/-/core-linux-arm64-musl-0.8.4.tgz", + "integrity": "sha512-IG887NHjPJEw5D1dvNl9jPbcwNFREFKj2fnqEjdrwCnDRywtjNL7k7GgTo24NNlyMAZAq0OkoM0M0Sn6ex/Adg==", "cpu": [ "arm64" ], "dev": true, - "license": "MIT", + "license": "MIT AND LGPL-2.1-or-later", "optional": true, "os": [ "linux" ] }, "node_modules/@opencode/theme/node_modules/@opentui/core-linux-x64": { - "version": "0.5.10", - "resolved": "https://registry.npmjs.org/@opentui/core-linux-x64/-/core-linux-x64-0.5.10.tgz", - "integrity": "sha512-5qtYaOgwVycZD1GaGshTRsi0rXPAmVExO03N1JQaHu+NYxK/vXSOc7Bu4QW0sPXx3Sp0SpzpP+FHjXABfoK66g==", + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/@opentui/core-linux-x64/-/core-linux-x64-0.8.4.tgz", + "integrity": "sha512-N/uxyaPpWkCZlDXz3fgHMfMuj1L3IVZ/xZ4JifUc4NW9bwa/CYWFJ5J5jBoy2QsAIqoqo8/OD3iFpXR4o12mNQ==", "cpu": [ "x64" ], "dev": true, - "license": "MIT", + "license": "MIT AND LGPL-2.1-or-later", "optional": true, "os": [ "linux" ] }, "node_modules/@opencode/theme/node_modules/@opentui/core-linux-x64-musl": { - "version": "0.5.10", - "resolved": "https://registry.npmjs.org/@opentui/core-linux-x64-musl/-/core-linux-x64-musl-0.5.10.tgz", - "integrity": "sha512-Oj4H9hApuvuTKPWxh4SoZAgGJorR7vbvnrZA/cAkSMAk2VGSoHRRcqeXQbcH8IcdjVZ0KFpv8Zkl/D5Ye+2mew==", + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/@opentui/core-linux-x64-musl/-/core-linux-x64-musl-0.8.4.tgz", + "integrity": "sha512-FAiH7wMt/ZbpP2w6TL62deNExTg5w6mujKUBSK89+gJV8FN4jk/K2xz9f522aYhC6SdbpyIKwS0oGIJldYLkcg==", "cpu": [ "x64" ], "dev": true, - "license": "MIT", + "license": "MIT AND LGPL-2.1-or-later", "optional": true, "os": [ "linux" ] }, "node_modules/@opencode/theme/node_modules/@opentui/core-win32-arm64": { - "version": "0.5.10", - "resolved": "https://registry.npmjs.org/@opentui/core-win32-arm64/-/core-win32-arm64-0.5.10.tgz", - "integrity": "sha512-A9VhgvTxQoUdZ+8LmUumEng1sQNbj9QQQT3NYG9mSxI54qTANi7vOWNSphMiY6RMVsr22pgm6nUvSSvJXv7Jog==", + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/@opentui/core-win32-arm64/-/core-win32-arm64-0.8.4.tgz", + "integrity": "sha512-vjDuuIcmanoipIKdME8A7ZuBgIw2E1fv4pRJp6M19+Zfx0HIUmtA8bv+mT/kaz8Cpad9EUzJkNI5fV8P2p/iKg==", "cpu": [ "arm64" ], "dev": true, - "license": "MIT", + "license": "MIT AND LGPL-2.1-or-later", "optional": true, "os": [ "win32" ] }, "node_modules/@opencode/theme/node_modules/@opentui/core-win32-x64": { - "version": "0.5.10", - "resolved": "https://registry.npmjs.org/@opentui/core-win32-x64/-/core-win32-x64-0.5.10.tgz", - "integrity": "sha512-u3KHa7kEeWrmKVDRJYpxSGO+g5E9cMGlrmTsPN3GVPHUmQMiREUawLXUvsU8+IHaQnqG3Q5nuE1yf4fPBzS+Qw==", + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/@opentui/core-win32-x64/-/core-win32-x64-0.8.4.tgz", + "integrity": "sha512-I4XnzUmyKCb8cRD1UntQXRkIEl0fxfQnzS3bTODWbENAOdRsK2c7Ff07DG2qTAqNijyTuk63C+uLmAT9ObOQ1Q==", "cpu": [ "x64" ], "dev": true, - "license": "MIT", + "license": "MIT AND LGPL-2.1-or-later", "optional": true, "os": [ "win32" ] }, + "node_modules/@opencode/theme/node_modules/effect": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/effect/-/effect-4.1.0.tgz", + "integrity": "sha512-lGx2MJJyrXA8RZb2UpQ/0Nkb5Utaimby7oD92+18noBxLPE85IFOvptdzau8dvcxAOwfwHo9iqapbKeFzqQM/Q==", + "dev": true, + "license": "MIT" + }, "node_modules/@opencode/util": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@opencode/util/-/util-2.0.4.tgz", - "integrity": "sha512-jo6zhWqJ4WaU+fUjM8/Ea4i06gxTQFEFgfq2XG9J8gSDUhfsj4l9wJ3cLtSuKFQGeUeWqJJwRgDhCW+rUbis6Q==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@opencode/util/-/util-2.3.2.tgz", + "integrity": "sha512-ntNbSHLWwY5uHEj+u0U6fRdUldTX9+THklfnMsybQ6SHOyv7H5eppX/Se59daJlfcxq5AfkIKnp3Cide6OR8kw==", "devOptional": true, "license": "MIT", "dependencies": { - "@effect/opentelemetry": "4.0.0-rc.112", - "@effect/platform-node": "4.0.0-rc.112", - "@effect/platform-node-shared": "4.0.0-rc.112", + "@effect/opentelemetry": "4.1.0", + "@effect/platform-node": "4.1.0", + "@effect/platform-node-shared": "4.1.0", "@npmcli/arborist": "9.4.0", "@npmcli/config": "10.8.1", "@opentelemetry/api": "1.9.0", - "@opentelemetry/context-async-hooks": "2.6.1", - "@opentelemetry/exporter-trace-otlp-http": "0.214.0", - "@opentelemetry/sdk-trace-base": "2.6.1", - "@opentelemetry/sdk-trace-node": "2.6.1", + "@opentelemetry/api-logs": "0.219.0", + "@opentelemetry/context-async-hooks": "2.8.0", + "@opentelemetry/exporter-trace-otlp-http": "0.219.0", + "@opentelemetry/resources": "2.8.0", + "@opentelemetry/sdk-logs": "0.219.0", + "@opentelemetry/sdk-metrics": "2.8.0", + "@opentelemetry/sdk-trace-base": "2.8.0", + "@opentelemetry/sdk-trace-node": "2.8.0", "cross-spawn": "7.0.6", - "effect": "4.0.0-rc.112", + "effect": "4.1.0", "glob": "13.0.5", "mime-types": "3.0.2", "minimatch": "10.2.5", "npm-package-arg": "13.0.2", + "open": "11.0.4", "pacote": "21.5.1" } }, + "node_modules/@opencode/util/node_modules/@effect/opentelemetry": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@effect/opentelemetry/-/opentelemetry-4.1.0.tgz", + "integrity": "sha512-j9bNzQaoQvcnimBFMG0i3piEW20E8HjkXAQHTJN/XqG2e4uJ9zCv53/HCNzD7+ooFn5S4nwQy/BOXeNReMIe+A==", + "devOptional": true, + "license": "MIT", + "engines": { + "node": ">=22.19.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.9.0 <2.0.0", + "@opentelemetry/api-logs": ">=0.203.0 <0.300.0", + "@opentelemetry/resources": ">=2.0.0 <3.0.0", + "@opentelemetry/sdk-logs": ">=0.203.0 <0.300.0", + "@opentelemetry/sdk-metrics": ">=2.0.0 <3.0.0", + "@opentelemetry/sdk-trace-base": ">=2.0.0 <3.0.0", + "@opentelemetry/sdk-trace-node": ">=2.0.0 <3.0.0", + "@opentelemetry/sdk-trace-web": ">=2.0.0 <3.0.0", + "@opentelemetry/semantic-conventions": ">=1.33.0 <2.0.0", + "effect": "^4.1.0" + }, + "peerDependenciesMeta": { + "@opentelemetry/api": { + "optional": true + }, + "@opentelemetry/api-logs": { + "optional": true + }, + "@opentelemetry/resources": { + "optional": true + }, + "@opentelemetry/sdk-logs": { + "optional": true + }, + "@opentelemetry/sdk-metrics": { + "optional": true + }, + "@opentelemetry/sdk-trace-base": { + "optional": true + }, + "@opentelemetry/sdk-trace-node": { + "optional": true + }, + "@opentelemetry/sdk-trace-web": { + "optional": true + } + } + }, + "node_modules/@opencode/util/node_modules/@effect/platform-node": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@effect/platform-node/-/platform-node-4.1.0.tgz", + "integrity": "sha512-v+X7moGVF9k5oMVvz0slA+NgtEod+W+oygeI285MDJgSlUCW3JcqElj+cD3rlijFZtpKhC7RLkU1GuCxjGHTpA==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "@effect/platform-node-shared": "^4.1.0", + "undici": "^8.12.2" + }, + "engines": { + "node": ">=22.19.0" + }, + "peerDependencies": { + "effect": "^4.1.0", + "redis": ">=5.0.0 <7.0.0" + } + }, + "node_modules/@opencode/util/node_modules/@effect/platform-node-shared": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/@effect/platform-node-shared/-/platform-node-shared-4.1.0.tgz", + "integrity": "sha512-uYQfFRoxWLo8fIhiSeBcmz/R1ooOfE3HF3cWHFgxz82tZMk2Wn02BGABcdLmaAch9VpDLbtWnuhSxNyBsGMUFg==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "@types/ws": "^8.18.2", + "ws": "^8.22.0" + }, + "engines": { + "node": ">=22.19.0" + }, + "peerDependencies": { + "effect": "^4.1.0" + } + }, "node_modules/@opencode/util/node_modules/balanced-match": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", @@ -2687,9 +2611,9 @@ } }, "node_modules/@opencode/util/node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz", + "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==", "devOptional": true, "license": "MIT", "dependencies": { @@ -2699,6 +2623,13 @@ "node": "20 || >=22" } }, + "node_modules/@opencode/util/node_modules/effect": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/effect/-/effect-4.1.0.tgz", + "integrity": "sha512-lGx2MJJyrXA8RZb2UpQ/0Nkb5Utaimby7oD92+18noBxLPE85IFOvptdzau8dvcxAOwfwHo9iqapbKeFzqQM/Q==", + "devOptional": true, + "license": "MIT" + }, "node_modules/@opencode/util/node_modules/glob": { "version": "13.0.5", "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.5.tgz", @@ -2718,9 +2649,9 @@ } }, "node_modules/@opencode/util/node_modules/lru-cache": { - "version": "11.5.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz", - "integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==", + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", "devOptional": true, "license": "BlueOak-1.0.0", "engines": { @@ -2781,9 +2712,9 @@ } }, "node_modules/@opentelemetry/api-logs": { - "version": "0.214.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.214.0.tgz", - "integrity": "sha512-40lSJeqYO8Uz2Yj7u94/SJWE/wONa7rmMKjI1ZcIjgf3MHNHv1OZUCrCETGuaRF62d5pQD1wKIW+L4lmSMTzZA==", + "version": "0.219.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.219.0.tgz", + "integrity": "sha512-FFx7YnaYJlIjqWW/AG/yAZ0L/NEY724PipXXXQLdtZPbLwBGbUMTGL1i/esI56TWfTUXxhLfpgrnWJCG8aUJyg==", "devOptional": true, "license": "Apache-2.0", "dependencies": { @@ -2794,9 +2725,9 @@ } }, "node_modules/@opentelemetry/context-async-hooks": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/@opentelemetry/context-async-hooks/-/context-async-hooks-2.6.1.tgz", - "integrity": "sha512-XHzhwRNkBpeP8Fs/qjGrAf9r9PRv67wkJQ/7ZPaBQQ68DYlTBBx5MF9LvPx7mhuXcDessKK2b+DcxqwpgkcivQ==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/context-async-hooks/-/context-async-hooks-2.8.0.tgz", + "integrity": "sha512-/3FIraneMcng67SUJCxvyInk/oxzwsxyadufk0wwfOBLf5wqtAGX4MoQASwSbndBPeARzBryUM9Azr5kHIdWLw==", "devOptional": true, "license": "Apache-2.0", "engines": { @@ -2807,9 +2738,9 @@ } }, "node_modules/@opentelemetry/core": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.6.1.tgz", - "integrity": "sha512-8xHSGWpJP9wBxgBpnqGL0R3PbdWQndL1Qp50qrg71+B28zK5OQmUgcDKLJgzyAAV38t4tOyLMGDD60LneR5W8g==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.8.0.tgz", + "integrity": "sha512-hd1Lfh8p545nNz+jq1Ejfz+Mn1hyLuxYn1YzTfFNrxr8urEWMNQLPf1Th8kjOH+HxwawCrtgBp8JpBUR4ZSgww==", "devOptional": true, "license": "Apache-2.0", "dependencies": { @@ -2823,17 +2754,17 @@ } }, "node_modules/@opentelemetry/exporter-trace-otlp-http": { - "version": "0.214.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-trace-otlp-http/-/exporter-trace-otlp-http-0.214.0.tgz", - "integrity": "sha512-kIN8nTBMgV2hXzV/a20BCFilPZdAIMYYJGSgfMMRm/Xa+07y5hRDS2Vm12A/z8Cdu3Sq++ZvJfElokX2rkgGgw==", + "version": "0.219.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-trace-otlp-http/-/exporter-trace-otlp-http-0.219.0.tgz", + "integrity": "sha512-9t6SvBXXBEjOBcIzgozvBbd3jWrv3Gt3ngGhl1fhdZ/zRc7oZDVOFEqbi2zlBpW9BXhgDMKv422J0DL/3iQWfw==", "devOptional": true, "license": "Apache-2.0", "dependencies": { - "@opentelemetry/core": "2.6.1", - "@opentelemetry/otlp-exporter-base": "0.214.0", - "@opentelemetry/otlp-transformer": "0.214.0", - "@opentelemetry/resources": "2.6.1", - "@opentelemetry/sdk-trace-base": "2.6.1" + "@opentelemetry/core": "2.8.0", + "@opentelemetry/otlp-exporter-base": "0.219.0", + "@opentelemetry/otlp-transformer": "0.219.0", + "@opentelemetry/resources": "2.8.0", + "@opentelemetry/sdk-trace-base": "2.8.0" }, "engines": { "node": "^18.19.0 || >=20.6.0" @@ -2843,14 +2774,14 @@ } }, "node_modules/@opentelemetry/otlp-exporter-base": { - "version": "0.214.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-exporter-base/-/otlp-exporter-base-0.214.0.tgz", - "integrity": "sha512-u1Gdv0/E9wP+apqWf7Wv2npXmgJtxsW2XL0TEv9FZloTZRuMBKmu8cYVXwS4Hm3q/f/3FuCnPTgiwYvIqRSpRg==", + "version": "0.219.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-exporter-base/-/otlp-exporter-base-0.219.0.tgz", + "integrity": "sha512-zvIxQX/AZUVKDU+hCuYx+7UkiP7GRdnk1ZbFQRYzHvYp47cAWR4j3IhoPhV9KaeXEv2xdGq3IA6PnpzDmLcmSA==", "devOptional": true, "license": "Apache-2.0", "dependencies": { - "@opentelemetry/core": "2.6.1", - "@opentelemetry/otlp-transformer": "0.214.0" + "@opentelemetry/core": "2.8.0", + "@opentelemetry/otlp-transformer": "0.219.0" }, "engines": { "node": "^18.19.0 || >=20.6.0" @@ -2860,19 +2791,18 @@ } }, "node_modules/@opentelemetry/otlp-transformer": { - "version": "0.214.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.214.0.tgz", - "integrity": "sha512-DSaYcuBRh6uozfsWN3R8HsN0yDhCuWP7tOFdkUOVaWD1KVJg8m4qiLUsg/tNhTLS9HUYUcwNpwL2eroLtsZZ/w==", + "version": "0.219.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.219.0.tgz", + "integrity": "sha512-aaYKAyXhw9VchKZVGOopD3Gw/kPsyrX2c6IQ0AW32mTjqmZOh5Y6Gf5OYqTNqVktAeBjmFinhyFaCwW6GYK9YQ==", "devOptional": true, "license": "Apache-2.0", "dependencies": { - "@opentelemetry/api-logs": "0.214.0", - "@opentelemetry/core": "2.6.1", - "@opentelemetry/resources": "2.6.1", - "@opentelemetry/sdk-logs": "0.214.0", - "@opentelemetry/sdk-metrics": "2.6.1", - "@opentelemetry/sdk-trace-base": "2.6.1", - "protobufjs": "^7.0.0" + "@opentelemetry/api-logs": "0.219.0", + "@opentelemetry/core": "2.8.0", + "@opentelemetry/resources": "2.8.0", + "@opentelemetry/sdk-logs": "0.219.0", + "@opentelemetry/sdk-metrics": "2.8.0", + "@opentelemetry/sdk-trace-base": "2.8.0" }, "engines": { "node": "^18.19.0 || >=20.6.0" @@ -2882,13 +2812,13 @@ } }, "node_modules/@opentelemetry/resources": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.6.1.tgz", - "integrity": "sha512-lID/vxSuKWXM55XhAKNoYXu9Cutoq5hFdkbTdI/zDKQktXzcWBVhNsOkiZFTMU9UtEWuGRNe0HUgmsFldIdxVA==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.8.0.tgz", + "integrity": "sha512-qmXQ27ilDbUK/vGMqwL8D4/rhn76C+sherM4wTbjlfknR8Nvfc/hCxjRJPhkzZzUsPiNg16SA31NxMabwttRjg==", "devOptional": true, "license": "Apache-2.0", "dependencies": { - "@opentelemetry/core": "2.6.1", + "@opentelemetry/core": "2.8.0", "@opentelemetry/semantic-conventions": "^1.29.0" }, "engines": { @@ -2899,15 +2829,15 @@ } }, "node_modules/@opentelemetry/sdk-logs": { - "version": "0.214.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.214.0.tgz", - "integrity": "sha512-zf6acnScjhsaBUU22zXZ/sLWim1dfhUAbGXdMmHmNG3LfBnQ3DKsOCITb2IZwoUsNNMTogqFKBnlIPPftUgGwA==", + "version": "0.219.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.219.0.tgz", + "integrity": "sha512-s6lTKRakaPClvKoWHRChxnXjDMkM/TQ30ff78jN6EBGf7MI7VzANE5PU3f4z9qDUudWjvZjOLHG0rBnBKYvoXA==", "devOptional": true, "license": "Apache-2.0", "dependencies": { - "@opentelemetry/api-logs": "0.214.0", - "@opentelemetry/core": "2.6.1", - "@opentelemetry/resources": "2.6.1", + "@opentelemetry/api-logs": "0.219.0", + "@opentelemetry/core": "2.8.0", + "@opentelemetry/resources": "2.8.0", "@opentelemetry/semantic-conventions": "^1.29.0" }, "engines": { @@ -2918,14 +2848,14 @@ } }, "node_modules/@opentelemetry/sdk-metrics": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-2.6.1.tgz", - "integrity": "sha512-9t9hJHX15meBy2NmTJxL+NJfXmnausR2xUDvE19XQce0Qi/GBtDGamU8nS1RMbdgDmhgpm3VaOu2+fiS/SfTpQ==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-2.8.0.tgz", + "integrity": "sha512-UDBGaj6W0Rgy5rTTaoxs8gVGF/aGkAKyjurJv7se6wjRxJu7FoquTLT/vt54DZfo4crbprYfhX/SOK9+BPw1qg==", "devOptional": true, "license": "Apache-2.0", "dependencies": { - "@opentelemetry/core": "2.6.1", - "@opentelemetry/resources": "2.6.1" + "@opentelemetry/core": "2.8.0", + "@opentelemetry/resources": "2.8.0" }, "engines": { "node": "^18.19.0 || >=20.6.0" @@ -2935,14 +2865,15 @@ } }, "node_modules/@opentelemetry/sdk-trace-base": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-2.6.1.tgz", - "integrity": "sha512-r86ut4T1e8vNwB35CqCcKd45yzqH6/6Wzvpk2/cZB8PsPLlZFTvrh8yfOS3CYZYcUmAx4hHTZJ8AO8Dj8nrdhw==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-2.8.0.tgz", + "integrity": "sha512-mhU4jp+vW0mGbFRd+GeXHvmfA4aDqWjBjLC3pE5XMpLs0IE2ryYb019Ts2AQrOq67gaTF25D91+fgvEHDZEnuQ==", + "deprecated": "Use @opentelemetry/sdk-trace package", "devOptional": true, "license": "Apache-2.0", "dependencies": { - "@opentelemetry/core": "2.6.1", - "@opentelemetry/resources": "2.6.1", + "@opentelemetry/core": "2.8.0", + "@opentelemetry/resources": "2.8.0", "@opentelemetry/semantic-conventions": "^1.29.0" }, "engines": { @@ -2953,15 +2884,16 @@ } }, "node_modules/@opentelemetry/sdk-trace-node": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-node/-/sdk-trace-node-2.6.1.tgz", - "integrity": "sha512-Hh2i4FwHWRFhnO2Q/p6svMxy8MPsNCG0uuzUY3glqm0rwM0nQvbTO1dXSp9OqQoTKXcQzaz9q1f65fsurmOhNw==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-node/-/sdk-trace-node-2.8.0.tgz", + "integrity": "sha512-nZt9OGufioAc3AfoLTqA9bsAeaMJAictYDdI2VcNQ+PmT+3rfKjAZDZvgPfd8VPX0O5Bw1hdQF6kDK8VSpZiWg==", + "deprecated": "Use @opentelemetry/sdk-trace package", "devOptional": true, "license": "Apache-2.0", "dependencies": { - "@opentelemetry/context-async-hooks": "2.6.1", - "@opentelemetry/core": "2.6.1", - "@opentelemetry/sdk-trace-base": "2.6.1" + "@opentelemetry/context-async-hooks": "2.8.0", + "@opentelemetry/core": "2.8.0", + "@opentelemetry/sdk-trace-base": "2.8.0" }, "engines": { "node": "^18.19.0 || >=20.6.0" @@ -2971,9 +2903,9 @@ } }, "node_modules/@opentelemetry/semantic-conventions": { - "version": "1.43.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.43.0.tgz", - "integrity": "sha512-eSYWTm620tTk45EKSedaUL8MFYI8hW164hIXsgIHyxu3VobUB3fFCu5t0hQby6OoWRPsG1KkKUG2M5UadiLiVg==", + "version": "1.45.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.45.0.tgz", + "integrity": "sha512-aOP45mbcOKbQVvFWfQmgoOPT8R2iwbbbgl83k4CujGV9BrJhFr3qG55MFpwFs4YLabpuW3HhzUY9eQxPlDqaZw==", "devOptional": true, "license": "Apache-2.0", "engines": { @@ -2981,14 +2913,13 @@ } }, "node_modules/@opentui/core": { - "version": "0.6.8", - "resolved": "https://registry.npmjs.org/@opentui/core/-/core-0.6.8.tgz", - "integrity": "sha512-wjqLwLdYGy/6qEBTtZEifuwwVzt06o0BqBF02xJ46whGEUK/gy+h25+1GK4dE9LFnHphgsqeA31f7PHBJPp91w==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/@opentui/core/-/core-0.9.3.tgz", + "integrity": "sha512-DIVj5F59i0a6pDC9ZH5M4DkR/GlbnoExPrev++mz2FlGWbO1I6GhyCflwmLefIdoewUN5Dw0zRNgNfDqoKEg4w==", "license": "MIT", "dependencies": { "bun-ffi-structs": "0.3.1", "diff": "9.0.0", - "marked": "17.0.1", "string-width": "7.2.0" }, "engines": { @@ -2996,139 +2927,139 @@ "node": ">=26.4.0" }, "optionalDependencies": { - "@opentui/core-darwin-arm64": "0.6.8", - "@opentui/core-darwin-x64": "0.6.8", - "@opentui/core-linux-arm64": "0.6.8", - "@opentui/core-linux-arm64-musl": "0.6.8", - "@opentui/core-linux-x64": "0.6.8", - "@opentui/core-linux-x64-musl": "0.6.8", - "@opentui/core-win32-arm64": "0.6.8", - "@opentui/core-win32-x64": "0.6.8" + "@opentui/core-darwin-arm64": "0.9.3", + "@opentui/core-darwin-x64": "0.9.3", + "@opentui/core-linux-arm64": "0.9.3", + "@opentui/core-linux-arm64-musl": "0.9.3", + "@opentui/core-linux-x64": "0.9.3", + "@opentui/core-linux-x64-musl": "0.9.3", + "@opentui/core-win32-arm64": "0.9.3", + "@opentui/core-win32-x64": "0.9.3" }, "peerDependencies": { "web-tree-sitter": "0.25.10" } }, "node_modules/@opentui/core-darwin-arm64": { - "version": "0.6.8", - "resolved": "https://registry.npmjs.org/@opentui/core-darwin-arm64/-/core-darwin-arm64-0.6.8.tgz", - "integrity": "sha512-kmu5Rp5qC3StrGAzLvBu6SLEXd2Qq60Yf0YCmL7BmDgYt0QUZ4M2JsSS7BFg7crpk+4Yz17N1ZeOCPumE4s83w==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/@opentui/core-darwin-arm64/-/core-darwin-arm64-0.9.3.tgz", + "integrity": "sha512-zEyxo8tPBOXBmPx7uNZk8DuqyvxFpXO4uUxiNiX4P0zk0uQNtyrMtawryUA20iadTcUK3fr/P6DI5qQPVjvS+g==", "cpu": [ "arm64" ], - "license": "MIT", + "license": "MIT AND LGPL-2.1-or-later", "optional": true, "os": [ "darwin" ] }, "node_modules/@opentui/core-darwin-x64": { - "version": "0.6.8", - "resolved": "https://registry.npmjs.org/@opentui/core-darwin-x64/-/core-darwin-x64-0.6.8.tgz", - "integrity": "sha512-eGJcssaONQ32+xYOTRCdGGXnsMJJJLn6mHYt0W79Lck8zlMuel5dWWlCbxdM3qvX/IEHr+f56bGoojTvJjDw6w==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/@opentui/core-darwin-x64/-/core-darwin-x64-0.9.3.tgz", + "integrity": "sha512-oWquIfk4MQVed9E6eC5SYb0O+MX2MvdhVNOZCTMgagTU0fGuYaB3YRuqGVRtgammkjXmXaVFdXVYQnnTvKCEYQ==", "cpu": [ "x64" ], - "license": "MIT", + "license": "MIT AND LGPL-2.1-or-later", "optional": true, "os": [ "darwin" ] }, "node_modules/@opentui/core-linux-arm64": { - "version": "0.6.8", - "resolved": "https://registry.npmjs.org/@opentui/core-linux-arm64/-/core-linux-arm64-0.6.8.tgz", - "integrity": "sha512-ji2LPeEX4RU6RKC0/l70hZWmqD0AvvMvnd3WvpZUNOeaIBFseSzE0QEl3apRPUqAoYiuL7uRgwSV4eewa+xXpg==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/@opentui/core-linux-arm64/-/core-linux-arm64-0.9.3.tgz", + "integrity": "sha512-JFOJUwm5gg0JniigcXLeFmgTAVEgbFaLhQxRoUokROcaVgNMs3aMuBqFXpOdhH7jU3HT3cHPHP3fhrbI002fEQ==", "cpu": [ "arm64" ], - "license": "MIT", + "license": "MIT AND LGPL-2.1-or-later", "optional": true, "os": [ "linux" ] }, "node_modules/@opentui/core-linux-arm64-musl": { - "version": "0.6.8", - "resolved": "https://registry.npmjs.org/@opentui/core-linux-arm64-musl/-/core-linux-arm64-musl-0.6.8.tgz", - "integrity": "sha512-b+3TI8rtFBQa7T04F7XVt1I8/eL2+GX0X6x9WbDBnNmolgf1DX3ZdVPmKEP8PlxAmDYB+gek+cQAwnkwiYl5YQ==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/@opentui/core-linux-arm64-musl/-/core-linux-arm64-musl-0.9.3.tgz", + "integrity": "sha512-RMn9XWodLs7JCMRuPqc3ybatJWwqDHJA+FyI3tI2c7g/G4Dn8sGodbroARclPLU5E/uIC78K4//LUylxB5wfMA==", "cpu": [ "arm64" ], - "license": "MIT", + "license": "MIT AND LGPL-2.1-or-later", "optional": true, "os": [ "linux" ] }, "node_modules/@opentui/core-linux-x64": { - "version": "0.6.8", - "resolved": "https://registry.npmjs.org/@opentui/core-linux-x64/-/core-linux-x64-0.6.8.tgz", - "integrity": "sha512-g8hOxXpff7hOnZNlJRKCqWJr/dwVK/EyEhNsgNK4jLS13BUoaYWXi878xLXJ5acC82qEyGlYWL/kR6ACkiD0YA==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/@opentui/core-linux-x64/-/core-linux-x64-0.9.3.tgz", + "integrity": "sha512-y5jVc28p2UULazGELqblXRp8TczyBUwaP/1wFcB+LwBOJuiEXgyrcgr9Iw/E+TslRYJ3RVHABz8jWGbdPiQjGg==", "cpu": [ "x64" ], - "license": "MIT", + "license": "MIT AND LGPL-2.1-or-later", "optional": true, "os": [ "linux" ] }, "node_modules/@opentui/core-linux-x64-musl": { - "version": "0.6.8", - "resolved": "https://registry.npmjs.org/@opentui/core-linux-x64-musl/-/core-linux-x64-musl-0.6.8.tgz", - "integrity": "sha512-eVQSjO5wXYiqunz/V92WweHvVTCV+LtZOnu0z6kYjwwbAvsnTxISOFAyA9H71Sy3tsibjiu1o+E27twDyM9HlA==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/@opentui/core-linux-x64-musl/-/core-linux-x64-musl-0.9.3.tgz", + "integrity": "sha512-dEzNJMCBi7rEnX8mWTnxQaprcnqTRyU73gE2g5zQyQnXOGi2rVbcIzbxCQesnyDq3YRUHd30MUGeppF82qw6tw==", "cpu": [ "x64" ], - "license": "MIT", + "license": "MIT AND LGPL-2.1-or-later", "optional": true, "os": [ "linux" ] }, "node_modules/@opentui/core-win32-arm64": { - "version": "0.6.8", - "resolved": "https://registry.npmjs.org/@opentui/core-win32-arm64/-/core-win32-arm64-0.6.8.tgz", - "integrity": "sha512-P4llQH8kFeiknVp0kfTydKaJC95BSW4mf3fub9HMgFx49eiF3qgcctbebZN+/WaD8Pshu0wiN1KPitqDTyrIDw==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/@opentui/core-win32-arm64/-/core-win32-arm64-0.9.3.tgz", + "integrity": "sha512-JDuSQAEWFjRS3hstOk62QJ9NAuoaJgpQf+A4p/c+LZQUMKDAJXP7/Y6EKXQcWhGbv1FsZseoSmsTFbSTYaisZg==", "cpu": [ "arm64" ], - "license": "MIT", + "license": "MIT AND LGPL-2.1-or-later", "optional": true, "os": [ "win32" ] }, "node_modules/@opentui/core-win32-x64": { - "version": "0.6.8", - "resolved": "https://registry.npmjs.org/@opentui/core-win32-x64/-/core-win32-x64-0.6.8.tgz", - "integrity": "sha512-6dZuSw883BDetY59G2QwWHJG1kwfPkL+lWhDQ3a6ICxW4/7nito3uPkMRaRDb8DiTHgx0wMt/RdiydjQmZd+lw==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/@opentui/core-win32-x64/-/core-win32-x64-0.9.3.tgz", + "integrity": "sha512-SMyMpFZzNUhVp2coirNZhTZWoM6942g+V79fwvgq+ymo5nBCPhfxQPQnNBxDxMLb5rt9nowtcs+4NAPPvArJbA==", "cpu": [ "x64" ], - "license": "MIT", + "license": "MIT AND LGPL-2.1-or-later", "optional": true, "os": [ "win32" ] }, "node_modules/@opentui/solid": { - "version": "0.6.8", - "resolved": "https://registry.npmjs.org/@opentui/solid/-/solid-0.6.8.tgz", - "integrity": "sha512-GwLhMdGSRBX1Tlh/aUcbpDwIG/FI15y5xL2yMlNIO27q5yRTiZHeg6yvXv3HgM55ykRm9F8YBhiFcuc5M609FA==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/@opentui/solid/-/solid-0.9.3.tgz", + "integrity": "sha512-rf+Ok2vbKj8TnEWoqvEYaMBVJ63g8Nne/c2vSa9/7P9vM1IUAQ3ZvFJSReF8/zPkH5lcwu6A0h6rSr30UghH8Q==", "license": "MIT", "dependencies": { "@babel/core": "7.29.7", "@babel/preset-typescript": "7.27.1", - "@opentui/core": "0.6.8", + "@opentui/core": "0.9.3", "babel-plugin-module-resolver": "5.0.2", - "babel-preset-solid": "1.9.12", + "babel-preset-solid": "1.9.16", "entities": "7.0.1", "s-js": "^0.4.9" }, "peerDependencies": { - "solid-js": "1.9.12" + "solid-js": "^1.9.12" } }, "node_modules/@pkgjs/parseargs": { @@ -3142,72 +3073,6 @@ "node": ">=14" } }, - "node_modules/@protobufjs/aspromise": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", - "integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==", - "devOptional": true, - "license": "BSD-3-Clause" - }, - "node_modules/@protobufjs/base64": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", - "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==", - "devOptional": true, - "license": "BSD-3-Clause" - }, - "node_modules/@protobufjs/codegen": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.5.tgz", - "integrity": "sha512-zgXFLzW3Ap33e6d0Wlj4MGIm6Ce8O89n/apUaGNB/jx+hw+ruWEp7EwGUshdLKVRCxZW12fp9r40E1mQrf/34g==", - "devOptional": true, - "license": "BSD-3-Clause" - }, - "node_modules/@protobufjs/eventemitter": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.1.tgz", - "integrity": "sha512-vW1GmwMZNnL+gMRaovlh9yZX74kc+TTU3FObkkurpMaRtBfLP3ldjS9KQWlwZgraRE0+dheEEoAxdzcJQ8eXZg==", - "devOptional": true, - "license": "BSD-3-Clause" - }, - "node_modules/@protobufjs/fetch": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.1.tgz", - "integrity": "sha512-GpptLrs57adMSuHi3VNj0mAF8dwh36LMaYF6XyJ6JMWlVsc+t42tm1HSEDmOs3A8fC9yyeisgLhsTVQokOZ0zw==", - "devOptional": true, - "license": "BSD-3-Clause", - "dependencies": { - "@protobufjs/aspromise": "^1.1.1" - } - }, - "node_modules/@protobufjs/float": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", - "integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==", - "devOptional": true, - "license": "BSD-3-Clause" - }, - "node_modules/@protobufjs/path": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", - "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==", - "devOptional": true, - "license": "BSD-3-Clause" - }, - "node_modules/@protobufjs/pool": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", - "integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==", - "devOptional": true, - "license": "BSD-3-Clause" - }, - "node_modules/@protobufjs/utf8": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.2.tgz", - "integrity": "sha512-b1UQwcEZ4yCnMCD8DAL1VlbvBJE9/IX4FTIp7BG1xYpf29SLazLSrqUkj4w7Y5y7cCVP6E5tcqqcI0xemPkHug==", - "devOptional": true, - "license": "BSD-3-Clause" - }, "node_modules/@redis/bloom": { "version": "6.3.1", "resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-6.3.1.tgz", @@ -3917,9 +3782,9 @@ } }, "node_modules/@tufjs/models/node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz", + "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==", "devOptional": true, "license": "MIT", "dependencies": { @@ -3963,9 +3828,9 @@ } }, "node_modules/@types/ws": { - "version": "8.18.1", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz", - "integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==", + "version": "8.18.2", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.2.tgz", + "integrity": "sha512-67MQl+fpWKVTT1NYdnmo3U4sc/xPo/zQBncVnI74qmQa0z/b+1g6iYqNmGCPbxO+zz2aklb08a0oHfegiVd0/w==", "devOptional": true, "license": "MIT", "dependencies": { @@ -4045,9 +3910,9 @@ "license": "MIT" }, "node_modules/babel-plugin-jsx-dom-expressions": { - "version": "0.40.7", - "resolved": "https://registry.npmjs.org/babel-plugin-jsx-dom-expressions/-/babel-plugin-jsx-dom-expressions-0.40.7.tgz", - "integrity": "sha512-/O6JWUmjv03OI9lL2ry9bUjpD5S3PclM55RRJEyCdcFZ5W2SEA/59d+l2hNsk3gI6kiWRdRPdOtqZmsQzFN1pQ==", + "version": "0.40.14", + "resolved": "https://registry.npmjs.org/babel-plugin-jsx-dom-expressions/-/babel-plugin-jsx-dom-expressions-0.40.14.tgz", + "integrity": "sha512-5RDcd9lN4eVJyvIrkV7xwuGT+EYVTnWmqO9A8alGRVVLY95aA/U0cNGWv3ThWeI+/ufe2MMS6lILyuWsHmFBgA==", "license": "MIT", "dependencies": { "@babel/helper-module-imports": "7.18.6", @@ -4086,16 +3951,16 @@ } }, "node_modules/babel-preset-solid": { - "version": "1.9.12", - "resolved": "https://registry.npmjs.org/babel-preset-solid/-/babel-preset-solid-1.9.12.tgz", - "integrity": "sha512-LLqnuKVDlKpyBlMPcH6qEvs/wmS9a+NczppxJ3ryS/c0O5IiSFOIBQi9GzyiGDSbcJpx4Gr87jyFTos1MyEuWg==", + "version": "1.9.16", + "resolved": "https://registry.npmjs.org/babel-preset-solid/-/babel-preset-solid-1.9.16.tgz", + "integrity": "sha512-+0h40Qk2oBfkQ4OGDBHIDtvq/XQiOnCfzjNHmMxriAr8MmdsaIbyJgqYglDs4d70sF8O08sSpx61TKdpUt3oRw==", "license": "MIT", "dependencies": { - "babel-plugin-jsx-dom-expressions": "^0.40.6" + "babel-plugin-jsx-dom-expressions": "^0.40.11" }, "peerDependencies": { "@babel/core": "^7.0.0", - "solid-js": "^1.9.12" + "solid-js": "^1.9.16" }, "peerDependenciesMeta": { "solid-js": { @@ -4153,9 +4018,9 @@ } }, "node_modules/bin-links": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-6.0.2.tgz", - "integrity": "sha512-frE1t78WOwJ45PKV2cF2tNPjTcs9L1J9s6VkrV59wanRP4GlaomuxYPVma7BwthMg8WnfSory4w5PTE6FZZ81w==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-6.0.3.tgz", + "integrity": "sha512-Qg5FD7/YSReWJB1zaM8VIi1l4O637JKK/WPaF/JzJGy/9FcMDWtSklF0dOX5S9X2OMrPGhifIHIKuwtHG0IGFg==", "devOptional": true, "license": "ISC", "dependencies": { @@ -4177,9 +4042,9 @@ "license": "MIT" }, "node_modules/brace-expansion": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz", - "integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==", + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.8.tgz", + "integrity": "sha512-BnlDzDYQoplTsZSvPi86CNzmbcb07X8ufR8fk1zivaiEJlXJkiq1MQyDCVmlWcsWbj6aWXqHnrwwevbrm/Saig==", "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" @@ -4234,6 +4099,22 @@ "typescript": "^5" } }, + "node_modules/bundle-name": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.1.tgz", + "integrity": "sha512-DdH81/zPLVS11EUgWq3tEu/xn+EzljlMYooDNdzWEnFha3R3NBMpMV1UqYIpjYHV/SgpFKMIX1Oh7o06SjM/oA==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "run-applescript": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/bundle-require": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/bundle-require/-/bundle-require-5.1.0.tgz", @@ -4293,9 +4174,9 @@ } }, "node_modules/cacache/node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz", + "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==", "devOptional": true, "license": "MIT", "dependencies": { @@ -4306,9 +4187,9 @@ } }, "node_modules/cacache/node_modules/glob": { - "version": "13.0.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz", - "integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==", + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.7.tgz", + "integrity": "sha512-wfsFgXQ8A3SEI9XGf7Nl3Y9l7ffSrGh7SUCT7vU/2CzYPep9kjxAn1S40F9OPKxAMGCVl7HtNlJhrCJUeUq83g==", "devOptional": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -4324,9 +4205,9 @@ } }, "node_modules/cacache/node_modules/lru-cache": { - "version": "11.5.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz", - "integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==", + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", "devOptional": true, "license": "BlueOak-1.0.0", "engines": { @@ -4423,9 +4304,9 @@ } }, "node_modules/ci-info": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.4.0.tgz", - "integrity": "sha512-77PSwercCZU2Fc4sX94eF8k8Pxte6JAwL4/ICZLFjJLqegs7kCuAsqqj/70NQF6TvDpgFjkubQB2FW2ZZddvQg==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.5.0.tgz", + "integrity": "sha512-d1uM8k5UZEyPza1n/MG3ko8nKupKN0KJpFsipgPcgaCCvV+IqIfJ+NzTjetlLM+UcXZx3+cLrNr76+eAO7G1Mw==", "devOptional": true, "funding": [ { @@ -4529,6 +4410,7 @@ "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "devOptional": true, "license": "MIT", "dependencies": { "path-key": "^3.1.0", @@ -4539,19 +4421,6 @@ "node": ">= 8" } }, - "node_modules/cssesc": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", - "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", - "devOptional": true, - "license": "MIT", - "bin": { - "cssesc": "bin/cssesc" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/csstype": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", @@ -4585,15 +4454,47 @@ } } }, - "node_modules/detect-libc": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", - "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", - "dev": true, - "license": "Apache-2.0", - "optional": true, + "node_modules/default-browser": { + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.5.1.tgz", + "integrity": "sha512-m1pAzaJgZ/gssEqlOhJkPJp8Xly7QyW6xcrkUa2KKcDeDSEMP7X8xipU3snUcfisTQx0w1AGae+9UtJSfVnXGw==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "bundle-name": "^4.1.0", + "default-browser-id": "^5.0.0" + }, "engines": { - "node": ">=8" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser-id": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.1.tgz", + "integrity": "sha512-x1VCxdX4t+8wVfd1so/9w+vQ4vx7lKd2Qp5tDRutErwmR85OgmfX7RlLRMWafRMY7hbEiXIbudNrjOAPa/hL8Q==", + "devOptional": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/define-lazy-prop": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz", + "integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==", + "devOptional": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/diff": { @@ -4622,17 +4523,6 @@ "safe-buffer": "^5.0.1" } }, - "node_modules/effect": { - "version": "4.0.0-rc.112", - "resolved": "https://registry.npmjs.org/effect/-/effect-4.0.0-rc.112.tgz", - "integrity": "sha512-wXxwuh1Ywnv4cPRM3Wfa0vDwuOHnZ1TsTgHJkG9XgzND6inhBH9n1vBxhg3iIXOia/OrpmvVmd3lrD4vq6bF3A==", - "devOptional": true, - "license": "MIT", - "dependencies": { - "fast-check": "^4.9.0", - "msgpackr": "^2.0.5" - } - }, "node_modules/electron-to-chromium": { "version": "1.5.430", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.430.tgz", @@ -4683,6 +4573,7 @@ "dev": true, "hasInstallScript": true, "license": "MIT", + "peer": true, "bin": { "esbuild": "bin/esbuild" }, @@ -4741,29 +4632,6 @@ "devOptional": true, "license": "MIT" }, - "node_modules/fast-check": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/fast-check/-/fast-check-4.10.1.tgz", - "integrity": "sha512-sB5Vghiu8MyCyToHoBVGsT0baZg3sZWNIY+a6Ct2EDrQJlT4YdH6MC1BSLNe3kX1k5i5g0q1O52XFgcKK/rGHg==", - "devOptional": true, - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/dubzzz" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/fast-check" - } - ], - "license": "MIT", - "dependencies": { - "pure-rand": "^8.0.0" - }, - "engines": { - "node": ">=12.17.0" - } - }, "node_modules/fdir": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", @@ -4815,13 +4683,6 @@ "json5": "^2.2.3" } }, - "node_modules/find-my-way-ts": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/find-my-way-ts/-/find-my-way-ts-0.1.6.tgz", - "integrity": "sha512-a85L9ZoXtNAey3Y6Z+eBWW658kO/MwR7zIafkIUPUMf3isZG0NCs2pjW2wtjxAKuJPxMAsHUIP4ZPGv0o5gyTA==", - "devOptional": true, - "license": "MIT" - }, "node_modules/find-up": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", @@ -5068,11 +4929,11 @@ } }, "node_modules/graceful-fs": { - "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "version": "4.2.12", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.12.tgz", + "integrity": "sha512-iuyGF2E4oafQfPsRrG2wtY2ILupMhvtdrhzrxB+0VcjsPpSPttpfYdjnGFGsTi5MaJFjI1jOKHPQ6UTbTj9TAw==", "devOptional": true, - "license": "ISC" + "license": "BlueOak-1.0.0" }, "node_modules/gtoken": { "version": "8.0.0", @@ -5114,9 +4975,9 @@ } }, "node_modules/hosted-git-info/node_modules/lru-cache": { - "version": "11.5.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz", - "integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==", + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", "devOptional": true, "license": "BlueOak-1.0.0", "engines": { @@ -5130,9 +4991,9 @@ "license": "MIT" }, "node_modules/http-cache-semantics": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.2.0.tgz", - "integrity": "sha512-dTxcvPXqPvXBQpq5dUr6mEMJX4oIEFv6bwom3FDwKRDsuIjjJGANqhBuoAn9c1RQJIdAKav33ED65E2ys+87QQ==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.3.0.tgz", + "integrity": "sha512-M5t5LlJpS1UHMjvwRQVdFHvPISGeLAxNcrWuJkeGh0KxsqCHZ1O3NXZU/8x7cD0BDcGW8kapxMKTvwlqrNkHkA==", "devOptional": true, "license": "BSD-2-Clause" }, @@ -5206,9 +5067,9 @@ } }, "node_modules/ignore-walk/node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz", + "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==", "devOptional": true, "license": "MIT", "dependencies": { @@ -5245,9 +5106,9 @@ } }, "node_modules/ip-address": { - "version": "10.7.2", - "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.2.tgz", - "integrity": "sha512-7H/2gFSIitxc0hG3nOI1glS8QLo/EHBFFLk8vEUjXY/xu0AdL8jZ9U1IzO2PUm0d2D/ofQcAifb0g6OBkt8U7w==", + "version": "10.7.6", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.6.tgz", + "integrity": "sha512-00LYkM6byILa9eQIx6qoaXCM40xTLd56AZ4vyaPW3YTyb49VZYPo5xsiAq4tuQ54GH4R7gVdYScJ1B7B77PuTg==", "devOptional": true, "license": "MIT", "engines": { @@ -5269,6 +5130,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-docker": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", + "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", + "devOptional": true, + "license": "MIT", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -5279,10 +5156,59 @@ "node": ">=8" } }, + "node_modules/is-in-ssh": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-in-ssh/-/is-in-ssh-1.0.0.tgz", + "integrity": "sha512-jYa6Q9rH90kR1vKB6NM7qqd1mge3Fx4Dhw5TVlK1MUBqhEOuCagrEHMevNuCcbECmXZ0ThXkRm+Ymr51HwEPAw==", + "devOptional": true, + "license": "MIT", + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-inside-container": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", + "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "is-docker": "^3.0.0" + }, + "bin": { + "is-inside-container": "cli.js" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-wsl": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.1.tgz", + "integrity": "sha512-e6rvdUCiQCAuumZslxRJWR/Doq4VpPR82kqclvcS0efgt430SlGIk05vdCN58+VrzgtIcfNODjozVielycD4Sw==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "is-inside-container": "^1.0.0" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "devOptional": true, "license": "ISC" }, "node_modules/jackspeak": { @@ -5431,13 +5357,6 @@ "safe-buffer": "^5.0.1" } }, - "node_modules/kubernetes-types": { - "version": "1.30.0", - "resolved": "https://registry.npmjs.org/kubernetes-types/-/kubernetes-types-1.30.0.tgz", - "integrity": "sha512-Dew1okvhM/SQcIa2rcgujNndZwU8VnSapDgdxlYoB84ZlpAD43U6KLAFqYo17ykSFGHNPrg0qry0bP+GJd9v7Q==", - "devOptional": true, - "license": "Apache-2.0" - }, "node_modules/lilconfig": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.3.tgz", @@ -5481,13 +5400,6 @@ "node": ">=6" } }, - "node_modules/long": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz", - "integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==", - "devOptional": true, - "license": "Apache-2.0" - }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -5545,6 +5457,7 @@ "version": "17.0.1", "resolved": "https://registry.npmjs.org/marked/-/marked-17.0.1.tgz", "integrity": "sha512-boeBdiS0ghpWcSwoNm/jJBwdpFaMnZWRzjA6SkUMYb40SVaN1x7mmfGKp0jvexGcx+7y2La5zRZsYFZI6Qpypg==", + "dev": true, "license": "MIT", "bin": { "marked": "bin/marked.js" @@ -5553,22 +5466,6 @@ "node": ">= 20" } }, - "node_modules/mime": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-4.1.0.tgz", - "integrity": "sha512-X5ju04+cAzsojXKes0B/S4tcYtFAJ6tTMuSPBEn9CPGlrWr8Fiw7qYeLT0XyH80HSoAoqWCaz+MWKh22P7G1cw==", - "devOptional": true, - "funding": [ - "https://github.com/sponsors/broofa" - ], - "license": "MIT", - "bin": { - "mime": "bin/cli.js" - }, - "engines": { - "node": ">=16" - } - }, "node_modules/mime-db": { "version": "1.54.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", @@ -5802,46 +5699,6 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "license": "MIT" }, - "node_modules/msgpackr": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/msgpackr/-/msgpackr-2.1.0.tgz", - "integrity": "sha512-p/pBCVO63CsvvpkomUnNNag6+n38rULuDA6HHe70o2gtC8ODI52foF/4ko2qQcp6OiErJXTmrZeXmsGGHsIQNQ==", - "devOptional": true, - "license": "MIT", - "optionalDependencies": { - "msgpackr-extract": "^3.0.4" - } - }, - "node_modules/msgpackr-extract": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/msgpackr-extract/-/msgpackr-extract-3.0.4.tgz", - "integrity": "sha512-4kmO/MdyUIkLIvTPr8VHLil4AtoKIoniWPIEk5+CDy0xnWC84azhSFmuJ7PxZdsYtiP5kEeQsORAVIeMgxT+Hw==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "dependencies": { - "node-gyp-build-optional-packages": "5.2.2" - }, - "bin": { - "download-msgpackr-prebuilds": "bin/download-prebuilds.js" - }, - "optionalDependencies": { - "@msgpackr-extract/msgpackr-extract-darwin-arm64": "3.0.4", - "@msgpackr-extract/msgpackr-extract-darwin-x64": "3.0.4", - "@msgpackr-extract/msgpackr-extract-linux-arm": "3.0.4", - "@msgpackr-extract/msgpackr-extract-linux-arm64": "3.0.4", - "@msgpackr-extract/msgpackr-extract-linux-x64": "3.0.4", - "@msgpackr-extract/msgpackr-extract-win32-x64": "3.0.4" - } - }, - "node_modules/multipasta": { - "version": "0.2.8", - "resolved": "https://registry.npmjs.org/multipasta/-/multipasta-0.2.8.tgz", - "integrity": "sha512-ZPWuMKyv0cSO29f7hozp+k6+crZbQijV8ipMvxNxRf2SwtYGTX1ZX89Kd20VV4H9Znonx+EQn+iy1wGQsJ+b+Q==", - "devOptional": true, - "license": "MIT" - }, "node_modules/mz": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", @@ -5936,22 +5793,6 @@ "node": "^20.17.0 || >=22.9.0" } }, - "node_modules/node-gyp-build-optional-packages": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/node-gyp-build-optional-packages/-/node-gyp-build-optional-packages-5.2.2.tgz", - "integrity": "sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "detect-libc": "^2.0.1" - }, - "bin": { - "node-gyp-build-optional-packages": "bin.js", - "node-gyp-build-optional-packages-optional": "optional.js", - "node-gyp-build-optional-packages-test": "build-test.js" - } - }, "node_modules/node-gyp/node_modules/isexe": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-4.0.0.tgz", @@ -5963,9 +5804,9 @@ } }, "node_modules/node-gyp/node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", "devOptional": true, "license": "ISC", "bin": { @@ -5976,9 +5817,9 @@ } }, "node_modules/node-gyp/node_modules/undici": { - "version": "6.28.1", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.28.1.tgz", - "integrity": "sha512-zWpdTVD54H48CIybL0rWQ3ukpb9d23wM7eH5RtfdmeP70cWHNjtfo7P4vZX+5CoDcO53J4Pu5uXp7lNfjc6DRA==", + "version": "6.29.1", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.29.1.tgz", + "integrity": "sha512-EvRlUt/QqAEvXdQeRMYUfwOQsfzpDztykrG2owGEE/rBOBoYv9uF39ZzsNDh4lTFHhTr2XOZjKkYgueD12ZmGA==", "devOptional": true, "license": "MIT", "engines": { @@ -6053,9 +5894,9 @@ } }, "node_modules/npm-install-checks/node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", "devOptional": true, "license": "ISC", "bin": { @@ -6092,9 +5933,9 @@ } }, "node_modules/npm-package-arg/node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", "devOptional": true, "license": "ISC", "bin": { @@ -6135,9 +5976,9 @@ } }, "node_modules/npm-pick-manifest/node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", "devOptional": true, "license": "ISC", "bin": { @@ -6187,6 +6028,27 @@ "node": ">=0.10.0" } }, + "node_modules/open": { + "version": "11.0.4", + "resolved": "https://registry.npmjs.org/open/-/open-11.0.4.tgz", + "integrity": "sha512-++Zlftm0kVLPmzC06t6epuWmcRMDbI4z5P3NNX979WA/k23+NtSOynEGzsVfZwguKw2mi5umVgnBlJQMwRz4Pg==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "default-browser": "^5.5.1", + "define-lazy-prop": "^3.0.0", + "is-in-ssh": "^1.0.0", + "is-inside-container": "^1.0.0", + "powershell-utils": "^0.2.1", + "wsl-utils": "^1.0.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/opencode-request-logger": { "resolved": "tests/logger", "link": true @@ -6219,9 +6081,9 @@ } }, "node_modules/p-map": { - "version": "7.0.8", - "resolved": "https://registry.npmjs.org/p-map/-/p-map-7.0.8.tgz", - "integrity": "sha512-MitaVsCuCFIvOLLPIU7NnfrZvS9H9h7kwMUkDo+T2pEISaJD48IV9S8iIdXB7PsvvdxyYcsSTTrr90XKsbulNw==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-7.1.1.tgz", + "integrity": "sha512-6Lh3jQPLthYujSrlw6ccWXBGZTkoTCz27Hd92g79LH/kjAbgoEu0t442cCCNbegPSJsA0lwDX8z0bcKtkpA32g==", "devOptional": true, "license": "MIT", "engines": { @@ -6341,6 +6203,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "devOptional": true, "license": "MIT", "engines": { "node": ">=8" @@ -6487,19 +6350,31 @@ } }, "node_modules/postcss-selector-parser": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.1.6.tgz", - "integrity": "sha512-7qASPzhKF2l2KLboRZux8CCTRMdGiV08vWmyKzPz22qZ7ZjQBOeY7rNzNoCLSUiftJ7HUq0GERHmxw/t0dCdMw==", + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.2.1.tgz", + "integrity": "sha512-GwxlMgTTXwIom+ebC7an3k6RaJDwklRQQnfiXsLPGicu8FYV/k/+1/9YY2OU2+r938H2t4X0TDxoif+HP2rjzQ==", "devOptional": true, "license": "MIT", "dependencies": { - "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" }, "engines": { "node": ">=4" } }, + "node_modules/powershell-utils": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/powershell-utils/-/powershell-utils-0.2.1.tgz", + "integrity": "sha512-C+y9x90UElAddDZmV4qOx9W53B61PO7cIqWz2dQsWlwswuq4mr8NEwytdGKboYbQlGZ3awrkTeNvcZiZNHnQ8A==", + "devOptional": true, + "license": "MIT", + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/prettier": { "version": "3.8.1", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.1.tgz", @@ -6556,47 +6431,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/protobufjs": { - "version": "7.6.6", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.6.6.tgz", - "integrity": "sha512-dYDWdjSl5RNb7SgPxGQcRU+GtvP7s2fpkrY0r432PcOIaZ0/rBcxEZnQN67iJhFuQiVw754JDoPruPCNdGsbjg==", - "devOptional": true, - "hasInstallScript": true, - "license": "BSD-3-Clause", - "dependencies": { - "@protobufjs/aspromise": "^1.1.2", - "@protobufjs/base64": "^1.1.2", - "@protobufjs/codegen": "^2.0.5", - "@protobufjs/eventemitter": "^1.1.1", - "@protobufjs/fetch": "^1.1.1", - "@protobufjs/float": "^1.0.2", - "@protobufjs/path": "^1.1.2", - "@protobufjs/pool": "^1.1.0", - "@protobufjs/utf8": "^1.1.1", - "@types/node": ">=13.7.0", - "long": "^5.3.2" - }, - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/pure-rand": { - "version": "8.4.2", - "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-8.4.2.tgz", - "integrity": "sha512-vvuOGgcuPJAirlHvuQw1TrOiw7ptaIXXmIbNuiNOY6lNGJJH49PQ1Kj4nd783nPdQhQdicgOjVI2yI/9BD6/Ng==", - "devOptional": true, - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/dubzzz" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/fast-check" - } - ], - "license": "MIT" - }, "node_modules/read-cmd-shim": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-6.0.0.tgz", @@ -6795,6 +6629,19 @@ "fsevents": "~2.3.2" } }, + "node_modules/run-applescript": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-7.1.0.tgz", + "integrity": "sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q==", + "devOptional": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/s-js": { "version": "0.4.9", "resolved": "https://registry.npmjs.org/s-js/-/s-js-0.4.9.tgz", @@ -6840,18 +6687,18 @@ } }, "node_modules/seroval": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/seroval/-/seroval-1.5.4.tgz", - "integrity": "sha512-46uFvgrXTVxZcUorgSSRZ4y+ieqLLQRMlG4bnCZKW3qI6BZm7Rg4ntMW4p1mILEEBZWrFlcpp0AyIIlM6jD9iw==", + "version": "1.6.12", + "resolved": "https://registry.npmjs.org/seroval/-/seroval-1.6.12.tgz", + "integrity": "sha512-CqbIVfk/7GL3ITwZI55lcPbpQbjHZ2DD5cUj4iH7E9YsCfHNJV1mx7yNp86Z84w5IpmkZZS/2s5vPOWmVWSdQg==", "license": "MIT", "engines": { "node": ">=10" } }, "node_modules/seroval-plugins": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/seroval-plugins/-/seroval-plugins-1.5.4.tgz", - "integrity": "sha512-S0xQPhUTefAhNvNWFg0c1J8qJArHt5KdtJ/cFAofo06KD1MVSeFWyl4iiu+ApDIuw0WhjpOfCdgConOfAnLgkw==", + "version": "1.6.12", + "resolved": "https://registry.npmjs.org/seroval-plugins/-/seroval-plugins-1.6.12.tgz", + "integrity": "sha512-+reiwp/lYxiyctSrdvX7OQ1YLrcbWYgBiZrhSFL+V43b0/DGRLNVSDyZINbQe+tWplPOI2fw2dPrdv6hcc09kQ==", "license": "MIT", "engines": { "node": ">=10" @@ -6864,6 +6711,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "devOptional": true, "license": "MIT", "dependencies": { "shebang-regex": "^3.0.0" @@ -6876,6 +6724,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "devOptional": true, "license": "MIT", "engines": { "node": ">=8" @@ -6954,14 +6803,14 @@ } }, "node_modules/solid-js": { - "version": "1.9.12", - "resolved": "https://registry.npmjs.org/solid-js/-/solid-js-1.9.12.tgz", - "integrity": "sha512-QzKaSJq2/iDrWR1As6MHZQ8fQkdOBf8GReYb7L5iKwMGceg7HxDcaOHk0at66tNgn9U2U7dXo8ZZpLIAmGMzgw==", + "version": "1.9.19", + "resolved": "https://registry.npmjs.org/solid-js/-/solid-js-1.9.19.tgz", + "integrity": "sha512-NIrV/6o1FtmrA9iuAAYvnQJZaHrGcaH3LKSVj4kCiZfwqjCtJNDgIgR9XcqYl6KR/Lb3oRx1HrlyswPWR8SRvw==", "license": "MIT", "dependencies": { "csstype": "^3.1.0", - "seroval": "~1.5.0", - "seroval-plugins": "~1.5.0" + "seroval": "~1.6.11", + "seroval-plugins": "~1.6.8" } }, "node_modules/source-map": { @@ -6993,9 +6842,9 @@ } }, "node_modules/spdx-license-ids": { - "version": "3.0.23", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.23.tgz", - "integrity": "sha512-CWLcCCH7VLu13TgOH+r8p1O/Znwhqv/dbb6lqWy67G+pT1kHmeD/+V36AVb/vq8QMIQwVShJ6Ssl5FPh0fuSdw==", + "version": "3.0.24", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.24.tgz", + "integrity": "sha512-cLS9TtWkIQFyLkJ3/5aFQAOHOSKTlOs/7WDut/XPSdjom1fJhUdkepeJAKXa9Y05+FabHd0sti+Et559vDtkpQ==", "devOptional": true, "license": "CC0-1.0" }, @@ -7160,9 +7009,9 @@ } }, "node_modules/tar": { - "version": "7.5.22", - "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.22.tgz", - "integrity": "sha512-MFO/QzvtAOmJbkhOaCTvbGcFN9L9b+JunIsDwaKljSOdcLMea3NJ1k9Usz/rjdfSXTq4dfzfeS7W4p4YOAAHeA==", + "version": "7.5.23", + "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.23.tgz", + "integrity": "sha512-lkukzdoGngZHJZXxW4S/E4Fp9ghTDlyZXrQGRNoJ/LXvDKcXUTq2sg5yQe74po7Voea6n/IN09+wE/QvJMiifA==", "devOptional": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -7249,16 +7098,6 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, - "node_modules/toml": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/toml/-/toml-4.3.0.tgz", - "integrity": "sha512-lVb8X9BsPVuH0M4BKeS91tXAmJvCjQ5UIyAbQFaxkKGyUFK2RPkhwaFSQH8vbpl1d23eu/IBH+dwVMHWaq9A5A==", - "devOptional": true, - "license": "MIT", - "engines": { - "node": ">=20" - } - }, "node_modules/tree-kill": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", @@ -7346,147 +7185,1101 @@ } } }, - "node_modules/tsx": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.21.0.tgz", - "integrity": "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw==", + "node_modules/tsup/node_modules/@esbuild/aix-ppc64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.7.tgz", + "integrity": "sha512-EKX3Qwmhz1eMdEJokhALr0YiD0lhQNwDqkPYyPhiSwKrh7/4KRjQc04sZ8db+5DVVnZ1LmbNDI1uAMPEUBnQPg==", + "cpu": [ + "ppc64" + ], "dev": true, "license": "MIT", - "dependencies": { - "esbuild": "~0.27.0", - "get-tsconfig": "^4.7.5" - }, - "bin": { - "tsx": "dist/cli.mjs" - }, + "optional": true, + "os": [ + "aix" + ], "engines": { - "node": ">=18.0.0" - }, - "optionalDependencies": { - "fsevents": "~2.3.3" + "node": ">=18" } }, - "node_modules/tuf-js": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/tuf-js/-/tuf-js-4.1.0.tgz", - "integrity": "sha512-50QV99kCKH5P/Vs4E2Gzp7BopNV+KzTXqWeaxrfu5IQJBOULRsTIS9seSsOVT8ZnGXzCyx55nYWAi4qJzpZKEQ==", - "devOptional": true, + "node_modules/tsup/node_modules/@esbuild/android-arm": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.7.tgz", + "integrity": "sha512-jbPXvB4Yj2yBV7HUfE2KHe4GJX51QplCN1pGbYjvsyCZbQmies29EoJbkEc+vYuU5o45AfQn37vZlyXy4YJ8RQ==", + "cpu": [ + "arm" + ], + "dev": true, "license": "MIT", - "dependencies": { - "@tufjs/models": "4.1.0", - "debug": "^4.4.3", - "make-fetch-happen": "^15.0.1" - }, + "optional": true, + "os": [ + "android" + ], "engines": { - "node": "^20.17.0 || >=22.9.0" + "node": ">=18" } }, - "node_modules/typescript": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.2.tgz", - "integrity": "sha512-bGdAIrZ0wiGDo5l8c++HWtbaNCWTS4UTv7RaTH/ThVIgjkveJt83m74bBHMJkuCbslY8ixgLBVZJIOiQlQTjfQ==", - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, + "node_modules/tsup/node_modules/@esbuild/android-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.7.tgz", + "integrity": "sha512-62dPZHpIXzvChfvfLJow3q5dDtiNMkwiRzPylSCfriLvZeq0a1bWChrGx/BbUbPwOrsWKMn8idSllklzBy+dgQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], "engines": { - "node": ">=14.17" + "node": ">=18" } }, - "node_modules/ufo": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.6.3.tgz", - "integrity": "sha512-yDJTmhydvl5lJzBmy/hyOAA0d+aqCBuwl818haVdYCRrWV84o7YyeVm4QlVHStqNrrJSTb6jKuFAVqAFsr+K3Q==", + "node_modules/tsup/node_modules/@esbuild/android-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.7.tgz", + "integrity": "sha512-x5VpMODneVDb70PYV2VQOmIUUiBtY3D3mPBG8NxVk5CogneYhkR7MmM3yR/uMdITLrC1ml/NV1rj4bMJuy9MCg==", + "cpu": [ + "x64" + ], "dev": true, - "license": "MIT" - }, - "node_modules/undici": { - "version": "8.10.2", - "resolved": "https://registry.npmjs.org/undici/-/undici-8.10.2.tgz", - "integrity": "sha512-/y4/bH9YNU5hi9NIrpOuvGXFcxrj3CMrV+/AYpowAYTpHn8gX/XPFjNy766FPoYY0miQhdW977JFWKGNhBdwyQ==", - "devOptional": true, "license": "MIT", + "optional": true, + "os": [ + "android" + ], "engines": { - "node": ">=22.19.0" + "node": ">=18" } }, - "node_modules/undici-types": { - "version": "7.18.2", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz", - "integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==", - "devOptional": true, - "license": "MIT" - }, - "node_modules/update-browserslist-db": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.3.tgz", - "integrity": "sha512-pJ2sYawQS0R/WI928Gj5GlPhTGzbMelq0+4INtSYNDV9ErKJcX6xjGWkoG/VnB3dpUm00zALaqkrUD77pO5TDQ==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } + "node_modules/tsup/node_modules/@esbuild/darwin-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.7.tgz", + "integrity": "sha512-5lckdqeuBPlKUwvoCXIgI2D9/ABmPq3Rdp7IfL70393YgaASt7tbju3Ac+ePVi3KDH6N2RqePfHnXkaDtY9fkw==", + "cpu": [ + "arm64" ], + "dev": true, "license": "MIT", - "dependencies": { - "escalade": "^3.2.0", - "picocolors": "^1.1.1" - }, - "bin": { - "update-browserslist-db": "cli.js" - }, - "peerDependencies": { - "browserslist": ">= 4.21.0" + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" } }, - "node_modules/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "devOptional": true, - "license": "MIT" - }, - "node_modules/uuid": { - "version": "14.0.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-14.0.2.tgz", - "integrity": "sha512-xZe/16rV4aa+HGSOCiY2YeLT1OybRLrrkL/Rqaq7p7GMVXjFh+6wN4oMYgjFmnSnhY8t6Xpdl2l9qmnHYuMHwQ==", - "devOptional": true, - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" + "node_modules/tsup/node_modules/@esbuild/darwin-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.7.tgz", + "integrity": "sha512-rYnXrKcXuT7Z+WL5K980jVFdvVKhCHhUwid+dDYQpH+qu+TefcomiMAJpIiC2EM3Rjtq0sO3StMV/+3w3MyyqQ==", + "cpu": [ + "x64" ], + "dev": true, "license": "MIT", - "bin": { - "uuid": "dist-node/bin/uuid" - } - }, - "node_modules/validate-npm-package-name": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-7.0.2.tgz", - "integrity": "sha512-hVDIBwsRruT73PbK7uP5ebUt+ezEtCmzZz3F59BSr2F6OVFnJ/6h8liuvdLrQ88Xmnk6/+xGGuq+pG9WwTuy3A==", - "devOptional": true, - "license": "ISC", + "optional": true, + "os": [ + "darwin" + ], "engines": { - "node": "^20.17.0 || >=22.9.0" + "node": ">=18" } }, - "node_modules/walk-up-path": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/walk-up-path/-/walk-up-path-4.0.0.tgz", - "integrity": "sha512-3hu+tD8YzSLGuFYtPRb48vdhKMi0KQV5sn+uWr8+7dMEq/2G/dtLrdDinkLjqq5TIbIBjYJ4Ax/n3YiaW7QM8A==", - "devOptional": true, - "license": "ISC", - "engines": { - "node": "20 || >=22" + "node_modules/tsup/node_modules/@esbuild/freebsd-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.7.tgz", + "integrity": "sha512-B48PqeCsEgOtzME2GbNM2roU29AMTuOIN91dsMO30t+Ydis3z/3Ngoj5hhnsOSSwNzS+6JppqWsuhTp6E82l2w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/freebsd-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.7.tgz", + "integrity": "sha512-jOBDK5XEjA4m5IJK3bpAQF9/Lelu/Z9ZcdhTRLf4cajlB+8VEhFFRjWgfy3M1O4rO2GQ/b2dLwCUGpiF/eATNQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-arm": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.7.tgz", + "integrity": "sha512-RkT/YXYBTSULo3+af8Ib0ykH8u2MBh57o7q/DAs3lTJlyVQkgQvlrPTnjIzzRPQyavxtPtfg0EopvDyIt0j1rA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.7.tgz", + "integrity": "sha512-RZPHBoxXuNnPQO9rvjh5jdkRmVizktkT7TCDkDmQ0W2SwHInKCAV95GRuvdSvA7w4VMwfCjUiPwDi0ZO6Nfe9A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-ia32": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.7.tgz", + "integrity": "sha512-GA48aKNkyQDbd3KtkplYWT102C5sn/EZTY4XROkxONgruHPU72l+gW+FfF8tf2cFjeHaRbWpOYa/uRBz/Xq1Pg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-loong64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.7.tgz", + "integrity": "sha512-a4POruNM2oWsD4WKvBSEKGIiWQF8fZOAsycHOt6JBpZ+JN2n2JH9WAv56SOyu9X5IqAjqSIPTaJkqN8F7XOQ5Q==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-mips64el": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.7.tgz", + "integrity": "sha512-KabT5I6StirGfIz0FMgl1I+R1H73Gp0ofL9A3nG3i/cYFJzKHhouBV5VWK1CSgKvVaG4q1RNpCTR2LuTVB3fIw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-ppc64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.7.tgz", + "integrity": "sha512-gRsL4x6wsGHGRqhtI+ifpN/vpOFTQtnbsupUF5R5YTAg+y/lKelYR1hXbnBdzDjGbMYjVJLJTd2OFmMewAgwlQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-riscv64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.7.tgz", + "integrity": "sha512-hL25LbxO1QOngGzu2U5xeXtxXcW+/GvMN3ejANqXkxZ/opySAZMrc+9LY/WyjAan41unrR3YrmtTsUpwT66InQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-s390x": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.7.tgz", + "integrity": "sha512-2k8go8Ycu1Kb46vEelhu1vqEP+UeRVj2zY1pSuPdgvbd5ykAw82Lrro28vXUrRmzEsUV0NzCf54yARIK8r0fdw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/linux-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.7.tgz", + "integrity": "sha512-hzznmADPt+OmsYzw1EE33ccA+HPdIqiCRq7cQeL1Jlq2gb1+OyWBkMCrYGBJ+sxVzve2ZJEVeePbLM2iEIZSxA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/netbsd-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.7.tgz", + "integrity": "sha512-b6pqtrQdigZBwZxAn1UpazEisvwaIDvdbMbmrly7cDTMFnw/+3lVxxCTGOrkPVnsYIosJJXAsILG9XcQS+Yu6w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/netbsd-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.7.tgz", + "integrity": "sha512-OfatkLojr6U+WN5EDYuoQhtM+1xco+/6FSzJJnuWiUw5eVcicbyK3dq5EeV/QHT1uy6GoDhGbFpprUiHUYggrw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/openbsd-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.7.tgz", + "integrity": "sha512-AFuojMQTxAz75Fo8idVcqoQWEHIXFRbOc1TrVcFSgCZtQfSdc1RXgB3tjOn/krRHENUB4j00bfGjyl2mJrU37A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/openbsd-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.7.tgz", + "integrity": "sha512-+A1NJmfM8WNDv5CLVQYJ5PshuRm/4cI6WMZRg1by1GwPIQPCTs1GLEUHwiiQGT5zDdyLiRM/l1G0Pv54gvtKIg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/openharmony-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.7.tgz", + "integrity": "sha512-+KrvYb/C8zA9CU/g0sR6w2RBw7IGc5J2BPnc3dYc5VJxHCSF1yNMxTV5LQ7GuKteQXZtspjFbiuW5/dOj7H4Yw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/sunos-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.7.tgz", + "integrity": "sha512-ikktIhFBzQNt/QDyOL580ti9+5mL/YZeUPKU2ivGtGjdTYoqz6jObj6nOMfhASpS4GU4Q/Clh1QtxWAvcYKamA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/win32-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.7.tgz", + "integrity": "sha512-7yRhbHvPqSpRUV7Q20VuDwbjW5kIMwTHpptuUzV+AA46kiPze5Z7qgt6CLCK3pWFrHeNfDd1VKgyP4O+ng17CA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/win32-ia32": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.7.tgz", + "integrity": "sha512-SmwKXe6VHIyZYbBLJrhOoCJRB/Z1tckzmgTLfFYOfpMAx63BJEaL9ExI8x7v0oAO3Zh6D/Oi1gVxEYr5oUCFhw==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/@esbuild/win32-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.7.tgz", + "integrity": "sha512-56hiAJPhwQ1R4i+21FVF7V8kSD5zZTdHcVuRFMW0hn753vVfQN8xlx4uOPT4xoGH0Z/oVATuR82AiqSTDIpaHg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsup/node_modules/esbuild": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.7.tgz", + "integrity": "sha512-IxpibTjyVnmrIQo5aqNpCgoACA/dTKLTlhMHihVHhdkxKyPO1uBBthumT0rdHmcsk9uMonIWS0m4FljWzILh3w==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.27.7", + "@esbuild/android-arm": "0.27.7", + "@esbuild/android-arm64": "0.27.7", + "@esbuild/android-x64": "0.27.7", + "@esbuild/darwin-arm64": "0.27.7", + "@esbuild/darwin-x64": "0.27.7", + "@esbuild/freebsd-arm64": "0.27.7", + "@esbuild/freebsd-x64": "0.27.7", + "@esbuild/linux-arm": "0.27.7", + "@esbuild/linux-arm64": "0.27.7", + "@esbuild/linux-ia32": "0.27.7", + "@esbuild/linux-loong64": "0.27.7", + "@esbuild/linux-mips64el": "0.27.7", + "@esbuild/linux-ppc64": "0.27.7", + "@esbuild/linux-riscv64": "0.27.7", + "@esbuild/linux-s390x": "0.27.7", + "@esbuild/linux-x64": "0.27.7", + "@esbuild/netbsd-arm64": "0.27.7", + "@esbuild/netbsd-x64": "0.27.7", + "@esbuild/openbsd-arm64": "0.27.7", + "@esbuild/openbsd-x64": "0.27.7", + "@esbuild/openharmony-arm64": "0.27.7", + "@esbuild/sunos-x64": "0.27.7", + "@esbuild/win32-arm64": "0.27.7", + "@esbuild/win32-ia32": "0.27.7", + "@esbuild/win32-x64": "0.27.7" + } + }, + "node_modules/tsx": { + "version": "4.21.0", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.21.0.tgz", + "integrity": "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "~0.27.0", + "get-tsconfig": "^4.7.5" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, + "node_modules/tsx/node_modules/@esbuild/aix-ppc64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.7.tgz", + "integrity": "sha512-EKX3Qwmhz1eMdEJokhALr0YiD0lhQNwDqkPYyPhiSwKrh7/4KRjQc04sZ8db+5DVVnZ1LmbNDI1uAMPEUBnQPg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-arm": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.7.tgz", + "integrity": "sha512-jbPXvB4Yj2yBV7HUfE2KHe4GJX51QplCN1pGbYjvsyCZbQmies29EoJbkEc+vYuU5o45AfQn37vZlyXy4YJ8RQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.7.tgz", + "integrity": "sha512-62dPZHpIXzvChfvfLJow3q5dDtiNMkwiRzPylSCfriLvZeq0a1bWChrGx/BbUbPwOrsWKMn8idSllklzBy+dgQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/android-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.7.tgz", + "integrity": "sha512-x5VpMODneVDb70PYV2VQOmIUUiBtY3D3mPBG8NxVk5CogneYhkR7MmM3yR/uMdITLrC1ml/NV1rj4bMJuy9MCg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/darwin-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.7.tgz", + "integrity": "sha512-5lckdqeuBPlKUwvoCXIgI2D9/ABmPq3Rdp7IfL70393YgaASt7tbju3Ac+ePVi3KDH6N2RqePfHnXkaDtY9fkw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/darwin-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.7.tgz", + "integrity": "sha512-rYnXrKcXuT7Z+WL5K980jVFdvVKhCHhUwid+dDYQpH+qu+TefcomiMAJpIiC2EM3Rjtq0sO3StMV/+3w3MyyqQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/freebsd-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.7.tgz", + "integrity": "sha512-B48PqeCsEgOtzME2GbNM2roU29AMTuOIN91dsMO30t+Ydis3z/3Ngoj5hhnsOSSwNzS+6JppqWsuhTp6E82l2w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/freebsd-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.7.tgz", + "integrity": "sha512-jOBDK5XEjA4m5IJK3bpAQF9/Lelu/Z9ZcdhTRLf4cajlB+8VEhFFRjWgfy3M1O4rO2GQ/b2dLwCUGpiF/eATNQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-arm": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.7.tgz", + "integrity": "sha512-RkT/YXYBTSULo3+af8Ib0ykH8u2MBh57o7q/DAs3lTJlyVQkgQvlrPTnjIzzRPQyavxtPtfg0EopvDyIt0j1rA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.7.tgz", + "integrity": "sha512-RZPHBoxXuNnPQO9rvjh5jdkRmVizktkT7TCDkDmQ0W2SwHInKCAV95GRuvdSvA7w4VMwfCjUiPwDi0ZO6Nfe9A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-ia32": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.7.tgz", + "integrity": "sha512-GA48aKNkyQDbd3KtkplYWT102C5sn/EZTY4XROkxONgruHPU72l+gW+FfF8tf2cFjeHaRbWpOYa/uRBz/Xq1Pg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-loong64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.7.tgz", + "integrity": "sha512-a4POruNM2oWsD4WKvBSEKGIiWQF8fZOAsycHOt6JBpZ+JN2n2JH9WAv56SOyu9X5IqAjqSIPTaJkqN8F7XOQ5Q==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-mips64el": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.7.tgz", + "integrity": "sha512-KabT5I6StirGfIz0FMgl1I+R1H73Gp0ofL9A3nG3i/cYFJzKHhouBV5VWK1CSgKvVaG4q1RNpCTR2LuTVB3fIw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-ppc64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.7.tgz", + "integrity": "sha512-gRsL4x6wsGHGRqhtI+ifpN/vpOFTQtnbsupUF5R5YTAg+y/lKelYR1hXbnBdzDjGbMYjVJLJTd2OFmMewAgwlQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-riscv64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.7.tgz", + "integrity": "sha512-hL25LbxO1QOngGzu2U5xeXtxXcW+/GvMN3ejANqXkxZ/opySAZMrc+9LY/WyjAan41unrR3YrmtTsUpwT66InQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-s390x": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.7.tgz", + "integrity": "sha512-2k8go8Ycu1Kb46vEelhu1vqEP+UeRVj2zY1pSuPdgvbd5ykAw82Lrro28vXUrRmzEsUV0NzCf54yARIK8r0fdw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/linux-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.7.tgz", + "integrity": "sha512-hzznmADPt+OmsYzw1EE33ccA+HPdIqiCRq7cQeL1Jlq2gb1+OyWBkMCrYGBJ+sxVzve2ZJEVeePbLM2iEIZSxA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/netbsd-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.7.tgz", + "integrity": "sha512-b6pqtrQdigZBwZxAn1UpazEisvwaIDvdbMbmrly7cDTMFnw/+3lVxxCTGOrkPVnsYIosJJXAsILG9XcQS+Yu6w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/netbsd-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.7.tgz", + "integrity": "sha512-OfatkLojr6U+WN5EDYuoQhtM+1xco+/6FSzJJnuWiUw5eVcicbyK3dq5EeV/QHT1uy6GoDhGbFpprUiHUYggrw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/openbsd-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.7.tgz", + "integrity": "sha512-AFuojMQTxAz75Fo8idVcqoQWEHIXFRbOc1TrVcFSgCZtQfSdc1RXgB3tjOn/krRHENUB4j00bfGjyl2mJrU37A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/openbsd-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.7.tgz", + "integrity": "sha512-+A1NJmfM8WNDv5CLVQYJ5PshuRm/4cI6WMZRg1by1GwPIQPCTs1GLEUHwiiQGT5zDdyLiRM/l1G0Pv54gvtKIg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/openharmony-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.7.tgz", + "integrity": "sha512-+KrvYb/C8zA9CU/g0sR6w2RBw7IGc5J2BPnc3dYc5VJxHCSF1yNMxTV5LQ7GuKteQXZtspjFbiuW5/dOj7H4Yw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/sunos-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.7.tgz", + "integrity": "sha512-ikktIhFBzQNt/QDyOL580ti9+5mL/YZeUPKU2ivGtGjdTYoqz6jObj6nOMfhASpS4GU4Q/Clh1QtxWAvcYKamA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.7.tgz", + "integrity": "sha512-7yRhbHvPqSpRUV7Q20VuDwbjW5kIMwTHpptuUzV+AA46kiPze5Z7qgt6CLCK3pWFrHeNfDd1VKgyP4O+ng17CA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-ia32": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.7.tgz", + "integrity": "sha512-SmwKXe6VHIyZYbBLJrhOoCJRB/Z1tckzmgTLfFYOfpMAx63BJEaL9ExI8x7v0oAO3Zh6D/Oi1gVxEYr5oUCFhw==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/@esbuild/win32-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.7.tgz", + "integrity": "sha512-56hiAJPhwQ1R4i+21FVF7V8kSD5zZTdHcVuRFMW0hn753vVfQN8xlx4uOPT4xoGH0Z/oVATuR82AiqSTDIpaHg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/tsx/node_modules/esbuild": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.7.tgz", + "integrity": "sha512-IxpibTjyVnmrIQo5aqNpCgoACA/dTKLTlhMHihVHhdkxKyPO1uBBthumT0rdHmcsk9uMonIWS0m4FljWzILh3w==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.27.7", + "@esbuild/android-arm": "0.27.7", + "@esbuild/android-arm64": "0.27.7", + "@esbuild/android-x64": "0.27.7", + "@esbuild/darwin-arm64": "0.27.7", + "@esbuild/darwin-x64": "0.27.7", + "@esbuild/freebsd-arm64": "0.27.7", + "@esbuild/freebsd-x64": "0.27.7", + "@esbuild/linux-arm": "0.27.7", + "@esbuild/linux-arm64": "0.27.7", + "@esbuild/linux-ia32": "0.27.7", + "@esbuild/linux-loong64": "0.27.7", + "@esbuild/linux-mips64el": "0.27.7", + "@esbuild/linux-ppc64": "0.27.7", + "@esbuild/linux-riscv64": "0.27.7", + "@esbuild/linux-s390x": "0.27.7", + "@esbuild/linux-x64": "0.27.7", + "@esbuild/netbsd-arm64": "0.27.7", + "@esbuild/netbsd-x64": "0.27.7", + "@esbuild/openbsd-arm64": "0.27.7", + "@esbuild/openbsd-x64": "0.27.7", + "@esbuild/openharmony-arm64": "0.27.7", + "@esbuild/sunos-x64": "0.27.7", + "@esbuild/win32-arm64": "0.27.7", + "@esbuild/win32-ia32": "0.27.7", + "@esbuild/win32-x64": "0.27.7" + } + }, + "node_modules/tuf-js": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/tuf-js/-/tuf-js-4.1.0.tgz", + "integrity": "sha512-50QV99kCKH5P/Vs4E2Gzp7BopNV+KzTXqWeaxrfu5IQJBOULRsTIS9seSsOVT8ZnGXzCyx55nYWAi4qJzpZKEQ==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "@tufjs/models": "4.1.0", + "debug": "^4.4.3", + "make-fetch-happen": "^15.0.1" + }, + "engines": { + "node": "^20.17.0 || >=22.9.0" + } + }, + "node_modules/typescript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.2.tgz", + "integrity": "sha512-bGdAIrZ0wiGDo5l8c++HWtbaNCWTS4UTv7RaTH/ThVIgjkveJt83m74bBHMJkuCbslY8ixgLBVZJIOiQlQTjfQ==", + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/ufo": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.6.3.tgz", + "integrity": "sha512-yDJTmhydvl5lJzBmy/hyOAA0d+aqCBuwl818haVdYCRrWV84o7YyeVm4QlVHStqNrrJSTb6jKuFAVqAFsr+K3Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/undici": { + "version": "8.12.4", + "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.4.tgz", + "integrity": "sha512-8Mx+uNKKER2bA4AdtedkqRbwUCIJFr2nJckXRe5yrDqzePqwLP7VNcctN8/XdmDSbF7mS+jJKIszlL+vbam1VA==", + "devOptional": true, + "license": "MIT", + "engines": { + "node": ">=22.19.0" + } + }, + "node_modules/undici-types": { + "version": "7.18.2", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz", + "integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==", + "devOptional": true, + "license": "MIT" + }, + "node_modules/update-browserslist-db": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.3.tgz", + "integrity": "sha512-pJ2sYawQS0R/WI928Gj5GlPhTGzbMelq0+4INtSYNDV9ErKJcX6xjGWkoG/VnB3dpUm00zALaqkrUD77pO5TDQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "devOptional": true, + "license": "MIT" + }, + "node_modules/validate-npm-package-name": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-7.0.2.tgz", + "integrity": "sha512-hVDIBwsRruT73PbK7uP5ebUt+ezEtCmzZz3F59BSr2F6OVFnJ/6h8liuvdLrQ88Xmnk6/+xGGuq+pG9WwTuy3A==", + "devOptional": true, + "license": "ISC", + "engines": { + "node": "^20.17.0 || >=22.9.0" + } + }, + "node_modules/walk-up-path": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/walk-up-path/-/walk-up-path-4.0.0.tgz", + "integrity": "sha512-3hu+tD8YzSLGuFYtPRb48vdhKMi0KQV5sn+uWr8+7dMEq/2G/dtLrdDinkLjqq5TIbIBjYJ4Ax/n3YiaW7QM8A==", + "devOptional": true, + "license": "ISC", + "engines": { + "node": "20 || >=22" } }, "node_modules/web-streams-polyfill": { @@ -7518,6 +8311,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "devOptional": true, "license": "ISC", "dependencies": { "isexe": "^2.0.0" @@ -7666,9 +8460,9 @@ } }, "node_modules/ws": { - "version": "8.21.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.3.tgz", - "integrity": "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw==", + "version": "8.23.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.23.0.tgz", + "integrity": "sha512-wCkmX8QMOrKjgO8HW2WyDbTSGeqkocxgDzS9iR79rEAexty6/2qzilx3Ag8Tqf9ykop3irLKle0MtVn5qjVnoQ==", "license": "MIT", "engines": { "node": ">=10.0.0" @@ -7686,6 +8480,23 @@ } } }, + "node_modules/wsl-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/wsl-utils/-/wsl-utils-1.0.1.tgz", + "integrity": "sha512-c16PKLIRxBYpR3jSWsdS7SFp0COm5SOQdiFjY818dYFHJbMGuLBszpF07LBWmOS1uzrHa9VGdynsEgoeKy0oOQ==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "is-wsl": "^3.1.0", + "powershell-utils": "^0.2.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", @@ -7696,8 +8507,10 @@ "version": "2.9.1", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz", "integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==", - "devOptional": true, + "dev": true, "license": "ISC", + "optional": true, + "peer": true, "bin": { "yaml": "bin.mjs" }, @@ -7709,10 +8522,9 @@ } }, "node_modules/zod": { - "version": "4.1.8", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.1.8.tgz", - "integrity": "sha512-5R1P+WwQqmmMIEACyzSvo4JXHY5WiAFHRMg+zBZKgKS+Q1viRa0C1hmUKtHltoIFKtIdki3pRxkmpP74jnNYHQ==", - "devOptional": true, + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", "license": "MIT", "funding": { "url": "https://github.com/sponsors/colinhacks" @@ -7725,13 +8537,9 @@ "ws": "^8.21.3" }, "peerDependencies": { - "@opencode-ai/plugin": ">=1.18.29", - "@opencode/plugin": "^2.0.4" + "@opencode/plugin": "^2.3.2" }, "peerDependenciesMeta": { - "@opencode-ai/plugin": { - "optional": true - }, "@opencode/plugin": { "optional": true } diff --git a/package.json b/package.json index 468c60ad2..95807ed51 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/package.json", "name": "@mbarnett/opencode-dcp", - "version": "3.2.1", + "version": "4.0.0", "type": "module", "workspaces": [ "tests/logger" @@ -14,13 +14,9 @@ "types": "./dist/index.d.ts", "import": "./dist/index.js" }, - "./server": { - "types": "./dist/index.d.ts", - "import": "./dist/index.js" - }, "./tui": { "types": "./dist/tui.d.ts", - "import": "./tui.tsx" + "import": "./dist/tui.js" } }, "scripts": { @@ -32,7 +28,7 @@ "dev": "opencode plugin dev", "sandbox": "node scripts/sandbox.mjs", "typecheck": "tsc --noEmit && npm run typecheck --workspace=tests/logger", - "test": "node --import tsx --test tests/*.test.ts && npm test --workspace=tests/logger", + "test": "node --import tsx --test tests/*.test.ts tests/native/*.test.ts && npm test --workspace=tests/logger", "format": "prettier --write .", "format:check": "prettier --check .", "dcp": "tsx scripts/print.ts" @@ -56,36 +52,27 @@ "homepage": "https://github.com/mathewbarnett/opencode-dynamic-context-pruning#readme", "author": "mbarnett", "license": "AGPL-3.0-or-later", - "peerDependencies": { - "@opencode-ai/plugin": ">=1.18.29" - }, "dependencies": { "@anthropic-ai/tokenizer": "^0.0.4", - "@opencode-ai/sdk": "^1.4.3", - "@opentui/core": "^0.6.8", - "@opentui/solid": "^0.6.8", + "@opentui/core": "^0.9.3", + "@opentui/solid": "^0.9.3", "jsonc-parser": "^3.3.1", - "solid-js": "^1.9.12" + "solid-js": "^1.9.12", + "zod": "^4.1.8" }, "devDependencies": { - "@opencode-ai/plugin": "^1.18.29", - "@opencode/plugin": "^2.0.4", - "@opencode/theme": "^2.0.4", + "@opencode/ai": "^2.3.2", + "@opencode/plugin": "^2.3.2", + "@opencode/theme": "^2.3.2", "@types/node": "^25.5.0", "prettier": "^3.8.1", "tsup": "^8.5.1", "tsx": "^4.21.0", "typescript": "^6.0.2" }, - "overrides": { - "@babel/core": "7.29.7", - "esbuild": "0.28.1" - }, "files": [ "dist/", - "lib/", - "server.js", - "tui.tsx", + "dcp.schema.json", "dcp.example.jsonc", "README.md", "LICENSE" diff --git a/scripts/sandbox.mjs b/scripts/sandbox.mjs index aba694c56..eb628eaab 100755 --- a/scripts/sandbox.mjs +++ b/scripts/sandbox.mjs @@ -16,8 +16,6 @@ const { values } = parseArgs({ options: { help: { type: "boolean", short: "h" }, fresh: { type: "boolean" }, - v1: { type: "boolean" }, - v2: { type: "boolean" }, opencode: { type: "string" }, dcp: { type: "string" }, model: { type: "string" }, @@ -34,22 +32,19 @@ Open isolated OpenCode with DCP and the bundled test logger. Sessions and scratch files persist. Local plugins are rebuilt on every launch. Each launch uses the latest stable release of the selected major version. - --v1 Use V1 over HTTP, with its own saved state - --v2 Use V2 (default), with its own saved state --fresh Start a new empty sandbox; keep old ones --logs Show the latest raw/readable log paths and capture counts --path Print the current sandbox's host directory - --opencode VERSION Use an exact version for this launch (V1 requires 1.18.29+) - --dcp VERSION Use npm DCP (e.g. latest or 3.2.1); default: local checkout + --opencode VERSION Use an exact OpenCode 2.x version for this launch + --dcp VERSION Use npm DCP (e.g. latest); default: local checkout --model MODEL Remember a provider/model (otherwise OpenCode selects one) - --transport TYPE V2: websocket or http; V1: http only + --transport TYPE websocket or http Examples: dcp-sandbox - dcp-sandbox --v1 dcp-sandbox --dcp latest --fresh - dcp-sandbox --opencode 2.0.12 --dcp 3.2.1 - dcp-sandbox --v1 --logs + dcp-sandbox --opencode 2.3.2 --dcp latest + dcp-sandbox --logs dcp-sandbox -- --continue dcp-sandbox -- run --format json "Reply with OK." @@ -69,11 +64,8 @@ function save(path, value) { async function main() { process.umask(0o077) - if (values.v1 && values.v2) throw new Error("Choose --v1 or --v2, not both.") - const major = values.v1 ? 1 : values.v2 ? 2 : Number(values.opencode?.split(".")[0] || 2) - if (![1, 2].includes(major)) throw new Error("Choose an OpenCode 1.x or 2.x version.") - // Each major has independent sessions and settings. - const state = major === 1 ? join(root, "v1") : root + const major = 2 + const state = root const stamp = new Date().toISOString().replace(/[:.]/g, "-") const current = join(state, "current.json") const profile = values.fresh ? stamp : json(current, "default") @@ -101,10 +93,10 @@ async function main() { const saved = json(settingsPath, {}) const settings = { model: values.model ?? saved.model, - transport: values.transport ?? saved.transport ?? (major === 1 ? "http" : undefined), + transport: values.transport ?? saved.transport, } const dcp = values.dcp ?? "local" - const packageName = major === 1 ? "opencode-ai" : "@opencode/cli" + const packageName = "@opencode/cli" let release = values.opencode if (!release) { const versions = JSON.parse( @@ -116,26 +108,13 @@ async function main() { } const version = /^(1|2)\.(\d+)\.(\d+)(-[\w.-]+)?$/.exec(release) if (!version || Number(version[1]) !== major) - throw new Error( - `--opencode requires an exact ${major}.x version matching the selected host.`, - ) - if ( - major === 1 && - (Number(version[2]) < 18 || - (Number(version[2]) === 18 && - (Number(version[3]) < 29 || (Number(version[3]) === 29 && version[4])))) - ) - throw new Error("DCP's shared entrypoint requires OpenCode 1.18.29 or newer.") + throw new Error(`--opencode requires an exact ${major}.x version.`) if (settings.model && !/^[^/]+\/.+$/.test(settings.model)) throw new Error("--model must use provider/model format.") if (settings.transport && !["websocket", "http"].includes(settings.transport)) throw new Error("--transport must be websocket or http.") - if (major === 2 && settings.transport && !settings.model) + if (settings.transport && !settings.model) throw new Error("Select --model provider/model when overriding its transport.") - if (major === 1 && settings.transport !== "http") - throw new Error( - "The V1 sandbox uses HTTP so all requests can be logged. Use --transport http.", - ) const input = join(state, "launches", stamp) mkdirSync(input, { recursive: true, mode: 0o700 }) @@ -169,7 +148,7 @@ async function main() { join(repo, "scripts/sandbox"), ]) console.log(dcp === "local" ? "Building DCP and request logger…" : "Building request logger…") - if (!existsSync(join(repo, "node_modules"))) command("npm", ["ci", "--legacy-peer-deps"]) + if (!existsSync(join(repo, "node_modules"))) command("npm", ["ci"]) const packages = [] const directories = [join(repo, "tests/logger")] if (dcp === "local") directories.unshift(repo) diff --git a/scripts/sandbox/auth.mjs b/scripts/sandbox/auth.mjs index 2e87ce78a..b3896ffba 100644 --- a/scripts/sandbox/auth.mjs +++ b/scripts/sandbox/auth.mjs @@ -12,7 +12,6 @@ function dataPath(env) { export function authPath(major, env = process.env) { if (env.DCP_AUTH_PATH) return resolve(env.DCP_AUTH_PATH) - if (major === 1) return join(dataPath(env), "auth.json") try { return execFileSync("opencode2", ["debug", "paths", "db"], { env, @@ -33,10 +32,6 @@ export function copyAuth(major, destination, image) { `OpenCode V${major} authentication not found at ${source}. Sign in with OpenCode or set DCP_AUTH_PATH.`, ) mkdirSync(dirname(destination), { recursive: true, mode: 0o700 }) - if (major === 1) { - writeFileSync(destination, readFileSync(source), { mode: 0o600 }) - return - } // Only this short-lived exporter sees the host database, mounted read-only. // The sandbox receives credential records, never the host session database. execFileSync( @@ -82,10 +77,6 @@ export async function exportAuth(source, destination) { export async function restoreAuth(major, source, cli, env = process.env) { const data = dataPath(env) mkdirSync(data, { recursive: true, mode: 0o700 }) - if (major === 1) { - writeFileSync(join(data, "auth.json"), readFileSync(source), { mode: 0o600 }) - return - } // Let this OpenCode release initialize/migrate its own isolated database, // then import authentication while its private server is stopped. execFileSync(cli, ["auth", "list", "--standalone", "--format", "json"], { diff --git a/scripts/sandbox/run.mjs b/scripts/sandbox/run.mjs index 4f6959c87..122723d24 100644 --- a/scripts/sandbox/run.mjs +++ b/scripts/sandbox/run.mjs @@ -35,7 +35,7 @@ const { watch } = await import(pathToFileURL(join(logger, "readable.mjs"))) const logs = join("/lab/logs", launch.stamp) const raw = join(logs, "raw") const config = process.env.OPENCODE_CONFIG_DIR -const cli = `/opt/opencode/node_modules/.bin/${launch.major === 1 ? "opencode" : "opencode2"}` +const cli = `/opt/opencode/node_modules/.bin/opencode2` const separator = launch.model?.indexOf("/") const providers = launch.model && launch.transport @@ -55,67 +55,34 @@ try { await writeFile( join(config, "opencode.json"), JSON.stringify( - launch.major === 1 - ? { - $schema: "https://opencode.ai/config.json", - autoupdate: false, - model: launch.model, - small_model: launch.model, - plugin: [dcp, logger], - permission: { compress: "allow" }, - } - : { - $schema: "https://opencode.ai/config.json", - update: "disable", - model: launch.model, - plugins: [ - { package: dcp }, - { - package: logger, - options: { - directory: raw, - relay: `ws://127.0.0.1:${relay.server.address().port}`, - }, - }, - ], - permissions: [{ action: "compress", resource: "*", effect: "allow" }], - providers, - }, + { + $schema: "https://opencode.ai/config.json", + update: "disable", + model: launch.model, + plugins: [ + { package: dcp }, + { + package: logger, + options: { + directory: raw, + relay: `ws://127.0.0.1:${relay.server.address().port}`, + }, + }, + ], + permissions: [{ action: "compress", resource: "*", effect: "allow" }], + providers, + }, null, 2, ) + "\n", ) - if (launch.major === 1) { - // Keep the panel's source in sync, retaining user terminal preferences. - const path = join(config, "tui.json") - let tui = {} - try { - tui = JSON.parse(await readFile(path, "utf8")) - } catch (error) { - if (error.code !== "ENOENT") throw error - } - const plugins = [dcp] - for (const plugin of tui.plugin ?? []) { - if ( - typeof plugin === "string" && - (plugin === "/lab/plugins/node_modules/@mbarnett/opencode-dcp" || - plugin === "@mbarnett/opencode-dcp" || - plugin.startsWith("@mbarnett/opencode-dcp@")) - ) - continue - plugins.push(plugin) - } - tui.plugin = plugins - await writeFile(path, JSON.stringify(tui, null, 2) + "\n") - } try { await writeFile( join(config, "dcp.jsonc"), JSON.stringify( { $schema: - "https://raw.githubusercontent.com/Opencode-DCP/opencode-dynamic-context-pruning/main/dcp.schema.json", - autoUpdate: false, + "https://raw.githubusercontent.com/mathewbarnett/opencode-dynamic-context-pruning/master/dcp.schema.json", debug: true, pruneNotification: "off", }, @@ -128,13 +95,12 @@ try { if (error.code !== "EEXIST") throw error } await restoreAuth(launch.major, "/input/auth.json", cli) - const child = spawn(cli, [...launch.args, ...(launch.major === 1 ? [] : ["--standalone"])], { + const child = spawn(cli, [...launch.args, "--standalone"], { cwd: "/lab/project", stdio: "inherit", env: { ...process.env, OPENCODE_LOG_LEVEL: "DEBUG", - ...(launch.major === 1 ? { OPENCODE_EXPERIMENTAL_WEBSOCKETS: "false" } : {}), REQUEST_LOG_DIR: raw, }, }) diff --git a/scripts/verify-package.mjs b/scripts/verify-package.mjs index 8f841e484..f9f3d221c 100644 --- a/scripts/verify-package.mjs +++ b/scripts/verify-package.mjs @@ -16,9 +16,10 @@ const builtinNames = new Set([ const requiredRepoFiles = [ "dist/index.js", "dist/index.d.ts", + "dist/tui.js", "dist/tui.d.ts", - "tui.tsx", - "server.js", + "dcp.schema.json", + "dcp.example.jsonc", "README.md", "LICENSE", ] @@ -27,16 +28,20 @@ const requiredTarballFiles = [ "package.json", "dist/index.js", "dist/index.d.ts", + "dist/tui.js", "dist/tui.d.ts", - "tui.tsx", - "server.js", + "dcp.schema.json", + "dcp.example.jsonc", "README.md", "LICENSE", ] const forbiddenTarballPatterns = [ /^node_modules\//, + /^lib\//, // TUI and plugin are bundled; raw TS source must not ship /^index\.ts$/, + /^tui\.tsx$/, + /^server\.js$/, /^tests\//, /^scripts\//, /^docs\//, @@ -45,6 +50,7 @@ const forbiddenTarballPatterns = [ /^\.github\//, /^package-lock\.json$/, /^tsconfig\.json$/, + /^tsup\.config\.ts$/, ] const packageInfoCache = new Map() @@ -73,37 +79,59 @@ function assertPackageJsonShape() { fail("expected package.json exports['.'].import to be './dist/index.js'") } - if (pkg.exports?.["./server"]?.import !== "./dist/index.js") { - fail("expected package.json exports['./server'].import to be './dist/index.js'") + if (pkg.exports?.["./server"] !== undefined) { + fail("package.json must not export './server' (the V1 server path was removed)") } - if (pkg.exports?.["./tui"]?.import !== "./tui.tsx") { - fail("expected package.json exports['./tui'].import to be './tui.tsx'") + if (pkg.exports?.["./tui"]?.import !== "./dist/tui.js") { + fail("expected package.json exports['./tui'].import to be './dist/tui.js'") } const files = Array.isArray(pkg.files) ? pkg.files : [] - for (const entry of ["dist/", "lib/", "tui.tsx", "README.md", "LICENSE"]) { + for (const entry of ["dist/", "dcp.schema.json", "dcp.example.jsonc", "README.md", "LICENSE"]) { if (!files.includes(entry)) { fail(`package.json files must include ${entry}`) } } + for (const forbidden of ["lib/", "tui.tsx", "server.js"]) { + if (files.includes(forbidden)) { + fail(`package.json files must not include ${forbidden} (bundled output ships instead)`) + } + } } function getImportStatements(source) { - const pattern = /^\s*import\s+([^\n;]+?)\s+from\s+["']([^"']+)["']/gm - return Array.from(source.matchAll(pattern), (match) => ({ - clause: match[1].trim(), - specifier: match[2], - })) + const entries = [] + // Static imports (including multiline and side-effect/namespace forms). + const staticPattern = /\bimport\s+([\s\S]*?)\s+from\s*["']([^"']+)["']/g + for (const match of source.matchAll(staticPattern)) { + entries.push({ clause: match[1].trim(), specifier: match[2] }) + } + // Side-effect imports: import "pkg" + const sideEffectPattern = /\bimport\s*["']([^"']+)["']/g + for (const match of source.matchAll(sideEffectPattern)) { + entries.push({ clause: "", specifier: match[1] }) + } + // Dynamic imports: import("pkg") + const dynamicPattern = /\bimport\s*\(\s*["']([^"']+)["']\s*\)/g + for (const match of source.matchAll(dynamicPattern)) { + entries.push({ clause: "*", specifier: match[1] }) + } + return entries } function getImportKind(clause) { - if (clause.startsWith("type ")) return "type" + if (clause === "") return "side-effect" + if (clause === "*") return "dynamic" + if (clause.startsWith("type ") || /\btype\s*\{/.test(clause)) return "type" if (clause.startsWith("* as ")) return "namespace" if (clause.startsWith("{")) return "named" if (clause.includes(",")) { const [, trailing = ""] = clause.split(",", 2) - return trailing.trim().startsWith("* as ") ? "default+namespace" : "default+named" + const trailingTrimmed = trailing.trim() + if (trailingTrimmed.startsWith("* as ")) return "default+namespace" + if (trailingTrimmed.startsWith("type ")) return "default+named" + return "default+named" } return "default" } @@ -172,11 +200,29 @@ function packageLooksCommonJs(pkg) { if (!pkg) return false if (pkg.type === "commonjs") return true + // A package with an explicit ESM export condition is importable even when + // its legacy `main` points at a CJS bundle (e.g. zod, @anthropic-ai/*). + const rootExport = pkg.exports?.["."] + if (typeof rootExport === "string") return rootExport.endsWith(".cjs") + if (rootExport && typeof rootExport === "object" && rootExport.import) return false + + // A non-CJS `module` field points at an ESM build (e.g. jsonc-parser), so + // named ESM imports resolve even when the legacy `main` is a UMD bundle. + const moduleEntry = typeof pkg.module === "string" ? pkg.module : "" + if (moduleEntry.endsWith(".mjs") || moduleEntry.endsWith(".js")) return false + const main = typeof pkg.main === "string" ? pkg.main : "" return /(?:^|\/)(cjs|umd)(?:\/|$)/.test(main) || main.endsWith(".cjs") } function validateRuntimeImportGraph() { + const pkg = JSON.parse(readFileSync(path.join(root, "package.json"), "utf8")) + const declared = new Set([ + ...Object.keys(pkg.dependencies ?? {}), + ...Object.keys(pkg.peerDependencies ?? {}), + ]) + const devDeclared = new Set(Object.keys(pkg.devDependencies ?? {})) + const pending = [path.join(root, "index.ts"), path.join(root, "tui.tsx")] const seen = new Set() @@ -192,18 +238,29 @@ function validateRuntimeImportGraph() { continue } - if (entry.specifier === "jsonc-parser/lib/esm/main.js") { - continue - } - const packageName = getPackageName(entry.specifier) if (builtinNames.has(packageName)) continue const kind = getImportKind(entry.clause) - if (kind === "type" || kind === "namespace") continue + if (kind === "type") continue + + // Every runtime import must be declared as a production dependency; + // type-only imports may live in devDependencies. + if (!declared.has(packageName)) { + if (devDeclared.has(packageName) && kind !== "type") { + fail( + `${path.relative(root, filePath)} has a runtime ${kind} import from devDependency ${packageName}`, + ) + } + fail(`${path.relative(root, filePath)} imports undeclared package ${packageName}`) + } - const pkg = findPackageInfo(packageName, filePath) - if (packageLooksCommonJs(pkg)) { + // Namespace/dynamic imports of CJS packages are safe (the namespace + // object is the CJS exports); named/default imports are not. + if (kind === "namespace" || kind === "dynamic" || kind === "side-effect") continue + + const importedPkg = findPackageInfo(packageName, filePath) + if (packageLooksCommonJs(importedPkg)) { fail( `${path.relative(root, filePath)} uses ${kind} import from CommonJS-style package ${packageName}`, ) @@ -238,6 +295,29 @@ function validatePackedFiles() { fail(`packed tarball contains forbidden path ${forbidden}`) } + // The TUI must be fully bundled: every relative import reachable from + // dist/tui.js must exist in the tarball so no host-side transpilation of + // raw source is required. + const pendingTui = ["dist/tui.js"] + const seenTui = new Set() + while (pendingTui.length > 0) { + const current = pendingTui.pop() + if (seenTui.has(current)) continue + seenTui.add(current) + if (!packedPaths.includes(current)) { + fail(`packed tarball is missing TUI bundle chunk ${current}`) + } + const source = readFileSync(path.join(root, current), "utf8") + for (const entry of getImportStatements(source)) { + if (!entry.specifier.startsWith(".")) continue + const resolved = path + .normalize(path.join(path.dirname(current), entry.specifier)) + .split(path.sep) + .join("/") + pendingTui.push(resolved) + } + } + console.log(`package verification passed for ${result.name}@${result.version}`) console.log(`tarball entries: ${result.entryCount}`) } diff --git a/tests/compress-message.test.ts b/tests/compress-message.test.ts index 0ab54187c..54c3aa68f 100644 --- a/tests/compress-message.test.ts +++ b/tests/compress-message.test.ts @@ -22,7 +22,6 @@ function buildConfig(): PluginConfig { enabled: true, debug: false, pruneNotification: "off", - pruneNotificationType: "chat", commands: { enabled: true, protectedTools: [], @@ -641,7 +640,6 @@ test("compress message mode sends one aggregated notification for batched messag const logger = new Logger(false) const config = buildConfig() config.pruneNotification = "detailed" - config.pruneNotificationType = "toast" const toastCalls: string[] = [] const tool = createCompressMessageTool({ diff --git a/tests/compress-range.test.ts b/tests/compress-range.test.ts index ff9c71617..0ecf5daa1 100644 --- a/tests/compress-range.test.ts +++ b/tests/compress-range.test.ts @@ -22,7 +22,6 @@ function buildConfig(): PluginConfig { enabled: true, debug: false, pruneNotification: "off", - pruneNotificationType: "chat", commands: { enabled: true, protectedTools: [], @@ -271,7 +270,6 @@ test("compress range mode batches multiple ranges into one notification", async const logger = new Logger(false) const config = buildConfig() config.pruneNotification = "detailed" - config.pruneNotificationType = "toast" const toastCalls: string[] = [] const tool = createCompressRangeTool({ diff --git a/tests/compression-groups.test.ts b/tests/compression-groups.test.ts index c5bac056a..39fe49feb 100644 --- a/tests/compression-groups.test.ts +++ b/tests/compression-groups.test.ts @@ -25,7 +25,6 @@ function buildConfig(mode: "message" | "range"): PluginConfig { enabled: true, debug: false, pruneNotification: "off", - pruneNotificationType: "chat", commands: { enabled: true, protectedTools: [], @@ -177,10 +176,8 @@ test("compression notifications increment by tool call across range and message const rangeConfig = buildConfig("range") rangeConfig.pruneNotification = "detailed" - rangeConfig.pruneNotificationType = "toast" const messageConfig = buildConfig("message") messageConfig.pruneNotification = "detailed" - messageConfig.pruneNotificationType = "toast" const rangeTool = createCompressRangeTool({ client, diff --git a/tests/example-config.test.ts b/tests/example-config.test.ts index 9e61fbddf..8b2071a0c 100644 --- a/tests/example-config.test.ts +++ b/tests/example-config.test.ts @@ -12,7 +12,11 @@ test("example config is valid JSONC and documents every schema option", () => { assert.deepEqual(errors, []) function checkProperties(value: Record, definition: any, path = "") { - assert.deepEqual(Object.keys(value).sort(), Object.keys(definition.properties ?? {}).sort(), path) + assert.deepEqual( + Object.keys(value).sort(), + Object.keys(definition.properties ?? {}).sort(), + path, + ) for (const [key, property] of Object.entries(definition.properties ?? {})) { const name = path ? `${path}.${key}` : key assert.ok(Object.hasOwn(value, key), `missing example option ${name}`) diff --git a/tests/finalize-session.test.ts b/tests/finalize-session.test.ts index 6d5f70f75..76d05d4cb 100644 --- a/tests/finalize-session.test.ts +++ b/tests/finalize-session.test.ts @@ -15,7 +15,6 @@ function buildConfig(manualMode = false): PluginConfig { enabled: true, debug: false, pruneNotification: "off", - pruneNotificationType: "chat", commands: { enabled: true, protectedTools: [] }, manualMode: { enabled: manualMode, automaticStrategies: true }, turnProtection: { enabled: false, turns: 4 }, diff --git a/tests/hooks-permission.test.ts b/tests/hooks-permission.test.ts index 58d26c839..a2958618b 100644 --- a/tests/hooks-permission.test.ts +++ b/tests/hooks-permission.test.ts @@ -23,7 +23,6 @@ function buildConfig(permission: "allow" | "ask" | "deny" = "allow"): PluginConf enabled: true, debug: false, pruneNotification: "off", - pruneNotificationType: "chat", commands: { enabled: true, protectedTools: [], diff --git a/tests/logger/index.ts b/tests/logger/index.ts index 128a8da82..9c94a1d11 100644 --- a/tests/logger/index.ts +++ b/tests/logger/index.ts @@ -1,10 +1,7 @@ import type { Plugin } from "@opencode/plugin" -import { server } from "./v1.js" import { setup } from "./v2.js" -// Type-only V2 imports keep the shared entrypoint loadable in V1. export default { id: "opencode-request-logger", setup, - server, -} satisfies Plugin.Plugin & { server: typeof server } +} satisfies Plugin.Plugin diff --git a/tests/logger/package.json b/tests/logger/package.json index 4319ccbd5..28d04be3b 100644 --- a/tests/logger/package.json +++ b/tests/logger/package.json @@ -20,13 +20,9 @@ "test": "npm run build && node --test tests/*.test.mjs" }, "peerDependencies": { - "@opencode-ai/plugin": ">=1.18.29", - "@opencode/plugin": "^2.0.4" + "@opencode/plugin": "^2.3.2" }, "peerDependenciesMeta": { - "@opencode-ai/plugin": { - "optional": true - }, "@opencode/plugin": { "optional": true } diff --git a/tests/logger/v1.ts b/tests/logger/v1.ts deleted file mode 100644 index a7f59606d..000000000 --- a/tests/logger/v1.ts +++ /dev/null @@ -1,42 +0,0 @@ -import type { Plugin } from "@opencode-ai/plugin" -import { Capture } from "./log.js" - -let users = 0 -let restore: (() => void) | undefined - -export const server: Plugin = async () => { - users++ - if (!restore) { - const original = globalThis.fetch - const capture = new Capture() - const wrapped: typeof fetch = async (input, init) => { - const headers = new Headers( - init?.headers ?? (input instanceof Request ? input.headers : undefined), - ) - const sessionID = headers.get("x-opencode-session") - if (!users || !sessionID) return original(input, init) - const request = new Request(input, init) - const scope = { sessionID } - const id = await capture.request(scope, request) - try { - return await capture.response(scope, id, await original(input, init)) - } catch (error) { - await capture.write(scope, id, "end.json", { type: "http.end", status: "error" }) - throw error - } - } - globalThis.fetch = wrapped - restore = () => { - if (globalThis.fetch === wrapped) globalThis.fetch = original - restore = undefined - } - } - return { - "chat.headers": async (input, output) => { - output.headers["x-opencode-session"] = input.sessionID - }, - dispose: async () => { - if (--users === 0) restore?.() - }, - } -} diff --git a/tests/message-priority.test.ts b/tests/message-priority.test.ts index d6105eaea..a47417495 100644 --- a/tests/message-priority.test.ts +++ b/tests/message-priority.test.ts @@ -16,7 +16,6 @@ function buildConfig(mode: "message" | "range" = "message"): PluginConfig { enabled: true, debug: false, pruneNotification: "off", - pruneNotificationType: "chat", commands: { enabled: true, protectedTools: [], diff --git a/tests/native/history.test.ts b/tests/native/history.test.ts new file mode 100644 index 000000000..c6f25b63b --- /dev/null +++ b/tests/native/history.test.ts @@ -0,0 +1,128 @@ +import assert from "node:assert/strict" +import test from "node:test" +import { history } from "../../lib/native/messages" + +const session = { + id: "ses_1", + agent: "build", + model: { providerID: "anthropic", id: "claude-sonnet-4", variant: undefined }, + parentID: null, +} + +const entries: any[] = [ + { id: "msg_u1", type: "user", time: { created: 1000 }, text: "hello", skills: [] }, + { + id: "msg_u2", + type: "user", + time: { created: 1500 }, + text: "second", + skills: [{ text: "skill context" }], + }, + { + id: "msg_a1", + type: "assistant", + time: { created: 2000 }, + agent: "build", + model: { providerID: "anthropic", id: "claude-sonnet-4" }, + tokens: { input: 10, output: 5, reasoning: 0, cache: { read: 0, write: 0 } }, + content: [ + { type: "text", text: "working" }, + { + type: "tool", + id: "call_1", + name: "bash", + input: { command: "ls" }, + state: { + status: "completed", + content: [{ type: "text", text: "file.ts" }], + }, + }, + ], + }, + { id: "msg_s1", type: "synthetic", time: { created: 3000 }, text: "a synthetic note" }, + { + id: "msg_l1", + type: "location-switched", + time: { created: 4000 }, + location: { directory: "/tmp/project" }, + }, + { + id: "msg_sh1", + type: "shell", + time: { created: 5000 }, + command: "echo hi", + output: { output: "hi" }, + metadata: {}, + }, + { + id: "msg_sh2", + type: "shell", + time: { created: 5500 }, + command: "npm run watch", + output: { output: "" }, + metadata: { background: true }, + }, + { id: "msg_c1", type: "compaction", time: { created: 6000 }, status: "pending" }, + { id: "msg_c2", type: "compaction", time: { created: 7000 }, status: "completed" }, +] + +test("history projects session entries into engine messages", () => { + const messages = history(entries as any, session as any) + assert.deepEqual( + messages.map((message) => message.info.id), + ["msg_u1", "msg_u2", "msg_a1", "msg_s1", "msg_l1", "msg_sh1", "msg_c2"], + ) +}) + +test("history joins user skill context with user text", () => { + const messages = history(entries as any, session as any) + assert.equal(messages[1]!.info.role, "user") + assert.equal(messages[1]!.parts[0]!.text, "skill context\n\nsecond") +}) + +test("history expands assistant tool calls into tool parts with output", () => { + const messages = history(entries as any, session as any) + const assistant = messages[2]! + assert.equal(assistant.info.role, "assistant") + assert.equal(assistant.parts[0]!.type, "step-start") + assert.equal(assistant.parts[1]!.text, "working") + const tool = assistant.parts[2]! + assert.equal(tool.type, "tool") + assert.equal(tool.tool, "bash") + assert.equal(tool.callID, "call_1") + assert.equal(tool.state.status, "completed") + assert.equal(tool.state.output, "file.ts") +}) + +test("history fills info fields from the assistant entry and session", () => { + const messages = history(entries as any, session as any) + const assistant = messages[2]!.info + assert.equal(assistant.sessionID, "ses_1") + assert.equal(assistant.time.created, 2000) + assert.equal(assistant.agent, "build") + assert.equal(assistant.model.providerID, "anthropic") + assert.equal(assistant.model.modelID, "claude-sonnet-4") + assert.equal(assistant.tokens.input, 10) + assert.equal(assistant.tokens.output, 5) +}) + +test("history renders location switches and foreground shell commands as user text", () => { + const messages = history(entries as any, session as any) + assert.match(messages[4]!.parts[0]!.text, /\/tmp\/project/) + assert.match(messages[5]!.parts[0]!.text, /echo hi/) +}) + +test("history ignores background shells and incomplete compactions", () => { + const ids = history(entries as any, session as any).map((message) => message.info.id) + assert.ok(!ids.includes("msg_sh2"), "background shell ignored") + assert.ok(!ids.includes("msg_c1"), "pending compaction ignored") +}) + +test("history marks completed compactions as summary messages", () => { + const messages = history(entries as any, session as any) + const summary = messages[6]! + assert.equal(summary.info.id, "msg_c2") + assert.equal(summary.info.role, "assistant") + assert.equal(summary.info.summary, true) + assert.equal(summary.parts.length, 0) +}) diff --git a/tests/native/mock-context.ts b/tests/native/mock-context.ts new file mode 100644 index 000000000..598e8115e --- /dev/null +++ b/tests/native/mock-context.ts @@ -0,0 +1,209 @@ +/** + * Minimal mock of the OpenCode 2.3.x Plugin.Context for characterizing the + * plugin wiring without a running host. + */ +export interface MockOptions { + directory: string + entries?: any[] + session?: any + agent?: any + models?: any[] + config?: Record +} + +export function createMockContext(options: MockOptions) { + const session = options.session ?? { + id: "ses_1", + agent: "build", + model: { providerID: "anthropic", id: "claude-sonnet-4", variant: undefined }, + parentID: null, + permissions: [], + } + const entries = options.entries ?? [ + { + id: "msg_1", + type: "user", + time: { created: 1000 }, + text: "Please inspect the repo", + }, + { + id: "msg_2", + type: "assistant", + time: { created: 2000 }, + agent: "build", + model: { providerID: "anthropic", id: "claude-sonnet-4" }, + tokens: { input: 10, output: 5, reasoning: 0, cache: { read: 0, write: 0 } }, + content: [], + }, + ] + const agent = options.agent ?? { id: "build", permissions: [] } + const models = options.models ?? [ + { providerID: "anthropic", id: "claude-sonnet-4", limit: { context: 200000 } }, + ] + + const hooks: Record Promise> = {} + const tools: any[] = [] + const commands: any[] = [] + const prompts: any[] = [] + const permissionHooks: Record Promise | void> = {} + const permissionAsserts: any[] = [] + const registrations: Array<{ dispose(): Promise | void }> = [] + let rpcDefinition: any + let rpcHandlers: any + const rpcEvents: Array<{ name: string; data: any }> = [] + + const ctx: any = { + location: { directory: options.directory }, + model: { + transform: async (callback: (editor: any) => void) => { + callback({ list: () => models }) + const registration = { dispose: async () => {} } + registrations.push(registration) + return registration + }, + }, + session: { + get: async () => session, + context: async () => entries, + prompt: async (input: any) => { + prompts.push(input) + return {} + }, + hook: async (kind: string, callback: (event: any) => Promise) => { + hooks[kind] = callback + registrations.push({ + dispose: async () => { + delete hooks[kind] + }, + }) + return { + dispose: async () => { + delete hooks[kind] + }, + } + }, + }, + agent: { + get: async () => ({ data: agent }), + }, + permission: { + hook: async (name: string, callback: (event: any) => void) => { + permissionHooks[name] = callback + registrations.push({ + dispose: async () => { + delete permissionHooks[name] + }, + }) + return { + dispose: async () => { + delete permissionHooks[name] + }, + } + }, + assert: async (input: any) => { + permissionAsserts.push(input) + }, + }, + tool: { + transform: async (callback: (editor: any) => void) => { + callback({ add: (tool: any) => tools.push(tool) }) + registrations.push({ + dispose: async () => { + tools.length = 0 + }, + }) + return { + dispose: async () => { + tools.length = 0 + }, + } + }, + }, + command: { + transform: async (callback: (editor: any) => void) => { + callback({ add: (command: any) => commands.push(command) }) + registrations.push({ + dispose: async () => { + commands.length = 0 + }, + }) + return { + dispose: async () => { + commands.length = 0 + }, + } + }, + }, + rpc: { + register: async (definition: any, handlers: any) => { + rpcDefinition = definition + rpcHandlers = handlers + const registration = { + events: { + emit: async (name: string, data: any) => { + rpcEvents.push({ name, data }) + }, + }, + dispose: async () => {}, + } + registrations.push({ + dispose: async () => { + rpcDefinition = undefined + rpcHandlers = undefined + }, + }) + return registration + }, + }, + ui: { + toast: { show: () => {} }, + dialog: { show: () => {}, set: () => {}, clear: () => {} }, + router: { current: () => ({ type: "session", sessionID: session.id }) }, + slot: () => ({ dispose: () => {} }), + }, + attention: { notify: async () => ({ ok: true, notification: false, sound: false }) }, + keymap: { layer: (cb: () => any) => cb() }, + renderer: { height: 40, on: () => {}, off: () => {} }, + theme: {}, + client: {}, + } + + return { + ctx, + session, + entries, + agent, + hooks, + tools, + commands, + prompts, + permissionHooks, + permissionAsserts, + registrations, + getRpcDefinition: () => rpcDefinition, + getRpcHandlers: () => rpcHandlers, + rpcEvents, + invoke: async (kind: "context" | "compaction", event: any) => hooks[kind]?.(event), + } +} + +export function sessionEvent(overrides: Partial = {}) { + const message = (id: string, role: string, text: string) => ({ + id, + role, + content: [{ type: "text", text }], + }) + return { + sessionID: "ses_1", + agent: "build", + model: { providerID: "anthropic", id: "claude-sonnet-4" }, + system: [{ type: "text", text: "You are a helpful assistant." }], + messages: [ + message("msg_1", "user", "Please inspect the repo"), + message("msg_2", "assistant", "I will take a look"), + ], + options: {}, + tools: {}, + ...overrides, + } +} diff --git a/tests/native/notifications.test.ts b/tests/native/notifications.test.ts new file mode 100644 index 000000000..67c62218e --- /dev/null +++ b/tests/native/notifications.test.ts @@ -0,0 +1,147 @@ +import assert from "node:assert/strict" +import test from "node:test" +import { notificationEvent, rpc } from "../../lib/native/rpc" +import { createNotifier, createToastSubscriber } from "../../lib/native/notifications" +import { createMockContext } from "./mock-context" +import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs" +import { tmpdir } from "node:os" +import { join } from "node:path" + +const root = mkdtempSync(join(tmpdir(), "dcp-native-notifications-")) +const configHome = join(root, "config") +const opencodeDir = join(configHome, "opencode") +mkdirSync(opencodeDir, { recursive: true }) +mkdirSync(join(root, "data"), { recursive: true }) +process.env.XDG_CONFIG_HOME = configHome +process.env.XDG_DATA_HOME = join(root, "data") +writeFileSync( + join(opencodeDir, "dcp.jsonc"), + JSON.stringify({ enabled: true, debug: false, pruneNotification: "off" }), +) + +test("RPC definition exposes the notification event", () => { + assert.deepEqual(Object.keys(rpc.events), ["notification", "openPanel"]) + assert.deepEqual( + notificationEvent.parse({ + title: "DCP", + message: "Compressed 3 messages", + variant: "success", + duration: 4000, + sessionID: "ses_1", + }), + { + title: "DCP", + message: "Compressed 3 messages", + variant: "success", + duration: 4000, + sessionID: "ses_1", + }, + ) + assert.throws(() => notificationEvent.parse({ message: "x", variant: "unknown" })) +}) + +test("notifier turns a toast call into a normalized RPC event", async () => { + const emitted: unknown[] = [] + const notifier = createNotifier(async (event) => { + emitted.push(event) + }) + await notifier.showToast({ + body: { title: "DCP: Prune", message: "Pruned 2 outputs", variant: "weird" }, + sessionID: "ses_1", + }) + assert.deepEqual(emitted, [ + { + title: "DCP: Prune", + message: "Pruned 2 outputs", + variant: "info", + duration: 5000, + sessionID: "ses_1", + }, + ]) +}) + +test("notifier carries command output as a toast, never a prompt message", async () => { + const emitted: unknown[] = [] + const notifier = createNotifier(async (event) => { + emitted.push(event) + }) + await notifier.prompt({ + path: { id: "ses_1" }, + body: { parts: [{ text: "Context report" }, { text: "42 tokens" }] }, + }) + assert.deepEqual(emitted, [ + { + title: "DCP", + message: "Context report\n42 tokens", + variant: "info", + duration: 5000, + sessionID: "ses_1", + }, + ]) +}) + +test("notifier suppresses duplicate and burst notifications", async () => { + const emitted: string[] = [] + const notifier = createNotifier(async (event) => { + emitted.push(event.message) + }) + await notifier.showToast({ body: { message: "same" }, sessionID: "ses_1" }) + await notifier.showToast({ body: { message: "same" }, sessionID: "ses_1" }) + await notifier.showToast({ body: { message: "other" }, sessionID: "ses_1" }) + for (let i = 0; i < 10; i++) + await notifier.showToast({ body: { message: `burst ${i}` }, sessionID: "ses_1" }) + assert.deepEqual(emitted, ["same", "other", "burst 0", "burst 1"]) // 4 per window +}) + +test("toast subscriber shows and deduplicates events", () => { + const shown: unknown[] = [] + const subscriber = createToastSubscriber({ + show: (toast) => { + shown.push(toast) + }, + }) + const event = { + data: { title: "DCP", message: "Compressed", variant: "success" as const }, + } + subscriber(event) + subscriber(event) + assert.deepEqual(shown, [ + { + title: "DCP", + message: "Compressed", + variant: "success", + duration: 5000, + sessionID: undefined, + }, + ]) +}) + +test("command output emits a notification event through RPC", async () => { + const mock = createMockContext({ directory: "/tmp" }) + const cleanup = await import("../../lib/native/plugin").then(({ setup }) => setup(mock.ctx)) + const command = mock.commands.find((entry) => entry.name === "dcp") + assert.ok(command) + await command.execute({ + sessionID: "ses_1", + prompt: { text: "help" }, + delivery: "ui", + }) + assert.ok(mock.rpcEvents.length > 0, "command output emitted a notification") + assert.equal(mock.rpcEvents[0]!.name, "notification") + assert.match(String(mock.rpcEvents[0]!.data.message), /DCP/) + await cleanup?.() +}) + +test("bare /dcp emits openPanel instead of registering a second slash command", async () => { + const mock = createMockContext({ directory: "/tmp" }) + const cleanup = await import("../../lib/native/plugin").then(({ setup }) => setup(mock.ctx)) + const command = mock.commands.find((entry) => entry.name === "dcp") + assert.ok(command) + await command.execute({ + sessionID: "ses_1", + prompt: { text: "" }, + delivery: "ui", + }) + assert.deepEqual(mock.rpcEvents, [{ name: "openPanel", data: {} }]) + await cleanup?.() +}) diff --git a/tests/native/permissions.test.ts b/tests/native/permissions.test.ts new file mode 100644 index 000000000..5bdd9e045 --- /dev/null +++ b/tests/native/permissions.test.ts @@ -0,0 +1,191 @@ +import assert from "node:assert/strict" +import test from "node:test" +import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs" +import { tmpdir } from "node:os" +import { join } from "node:path" +import { createMockContext } from "./mock-context" + +const root = mkdtempSync(join(tmpdir(), "dcp-native-perms-")) +const configHome = join(root, "config") +const dataHome = join(root, "data") +const directory = join(root, "project") +const opencodeDir = join(configHome, "opencode") +for (const dir of [configHome, opencodeDir, dataHome, directory]) + mkdirSync(dir, { recursive: true }) +process.env.XDG_CONFIG_HOME = configHome +process.env.XDG_DATA_HOME = dataHome +const configPath = join(opencodeDir, "dcp.jsonc") + +function writeConfig(config: Record) { + writeFileSync(configPath, JSON.stringify({ enabled: true, debug: false, ...config })) +} + +const { setup } = await import("../../lib/native/plugin") +const { applyCompressEvaluation, resolveCompressPermission } = + await import("../../lib/native/permissions") + +async function snapshot(options: Parameters[0]) { + const mock = createMockContext(options) + await setup(mock.ctx) + const result = await mock + .getRpcHandlers() + .snapshot({ sessionID: "ses_1" }, { signal: new AbortController().signal }) + return { mock, result } +} + +test("compression is allowed by default", async () => { + writeConfig({ compress: { permission: "allow" } }) + const { mock, result } = await snapshot({ directory }) + assert.equal(result.canCompress, true) + assert.equal(result.blockedReason, undefined) + assert.ok(mock.tools.some((tool) => tool.name === "compress")) +}) + +test("an agent deny rule disables compression", async () => { + writeConfig({ compress: { permission: "allow" } }) + const { mock, result } = await snapshot({ + directory, + agent: { + id: "build", + permissions: [{ action: "compress", resource: "*", effect: "deny" }], + }, + }) + assert.equal(result.canCompress, false) + assert.ok( + mock.tools.some((tool) => tool.name === "compress"), + "tool is registered but gated at execution time", + ) +}) + +test("a session deny rule disables compression", async () => { + writeConfig({ compress: { permission: "allow" } }) + const { result } = await snapshot({ + directory, + session: { + id: "ses_1", + agent: "build", + model: { providerID: "anthropic", id: "claude-sonnet-4" }, + parentID: null, + permissions: [{ action: "compress", resource: "*", effect: "deny" }], + }, + }) + assert.equal(result.canCompress, false) +}) + +test("a later explicit allow overrides an earlier deny", async () => { + writeConfig({ compress: { permission: "allow" } }) + const { result } = await snapshot({ + directory, + agent: { + id: "build", + permissions: [ + { action: "compress", resource: "*", effect: "deny" }, + { action: "compress", resource: "*", effect: "allow" }, + ], + }, + }) + assert.equal(result.canCompress, true) +}) + +test("config deny disables compression and removes the tool", async () => { + writeConfig({ compress: { permission: "deny" } }) + const { mock, result } = await snapshot({ directory }) + assert.equal(result.canCompress, false) + assert.ok(!mock.tools.some((tool) => tool.name === "compress")) +}) + +test("config ask is approval-gated instead of unsupported", async () => { + writeConfig({ compress: { permission: "ask" } }) + const { mock, result } = await snapshot({ directory }) + assert.equal(result.canCompress, true) + assert.match(result.blockedReason ?? "", /approval/) + assert.ok(mock.permissionHooks.evaluate, "native evaluate hook registered") +}) + +test("subagents are blocked unless enabled", async () => { + writeConfig({ compress: { permission: "allow" } }) + const { result } = await snapshot({ + directory, + session: { + id: "ses_sub", + parentID: "ses_1", + agent: "build", + model: { providerID: "anthropic", id: "claude-sonnet-4" }, + permissions: [], + }, + }) + assert.equal(result.canCompress, false) +}) + +test("native resolver: config deny wins over host allow", () => { + assert.deepEqual( + resolveCompressPermission( + "deny", + [{ action: "compress", resource: "*", effect: "allow" }], + [], + ), + { effect: "deny", source: "config" }, + ) +}) + +test("native resolver: later session rule overrides agent rule", () => { + assert.equal( + resolveCompressPermission( + "allow", + [{ action: "compress", resource: "*", effect: "deny" }], + [{ action: "compress", resource: "*", effect: "allow" }], + ).effect, + "allow", + ) +}) + +test("native resolver: resource-specific rules do not gate the whole tool", () => { + assert.equal( + resolveCompressPermission("allow", [ + { action: "compress", resource: "/tmp/*", effect: "deny" }, + ]).effect, + "allow", + ) +}) + +test("native resolver: host deny overrides config ask", () => { + assert.equal( + resolveCompressPermission("ask", [{ action: "c?mpress", resource: "*", effect: "deny" }]) + .effect, + "deny", + ) +}) + +test("evaluate hook applies config ask to native evaluations", () => { + const evaluation: any = { action: "compress", effect: "allow" } + applyCompressEvaluation("ask", evaluation) + assert.equal(evaluation.effect, "ask") + const other: any = { action: "read", effect: "allow" } + applyCompressEvaluation("deny", other) + assert.equal(other.effect, "allow") +}) + +test("compress tool calls native permission assert before running", async () => { + writeConfig({ compress: { permission: "ask" } }) + const mock = createMockContext({ directory }) + await setup(mock.ctx) + const tool = mock.tools.find((item: any) => item.name === "compress") + assert.ok(tool) + try { + await tool.execute( + { topic: "topic", content: "content" }, + { + sessionID: "ses_1", + messageID: "msg_9", + id: "call_1", + agent: "build", + progress: async () => {}, + }, + ) + } catch { + // The mock host cannot run a full compression; the assert still must have happened. + } + assert.equal(mock.permissionAsserts.length, 1) + assert.equal(mock.permissionAsserts[0].action, "compress") + assert.equal(mock.permissionAsserts[0].source.id, "call_1") +}) diff --git a/tests/native/phase5.test.ts b/tests/native/phase5.test.ts new file mode 100644 index 000000000..bffdadec1 --- /dev/null +++ b/tests/native/phase5.test.ts @@ -0,0 +1,100 @@ +import assert from "node:assert/strict" +import test from "node:test" +import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs" +import { tmpdir } from "node:os" +import { join } from "node:path" + +const root = mkdtempSync(join(tmpdir(), "dcp-native-phase5-")) +const configHome = join(root, "config") +const opencodeDir = join(configHome, "opencode") +mkdirSync(opencodeDir, { recursive: true }) +mkdirSync(join(root, "data"), { recursive: true }) +process.env.XDG_CONFIG_HOME = configHome +process.env.XDG_DATA_HOME = join(root, "data") +writeFileSync( + join(opencodeDir, "dcp.jsonc"), + JSON.stringify({ enabled: true, debug: false, pruneNotification: "off" }), +) + +const { getConfig } = await import("../../lib/config") +const { Logger } = await import("../../lib/logger") +const { PromptStore } = await import("../../lib/prompts/store") +const { createSessionState } = await import("../../lib/state") +const { injectNativeSystemPrompt } = await import("../../lib/native/system-prompt") +const { executeNativeCommand } = await import("../../lib/native/commands") + +const warnings = { tui: { showToast: async () => {} } } + +function deps() { + const logger = new Logger(false) + const config = getConfig({ directory: root, client: warnings as any }) + const state = createSessionState("compact") + const prompts = new PromptStore(logger, root, config.experimental.customPrompts, "compact") + const emitted: any[] = [] + const client = { + session: { + messages: async () => ({ data: [] }), + prompt: async (input: any) => { + emitted.push(input) + return {} + }, + }, + tui: { showToast: async () => {} }, + } + return { logger, config, state, prompts, client, emitted } +} + +test("native system prompt preserves non-text parts and appends to last text part", () => { + const { logger, config, state, prompts } = deps() + const system: any[] = [ + { type: "text", text: "base", cache: { type: "ephemeral" }, metadata: { a: 1 } }, + { type: "text", text: "ignored-marker" }, + ] + injectNativeSystemPrompt(state, logger, config, prompts, system) + assert.equal(system.length, 2) + assert.equal(system[0]!.cache?.type, "ephemeral") + assert.deepEqual(system[0]!.metadata, { a: 1 }) + assert.ok(system[1]!.text.startsWith("ignored-marker\n\n")) + assert.match(system[1]!.text, /context management/) +}) + +test("native system prompt skips internal agent calls", () => { + const { logger, config, state, prompts } = deps() + const system: any[] = [{ type: "text", text: "You are a title generator" }] + injectNativeSystemPrompt(state, logger, config, prompts, system) + assert.equal(system.length, 1) + assert.equal(system[0]!.text, "You are a title generator") +}) + +test("native command dispatch toggles manual mode via shared handler", async () => { + const { logger, config, state, client } = deps() + const trigger = await executeNativeCommand({ + client, + state, + logger, + config, + workingDirectory: root, + sessionID: "ses_1", + text: "manual on", + messages: [], + }) + assert.equal(trigger, null) + assert.ok(state.manualMode) +}) + +test("native command dispatch stages a manual compress trigger", async () => { + const { logger, config, state, client } = deps() + const trigger = await executeNativeCommand({ + client, + state, + logger, + config, + workingDirectory: root, + sessionID: "ses_1", + text: "compress focus here", + messages: [], + }) + assert.ok(trigger, "a trigger prompt is returned") + assert.equal(state.manualMode, "compress-pending") + assert.equal(state.pendingManualTrigger?.prompt, trigger) +}) diff --git a/tests/native/rpc.test.ts b/tests/native/rpc.test.ts new file mode 100644 index 000000000..ae33ce984 --- /dev/null +++ b/tests/native/rpc.test.ts @@ -0,0 +1,69 @@ +import assert from "node:assert/strict" +import test from "node:test" +import { rpc } from "../../lib/native/rpc" + +test("rpc definition uses the dcp namespace", () => { + assert.equal(rpc.id, "dcp") + assert.deepEqual(Object.keys(rpc.methods).sort(), ["manual", "snapshot", "status"]) + assert.deepEqual(Object.keys(rpc.events), ["notification", "openPanel"]) +}) + +test("status method schemas validate their payloads", () => { + assert.deepEqual(rpc.methods.status.input.parse({}), {}) + assert.deepEqual(rpc.methods.status.output.parse({ enabled: true }), { enabled: true }) + assert.throws(() => rpc.methods.status.output.parse({ enabled: "yes" })) +}) + +test("snapshot input requires a session ID", () => { + assert.deepEqual(rpc.methods.snapshot.input.parse({ sessionID: "ses_1" }), { + sessionID: "ses_1", + }) + assert.throws(() => rpc.methods.snapshot.input.parse({})) +}) + +test("snapshot output allows an optional blocked reason", () => { + const base = { + manualMode: false, + canCompress: true, + context: { + system: 0, + user: 0, + assistant: 0, + tools: 0, + toolCount: 0, + toolsInContextCount: 0, + prunedTokens: 0, + prunedToolCount: 0, + prunedMessageCount: 0, + total: 0, + }, + stats: { + sessionTokens: 0, + sessionSummaryTokens: 0, + sessionDurationMs: 0, + sessionTools: 0, + sessionMessages: 0, + allTime: { + totalTokens: 0, + totalTools: 0, + totalMessages: 0, + sessionCount: 0, + }, + }, + } + assert.deepEqual(rpc.methods.snapshot.output.parse(base), base) + assert.deepEqual( + rpc.methods.snapshot.output.parse({ ...base, blockedReason: "not supported" }) + .blockedReason, + "not supported", + ) +}) + +test("manual method schemas validate their payloads", () => { + assert.deepEqual(rpc.methods.manual.input.parse({ sessionID: "ses_1", enabled: true }), { + sessionID: "ses_1", + enabled: true, + }) + assert.throws(() => rpc.methods.manual.input.parse({ sessionID: "ses_1" })) + assert.deepEqual(rpc.methods.manual.output.parse({}), {}) +}) diff --git a/tests/native/setup.test.ts b/tests/native/setup.test.ts new file mode 100644 index 000000000..1f9ee81bc --- /dev/null +++ b/tests/native/setup.test.ts @@ -0,0 +1,123 @@ +import assert from "node:assert/strict" +import test from "node:test" +import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs" +import { tmpdir } from "node:os" +import { join } from "node:path" +import { createMockContext, sessionEvent } from "./mock-context" + +const root = mkdtempSync(join(tmpdir(), "dcp-native-setup-")) +const configHome = join(root, "config") +const dataHome = join(root, "data") +const opencodeDir = join(configHome, "opencode") +mkdirSync(opencodeDir, { recursive: true }) +mkdirSync(dataHome, { recursive: true }) +process.env.XDG_CONFIG_HOME = configHome +process.env.XDG_DATA_HOME = dataHome +const directory = join(root, "project") +mkdirSync(directory, { recursive: true }) + +writeFileSync( + join(opencodeDir, "dcp.jsonc"), + JSON.stringify({ enabled: true, debug: false, pruneNotification: "off" }), +) + +const { setup } = await import("../../lib/native/plugin") + +test("setup registers context and compaction hooks", async () => { + const mock = createMockContext({ directory }) + const cleanup = await setup(mock.ctx) + assert.equal(typeof cleanup, "function") + assert.ok(mock.hooks.context, "context hook registered") + assert.ok(mock.hooks.compaction, "compaction hook registered") +}) + +test("setup registers a JSON-schema compress tool", async () => { + const mock = createMockContext({ directory }) + await setup(mock.ctx) + const compress = mock.tools.find((tool) => tool.name === "compress") + assert.ok(compress, "compress tool registered") + assert.equal(compress.options.permission, "compress") + assert.equal(compress.input.type, "object") + assert.deepEqual(compress.input.required, ["topic", "content"]) + assert.equal(typeof compress.execute, "function") +}) + +test("setup registers dcp commands", async () => { + const mock = createMockContext({ directory }) + await setup(mock.ctx) + const names = mock.commands.map((command) => command.name) + assert.ok(names.includes("dcp"), "dcp command registered") + assert.ok(names.includes("dcp-compress"), "dcp-compress command registered") +}) + +test("setup registers RPC methods", async () => { + const mock = createMockContext({ directory }) + await setup(mock.ctx) + const definition = mock.getRpcDefinition() + assert.equal(definition.id, "dcp") + assert.deepEqual(Object.keys(definition.methods).sort(), ["manual", "snapshot", "status"]) +}) + +test("status RPC reports command availability", async () => { + const mock = createMockContext({ directory }) + await setup(mock.ctx) + assert.deepEqual( + await mock.getRpcHandlers().status({}, { signal: new AbortController().signal }), + { + enabled: true, + }, + ) +}) + +test("snapshot RPC returns context and stats for a session", async () => { + const mock = createMockContext({ directory }) + await setup(mock.ctx) + const snapshot = await mock + .getRpcHandlers() + .snapshot({ sessionID: "ses_1" }, { signal: new AbortController().signal }) + assert.equal(typeof snapshot.manualMode, "boolean") + assert.equal(typeof snapshot.canCompress, "boolean") + assert.equal(typeof snapshot.context.total, "number") + assert.equal(typeof snapshot.stats.sessionTokens, "number") +}) + +test("manual RPC toggles manual mode", async () => { + const mock = createMockContext({ directory }) + await setup(mock.ctx) + const handlers = mock.getRpcHandlers() + const context = { signal: new AbortController().signal } + await handlers.manual({ sessionID: "ses_1", enabled: true }, context) + let snapshot = await handlers.snapshot({ sessionID: "ses_1" }, context) + assert.equal(snapshot.manualMode, true) + await handlers.manual({ sessionID: "ses_1", enabled: false }, context) + snapshot = await handlers.snapshot({ sessionID: "ses_1" }, context) + assert.equal(snapshot.manualMode, false) +}) + +test("context hook runs the pipeline without throwing", async () => { + const mock = createMockContext({ directory }) + await setup(mock.ctx) + const event = sessionEvent() + await mock.invoke("context", event) + assert.ok(event.messages.length >= 2, "messages survive the transform") + assert.ok( + event.system.some((part: any) => part.text.includes("context management")), + "system prompt injected", + ) +}) + +test("disabled config skips hooks and tools", async () => { + const disabledDir = join(root, "disabled-project") + const opencodeDir = join(disabledDir, ".opencode") + mkdirSync(opencodeDir, { recursive: true }) + writeFileSync(join(opencodeDir, "dcp.jsonc"), JSON.stringify({ enabled: false })) + const mock = createMockContext({ directory: disabledDir }) + await setup(mock.ctx) + assert.equal(Object.keys(mock.hooks).length, 0) + assert.equal(mock.tools.length, 0) + assert.equal(mock.commands.length, 0) + assert.deepEqual( + await mock.getRpcHandlers().status({}, { signal: new AbortController().signal }), + { enabled: false }, + ) +}) diff --git a/tests/phase6-regressions.test.ts b/tests/phase6-regressions.test.ts new file mode 100644 index 000000000..bf8c53739 --- /dev/null +++ b/tests/phase6-regressions.test.ts @@ -0,0 +1,330 @@ +import assert from "node:assert/strict" +import test from "node:test" +import { join } from "node:path" +import { tmpdir } from "node:os" +import { mkdirSync } from "node:fs" +import { parse } from "jsonc-parser" +import { createCompressMessageTool } from "../lib/compress/message" +import { createSessionState, type WithParts } from "../lib/state" +import type { PluginConfig } from "../lib/config" +import { Logger } from "../lib/logger" +import { syncToolCache } from "../lib/state/tool-cache" +import { deduplicate } from "../lib/strategies/deduplication" +import { syncCompressionBlocks } from "../lib/messages/sync" +import { resetOnCompaction } from "../lib/state/utils" +import { appendProtectedUserMessages } from "../lib/compress/protected-content" +import { validateConfigTypes } from "../lib/config" +import { getCurrentTokenUsage } from "../lib/token-utils" + +const testDataHome = join(tmpdir(), `dcp-p6-data-${process.pid}`) +const testConfigHome = join(tmpdir(), `dcp-p6-config-${process.pid}`) +process.env.XDG_DATA_HOME = testDataHome +process.env.XDG_CONFIG_HOME = testConfigHome +mkdirSync(testDataHome, { recursive: true }) +mkdirSync(testConfigHome, { recursive: true }) + +function buildConfig(): PluginConfig { + return { + enabled: true, + debug: false, + pruneNotification: "off", + commands: { enabled: true, protectedTools: [] }, + manualMode: { enabled: false, automaticStrategies: true }, + turnProtection: { enabled: false, turns: 4 }, + experimental: { allowSubAgents: false, customPrompts: false }, + protectedFilePatterns: [], + compress: { + mode: "message", + permission: "allow", + showCompression: false, + maxContextLimit: 150000, + minContextLimit: 50000, + nudgeFrequency: 5, + iterationNudgeThreshold: 15, + nudgeForce: "soft", + protectedTools: [], + protectTags: false, + protectUserMessages: false, + }, + strategies: { + deduplication: { enabled: true, protectedTools: [] }, + purgeErrors: { enabled: true, turns: 4, protectedTools: [] }, + }, + } as PluginConfig +} + +function textPart(messageID: string, sessionID: string, id: string, text: string) { + return { id, messageID, sessionID, type: "text" as const, text } +} + +function buildMessages(sessionID: string): WithParts[] { + return [ + { + info: { + id: "msg-user-1", + role: "user", + sessionID, + agent: "assistant", + model: { providerID: "anthropic", modelID: "claude-test" }, + time: { created: 1 }, + } as WithParts["info"], + parts: [textPart("msg-user-1", sessionID, "part-1", "First line\nSecond line")], + }, + { + info: { + id: "msg-assistant-1", + role: "assistant", + sessionID, + agent: "assistant", + time: { created: 2 }, + } as WithParts["info"], + parts: [textPart("msg-assistant-1", sessionID, "part-2", "I mapped the code path")], + }, + ] +} + +function buildTool( + state: ReturnType, + messages: WithParts[], + config = buildConfig(), +) { + return createCompressMessageTool({ + client: { + session: { + messages: async () => ({ data: messages }), + get: async () => ({ data: { parentID: null } }), + }, + }, + state, + logger: new Logger(false), + config, + prompts: { + reload() {}, + getRuntimePrompts: () => ({ compressMessage: "", compressRange: "" }), + }, + } as any) +} + +// Fix 1: canonical dedupe +test("duplicate message refs differing only in case produce one block", async () => { + const sessionID = `ses_dupe_${Date.now()}` + const state = createSessionState() + const tool = buildTool(state, buildMessages(sessionID)) + await tool.execute( + { + topic: "dupes", + content: [ + { messageId: "M0002", topic: "a", summary: "first" }, + { messageId: "m0002", topic: "b", summary: "second" }, + ], + }, + { + ask: async () => {}, + metadata: () => {}, + sessionID, + messageID: "msg-compress", + callID: "call-1", + } as any, + ) + assert.equal(state.prune.messages.blocksById.size, 1) +}) + +// Fix 2: tool cache refreshes mutable fields +test("tool cache refreshes status when a pending tool becomes errored", () => { + const state = createSessionState() + const config = buildConfig() + const logger = new Logger(false) + const part: any = { + id: "p1", + messageID: "msg-a", + sessionID: "ses", + type: "tool", + callID: "call-x", + tool: "bash", + state: { status: "running", input: { command: "echo hi" } }, + } + const msg: WithParts = { + info: { + id: "msg-a", + role: "assistant", + sessionID: "ses", + time: { created: 1 }, + model: { providerID: "p", modelID: "m" }, + } as WithParts["info"], + parts: [part], + } + syncToolCache(state, config, logger, [msg]) + assert.equal(state.toolParameters.get("call-x")?.status, "running") + + part.state = { status: "error", input: { command: "echo hi" }, error: "boom" } + syncToolCache(state, config, logger, [msg]) + assert.equal(state.toolParameters.get("call-x")?.status, "error") + assert.equal(state.toolParameters.get("call-x")?.error, "boom") +}) + +// Fix 5: dedup keeps successful output +test("deduplication keeps the most recent successful duplicate", () => { + const state = createSessionState() + const config = buildConfig() + const logger = new Logger(false) + for (const [id, status] of [ + ["c1", "completed"], + ["c2", "error"], + ] as const) { + state.toolParameters.set(id, { + tool: "grep", + parameters: { pattern: "x" }, + status, + turn: 0, + tokenCount: 10, + }) + } + const messages: WithParts[] = [ + { + info: { + id: "m", + role: "assistant", + sessionID: "s", + time: { created: 1 }, + } as WithParts["info"], + parts: [ + { + type: "tool", + callID: "c1", + tool: "grep", + state: { status: "completed", input: { pattern: "x" }, output: "found" }, + }, + { + type: "tool", + callID: "c2", + tool: "grep", + state: { status: "error", input: { pattern: "x" }, error: "fail" }, + }, + ] as any, + }, + ] + deduplicate(state, logger, config, messages) + assert.equal(state.prune.tools.has("c1"), false, "successful call retained") + assert.equal(state.prune.tools.has("c2"), true, "failed duplicate pruned") +}) + +// Fix 3: blocks stay active when origin leaves window +test("compression block stays active when its origin message is absent", () => { + const state = createSessionState() + state.prune.messages.blocksById.set(1, { + blockId: 1, + runId: 1, + active: true, + deactivatedByUser: false, + compressedTokens: 10, + summaryTokens: 5, + durationMs: 0, + topic: "t", + startId: "m1", + endId: "m1", + anchorMessageId: "m1", + compressMessageId: "origin-msg", + includedBlockIds: [], + consumedBlockIds: [], + parentBlockIds: [], + directMessageIds: ["m1"], + directToolIds: [], + effectiveMessageIds: ["m1"], + effectiveToolIds: [], + createdAt: 1, + summary: "S", + }) + state.prune.messages.byMessageId.set("m1", { + tokenCount: 10, + allBlockIds: [1], + activeBlockIds: [1], + }) + syncCompressionBlocks(state, new Logger(false), [ + { + info: { + id: "m1", + role: "user", + sessionID: "s", + time: { created: 1 }, + tokens: {}, + } as WithParts["info"], + parts: [], + }, + ]) + assert.equal(state.prune.messages.blocksById.get(1)?.active, true) + assert.equal(state.prune.messages.activeBlockIds.has(1), true) +}) + +// Fix 6: protected user messages keep all text parts +test("protected user message preserves all text parts", () => { + const config = buildConfig() + const messages = buildMessages("ses") + const searchContext = { + rawMessages: messages, + rawMessagesById: new Map(messages.map((m) => [m.info.id, m])), + rawIndexById: new Map(messages.map((m, i) => [m.info.id, i])), + summaryByBlockId: new Map(), + } + const selection = { + startReference: { type: "message" as const, id: "msg-user-1" }, + endReference: { type: "message" as const, id: "msg-user-1" }, + messageIds: ["msg-user-1"], + messageTokenById: new Map([["msg-user-1", 10]]), + toolIds: [], + requiredBlockIds: [], + } + const summary = appendProtectedUserMessages( + "", + selection as any, + searchContext, + createSessionState(), + true, + ) + assert.match(summary, /First line/) + assert.match(summary, /Second line/) +}) + +// Fix 8: resetOnCompaction clears stale fields +test("resetOnCompaction clears timing/cache/stats/context state", () => { + const state = createSessionState() + state.compressionTiming.startsByCallId.set("c", 1) + state.subAgentResultCache.set("c", "result") + state.toolIdList = ["c"] + state.stats.totalPruneTokens = 100 + state.manualMode = "active" + state.modelContextLimit = 1000 + state.systemPromptTokens = 50 + resetOnCompaction(state) + assert.equal(state.compressionTiming.startsByCallId.size, 0) + assert.equal(state.subAgentResultCache.size, 0) + assert.deepEqual(state.toolIdList, []) + assert.equal(state.stats.totalPruneTokens, 0) + assert.equal(state.manualMode, false) + assert.equal(state.modelContextLimit, undefined) + assert.equal(state.systemPromptTokens, undefined) +}) + +// Fix 4: strict percent validation +test("config validation rejects malformed percent limits", () => { + const raw: any = parse(`{"compress":{"maxContextLimit":"abc%"}}`) + const errors = validateConfigTypes(raw) + assert.ok(errors.some((e) => e.key === "compress.maxContextLimit")) +}) + +// Fix 9: token accounting is explicit (no cache double count) +test("token usage sums input, output, reasoning and cache separately", () => { + const state = createSessionState() + const messages: WithParts[] = [ + { + info: { + id: "m", + role: "assistant", + sessionID: "s", + time: { created: 1 }, + tokens: { input: 100, output: 20, reasoning: 5, cache: { read: 30, write: 10 } }, + } as WithParts["info"], + parts: [], + }, + ] + assert.equal(getCurrentTokenUsage(state, messages), 165) +}) diff --git a/tests/token-usage.test.ts b/tests/token-usage.test.ts index 549edeae7..fc6cb536d 100644 --- a/tests/token-usage.test.ts +++ b/tests/token-usage.test.ts @@ -12,7 +12,6 @@ function buildConfig(maxContextLimit: number, minContextLimit = 1): PluginConfig enabled: true, debug: false, pruneNotification: "off", - pruneNotificationType: "chat", commands: { enabled: true, protectedTools: [], diff --git a/tests/update.test.ts b/tests/update.test.ts deleted file mode 100644 index 5c88fe39e..000000000 --- a/tests/update.test.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { mkdir, mkdtemp, writeFile } from "node:fs/promises" -import { join } from "node:path" -import { tmpdir } from "node:os" -import test from "node:test" -import assert from "node:assert/strict" -import { isAutoUpdatableSpec, isVersionNewer, updateRemoveDir } from "../lib/update" - -test("isVersionNewer compares semver versions", () => { - assert.equal(isVersionNewer("3.2.1", "3.1.9"), true) - assert.equal(isVersionNewer("3.1.9", "3.1.9"), false) - assert.equal(isVersionNewer("3.1.9", "3.2.1"), false) - assert.equal(isVersionNewer("3.1.9", "3.1.9-beta.1"), true) -}) - -test("isAutoUpdatableSpec allows latest and ranges", () => { - assert.equal(isAutoUpdatableSpec("latest"), true) - assert.equal(isAutoUpdatableSpec("*"), true) - assert.equal(isAutoUpdatableSpec("^3.1.9"), true) - assert.equal(isAutoUpdatableSpec(">=3.1.9"), true) -}) - -test("isAutoUpdatableSpec rejects pinned and non-registry specs", () => { - assert.equal(isAutoUpdatableSpec("3.1.9"), false) - assert.equal(isAutoUpdatableSpec("file:../opencode-dcp"), false) - assert.equal(isAutoUpdatableSpec("github:user/repo"), false) -}) - -test("updateRemoveDir removes opencode npm wrapper for latest installs", async () => { - const rootDir = await mkdtemp(join(tmpdir(), "dcp-update-")) - const wrapperDir = join(rootDir, "@mbarnett", "opencode-dcp@latest") - const packageDir = join(wrapperDir, "node_modules", "@mbarnett", "opencode-dcp") - await writePackageJson(wrapperDir, { - dependencies: { "@mbarnett/opencode-dcp": "3.1.10" }, - }) - await writePackageJson(packageDir, { - name: "@mbarnett/opencode-dcp", - version: "3.1.9", - }) - - assert.equal(await updateRemoveDir(packageDir, "@mbarnett/opencode-dcp"), wrapperDir) -}) - -test("updateRemoveDir skips version-locked opencode installs", async () => { - const rootDir = await mkdtemp(join(tmpdir(), "dcp-update-")) - const wrapperDir = join(rootDir, "@mbarnett", "opencode-dcp@3.1.9") - const packageDir = join(wrapperDir, "node_modules", "@mbarnett", "opencode-dcp") - await writePackageJson(wrapperDir, { - dependencies: { "@mbarnett/opencode-dcp": "3.1.9" }, - }) - await writePackageJson(packageDir, { - name: "@mbarnett/opencode-dcp", - version: "3.1.9", - }) - - assert.equal(await updateRemoveDir(packageDir, "@mbarnett/opencode-dcp"), undefined) -}) - -async function writePackageJson(dir: string, data: Record) { - await mkdir(dir, { recursive: true }) - await writeFile(join(dir, "package.json"), `${JSON.stringify(data)}\n`, "utf-8") -} diff --git a/tests/v2-ids.test.ts b/tests/v2-ids.test.ts index eb1b5a32a..4ddd11fbb 100644 --- a/tests/v2-ids.test.ts +++ b/tests/v2-ids.test.ts @@ -241,7 +241,7 @@ test("V2 prompt defaults, schemas and reloads all describe compact IDs", () => { const { tool } = fixture(mode) assert.match(tool.description, /@4@/) assert.doesNotMatch(tool.description, /mNNNN|m000\d|dcp-message-id|XML/) - const schema = tool.args.content.element.shape + const schema = tool.args.properties.content.items.properties assert.match((mode === "range" ? schema.startId : schema.messageId).description, /@1@/) } const overrides = join(process.env.OPENCODE_CONFIG_DIR!, "dcp-prompts", "overrides") diff --git a/tests/v2-messages.test.ts b/tests/v2-messages.test.ts index 072c99f42..a310ca1a2 100644 --- a/tests/v2-messages.test.ts +++ b/tests/v2-messages.test.ts @@ -1,7 +1,7 @@ import assert from "node:assert/strict" import test from "node:test" import type { Message } from "@opencode/ai/schema/messages" -import { project } from "../lib/v2/messages" +import { view } from "../lib/native/messages" import { createSessionState, type CompressionBlock } from "../lib/state" import { assignMessageRefs } from "../lib/message-ids" import { injectMessageIds, prune } from "../lib/messages" @@ -12,7 +12,7 @@ const session = { id: "ses_test", agent: "build", model: { id: "test", providerID: "test" }, -} as Parameters[2] +} as Parameters[2] const config = { compress: { mode: "range", permission: "allow", protectUserMessages: false }, } as PluginConfig @@ -90,21 +90,21 @@ function entries(messages: Message[]) { model: session.model, content: [], text: "", - })) as Parameters[1] + })) as Parameters[1] } test("V2 projection preserves all native content without edits", () => { const messages = transcript() - assert.deepEqual(project(messages, entries(messages), session).restore(), messages) + assert.deepEqual(view(messages, entries(messages), session).commit(), messages) }) test("V2 ID injection preserves signatures, media and tool pairing", () => { const native = transcript() - const view = project(native, entries(native), session) + const projected = view(native, entries(native), session) const state = createSessionState("compact") - assignMessageRefs(state, view.messages) - injectMessageIds(state, config, view.messages, new Map()) - const restored = view.restore() + assignMessageRefs(state, projected.messages) + injectMessageIds(state, config, projected.messages, new Map()) + const restored = projected.commit() assert.deepEqual(restored[0], native[0]) assert.equal(restored[1]!.content[0], native[1]!.content[0]) assert.equal(restored[2]!.content[0], native[2]!.content[0]) @@ -116,11 +116,11 @@ test("V2 ID injection preserves signatures, media and tool pairing", () => { test("V2 tool pruning replaces only marked results", () => { const native = transcript() - const view = project(native, entries(native), session) + const projected = view(native, entries(native), session) const state = createSessionState("compact") state.prune.tools.set("call_one", 100) - prune(state, logger, config, view.messages) - const restored = view.restore() + prune(state, logger, config, projected.messages) + const restored = projected.commit() assert.match(JSON.stringify(restored[3]!.content[0]), /Output removed/) assert.equal(restored[3]!.content[1], native[3]!.content[1]) assert.deepEqual(restored[2], native[2]) @@ -128,28 +128,28 @@ test("V2 tool pruning replaces only marked results", () => { test("V2 compression removes the assistant and its ID-less results together", () => { const native = transcript() - const view = project(native, entries(native), session) + const projected = view(native, entries(native), session) const state = createSessionState("compact") state.prune.messages.byMessageId.set("msg_assistant", { tokenCount: 100, allBlockIds: [1], activeBlockIds: [1], }) - prune(state, logger, config, view.messages) - const restored = view.restore() + prune(state, logger, config, projected.messages) + const restored = projected.commit() assert.deepEqual(restored, [native[0], native[1], native[4]]) }) test("V2 leaves non-durable plugin messages and checkpoint tool results intact", () => { const native = transcript() - const view = project(native, [], session) - assert.equal(view.messages.length, 0, "unselectable messages must not receive DCP IDs") - assert.deepEqual(view.restore(), native) + const projected = view(native, [], session) + assert.equal(projected.messages.length, 0, "unselectable messages must not receive DCP IDs") + assert.deepEqual(projected.commit(), native) }) -test("V2 inserts summaries after native checkpoints without an ordinary user message", () => { +test("V2 does not fabricate a base message for summary injection", () => { const native = transcript().filter((message) => message.role !== "user") - const view = project(native, entries(native), session) + const projected = view(native, entries(native), session) const state = createSessionState("compact") state.prune.messages.byMessageId.set("msg_assistant", { tokenCount: 100, @@ -163,9 +163,7 @@ test("V2 inserts summaries after native checkpoints without an ordinary user mes anchorMessageId: "msg_assistant", summary: "CHECKPOINT_SUMMARY", } as CompressionBlock) - prune(state, logger, config, view.messages, view.summaryBase) - const restored = view.restore() - assert.equal(restored.length, 2) - assert.deepEqual(restored[0], native[0]) - assert.deepEqual(restored[1]?.content, [{ type: "text", text: "CHECKPOINT_SUMMARY" }]) + prune(state, logger, config, projected.messages) + const restored = projected.commit() + assert.deepEqual(restored, [native[0]], "no synthetic base message is invented") }) diff --git a/tests/v2-protection.test.ts b/tests/v2-protection.test.ts index ad9db7e70..5caf8efa6 100644 --- a/tests/v2-protection.test.ts +++ b/tests/v2-protection.test.ts @@ -73,7 +73,9 @@ test("Code Mode protections survive caching, strategy selection, and compression const unprotected = { ...config, protectedFilePatterns: [] } deduplicate(state, logger, unprotected, messages) purgeErrors(state, logger, unprotected, messages) - assert.deepEqual([...state.prune.tools.keys()], ["first", "second", "failed"]) + // Dedup now keeps the most recent successful duplicate ("second") rather + // than the newest call regardless of outcome; the failed call is purged. + assert.deepEqual([...state.prune.tools.keys()], ["first", "failed"]) }) test("Code Mode honors protected tool names as well as file paths", () => { diff --git a/tsup.config.ts b/tsup.config.ts index 8fb58167a..968de95c0 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,7 +1,7 @@ import { defineConfig } from "tsup" export default defineConfig({ - entry: ["index.ts"], + entry: ["index.ts", "tui.tsx"], format: ["esm"], dts: false, clean: true, diff --git a/tui.tsx b/tui.tsx index 8a4c89d58..fd9cf7947 100644 --- a/tui.tsx +++ b/tui.tsx @@ -1,29 +1,6 @@ /** @jsxImportSource @opentui/solid */ -import type { TuiPluginModule } from "@opencode-ai/plugin/tui" -import { registerCommands } from "./lib/tui/commands" -import { loadConfig } from "./lib/tui/data" -import { openPanelModal } from "./lib/tui/modals" import type { Plugin } from "@opencode/plugin/tui" -import { setup } from "./lib/v2/tui" +import { setup } from "./lib/native/tui" -const tui: TuiPluginModule["tui"] = async (api) => { - const config = loadConfig(api) - if (!config.enabled || !config.commands.enabled) return - - registerCommands(api, [ - { - title: "DCP", - name: "dcp.panel", - description: "Open DCP panel", - slashName: "dcp", - run: () => openPanelModal(api, config), - }, - ]) -} - -export default { - id: "opencode-dcp", - setup, - tui, -} satisfies TuiPluginModule & Plugin.Definition +export default { id: "opencode-dcp", setup } satisfies Plugin.Definition From c110bbbd7564693419220c083097cead1cb9e15d Mon Sep 17 00:00:00 2001 From: mbarnett Date: Thu, 19 Nov 2026 09:57:24 -0500 Subject: [PATCH 2/3] fix: scope /dcp panel events, surface config warnings, address review findings - Scope openPanel RPC events to the invoking session so other open sessions no longer pop their panel on /dcp. - Deliver config warnings/parse errors as real toasts at load time and reject malformed JSONC instead of partially merging it (jsonc-parser reports errors in an array rather than throwing). - Remove duplicate prompt reload per request; bound debug context snapshots; cap cached session state and avoid mutating loaded config. - Drop runtime-dead V1 hook/host-permission modules, their tests, and server.js; trim tests to live-code coverage. - Add SPDX headers, NOTICE and CHANGELOG; document compatibility, local data, config reload semantics and token/debug limitations. --- CHANGELOG.md | 14 + NOTICE | 13 + README.md | 42 +- index.ts | 1 + lib/commands/compression-targets.ts | 1 + lib/commands/context.ts | 1 + lib/commands/decompress.ts | 1 + lib/commands/help.ts | 1 + lib/commands/index.ts | 1 + lib/commands/manual.ts | 1 + lib/commands/recompress.ts | 1 + lib/commands/stats.ts | 1 + lib/commands/sweep.ts | 1 + lib/compress-permission.ts | 24 +- lib/compress/index.ts | 1 + lib/compress/message-utils.ts | 1 + lib/compress/message.ts | 1 + lib/compress/pipeline.ts | 1 + lib/compress/protected-content.ts | 1 + lib/compress/range-utils.ts | 1 + lib/compress/range.ts | 1 + lib/compress/search.ts | 1 + lib/compress/state.ts | 1 + lib/compress/timing.ts | 1 + lib/compress/types.ts | 1 + lib/config.ts | 60 +- lib/hooks.ts | 383 ----------- lib/host-permissions.ts | 101 --- lib/logger.ts | 16 +- lib/message-ids.ts | 1 + lib/message-info.ts | 1 + lib/messages/index.ts | 1 + lib/messages/inject/inject.ts | 1 + lib/messages/inject/subagent-results.ts | 1 + lib/messages/inject/utils.ts | 1 + lib/messages/priority.ts | 1 + lib/messages/prune.ts | 1 + lib/messages/query.ts | 1 + lib/messages/reasoning-strip.ts | 1 + lib/messages/shape.ts | 1 + lib/messages/sync.ts | 1 + lib/messages/utils.ts | 1 + lib/native/commands.ts | 1 + lib/native/messages.ts | 1 + lib/native/notifications.ts | 1 + lib/native/permissions.ts | 4 +- lib/native/plugin.ts | 76 ++- lib/native/rpc.ts | 5 +- lib/native/system-prompt.ts | 4 +- lib/native/theme.ts | 1 + lib/native/tui.tsx | 9 +- lib/prompts/compress-message.ts | 1 + lib/prompts/compress-range.ts | 1 + lib/prompts/context-limit-nudge.ts | 1 + lib/prompts/extensions/nudge.ts | 1 + lib/prompts/extensions/system.ts | 1 + lib/prompts/extensions/tool.ts | 1 + lib/prompts/index.ts | 1 + lib/prompts/iteration-nudge.ts | 1 + lib/prompts/store.ts | 1 + lib/prompts/system.ts | 1 + lib/prompts/turn-nudge.ts | 1 + lib/protected-patterns.ts | 1 + lib/state/index.ts | 1 + lib/state/persistence.ts | 1 + lib/state/state.ts | 3 + lib/state/tool-cache.ts | 1 + lib/state/types.ts | 1 + lib/state/utils.ts | 1 + lib/strategies/deduplication.ts | 1 + lib/strategies/index.ts | 1 + lib/strategies/purge-errors.ts | 1 + lib/subagents/subagent-results.ts | 1 + lib/token-utils.ts | 1 + lib/tool-schema.ts | 1 + lib/tui/dialogs.tsx | 1 + lib/tui/format.ts | 1 + lib/tui/types.ts | 1 + lib/tui/ui.tsx | 1 + lib/ui/notification.ts | 1 + lib/ui/utils.ts | 1 + package.json | 2 + server.js | 1 - tests/config-warnings.test.ts | 53 ++ tests/hooks-permission.test.ts | 808 ------------------------ tests/host-permissions.test.ts | 104 --- tests/manual-mode-state.test.ts | 38 ++ tests/message-priority.test.ts | 8 +- tests/native/notifications.test.ts | 2 +- tests/native/rpc.test.ts | 7 + tui.tsx | 1 + 91 files changed, 373 insertions(+), 1472 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 NOTICE delete mode 100644 lib/hooks.ts delete mode 100644 lib/host-permissions.ts delete mode 100644 server.js create mode 100644 tests/config-warnings.test.ts delete mode 100644 tests/hooks-permission.test.ts delete mode 100644 tests/host-permissions.test.ts create mode 100644 tests/manual-mode-state.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..e0f2b26c0 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +# Changelog + +## 4.0.0 + +- Native OpenCode 2 plugin: new `lib/native` entrypoints for plugin setup, message projection, + RPC, permissions, commands, notifications, system prompt, and TUI. OpenCode 1 is no longer + supported. +- Removed the upstream V1 compatibility layer, npm auto-update, and in-session notification + injection; notifications are now toasts. +- Config warnings (unknown keys, type errors, malformed JSONC) are delivered as toasts when the + plugin loads, and malformed config files are rejected instead of partially merged. +- `/dcp` panel-open events are scoped to the invoking session so other open sessions are unaffected. +- Debug context snapshots are capped at 10 per session. +- Removed runtime-dead V1 hook and host-permission modules and their tests. diff --git a/NOTICE b/NOTICE new file mode 100644 index 000000000..71d3abba5 --- /dev/null +++ b/NOTICE @@ -0,0 +1,13 @@ +Dynamic Context Pruning (OpenCode 2) +Copyright (C) 2026 mbarnett + +This project is a fork of Tarquinen/opencode-dynamic-context-pruning +(https://github.com/Tarquinen/opencode-dynamic-context-pruning), which is licensed under the +GNU Affero General Public License, version 3 or later. + +This fork replaces the upstream OpenCode 1 compatibility layer with native OpenCode 2 plugin +APIs. Source files carry `SPDX-License-Identifier: AGPL-3.0-or-later`; see CHANGELOG.md for a +summary of changes. No code from the upstream author's commercial successor is included. + +Licensed under the GNU Affero General Public License, version 3 or later. See LICENSE for the +full license text. diff --git a/README.md b/README.md index af17205e2..9eda5c97b 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,12 @@ Copy [`dcp.example.jsonc`](dcp.example.jsonc) to one of those paths to customize options is documented in [`dcp.schema.json`](dcp.schema.json). Protected-tool lists are additive across layers. +`dcp.jsonc` is read once when the plugin loads — reload OpenCode (or restart the plugin) to apply +edits. Project config resolution walks up from the working directory to the nearest `.opencode` +directory, so a nested project can inherit a parent's `dcp.jsonc`. Unknown keys, type errors and +malformed JSONC are reported as toasts at load time, and a malformed file is ignored rather than +partially applied. + Notable settings: | Setting | Default | Meaning | @@ -68,7 +74,11 @@ Notable settings: ## Notifications Notifications are delivered as toasts. The V1 option `pruneNotificationType` has been removed; -there is no invisible in-session notification under OpenCode 2's public plugin API. +there is no invisible in-session notification under OpenCode 2's public plugin API. The V1 +`autoUpdate` option was also removed — updates are managed by OpenCode's plugin installer. + +Opening the panel with bare `/dcp` is scoped to the session that invoked it; other open sessions +are left alone. ## Limitations @@ -80,6 +90,32 @@ there is no invisible in-session notification under OpenCode 2's public plugin A startup are detected on the next request. - `permission: "ask"` uses OpenCode's native permission prompt; it requires an interactive session to approve. +- Token counts used for nudge thresholds and context reports come from an Anthropic tokenizer for + every provider. Treat them as approximations for non-Anthropic models; reported session usage + from the host is used directly where available. +- Debug logging (`"debug": true`) writes full message and tool text to + `~/.config/opencode/logs/dcp/context//`. Snapshots are capped at 10 per session, but + they can contain sensitive data — avoid enabling it in shared environments. + +## Compatibility + +| OpenCode | Status | +| -------- | ------------------------------ | +| 2.3.x+ | Supported (native plugin APIs) | +| 2.0–2.2 | Not tested | +| 1.x | Not supported | + +This fork deliberately diverges from the upstream/commercial continuation: it targets OpenCode 2 +natively, drops the V1 adapter and npm auto-update, and stays AGPL-3.0-or-later. See +[`CHANGELOG.md`](CHANGELOG.md) and [`CONTRIBUTING.md`](CONTRIBUTING.md). + +## Local data + +- Pruning state: `$XDG_DATA_HOME/opencode/storage/plugin/dcp/.json` (default + `~/.local/share/opencode/...`). +- Debug logs and context snapshots: `$XDG_CONFIG_HOME/opencode/logs/dcp/` (default + `~/.config/opencode/...`). +- The plugin does not transmit data anywhere itself. ## Development @@ -96,5 +132,5 @@ for the diagnostic CLI tooling. ## License -AGPL-3.0-or-later. See [LICENSE](LICENSE). Upstream attribution to Tarquinen/opencode-dynamic-context-pruning -is retained. +AGPL-3.0-or-later. See [LICENSE](LICENSE) and [NOTICE](NOTICE). Upstream attribution to +Tarquinen/opencode-dynamic-context-pruning is retained. diff --git a/index.ts b/index.ts index 39baf7f23..60ff3d842 100644 --- a/index.ts +++ b/index.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { Plugin } from "@opencode/plugin" import { setup } from "./lib/native/plugin" diff --git a/lib/commands/compression-targets.ts b/lib/commands/compression-targets.ts index 59bc25552..2cb3d9ef4 100644 --- a/lib/commands/compression-targets.ts +++ b/lib/commands/compression-targets.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { CompressionBlock, PruneMessagesState } from "../state" export interface CompressionTarget { diff --git a/lib/commands/context.ts b/lib/commands/context.ts index 8a0100f17..a3075d9d5 100644 --- a/lib/commands/context.ts +++ b/lib/commands/context.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later /** * DCP Context Command * Shows a visual breakdown of token usage in the current session. diff --git a/lib/commands/decompress.ts b/lib/commands/decompress.ts index 3eafc847f..6b70c3f28 100644 --- a/lib/commands/decompress.ts +++ b/lib/commands/decompress.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { Logger } from "../logger" import type { CompressionBlock, PruneMessagesState, SessionState, WithParts } from "../state" import { syncCompressionBlocks } from "../messages" diff --git a/lib/commands/help.ts b/lib/commands/help.ts index ee1eca6ef..d2527ffd9 100644 --- a/lib/commands/help.ts +++ b/lib/commands/help.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later /** * DCP Help command handler. * Shows available DCP commands and their descriptions. diff --git a/lib/commands/index.ts b/lib/commands/index.ts index 993420bfc..cd4765359 100644 --- a/lib/commands/index.ts +++ b/lib/commands/index.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later export { handleContextCommand } from "./context" export { handleDecompressCommand } from "./decompress" export { handleHelpCommand } from "./help" diff --git a/lib/commands/manual.ts b/lib/commands/manual.ts index b871efd49..b5736a79c 100644 --- a/lib/commands/manual.ts +++ b/lib/commands/manual.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later /** * DCP Manual mode command handler. * Handles toggling manual mode and triggering individual tool executions. diff --git a/lib/commands/recompress.ts b/lib/commands/recompress.ts index 84e8a01e1..2d6f52acb 100644 --- a/lib/commands/recompress.ts +++ b/lib/commands/recompress.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { Logger } from "../logger" import type { PruneMessagesState, SessionState, WithParts } from "../state" import { syncCompressionBlocks } from "../messages" diff --git a/lib/commands/stats.ts b/lib/commands/stats.ts index 74d116321..d0586b624 100644 --- a/lib/commands/stats.ts +++ b/lib/commands/stats.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later /** * DCP Stats command handler. * Shows pruning statistics for the current session and all-time totals. diff --git a/lib/commands/sweep.ts b/lib/commands/sweep.ts index 15c4a5c8c..b73fd177c 100644 --- a/lib/commands/sweep.ts +++ b/lib/commands/sweep.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later /** * DCP Sweep command handler. * Prunes tool outputs since the last user message, or the last N tools. diff --git a/lib/compress-permission.ts b/lib/compress-permission.ts index b7826343e..c4a030d96 100644 --- a/lib/compress-permission.ts +++ b/lib/compress-permission.ts @@ -1,25 +1,15 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { PluginConfig } from "./config" -import { type HostPermissionSnapshot, resolveEffectiveCompressPermission } from "./host-permissions" -import type { SessionState, WithParts } from "./state" -import { getLastUserMessage } from "./messages/query" +import type { SessionState } from "./state" +/** + * Effective compress permission for the native OC2 path. Host rules are + * resolved once in `resolveCompressPermission` and cached on the session; + * this helper just reads that cached value with the config as fallback. + */ export const compressPermission = ( state: SessionState, config: PluginConfig, ): "ask" | "allow" | "deny" => { return state.compressPermission ?? config.compress.permission } - -export const syncCompressPermissionState = ( - state: SessionState, - config: PluginConfig, - hostPermissions: HostPermissionSnapshot, - messages: WithParts[], -): void => { - const activeAgent = getLastUserMessage(messages)?.info.agent - state.compressPermission = resolveEffectiveCompressPermission( - config.compress.permission, - hostPermissions, - activeAgent, - ) -} diff --git a/lib/compress/index.ts b/lib/compress/index.ts index 347887a43..e65158d43 100644 --- a/lib/compress/index.ts +++ b/lib/compress/index.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later export type { ToolContext } from "./types" export { createCompressMessageTool } from "./message" export { createCompressRangeTool } from "./range" diff --git a/lib/compress/message-utils.ts b/lib/compress/message-utils.ts index 5259bc75a..a11c1680b 100644 --- a/lib/compress/message-utils.ts +++ b/lib/compress/message-utils.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { PluginConfig } from "../config" import type { SessionState } from "../state" import { parseBoundaryId, type IdFormat } from "../message-ids" diff --git a/lib/compress/message.ts b/lib/compress/message.ts index 4778d9cf6..4ae28b752 100644 --- a/lib/compress/message.ts +++ b/lib/compress/message.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import { defineTool, schema, type ToolDefinition } from "../tool-schema" import type { ToolContext } from "./types" import { countTokens } from "../token-utils" diff --git a/lib/compress/pipeline.ts b/lib/compress/pipeline.ts index cddb2be45..bde35be38 100644 --- a/lib/compress/pipeline.ts +++ b/lib/compress/pipeline.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { WithParts } from "../state" import { ensureSessionInitialized, refreshManualMode } from "../state" import { saveSessionState } from "../state/persistence" diff --git a/lib/compress/protected-content.ts b/lib/compress/protected-content.ts index b09833564..d8812821a 100644 --- a/lib/compress/protected-content.ts +++ b/lib/compress/protected-content.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { SessionState } from "../state" import { isIgnoredUserMessage } from "../messages/query" import { isToolProtected } from "../protected-patterns" diff --git a/lib/compress/range-utils.ts b/lib/compress/range-utils.ts index 2e37d222b..1323917e9 100644 --- a/lib/compress/range-utils.ts +++ b/lib/compress/range-utils.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { CompressionBlock, SessionState } from "../state" import { resolveAnchorMessageId, resolveBoundaryIds, resolveSelection } from "./search" import type { IdFormat } from "../message-ids" diff --git a/lib/compress/range.ts b/lib/compress/range.ts index 8c0a16cf8..aa0524576 100644 --- a/lib/compress/range.ts +++ b/lib/compress/range.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import { defineTool, schema, type ToolDefinition } from "../tool-schema" import type { ToolContext } from "./types" import { countTokens } from "../token-utils" diff --git a/lib/compress/search.ts b/lib/compress/search.ts index db9f3219c..123e893e0 100644 --- a/lib/compress/search.ts +++ b/lib/compress/search.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { SessionState, WithParts } from "../state" import { formatBlockRef, parseBoundaryId } from "../message-ids" import { isIgnoredUserMessage } from "../messages/query" diff --git a/lib/compress/state.ts b/lib/compress/state.ts index b902e0147..33fd79a29 100644 --- a/lib/compress/state.ts +++ b/lib/compress/state.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { CompressionBlock, PruneMessagesState, SessionState } from "../state" import { formatBlockRef, formatMessageIdTag, type IdFormat } from "../message-ids" import type { AppliedCompressionResult, CompressionStateInput, SelectionResolution } from "./types" diff --git a/lib/compress/timing.ts b/lib/compress/timing.ts index f99ad6124..e7efd6732 100644 --- a/lib/compress/timing.ts +++ b/lib/compress/timing.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { SessionState } from "../state/types" import { attachCompressionDuration } from "./state" diff --git a/lib/compress/types.ts b/lib/compress/types.ts index f0eb5d0c6..9ccbf5205 100644 --- a/lib/compress/types.ts +++ b/lib/compress/types.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { PluginConfig } from "../config" import type { Logger } from "../logger" import type { PromptStore } from "../prompts/store" diff --git a/lib/config.ts b/lib/config.ts index 5669cd966..0e7694a96 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -1,7 +1,8 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import { readFileSync, existsSync, statSync } from "fs" import { join, dirname } from "path" import { homedir } from "os" -import { parse } from "jsonc-parser" +import { parse, type ParseError } from "jsonc-parser" type ConfigContext = { directory: string client: { @@ -630,18 +631,16 @@ function showConfigWarnings( } } - setTimeout(() => { - try { - ctx.client.tui.showToast({ - body: { - title: `DCP: ${configType} warning`, - message: `${configPath}\n${messages.join("\n")}`, - variant: "warning", - duration: 7000, - }, - }) - } catch {} - }, 7000) + try { + ctx.client.tui.showToast({ + body: { + title: `DCP: ${configType} warning`, + message: `${configPath}\n${messages.join("\n")}`, + variant: "warning", + duration: 7000, + }, + }) + } catch {} } const defaultConfig: PluginConfig = { @@ -768,7 +767,14 @@ function loadConfigFile(configPath: string): ConfigLoadResult { } try { - const parsed = parse(fileContent, undefined, { allowTrailingComma: true }) + const errors: ParseError[] = [] + const parsed = parse(fileContent, errors, { allowTrailingComma: true }) + // jsonc-parser is error-tolerant: it returns a partial value and records + // problems in `errors` instead of throwing. Treat those as parse failures + // so malformed config never leaks into the merged settings. + if (errors.length > 0) { + return { data: null, parseError: `Invalid JSONC at offset ${errors[0]!.offset}` } + } if (parsed === undefined || parsed === null) { return { data: null, parseError: "Config file is empty or invalid" } } @@ -926,19 +932,17 @@ function mergeLayer(config: PluginConfig, data: Record): PluginConf } } -function scheduleParseWarning(ctx: ConfigContext, title: string, message: string): void { - setTimeout(() => { - try { - ctx.client.tui.showToast({ - body: { - title, - message, - variant: "warning", - duration: 7000, - }, - }) - } catch {} - }, 7000) +function showParseWarning(ctx: ConfigContext, title: string, message: string): void { + try { + ctx.client.tui.showToast({ + body: { + title, + message, + variant: "warning", + duration: 7000, + }, + }) + } catch {} } export function getConfig(ctx: ConfigContext): PluginConfig { @@ -958,7 +962,7 @@ export function getConfig(ctx: ConfigContext): PluginConfig { const result = loadConfigFile(layer.path) if (result.parseError) { - scheduleParseWarning( + showParseWarning( ctx, `DCP: Invalid ${layer.name}`, `${layer.path}\n${result.parseError}\nUsing previous/default values`, diff --git a/lib/hooks.ts b/lib/hooks.ts deleted file mode 100644 index 6d6f3862d..000000000 --- a/lib/hooks.ts +++ /dev/null @@ -1,383 +0,0 @@ -import type { SessionState, WithParts } from "./state" -import type { Logger } from "./logger" -import type { PluginConfig } from "./config" -import { assignMessageRefs } from "./message-ids" -import { - buildPriorityMap, - buildToolIdList, - injectCompressNudges, - injectExtendedSubAgentResults, - injectMessageIds, - prune, - stripHallucinations, - stripHallucinationsFromString, - stripStaleMetadata, - syncCompressionBlocks, -} from "./messages" -import { renderSystemPrompt, type PromptStore } from "./prompts" -import { buildProtectedToolsExtension } from "./prompts/extensions/system" -import { - applyPendingCompressionDurations, - buildCompressionTimingKey, - consumeCompressionStart, - resolveCompressionDuration, -} from "./compress/timing" -import { filterMessages, filterMessagesInPlace } from "./messages/shape" -import { - applyPendingManualTrigger, - handleContextCommand, - handleDecompressCommand, - handleHelpCommand, - handleManualToggleCommand, - handleManualTriggerCommand, - handleRecompressCommand, - handleStatsCommand, - handleSweepCommand, -} from "./commands" -import { type HostPermissionSnapshot } from "./host-permissions" -import { compressPermission, syncCompressPermissionState } from "./compress-permission" -import { checkSession, ensureSessionInitialized, saveSessionState, syncToolCache } from "./state" -import { cacheSystemPromptTokens } from "./ui/utils" - -const INTERNAL_AGENT_SIGNATURES = [ - "You are a title generator", - "You are a helpful AI assistant tasked with summarizing conversations", - "You are an anchored context summarization assistant for coding sessions", - "Summarize what was done in this conversation", -] - -function isInternalAgentCall(systemPrompts: string[]): boolean { - const primaryPrompt = systemPrompts[0] - if (typeof primaryPrompt !== "string" || primaryPrompt.length === 0) { - return false - } - - return INTERNAL_AGENT_SIGNATURES.some((signature) => primaryPrompt.includes(signature)) -} - -export function createSystemPromptHandler( - state: SessionState, - logger: Logger, - config: PluginConfig, - prompts: PromptStore, -) { - return async ( - input: { sessionID?: string; model: { limit: { context: number } } }, - output: { system: string[] }, - ) => { - if (input.model?.limit?.context) { - state.modelContextLimit = input.model.limit.context - logger.debug("Cached model context limit", { limit: state.modelContextLimit }) - } - - if (state.isSubAgent && !config.experimental.allowSubAgents) { - return - } - - if (isInternalAgentCall(output.system)) { - logger.info("Skipping DCP system prompt injection for internal agent") - return - } - - const effectivePermission = - input.sessionID && state.sessionId === input.sessionID - ? compressPermission(state, config) - : config.compress.permission - - if (effectivePermission === "deny") { - return - } - - prompts.reload() - const runtimePrompts = prompts.getRuntimePrompts() - const newPrompt = renderSystemPrompt( - runtimePrompts, - buildProtectedToolsExtension(config.compress.protectedTools), - !!state.manualMode, - state.isSubAgent && config.experimental.allowSubAgents, - ) - if (output.system.length > 0) { - output.system[output.system.length - 1] += "\n\n" + newPrompt - } else { - output.system.push(newPrompt) - } - } -} - -export function createChatMessageTransformHandler( - client: any, - state: SessionState, - logger: Logger, - config: PluginConfig, - prompts: PromptStore, - hostPermissions: HostPermissionSnapshot, -) { - return async (input: {}, output: { messages: WithParts[] }) => { - const receivedMessages = Array.isArray(output.messages) ? output.messages.length : 0 - const messages = filterMessagesInPlace(output.messages) - if (messages.length !== receivedMessages) { - logger.warn("Skipping messages with unexpected shape during chat transform", { - received: receivedMessages, - usable: messages.length, - }) - } - - await checkSession(client, state, logger, output.messages, config.manualMode.enabled) - - syncCompressPermissionState(state, config, hostPermissions, output.messages) - - if (state.isSubAgent && !config.experimental.allowSubAgents) { - return - } - - stripHallucinations(output.messages) - cacheSystemPromptTokens(state, output.messages) - assignMessageRefs(state, output.messages) - syncCompressionBlocks(state, logger, output.messages) - syncToolCache(state, config, logger, output.messages) - buildToolIdList(state, output.messages) - prune(state, logger, config, output.messages) - await injectExtendedSubAgentResults( - client, - state, - logger, - output.messages, - config.experimental.allowSubAgents, - ) - const compressionPriorities = buildPriorityMap(config, state, output.messages) - prompts.reload() - injectCompressNudges( - state, - config, - logger, - output.messages, - prompts.getRuntimePrompts(), - compressionPriorities, - ) - injectMessageIds(state, config, output.messages, compressionPriorities) - applyPendingManualTrigger(state, output.messages, logger) - stripStaleMetadata(output.messages) - - if (state.sessionId) { - await logger.saveContext(state.sessionId, output.messages) - } - } -} - -export function createCommandExecuteHandler( - client: any, - state: SessionState, - logger: Logger, - config: PluginConfig, - workingDirectory: string, - hostPermissions: HostPermissionSnapshot, -) { - return async ( - input: { command: string; sessionID: string; arguments: string }, - output: { parts: any[] }, - ) => { - if (!config.commands.enabled) { - return - } - - if (input.command === "dcp" || input.command === "dcp-compress") { - const messagesResponse = await client.session.messages({ - path: { id: input.sessionID }, - }) - const messages = filterMessages(messagesResponse.data || messagesResponse) - - await ensureSessionInitialized( - client, - state, - input.sessionID, - logger, - messages, - config.manualMode.enabled, - ) - - syncCompressPermissionState(state, config, hostPermissions, messages) - - const effectivePermission = compressPermission(state, config) - if (effectivePermission === "deny") { - return - } - - const args = (input.arguments || "").trim().split(/\s+/).filter(Boolean) - const isCompressCommand = input.command === "dcp-compress" - const subcommand = isCompressCommand ? "compress" : args[0]?.toLowerCase() || "" - const subArgs = isCompressCommand ? args : args.slice(1) - - const commandCtx = { - client, - state, - config, - logger, - sessionId: input.sessionID, - messages, - } - - if (subcommand === "context") { - await handleContextCommand(commandCtx) - return - } - - if (subcommand === "stats") { - await handleStatsCommand(commandCtx) - return - } - - if (subcommand === "sweep") { - await handleSweepCommand({ - ...commandCtx, - args: subArgs, - workingDirectory, - }) - return - } - - if (subcommand === "manual") { - await handleManualToggleCommand(commandCtx, subArgs[0]?.toLowerCase()) - return - } - - if (subcommand === "compress") { - const userFocus = subArgs.join(" ").trim() - const prompt = await handleManualTriggerCommand(commandCtx, "compress", userFocus) - if (!prompt) { - throw new Error("__DCP_MANUAL_TRIGGER_BLOCKED__") - } - - state.manualMode = "compress-pending" - state.pendingManualTrigger = { - sessionId: input.sessionID, - prompt, - } - const rawArgs = (input.arguments || "").trim() - output.parts.length = 0 - output.parts.push({ - type: "text", - text: isCompressCommand - ? rawArgs - ? `/dcp-compress ${rawArgs}` - : "/dcp-compress" - : rawArgs - ? `/dcp ${rawArgs}` - : `/dcp ${subcommand}`, - }) - return - } - - if (subcommand === "decompress") { - await handleDecompressCommand({ - ...commandCtx, - args: subArgs, - }) - return - } - - if (subcommand === "recompress") { - await handleRecompressCommand({ - ...commandCtx, - args: subArgs, - }) - return - } - - await handleHelpCommand(commandCtx) - return - } - } -} - -export function createTextCompleteHandler() { - return async ( - _input: { sessionID: string; messageID: string; partID: string }, - output: { text: string }, - ) => { - output.text = stripHallucinationsFromString(output.text) - } -} - -export function createEventHandler(state: SessionState, logger: Logger) { - return async (input: { event: any }) => { - const eventTime = - typeof input.event?.time === "number" && Number.isFinite(input.event.time) - ? input.event.time - : typeof input.event?.properties?.time === "number" && - Number.isFinite(input.event.properties.time) - ? input.event.properties.time - : undefined - - if (input.event.type !== "message.part.updated") { - return - } - - const part = input.event.properties?.part - if (part?.type !== "tool" || part.tool !== "compress") { - return - } - - if (part.state.status === "pending") { - if (typeof part.callID !== "string" || typeof part.messageID !== "string") { - return - } - - const startedAt = eventTime ?? Date.now() - const key = buildCompressionTimingKey(part.messageID, part.callID) - if (state.compressionTiming.startsByCallId.has(key)) { - return - } - state.compressionTiming.startsByCallId.set(key, startedAt) - logger.debug("Recorded compression start", { - messageID: part.messageID, - callID: part.callID, - startedAt, - }) - return - } - - if (part.state.status === "completed") { - if (typeof part.callID !== "string" || typeof part.messageID !== "string") { - return - } - - const key = buildCompressionTimingKey(part.messageID, part.callID) - const start = consumeCompressionStart(state, part.messageID, part.callID) - const durationMs = resolveCompressionDuration(start, eventTime, part.state.time) - if (typeof durationMs !== "number") { - return - } - - state.compressionTiming.pendingByCallId.set(key, { - messageId: part.messageID, - callId: part.callID, - durationMs, - }) - - const updates = applyPendingCompressionDurations(state) - if (updates === 0) { - return - } - - await saveSessionState(state, logger) - - logger.info("Attached compression time to blocks", { - messageID: part.messageID, - callID: part.callID, - blocks: updates, - durationMs, - }) - return - } - - if (part.state.status === "running") { - return - } - - if (typeof part.callID === "string" && typeof part.messageID === "string") { - state.compressionTiming.startsByCallId.delete( - buildCompressionTimingKey(part.messageID, part.callID), - ) - } - } -} diff --git a/lib/host-permissions.ts b/lib/host-permissions.ts deleted file mode 100644 index 6dc2cc78d..000000000 --- a/lib/host-permissions.ts +++ /dev/null @@ -1,101 +0,0 @@ -export type PermissionAction = "ask" | "allow" | "deny" - -export type PermissionValue = PermissionAction | Record - -export type PermissionConfig = Record | undefined - -export interface HostPermissionSnapshot { - global: PermissionConfig - agents: Record -} - -type PermissionRule = { - permission: string - pattern: string - action: PermissionAction -} - -const findLastMatchingRule = ( - rules: PermissionRule[], - predicate: (rule: PermissionRule) => boolean, -): PermissionRule | undefined => { - for (let index = rules.length - 1; index >= 0; index -= 1) { - const rule = rules[index] - if (rule && predicate(rule)) { - return rule - } - } - - return undefined -} - -const wildcardMatch = (value: string, pattern: string): boolean => { - const normalizedValue = value.replaceAll("\\", "/") - let escaped = pattern - .replaceAll("\\", "/") - .replace(/[.+^${}()|[\]\\]/g, "\\$&") - .replace(/\*/g, ".*") - .replace(/\?/g, ".") - - if (escaped.endsWith(" .*")) { - escaped = escaped.slice(0, -3) + "( .*)?" - } - - const flags = process.platform === "win32" ? "si" : "s" - return new RegExp(`^${escaped}$`, flags).test(normalizedValue) -} - -const getPermissionRules = (permissionConfigs: PermissionConfig[]): PermissionRule[] => { - const rules: PermissionRule[] = [] - for (const permissionConfig of permissionConfigs) { - if (!permissionConfig) { - continue - } - - for (const [permission, value] of Object.entries(permissionConfig)) { - if (value === "ask" || value === "allow" || value === "deny") { - rules.push({ permission, pattern: "*", action: value }) - continue - } - - for (const [pattern, action] of Object.entries(value)) { - if (action === "ask" || action === "allow" || action === "deny") { - rules.push({ permission, pattern, action }) - } - } - } - } - return rules -} - -export const compressDisabledByOpencode = (...permissionConfigs: PermissionConfig[]): boolean => { - const match = findLastMatchingRule(getPermissionRules(permissionConfigs), (rule) => - wildcardMatch("compress", rule.permission), - ) - - return match?.pattern === "*" && match.action === "deny" -} - -export const resolveEffectiveCompressPermission = ( - basePermission: PermissionAction, - hostPermissions: HostPermissionSnapshot, - agentName?: string, -): PermissionAction => { - if (basePermission === "deny") { - return "deny" - } - - return compressDisabledByOpencode( - hostPermissions.global, - agentName ? hostPermissions.agents[agentName] : undefined, - ) - ? "deny" - : basePermission -} - -export const hasExplicitToolPermission = ( - permissionConfig: PermissionConfig, - tool: string, -): boolean => { - return permissionConfig ? Object.prototype.hasOwnProperty.call(permissionConfig, tool) : false -} diff --git a/lib/logger.ts b/lib/logger.ts index 43b5d9e8a..540cd843a 100644 --- a/lib/logger.ts +++ b/lib/logger.ts @@ -1,8 +1,13 @@ -import { writeFile, mkdir } from "fs/promises" +// SPDX-License-Identifier: AGPL-3.0-or-later +import { writeFile, mkdir, readdir, unlink } from "fs/promises" import { join } from "path" import { existsSync } from "fs" import { homedir } from "os" +// Context snapshots contain full message and tool text. Keep only a small +// window on disk so debug mode doesn't grow without bound. +const MAX_CONTEXT_SNAPSHOTS = 10 + export class Logger { private logDir: string public enabled: boolean @@ -221,6 +226,15 @@ export class Logger { const timestamp = new Date().toISOString().replace(/[:.]/g, "-") const contextFile = join(contextDir, `${timestamp}.json`) await writeFile(contextFile, JSON.stringify(minimized, null, 2)) + + const snapshots = (await readdir(contextDir)) + .filter((name) => name.endsWith(".json")) + .sort() + for (const name of snapshots.slice( + 0, + Math.max(0, snapshots.length - MAX_CONTEXT_SNAPSHOTS), + )) + await unlink(join(contextDir, name)).catch(() => {}) } catch (error) {} } } diff --git a/lib/message-ids.ts b/lib/message-ids.ts index ad4a220c4..98694b90f 100644 --- a/lib/message-ids.ts +++ b/lib/message-ids.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { SessionState, WithParts } from "./state" import { isIgnoredUserMessage } from "./messages/query" diff --git a/lib/message-info.ts b/lib/message-info.ts index 12186e64e..04ab44bde 100644 --- a/lib/message-info.ts +++ b/lib/message-info.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later /** * Structural message/part types used by the shared pruning engine. * diff --git a/lib/messages/index.ts b/lib/messages/index.ts index 4eb50c256..0cca666bb 100644 --- a/lib/messages/index.ts +++ b/lib/messages/index.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later export { prune } from "./prune" export { syncCompressionBlocks } from "./sync" export { injectCompressNudges } from "./inject/inject" diff --git a/lib/messages/inject/inject.ts b/lib/messages/inject/inject.ts index 9d446056b..0f147ae8c 100644 --- a/lib/messages/inject/inject.ts +++ b/lib/messages/inject/inject.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { SessionState, WithParts } from "../../state" import type { Logger } from "../../logger" import type { PluginConfig } from "../../config" diff --git a/lib/messages/inject/subagent-results.ts b/lib/messages/inject/subagent-results.ts index 967121f81..c2f60d2c4 100644 --- a/lib/messages/inject/subagent-results.ts +++ b/lib/messages/inject/subagent-results.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { Logger } from "../../logger" import type { SessionState, WithParts } from "../../state" import { filterMessages } from "../shape" diff --git a/lib/messages/inject/utils.ts b/lib/messages/inject/utils.ts index b682a01bb..d67ac4f53 100644 --- a/lib/messages/inject/utils.ts +++ b/lib/messages/inject/utils.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { SessionState, WithParts } from "../../state" import type { PluginConfig } from "../../config" import { diff --git a/lib/messages/priority.ts b/lib/messages/priority.ts index 2ff99fbd4..6b6339312 100644 --- a/lib/messages/priority.ts +++ b/lib/messages/priority.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { PluginConfig } from "../config" import { countAllMessageTokens } from "../token-utils" import { isMessageCompacted } from "../state/utils" diff --git a/lib/messages/prune.ts b/lib/messages/prune.ts index 95096bd5b..159cf1566 100644 --- a/lib/messages/prune.ts +++ b/lib/messages/prune.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { SessionState, WithParts } from "../state" import type { Logger } from "../logger" import type { PluginConfig } from "../config" diff --git a/lib/messages/query.ts b/lib/messages/query.ts index 49a9f26ca..30852d96c 100644 --- a/lib/messages/query.ts +++ b/lib/messages/query.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { PluginConfig } from "../config" import type { WithParts } from "../state" import { isMessageWithInfo } from "./shape" diff --git a/lib/messages/reasoning-strip.ts b/lib/messages/reasoning-strip.ts index d2c98620c..fba30782b 100644 --- a/lib/messages/reasoning-strip.ts +++ b/lib/messages/reasoning-strip.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { WithParts } from "../state" import { getLastUserMessage } from "./query" diff --git a/lib/messages/shape.ts b/lib/messages/shape.ts index e18eeec31..1bd49d529 100644 --- a/lib/messages/shape.ts +++ b/lib/messages/shape.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { WithParts } from "../state" export function isMessageWithInfo(message: unknown): message is WithParts { diff --git a/lib/messages/sync.ts b/lib/messages/sync.ts index cd3056227..ab7da345a 100644 --- a/lib/messages/sync.ts +++ b/lib/messages/sync.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { SessionState, WithParts } from "../state" import type { Logger } from "../logger" diff --git a/lib/messages/utils.ts b/lib/messages/utils.ts index e3cf5a223..8773347c0 100644 --- a/lib/messages/utils.ts +++ b/lib/messages/utils.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import { createHash } from "node:crypto" import type { SessionState, WithParts } from "../state" import { isMessageCompacted } from "../state/utils" diff --git a/lib/native/commands.ts b/lib/native/commands.ts index 0a8d53761..1848cc31a 100644 --- a/lib/native/commands.ts +++ b/lib/native/commands.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { PluginConfig } from "../config" import type { Logger } from "../logger" import type { SessionState } from "../state" diff --git a/lib/native/messages.ts b/lib/native/messages.ts index b912f0cb4..e8d89eeb3 100644 --- a/lib/native/messages.ts +++ b/lib/native/messages.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { Message, ContentPart, ToolResultPart } from "@opencode/ai" import type { Plugin } from "@opencode/plugin" import type { WithParts } from "../state" diff --git a/lib/native/notifications.ts b/lib/native/notifications.ts index e5d9a3145..a09170548 100644 --- a/lib/native/notifications.ts +++ b/lib/native/notifications.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { NotificationEvent } from "./rpc" /** diff --git a/lib/native/permissions.ts b/lib/native/permissions.ts index f9f093876..0e254181c 100644 --- a/lib/native/permissions.ts +++ b/lib/native/permissions.ts @@ -1,6 +1,8 @@ -import type { PermissionAction } from "../host-permissions" +// SPDX-License-Identifier: AGPL-3.0-or-later import { matchesGlob } from "../protected-patterns" +type PermissionAction = "ask" | "allow" | "deny" + export interface NativePermissionRule { action?: unknown resource?: unknown diff --git a/lib/native/plugin.ts b/lib/native/plugin.ts index cde6f3647..680dae854 100644 --- a/lib/native/plugin.ts +++ b/lib/native/plugin.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { Plugin } from "@opencode/plugin" import { getConfig } from "../config" import { Logger } from "../logger" @@ -35,19 +36,35 @@ import { injectNativeSystemPrompt } from "./system-prompt" import { executeNativeCommand } from "./commands" export async function setup(ctx: Plugin.Context) { + // Config is loaded before the RPC notification channel exists, so collect + // config warnings here and flush them once emitNotification is wired up. + const pendingWarnings: NotificationEvent[] = [] const warnings = { tui: { - showToast: async (input: { body: { message: string } }) => { - console.warn(`DCP: ${input.body.message}`) + showToast: async (input: { + body: { title?: string; message: string; variant?: string; duration?: number } + }) => { + pendingWarnings.push({ + title: input.body.title ?? "DCP config", + message: input.body.message, + variant: "warning", + duration: input.body.duration, + }) }, }, } - const config = getConfig({ directory: ctx.location.directory, client: warnings }) + function flushWarnings(emit: (event: NotificationEvent) => Promise): void { + for (const event of pendingWarnings.splice(0)) void emit(event).catch(() => {}) + } + let config = getConfig({ directory: ctx.location.directory, client: warnings }) if (!config.enabled) { await ctx.rpc.register( { ...rpc, methods: { status: rpc.methods.status } }, { status: async () => ({ enabled: false }) }, ) + flushWarnings(async (event) => { + console.warn(`DCP: ${event.title}: ${event.message}`) + }) return } const logger = new Logger(config.debug) @@ -60,6 +77,14 @@ export async function setup(ctx: Plugin.Context) { const sessions = new Map() const queues = new Map>() const limits = new Map() + const MAX_CACHED_SESSIONS = 100 + function trimSessionCache(): void { + while (sessions.size > MAX_CACHED_SESSIONS) { + const oldest = sessions.keys().next() + if (oldest.done) return + sessions.delete(oldest.value) + } + } const registrations: Array<{ dispose(): Promise }> = [] registrations.push( await ctx.permission.hook("evaluate", (evaluation) => @@ -71,14 +96,35 @@ export async function setup(ctx: Plugin.Context) { bash: "shell", apply_patch: "patch", } - for (const list of [ - config.compress.protectedTools, - config.commands.protectedTools, - config.strategies.deduplication.protectedTools, - config.strategies.purgeErrors.protectedTools, - ]) { - for (const name of [...list]) - if (aliases[name] && !list.includes(aliases[name]!)) list.push(aliases[name]!) + const withAliases = (list: string[]): string[] => { + const result = [...list] + for (const name of [...result]) { + const alias = aliases[name] + if (alias && !result.includes(alias)) result.push(alias) + } + return result + } + // Replace the affected lists instead of mutating the loaded config in place. + config = { + ...config, + commands: { + ...config.commands, + protectedTools: withAliases(config.commands.protectedTools), + }, + compress: { + ...config.compress, + protectedTools: withAliases(config.compress.protectedTools), + }, + strategies: { + deduplication: { + ...config.strategies.deduplication, + protectedTools: withAliases(config.strategies.deduplication.protectedTools), + }, + purgeErrors: { + ...config.strategies.purgeErrors, + protectedTools: withAliases(config.strategies.purgeErrors.protectedTools), + }, + }, } function serial(sessionID: string, operation: () => Promise): Promise { @@ -93,7 +139,7 @@ export async function setup(ctx: Plugin.Context) { } let emitNotification: (event: NotificationEvent) => Promise = async () => {} - let emitOpenPanel: () => Promise = async () => {} + let emitOpenPanel: (sessionID: string) => Promise = async () => {} const notifier = createNotifier(async (event) => emitNotification(event)) const client = { session: { @@ -129,6 +175,7 @@ export async function setup(ctx: Plugin.Context) { if (!state) { state = createSessionState("compact") sessions.set(sessionID, state) + trimSessionCache() } const messages = history(entries, session) await ensureSessionInitialized( @@ -282,7 +329,7 @@ export async function setup(ctx: Plugin.Context) { name === "dcp" ? "DCP commands" : "Trigger DCP manual compression", execute: async (invocation) => { if (name === "dcp" && !invocation.prompt.text.trim()) { - await emitOpenPanel() + await emitOpenPanel(invocation.sessionID) return } const prompt = await serial(invocation.sessionID, async () => { @@ -348,7 +395,8 @@ export async function setup(ctx: Plugin.Context) { }), }) emitNotification = (event) => rpcRegistration.events.emit("notification", event) - emitOpenPanel = () => rpcRegistration.events.emit("openPanel", {}) + flushWarnings(emitNotification) + emitOpenPanel = (sessionID) => rpcRegistration.events.emit("openPanel", { sessionID }) registrations.push(rpcRegistration) logger.info("DCP native initialized") return async () => { diff --git a/lib/native/rpc.ts b/lib/native/rpc.ts index 844533df5..97cab14c2 100644 --- a/lib/native/rpc.ts +++ b/lib/native/rpc.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import { z } from "zod" export const notificationEvent = z.object({ @@ -61,6 +62,8 @@ export const rpc = { }, events: { notification: { schema: notificationEvent }, - openPanel: { schema: z.object({}) }, + // Scoped to the session that invoked /dcp so other open sessions don't + // pop their panels when a command runs elsewhere. + openPanel: { schema: z.object({ sessionID: z.string() }) }, }, } as const diff --git a/lib/native/system-prompt.ts b/lib/native/system-prompt.ts index 628bec0ca..0f5996b3c 100644 --- a/lib/native/system-prompt.ts +++ b/lib/native/system-prompt.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { SystemPart } from "@opencode/ai" import type { PluginConfig } from "../config" import type { Logger } from "../logger" @@ -40,7 +41,8 @@ export function injectNativeSystemPrompt( if (compressPermission(state, config) === "deny") return - prompts.reload() + // The context hook reloads prompts once before nudges are injected; doing it + // again here would re-read every override file twice per request. const newPrompt = renderSystemPrompt( prompts.getRuntimePrompts(), buildProtectedToolsExtension(config.compress.protectedTools), diff --git a/lib/native/theme.ts b/lib/native/theme.ts index 3dfec4dff..260790ccd 100644 --- a/lib/native/theme.ts +++ b/lib/native/theme.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { Theme } from "../tui/types" type Color = Theme["text"] diff --git a/lib/native/tui.tsx b/lib/native/tui.tsx index 68cb301e2..b4c23c55f 100644 --- a/lib/native/tui.tsx +++ b/lib/native/tui.tsx @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later /** @jsxImportSource @opentui/solid */ import type { Plugin } from "@opencode/plugin/tui" import { ContextDialog, PanelDialog, StatsDialog, StatusDialog } from "../tui/dialogs" @@ -94,7 +95,13 @@ export async function setup(ctx: Plugin.Context) { }, }) const unsubscribeNotification = client.events.on("notification", onNotification) - const unsubscribeOpenPanel = client.events.on("openPanel", () => open()) + const unsubscribeOpenPanel = client.events.on("openPanel", ({ data }) => { + const route = ctx.ui.router.current() + // The event is broadcast to every TUI session; only the session that + // invoked /dcp should actually pop its panel. + if (route.type !== "session" || route.sessionID !== data.sessionID) return + void open() + }) ctx.ui.slot({ append: "app", diff --git a/lib/prompts/compress-message.ts b/lib/prompts/compress-message.ts index 030fc0c7b..3d8dfdae7 100644 --- a/lib/prompts/compress-message.ts +++ b/lib/prompts/compress-message.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { IdFormat } from "../message-ids" export function messagePrompt(format: IdFormat = "xml"): string { diff --git a/lib/prompts/compress-range.ts b/lib/prompts/compress-range.ts index 4835bd6d8..3741eb8e6 100644 --- a/lib/prompts/compress-range.ts +++ b/lib/prompts/compress-range.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { IdFormat } from "../message-ids" export function rangePrompt(format: IdFormat = "xml"): string { diff --git a/lib/prompts/context-limit-nudge.ts b/lib/prompts/context-limit-nudge.ts index 1b3784700..8b8bfe5a4 100644 --- a/lib/prompts/context-limit-nudge.ts +++ b/lib/prompts/context-limit-nudge.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later export const CONTEXT_LIMIT_NUDGE = ` CRITICAL WARNING: MAX CONTEXT LIMIT REACHED diff --git a/lib/prompts/extensions/nudge.ts b/lib/prompts/extensions/nudge.ts index 578f6d9c3..02645ad34 100644 --- a/lib/prompts/extensions/nudge.ts +++ b/lib/prompts/extensions/nudge.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { SessionState } from "../../state" import { formatBlockRef } from "../../message-ids" diff --git a/lib/prompts/extensions/system.ts b/lib/prompts/extensions/system.ts index f5f038bd0..a4b53e9f1 100644 --- a/lib/prompts/extensions/system.ts +++ b/lib/prompts/extensions/system.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later export const MANUAL_MODE_SYSTEM_EXTENSION = ` Manual mode is enabled. Do NOT use compress unless the user has explicitly triggered it through a manual marker. diff --git a/lib/prompts/extensions/tool.ts b/lib/prompts/extensions/tool.ts index e896c1870..03b1c3ffe 100644 --- a/lib/prompts/extensions/tool.ts +++ b/lib/prompts/extensions/tool.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later // These format schemas are kept separate from the editable compress prompts // so they cannot be modified via custom prompt overrides. The schemas must // match the tool's input validation and are not safe to change independently. diff --git a/lib/prompts/index.ts b/lib/prompts/index.ts index bdfbee5ed..130fd281a 100644 --- a/lib/prompts/index.ts +++ b/lib/prompts/index.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { RuntimePrompts } from "./store" export type { PromptStore, RuntimePrompts } from "./store" diff --git a/lib/prompts/iteration-nudge.ts b/lib/prompts/iteration-nudge.ts index f8e4fa9b8..1faf82667 100644 --- a/lib/prompts/iteration-nudge.ts +++ b/lib/prompts/iteration-nudge.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later export const ITERATION_NUDGE = ` You've been iterating for a while after the last user message. diff --git a/lib/prompts/store.ts b/lib/prompts/store.ts index a9213a7ee..a0081a7ab 100644 --- a/lib/prompts/store.ts +++ b/lib/prompts/store.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import { existsSync, mkdirSync, readFileSync, writeFileSync, statSync } from "fs" import { join, dirname } from "path" import { homedir } from "os" diff --git a/lib/prompts/system.ts b/lib/prompts/system.ts index 08a89450e..dfab0b1dd 100644 --- a/lib/prompts/system.ts +++ b/lib/prompts/system.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { IdFormat } from "../message-ids" export function systemPrompt(format: IdFormat = "xml"): string { diff --git a/lib/prompts/turn-nudge.ts b/lib/prompts/turn-nudge.ts index 9f64f108d..b9c5dccbf 100644 --- a/lib/prompts/turn-nudge.ts +++ b/lib/prompts/turn-nudge.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later export const TURN_NUDGE = ` Evaluate the conversation for compressible ranges. diff --git a/lib/protected-patterns.ts b/lib/protected-patterns.ts index c2da8c685..e7c768308 100644 --- a/lib/protected-patterns.ts +++ b/lib/protected-patterns.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later function normalizePath(input: string): string { // A single backslash. In source, "\\" is the one-character string; the // previous "\\\\" was a *two*-character string, so it only ever matched a diff --git a/lib/state/index.ts b/lib/state/index.ts index e3a2089ce..1e3b1e973 100644 --- a/lib/state/index.ts +++ b/lib/state/index.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later export * from "./persistence" export * from "./types" export * from "./state" diff --git a/lib/state/persistence.ts b/lib/state/persistence.ts index 02998aeff..c2fc4f296 100644 --- a/lib/state/persistence.ts +++ b/lib/state/persistence.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later /** * State persistence module for DCP plugin. * Persists pruned tool IDs across sessions so they survive OpenCode restarts. diff --git a/lib/state/state.ts b/lib/state/state.ts index 47ce19af7..5d0697b1c 100644 --- a/lib/state/state.ts +++ b/lib/state/state.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { SessionState, ToolParameterEntry, WithParts } from "./types" import type { Logger } from "../logger" import { applyPendingCompressionDurations } from "../compress/timing" @@ -135,6 +136,8 @@ export function resetSessionState(state: SessionState): void { state.currentTurn = 0 state.modelContextLimit = undefined state.systemPromptTokens = undefined + state.compressionTiming.startsByCallId.clear() + state.compressionTiming.pendingByCallId.clear() } export async function ensureSessionInitialized( diff --git a/lib/state/tool-cache.ts b/lib/state/tool-cache.ts index cde960e82..93328e781 100644 --- a/lib/state/tool-cache.ts +++ b/lib/state/tool-cache.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { SessionState, ToolStatus, WithParts } from "./index" import type { Logger } from "../logger" import { PluginConfig } from "../config" diff --git a/lib/state/types.ts b/lib/state/types.ts index ea020000a..5a3c253d9 100644 --- a/lib/state/types.ts +++ b/lib/state/types.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { CompressionTimingState } from "../compress/timing" import type { IdFormat } from "../message-ids" import type { MessageInfo, PartLike } from "../message-info" diff --git a/lib/state/utils.ts b/lib/state/utils.ts index ce05e27ba..bc15f58cd 100644 --- a/lib/state/utils.ts +++ b/lib/state/utils.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { CompressionBlock, PruneMessagesState, diff --git a/lib/strategies/deduplication.ts b/lib/strategies/deduplication.ts index 5b821a5c5..a0f8e9eb3 100644 --- a/lib/strategies/deduplication.ts +++ b/lib/strategies/deduplication.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import { PluginConfig } from "../config" import { Logger } from "../logger" import type { SessionState, WithParts } from "../state" diff --git a/lib/strategies/index.ts b/lib/strategies/index.ts index d6ef1009a..d1d736e34 100644 --- a/lib/strategies/index.ts +++ b/lib/strategies/index.ts @@ -1,2 +1,3 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later export { deduplicate } from "./deduplication" export { purgeErrors } from "./purge-errors" diff --git a/lib/strategies/purge-errors.ts b/lib/strategies/purge-errors.ts index 202d2d03d..21e4d8120 100644 --- a/lib/strategies/purge-errors.ts +++ b/lib/strategies/purge-errors.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import { PluginConfig } from "../config" import { Logger } from "../logger" import type { SessionState, WithParts } from "../state" diff --git a/lib/subagents/subagent-results.ts b/lib/subagents/subagent-results.ts index 2839d2df3..ee59fe0de 100644 --- a/lib/subagents/subagent-results.ts +++ b/lib/subagents/subagent-results.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { WithParts } from "../state" const SUB_AGENT_RESULT_BLOCK_REGEX = diff --git a/lib/token-utils.ts b/lib/token-utils.ts index 4fe7a3de6..4633cedc6 100644 --- a/lib/token-utils.ts +++ b/lib/token-utils.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import { SessionState, WithParts } from "./state" import type { MessageInfo } from "./message-info" import { Logger } from "./logger" diff --git a/lib/tool-schema.ts b/lib/tool-schema.ts index 6a591ae26..bfbd4ea12 100644 --- a/lib/tool-schema.ts +++ b/lib/tool-schema.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later /** * Minimal JSON Schema builders for DCP's tool definitions. * diff --git a/lib/tui/dialogs.tsx b/lib/tui/dialogs.tsx index 1f1c58021..4ab5c4eea 100644 --- a/lib/tui/dialogs.tsx +++ b/lib/tui/dialogs.tsx @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later /** @jsxImportSource @opentui/solid */ import type { analyzeContextTokens } from "../commands/context" diff --git a/lib/tui/format.ts b/lib/tui/format.ts index d096a5f6d..99da93f17 100644 --- a/lib/tui/format.ts +++ b/lib/tui/format.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later export function formatDuration(ms: number): string { const safeMs = Math.max(0, Math.round(ms)) if (safeMs < 1000) return `${safeMs} ms` diff --git a/lib/tui/types.ts b/lib/tui/types.ts index 2f7d7edfc..ba140acba 100644 --- a/lib/tui/types.ts +++ b/lib/tui/types.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { Plugin } from "@opencode/plugin/tui" import type { RGBA } from "@opentui/core" import type { buildStatsReport } from "../commands/stats" diff --git a/lib/tui/ui.tsx b/lib/tui/ui.tsx index dbb2ee992..23a42a7ef 100644 --- a/lib/tui/ui.tsx +++ b/lib/tui/ui.tsx @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later /** @jsxImportSource @opentui/solid */ import type { BoxRenderable, ScrollBoxRenderable } from "@opentui/core" diff --git a/lib/ui/notification.ts b/lib/ui/notification.ts index 64fa5c38f..a2d6b6461 100644 --- a/lib/ui/notification.ts +++ b/lib/ui/notification.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import type { Logger } from "../logger" import type { SessionState } from "../state" import { diff --git a/lib/ui/utils.ts b/lib/ui/utils.ts index a3de072b0..a58bed7db 100644 --- a/lib/ui/utils.ts +++ b/lib/ui/utils.ts @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later import { SessionState, ToolParameterEntry, WithParts } from "../state" import { countTokens } from "../token-utils" import { isIgnoredUserMessage } from "../messages/query" diff --git a/package.json b/package.json index 95807ed51..2f756bc49 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,8 @@ "dcp.schema.json", "dcp.example.jsonc", "README.md", + "CHANGELOG.md", + "NOTICE", "LICENSE" ] } diff --git a/server.js b/server.js deleted file mode 100644 index 1842a4493..000000000 --- a/server.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from "./dist/index.js" diff --git a/tests/config-warnings.test.ts b/tests/config-warnings.test.ts new file mode 100644 index 000000000..66c0872ec --- /dev/null +++ b/tests/config-warnings.test.ts @@ -0,0 +1,53 @@ +import assert from "node:assert/strict" +import test from "node:test" +import { mkdirSync, writeFileSync } from "node:fs" +import { join } from "node:path" +import { tmpdir } from "node:os" + +const configHome = join(tmpdir(), `dcp-config-warnings-${process.pid}`) +mkdirSync(join(configHome, "opencode"), { recursive: true }) +process.env.XDG_CONFIG_HOME = configHome +writeFileSync( + join(configHome, "opencode", "dcp.jsonc"), + JSON.stringify({ unknownKey: true, compress: { nudgeForce: "loud" } }), +) + +const { getConfig } = await import("../lib/config") + +test("config warnings are delivered synchronously to the client", () => { + const toasts: Array<{ title?: string; message: string; variant?: string }> = [] + getConfig({ + directory: "/tmp", + client: { + tui: { + showToast: (input) => { + toasts.push(input.body) + }, + }, + }, + }) + + assert.equal(toasts.length, 1) + assert.match(toasts[0]!.title ?? "", /warning/) + assert.match(toasts[0]!.message, /unknownKey/) + assert.match(toasts[0]!.message, /nudgeForce/) +}) + +test("parse errors are reported through the same channel", () => { + // Replace the config with malformed JSONC before reloading via cache bust. + writeFileSync(join(configHome, "opencode", "dcp.jsonc"), "{ this is not json") + const toasts: Array<{ title?: string; message: string; variant?: string }> = [] + getConfig({ + directory: "/tmp", + client: { + tui: { + showToast: (input) => { + toasts.push(input.body) + }, + }, + }, + }) + + assert.ok(toasts.length >= 1) + assert.match(toasts[0]!.title ?? "", /Invalid config/) +}) diff --git a/tests/hooks-permission.test.ts b/tests/hooks-permission.test.ts deleted file mode 100644 index a2958618b..000000000 --- a/tests/hooks-permission.test.ts +++ /dev/null @@ -1,808 +0,0 @@ -import assert from "node:assert/strict" -import test from "node:test" -import type { PluginConfig } from "../lib/config" -import { - createChatMessageTransformHandler, - createCommandExecuteHandler, - createEventHandler, - createSystemPromptHandler, - createTextCompleteHandler, -} from "../lib/hooks" -import { Logger } from "../lib/logger" -import { - createSessionState, - ensureSessionInitialized, - refreshManualMode, - saveManualModeSetting, - saveSessionState, - type WithParts, -} from "../lib/state" - -function buildConfig(permission: "allow" | "ask" | "deny" = "allow"): PluginConfig { - return { - enabled: true, - debug: false, - pruneNotification: "off", - commands: { - enabled: true, - protectedTools: [], - }, - manualMode: { - enabled: false, - automaticStrategies: true, - }, - turnProtection: { - enabled: false, - turns: 4, - }, - experimental: { - allowSubAgents: false, - customPrompts: false, - }, - protectedFilePatterns: [], - compress: { - mode: "message", - permission, - showCompression: false, - maxContextLimit: 150000, - minContextLimit: 50000, - nudgeFrequency: 5, - iterationNudgeThreshold: 15, - nudgeForce: "soft", - protectedTools: ["task"], - protectTags: false, - protectUserMessages: false, - }, - strategies: { - deduplication: { - enabled: true, - protectedTools: [], - }, - purgeErrors: { - enabled: true, - turns: 4, - protectedTools: [], - }, - }, - } -} - -function buildMessage(id: string, role: "user" | "assistant", text: string): WithParts { - return { - info: { - id, - role, - sessionID: "session-1", - agent: "assistant", - time: { created: 1 }, - } as WithParts["info"], - parts: [ - { - id: `${id}-part`, - messageID: id, - sessionID: "session-1", - type: "text", - text, - }, - ], - } -} - -test("system prompt handler caches full model context for percentage thresholds", async () => { - const state = createSessionState() - const handler = createSystemPromptHandler(state, new Logger(false), buildConfig("deny"), { - reload() {}, - getRuntimePrompts() { - return {} as any - }, - } as any) - - await handler( - { - sessionID: "session-1", - model: { - limit: { - context: 200000, - output: 131072, - }, - }, - } as any, - { system: ["base system"] }, - ) - - assert.equal(state.modelContextLimit, 200000) -}) - -function buildPromptStore() { - return { - reload() {}, - getRuntimePrompts() { - return { - system: "DCP-RUNTIME-PROMPT", - manualExtension: "", - subagentExtension: "", - } - }, - } as any -} - -test("system prompt handler injects nudges for main session with bundled internal prompts", async () => { - const state = createSessionState() - const handler = createSystemPromptHandler( - state, - new Logger(false), - buildConfig("allow"), - buildPromptStore(), - ) - const output = { - system: [ - "You are the primary coding assistant for this repository.", - "You are a title generator for short session names.", - ], - } - - await handler( - { - sessionID: "session-1", - model: { limit: { context: 200000 } }, - } as any, - output, - ) - - assert.match(output.system[output.system.length - 1], /DCP-RUNTIME-PROMPT/) -}) - -test("system prompt handler skips injection for internal agent calls", async () => { - const state = createSessionState() - const handler = createSystemPromptHandler( - state, - new Logger(false), - buildConfig("allow"), - buildPromptStore(), - ) - const output = { - system: ["You are a title generator. Return only a short title."], - } - - await handler( - { - sessionID: "session-1", - model: { limit: { context: 200000 } }, - } as any, - output, - ) - - assert.equal(output.system.length, 1) - assert.doesNotMatch(output.system[0], /DCP-RUNTIME-PROMPT/) -}) - -test("chat message transform strips hallucinated tags even when compress is denied", async () => { - const state = createSessionState() - const logger = new Logger(false) - const config = buildConfig("deny") - const handler = createChatMessageTransformHandler( - { session: { get: async () => ({}) } } as any, - state, - logger, - config, - { - reload() {}, - getRuntimePrompts() { - return {} as any - }, - } as any, - { global: undefined, agents: {} }, - ) - const output = { - messages: [buildMessage("assistant-1", "assistant", "alpha beta omega")], - } - - await handler({}, output) - - assert.equal(output.messages[0]?.parts[0]?.type, "text") - assert.equal((output.messages[0]?.parts[0] as any).text, "alpha omega") -}) - -test("chat message transform drops messages without info instead of crashing", async () => { - const state = createSessionState() - const logger = new Logger(false) - const config = buildConfig("deny") - const handler = createChatMessageTransformHandler( - { session: { get: async () => ({}) } } as any, - state, - logger, - config, - { - reload() {}, - getRuntimePrompts() { - return {} as any - }, - } as any, - { global: undefined, agents: {} }, - ) - const output = { - messages: [ - { - role: "user", - time: 1, - parts: [ - { - type: "text", - text: "Carica le skill di laravel", - }, - ], - } as any, - ], - } - - await handler({}, output as any) - - assert.equal(state.sessionId, null) - assert.equal(output.messages.length, 0) -}) - -test("command execute exits after effective permission resolves to deny", async () => { - let sessionMessagesCalls = 0 - const output = { parts: [] as any[] } - const handler = createCommandExecuteHandler( - { - session: { - messages: async () => { - sessionMessagesCalls += 1 - return { data: [] } - }, - }, - } as any, - createSessionState(), - new Logger(false), - buildConfig("deny"), - "/tmp", - { global: undefined, agents: {} }, - ) - - await handler({ command: "dcp", sessionID: "session-1", arguments: "context" }, output) - - assert.equal(sessionMessagesCalls, 1) - assert.deepEqual(output.parts, []) -}) - -test("text complete strips hallucinated metadata tags", async () => { - const output = { text: "alpha beta omega" } - const handler = createTextCompleteHandler() - - await handler({ sessionID: "session-1", messageID: "message-1", partID: "part-1" }, output) - - assert.equal(output.text, "alpha omega") -}) - -test("event hook attaches durations to matching blocks by message and call id", async () => { - const state = createSessionState() - state.sessionId = "session-1" - const handler = createEventHandler(state, new Logger(false)) - const originalNow = Date.now - Date.now = () => 100 - - try { - await handler({ - event: { - type: "message.part.updated", - properties: { - part: { - type: "tool", - tool: "compress", - callID: "call-1", - messageID: "message-1", - sessionID: "session-1", - state: { - status: "pending", - input: {}, - raw: "", - }, - }, - }, - }, - }) - - await handler({ - event: { - type: "message.part.updated", - properties: { - part: { - type: "tool", - tool: "compress", - callID: "call-2", - messageID: "message-1", - sessionID: "session-1", - state: { - status: "pending", - input: {}, - raw: "", - }, - }, - }, - }, - }) - - await handler({ - event: { - type: "message.part.updated", - properties: { - part: { - type: "tool", - tool: "compress", - callID: "call-1", - messageID: "message-1", - sessionID: "session-1", - state: { - status: "running", - input: {}, - time: { start: 325 }, - }, - }, - }, - }, - }) - - await handler({ - event: { - type: "message.part.updated", - properties: { - part: { - type: "tool", - tool: "compress", - callID: "call-2", - messageID: "message-1", - sessionID: "session-1", - state: { - status: "running", - input: {}, - time: { start: 410 }, - }, - }, - }, - }, - }) - state.prune.messages.blocksById.set(1, { - blockId: 1, - runId: 1, - active: true, - deactivatedByUser: false, - compressedTokens: 0, - summaryTokens: 0, - durationMs: 0, - mode: "message", - topic: "one", - batchTopic: "one", - startId: "m0001", - endId: "m0001", - anchorMessageId: "msg-a", - compressMessageId: "message-1", - compressCallId: "call-1", - includedBlockIds: [], - consumedBlockIds: [], - parentBlockIds: [], - directMessageIds: [], - directToolIds: [], - effectiveMessageIds: ["msg-a"], - effectiveToolIds: [], - createdAt: 1, - summary: "a", - }) - state.prune.messages.blocksById.set(2, { - blockId: 2, - runId: 2, - active: true, - deactivatedByUser: false, - compressedTokens: 0, - summaryTokens: 0, - durationMs: 0, - mode: "message", - topic: "two", - batchTopic: "two", - startId: "m0002", - endId: "m0002", - anchorMessageId: "msg-b", - compressMessageId: "message-1", - compressCallId: "call-2", - includedBlockIds: [], - consumedBlockIds: [], - parentBlockIds: [], - directMessageIds: [], - directToolIds: [], - effectiveMessageIds: ["msg-b"], - effectiveToolIds: [], - createdAt: 2, - summary: "b", - }) - - await handler({ - event: { - type: "message.part.updated", - properties: { - part: { - type: "tool", - tool: "compress", - callID: "call-2", - messageID: "message-1", - sessionID: "session-1", - state: { - status: "completed", - input: {}, - output: "done", - title: "", - metadata: {}, - time: { start: 410, end: 500 }, - }, - }, - }, - }, - }) - - await handler({ - event: { - type: "message.part.updated", - properties: { - part: { - type: "tool", - tool: "compress", - callID: "call-1", - messageID: "message-1", - sessionID: "session-1", - state: { - status: "completed", - input: {}, - output: "done", - title: "", - metadata: {}, - time: { start: 325, end: 500 }, - }, - }, - }, - }, - }) - } finally { - Date.now = originalNow - } - - assert.equal(state.prune.messages.blocksById.get(1)?.durationMs, 225) - assert.equal(state.prune.messages.blocksById.get(2)?.durationMs, 310) -}) - -test("event hook falls back to completed runtime when running duration missing", async () => { - const state = createSessionState() - state.sessionId = "session-1" - const handler = createEventHandler(state, new Logger(false)) - - state.prune.messages.blocksById.set(1, { - blockId: 1, - runId: 1, - active: true, - deactivatedByUser: false, - compressedTokens: 0, - summaryTokens: 0, - durationMs: 0, - mode: "message", - topic: "one", - batchTopic: "one", - startId: "m0001", - endId: "m0001", - anchorMessageId: "msg-a", - compressMessageId: "message-1", - compressCallId: "call-3", - includedBlockIds: [], - consumedBlockIds: [], - parentBlockIds: [], - directMessageIds: [], - directToolIds: [], - effectiveMessageIds: ["msg-a"], - effectiveToolIds: [], - createdAt: 1, - summary: "a", - }) - - await handler({ - event: { - type: "message.part.updated", - properties: { - part: { - type: "tool", - tool: "compress", - callID: "call-3", - messageID: "message-1", - sessionID: "session-1", - state: { - status: "completed", - input: {}, - output: "done", - title: "", - metadata: {}, - time: { start: 500, end: 940 }, - }, - }, - }, - }, - }) - - assert.equal(state.prune.messages.blocksById.get(1)?.durationMs, 440) -}) - -test("event hook queues duration updates until the matching session is loaded", async () => { - const logger = new Logger(false) - const targetSessionId = `session-target-${process.pid}-${Date.now()}` - const otherSessionId = `session-other-${process.pid}-${Date.now()}` - const persistedState = createSessionState() - persistedState.sessionId = targetSessionId - persistedState.prune.messages.blocksById.set(1, { - blockId: 1, - runId: 1, - active: true, - deactivatedByUser: false, - compressedTokens: 0, - summaryTokens: 0, - durationMs: 0, - mode: "message", - topic: "one", - batchTopic: "one", - startId: "m0001", - endId: "m0001", - anchorMessageId: "msg-a", - compressMessageId: "message-1", - compressCallId: "call-remote", - includedBlockIds: [], - consumedBlockIds: [], - parentBlockIds: [], - directMessageIds: [], - directToolIds: [], - effectiveMessageIds: ["msg-a"], - effectiveToolIds: [], - createdAt: 1, - summary: "a", - }) - await saveSessionState(persistedState, logger) - - const liveState = createSessionState() - liveState.sessionId = otherSessionId - const handler = createEventHandler(liveState, logger) - - await handler({ - event: { - type: "message.part.updated", - properties: { - sessionID: targetSessionId, - part: { - type: "tool", - tool: "compress", - callID: "call-remote", - messageID: "message-1", - state: { - status: "pending", - input: {}, - raw: "", - }, - }, - }, - time: 100, - }, - }) - - await handler({ - event: { - type: "message.part.updated", - properties: { - sessionID: targetSessionId, - part: { - type: "tool", - tool: "compress", - callID: "call-remote", - messageID: "message-1", - state: { - status: "completed", - input: {}, - output: "done", - title: "", - metadata: {}, - time: { start: 350, end: 500 }, - }, - }, - }, - }, - }) - - assert.equal(liveState.compressionTiming.pendingByCallId.has("message-1:call-remote"), true) - assert.equal(liveState.compressionTiming.startsByCallId.has("message-1:call-remote"), false) - - await ensureSessionInitialized( - { - session: { - get: async () => ({ data: { parentID: null } }), - }, - } as any, - liveState, - targetSessionId, - logger, - [ - { - info: { - id: "msg-user-1", - role: "user", - sessionID: targetSessionId, - agent: "assistant", - time: { created: 1 }, - } as WithParts["info"], - parts: [], - }, - ], - false, - ) - - assert.equal(liveState.prune.messages.blocksById.get(1)?.durationMs, 250) - assert.equal(liveState.compressionTiming.pendingByCallId.has("message-1:call-remote"), false) -}) - -test("event hook keeps same call id distinct across message ids", async () => { - const state = createSessionState() - state.sessionId = "session-1" - const handler = createEventHandler(state, new Logger(false)) - - state.prune.messages.blocksById.set(1, { - blockId: 1, - runId: 1, - active: true, - deactivatedByUser: false, - compressedTokens: 0, - summaryTokens: 0, - durationMs: 0, - mode: "message", - topic: "one", - batchTopic: "one", - startId: "m0001", - endId: "m0001", - anchorMessageId: "msg-a", - compressMessageId: "message-1", - compressCallId: "shared-call", - includedBlockIds: [], - consumedBlockIds: [], - parentBlockIds: [], - directMessageIds: [], - directToolIds: [], - effectiveMessageIds: ["msg-a"], - effectiveToolIds: [], - createdAt: 1, - summary: "a", - }) - state.prune.messages.blocksById.set(2, { - blockId: 2, - runId: 2, - active: true, - deactivatedByUser: false, - compressedTokens: 0, - summaryTokens: 0, - durationMs: 0, - mode: "message", - topic: "two", - batchTopic: "two", - startId: "m0002", - endId: "m0002", - anchorMessageId: "msg-b", - compressMessageId: "message-2", - compressCallId: "shared-call", - includedBlockIds: [], - consumedBlockIds: [], - parentBlockIds: [], - directMessageIds: [], - directToolIds: [], - effectiveMessageIds: ["msg-b"], - effectiveToolIds: [], - createdAt: 2, - summary: "b", - }) - - await handler({ - event: { - type: "message.part.updated", - properties: { - part: { - type: "tool", - tool: "compress", - callID: "shared-call", - messageID: "message-1", - sessionID: "session-1", - state: { - status: "pending", - input: {}, - raw: "", - }, - }, - }, - time: 100, - }, - }) - - await handler({ - event: { - type: "message.part.updated", - properties: { - part: { - type: "tool", - tool: "compress", - callID: "shared-call", - messageID: "message-2", - sessionID: "session-1", - state: { - status: "pending", - input: {}, - raw: "", - }, - }, - }, - time: 200, - }, - }) - - await handler({ - event: { - type: "message.part.updated", - properties: { - part: { - type: "tool", - tool: "compress", - callID: "shared-call", - messageID: "message-2", - sessionID: "session-1", - state: { - status: "completed", - input: {}, - output: "done", - title: "", - metadata: {}, - time: { start: 350, end: 500 }, - }, - }, - }, - }, - }) - - await handler({ - event: { - type: "message.part.updated", - properties: { - part: { - type: "tool", - tool: "compress", - callID: "shared-call", - messageID: "message-1", - sessionID: "session-1", - state: { - status: "completed", - input: {}, - output: "done", - title: "", - metadata: {}, - time: { start: 450, end: 700 }, - }, - }, - }, - }, - }) - - assert.equal(state.prune.messages.blocksById.get(1)?.durationMs, 350) - assert.equal(state.prune.messages.blocksById.get(2)?.durationMs, 150) -}) - -test("manual mode persisted setting refreshes server session state", async () => { - const logger = new Logger(false) - const sessionId = `manual-mode-${Date.now()}-${Math.random().toString(16).slice(2)}` - - await saveManualModeSetting(sessionId, true, logger) - - const state = createSessionState() - state.sessionId = sessionId - state.manualMode = false - - await refreshManualMode(state, sessionId, logger, false) - assert.equal(state.manualMode, "active") - - await saveManualModeSetting(sessionId, false, logger) - await refreshManualMode(state, sessionId, logger, true) - assert.equal(state.manualMode, false) -}) diff --git a/tests/host-permissions.test.ts b/tests/host-permissions.test.ts deleted file mode 100644 index 81b84e427..000000000 --- a/tests/host-permissions.test.ts +++ /dev/null @@ -1,104 +0,0 @@ -import assert from "node:assert/strict" -import test from "node:test" -import { - compressDisabledByOpencode, - hasExplicitToolPermission, - resolveEffectiveCompressPermission, -} from "../lib/host-permissions" - -test("wildcard deny disables compress", () => { - assert.equal(compressDisabledByOpencode({ "*": "deny" }), true) -}) - -test("later explicit compress allow overrides wildcard deny", () => { - assert.equal( - compressDisabledByOpencode({ - "*": "deny", - compress: "allow", - }), - false, - ) -}) - -test("agent wildcard deny disables compress even when global config allows it", () => { - assert.equal( - resolveEffectiveCompressPermission( - "allow", - { - global: { question: "allow" }, - agents: { - fast: { "*": "deny", question: "allow" }, - }, - }, - "fast", - ), - "deny", - ) -}) - -test("agent explicit allow overrides global wildcard deny", () => { - assert.equal( - resolveEffectiveCompressPermission( - "allow", - { - global: { "*": "deny" }, - agents: { - build: { compress: "allow" }, - }, - }, - "build", - ), - "allow", - ) -}) - -test("permission wildcards follow opencode-style matching", () => { - assert.equal(compressDisabledByOpencode({ "c?mpress": "deny" }), true) -}) - -test("pattern-specific denies do not disable the whole tool", () => { - assert.equal( - compressDisabledByOpencode({ - compress: { - "/tmp/*": "deny", - }, - }), - false, - ) -}) - -test("compress permission resolution works without Array.findLast", () => { - const originalFindLast = Array.prototype.findLast - - try { - delete (Array.prototype as Array & { findLast?: unknown }).findLast - - assert.equal( - compressDisabledByOpencode({ - "*": "deny", - compress: "allow", - }), - false, - ) - } finally { - Array.prototype.findLast = originalFindLast - } -}) - -test("explicit compress permissions are detected", () => { - assert.equal(hasExplicitToolPermission({ compress: "ask" }, "compress"), true) - assert.equal(hasExplicitToolPermission({ "*": "deny" }, "compress"), false) -}) - -test("explicit permission detection works without Object.hasOwn", () => { - const originalHasOwn = Object.hasOwn - - try { - delete (Object as typeof Object & { hasOwn?: unknown }).hasOwn - - assert.equal(hasExplicitToolPermission({ compress: "ask" }, "compress"), true) - assert.equal(hasExplicitToolPermission({ "*": "deny" }, "compress"), false) - } finally { - Object.hasOwn = originalHasOwn - } -}) diff --git a/tests/manual-mode-state.test.ts b/tests/manual-mode-state.test.ts new file mode 100644 index 000000000..b418b7c6d --- /dev/null +++ b/tests/manual-mode-state.test.ts @@ -0,0 +1,38 @@ +import assert from "node:assert/strict" +import test from "node:test" +import { Logger } from "../lib/logger" +import { + createSessionState, + refreshManualMode, + resetSessionState, + saveManualModeSetting, +} from "../lib/state" + +test("persisted manual mode setting refreshes session state", async () => { + const logger = new Logger(false) + const sessionId = `manual-mode-${Date.now()}-${Math.random().toString(16).slice(2)}` + + await saveManualModeSetting(sessionId, true, logger) + + const state = createSessionState() + state.sessionId = sessionId + state.manualMode = false + + await refreshManualMode(state, sessionId, logger, false) + assert.equal(state.manualMode, "active") + + await saveManualModeSetting(sessionId, false, logger) + await refreshManualMode(state, sessionId, logger, true) + assert.equal(state.manualMode, false) +}) + +test("resetSessionState clears compression timing", () => { + const state = createSessionState() + state.compressionTiming.startsByCallId.set("message-1:call-1", 100) + state.compressionTiming.pendingByCallId.set("message-1:call-2", "queued" as never) + + resetSessionState(state) + + assert.equal(state.compressionTiming.startsByCallId.size, 0) + assert.equal(state.compressionTiming.pendingByCallId.size, 0) +}) diff --git a/tests/message-priority.test.ts b/tests/message-priority.test.ts index a47417495..b87d96bc7 100644 --- a/tests/message-priority.test.ts +++ b/tests/message-priority.test.ts @@ -1,7 +1,6 @@ import assert from "node:assert/strict" import test from "node:test" import type { PluginConfig } from "../lib/config" -import { createTextCompleteHandler } from "../lib/hooks" import { Logger } from "../lib/logger" import { assignMessageRefs } from "../lib/message-ids" import { injectMessageIds } from "../lib/messages/inject/inject" @@ -753,7 +752,7 @@ test("range-mode rendered compressed summaries keep block IDs", () => { assert.doesNotMatch(summaryText, /BLOCKED<\/dcp-message-id>/) }) -test("hallucination stripping removes all dcp-prefixed XML tags including variants", async () => { +test("hallucination stripping removes all dcp-prefixed XML tags including variants", () => { const text = "alpha" + 'm0008' + @@ -763,11 +762,6 @@ test("hallucination stripping removes all dcp-prefixed XML tags including varian "omega" assert.equal(stripHallucinationsFromString(text), "alphaomega") - - const handler = createTextCompleteHandler() - const output = { text } - await handler({ sessionID: "session", messageID: "message", partID: "part" }, output) - assert.equal(output.text, "alphaomega") }) test("hallucination stripping removes colon and underscore dcp tag variants", async () => { diff --git a/tests/native/notifications.test.ts b/tests/native/notifications.test.ts index 67c62218e..4400ca639 100644 --- a/tests/native/notifications.test.ts +++ b/tests/native/notifications.test.ts @@ -142,6 +142,6 @@ test("bare /dcp emits openPanel instead of registering a second slash command", prompt: { text: "" }, delivery: "ui", }) - assert.deepEqual(mock.rpcEvents, [{ name: "openPanel", data: {} }]) + assert.deepEqual(mock.rpcEvents, [{ name: "openPanel", data: { sessionID: "ses_1" } }]) await cleanup?.() }) diff --git a/tests/native/rpc.test.ts b/tests/native/rpc.test.ts index ae33ce984..2d58aebeb 100644 --- a/tests/native/rpc.test.ts +++ b/tests/native/rpc.test.ts @@ -8,6 +8,13 @@ test("rpc definition uses the dcp namespace", () => { assert.deepEqual(Object.keys(rpc.events), ["notification", "openPanel"]) }) +test("openPanel events are scoped to a session", () => { + assert.deepEqual(rpc.events.openPanel.schema.parse({ sessionID: "ses_1" }), { + sessionID: "ses_1", + }) + assert.throws(() => rpc.events.openPanel.schema.parse({})) +}) + test("status method schemas validate their payloads", () => { assert.deepEqual(rpc.methods.status.input.parse({}), {}) assert.deepEqual(rpc.methods.status.output.parse({ enabled: true }), { enabled: true }) diff --git a/tui.tsx b/tui.tsx index fd9cf7947..d0a977dc3 100644 --- a/tui.tsx +++ b/tui.tsx @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later /** @jsxImportSource @opentui/solid */ import type { Plugin } from "@opencode/plugin/tui" From cab3c667d09bc2733888d1ff631e7564a44f46f9 Mon Sep 17 00:00:00 2001 From: mbarnett Date: Thu, 19 Nov 2026 10:30:19 -0500 Subject: [PATCH 3/3] fix: retain undated history entries using real neighbouring timestamps Entries without time.created were silently dropped from the compress tool's message view. Resolve a timestamp from an existing neighbouring entry instead of inventing one; apply the same lookup in the native message projection. --- lib/native/messages.ts | 43 ++++++++++++++++++++++++++++-------- tests/native/history.test.ts | 30 +++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 9 deletions(-) diff --git a/lib/native/messages.ts b/lib/native/messages.ts index e8d89eeb3..2c1b48991 100644 --- a/lib/native/messages.ts +++ b/lib/native/messages.ts @@ -8,25 +8,44 @@ type Session = Awaited> type Entry = History[number] type Part = WithParts["parts"][number] +/** + * Resolve a timestamp from real values already present in the session. An entry + * that lacks `time.created` borrows the nearest neighbouring entry's timestamp + * instead of being dropped; we never invent a value that the session did not + * contain. Returns undefined only when no timestamp exists anywhere in the list. + */ +function resolveCreated(entries: readonly Entry[], index: number): number | undefined { + const direct = entries[index]?.time?.created + if (typeof direct === "number" && Number.isFinite(direct)) return direct + for (let i = index - 1; i >= 0; i--) { + const value = entries[i]?.time?.created + if (typeof value === "number" && Number.isFinite(value)) return value + } + for (let i = index + 1; i < entries.length; i++) { + const value = entries[i]?.time?.created + if (typeof value === "number" && Number.isFinite(value)) return value + } + return undefined +} + /** * Build engine metadata from a real stored session entry. Returns undefined when - * the entry is missing or lacks the fields the shared engine requires. We never - * synthesize timestamps, token counts, model identity, or message IDs here: - * fabricated values previously fed compaction detection and nudge thresholds - * with data that did not exist in the session. + * the entry is missing or no real timestamp can be resolved. Token counts, model + * identity and message IDs are always taken from the entry/session verbatim. */ function info( entry: Entry | undefined, session: Session, role: string, + created: number | undefined, ): WithParts["info"] | undefined { - if (!entry || typeof entry.time?.created !== "number") return undefined + if (!entry || created === undefined) return undefined const model = entry.type === "assistant" ? entry.model : session.model return { id: entry.id, role, sessionID: session.id, - time: { created: entry.time.created }, + time: { created }, agent: entry.type === "assistant" ? entry.agent : session.agent, model: model ? { providerID: model.providerID, modelID: model.id, variant: model.variant } @@ -40,10 +59,10 @@ function info( /** Project stored entries into the engine's working shape for the compress tool. */ export function history(entries: History, session: Session): WithParts[] { - return entries.flatMap((entry): WithParts[] => { + return entries.flatMap((entry, index): WithParts[] => { const role = entry.type === "assistant" || entry.type === "compaction" ? "assistant" : "user" - const meta = info(entry, session, role) + const meta = info(entry, session, role, resolveCreated(entries, index)) if (!meta) return [] const base = { sessionID: session.id, messageID: entry.id } if (entry.type === "assistant") { @@ -110,6 +129,7 @@ function output(content: ReadonlyArray<{ type: string; text?: string }>): unknow */ export function view(native: Message[], entries: History, session: Session) { const byID = new Map(entries.map((entry) => [entry.id, entry])) + const indexById = new Map(entries.map((entry, index) => [entry.id, index])) const results = new Map() const owners = new Map() const links = new Map() @@ -124,7 +144,12 @@ export function view(native: Message[], entries: History, session: Session) { if (!message.id || !["user", "assistant"].includes(message.role)) continue const entry = byID.get(message.id) if (!entry || entry.type === "compaction") continue - const meta = info(entry, session, message.role) + const meta = info( + entry, + session, + message.role, + resolveCreated(entries, indexById.get(message.id) ?? 0), + ) if (!meta) continue const base = { sessionID: session.id, messageID: message.id } const parts: Part[] = [] diff --git a/tests/native/history.test.ts b/tests/native/history.test.ts index c6f25b63b..f009e72d5 100644 --- a/tests/native/history.test.ts +++ b/tests/native/history.test.ts @@ -126,3 +126,33 @@ test("history marks completed compactions as summary messages", () => { assert.equal(summary.info.summary, true) assert.equal(summary.parts.length, 0) }) + +test("history retains an entry missing a timestamp using a real neighbouring timestamp", () => { + const undated: any[] = [ + { id: "m1", type: "user", time: { created: 1000 }, text: "first", skills: [] }, + { id: "m2", type: "user", text: "second", skills: [] }, + { id: "m3", type: "user", time: { created: 3000 }, text: "third", skills: [] }, + ] + const messages = history(undated, session as any) + assert.equal(messages.length, 3) + assert.equal(messages[1]!.info.id, "m2") + assert.equal(messages[1]!.info.time.created, 1000) +}) + +test("history falls back to the next real timestamp for an undated first entry", () => { + const undated: any[] = [ + { id: "m1", type: "user", text: "first", skills: [] }, + { id: "m2", type: "user", time: { created: 2000 }, text: "second", skills: [] }, + ] + const messages = history(undated, session as any) + assert.equal(messages.length, 2) + assert.equal(messages[0]!.info.time.created, 2000) +}) + +test("history drops entries when the session has no real timestamps at all", () => { + const messages = history( + [{ id: "m1", type: "user", text: "first", skills: [] }] as any, + session as any, + ) + assert.equal(messages.length, 0) +})