From f66e5dba9bca14b420438bd02170df06bafa3617 Mon Sep 17 00:00:00 2001 From: can1357 Date: Fri, 23 Jan 2026 23:50:31 +0100 Subject: [PATCH] build(config): refactored build and TypeScript configuration with Bun loaders - Removed WASM generation script; use Bun `wasm?raw` loader for imports. - Added bunfig.toml with loaders for `.md`, `.py`, and `.wasm?raw` text imports. - Added types/assets/index.d.ts for global TypeScript module declarations. - Unified TypeScript configuration with tsgo-based checking across monorepo. - Removed build and WASM steps from install and publish pipelines. --- .github/workflows/ci.yml | 5 +- bun.lock | 241 +- bunfig.toml | 8 + package.json | 8 +- packages/agent/package.json | 11 +- packages/agent/test/agent-loop.test.ts | 2 +- packages/agent/test/agent.test.ts | 6 +- packages/agent/test/e2e.test.ts | 3 +- packages/agent/tsconfig.build.json | 8 +- packages/agent/tsconfig.json | 17 +- packages/agent/tsconfig.publish.json | 10 +- packages/ai/package.json | 40 +- packages/ai/src/providers/amazon-bedrock.ts | 10 +- packages/ai/src/providers/anthropic.ts | 14 +- packages/ai/src/providers/cursor.ts | 12 +- .../src/providers/google-gemini-cli-usage.ts | 4 +- .../ai/src/providers/google-gemini-cli.ts | 10 +- packages/ai/src/providers/google-shared.ts | 4 +- packages/ai/src/providers/google-vertex.ts | 10 +- packages/ai/src/providers/google.ts | 12 +- .../src/providers/openai-codex-responses.ts | 36 +- .../ai/src/providers/openai-completions.ts | 34 +- packages/ai/src/providers/openai-responses.ts | 38 +- .../ai/src/providers/transform-messages.ts | 2 +- packages/ai/src/usage/claude.ts | 2 +- packages/ai/src/usage/github-copilot.ts | 2 +- packages/ai/src/usage/google-antigravity.ts | 4 +- packages/ai/src/usage/openai-codex.ts | 4 +- packages/ai/src/usage/zai.ts | 2 +- packages/ai/src/utils/event-stream.ts | 2 +- packages/ai/src/utils/oauth/github-copilot.ts | 2 +- packages/ai/src/utils/overflow.ts | 2 +- packages/ai/src/utils/validation.ts | 2 +- packages/ai/test/abort.test.ts | 160 +- packages/ai/test/context-overflow.test.ts | 24 +- .../ai/test/duplicate-tool-results.test.ts | 2 +- packages/ai/test/empty.test.ts | 462 ++-- .../ai/test/google-thinking-signature.test.ts | 2 +- packages/ai/test/handoff.test.ts | 13 +- packages/ai/test/image-limits.test.ts | 999 ++++---- packages/ai/test/image-tool-result.test.ts | 166 +- packages/ai/test/oauth.ts | 20 + packages/ai/test/openai-codex-include.test.ts | 2 +- packages/ai/test/openai-codex.test.ts | 2 +- packages/ai/test/stream.test.ts | 1235 +++++++--- packages/ai/test/tokens.test.ts | 128 +- .../ai/test/tool-call-without-result.test.ts | 128 +- packages/ai/test/total-tokens.test.ts | 88 +- packages/ai/test/unicode-surrogate.test.ts | 348 ++- packages/ai/test/xhigh.test.ts | 5 +- packages/ai/test/zen.test.ts | 5 +- packages/ai/tsconfig.build.json | 8 +- packages/ai/tsconfig.json | 17 +- packages/ai/tsconfig.publish.json | 10 +- packages/coding-agent/CHANGELOG.md | 6 +- packages/coding-agent/bunfig.toml | 8 + packages/coding-agent/package.json | 50 +- .../coding-agent/scripts/generate-wasm-b64.ts | 24 - packages/coding-agent/src/cli/args.ts | 4 +- packages/coding-agent/src/cli/config-cli.ts | 8 +- .../coding-agent/src/cli/file-processor.ts | 6 +- packages/coding-agent/src/cli/list-models.ts | 4 +- packages/coding-agent/src/cli/plugin-cli.ts | 6 +- .../coding-agent/src/cli/session-picker.ts | 4 +- packages/coding-agent/src/cli/setup-cli.ts | 4 +- packages/coding-agent/src/cli/stats-cli.ts | 4 +- packages/coding-agent/src/cli/update-cli.ts | 4 +- .../coding-agent/src/commit/agentic/agent.ts | 28 +- .../src/commit/agentic/fallback.ts | 4 +- .../coding-agent/src/commit/agentic/index.ts | 39 +- .../coding-agent/src/commit/agentic/state.ts | 7 +- .../src/commit/agentic/tools/analyze-file.ts | 24 +- .../src/commit/agentic/tools/git-file-diff.ts | 6 +- .../src/commit/agentic/tools/git-hunk.ts | 6 +- .../src/commit/agentic/tools/git-overview.ts | 8 +- .../src/commit/agentic/tools/index.ts | 28 +- .../commit/agentic/tools/propose-changelog.ts | 6 +- .../commit/agentic/tools/propose-commit.ts | 14 +- .../commit/agentic/tools/recent-commits.ts | 4 +- .../src/commit/agentic/tools/split-commit.ts | 20 +- .../src/commit/agentic/topo-sort.ts | 2 +- .../src/commit/agentic/trivial.ts | 2 +- .../src/commit/agentic/validation.ts | 6 +- .../src/commit/analysis/conventional.ts | 12 +- .../coding-agent/src/commit/analysis/index.ts | 8 +- .../coding-agent/src/commit/analysis/scope.ts | 4 +- .../src/commit/analysis/summary.ts | 8 +- .../src/commit/analysis/validation.ts | 2 +- .../src/commit/changelog/detect.ts | 2 +- .../src/commit/changelog/generate.ts | 8 +- .../src/commit/changelog/index.ts | 8 +- .../src/commit/changelog/parse.ts | 2 +- packages/coding-agent/src/commit/cli.ts | 2 +- packages/coding-agent/src/commit/git/diff.ts | 2 +- packages/coding-agent/src/commit/git/index.ts | 13 +- packages/coding-agent/src/commit/index.ts | 2 +- .../src/commit/map-reduce/index.ts | 12 +- .../src/commit/map-reduce/map-phase.ts | 16 +- .../src/commit/map-reduce/reduce-phase.ts | 8 +- packages/coding-agent/src/commit/message.ts | 2 +- .../src/commit/model-selection.ts | 8 +- packages/coding-agent/src/commit/pipeline.ts | 32 +- .../coding-agent/src/config/keybindings.ts | 2 +- .../coding-agent/src/config/model-registry.ts | 2 +- .../coding-agent/src/config/model-resolver.ts | 2 +- .../src/config/prompt-templates.ts | 4 +- .../src/config/settings-manager.ts | 12 +- packages/coding-agent/src/cursor.ts | 2 +- .../coding-agent/src/discovery/agents-md.ts | 8 +- .../coding-agent/src/discovery/builtin.ts | 38 +- packages/coding-agent/src/discovery/claude.ts | 24 +- packages/coding-agent/src/discovery/cline.ts | 12 +- packages/coding-agent/src/discovery/codex.ts | 42 +- packages/coding-agent/src/discovery/cursor.ts | 18 +- packages/coding-agent/src/discovery/gemini.ts | 22 +- packages/coding-agent/src/discovery/github.ts | 12 +- .../coding-agent/src/discovery/helpers.ts | 8 +- packages/coding-agent/src/discovery/index.ts | 32 +- .../coding-agent/src/discovery/mcp-json.ts | 8 +- packages/coding-agent/src/discovery/ssh.ts | 8 +- packages/coding-agent/src/discovery/vscode.ts | 8 +- .../coding-agent/src/discovery/windsurf.ts | 12 +- packages/coding-agent/src/exa/company.ts | 2 +- packages/coding-agent/src/exa/index.ts | 4 +- packages/coding-agent/src/exa/linkedin.ts | 2 +- packages/coding-agent/src/exa/mcp-client.ts | 4 +- packages/coding-agent/src/exa/render.ts | 12 +- packages/coding-agent/src/exa/researcher.ts | 2 +- packages/coding-agent/src/exa/search.ts | 2 +- packages/coding-agent/src/exa/websets.ts | 2 +- .../coding-agent/src/exec/bash-executor.ts | 6 +- .../coding-agent/src/export/custom-share.ts | 2 +- .../coding-agent/src/export/html/index.ts | 6 +- packages/coding-agent/src/export/ttsr.ts | 4 +- .../custom-commands/bundled/review/index.ts | 8 +- .../extensibility/custom-commands/loader.ts | 4 +- .../extensibility/custom-commands/types.ts | 2 +- .../src/extensibility/custom-tools/loader.ts | 16 +- .../src/extensibility/custom-tools/types.ts | 12 +- .../src/extensibility/custom-tools/wrapper.ts | 2 +- .../src/extensibility/extensions/loader.ts | 14 +- .../src/extensibility/extensions/runner.ts | 6 +- .../src/extensibility/extensions/types.ts | 38 +- .../src/extensibility/extensions/wrapper.ts | 2 +- .../src/extensibility/hooks/index.ts | 2 +- .../src/extensibility/hooks/loader.ts | 12 +- .../src/extensibility/hooks/runner.ts | 8 +- .../src/extensibility/hooks/types.ts | 26 +- .../src/extensibility/plugins/doctor.ts | 2 +- .../src/extensibility/plugins/installer.ts | 2 +- .../src/extensibility/plugins/paths.ts | 2 +- .../coding-agent/src/extensibility/skills.ts | 15 +- .../src/extensibility/slash-commands.ts | 12 +- packages/coding-agent/src/index.ts | 92 +- .../src/internal-urls/rule-protocol.ts | 2 +- .../src/internal-urls/skill-protocol.ts | 2 +- packages/coding-agent/src/ipy/executor.ts | 8 +- .../src/ipy/gateway-coordinator.ts | 6 +- packages/coding-agent/src/ipy/kernel.ts | 6 +- packages/coding-agent/src/lsp/client.ts | 2 +- .../src/lsp/clients/biome-client.ts | 2 +- .../coding-agent/src/lsp/clients/index.ts | 2 +- .../src/lsp/clients/lsp-linter-client.ts | 8 +- packages/coding-agent/src/lsp/config.ts | 2 +- packages/coding-agent/src/lsp/index.ts | 12 +- packages/coding-agent/src/lsp/render.ts | 11 +- packages/coding-agent/src/lsp/utils.ts | 2 +- packages/coding-agent/src/main.ts | 2 +- packages/coding-agent/src/mcp/config.ts | 6 +- packages/coding-agent/src/mcp/loader.ts | 4 +- packages/coding-agent/src/mcp/manager.ts | 2 +- packages/coding-agent/src/mcp/tool-bridge.ts | 8 +- packages/coding-agent/src/mcp/tool-cache.ts | 2 +- .../coding-agent/src/mcp/transports/http.ts | 2 +- .../coding-agent/src/mcp/transports/stdio.ts | 2 +- packages/coding-agent/src/migrations.ts | 4 +- .../src/modes/components/armin.ts | 2 +- .../src/modes/components/assistant-message.ts | 4 +- .../src/modes/components/bash-execution.ts | 6 +- .../src/modes/components/bordered-loader.ts | 2 +- .../components/branch-summary-message.ts | 4 +- .../components/compaction-summary-message.ts | 4 +- .../src/modes/components/custom-message.ts | 6 +- .../coding-agent/src/modes/components/diff.ts | 2 +- .../src/modes/components/dynamic-border.ts | 2 +- .../extensions/extension-dashboard.ts | 6 +- .../components/extensions/extension-list.ts | 4 +- .../components/extensions/inspector-panel.ts | 2 +- .../components/extensions/state-manager.ts | 24 +- .../src/modes/components/extensions/types.ts | 2 +- .../src/modes/components/footer.ts | 6 +- .../src/modes/components/history-search.ts | 4 +- .../src/modes/components/hook-editor.ts | 2 +- .../src/modes/components/hook-input.ts | 2 +- .../src/modes/components/hook-message.ts | 6 +- .../src/modes/components/hook-selector.ts | 2 +- .../src/modes/components/keybinding-hints.ts | 4 +- .../src/modes/components/login-dialog.ts | 2 +- .../src/modes/components/model-selector.ts | 10 +- .../src/modes/components/oauth-selector.ts | 4 +- .../src/modes/components/plugin-settings.ts | 6 +- .../src/modes/components/python-execution.ts | 6 +- .../modes/components/queue-mode-selector.ts | 2 +- .../src/modes/components/read-tool-group.ts | 4 +- .../src/modes/components/session-selector.ts | 6 +- .../src/modes/components/settings-defs.ts | 4 +- .../src/modes/components/settings-selector.ts | 4 +- .../modes/components/show-images-selector.ts | 2 +- .../components/status-line-segment-editor.ts | 4 +- .../src/modes/components/status-line.ts | 6 +- .../modes/components/status-line/segments.ts | 4 +- .../components/status-line/separators.ts | 2 +- .../src/modes/components/status-line/types.ts | 4 +- .../src/modes/components/theme-selector.ts | 2 +- .../src/modes/components/thinking-selector.ts | 2 +- .../src/modes/components/todo-display.ts | 4 +- .../src/modes/components/todo-reminder.ts | 4 +- .../src/modes/components/tool-execution.ts | 17 +- .../src/modes/components/tree-selector.ts | 6 +- .../src/modes/components/ttsr-notification.ts | 4 +- .../modes/components/user-message-selector.ts | 2 +- .../src/modes/components/user-message.ts | 2 +- .../src/modes/components/welcome.ts | 4 +- .../modes/controllers/command-controller.ts | 30 +- .../src/modes/controllers/event-controller.ts | 22 +- .../controllers/extension-ui-controller.ts | 28 +- .../src/modes/controllers/input-controller.ts | 12 +- .../modes/controllers/selector-controller.ts | 38 +- .../src/modes/interactive-mode.ts | 20 +- packages/coding-agent/src/modes/print-mode.ts | 2 +- .../coding-agent/src/modes/rpc/rpc-client.ts | 6 +- .../coding-agent/src/modes/rpc/rpc-mode.ts | 6 +- .../coding-agent/src/modes/rpc/rpc-types.ts | 6 +- .../coding-agent/src/modes/theme/theme.ts | 2 +- packages/coding-agent/src/modes/types.ts | 16 +- .../src/modes/utils/ui-helpers.ts | 28 +- packages/coding-agent/src/patch/applicator.ts | 2 +- packages/coding-agent/src/patch/diff.ts | 2 +- packages/coding-agent/src/patch/index.ts | 16 +- packages/coding-agent/src/patch/shared.ts | 20 +- packages/coding-agent/src/sdk.ts | 34 +- .../coding-agent/src/session/agent-session.ts | 54 +- .../coding-agent/src/session/agent-storage.ts | 4 +- .../coding-agent/src/session/auth-storage.ts | 2 +- .../compaction/branch-summarization.ts | 12 +- .../src/session/compaction/compaction.ts | 22 +- .../src/session/compaction/utils.ts | 8 +- .../src/session/history-storage.ts | 2 +- packages/coding-agent/src/session/messages.ts | 4 +- .../src/session/session-manager.ts | 4 +- .../src/session/storage-migration.ts | 2 +- .../src/session/streaming-output.ts | 2 +- .../src/ssh/connection-manager.ts | 2 +- packages/coding-agent/src/ssh/ssh-executor.ts | 2 +- packages/coding-agent/src/ssh/sshfs-mount.ts | 2 +- packages/coding-agent/src/system-prompt.ts | 22 +- packages/coding-agent/src/task/agents.ts | 16 +- packages/coding-agent/src/task/commands.ts | 10 +- packages/coding-agent/src/task/discovery.ts | 6 +- packages/coding-agent/src/task/executor.ts | 20 +- packages/coding-agent/src/task/index.ts | 10 +- packages/coding-agent/src/task/render.ts | 14 +- .../src/task/subprocess-tool-registry.ts | 2 +- .../coding-agent/src/task/worker-protocol.ts | 6 +- packages/coding-agent/src/task/worker.ts | 31 +- packages/coding-agent/src/tools/ask.ts | 10 +- .../src/tools/bash-interceptor.ts | 5 +- packages/coding-agent/src/tools/bash.ts | 18 +- packages/coding-agent/src/tools/calculator.ts | 10 +- packages/coding-agent/src/tools/complete.ts | 2 +- packages/coding-agent/src/tools/context.ts | 4 +- packages/coding-agent/src/tools/fetch.ts | 24 +- packages/coding-agent/src/tools/find.ts | 17 +- .../coding-agent/src/tools/gemini-image.ts | 12 +- packages/coding-agent/src/tools/grep.ts | 18 +- packages/coding-agent/src/tools/index.ts | 35 +- packages/coding-agent/src/tools/list-limit.ts | 2 +- packages/coding-agent/src/tools/ls.ts | 10 +- packages/coding-agent/src/tools/notebook.ts | 8 +- .../coding-agent/src/tools/output-meta.ts | 6 +- .../coding-agent/src/tools/output-utils.ts | 2 +- packages/coding-agent/src/tools/python.ts | 22 +- packages/coding-agent/src/tools/read.ts | 24 +- .../coding-agent/src/tools/render-utils.ts | 4 +- packages/coding-agent/src/tools/renderers.ts | 12 +- packages/coding-agent/src/tools/review.ts | 4 +- packages/coding-agent/src/tools/ssh.ts | 26 +- packages/coding-agent/src/tools/todo-write.ts | 12 +- .../coding-agent/src/tools/tool-result.ts | 11 +- packages/coding-agent/src/tools/write.ts | 21 +- packages/coding-agent/src/tui/code-cell.ts | 9 +- packages/coding-agent/src/tui/file-list.ts | 4 +- packages/coding-agent/src/tui/output-block.ts | 2 +- packages/coding-agent/src/tui/status-line.ts | 2 +- packages/coding-agent/src/tui/tree-list.ts | 4 +- packages/coding-agent/src/tui/types.ts | 2 +- packages/coding-agent/src/tui/utils.ts | 2 +- packages/coding-agent/src/utils/changelog.ts | 2 +- .../coding-agent/src/utils/file-mentions.ts | 13 +- .../coding-agent/src/utils/image-convert.ts | 2 +- .../coding-agent/src/utils/image-resize.ts | 2 +- packages/coding-agent/src/utils/shell.ts | 2 +- .../coding-agent/src/utils/title-generator.ts | 8 +- .../coding-agent/src/utils/tools-manager.ts | 2 +- .../coding-agent/src/vendor/photon/index.js | 2144 +++++++++-------- .../src/vendor/photon/photon_rs_bg.wasm | 4 +- .../src/web/scrapers/choosealicense.ts | 2 +- .../coding-agent/src/web/scrapers/twitter.ts | 2 +- .../coding-agent/src/web/scrapers/types.ts | 2 +- .../coding-agent/src/web/scrapers/utils.ts | 2 +- .../coding-agent/src/web/scrapers/youtube.ts | 4 +- packages/coding-agent/src/web/search/auth.ts | 12 +- packages/coding-agent/src/web/search/index.ts | 29 +- .../src/web/search/providers/anthropic.ts | 11 +- .../src/web/search/providers/exa.ts | 4 +- .../src/web/search/providers/perplexity.ts | 4 +- .../coding-agent/src/web/search/render.ts | 12 +- .../test/core/apply-patch-regression.test.ts | 2 +- .../test/core/python-kernel-env.test.ts | 2 +- packages/coding-agent/tsconfig.build.json | 8 +- packages/coding-agent/tsconfig.check.json | 4 +- packages/coding-agent/tsconfig.json | 22 +- packages/coding-agent/tsconfig.publish.json | 11 +- packages/pi-utils/package.json | 6 +- packages/pi-utils/tsconfig.build.json | 8 +- packages/pi-utils/tsconfig.json | 8 + packages/pi-utils/tsconfig.publish.json | 10 +- packages/react-edit-benchmark/package.json | 3 +- packages/react-edit-benchmark/tsconfig.json | 4 +- packages/stats/package.json | 8 +- packages/stats/src/index.ts | 2 +- packages/stats/src/server.ts | 66 +- packages/stats/tsconfig.build.json | 8 +- packages/stats/tsconfig.json | 6 +- packages/stats/tsconfig.publish.json | 10 +- packages/tui/package.json | 22 +- packages/tui/src/components/box.ts | 4 +- .../tui/src/components/cancellable-loader.ts | 2 +- packages/tui/src/components/editor.ts | 16 +- packages/tui/src/components/image.ts | 4 +- packages/tui/src/components/input.ts | 6 +- packages/tui/src/components/loader.ts | 2 +- packages/tui/src/components/markdown.ts | 10 +- packages/tui/src/components/select-list.ts | 8 +- packages/tui/src/components/settings-list.ts | 6 +- packages/tui/src/components/spacer.ts | 2 +- packages/tui/src/components/tab-bar.ts | 6 +- packages/tui/src/components/text.ts | 4 +- packages/tui/src/components/truncated-text.ts | 4 +- packages/tui/tsconfig.build.json | 8 +- packages/tui/tsconfig.json | 17 +- packages/tui/tsconfig.publish.json | 10 +- tsconfig.base.json | 25 +- tsconfig.json | 24 +- types/assets/index.d.ts | 19 + 355 files changed, 5039 insertions(+), 4293 deletions(-) create mode 100644 bunfig.toml create mode 100644 packages/coding-agent/bunfig.toml delete mode 100644 packages/coding-agent/scripts/generate-wasm-b64.ts create mode 100644 packages/pi-utils/tsconfig.json create mode 100644 types/assets/index.d.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8967565e1..d5f54dea5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: sudo ln -sf /usr/bin/convert /usr/local/bin/magick - run: bun install --frozen-lockfile - run: bun run check - - run: bun test --only-failures + - run: bun run test - name: CLI smoke test run: | bun packages/coding-agent/src/cli.ts --version @@ -67,8 +67,7 @@ jobs: path: ~/.bun/install/cache key: bun-${{ runner.os }}-${{ hashFiles('**/bun.lock') }} - run: bun install --frozen-lockfile - - name: Generate WASM base64 - run: bun packages/coding-agent/scripts/generate-wasm-b64.ts + - name: Build binaries run: | cd packages/coding-agent diff --git a/bun.lock b/bun.lock index ddc0dc2f7..ecbbc0f42 100644 --- a/bun.lock +++ b/bun.lock @@ -31,7 +31,6 @@ "devDependencies": { "@sinclair/typebox": "^0.34.46", "@types/node": "^24.3.0", - "vitest": "^3.2.4", }, }, "packages/ai": { @@ -66,7 +65,7 @@ "name": "@oh-my-pi/pi-coding-agent", "version": "8.1.0", "bin": { - "omp": "src/cli.ts", + "omp": "dist/cli.js", }, "dependencies": { "@oh-my-pi/omp-stats": "workspace:*", @@ -100,26 +99,6 @@ "ms": "^2.1.3", }, }, - "packages/stats": { - "name": "@oh-my-pi/omp-stats", - "version": "8.1.0", - "bin": { - "omp-stats": "./src/index.ts", - }, - "dependencies": { - "@oh-my-pi/pi-ai": "workspace:*", - "date-fns": "^4.1.0", - "lucide-react": "^0.562.0", - "react": "^19.2.3", - "react-dom": "^19.2.3", - "recharts": "^3.6.0", - }, - "devDependencies": { - "@types/node": "^24.3.0", - "@types/react": "^19.2.9", - "@types/react-dom": "^19.2.3", - }, - }, "packages/pi-utils": { "name": "@oh-my-pi/pi-utils", "version": "8.1.0", @@ -149,6 +128,26 @@ "@types/diff": "^7.0.2", }, }, + "packages/stats": { + "name": "@oh-my-pi/omp-stats", + "version": "8.1.0", + "bin": { + "omp-stats": "./dist/index.js", + }, + "dependencies": { + "@oh-my-pi/pi-ai": "workspace:*", + "date-fns": "^4.1.0", + "lucide-react": "^0.562.0", + "react": "^19.2.3", + "react-dom": "^19.2.3", + "recharts": "^3.6.0", + }, + "devDependencies": { + "@types/node": "^24.3.0", + "@types/react": "^19.2.9", + "@types/react-dom": "^19.2.3", + }, + }, "packages/tui": { "name": "@oh-my-pi/pi-tui", "version": "8.1.0", @@ -272,58 +271,6 @@ "@dabh/diagnostics": ["@dabh/diagnostics@2.0.8", "", { "dependencies": { "@so-ric/colorspace": "^1.1.6", "enabled": "2.0.x", "kuler": "^2.0.0" } }, "sha512-R4MSXTVnuMzGD7bzHdW2ZhhdPC/igELENcq5IjEverBvq5hn1SXCWcsi6eSsdWP0/Ur+SItRRjAktmdoX/8R/Q=="], - "@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.27.2", "", { "os": "aix", "cpu": "ppc64" }, "sha512-GZMB+a0mOMZs4MpDbj8RJp4cw+w1WV5NYD6xzgvzUJ5Ek2jerwfO2eADyI6ExDSUED+1X8aMbegahsJi+8mgpw=="], - - "@esbuild/android-arm": ["@esbuild/android-arm@0.27.2", "", { "os": "android", "cpu": "arm" }, "sha512-DVNI8jlPa7Ujbr1yjU2PfUSRtAUZPG9I1RwW4F4xFB1Imiu2on0ADiI/c3td+KmDtVKNbi+nffGDQMfcIMkwIA=="], - - "@esbuild/android-arm64": ["@esbuild/android-arm64@0.27.2", "", { "os": "android", "cpu": "arm64" }, "sha512-pvz8ZZ7ot/RBphf8fv60ljmaoydPU12VuXHImtAs0XhLLw+EXBi2BLe3OYSBslR4rryHvweW5gmkKFwTiFy6KA=="], - - "@esbuild/android-x64": ["@esbuild/android-x64@0.27.2", "", { "os": "android", "cpu": "x64" }, "sha512-z8Ank4Byh4TJJOh4wpz8g2vDy75zFL0TlZlkUkEwYXuPSgX8yzep596n6mT7905kA9uHZsf/o2OJZubl2l3M7A=="], - - "@esbuild/darwin-arm64": ["@esbuild/darwin-arm64@0.27.2", "", { "os": "darwin", "cpu": "arm64" }, "sha512-davCD2Zc80nzDVRwXTcQP/28fiJbcOwvdolL0sOiOsbwBa72kegmVU0Wrh1MYrbuCL98Omp5dVhQFWRKR2ZAlg=="], - - "@esbuild/darwin-x64": ["@esbuild/darwin-x64@0.27.2", "", { "os": "darwin", "cpu": "x64" }, "sha512-ZxtijOmlQCBWGwbVmwOF/UCzuGIbUkqB1faQRf5akQmxRJ1ujusWsb3CVfk/9iZKr2L5SMU5wPBi1UWbvL+VQA=="], - - "@esbuild/freebsd-arm64": ["@esbuild/freebsd-arm64@0.27.2", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-lS/9CN+rgqQ9czogxlMcBMGd+l8Q3Nj1MFQwBZJyoEKI50XGxwuzznYdwcav6lpOGv5BqaZXqvBSiB/kJ5op+g=="], - - "@esbuild/freebsd-x64": ["@esbuild/freebsd-x64@0.27.2", "", { "os": "freebsd", "cpu": "x64" }, "sha512-tAfqtNYb4YgPnJlEFu4c212HYjQWSO/w/h/lQaBK7RbwGIkBOuNKQI9tqWzx7Wtp7bTPaGC6MJvWI608P3wXYA=="], - - "@esbuild/linux-arm": ["@esbuild/linux-arm@0.27.2", "", { "os": "linux", "cpu": "arm" }, "sha512-vWfq4GaIMP9AIe4yj1ZUW18RDhx6EPQKjwe7n8BbIecFtCQG4CfHGaHuh7fdfq+y3LIA2vGS/o9ZBGVxIDi9hw=="], - - "@esbuild/linux-arm64": ["@esbuild/linux-arm64@0.27.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-hYxN8pr66NsCCiRFkHUAsxylNOcAQaxSSkHMMjcpx0si13t1LHFphxJZUiGwojB1a/Hd5OiPIqDdXONia6bhTw=="], - - "@esbuild/linux-ia32": ["@esbuild/linux-ia32@0.27.2", "", { "os": "linux", "cpu": "ia32" }, "sha512-MJt5BRRSScPDwG2hLelYhAAKh9imjHK5+NE/tvnRLbIqUWa+0E9N4WNMjmp/kXXPHZGqPLxggwVhz7QP8CTR8w=="], - - "@esbuild/linux-loong64": ["@esbuild/linux-loong64@0.27.2", "", { "os": "linux", "cpu": "none" }, "sha512-lugyF1atnAT463aO6KPshVCJK5NgRnU4yb3FUumyVz+cGvZbontBgzeGFO1nF+dPueHD367a2ZXe1NtUkAjOtg=="], - - "@esbuild/linux-mips64el": ["@esbuild/linux-mips64el@0.27.2", "", { "os": "linux", "cpu": "none" }, "sha512-nlP2I6ArEBewvJ2gjrrkESEZkB5mIoaTswuqNFRv/WYd+ATtUpe9Y09RnJvgvdag7he0OWgEZWhviS1OTOKixw=="], - - "@esbuild/linux-ppc64": ["@esbuild/linux-ppc64@0.27.2", "", { "os": "linux", "cpu": "ppc64" }, "sha512-C92gnpey7tUQONqg1n6dKVbx3vphKtTHJaNG2Ok9lGwbZil6DrfyecMsp9CrmXGQJmZ7iiVXvvZH6Ml5hL6XdQ=="], - - "@esbuild/linux-riscv64": ["@esbuild/linux-riscv64@0.27.2", "", { "os": "linux", "cpu": "none" }, "sha512-B5BOmojNtUyN8AXlK0QJyvjEZkWwy/FKvakkTDCziX95AowLZKR6aCDhG7LeF7uMCXEJqwa8Bejz5LTPYm8AvA=="], - - "@esbuild/linux-s390x": ["@esbuild/linux-s390x@0.27.2", "", { "os": "linux", "cpu": "s390x" }, "sha512-p4bm9+wsPwup5Z8f4EpfN63qNagQ47Ua2znaqGH6bqLlmJ4bx97Y9JdqxgGZ6Y8xVTixUnEkoKSHcpRlDnNr5w=="], - - "@esbuild/linux-x64": ["@esbuild/linux-x64@0.27.2", "", { "os": "linux", "cpu": "x64" }, "sha512-uwp2Tip5aPmH+NRUwTcfLb+W32WXjpFejTIOWZFw/v7/KnpCDKG66u4DLcurQpiYTiYwQ9B7KOeMJvLCu/OvbA=="], - - "@esbuild/netbsd-arm64": ["@esbuild/netbsd-arm64@0.27.2", "", { "os": "none", "cpu": "arm64" }, "sha512-Kj6DiBlwXrPsCRDeRvGAUb/LNrBASrfqAIok+xB0LxK8CHqxZ037viF13ugfsIpePH93mX7xfJp97cyDuTZ3cw=="], - - "@esbuild/netbsd-x64": ["@esbuild/netbsd-x64@0.27.2", "", { "os": "none", "cpu": "x64" }, "sha512-HwGDZ0VLVBY3Y+Nw0JexZy9o/nUAWq9MlV7cahpaXKW6TOzfVno3y3/M8Ga8u8Yr7GldLOov27xiCnqRZf0tCA=="], - - "@esbuild/openbsd-arm64": ["@esbuild/openbsd-arm64@0.27.2", "", { "os": "openbsd", "cpu": "arm64" }, "sha512-DNIHH2BPQ5551A7oSHD0CKbwIA/Ox7+78/AWkbS5QoRzaqlev2uFayfSxq68EkonB+IKjiuxBFoV8ESJy8bOHA=="], - - "@esbuild/openbsd-x64": ["@esbuild/openbsd-x64@0.27.2", "", { "os": "openbsd", "cpu": "x64" }, "sha512-/it7w9Nb7+0KFIzjalNJVR5bOzA9Vay+yIPLVHfIQYG/j+j9VTH84aNB8ExGKPU4AzfaEvN9/V4HV+F+vo8OEg=="], - - "@esbuild/openharmony-arm64": ["@esbuild/openharmony-arm64@0.27.2", "", { "os": "none", "cpu": "arm64" }, "sha512-LRBbCmiU51IXfeXk59csuX/aSaToeG7w48nMwA6049Y4J4+VbWALAuXcs+qcD04rHDuSCSRKdmY63sruDS5qag=="], - - "@esbuild/sunos-x64": ["@esbuild/sunos-x64@0.27.2", "", { "os": "sunos", "cpu": "x64" }, "sha512-kMtx1yqJHTmqaqHPAzKCAkDaKsffmXkPHThSfRwZGyuqyIeBvf08KSsYXl+abf5HDAPMJIPnbBfXvP2ZC2TfHg=="], - - "@esbuild/win32-arm64": ["@esbuild/win32-arm64@0.27.2", "", { "os": "win32", "cpu": "arm64" }, "sha512-Yaf78O/B3Kkh+nKABUF++bvJv5Ijoy9AN1ww904rOXZFLWVc5OLOfL56W+C8F9xn5JQZa3UX6m+IktJnIb1Jjg=="], - - "@esbuild/win32-ia32": ["@esbuild/win32-ia32@0.27.2", "", { "os": "win32", "cpu": "ia32" }, "sha512-Iuws0kxo4yusk7sw70Xa2E2imZU5HoixzxfGCdxwBdhiDgt9vX9VUCBhqcwY7/uh//78A1hMkkROMJq9l27oLQ=="], - - "@esbuild/win32-x64": ["@esbuild/win32-x64@0.27.2", "", { "os": "win32", "cpu": "x64" }, "sha512-sRdU18mcKf7F+YgheI/zGf5alZatMUTKj/jNS6l744f9u3WFu4v7twcUI9vu4mknF4Y9aDlblIie0IM+5xxaqQ=="], - "@google/genai": ["@google/genai@1.34.0", "", { "dependencies": { "google-auth-library": "^10.3.0", "ws": "^8.18.0" }, "peerDependencies": { "@modelcontextprotocol/sdk": "^1.24.0" }, "optionalPeers": ["@modelcontextprotocol/sdk"] }, "sha512-vu53UMPvjmb7PGzlYu6Tzxso8Dfhn+a7eQFaS2uNemVtDZKwzSpJ5+ikqBbXplF7RGB1STcVDqCkPvquiwb2sw=="], "@hono/node-server": ["@hono/node-server@1.19.9", "", { "peerDependencies": { "hono": "^4" } }, "sha512-vHL6w3ecZsky+8P5MD+eFfaGTyCeOHUIFYMGpQGbrBTSmNNoxv0if69rEZ5giu36weC5saFuznL411gRX7bJDw=="], @@ -334,8 +281,6 @@ "@isaacs/cliui": ["@isaacs/cliui@8.0.2", "", { "dependencies": { "string-width": "^5.1.2", "string-width-cjs": "npm:string-width@^4.2.0", "strip-ansi": "^7.0.1", "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", "wrap-ansi": "^8.1.0", "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" } }, "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA=="], - "@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.5.5", "", {}, "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og=="], - "@mistralai/mistralai": ["@mistralai/mistralai@1.10.0", "", { "dependencies": { "zod": "^3.20.0", "zod-to-json-schema": "^3.24.1" } }, "sha512-tdIgWs4Le8vpvPiUEWne6tK0qbVc+jMenujnvTqOjogrJUsCSQhus0tHTU1avDDh5//Rq2dFgP9mWRAdIEoBqg=="], "@modelcontextprotocol/sdk": ["@modelcontextprotocol/sdk@1.25.3", "", { "dependencies": { "@hono/node-server": "^1.19.9", "ajv": "^8.17.1", "ajv-formats": "^3.0.1", "content-type": "^1.0.5", "cors": "^2.8.5", "cross-spawn": "^7.0.5", "eventsource": "^3.0.2", "eventsource-parser": "^3.0.0", "express": "^5.0.1", "express-rate-limit": "^7.5.0", "jose": "^6.1.1", "json-schema-typed": "^8.0.2", "pkce-challenge": "^5.0.0", "raw-body": "^3.0.0", "zod": "^3.25 || ^4.0", "zod-to-json-schema": "^3.25.0" }, "peerDependencies": { "@cfworker/json-schema": "^4.1.1" }, "optionalPeers": ["@cfworker/json-schema"] }, "sha512-vsAMBMERybvYgKbg/l4L1rhS7VXV1c0CtyJg72vwxONVX0l4ZfKVAnZEWTQixJGTzKnELjQ59e4NbdFDALRiAQ=="], @@ -366,56 +311,6 @@ "@reduxjs/toolkit": ["@reduxjs/toolkit@2.11.2", "", { "dependencies": { "@standard-schema/spec": "^1.0.0", "@standard-schema/utils": "^0.3.0", "immer": "^11.0.0", "redux": "^5.0.1", "redux-thunk": "^3.1.0", "reselect": "^5.1.0" }, "peerDependencies": { "react": "^16.9.0 || ^17.0.0 || ^18 || ^19", "react-redux": "^7.2.1 || ^8.1.3 || ^9.0.0" }, "optionalPeers": ["react", "react-redux"] }, "sha512-Kd6kAHTA6/nUpp8mySPqj3en3dm0tdMIgbttnQ1xFMVpufoj+ADi8pXLBsd4xzTRHQa7t/Jv8W5UnCuW4kuWMQ=="], - "@rollup/rollup-android-arm-eabi": ["@rollup/rollup-android-arm-eabi@4.56.0", "", { "os": "android", "cpu": "arm" }, "sha512-LNKIPA5k8PF1+jAFomGe3qN3bbIgJe/IlpDBwuVjrDKrJhVWywgnJvflMt/zkbVNLFtF1+94SljYQS6e99klnw=="], - - "@rollup/rollup-android-arm64": ["@rollup/rollup-android-arm64@4.56.0", "", { "os": "android", "cpu": "arm64" }, "sha512-lfbVUbelYqXlYiU/HApNMJzT1E87UPGvzveGg2h0ktUNlOCxKlWuJ9jtfvs1sKHdwU4fzY7Pl8sAl49/XaEk6Q=="], - - "@rollup/rollup-darwin-arm64": ["@rollup/rollup-darwin-arm64@4.56.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-EgxD1ocWfhoD6xSOeEEwyE7tDvwTgZc8Bss7wCWe+uc7wO8G34HHCUH+Q6cHqJubxIAnQzAsyUsClt0yFLu06w=="], - - "@rollup/rollup-darwin-x64": ["@rollup/rollup-darwin-x64@4.56.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-1vXe1vcMOssb/hOF8iv52A7feWW2xnu+c8BV4t1F//m9QVLTfNVpEdja5ia762j/UEJe2Z1jAmEqZAK42tVW3g=="], - - "@rollup/rollup-freebsd-arm64": ["@rollup/rollup-freebsd-arm64@4.56.0", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-bof7fbIlvqsyv/DtaXSck4VYQ9lPtoWNFCB/JY4snlFuJREXfZnm+Ej6yaCHfQvofJDXLDMTVxWscVSuQvVWUQ=="], - - "@rollup/rollup-freebsd-x64": ["@rollup/rollup-freebsd-x64@4.56.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-KNa6lYHloW+7lTEkYGa37fpvPq+NKG/EHKM8+G/g9WDU7ls4sMqbVRV78J6LdNuVaeeK5WB9/9VAFbKxcbXKYg=="], - - "@rollup/rollup-linux-arm-gnueabihf": ["@rollup/rollup-linux-arm-gnueabihf@4.56.0", "", { "os": "linux", "cpu": "arm" }, "sha512-E8jKK87uOvLrrLN28jnAAAChNq5LeCd2mGgZF+fGF5D507WlG/Noct3lP/QzQ6MrqJ5BCKNwI9ipADB6jyiq2A=="], - - "@rollup/rollup-linux-arm-musleabihf": ["@rollup/rollup-linux-arm-musleabihf@4.56.0", "", { "os": "linux", "cpu": "arm" }, "sha512-jQosa5FMYF5Z6prEpTCCmzCXz6eKr/tCBssSmQGEeozA9tkRUty/5Vx06ibaOP9RCrW1Pvb8yp3gvZhHwTDsJw=="], - - "@rollup/rollup-linux-arm64-gnu": ["@rollup/rollup-linux-arm64-gnu@4.56.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-uQVoKkrC1KGEV6udrdVahASIsaF8h7iLG0U0W+Xn14ucFwi6uS539PsAr24IEF9/FoDtzMeeJXJIBo5RkbNWvQ=="], - - "@rollup/rollup-linux-arm64-musl": ["@rollup/rollup-linux-arm64-musl@4.56.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-vLZ1yJKLxhQLFKTs42RwTwa6zkGln+bnXc8ueFGMYmBTLfNu58sl5/eXyxRa2RarTkJbXl8TKPgfS6V5ijNqEA=="], - - "@rollup/rollup-linux-loong64-gnu": ["@rollup/rollup-linux-loong64-gnu@4.56.0", "", { "os": "linux", "cpu": "none" }, "sha512-FWfHOCub564kSE3xJQLLIC/hbKqHSVxy8vY75/YHHzWvbJL7aYJkdgwD/xGfUlL5UV2SB7otapLrcCj2xnF1dg=="], - - "@rollup/rollup-linux-loong64-musl": ["@rollup/rollup-linux-loong64-musl@4.56.0", "", { "os": "linux", "cpu": "none" }, "sha512-z1EkujxIh7nbrKL1lmIpqFTc/sr0u8Uk0zK/qIEFldbt6EDKWFk/pxFq3gYj4Bjn3aa9eEhYRlL3H8ZbPT1xvA=="], - - "@rollup/rollup-linux-ppc64-gnu": ["@rollup/rollup-linux-ppc64-gnu@4.56.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-iNFTluqgdoQC7AIE8Q34R3AuPrJGJirj5wMUErxj22deOcY7XwZRaqYmB6ZKFHoVGqRcRd0mqO+845jAibKCkw=="], - - "@rollup/rollup-linux-ppc64-musl": ["@rollup/rollup-linux-ppc64-musl@4.56.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-MtMeFVlD2LIKjp2sE2xM2slq3Zxf9zwVuw0jemsxvh1QOpHSsSzfNOTH9uYW9i1MXFxUSMmLpeVeUzoNOKBaWg=="], - - "@rollup/rollup-linux-riscv64-gnu": ["@rollup/rollup-linux-riscv64-gnu@4.56.0", "", { "os": "linux", "cpu": "none" }, "sha512-in+v6wiHdzzVhYKXIk5U74dEZHdKN9KH0Q4ANHOTvyXPG41bajYRsy7a8TPKbYPl34hU7PP7hMVHRvv/5aCSew=="], - - "@rollup/rollup-linux-riscv64-musl": ["@rollup/rollup-linux-riscv64-musl@4.56.0", "", { "os": "linux", "cpu": "none" }, "sha512-yni2raKHB8m9NQpI9fPVwN754mn6dHQSbDTwxdr9SE0ks38DTjLMMBjrwvB5+mXrX+C0npX0CVeCUcvvvD8CNQ=="], - - "@rollup/rollup-linux-s390x-gnu": ["@rollup/rollup-linux-s390x-gnu@4.56.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-zhLLJx9nQPu7wezbxt2ut+CI4YlXi68ndEve16tPc/iwoylWS9B3FxpLS2PkmfYgDQtosah07Mj9E0khc3Y+vQ=="], - - "@rollup/rollup-linux-x64-gnu": ["@rollup/rollup-linux-x64-gnu@4.56.0", "", { "os": "linux", "cpu": "x64" }, "sha512-MVC6UDp16ZSH7x4rtuJPAEoE1RwS8N4oK9DLHy3FTEdFoUTCFVzMfJl/BVJ330C+hx8FfprA5Wqx4FhZXkj2Kw=="], - - "@rollup/rollup-linux-x64-musl": ["@rollup/rollup-linux-x64-musl@4.56.0", "", { "os": "linux", "cpu": "x64" }, "sha512-ZhGH1eA4Qv0lxaV00azCIS1ChedK0V32952Md3FtnxSqZTBTd6tgil4nZT5cU8B+SIw3PFYkvyR4FKo2oyZIHA=="], - - "@rollup/rollup-openbsd-x64": ["@rollup/rollup-openbsd-x64@4.56.0", "", { "os": "openbsd", "cpu": "x64" }, "sha512-O16XcmyDeFI9879pEcmtWvD/2nyxR9mF7Gs44lf1vGGx8Vg2DRNx11aVXBEqOQhWb92WN4z7fW/q4+2NYzCbBA=="], - - "@rollup/rollup-openharmony-arm64": ["@rollup/rollup-openharmony-arm64@4.56.0", "", { "os": "none", "cpu": "arm64" }, "sha512-LhN/Reh+7F3RCgQIRbgw8ZMwUwyqJM+8pXNT6IIJAqm2IdKkzpCh/V9EdgOMBKuebIrzswqy4ATlrDgiOwbRcQ=="], - - "@rollup/rollup-win32-arm64-msvc": ["@rollup/rollup-win32-arm64-msvc@4.56.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-kbFsOObXp3LBULg1d3JIUQMa9Kv4UitDmpS+k0tinPBz3watcUiV2/LUDMMucA6pZO3WGE27P7DsfaN54l9ing=="], - - "@rollup/rollup-win32-ia32-msvc": ["@rollup/rollup-win32-ia32-msvc@4.56.0", "", { "os": "win32", "cpu": "ia32" }, "sha512-vSSgny54D6P4vf2izbtFm/TcWYedw7f8eBrOiGGecyHyQB9q4Kqentjaj8hToe+995nob/Wv48pDqL5a62EWtg=="], - - "@rollup/rollup-win32-x64-gnu": ["@rollup/rollup-win32-x64-gnu@4.56.0", "", { "os": "win32", "cpu": "x64" }, "sha512-FeCnkPCTHQJFbiGG49KjV5YGW/8b9rrXAM2Mz2kiIoktq2qsJxRD5giEMEOD2lPdgs72upzefaUvS+nc8E3UzQ=="], - - "@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.56.0", "", { "os": "win32", "cpu": "x64" }, "sha512-H8AE9Ur/t0+1VXujj90w0HrSOuv0Nq9r1vSZF2t5km20NTfosQsGGUXDaKdQZzwuLts7IyL1fYT4hM95TI9c4g=="], - "@sinclair/typebox": ["@sinclair/typebox@0.34.48", "", {}, "sha512-kKJTNuK3AQOrgjjotVxMrCn1sUJwM76wMszfq1kdU4uYVJjvEWuFQ6HgvLt4Xz3fSmZlTOxJ/Ie13KnIcWQXFA=="], "@smithy/abort-controller": ["@smithy/abort-controller@4.2.8", "", { "dependencies": { "@smithy/types": "^4.12.0", "tslib": "^2.6.2" } }, "sha512-peuVfkYHAmS5ybKxWcfraK7WBBP0J+rkfUcbHJJKQ4ir3UAUNQI+Y4Vt/PqSzGqgloJ5O1dk7+WzNL8wcCSXbw=="], @@ -520,8 +415,6 @@ "@types/bun": ["@types/bun@1.3.6", "", { "dependencies": { "bun-types": "1.3.6" } }, "sha512-uWCv6FO/8LcpREhenN1d1b6fcspAB+cefwD7uti8C8VffIv0Um08TKMn98FynpTiU38+y2dUO55T11NgDt8VAA=="], - "@types/chai": ["@types/chai@5.2.3", "", { "dependencies": { "@types/deep-eql": "*", "assertion-error": "^2.0.1" } }, "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA=="], - "@types/d3-array": ["@types/d3-array@3.2.2", "", {}, "sha512-hOLWVbm7uRza0BYXpIIW5pxfrKe0W+D5lrFiAEYR+pb6w3N2SwSMaJbXdUfSEv+dT4MfHBLtn5js0LAWaO6otw=="], "@types/d3-color": ["@types/d3-color@3.1.3", "", {}, "sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A=="], @@ -540,12 +433,8 @@ "@types/d3-timer": ["@types/d3-timer@3.0.2", "", {}, "sha512-Ps3T8E8dZDam6fUyNiMkekK3XUsaUEik+idO9/YjPtfj2qruF8tFBXS7XhtE4iIXBLxhmLjP3SXpLhVf21I9Lw=="], - "@types/deep-eql": ["@types/deep-eql@4.0.2", "", {}, "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw=="], - "@types/diff": ["@types/diff@7.0.2", "", {}, "sha512-JSWRMozjFKsGlEjiiKajUjIJVKuKdE3oVy2DNtK+fUo8q82nhFZ2CPQwicAIkXrofahDXrWJ7mjelvZphMS98Q=="], - "@types/estree": ["@types/estree@1.0.8", "", {}, "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w=="], - "@types/mime-types": ["@types/mime-types@2.1.4", "", {}, "sha512-lfU4b34HOri+kAY5UheuFMWPDOI+OPceBSHZKp69gEyTL/mmJ4cnU6Y/rlme3UL3GyOn6Y42hyIEw0/q8sWx5w=="], "@types/ms": ["@types/ms@2.1.0", "", {}, "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA=="], @@ -584,20 +473,6 @@ "@typescript/vfs": ["@typescript/vfs@1.6.2", "", { "dependencies": { "debug": "^4.1.1" }, "peerDependencies": { "typescript": "*" } }, "sha512-hoBwJwcbKHmvd2QVebiytN1aELvpk9B74B4L1mFm/XT1Q/VOYAWl2vQ9AWRFtQq8zmz6enTpfTV8WRc4ATjW/g=="], - "@vitest/expect": ["@vitest/expect@3.2.4", "", { "dependencies": { "@types/chai": "^5.2.2", "@vitest/spy": "3.2.4", "@vitest/utils": "3.2.4", "chai": "^5.2.0", "tinyrainbow": "^2.0.0" } }, "sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig=="], - - "@vitest/mocker": ["@vitest/mocker@3.2.4", "", { "dependencies": { "@vitest/spy": "3.2.4", "estree-walker": "^3.0.3", "magic-string": "^0.30.17" }, "peerDependencies": { "msw": "^2.4.9", "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" }, "optionalPeers": ["msw", "vite"] }, "sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ=="], - - "@vitest/pretty-format": ["@vitest/pretty-format@3.2.4", "", { "dependencies": { "tinyrainbow": "^2.0.0" } }, "sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA=="], - - "@vitest/runner": ["@vitest/runner@3.2.4", "", { "dependencies": { "@vitest/utils": "3.2.4", "pathe": "^2.0.3", "strip-literal": "^3.0.0" } }, "sha512-oukfKT9Mk41LreEW09vt45f8wx7DordoWUZMYdY/cyAk7w5TWkTRCNZYF7sX7n2wB7jyGAl74OxgwhPgKaqDMQ=="], - - "@vitest/snapshot": ["@vitest/snapshot@3.2.4", "", { "dependencies": { "@vitest/pretty-format": "3.2.4", "magic-string": "^0.30.17", "pathe": "^2.0.3" } }, "sha512-dEYtS7qQP2CjU27QBC5oUOxLE/v5eLkGqPE0ZKEIDGMs4vKWe7IjgLOeauHsR0D5YuuycGRO5oSRXnwnmA78fQ=="], - - "@vitest/spy": ["@vitest/spy@3.2.4", "", { "dependencies": { "tinyspy": "^4.0.3" } }, "sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw=="], - - "@vitest/utils": ["@vitest/utils@3.2.4", "", { "dependencies": { "@vitest/pretty-format": "3.2.4", "loupe": "^3.1.4", "tinyrainbow": "^2.0.0" } }, "sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA=="], - "@xterm/headless": ["@xterm/headless@5.5.0", "", {}, "sha512-5xXB7kdQlFBP82ViMJTwwEc3gKCLGKR/eoxQm4zge7GPBl86tCdI0IdPJjoKd8mUSFXz5V7i/25sfsEkP4j46g=="], "@xterm/xterm": ["@xterm/xterm@5.5.0", "", {}, "sha512-hqJHYaQb5OptNunnyAnkHyM8aCjZ1MEIDTQu1iIbbTD/xops91NB5yq1ZK/dC2JDbVWtF23zUtl9JE2NqwT87A=="], @@ -618,8 +493,6 @@ "any-promise": ["any-promise@1.3.0", "", {}, "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A=="], - "assertion-error": ["assertion-error@2.0.1", "", {}, "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA=="], - "async": ["async@3.2.6", "", {}, "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA=="], "balanced-match": ["balanced-match@1.0.2", "", {}, "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="], @@ -644,18 +517,12 @@ "bytes": ["bytes@3.1.2", "", {}, "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg=="], - "cac": ["cac@6.7.14", "", {}, "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ=="], - "call-bind-apply-helpers": ["call-bind-apply-helpers@1.0.2", "", { "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2" } }, "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ=="], "call-bound": ["call-bound@1.0.4", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "get-intrinsic": "^1.3.0" } }, "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg=="], - "chai": ["chai@5.3.3", "", { "dependencies": { "assertion-error": "^2.0.1", "check-error": "^2.1.1", "deep-eql": "^5.0.1", "loupe": "^3.1.0", "pathval": "^2.0.0" } }, "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw=="], - "chalk": ["chalk@5.6.2", "", {}, "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA=="], - "check-error": ["check-error@2.1.3", "", {}, "sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA=="], - "cli-cursor": ["cli-cursor@5.0.0", "", { "dependencies": { "restore-cursor": "^5.0.0" } }, "sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw=="], "cli-highlight": ["cli-highlight@2.1.11", "", { "dependencies": { "chalk": "^4.0.0", "highlight.js": "^10.7.1", "mz": "^2.4.0", "parse5": "^5.1.1", "parse5-htmlparser2-tree-adapter": "^6.0.0", "yargs": "^16.0.0" }, "bin": { "highlight": "bin/highlight" } }, "sha512-9KDcoEVwyUXrjcJNvHD0NFc/hiwe/WPVYIleQh2O1N2Zro5gWJZ/K+3DGn8w8P/F6FxOgzyC5bxDyHIgCSPhGg=="], @@ -728,8 +595,6 @@ "decimal.js-light": ["decimal.js-light@2.5.1", "", {}, "sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg=="], - "deep-eql": ["deep-eql@5.0.2", "", {}, "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q=="], - "depd": ["depd@2.0.0", "", {}, "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw=="], "diff": ["diff@8.0.3", "", {}, "sha512-qejHi7bcSD4hQAZE0tNAawRK1ZtafHDmMTMkrrIGgSLl7hTnQHmKCeB45xAcbfTqK2zowkM3j3bHt/4b/ARbYQ=="], @@ -764,20 +629,14 @@ "es-errors": ["es-errors@1.3.0", "", {}, "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw=="], - "es-module-lexer": ["es-module-lexer@1.7.0", "", {}, "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA=="], - "es-object-atoms": ["es-object-atoms@1.1.1", "", { "dependencies": { "es-errors": "^1.3.0" } }, "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA=="], "es-toolkit": ["es-toolkit@1.44.0", "", {}, "sha512-6penXeZalaV88MM3cGkFZZfOoLGWshWWfdy0tWw/RlVVyhvMaWSBTOvXNeiW3e5FwdS5ePW0LGEu17zT139ktg=="], - "esbuild": ["esbuild@0.27.2", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.27.2", "@esbuild/android-arm": "0.27.2", "@esbuild/android-arm64": "0.27.2", "@esbuild/android-x64": "0.27.2", "@esbuild/darwin-arm64": "0.27.2", "@esbuild/darwin-x64": "0.27.2", "@esbuild/freebsd-arm64": "0.27.2", "@esbuild/freebsd-x64": "0.27.2", "@esbuild/linux-arm": "0.27.2", "@esbuild/linux-arm64": "0.27.2", "@esbuild/linux-ia32": "0.27.2", "@esbuild/linux-loong64": "0.27.2", "@esbuild/linux-mips64el": "0.27.2", "@esbuild/linux-ppc64": "0.27.2", "@esbuild/linux-riscv64": "0.27.2", "@esbuild/linux-s390x": "0.27.2", "@esbuild/linux-x64": "0.27.2", "@esbuild/netbsd-arm64": "0.27.2", "@esbuild/netbsd-x64": "0.27.2", "@esbuild/openbsd-arm64": "0.27.2", "@esbuild/openbsd-x64": "0.27.2", "@esbuild/openharmony-arm64": "0.27.2", "@esbuild/sunos-x64": "0.27.2", "@esbuild/win32-arm64": "0.27.2", "@esbuild/win32-ia32": "0.27.2", "@esbuild/win32-x64": "0.27.2" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-HyNQImnsOC7X9PMNaCIeAm4ISCQXs5a5YasTXVliKv4uuBo1dKrG0A+uQS8M5eXjVMnLg3WgXaKvprHlFJQffw=="], - "escalade": ["escalade@3.2.0", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="], "escape-html": ["escape-html@1.0.3", "", {}, "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="], - "estree-walker": ["estree-walker@3.0.3", "", { "dependencies": { "@types/estree": "^1.0.0" } }, "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g=="], - "etag": ["etag@1.8.1", "", {}, "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg=="], "eventemitter3": ["eventemitter3@5.0.4", "", {}, "sha512-mlsTRyGaPBjPedk6Bvw+aqbsXDtoAyAzm5MO7JgU+yVRyMQ5O8bD4Kcci7BS85f93veegeCPkL8R4GLClnjLFw=="], @@ -786,8 +645,6 @@ "eventsource-parser": ["eventsource-parser@3.0.6", "", {}, "sha512-Vo1ab+QXPzZ4tCa8SwIHJFaSzy4R6SHf7BY79rFBDf0idraZWAkYrDjDj8uWaSm3S2TK+hJ7/t1CEmZ7jXw+pg=="], - "expect-type": ["expect-type@1.3.0", "", {}, "sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA=="], - "express": ["express@5.2.1", "", { "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.1", "content-disposition": "^1.0.0", "content-type": "^1.0.5", "cookie": "^0.7.1", "cookie-signature": "^1.2.1", "debug": "^4.4.0", "depd": "^2.0.0", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "etag": "^1.8.1", "finalhandler": "^2.1.0", "fresh": "^2.0.0", "http-errors": "^2.0.0", "merge-descriptors": "^2.0.0", "mime-types": "^3.0.0", "on-finished": "^2.4.1", "once": "^1.4.0", "parseurl": "^1.3.3", "proxy-addr": "^2.0.7", "qs": "^6.14.0", "range-parser": "^1.2.1", "router": "^2.2.0", "send": "^1.1.0", "serve-static": "^2.2.0", "statuses": "^2.0.1", "type-is": "^2.0.1", "vary": "^1.1.2" } }, "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw=="], "express-rate-limit": ["express-rate-limit@7.5.1", "", { "peerDependencies": { "express": ">= 4.11" } }, "sha512-7iN8iPMDzOMHPUYllBEsQdWVB6fPDMPqwjBaFrgr4Jgr/+okjvzAy+UHlYYL/Vs0OsOrMkwS6PJDkFlJwoxUnw=="], @@ -800,8 +657,6 @@ "fast-xml-parser": ["fast-xml-parser@5.2.5", "", { "dependencies": { "strnum": "^2.1.0" }, "bin": { "fxparser": "src/cli/cli.js" } }, "sha512-pfX9uG9Ki0yekDHx2SiuRIyFdyAr1kMIMitPvb0YBo8SUfKvia7w7FIyd/l6av85pFYRhZscS75MwMnbvY+hcQ=="], - "fdir": ["fdir@6.5.0", "", { "peerDependencies": { "picomatch": "^3 || ^4" }, "optionalPeers": ["picomatch"] }, "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg=="], - "fecha": ["fecha@4.2.3", "", {}, "sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw=="], "fetch-blob": ["fetch-blob@3.2.0", "", { "dependencies": { "node-domexception": "^1.0.0", "web-streams-polyfill": "^3.0.3" } }, "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ=="], @@ -824,8 +679,6 @@ "fresh": ["fresh@2.0.0", "", {}, "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A=="], - "fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="], - "function-bind": ["function-bind@1.1.2", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="], "gaxios": ["gaxios@7.1.3", "", { "dependencies": { "extend": "^3.0.2", "https-proxy-agent": "^7.0.1", "node-fetch": "^3.3.2", "rimraf": "^5.0.1" } }, "sha512-YGGyuEdVIjqxkxVH1pUTMY/XtmmsApXrCVv5EU25iX6inEPbV+VakJfLealkBtJN69AQmh1eGOdCl9Sm1UP6XQ=="], @@ -894,8 +747,6 @@ "jose": ["jose@6.1.3", "", {}, "sha512-0TpaTfihd4QMNwrz/ob2Bp7X04yuxJkjRGi4aKmOqwhov54i6u79oCv7T+C7lo70MKH6BesI3vscD1yb/yzKXQ=="], - "js-tokens": ["js-tokens@9.0.1", "", {}, "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ=="], - "json-bigint": ["json-bigint@1.0.0", "", { "dependencies": { "bignumber.js": "^9.0.0" } }, "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ=="], "json-schema-to-ts": ["json-schema-to-ts@3.1.1", "", { "dependencies": { "@babel/runtime": "^7.18.3", "ts-algebra": "^2.0.0" } }, "sha512-+DWg8jCJG2TEnpy7kOm/7/AxaYoaRbjVB4LFZLySZlWn8exGs3A4OLJR966cVvU26N7X9TWxl+Jsw7dzAqKT6g=="], @@ -922,14 +773,10 @@ "logform": ["logform@2.7.0", "", { "dependencies": { "@colors/colors": "1.6.0", "@types/triple-beam": "^1.3.2", "fecha": "^4.2.0", "ms": "^2.1.1", "safe-stable-stringify": "^2.3.1", "triple-beam": "^1.3.0" } }, "sha512-TFYA4jnP7PVbmlBIfhlSe+WKxs9dklXMTEGcBCIvLhE/Tn3H6Gk1norupVW7m5Cnd4bLcr08AytbyV/xj7f/kQ=="], - "loupe": ["loupe@3.2.1", "", {}, "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ=="], - "lru-cache": ["lru-cache@11.2.4", "", {}, "sha512-B5Y16Jr9LB9dHVkh6ZevG+vAbOsNOYCX+sXvFWFu7B3Iz5mijW3zdbMyhsh8ANd2mSWBYdJgnqi+mL7/LrOPYg=="], "lucide-react": ["lucide-react@0.562.0", "", { "peerDependencies": { "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-82hOAu7y0dbVuFfmO4bYF1XEwYk/mEbM5E+b1jgci/udUBEE/R7LF5Ip0CCEmXe8AybRM8L+04eP+LGZeDvkiw=="], - "magic-string": ["magic-string@0.30.21", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="], - "marked": ["marked@15.0.12", "", { "bin": { "marked": "bin/marked.js" } }, "sha512-8dD6FusOQSrpv9Z1rdNMdlSgQOIP880DHqnohobOmYLElGEqAL/JvxvuxZO16r4HtjTlfPRDC1hbvxC9dPN2nA=="], "math-intrinsics": ["math-intrinsics@1.1.0", "", {}, "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g=="], @@ -1008,20 +855,12 @@ "path-to-regexp": ["path-to-regexp@8.3.0", "", {}, "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA=="], - "pathe": ["pathe@2.0.3", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="], - - "pathval": ["pathval@2.0.1", "", {}, "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ=="], - - "picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="], - - "picomatch": ["picomatch@4.0.3", "", {}, "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q=="], + "picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="], "pidtree": ["pidtree@0.6.0", "", { "bin": { "pidtree": "bin/pidtree.js" } }, "sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g=="], "pkce-challenge": ["pkce-challenge@5.0.1", "", {}, "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ=="], - "postcss": ["postcss@8.5.6", "", { "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg=="], - "prettier": ["prettier@3.8.1", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg=="], "proxy-addr": ["proxy-addr@2.0.7", "", { "dependencies": { "forwarded": "0.2.0", "ipaddr.js": "1.9.1" } }, "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg=="], @@ -1060,8 +899,6 @@ "rimraf": ["rimraf@5.0.10", "", { "dependencies": { "glob": "^10.3.7" }, "bin": { "rimraf": "dist/esm/bin.mjs" } }, "sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ=="], - "rollup": ["rollup@4.56.0", "", { "dependencies": { "@types/estree": "1.0.8" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.56.0", "@rollup/rollup-android-arm64": "4.56.0", "@rollup/rollup-darwin-arm64": "4.56.0", "@rollup/rollup-darwin-x64": "4.56.0", "@rollup/rollup-freebsd-arm64": "4.56.0", "@rollup/rollup-freebsd-x64": "4.56.0", "@rollup/rollup-linux-arm-gnueabihf": "4.56.0", "@rollup/rollup-linux-arm-musleabihf": "4.56.0", "@rollup/rollup-linux-arm64-gnu": "4.56.0", "@rollup/rollup-linux-arm64-musl": "4.56.0", "@rollup/rollup-linux-loong64-gnu": "4.56.0", "@rollup/rollup-linux-loong64-musl": "4.56.0", "@rollup/rollup-linux-ppc64-gnu": "4.56.0", "@rollup/rollup-linux-ppc64-musl": "4.56.0", "@rollup/rollup-linux-riscv64-gnu": "4.56.0", "@rollup/rollup-linux-riscv64-musl": "4.56.0", "@rollup/rollup-linux-s390x-gnu": "4.56.0", "@rollup/rollup-linux-x64-gnu": "4.56.0", "@rollup/rollup-linux-x64-musl": "4.56.0", "@rollup/rollup-openbsd-x64": "4.56.0", "@rollup/rollup-openharmony-arm64": "4.56.0", "@rollup/rollup-win32-arm64-msvc": "4.56.0", "@rollup/rollup-win32-ia32-msvc": "4.56.0", "@rollup/rollup-win32-x64-gnu": "4.56.0", "@rollup/rollup-win32-x64-msvc": "4.56.0", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-9FwVqlgUHzbXtDg9RCMgodF3Ua4Na6Gau+Sdt9vyCN4RhHfVKX2DCHy3BjMLTDd47ITDhYAnTwGulWTblJSDLg=="], - "router": ["router@2.2.0", "", { "dependencies": { "debug": "^4.4.0", "depd": "^2.0.0", "is-promise": "^4.0.0", "parseurl": "^1.3.3", "path-to-regexp": "^8.0.0" } }, "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ=="], "rxjs": ["rxjs@7.8.2", "", { "dependencies": { "tslib": "^2.1.0" } }, "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA=="], @@ -1094,8 +931,6 @@ "side-channel-weakmap": ["side-channel-weakmap@1.0.2", "", { "dependencies": { "call-bound": "^1.0.2", "es-errors": "^1.3.0", "get-intrinsic": "^1.2.5", "object-inspect": "^1.13.3", "side-channel-map": "^1.0.1" } }, "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A=="], - "siginfo": ["siginfo@2.0.0", "", {}, "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g=="], - "signal-exit": ["signal-exit@4.1.0", "", {}, "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw=="], "slice-ansi": ["slice-ansi@7.1.2", "", { "dependencies": { "ansi-styles": "^6.2.1", "is-fullwidth-code-point": "^5.0.0" } }, "sha512-iOBWFgUX7caIZiuutICxVgX1SdxwAVFFKwt1EvMYYec/NWO5meOJ6K5uQxhrYBdQJne4KxiqZc+KptFOWFSI9w=="], @@ -1104,18 +939,12 @@ "source-map": ["source-map@0.6.1", "", {}, "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="], - "source-map-js": ["source-map-js@1.2.1", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="], - "split2": ["split2@3.2.2", "", { "dependencies": { "readable-stream": "^3.0.0" } }, "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg=="], "stack-trace": ["stack-trace@0.0.10", "", {}, "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg=="], - "stackback": ["stackback@0.0.2", "", {}, "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw=="], - "statuses": ["statuses@2.0.2", "", {}, "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw=="], - "std-env": ["std-env@3.10.0", "", {}, "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg=="], - "string-argv": ["string-argv@0.3.2", "", {}, "sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q=="], "string-width": ["string-width@4.2.3", "", { "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" } }, "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g=="], @@ -1128,8 +957,6 @@ "strip-ansi-cjs": ["strip-ansi@6.0.1", "", { "dependencies": { "ansi-regex": "^5.0.1" } }, "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A=="], - "strip-literal": ["strip-literal@3.1.0", "", { "dependencies": { "js-tokens": "^9.0.1" } }, "sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg=="], - "strnum": ["strnum@2.1.2", "", {}, "sha512-l63NF9y/cLROq/yqKXSLtcMeeyOfnSQlfMSlzFt/K73oIaD8DGaQWd7Z34X9GPiKqP5rbSh84Hl4bOlLcjiSrQ=="], "strtok3": ["strtok3@10.3.4", "", { "dependencies": { "@tokenizer/token": "^0.3.0" } }, "sha512-KIy5nylvC5le1OdaaoCJ07L+8iQzJHGH6pWDuzS+d07Cu7n1MZ2x26P8ZKIWfbK02+XIL8Mp4RkWeqdUCrDMfg=="], @@ -1146,18 +973,6 @@ "tiny-invariant": ["tiny-invariant@1.3.3", "", {}, "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg=="], - "tinybench": ["tinybench@2.9.0", "", {}, "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg=="], - - "tinyexec": ["tinyexec@0.3.2", "", {}, "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA=="], - - "tinyglobby": ["tinyglobby@0.2.15", "", { "dependencies": { "fdir": "^6.5.0", "picomatch": "^4.0.3" } }, "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ=="], - - "tinypool": ["tinypool@1.1.1", "", {}, "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg=="], - - "tinyrainbow": ["tinyrainbow@2.0.0", "", {}, "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw=="], - - "tinyspy": ["tinyspy@4.0.4", "", {}, "sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q=="], - "to-regex-range": ["to-regex-range@5.0.1", "", { "dependencies": { "is-number": "^7.0.0" } }, "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ=="], "toidentifier": ["toidentifier@1.0.1", "", {}, "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA=="], @@ -1192,18 +1007,10 @@ "victory-vendor": ["victory-vendor@37.3.6", "", { "dependencies": { "@types/d3-array": "^3.0.3", "@types/d3-ease": "^3.0.0", "@types/d3-interpolate": "^3.0.1", "@types/d3-scale": "^4.0.2", "@types/d3-shape": "^3.1.0", "@types/d3-time": "^3.0.0", "@types/d3-timer": "^3.0.0", "d3-array": "^3.1.6", "d3-ease": "^3.0.1", "d3-interpolate": "^3.0.1", "d3-scale": "^4.0.2", "d3-shape": "^3.1.0", "d3-time": "^3.0.0", "d3-timer": "^3.0.1" } }, "sha512-SbPDPdDBYp+5MJHhBCAyI7wKM3d5ivekigc2Dk2s7pgbZ9wIgIBYGVw4zGHBml/qTFbexrofXW6Gu4noGxrOwQ=="], - "vite": ["vite@7.3.1", "", { "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rollup": "^4.43.0", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", "less": "^4.0.0", "lightningcss": "^1.21.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA=="], - - "vite-node": ["vite-node@3.2.4", "", { "dependencies": { "cac": "^6.7.14", "debug": "^4.4.1", "es-module-lexer": "^1.7.0", "pathe": "^2.0.3", "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" }, "bin": { "vite-node": "vite-node.mjs" } }, "sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg=="], - - "vitest": ["vitest@3.2.4", "", { "dependencies": { "@types/chai": "^5.2.2", "@vitest/expect": "3.2.4", "@vitest/mocker": "3.2.4", "@vitest/pretty-format": "^3.2.4", "@vitest/runner": "3.2.4", "@vitest/snapshot": "3.2.4", "@vitest/spy": "3.2.4", "@vitest/utils": "3.2.4", "chai": "^5.2.0", "debug": "^4.4.1", "expect-type": "^1.2.1", "magic-string": "^0.30.17", "pathe": "^2.0.3", "picomatch": "^4.0.2", "std-env": "^3.9.0", "tinybench": "^2.9.0", "tinyexec": "^0.3.2", "tinyglobby": "^0.2.14", "tinypool": "^1.1.1", "tinyrainbow": "^2.0.0", "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0", "vite-node": "3.2.4", "why-is-node-running": "^2.3.0" }, "peerDependencies": { "@edge-runtime/vm": "*", "@types/debug": "^4.1.12", "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", "@vitest/browser": "3.2.4", "@vitest/ui": "3.2.4", "happy-dom": "*", "jsdom": "*" }, "optionalPeers": ["@edge-runtime/vm", "@types/debug", "@types/node", "@vitest/browser", "@vitest/ui", "happy-dom", "jsdom"], "bin": { "vitest": "vitest.mjs" } }, "sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A=="], - "web-streams-polyfill": ["web-streams-polyfill@3.3.3", "", {}, "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw=="], "which": ["which@2.0.2", "", { "dependencies": { "isexe": "^2.0.0" }, "bin": { "node-which": "./bin/node-which" } }, "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA=="], - "why-is-node-running": ["why-is-node-running@2.3.0", "", { "dependencies": { "siginfo": "^2.0.0", "stackback": "0.0.2" }, "bin": { "why-is-node-running": "cli.js" } }, "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w=="], - "winston": ["winston@3.19.0", "", { "dependencies": { "@colors/colors": "^1.6.0", "@dabh/diagnostics": "^2.0.8", "async": "^3.2.3", "is-stream": "^2.0.0", "logform": "^2.7.0", "one-time": "^1.0.0", "readable-stream": "^3.4.0", "safe-stable-stringify": "^2.3.1", "stack-trace": "0.0.x", "triple-beam": "^1.3.0", "winston-transport": "^4.9.0" } }, "sha512-LZNJgPzfKR+/J3cHkxcpHKpKKvGfDZVPS4hfJCc4cCG0CgYzvlD6yE/S3CIL/Yt91ak327YCpiF/0MyeZHEHKA=="], "winston-daily-rotate-file": ["winston-daily-rotate-file@5.0.0", "", { "dependencies": { "file-stream-rotator": "^0.6.1", "object-hash": "^3.0.0", "triple-beam": "^1.4.1", "winston-transport": "^4.7.0" }, "peerDependencies": { "winston": "^3" } }, "sha512-JDjiXXkM5qvwY06733vf09I2wnMXpZEhxEVOSPenZMii+g7pcDcTBt2MRugnoi8BwVSuCT2jfRXBUy+n1Zz/Yw=="], @@ -1282,12 +1089,8 @@ "concurrently/chalk": ["chalk@4.1.2", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA=="], - "micromatch/picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="], - "parse5-htmlparser2-tree-adapter/parse5": ["parse5@6.0.1", "", {}, "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw=="], - "postcss/nanoid": ["nanoid@3.3.11", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="], - "rimraf/glob": ["glob@10.5.0", "", { "dependencies": { "foreground-child": "^3.1.0", "jackspeak": "^3.1.2", "minimatch": "^9.0.4", "minipass": "^7.1.2", "package-json-from-dist": "^1.0.0", "path-scurry": "^1.11.1" }, "bin": { "glob": "dist/esm/bin.mjs" } }, "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg=="], "slice-ansi/ansi-styles": ["ansi-styles@6.2.3", "", {}, "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg=="], diff --git a/bunfig.toml b/bunfig.toml new file mode 100644 index 000000000..1bf5937d4 --- /dev/null +++ b/bunfig.toml @@ -0,0 +1,8 @@ +[install] +linker = "isolated" +exact = true +saveTextLockfile = true + +[loader] +".md" = "text" +".py" = "text" diff --git a/package.json b/package.json index 123a5fc45..86946e2a7 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,11 @@ "packages/*" ], "scripts": { - "install:dev": "bun install && bun packages/coding-agent/scripts/generate-wasm-b64.ts && bun --cwd=packages/coding-agent link && bun --cwd=packages/ai link", + "install:dev": "bun install && bun --cwd=packages/coding-agent link && bun --cwd=packages/ai link", "dev": "bun packages/coding-agent/src/cli.ts", "stats": "bun --cwd=packages/coding-agent src/cli.ts stats", - "check": "biome check --write . && bun --cwd=packages/coding-agent run check && bun --cwd=packages/stats run check", + "check": "biome check --write . && tsgo -p tsconfig.json && tsgo -p packages/stats/tsconfig.client.json", + "test": "bun --cwd=packages/ai run test && bun --cwd=packages/agent run test && bun --cwd=packages/tui run test && bun --cwd=packages/coding-agent run test", "fix": "biome check --write --unsafe . && bun --cwd=packages/coding-agent run format-prompts", "bench:gen-fixtures": "bun run packages/react-edit-benchmark/generate.ts --react-dir /tmp/react-source --count-per-type 3", "bench:edit": "bun --cwd=packages/react-edit-benchmark run start", @@ -17,7 +18,7 @@ "version:minor": "npm version minor -ws --no-git-tag-version && bun scripts/sync-versions.ts && rm -rf node_modules packages/*/node_modules bun.lock && bun install", "version:major": "npm version major -ws --no-git-tag-version && bun scripts/sync-versions.ts && rm -rf node_modules packages/*/node_modules bun.lock && bun install", "version:set": "npm version -ws", - "prepublishOnly": "bun run build && bun run check", + "prepublishOnly": "bun run check", "publish": "bun run prepublishOnly && npm publish -ws --access public", "publish:dry": "bun run prepublishOnly && npm publish -ws --access public --dry-run", "release": "bun scripts/release.ts" @@ -39,6 +40,7 @@ "engines": { "bun": ">=1.0.0" }, + "packageManager": "bun@1.3.7", "version": "0.0.3", "dependencies": { "@sinclair/typebox": "^0.34.46", diff --git a/packages/agent/package.json b/packages/agent/package.json index d3de03d36..70005394c 100644 --- a/packages/agent/package.json +++ b/packages/agent/package.json @@ -11,8 +11,8 @@ "import": "./src/index.ts" }, "./*": { - "types": "./src/*", - "import": "./src/*" + "types": "./src/*.ts", + "import": "./src/*.ts" } }, "files": [ @@ -20,8 +20,8 @@ "README.md" ], "scripts": { - "test": "vitest --run", - "prepublishOnly": "cp tsconfig.publish.json tsconfig.json" + "check": "tsgo -p tsconfig.json", + "test": "bun test" }, "dependencies": { "@oh-my-pi/pi-ai": "workspace:*", @@ -47,7 +47,6 @@ }, "devDependencies": { "@sinclair/typebox": "^0.34.46", - "@types/node": "^24.3.0", - "vitest": "^3.2.4" + "@types/node": "^24.3.0" } } diff --git a/packages/agent/test/agent-loop.test.ts b/packages/agent/test/agent-loop.test.ts index 18a4e9b0d..17796506f 100644 --- a/packages/agent/test/agent-loop.test.ts +++ b/packages/agent/test/agent-loop.test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it } from "bun:test"; import { agentLoop, agentLoopContinue } from "@oh-my-pi/pi-agent-core/agent-loop"; import type { AgentContext, @@ -17,7 +18,6 @@ import { type UserMessage, } from "@oh-my-pi/pi-ai"; import { Type } from "@sinclair/typebox"; -import { describe, expect, it } from "vitest"; // Mock stream for testing - mimics MockAssistantStream class MockAssistantStream extends EventStream { diff --git a/packages/agent/test/agent.test.ts b/packages/agent/test/agent.test.ts index 02dcdd9bb..d62771b7e 100644 --- a/packages/agent/test/agent.test.ts +++ b/packages/agent/test/agent.test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it } from "bun:test"; import { Agent } from "@oh-my-pi/pi-agent-core"; import { type AssistantMessage, @@ -7,7 +8,6 @@ import { type ThinkingBudgets, type Usage, } from "@oh-my-pi/pi-ai"; -import { describe, expect, it } from "vitest"; class MockAssistantStream extends EventStream { constructor() { @@ -130,8 +130,8 @@ describe("Agent", () => { expect(agent.state.messages).not.toBe(messages); // Should be a copy // Test appendMessage - const newMessage = { role: "assistant" as const, content: [{ type: "text" as const, text: "Hi" }] }; - agent.appendMessage(newMessage as any); + const newMessage = createAssistantMessage([{ type: "text", text: "Hi" }]); + agent.appendMessage(newMessage); expect(agent.state.messages).toHaveLength(2); expect(agent.state.messages[1]).toBe(newMessage); diff --git a/packages/agent/test/e2e.test.ts b/packages/agent/test/e2e.test.ts index 34b094464..051fbf742 100644 --- a/packages/agent/test/e2e.test.ts +++ b/packages/agent/test/e2e.test.ts @@ -1,7 +1,7 @@ +import { describe, expect, it } from "bun:test"; import { Agent } from "@oh-my-pi/pi-agent-core"; import type { AssistantMessage, Model, ToolResultMessage, UserMessage } from "@oh-my-pi/pi-ai"; import { getModel } from "@oh-my-pi/pi-ai"; -import { describe, expect, it } from "vitest"; import { calculateTool } from "./utils/calculate"; async function basicPrompt(model: Model) { @@ -455,6 +455,7 @@ describe("Agent.continue()", () => { toolCallId: "calc-1", toolName: "calculate", content: [{ type: "text", text: "5 + 3 = 8" }], + isError: false, timestamp: Date.now(), }; diff --git a/packages/agent/tsconfig.build.json b/packages/agent/tsconfig.build.json index 695dd9ad2..ea6be8e9a 100644 --- a/packages/agent/tsconfig.build.json +++ b/packages/agent/tsconfig.build.json @@ -1,9 +1,3 @@ { - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist", - "rootDir": "./src" - }, - "include": ["src/**/*.ts"], - "exclude": ["node_modules", "dist", "**/*.d.ts", "src/**/*.d.ts"] + "extends": "./tsconfig.json" } diff --git a/packages/agent/tsconfig.json b/packages/agent/tsconfig.json index 9f01e136d..41b5f2b67 100644 --- a/packages/agent/tsconfig.json +++ b/packages/agent/tsconfig.json @@ -1,21 +1,8 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "noEmit": true, - "baseUrl": ".", - "paths": { - "@oh-my-pi/pi-agent-core": ["./src/index.ts"], - "@oh-my-pi/pi-agent-core/*": ["./src/*"], - "@oh-my-pi/pi-ai": ["../ai/src/index.ts"], - "@oh-my-pi/pi-ai/*": ["../ai/src/*"], - "@oh-my-pi/pi-utils": ["../pi-utils/src/index.ts"], - "@oh-my-pi/pi-utils/*": ["../pi-utils/src/*"], - "@oh-my-pi/pi-coding-agent": ["../coding-agent/src/index.ts"], - "@oh-my-pi/pi-coding-agent/*": ["../coding-agent/src/*"], - "@oh-my-pi/pi-tui": ["../tui/src/index.ts"], - "@oh-my-pi/pi-tui/*": ["../tui/src/*"] - } + "noEmit": true }, - "include": ["src/**/*.ts"], + "include": ["src/**/*.ts", "test/**/*.ts"], "exclude": ["node_modules", "dist"] } diff --git a/packages/agent/tsconfig.publish.json b/packages/agent/tsconfig.publish.json index d3545e257..ea6be8e9a 100644 --- a/packages/agent/tsconfig.publish.json +++ b/packages/agent/tsconfig.publish.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "noEmit": true, - "baseUrl": ".", - "paths": { - "@oh-my-pi/pi-agent-core": ["./src/index.ts"], - "@oh-my-pi/pi-agent-core/*": ["./src/*"] - } - }, - "include": ["src/**/*.ts"] + "extends": "./tsconfig.json" } diff --git a/packages/ai/package.json b/packages/ai/package.json index 27e9ec1ea..45e674169 100644 --- a/packages/ai/package.json +++ b/packages/ai/package.json @@ -10,28 +10,50 @@ "types": "./src/index.ts", "import": "./src/index.ts" }, + "./models": { + "types": "./src/models.ts", + "import": "./src/models.ts" + }, + "./models.generated": { + "types": "./src/models.generated.ts", + "import": "./src/models.generated.ts" + }, + "./stream": { + "types": "./src/stream.ts", + "import": "./src/stream.ts" + }, + "./types": { + "types": "./src/types.ts", + "import": "./src/types.ts" + }, + "./usage": { + "types": "./src/usage.ts", + "import": "./src/usage.ts" + }, + "./storage": { + "types": "./src/storage.ts", + "import": "./src/storage.ts" + }, + "./providers/*": { + "types": "./src/providers/*.ts", + "import": "./src/providers/*.ts" + }, "./utils/*": { "types": "./src/utils/*.ts", "import": "./src/utils/*.ts" - }, - "./*": { - "types": "./src/*", - "import": "./src/*" } }, "bin": { - "pi-ai": "./dist/cli.js" + "pi-ai": "./src/cli.ts" }, "files": [ - "dist", "src", "README.md" ], "scripts": { - "build": "tsgo -p tsconfig.build.json", + "check": "tsgo -p tsconfig.json", "generate-models": "bun scripts/generate-models.ts", - "test": "bun test", - "prepublishOnly": "cp tsconfig.publish.json tsconfig.json && bun run build" + "test": "bun test" }, "dependencies": { "@oh-my-pi/pi-utils": "workspace:*", diff --git a/packages/ai/src/providers/amazon-bedrock.ts b/packages/ai/src/providers/amazon-bedrock.ts index acf3f35f6..acffc172d 100644 --- a/packages/ai/src/providers/amazon-bedrock.ts +++ b/packages/ai/src/providers/amazon-bedrock.ts @@ -18,7 +18,7 @@ import { ToolResultStatus, } from "@aws-sdk/client-bedrock-runtime"; -import { calculateCost } from "@oh-my-pi/pi-ai/models"; +import { calculateCost } from "../models"; import type { Api, AssistantMessage, @@ -34,10 +34,10 @@ import type { Tool, ToolCall, ToolResultMessage, -} from "@oh-my-pi/pi-ai/types"; -import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream"; -import { parseStreamingJson } from "@oh-my-pi/pi-ai/utils/json-parse"; -import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode"; +} from "../types"; +import { AssistantMessageEventStream } from "../utils/event-stream"; +import { parseStreamingJson } from "../utils/json-parse"; +import { sanitizeSurrogates } from "../utils/sanitize-unicode"; import { transformMessages } from "./transform-messages"; export interface BedrockOptions extends StreamOptions { diff --git a/packages/ai/src/providers/anthropic.ts b/packages/ai/src/providers/anthropic.ts index 332f3395f..4c72ef266 100644 --- a/packages/ai/src/providers/anthropic.ts +++ b/packages/ai/src/providers/anthropic.ts @@ -4,8 +4,8 @@ import type { MessageCreateParamsStreaming, MessageParam, } from "@anthropic-ai/sdk/resources/messages"; -import { calculateCost } from "@oh-my-pi/pi-ai/models"; -import { getEnvApiKey, OUTPUT_FALLBACK_BUFFER } from "@oh-my-pi/pi-ai/stream"; +import { calculateCost } from "../models"; +import { getEnvApiKey, OUTPUT_FALLBACK_BUFFER } from "../stream"; import type { Api, AssistantMessage, @@ -21,11 +21,11 @@ import type { Tool, ToolCall, ToolResultMessage, -} from "@oh-my-pi/pi-ai/types"; -import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream"; -import { parseStreamingJson } from "@oh-my-pi/pi-ai/utils/json-parse"; -import { formatErrorMessageWithRetryAfter } from "@oh-my-pi/pi-ai/utils/retry-after"; -import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode"; +} from "../types"; +import { AssistantMessageEventStream } from "../utils/event-stream"; +import { parseStreamingJson } from "../utils/json-parse"; +import { formatErrorMessageWithRetryAfter } from "../utils/retry-after"; +import { sanitizeSurrogates } from "../utils/sanitize-unicode"; import { transformMessages } from "./transform-messages"; diff --git a/packages/ai/src/providers/cursor.ts b/packages/ai/src/providers/cursor.ts index 367f39fc7..22a8d63ea 100644 --- a/packages/ai/src/providers/cursor.ts +++ b/packages/ai/src/providers/cursor.ts @@ -3,7 +3,8 @@ import { appendFile } from "node:fs/promises"; import http2 from "node:http2"; import { create, fromBinary, fromJson, type JsonValue, toBinary, toJson } from "@bufbuild/protobuf"; import { ValueSchema } from "@bufbuild/protobuf/wkt"; -import { calculateCost } from "@oh-my-pi/pi-ai/models"; +import JSON5 from "json5"; +import { calculateCost } from "../models"; import type { Api, AssistantMessage, @@ -22,11 +23,10 @@ import type { Tool, ToolCall, ToolResultMessage, -} from "@oh-my-pi/pi-ai/types"; -import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream"; -import { parseStreamingJson } from "@oh-my-pi/pi-ai/utils/json-parse"; -import { formatErrorMessageWithRetryAfter } from "@oh-my-pi/pi-ai/utils/retry-after"; -import JSON5 from "json5"; +} from "../types"; +import { AssistantMessageEventStream } from "../utils/event-stream"; +import { parseStreamingJson } from "../utils/json-parse"; +import { formatErrorMessageWithRetryAfter } from "../utils/retry-after"; import type { McpToolDefinition } from "./cursor/gen/agent_pb"; import { AgentClientMessageSchema, diff --git a/packages/ai/src/providers/google-gemini-cli-usage.ts b/packages/ai/src/providers/google-gemini-cli-usage.ts index 89097df77..0c2b62cc8 100644 --- a/packages/ai/src/providers/google-gemini-cli-usage.ts +++ b/packages/ai/src/providers/google-gemini-cli-usage.ts @@ -6,8 +6,8 @@ import type { UsageProvider, UsageReport, UsageWindow, -} from "@oh-my-pi/pi-ai/usage"; -import { refreshGoogleCloudToken } from "@oh-my-pi/pi-ai/utils/oauth/google-gemini-cli"; +} from "../usage"; +import { refreshGoogleCloudToken } from "../utils/oauth/google-gemini-cli"; const DEFAULT_ENDPOINT = "https://cloudcode-pa.googleapis.com"; const CACHE_TTL_MS = 60_000; diff --git a/packages/ai/src/providers/google-gemini-cli.ts b/packages/ai/src/providers/google-gemini-cli.ts index 785a0d402..e8d8d30d6 100644 --- a/packages/ai/src/providers/google-gemini-cli.ts +++ b/packages/ai/src/providers/google-gemini-cli.ts @@ -6,7 +6,8 @@ import { createHash } from "node:crypto"; import type { Content, ThinkingConfig } from "@google/genai"; -import { calculateCost } from "@oh-my-pi/pi-ai/models"; +import { abortableSleep } from "@oh-my-pi/pi-utils"; +import { calculateCost } from "../models"; import type { Api, AssistantMessage, @@ -17,10 +18,9 @@ import type { TextContent, ThinkingContent, ToolCall, -} from "@oh-my-pi/pi-ai/types"; -import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream"; -import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode"; -import { abortableSleep } from "@oh-my-pi/pi-utils"; +} from "../types"; +import { AssistantMessageEventStream } from "../utils/event-stream"; +import { sanitizeSurrogates } from "../utils/sanitize-unicode"; import { convertMessages, convertTools, diff --git a/packages/ai/src/providers/google-shared.ts b/packages/ai/src/providers/google-shared.ts index f8b48aa0e..7c65378bd 100644 --- a/packages/ai/src/providers/google-shared.ts +++ b/packages/ai/src/providers/google-shared.ts @@ -3,8 +3,8 @@ */ import { type Content, FinishReason, FunctionCallingConfigMode, type Part, type Schema } from "@google/genai"; -import type { Context, ImageContent, Model, StopReason, TextContent, Tool } from "@oh-my-pi/pi-ai/types"; -import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode"; +import type { Context, ImageContent, Model, StopReason, TextContent, Tool } from "../types"; +import { sanitizeSurrogates } from "../utils/sanitize-unicode"; import { transformMessages } from "./transform-messages"; type GoogleApiType = "google-generative-ai" | "google-gemini-cli" | "google-vertex"; diff --git a/packages/ai/src/providers/google-vertex.ts b/packages/ai/src/providers/google-vertex.ts index 260080064..9be089621 100644 --- a/packages/ai/src/providers/google-vertex.ts +++ b/packages/ai/src/providers/google-vertex.ts @@ -5,7 +5,7 @@ import { type ThinkingConfig, ThinkingLevel, } from "@google/genai"; -import { calculateCost } from "@oh-my-pi/pi-ai/models"; +import { calculateCost } from "../models"; import type { Api, AssistantMessage, @@ -16,10 +16,10 @@ import type { TextContent, ThinkingContent, ToolCall, -} from "@oh-my-pi/pi-ai/types"; -import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream"; -import { formatErrorMessageWithRetryAfter } from "@oh-my-pi/pi-ai/utils/retry-after"; -import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode"; +} from "../types"; +import { AssistantMessageEventStream } from "../utils/event-stream"; +import { formatErrorMessageWithRetryAfter } from "../utils/retry-after"; +import { sanitizeSurrogates } from "../utils/sanitize-unicode"; import type { GoogleThinkingLevel } from "./google-gemini-cli"; import { convertMessages, diff --git a/packages/ai/src/providers/google.ts b/packages/ai/src/providers/google.ts index f18566717..102d62450 100644 --- a/packages/ai/src/providers/google.ts +++ b/packages/ai/src/providers/google.ts @@ -4,8 +4,8 @@ import { GoogleGenAI, type ThinkingConfig, } from "@google/genai"; -import { calculateCost } from "@oh-my-pi/pi-ai/models"; -import { getEnvApiKey } from "@oh-my-pi/pi-ai/stream"; +import { calculateCost } from "../models"; +import { getEnvApiKey } from "../stream"; import type { Api, AssistantMessage, @@ -16,10 +16,10 @@ import type { TextContent, ThinkingContent, ToolCall, -} from "@oh-my-pi/pi-ai/types"; -import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream"; -import { formatErrorMessageWithRetryAfter } from "@oh-my-pi/pi-ai/utils/retry-after"; -import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode"; +} from "../types"; +import { AssistantMessageEventStream } from "../utils/event-stream"; +import { formatErrorMessageWithRetryAfter } from "../utils/retry-after"; +import { sanitizeSurrogates } from "../utils/sanitize-unicode"; import type { GoogleThinkingLevel } from "./google-gemini-cli"; import { convertMessages, diff --git a/packages/ai/src/providers/openai-codex-responses.ts b/packages/ai/src/providers/openai-codex-responses.ts index d4e6e4533..061ee0dfd 100644 --- a/packages/ai/src/providers/openai-codex-responses.ts +++ b/packages/ai/src/providers/openai-codex-responses.ts @@ -1,6 +1,17 @@ import os from "node:os"; -import { calculateCost } from "@oh-my-pi/pi-ai/models"; -import { getEnvApiKey } from "@oh-my-pi/pi-ai/stream"; +import { abortableSleep } from "@oh-my-pi/pi-utils"; +import type { + ResponseFunctionToolCall, + ResponseInput, + ResponseInputContent, + ResponseInputImage, + ResponseInputText, + ResponseOutputMessage, + ResponseReasoningItem, +} from "openai/resources/responses/responses"; +import packageJson from "../../package.json" with { type: "json" }; +import { calculateCost } from "../models"; +import { getEnvApiKey } from "../stream"; import type { Api, AssistantMessage, @@ -13,22 +24,11 @@ import type { ThinkingContent, Tool, ToolCall, -} from "@oh-my-pi/pi-ai/types"; -import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream"; -import { parseStreamingJson } from "@oh-my-pi/pi-ai/utils/json-parse"; -import { formatErrorMessageWithRetryAfter } from "@oh-my-pi/pi-ai/utils/retry-after"; -import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode"; -import { abortableSleep } from "@oh-my-pi/pi-utils"; -import type { - ResponseFunctionToolCall, - ResponseInput, - ResponseInputContent, - ResponseInputImage, - ResponseInputText, - ResponseOutputMessage, - ResponseReasoningItem, -} from "openai/resources/responses/responses"; -import packageJson from "../../package.json" with { type: "json" }; +} from "../types"; +import { AssistantMessageEventStream } from "../utils/event-stream"; +import { parseStreamingJson } from "../utils/json-parse"; +import { formatErrorMessageWithRetryAfter } from "../utils/retry-after"; +import { sanitizeSurrogates } from "../utils/sanitize-unicode"; import { CODEX_BASE_URL, JWT_CLAIM_PATH, diff --git a/packages/ai/src/providers/openai-completions.ts b/packages/ai/src/providers/openai-completions.ts index 68d66f6b9..628490de9 100644 --- a/packages/ai/src/providers/openai-completions.ts +++ b/packages/ai/src/providers/openai-completions.ts @@ -1,5 +1,15 @@ -import { calculateCost } from "@oh-my-pi/pi-ai/models"; -import { getEnvApiKey } from "@oh-my-pi/pi-ai/stream"; +import OpenAI from "openai"; +import type { + ChatCompletionAssistantMessageParam, + ChatCompletionChunk, + ChatCompletionContentPart, + ChatCompletionContentPartImage, + ChatCompletionContentPartText, + ChatCompletionMessageParam, + ChatCompletionToolMessageParam, +} from "openai/resources/chat/completions"; +import { calculateCost } from "../models"; +import { getEnvApiKey } from "../stream"; import type { AssistantMessage, Context, @@ -14,21 +24,11 @@ import type { Tool, ToolCall, ToolResultMessage, -} from "@oh-my-pi/pi-ai/types"; -import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream"; -import { parseStreamingJson } from "@oh-my-pi/pi-ai/utils/json-parse"; -import { formatErrorMessageWithRetryAfter } from "@oh-my-pi/pi-ai/utils/retry-after"; -import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode"; -import OpenAI from "openai"; -import type { - ChatCompletionAssistantMessageParam, - ChatCompletionChunk, - ChatCompletionContentPart, - ChatCompletionContentPartImage, - ChatCompletionContentPartText, - ChatCompletionMessageParam, - ChatCompletionToolMessageParam, -} from "openai/resources/chat/completions"; +} from "../types"; +import { AssistantMessageEventStream } from "../utils/event-stream"; +import { parseStreamingJson } from "../utils/json-parse"; +import { formatErrorMessageWithRetryAfter } from "../utils/retry-after"; +import { sanitizeSurrogates } from "../utils/sanitize-unicode"; import { transformMessages } from "./transform-messages"; /** diff --git a/packages/ai/src/providers/openai-responses.ts b/packages/ai/src/providers/openai-responses.ts index d70adbcb9..423ebf03f 100644 --- a/packages/ai/src/providers/openai-responses.ts +++ b/packages/ai/src/providers/openai-responses.ts @@ -1,22 +1,3 @@ -import { calculateCost } from "@oh-my-pi/pi-ai/models"; -import { getEnvApiKey } from "@oh-my-pi/pi-ai/stream"; -import type { - Api, - AssistantMessage, - Context, - Model, - StopReason, - StreamFunction, - StreamOptions, - TextContent, - ThinkingContent, - Tool, - ToolCall, -} from "@oh-my-pi/pi-ai/types"; -import { AssistantMessageEventStream } from "@oh-my-pi/pi-ai/utils/event-stream"; -import { parseStreamingJson } from "@oh-my-pi/pi-ai/utils/json-parse"; -import { formatErrorMessageWithRetryAfter } from "@oh-my-pi/pi-ai/utils/retry-after"; -import { sanitizeSurrogates } from "@oh-my-pi/pi-ai/utils/sanitize-unicode"; import OpenAI from "openai"; import type { Tool as OpenAITool, @@ -29,6 +10,25 @@ import type { ResponseOutputMessage, ResponseReasoningItem, } from "openai/resources/responses/responses"; +import { calculateCost } from "../models"; +import { getEnvApiKey } from "../stream"; +import type { + Api, + AssistantMessage, + Context, + Model, + StopReason, + StreamFunction, + StreamOptions, + TextContent, + ThinkingContent, + Tool, + ToolCall, +} from "../types"; +import { AssistantMessageEventStream } from "../utils/event-stream"; +import { parseStreamingJson } from "../utils/json-parse"; +import { formatErrorMessageWithRetryAfter } from "../utils/retry-after"; +import { sanitizeSurrogates } from "../utils/sanitize-unicode"; import { transformMessages } from "./transform-messages"; /** Fast deterministic hash to shorten long strings */ diff --git a/packages/ai/src/providers/transform-messages.ts b/packages/ai/src/providers/transform-messages.ts index 5d6b5bce2..43c6fc473 100644 --- a/packages/ai/src/providers/transform-messages.ts +++ b/packages/ai/src/providers/transform-messages.ts @@ -1,4 +1,4 @@ -import type { Api, AssistantMessage, Message, Model, ToolCall, ToolResultMessage } from "@oh-my-pi/pi-ai/types"; +import type { Api, AssistantMessage, Message, Model, ToolCall, ToolResultMessage } from "../types"; /** * Normalize tool call ID for cross-provider compatibility. diff --git a/packages/ai/src/usage/claude.ts b/packages/ai/src/usage/claude.ts index aaa3234e9..6becd9d10 100644 --- a/packages/ai/src/usage/claude.ts +++ b/packages/ai/src/usage/claude.ts @@ -7,7 +7,7 @@ import type { UsageReport, UsageStatus, UsageWindow, -} from "@oh-my-pi/pi-ai/usage"; +} from "../usage"; const DEFAULT_ENDPOINT = "https://api.anthropic.com/api/oauth"; const DEFAULT_CACHE_TTL_MS = 60_000; diff --git a/packages/ai/src/usage/github-copilot.ts b/packages/ai/src/usage/github-copilot.ts index c7ba5405d..e71c739a2 100644 --- a/packages/ai/src/usage/github-copilot.ts +++ b/packages/ai/src/usage/github-copilot.ts @@ -14,7 +14,7 @@ import type { UsageReport, UsageStatus, UsageWindow, -} from "@oh-my-pi/pi-ai/usage"; +} from "../usage"; const COPILOT_HEADERS = { "User-Agent": "GitHubCopilotChat/0.35.0", diff --git a/packages/ai/src/usage/google-antigravity.ts b/packages/ai/src/usage/google-antigravity.ts index 149d535e8..c9b78086b 100644 --- a/packages/ai/src/usage/google-antigravity.ts +++ b/packages/ai/src/usage/google-antigravity.ts @@ -7,8 +7,8 @@ import type { UsageReport, UsageStatus, UsageWindow, -} from "@oh-my-pi/pi-ai/usage"; -import { refreshAntigravityToken } from "@oh-my-pi/pi-ai/utils/oauth/google-antigravity"; +} from "../usage"; +import { refreshAntigravityToken } from "../utils/oauth/google-antigravity"; interface AntigravityQuotaInfo { remainingFraction?: number; diff --git a/packages/ai/src/usage/openai-codex.ts b/packages/ai/src/usage/openai-codex.ts index 7b8ccd2f7..ddfb6293d 100644 --- a/packages/ai/src/usage/openai-codex.ts +++ b/packages/ai/src/usage/openai-codex.ts @@ -1,5 +1,5 @@ import { Buffer } from "node:buffer"; -import { CODEX_BASE_URL } from "@oh-my-pi/pi-ai/providers/openai-codex/constants"; +import { CODEX_BASE_URL } from "../providers/openai-codex/constants"; import type { UsageAmount, UsageCache, @@ -9,7 +9,7 @@ import type { UsageProvider, UsageReport, UsageWindow, -} from "@oh-my-pi/pi-ai/usage"; +} from "../usage"; const CODEX_USAGE_PATH = "wham/usage"; const DEFAULT_CACHE_TTL_MS = 60_000; diff --git a/packages/ai/src/usage/zai.ts b/packages/ai/src/usage/zai.ts index 16b5a78a9..47531b546 100644 --- a/packages/ai/src/usage/zai.ts +++ b/packages/ai/src/usage/zai.ts @@ -7,7 +7,7 @@ import type { UsageReport, UsageStatus, UsageWindow, -} from "@oh-my-pi/pi-ai/usage"; +} from "../usage"; const DEFAULT_ENDPOINT = "https://api.z.ai"; const QUOTA_PATH = "/api/monitor/usage/quota/limit"; diff --git a/packages/ai/src/utils/event-stream.ts b/packages/ai/src/utils/event-stream.ts index b7c69276f..6fb17fe2d 100644 --- a/packages/ai/src/utils/event-stream.ts +++ b/packages/ai/src/utils/event-stream.ts @@ -1,4 +1,4 @@ -import type { AssistantMessage, AssistantMessageEvent } from "@oh-my-pi/pi-ai/types"; +import type { AssistantMessage, AssistantMessageEvent } from "../types"; // Generic event stream class for async iteration export class EventStream implements AsyncIterable { diff --git a/packages/ai/src/utils/oauth/github-copilot.ts b/packages/ai/src/utils/oauth/github-copilot.ts index a48b75d1a..670242b4b 100644 --- a/packages/ai/src/utils/oauth/github-copilot.ts +++ b/packages/ai/src/utils/oauth/github-copilot.ts @@ -2,8 +2,8 @@ * GitHub Copilot OAuth flow */ -import { getModels } from "@oh-my-pi/pi-ai/models"; import { abortableSleep } from "@oh-my-pi/pi-utils"; +import { getModels } from "../../models"; import type { OAuthCredentials } from "./types"; const decode = (s: string) => atob(s); diff --git a/packages/ai/src/utils/overflow.ts b/packages/ai/src/utils/overflow.ts index 8df44dbae..e21fe5474 100644 --- a/packages/ai/src/utils/overflow.ts +++ b/packages/ai/src/utils/overflow.ts @@ -1,4 +1,4 @@ -import type { AssistantMessage } from "@oh-my-pi/pi-ai/types"; +import type { AssistantMessage } from "../types"; /** * Regex patterns to detect context overflow errors from different providers. diff --git a/packages/ai/src/utils/validation.ts b/packages/ai/src/utils/validation.ts index 19b44bc2e..8edc69f39 100644 --- a/packages/ai/src/utils/validation.ts +++ b/packages/ai/src/utils/validation.ts @@ -5,7 +5,7 @@ import addFormatsModule from "ajv-formats"; const Ajv = (AjvModule as any).default || AjvModule; const addFormats = (addFormatsModule as any).default || addFormatsModule; -import type { Tool, ToolCall } from "@oh-my-pi/pi-ai/types"; +import type { Tool, ToolCall } from "../types"; // ============================================================================ // Type Coercion Utilities diff --git a/packages/ai/test/abort.test.ts b/packages/ai/test/abort.test.ts index 83256d1e6..2dd866623 100644 --- a/packages/ai/test/abort.test.ts +++ b/packages/ai/test/abort.test.ts @@ -1,8 +1,8 @@ +import { describe, expect, it } from "bun:test"; import { getModel } from "@oh-my-pi/pi-ai/models"; import { complete, stream } from "@oh-my-pi/pi-ai/stream"; import type { Api, Context, Model, OptionsForApi } from "@oh-my-pi/pi-ai/types"; -import { describe, expect, it } from "vitest"; -import { resolveApiKey } from "./oauth"; +import { e2eApiKey, resolveApiKey } from "./oauth"; // Resolve OAuth tokens at module level (async, runs before tests) const [geminiCliToken, openaiCodexToken] = await Promise.all([ @@ -67,91 +67,147 @@ async function testImmediateAbort(llm: Model, options: O } describe("AI Providers Abort Tests", () => { - describe.skipIf(!process.env.GEMINI_API_KEY)("Google Provider Abort", () => { + describe.skipIf(!e2eApiKey("GEMINI_API_KEY"))("Google Provider Abort", () => { const llm = getModel("google", "gemini-2.5-flash"); - it("should abort mid-stream", { retry: 3 }, async () => { - await testAbortSignal(llm, { thinking: { enabled: true } }); - }); + it( + "should abort mid-stream", + async () => { + await testAbortSignal(llm, { thinking: { enabled: true } }); + }, + { retry: 3 }, + ); - it("should handle immediate abort", { retry: 3 }, async () => { - await testImmediateAbort(llm, { thinking: { enabled: true } }); - }); + it( + "should handle immediate abort", + async () => { + await testImmediateAbort(llm, { thinking: { enabled: true } }); + }, + { retry: 3 }, + ); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Completions Provider Abort", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Completions Provider Abort", () => { const llm: Model<"openai-completions"> = { ...getModel("openai", "gpt-4o-mini")!, api: "openai-completions", }; - it("should abort mid-stream", { retry: 3 }, async () => { - await testAbortSignal(llm); - }); + it( + "should abort mid-stream", + async () => { + await testAbortSignal(llm); + }, + { retry: 3 }, + ); - it("should handle immediate abort", { retry: 3 }, async () => { - await testImmediateAbort(llm); - }); + it( + "should handle immediate abort", + async () => { + await testImmediateAbort(llm); + }, + { retry: 3 }, + ); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Responses Provider Abort", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Responses Provider Abort", () => { const llm = getModel("openai", "gpt-5-mini"); - it("should abort mid-stream", { retry: 3 }, async () => { - await testAbortSignal(llm); - }); + it( + "should abort mid-stream", + async () => { + await testAbortSignal(llm); + }, + { retry: 3 }, + ); - it("should handle immediate abort", { retry: 3 }, async () => { - await testImmediateAbort(llm); - }); + it( + "should handle immediate abort", + async () => { + await testImmediateAbort(llm); + }, + { retry: 3 }, + ); }); describe.skipIf(!process.env.ANTHROPIC_OAUTH_TOKEN)("Anthropic Provider Abort", () => { const llm = getModel("anthropic", "claude-opus-4-1-20250805"); - it("should abort mid-stream", { retry: 3 }, async () => { - await testAbortSignal(llm, { thinkingEnabled: true, thinkingBudgetTokens: 2048 }); - }); + it( + "should abort mid-stream", + async () => { + await testAbortSignal(llm, { thinkingEnabled: true, thinkingBudgetTokens: 2048 }); + }, + { retry: 3 }, + ); - it("should handle immediate abort", { retry: 3 }, async () => { - await testImmediateAbort(llm, { thinkingEnabled: true, thinkingBudgetTokens: 2048 }); - }); + it( + "should handle immediate abort", + async () => { + await testImmediateAbort(llm, { thinkingEnabled: true, thinkingBudgetTokens: 2048 }); + }, + { retry: 3 }, + ); }); - describe.skipIf(!process.env.MISTRAL_API_KEY)("Mistral Provider Abort", () => { + describe.skipIf(!e2eApiKey("MISTRAL_API_KEY"))("Mistral Provider Abort", () => { const llm = getModel("mistral", "devstral-medium-latest"); - it("should abort mid-stream", { retry: 3 }, async () => { - await testAbortSignal(llm); - }); + it( + "should abort mid-stream", + async () => { + await testAbortSignal(llm); + }, + { retry: 3 }, + ); - it("should handle immediate abort", { retry: 3 }, async () => { - await testImmediateAbort(llm); - }); + it( + "should handle immediate abort", + async () => { + await testImmediateAbort(llm); + }, + { retry: 3 }, + ); }); // Google Gemini CLI / Antigravity share the same provider, so one test covers both describe("Google Gemini CLI Provider Abort", () => { - it.skipIf(!geminiCliToken)("should abort mid-stream", { retry: 3 }, async () => { - const llm = getModel("google-gemini-cli", "gemini-2.5-flash"); - await testAbortSignal(llm, { apiKey: geminiCliToken }); - }); + it.skipIf(!geminiCliToken)( + "should abort mid-stream", + async () => { + const llm = getModel("google-gemini-cli", "gemini-2.5-flash"); + await testAbortSignal(llm, { apiKey: geminiCliToken }); + }, + { retry: 3 }, + ); - it.skipIf(!geminiCliToken)("should handle immediate abort", { retry: 3 }, async () => { - const llm = getModel("google-gemini-cli", "gemini-2.5-flash"); - await testImmediateAbort(llm, { apiKey: geminiCliToken }); - }); + it.skipIf(!geminiCliToken)( + "should handle immediate abort", + async () => { + const llm = getModel("google-gemini-cli", "gemini-2.5-flash"); + await testImmediateAbort(llm, { apiKey: geminiCliToken }); + }, + { retry: 3 }, + ); }); describe("OpenAI Codex Provider Abort", () => { - it.skipIf(!openaiCodexToken)("should abort mid-stream", { retry: 3 }, async () => { - const llm = getModel("openai-codex", "gpt-5.2-codex"); - await testAbortSignal(llm, { apiKey: openaiCodexToken }); - }); + it.skipIf(!openaiCodexToken)( + "should abort mid-stream", + async () => { + const llm = getModel("openai-codex", "gpt-5.2-codex"); + await testAbortSignal(llm, { apiKey: openaiCodexToken }); + }, + { retry: 3 }, + ); - it.skipIf(!openaiCodexToken)("should handle immediate abort", { retry: 3 }, async () => { - const llm = getModel("openai-codex", "gpt-5.2-codex"); - await testImmediateAbort(llm, { apiKey: openaiCodexToken }); - }); + it.skipIf(!openaiCodexToken)( + "should handle immediate abort", + async () => { + const llm = getModel("openai-codex", "gpt-5.2-codex"); + await testImmediateAbort(llm, { apiKey: openaiCodexToken }); + }, + { retry: 3 }, + ); }); }); diff --git a/packages/ai/test/context-overflow.test.ts b/packages/ai/test/context-overflow.test.ts index 7a196317c..a4f59e471 100644 --- a/packages/ai/test/context-overflow.test.ts +++ b/packages/ai/test/context-overflow.test.ts @@ -11,14 +11,14 @@ * The isContextOverflow() function must return true for all providers. */ +import { afterAll, beforeAll, describe, expect, it } from "bun:test"; import type { ChildProcess } from "node:child_process"; import { execSync, spawn } from "node:child_process"; import { getModel } from "@oh-my-pi/pi-ai/models"; import { complete } from "@oh-my-pi/pi-ai/stream"; import type { AssistantMessage, Context, Model, Usage } from "@oh-my-pi/pi-ai/types"; import { isContextOverflow } from "@oh-my-pi/pi-ai/utils/overflow"; -import { afterAll, beforeAll, describe, expect, it } from "vitest"; -import { resolveApiKey } from "./oauth"; +import { e2eApiKey, resolveApiKey } from "./oauth"; // Resolve OAuth tokens at module level (async, runs before tests) const oauthTokens = await Promise.all([ @@ -97,7 +97,7 @@ function logResult(result: OverflowResult) { // ============================================================================= describe("Context overflow error handling", () => { - describe.skipIf(!process.env.ANTHROPIC_API_KEY)("Anthropic (API Key)", () => { + describe.skipIf(!e2eApiKey("ANTHROPIC_API_KEY"))("Anthropic (API Key)", () => { it("claude-3-5-haiku - should detect overflow via isContextOverflow", async () => { const model = getModel("anthropic", "claude-3-5-haiku-20241022"); const result = await testContextOverflow(model, process.env.ANTHROPIC_API_KEY!); @@ -163,7 +163,7 @@ describe("Context overflow error handling", () => { // Expected pattern: "exceeds the context window" // ============================================================================= - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Completions", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Completions", () => { it("gpt-4o-mini - should detect overflow via isContextOverflow", async () => { const model = { ...getModel("openai", "gpt-4o-mini") }; model.api = "openai-completions" as any; @@ -176,7 +176,7 @@ describe("Context overflow error handling", () => { }, 120000); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Responses", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Responses", () => { it("gpt-4o - should detect overflow via isContextOverflow", async () => { const model = getModel("openai", "gpt-4o"); const result = await testContextOverflow(model, process.env.OPENAI_API_KEY!); @@ -193,7 +193,7 @@ describe("Context overflow error handling", () => { // Expected pattern: "input token count (X) exceeds the maximum" // ============================================================================= - describe.skipIf(!process.env.GEMINI_API_KEY)("Google", () => { + describe.skipIf(!e2eApiKey("GEMINI_API_KEY"))("Google", () => { it("gemini-2.0-flash - should detect overflow via isContextOverflow", async () => { const model = getModel("google", "gemini-2.0-flash"); const result = await testContextOverflow(model, process.env.GEMINI_API_KEY!); @@ -289,7 +289,7 @@ describe("Context overflow error handling", () => { // Expected pattern: "maximum prompt length is X but the request contains Y" // ============================================================================= - describe.skipIf(!process.env.XAI_API_KEY)("xAI", () => { + describe.skipIf(!e2eApiKey("XAI_API_KEY"))("xAI", () => { it("grok-3-fast - should detect overflow via isContextOverflow", async () => { const model = getModel("xai", "grok-3-fast"); const result = await testContextOverflow(model, process.env.XAI_API_KEY!); @@ -306,7 +306,7 @@ describe("Context overflow error handling", () => { // Expected pattern: "reduce the length of the messages" // ============================================================================= - describe.skipIf(!process.env.GROQ_API_KEY)("Groq", () => { + describe.skipIf(!e2eApiKey("GROQ_API_KEY"))("Groq", () => { it("llama-3.3-70b-versatile - should detect overflow via isContextOverflow", async () => { const model = getModel("groq", "llama-3.3-70b-versatile"); const result = await testContextOverflow(model, process.env.GROQ_API_KEY!); @@ -323,7 +323,7 @@ describe("Context overflow error handling", () => { // Expected: 400/413 status code with no body // ============================================================================= - describe.skipIf(!process.env.CEREBRAS_API_KEY)("Cerebras", () => { + describe.skipIf(!e2eApiKey("CEREBRAS_API_KEY"))("Cerebras", () => { it("qwen-3-235b - should detect overflow via isContextOverflow", async () => { const model = getModel("cerebras", "qwen-3-235b-a22b-instruct-2507"); const result = await testContextOverflow(model, process.env.CEREBRAS_API_KEY!); @@ -342,7 +342,7 @@ describe("Context overflow error handling", () => { // Detection via usage.input > contextWindow when successful // ============================================================================= - describe.skipIf(!process.env.ZAI_API_KEY)("z.ai", () => { + describe.skipIf(!e2eApiKey("ZAI_API_KEY"))("z.ai", () => { it("glm-4.5-flash - should detect overflow via isContextOverflow (silent overflow or rate limit)", async () => { const model = getModel("zai", "glm-4.5-flash"); const result = await testContextOverflow(model, process.env.ZAI_API_KEY!); @@ -368,7 +368,7 @@ describe("Context overflow error handling", () => { // Expected pattern: TBD - need to test actual error message // ============================================================================= - describe.skipIf(!process.env.MISTRAL_API_KEY)("Mistral", () => { + describe.skipIf(!e2eApiKey("MISTRAL_API_KEY"))("Mistral", () => { it("devstral-medium-latest - should detect overflow via isContextOverflow", async () => { const model = getModel("mistral", "devstral-medium-latest"); const result = await testContextOverflow(model, process.env.MISTRAL_API_KEY!); @@ -384,7 +384,7 @@ describe("Context overflow error handling", () => { // Expected pattern: "maximum context length is X tokens" // ============================================================================= - describe.skipIf(!process.env.OPENROUTER_API_KEY)("OpenRouter", () => { + describe.skipIf(!e2eApiKey("OPENROUTER_API_KEY"))("OpenRouter", () => { // Anthropic backend it("anthropic/claude-sonnet-4 via OpenRouter - should detect overflow via isContextOverflow", async () => { const model = getModel("openrouter", "anthropic/claude-sonnet-4"); diff --git a/packages/ai/test/duplicate-tool-results.test.ts b/packages/ai/test/duplicate-tool-results.test.ts index 2c601ea48..aa969158c 100644 --- a/packages/ai/test/duplicate-tool-results.test.ts +++ b/packages/ai/test/duplicate-tool-results.test.ts @@ -1,6 +1,6 @@ +import { describe, expect, it } from "bun:test"; import { transformMessages } from "@oh-my-pi/pi-ai/providers/transform-messages"; import type { AssistantMessage, Model, ToolResultMessage } from "@oh-my-pi/pi-ai/types"; -import { describe, expect, it } from "vitest"; /** * Regression test for: "each tool_use must have a single result. Found multiple tool_result blocks with id" diff --git a/packages/ai/test/empty.test.ts b/packages/ai/test/empty.test.ts index c4e36cc5c..79ff9011b 100644 --- a/packages/ai/test/empty.test.ts +++ b/packages/ai/test/empty.test.ts @@ -1,8 +1,8 @@ +import { describe, expect, it } from "bun:test"; import { getModel } from "@oh-my-pi/pi-ai/models"; import { complete } from "@oh-my-pi/pi-ai/stream"; import type { Api, AssistantMessage, Context, Model, OptionsForApi, UserMessage } from "@oh-my-pi/pi-ai/types"; -import { describe, expect, it } from "vitest"; -import { resolveApiKey } from "./oauth"; +import { e2eApiKey, resolveApiKey } from "./oauth"; // Resolve OAuth tokens at module level (async, runs before tests) const oauthTokens = await Promise.all([ @@ -141,184 +141,328 @@ async function testEmptyAssistantMessage(llm: Model, opt } describe("AI Providers Empty Message Tests", () => { - describe.skipIf(!process.env.GEMINI_API_KEY)("Google Provider Empty Messages", () => { + describe.skipIf(!e2eApiKey("GEMINI_API_KEY"))("Google Provider Empty Messages", () => { const llm = getModel("google", "gemini-2.5-flash"); - it("should handle empty content array", { retry: 3, timeout: 30000 }, async () => { - await testEmptyMessage(llm); - }); + it( + "should handle empty content array", + async () => { + await testEmptyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty string content", { retry: 3, timeout: 30000 }, async () => { - await testEmptyStringMessage(llm); - }); + it( + "should handle empty string content", + async () => { + await testEmptyStringMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle whitespace-only content", { retry: 3, timeout: 30000 }, async () => { - await testWhitespaceOnlyMessage(llm); - }); + it( + "should handle whitespace-only content", + async () => { + await testWhitespaceOnlyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty assistant message in conversation", { retry: 3, timeout: 30000 }, async () => { - await testEmptyAssistantMessage(llm); - }); + it( + "should handle empty assistant message in conversation", + async () => { + await testEmptyAssistantMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Completions Provider Empty Messages", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Completions Provider Empty Messages", () => { const llm = getModel("openai", "gpt-4o-mini"); - it("should handle empty content array", { retry: 3, timeout: 30000 }, async () => { - await testEmptyMessage(llm); - }); + it( + "should handle empty content array", + async () => { + await testEmptyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty string content", { retry: 3, timeout: 30000 }, async () => { - await testEmptyStringMessage(llm); - }); + it( + "should handle empty string content", + async () => { + await testEmptyStringMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle whitespace-only content", { retry: 3, timeout: 30000 }, async () => { - await testWhitespaceOnlyMessage(llm); - }); + it( + "should handle whitespace-only content", + async () => { + await testWhitespaceOnlyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty assistant message in conversation", { retry: 3, timeout: 30000 }, async () => { - await testEmptyAssistantMessage(llm); - }); + it( + "should handle empty assistant message in conversation", + async () => { + await testEmptyAssistantMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Responses Provider Empty Messages", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Responses Provider Empty Messages", () => { const llm = getModel("openai", "gpt-5-mini"); - it("should handle empty content array", { retry: 3, timeout: 30000 }, async () => { - await testEmptyMessage(llm); - }); + it( + "should handle empty content array", + async () => { + await testEmptyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty string content", { retry: 3, timeout: 30000 }, async () => { - await testEmptyStringMessage(llm); - }); + it( + "should handle empty string content", + async () => { + await testEmptyStringMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle whitespace-only content", { retry: 3, timeout: 30000 }, async () => { - await testWhitespaceOnlyMessage(llm); - }); + it( + "should handle whitespace-only content", + async () => { + await testWhitespaceOnlyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty assistant message in conversation", { retry: 3, timeout: 30000 }, async () => { - await testEmptyAssistantMessage(llm); - }); + it( + "should handle empty assistant message in conversation", + async () => { + await testEmptyAssistantMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.ANTHROPIC_API_KEY)("Anthropic Provider Empty Messages", () => { + describe.skipIf(!e2eApiKey("ANTHROPIC_API_KEY"))("Anthropic Provider Empty Messages", () => { const llm = getModel("anthropic", "claude-3-5-haiku-20241022"); - it("should handle empty content array", { retry: 3, timeout: 30000 }, async () => { - await testEmptyMessage(llm); - }); + it( + "should handle empty content array", + async () => { + await testEmptyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty string content", { retry: 3, timeout: 30000 }, async () => { - await testEmptyStringMessage(llm); - }); + it( + "should handle empty string content", + async () => { + await testEmptyStringMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle whitespace-only content", { retry: 3, timeout: 30000 }, async () => { - await testWhitespaceOnlyMessage(llm); - }); + it( + "should handle whitespace-only content", + async () => { + await testWhitespaceOnlyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty assistant message in conversation", { retry: 3, timeout: 30000 }, async () => { - await testEmptyAssistantMessage(llm); - }); + it( + "should handle empty assistant message in conversation", + async () => { + await testEmptyAssistantMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.XAI_API_KEY)("xAI Provider Empty Messages", () => { + describe.skipIf(!e2eApiKey("XAI_API_KEY"))("xAI Provider Empty Messages", () => { const llm = getModel("xai", "grok-3"); - it("should handle empty content array", { retry: 3, timeout: 30000 }, async () => { - await testEmptyMessage(llm); - }); + it( + "should handle empty content array", + async () => { + await testEmptyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty string content", { retry: 3, timeout: 30000 }, async () => { - await testEmptyStringMessage(llm); - }); + it( + "should handle empty string content", + async () => { + await testEmptyStringMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle whitespace-only content", { retry: 3, timeout: 30000 }, async () => { - await testWhitespaceOnlyMessage(llm); - }); + it( + "should handle whitespace-only content", + async () => { + await testWhitespaceOnlyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty assistant message in conversation", { retry: 3, timeout: 30000 }, async () => { - await testEmptyAssistantMessage(llm); - }); + it( + "should handle empty assistant message in conversation", + async () => { + await testEmptyAssistantMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.GROQ_API_KEY)("Groq Provider Empty Messages", () => { + describe.skipIf(!e2eApiKey("GROQ_API_KEY"))("Groq Provider Empty Messages", () => { const llm = getModel("groq", "openai/gpt-oss-20b"); - it("should handle empty content array", { retry: 3, timeout: 30000 }, async () => { - await testEmptyMessage(llm); - }); + it( + "should handle empty content array", + async () => { + await testEmptyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty string content", { retry: 3, timeout: 30000 }, async () => { - await testEmptyStringMessage(llm); - }); + it( + "should handle empty string content", + async () => { + await testEmptyStringMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle whitespace-only content", { retry: 3, timeout: 30000 }, async () => { - await testWhitespaceOnlyMessage(llm); - }); + it( + "should handle whitespace-only content", + async () => { + await testWhitespaceOnlyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty assistant message in conversation", { retry: 3, timeout: 30000 }, async () => { - await testEmptyAssistantMessage(llm); - }); + it( + "should handle empty assistant message in conversation", + async () => { + await testEmptyAssistantMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.CEREBRAS_API_KEY)("Cerebras Provider Empty Messages", () => { + describe.skipIf(!e2eApiKey("CEREBRAS_API_KEY"))("Cerebras Provider Empty Messages", () => { const llm = getModel("cerebras", "gpt-oss-120b"); - it("should handle empty content array", { retry: 3, timeout: 30000 }, async () => { - await testEmptyMessage(llm); - }); + it( + "should handle empty content array", + async () => { + await testEmptyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty string content", { retry: 3, timeout: 30000 }, async () => { - await testEmptyStringMessage(llm); - }); + it( + "should handle empty string content", + async () => { + await testEmptyStringMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle whitespace-only content", { retry: 3, timeout: 30000 }, async () => { - await testWhitespaceOnlyMessage(llm); - }); + it( + "should handle whitespace-only content", + async () => { + await testWhitespaceOnlyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty assistant message in conversation", { retry: 3, timeout: 30000 }, async () => { - await testEmptyAssistantMessage(llm); - }); + it( + "should handle empty assistant message in conversation", + async () => { + await testEmptyAssistantMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.ZAI_API_KEY)("zAI Provider Empty Messages", () => { + describe.skipIf(!e2eApiKey("ZAI_API_KEY"))("zAI Provider Empty Messages", () => { const llm = getModel("zai", "glm-4.5-air"); - it("should handle empty content array", { retry: 3, timeout: 30000 }, async () => { - await testEmptyMessage(llm); - }); + it( + "should handle empty content array", + async () => { + await testEmptyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty string content", { retry: 3, timeout: 30000 }, async () => { - await testEmptyStringMessage(llm); - }); + it( + "should handle empty string content", + async () => { + await testEmptyStringMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle whitespace-only content", { retry: 3, timeout: 30000 }, async () => { - await testWhitespaceOnlyMessage(llm); - }); + it( + "should handle whitespace-only content", + async () => { + await testWhitespaceOnlyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty assistant message in conversation", { retry: 3, timeout: 30000 }, async () => { - await testEmptyAssistantMessage(llm); - }); + it( + "should handle empty assistant message in conversation", + async () => { + await testEmptyAssistantMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.MISTRAL_API_KEY)("Mistral Provider Empty Messages", () => { + describe.skipIf(!e2eApiKey("MISTRAL_API_KEY"))("Mistral Provider Empty Messages", () => { const llm = getModel("mistral", "devstral-medium-latest"); - it("should handle empty content array", { retry: 3, timeout: 30000 }, async () => { - await testEmptyMessage(llm); - }); + it( + "should handle empty content array", + async () => { + await testEmptyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty string content", { retry: 3, timeout: 30000 }, async () => { - await testEmptyStringMessage(llm); - }); + it( + "should handle empty string content", + async () => { + await testEmptyStringMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle whitespace-only content", { retry: 3, timeout: 30000 }, async () => { - await testWhitespaceOnlyMessage(llm); - }); + it( + "should handle whitespace-only content", + async () => { + await testWhitespaceOnlyMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle empty assistant message in conversation", { retry: 3, timeout: 30000 }, async () => { - await testEmptyAssistantMessage(llm); - }); + it( + "should handle empty assistant message in conversation", + async () => { + await testEmptyAssistantMessage(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); // ========================================================================= @@ -328,288 +472,296 @@ describe("AI Providers Empty Message Tests", () => { describe("Anthropic OAuth Provider Empty Messages", () => { const llm = getModel("anthropic", "claude-3-5-haiku-20241022"); - it.skipIf(!anthropicOAuthToken)("should handle empty content array", { retry: 3, timeout: 30000 }, async () => { - await testEmptyMessage(llm, { apiKey: anthropicOAuthToken }); - }); + it.skipIf(!anthropicOAuthToken)( + "should handle empty content array", + async () => { + await testEmptyMessage(llm, { apiKey: anthropicOAuthToken }); + }, + { retry: 3, timeout: 30000 }, + ); - it.skipIf(!anthropicOAuthToken)("should handle empty string content", { retry: 3, timeout: 30000 }, async () => { - await testEmptyStringMessage(llm, { apiKey: anthropicOAuthToken }); - }); + it.skipIf(!anthropicOAuthToken)( + "should handle empty string content", + async () => { + await testEmptyStringMessage(llm, { apiKey: anthropicOAuthToken }); + }, + { retry: 3, timeout: 30000 }, + ); it.skipIf(!anthropicOAuthToken)( "should handle whitespace-only content", - { retry: 3, timeout: 30000 }, async () => { await testWhitespaceOnlyMessage(llm, { apiKey: anthropicOAuthToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!anthropicOAuthToken)( "should handle empty assistant message in conversation", - { retry: 3, timeout: 30000 }, async () => { await testEmptyAssistantMessage(llm, { apiKey: anthropicOAuthToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("GitHub Copilot Provider Empty Messages", () => { it.skipIf(!githubCopilotToken)( "gpt-4o - should handle empty content array", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "gpt-4o"); await testEmptyMessage(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!githubCopilotToken)( "gpt-4o - should handle empty string content", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "gpt-4o"); await testEmptyStringMessage(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!githubCopilotToken)( "gpt-4o - should handle whitespace-only content", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "gpt-4o"); await testWhitespaceOnlyMessage(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!githubCopilotToken)( "gpt-4o - should handle empty assistant message in conversation", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "gpt-4o"); await testEmptyAssistantMessage(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!githubCopilotToken)( "claude-sonnet-4 - should handle empty content array", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "claude-sonnet-4"); await testEmptyMessage(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!githubCopilotToken)( "claude-sonnet-4 - should handle empty string content", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "claude-sonnet-4"); await testEmptyStringMessage(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!githubCopilotToken)( "claude-sonnet-4 - should handle whitespace-only content", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "claude-sonnet-4"); await testWhitespaceOnlyMessage(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!githubCopilotToken)( "claude-sonnet-4 - should handle empty assistant message in conversation", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "claude-sonnet-4"); await testEmptyAssistantMessage(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("Google Gemini CLI Provider Empty Messages", () => { it.skipIf(!geminiCliToken)( "gemini-2.5-flash - should handle empty content array", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-gemini-cli", "gemini-2.5-flash"); await testEmptyMessage(llm, { apiKey: geminiCliToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!geminiCliToken)( "gemini-2.5-flash - should handle empty string content", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-gemini-cli", "gemini-2.5-flash"); await testEmptyStringMessage(llm, { apiKey: geminiCliToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!geminiCliToken)( "gemini-2.5-flash - should handle whitespace-only content", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-gemini-cli", "gemini-2.5-flash"); await testWhitespaceOnlyMessage(llm, { apiKey: geminiCliToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!geminiCliToken)( "gemini-2.5-flash - should handle empty assistant message in conversation", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-gemini-cli", "gemini-2.5-flash"); await testEmptyAssistantMessage(llm, { apiKey: geminiCliToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("Google Antigravity Provider Empty Messages", () => { it.skipIf(!antigravityToken)( "gemini-3-flash - should handle empty content array", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gemini-3-flash"); await testEmptyMessage(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "gemini-3-flash - should handle empty string content", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gemini-3-flash"); await testEmptyStringMessage(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "gemini-3-flash - should handle whitespace-only content", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gemini-3-flash"); await testWhitespaceOnlyMessage(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "gemini-3-flash - should handle empty assistant message in conversation", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gemini-3-flash"); await testEmptyAssistantMessage(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "claude-sonnet-4-5 - should handle empty content array", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "claude-sonnet-4-5"); await testEmptyMessage(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "claude-sonnet-4-5 - should handle empty string content", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "claude-sonnet-4-5"); await testEmptyStringMessage(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "claude-sonnet-4-5 - should handle whitespace-only content", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "claude-sonnet-4-5"); await testWhitespaceOnlyMessage(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "claude-sonnet-4-5 - should handle empty assistant message in conversation", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "claude-sonnet-4-5"); await testEmptyAssistantMessage(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "gpt-oss-120b-medium - should handle empty content array", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gpt-oss-120b-medium"); await testEmptyMessage(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "gpt-oss-120b-medium - should handle empty string content", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gpt-oss-120b-medium"); await testEmptyStringMessage(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "gpt-oss-120b-medium - should handle whitespace-only content", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gpt-oss-120b-medium"); await testWhitespaceOnlyMessage(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "gpt-oss-120b-medium - should handle empty assistant message in conversation", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gpt-oss-120b-medium"); await testEmptyAssistantMessage(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("OpenAI Codex Provider Empty Messages", () => { it.skipIf(!openaiCodexToken)( "gpt-5.2-codex - should handle empty content array", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("openai-codex", "gpt-5.2-codex"); await testEmptyMessage(llm, { apiKey: openaiCodexToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!openaiCodexToken)( "gpt-5.2-codex - should handle empty string content", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("openai-codex", "gpt-5.2-codex"); await testEmptyStringMessage(llm, { apiKey: openaiCodexToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!openaiCodexToken)( "gpt-5.2-codex - should handle whitespace-only content", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("openai-codex", "gpt-5.2-codex"); await testWhitespaceOnlyMessage(llm, { apiKey: openaiCodexToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!openaiCodexToken)( "gpt-5.2-codex - should handle empty assistant message in conversation", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("openai-codex", "gpt-5.2-codex"); await testEmptyAssistantMessage(llm, { apiKey: openaiCodexToken }); }, + { retry: 3, timeout: 30000 }, ); }); }); diff --git a/packages/ai/test/google-thinking-signature.test.ts b/packages/ai/test/google-thinking-signature.test.ts index ae4c1528e..45042a935 100644 --- a/packages/ai/test/google-thinking-signature.test.ts +++ b/packages/ai/test/google-thinking-signature.test.ts @@ -1,5 +1,5 @@ +import { describe, expect, it } from "bun:test"; import { isThinkingPart, retainThoughtSignature } from "@oh-my-pi/pi-ai/providers/google-shared"; -import { describe, expect, it } from "vitest"; describe("Google thinking detection (thoughtSignature)", () => { it("treats part.thought === true as thinking", () => { diff --git a/packages/ai/test/handoff.test.ts b/packages/ai/test/handoff.test.ts index 0abe7b23b..b269de687 100644 --- a/packages/ai/test/handoff.test.ts +++ b/packages/ai/test/handoff.test.ts @@ -1,8 +1,9 @@ +import { describe, expect, it } from "bun:test"; import { getModel } from "@oh-my-pi/pi-ai/models"; import { complete } from "@oh-my-pi/pi-ai/stream"; import type { Api, AssistantMessage, Context, Message, Model, Tool, ToolResultMessage } from "@oh-my-pi/pi-ai/types"; import { Type } from "@sinclair/typebox"; -import { describe, expect, it } from "vitest"; +import { e2eApiKey } from "./oauth"; // Tool for testing const weatherSchema = Type.Object({ @@ -366,7 +367,7 @@ async function testProviderHandoff( } describe("Cross-Provider Handoff Tests", () => { - describe.skipIf(!process.env.ANTHROPIC_API_KEY)("Anthropic Provider Handoff", () => { + describe.skipIf(!e2eApiKey("ANTHROPIC_API_KEY"))("Anthropic Provider Handoff", () => { const model = getModel("anthropic", "claude-3-5-haiku-20241022"); it("should handle contexts from all providers", async () => { @@ -402,7 +403,7 @@ describe("Cross-Provider Handoff Tests", () => { }); }); - describe.skipIf(!process.env.GEMINI_API_KEY)("Google Provider Handoff", () => { + describe.skipIf(!e2eApiKey("GEMINI_API_KEY"))("Google Provider Handoff", () => { const model = getModel("google", "gemini-2.5-flash"); it("should handle contexts from all providers", async () => { @@ -438,7 +439,7 @@ describe("Cross-Provider Handoff Tests", () => { }); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Completions Provider Handoff", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Completions Provider Handoff", () => { const model: Model<"openai-completions"> = { ...getModel("openai", "gpt-4o-mini"), api: "openai-completions" }; it("should handle contexts from all providers", async () => { @@ -474,7 +475,7 @@ describe("Cross-Provider Handoff Tests", () => { }); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Responses Provider Handoff", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Responses Provider Handoff", () => { const model = getModel("openai", "gpt-5-mini"); it("should handle contexts from all providers", async () => { @@ -510,7 +511,7 @@ describe("Cross-Provider Handoff Tests", () => { }); }); - describe.skipIf(!process.env.MISTRAL_API_KEY)("Mistral Provider Handoff", () => { + describe.skipIf(!e2eApiKey("MISTRAL_API_KEY"))("Mistral Provider Handoff", () => { const model = getModel("mistral", "devstral-medium-latest"); it("should handle contexts from all providers", async () => { diff --git a/packages/ai/test/image-limits.test.ts b/packages/ai/test/image-limits.test.ts index edd4bd8fc..e07aee12d 100644 --- a/packages/ai/test/image-limits.test.ts +++ b/packages/ai/test/image-limits.test.ts @@ -67,13 +67,14 @@ * ============================================================================ */ +import { afterAll, beforeAll, describe, expect, it } from "bun:test"; import { execSync } from "node:child_process"; import { mkdirSync, rmSync } from "node:fs"; import { join } from "node:path"; import { getModel } from "@oh-my-pi/pi-ai/models"; import { complete } from "@oh-my-pi/pi-ai/stream"; import type { Api, Context, ImageContent, Model, OptionsForApi, UserMessage } from "@oh-my-pi/pi-ai/types"; -import { afterAll, beforeAll, describe, expect, it } from "vitest"; +import { e2eApiKey } from "./oauth"; const TEMP_DIR = join(import.meta.dir, ".temp-images"); @@ -276,7 +277,7 @@ describe("Image Limits E2E Tests", () => { // Anthropic (claude-3-5-haiku-20241022) // Limits: 100 images, 5MB per image, 8000px max dimension // ------------------------------------------------------------------------- - describe.skipIf(!process.env.ANTHROPIC_API_KEY)("Anthropic (claude-3-5-haiku-20241022)", () => { + describe.skipIf(!e2eApiKey("ANTHROPIC_API_KEY"))("Anthropic (claude-3-5-haiku-20241022)", () => { const model = getModel("anthropic", "claude-3-5-haiku-20241022"); it("should accept a small number of images (5)", async () => { @@ -284,72 +285,89 @@ describe("Image Limits E2E Tests", () => { expect(result.success, result.error).toBe(true); }); - it("should find maximum image count limit", { timeout: 600000 }, async () => { - // Known limit: 100 images - const { limit, lastError } = await findLimit((count) => testImageCount(model, count, smallImage), 20, 120, 20); - console.log(`\n Anthropic max images: ~${limit} (last error: ${lastError})`); - expect(limit).toBeGreaterThanOrEqual(80); - expect(limit).toBeLessThanOrEqual(100); - }); + it( + "should find maximum image count limit", + async () => { + // Known limit: 100 images + const { limit, lastError } = await findLimit( + (count) => testImageCount(model, count, smallImage), + 20, + 120, + 20, + ); + console.log(`\n Anthropic max images: ~${limit} (last error: ${lastError})`); + expect(limit).toBeGreaterThanOrEqual(80); + expect(limit).toBeLessThanOrEqual(100); + }, + { timeout: 600000 }, + ); - it("should find maximum image size limit", { timeout: 600000 }, async () => { - const MB = 1024 * 1024; - // Known limit: 5MB per image - const sizes = [1, 2, 3, 4, 5, 6]; + it( + "should find maximum image size limit", + async () => { + const MB = 1024 * 1024; + // Known limit: 5MB per image + const sizes = [1, 2, 3, 4, 5, 6]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const sizeMB of sizes) { - console.log(` Testing size: ${sizeMB}MB...`); - const imageBase64 = generateImageWithSize(sizeMB * MB, `size-${sizeMB}mb.png`); - const result = await testImageSize(model, imageBase64); - if (result.success) { - lastSuccess = sizeMB; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 100)}`); - break; + for (const sizeMB of sizes) { + console.log(` Testing size: ${sizeMB}MB...`); + const imageBase64 = generateImageWithSize(sizeMB * MB, `size-${sizeMB}mb.png`); + const result = await testImageSize(model, imageBase64); + if (result.success) { + lastSuccess = sizeMB; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 100)}`); + break; + } } - } - console.log(`\n Anthropic max image size: ~${lastSuccess}MB (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(1); - }); + console.log(`\n Anthropic max image size: ~${lastSuccess}MB (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(1); + }, + { timeout: 600000 }, + ); - it("should find maximum image dimension limit", { timeout: 600000 }, async () => { - // Known limit: 8000px - const dimensions = [1000, 2000, 4000, 6000, 8000, 10000]; + it( + "should find maximum image dimension limit", + async () => { + // Known limit: 8000px + const dimensions = [1000, 2000, 4000, 6000, 8000, 10000]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const dim of dimensions) { - console.log(` Testing dimension: ${dim}x${dim}...`); - const imageBase64 = generateImage(dim, dim, `dim-${dim}.png`); - const result = await testImageDimensions(model, imageBase64); - if (result.success) { - lastSuccess = dim; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 100)}`); - break; + for (const dim of dimensions) { + console.log(` Testing dimension: ${dim}x${dim}...`); + const imageBase64 = generateImage(dim, dim, `dim-${dim}.png`); + const result = await testImageDimensions(model, imageBase64); + if (result.success) { + lastSuccess = dim; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 100)}`); + break; + } } - } - console.log(`\n Anthropic max dimension: ~${lastSuccess}px (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(6000); - expect(lastSuccess).toBeLessThanOrEqual(8000); - }); + console.log(`\n Anthropic max dimension: ~${lastSuccess}px (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(6000); + expect(lastSuccess).toBeLessThanOrEqual(8000); + }, + { timeout: 600000 }, + ); }); // ------------------------------------------------------------------------- // OpenAI (gpt-4o-mini via openai-completions) // Limits: 500 images, ~20MB per image (documented) // ------------------------------------------------------------------------- - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI (gpt-4o-mini)", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI (gpt-4o-mini)", () => { const model: Model<"openai-completions"> = { ...getModel("openai", "gpt-4o-mini"), api: "openai-completions" }; it("should accept a small number of images (5)", async () => { @@ -357,75 +375,87 @@ describe("Image Limits E2E Tests", () => { expect(result.success, result.error).toBe(true); }); - it("should find maximum image count limit", { timeout: 600000 }, async () => { - // Known limit: 500 images - const { limit, lastError } = await findLimit( - (count) => testImageCount(model, count, smallImage), - 100, - 600, - 100, - ); - console.log(`\n OpenAI max images: ~${limit} (last error: ${lastError})`); - expect(limit).toBeGreaterThanOrEqual(400); - expect(limit).toBeLessThanOrEqual(500); - }); + it( + "should find maximum image count limit", + async () => { + // Known limit: 500 images + const { limit, lastError } = await findLimit( + (count) => testImageCount(model, count, smallImage), + 100, + 600, + 100, + ); + console.log(`\n OpenAI max images: ~${limit} (last error: ${lastError})`); + expect(limit).toBeGreaterThanOrEqual(400); + expect(limit).toBeLessThanOrEqual(500); + }, + { timeout: 600000 }, + ); - it("should find maximum image size limit", { timeout: 600000 }, async () => { - const MB = 1024 * 1024; - // Documented limit: 20MB - const sizes = [5, 10, 15, 20, 25]; + it( + "should find maximum image size limit", + async () => { + const MB = 1024 * 1024; + // Documented limit: 20MB + const sizes = [5, 10, 15, 20, 25]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const sizeMB of sizes) { - console.log(` Testing size: ${sizeMB}MB...`); - const imageBase64 = generateImageWithSize(sizeMB * MB, `size-${sizeMB}mb.png`); - const result = await testImageSize(model, imageBase64); - if (result.success) { - lastSuccess = sizeMB; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 100)}`); - break; + for (const sizeMB of sizes) { + console.log(` Testing size: ${sizeMB}MB...`); + const imageBase64 = generateImageWithSize(sizeMB * MB, `size-${sizeMB}mb.png`); + const result = await testImageSize(model, imageBase64); + if (result.success) { + lastSuccess = sizeMB; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 100)}`); + break; + } } - } - console.log(`\n OpenAI max image size: ~${lastSuccess}MB (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(15); - }); + console.log(`\n OpenAI max image size: ~${lastSuccess}MB (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(15); + }, + { timeout: 600000 }, + ); - it("should find maximum image dimension limit", { timeout: 600000 }, async () => { - const dimensions = [2000, 4000, 8000, 16000, 20000]; + it( + "should find maximum image dimension limit", + async () => { + const dimensions = [2000, 4000, 8000, 16000, 20000]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const dim of dimensions) { - console.log(` Testing dimension: ${dim}x${dim}...`); - const imageBase64 = generateImage(dim, dim, `dim-${dim}.png`); - const result = await testImageDimensions(model, imageBase64); - if (result.success) { - lastSuccess = dim; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 100)}`); - break; + for (const dim of dimensions) { + console.log(` Testing dimension: ${dim}x${dim}...`); + const imageBase64 = generateImage(dim, dim, `dim-${dim}.png`); + const result = await testImageDimensions(model, imageBase64); + if (result.success) { + lastSuccess = dim; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 100)}`); + break; + } } - } - console.log(`\n OpenAI max dimension: ~${lastSuccess}px (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(2000); - }); + console.log(`\n OpenAI max dimension: ~${lastSuccess}px (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(2000); + }, + { timeout: 600000 }, + ); }); // ------------------------------------------------------------------------- // Google Gemini (gemini-2.5-flash) // Limits: Very high (~2500 images), large size support // ------------------------------------------------------------------------- - describe.skipIf(!process.env.GEMINI_API_KEY)("Gemini (gemini-2.5-flash)", () => { + describe.skipIf(!e2eApiKey("GEMINI_API_KEY"))("Gemini (gemini-2.5-flash)", () => { const model = getModel("google", "gemini-2.5-flash"); it("should accept a small number of images (5)", async () => { @@ -433,74 +463,86 @@ describe("Image Limits E2E Tests", () => { expect(result.success, result.error).toBe(true); }); - it("should find maximum image count limit", { timeout: 900000 }, async () => { - // Known to work up to ~2500, hits errors around 3000 - const { limit, lastError } = await findLimit( - (count) => testImageCount(model, count, smallImage), - 500, - 3000, - 500, - ); - console.log(`\n Gemini max images: ~${limit} (last error: ${lastError})`); - expect(limit).toBeGreaterThanOrEqual(500); - }); + it( + "should find maximum image count limit", + async () => { + // Known to work up to ~2500, hits errors around 3000 + const { limit, lastError } = await findLimit( + (count) => testImageCount(model, count, smallImage), + 500, + 3000, + 500, + ); + console.log(`\n Gemini max images: ~${limit} (last error: ${lastError})`); + expect(limit).toBeGreaterThanOrEqual(500); + }, + { timeout: 900000 }, + ); - it("should find maximum image size limit", { timeout: 600000 }, async () => { - const MB = 1024 * 1024; - // Very permissive, tested up to 60MB successfully - const sizes = [10, 20, 30, 40]; + it( + "should find maximum image size limit", + async () => { + const MB = 1024 * 1024; + // Very permissive, tested up to 60MB successfully + const sizes = [10, 20, 30, 40]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const sizeMB of sizes) { - console.log(` Testing size: ${sizeMB}MB...`); - const imageBase64 = generateImageWithSize(sizeMB * MB, `size-${sizeMB}mb.png`); - const result = await testImageSize(model, imageBase64); - if (result.success) { - lastSuccess = sizeMB; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 100)}`); - break; + for (const sizeMB of sizes) { + console.log(` Testing size: ${sizeMB}MB...`); + const imageBase64 = generateImageWithSize(sizeMB * MB, `size-${sizeMB}mb.png`); + const result = await testImageSize(model, imageBase64); + if (result.success) { + lastSuccess = sizeMB; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 100)}`); + break; + } } - } - console.log(`\n Gemini max image size: ~${lastSuccess}MB (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(20); - }); + console.log(`\n Gemini max image size: ~${lastSuccess}MB (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(20); + }, + { timeout: 600000 }, + ); - it("should find maximum image dimension limit", { timeout: 600000 }, async () => { - const dimensions = [2000, 4000, 8000, 16000, 20000]; + it( + "should find maximum image dimension limit", + async () => { + const dimensions = [2000, 4000, 8000, 16000, 20000]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const dim of dimensions) { - console.log(` Testing dimension: ${dim}x${dim}...`); - const imageBase64 = generateImage(dim, dim, `dim-${dim}.png`); - const result = await testImageDimensions(model, imageBase64); - if (result.success) { - lastSuccess = dim; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 100)}`); - break; + for (const dim of dimensions) { + console.log(` Testing dimension: ${dim}x${dim}...`); + const imageBase64 = generateImage(dim, dim, `dim-${dim}.png`); + const result = await testImageDimensions(model, imageBase64); + if (result.success) { + lastSuccess = dim; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 100)}`); + break; + } } - } - console.log(`\n Gemini max dimension: ~${lastSuccess}px (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(2000); - }); + console.log(`\n Gemini max dimension: ~${lastSuccess}px (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(2000); + }, + { timeout: 600000 }, + ); }); // ------------------------------------------------------------------------- // Mistral (pixtral-12b) // Limits: ~8 images, ~15MB per image // ------------------------------------------------------------------------- - describe.skipIf(!process.env.MISTRAL_API_KEY)("Mistral (pixtral-12b)", () => { + describe.skipIf(!e2eApiKey("MISTRAL_API_KEY"))("Mistral (pixtral-12b)", () => { const model = getModel("mistral", "pixtral-12b"); it("should accept a small number of images (5)", async () => { @@ -508,68 +550,80 @@ describe("Image Limits E2E Tests", () => { expect(result.success, result.error).toBe(true); }); - it("should find maximum image count limit", { timeout: 600000 }, async () => { - // Known to fail around 9 images - const { limit, lastError } = await findLimit((count) => testImageCount(model, count, smallImage), 5, 15, 1); - console.log(`\n Mistral max images: ~${limit} (last error: ${lastError})`); - expect(limit).toBeGreaterThanOrEqual(5); - }); + it( + "should find maximum image count limit", + async () => { + // Known to fail around 9 images + const { limit, lastError } = await findLimit((count) => testImageCount(model, count, smallImage), 5, 15, 1); + console.log(`\n Mistral max images: ~${limit} (last error: ${lastError})`); + expect(limit).toBeGreaterThanOrEqual(5); + }, + { timeout: 600000 }, + ); - it("should find maximum image size limit", { timeout: 600000 }, async () => { - const MB = 1024 * 1024; - const sizes = [5, 10, 15, 20]; + it( + "should find maximum image size limit", + async () => { + const MB = 1024 * 1024; + const sizes = [5, 10, 15, 20]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const sizeMB of sizes) { - console.log(` Testing size: ${sizeMB}MB...`); - const imageBase64 = generateImageWithSize(sizeMB * MB, `size-${sizeMB}mb.png`); - const result = await testImageSize(model, imageBase64); - if (result.success) { - lastSuccess = sizeMB; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 100)}`); - break; + for (const sizeMB of sizes) { + console.log(` Testing size: ${sizeMB}MB...`); + const imageBase64 = generateImageWithSize(sizeMB * MB, `size-${sizeMB}mb.png`); + const result = await testImageSize(model, imageBase64); + if (result.success) { + lastSuccess = sizeMB; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 100)}`); + break; + } } - } - console.log(`\n Mistral max image size: ~${lastSuccess}MB (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(5); - }); + console.log(`\n Mistral max image size: ~${lastSuccess}MB (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(5); + }, + { timeout: 600000 }, + ); - it("should find maximum image dimension limit", { timeout: 600000 }, async () => { - const dimensions = [2000, 4000, 8000, 16000, 20000]; + it( + "should find maximum image dimension limit", + async () => { + const dimensions = [2000, 4000, 8000, 16000, 20000]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const dim of dimensions) { - console.log(` Testing dimension: ${dim}x${dim}...`); - const imageBase64 = generateImage(dim, dim, `dim-${dim}.png`); - const result = await testImageDimensions(model, imageBase64); - if (result.success) { - lastSuccess = dim; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 100)}`); - break; + for (const dim of dimensions) { + console.log(` Testing dimension: ${dim}x${dim}...`); + const imageBase64 = generateImage(dim, dim, `dim-${dim}.png`); + const result = await testImageDimensions(model, imageBase64); + if (result.success) { + lastSuccess = dim; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 100)}`); + break; + } } - } - console.log(`\n Mistral max dimension: ~${lastSuccess}px (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(2000); - }); + console.log(`\n Mistral max dimension: ~${lastSuccess}px (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(2000); + }, + { timeout: 600000 }, + ); }); // ------------------------------------------------------------------------- // OpenRouter (z-ai/glm-4.5v) // Limits: Context-window limited (~45 images at 100x100), ~15MB per image // ------------------------------------------------------------------------- - describe.skipIf(!process.env.OPENROUTER_API_KEY)("OpenRouter (z-ai/glm-4.5v)", () => { + describe.skipIf(!e2eApiKey("OPENROUTER_API_KEY"))("OpenRouter (z-ai/glm-4.5v)", () => { const model = getModel("openrouter", "z-ai/glm-4.5v"); it("should accept a small number of images (5)", async () => { @@ -577,67 +631,84 @@ describe("Image Limits E2E Tests", () => { expect(result.success, result.error).toBe(true); }); - it("should find maximum image count limit", { timeout: 600000 }, async () => { - // Limited by context window, not explicit image limit - const { limit, lastError } = await findLimit((count) => testImageCount(model, count, smallImage), 10, 60, 10); - console.log(`\n OpenRouter max images: ~${limit} (last error: ${lastError})`); - expect(limit).toBeGreaterThanOrEqual(10); - }); + it( + "should find maximum image count limit", + async () => { + // Limited by context window, not explicit image limit + const { limit, lastError } = await findLimit( + (count) => testImageCount(model, count, smallImage), + 10, + 60, + 10, + ); + console.log(`\n OpenRouter max images: ~${limit} (last error: ${lastError})`); + expect(limit).toBeGreaterThanOrEqual(10); + }, + { timeout: 600000 }, + ); - it("should find maximum image size limit", { timeout: 600000 }, async () => { - const MB = 1024 * 1024; - const sizes = [5, 10, 15, 20]; + it( + "should find maximum image size limit", + async () => { + const MB = 1024 * 1024; + const sizes = [5, 10, 15, 20]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const sizeMB of sizes) { - console.log(` Testing size: ${sizeMB}MB...`); - const imageBase64 = generateImageWithSize(sizeMB * MB, `size-${sizeMB}mb.png`); - const result = await testImageSize(model, imageBase64); - if (result.success) { - lastSuccess = sizeMB; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 100)}`); - break; + for (const sizeMB of sizes) { + console.log(` Testing size: ${sizeMB}MB...`); + const imageBase64 = generateImageWithSize(sizeMB * MB, `size-${sizeMB}mb.png`); + const result = await testImageSize(model, imageBase64); + if (result.success) { + lastSuccess = sizeMB; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 100)}`); + break; + } } - } - console.log(`\n OpenRouter max image size: ~${lastSuccess}MB (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(5); - }); + console.log(`\n OpenRouter max image size: ~${lastSuccess}MB (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(5); + }, + { timeout: 600000 }, + ); - it("should find maximum image dimension limit", { timeout: 600000 }, async () => { - const dimensions = [2000, 4000, 8000, 16000, 20000]; + it( + "should find maximum image dimension limit", + async () => { + const dimensions = [2000, 4000, 8000, 16000, 20000]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const dim of dimensions) { - console.log(` Testing dimension: ${dim}x${dim}...`); - const imageBase64 = generateImage(dim, dim, `dim-${dim}.png`); - const result = await testImageDimensions(model, imageBase64); - if (result.success) { - lastSuccess = dim; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 100)}`); - break; + for (const dim of dimensions) { + console.log(` Testing dimension: ${dim}x${dim}...`); + const imageBase64 = generateImage(dim, dim, `dim-${dim}.png`); + const result = await testImageDimensions(model, imageBase64); + if (result.success) { + lastSuccess = dim; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 100)}`); + break; + } } - } - console.log(`\n OpenRouter max dimension: ~${lastSuccess}px (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(2000); - }); + console.log(`\n OpenRouter max dimension: ~${lastSuccess}px (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(2000); + }, + { timeout: 600000 }, + ); }); // ------------------------------------------------------------------------- // xAI (grok-2-vision) // ------------------------------------------------------------------------- - describe.skipIf(!process.env.XAI_API_KEY)("xAI (grok-2-vision)", () => { + describe.skipIf(!e2eApiKey("XAI_API_KEY"))("xAI (grok-2-vision)", () => { const model = getModel("xai", "grok-2-vision"); it("should accept a small number of images (5)", async () => { @@ -645,66 +716,83 @@ describe("Image Limits E2E Tests", () => { expect(result.success, result.error).toBe(true); }); - it("should find maximum image count limit", { timeout: 600000 }, async () => { - const { limit, lastError } = await findLimit((count) => testImageCount(model, count, smallImage), 10, 100, 10); - console.log(`\n xAI max images: ~${limit} (last error: ${lastError})`); - expect(limit).toBeGreaterThanOrEqual(5); - }); + it( + "should find maximum image count limit", + async () => { + const { limit, lastError } = await findLimit( + (count) => testImageCount(model, count, smallImage), + 10, + 100, + 10, + ); + console.log(`\n xAI max images: ~${limit} (last error: ${lastError})`); + expect(limit).toBeGreaterThanOrEqual(5); + }, + { timeout: 600000 }, + ); - it("should find maximum image size limit", { timeout: 600000 }, async () => { - const MB = 1024 * 1024; - const sizes = [5, 10, 15, 20, 25]; + it( + "should find maximum image size limit", + async () => { + const MB = 1024 * 1024; + const sizes = [5, 10, 15, 20, 25]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const sizeMB of sizes) { - console.log(` Testing size: ${sizeMB}MB...`); - const imageBase64 = generateImageWithSize(sizeMB * MB, `size-${sizeMB}mb.png`); - const result = await testImageSize(model, imageBase64); - if (result.success) { - lastSuccess = sizeMB; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 100)}`); - break; + for (const sizeMB of sizes) { + console.log(` Testing size: ${sizeMB}MB...`); + const imageBase64 = generateImageWithSize(sizeMB * MB, `size-${sizeMB}mb.png`); + const result = await testImageSize(model, imageBase64); + if (result.success) { + lastSuccess = sizeMB; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 100)}`); + break; + } } - } - console.log(`\n xAI max image size: ~${lastSuccess}MB (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(5); - }); + console.log(`\n xAI max image size: ~${lastSuccess}MB (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(5); + }, + { timeout: 600000 }, + ); - it("should find maximum image dimension limit", { timeout: 600000 }, async () => { - const dimensions = [2000, 4000, 8000, 16000, 20000]; + it( + "should find maximum image dimension limit", + async () => { + const dimensions = [2000, 4000, 8000, 16000, 20000]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const dim of dimensions) { - console.log(` Testing dimension: ${dim}x${dim}...`); - const imageBase64 = generateImage(dim, dim, `dim-${dim}.png`); - const result = await testImageDimensions(model, imageBase64); - if (result.success) { - lastSuccess = dim; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 100)}`); - break; + for (const dim of dimensions) { + console.log(` Testing dimension: ${dim}x${dim}...`); + const imageBase64 = generateImage(dim, dim, `dim-${dim}.png`); + const result = await testImageDimensions(model, imageBase64); + if (result.success) { + lastSuccess = dim; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 100)}`); + break; + } } - } - console.log(`\n xAI max dimension: ~${lastSuccess}px (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(2000); - }); + console.log(`\n xAI max dimension: ~${lastSuccess}px (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(2000); + }, + { timeout: 600000 }, + ); }); // ------------------------------------------------------------------------- // Groq (llama-4-scout-17b) // ------------------------------------------------------------------------- - describe.skipIf(!process.env.GROQ_API_KEY)("Groq (llama-4-scout-17b)", () => { + describe.skipIf(!e2eApiKey("GROQ_API_KEY"))("Groq (llama-4-scout-17b)", () => { const model = getModel("groq", "meta-llama/llama-4-scout-17b-16e-instruct"); it("should accept a small number of images (5)", async () => { @@ -712,66 +800,78 @@ describe("Image Limits E2E Tests", () => { expect(result.success, result.error).toBe(true); }); - it("should find maximum image count limit", { timeout: 600000 }, async () => { - const { limit, lastError } = await findLimit((count) => testImageCount(model, count, smallImage), 5, 50, 5); - console.log(`\n Groq max images: ~${limit} (last error: ${lastError})`); - expect(limit).toBeGreaterThanOrEqual(5); - }); + it( + "should find maximum image count limit", + async () => { + const { limit, lastError } = await findLimit((count) => testImageCount(model, count, smallImage), 5, 50, 5); + console.log(`\n Groq max images: ~${limit} (last error: ${lastError})`); + expect(limit).toBeGreaterThanOrEqual(5); + }, + { timeout: 600000 }, + ); - it("should find maximum image size limit", { timeout: 600000 }, async () => { - const MB = 1024 * 1024; - const sizes = [1, 5, 10, 15, 20]; + it( + "should find maximum image size limit", + async () => { + const MB = 1024 * 1024; + const sizes = [1, 5, 10, 15, 20]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const sizeMB of sizes) { - console.log(` Testing size: ${sizeMB}MB...`); - const imageBase64 = generateImageWithSize(sizeMB * MB, `size-${sizeMB}mb.png`); - const result = await testImageSize(model, imageBase64); - if (result.success) { - lastSuccess = sizeMB; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 100)}`); - break; + for (const sizeMB of sizes) { + console.log(` Testing size: ${sizeMB}MB...`); + const imageBase64 = generateImageWithSize(sizeMB * MB, `size-${sizeMB}mb.png`); + const result = await testImageSize(model, imageBase64); + if (result.success) { + lastSuccess = sizeMB; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 100)}`); + break; + } } - } - console.log(`\n Groq max image size: ~${lastSuccess}MB (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(1); - }); + console.log(`\n Groq max image size: ~${lastSuccess}MB (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(1); + }, + { timeout: 600000 }, + ); - it("should find maximum image dimension limit", { timeout: 600000 }, async () => { - const dimensions = [2000, 4000, 8000, 16000, 20000]; + it( + "should find maximum image dimension limit", + async () => { + const dimensions = [2000, 4000, 8000, 16000, 20000]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const dim of dimensions) { - console.log(` Testing dimension: ${dim}x${dim}...`); - const imageBase64 = generateImage(dim, dim, `dim-${dim}.png`); - const result = await testImageDimensions(model, imageBase64); - if (result.success) { - lastSuccess = dim; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 100)}`); - break; + for (const dim of dimensions) { + console.log(` Testing dimension: ${dim}x${dim}...`); + const imageBase64 = generateImage(dim, dim, `dim-${dim}.png`); + const result = await testImageDimensions(model, imageBase64); + if (result.success) { + lastSuccess = dim; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 100)}`); + break; + } } - } - console.log(`\n Groq max dimension: ~${lastSuccess}px (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(2000); - }); + console.log(`\n Groq max dimension: ~${lastSuccess}px (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(2000); + }, + { timeout: 600000 }, + ); }); // ------------------------------------------------------------------------- // zAI (glm-4.5v) // ------------------------------------------------------------------------- - describe.skipIf(!process.env.ZAI_API_KEY)("zAI (glm-4.5v)", () => { + describe.skipIf(!e2eApiKey("ZAI_API_KEY"))("zAI (glm-4.5v)", () => { const model = getModel("zai", "glm-4.5v"); it("should accept a small number of images (5)", async () => { @@ -779,60 +879,77 @@ describe("Image Limits E2E Tests", () => { expect(result.success, result.error).toBe(true); }); - it("should find maximum image count limit", { timeout: 600000 }, async () => { - const { limit, lastError } = await findLimit((count) => testImageCount(model, count, smallImage), 10, 100, 10); - console.log(`\n zAI max images: ~${limit} (last error: ${lastError})`); - expect(limit).toBeGreaterThanOrEqual(5); - }); + it( + "should find maximum image count limit", + async () => { + const { limit, lastError } = await findLimit( + (count) => testImageCount(model, count, smallImage), + 10, + 100, + 10, + ); + console.log(`\n zAI max images: ~${limit} (last error: ${lastError})`); + expect(limit).toBeGreaterThanOrEqual(5); + }, + { timeout: 600000 }, + ); - it("should find maximum image size limit", { timeout: 600000 }, async () => { - const MB = 1024 * 1024; - const sizes = [5, 10, 15, 20]; + it( + "should find maximum image size limit", + async () => { + const MB = 1024 * 1024; + const sizes = [5, 10, 15, 20]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const sizeMB of sizes) { - console.log(` Testing size: ${sizeMB}MB...`); - const imageBase64 = generateImageWithSize(sizeMB * MB, `size-${sizeMB}mb.png`); - const result = await testImageSize(model, imageBase64); - if (result.success) { - lastSuccess = sizeMB; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 100)}`); - break; + for (const sizeMB of sizes) { + console.log(` Testing size: ${sizeMB}MB...`); + const imageBase64 = generateImageWithSize(sizeMB * MB, `size-${sizeMB}mb.png`); + const result = await testImageSize(model, imageBase64); + if (result.success) { + lastSuccess = sizeMB; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 100)}`); + break; + } } - } - console.log(`\n zAI max image size: ~${lastSuccess}MB (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(5); - }); + console.log(`\n zAI max image size: ~${lastSuccess}MB (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(5); + }, + { timeout: 600000 }, + ); - it("should find maximum image dimension limit", { timeout: 600000 }, async () => { - const dimensions = [2000, 4000, 8000, 16000, 20000]; + it( + "should find maximum image dimension limit", + async () => { + const dimensions = [2000, 4000, 8000, 16000, 20000]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const dim of dimensions) { - console.log(` Testing dimension: ${dim}x${dim}...`); - const imageBase64 = generateImage(dim, dim, `dim-${dim}.png`); - const result = await testImageDimensions(model, imageBase64); - if (result.success) { - lastSuccess = dim; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 100)}`); - break; + for (const dim of dimensions) { + console.log(` Testing dimension: ${dim}x${dim}...`); + const imageBase64 = generateImage(dim, dim, `dim-${dim}.png`); + const result = await testImageDimensions(model, imageBase64); + if (result.success) { + lastSuccess = dim; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 100)}`); + break; + } } - } - console.log(`\n zAI max dimension: ~${lastSuccess}px (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(2000); - }); + console.log(`\n zAI max dimension: ~${lastSuccess}px (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(2000); + }, + { timeout: 600000 }, + ); }); // ========================================================================= @@ -863,9 +980,8 @@ describe("Image Limits E2E Tests", () => { // Anthropic - 5MB per image limit, 32MB total request, 100 image count // Using 3MB to stay under 5MB limit (generateImageWithSize has overhead) - it.skipIf(!process.env.ANTHROPIC_API_KEY)( + it.skipIf(!e2eApiKey("ANTHROPIC_API_KEY"))( "Anthropic: max ~3MB images before rejection", - { timeout: 900000 }, async () => { const model = getModel("anthropic", "claude-3-5-haiku-20241022"); const image3mb = getImageAtSize(3); @@ -891,13 +1007,13 @@ describe("Image Limits E2E Tests", () => { console.log(`\n Anthropic max ~3MB images: ${lastSuccess} (last error: ${lastError})`); expect(lastSuccess).toBeGreaterThanOrEqual(1); }, + { timeout: 900000 }, ); // OpenAI - 20MB per image documented, we found ≥25MB works // Test with 15MB images to stay safely under limit - it.skipIf(!process.env.OPENAI_API_KEY)( + it.skipIf(!e2eApiKey("OPENAI_API_KEY"))( "OpenAI: max ~15MB images before rejection", - { timeout: 1800000 }, async () => { const model = getModel("openai", "gpt-4o-mini"); const image15mb = getImageAtSize(15); @@ -923,13 +1039,13 @@ describe("Image Limits E2E Tests", () => { console.log(`\n OpenAI max ~15MB images: ${lastSuccess} (last error: ${lastError})`); expect(lastSuccess).toBeGreaterThanOrEqual(1); }, + { timeout: 1800000 }, ); // Gemini - very permissive, ≥40MB per image works // Test with 20MB images - it.skipIf(!process.env.GEMINI_API_KEY)( + it.skipIf(!e2eApiKey("GEMINI_API_KEY"))( "Gemini: max ~20MB images before rejection", - { timeout: 1800000 }, async () => { const model = getModel("google", "gemini-2.5-flash"); const image20mb = getImageAtSize(20); @@ -955,13 +1071,13 @@ describe("Image Limits E2E Tests", () => { console.log(`\n Gemini max ~20MB images: ${lastSuccess} (last error: ${lastError})`); expect(lastSuccess).toBeGreaterThanOrEqual(1); }, + { timeout: 1800000 }, ); // Mistral - 8 image limit, ~15MB per image // Test with 10MB images (safely under limit) - it.skipIf(!process.env.MISTRAL_API_KEY)( + it.skipIf(!e2eApiKey("MISTRAL_API_KEY"))( "Mistral: max ~10MB images before rejection", - { timeout: 600000 }, async () => { const model = getModel("mistral", "pixtral-12b"); const image10mb = getImageAtSize(10); @@ -987,41 +1103,45 @@ describe("Image Limits E2E Tests", () => { console.log(`\n Mistral max ~10MB images: ${lastSuccess} (last error: ${lastError})`); expect(lastSuccess).toBeGreaterThanOrEqual(1); }, + { timeout: 600000 }, ); // xAI - 25MB per image limit (26214400 bytes exact) // Test with 20MB images (safely under limit) - it.skipIf(!process.env.XAI_API_KEY)("xAI: max ~20MB images before rejection", { timeout: 1200000 }, async () => { - const model = getModel("xai", "grok-2-vision"); - const image20mb = getImageAtSize(20); - // Test progressively - const counts = [1, 2, 5, 10, 20]; + it.skipIf(!e2eApiKey("XAI_API_KEY"))( + "xAI: max ~20MB images before rejection", + async () => { + const model = getModel("xai", "grok-2-vision"); + const image20mb = getImageAtSize(20); + // Test progressively + const counts = [1, 2, 5, 10, 20]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const count of counts) { - console.log(` Testing ${count} x ~20MB images...`); - const result = await testImageCount(model, count, image20mb); - if (result.success) { - lastSuccess = count; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 150)}`); - break; + for (const count of counts) { + console.log(` Testing ${count} x ~20MB images...`); + const result = await testImageCount(model, count, image20mb); + if (result.success) { + lastSuccess = count; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 150)}`); + break; + } } - } - console.log(`\n xAI max ~20MB images: ${lastSuccess} (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(1); - }); + console.log(`\n xAI max ~20MB images: ${lastSuccess} (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(1); + }, + { timeout: 1200000 }, + ); // Groq - very limited (5 images, ~5760px max due to 33M pixel limit) // 8k images (64M pixels) exceed limit, so test with 5760px images instead - it.skipIf(!process.env.GROQ_API_KEY)( + it.skipIf(!e2eApiKey("GROQ_API_KEY"))( "Groq: max 5760px images before rejection", - { timeout: 600000 }, async () => { const model = getModel("groq", "meta-llama/llama-4-scout-17b-16e-instruct"); // Generate 5760x5760 image (33177600 pixels = Groq's limit) @@ -1050,41 +1170,45 @@ describe("Image Limits E2E Tests", () => { console.log(`\n Groq max 5760px images: ${lastSuccess} (last error: ${lastError})`); expect(lastSuccess).toBeGreaterThanOrEqual(1); }, + { timeout: 600000 }, ); // zAI - ≥20MB per image, context-window limited (65k tokens) // Test with 15MB images - it.skipIf(!process.env.ZAI_API_KEY)("zAI: max ~15MB images before rejection", { timeout: 1200000 }, async () => { - const model = getModel("zai", "glm-4.5v"); - const image15mb = getImageAtSize(15); - // Context-limited, test progressively - const counts = [1, 2, 5, 10, 20]; + it.skipIf(!e2eApiKey("ZAI_API_KEY"))( + "zAI: max ~15MB images before rejection", + async () => { + const model = getModel("zai", "glm-4.5v"); + const image15mb = getImageAtSize(15); + // Context-limited, test progressively + const counts = [1, 2, 5, 10, 20]; - let lastSuccess = 0; - let lastError: string | undefined; + let lastSuccess = 0; + let lastError: string | undefined; - for (const count of counts) { - console.log(` Testing ${count} x ~15MB images...`); - const result = await testImageCount(model, count, image15mb); - if (result.success) { - lastSuccess = count; - console.log(` SUCCESS`); - } else { - lastError = result.error; - console.log(` FAILED: ${result.error?.substring(0, 150)}`); - break; + for (const count of counts) { + console.log(` Testing ${count} x ~15MB images...`); + const result = await testImageCount(model, count, image15mb); + if (result.success) { + lastSuccess = count; + console.log(` SUCCESS`); + } else { + lastError = result.error; + console.log(` FAILED: ${result.error?.substring(0, 150)}`); + break; + } } - } - console.log(`\n zAI max ~15MB images: ${lastSuccess} (last error: ${lastError})`); - expect(lastSuccess).toBeGreaterThanOrEqual(1); - }); + console.log(`\n zAI max ~15MB images: ${lastSuccess} (last error: ${lastError})`); + expect(lastSuccess).toBeGreaterThanOrEqual(1); + }, + { timeout: 1200000 }, + ); // OpenRouter - ~10MB per image, context-window limited (65k tokens) // Test with 5MB images (safer size) - it.skipIf(!process.env.OPENROUTER_API_KEY)( + it.skipIf(!e2eApiKey("OPENROUTER_API_KEY"))( "OpenRouter: max ~5MB images before rejection", - { timeout: 900000 }, async () => { const model = getModel("openrouter", "z-ai/glm-4.5v"); const image5mb = getImageAtSize(5); @@ -1110,6 +1234,7 @@ describe("Image Limits E2E Tests", () => { console.log(`\n OpenRouter max ~5MB images: ${lastSuccess} (last error: ${lastError})`); expect(lastSuccess).toBeGreaterThanOrEqual(1); }, + { timeout: 900000 }, ); }); }); diff --git a/packages/ai/test/image-tool-result.test.ts b/packages/ai/test/image-tool-result.test.ts index 83a1d3e47..a85dc4a82 100644 --- a/packages/ai/test/image-tool-result.test.ts +++ b/packages/ai/test/image-tool-result.test.ts @@ -1,11 +1,11 @@ +import { describe, expect, it } from "bun:test"; import { readFileSync } from "node:fs"; import { join } from "node:path"; import type { Api, Context, Model, Tool, ToolResultMessage } from "@oh-my-pi/pi-ai"; import { complete, getModel } from "@oh-my-pi/pi-ai"; import type { OptionsForApi } from "@oh-my-pi/pi-ai/types"; import { Type } from "@sinclair/typebox"; -import { describe, expect, it } from "vitest"; -import { resolveApiKey } from "./oauth"; +import { e2eApiKey, resolveApiKey } from "./oauth"; // Resolve OAuth tokens at module level (async, runs before tests) const oauthTokens = await Promise.all([ @@ -201,76 +201,124 @@ async function handleToolWithTextAndImageResult(model: Model { - describe.skipIf(!process.env.GEMINI_API_KEY)("Google Provider (gemini-2.5-flash)", () => { + describe.skipIf(!e2eApiKey("GEMINI_API_KEY"))("Google Provider (gemini-2.5-flash)", () => { const llm = getModel("google", "gemini-2.5-flash"); - it("should handle tool result with only image", { retry: 3, timeout: 30000 }, async () => { - await handleToolWithImageResult(llm); - }); + it( + "should handle tool result with only image", + async () => { + await handleToolWithImageResult(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle tool result with text and image", { retry: 3, timeout: 30000 }, async () => { - await handleToolWithTextAndImageResult(llm); - }); + it( + "should handle tool result with text and image", + async () => { + await handleToolWithTextAndImageResult(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Completions Provider (gpt-4o-mini)", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Completions Provider (gpt-4o-mini)", () => { const llm: Model<"openai-completions"> = { ...getModel("openai", "gpt-4o-mini"), api: "openai-completions" }; - it("should handle tool result with only image", { retry: 3, timeout: 30000 }, async () => { - await handleToolWithImageResult(llm); - }); + it( + "should handle tool result with only image", + async () => { + await handleToolWithImageResult(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle tool result with text and image", { retry: 3, timeout: 30000 }, async () => { - await handleToolWithTextAndImageResult(llm); - }); + it( + "should handle tool result with text and image", + async () => { + await handleToolWithTextAndImageResult(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Responses Provider (gpt-5-mini)", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Responses Provider (gpt-5-mini)", () => { const llm = getModel("openai", "gpt-5-mini"); - it("should handle tool result with only image", { retry: 3, timeout: 30000 }, async () => { - await handleToolWithImageResult(llm); - }); + it( + "should handle tool result with only image", + async () => { + await handleToolWithImageResult(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle tool result with text and image", { retry: 3, timeout: 30000 }, async () => { - await handleToolWithTextAndImageResult(llm); - }); + it( + "should handle tool result with text and image", + async () => { + await handleToolWithTextAndImageResult(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.ANTHROPIC_API_KEY)("Anthropic Provider (claude-haiku-4-5)", () => { + describe.skipIf(!e2eApiKey("ANTHROPIC_API_KEY"))("Anthropic Provider (claude-haiku-4-5)", () => { const model = getModel("anthropic", "claude-haiku-4-5"); - it("should handle tool result with only image", { retry: 3, timeout: 30000 }, async () => { - await handleToolWithImageResult(model); - }); + it( + "should handle tool result with only image", + async () => { + await handleToolWithImageResult(model); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle tool result with text and image", { retry: 3, timeout: 30000 }, async () => { - await handleToolWithTextAndImageResult(model); - }); + it( + "should handle tool result with text and image", + async () => { + await handleToolWithTextAndImageResult(model); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.OPENROUTER_API_KEY)("OpenRouter Provider (glm-4.5v)", () => { + describe.skipIf(!e2eApiKey("OPENROUTER_API_KEY"))("OpenRouter Provider (glm-4.5v)", () => { const llm = getModel("openrouter", "z-ai/glm-4.5v"); - it("should handle tool result with only image", { retry: 3, timeout: 30000 }, async () => { - await handleToolWithImageResult(llm); - }); + it( + "should handle tool result with only image", + async () => { + await handleToolWithImageResult(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle tool result with text and image", { retry: 3, timeout: 30000 }, async () => { - await handleToolWithTextAndImageResult(llm); - }); + it( + "should handle tool result with text and image", + async () => { + await handleToolWithTextAndImageResult(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.MISTRAL_API_KEY)("Mistral Provider (pixtral-12b)", () => { + describe.skipIf(!e2eApiKey("MISTRAL_API_KEY"))("Mistral Provider (pixtral-12b)", () => { const llm = getModel("mistral", "pixtral-12b"); - it("should handle tool result with only image", { retry: 3, timeout: 30000 }, async () => { - await handleToolWithImageResult(llm); - }); + it( + "should handle tool result with only image", + async () => { + await handleToolWithImageResult(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle tool result with text and image", { retry: 3, timeout: 30000 }, async () => { - await handleToolWithTextAndImageResult(llm); - }); + it( + "should handle tool result with text and image", + async () => { + await handleToolWithTextAndImageResult(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); // ========================================================================= @@ -282,116 +330,114 @@ describe("Tool Results with Images", () => { it.skipIf(!anthropicOAuthToken)( "should handle tool result with only image", - { retry: 3, timeout: 30000 }, async () => { await handleToolWithImageResult(model, { apiKey: anthropicOAuthToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!anthropicOAuthToken)( "should handle tool result with text and image", - { retry: 3, timeout: 30000 }, async () => { await handleToolWithTextAndImageResult(model, { apiKey: anthropicOAuthToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("GitHub Copilot Provider", () => { it.skipIf(!githubCopilotToken)( "gpt-4o - should handle tool result with only image", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "gpt-4o"); await handleToolWithImageResult(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!githubCopilotToken)( "gpt-4o - should handle tool result with text and image", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "gpt-4o"); await handleToolWithTextAndImageResult(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!githubCopilotToken)( "claude-sonnet-4 - should handle tool result with only image", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "claude-sonnet-4"); await handleToolWithImageResult(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!githubCopilotToken)( "claude-sonnet-4 - should handle tool result with text and image", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "claude-sonnet-4"); await handleToolWithTextAndImageResult(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("Google Gemini CLI Provider", () => { it.skipIf(!geminiCliToken)( "gemini-2.5-flash - should handle tool result with only image", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-gemini-cli", "gemini-2.5-flash"); await handleToolWithImageResult(llm, { apiKey: geminiCliToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!geminiCliToken)( "gemini-2.5-flash - should handle tool result with text and image", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-gemini-cli", "gemini-2.5-flash"); await handleToolWithTextAndImageResult(llm, { apiKey: geminiCliToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("Google Antigravity Provider", () => { it.skipIf(!antigravityToken)( "gemini-3-flash - should handle tool result with only image", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gemini-3-flash"); await handleToolWithImageResult(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "gemini-3-flash - should handle tool result with text and image", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gemini-3-flash"); await handleToolWithTextAndImageResult(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); /** These two don't work, the model simply won't call the tool, works in pi it.skipIf(!antigravityToken)( "claude-sonnet-4-5 - should handle tool result with only image", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "claude-sonnet-4-5"); await handleToolWithImageResult(llm, { apiKey: antigravityToken }); }, - ); + { retry: 3, timeout: 30000 }); it.skipIf(!antigravityToken)( "claude-sonnet-4-5 - should handle tool result with text and image", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "claude-sonnet-4-5"); await handleToolWithTextAndImageResult(llm, { apiKey: antigravityToken }); }, - );**/ + { retry: 3, timeout: 30000 });**/ // Note: gpt-oss-120b-medium does not support images, so not tested here }); @@ -399,20 +445,20 @@ describe("Tool Results with Images", () => { describe("OpenAI Codex Provider", () => { it.skipIf(!openaiCodexToken)( "gpt-5.2-codex - should handle tool result with only image", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("openai-codex", "gpt-5.2-codex"); await handleToolWithImageResult(llm, { apiKey: openaiCodexToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!openaiCodexToken)( "gpt-5.2-codex - should handle tool result with text and image", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("openai-codex", "gpt-5.2-codex"); await handleToolWithTextAndImageResult(llm, { apiKey: openaiCodexToken }); }, + { retry: 3, timeout: 30000 }, ); }); }); diff --git a/packages/ai/test/oauth.ts b/packages/ai/test/oauth.ts index 29ed8ab19..cfb37c71e 100644 --- a/packages/ai/test/oauth.ts +++ b/packages/ai/test/oauth.ts @@ -3,9 +3,27 @@ * * Supports both API key and OAuth credentials. * OAuth tokens are automatically refreshed if expired and saved back to auth.json. + * + * E2E tests are disabled by default. Set E2E=1 environment variable to enable. */ import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; + +/** + * E2E tests require explicit opt-in via E2E=1 environment variable. + * This prevents accidental API calls when keys happen to be in the environment. + */ +export const E2E_ENABLED = process.env.E2E === "1" || process.env.E2E === "true"; + +/** + * Get an API key from environment, but only if E2E tests are enabled. + * Use this in skipIf conditions: `describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))(...)` + */ +export function e2eApiKey(envVar: string): string | undefined { + if (!E2E_ENABLED) return undefined; + return process.env[envVar]; +} + import { getOAuthApiKey } from "@oh-my-pi/pi-ai/utils/oauth"; import type { OAuthCredentials, OAuthProvider } from "@oh-my-pi/pi-ai/utils/oauth/types"; import { homedir } from "os"; @@ -56,6 +74,8 @@ function saveAuthStorage(storage: AuthStorage): void { * For google-gemini-cli and google-antigravity, returns JSON-encoded { token, projectId } */ export async function resolveApiKey(provider: string): Promise { + if (!E2E_ENABLED) return undefined; + const storage = loadAuthStorage(); const entry = storage[provider]; diff --git a/packages/ai/test/openai-codex-include.test.ts b/packages/ai/test/openai-codex-include.test.ts index 0a129a06f..c7a336ece 100644 --- a/packages/ai/test/openai-codex-include.test.ts +++ b/packages/ai/test/openai-codex-include.test.ts @@ -1,5 +1,5 @@ +import { describe, expect, it } from "bun:test"; import { type RequestBody, transformRequestBody } from "@oh-my-pi/pi-ai/providers/openai-codex/request-transformer"; -import { describe, expect, it } from "vitest"; describe("openai-codex include handling", () => { it("always includes reasoning.encrypted_content when caller include is custom", async () => { diff --git a/packages/ai/test/openai-codex.test.ts b/packages/ai/test/openai-codex.test.ts index 960af9409..222dbd76a 100644 --- a/packages/ai/test/openai-codex.test.ts +++ b/packages/ai/test/openai-codex.test.ts @@ -1,6 +1,6 @@ +import { describe, expect, it } from "bun:test"; import { type RequestBody, transformRequestBody } from "@oh-my-pi/pi-ai/providers/openai-codex/request-transformer"; import { parseCodexError } from "@oh-my-pi/pi-ai/providers/openai-codex/response-handler"; -import { describe, expect, it } from "vitest"; const DEFAULT_PROMPT_PREFIX = "You are an expert coding assistant. You help users with coding tasks by reading files, executing commands"; diff --git a/packages/ai/test/stream.test.ts b/packages/ai/test/stream.test.ts index a33ae12f0..4fe172387 100644 --- a/packages/ai/test/stream.test.ts +++ b/packages/ai/test/stream.test.ts @@ -1,3 +1,4 @@ +import { afterAll, beforeAll, describe, expect, it } from "bun:test"; import { type ChildProcess, execSync, spawn } from "node:child_process"; import { readFileSync } from "node:fs"; import { getModel } from "@oh-my-pi/pi-ai/models"; @@ -6,8 +7,7 @@ import type { Api, Context, ImageContent, Model, OptionsForApi, Tool, ToolResult import { StringEnum } from "@oh-my-pi/pi-ai/utils/typebox-helpers"; import { Type } from "@sinclair/typebox"; import { join } from "path"; -import { afterAll, beforeAll, describe, expect, it } from "vitest"; -import { resolveApiKey } from "./oauth"; +import { e2eApiKey, resolveApiKey } from "./oauth"; // Resolve OAuth tokens at module level (async, runs before tests) const oauthTokens = await Promise.all([ @@ -339,32 +339,56 @@ async function multiTurn(model: Model, options?: Options } describe("Generate E2E Tests", () => { - describe.skipIf(!process.env.GEMINI_API_KEY)("Gemini Provider (gemini-2.5-flash)", () => { + describe.skipIf(!e2eApiKey("GEMINI_API_KEY"))("Gemini Provider (gemini-2.5-flash)", () => { const llm = getModel("google", "gemini-2.5-flash"); - it("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm); - }); + it( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm); + }, + { retry: 3 }, + ); - it("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm); - }); + it( + "should handle tool calling", + async () => { + await handleToolCall(llm); + }, + { retry: 3 }, + ); - it("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm); - }); + it( + "should handle streaming", + async () => { + await handleStreaming(llm); + }, + { retry: 3 }, + ); - it("should handle ", { retry: 3 }, async () => { - await handleThinking(llm, { thinking: { enabled: true, budgetTokens: 1024 } }); - }); + it( + "should handle ", + async () => { + await handleThinking(llm, { thinking: { enabled: true, budgetTokens: 1024 } }); + }, + { retry: 3 }, + ); - it("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - await multiTurn(llm, { thinking: { enabled: true, budgetTokens: 2048 } }); - }); + it( + "should handle multi-turn with thinking and tools", + async () => { + await multiTurn(llm, { thinking: { enabled: true, budgetTokens: 2048 } }); + }, + { retry: 3 }, + ); - it("should handle image input", { retry: 3 }, async () => { - await handleImage(llm); - }); + it( + "should handle image input", + async () => { + await handleImage(llm); + }, + { retry: 3 }, + ); }); describe("Google Vertex Provider (gemini-3-flash-preview)", () => { @@ -374,326 +398,586 @@ describe("Generate E2E Tests", () => { const vertexOptions = { project: vertexProject, location: vertexLocation } as const; const llm = getModel("google-vertex", "gemini-3-flash-preview"); - it.skipIf(!isVertexConfigured)("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm, vertexOptions); - }); + it.skipIf(!isVertexConfigured)( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm, vertexOptions); + }, + { retry: 3 }, + ); - it.skipIf(!isVertexConfigured)("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm, vertexOptions); - }); + it.skipIf(!isVertexConfigured)( + "should handle tool calling", + async () => { + await handleToolCall(llm, vertexOptions); + }, + { retry: 3 }, + ); - it.skipIf(!isVertexConfigured)("should handle thinking", { retry: 3 }, async () => { - const { ThinkingLevel } = await import("@google/genai"); - await handleThinking(llm, { - ...vertexOptions, - thinking: { enabled: true, budgetTokens: 1024, level: ThinkingLevel.LOW }, - }); - }); + it.skipIf(!isVertexConfigured)( + "should handle thinking", + async () => { + const { ThinkingLevel } = await import("@google/genai"); + await handleThinking(llm, { + ...vertexOptions, + thinking: { enabled: true, budgetTokens: 1024, level: ThinkingLevel.LOW }, + }); + }, + { retry: 3 }, + ); - it.skipIf(!isVertexConfigured)("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm, vertexOptions); - }); + it.skipIf(!isVertexConfigured)( + "should handle streaming", + async () => { + await handleStreaming(llm, vertexOptions); + }, + { retry: 3 }, + ); - it.skipIf(!isVertexConfigured)("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - const { ThinkingLevel } = await import("@google/genai"); - await multiTurn(llm, { - ...vertexOptions, - thinking: { enabled: true, budgetTokens: 1024, level: ThinkingLevel.MEDIUM }, - }); - }); + it.skipIf(!isVertexConfigured)( + "should handle multi-turn with thinking and tools", + async () => { + const { ThinkingLevel } = await import("@google/genai"); + await multiTurn(llm, { + ...vertexOptions, + thinking: { enabled: true, budgetTokens: 1024, level: ThinkingLevel.MEDIUM }, + }); + }, + { retry: 3 }, + ); - it.skipIf(!isVertexConfigured)("should handle image input", { retry: 3 }, async () => { - await handleImage(llm, vertexOptions); - }); + it.skipIf(!isVertexConfigured)( + "should handle image input", + async () => { + await handleImage(llm, vertexOptions); + }, + { retry: 3 }, + ); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Completions Provider (gpt-4o-mini)", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Completions Provider (gpt-4o-mini)", () => { const llm: Model<"openai-completions"> = { ...getModel("openai", "gpt-4o-mini"), api: "openai-completions" }; - it("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm); - }); + it( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm); + }, + { retry: 3 }, + ); - it("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm); - }); + it( + "should handle tool calling", + async () => { + await handleToolCall(llm); + }, + { retry: 3 }, + ); - it("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm); - }); + it( + "should handle streaming", + async () => { + await handleStreaming(llm); + }, + { retry: 3 }, + ); - it("should handle image input", { retry: 3 }, async () => { - await handleImage(llm); - }); + it( + "should handle image input", + async () => { + await handleImage(llm); + }, + { retry: 3 }, + ); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Responses Provider (gpt-5-mini)", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Responses Provider (gpt-5-mini)", () => { const llm = getModel("openai", "gpt-5-mini"); - it("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm); - }); + it( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm); + }, + { retry: 3 }, + ); - it("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm); - }); + it( + "should handle tool calling", + async () => { + await handleToolCall(llm); + }, + { retry: 3 }, + ); - it("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm); - }); + it( + "should handle streaming", + async () => { + await handleStreaming(llm); + }, + { retry: 3 }, + ); - it("should handle thinking", { retry: 2 }, async () => { - await handleThinking(llm, { reasoningEffort: "high" }); - }); + it( + "should handle thinking", + async () => { + await handleThinking(llm, { reasoningEffort: "high" }); + }, + { retry: 2 }, + ); - it("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - await multiTurn(llm, { reasoningEffort: "high" }); - }); + it( + "should handle multi-turn with thinking and tools", + async () => { + await multiTurn(llm, { reasoningEffort: "high" }); + }, + { retry: 3 }, + ); - it("should handle image input", { retry: 3 }, async () => { - await handleImage(llm); - }); + it( + "should handle image input", + async () => { + await handleImage(llm); + }, + { retry: 3 }, + ); }); - describe.skipIf(!process.env.ANTHROPIC_API_KEY)("Anthropic Provider (claude-3-5-haiku-20241022)", () => { + describe.skipIf(!e2eApiKey("ANTHROPIC_API_KEY"))("Anthropic Provider (claude-3-5-haiku-20241022)", () => { const model = getModel("anthropic", "claude-3-5-haiku-20241022"); - it("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(model, { thinkingEnabled: true }); - }); + it( + "should complete basic text generation", + async () => { + await basicTextGeneration(model, { thinkingEnabled: true }); + }, + { retry: 3 }, + ); - it("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(model); - }); + it( + "should handle tool calling", + async () => { + await handleToolCall(model); + }, + { retry: 3 }, + ); - it("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(model); - }); + it( + "should handle streaming", + async () => { + await handleStreaming(model); + }, + { retry: 3 }, + ); - it("should handle image input", { retry: 3 }, async () => { - await handleImage(model); - }); + it( + "should handle image input", + async () => { + await handleImage(model); + }, + { retry: 3 }, + ); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Responses Provider (gpt-5-mini)", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Responses Provider (gpt-5-mini)", () => { const model = getModel("openai", "gpt-5-mini"); - it("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(model); - }); + it( + "should complete basic text generation", + async () => { + await basicTextGeneration(model); + }, + { retry: 3 }, + ); - it("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(model); - }); + it( + "should handle tool calling", + async () => { + await handleToolCall(model); + }, + { retry: 3 }, + ); - it("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(model); - }); + it( + "should handle streaming", + async () => { + await handleStreaming(model); + }, + { retry: 3 }, + ); - it("should handle image input", { retry: 3 }, async () => { - await handleImage(model); - }); + it( + "should handle image input", + async () => { + await handleImage(model); + }, + { retry: 3 }, + ); }); - describe.skipIf(!process.env.XAI_API_KEY)("xAI Provider (grok-code-fast-1 via OpenAI Completions)", () => { + describe.skipIf(!e2eApiKey("XAI_API_KEY"))("xAI Provider (grok-code-fast-1 via OpenAI Completions)", () => { const llm = getModel("xai", "grok-code-fast-1"); - it("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm); - }); + it( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm); + }, + { retry: 3 }, + ); - it("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm); - }); + it( + "should handle tool calling", + async () => { + await handleToolCall(llm); + }, + { retry: 3 }, + ); - it("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm); - }); + it( + "should handle streaming", + async () => { + await handleStreaming(llm); + }, + { retry: 3 }, + ); - it("should handle thinking mode", { retry: 3 }, async () => { - await handleThinking(llm, { reasoningEffort: "medium" }); - }); + it( + "should handle thinking mode", + async () => { + await handleThinking(llm, { reasoningEffort: "medium" }); + }, + { retry: 3 }, + ); - it("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - await multiTurn(llm, { reasoningEffort: "medium" }); - }); + it( + "should handle multi-turn with thinking and tools", + async () => { + await multiTurn(llm, { reasoningEffort: "medium" }); + }, + { retry: 3 }, + ); }); - describe.skipIf(!process.env.GROQ_API_KEY)("Groq Provider (gpt-oss-20b via OpenAI Completions)", () => { + describe.skipIf(!e2eApiKey("GROQ_API_KEY"))("Groq Provider (gpt-oss-20b via OpenAI Completions)", () => { const llm = getModel("groq", "openai/gpt-oss-20b"); - it("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm); - }); + it( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm); + }, + { retry: 3 }, + ); - it("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm); - }); + it( + "should handle tool calling", + async () => { + await handleToolCall(llm); + }, + { retry: 3 }, + ); - it("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm); - }); + it( + "should handle streaming", + async () => { + await handleStreaming(llm); + }, + { retry: 3 }, + ); - it("should handle thinking mode", { retry: 3 }, async () => { - await handleThinking(llm, { reasoningEffort: "medium" }); - }); + it( + "should handle thinking mode", + async () => { + await handleThinking(llm, { reasoningEffort: "medium" }); + }, + { retry: 3 }, + ); - it("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - await multiTurn(llm, { reasoningEffort: "medium" }); - }); + it( + "should handle multi-turn with thinking and tools", + async () => { + await multiTurn(llm, { reasoningEffort: "medium" }); + }, + { retry: 3 }, + ); }); - describe.skipIf(!process.env.CEREBRAS_API_KEY)("Cerebras Provider (gpt-oss-120b via OpenAI Completions)", () => { + describe.skipIf(!e2eApiKey("CEREBRAS_API_KEY"))("Cerebras Provider (gpt-oss-120b via OpenAI Completions)", () => { const llm = getModel("cerebras", "gpt-oss-120b"); - it("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm); - }); + it( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm); + }, + { retry: 3 }, + ); - it("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm); - }); + it( + "should handle tool calling", + async () => { + await handleToolCall(llm); + }, + { retry: 3 }, + ); - it("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm); - }); + it( + "should handle streaming", + async () => { + await handleStreaming(llm); + }, + { retry: 3 }, + ); - it("should handle thinking mode", { retry: 3 }, async () => { - await handleThinking(llm, { reasoningEffort: "medium" }); - }); + it( + "should handle thinking mode", + async () => { + await handleThinking(llm, { reasoningEffort: "medium" }); + }, + { retry: 3 }, + ); - it("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - await multiTurn(llm, { reasoningEffort: "medium" }); - }); + it( + "should handle multi-turn with thinking and tools", + async () => { + await multiTurn(llm, { reasoningEffort: "medium" }); + }, + { retry: 3 }, + ); }); - describe.skipIf(!process.env.OPENROUTER_API_KEY)("OpenRouter Provider (glm-4.5v via OpenAI Completions)", () => { + describe.skipIf(!e2eApiKey("OPENROUTER_API_KEY"))("OpenRouter Provider (glm-4.5v via OpenAI Completions)", () => { const llm = getModel("openrouter", "z-ai/glm-4.5v"); - it("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm); - }); + it( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm); + }, + { retry: 3 }, + ); - it("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm); - }); + it( + "should handle tool calling", + async () => { + await handleToolCall(llm); + }, + { retry: 3 }, + ); - it("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm); - }); + it( + "should handle streaming", + async () => { + await handleStreaming(llm); + }, + { retry: 3 }, + ); - it("should handle thinking mode", { retry: 3 }, async () => { - await handleThinking(llm, { reasoningEffort: "medium" }); - }); + it( + "should handle thinking mode", + async () => { + await handleThinking(llm, { reasoningEffort: "medium" }); + }, + { retry: 3 }, + ); - it("should handle multi-turn with thinking and tools", { retry: 2 }, async () => { - await multiTurn(llm, { reasoningEffort: "medium" }); - }); + it( + "should handle multi-turn with thinking and tools", + async () => { + await multiTurn(llm, { reasoningEffort: "medium" }); + }, + { retry: 2 }, + ); - it("should handle image input", { retry: 3 }, async () => { - await handleImage(llm); - }); + it( + "should handle image input", + async () => { + await handleImage(llm); + }, + { retry: 3 }, + ); }); - describe.skipIf(!process.env.ZAI_API_KEY)("zAI Provider (glm-4.5-air via OpenAI Completions)", () => { + describe.skipIf(!e2eApiKey("ZAI_API_KEY"))("zAI Provider (glm-4.5-air via OpenAI Completions)", () => { const llm = getModel("zai", "glm-4.5-air"); - it("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm); - }); + it( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm); + }, + { retry: 3 }, + ); - it("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm); - }); + it( + "should handle tool calling", + async () => { + await handleToolCall(llm); + }, + { retry: 3 }, + ); - it("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm); - }); + it( + "should handle streaming", + async () => { + await handleStreaming(llm); + }, + { retry: 3 }, + ); - it.skip("should handle thinking mode", { retry: 3 }, async () => { - await handleThinking(llm, { reasoningEffort: "medium" }); - }); + it.skip( + "should handle thinking mode", + async () => { + await handleThinking(llm, { reasoningEffort: "medium" }); + }, + { retry: 3 }, + ); - it("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - await multiTurn(llm, { reasoningEffort: "medium" }); - }); + it( + "should handle multi-turn with thinking and tools", + async () => { + await multiTurn(llm, { reasoningEffort: "medium" }); + }, + { retry: 3 }, + ); }); - describe.skipIf(!process.env.ZAI_API_KEY)("zAI Provider (glm-4.5v via OpenAI Completions)", () => { + describe.skipIf(!e2eApiKey("ZAI_API_KEY"))("zAI Provider (glm-4.5v via OpenAI Completions)", () => { const llm = getModel("zai", "glm-4.5v"); - it("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm); - }); + it( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm); + }, + { retry: 3 }, + ); - it("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm); - }); + it( + "should handle tool calling", + async () => { + await handleToolCall(llm); + }, + { retry: 3 }, + ); - it("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm); - }); + it( + "should handle streaming", + async () => { + await handleStreaming(llm); + }, + { retry: 3 }, + ); - it("should handle thinking mode", { retry: 3 }, async () => { - await handleThinking(llm, { reasoningEffort: "medium" }); - }); + it( + "should handle thinking mode", + async () => { + await handleThinking(llm, { reasoningEffort: "medium" }); + }, + { retry: 3 }, + ); - it("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - await multiTurn(llm, { reasoningEffort: "medium" }); - }); + it( + "should handle multi-turn with thinking and tools", + async () => { + await multiTurn(llm, { reasoningEffort: "medium" }); + }, + { retry: 3 }, + ); - it("should handle image input", { retry: 3 }, async () => { - await handleImage(llm); - }); + it( + "should handle image input", + async () => { + await handleImage(llm); + }, + { retry: 3 }, + ); }); - describe.skipIf(!process.env.MISTRAL_API_KEY)( + describe.skipIf(!e2eApiKey("MISTRAL_API_KEY"))( "Mistral Provider (devstral-medium-latest via OpenAI Completions)", () => { const llm = getModel("mistral", "devstral-medium-latest"); - it("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm); - }); + it( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm); + }, + { retry: 3 }, + ); - it("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm); - }); + it( + "should handle tool calling", + async () => { + await handleToolCall(llm); + }, + { retry: 3 }, + ); - it("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm); - }); + it( + "should handle streaming", + async () => { + await handleStreaming(llm); + }, + { retry: 3 }, + ); - it("should handle thinking mode", { retry: 3 }, async () => { - // FIXME Skip for now, getting a 422 stauts code, need to test with official SDK - // const llm = getModel("mistral", "magistral-medium-latest"); - // await handleThinking(llm, { reasoningEffort: "medium" }); - }); + it( + "should handle thinking mode", + async () => { + // FIXME Skip for now, getting a 422 stauts code, need to test with official SDK + // const llm = getModel("mistral", "magistral-medium-latest"); + // await handleThinking(llm, { reasoningEffort: "medium" }); + }, + { retry: 3 }, + ); - it("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - await multiTurn(llm, { reasoningEffort: "medium" }); - }); + it( + "should handle multi-turn with thinking and tools", + async () => { + await multiTurn(llm, { reasoningEffort: "medium" }); + }, + { retry: 3 }, + ); }, ); - describe.skipIf(!process.env.MISTRAL_API_KEY)("Mistral Provider (pixtral-12b with image support)", () => { + describe.skipIf(!e2eApiKey("MISTRAL_API_KEY"))("Mistral Provider (pixtral-12b with image support)", () => { const llm = getModel("mistral", "pixtral-12b"); - it("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm); - }); + it( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm); + }, + { retry: 3 }, + ); - it("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm); - }); + it( + "should handle tool calling", + async () => { + await handleToolCall(llm); + }, + { retry: 3 }, + ); - it("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm); - }); + it( + "should handle streaming", + async () => { + await handleStreaming(llm); + }, + { retry: 3 }, + ); - it("should handle image input", { retry: 3 }, async () => { - await handleImage(llm); - }); + it( + "should handle image input", + async () => { + await handleImage(llm); + }, + { retry: 3 }, + ); }); // ========================================================================= @@ -704,205 +988,364 @@ describe("Generate E2E Tests", () => { describe("Anthropic OAuth Provider (claude-sonnet-4-20250514)", () => { const model = getModel("anthropic", "claude-sonnet-4-20250514"); - it.skipIf(!anthropicOAuthToken)("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(model, { apiKey: anthropicOAuthToken }); - }); + it.skipIf(!anthropicOAuthToken)( + "should complete basic text generation", + async () => { + await basicTextGeneration(model, { apiKey: anthropicOAuthToken }); + }, + { retry: 3 }, + ); - it.skipIf(!anthropicOAuthToken)("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(model, { apiKey: anthropicOAuthToken }); - }); + it.skipIf(!anthropicOAuthToken)( + "should handle tool calling", + async () => { + await handleToolCall(model, { apiKey: anthropicOAuthToken }); + }, + { retry: 3 }, + ); - it.skipIf(!anthropicOAuthToken)("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(model, { apiKey: anthropicOAuthToken }); - }); + it.skipIf(!anthropicOAuthToken)( + "should handle streaming", + async () => { + await handleStreaming(model, { apiKey: anthropicOAuthToken }); + }, + { retry: 3 }, + ); - it.skipIf(!anthropicOAuthToken)("should handle thinking", { retry: 3 }, async () => { - await handleThinking(model, { apiKey: anthropicOAuthToken, thinkingEnabled: true }); - }); + it.skipIf(!anthropicOAuthToken)( + "should handle thinking", + async () => { + await handleThinking(model, { apiKey: anthropicOAuthToken, thinkingEnabled: true }); + }, + { retry: 3 }, + ); - it.skipIf(!anthropicOAuthToken)("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - await multiTurn(model, { apiKey: anthropicOAuthToken, thinkingEnabled: true }); - }); + it.skipIf(!anthropicOAuthToken)( + "should handle multi-turn with thinking and tools", + async () => { + await multiTurn(model, { apiKey: anthropicOAuthToken, thinkingEnabled: true }); + }, + { retry: 3 }, + ); - it.skipIf(!anthropicOAuthToken)("should handle image input", { retry: 3 }, async () => { - await handleImage(model, { apiKey: anthropicOAuthToken }); - }); + it.skipIf(!anthropicOAuthToken)( + "should handle image input", + async () => { + await handleImage(model, { apiKey: anthropicOAuthToken }); + }, + { retry: 3 }, + ); }); describe("GitHub Copilot Provider (gpt-4o via OpenAI Completions)", () => { const llm = getModel("github-copilot", "gpt-4o"); - it.skipIf(!githubCopilotToken)("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm, { apiKey: githubCopilotToken }); - }); + it.skipIf(!githubCopilotToken)( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm, { apiKey: githubCopilotToken }); + }, + { retry: 3 }, + ); - it.skipIf(!githubCopilotToken)("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm, { apiKey: githubCopilotToken }); - }); + it.skipIf(!githubCopilotToken)( + "should handle tool calling", + async () => { + await handleToolCall(llm, { apiKey: githubCopilotToken }); + }, + { retry: 3 }, + ); - it.skipIf(!githubCopilotToken)("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm, { apiKey: githubCopilotToken }); - }); + it.skipIf(!githubCopilotToken)( + "should handle streaming", + async () => { + await handleStreaming(llm, { apiKey: githubCopilotToken }); + }, + { retry: 3 }, + ); - it.skipIf(!githubCopilotToken)("should handle thinking", { retry: 2 }, async () => { - const thinkingModel = getModel("github-copilot", "gpt-5-mini"); - await handleThinking(thinkingModel, { apiKey: githubCopilotToken, reasoningEffort: "high" }); - }); + it.skipIf(!githubCopilotToken)( + "should handle thinking", + async () => { + const thinkingModel = getModel("github-copilot", "gpt-5-mini"); + await handleThinking(thinkingModel, { apiKey: githubCopilotToken, reasoningEffort: "high" }); + }, + { retry: 2 }, + ); - it.skipIf(!githubCopilotToken)("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - const thinkingModel = getModel("github-copilot", "gpt-5-mini"); - await multiTurn(thinkingModel, { apiKey: githubCopilotToken, reasoningEffort: "high" }); - }); + it.skipIf(!githubCopilotToken)( + "should handle multi-turn with thinking and tools", + async () => { + const thinkingModel = getModel("github-copilot", "gpt-5-mini"); + await multiTurn(thinkingModel, { apiKey: githubCopilotToken, reasoningEffort: "high" }); + }, + { retry: 3 }, + ); - it.skipIf(!githubCopilotToken)("should handle image input", { retry: 3 }, async () => { - await handleImage(llm, { apiKey: githubCopilotToken }); - }); + it.skipIf(!githubCopilotToken)( + "should handle image input", + async () => { + await handleImage(llm, { apiKey: githubCopilotToken }); + }, + { retry: 3 }, + ); }); describe("Google Gemini CLI Provider (gemini-2.5-flash)", () => { const llm = getModel("google-gemini-cli", "gemini-2.5-flash"); - it.skipIf(!geminiCliToken)("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm, { apiKey: geminiCliToken }); - }); + it.skipIf(!geminiCliToken)( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm, { apiKey: geminiCliToken }); + }, + { retry: 3 }, + ); - it.skipIf(!geminiCliToken)("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm, { apiKey: geminiCliToken }); - }); + it.skipIf(!geminiCliToken)( + "should handle tool calling", + async () => { + await handleToolCall(llm, { apiKey: geminiCliToken }); + }, + { retry: 3 }, + ); - it.skipIf(!geminiCliToken)("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm, { apiKey: geminiCliToken }); - }); + it.skipIf(!geminiCliToken)( + "should handle streaming", + async () => { + await handleStreaming(llm, { apiKey: geminiCliToken }); + }, + { retry: 3 }, + ); - it.skipIf(!geminiCliToken)("should handle thinking", { retry: 3 }, async () => { - await handleThinking(llm, { apiKey: geminiCliToken, thinking: { enabled: true, budgetTokens: 1024 } }); - }); + it.skipIf(!geminiCliToken)( + "should handle thinking", + async () => { + await handleThinking(llm, { apiKey: geminiCliToken, thinking: { enabled: true, budgetTokens: 1024 } }); + }, + { retry: 3 }, + ); - it.skipIf(!geminiCliToken)("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - await multiTurn(llm, { apiKey: geminiCliToken, thinking: { enabled: true, budgetTokens: 2048 } }); - }); + it.skipIf(!geminiCliToken)( + "should handle multi-turn with thinking and tools", + async () => { + await multiTurn(llm, { apiKey: geminiCliToken, thinking: { enabled: true, budgetTokens: 2048 } }); + }, + { retry: 3 }, + ); - it.skipIf(!geminiCliToken)("should handle image input", { retry: 3 }, async () => { - await handleImage(llm, { apiKey: geminiCliToken }); - }); + it.skipIf(!geminiCliToken)( + "should handle image input", + async () => { + await handleImage(llm, { apiKey: geminiCliToken }); + }, + { retry: 3 }, + ); }); describe("Google Gemini CLI Provider (gemini-3-flash-preview with thinkingLevel)", () => { const llm = getModel("google-gemini-cli", "gemini-3-flash-preview"); - it.skipIf(!geminiCliToken)("should handle thinking with thinkingLevel", { retry: 3 }, async () => { - await handleThinking(llm, { apiKey: geminiCliToken, thinking: { enabled: true, level: "LOW" } }); - }); + it.skipIf(!geminiCliToken)( + "should handle thinking with thinkingLevel", + async () => { + await handleThinking(llm, { apiKey: geminiCliToken, thinking: { enabled: true, level: "LOW" } }); + }, + { retry: 3 }, + ); - it.skipIf(!geminiCliToken)("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - await multiTurn(llm, { apiKey: geminiCliToken, thinking: { enabled: true, level: "MEDIUM" } }); - }); + it.skipIf(!geminiCliToken)( + "should handle multi-turn with thinking and tools", + async () => { + await multiTurn(llm, { apiKey: geminiCliToken, thinking: { enabled: true, level: "MEDIUM" } }); + }, + { retry: 3 }, + ); }); describe("Google Antigravity Provider (gemini-3-flash)", () => { const llm = getModel("google-antigravity", "gemini-3-flash"); - it.skipIf(!antigravityToken)("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm, { apiKey: antigravityToken }); - }); + it.skipIf(!antigravityToken)( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm, { apiKey: antigravityToken }); + }, + { retry: 3 }, + ); - it.skipIf(!antigravityToken)("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm, { apiKey: antigravityToken }); - }); + it.skipIf(!antigravityToken)( + "should handle tool calling", + async () => { + await handleToolCall(llm, { apiKey: antigravityToken }); + }, + { retry: 3 }, + ); - it.skipIf(!antigravityToken)("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm, { apiKey: antigravityToken }); - }); + it.skipIf(!antigravityToken)( + "should handle streaming", + async () => { + await handleStreaming(llm, { apiKey: antigravityToken }); + }, + { retry: 3 }, + ); - it.skipIf(!antigravityToken)("should handle thinking with thinkingLevel", { retry: 3 }, async () => { - // gemini-3-flash supports all four levels: MINIMAL, LOW, MEDIUM, HIGH - await handleThinking(llm, { - apiKey: antigravityToken, - thinking: { enabled: true, level: "LOW" }, - }); - }); + it.skipIf(!antigravityToken)( + "should handle thinking with thinkingLevel", + async () => { + // gemini-3-flash supports all four levels: MINIMAL, LOW, MEDIUM, HIGH + await handleThinking(llm, { + apiKey: antigravityToken, + thinking: { enabled: true, level: "LOW" }, + }); + }, + { retry: 3 }, + ); - it.skipIf(!antigravityToken)("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - await multiTurn(llm, { apiKey: antigravityToken, thinking: { enabled: true, level: "MEDIUM" } }); - }); + it.skipIf(!antigravityToken)( + "should handle multi-turn with thinking and tools", + async () => { + await multiTurn(llm, { apiKey: antigravityToken, thinking: { enabled: true, level: "MEDIUM" } }); + }, + { retry: 3 }, + ); - it.skipIf(!antigravityToken)("should handle image input", { retry: 3 }, async () => { - await handleImage(llm, { apiKey: antigravityToken }); - }); + it.skipIf(!antigravityToken)( + "should handle image input", + async () => { + await handleImage(llm, { apiKey: antigravityToken }); + }, + { retry: 3 }, + ); }); describe("Google Antigravity Provider (gemini-3-pro-high with thinkingLevel)", () => { const llm = getModel("google-antigravity", "gemini-3-pro-high"); - it.skipIf(!antigravityToken)("should handle thinking with thinkingLevel HIGH", { retry: 3 }, async () => { - // gemini-3-pro only supports LOW/HIGH - await handleThinking(llm, { - apiKey: antigravityToken, - thinking: { enabled: true, level: "HIGH" }, - }); - }); + it.skipIf(!antigravityToken)( + "should handle thinking with thinkingLevel HIGH", + async () => { + // gemini-3-pro only supports LOW/HIGH + await handleThinking(llm, { + apiKey: antigravityToken, + thinking: { enabled: true, level: "HIGH" }, + }); + }, + { retry: 3 }, + ); }); describe("Google Antigravity Provider (claude-sonnet-4-5)", () => { const llm = getModel("google-antigravity", "claude-sonnet-4-5"); - it.skipIf(!antigravityToken)("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm, { apiKey: antigravityToken }); - }); + it.skipIf(!antigravityToken)( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm, { apiKey: antigravityToken }); + }, + { retry: 3 }, + ); - it.skipIf(!antigravityToken)("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm, { apiKey: antigravityToken }); - }); + it.skipIf(!antigravityToken)( + "should handle tool calling", + async () => { + await handleToolCall(llm, { apiKey: antigravityToken }); + }, + { retry: 3 }, + ); - it.skipIf(!antigravityToken)("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm, { apiKey: antigravityToken }); - }); + it.skipIf(!antigravityToken)( + "should handle streaming", + async () => { + await handleStreaming(llm, { apiKey: antigravityToken }); + }, + { retry: 3 }, + ); - it.skipIf(!antigravityToken)("should handle thinking", { retry: 3 }, async () => { - // claude-sonnet-4-5 has reasoning: false, use claude-sonnet-4-5-thinking - const thinkingModel = getModel("google-antigravity", "claude-sonnet-4-5-thinking"); - await handleThinking(thinkingModel, { - apiKey: antigravityToken, - thinking: { enabled: true, budgetTokens: 4096 }, - }); - }); + it.skipIf(!antigravityToken)( + "should handle thinking", + async () => { + // claude-sonnet-4-5 has reasoning: false, use claude-sonnet-4-5-thinking + const thinkingModel = getModel("google-antigravity", "claude-sonnet-4-5-thinking"); + await handleThinking(thinkingModel, { + apiKey: antigravityToken, + thinking: { enabled: true, budgetTokens: 4096 }, + }); + }, + { retry: 3 }, + ); - it.skipIf(!antigravityToken)("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - const thinkingModel = getModel("google-antigravity", "claude-sonnet-4-5-thinking"); - await multiTurn(thinkingModel, { apiKey: antigravityToken, thinking: { enabled: true, budgetTokens: 4096 } }); - }); + it.skipIf(!antigravityToken)( + "should handle multi-turn with thinking and tools", + async () => { + const thinkingModel = getModel("google-antigravity", "claude-sonnet-4-5-thinking"); + await multiTurn(thinkingModel, { + apiKey: antigravityToken, + thinking: { enabled: true, budgetTokens: 4096 }, + }); + }, + { retry: 3 }, + ); - it.skipIf(!antigravityToken)("should handle image input", { retry: 3 }, async () => { - await handleImage(llm, { apiKey: antigravityToken }); - }); + it.skipIf(!antigravityToken)( + "should handle image input", + async () => { + await handleImage(llm, { apiKey: antigravityToken }); + }, + { retry: 3 }, + ); }); describe("OpenAI Codex Provider (gpt-5.2-codex)", () => { const llm = getModel("openai-codex", "gpt-5.2-codex"); - it.skipIf(!openaiCodexToken)("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm, { apiKey: openaiCodexToken }); - }); + it.skipIf(!openaiCodexToken)( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm, { apiKey: openaiCodexToken }); + }, + { retry: 3 }, + ); - it.skipIf(!openaiCodexToken)("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm, { apiKey: openaiCodexToken }); - }); + it.skipIf(!openaiCodexToken)( + "should handle tool calling", + async () => { + await handleToolCall(llm, { apiKey: openaiCodexToken }); + }, + { retry: 3 }, + ); - it.skipIf(!openaiCodexToken)("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm, { apiKey: openaiCodexToken }); - }); + it.skipIf(!openaiCodexToken)( + "should handle streaming", + async () => { + await handleStreaming(llm, { apiKey: openaiCodexToken }); + }, + { retry: 3 }, + ); - it.skipIf(!openaiCodexToken)("should handle thinking", { retry: 3 }, async () => { - await handleThinking(llm, { apiKey: openaiCodexToken, reasoningEffort: "high" }); - }); + it.skipIf(!openaiCodexToken)( + "should handle thinking", + async () => { + await handleThinking(llm, { apiKey: openaiCodexToken, reasoningEffort: "high" }); + }, + { retry: 3 }, + ); - it.skipIf(!openaiCodexToken)("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - await multiTurn(llm, { apiKey: openaiCodexToken }); - }); + it.skipIf(!openaiCodexToken)( + "should handle multi-turn with thinking and tools", + async () => { + await multiTurn(llm, { apiKey: openaiCodexToken }); + }, + { retry: 3 }, + ); - it.skipIf(!openaiCodexToken)("should handle image input", { retry: 3 }, async () => { - await handleImage(llm, { apiKey: openaiCodexToken }); - }); + it.skipIf(!openaiCodexToken)( + "should handle image input", + async () => { + await handleImage(llm, { apiKey: openaiCodexToken }); + }, + { retry: 3 }, + ); }); // Check if ollama is installed and local LLM tests are enabled @@ -984,24 +1427,44 @@ describe("Generate E2E Tests", () => { } }); - it("should complete basic text generation", { retry: 3 }, async () => { - await basicTextGeneration(llm, { apiKey: "test" }); - }); + it( + "should complete basic text generation", + async () => { + await basicTextGeneration(llm, { apiKey: "test" }); + }, + { retry: 3 }, + ); - it("should handle tool calling", { retry: 3 }, async () => { - await handleToolCall(llm, { apiKey: "test" }); - }); + it( + "should handle tool calling", + async () => { + await handleToolCall(llm, { apiKey: "test" }); + }, + { retry: 3 }, + ); - it("should handle streaming", { retry: 3 }, async () => { - await handleStreaming(llm, { apiKey: "test" }); - }); + it( + "should handle streaming", + async () => { + await handleStreaming(llm, { apiKey: "test" }); + }, + { retry: 3 }, + ); - it("should handle thinking mode", { retry: 3 }, async () => { - await handleThinking(llm, { apiKey: "test", reasoningEffort: "medium" }); - }); + it( + "should handle thinking mode", + async () => { + await handleThinking(llm, { apiKey: "test", reasoningEffort: "medium" }); + }, + { retry: 3 }, + ); - it("should handle multi-turn with thinking and tools", { retry: 3 }, async () => { - await multiTurn(llm, { apiKey: "test", reasoningEffort: "medium" }); - }); + it( + "should handle multi-turn with thinking and tools", + async () => { + await multiTurn(llm, { apiKey: "test", reasoningEffort: "medium" }); + }, + { retry: 3 }, + ); }); }); diff --git a/packages/ai/test/tokens.test.ts b/packages/ai/test/tokens.test.ts index 44bc4b0bb..c4a88e292 100644 --- a/packages/ai/test/tokens.test.ts +++ b/packages/ai/test/tokens.test.ts @@ -1,8 +1,8 @@ +import { describe, expect, it } from "bun:test"; import { getModel } from "@oh-my-pi/pi-ai/models"; import { stream } from "@oh-my-pi/pi-ai/stream"; import type { Api, Context, Model, OptionsForApi } from "@oh-my-pi/pi-ai/types"; -import { describe, expect, it } from "vitest"; -import { resolveApiKey } from "./oauth"; +import { e2eApiKey, resolveApiKey } from "./oauth"; // Resolve OAuth tokens at module level (async, runs before tests) const oauthTokens = await Promise.all([ @@ -69,79 +69,115 @@ async function testTokensOnAbort(llm: Model, options: Op } describe("Token Statistics on Abort", () => { - describe.skipIf(!process.env.GEMINI_API_KEY)("Google Provider", () => { + describe.skipIf(!e2eApiKey("GEMINI_API_KEY"))("Google Provider", () => { const llm = getModel("google", "gemini-2.5-flash"); - it("should include token stats when aborted mid-stream", { retry: 3, timeout: 30000 }, async () => { - await testTokensOnAbort(llm, { thinking: { enabled: true } }); - }); + it( + "should include token stats when aborted mid-stream", + async () => { + await testTokensOnAbort(llm, { thinking: { enabled: true } }); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Completions Provider", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Completions Provider", () => { const llm: Model<"openai-completions"> = { ...getModel("openai", "gpt-4o-mini")!, api: "openai-completions", }; - it("should include token stats when aborted mid-stream", { retry: 3, timeout: 30000 }, async () => { - await testTokensOnAbort(llm); - }); + it( + "should include token stats when aborted mid-stream", + async () => { + await testTokensOnAbort(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Responses Provider", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Responses Provider", () => { const llm = getModel("openai", "gpt-5-mini"); - it("should include token stats when aborted mid-stream", { retry: 3, timeout: 30000 }, async () => { - await testTokensOnAbort(llm); - }); + it( + "should include token stats when aborted mid-stream", + async () => { + await testTokensOnAbort(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.ANTHROPIC_API_KEY)("Anthropic Provider", () => { + describe.skipIf(!e2eApiKey("ANTHROPIC_API_KEY"))("Anthropic Provider", () => { const llm = getModel("anthropic", "claude-3-5-haiku-20241022"); - it("should include token stats when aborted mid-stream", { retry: 3, timeout: 30000 }, async () => { - await testTokensOnAbort(llm); - }); + it( + "should include token stats when aborted mid-stream", + async () => { + await testTokensOnAbort(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.XAI_API_KEY)("xAI Provider", () => { + describe.skipIf(!e2eApiKey("XAI_API_KEY"))("xAI Provider", () => { const llm = getModel("xai", "grok-3-fast"); - it("should include token stats when aborted mid-stream", { retry: 3, timeout: 30000 }, async () => { - await testTokensOnAbort(llm); - }); + it( + "should include token stats when aborted mid-stream", + async () => { + await testTokensOnAbort(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.GROQ_API_KEY)("Groq Provider", () => { + describe.skipIf(!e2eApiKey("GROQ_API_KEY"))("Groq Provider", () => { const llm = getModel("groq", "openai/gpt-oss-20b"); - it("should include token stats when aborted mid-stream", { retry: 3, timeout: 30000 }, async () => { - await testTokensOnAbort(llm); - }); + it( + "should include token stats when aborted mid-stream", + async () => { + await testTokensOnAbort(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.CEREBRAS_API_KEY)("Cerebras Provider", () => { + describe.skipIf(!e2eApiKey("CEREBRAS_API_KEY"))("Cerebras Provider", () => { const llm = getModel("cerebras", "gpt-oss-120b"); - it("should include token stats when aborted mid-stream", { retry: 3, timeout: 30000 }, async () => { - await testTokensOnAbort(llm); - }); + it( + "should include token stats when aborted mid-stream", + async () => { + await testTokensOnAbort(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.ZAI_API_KEY)("zAI Provider", () => { + describe.skipIf(!e2eApiKey("ZAI_API_KEY"))("zAI Provider", () => { const llm = getModel("zai", "glm-4.5-flash"); - it("should include token stats when aborted mid-stream", { retry: 3, timeout: 30000 }, async () => { - await testTokensOnAbort(llm); - }); + it( + "should include token stats when aborted mid-stream", + async () => { + await testTokensOnAbort(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.MISTRAL_API_KEY)("Mistral Provider", () => { + describe.skipIf(!e2eApiKey("MISTRAL_API_KEY"))("Mistral Provider", () => { const llm = getModel("mistral", "devstral-medium-latest"); - it("should include token stats when aborted mid-stream", { retry: 3, timeout: 30000 }, async () => { - await testTokensOnAbort(llm); - }); + it( + "should include token stats when aborted mid-stream", + async () => { + await testTokensOnAbort(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); // ========================================================================= @@ -153,81 +189,81 @@ describe("Token Statistics on Abort", () => { it.skipIf(!anthropicOAuthToken)( "should include token stats when aborted mid-stream", - { retry: 3, timeout: 30000 }, async () => { await testTokensOnAbort(llm, { apiKey: anthropicOAuthToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("GitHub Copilot Provider", () => { it.skipIf(!githubCopilotToken)( "gpt-4o - should include token stats when aborted mid-stream", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "gpt-4o"); await testTokensOnAbort(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!githubCopilotToken)( "claude-sonnet-4 - should include token stats when aborted mid-stream", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "claude-sonnet-4"); await testTokensOnAbort(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("Google Gemini CLI Provider", () => { it.skipIf(!geminiCliToken)( "gemini-2.5-flash - should include token stats when aborted mid-stream", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-gemini-cli", "gemini-2.5-flash"); await testTokensOnAbort(llm, { apiKey: geminiCliToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("Google Antigravity Provider", () => { it.skipIf(!antigravityToken)( "gemini-3-flash - should include token stats when aborted mid-stream", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gemini-3-flash"); await testTokensOnAbort(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "claude-sonnet-4-5 - should include token stats when aborted mid-stream", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "claude-sonnet-4-5"); await testTokensOnAbort(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "gpt-oss-120b-medium - should include token stats when aborted mid-stream", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gpt-oss-120b-medium"); await testTokensOnAbort(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("OpenAI Codex Provider", () => { it.skipIf(!openaiCodexToken)( "gpt-5.2-codex - should include token stats when aborted mid-stream", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("openai-codex", "gpt-5.2-codex"); await testTokensOnAbort(llm, { apiKey: openaiCodexToken }); }, + { retry: 3, timeout: 30000 }, ); }); }); diff --git a/packages/ai/test/tool-call-without-result.test.ts b/packages/ai/test/tool-call-without-result.test.ts index 743775367..d0ec78d8b 100644 --- a/packages/ai/test/tool-call-without-result.test.ts +++ b/packages/ai/test/tool-call-without-result.test.ts @@ -1,9 +1,9 @@ +import { describe, expect, it } from "bun:test"; import { getModel } from "@oh-my-pi/pi-ai/models"; import { complete } from "@oh-my-pi/pi-ai/stream"; import type { Api, Context, Model, OptionsForApi, Tool } from "@oh-my-pi/pi-ai/types"; import { Type } from "@sinclair/typebox"; -import { describe, expect, it } from "vitest"; -import { resolveApiKey } from "./oauth"; +import { e2eApiKey, resolveApiKey } from "./oauth"; // Resolve OAuth tokens at module level (async, runs before tests) const oauthTokens = await Promise.all([ @@ -95,79 +95,115 @@ describe("Tool Call Without Result Tests", () => { // API Key-based providers // ========================================================================= - describe.skipIf(!process.env.GEMINI_API_KEY)("Google Provider", () => { + describe.skipIf(!e2eApiKey("GEMINI_API_KEY"))("Google Provider", () => { const model = getModel("google", "gemini-2.5-flash"); - it("should filter out tool calls without corresponding tool results", { retry: 3, timeout: 30000 }, async () => { - await testToolCallWithoutResult(model); - }); + it( + "should filter out tool calls without corresponding tool results", + async () => { + await testToolCallWithoutResult(model); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Completions Provider", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Completions Provider", () => { const model: Model<"openai-completions"> = { ...getModel("openai", "gpt-4o-mini")!, api: "openai-completions", }; - it("should filter out tool calls without corresponding tool results", { retry: 3, timeout: 30000 }, async () => { - await testToolCallWithoutResult(model); - }); + it( + "should filter out tool calls without corresponding tool results", + async () => { + await testToolCallWithoutResult(model); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Responses Provider", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Responses Provider", () => { const model = getModel("openai", "gpt-5-mini"); - it("should filter out tool calls without corresponding tool results", { retry: 3, timeout: 30000 }, async () => { - await testToolCallWithoutResult(model); - }); + it( + "should filter out tool calls without corresponding tool results", + async () => { + await testToolCallWithoutResult(model); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.ANTHROPIC_API_KEY)("Anthropic Provider", () => { + describe.skipIf(!e2eApiKey("ANTHROPIC_API_KEY"))("Anthropic Provider", () => { const model = getModel("anthropic", "claude-3-5-haiku-20241022"); - it("should filter out tool calls without corresponding tool results", { retry: 3, timeout: 30000 }, async () => { - await testToolCallWithoutResult(model); - }); + it( + "should filter out tool calls without corresponding tool results", + async () => { + await testToolCallWithoutResult(model); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.XAI_API_KEY)("xAI Provider", () => { + describe.skipIf(!e2eApiKey("XAI_API_KEY"))("xAI Provider", () => { const model = getModel("xai", "grok-3-fast"); - it("should filter out tool calls without corresponding tool results", { retry: 3, timeout: 30000 }, async () => { - await testToolCallWithoutResult(model); - }); + it( + "should filter out tool calls without corresponding tool results", + async () => { + await testToolCallWithoutResult(model); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.GROQ_API_KEY)("Groq Provider", () => { + describe.skipIf(!e2eApiKey("GROQ_API_KEY"))("Groq Provider", () => { const model = getModel("groq", "openai/gpt-oss-20b"); - it("should filter out tool calls without corresponding tool results", { retry: 3, timeout: 30000 }, async () => { - await testToolCallWithoutResult(model); - }); + it( + "should filter out tool calls without corresponding tool results", + async () => { + await testToolCallWithoutResult(model); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.CEREBRAS_API_KEY)("Cerebras Provider", () => { + describe.skipIf(!e2eApiKey("CEREBRAS_API_KEY"))("Cerebras Provider", () => { const model = getModel("cerebras", "gpt-oss-120b"); - it("should filter out tool calls without corresponding tool results", { retry: 3, timeout: 30000 }, async () => { - await testToolCallWithoutResult(model); - }); + it( + "should filter out tool calls without corresponding tool results", + async () => { + await testToolCallWithoutResult(model); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.ZAI_API_KEY)("zAI Provider", () => { + describe.skipIf(!e2eApiKey("ZAI_API_KEY"))("zAI Provider", () => { const model = getModel("zai", "glm-4.5-flash"); - it("should filter out tool calls without corresponding tool results", { retry: 3, timeout: 30000 }, async () => { - await testToolCallWithoutResult(model); - }); + it( + "should filter out tool calls without corresponding tool results", + async () => { + await testToolCallWithoutResult(model); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.MISTRAL_API_KEY)("Mistral Provider", () => { + describe.skipIf(!e2eApiKey("MISTRAL_API_KEY"))("Mistral Provider", () => { const model = getModel("mistral", "devstral-medium-latest"); - it("should filter out tool calls without corresponding tool results", { retry: 3, timeout: 30000 }, async () => { - await testToolCallWithoutResult(model); - }); + it( + "should filter out tool calls without corresponding tool results", + async () => { + await testToolCallWithoutResult(model); + }, + { retry: 3, timeout: 30000 }, + ); }); // ========================================================================= @@ -179,81 +215,81 @@ describe("Tool Call Without Result Tests", () => { it.skipIf(!anthropicOAuthToken)( "should filter out tool calls without corresponding tool results", - { retry: 3, timeout: 30000 }, async () => { await testToolCallWithoutResult(model, { apiKey: anthropicOAuthToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("GitHub Copilot Provider", () => { it.skipIf(!githubCopilotToken)( "gpt-4o - should filter out tool calls without corresponding tool results", - { retry: 3, timeout: 30000 }, async () => { const model = getModel("github-copilot", "gpt-4o"); await testToolCallWithoutResult(model, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!githubCopilotToken)( "claude-sonnet-4 - should filter out tool calls without corresponding tool results", - { retry: 3, timeout: 30000 }, async () => { const model = getModel("github-copilot", "claude-sonnet-4"); await testToolCallWithoutResult(model, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("Google Gemini CLI Provider", () => { it.skipIf(!geminiCliToken)( "gemini-2.5-flash - should filter out tool calls without corresponding tool results", - { retry: 3, timeout: 30000 }, async () => { const model = getModel("google-gemini-cli", "gemini-2.5-flash"); await testToolCallWithoutResult(model, { apiKey: geminiCliToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("Google Antigravity Provider", () => { it.skipIf(!antigravityToken)( "gemini-3-flash - should filter out tool calls without corresponding tool results", - { retry: 3, timeout: 30000 }, async () => { const model = getModel("google-antigravity", "gemini-3-flash"); await testToolCallWithoutResult(model, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "claude-sonnet-4-5 - should filter out tool calls without corresponding tool results", - { retry: 3, timeout: 30000 }, async () => { const model = getModel("google-antigravity", "claude-sonnet-4-5"); await testToolCallWithoutResult(model, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "gpt-oss-120b-medium - should filter out tool calls without corresponding tool results", - { retry: 3, timeout: 30000 }, async () => { const model = getModel("google-antigravity", "gpt-oss-120b-medium"); await testToolCallWithoutResult(model, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("OpenAI Codex Provider", () => { it.skipIf(!openaiCodexToken)( "gpt-5.2-codex - should filter out tool calls without corresponding tool results", - { retry: 3, timeout: 30000 }, async () => { const model = getModel("openai-codex", "gpt-5.2-codex"); await testToolCallWithoutResult(model, { apiKey: openaiCodexToken }); }, + { retry: 3, timeout: 30000 }, ); }); }); diff --git a/packages/ai/test/total-tokens.test.ts b/packages/ai/test/total-tokens.test.ts index cc94ba3cd..cf4627dfb 100644 --- a/packages/ai/test/total-tokens.test.ts +++ b/packages/ai/test/total-tokens.test.ts @@ -12,11 +12,11 @@ * - Other OpenAI-compatible providers: Uses native total_tokens field */ +import { describe, expect, it } from "bun:test"; import { getModel } from "@oh-my-pi/pi-ai/models"; import { complete } from "@oh-my-pi/pi-ai/stream"; import type { Api, Context, Model, OptionsForApi, Usage } from "@oh-my-pi/pi-ai/types"; -import { describe, expect, it } from "vitest"; -import { resolveApiKey } from "./oauth"; +import { e2eApiKey, resolveApiKey } from "./oauth"; // Resolve OAuth tokens at module level (async, runs before tests) const oauthTokens = await Promise.all([ @@ -99,10 +99,9 @@ describe("totalTokens field", () => { // Anthropic // ========================================================================= - describe.skipIf(!process.env.ANTHROPIC_API_KEY)("Anthropic (API Key)", () => { + describe.skipIf(!e2eApiKey("ANTHROPIC_API_KEY"))("Anthropic (API Key)", () => { it( "claude-3-5-haiku - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("anthropic", "claude-3-5-haiku-20241022"); @@ -119,13 +118,13 @@ describe("totalTokens field", () => { const hasCache = second.cacheRead > 0 || second.cacheWrite > 0 || first.cacheWrite > 0; expect(hasCache).toBe(true); }, + { retry: 3, timeout: 60000 }, ); }); describe("Anthropic (OAuth)", () => { it.skipIf(!anthropicOAuthToken)( "claude-sonnet-4 - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("anthropic", "claude-sonnet-4-20250514"); @@ -142,6 +141,7 @@ describe("totalTokens field", () => { const hasCache = second.cacheRead > 0 || second.cacheWrite > 0 || first.cacheWrite > 0; expect(hasCache).toBe(true); }, + { retry: 3, timeout: 60000 }, ); }); @@ -149,10 +149,9 @@ describe("totalTokens field", () => { // OpenAI // ========================================================================= - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Completions", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Completions", () => { it( "gpt-4o-mini - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm: Model<"openai-completions"> = { ...getModel("openai", "gpt-4o-mini")!, @@ -168,32 +167,36 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Responses", () => { - it("gpt-4o - should return totalTokens equal to sum of components", { retry: 3, timeout: 60000 }, async () => { - const llm = getModel("openai", "gpt-4o"); + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Responses", () => { + it( + "gpt-4o - should return totalTokens equal to sum of components", + async () => { + const llm = getModel("openai", "gpt-4o"); - console.log(`\nOpenAI Responses / ${llm.id}:`); - const { first, second } = await testTotalTokensWithCache(llm); + console.log(`\nOpenAI Responses / ${llm.id}:`); + const { first, second } = await testTotalTokensWithCache(llm); - logUsage("First request", first); - logUsage("Second request", second); + logUsage("First request", first); + logUsage("Second request", second); - assertTotalTokensEqualsComponents(first); - assertTotalTokensEqualsComponents(second); - }); + assertTotalTokensEqualsComponents(first); + assertTotalTokensEqualsComponents(second); + }, + { retry: 3, timeout: 60000 }, + ); }); // ========================================================================= // Google // ========================================================================= - describe.skipIf(!process.env.GEMINI_API_KEY)("Google", () => { + describe.skipIf(!e2eApiKey("GEMINI_API_KEY"))("Google", () => { it( "gemini-2.0-flash - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("google", "gemini-2.0-flash"); @@ -206,6 +209,7 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); }); @@ -213,10 +217,9 @@ describe("totalTokens field", () => { // xAI // ========================================================================= - describe.skipIf(!process.env.XAI_API_KEY)("xAI", () => { + describe.skipIf(!e2eApiKey("XAI_API_KEY"))("xAI", () => { it( "grok-3-fast - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("xai", "grok-3-fast"); @@ -229,6 +232,7 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); }); @@ -236,10 +240,9 @@ describe("totalTokens field", () => { // Groq // ========================================================================= - describe.skipIf(!process.env.GROQ_API_KEY)("Groq", () => { + describe.skipIf(!e2eApiKey("GROQ_API_KEY"))("Groq", () => { it( "openai/gpt-oss-120b - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("groq", "openai/gpt-oss-120b"); @@ -252,6 +255,7 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); }); @@ -259,10 +263,9 @@ describe("totalTokens field", () => { // Cerebras // ========================================================================= - describe.skipIf(!process.env.CEREBRAS_API_KEY)("Cerebras", () => { + describe.skipIf(!e2eApiKey("CEREBRAS_API_KEY"))("Cerebras", () => { it( "gpt-oss-120b - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("cerebras", "gpt-oss-120b"); @@ -275,6 +278,7 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); }); @@ -282,10 +286,9 @@ describe("totalTokens field", () => { // z.ai // ========================================================================= - describe.skipIf(!process.env.ZAI_API_KEY)("z.ai", () => { + describe.skipIf(!e2eApiKey("ZAI_API_KEY"))("z.ai", () => { it( "glm-4.5-flash - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("zai", "glm-4.5-flash"); @@ -298,6 +301,7 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); }); @@ -305,10 +309,9 @@ describe("totalTokens field", () => { // Mistral // ========================================================================= - describe.skipIf(!process.env.MISTRAL_API_KEY)("Mistral", () => { + describe.skipIf(!e2eApiKey("MISTRAL_API_KEY"))("Mistral", () => { it( "devstral-medium-latest - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("mistral", "devstral-medium-latest"); @@ -321,6 +324,7 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); }); @@ -328,10 +332,9 @@ describe("totalTokens field", () => { // OpenRouter - Multiple backend providers // ========================================================================= - describe.skipIf(!process.env.OPENROUTER_API_KEY)("OpenRouter", () => { + describe.skipIf(!e2eApiKey("OPENROUTER_API_KEY"))("OpenRouter", () => { it( "anthropic/claude-sonnet-4 - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("openrouter", "anthropic/claude-sonnet-4"); @@ -344,11 +347,11 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); it( "deepseek/deepseek-chat - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("openrouter", "deepseek/deepseek-chat"); @@ -361,11 +364,11 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); it( "mistralai/mistral-small-3.1-24b-instruct - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("openrouter", "mistralai/mistral-small-3.1-24b-instruct"); @@ -378,11 +381,11 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); it( "google/gemini-2.0-flash-001 - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("openrouter", "google/gemini-2.0-flash-001"); @@ -395,11 +398,11 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); it( "meta-llama/llama-4-maverick - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("openrouter", "meta-llama/llama-4-maverick"); @@ -412,6 +415,7 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); }); @@ -422,7 +426,6 @@ describe("totalTokens field", () => { describe("GitHub Copilot (OAuth)", () => { it.skipIf(!githubCopilotToken)( "gpt-4o - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("github-copilot", "gpt-4o"); @@ -435,11 +438,11 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); it.skipIf(!githubCopilotToken)( "claude-sonnet-4 - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("github-copilot", "claude-sonnet-4"); @@ -452,6 +455,7 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); }); @@ -462,7 +466,6 @@ describe("totalTokens field", () => { describe("Google Gemini CLI (OAuth)", () => { it.skipIf(!geminiCliToken)( "gemini-2.5-flash - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("google-gemini-cli", "gemini-2.5-flash"); @@ -475,6 +478,7 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); }); @@ -485,7 +489,6 @@ describe("totalTokens field", () => { describe("Google Antigravity (OAuth)", () => { it.skipIf(!antigravityToken)( "gemini-3-flash - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("google-antigravity", "gemini-3-flash"); @@ -498,11 +501,11 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); it.skipIf(!antigravityToken)( "claude-sonnet-4-5 - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("google-antigravity", "claude-sonnet-4-5"); @@ -515,11 +518,11 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); it.skipIf(!antigravityToken)( "gpt-oss-120b-medium - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("google-antigravity", "gpt-oss-120b-medium"); @@ -532,6 +535,7 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); }); @@ -542,7 +546,6 @@ describe("totalTokens field", () => { describe("OpenAI Codex (OAuth)", () => { it.skipIf(!openaiCodexToken)( "gpt-5.2-codex - should return totalTokens equal to sum of components", - { retry: 3, timeout: 60000 }, async () => { const llm = getModel("openai-codex", "gpt-5.2-codex"); @@ -555,6 +558,7 @@ describe("totalTokens field", () => { assertTotalTokensEqualsComponents(first); assertTotalTokensEqualsComponents(second); }, + { retry: 3, timeout: 60000 }, ); }); }); diff --git a/packages/ai/test/unicode-surrogate.test.ts b/packages/ai/test/unicode-surrogate.test.ts index eda0a9a41..82a49353d 100644 --- a/packages/ai/test/unicode-surrogate.test.ts +++ b/packages/ai/test/unicode-surrogate.test.ts @@ -1,9 +1,9 @@ +import { describe, expect, it } from "bun:test"; import { getModel } from "@oh-my-pi/pi-ai/models"; import { complete } from "@oh-my-pi/pi-ai/stream"; import type { Api, Context, Model, OptionsForApi, ToolResultMessage } from "@oh-my-pi/pi-ai/types"; import { Type } from "@sinclair/typebox"; -import { describe, expect, it } from "vitest"; -import { resolveApiKey } from "./oauth"; +import { e2eApiKey, resolveApiKey } from "./oauth"; // Empty schema for test tools - must be proper OBJECT type for Cloud Code Assist const emptySchema = Type.Object({}); @@ -277,68 +277,116 @@ async function testUnpairedHighSurrogate(llm: Model, opt } describe("AI Providers Unicode Surrogate Pair Tests", () => { - describe.skipIf(!process.env.GEMINI_API_KEY)("Google Provider Unicode Handling", () => { + describe.skipIf(!e2eApiKey("GEMINI_API_KEY"))("Google Provider Unicode Handling", () => { const llm = getModel("google", "gemini-2.5-flash"); - it("should handle emoji in tool results", { retry: 3, timeout: 30000 }, async () => { - await testEmojiInToolResults(llm); - }); + it( + "should handle emoji in tool results", + async () => { + await testEmojiInToolResults(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle real-world LinkedIn comment data with emoji", { retry: 3, timeout: 30000 }, async () => { - await testRealWorldLinkedInData(llm); - }); + it( + "should handle real-world LinkedIn comment data with emoji", + async () => { + await testRealWorldLinkedInData(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle unpaired high surrogate (0xD83D) in tool results", { retry: 3, timeout: 30000 }, async () => { - await testUnpairedHighSurrogate(llm); - }); + it( + "should handle unpaired high surrogate (0xD83D) in tool results", + async () => { + await testUnpairedHighSurrogate(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Completions Provider Unicode Handling", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Completions Provider Unicode Handling", () => { const llm = getModel("openai", "gpt-4o-mini"); - it("should handle emoji in tool results", { retry: 3, timeout: 30000 }, async () => { - await testEmojiInToolResults(llm); - }); + it( + "should handle emoji in tool results", + async () => { + await testEmojiInToolResults(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle real-world LinkedIn comment data with emoji", { retry: 3, timeout: 30000 }, async () => { - await testRealWorldLinkedInData(llm); - }); + it( + "should handle real-world LinkedIn comment data with emoji", + async () => { + await testRealWorldLinkedInData(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle unpaired high surrogate (0xD83D) in tool results", { retry: 3, timeout: 30000 }, async () => { - await testUnpairedHighSurrogate(llm); - }); + it( + "should handle unpaired high surrogate (0xD83D) in tool results", + async () => { + await testUnpairedHighSurrogate(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.OPENAI_API_KEY)("OpenAI Responses Provider Unicode Handling", () => { + describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("OpenAI Responses Provider Unicode Handling", () => { const llm = getModel("openai", "gpt-5-mini"); - it("should handle emoji in tool results", { retry: 3, timeout: 30000 }, async () => { - await testEmojiInToolResults(llm); - }); + it( + "should handle emoji in tool results", + async () => { + await testEmojiInToolResults(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle real-world LinkedIn comment data with emoji", { retry: 3, timeout: 30000 }, async () => { - await testRealWorldLinkedInData(llm); - }); + it( + "should handle real-world LinkedIn comment data with emoji", + async () => { + await testRealWorldLinkedInData(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle unpaired high surrogate (0xD83D) in tool results", { retry: 3, timeout: 30000 }, async () => { - await testUnpairedHighSurrogate(llm); - }); + it( + "should handle unpaired high surrogate (0xD83D) in tool results", + async () => { + await testUnpairedHighSurrogate(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.ANTHROPIC_API_KEY)("Anthropic Provider Unicode Handling", () => { + describe.skipIf(!e2eApiKey("ANTHROPIC_API_KEY"))("Anthropic Provider Unicode Handling", () => { const llm = getModel("anthropic", "claude-3-5-haiku-20241022"); - it("should handle emoji in tool results", { retry: 3, timeout: 30000 }, async () => { - await testEmojiInToolResults(llm); - }); + it( + "should handle emoji in tool results", + async () => { + await testEmojiInToolResults(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle real-world LinkedIn comment data with emoji", { retry: 3, timeout: 30000 }, async () => { - await testRealWorldLinkedInData(llm); - }); + it( + "should handle real-world LinkedIn comment data with emoji", + async () => { + await testRealWorldLinkedInData(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle unpaired high surrogate (0xD83D) in tool results", { retry: 3, timeout: 30000 }, async () => { - await testUnpairedHighSurrogate(llm); - }); + it( + "should handle unpaired high surrogate (0xD83D) in tool results", + async () => { + await testUnpairedHighSurrogate(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); // ========================================================================= @@ -348,301 +396,365 @@ describe("AI Providers Unicode Surrogate Pair Tests", () => { describe("Anthropic OAuth Provider Unicode Handling", () => { const llm = getModel("anthropic", "claude-3-5-haiku-20241022"); - it.skipIf(!anthropicOAuthToken)("should handle emoji in tool results", { retry: 3, timeout: 30000 }, async () => { - await testEmojiInToolResults(llm, { apiKey: anthropicOAuthToken }); - }); + it.skipIf(!anthropicOAuthToken)( + "should handle emoji in tool results", + async () => { + await testEmojiInToolResults(llm, { apiKey: anthropicOAuthToken }); + }, + { retry: 3, timeout: 30000 }, + ); it.skipIf(!anthropicOAuthToken)( "should handle real-world LinkedIn comment data with emoji", - { retry: 3, timeout: 30000 }, async () => { await testRealWorldLinkedInData(llm, { apiKey: anthropicOAuthToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!anthropicOAuthToken)( "should handle unpaired high surrogate (0xD83D) in tool results", - { retry: 3, timeout: 30000 }, async () => { await testUnpairedHighSurrogate(llm, { apiKey: anthropicOAuthToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("GitHub Copilot Provider Unicode Handling", () => { it.skipIf(!githubCopilotToken)( "gpt-4o - should handle emoji in tool results", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "gpt-4o"); await testEmojiInToolResults(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!githubCopilotToken)( "gpt-4o - should handle real-world LinkedIn comment data with emoji", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "gpt-4o"); await testRealWorldLinkedInData(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!githubCopilotToken)( "gpt-4o - should handle unpaired high surrogate (0xD83D) in tool results", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "gpt-4o"); await testUnpairedHighSurrogate(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!githubCopilotToken)( "claude-sonnet-4 - should handle emoji in tool results", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "claude-sonnet-4"); await testEmojiInToolResults(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!githubCopilotToken)( "claude-sonnet-4 - should handle real-world LinkedIn comment data with emoji", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "claude-sonnet-4"); await testRealWorldLinkedInData(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!githubCopilotToken)( "claude-sonnet-4 - should handle unpaired high surrogate (0xD83D) in tool results", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("github-copilot", "claude-sonnet-4"); await testUnpairedHighSurrogate(llm, { apiKey: githubCopilotToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("Google Gemini CLI Provider Unicode Handling", () => { it.skipIf(!geminiCliToken)( "gemini-2.5-flash - should handle emoji in tool results", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-gemini-cli", "gemini-2.5-flash"); await testEmojiInToolResults(llm, { apiKey: geminiCliToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!geminiCliToken)( "gemini-2.5-flash - should handle real-world LinkedIn comment data with emoji", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-gemini-cli", "gemini-2.5-flash"); await testRealWorldLinkedInData(llm, { apiKey: geminiCliToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!geminiCliToken)( "gemini-2.5-flash - should handle unpaired high surrogate (0xD83D) in tool results", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-gemini-cli", "gemini-2.5-flash"); await testUnpairedHighSurrogate(llm, { apiKey: geminiCliToken }); }, + { retry: 3, timeout: 30000 }, ); }); describe("Google Antigravity Provider Unicode Handling", () => { it.skipIf(!antigravityToken)( "gemini-3-flash - should handle emoji in tool results", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gemini-3-flash"); await testEmojiInToolResults(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "gemini-3-flash - should handle real-world LinkedIn comment data with emoji", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gemini-3-flash"); await testRealWorldLinkedInData(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "gemini-3-flash - should handle unpaired high surrogate (0xD83D) in tool results", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gemini-3-flash"); await testUnpairedHighSurrogate(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "claude-sonnet-4-5 - should handle emoji in tool results", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "claude-sonnet-4-5"); await testEmojiInToolResults(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "claude-sonnet-4-5 - should handle real-world LinkedIn comment data with emoji", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "claude-sonnet-4-5"); await testRealWorldLinkedInData(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "claude-sonnet-4-5 - should handle unpaired high surrogate (0xD83D) in tool results", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "claude-sonnet-4-5"); await testUnpairedHighSurrogate(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "gpt-oss-120b-medium - should handle emoji in tool results", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gpt-oss-120b-medium"); await testEmojiInToolResults(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "gpt-oss-120b-medium - should handle real-world LinkedIn comment data with emoji", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gpt-oss-120b-medium"); await testRealWorldLinkedInData(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!antigravityToken)( "gpt-oss-120b-medium - should handle unpaired high surrogate (0xD83D) in tool results", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("google-antigravity", "gpt-oss-120b-medium"); await testUnpairedHighSurrogate(llm, { apiKey: antigravityToken }); }, + { retry: 3, timeout: 30000 }, ); }); - describe.skipIf(!process.env.XAI_API_KEY)("xAI Provider Unicode Handling", () => { + describe.skipIf(!e2eApiKey("XAI_API_KEY"))("xAI Provider Unicode Handling", () => { const llm = getModel("xai", "grok-3"); - it("should handle emoji in tool results", { retry: 3, timeout: 30000 }, async () => { - await testEmojiInToolResults(llm); - }); + it( + "should handle emoji in tool results", + async () => { + await testEmojiInToolResults(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle real-world LinkedIn comment data with emoji", { retry: 3, timeout: 30000 }, async () => { - await testRealWorldLinkedInData(llm); - }); + it( + "should handle real-world LinkedIn comment data with emoji", + async () => { + await testRealWorldLinkedInData(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle unpaired high surrogate (0xD83D) in tool results", { retry: 3, timeout: 30000 }, async () => { - await testUnpairedHighSurrogate(llm); - }); + it( + "should handle unpaired high surrogate (0xD83D) in tool results", + async () => { + await testUnpairedHighSurrogate(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.GROQ_API_KEY)("Groq Provider Unicode Handling", () => { + describe.skipIf(!e2eApiKey("GROQ_API_KEY"))("Groq Provider Unicode Handling", () => { const llm = getModel("groq", "openai/gpt-oss-20b"); - it("should handle emoji in tool results", { retry: 3, timeout: 30000 }, async () => { - await testEmojiInToolResults(llm); - }); + it( + "should handle emoji in tool results", + async () => { + await testEmojiInToolResults(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle real-world LinkedIn comment data with emoji", { retry: 3, timeout: 30000 }, async () => { - await testRealWorldLinkedInData(llm); - }); + it( + "should handle real-world LinkedIn comment data with emoji", + async () => { + await testRealWorldLinkedInData(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle unpaired high surrogate (0xD83D) in tool results", { retry: 3, timeout: 30000 }, async () => { - await testUnpairedHighSurrogate(llm); - }); + it( + "should handle unpaired high surrogate (0xD83D) in tool results", + async () => { + await testUnpairedHighSurrogate(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.CEREBRAS_API_KEY)("Cerebras Provider Unicode Handling", () => { + describe.skipIf(!e2eApiKey("CEREBRAS_API_KEY"))("Cerebras Provider Unicode Handling", () => { const llm = getModel("cerebras", "gpt-oss-120b"); - it("should handle emoji in tool results", { retry: 3, timeout: 30000 }, async () => { - await testEmojiInToolResults(llm); - }); + it( + "should handle emoji in tool results", + async () => { + await testEmojiInToolResults(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle real-world LinkedIn comment data with emoji", { retry: 3, timeout: 30000 }, async () => { - await testRealWorldLinkedInData(llm); - }); + it( + "should handle real-world LinkedIn comment data with emoji", + async () => { + await testRealWorldLinkedInData(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle unpaired high surrogate (0xD83D) in tool results", { retry: 3, timeout: 30000 }, async () => { - await testUnpairedHighSurrogate(llm); - }); + it( + "should handle unpaired high surrogate (0xD83D) in tool results", + async () => { + await testUnpairedHighSurrogate(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.ZAI_API_KEY)("zAI Provider Unicode Handling", () => { + describe.skipIf(!e2eApiKey("ZAI_API_KEY"))("zAI Provider Unicode Handling", () => { const llm = getModel("zai", "glm-4.5-air"); - it("should handle emoji in tool results", { retry: 3, timeout: 30000 }, async () => { - await testEmojiInToolResults(llm); - }); + it( + "should handle emoji in tool results", + async () => { + await testEmojiInToolResults(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle real-world LinkedIn comment data with emoji", { retry: 3, timeout: 30000 }, async () => { - await testRealWorldLinkedInData(llm); - }); + it( + "should handle real-world LinkedIn comment data with emoji", + async () => { + await testRealWorldLinkedInData(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle unpaired high surrogate (0xD83D) in tool results", { retry: 3, timeout: 30000 }, async () => { - await testUnpairedHighSurrogate(llm); - }); + it( + "should handle unpaired high surrogate (0xD83D) in tool results", + async () => { + await testUnpairedHighSurrogate(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); - describe.skipIf(!process.env.MISTRAL_API_KEY)("Mistral Provider Unicode Handling", () => { + describe.skipIf(!e2eApiKey("MISTRAL_API_KEY"))("Mistral Provider Unicode Handling", () => { const llm = getModel("mistral", "devstral-medium-latest"); - it("should handle emoji in tool results", { retry: 3, timeout: 30000 }, async () => { - await testEmojiInToolResults(llm); - }); + it( + "should handle emoji in tool results", + async () => { + await testEmojiInToolResults(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle real-world LinkedIn comment data with emoji", { retry: 3, timeout: 30000 }, async () => { - await testRealWorldLinkedInData(llm); - }); + it( + "should handle real-world LinkedIn comment data with emoji", + async () => { + await testRealWorldLinkedInData(llm); + }, + { retry: 3, timeout: 30000 }, + ); - it("should handle unpaired high surrogate (0xD83D) in tool results", { retry: 3, timeout: 30000 }, async () => { - await testUnpairedHighSurrogate(llm); - }); + it( + "should handle unpaired high surrogate (0xD83D) in tool results", + async () => { + await testUnpairedHighSurrogate(llm); + }, + { retry: 3, timeout: 30000 }, + ); }); describe("OpenAI Codex Provider Unicode Handling", () => { it.skipIf(!openaiCodexToken)( "gpt-5.2-codex - should handle emoji in tool results", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("openai-codex", "gpt-5.2-codex"); await testEmojiInToolResults(llm, { apiKey: openaiCodexToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!openaiCodexToken)( "gpt-5.2-codex - should handle real-world LinkedIn comment data with emoji", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("openai-codex", "gpt-5.2-codex"); await testRealWorldLinkedInData(llm, { apiKey: openaiCodexToken }); }, + { retry: 3, timeout: 30000 }, ); it.skipIf(!openaiCodexToken)( "gpt-5.2-codex - should handle unpaired high surrogate (0xD83D) in tool results", - { retry: 3, timeout: 30000 }, async () => { const llm = getModel("openai-codex", "gpt-5.2-codex"); await testUnpairedHighSurrogate(llm, { apiKey: openaiCodexToken }); }, + { retry: 3, timeout: 30000 }, ); }); }); diff --git a/packages/ai/test/xhigh.test.ts b/packages/ai/test/xhigh.test.ts index e9f320f57..4fd7796de 100644 --- a/packages/ai/test/xhigh.test.ts +++ b/packages/ai/test/xhigh.test.ts @@ -1,7 +1,8 @@ +import { describe, expect, it } from "bun:test"; import { getModel } from "@oh-my-pi/pi-ai/models"; import { stream } from "@oh-my-pi/pi-ai/stream"; import type { Context, Model } from "@oh-my-pi/pi-ai/types"; -import { describe, expect, it } from "vitest"; +import { e2eApiKey } from "./oauth"; function makeContext(): Context { return { @@ -15,7 +16,7 @@ function makeContext(): Context { }; } -describe.skipIf(!process.env.OPENAI_API_KEY)("xhigh reasoning", () => { +describe.skipIf(!e2eApiKey("OPENAI_API_KEY"))("xhigh reasoning", () => { describe("codex-max (supports xhigh)", () => { // Note: codex models only support the responses API, not chat completions it("should work with openai-responses", async () => { diff --git a/packages/ai/test/zen.test.ts b/packages/ai/test/zen.test.ts index c682ef281..7ffa3a7a4 100644 --- a/packages/ai/test/zen.test.ts +++ b/packages/ai/test/zen.test.ts @@ -1,9 +1,10 @@ +import { describe, expect, it } from "bun:test"; import { MODELS } from "@oh-my-pi/pi-ai/models.generated"; import { complete } from "@oh-my-pi/pi-ai/stream"; import type { Model } from "@oh-my-pi/pi-ai/types"; -import { describe, expect, it } from "vitest"; +import { e2eApiKey } from "./oauth"; -describe.skipIf(!process.env.OPENCODE_API_KEY)("OpenCode Zen Models Smoke Test", () => { +describe.skipIf(!e2eApiKey("OPENCODE_API_KEY"))("OpenCode Zen Models Smoke Test", () => { const zenModels = Object.values(MODELS.opencode); zenModels.forEach((model) => { diff --git a/packages/ai/tsconfig.build.json b/packages/ai/tsconfig.build.json index 6089faa7f..c9011ba2a 100644 --- a/packages/ai/tsconfig.build.json +++ b/packages/ai/tsconfig.build.json @@ -1,9 +1,3 @@ { - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist", - "rootDir": "./src" - }, - "include": ["src/**/*.ts"], - "exclude": ["node_modules", "dist", "**/*.d.ts", "src/**/*.d.ts"] + "extends": "./tsconfig.json" } \ No newline at end of file diff --git a/packages/ai/tsconfig.json b/packages/ai/tsconfig.json index f889c005d..41b5f2b67 100644 --- a/packages/ai/tsconfig.json +++ b/packages/ai/tsconfig.json @@ -1,21 +1,8 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "noEmit": true, - "baseUrl": ".", - "paths": { - "@oh-my-pi/pi-ai": ["./src/index.ts"], - "@oh-my-pi/pi-ai/*": ["./src/*"], - "@oh-my-pi/pi-agent-core": ["../agent/src/index.ts"], - "@oh-my-pi/pi-agent-core/*": ["../agent/src/*"], - "@oh-my-pi/pi-utils": ["../pi-utils/src/index.ts"], - "@oh-my-pi/pi-utils/*": ["../pi-utils/src/*"], - "@oh-my-pi/pi-coding-agent": ["../coding-agent/src/index.ts"], - "@oh-my-pi/pi-coding-agent/*": ["../coding-agent/src/*"], - "@oh-my-pi/pi-tui": ["../tui/src/index.ts"], - "@oh-my-pi/pi-tui/*": ["../tui/src/*"] - } + "noEmit": true }, - "include": ["src/**/*.ts"], + "include": ["src/**/*.ts", "test/**/*.ts"], "exclude": ["node_modules", "dist"] } diff --git a/packages/ai/tsconfig.publish.json b/packages/ai/tsconfig.publish.json index 6404e7a24..ea6be8e9a 100644 --- a/packages/ai/tsconfig.publish.json +++ b/packages/ai/tsconfig.publish.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "noEmit": true, - "baseUrl": ".", - "paths": { - "@oh-my-pi/pi-ai": ["./src/index.ts"], - "@oh-my-pi/pi-ai/*": ["./src/*"] - } - }, - "include": ["src/**/*.ts"] + "extends": "./tsconfig.json" } diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index ae1393230..885f0dfb9 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -44,7 +44,8 @@ - Added two-level mermaid caching with pending deduplication to prevent redundant renders - Added Python kernel session pooling with MAX_KERNEL_SESSIONS limit and automatic eviction of oldest sessions - Added automatic idle kernel session cleanup timer (5-minute timeout, 30-second interval) -- Added WASM binary generation script for photon module distribution +- Added types/assets/index.d.ts for global TypeScript module declarations supporting `.md`, `.py`, and `.wasm?raw` imports +- Added bunfig.toml loader configuration for importing markdown, Python, and WASM files as text modules ### Changed - Changed changelog diff truncation limit to be configurable via settings @@ -98,6 +99,9 @@ - Changed AuthStorage from constructor-based instantiation to async factory method (AuthStorage.create()) - Changed Python kernel resource management with gateway shutdown on session disposal - Updated TypeScript configuration for better publish-time configuration handling with tsconfig.publish.json +- Updated TypeScript and Bun configuration for monorepo-wide build consistency and reduced boilerplate +- Removed WASM base64 encoding build script; imports now use Bun loader with `wasm?raw` query parameter +- Unified TypeScript checking pipeline with tsgo-based configuration instead of per-package tsconfig.publish.json boilerplate ### Fixed - Fixed database busy errors during concurrent access by adding retry logic with exponential backoff when opening storage diff --git a/packages/coding-agent/bunfig.toml b/packages/coding-agent/bunfig.toml new file mode 100644 index 000000000..1bf5937d4 --- /dev/null +++ b/packages/coding-agent/bunfig.toml @@ -0,0 +1,8 @@ +[install] +linker = "isolated" +exact = true +saveTextLockfile = true + +[loader] +".md" = "text" +".py" = "text" diff --git a/packages/coding-agent/package.json b/packages/coding-agent/package.json index 5c15536f8..c02b9da3b 100644 --- a/packages/coding-agent/package.json +++ b/packages/coding-agent/package.json @@ -21,10 +21,42 @@ "types": "./src/extensibility/hooks/index.ts", "import": "./src/extensibility/hooks/index.ts" }, - "./prompts/*": "./src/prompts/*", + "./sdk": { + "types": "./src/sdk.ts", + "import": "./src/sdk.ts" + }, + "./prompts/*": "./src/prompts/*.md", + "./capability/*": { + "types": "./src/capability/*.ts", + "import": "./src/capability/*.ts" + }, + "./config/*": { + "types": "./src/config/*.ts", + "import": "./src/config/*.ts" + }, + "./extensibility/*": { + "types": "./src/extensibility/*.ts", + "import": "./src/extensibility/*.ts" + }, + "./extensibility/hooks/*": { + "types": "./src/extensibility/hooks/*.ts", + "import": "./src/extensibility/hooks/*.ts" + }, + "./extensibility/extensions/*": { + "types": "./src/extensibility/extensions/*.ts", + "import": "./src/extensibility/extensions/*.ts" + }, + "./session/*": { + "types": "./src/session/*.ts", + "import": "./src/session/*.ts" + }, + "./vendor/photon/*": { + "types": "./src/vendor/photon/*", + "import": "./src/vendor/photon/*" + }, "./*": { - "types": "./src/*", - "import": "./src/*" + "types": "./src/*.ts", + "import": "./src/*.ts" } }, "files": [ @@ -32,19 +64,15 @@ "scripts", "docs", "examples", + "README.md", "CHANGELOG.md" ], "scripts": { - "check": "tsgo -p tsconfig.check.json", + "check": "tsgo -p tsconfig.json", "format-prompts": "bun scripts/format-prompts.ts", - "clean": "rm -rf dist", - "build": "tsgo -p tsconfig.build.json && chmod +x dist/cli.js", - "build:binary": "bun run generate-wasm-b64 && bun build --compile ./src/cli.ts --outfile dist/omp", - "generate-wasm-b64": "bun scripts/generate-wasm-b64.ts", + "build:binary": "bun build --compile ./src/cli.ts --outfile dist/omp", "generate-template": "bun scripts/generate-template.ts", - "postinstall": "(bun run generate-wasm-b64 && bun run generate-template) || true", - "test": "bun test", - "prepublishOnly": "cp tsconfig.publish.json tsconfig.json && bun run generate-template" + "test": "bun test" }, "dependencies": { "@oh-my-pi/omp-stats": "workspace:*", diff --git a/packages/coding-agent/scripts/generate-wasm-b64.ts b/packages/coding-agent/scripts/generate-wasm-b64.ts deleted file mode 100644 index e836b5be1..000000000 --- a/packages/coding-agent/scripts/generate-wasm-b64.ts +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bun -/** - * Generates a base64-encoded JavaScript module from the photon WASM file. - * This allows bundling the WASM binary inline for single-file distribution. - */ - -import { join } from "node:path"; - -const VENDOR_DIR = join(import.meta.dir, "../src/vendor/photon"); -const WASM_PATH = join(VENDOR_DIR, "photon_rs_bg.wasm"); -const OUTPUT_PATH = join(VENDOR_DIR, "photon_rs_bg.wasm.b64.js"); - -const wasmFile = Bun.file(WASM_PATH); -if (!(await wasmFile.exists())) { - console.error(`WASM file not found: ${WASM_PATH}`); - process.exit(1); -} - -const wasmBytes = await wasmFile.arrayBuffer(); -const base64 = Buffer.from(wasmBytes).toString("base64"); -const content = `export default "${base64}";\n`; - -await Bun.write(OUTPUT_PATH, content); -console.log(`Generated ${OUTPUT_PATH} (${Math.round(base64.length / 1024)}KB)`); diff --git a/packages/coding-agent/src/cli/args.ts b/packages/coding-agent/src/cli/args.ts index d1f2d96ab..dd9a71f75 100644 --- a/packages/coding-agent/src/cli/args.ts +++ b/packages/coding-agent/src/cli/args.ts @@ -3,9 +3,9 @@ */ import type { ThinkingLevel } from "@oh-my-pi/pi-agent-core"; -import { APP_NAME, CONFIG_DIR_NAME, ENV_AGENT_DIR } from "@oh-my-pi/pi-coding-agent/config"; -import { BUILTIN_TOOLS } from "@oh-my-pi/pi-coding-agent/tools"; import chalk from "chalk"; +import { APP_NAME, CONFIG_DIR_NAME, ENV_AGENT_DIR } from "../config"; +import { BUILTIN_TOOLS } from "../tools"; export type Mode = "text" | "json" | "rpc"; diff --git a/packages/coding-agent/src/cli/config-cli.ts b/packages/coding-agent/src/cli/config-cli.ts index bbe948ce5..76f3fc1aa 100644 --- a/packages/coding-agent/src/cli/config-cli.ts +++ b/packages/coding-agent/src/cli/config-cli.ts @@ -5,11 +5,11 @@ * Uses SETTINGS_DEFS as the source of truth for available settings. */ -import { APP_NAME, getAgentDir } from "@oh-my-pi/pi-coding-agent/config"; -import { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import { SETTINGS_DEFS, type SettingDef } from "@oh-my-pi/pi-coding-agent/modes/components/settings-defs"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import chalk from "chalk"; +import { APP_NAME, getAgentDir } from "../config"; +import { SettingsManager } from "../config/settings-manager"; +import { SETTINGS_DEFS, type SettingDef } from "../modes/components/settings-defs"; +import { theme } from "../modes/theme/theme"; // ============================================================================= // Types diff --git a/packages/coding-agent/src/cli/file-processor.ts b/packages/coding-agent/src/cli/file-processor.ts index 4a2a6e56c..8fdc80761 100644 --- a/packages/coding-agent/src/cli/file-processor.ts +++ b/packages/coding-agent/src/cli/file-processor.ts @@ -5,10 +5,10 @@ import { existsSync, readFileSync, statSync } from "node:fs"; import { resolve } from "node:path"; import type { ImageContent } from "@oh-my-pi/pi-ai"; -import { resolveReadPath } from "@oh-my-pi/pi-coding-agent/tools/path-utils"; -import { formatDimensionNote, resizeImage } from "@oh-my-pi/pi-coding-agent/utils/image-resize"; -import { detectSupportedImageMimeTypeFromFile } from "@oh-my-pi/pi-coding-agent/utils/mime"; import chalk from "chalk"; +import { resolveReadPath } from "../tools/path-utils"; +import { formatDimensionNote, resizeImage } from "../utils/image-resize"; +import { detectSupportedImageMimeTypeFromFile } from "../utils/mime"; export interface ProcessedFiles { text: string; diff --git a/packages/coding-agent/src/cli/list-models.ts b/packages/coding-agent/src/cli/list-models.ts index 9450506af..46f7295ac 100644 --- a/packages/coding-agent/src/cli/list-models.ts +++ b/packages/coding-agent/src/cli/list-models.ts @@ -3,8 +3,8 @@ */ import type { Api, Model } from "@oh-my-pi/pi-ai"; -import type { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry"; -import { fuzzyFilter } from "@oh-my-pi/pi-coding-agent/utils/fuzzy"; +import type { ModelRegistry } from "../config/model-registry"; +import { fuzzyFilter } from "../utils/fuzzy"; /** * Format a number as human-readable (e.g., 200000 -> "200K", 1000000 -> "1M") diff --git a/packages/coding-agent/src/cli/plugin-cli.ts b/packages/coding-agent/src/cli/plugin-cli.ts index ff61d27e8..3de86d2e7 100644 --- a/packages/coding-agent/src/cli/plugin-cli.ts +++ b/packages/coding-agent/src/cli/plugin-cli.ts @@ -4,10 +4,10 @@ * Handles `omp plugin ` subcommands for plugin lifecycle management. */ -import { APP_NAME } from "@oh-my-pi/pi-coding-agent/config"; -import { PluginManager, parseSettingValue, validateSetting } from "@oh-my-pi/pi-coding-agent/extensibility/plugins"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import chalk from "chalk"; +import { APP_NAME } from "../config"; +import { PluginManager, parseSettingValue, validateSetting } from "../extensibility/plugins"; +import { theme } from "../modes/theme/theme"; // ============================================================================= // Types diff --git a/packages/coding-agent/src/cli/session-picker.ts b/packages/coding-agent/src/cli/session-picker.ts index c3fc42a80..6c2a2d8e2 100644 --- a/packages/coding-agent/src/cli/session-picker.ts +++ b/packages/coding-agent/src/cli/session-picker.ts @@ -2,9 +2,9 @@ * TUI session selector for --resume flag */ -import { SessionSelectorComponent } from "@oh-my-pi/pi-coding-agent/modes/components/session-selector"; -import type { SessionInfo } from "@oh-my-pi/pi-coding-agent/session/session-manager"; import { ProcessTerminal, TUI } from "@oh-my-pi/pi-tui"; +import { SessionSelectorComponent } from "../modes/components/session-selector"; +import type { SessionInfo } from "../session/session-manager"; /** Show TUI session selector and return selected session path or null if cancelled */ export async function selectSession(sessions: SessionInfo[]): Promise { diff --git a/packages/coding-agent/src/cli/setup-cli.ts b/packages/coding-agent/src/cli/setup-cli.ts index 4fd75691e..82e7c421d 100644 --- a/packages/coding-agent/src/cli/setup-cli.ts +++ b/packages/coding-agent/src/cli/setup-cli.ts @@ -4,10 +4,10 @@ * Handles `omp setup ` to install dependencies for optional features. */ -import { APP_NAME } from "@oh-my-pi/pi-coding-agent/config"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { $ } from "bun"; import chalk from "chalk"; +import { APP_NAME } from "../config"; +import { theme } from "../modes/theme/theme"; export type SetupComponent = "python"; diff --git a/packages/coding-agent/src/cli/stats-cli.ts b/packages/coding-agent/src/cli/stats-cli.ts index f4a32e8e8..4bb7d0be3 100644 --- a/packages/coding-agent/src/cli/stats-cli.ts +++ b/packages/coding-agent/src/cli/stats-cli.ts @@ -4,8 +4,8 @@ * Handles `omp stats` subcommand for viewing AI usage statistics. */ -import { APP_NAME } from "@oh-my-pi/pi-coding-agent/config"; import chalk from "chalk"; +import { APP_NAME } from "../config"; // ============================================================================= // Types @@ -106,7 +106,7 @@ export async function runStatsCommand(cmd: StatsCommandArgs): Promise { } // Start the dashboard server - const { port } = startServer(cmd.port); + const { port } = await startServer(cmd.port); console.log(chalk.green(`Dashboard available at: http://localhost:${port}`)); console.log("Press Ctrl+C to stop\n"); diff --git a/packages/coding-agent/src/cli/update-cli.ts b/packages/coding-agent/src/cli/update-cli.ts index b4bd0e275..46bdbbbfe 100644 --- a/packages/coding-agent/src/cli/update-cli.ts +++ b/packages/coding-agent/src/cli/update-cli.ts @@ -10,9 +10,9 @@ import { createWriteStream, existsSync, renameSync, unlinkSync } from "node:fs"; import { dirname } from "node:path"; import { Readable } from "node:stream"; import { pipeline } from "node:stream/promises"; -import { APP_NAME, VERSION } from "@oh-my-pi/pi-coding-agent/config"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import chalk from "chalk"; +import { APP_NAME, VERSION } from "../config"; +import { theme } from "../modes/theme/theme"; /** * Detect if we're running as a Bun compiled binary. diff --git a/packages/coding-agent/src/commit/agentic/agent.ts b/packages/coding-agent/src/commit/agentic/agent.ts index 345fc5b3d..e5ad14bd0 100644 --- a/packages/coding-agent/src/commit/agentic/agent.ts +++ b/packages/coding-agent/src/commit/agentic/agent.ts @@ -1,21 +1,19 @@ import type { Api, Model } from "@oh-my-pi/pi-ai"; -import agentUserPrompt from "@oh-my-pi/pi-coding-agent/commit/agentic/prompts/session-user.md" with { type: "text" }; -import agentSystemPrompt from "@oh-my-pi/pi-coding-agent/commit/agentic/prompts/system.md" with { type: "text" }; -import type { CommitAgentState } from "@oh-my-pi/pi-coding-agent/commit/agentic/state"; -import { createCommitTools } from "@oh-my-pi/pi-coding-agent/commit/agentic/tools"; -import type { ControlledGit } from "@oh-my-pi/pi-coding-agent/commit/git"; -import typesDescriptionPrompt from "@oh-my-pi/pi-coding-agent/commit/prompts/types-description.md" with { - type: "text", -}; -import type { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import type { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import { getMarkdownTheme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import { createAgentSession } from "@oh-my-pi/pi-coding-agent/sdk"; -import type { AgentSessionEvent } from "@oh-my-pi/pi-coding-agent/session/agent-session"; -import type { AuthStorage } from "@oh-my-pi/pi-coding-agent/session/auth-storage"; import { Markdown } from "@oh-my-pi/pi-tui"; import chalk from "chalk"; +import type { ControlledGit } from "../../commit/git"; +import typesDescriptionPrompt from "../../commit/prompts/types-description.md" with { type: "text" }; +import type { ModelRegistry } from "../../config/model-registry"; +import { renderPromptTemplate } from "../../config/prompt-templates"; +import type { SettingsManager } from "../../config/settings-manager"; +import { getMarkdownTheme } from "../../modes/theme/theme"; +import { createAgentSession } from "../../sdk"; +import type { AgentSessionEvent } from "../../session/agent-session"; +import type { AuthStorage } from "../../session/auth-storage"; +import agentUserPrompt from "./prompts/session-user.md" with { type: "text" }; +import agentSystemPrompt from "./prompts/system.md" with { type: "text" }; +import type { CommitAgentState } from "./state"; +import { createCommitTools } from "./tools"; export interface CommitAgentInput { cwd: string; diff --git a/packages/coding-agent/src/commit/agentic/fallback.ts b/packages/coding-agent/src/commit/agentic/fallback.ts index 2a0c32509..c1023c8b2 100644 --- a/packages/coding-agent/src/commit/agentic/fallback.ts +++ b/packages/coding-agent/src/commit/agentic/fallback.ts @@ -1,6 +1,6 @@ import { basename } from "node:path"; -import type { CommitProposal } from "@oh-my-pi/pi-coding-agent/commit/agentic/state"; -import type { CommitType, ConventionalAnalysis, NumstatEntry } from "@oh-my-pi/pi-coding-agent/commit/types"; +import type { CommitType, ConventionalAnalysis, NumstatEntry } from "../../commit/types"; +import type { CommitProposal } from "./state"; const TEST_PATTERNS = ["/test/", "/tests/", "/__tests__/", "_test.", ".test.", ".spec.", "_spec."]; const DOC_EXTENSIONS = new Set([".md", ".txt", ".rst", ".adoc"]); diff --git a/packages/coding-agent/src/commit/agentic/index.ts b/packages/coding-agent/src/commit/agentic/index.ts index cdfc13312..6a7f5e686 100644 --- a/packages/coding-agent/src/commit/agentic/index.ts +++ b/packages/coding-agent/src/commit/agentic/index.ts @@ -1,28 +1,21 @@ import { relative } from "node:path"; import { createInterface } from "node:readline/promises"; -import { type ExistingChangelogEntries, runCommitAgentSession } from "@oh-my-pi/pi-coding-agent/commit/agentic/agent"; -import { generateFallbackProposal } from "@oh-my-pi/pi-coding-agent/commit/agentic/fallback"; -import splitConfirmPrompt from "@oh-my-pi/pi-coding-agent/commit/agentic/prompts/split-confirm.md" with { - type: "text", -}; -import type { - CommitAgentState, - CommitProposal, - HunkSelector, - SplitCommitPlan, -} from "@oh-my-pi/pi-coding-agent/commit/agentic/state"; -import { computeDependencyOrder } from "@oh-my-pi/pi-coding-agent/commit/agentic/topo-sort"; -import { detectTrivialChange } from "@oh-my-pi/pi-coding-agent/commit/agentic/trivial"; -import { applyChangelogProposals } from "@oh-my-pi/pi-coding-agent/commit/changelog"; -import { detectChangelogBoundaries } from "@oh-my-pi/pi-coding-agent/commit/changelog/detect"; -import { parseUnreleasedSection } from "@oh-my-pi/pi-coding-agent/commit/changelog/parse"; -import { ControlledGit } from "@oh-my-pi/pi-coding-agent/commit/git"; -import { formatCommitMessage } from "@oh-my-pi/pi-coding-agent/commit/message"; -import { resolvePrimaryModel, resolveSmolModel } from "@oh-my-pi/pi-coding-agent/commit/model-selection"; -import type { CommitCommandArgs, ConventionalAnalysis } from "@oh-my-pi/pi-coding-agent/commit/types"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import { discoverAuthStorage, discoverContextFiles, discoverModels } from "@oh-my-pi/pi-coding-agent/sdk"; +import { applyChangelogProposals } from "../../commit/changelog"; +import { detectChangelogBoundaries } from "../../commit/changelog/detect"; +import { parseUnreleasedSection } from "../../commit/changelog/parse"; +import { ControlledGit } from "../../commit/git"; +import { formatCommitMessage } from "../../commit/message"; +import { resolvePrimaryModel, resolveSmolModel } from "../../commit/model-selection"; +import type { CommitCommandArgs, ConventionalAnalysis } from "../../commit/types"; +import { renderPromptTemplate } from "../../config/prompt-templates"; +import { SettingsManager } from "../../config/settings-manager"; +import { discoverAuthStorage, discoverContextFiles, discoverModels } from "../../sdk"; +import { type ExistingChangelogEntries, runCommitAgentSession } from "./agent"; +import { generateFallbackProposal } from "./fallback"; +import splitConfirmPrompt from "./prompts/split-confirm.md" with { type: "text" }; +import type { CommitAgentState, CommitProposal, HunkSelector, SplitCommitPlan } from "./state"; +import { computeDependencyOrder } from "./topo-sort"; +import { detectTrivialChange } from "./trivial"; interface CommitExecutionContext { git: ControlledGit; diff --git a/packages/coding-agent/src/commit/agentic/state.ts b/packages/coding-agent/src/commit/agentic/state.ts index 15e7ba8c2..e8e2b48bf 100644 --- a/packages/coding-agent/src/commit/agentic/state.ts +++ b/packages/coding-agent/src/commit/agentic/state.ts @@ -1,9 +1,4 @@ -import type { - CommitType, - ConventionalAnalysis, - ConventionalDetail, - NumstatEntry, -} from "@oh-my-pi/pi-coding-agent/commit/types"; +import type { CommitType, ConventionalAnalysis, ConventionalDetail, NumstatEntry } from "../../commit/types"; export interface GitOverviewSnapshot { files: string[]; diff --git a/packages/coding-agent/src/commit/agentic/tools/analyze-file.ts b/packages/coding-agent/src/commit/agentic/tools/analyze-file.ts index e0012faa1..a890465e6 100644 --- a/packages/coding-agent/src/commit/agentic/tools/analyze-file.ts +++ b/packages/coding-agent/src/commit/agentic/tools/analyze-file.ts @@ -1,16 +1,16 @@ -import analyzeFilePrompt from "@oh-my-pi/pi-coding-agent/commit/agentic/prompts/analyze-file.md" with { type: "text" }; -import type { CommitAgentState } from "@oh-my-pi/pi-coding-agent/commit/agentic/state"; -import { getFilePriority } from "@oh-my-pi/pi-coding-agent/commit/agentic/tools/git-file-diff"; -import type { NumstatEntry } from "@oh-my-pi/pi-coding-agent/commit/types"; -import type { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import type { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import type { CustomTool, CustomToolContext } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import type { AuthStorage } from "@oh-my-pi/pi-coding-agent/session/auth-storage"; -import { TaskTool } from "@oh-my-pi/pi-coding-agent/task"; -import type { TaskParams } from "@oh-my-pi/pi-coding-agent/task/types"; -import type { ToolSession } from "@oh-my-pi/pi-coding-agent/tools"; import { Type } from "@sinclair/typebox"; +import analyzeFilePrompt from "../../../commit/agentic/prompts/analyze-file.md" with { type: "text" }; +import type { CommitAgentState } from "../../../commit/agentic/state"; +import type { NumstatEntry } from "../../../commit/types"; +import type { ModelRegistry } from "../../../config/model-registry"; +import { renderPromptTemplate } from "../../../config/prompt-templates"; +import type { SettingsManager } from "../../../config/settings-manager"; +import type { CustomTool, CustomToolContext } from "../../../extensibility/custom-tools/types"; +import type { AuthStorage } from "../../../session/auth-storage"; +import { TaskTool } from "../../../task"; +import type { TaskParams } from "../../../task/types"; +import type { ToolSession } from "../../../tools"; +import { getFilePriority } from "./git-file-diff"; const analyzeFileSchema = Type.Object({ files: Type.Array(Type.String({ description: "File path" }), { minItems: 1 }), diff --git a/packages/coding-agent/src/commit/agentic/tools/git-file-diff.ts b/packages/coding-agent/src/commit/agentic/tools/git-file-diff.ts index 01bbc0347..814a0d9a9 100644 --- a/packages/coding-agent/src/commit/agentic/tools/git-file-diff.ts +++ b/packages/coding-agent/src/commit/agentic/tools/git-file-diff.ts @@ -1,7 +1,7 @@ -import type { CommitAgentState } from "@oh-my-pi/pi-coding-agent/commit/agentic/state"; -import type { ControlledGit } from "@oh-my-pi/pi-coding-agent/commit/git"; -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; import { Type } from "@sinclair/typebox"; +import type { CommitAgentState } from "../../../commit/agentic/state"; +import type { ControlledGit } from "../../../commit/git"; +import type { CustomTool } from "../../../extensibility/custom-tools/types"; const TARGET_TOKENS = 30000; const CHARS_PER_TOKEN = 4; diff --git a/packages/coding-agent/src/commit/agentic/tools/git-hunk.ts b/packages/coding-agent/src/commit/agentic/tools/git-hunk.ts index a8da26843..6c7ad024f 100644 --- a/packages/coding-agent/src/commit/agentic/tools/git-hunk.ts +++ b/packages/coding-agent/src/commit/agentic/tools/git-hunk.ts @@ -1,7 +1,7 @@ -import type { ControlledGit } from "@oh-my-pi/pi-coding-agent/commit/git"; -import type { DiffHunk, FileHunks } from "@oh-my-pi/pi-coding-agent/commit/types"; -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; import { Type } from "@sinclair/typebox"; +import type { ControlledGit } from "../../../commit/git"; +import type { DiffHunk, FileHunks } from "../../../commit/types"; +import type { CustomTool } from "../../../extensibility/custom-tools/types"; const gitHunkSchema = Type.Object({ file: Type.String({ description: "File path" }), diff --git a/packages/coding-agent/src/commit/agentic/tools/git-overview.ts b/packages/coding-agent/src/commit/agentic/tools/git-overview.ts index b8ff5771f..de956c77e 100644 --- a/packages/coding-agent/src/commit/agentic/tools/git-overview.ts +++ b/packages/coding-agent/src/commit/agentic/tools/git-overview.ts @@ -1,8 +1,8 @@ -import type { CommitAgentState, GitOverviewSnapshot } from "@oh-my-pi/pi-coding-agent/commit/agentic/state"; -import { extractScopeCandidates } from "@oh-my-pi/pi-coding-agent/commit/analysis/scope"; -import type { ControlledGit } from "@oh-my-pi/pi-coding-agent/commit/git"; -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; import { Type } from "@sinclair/typebox"; +import type { CommitAgentState, GitOverviewSnapshot } from "../../../commit/agentic/state"; +import { extractScopeCandidates } from "../../../commit/analysis/scope"; +import type { ControlledGit } from "../../../commit/git"; +import type { CustomTool } from "../../../extensibility/custom-tools/types"; const EXCLUDED_LOCK_FILES = new Set([ "Cargo.lock", diff --git a/packages/coding-agent/src/commit/agentic/tools/index.ts b/packages/coding-agent/src/commit/agentic/tools/index.ts index 588f05b6a..67624871b 100644 --- a/packages/coding-agent/src/commit/agentic/tools/index.ts +++ b/packages/coding-agent/src/commit/agentic/tools/index.ts @@ -1,17 +1,17 @@ -import type { CommitAgentState } from "@oh-my-pi/pi-coding-agent/commit/agentic/state"; -import { createAnalyzeFileTool } from "@oh-my-pi/pi-coding-agent/commit/agentic/tools/analyze-file"; -import { createGitFileDiffTool } from "@oh-my-pi/pi-coding-agent/commit/agentic/tools/git-file-diff"; -import { createGitHunkTool } from "@oh-my-pi/pi-coding-agent/commit/agentic/tools/git-hunk"; -import { createGitOverviewTool } from "@oh-my-pi/pi-coding-agent/commit/agentic/tools/git-overview"; -import { createProposeChangelogTool } from "@oh-my-pi/pi-coding-agent/commit/agentic/tools/propose-changelog"; -import { createProposeCommitTool } from "@oh-my-pi/pi-coding-agent/commit/agentic/tools/propose-commit"; -import { createRecentCommitsTool } from "@oh-my-pi/pi-coding-agent/commit/agentic/tools/recent-commits"; -import { createSplitCommitTool } from "@oh-my-pi/pi-coding-agent/commit/agentic/tools/split-commit"; -import type { ControlledGit } from "@oh-my-pi/pi-coding-agent/commit/git"; -import type { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry"; -import type { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import type { AuthStorage } from "@oh-my-pi/pi-coding-agent/session/auth-storage"; +import type { CommitAgentState } from "../../../commit/agentic/state"; +import type { ControlledGit } from "../../../commit/git"; +import type { ModelRegistry } from "../../../config/model-registry"; +import type { SettingsManager } from "../../../config/settings-manager"; +import type { CustomTool } from "../../../extensibility/custom-tools/types"; +import type { AuthStorage } from "../../../session/auth-storage"; +import { createAnalyzeFileTool } from "./analyze-file"; +import { createGitFileDiffTool } from "./git-file-diff"; +import { createGitHunkTool } from "./git-hunk"; +import { createGitOverviewTool } from "./git-overview"; +import { createProposeChangelogTool } from "./propose-changelog"; +import { createProposeCommitTool } from "./propose-commit"; +import { createRecentCommitsTool } from "./recent-commits"; +import { createSplitCommitTool } from "./split-commit"; export interface CommitToolOptions { cwd: string; diff --git a/packages/coding-agent/src/commit/agentic/tools/propose-changelog.ts b/packages/coding-agent/src/commit/agentic/tools/propose-changelog.ts index 5c45ce4fb..bd07c974c 100644 --- a/packages/coding-agent/src/commit/agentic/tools/propose-changelog.ts +++ b/packages/coding-agent/src/commit/agentic/tools/propose-changelog.ts @@ -1,7 +1,7 @@ -import type { CommitAgentState } from "@oh-my-pi/pi-coding-agent/commit/agentic/state"; -import type { ChangelogCategory } from "@oh-my-pi/pi-coding-agent/commit/types"; -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; import { Type } from "@sinclair/typebox"; +import type { CommitAgentState } from "../../../commit/agentic/state"; +import type { ChangelogCategory } from "../../../commit/types"; +import type { CustomTool } from "../../../extensibility/custom-tools/types"; const changelogEntrySchema = Type.Object({ path: Type.String(), diff --git a/packages/coding-agent/src/commit/agentic/tools/propose-commit.ts b/packages/coding-agent/src/commit/agentic/tools/propose-commit.ts index 136e7c05d..71447c7b1 100644 --- a/packages/coding-agent/src/commit/agentic/tools/propose-commit.ts +++ b/packages/coding-agent/src/commit/agentic/tools/propose-commit.ts @@ -1,4 +1,5 @@ -import type { CommitAgentState } from "@oh-my-pi/pi-coding-agent/commit/agentic/state"; +import { Type } from "@sinclair/typebox"; +import type { CommitAgentState } from "../../../commit/agentic/state"; import { capDetails, MAX_DETAIL_ITEMS, @@ -6,12 +7,11 @@ import { SUMMARY_MAX_CHARS, validateSummaryRules, validateTypeConsistency, -} from "@oh-my-pi/pi-coding-agent/commit/agentic/validation"; -import { validateAnalysis } from "@oh-my-pi/pi-coding-agent/commit/analysis/validation"; -import type { ControlledGit } from "@oh-my-pi/pi-coding-agent/commit/git"; -import type { CommitType, ConventionalAnalysis, ConventionalDetail } from "@oh-my-pi/pi-coding-agent/commit/types"; -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import { Type } from "@sinclair/typebox"; +} from "../../../commit/agentic/validation"; +import { validateAnalysis } from "../../../commit/analysis/validation"; +import type { ControlledGit } from "../../../commit/git"; +import type { CommitType, ConventionalAnalysis, ConventionalDetail } from "../../../commit/types"; +import type { CustomTool } from "../../../extensibility/custom-tools/types"; const commitTypeSchema = Type.Union([ Type.Literal("feat"), diff --git a/packages/coding-agent/src/commit/agentic/tools/recent-commits.ts b/packages/coding-agent/src/commit/agentic/tools/recent-commits.ts index 03ce0efa3..025f2d4a8 100644 --- a/packages/coding-agent/src/commit/agentic/tools/recent-commits.ts +++ b/packages/coding-agent/src/commit/agentic/tools/recent-commits.ts @@ -1,6 +1,6 @@ -import type { ControlledGit } from "@oh-my-pi/pi-coding-agent/commit/git"; -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; import { Type } from "@sinclair/typebox"; +import type { ControlledGit } from "../../../commit/git"; +import type { CustomTool } from "../../../extensibility/custom-tools/types"; const recentCommitsSchema = Type.Object({ count: Type.Optional(Type.Number({ description: "Number of commits to fetch", minimum: 1, maximum: 50 })), diff --git a/packages/coding-agent/src/commit/agentic/tools/split-commit.ts b/packages/coding-agent/src/commit/agentic/tools/split-commit.ts index 514a681f6..f5d7ef274 100644 --- a/packages/coding-agent/src/commit/agentic/tools/split-commit.ts +++ b/packages/coding-agent/src/commit/agentic/tools/split-commit.ts @@ -1,9 +1,6 @@ -import type { - CommitAgentState, - SplitCommitGroup, - SplitCommitPlan, -} from "@oh-my-pi/pi-coding-agent/commit/agentic/state"; -import { computeDependencyOrder } from "@oh-my-pi/pi-coding-agent/commit/agentic/topo-sort"; +import { Type } from "@sinclair/typebox"; +import type { CommitAgentState, SplitCommitGroup, SplitCommitPlan } from "../../../commit/agentic/state"; +import { computeDependencyOrder } from "../../../commit/agentic/topo-sort"; import { capDetails, MAX_DETAIL_ITEMS, @@ -11,12 +8,11 @@ import { SUMMARY_MAX_CHARS, validateSummaryRules, validateTypeConsistency, -} from "@oh-my-pi/pi-coding-agent/commit/agentic/validation"; -import { validateScope } from "@oh-my-pi/pi-coding-agent/commit/analysis/validation"; -import type { ControlledGit } from "@oh-my-pi/pi-coding-agent/commit/git"; -import type { ConventionalDetail } from "@oh-my-pi/pi-coding-agent/commit/types"; -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import { Type } from "@sinclair/typebox"; +} from "../../../commit/agentic/validation"; +import { validateScope } from "../../../commit/analysis/validation"; +import type { ControlledGit } from "../../../commit/git"; +import type { ConventionalDetail } from "../../../commit/types"; +import type { CustomTool } from "../../../extensibility/custom-tools/types"; const commitTypeSchema = Type.Union([ Type.Literal("feat"), diff --git a/packages/coding-agent/src/commit/agentic/topo-sort.ts b/packages/coding-agent/src/commit/agentic/topo-sort.ts index 2d6c59edc..b0eb549c3 100644 --- a/packages/coding-agent/src/commit/agentic/topo-sort.ts +++ b/packages/coding-agent/src/commit/agentic/topo-sort.ts @@ -1,4 +1,4 @@ -import type { SplitCommitGroup } from "@oh-my-pi/pi-coding-agent/commit/agentic/state"; +import type { SplitCommitGroup } from "./state"; export function computeDependencyOrder(groups: SplitCommitGroup[]): number[] | { error: string } { const total = groups.length; diff --git a/packages/coding-agent/src/commit/agentic/trivial.ts b/packages/coding-agent/src/commit/agentic/trivial.ts index e043c2f77..5e3d3303a 100644 --- a/packages/coding-agent/src/commit/agentic/trivial.ts +++ b/packages/coding-agent/src/commit/agentic/trivial.ts @@ -1,4 +1,4 @@ -import type { CommitType } from "@oh-my-pi/pi-coding-agent/commit/types"; +import type { CommitType } from "../../commit/types"; export interface TrivialChangeResult { isTrivial: true; diff --git a/packages/coding-agent/src/commit/agentic/validation.ts b/packages/coding-agent/src/commit/agentic/validation.ts index d2284bb8b..77b668ca1 100644 --- a/packages/coding-agent/src/commit/agentic/validation.ts +++ b/packages/coding-agent/src/commit/agentic/validation.ts @@ -1,6 +1,6 @@ -import { stripTypePrefix } from "@oh-my-pi/pi-coding-agent/commit/analysis/summary"; -import { validateSummary } from "@oh-my-pi/pi-coding-agent/commit/analysis/validation"; -import type { CommitType, ConventionalDetail } from "@oh-my-pi/pi-coding-agent/commit/types"; +import { stripTypePrefix } from "../../commit/analysis/summary"; +import { validateSummary } from "../../commit/analysis/validation"; +import type { CommitType, ConventionalDetail } from "../../commit/types"; export const SUMMARY_MAX_CHARS = 72; export const MAX_DETAIL_ITEMS = 6; diff --git a/packages/coding-agent/src/commit/analysis/conventional.ts b/packages/coding-agent/src/commit/analysis/conventional.ts index fa2b4b86e..346541232 100644 --- a/packages/coding-agent/src/commit/analysis/conventional.ts +++ b/packages/coding-agent/src/commit/analysis/conventional.ts @@ -1,14 +1,10 @@ import type { Api, AssistantMessage, Model, ToolCall } from "@oh-my-pi/pi-ai"; import { completeSimple, validateToolCall } from "@oh-my-pi/pi-ai"; -import analysisSystemPrompt from "@oh-my-pi/pi-coding-agent/commit/prompts/analysis-system.md" with { type: "text" }; -import analysisUserPrompt from "@oh-my-pi/pi-coding-agent/commit/prompts/analysis-user.md" with { type: "text" }; -import type { - ChangelogCategory, - ConventionalAnalysis, - ConventionalDetail, -} from "@oh-my-pi/pi-coding-agent/commit/types"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; import { Type } from "@sinclair/typebox"; +import analysisSystemPrompt from "../../commit/prompts/analysis-system.md" with { type: "text" }; +import analysisUserPrompt from "../../commit/prompts/analysis-user.md" with { type: "text" }; +import type { ChangelogCategory, ConventionalAnalysis, ConventionalDetail } from "../../commit/types"; +import { renderPromptTemplate } from "../../config/prompt-templates"; const ConventionalAnalysisTool = { name: "create_conventional_analysis", diff --git a/packages/coding-agent/src/commit/analysis/index.ts b/packages/coding-agent/src/commit/analysis/index.ts index 323a63d8e..1eca1491b 100644 --- a/packages/coding-agent/src/commit/analysis/index.ts +++ b/packages/coding-agent/src/commit/analysis/index.ts @@ -1,4 +1,4 @@ -export { generateConventionalAnalysis } from "@oh-my-pi/pi-coding-agent/commit/analysis/conventional"; -export { extractScopeCandidates } from "@oh-my-pi/pi-coding-agent/commit/analysis/scope"; -export { generateSummary, stripTypePrefix } from "@oh-my-pi/pi-coding-agent/commit/analysis/summary"; -export { validateAnalysis, validateScope, validateSummary } from "@oh-my-pi/pi-coding-agent/commit/analysis/validation"; +export { generateConventionalAnalysis } from "./conventional"; +export { extractScopeCandidates } from "./scope"; +export { generateSummary, stripTypePrefix } from "./summary"; +export { validateAnalysis, validateScope, validateSummary } from "./validation"; diff --git a/packages/coding-agent/src/commit/analysis/scope.ts b/packages/coding-agent/src/commit/analysis/scope.ts index 6d2fe1920..ce61c38b3 100644 --- a/packages/coding-agent/src/commit/analysis/scope.ts +++ b/packages/coding-agent/src/commit/analysis/scope.ts @@ -1,5 +1,5 @@ -import type { NumstatEntry } from "@oh-my-pi/pi-coding-agent/commit/types"; -import { isExcludedFile } from "@oh-my-pi/pi-coding-agent/commit/utils/exclusions"; +import type { NumstatEntry } from "../../commit/types"; +import { isExcludedFile } from "../../commit/utils/exclusions"; interface ScopeCandidate { path: string; diff --git a/packages/coding-agent/src/commit/analysis/summary.ts b/packages/coding-agent/src/commit/analysis/summary.ts index f0a0f8c18..f520a961f 100644 --- a/packages/coding-agent/src/commit/analysis/summary.ts +++ b/packages/coding-agent/src/commit/analysis/summary.ts @@ -1,10 +1,10 @@ import type { Api, AssistantMessage, Model, ToolCall } from "@oh-my-pi/pi-ai"; import { completeSimple, validateToolCall } from "@oh-my-pi/pi-ai"; -import summarySystemPrompt from "@oh-my-pi/pi-coding-agent/commit/prompts/summary-system.md" with { type: "text" }; -import summaryUserPrompt from "@oh-my-pi/pi-coding-agent/commit/prompts/summary-user.md" with { type: "text" }; -import type { CommitSummary } from "@oh-my-pi/pi-coding-agent/commit/types"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; import { Type } from "@sinclair/typebox"; +import summarySystemPrompt from "../../commit/prompts/summary-system.md" with { type: "text" }; +import summaryUserPrompt from "../../commit/prompts/summary-user.md" with { type: "text" }; +import type { CommitSummary } from "../../commit/types"; +import { renderPromptTemplate } from "../../config/prompt-templates"; const SummaryTool = { name: "create_commit_summary", diff --git a/packages/coding-agent/src/commit/analysis/validation.ts b/packages/coding-agent/src/commit/analysis/validation.ts index c88a9f12b..d2e73ea28 100644 --- a/packages/coding-agent/src/commit/analysis/validation.ts +++ b/packages/coding-agent/src/commit/analysis/validation.ts @@ -1,4 +1,4 @@ -import type { ConventionalAnalysis } from "@oh-my-pi/pi-coding-agent/commit/types"; +import type { ConventionalAnalysis } from "../../commit/types"; export interface ValidationResult { valid: boolean; diff --git a/packages/coding-agent/src/commit/changelog/detect.ts b/packages/coding-agent/src/commit/changelog/detect.ts index e045662b4..e7153e7d7 100644 --- a/packages/coding-agent/src/commit/changelog/detect.ts +++ b/packages/coding-agent/src/commit/changelog/detect.ts @@ -1,5 +1,5 @@ import { dirname, resolve } from "node:path"; -import type { ChangelogBoundary } from "@oh-my-pi/pi-coding-agent/commit/types"; +import type { ChangelogBoundary } from "../../commit/types"; const CHANGELOG_NAME = "CHANGELOG.md"; diff --git a/packages/coding-agent/src/commit/changelog/generate.ts b/packages/coding-agent/src/commit/changelog/generate.ts index 0daa949ec..1cc1e55ad 100644 --- a/packages/coding-agent/src/commit/changelog/generate.ts +++ b/packages/coding-agent/src/commit/changelog/generate.ts @@ -1,10 +1,10 @@ import type { Api, AssistantMessage, Model, ToolCall } from "@oh-my-pi/pi-ai"; import { completeSimple, validateToolCall } from "@oh-my-pi/pi-ai"; -import changelogSystemPrompt from "@oh-my-pi/pi-coding-agent/commit/prompts/changelog-system.md" with { type: "text" }; -import changelogUserPrompt from "@oh-my-pi/pi-coding-agent/commit/prompts/changelog-user.md" with { type: "text" }; -import type { ChangelogGenerationResult } from "@oh-my-pi/pi-coding-agent/commit/types"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; import { Type } from "@sinclair/typebox"; +import changelogSystemPrompt from "../../commit/prompts/changelog-system.md" with { type: "text" }; +import changelogUserPrompt from "../../commit/prompts/changelog-user.md" with { type: "text" }; +import type { ChangelogGenerationResult } from "../../commit/types"; +import { renderPromptTemplate } from "../../config/prompt-templates"; const ChangelogTool = { name: "create_changelog_entries", diff --git a/packages/coding-agent/src/commit/changelog/index.ts b/packages/coding-agent/src/commit/changelog/index.ts index a5cafd65b..f414db787 100644 --- a/packages/coding-agent/src/commit/changelog/index.ts +++ b/packages/coding-agent/src/commit/changelog/index.ts @@ -1,10 +1,10 @@ import { relative, resolve } from "node:path"; import type { Api, Model } from "@oh-my-pi/pi-ai"; -import { detectChangelogBoundaries } from "@oh-my-pi/pi-coding-agent/commit/changelog/detect"; -import { generateChangelogEntries } from "@oh-my-pi/pi-coding-agent/commit/changelog/generate"; -import { parseUnreleasedSection } from "@oh-my-pi/pi-coding-agent/commit/changelog/parse"; -import type { ControlledGit } from "@oh-my-pi/pi-coding-agent/commit/git"; import { logger } from "@oh-my-pi/pi-utils"; +import type { ControlledGit } from "../../commit/git"; +import { detectChangelogBoundaries } from "./detect"; +import { generateChangelogEntries } from "./generate"; +import { parseUnreleasedSection } from "./parse"; const CHANGELOG_SECTIONS = ["Breaking Changes", "Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"]; diff --git a/packages/coding-agent/src/commit/changelog/parse.ts b/packages/coding-agent/src/commit/changelog/parse.ts index c11ad7777..b0a981f6a 100644 --- a/packages/coding-agent/src/commit/changelog/parse.ts +++ b/packages/coding-agent/src/commit/changelog/parse.ts @@ -1,4 +1,4 @@ -import type { UnreleasedSection } from "@oh-my-pi/pi-coding-agent/commit/types"; +import type { UnreleasedSection } from "../../commit/types"; const UNRELEASED_PATTERN = /^##\s+\[?Unreleased\]?/i; const SECTION_PATTERN = /^###\s+(.*)$/; diff --git a/packages/coding-agent/src/commit/cli.ts b/packages/coding-agent/src/commit/cli.ts index 9cfd0b6bb..5fa6af9ec 100644 --- a/packages/coding-agent/src/commit/cli.ts +++ b/packages/coding-agent/src/commit/cli.ts @@ -1,5 +1,5 @@ -import type { CommitCommandArgs } from "@oh-my-pi/pi-coding-agent/commit/types"; import chalk from "chalk"; +import type { CommitCommandArgs } from "./types"; const FLAG_ALIASES = new Map([ ["-c", "--context"], diff --git a/packages/coding-agent/src/commit/git/diff.ts b/packages/coding-agent/src/commit/git/diff.ts index 9d867a6a8..221b36a03 100644 --- a/packages/coding-agent/src/commit/git/diff.ts +++ b/packages/coding-agent/src/commit/git/diff.ts @@ -1,4 +1,4 @@ -import type { DiffHunk, FileDiff, FileHunks, NumstatEntry } from "@oh-my-pi/pi-coding-agent/commit/types"; +import type { DiffHunk, FileDiff, FileHunks, NumstatEntry } from "../../commit/types"; export function parseNumstat(output: string): NumstatEntry[] { const entries: NumstatEntry[] = []; diff --git a/packages/coding-agent/src/commit/git/index.ts b/packages/coding-agent/src/commit/git/index.ts index 1545afa65..f8c9cd9b5 100644 --- a/packages/coding-agent/src/commit/git/index.ts +++ b/packages/coding-agent/src/commit/git/index.ts @@ -2,16 +2,11 @@ import { randomUUID } from "node:crypto"; import { rm } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { - parseDiffHunks, - parseFileDiffs, - parseFileHunks, - parseNumstat, -} from "@oh-my-pi/pi-coding-agent/commit/git/diff"; -import { GitError } from "@oh-my-pi/pi-coding-agent/commit/git/errors"; -import { commit, push, resetStaging, runGitCommand, stageFiles } from "@oh-my-pi/pi-coding-agent/commit/git/operations"; -import type { FileDiff, FileHunks, NumstatEntry } from "@oh-my-pi/pi-coding-agent/commit/types"; import { logger } from "@oh-my-pi/pi-utils"; +import type { FileDiff, FileHunks, NumstatEntry } from "../../commit/types"; +import { parseDiffHunks, parseFileDiffs, parseFileHunks, parseNumstat } from "./diff"; +import { GitError } from "./errors"; +import { commit, push, resetStaging, runGitCommand, stageFiles } from "./operations"; export type HunkSelection = { path: string; diff --git a/packages/coding-agent/src/commit/index.ts b/packages/coding-agent/src/commit/index.ts index 437dc94c2..1bdf6a5b8 100644 --- a/packages/coding-agent/src/commit/index.ts +++ b/packages/coding-agent/src/commit/index.ts @@ -2,4 +2,4 @@ * Entry points for the omp commit command. */ -export { runCommitCommand } from "@oh-my-pi/pi-coding-agent/commit/pipeline"; +export { runCommitCommand } from "./pipeline"; diff --git a/packages/coding-agent/src/commit/map-reduce/index.ts b/packages/coding-agent/src/commit/map-reduce/index.ts index 54ebda81d..ba997555c 100644 --- a/packages/coding-agent/src/commit/map-reduce/index.ts +++ b/packages/coding-agent/src/commit/map-reduce/index.ts @@ -1,10 +1,10 @@ import type { Api, Model } from "@oh-my-pi/pi-ai"; -import { parseFileDiffs } from "@oh-my-pi/pi-coding-agent/commit/git/diff"; -import { runMapPhase } from "@oh-my-pi/pi-coding-agent/commit/map-reduce/map-phase"; -import { runReducePhase } from "@oh-my-pi/pi-coding-agent/commit/map-reduce/reduce-phase"; -import { estimateTokens } from "@oh-my-pi/pi-coding-agent/commit/map-reduce/utils"; -import type { ConventionalAnalysis } from "@oh-my-pi/pi-coding-agent/commit/types"; -import { isExcludedFile } from "@oh-my-pi/pi-coding-agent/commit/utils/exclusions"; +import { parseFileDiffs } from "../../commit/git/diff"; +import type { ConventionalAnalysis } from "../../commit/types"; +import { isExcludedFile } from "../../commit/utils/exclusions"; +import { runMapPhase } from "./map-phase"; +import { runReducePhase } from "./reduce-phase"; +import { estimateTokens } from "./utils"; const MIN_FILES_FOR_MAP_REDUCE = 4; const MAX_FILE_TOKENS = 50_000; diff --git a/packages/coding-agent/src/commit/map-reduce/map-phase.ts b/packages/coding-agent/src/commit/map-reduce/map-phase.ts index 07e4b97c9..e13500e65 100644 --- a/packages/coding-agent/src/commit/map-reduce/map-phase.ts +++ b/packages/coding-agent/src/commit/map-reduce/map-phase.ts @@ -1,15 +1,11 @@ import type { Api, AssistantMessage, Model } from "@oh-my-pi/pi-ai"; import { completeSimple } from "@oh-my-pi/pi-ai"; -import { truncateToTokenLimit } from "@oh-my-pi/pi-coding-agent/commit/map-reduce/utils"; -import fileObserverSystemPrompt from "@oh-my-pi/pi-coding-agent/commit/prompts/file-observer-system.md" with { - type: "text", -}; -import fileObserverUserPrompt from "@oh-my-pi/pi-coding-agent/commit/prompts/file-observer-user.md" with { - type: "text", -}; -import type { FileDiff, FileObservation } from "@oh-my-pi/pi-coding-agent/commit/types"; -import { isExcludedFile } from "@oh-my-pi/pi-coding-agent/commit/utils/exclusions"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; +import fileObserverSystemPrompt from "../../commit/prompts/file-observer-system.md" with { type: "text" }; +import fileObserverUserPrompt from "../../commit/prompts/file-observer-user.md" with { type: "text" }; +import type { FileDiff, FileObservation } from "../../commit/types"; +import { isExcludedFile } from "../../commit/utils/exclusions"; +import { renderPromptTemplate } from "../../config/prompt-templates"; +import { truncateToTokenLimit } from "./utils"; const MAX_FILE_TOKENS = 50_000; const MAX_CONTEXT_FILES = 20; diff --git a/packages/coding-agent/src/commit/map-reduce/reduce-phase.ts b/packages/coding-agent/src/commit/map-reduce/reduce-phase.ts index b8aff9ff1..801e17e03 100644 --- a/packages/coding-agent/src/commit/map-reduce/reduce-phase.ts +++ b/packages/coding-agent/src/commit/map-reduce/reduce-phase.ts @@ -1,10 +1,10 @@ import type { Api, AssistantMessage, Model, ToolCall } from "@oh-my-pi/pi-ai"; import { completeSimple, validateToolCall } from "@oh-my-pi/pi-ai"; -import reduceSystemPrompt from "@oh-my-pi/pi-coding-agent/commit/prompts/reduce-system.md" with { type: "text" }; -import reduceUserPrompt from "@oh-my-pi/pi-coding-agent/commit/prompts/reduce-user.md" with { type: "text" }; -import type { ChangelogCategory, ConventionalAnalysis, FileObservation } from "@oh-my-pi/pi-coding-agent/commit/types"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; import { Type } from "@sinclair/typebox"; +import reduceSystemPrompt from "../../commit/prompts/reduce-system.md" with { type: "text" }; +import reduceUserPrompt from "../../commit/prompts/reduce-user.md" with { type: "text" }; +import type { ChangelogCategory, ConventionalAnalysis, FileObservation } from "../../commit/types"; +import { renderPromptTemplate } from "../../config/prompt-templates"; const ReduceTool = { name: "create_conventional_analysis", diff --git a/packages/coding-agent/src/commit/message.ts b/packages/coding-agent/src/commit/message.ts index ca0fc678b..5b9af8708 100644 --- a/packages/coding-agent/src/commit/message.ts +++ b/packages/coding-agent/src/commit/message.ts @@ -1,4 +1,4 @@ -import type { ConventionalAnalysis } from "@oh-my-pi/pi-coding-agent/commit/types"; +import type { ConventionalAnalysis } from "./types"; export function formatCommitMessage(analysis: ConventionalAnalysis, summary: string): string { const scopePart = analysis.scope ? `(${analysis.scope})` : ""; diff --git a/packages/coding-agent/src/commit/model-selection.ts b/packages/coding-agent/src/commit/model-selection.ts index 478651259..536e66982 100644 --- a/packages/coding-agent/src/commit/model-selection.ts +++ b/packages/coding-agent/src/commit/model-selection.ts @@ -1,10 +1,6 @@ import type { Api, Model } from "@oh-my-pi/pi-ai"; -import { - parseModelPattern, - parseModelString, - SMOL_MODEL_PRIORITY, -} from "@oh-my-pi/pi-coding-agent/config/model-resolver"; -import type { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; +import { parseModelPattern, parseModelString, SMOL_MODEL_PRIORITY } from "../config/model-resolver"; +import type { SettingsManager } from "../config/settings-manager"; export async function resolvePrimaryModel( override: string | undefined, diff --git a/packages/coding-agent/src/commit/pipeline.ts b/packages/coding-agent/src/commit/pipeline.ts index c971cc58e..7ac1b5486 100644 --- a/packages/coding-agent/src/commit/pipeline.ts +++ b/packages/coding-agent/src/commit/pipeline.ts @@ -1,28 +1,26 @@ import { relative } from "node:path"; import type { Api, Model } from "@oh-my-pi/pi-ai"; -import { runAgenticCommit } from "@oh-my-pi/pi-coding-agent/commit/agentic"; +import { logger } from "@oh-my-pi/pi-utils"; +import { renderPromptTemplate } from "../config/prompt-templates"; +import { SettingsManager } from "../config/settings-manager"; +import { discoverAuthStorage, discoverModels } from "../sdk"; +import { loadProjectContextFiles } from "../system-prompt"; +import { runAgenticCommit } from "./agentic"; import { extractScopeCandidates, generateConventionalAnalysis, generateSummary, validateAnalysis, validateSummary, -} from "@oh-my-pi/pi-coding-agent/commit/analysis"; -import { runChangelogFlow } from "@oh-my-pi/pi-coding-agent/commit/changelog"; -import { ControlledGit } from "@oh-my-pi/pi-coding-agent/commit/git"; -import { runMapReduceAnalysis, shouldUseMapReduce } from "@oh-my-pi/pi-coding-agent/commit/map-reduce"; -import { formatCommitMessage } from "@oh-my-pi/pi-coding-agent/commit/message"; -import { resolvePrimaryModel, resolveSmolModel } from "@oh-my-pi/pi-coding-agent/commit/model-selection"; -import summaryRetryPrompt from "@oh-my-pi/pi-coding-agent/commit/prompts/summary-retry.md" with { type: "text" }; -import typesDescriptionPrompt from "@oh-my-pi/pi-coding-agent/commit/prompts/types-description.md" with { - type: "text", -}; -import type { CommitCommandArgs, ConventionalAnalysis } from "@oh-my-pi/pi-coding-agent/commit/types"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import { discoverAuthStorage, discoverModels } from "@oh-my-pi/pi-coding-agent/sdk"; -import { loadProjectContextFiles } from "@oh-my-pi/pi-coding-agent/system-prompt"; -import { logger } from "@oh-my-pi/pi-utils"; +} from "./analysis"; +import { runChangelogFlow } from "./changelog"; +import { ControlledGit } from "./git"; +import { runMapReduceAnalysis, shouldUseMapReduce } from "./map-reduce"; +import { formatCommitMessage } from "./message"; +import { resolvePrimaryModel, resolveSmolModel } from "./model-selection"; +import summaryRetryPrompt from "./prompts/summary-retry.md" with { type: "text" }; +import typesDescriptionPrompt from "./prompts/types-description.md" with { type: "text" }; +import type { CommitCommandArgs, ConventionalAnalysis } from "./types"; const SUMMARY_MAX_CHARS = 72; const RECENT_COMMITS_COUNT = 8; diff --git a/packages/coding-agent/src/config/keybindings.ts b/packages/coding-agent/src/config/keybindings.ts index 6bee18d0b..99c5de4ea 100644 --- a/packages/coding-agent/src/config/keybindings.ts +++ b/packages/coding-agent/src/config/keybindings.ts @@ -1,6 +1,5 @@ import { existsSync, readFileSync } from "node:fs"; import { join } from "node:path"; -import { getAgentDir } from "@oh-my-pi/pi-coding-agent/config"; import { DEFAULT_EDITOR_KEYBINDINGS, type EditorAction, @@ -11,6 +10,7 @@ import { setEditorKeybindings, } from "@oh-my-pi/pi-tui"; import { logger } from "@oh-my-pi/pi-utils"; +import { getAgentDir } from "../config"; /** * Application-level actions (coding agent specific). diff --git a/packages/coding-agent/src/config/model-registry.ts b/packages/coding-agent/src/config/model-registry.ts index 5e7c5fadc..b4b19ba77 100644 --- a/packages/coding-agent/src/config/model-registry.ts +++ b/packages/coding-agent/src/config/model-registry.ts @@ -12,11 +12,11 @@ import { type Model, normalizeDomain, } from "@oh-my-pi/pi-ai"; -import type { AuthStorage } from "@oh-my-pi/pi-coding-agent/session/auth-storage"; import { logger } from "@oh-my-pi/pi-utils"; import { type Static, Type } from "@sinclair/typebox"; import AjvModule from "ajv"; import { YAML } from "bun"; +import type { AuthStorage } from "../session/auth-storage"; const Ajv = (AjvModule as any).default || AjvModule; diff --git a/packages/coding-agent/src/config/model-resolver.ts b/packages/coding-agent/src/config/model-resolver.ts index 545a956a9..e12fbd2a4 100644 --- a/packages/coding-agent/src/config/model-resolver.ts +++ b/packages/coding-agent/src/config/model-resolver.ts @@ -4,8 +4,8 @@ import type { ThinkingLevel } from "@oh-my-pi/pi-agent-core"; import { type Api, type KnownProvider, type Model, modelsAreEqual } from "@oh-my-pi/pi-ai"; -import { isValidThinkingLevel } from "@oh-my-pi/pi-coding-agent/cli/args"; import chalk from "chalk"; +import { isValidThinkingLevel } from "../cli/args"; import type { ModelRegistry } from "./model-registry"; /** Default model IDs for each known provider */ diff --git a/packages/coding-agent/src/config/prompt-templates.ts b/packages/coding-agent/src/config/prompt-templates.ts index 220aa7151..1e448acf0 100644 --- a/packages/coding-agent/src/config/prompt-templates.ts +++ b/packages/coding-agent/src/config/prompt-templates.ts @@ -1,8 +1,8 @@ import { join, resolve } from "node:path"; -import { CONFIG_DIR_NAME, getPromptsDir } from "@oh-my-pi/pi-coding-agent/config"; -import { parseFrontmatter } from "@oh-my-pi/pi-coding-agent/utils/frontmatter"; import { logger } from "@oh-my-pi/pi-utils"; import Handlebars from "handlebars"; +import { CONFIG_DIR_NAME, getPromptsDir } from "../config"; +import { parseFrontmatter } from "../utils/frontmatter"; /** * Represents a prompt template loaded from a markdown file diff --git a/packages/coding-agent/src/config/settings-manager.ts b/packages/coding-agent/src/config/settings-manager.ts index e9b8a7851..edb796d12 100644 --- a/packages/coding-agent/src/config/settings-manager.ts +++ b/packages/coding-agent/src/config/settings-manager.ts @@ -1,14 +1,14 @@ import { existsSync, readFileSync } from "node:fs"; import { rename } from "node:fs/promises"; import { join } from "node:path"; -import { type Settings as SettingsItem, settingsCapability } from "@oh-my-pi/pi-coding-agent/capability/settings"; -import { getAgentDbPath, getAgentDir } from "@oh-my-pi/pi-coding-agent/config"; -import { withFileLock } from "@oh-my-pi/pi-coding-agent/config/file-lock"; -import { loadCapability } from "@oh-my-pi/pi-coding-agent/discovery"; -import type { SymbolPreset } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import { AgentStorage } from "@oh-my-pi/pi-coding-agent/session/agent-storage"; import { logger } from "@oh-my-pi/pi-utils"; import { YAML } from "bun"; +import { type Settings as SettingsItem, settingsCapability } from "../capability/settings"; +import { getAgentDbPath, getAgentDir } from "../config"; +import { loadCapability } from "../discovery"; +import type { SymbolPreset } from "../modes/theme/theme"; +import { AgentStorage } from "../session/agent-storage"; +import { withFileLock } from "./file-lock"; export interface CompactionSettings { enabled?: boolean; // default: true diff --git a/packages/coding-agent/src/cursor.ts b/packages/coding-agent/src/cursor.ts index 3fc5f31ba..79261a1b8 100644 --- a/packages/coding-agent/src/cursor.ts +++ b/packages/coding-agent/src/cursor.ts @@ -8,7 +8,7 @@ import type { AgentToolUpdateCallback, } from "@oh-my-pi/pi-agent-core"; import type { CursorMcpCall, CursorExecHandlers as ICursorExecHandlers, ToolResultMessage } from "@oh-my-pi/pi-ai"; -import { resolveToCwd } from "@oh-my-pi/pi-coding-agent/tools/path-utils"; +import { resolveToCwd } from "./tools/path-utils"; interface CursorExecBridgeOptions { cwd: string; diff --git a/packages/coding-agent/src/discovery/agents-md.ts b/packages/coding-agent/src/discovery/agents-md.ts index b11568641..982533211 100644 --- a/packages/coding-agent/src/discovery/agents-md.ts +++ b/packages/coding-agent/src/discovery/agents-md.ts @@ -7,10 +7,10 @@ */ import { dirname, join, sep } from "node:path"; -import { registerProvider } from "@oh-my-pi/pi-coding-agent/capability"; -import { type ContextFile, contextFileCapability } from "@oh-my-pi/pi-coding-agent/capability/context-file"; -import { readFile } from "@oh-my-pi/pi-coding-agent/capability/fs"; -import type { LoadContext, LoadResult } from "@oh-my-pi/pi-coding-agent/capability/types"; +import { registerProvider } from "../capability"; +import { type ContextFile, contextFileCapability } from "../capability/context-file"; +import { readFile } from "../capability/fs"; +import type { LoadContext, LoadResult } from "../capability/types"; import { calculateDepth, createSourceMeta } from "./helpers"; const PROVIDER_ID = "agents-md"; diff --git a/packages/coding-agent/src/discovery/builtin.ts b/packages/coding-agent/src/discovery/builtin.ts index 3fe623a05..825c1e432 100644 --- a/packages/coding-agent/src/discovery/builtin.ts +++ b/packages/coding-agent/src/discovery/builtin.ts @@ -5,28 +5,24 @@ * .pi is an alias for backwards compatibility. */ -import { registerProvider } from "@oh-my-pi/pi-coding-agent/capability"; -import { type ContextFile, contextFileCapability } from "@oh-my-pi/pi-coding-agent/capability/context-file"; -import { - type Extension, - type ExtensionManifest, - extensionCapability, -} from "@oh-my-pi/pi-coding-agent/capability/extension"; -import { type ExtensionModule, extensionModuleCapability } from "@oh-my-pi/pi-coding-agent/capability/extension-module"; -import { readDirEntries, readFile } from "@oh-my-pi/pi-coding-agent/capability/fs"; -import { type Hook, hookCapability } from "@oh-my-pi/pi-coding-agent/capability/hook"; -import { type Instruction, instructionCapability } from "@oh-my-pi/pi-coding-agent/capability/instruction"; -import { type MCPServer, mcpCapability } from "@oh-my-pi/pi-coding-agent/capability/mcp"; -import { type Prompt, promptCapability } from "@oh-my-pi/pi-coding-agent/capability/prompt"; -import { type Rule, ruleCapability } from "@oh-my-pi/pi-coding-agent/capability/rule"; -import { type Settings, settingsCapability } from "@oh-my-pi/pi-coding-agent/capability/settings"; -import { type Skill, skillCapability } from "@oh-my-pi/pi-coding-agent/capability/skill"; -import { type SlashCommand, slashCommandCapability } from "@oh-my-pi/pi-coding-agent/capability/slash-command"; -import { type SystemPrompt, systemPromptCapability } from "@oh-my-pi/pi-coding-agent/capability/system-prompt"; -import { type CustomTool, toolCapability } from "@oh-my-pi/pi-coding-agent/capability/tool"; -import type { LoadContext, LoadResult } from "@oh-my-pi/pi-coding-agent/capability/types"; -import { parseFrontmatter } from "@oh-my-pi/pi-coding-agent/utils/frontmatter"; import { dirname, isAbsolute, join, resolve } from "path"; +import { registerProvider } from "../capability"; +import { type ContextFile, contextFileCapability } from "../capability/context-file"; +import { type Extension, type ExtensionManifest, extensionCapability } from "../capability/extension"; +import { type ExtensionModule, extensionModuleCapability } from "../capability/extension-module"; +import { readDirEntries, readFile } from "../capability/fs"; +import { type Hook, hookCapability } from "../capability/hook"; +import { type Instruction, instructionCapability } from "../capability/instruction"; +import { type MCPServer, mcpCapability } from "../capability/mcp"; +import { type Prompt, promptCapability } from "../capability/prompt"; +import { type Rule, ruleCapability } from "../capability/rule"; +import { type Settings, settingsCapability } from "../capability/settings"; +import { type Skill, skillCapability } from "../capability/skill"; +import { type SlashCommand, slashCommandCapability } from "../capability/slash-command"; +import { type SystemPrompt, systemPromptCapability } from "../capability/system-prompt"; +import { type CustomTool, toolCapability } from "../capability/tool"; +import type { LoadContext, LoadResult } from "../capability/types"; +import { parseFrontmatter } from "../utils/frontmatter"; import { createSourceMeta, discoverExtensionModulePaths, diff --git a/packages/coding-agent/src/discovery/claude.ts b/packages/coding-agent/src/discovery/claude.ts index 3cc78cdd7..08b07f73d 100644 --- a/packages/coding-agent/src/discovery/claude.ts +++ b/packages/coding-agent/src/discovery/claude.ts @@ -6,18 +6,18 @@ */ import { join, sep } from "node:path"; -import { registerProvider } from "@oh-my-pi/pi-coding-agent/capability"; -import { type ContextFile, contextFileCapability } from "@oh-my-pi/pi-coding-agent/capability/context-file"; -import { type ExtensionModule, extensionModuleCapability } from "@oh-my-pi/pi-coding-agent/capability/extension-module"; -import { readFile } from "@oh-my-pi/pi-coding-agent/capability/fs"; -import { type Hook, hookCapability } from "@oh-my-pi/pi-coding-agent/capability/hook"; -import { type MCPServer, mcpCapability } from "@oh-my-pi/pi-coding-agent/capability/mcp"; -import { type Settings, settingsCapability } from "@oh-my-pi/pi-coding-agent/capability/settings"; -import { type Skill, skillCapability } from "@oh-my-pi/pi-coding-agent/capability/skill"; -import { type SlashCommand, slashCommandCapability } from "@oh-my-pi/pi-coding-agent/capability/slash-command"; -import { type SystemPrompt, systemPromptCapability } from "@oh-my-pi/pi-coding-agent/capability/system-prompt"; -import { type CustomTool, toolCapability } from "@oh-my-pi/pi-coding-agent/capability/tool"; -import type { LoadContext, LoadResult } from "@oh-my-pi/pi-coding-agent/capability/types"; +import { registerProvider } from "../capability"; +import { type ContextFile, contextFileCapability } from "../capability/context-file"; +import { type ExtensionModule, extensionModuleCapability } from "../capability/extension-module"; +import { readFile } from "../capability/fs"; +import { type Hook, hookCapability } from "../capability/hook"; +import { type MCPServer, mcpCapability } from "../capability/mcp"; +import { type Settings, settingsCapability } from "../capability/settings"; +import { type Skill, skillCapability } from "../capability/skill"; +import { type SlashCommand, slashCommandCapability } from "../capability/slash-command"; +import { type SystemPrompt, systemPromptCapability } from "../capability/system-prompt"; +import { type CustomTool, toolCapability } from "../capability/tool"; +import type { LoadContext, LoadResult } from "../capability/types"; import { calculateDepth, createSourceMeta, diff --git a/packages/coding-agent/src/discovery/cline.ts b/packages/coding-agent/src/discovery/cline.ts index 8b7d3b64d..057128d25 100644 --- a/packages/coding-agent/src/discovery/cline.ts +++ b/packages/coding-agent/src/discovery/cline.ts @@ -6,12 +6,12 @@ */ import { dirname, resolve } from "node:path"; -import { registerProvider } from "@oh-my-pi/pi-coding-agent/capability"; -import { readDirEntries, readFile } from "@oh-my-pi/pi-coding-agent/capability/fs"; -import type { Rule } from "@oh-my-pi/pi-coding-agent/capability/rule"; -import { ruleCapability } from "@oh-my-pi/pi-coding-agent/capability/rule"; -import type { LoadContext, LoadResult } from "@oh-my-pi/pi-coding-agent/capability/types"; -import { parseFrontmatter } from "@oh-my-pi/pi-coding-agent/utils/frontmatter"; +import { registerProvider } from "../capability"; +import { readDirEntries, readFile } from "../capability/fs"; +import type { Rule } from "../capability/rule"; +import { ruleCapability } from "../capability/rule"; +import type { LoadContext, LoadResult } from "../capability/types"; +import { parseFrontmatter } from "../utils/frontmatter"; import { createSourceMeta, loadFilesFromDir } from "./helpers"; const PROVIDER_ID = "cline"; diff --git a/packages/coding-agent/src/discovery/codex.ts b/packages/coding-agent/src/discovery/codex.ts index 823a98cd6..5649179da 100644 --- a/packages/coding-agent/src/discovery/codex.ts +++ b/packages/coding-agent/src/discovery/codex.ts @@ -8,29 +8,29 @@ */ import { join } from "node:path"; -import { registerProvider } from "@oh-my-pi/pi-coding-agent/capability"; -import type { ContextFile } from "@oh-my-pi/pi-coding-agent/capability/context-file"; -import { contextFileCapability } from "@oh-my-pi/pi-coding-agent/capability/context-file"; -import { type ExtensionModule, extensionModuleCapability } from "@oh-my-pi/pi-coding-agent/capability/extension-module"; -import { readFile } from "@oh-my-pi/pi-coding-agent/capability/fs"; -import type { Hook } from "@oh-my-pi/pi-coding-agent/capability/hook"; -import { hookCapability } from "@oh-my-pi/pi-coding-agent/capability/hook"; -import type { MCPServer } from "@oh-my-pi/pi-coding-agent/capability/mcp"; -import { mcpCapability } from "@oh-my-pi/pi-coding-agent/capability/mcp"; -import type { Prompt } from "@oh-my-pi/pi-coding-agent/capability/prompt"; -import { promptCapability } from "@oh-my-pi/pi-coding-agent/capability/prompt"; -import type { Settings } from "@oh-my-pi/pi-coding-agent/capability/settings"; -import { settingsCapability } from "@oh-my-pi/pi-coding-agent/capability/settings"; -import type { Skill } from "@oh-my-pi/pi-coding-agent/capability/skill"; -import { skillCapability } from "@oh-my-pi/pi-coding-agent/capability/skill"; -import type { SlashCommand } from "@oh-my-pi/pi-coding-agent/capability/slash-command"; -import { slashCommandCapability } from "@oh-my-pi/pi-coding-agent/capability/slash-command"; -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/capability/tool"; -import { toolCapability } from "@oh-my-pi/pi-coding-agent/capability/tool"; -import type { LoadContext, LoadResult } from "@oh-my-pi/pi-coding-agent/capability/types"; -import { parseFrontmatter } from "@oh-my-pi/pi-coding-agent/utils/frontmatter"; import { logger } from "@oh-my-pi/pi-utils"; import { parse as parseToml } from "smol-toml"; +import { registerProvider } from "../capability"; +import type { ContextFile } from "../capability/context-file"; +import { contextFileCapability } from "../capability/context-file"; +import { type ExtensionModule, extensionModuleCapability } from "../capability/extension-module"; +import { readFile } from "../capability/fs"; +import type { Hook } from "../capability/hook"; +import { hookCapability } from "../capability/hook"; +import type { MCPServer } from "../capability/mcp"; +import { mcpCapability } from "../capability/mcp"; +import type { Prompt } from "../capability/prompt"; +import { promptCapability } from "../capability/prompt"; +import type { Settings } from "../capability/settings"; +import { settingsCapability } from "../capability/settings"; +import type { Skill } from "../capability/skill"; +import { skillCapability } from "../capability/skill"; +import type { SlashCommand } from "../capability/slash-command"; +import { slashCommandCapability } from "../capability/slash-command"; +import type { CustomTool } from "../capability/tool"; +import { toolCapability } from "../capability/tool"; +import type { LoadContext, LoadResult } from "../capability/types"; +import { parseFrontmatter } from "../utils/frontmatter"; import { createSourceMeta, discoverExtensionModulePaths, diff --git a/packages/coding-agent/src/discovery/cursor.ts b/packages/coding-agent/src/discovery/cursor.ts index a30d46ba9..c87b4688b 100644 --- a/packages/coding-agent/src/discovery/cursor.ts +++ b/packages/coding-agent/src/discovery/cursor.ts @@ -14,15 +14,15 @@ * - settings: From settings.json if present */ -import { registerProvider } from "@oh-my-pi/pi-coding-agent/capability"; -import { readFile } from "@oh-my-pi/pi-coding-agent/capability/fs"; -import { type MCPServer, mcpCapability } from "@oh-my-pi/pi-coding-agent/capability/mcp"; -import type { Rule } from "@oh-my-pi/pi-coding-agent/capability/rule"; -import { ruleCapability } from "@oh-my-pi/pi-coding-agent/capability/rule"; -import type { Settings } from "@oh-my-pi/pi-coding-agent/capability/settings"; -import { settingsCapability } from "@oh-my-pi/pi-coding-agent/capability/settings"; -import type { LoadContext, LoadResult } from "@oh-my-pi/pi-coding-agent/capability/types"; -import { parseFrontmatter } from "@oh-my-pi/pi-coding-agent/utils/frontmatter"; +import { registerProvider } from "../capability"; +import { readFile } from "../capability/fs"; +import { type MCPServer, mcpCapability } from "../capability/mcp"; +import type { Rule } from "../capability/rule"; +import { ruleCapability } from "../capability/rule"; +import type { Settings } from "../capability/settings"; +import { settingsCapability } from "../capability/settings"; +import type { LoadContext, LoadResult } from "../capability/types"; +import { parseFrontmatter } from "../utils/frontmatter"; import { createSourceMeta, expandEnvVarsDeep, diff --git a/packages/coding-agent/src/discovery/gemini.ts b/packages/coding-agent/src/discovery/gemini.ts index d3c4e4c2e..c1f564616 100644 --- a/packages/coding-agent/src/discovery/gemini.ts +++ b/packages/coding-agent/src/discovery/gemini.ts @@ -17,19 +17,15 @@ */ import { join, sep } from "node:path"; -import { registerProvider } from "@oh-my-pi/pi-coding-agent/capability"; -import { type ContextFile, contextFileCapability } from "@oh-my-pi/pi-coding-agent/capability/context-file"; -import { - type Extension, - type ExtensionManifest, - extensionCapability, -} from "@oh-my-pi/pi-coding-agent/capability/extension"; -import { type ExtensionModule, extensionModuleCapability } from "@oh-my-pi/pi-coding-agent/capability/extension-module"; -import { readDirEntries, readFile } from "@oh-my-pi/pi-coding-agent/capability/fs"; -import { type MCPServer, mcpCapability } from "@oh-my-pi/pi-coding-agent/capability/mcp"; -import { type Settings, settingsCapability } from "@oh-my-pi/pi-coding-agent/capability/settings"; -import { type SystemPrompt, systemPromptCapability } from "@oh-my-pi/pi-coding-agent/capability/system-prompt"; -import type { LoadContext, LoadResult } from "@oh-my-pi/pi-coding-agent/capability/types"; +import { registerProvider } from "../capability"; +import { type ContextFile, contextFileCapability } from "../capability/context-file"; +import { type Extension, type ExtensionManifest, extensionCapability } from "../capability/extension"; +import { type ExtensionModule, extensionModuleCapability } from "../capability/extension-module"; +import { readDirEntries, readFile } from "../capability/fs"; +import { type MCPServer, mcpCapability } from "../capability/mcp"; +import { type Settings, settingsCapability } from "../capability/settings"; +import { type SystemPrompt, systemPromptCapability } from "../capability/system-prompt"; +import type { LoadContext, LoadResult } from "../capability/types"; import { calculateDepth, createSourceMeta, diff --git a/packages/coding-agent/src/discovery/github.ts b/packages/coding-agent/src/discovery/github.ts index 8122f89d6..d7003e1ce 100644 --- a/packages/coding-agent/src/discovery/github.ts +++ b/packages/coding-agent/src/discovery/github.ts @@ -13,12 +13,12 @@ */ import { basename, dirname, sep } from "node:path"; -import { registerProvider } from "@oh-my-pi/pi-coding-agent/capability"; -import { type ContextFile, contextFileCapability } from "@oh-my-pi/pi-coding-agent/capability/context-file"; -import { readFile } from "@oh-my-pi/pi-coding-agent/capability/fs"; -import { type Instruction, instructionCapability } from "@oh-my-pi/pi-coding-agent/capability/instruction"; -import type { LoadContext, LoadResult, SourceMeta } from "@oh-my-pi/pi-coding-agent/capability/types"; -import { parseFrontmatter } from "@oh-my-pi/pi-coding-agent/utils/frontmatter"; +import { registerProvider } from "../capability"; +import { type ContextFile, contextFileCapability } from "../capability/context-file"; +import { readFile } from "../capability/fs"; +import { type Instruction, instructionCapability } from "../capability/instruction"; +import type { LoadContext, LoadResult, SourceMeta } from "../capability/types"; +import { parseFrontmatter } from "../utils/frontmatter"; import { calculateDepth, createSourceMeta, getProjectPath, loadFilesFromDir } from "./helpers"; const PROVIDER_ID = "github"; diff --git a/packages/coding-agent/src/discovery/helpers.ts b/packages/coding-agent/src/discovery/helpers.ts index 4acacb793..c14b86ba5 100644 --- a/packages/coding-agent/src/discovery/helpers.ts +++ b/packages/coding-agent/src/discovery/helpers.ts @@ -5,10 +5,10 @@ import { homedir } from "node:os"; import { join, resolve } from "node:path"; import type { ThinkingLevel } from "@oh-my-pi/pi-agent-core"; -import { readDirEntries, readFile } from "@oh-my-pi/pi-coding-agent/capability/fs"; -import type { Skill, SkillFrontmatter } from "@oh-my-pi/pi-coding-agent/capability/skill"; -import type { LoadContext, LoadResult, SourceMeta } from "@oh-my-pi/pi-coding-agent/capability/types"; -import { parseFrontmatter } from "@oh-my-pi/pi-coding-agent/utils/frontmatter"; +import { readDirEntries, readFile } from "../capability/fs"; +import type { Skill, SkillFrontmatter } from "../capability/skill"; +import type { LoadContext, LoadResult, SourceMeta } from "../capability/types"; +import { parseFrontmatter } from "../utils/frontmatter"; const VALID_THINKING_LEVELS: readonly string[] = ["off", "minimal", "low", "medium", "high", "xhigh"]; const UNICODE_SPACES = /[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g; diff --git a/packages/coding-agent/src/discovery/index.ts b/packages/coding-agent/src/discovery/index.ts index 305342b16..5acfd44c7 100644 --- a/packages/coding-agent/src/discovery/index.ts +++ b/packages/coding-agent/src/discovery/index.ts @@ -58,22 +58,22 @@ export { // Cache management reset, setDisabledProviders, -} from "@oh-my-pi/pi-coding-agent/capability"; -export type { ContextFile } from "@oh-my-pi/pi-coding-agent/capability/context-file"; -export type { Extension, ExtensionManifest } from "@oh-my-pi/pi-coding-agent/capability/extension"; -export type { ExtensionModule } from "@oh-my-pi/pi-coding-agent/capability/extension-module"; -export type { Hook } from "@oh-my-pi/pi-coding-agent/capability/hook"; -export type { Instruction } from "@oh-my-pi/pi-coding-agent/capability/instruction"; +} from "../capability"; +export type { ContextFile } from "../capability/context-file"; +export type { Extension, ExtensionManifest } from "../capability/extension"; +export type { ExtensionModule } from "../capability/extension-module"; +export type { Hook } from "../capability/hook"; +export type { Instruction } from "../capability/instruction"; // Re-export capability item types -export type { MCPServer } from "@oh-my-pi/pi-coding-agent/capability/mcp"; -export type { Prompt } from "@oh-my-pi/pi-coding-agent/capability/prompt"; -export type { Rule, RuleFrontmatter } from "@oh-my-pi/pi-coding-agent/capability/rule"; -export type { Settings } from "@oh-my-pi/pi-coding-agent/capability/settings"; -export type { Skill, SkillFrontmatter } from "@oh-my-pi/pi-coding-agent/capability/skill"; -export type { SlashCommand } from "@oh-my-pi/pi-coding-agent/capability/slash-command"; -export type { SSHHost } from "@oh-my-pi/pi-coding-agent/capability/ssh"; -export type { SystemPrompt } from "@oh-my-pi/pi-coding-agent/capability/system-prompt"; -export type { CustomTool } from "@oh-my-pi/pi-coding-agent/capability/tool"; +export type { MCPServer } from "../capability/mcp"; +export type { Prompt } from "../capability/prompt"; +export type { Rule, RuleFrontmatter } from "../capability/rule"; +export type { Settings } from "../capability/settings"; +export type { Skill, SkillFrontmatter } from "../capability/skill"; +export type { SlashCommand } from "../capability/slash-command"; +export type { SSHHost } from "../capability/ssh"; +export type { SystemPrompt } from "../capability/system-prompt"; +export type { CustomTool } from "../capability/tool"; // Re-export types export type { Capability, @@ -85,4 +85,4 @@ export type { Provider, ProviderInfo, SourceMeta, -} from "@oh-my-pi/pi-coding-agent/capability/types"; +} from "../capability/types"; diff --git a/packages/coding-agent/src/discovery/mcp-json.ts b/packages/coding-agent/src/discovery/mcp-json.ts index 66846e656..99b38dcea 100644 --- a/packages/coding-agent/src/discovery/mcp-json.ts +++ b/packages/coding-agent/src/discovery/mcp-json.ts @@ -8,10 +8,10 @@ */ import { join } from "node:path"; -import { registerProvider } from "@oh-my-pi/pi-coding-agent/capability"; -import { readFile } from "@oh-my-pi/pi-coding-agent/capability/fs"; -import { type MCPServer, mcpCapability } from "@oh-my-pi/pi-coding-agent/capability/mcp"; -import type { LoadContext, LoadResult, SourceMeta } from "@oh-my-pi/pi-coding-agent/capability/types"; +import { registerProvider } from "../capability"; +import { readFile } from "../capability/fs"; +import { type MCPServer, mcpCapability } from "../capability/mcp"; +import type { LoadContext, LoadResult, SourceMeta } from "../capability/types"; import { createSourceMeta, expandEnvVarsDeep, parseJSON } from "./helpers"; const PROVIDER_ID = "mcp-json"; diff --git a/packages/coding-agent/src/discovery/ssh.ts b/packages/coding-agent/src/discovery/ssh.ts index 4aac07430..d09497411 100644 --- a/packages/coding-agent/src/discovery/ssh.ts +++ b/packages/coding-agent/src/discovery/ssh.ts @@ -6,10 +6,10 @@ */ import { join } from "node:path"; -import { registerProvider } from "@oh-my-pi/pi-coding-agent/capability"; -import { readFile } from "@oh-my-pi/pi-coding-agent/capability/fs"; -import { type SSHHost, sshCapability } from "@oh-my-pi/pi-coding-agent/capability/ssh"; -import type { LoadContext, LoadResult, SourceMeta } from "@oh-my-pi/pi-coding-agent/capability/types"; +import { registerProvider } from "../capability"; +import { readFile } from "../capability/fs"; +import { type SSHHost, sshCapability } from "../capability/ssh"; +import type { LoadContext, LoadResult, SourceMeta } from "../capability/types"; import { createSourceMeta, expandEnvVarsDeep, parseJSON } from "./helpers"; const PROVIDER_ID = "ssh-json"; diff --git a/packages/coding-agent/src/discovery/vscode.ts b/packages/coding-agent/src/discovery/vscode.ts index 0e43a926f..bd9569bd1 100644 --- a/packages/coding-agent/src/discovery/vscode.ts +++ b/packages/coding-agent/src/discovery/vscode.ts @@ -5,10 +5,10 @@ * Supports MCP server discovery from `mcp.json` with nested `mcp.servers` structure. */ -import { registerProvider } from "@oh-my-pi/pi-coding-agent/capability"; -import { readFile } from "@oh-my-pi/pi-coding-agent/capability/fs"; -import { type MCPServer, mcpCapability } from "@oh-my-pi/pi-coding-agent/capability/mcp"; -import type { LoadContext, LoadResult } from "@oh-my-pi/pi-coding-agent/capability/types"; +import { registerProvider } from "../capability"; +import { readFile } from "../capability/fs"; +import { type MCPServer, mcpCapability } from "../capability/mcp"; +import type { LoadContext, LoadResult } from "../capability/types"; import { createSourceMeta, expandEnvVarsDeep, getProjectPath, parseJSON } from "./helpers"; const PROVIDER_ID = "vscode"; diff --git a/packages/coding-agent/src/discovery/windsurf.ts b/packages/coding-agent/src/discovery/windsurf.ts index 067714201..097bed841 100644 --- a/packages/coding-agent/src/discovery/windsurf.ts +++ b/packages/coding-agent/src/discovery/windsurf.ts @@ -11,12 +11,12 @@ * - Legacy .windsurfrules file */ -import { registerProvider } from "@oh-my-pi/pi-coding-agent/capability"; -import { readFile } from "@oh-my-pi/pi-coding-agent/capability/fs"; -import { type MCPServer, mcpCapability } from "@oh-my-pi/pi-coding-agent/capability/mcp"; -import { type Rule, ruleCapability } from "@oh-my-pi/pi-coding-agent/capability/rule"; -import type { LoadContext, LoadResult } from "@oh-my-pi/pi-coding-agent/capability/types"; -import { parseFrontmatter } from "@oh-my-pi/pi-coding-agent/utils/frontmatter"; +import { registerProvider } from "../capability"; +import { readFile } from "../capability/fs"; +import { type MCPServer, mcpCapability } from "../capability/mcp"; +import { type Rule, ruleCapability } from "../capability/rule"; +import type { LoadContext, LoadResult } from "../capability/types"; +import { parseFrontmatter } from "../utils/frontmatter"; import { createSourceMeta, expandEnvVarsDeep, diff --git a/packages/coding-agent/src/exa/company.ts b/packages/coding-agent/src/exa/company.ts index 7def1a8a5..ddc7f1552 100644 --- a/packages/coding-agent/src/exa/company.ts +++ b/packages/coding-agent/src/exa/company.ts @@ -4,8 +4,8 @@ * Research companies using Exa's comprehensive data sources. */ -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; import { Type } from "@sinclair/typebox"; +import type { CustomTool } from "../extensibility/custom-tools/types"; import { callExaTool, findApiKey, formatSearchResults, isSearchResponse } from "./mcp-client"; import type { ExaRenderDetails } from "./types"; diff --git a/packages/coding-agent/src/exa/index.ts b/packages/coding-agent/src/exa/index.ts index 54a42d6b7..7ba2a22d1 100644 --- a/packages/coding-agent/src/exa/index.ts +++ b/packages/coding-agent/src/exa/index.ts @@ -9,8 +9,8 @@ * - 14 websets tools (CRUD, items, search, enrichment, monitor) */ -import type { ExaSettings } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; +import type { ExaSettings } from "../config/settings-manager"; +import type { CustomTool } from "../extensibility/custom-tools/types"; import { companyTool } from "./company"; import { linkedinTool } from "./linkedin"; import { researcherTools } from "./researcher"; diff --git a/packages/coding-agent/src/exa/linkedin.ts b/packages/coding-agent/src/exa/linkedin.ts index 45fba61e7..6d5d592dd 100644 --- a/packages/coding-agent/src/exa/linkedin.ts +++ b/packages/coding-agent/src/exa/linkedin.ts @@ -4,8 +4,8 @@ * Search LinkedIn for people, companies, and professional content. */ -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; import { Type } from "@sinclair/typebox"; +import type { CustomTool } from "../extensibility/custom-tools/types"; import { callExaTool, findApiKey, formatSearchResults, isSearchResponse } from "./mcp-client"; import type { ExaRenderDetails } from "./types"; diff --git a/packages/coding-agent/src/exa/mcp-client.ts b/packages/coding-agent/src/exa/mcp-client.ts index 0bf7efbb6..07173ebc0 100644 --- a/packages/coding-agent/src/exa/mcp-client.ts +++ b/packages/coding-agent/src/exa/mcp-client.ts @@ -6,10 +6,10 @@ import { existsSync, readFileSync } from "node:fs"; import { homedir } from "node:os"; -import type { CustomTool, CustomToolResult } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import { callMCP } from "@oh-my-pi/pi-coding-agent/mcp/json-rpc"; import { logger } from "@oh-my-pi/pi-utils"; import type { TSchema } from "@sinclair/typebox"; +import type { CustomTool, CustomToolResult } from "../extensibility/custom-tools/types"; +import { callMCP } from "../mcp/json-rpc"; import type { ExaRenderDetails, ExaSearchResponse, diff --git a/packages/coding-agent/src/exa/render.ts b/packages/coding-agent/src/exa/render.ts index 721edb6b8..4ea1b6075 100644 --- a/packages/coding-agent/src/exa/render.ts +++ b/packages/coding-agent/src/exa/render.ts @@ -4,8 +4,11 @@ * Tree-based rendering with collapsed/expanded states for Exa search results. */ -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; +import type { Component } from "@oh-my-pi/pi-tui"; +import { Text } from "@oh-my-pi/pi-tui"; +import { logger } from "@oh-my-pi/pi-utils"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import type { Theme } from "../modes/theme/theme"; import { formatCount, formatExpandHint, @@ -16,10 +19,7 @@ import { PREVIEW_LIMITS, TRUNCATE_LENGTHS, truncate, -} from "@oh-my-pi/pi-coding-agent/tools/render-utils"; -import type { Component } from "@oh-my-pi/pi-tui"; -import { Text } from "@oh-my-pi/pi-tui"; -import { logger } from "@oh-my-pi/pi-utils"; +} from "../tools/render-utils"; import type { ExaRenderDetails } from "./types"; const COLLAPSED_PREVIEW_LINES = PREVIEW_LIMITS.COLLAPSED_LINES; diff --git a/packages/coding-agent/src/exa/researcher.ts b/packages/coding-agent/src/exa/researcher.ts index a0f41d778..9d1dd25a6 100644 --- a/packages/coding-agent/src/exa/researcher.ts +++ b/packages/coding-agent/src/exa/researcher.ts @@ -4,8 +4,8 @@ * Async research tasks with polling for completion. */ -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; import { Type } from "@sinclair/typebox"; +import type { CustomTool } from "../extensibility/custom-tools/types"; import { callExaTool, findApiKey } from "./mcp-client"; import type { ExaRenderDetails } from "./types"; diff --git a/packages/coding-agent/src/exa/search.ts b/packages/coding-agent/src/exa/search.ts index f34777136..b4e14f560 100644 --- a/packages/coding-agent/src/exa/search.ts +++ b/packages/coding-agent/src/exa/search.ts @@ -5,8 +5,8 @@ */ import { StringEnum } from "@oh-my-pi/pi-ai"; -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; import { Type } from "@sinclair/typebox"; +import type { CustomTool } from "../extensibility/custom-tools/types"; import { callExaTool, findApiKey, formatSearchResults, isSearchResponse } from "./mcp-client"; import type { ExaRenderDetails } from "./types"; diff --git a/packages/coding-agent/src/exa/websets.ts b/packages/coding-agent/src/exa/websets.ts index f56bd74c9..7837ff7ea 100644 --- a/packages/coding-agent/src/exa/websets.ts +++ b/packages/coding-agent/src/exa/websets.ts @@ -4,8 +4,8 @@ * CRUD operations for websets, items, searches, enrichments, and monitoring. */ -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; import { Type } from "@sinclair/typebox"; +import type { CustomTool } from "../extensibility/custom-tools/types"; import { callWebsetsTool, findApiKey } from "./mcp-client"; import type { ExaRenderDetails } from "./types"; diff --git a/packages/coding-agent/src/exec/bash-executor.ts b/packages/coding-agent/src/exec/bash-executor.ts index 751301900..a0cdde9e8 100644 --- a/packages/coding-agent/src/exec/bash-executor.ts +++ b/packages/coding-agent/src/exec/bash-executor.ts @@ -4,10 +4,10 @@ * Provides unified bash execution for AgentSession.executeBash() and direct calls. */ -import { OutputSink } from "@oh-my-pi/pi-coding-agent/session/streaming-output"; -import { getShellConfig } from "@oh-my-pi/pi-coding-agent/utils/shell"; -import { getOrCreateSnapshot, getSnapshotSourceCommand } from "@oh-my-pi/pi-coding-agent/utils/shell-snapshot"; import { cspawn, Exception, ptree } from "@oh-my-pi/pi-utils"; +import { OutputSink } from "../session/streaming-output"; +import { getShellConfig } from "../utils/shell"; +import { getOrCreateSnapshot, getSnapshotSourceCommand } from "../utils/shell-snapshot"; export interface BashExecutorOptions { cwd?: string; diff --git a/packages/coding-agent/src/export/custom-share.ts b/packages/coding-agent/src/export/custom-share.ts index 461f6958b..db53d4e78 100644 --- a/packages/coding-agent/src/export/custom-share.ts +++ b/packages/coding-agent/src/export/custom-share.ts @@ -7,7 +7,7 @@ import { existsSync } from "node:fs"; import { join } from "node:path"; -import { getAgentDir } from "@oh-my-pi/pi-coding-agent/config"; +import { getAgentDir } from "../config"; export interface CustomShareResult { /** URL to display/open (optional - script may handle everything itself) */ diff --git a/packages/coding-agent/src/export/html/index.ts b/packages/coding-agent/src/export/html/index.ts index aff7f5aa0..3f1cb9399 100644 --- a/packages/coding-agent/src/export/html/index.ts +++ b/packages/coding-agent/src/export/html/index.ts @@ -1,9 +1,9 @@ import { existsSync, writeFileSync } from "node:fs"; import { basename } from "node:path"; import type { AgentState } from "@oh-my-pi/pi-agent-core"; -import { APP_NAME } from "@oh-my-pi/pi-coding-agent/config"; -import { getResolvedThemeColors, getThemeExportColors } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import { SessionManager } from "@oh-my-pi/pi-coding-agent/session/session-manager"; +import { APP_NAME } from "../../config"; +import { getResolvedThemeColors, getThemeExportColors } from "../../modes/theme/theme"; +import { SessionManager } from "../../session/session-manager"; // Pre-generated template (created by scripts/generate-template.ts at publish time) import { TEMPLATE } from "./template.generated"; diff --git a/packages/coding-agent/src/export/ttsr.ts b/packages/coding-agent/src/export/ttsr.ts index 553327039..aa8fc4429 100644 --- a/packages/coding-agent/src/export/ttsr.ts +++ b/packages/coding-agent/src/export/ttsr.ts @@ -6,9 +6,9 @@ * injected as a system reminder, and the request is retried. */ -import type { Rule } from "@oh-my-pi/pi-coding-agent/capability/rule"; -import type { TtsrSettings } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; import { logger } from "@oh-my-pi/pi-utils"; +import type { Rule } from "../capability/rule"; +import type { TtsrSettings } from "../config/settings-manager"; interface TtsrEntry { rule: Rule; diff --git a/packages/coding-agent/src/extensibility/custom-commands/bundled/review/index.ts b/packages/coding-agent/src/extensibility/custom-commands/bundled/review/index.ts index 01df5cbb3..20ef62963 100644 --- a/packages/coding-agent/src/extensibility/custom-commands/bundled/review/index.ts +++ b/packages/coding-agent/src/extensibility/custom-commands/bundled/review/index.ts @@ -12,10 +12,10 @@ * multiple reviewer agents based on diff weight and locality. */ -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import type { CustomCommand, CustomCommandAPI } from "@oh-my-pi/pi-coding-agent/extensibility/custom-commands/types"; -import type { HookCommandContext } from "@oh-my-pi/pi-coding-agent/extensibility/hooks/types"; -import reviewRequestTemplate from "@oh-my-pi/pi-coding-agent/prompts/review-request.md" with { type: "text" }; +import { renderPromptTemplate } from "../../../../config/prompt-templates"; +import type { CustomCommand, CustomCommandAPI } from "../../../../extensibility/custom-commands/types"; +import type { HookCommandContext } from "../../../../extensibility/hooks/types"; +import reviewRequestTemplate from "../../../../prompts/review-request.md" with { type: "text" }; // ───────────────────────────────────────────────────────────────────────────── // Types diff --git a/packages/coding-agent/src/extensibility/custom-commands/loader.ts b/packages/coding-agent/src/extensibility/custom-commands/loader.ts index 4eea5148f..e61cbc9ff 100644 --- a/packages/coding-agent/src/extensibility/custom-commands/loader.ts +++ b/packages/coding-agent/src/extensibility/custom-commands/loader.ts @@ -8,10 +8,10 @@ import { type Dirent, existsSync, readdirSync } from "node:fs"; import * as path from "node:path"; import * as piCodingAgent from "@oh-my-pi/pi-coding-agent"; -import { getAgentDir, getConfigDirs } from "@oh-my-pi/pi-coding-agent/config"; -import { execCommand } from "@oh-my-pi/pi-coding-agent/exec/exec"; import { logger } from "@oh-my-pi/pi-utils"; import * as typebox from "@sinclair/typebox"; +import { getAgentDir, getConfigDirs } from "../../config"; +import { execCommand } from "../../exec/exec"; import { ReviewCommand } from "./bundled/review"; import type { CustomCommand, diff --git a/packages/coding-agent/src/extensibility/custom-commands/types.ts b/packages/coding-agent/src/extensibility/custom-commands/types.ts index 4e180e767..4773fb335 100644 --- a/packages/coding-agent/src/extensibility/custom-commands/types.ts +++ b/packages/coding-agent/src/extensibility/custom-commands/types.ts @@ -6,7 +6,7 @@ * arbitrary logic with full access to the hook context. */ -import type { ExecOptions, ExecResult, HookCommandContext } from "@oh-my-pi/pi-coding-agent/extensibility/hooks/types"; +import type { ExecOptions, ExecResult, HookCommandContext } from "../../extensibility/hooks/types"; // Re-export for custom commands to use export type { ExecOptions, ExecResult, HookCommandContext }; diff --git a/packages/coding-agent/src/extensibility/custom-tools/loader.ts b/packages/coding-agent/src/extensibility/custom-tools/loader.ts index df4d1745a..0430231b0 100644 --- a/packages/coding-agent/src/extensibility/custom-tools/loader.ts +++ b/packages/coding-agent/src/extensibility/custom-tools/loader.ts @@ -7,16 +7,16 @@ import * as path from "node:path"; import * as piCodingAgent from "@oh-my-pi/pi-coding-agent"; -import { toolCapability } from "@oh-my-pi/pi-coding-agent/capability/tool"; -import { type CustomTool, loadCapability } from "@oh-my-pi/pi-coding-agent/discovery"; -import { expandPath } from "@oh-my-pi/pi-coding-agent/discovery/helpers"; -import type { ExecOptions } from "@oh-my-pi/pi-coding-agent/exec/exec"; -import { execCommand } from "@oh-my-pi/pi-coding-agent/exec/exec"; -import type { HookUIContext } from "@oh-my-pi/pi-coding-agent/extensibility/hooks/types"; -import { getAllPluginToolPaths } from "@oh-my-pi/pi-coding-agent/extensibility/plugins/loader"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { logger } from "@oh-my-pi/pi-utils"; import * as typebox from "@sinclair/typebox"; +import { toolCapability } from "../../capability/tool"; +import { type CustomTool, loadCapability } from "../../discovery"; +import { expandPath } from "../../discovery/helpers"; +import type { ExecOptions } from "../../exec/exec"; +import { execCommand } from "../../exec/exec"; +import type { HookUIContext } from "../../extensibility/hooks/types"; +import { getAllPluginToolPaths } from "../../extensibility/plugins/loader"; +import { theme } from "../../modes/theme/theme"; import type { CustomToolAPI, CustomToolFactory, LoadedCustomTool, ToolLoadError } from "./types"; /** diff --git a/packages/coding-agent/src/extensibility/custom-tools/types.ts b/packages/coding-agent/src/extensibility/custom-tools/types.ts index d1c70b4e9..64b259cd2 100644 --- a/packages/coding-agent/src/extensibility/custom-tools/types.ts +++ b/packages/coding-agent/src/extensibility/custom-tools/types.ts @@ -7,13 +7,13 @@ import type { AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; import type { Model } from "@oh-my-pi/pi-ai"; -import type { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry"; -import type { ExecOptions, ExecResult } from "@oh-my-pi/pi-coding-agent/exec/exec"; -import type { HookUIContext } from "@oh-my-pi/pi-coding-agent/extensibility/hooks/types"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { ReadonlySessionManager } from "@oh-my-pi/pi-coding-agent/session/session-manager"; import type { Component } from "@oh-my-pi/pi-tui"; import type { Static, TSchema } from "@sinclair/typebox"; +import type { ModelRegistry } from "../../config/model-registry"; +import type { ExecOptions, ExecResult } from "../../exec/exec"; +import type { HookUIContext } from "../../extensibility/hooks/types"; +import type { Theme } from "../../modes/theme/theme"; +import type { ReadonlySessionManager } from "../../session/session-manager"; /** Alias for clarity */ export type CustomToolUIContext = HookUIContext; @@ -22,7 +22,7 @@ export type CustomToolUIContext = HookUIContext; export type { AgentToolResult, AgentToolUpdateCallback }; // Re-export for backward compatibility -export type { ExecOptions, ExecResult } from "@oh-my-pi/pi-coding-agent/exec/exec"; +export type { ExecOptions, ExecResult } from "../../exec/exec"; /** API passed to custom tool factory (stable across session changes) */ export interface CustomToolAPI { diff --git a/packages/coding-agent/src/extensibility/custom-tools/wrapper.ts b/packages/coding-agent/src/extensibility/custom-tools/wrapper.ts index 6543f34d7..b239f010d 100644 --- a/packages/coding-agent/src/extensibility/custom-tools/wrapper.ts +++ b/packages/coding-agent/src/extensibility/custom-tools/wrapper.ts @@ -3,9 +3,9 @@ */ import type { AgentTool, AgentToolResult, AgentToolUpdateCallback, RenderResultOptions } from "@oh-my-pi/pi-agent-core"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import type { Component } from "@oh-my-pi/pi-tui"; import type { Static, TSchema } from "@sinclair/typebox"; +import type { Theme } from "../../modes/theme/theme"; import type { CustomTool, CustomToolContext, LoadedCustomTool } from "./types"; export class CustomToolAdapter diff --git a/packages/coding-agent/src/extensibility/extensions/loader.ts b/packages/coding-agent/src/extensibility/extensions/loader.ts index d91dc7894..670d92bad 100644 --- a/packages/coding-agent/src/extensibility/extensions/loader.ts +++ b/packages/coding-agent/src/extensibility/extensions/loader.ts @@ -7,17 +7,17 @@ import * as path from "node:path"; import type { ThinkingLevel } from "@oh-my-pi/pi-agent-core"; import type { ImageContent, Model, TextContent } from "@oh-my-pi/pi-ai"; import * as piCodingAgent from "@oh-my-pi/pi-coding-agent"; -import { type ExtensionModule, extensionModuleCapability } from "@oh-my-pi/pi-coding-agent/capability/extension-module"; -import { loadCapability } from "@oh-my-pi/pi-coding-agent/discovery"; -import { expandPath, getExtensionNameFromPath } from "@oh-my-pi/pi-coding-agent/discovery/helpers"; -import type { ExecOptions } from "@oh-my-pi/pi-coding-agent/exec/exec"; -import { execCommand } from "@oh-my-pi/pi-coding-agent/exec/exec"; -import type { CustomMessage } from "@oh-my-pi/pi-coding-agent/session/messages"; -import { EventBus } from "@oh-my-pi/pi-coding-agent/utils/event-bus"; import type { KeyId } from "@oh-my-pi/pi-tui"; import { logger } from "@oh-my-pi/pi-utils"; import type { TSchema } from "@sinclair/typebox"; import * as TypeBox from "@sinclair/typebox"; +import { type ExtensionModule, extensionModuleCapability } from "../../capability/extension-module"; +import { loadCapability } from "../../discovery"; +import { expandPath, getExtensionNameFromPath } from "../../discovery/helpers"; +import type { ExecOptions } from "../../exec/exec"; +import { execCommand } from "../../exec/exec"; +import type { CustomMessage } from "../../session/messages"; +import { EventBus } from "../../utils/event-bus"; import type { Extension, ExtensionAPI, diff --git a/packages/coding-agent/src/extensibility/extensions/runner.ts b/packages/coding-agent/src/extensibility/extensions/runner.ts index 8a0aa1afa..16c123840 100644 --- a/packages/coding-agent/src/extensibility/extensions/runner.ts +++ b/packages/coding-agent/src/extensibility/extensions/runner.ts @@ -4,11 +4,11 @@ import type { AgentMessage } from "@oh-my-pi/pi-agent-core"; import type { ImageContent, Model } from "@oh-my-pi/pi-ai"; -import type { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry"; -import { type Theme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { SessionManager } from "@oh-my-pi/pi-coding-agent/session/session-manager"; import type { KeyId } from "@oh-my-pi/pi-tui"; import { logger } from "@oh-my-pi/pi-utils"; +import type { ModelRegistry } from "../../config/model-registry"; +import { type Theme, theme } from "../../modes/theme/theme"; +import type { SessionManager } from "../../session/session-manager"; import type { BeforeAgentStartEvent, BeforeAgentStartEventResult, diff --git a/packages/coding-agent/src/extensibility/extensions/types.ts b/packages/coding-agent/src/extensibility/extensions/types.ts index 67e8f672c..9259219f7 100644 --- a/packages/coding-agent/src/extensibility/extensions/types.ts +++ b/packages/coding-agent/src/extensibility/extensions/types.ts @@ -11,35 +11,29 @@ import type { AgentMessage, AgentToolResult, AgentToolUpdateCallback, ThinkingLevel } from "@oh-my-pi/pi-agent-core"; import type { ImageContent, Model, TextContent, ToolResultMessage } from "@oh-my-pi/pi-ai"; import type * as piCodingAgent from "@oh-my-pi/pi-coding-agent"; -import type { KeybindingsManager } from "@oh-my-pi/pi-coding-agent/config/keybindings"; -import type { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry"; -import type { BashResult } from "@oh-my-pi/pi-coding-agent/exec/bash-executor"; -import type { ExecOptions, ExecResult } from "@oh-my-pi/pi-coding-agent/exec/exec"; -import type { PythonResult } from "@oh-my-pi/pi-coding-agent/ipy/executor"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { EditToolDetails } from "@oh-my-pi/pi-coding-agent/patch"; -import type { CompactionPreparation, CompactionResult } from "@oh-my-pi/pi-coding-agent/session/compaction"; -import type { CustomMessage } from "@oh-my-pi/pi-coding-agent/session/messages"; +import type { AutocompleteItem, Component, EditorComponent, EditorTheme, KeyId, TUI } from "@oh-my-pi/pi-tui"; +import type { Static, TSchema } from "@sinclair/typebox"; +import type { KeybindingsManager } from "../../config/keybindings"; +import type { ModelRegistry } from "../../config/model-registry"; +import type { BashResult } from "../../exec/bash-executor"; +import type { ExecOptions, ExecResult } from "../../exec/exec"; +import type { PythonResult } from "../../ipy/executor"; +import type { Theme } from "../../modes/theme/theme"; +import type { EditToolDetails } from "../../patch"; +import type { CompactionPreparation, CompactionResult } from "../../session/compaction"; +import type { CustomMessage } from "../../session/messages"; import type { BranchSummaryEntry, CompactionEntry, ReadonlySessionManager, SessionEntry, SessionManager, -} from "@oh-my-pi/pi-coding-agent/session/session-manager"; -import type { - BashToolDetails, - FindToolDetails, - GrepToolDetails, - LsToolDetails, - ReadToolDetails, -} from "@oh-my-pi/pi-coding-agent/tools"; -import type { EventBus } from "@oh-my-pi/pi-coding-agent/utils/event-bus"; -import type { AutocompleteItem, Component, EditorComponent, EditorTheme, KeyId, TUI } from "@oh-my-pi/pi-tui"; -import type { Static, TSchema } from "@sinclair/typebox"; +} from "../../session/session-manager"; +import type { BashToolDetails, FindToolDetails, GrepToolDetails, LsToolDetails, ReadToolDetails } from "../../tools"; +import type { EventBus } from "../../utils/event-bus"; -export type { AppAction, KeybindingsManager } from "@oh-my-pi/pi-coding-agent/config/keybindings"; -export type { ExecOptions, ExecResult } from "@oh-my-pi/pi-coding-agent/exec/exec"; +export type { AppAction, KeybindingsManager } from "../../config/keybindings"; +export type { ExecOptions, ExecResult } from "../../exec/exec"; export type { AgentToolResult, AgentToolUpdateCallback }; // ============================================================================ diff --git a/packages/coding-agent/src/extensibility/extensions/wrapper.ts b/packages/coding-agent/src/extensibility/extensions/wrapper.ts index 70fbd6dc7..4491cea56 100644 --- a/packages/coding-agent/src/extensibility/extensions/wrapper.ts +++ b/packages/coding-agent/src/extensibility/extensions/wrapper.ts @@ -4,8 +4,8 @@ import type { AgentTool, AgentToolContext, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; import type { ImageContent, TextContent } from "@oh-my-pi/pi-ai"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import type { Static, TSchema } from "@sinclair/typebox"; +import type { Theme } from "../../modes/theme/theme"; import type { ExtensionRunner } from "./runner"; import type { RegisteredTool, ToolCallEventResult, ToolResultEventResult } from "./types"; diff --git a/packages/coding-agent/src/extensibility/hooks/index.ts b/packages/coding-agent/src/extensibility/hooks/index.ts index 1b6fa900d..9d03d7f02 100644 --- a/packages/coding-agent/src/extensibility/hooks/index.ts +++ b/packages/coding-agent/src/extensibility/hooks/index.ts @@ -1,5 +1,5 @@ // biome-ignore assist/source/organizeImports: biome is not smart -export type { ReadonlySessionManager, UsageStatistics } from "@oh-my-pi/pi-coding-agent/session/session-manager"; +export type { ReadonlySessionManager, UsageStatistics } from "../../session/session-manager"; export { discoverAndLoadHooks, loadHooks, diff --git a/packages/coding-agent/src/extensibility/hooks/loader.ts b/packages/coding-agent/src/extensibility/hooks/loader.ts index b812fcb4c..a2d0c5cd6 100644 --- a/packages/coding-agent/src/extensibility/hooks/loader.ts +++ b/packages/coding-agent/src/extensibility/hooks/loader.ts @@ -4,14 +4,14 @@ import * as path from "node:path"; import * as piCodingAgent from "@oh-my-pi/pi-coding-agent"; -import { hookCapability } from "@oh-my-pi/pi-coding-agent/capability/hook"; -import type { Hook } from "@oh-my-pi/pi-coding-agent/discovery"; -import { loadCapability } from "@oh-my-pi/pi-coding-agent/discovery"; -import { expandPath } from "@oh-my-pi/pi-coding-agent/discovery/helpers"; -import type { HookMessage } from "@oh-my-pi/pi-coding-agent/session/messages"; -import type { SessionManager } from "@oh-my-pi/pi-coding-agent/session/session-manager"; import { logger } from "@oh-my-pi/pi-utils"; import * as typebox from "@sinclair/typebox"; +import { hookCapability } from "../../capability/hook"; +import type { Hook } from "../../discovery"; +import { loadCapability } from "../../discovery"; +import { expandPath } from "../../discovery/helpers"; +import type { HookMessage } from "../../session/messages"; +import type { SessionManager } from "../../session/session-manager"; import { execCommand } from "./runner"; import type { ExecOptions, HookAPI, HookFactory, HookMessageRenderer, RegisteredCommand } from "./types"; diff --git a/packages/coding-agent/src/extensibility/hooks/runner.ts b/packages/coding-agent/src/extensibility/hooks/runner.ts index 658c08764..a692308d6 100644 --- a/packages/coding-agent/src/extensibility/hooks/runner.ts +++ b/packages/coding-agent/src/extensibility/hooks/runner.ts @@ -4,9 +4,9 @@ import type { AgentMessage } from "@oh-my-pi/pi-agent-core"; import type { Model } from "@oh-my-pi/pi-ai"; -import type { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { SessionManager } from "@oh-my-pi/pi-coding-agent/session/session-manager"; +import type { ModelRegistry } from "../../config/model-registry"; +import { theme } from "../../modes/theme/theme"; +import type { SessionManager } from "../../session/session-manager"; import type { AppendEntryHandler, BranchHandler, @@ -40,7 +40,7 @@ import type { export type HookErrorListener = (error: HookError) => void; // Re-export execCommand for backward compatibility -export { execCommand } from "@oh-my-pi/pi-coding-agent/exec/exec"; +export { execCommand } from "../../exec/exec"; /** No-op UI context used when no UI is available */ const noOpUIContext: HookUIContext = { diff --git a/packages/coding-agent/src/extensibility/hooks/types.ts b/packages/coding-agent/src/extensibility/hooks/types.ts index d0ad87631..ff047e0b7 100644 --- a/packages/coding-agent/src/extensibility/hooks/types.ts +++ b/packages/coding-agent/src/extensibility/hooks/types.ts @@ -7,30 +7,24 @@ import type { AgentMessage } from "@oh-my-pi/pi-agent-core"; import type { ImageContent, Message, Model, TextContent, ToolResultMessage } from "@oh-my-pi/pi-ai"; -import type { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry"; -import type { ExecOptions, ExecResult } from "@oh-my-pi/pi-coding-agent/exec/exec"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { EditToolDetails } from "@oh-my-pi/pi-coding-agent/patch"; -import type { CompactionPreparation, CompactionResult } from "@oh-my-pi/pi-coding-agent/session/compaction"; -import type { HookMessage } from "@oh-my-pi/pi-coding-agent/session/messages"; +import type { Component, TUI } from "@oh-my-pi/pi-tui"; +import type { ModelRegistry } from "../../config/model-registry"; +import type { ExecOptions, ExecResult } from "../../exec/exec"; +import type { Theme } from "../../modes/theme/theme"; +import type { EditToolDetails } from "../../patch"; +import type { CompactionPreparation, CompactionResult } from "../../session/compaction"; +import type { HookMessage } from "../../session/messages"; import type { BranchSummaryEntry, CompactionEntry, ReadonlySessionManager, SessionEntry, SessionManager, -} from "@oh-my-pi/pi-coding-agent/session/session-manager"; -import type { - BashToolDetails, - FindToolDetails, - GrepToolDetails, - LsToolDetails, - ReadToolDetails, -} from "@oh-my-pi/pi-coding-agent/tools"; -import type { Component, TUI } from "@oh-my-pi/pi-tui"; +} from "../../session/session-manager"; +import type { BashToolDetails, FindToolDetails, GrepToolDetails, LsToolDetails, ReadToolDetails } from "../../tools"; // Re-export for backward compatibility -export type { ExecOptions, ExecResult } from "@oh-my-pi/pi-coding-agent/exec/exec"; +export type { ExecOptions, ExecResult } from "../../exec/exec"; /** * UI context for hooks to request interactive UI from the harness. diff --git a/packages/coding-agent/src/extensibility/plugins/doctor.ts b/packages/coding-agent/src/extensibility/plugins/doctor.ts index a3571e184..53afd05ed 100644 --- a/packages/coding-agent/src/extensibility/plugins/doctor.ts +++ b/packages/coding-agent/src/extensibility/plugins/doctor.ts @@ -1,4 +1,4 @@ -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; +import { theme } from "../../modes/theme/theme"; import type { DoctorCheck } from "./types"; export async function runDoctorChecks(): Promise { diff --git a/packages/coding-agent/src/extensibility/plugins/installer.ts b/packages/coding-agent/src/extensibility/plugins/installer.ts index cb7afb3fd..13e85f462 100644 --- a/packages/coding-agent/src/extensibility/plugins/installer.ts +++ b/packages/coding-agent/src/extensibility/plugins/installer.ts @@ -1,7 +1,7 @@ import { lstatSync, symlinkSync, unlinkSync } from "node:fs"; import { mkdir } from "node:fs/promises"; import { join, resolve } from "node:path"; -import { getAgentDir } from "@oh-my-pi/pi-coding-agent/config"; +import { getAgentDir } from "../../config"; import type { InstalledPlugin } from "./types"; const PLUGINS_DIR = join(getAgentDir(), "plugins"); diff --git a/packages/coding-agent/src/extensibility/plugins/paths.ts b/packages/coding-agent/src/extensibility/plugins/paths.ts index 3fa594e42..7af1d984c 100644 --- a/packages/coding-agent/src/extensibility/plugins/paths.ts +++ b/packages/coding-agent/src/extensibility/plugins/paths.ts @@ -1,6 +1,6 @@ import { homedir } from "node:os"; import { join } from "node:path"; -import { CONFIG_DIR_NAME, getConfigDirPaths } from "@oh-my-pi/pi-coding-agent/config"; +import { CONFIG_DIR_NAME, getConfigDirPaths } from "../../config"; // ============================================================================= // Plugin Directory Paths diff --git a/packages/coding-agent/src/extensibility/skills.ts b/packages/coding-agent/src/extensibility/skills.ts index f382b98df..79d113656 100644 --- a/packages/coding-agent/src/extensibility/skills.ts +++ b/packages/coding-agent/src/extensibility/skills.ts @@ -1,16 +1,13 @@ import { readdirSync, readFileSync, statSync } from "node:fs"; import { realpath } from "node:fs/promises"; import { basename, join } from "node:path"; -import { skillCapability } from "@oh-my-pi/pi-coding-agent/capability/skill"; -import type { SourceMeta } from "@oh-my-pi/pi-coding-agent/capability/types"; -import type { SkillsSettings } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import type { - Skill as CapabilitySkill, - SkillFrontmatter as ImportedSkillFrontmatter, -} from "@oh-my-pi/pi-coding-agent/discovery"; -import { loadCapability } from "@oh-my-pi/pi-coding-agent/discovery"; -import { parseFrontmatter } from "@oh-my-pi/pi-coding-agent/utils/frontmatter"; import { logger } from "@oh-my-pi/pi-utils"; +import { skillCapability } from "../capability/skill"; +import type { SourceMeta } from "../capability/types"; +import type { SkillsSettings } from "../config/settings-manager"; +import type { Skill as CapabilitySkill, SkillFrontmatter as ImportedSkillFrontmatter } from "../discovery"; +import { loadCapability } from "../discovery"; +import { parseFrontmatter } from "../utils/frontmatter"; // Re-export SkillFrontmatter for backward compatibility export type { ImportedSkillFrontmatter as SkillFrontmatter }; diff --git a/packages/coding-agent/src/extensibility/slash-commands.ts b/packages/coding-agent/src/extensibility/slash-commands.ts index c4f0dc055..d21b401a5 100644 --- a/packages/coding-agent/src/extensibility/slash-commands.ts +++ b/packages/coding-agent/src/extensibility/slash-commands.ts @@ -1,9 +1,9 @@ -import { slashCommandCapability } from "@oh-my-pi/pi-coding-agent/capability/slash-command"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import type { SlashCommand } from "@oh-my-pi/pi-coding-agent/discovery"; -import { loadCapability } from "@oh-my-pi/pi-coding-agent/discovery"; -import { EMBEDDED_COMMAND_TEMPLATES } from "@oh-my-pi/pi-coding-agent/task/commands"; -import { parseFrontmatter } from "@oh-my-pi/pi-coding-agent/utils/frontmatter"; +import { slashCommandCapability } from "../capability/slash-command"; +import { renderPromptTemplate } from "../config/prompt-templates"; +import type { SlashCommand } from "../discovery"; +import { loadCapability } from "../discovery"; +import { EMBEDDED_COMMAND_TEMPLATES } from "../task/commands"; +import { parseFrontmatter } from "../utils/frontmatter"; /** * Represents a custom slash command loaded from a file diff --git a/packages/coding-agent/src/index.ts b/packages/coding-agent/src/index.ts index 16c72dcba..f49d9c0e0 100644 --- a/packages/coding-agent/src/index.ts +++ b/packages/coding-agent/src/index.ts @@ -3,52 +3,6 @@ // TypeBox helper for string enums (convenience for custom tools) // Re-export from pi-ai which uses the correct enum-based schema format export { StringEnum } from "@oh-my-pi/pi-ai"; -export type { FileDiagnosticsResult } from "@oh-my-pi/pi-coding-agent/lsp"; -// UI components for extensions -export { - ArminComponent, - AssistantMessageComponent, - BashExecutionComponent, - BorderedLoader, - BranchSummaryMessageComponent, - CompactionSummaryMessageComponent, - CustomEditor, - CustomMessageComponent, - DynamicBorder, - FooterComponent, - HookEditorComponent as ExtensionEditorComponent, - HookInputComponent as ExtensionInputComponent, - HookSelectorComponent as ExtensionSelectorComponent, - LoginDialogComponent, - ModelSelectorComponent, - OAuthSelectorComponent, - type RenderDiffOptions, - renderDiff, - SessionSelectorComponent, - type SettingsCallbacks, - SettingsSelectorComponent, - ShowImagesSelectorComponent, - ThemeSelectorComponent, - ThinkingSelectorComponent, - ToolExecutionComponent, - type ToolExecutionOptions, - TreeSelectorComponent, - truncateToVisualLines, - UserMessageComponent, - UserMessageSelectorComponent, - type VisualTruncateResult, -} from "@oh-my-pi/pi-coding-agent/modes/components"; -// Theme utilities for custom tools -export { - getLanguageFromPath, - getMarkdownTheme, - getSelectListTheme, - getSettingsListTheme, - highlightCode, - initTheme, - Theme, - type ThemeColor, -} from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; // Re-export TUI components for custom tool rendering export { Container, Markdown, Spacer, Text } from "@oh-my-pi/pi-tui"; // Logging @@ -150,6 +104,7 @@ export { } from "./extensibility/skills"; // Slash commands export { type FileSlashCommand, loadSlashCommands as discoverSlashCommands } from "./extensibility/slash-commands"; +export type { FileDiagnosticsResult } from "./lsp"; // Main entry point export { main } from "./main"; // Run modes for programmatic SDK usage @@ -163,6 +118,51 @@ export { runPrintMode, runRpcMode, } from "./modes"; +// UI components for extensions +export { + ArminComponent, + AssistantMessageComponent, + BashExecutionComponent, + BorderedLoader, + BranchSummaryMessageComponent, + CompactionSummaryMessageComponent, + CustomEditor, + CustomMessageComponent, + DynamicBorder, + FooterComponent, + HookEditorComponent as ExtensionEditorComponent, + HookInputComponent as ExtensionInputComponent, + HookSelectorComponent as ExtensionSelectorComponent, + LoginDialogComponent, + ModelSelectorComponent, + OAuthSelectorComponent, + type RenderDiffOptions, + renderDiff, + SessionSelectorComponent, + type SettingsCallbacks, + SettingsSelectorComponent, + ShowImagesSelectorComponent, + ThemeSelectorComponent, + ThinkingSelectorComponent, + ToolExecutionComponent, + type ToolExecutionOptions, + TreeSelectorComponent, + truncateToVisualLines, + UserMessageComponent, + UserMessageSelectorComponent, + type VisualTruncateResult, +} from "./modes/components"; +// Theme utilities for custom tools +export { + getLanguageFromPath, + getMarkdownTheme, + getSelectListTheme, + getSettingsListTheme, + highlightCode, + initTheme, + Theme, + type ThemeColor, +} from "./modes/theme/theme"; // SDK for programmatic usage export { // Factory diff --git a/packages/coding-agent/src/internal-urls/rule-protocol.ts b/packages/coding-agent/src/internal-urls/rule-protocol.ts index aea5bff2a..76bb7130b 100644 --- a/packages/coding-agent/src/internal-urls/rule-protocol.ts +++ b/packages/coding-agent/src/internal-urls/rule-protocol.ts @@ -7,7 +7,7 @@ * - rule:// - Reads rule content */ -import type { Rule } from "@oh-my-pi/pi-coding-agent/capability/rule"; +import type { Rule } from "../capability/rule"; import type { InternalResource, InternalUrl, ProtocolHandler } from "./types"; export interface RuleProtocolOptions { diff --git a/packages/coding-agent/src/internal-urls/skill-protocol.ts b/packages/coding-agent/src/internal-urls/skill-protocol.ts index ac028ce6e..b9aa88a3d 100644 --- a/packages/coding-agent/src/internal-urls/skill-protocol.ts +++ b/packages/coding-agent/src/internal-urls/skill-protocol.ts @@ -9,7 +9,7 @@ */ import * as path from "node:path"; -import type { Skill } from "@oh-my-pi/pi-coding-agent/extensibility/skills"; +import type { Skill } from "../extensibility/skills"; import type { InternalResource, InternalUrl, ProtocolHandler } from "./types"; export interface SkillProtocolOptions { diff --git a/packages/coding-agent/src/ipy/executor.ts b/packages/coding-agent/src/ipy/executor.ts index d1f1faadc..98f07ddb2 100644 --- a/packages/coding-agent/src/ipy/executor.ts +++ b/packages/coding-agent/src/ipy/executor.ts @@ -1,4 +1,6 @@ -import { shutdownSharedGateway } from "@oh-my-pi/pi-coding-agent/ipy/gateway-coordinator"; +import { logger } from "@oh-my-pi/pi-utils"; +import { OutputSink } from "../session/streaming-output"; +import { shutdownSharedGateway } from "./gateway-coordinator"; import { checkPythonKernelAvailability, type KernelDisplayOutput, @@ -6,9 +8,7 @@ import { type KernelExecuteResult, type PreludeHelper, PythonKernel, -} from "@oh-my-pi/pi-coding-agent/ipy/kernel"; -import { OutputSink } from "@oh-my-pi/pi-coding-agent/session/streaming-output"; -import { logger } from "@oh-my-pi/pi-utils"; +} from "./kernel"; const IDLE_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes const MAX_KERNEL_SESSIONS = 4; diff --git a/packages/coding-agent/src/ipy/gateway-coordinator.ts b/packages/coding-agent/src/ipy/gateway-coordinator.ts index 9f15401ad..86139637d 100644 --- a/packages/coding-agent/src/ipy/gateway-coordinator.ts +++ b/packages/coding-agent/src/ipy/gateway-coordinator.ts @@ -12,11 +12,11 @@ import { } from "node:fs"; import { createServer } from "node:net"; import { delimiter, join } from "node:path"; -import { getAgentDir } from "@oh-my-pi/pi-coding-agent/config"; -import { getShellConfig, killProcessTree } from "@oh-my-pi/pi-coding-agent/utils/shell"; -import { getOrCreateSnapshot } from "@oh-my-pi/pi-coding-agent/utils/shell-snapshot"; import { logger } from "@oh-my-pi/pi-utils"; import type { Subprocess } from "bun"; +import { getAgentDir } from "../config"; +import { getShellConfig, killProcessTree } from "../utils/shell"; +import { getOrCreateSnapshot } from "../utils/shell-snapshot"; const GATEWAY_DIR_NAME = "python-gateway"; const GATEWAY_INFO_FILE = "gateway.json"; diff --git a/packages/coding-agent/src/ipy/kernel.ts b/packages/coding-agent/src/ipy/kernel.ts index 059a68a47..96a5e83c9 100644 --- a/packages/coding-agent/src/ipy/kernel.ts +++ b/packages/coding-agent/src/ipy/kernel.ts @@ -1,11 +1,11 @@ import { createServer } from "node:net"; import { delimiter, join } from "node:path"; -import { getShellConfig, killProcessTree } from "@oh-my-pi/pi-coding-agent/utils/shell"; -import { getOrCreateSnapshot } from "@oh-my-pi/pi-coding-agent/utils/shell-snapshot"; -import { htmlToBasicMarkdown } from "@oh-my-pi/pi-coding-agent/web/scrapers/types"; import { logger } from "@oh-my-pi/pi-utils"; import { $, type Subprocess } from "bun"; import { nanoid } from "nanoid"; +import { getShellConfig, killProcessTree } from "../utils/shell"; +import { getOrCreateSnapshot } from "../utils/shell-snapshot"; +import { htmlToBasicMarkdown } from "../web/scrapers/types"; import { acquireSharedGateway, releaseSharedGateway } from "./gateway-coordinator"; import { loadPythonModules } from "./modules"; import { PYTHON_PRELUDE } from "./prelude"; diff --git a/packages/coding-agent/src/lsp/client.ts b/packages/coding-agent/src/lsp/client.ts index 673327048..78d4c958d 100644 --- a/packages/coding-agent/src/lsp/client.ts +++ b/packages/coding-agent/src/lsp/client.ts @@ -1,6 +1,6 @@ import * as fs from "node:fs"; -import { ToolAbortError, throwIfAborted } from "@oh-my-pi/pi-coding-agent/tools/tool-errors"; import { logger } from "@oh-my-pi/pi-utils"; +import { ToolAbortError, throwIfAborted } from "../tools/tool-errors"; import { applyWorkspaceEdit } from "./edits"; import { getLspmuxCommand, isLspmuxSupported } from "./lspmux"; import type { diff --git a/packages/coding-agent/src/lsp/clients/biome-client.ts b/packages/coding-agent/src/lsp/clients/biome-client.ts index bb5dc8dbe..549017901 100644 --- a/packages/coding-agent/src/lsp/clients/biome-client.ts +++ b/packages/coding-agent/src/lsp/clients/biome-client.ts @@ -4,7 +4,7 @@ */ import path from "node:path"; -import type { Diagnostic, DiagnosticSeverity, LinterClient, ServerConfig } from "@oh-my-pi/pi-coding-agent/lsp/types"; +import type { Diagnostic, DiagnosticSeverity, LinterClient, ServerConfig } from "../../lsp/types"; // ============================================================================= // Biome JSON Output Types diff --git a/packages/coding-agent/src/lsp/clients/index.ts b/packages/coding-agent/src/lsp/clients/index.ts index 020f962a6..bc1bfce3e 100644 --- a/packages/coding-agent/src/lsp/clients/index.ts +++ b/packages/coding-agent/src/lsp/clients/index.ts @@ -8,7 +8,7 @@ export { BiomeClient } from "./biome-client"; export { LspLinterClient } from "./lsp-linter-client"; -import type { LinterClient, ServerConfig } from "@oh-my-pi/pi-coding-agent/lsp/types"; +import type { LinterClient, ServerConfig } from "../../lsp/types"; import { LspLinterClient } from "./lsp-linter-client"; // Cache of linter clients by server name + cwd diff --git a/packages/coding-agent/src/lsp/clients/lsp-linter-client.ts b/packages/coding-agent/src/lsp/clients/lsp-linter-client.ts index aaaa8576a..3ff5b7fb3 100644 --- a/packages/coding-agent/src/lsp/clients/lsp-linter-client.ts +++ b/packages/coding-agent/src/lsp/clients/lsp-linter-client.ts @@ -3,10 +3,10 @@ * Uses the Language Server Protocol for formatting and diagnostics. */ -import { getOrCreateClient, notifySaved, sendRequest, syncContent } from "@oh-my-pi/pi-coding-agent/lsp/client"; -import { applyTextEditsToString } from "@oh-my-pi/pi-coding-agent/lsp/edits"; -import type { Diagnostic, LinterClient, LspClient, ServerConfig, TextEdit } from "@oh-my-pi/pi-coding-agent/lsp/types"; -import { fileToUri } from "@oh-my-pi/pi-coding-agent/lsp/utils"; +import { getOrCreateClient, notifySaved, sendRequest, syncContent } from "../../lsp/client"; +import { applyTextEditsToString } from "../../lsp/edits"; +import type { Diagnostic, LinterClient, LspClient, ServerConfig, TextEdit } from "../../lsp/types"; +import { fileToUri } from "../../lsp/utils"; /** Default formatting options for LSP */ const DEFAULT_FORMAT_OPTIONS = { diff --git a/packages/coding-agent/src/lsp/config.ts b/packages/coding-agent/src/lsp/config.ts index 67dbffaec..2a9f957f5 100644 --- a/packages/coding-agent/src/lsp/config.ts +++ b/packages/coding-agent/src/lsp/config.ts @@ -1,9 +1,9 @@ import { homedir } from "node:os"; import { basename, extname, join } from "node:path"; -import { getConfigDirPaths } from "@oh-my-pi/pi-coding-agent/config"; import { logger } from "@oh-my-pi/pi-utils"; import { YAML } from "bun"; import { globSync } from "glob"; +import { getConfigDirPaths } from "../config"; import { BiomeClient } from "./clients/biome-client"; import DEFAULTS from "./defaults.json" with { type: "json" }; import type { ServerConfig } from "./types"; diff --git a/packages/coding-agent/src/lsp/index.ts b/packages/coding-agent/src/lsp/index.ts index 9b15dd230..379249e19 100644 --- a/packages/coding-agent/src/lsp/index.ts +++ b/packages/coding-agent/src/lsp/index.ts @@ -2,14 +2,14 @@ import type { Dirent } from "node:fs"; import { existsSync, statSync } from "node:fs"; import path from "node:path"; import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import { type Theme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import lspDescription from "@oh-my-pi/pi-coding-agent/prompts/tools/lsp.md" with { type: "text" }; -import type { ToolSession } from "@oh-my-pi/pi-coding-agent/tools"; -import { resolveToCwd } from "@oh-my-pi/pi-coding-agent/tools/path-utils"; -import { throwIfAborted } from "@oh-my-pi/pi-coding-agent/tools/tool-errors"; import { logger, once, untilAborted } from "@oh-my-pi/pi-utils"; import type { BunFile } from "bun"; +import { renderPromptTemplate } from "../config/prompt-templates"; +import { type Theme, theme } from "../modes/theme/theme"; +import lspDescription from "../prompts/tools/lsp.md" with { type: "text" }; +import type { ToolSession } from "../tools"; +import { resolveToCwd } from "../tools/path-utils"; +import { throwIfAborted } from "../tools/tool-errors"; import { ensureFileOpen, getActiveClients, diff --git a/packages/coding-agent/src/lsp/render.ts b/packages/coding-agent/src/lsp/render.ts index c8b6eb117..6b8ce1cc4 100644 --- a/packages/coding-agent/src/lsp/render.ts +++ b/packages/coding-agent/src/lsp/render.ts @@ -9,16 +9,11 @@ */ import type { AgentToolResult, RenderResultOptions } from "@oh-my-pi/pi-agent-core"; -import { getLanguageFromPath, type Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import { - formatExpandHint, - formatMoreItems, - TRUNCATE_LENGTHS, - truncate, -} from "@oh-my-pi/pi-coding-agent/tools/render-utils"; -import { renderOutputBlock, renderStatusLine } from "@oh-my-pi/pi-coding-agent/tui"; import { type Component, Text } from "@oh-my-pi/pi-tui"; import { highlight, supportsLanguage } from "cli-highlight"; +import { getLanguageFromPath, type Theme } from "../modes/theme/theme"; +import { formatExpandHint, formatMoreItems, TRUNCATE_LENGTHS, truncate } from "../tools/render-utils"; +import { renderOutputBlock, renderStatusLine } from "../tui"; import type { LspParams, LspToolDetails } from "./types"; // ============================================================================= diff --git a/packages/coding-agent/src/lsp/utils.ts b/packages/coding-agent/src/lsp/utils.ts index af9d3e080..6e45c2ff0 100644 --- a/packages/coding-agent/src/lsp/utils.ts +++ b/packages/coding-agent/src/lsp/utils.ts @@ -1,5 +1,5 @@ import path from "node:path"; -import { type Theme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; +import { type Theme, theme } from "../modes/theme/theme"; import type { Diagnostic, DiagnosticSeverity, diff --git a/packages/coding-agent/src/main.ts b/packages/coding-agent/src/main.ts index 1ea3d06ad..9d0572167 100644 --- a/packages/coding-agent/src/main.ts +++ b/packages/coding-agent/src/main.ts @@ -9,7 +9,6 @@ import { homedir, tmpdir } from "node:os"; import { join, resolve } from "node:path"; import { createInterface } from "node:readline/promises"; import { type ImageContent, supportsXhigh } from "@oh-my-pi/pi-ai"; -import { initTheme, stopThemeWatcher } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { postmortem } from "@oh-my-pi/pi-utils"; import chalk from "chalk"; import { type Args, parseArgs, printHelp } from "./cli/args"; @@ -32,6 +31,7 @@ import { exportFromFile } from "./export/html"; import type { ExtensionUIContext } from "./extensibility/extensions/types"; import { runMigrations, showDeprecationWarnings } from "./migrations"; import { InteractiveMode, runPrintMode, runRpcMode } from "./modes"; +import { initTheme, stopThemeWatcher } from "./modes/theme/theme"; import { type CreateAgentSessionOptions, createAgentSession, discoverAuthStorage, discoverModels } from "./sdk"; import type { AgentSession } from "./session/agent-session"; import { type SessionInfo, SessionManager } from "./session/session-manager"; diff --git a/packages/coding-agent/src/mcp/config.ts b/packages/coding-agent/src/mcp/config.ts index 0199a53ee..f78844879 100644 --- a/packages/coding-agent/src/mcp/config.ts +++ b/packages/coding-agent/src/mcp/config.ts @@ -4,9 +4,9 @@ * Uses the capability system to load MCP servers from multiple sources. */ -import { mcpCapability } from "@oh-my-pi/pi-coding-agent/capability/mcp"; -import type { MCPServer } from "@oh-my-pi/pi-coding-agent/discovery"; -import { loadCapability } from "@oh-my-pi/pi-coding-agent/discovery"; +import { mcpCapability } from "../capability/mcp"; +import type { MCPServer } from "../discovery"; +import { loadCapability } from "../discovery"; import type { MCPServerConfig } from "./types"; /** Options for loading MCP configs */ diff --git a/packages/coding-agent/src/mcp/loader.ts b/packages/coding-agent/src/mcp/loader.ts index 60f164391..de5df5e12 100644 --- a/packages/coding-agent/src/mcp/loader.ts +++ b/packages/coding-agent/src/mcp/loader.ts @@ -4,9 +4,9 @@ * Integrates MCP tool discovery with the custom tools system. */ -import type { LoadedCustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import { AgentStorage } from "@oh-my-pi/pi-coding-agent/session/agent-storage"; import { logger } from "@oh-my-pi/pi-utils"; +import type { LoadedCustomTool } from "../extensibility/custom-tools/types"; +import { AgentStorage } from "../session/agent-storage"; import { type MCPLoadResult, MCPManager } from "./manager"; import { MCPToolCache } from "./tool-cache"; diff --git a/packages/coding-agent/src/mcp/manager.ts b/packages/coding-agent/src/mcp/manager.ts index 22326a2da..777d78e00 100644 --- a/packages/coding-agent/src/mcp/manager.ts +++ b/packages/coding-agent/src/mcp/manager.ts @@ -5,9 +5,9 @@ * Handles tool loading and lifecycle. */ -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; import { logger } from "@oh-my-pi/pi-utils"; import type { TSchema } from "@sinclair/typebox"; +import type { CustomTool } from "../extensibility/custom-tools/types"; import { connectToServer, disconnectServer, listTools } from "./client"; import { loadAllMCPConfigs, validateServerConfig } from "./config"; import type { MCPToolDetails } from "./tool-bridge"; diff --git a/packages/coding-agent/src/mcp/tool-bridge.ts b/packages/coding-agent/src/mcp/tool-bridge.ts index 6b6e9bc75..14d67532b 100644 --- a/packages/coding-agent/src/mcp/tool-bridge.ts +++ b/packages/coding-agent/src/mcp/tool-bridge.ts @@ -5,13 +5,9 @@ */ import type { AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; -import type { SourceMeta } from "@oh-my-pi/pi-coding-agent/capability/types"; -import type { - CustomTool, - CustomToolContext, - CustomToolResult, -} from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; import type { TSchema } from "@sinclair/typebox"; +import type { SourceMeta } from "../capability/types"; +import type { CustomTool, CustomToolContext, CustomToolResult } from "../extensibility/custom-tools/types"; import { callTool } from "./client"; import type { MCPContent, MCPServerConnection, MCPToolDefinition } from "./types"; diff --git a/packages/coding-agent/src/mcp/tool-cache.ts b/packages/coding-agent/src/mcp/tool-cache.ts index 094d11878..bc10fdb1b 100644 --- a/packages/coding-agent/src/mcp/tool-cache.ts +++ b/packages/coding-agent/src/mcp/tool-cache.ts @@ -4,8 +4,8 @@ * Stores tool definitions per server in agent.db for fast startup. */ -import type { AgentStorage } from "@oh-my-pi/pi-coding-agent/session/agent-storage"; import { logger } from "@oh-my-pi/pi-utils"; +import type { AgentStorage } from "../session/agent-storage"; import type { MCPServerConfig, MCPToolDefinition } from "./types"; const CACHE_VERSION = 1; diff --git a/packages/coding-agent/src/mcp/transports/http.ts b/packages/coding-agent/src/mcp/transports/http.ts index b14732cc9..79d9a02b3 100644 --- a/packages/coding-agent/src/mcp/transports/http.ts +++ b/packages/coding-agent/src/mcp/transports/http.ts @@ -11,7 +11,7 @@ import type { MCPHttpServerConfig, MCPSseServerConfig, MCPTransport, -} from "@oh-my-pi/pi-coding-agent/mcp/types"; +} from "../../mcp/types"; /** Generate unique request ID */ function generateId(): string { diff --git a/packages/coding-agent/src/mcp/transports/stdio.ts b/packages/coding-agent/src/mcp/transports/stdio.ts index df28d0b25..bfbedc453 100644 --- a/packages/coding-agent/src/mcp/transports/stdio.ts +++ b/packages/coding-agent/src/mcp/transports/stdio.ts @@ -5,8 +5,8 @@ * Messages are newline-delimited JSON. */ -import type { JsonRpcResponse, MCPStdioServerConfig, MCPTransport } from "@oh-my-pi/pi-coding-agent/mcp/types"; import { type Subprocess, spawn } from "bun"; +import type { JsonRpcResponse, MCPStdioServerConfig, MCPTransport } from "../../mcp/types"; /** Generate unique request ID */ function generateId(): string { diff --git a/packages/coding-agent/src/migrations.ts b/packages/coding-agent/src/migrations.ts index 0b3a8e5cf..e63bb6137 100644 --- a/packages/coding-agent/src/migrations.ts +++ b/packages/coding-agent/src/migrations.ts @@ -4,11 +4,11 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs"; import { join } from "node:path"; -import { AgentStorage } from "@oh-my-pi/pi-coding-agent/session/agent-storage"; -import type { AuthCredential } from "@oh-my-pi/pi-coding-agent/session/auth-storage"; import { logger } from "@oh-my-pi/pi-utils"; import chalk from "chalk"; import { getAgentDbPath, getAgentDir, getBinDir } from "./config"; +import { AgentStorage } from "./session/agent-storage"; +import type { AuthCredential } from "./session/auth-storage"; /** * Migrate legacy oauth.json and settings.json apiKeys to agent.db. diff --git a/packages/coding-agent/src/modes/components/armin.ts b/packages/coding-agent/src/modes/components/armin.ts index 2a0d72403..b379e591a 100644 --- a/packages/coding-agent/src/modes/components/armin.ts +++ b/packages/coding-agent/src/modes/components/armin.ts @@ -2,8 +2,8 @@ * Armin says hi! A fun easter egg with animated XBM art. */ -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import type { Component, TUI } from "@oh-my-pi/pi-tui"; +import { theme } from "../../modes/theme/theme"; // XBM image: 31x36 pixels, LSB first, 1=background, 0=foreground const WIDTH = 31; diff --git a/packages/coding-agent/src/modes/components/assistant-message.ts b/packages/coding-agent/src/modes/components/assistant-message.ts index 8e83cc5eb..6bcfb1ad2 100644 --- a/packages/coding-agent/src/modes/components/assistant-message.ts +++ b/packages/coding-agent/src/modes/components/assistant-message.ts @@ -1,7 +1,7 @@ import type { AssistantMessage } from "@oh-my-pi/pi-ai"; -import { hasPendingMermaid, prerenderMermaid } from "@oh-my-pi/pi-coding-agent/modes/theme/mermaid-cache"; -import { getMarkdownTheme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { Container, getCapabilities, Markdown, Spacer, Text } from "@oh-my-pi/pi-tui"; +import { hasPendingMermaid, prerenderMermaid } from "../../modes/theme/mermaid-cache"; +import { getMarkdownTheme, theme } from "../../modes/theme/theme"; /** * Component that renders a complete assistant message diff --git a/packages/coding-agent/src/modes/components/bash-execution.ts b/packages/coding-agent/src/modes/components/bash-execution.ts index c1ffd30bf..5ce8a3709 100644 --- a/packages/coding-agent/src/modes/components/bash-execution.ts +++ b/packages/coding-agent/src/modes/components/bash-execution.ts @@ -2,11 +2,11 @@ * Component for displaying bash command execution with streaming output. */ -import { getSymbolTheme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { TruncationMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; -import { formatSize } from "@oh-my-pi/pi-coding-agent/tools/truncate"; import { Container, Loader, Spacer, Text, type TUI } from "@oh-my-pi/pi-tui"; import stripAnsi from "strip-ansi"; +import { getSymbolTheme, theme } from "../../modes/theme/theme"; +import type { TruncationMeta } from "../../tools/output-meta"; +import { formatSize } from "../../tools/truncate"; import { DynamicBorder } from "./dynamic-border"; import { truncateToVisualLines } from "./visual-truncate"; diff --git a/packages/coding-agent/src/modes/components/bordered-loader.ts b/packages/coding-agent/src/modes/components/bordered-loader.ts index 8434de2c5..db28ef800 100644 --- a/packages/coding-agent/src/modes/components/bordered-loader.ts +++ b/packages/coding-agent/src/modes/components/bordered-loader.ts @@ -1,5 +1,5 @@ -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { CancellableLoader, Container, Spacer, Text, type TUI } from "@oh-my-pi/pi-tui"; +import type { Theme } from "../../modes/theme/theme"; import { DynamicBorder } from "./dynamic-border"; /** Loader wrapped with borders for hook UI */ diff --git a/packages/coding-agent/src/modes/components/branch-summary-message.ts b/packages/coding-agent/src/modes/components/branch-summary-message.ts index 3a5ffb580..e9666593a 100644 --- a/packages/coding-agent/src/modes/components/branch-summary-message.ts +++ b/packages/coding-agent/src/modes/components/branch-summary-message.ts @@ -1,6 +1,6 @@ -import { getMarkdownTheme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { BranchSummaryMessage } from "@oh-my-pi/pi-coding-agent/session/messages"; import { Box, Markdown, Spacer, Text } from "@oh-my-pi/pi-tui"; +import { getMarkdownTheme, theme } from "../../modes/theme/theme"; +import type { BranchSummaryMessage } from "../../session/messages"; /** * Component that renders a branch summary message with collapsed/expanded state. diff --git a/packages/coding-agent/src/modes/components/compaction-summary-message.ts b/packages/coding-agent/src/modes/components/compaction-summary-message.ts index ea13a97c6..532d16fba 100644 --- a/packages/coding-agent/src/modes/components/compaction-summary-message.ts +++ b/packages/coding-agent/src/modes/components/compaction-summary-message.ts @@ -1,6 +1,6 @@ -import { getMarkdownTheme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { CompactionSummaryMessage } from "@oh-my-pi/pi-coding-agent/session/messages"; import { Box, Markdown, Spacer, Text } from "@oh-my-pi/pi-tui"; +import { getMarkdownTheme, theme } from "../../modes/theme/theme"; +import type { CompactionSummaryMessage } from "../../session/messages"; /** * Component that renders a compaction message with collapsed/expanded state. diff --git a/packages/coding-agent/src/modes/components/custom-message.ts b/packages/coding-agent/src/modes/components/custom-message.ts index d3f1455e3..2d5dbbd19 100644 --- a/packages/coding-agent/src/modes/components/custom-message.ts +++ b/packages/coding-agent/src/modes/components/custom-message.ts @@ -1,9 +1,9 @@ import type { TextContent } from "@oh-my-pi/pi-ai"; -import type { MessageRenderer } from "@oh-my-pi/pi-coding-agent/extensibility/extensions/types"; -import { getMarkdownTheme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { CustomMessage } from "@oh-my-pi/pi-coding-agent/session/messages"; import type { Component } from "@oh-my-pi/pi-tui"; import { Box, Container, Markdown, Spacer, Text } from "@oh-my-pi/pi-tui"; +import type { MessageRenderer } from "../../extensibility/extensions/types"; +import { getMarkdownTheme, theme } from "../../modes/theme/theme"; +import type { CustomMessage } from "../../session/messages"; /** * Component that renders a custom message entry from extensions. diff --git a/packages/coding-agent/src/modes/components/diff.ts b/packages/coding-agent/src/modes/components/diff.ts index 8ceeafd93..6285b53af 100644 --- a/packages/coding-agent/src/modes/components/diff.ts +++ b/packages/coding-agent/src/modes/components/diff.ts @@ -1,5 +1,5 @@ -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import * as Diff from "diff"; +import { theme } from "../../modes/theme/theme"; /** * Parse diff line to extract prefix, line number, and content. diff --git a/packages/coding-agent/src/modes/components/dynamic-border.ts b/packages/coding-agent/src/modes/components/dynamic-border.ts index fe480e8f6..c3efb3806 100644 --- a/packages/coding-agent/src/modes/components/dynamic-border.ts +++ b/packages/coding-agent/src/modes/components/dynamic-border.ts @@ -1,5 +1,5 @@ -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import type { Component } from "@oh-my-pi/pi-tui"; +import { theme } from "../../modes/theme/theme"; /** * Dynamic border component that adjusts to viewport width. diff --git a/packages/coding-agent/src/modes/components/extensions/extension-dashboard.ts b/packages/coding-agent/src/modes/components/extensions/extension-dashboard.ts index 99298852b..043625c34 100644 --- a/packages/coding-agent/src/modes/components/extensions/extension-dashboard.ts +++ b/packages/coding-agent/src/modes/components/extensions/extension-dashboard.ts @@ -12,10 +12,10 @@ * - Esc: Close dashboard (clears search first if active) */ -import type { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import { DynamicBorder } from "@oh-my-pi/pi-coding-agent/modes/components/dynamic-border"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { type Component, Container, matchesKey, Spacer, Text, truncateToWidth, visibleWidth } from "@oh-my-pi/pi-tui"; +import type { SettingsManager } from "../../../config/settings-manager"; +import { DynamicBorder } from "../../../modes/components/dynamic-border"; +import { theme } from "../../../modes/theme/theme"; import { ExtensionList } from "./extension-list"; import { InspectorPanel } from "./inspector-panel"; import { applyFilter, createInitialState, filterByProvider, refreshState, toggleProvider } from "./state-manager"; diff --git a/packages/coding-agent/src/modes/components/extensions/extension-list.ts b/packages/coding-agent/src/modes/components/extensions/extension-list.ts index 05b2a1cbd..60ce9969e 100644 --- a/packages/coding-agent/src/modes/components/extensions/extension-list.ts +++ b/packages/coding-agent/src/modes/components/extensions/extension-list.ts @@ -6,9 +6,9 @@ * master switch is off. */ -import { isProviderEnabled } from "@oh-my-pi/pi-coding-agent/discovery"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { type Component, matchesKey, truncateToWidth, visibleWidth } from "@oh-my-pi/pi-tui"; +import { isProviderEnabled } from "../../../discovery"; +import { theme } from "../../../modes/theme/theme"; import { applyFilter } from "./state-manager"; import type { Extension, ExtensionKind, ExtensionState } from "./types"; diff --git a/packages/coding-agent/src/modes/components/extensions/inspector-panel.ts b/packages/coding-agent/src/modes/components/extensions/inspector-panel.ts index 1b6562937..f320fb8bc 100644 --- a/packages/coding-agent/src/modes/components/extensions/inspector-panel.ts +++ b/packages/coding-agent/src/modes/components/extensions/inspector-panel.ts @@ -5,8 +5,8 @@ */ import { homedir } from "node:os"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { type Component, truncateToWidth, wrapTextWithAnsi } from "@oh-my-pi/pi-tui"; +import { theme } from "../../../modes/theme/theme"; import type { Extension, ExtensionState } from "./types"; export class InspectorPanel implements Component { diff --git a/packages/coding-agent/src/modes/components/extensions/state-manager.ts b/packages/coding-agent/src/modes/components/extensions/state-manager.ts index 0fc1b04db..8b739f73b 100644 --- a/packages/coding-agent/src/modes/components/extensions/state-manager.ts +++ b/packages/coding-agent/src/modes/components/extensions/state-manager.ts @@ -3,24 +3,24 @@ * Handles data loading, tree building, filtering, and toggle persistence. */ -import type { ContextFile } from "@oh-my-pi/pi-coding-agent/capability/context-file"; -import type { ExtensionModule } from "@oh-my-pi/pi-coding-agent/capability/extension-module"; -import type { Hook } from "@oh-my-pi/pi-coding-agent/capability/hook"; -import type { MCPServer } from "@oh-my-pi/pi-coding-agent/capability/mcp"; -import type { Prompt } from "@oh-my-pi/pi-coding-agent/capability/prompt"; -import type { Rule } from "@oh-my-pi/pi-coding-agent/capability/rule"; -import type { Skill } from "@oh-my-pi/pi-coding-agent/capability/skill"; -import type { SlashCommand } from "@oh-my-pi/pi-coding-agent/capability/slash-command"; -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/capability/tool"; -import type { SourceMeta } from "@oh-my-pi/pi-coding-agent/capability/types"; +import { logger } from "@oh-my-pi/pi-utils"; +import type { ContextFile } from "../../../capability/context-file"; +import type { ExtensionModule } from "../../../capability/extension-module"; +import type { Hook } from "../../../capability/hook"; +import type { MCPServer } from "../../../capability/mcp"; +import type { Prompt } from "../../../capability/prompt"; +import type { Rule } from "../../../capability/rule"; +import type { Skill } from "../../../capability/skill"; +import type { SlashCommand } from "../../../capability/slash-command"; +import type { CustomTool } from "../../../capability/tool"; +import type { SourceMeta } from "../../../capability/types"; import { disableProvider, enableProvider, getAllProvidersInfo, isProviderEnabled, loadCapability, -} from "@oh-my-pi/pi-coding-agent/discovery"; -import { logger } from "@oh-my-pi/pi-utils"; +} from "../../../discovery"; import type { DashboardState, Extension, diff --git a/packages/coding-agent/src/modes/components/extensions/types.ts b/packages/coding-agent/src/modes/components/extensions/types.ts index f2a872ce5..32db236a5 100644 --- a/packages/coding-agent/src/modes/components/extensions/types.ts +++ b/packages/coding-agent/src/modes/components/extensions/types.ts @@ -2,7 +2,7 @@ * Types for the Extension Control Center dashboard. */ -import type { SourceMeta } from "@oh-my-pi/pi-coding-agent/capability/types"; +import type { SourceMeta } from "../../../capability/types"; /** * Extension kinds matching capability types. diff --git a/packages/coding-agent/src/modes/components/footer.ts b/packages/coding-agent/src/modes/components/footer.ts index 10688835f..81801cb27 100644 --- a/packages/coding-agent/src/modes/components/footer.ts +++ b/packages/coding-agent/src/modes/components/footer.ts @@ -1,10 +1,10 @@ import { existsSync, type FSWatcher, readFileSync, watch } from "node:fs"; import type { AssistantMessage } from "@oh-my-pi/pi-ai"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { AgentSession } from "@oh-my-pi/pi-coding-agent/session/agent-session"; -import { shortenPath } from "@oh-my-pi/pi-coding-agent/tools/render-utils"; import { type Component, truncateToWidth, visibleWidth } from "@oh-my-pi/pi-tui"; import { dirname, join } from "path"; +import { theme } from "../../modes/theme/theme"; +import type { AgentSession } from "../../session/agent-session"; +import { shortenPath } from "../../tools/render-utils"; /** * Sanitize text for display in a single-line status. diff --git a/packages/coding-agent/src/modes/components/history-search.ts b/packages/coding-agent/src/modes/components/history-search.ts index 4220584d7..2c18778b5 100644 --- a/packages/coding-agent/src/modes/components/history-search.ts +++ b/packages/coding-agent/src/modes/components/history-search.ts @@ -1,5 +1,3 @@ -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { HistoryEntry, HistoryStorage } from "@oh-my-pi/pi-coding-agent/session/history-storage"; import { type Component, Container, @@ -10,6 +8,8 @@ import { truncateToWidth, visibleWidth, } from "@oh-my-pi/pi-tui"; +import { theme } from "../../modes/theme/theme"; +import type { HistoryEntry, HistoryStorage } from "../../session/history-storage"; import { DynamicBorder } from "./dynamic-border"; class HistoryResultsList implements Component { diff --git a/packages/coding-agent/src/modes/components/hook-editor.ts b/packages/coding-agent/src/modes/components/hook-editor.ts index be0464546..0f0c9d100 100644 --- a/packages/coding-agent/src/modes/components/hook-editor.ts +++ b/packages/coding-agent/src/modes/components/hook-editor.ts @@ -6,9 +6,9 @@ import { rm } from "node:fs/promises"; import * as os from "node:os"; import * as path from "node:path"; -import { getEditorTheme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { Container, Editor, matchesKey, Spacer, Text, type TUI } from "@oh-my-pi/pi-tui"; import { nanoid } from "nanoid"; +import { getEditorTheme, theme } from "../../modes/theme/theme"; import { DynamicBorder } from "./dynamic-border"; export class HookEditorComponent extends Container { diff --git a/packages/coding-agent/src/modes/components/hook-input.ts b/packages/coding-agent/src/modes/components/hook-input.ts index a5d1573ca..50280a8c9 100644 --- a/packages/coding-agent/src/modes/components/hook-input.ts +++ b/packages/coding-agent/src/modes/components/hook-input.ts @@ -2,8 +2,8 @@ * Simple text input component for hooks. */ -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { Container, Input, matchesKey, Spacer, Text, type TUI } from "@oh-my-pi/pi-tui"; +import { theme } from "../../modes/theme/theme"; import { CountdownTimer } from "./countdown-timer"; import { DynamicBorder } from "./dynamic-border"; diff --git a/packages/coding-agent/src/modes/components/hook-message.ts b/packages/coding-agent/src/modes/components/hook-message.ts index 1514cdc76..7311b177a 100644 --- a/packages/coding-agent/src/modes/components/hook-message.ts +++ b/packages/coding-agent/src/modes/components/hook-message.ts @@ -1,9 +1,9 @@ import type { TextContent } from "@oh-my-pi/pi-ai"; -import type { HookMessageRenderer } from "@oh-my-pi/pi-coding-agent/extensibility/hooks/types"; -import { getMarkdownTheme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { HookMessage } from "@oh-my-pi/pi-coding-agent/session/messages"; import type { Component } from "@oh-my-pi/pi-tui"; import { Box, Container, Markdown, Spacer, Text } from "@oh-my-pi/pi-tui"; +import type { HookMessageRenderer } from "../../extensibility/hooks/types"; +import { getMarkdownTheme, theme } from "../../modes/theme/theme"; +import type { HookMessage } from "../../session/messages"; /** * Component that renders a custom message entry from hooks. diff --git a/packages/coding-agent/src/modes/components/hook-selector.ts b/packages/coding-agent/src/modes/components/hook-selector.ts index b8e7ff3ab..98ecf2afb 100644 --- a/packages/coding-agent/src/modes/components/hook-selector.ts +++ b/packages/coding-agent/src/modes/components/hook-selector.ts @@ -3,8 +3,8 @@ * Displays a list of string options with keyboard navigation. */ -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { Container, matchesKey, Spacer, Text, type TUI } from "@oh-my-pi/pi-tui"; +import { theme } from "../../modes/theme/theme"; import { CountdownTimer } from "./countdown-timer"; import { DynamicBorder } from "./dynamic-border"; diff --git a/packages/coding-agent/src/modes/components/keybinding-hints.ts b/packages/coding-agent/src/modes/components/keybinding-hints.ts index 4aba88e89..dfe287c7e 100644 --- a/packages/coding-agent/src/modes/components/keybinding-hints.ts +++ b/packages/coding-agent/src/modes/components/keybinding-hints.ts @@ -2,9 +2,9 @@ * Utilities for formatting keybinding hints in the UI. */ -import type { AppAction, KeybindingsManager } from "@oh-my-pi/pi-coding-agent/config/keybindings"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { type EditorAction, getEditorKeybindings, type KeyId } from "@oh-my-pi/pi-tui"; +import type { AppAction, KeybindingsManager } from "../../config/keybindings"; +import { theme } from "../../modes/theme/theme"; /** * Format keys array as display string (e.g., ["ctrl+c", "escape"] -> "ctrl+c/escape"). diff --git a/packages/coding-agent/src/modes/components/login-dialog.ts b/packages/coding-agent/src/modes/components/login-dialog.ts index dfcbaad39..726ce7065 100644 --- a/packages/coding-agent/src/modes/components/login-dialog.ts +++ b/packages/coding-agent/src/modes/components/login-dialog.ts @@ -1,7 +1,7 @@ import { getOAuthProviders } from "@oh-my-pi/pi-ai"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { Container, getEditorKeybindings, Input, Spacer, Text, type TUI } from "@oh-my-pi/pi-tui"; import { $ } from "bun"; +import { theme } from "../../modes/theme/theme"; import { DynamicBorder } from "./dynamic-border"; /** diff --git a/packages/coding-agent/src/modes/components/model-selector.ts b/packages/coding-agent/src/modes/components/model-selector.ts index 6503b272c..f531c6747 100644 --- a/packages/coding-agent/src/modes/components/model-selector.ts +++ b/packages/coding-agent/src/modes/components/model-selector.ts @@ -1,9 +1,4 @@ import { type Model, modelsAreEqual } from "@oh-my-pi/pi-ai"; -import type { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry"; -import { parseModelString } from "@oh-my-pi/pi-coding-agent/config/model-resolver"; -import type { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import { type ThemeColor, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import { fuzzyFilter } from "@oh-my-pi/pi-coding-agent/utils/fuzzy"; import { Container, Input, @@ -16,6 +11,11 @@ import { type TUI, visibleWidth, } from "@oh-my-pi/pi-tui"; +import type { ModelRegistry } from "../../config/model-registry"; +import { parseModelString } from "../../config/model-resolver"; +import type { SettingsManager } from "../../config/settings-manager"; +import { type ThemeColor, theme } from "../../modes/theme/theme"; +import { fuzzyFilter } from "../../utils/fuzzy"; import { DynamicBorder } from "./dynamic-border"; function makeInvertedBadge(label: string, color: ThemeColor): string { diff --git a/packages/coding-agent/src/modes/components/oauth-selector.ts b/packages/coding-agent/src/modes/components/oauth-selector.ts index ac23ecf50..afa6063a9 100644 --- a/packages/coding-agent/src/modes/components/oauth-selector.ts +++ b/packages/coding-agent/src/modes/components/oauth-selector.ts @@ -1,7 +1,7 @@ import { getOAuthProviders, type OAuthProviderInfo } from "@oh-my-pi/pi-ai"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { AuthStorage } from "@oh-my-pi/pi-coding-agent/session/auth-storage"; import { Container, matchesKey, Spacer, TruncatedText } from "@oh-my-pi/pi-tui"; +import { theme } from "../../modes/theme/theme"; +import type { AuthStorage } from "../../session/auth-storage"; import { DynamicBorder } from "./dynamic-border"; /** diff --git a/packages/coding-agent/src/modes/components/plugin-settings.ts b/packages/coding-agent/src/modes/components/plugin-settings.ts index e64cb264d..f0c8597fe 100644 --- a/packages/coding-agent/src/modes/components/plugin-settings.ts +++ b/packages/coding-agent/src/modes/components/plugin-settings.ts @@ -8,9 +8,6 @@ * - Config value editor */ -import { PluginManager } from "@oh-my-pi/pi-coding-agent/extensibility/plugins/manager"; -import type { InstalledPlugin, PluginSettingSchema } from "@oh-my-pi/pi-coding-agent/extensibility/plugins/types"; -import { getSelectListTheme, getSettingsListTheme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { Container, Input, @@ -21,6 +18,9 @@ import { Spacer, Text, } from "@oh-my-pi/pi-tui"; +import { PluginManager } from "../../extensibility/plugins/manager"; +import type { InstalledPlugin, PluginSettingSchema } from "../../extensibility/plugins/types"; +import { getSelectListTheme, getSettingsListTheme, theme } from "../../modes/theme/theme"; import { DynamicBorder } from "./dynamic-border"; // ============================================================================= diff --git a/packages/coding-agent/src/modes/components/python-execution.ts b/packages/coding-agent/src/modes/components/python-execution.ts index d7c7fac90..697f2b280 100644 --- a/packages/coding-agent/src/modes/components/python-execution.ts +++ b/packages/coding-agent/src/modes/components/python-execution.ts @@ -3,11 +3,11 @@ * Shares the same kernel session as the agent's Python tool. */ -import { getSymbolTheme, highlightCode, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { TruncationMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; -import { formatSize } from "@oh-my-pi/pi-coding-agent/tools/truncate"; import { Container, Loader, Spacer, Text, type TUI } from "@oh-my-pi/pi-tui"; import stripAnsi from "strip-ansi"; +import { getSymbolTheme, highlightCode, theme } from "../../modes/theme/theme"; +import type { TruncationMeta } from "../../tools/output-meta"; +import { formatSize } from "../../tools/truncate"; import { DynamicBorder } from "./dynamic-border"; import { truncateToVisualLines } from "./visual-truncate"; diff --git a/packages/coding-agent/src/modes/components/queue-mode-selector.ts b/packages/coding-agent/src/modes/components/queue-mode-selector.ts index 08d31963b..00fd141de 100644 --- a/packages/coding-agent/src/modes/components/queue-mode-selector.ts +++ b/packages/coding-agent/src/modes/components/queue-mode-selector.ts @@ -1,5 +1,5 @@ -import { getSelectListTheme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { Container, type SelectItem, SelectList } from "@oh-my-pi/pi-tui"; +import { getSelectListTheme } from "../../modes/theme/theme"; import { DynamicBorder } from "./dynamic-border"; /** diff --git a/packages/coding-agent/src/modes/components/read-tool-group.ts b/packages/coding-agent/src/modes/components/read-tool-group.ts index 4d96641b6..31ec45f8a 100644 --- a/packages/coding-agent/src/modes/components/read-tool-group.ts +++ b/packages/coding-agent/src/modes/components/read-tool-group.ts @@ -1,7 +1,7 @@ -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import { shortenPath } from "@oh-my-pi/pi-coding-agent/tools/render-utils"; import type { Component } from "@oh-my-pi/pi-tui"; import { Container, Text } from "@oh-my-pi/pi-tui"; +import { theme } from "../../modes/theme/theme"; +import { shortenPath } from "../../tools/render-utils"; import type { ToolExecutionHandle } from "./tool-execution"; type ReadRenderArgs = { diff --git a/packages/coding-agent/src/modes/components/session-selector.ts b/packages/coding-agent/src/modes/components/session-selector.ts index 87e1a7666..c27ab4cf4 100644 --- a/packages/coding-agent/src/modes/components/session-selector.ts +++ b/packages/coding-agent/src/modes/components/session-selector.ts @@ -1,6 +1,3 @@ -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { SessionInfo } from "@oh-my-pi/pi-coding-agent/session/session-manager"; -import { fuzzyFilter } from "@oh-my-pi/pi-coding-agent/utils/fuzzy"; import { type Component, Container, @@ -11,6 +8,9 @@ import { truncateToWidth, visibleWidth, } from "@oh-my-pi/pi-tui"; +import { theme } from "../../modes/theme/theme"; +import type { SessionInfo } from "../../session/session-manager"; +import { fuzzyFilter } from "../../utils/fuzzy"; import { DynamicBorder } from "./dynamic-border"; /** diff --git a/packages/coding-agent/src/modes/components/settings-defs.ts b/packages/coding-agent/src/modes/components/settings-defs.ts index 238a78fdf..9b5bece22 100644 --- a/packages/coding-agent/src/modes/components/settings-defs.ts +++ b/packages/coding-agent/src/modes/components/settings-defs.ts @@ -9,6 +9,7 @@ */ import type { ThinkingLevel } from "@oh-my-pi/pi-agent-core"; +import { getCapabilities } from "@oh-my-pi/pi-tui"; import type { ImageProviderOption, NotificationMethod, @@ -19,8 +20,7 @@ import type { StatusLineSeparatorStyle, SymbolPreset, WebSearchProviderOption, -} from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import { getCapabilities } from "@oh-my-pi/pi-tui"; +} from "../../config/settings-manager"; import { getPreset } from "./status-line/presets"; // Setting value types diff --git a/packages/coding-agent/src/modes/components/settings-selector.ts b/packages/coding-agent/src/modes/components/settings-selector.ts index 68f98f805..f3a2c9dc0 100644 --- a/packages/coding-agent/src/modes/components/settings-selector.ts +++ b/packages/coding-agent/src/modes/components/settings-selector.ts @@ -1,6 +1,4 @@ import type { ThinkingLevel } from "@oh-my-pi/pi-agent-core"; -import type { SettingsManager, StatusLineSettings } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import { getSelectListTheme, getSettingsListTheme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { Container, matchesKey, @@ -14,6 +12,8 @@ import { type TabBarTheme, Text, } from "@oh-my-pi/pi-tui"; +import type { SettingsManager, StatusLineSettings } from "../../config/settings-manager"; +import { getSelectListTheme, getSettingsListTheme, theme } from "../../modes/theme/theme"; import { DynamicBorder } from "./dynamic-border"; import { PluginSettingsComponent } from "./plugin-settings"; import { getSettingsForTab, type SettingDef } from "./settings-defs"; diff --git a/packages/coding-agent/src/modes/components/show-images-selector.ts b/packages/coding-agent/src/modes/components/show-images-selector.ts index 8356918b1..05b3073f4 100644 --- a/packages/coding-agent/src/modes/components/show-images-selector.ts +++ b/packages/coding-agent/src/modes/components/show-images-selector.ts @@ -1,5 +1,5 @@ -import { getSelectListTheme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { Container, type SelectItem, SelectList } from "@oh-my-pi/pi-tui"; +import { getSelectListTheme } from "../../modes/theme/theme"; import { DynamicBorder } from "./dynamic-border"; /** diff --git a/packages/coding-agent/src/modes/components/status-line-segment-editor.ts b/packages/coding-agent/src/modes/components/status-line-segment-editor.ts index 55d91ef4d..3197baa1e 100644 --- a/packages/coding-agent/src/modes/components/status-line-segment-editor.ts +++ b/packages/coding-agent/src/modes/components/status-line-segment-editor.ts @@ -9,9 +9,9 @@ * - Live preview shown in the actual status line above */ -import type { StatusLineSegmentId } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { Container, matchesKey } from "@oh-my-pi/pi-tui"; +import type { StatusLineSegmentId } from "../../config/settings-manager"; +import { theme } from "../../modes/theme/theme"; import { ALL_SEGMENT_IDS } from "./status-line/segments"; // Segment display names and short descriptions diff --git a/packages/coding-agent/src/modes/components/status-line.ts b/packages/coding-agent/src/modes/components/status-line.ts index 21eebda72..0ea3204a0 100644 --- a/packages/coding-agent/src/modes/components/status-line.ts +++ b/packages/coding-agent/src/modes/components/status-line.ts @@ -1,11 +1,11 @@ import type { AssistantMessage } from "@oh-my-pi/pi-ai"; -import type { StatusLineSegmentOptions, StatusLineSettings } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { AgentSession } from "@oh-my-pi/pi-coding-agent/session/agent-session"; import { type Component, truncateToWidth, visibleWidth } from "@oh-my-pi/pi-tui"; import { $ } from "bun"; import { type FSWatcher, watch } from "fs"; import { dirname, join } from "path"; +import type { StatusLineSegmentOptions, StatusLineSettings } from "../../config/settings-manager"; +import { theme } from "../../modes/theme/theme"; +import type { AgentSession } from "../../session/agent-session"; import { getPreset } from "./status-line/presets"; import { renderSegment, type SegmentContext } from "./status-line/segments"; import { getSeparator } from "./status-line/separators"; diff --git a/packages/coding-agent/src/modes/components/status-line/segments.ts b/packages/coding-agent/src/modes/components/status-line/segments.ts index 36c1b7b0e..58db8afce 100644 --- a/packages/coding-agent/src/modes/components/status-line/segments.ts +++ b/packages/coding-agent/src/modes/components/status-line/segments.ts @@ -1,6 +1,6 @@ import { hostname as osHostname } from "node:os"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import { shortenPath } from "@oh-my-pi/pi-coding-agent/tools/render-utils"; +import { theme } from "../../../modes/theme/theme"; +import { shortenPath } from "../../../tools/render-utils"; import type { RenderedSegment, SegmentContext, StatusLineSegment, StatusLineSegmentId } from "./types"; export type { SegmentContext } from "./types"; diff --git a/packages/coding-agent/src/modes/components/status-line/separators.ts b/packages/coding-agent/src/modes/components/status-line/separators.ts index c227db015..160e00155 100644 --- a/packages/coding-agent/src/modes/components/status-line/separators.ts +++ b/packages/coding-agent/src/modes/components/status-line/separators.ts @@ -1,4 +1,4 @@ -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; +import type { Theme } from "../../../modes/theme/theme"; import type { SeparatorDef, StatusLineSeparatorStyle } from "./types"; function trimSep(value: string): string { diff --git a/packages/coding-agent/src/modes/components/status-line/types.ts b/packages/coding-agent/src/modes/components/status-line/types.ts index ca8e9ba5a..64742a464 100644 --- a/packages/coding-agent/src/modes/components/status-line/types.ts +++ b/packages/coding-agent/src/modes/components/status-line/types.ts @@ -4,8 +4,8 @@ import type { StatusLineSegmentOptions, StatusLineSeparatorStyle, StatusLineSettings, -} from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import type { AgentSession } from "@oh-my-pi/pi-coding-agent/session/agent-session"; +} from "../../../config/settings-manager"; +import type { AgentSession } from "../../../session/agent-session"; // Re-export types from settings-manager (single source of truth) export type { diff --git a/packages/coding-agent/src/modes/components/theme-selector.ts b/packages/coding-agent/src/modes/components/theme-selector.ts index 9bb9b9337..ab0231532 100644 --- a/packages/coding-agent/src/modes/components/theme-selector.ts +++ b/packages/coding-agent/src/modes/components/theme-selector.ts @@ -1,5 +1,5 @@ -import { getAvailableThemes, getSelectListTheme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { Container, type SelectItem, SelectList } from "@oh-my-pi/pi-tui"; +import { getAvailableThemes, getSelectListTheme } from "../../modes/theme/theme"; import { DynamicBorder } from "./dynamic-border"; /** diff --git a/packages/coding-agent/src/modes/components/thinking-selector.ts b/packages/coding-agent/src/modes/components/thinking-selector.ts index 233b5b9bc..f64450bd5 100644 --- a/packages/coding-agent/src/modes/components/thinking-selector.ts +++ b/packages/coding-agent/src/modes/components/thinking-selector.ts @@ -1,6 +1,6 @@ import type { ThinkingLevel } from "@oh-my-pi/pi-agent-core"; -import { getSelectListTheme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { Container, type SelectItem, SelectList } from "@oh-my-pi/pi-tui"; +import { getSelectListTheme } from "../../modes/theme/theme"; import { DynamicBorder } from "./dynamic-border"; const LEVEL_DESCRIPTIONS: Record = { diff --git a/packages/coding-agent/src/modes/components/todo-display.ts b/packages/coding-agent/src/modes/components/todo-display.ts index a3db53ba1..e37893f26 100644 --- a/packages/coding-agent/src/modes/components/todo-display.ts +++ b/packages/coding-agent/src/modes/components/todo-display.ts @@ -1,8 +1,8 @@ import * as path from "node:path"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { TodoItem } from "@oh-my-pi/pi-coding-agent/modes/types"; import { Text } from "@oh-my-pi/pi-tui"; import { logger } from "@oh-my-pi/pi-utils"; +import { theme } from "../../modes/theme/theme"; +import type { TodoItem } from "../../modes/types"; const TODO_FILE_NAME = "todos.json"; diff --git a/packages/coding-agent/src/modes/components/todo-reminder.ts b/packages/coding-agent/src/modes/components/todo-reminder.ts index 384350963..6a3677efa 100644 --- a/packages/coding-agent/src/modes/components/todo-reminder.ts +++ b/packages/coding-agent/src/modes/components/todo-reminder.ts @@ -1,6 +1,6 @@ -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { TodoItem } from "@oh-my-pi/pi-coding-agent/tools/todo-write"; import { Box, Container, Spacer, Text } from "@oh-my-pi/pi-tui"; +import { theme } from "../../modes/theme/theme"; +import type { TodoItem } from "../../tools/todo-write"; /** * Component that renders a todo completion reminder notification. diff --git a/packages/coding-agent/src/modes/components/tool-execution.ts b/packages/coding-agent/src/modes/components/tool-execution.ts index 29cd060fe..8b05e735b 100644 --- a/packages/coding-agent/src/modes/components/tool-execution.ts +++ b/packages/coding-agent/src/modes/components/tool-execution.ts @@ -1,15 +1,4 @@ import type { AgentTool } from "@oh-my-pi/pi-agent-core"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import { - computeEditDiff, - computePatchDiff, - type EditDiffError, - type EditDiffResult, -} from "@oh-my-pi/pi-coding-agent/patch"; -import { BASH_DEFAULT_PREVIEW_LINES } from "@oh-my-pi/pi-coding-agent/tools/bash"; -import { PYTHON_DEFAULT_PREVIEW_LINES } from "@oh-my-pi/pi-coding-agent/tools/python"; -import { toolRenderers } from "@oh-my-pi/pi-coding-agent/tools/renderers"; -import { convertToPng } from "@oh-my-pi/pi-coding-agent/utils/image-convert"; import { Box, Container, @@ -22,6 +11,12 @@ import { type TUI, } from "@oh-my-pi/pi-tui"; import { sanitizeText } from "@oh-my-pi/pi-utils"; +import { theme } from "../../modes/theme/theme"; +import { computeEditDiff, computePatchDiff, type EditDiffError, type EditDiffResult } from "../../patch"; +import { BASH_DEFAULT_PREVIEW_LINES } from "../../tools/bash"; +import { PYTHON_DEFAULT_PREVIEW_LINES } from "../../tools/python"; +import { toolRenderers } from "../../tools/renderers"; +import { convertToPng } from "../../utils/image-convert"; import { renderDiff } from "./diff"; // Preview line limit for bash when not expanded diff --git a/packages/coding-agent/src/modes/components/tree-selector.ts b/packages/coding-agent/src/modes/components/tree-selector.ts index 97a105ab3..8f768a5bf 100644 --- a/packages/coding-agent/src/modes/components/tree-selector.ts +++ b/packages/coding-agent/src/modes/components/tree-selector.ts @@ -1,6 +1,3 @@ -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { SessionTreeNode } from "@oh-my-pi/pi-coding-agent/session/session-manager"; -import { shortenPath } from "@oh-my-pi/pi-coding-agent/tools/render-utils"; import { type Component, Container, @@ -11,6 +8,9 @@ import { TruncatedText, truncateToWidth, } from "@oh-my-pi/pi-tui"; +import { theme } from "../../modes/theme/theme"; +import type { SessionTreeNode } from "../../session/session-manager"; +import { shortenPath } from "../../tools/render-utils"; import { DynamicBorder } from "./dynamic-border"; /** Gutter info: position (displayIndent where connector was) and whether to show │ */ diff --git a/packages/coding-agent/src/modes/components/ttsr-notification.ts b/packages/coding-agent/src/modes/components/ttsr-notification.ts index 20257cb8f..4cf72263d 100644 --- a/packages/coding-agent/src/modes/components/ttsr-notification.ts +++ b/packages/coding-agent/src/modes/components/ttsr-notification.ts @@ -1,6 +1,6 @@ -import type { Rule } from "@oh-my-pi/pi-coding-agent/capability/rule"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { Box, Container, Spacer, Text } from "@oh-my-pi/pi-tui"; +import type { Rule } from "../../capability/rule"; +import { theme } from "../../modes/theme/theme"; /** * Component that renders a TTSR (Time Traveling Stream Rules) notification. diff --git a/packages/coding-agent/src/modes/components/user-message-selector.ts b/packages/coding-agent/src/modes/components/user-message-selector.ts index 77c93c23d..22dd7b4f2 100644 --- a/packages/coding-agent/src/modes/components/user-message-selector.ts +++ b/packages/coding-agent/src/modes/components/user-message-selector.ts @@ -1,5 +1,5 @@ -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { type Component, Container, matchesKey, Spacer, Text, truncateToWidth } from "@oh-my-pi/pi-tui"; +import { theme } from "../../modes/theme/theme"; import { DynamicBorder } from "./dynamic-border"; interface UserMessageItem { diff --git a/packages/coding-agent/src/modes/components/user-message.ts b/packages/coding-agent/src/modes/components/user-message.ts index 3e44a7bc9..fc22cd61f 100644 --- a/packages/coding-agent/src/modes/components/user-message.ts +++ b/packages/coding-agent/src/modes/components/user-message.ts @@ -1,5 +1,5 @@ -import { getMarkdownTheme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { Container, Markdown, Spacer } from "@oh-my-pi/pi-tui"; +import { getMarkdownTheme, theme } from "../../modes/theme/theme"; /** * Component that renders a user message diff --git a/packages/coding-agent/src/modes/components/welcome.ts b/packages/coding-agent/src/modes/components/welcome.ts index 08638606e..c414d756e 100644 --- a/packages/coding-agent/src/modes/components/welcome.ts +++ b/packages/coding-agent/src/modes/components/welcome.ts @@ -1,6 +1,6 @@ -import { APP_NAME } from "@oh-my-pi/pi-coding-agent/config"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { type Component, truncateToWidth, visibleWidth } from "@oh-my-pi/pi-tui"; +import { APP_NAME } from "../../config"; +import { theme } from "../../modes/theme/theme"; export interface RecentSession { name: string; diff --git a/packages/coding-agent/src/modes/controllers/command-controller.ts b/packages/coding-agent/src/modes/controllers/command-controller.ts index f7355fbcc..e0df14e74 100644 --- a/packages/coding-agent/src/modes/controllers/command-controller.ts +++ b/packages/coding-agent/src/modes/controllers/command-controller.ts @@ -2,24 +2,24 @@ import { mkdir, rm } from "node:fs/promises"; import * as os from "node:os"; import * as path from "node:path"; import type { UsageLimit, UsageReport } from "@oh-my-pi/pi-ai"; -import { getDebugLogPath } from "@oh-my-pi/pi-coding-agent/config"; -import { loadCustomShare } from "@oh-my-pi/pi-coding-agent/export/custom-share"; -import type { CompactOptions } from "@oh-my-pi/pi-coding-agent/extensibility/extensions/types"; -import { getGatewayStatus } from "@oh-my-pi/pi-coding-agent/ipy/gateway-coordinator"; -import { ArminComponent } from "@oh-my-pi/pi-coding-agent/modes/components/armin"; -import { BashExecutionComponent } from "@oh-my-pi/pi-coding-agent/modes/components/bash-execution"; -import { BorderedLoader } from "@oh-my-pi/pi-coding-agent/modes/components/bordered-loader"; -import { DynamicBorder } from "@oh-my-pi/pi-coding-agent/modes/components/dynamic-border"; -import { PythonExecutionComponent } from "@oh-my-pi/pi-coding-agent/modes/components/python-execution"; -import { getMarkdownTheme, getSymbolTheme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { InteractiveModeContext } from "@oh-my-pi/pi-coding-agent/modes/types"; -import { createCompactionSummaryMessage } from "@oh-my-pi/pi-coding-agent/session/messages"; -import { outputMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; -import { getChangelogPath, parseChangelog } from "@oh-my-pi/pi-coding-agent/utils/changelog"; -import { copyToClipboard } from "@oh-my-pi/pi-coding-agent/utils/clipboard"; import { Loader, Markdown, Spacer, Text, visibleWidth } from "@oh-my-pi/pi-tui"; import { $ } from "bun"; import { nanoid } from "nanoid"; +import { getDebugLogPath } from "../../config"; +import { loadCustomShare } from "../../export/custom-share"; +import type { CompactOptions } from "../../extensibility/extensions/types"; +import { getGatewayStatus } from "../../ipy/gateway-coordinator"; +import { ArminComponent } from "../../modes/components/armin"; +import { BashExecutionComponent } from "../../modes/components/bash-execution"; +import { BorderedLoader } from "../../modes/components/bordered-loader"; +import { DynamicBorder } from "../../modes/components/dynamic-border"; +import { PythonExecutionComponent } from "../../modes/components/python-execution"; +import { getMarkdownTheme, getSymbolTheme, theme } from "../../modes/theme/theme"; +import type { InteractiveModeContext } from "../../modes/types"; +import { createCompactionSummaryMessage } from "../../session/messages"; +import { outputMeta } from "../../tools/output-meta"; +import { getChangelogPath, parseChangelog } from "../../utils/changelog"; +import { copyToClipboard } from "../../utils/clipboard"; export class CommandController { constructor(private readonly ctx: InteractiveModeContext) {} diff --git a/packages/coding-agent/src/modes/controllers/event-controller.ts b/packages/coding-agent/src/modes/controllers/event-controller.ts index af440c9fe..6ba0e0db9 100644 --- a/packages/coding-agent/src/modes/controllers/event-controller.ts +++ b/packages/coding-agent/src/modes/controllers/event-controller.ts @@ -1,17 +1,13 @@ -import { AssistantMessageComponent } from "@oh-my-pi/pi-coding-agent/modes/components/assistant-message"; -import { ReadToolGroupComponent } from "@oh-my-pi/pi-coding-agent/modes/components/read-tool-group"; -import { TodoReminderComponent } from "@oh-my-pi/pi-coding-agent/modes/components/todo-reminder"; -import { ToolExecutionComponent } from "@oh-my-pi/pi-coding-agent/modes/components/tool-execution"; -import { TtsrNotificationComponent } from "@oh-my-pi/pi-coding-agent/modes/components/ttsr-notification"; -import { getSymbolTheme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { InteractiveModeContext, TodoItem } from "@oh-my-pi/pi-coding-agent/modes/types"; -import type { AgentSessionEvent } from "@oh-my-pi/pi-coding-agent/session/agent-session"; -import { - detectNotificationProtocol, - isNotificationSuppressed, - sendNotification, -} from "@oh-my-pi/pi-coding-agent/utils/terminal-notify"; import { Loader, Text } from "@oh-my-pi/pi-tui"; +import { AssistantMessageComponent } from "../../modes/components/assistant-message"; +import { ReadToolGroupComponent } from "../../modes/components/read-tool-group"; +import { TodoReminderComponent } from "../../modes/components/todo-reminder"; +import { ToolExecutionComponent } from "../../modes/components/tool-execution"; +import { TtsrNotificationComponent } from "../../modes/components/ttsr-notification"; +import { getSymbolTheme, theme } from "../../modes/theme/theme"; +import type { InteractiveModeContext, TodoItem } from "../../modes/types"; +import type { AgentSessionEvent } from "../../session/agent-session"; +import { detectNotificationProtocol, isNotificationSuppressed, sendNotification } from "../../utils/terminal-notify"; export class EventController { private lastReadGroup: ReadToolGroupComponent | undefined = undefined; diff --git a/packages/coding-agent/src/modes/controllers/extension-ui-controller.ts b/packages/coding-agent/src/modes/controllers/extension-ui-controller.ts index f0f43038b..6e3fa394a 100644 --- a/packages/coding-agent/src/modes/controllers/extension-ui-controller.ts +++ b/packages/coding-agent/src/modes/controllers/extension-ui-controller.ts @@ -1,26 +1,20 @@ -import { KeybindingsManager } from "@oh-my-pi/pi-coding-agent/config/keybindings"; +import type { Component, TUI } from "@oh-my-pi/pi-tui"; +import { Spacer, Text } from "@oh-my-pi/pi-tui"; +import { logger } from "@oh-my-pi/pi-utils"; +import { KeybindingsManager } from "../../config/keybindings"; import type { ExtensionActions, ExtensionCommandContextActions, ExtensionContextActions, ExtensionError, ExtensionUIContext, -} from "@oh-my-pi/pi-coding-agent/extensibility/extensions"; -import { HookEditorComponent } from "@oh-my-pi/pi-coding-agent/modes/components/hook-editor"; -import { HookInputComponent } from "@oh-my-pi/pi-coding-agent/modes/components/hook-input"; -import { HookSelectorComponent } from "@oh-my-pi/pi-coding-agent/modes/components/hook-selector"; -import { - getAvailableThemesWithPaths, - getThemeByName, - setTheme, - type Theme, - theme, -} from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { InteractiveModeContext } from "@oh-my-pi/pi-coding-agent/modes/types"; -import { setTerminalTitle } from "@oh-my-pi/pi-coding-agent/utils/title-generator"; -import type { Component, TUI } from "@oh-my-pi/pi-tui"; -import { Spacer, Text } from "@oh-my-pi/pi-tui"; -import { logger } from "@oh-my-pi/pi-utils"; +} from "../../extensibility/extensions"; +import { HookEditorComponent } from "../../modes/components/hook-editor"; +import { HookInputComponent } from "../../modes/components/hook-input"; +import { HookSelectorComponent } from "../../modes/components/hook-selector"; +import { getAvailableThemesWithPaths, getThemeByName, setTheme, type Theme, theme } from "../../modes/theme/theme"; +import type { InteractiveModeContext } from "../../modes/types"; +import { setTerminalTitle } from "../../utils/title-generator"; export class ExtensionUiController { constructor(private ctx: InteractiveModeContext) {} diff --git a/packages/coding-agent/src/modes/controllers/input-controller.ts b/packages/coding-agent/src/modes/controllers/input-controller.ts index 8d0b01a74..379f4902e 100644 --- a/packages/coding-agent/src/modes/controllers/input-controller.ts +++ b/packages/coding-agent/src/modes/controllers/input-controller.ts @@ -4,13 +4,13 @@ import { open, rm } from "node:fs/promises"; import * as os from "node:os"; import * as path from "node:path"; import type { AgentMessage } from "@oh-my-pi/pi-agent-core"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { InteractiveModeContext } from "@oh-my-pi/pi-coding-agent/modes/types"; -import type { AgentSessionEvent } from "@oh-my-pi/pi-coding-agent/session/agent-session"; -import { readImageFromClipboard } from "@oh-my-pi/pi-coding-agent/utils/clipboard"; -import { resizeImage } from "@oh-my-pi/pi-coding-agent/utils/image-resize"; -import { generateSessionTitle, setTerminalTitle } from "@oh-my-pi/pi-coding-agent/utils/title-generator"; import { nanoid } from "nanoid"; +import { theme } from "../../modes/theme/theme"; +import type { InteractiveModeContext } from "../../modes/types"; +import type { AgentSessionEvent } from "../../session/agent-session"; +import { readImageFromClipboard } from "../../utils/clipboard"; +import { resizeImage } from "../../utils/image-resize"; +import { generateSessionTitle, setTerminalTitle } from "../../utils/title-generator"; interface Expandable { setExpanded(expanded: boolean): void; diff --git a/packages/coding-agent/src/modes/controllers/selector-controller.ts b/packages/coding-agent/src/modes/controllers/selector-controller.ts index 2fc4d8717..ed3851311 100644 --- a/packages/coding-agent/src/modes/controllers/selector-controller.ts +++ b/packages/coding-agent/src/modes/controllers/selector-controller.ts @@ -1,29 +1,23 @@ import type { ThinkingLevel } from "@oh-my-pi/pi-agent-core"; import type { OAuthProvider } from "@oh-my-pi/pi-ai"; -import { getAgentDbPath } from "@oh-my-pi/pi-coding-agent/config"; -import { disableProvider, enableProvider } from "@oh-my-pi/pi-coding-agent/discovery"; -import { AssistantMessageComponent } from "@oh-my-pi/pi-coding-agent/modes/components/assistant-message"; -import { ExtensionDashboard } from "@oh-my-pi/pi-coding-agent/modes/components/extensions"; -import { HistorySearchComponent } from "@oh-my-pi/pi-coding-agent/modes/components/history-search"; -import { ModelSelectorComponent } from "@oh-my-pi/pi-coding-agent/modes/components/model-selector"; -import { OAuthSelectorComponent } from "@oh-my-pi/pi-coding-agent/modes/components/oauth-selector"; -import { SessionSelectorComponent } from "@oh-my-pi/pi-coding-agent/modes/components/session-selector"; -import { SettingsSelectorComponent } from "@oh-my-pi/pi-coding-agent/modes/components/settings-selector"; -import { ToolExecutionComponent } from "@oh-my-pi/pi-coding-agent/modes/components/tool-execution"; -import { TreeSelectorComponent } from "@oh-my-pi/pi-coding-agent/modes/components/tree-selector"; -import { UserMessageSelectorComponent } from "@oh-my-pi/pi-coding-agent/modes/components/user-message-selector"; -import { - getAvailableThemes, - getSymbolTheme, - setSymbolPreset, - setTheme, - theme, -} from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { InteractiveModeContext } from "@oh-my-pi/pi-coding-agent/modes/types"; -import { SessionManager } from "@oh-my-pi/pi-coding-agent/session/session-manager"; -import { setPreferredImageProvider, setPreferredWebSearchProvider } from "@oh-my-pi/pi-coding-agent/tools"; import type { Component } from "@oh-my-pi/pi-tui"; import { Input, Loader, Spacer, Text } from "@oh-my-pi/pi-tui"; +import { getAgentDbPath } from "../../config"; +import { disableProvider, enableProvider } from "../../discovery"; +import { AssistantMessageComponent } from "../../modes/components/assistant-message"; +import { ExtensionDashboard } from "../../modes/components/extensions"; +import { HistorySearchComponent } from "../../modes/components/history-search"; +import { ModelSelectorComponent } from "../../modes/components/model-selector"; +import { OAuthSelectorComponent } from "../../modes/components/oauth-selector"; +import { SessionSelectorComponent } from "../../modes/components/session-selector"; +import { SettingsSelectorComponent } from "../../modes/components/settings-selector"; +import { ToolExecutionComponent } from "../../modes/components/tool-execution"; +import { TreeSelectorComponent } from "../../modes/components/tree-selector"; +import { UserMessageSelectorComponent } from "../../modes/components/user-message-selector"; +import { getAvailableThemes, getSymbolTheme, setSymbolPreset, setTheme, theme } from "../../modes/theme/theme"; +import type { InteractiveModeContext } from "../../modes/types"; +import { SessionManager } from "../../session/session-manager"; +import { setPreferredImageProvider, setPreferredWebSearchProvider } from "../../tools"; export class SelectorController { constructor(private ctx: InteractiveModeContext) {} diff --git a/packages/coding-agent/src/modes/interactive-mode.ts b/packages/coding-agent/src/modes/interactive-mode.ts index c8c06d1ca..e20dbbefc 100644 --- a/packages/coding-agent/src/modes/interactive-mode.ts +++ b/packages/coding-agent/src/modes/interactive-mode.ts @@ -6,16 +6,6 @@ import * as path from "node:path"; import type { AgentMessage } from "@oh-my-pi/pi-agent-core"; import type { AssistantMessage, ImageContent, Message, UsageReport } from "@oh-my-pi/pi-ai"; -import { KeybindingsManager } from "@oh-my-pi/pi-coding-agent/config/keybindings"; -import type { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import type { ExtensionUIContext } from "@oh-my-pi/pi-coding-agent/extensibility/extensions"; -import type { CompactOptions } from "@oh-my-pi/pi-coding-agent/extensibility/extensions/types"; -import { loadSlashCommands } from "@oh-my-pi/pi-coding-agent/extensibility/slash-commands"; -import type { AgentSession, AgentSessionEvent } from "@oh-my-pi/pi-coding-agent/session/agent-session"; -import { HistoryStorage } from "@oh-my-pi/pi-coding-agent/session/history-storage"; -import type { SessionContext, SessionManager } from "@oh-my-pi/pi-coding-agent/session/session-manager"; -import { getRecentSessions } from "@oh-my-pi/pi-coding-agent/session/session-manager"; -import { setTerminalTitle } from "@oh-my-pi/pi-coding-agent/utils/title-generator"; import type { Component, Loader, SlashCommand } from "@oh-my-pi/pi-tui"; import { CombinedAutocompleteProvider, @@ -28,6 +18,16 @@ import { } from "@oh-my-pi/pi-tui"; import { logger, postmortem } from "@oh-my-pi/pi-utils"; import chalk from "chalk"; +import { KeybindingsManager } from "../config/keybindings"; +import type { SettingsManager } from "../config/settings-manager"; +import type { ExtensionUIContext } from "../extensibility/extensions"; +import type { CompactOptions } from "../extensibility/extensions/types"; +import { loadSlashCommands } from "../extensibility/slash-commands"; +import type { AgentSession, AgentSessionEvent } from "../session/agent-session"; +import { HistoryStorage } from "../session/history-storage"; +import type { SessionContext, SessionManager } from "../session/session-manager"; +import { getRecentSessions } from "../session/session-manager"; +import { setTerminalTitle } from "../utils/title-generator"; import type { AssistantMessageComponent } from "./components/assistant-message"; import type { BashExecutionComponent } from "./components/bash-execution"; import { CustomEditor } from "./components/custom-editor"; diff --git a/packages/coding-agent/src/modes/print-mode.ts b/packages/coding-agent/src/modes/print-mode.ts index 40509a6df..3f5e18738 100644 --- a/packages/coding-agent/src/modes/print-mode.ts +++ b/packages/coding-agent/src/modes/print-mode.ts @@ -7,7 +7,7 @@ */ import type { AssistantMessage, ImageContent } from "@oh-my-pi/pi-ai"; -import type { AgentSession } from "@oh-my-pi/pi-coding-agent/session/agent-session"; +import type { AgentSession } from "../session/agent-session"; /** * Options for print mode. diff --git a/packages/coding-agent/src/modes/rpc/rpc-client.ts b/packages/coding-agent/src/modes/rpc/rpc-client.ts index bb3e22d2f..0e9a19f26 100644 --- a/packages/coding-agent/src/modes/rpc/rpc-client.ts +++ b/packages/coding-agent/src/modes/rpc/rpc-client.ts @@ -6,10 +6,10 @@ import type { AgentEvent, AgentMessage, ThinkingLevel } from "@oh-my-pi/pi-agent-core"; import type { ImageContent } from "@oh-my-pi/pi-ai"; -import type { BashResult } from "@oh-my-pi/pi-coding-agent/exec/bash-executor"; -import type { SessionStats } from "@oh-my-pi/pi-coding-agent/session/agent-session"; -import type { CompactionResult } from "@oh-my-pi/pi-coding-agent/session/compaction"; import { createSanitizerStream, createSplitterStream, createTextDecoderStream, ptree } from "@oh-my-pi/pi-utils"; +import type { BashResult } from "../../exec/bash-executor"; +import type { SessionStats } from "../../session/agent-session"; +import type { CompactionResult } from "../../session/compaction"; import type { RpcCommand, RpcResponse, RpcSessionState } from "./rpc-types"; /** Distributive Omit that works with union types */ diff --git a/packages/coding-agent/src/modes/rpc/rpc-mode.ts b/packages/coding-agent/src/modes/rpc/rpc-mode.ts index b78882a8c..de988d20e 100644 --- a/packages/coding-agent/src/modes/rpc/rpc-mode.ts +++ b/packages/coding-agent/src/modes/rpc/rpc-mode.ts @@ -11,11 +11,11 @@ * - Extension UI: Extension UI requests are emitted, client responds with extension_ui_response */ -import type { ExtensionUIContext, ExtensionUIDialogOptions } from "@oh-my-pi/pi-coding-agent/extensibility/extensions"; -import { type Theme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { AgentSession } from "@oh-my-pi/pi-coding-agent/session/agent-session"; import { readLines } from "@oh-my-pi/pi-utils"; import { nanoid } from "nanoid"; +import type { ExtensionUIContext, ExtensionUIDialogOptions } from "../../extensibility/extensions"; +import { type Theme, theme } from "../../modes/theme/theme"; +import type { AgentSession } from "../../session/agent-session"; import type { RpcCommand, RpcExtensionUIRequest, diff --git a/packages/coding-agent/src/modes/rpc/rpc-types.ts b/packages/coding-agent/src/modes/rpc/rpc-types.ts index dadbee42a..21191251f 100644 --- a/packages/coding-agent/src/modes/rpc/rpc-types.ts +++ b/packages/coding-agent/src/modes/rpc/rpc-types.ts @@ -7,9 +7,9 @@ import type { AgentMessage, ThinkingLevel } from "@oh-my-pi/pi-agent-core"; import type { ImageContent, Model } from "@oh-my-pi/pi-ai"; -import type { BashResult } from "@oh-my-pi/pi-coding-agent/exec/bash-executor"; -import type { SessionStats } from "@oh-my-pi/pi-coding-agent/session/agent-session"; -import type { CompactionResult } from "@oh-my-pi/pi-coding-agent/session/compaction"; +import type { BashResult } from "../../exec/bash-executor"; +import type { SessionStats } from "../../session/agent-session"; +import type { CompactionResult } from "../../session/compaction"; // ============================================================================ // RPC Commands (stdin) diff --git a/packages/coding-agent/src/modes/theme/theme.ts b/packages/coding-agent/src/modes/theme/theme.ts index 882d56ea9..a0ef1e0b0 100644 --- a/packages/coding-agent/src/modes/theme/theme.ts +++ b/packages/coding-agent/src/modes/theme/theme.ts @@ -1,12 +1,12 @@ import * as fs from "node:fs"; import * as path from "node:path"; -import { getCustomThemesDir } from "@oh-my-pi/pi-coding-agent/config"; import type { EditorTheme, MarkdownTheme, SelectListTheme, SymbolTheme } from "@oh-my-pi/pi-tui"; import { logger } from "@oh-my-pi/pi-utils"; import { type Static, Type } from "@sinclair/typebox"; import { TypeCompiler } from "@sinclair/typebox/compiler"; import chalk from "chalk"; import { highlight, supportsLanguage } from "cli-highlight"; +import { getCustomThemesDir } from "../../config"; // Embed theme JSON files at build time import darkThemeJson from "./dark.json" with { type: "json" }; import { defaultThemes } from "./defaults"; diff --git a/packages/coding-agent/src/modes/types.ts b/packages/coding-agent/src/modes/types.ts index 7a58ffb17..a50333d05 100644 --- a/packages/coding-agent/src/modes/types.ts +++ b/packages/coding-agent/src/modes/types.ts @@ -1,14 +1,14 @@ import type { AgentMessage } from "@oh-my-pi/pi-agent-core"; import type { AssistantMessage, ImageContent, Message, UsageReport } from "@oh-my-pi/pi-ai"; -import type { KeybindingsManager } from "@oh-my-pi/pi-coding-agent/config/keybindings"; -import type { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import type { ExtensionUIContext } from "@oh-my-pi/pi-coding-agent/extensibility/extensions"; -import type { CompactOptions } from "@oh-my-pi/pi-coding-agent/extensibility/extensions/types"; -import type { MCPManager } from "@oh-my-pi/pi-coding-agent/mcp"; -import type { AgentSession, AgentSessionEvent } from "@oh-my-pi/pi-coding-agent/session/agent-session"; -import type { HistoryStorage } from "@oh-my-pi/pi-coding-agent/session/history-storage"; -import type { SessionContext, SessionManager } from "@oh-my-pi/pi-coding-agent/session/session-manager"; import type { Component, Container, Loader, Spacer, Text, TUI } from "@oh-my-pi/pi-tui"; +import type { KeybindingsManager } from "../config/keybindings"; +import type { SettingsManager } from "../config/settings-manager"; +import type { ExtensionUIContext } from "../extensibility/extensions"; +import type { CompactOptions } from "../extensibility/extensions/types"; +import type { MCPManager } from "../mcp"; +import type { AgentSession, AgentSessionEvent } from "../session/agent-session"; +import type { HistoryStorage } from "../session/history-storage"; +import type { SessionContext, SessionManager } from "../session/session-manager"; import type { AssistantMessageComponent } from "./components/assistant-message"; import type { BashExecutionComponent } from "./components/bash-execution"; import type { CustomEditor } from "./components/custom-editor"; diff --git a/packages/coding-agent/src/modes/utils/ui-helpers.ts b/packages/coding-agent/src/modes/utils/ui-helpers.ts index 0eab7710e..e51ea33a6 100644 --- a/packages/coding-agent/src/modes/utils/ui-helpers.ts +++ b/packages/coding-agent/src/modes/utils/ui-helpers.ts @@ -1,20 +1,20 @@ import type { AgentMessage } from "@oh-my-pi/pi-agent-core"; import type { AssistantMessage, Message } from "@oh-my-pi/pi-ai"; -import { AssistantMessageComponent } from "@oh-my-pi/pi-coding-agent/modes/components/assistant-message"; -import { BashExecutionComponent } from "@oh-my-pi/pi-coding-agent/modes/components/bash-execution"; -import { BranchSummaryMessageComponent } from "@oh-my-pi/pi-coding-agent/modes/components/branch-summary-message"; -import { CompactionSummaryMessageComponent } from "@oh-my-pi/pi-coding-agent/modes/components/compaction-summary-message"; -import { CustomMessageComponent } from "@oh-my-pi/pi-coding-agent/modes/components/custom-message"; -import { DynamicBorder } from "@oh-my-pi/pi-coding-agent/modes/components/dynamic-border"; -import { PythonExecutionComponent } from "@oh-my-pi/pi-coding-agent/modes/components/python-execution"; -import { ReadToolGroupComponent } from "@oh-my-pi/pi-coding-agent/modes/components/read-tool-group"; -import { ToolExecutionComponent } from "@oh-my-pi/pi-coding-agent/modes/components/tool-execution"; -import { UserMessageComponent } from "@oh-my-pi/pi-coding-agent/modes/components/user-message"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { CompactionQueuedMessage, InteractiveModeContext } from "@oh-my-pi/pi-coding-agent/modes/types"; -import type { CustomMessage } from "@oh-my-pi/pi-coding-agent/session/messages"; -import type { SessionContext } from "@oh-my-pi/pi-coding-agent/session/session-manager"; import { Spacer, Text, TruncatedText } from "@oh-my-pi/pi-tui"; +import { AssistantMessageComponent } from "../../modes/components/assistant-message"; +import { BashExecutionComponent } from "../../modes/components/bash-execution"; +import { BranchSummaryMessageComponent } from "../../modes/components/branch-summary-message"; +import { CompactionSummaryMessageComponent } from "../../modes/components/compaction-summary-message"; +import { CustomMessageComponent } from "../../modes/components/custom-message"; +import { DynamicBorder } from "../../modes/components/dynamic-border"; +import { PythonExecutionComponent } from "../../modes/components/python-execution"; +import { ReadToolGroupComponent } from "../../modes/components/read-tool-group"; +import { ToolExecutionComponent } from "../../modes/components/tool-execution"; +import { UserMessageComponent } from "../../modes/components/user-message"; +import { theme } from "../../modes/theme/theme"; +import type { CompactionQueuedMessage, InteractiveModeContext } from "../../modes/types"; +import type { CustomMessage } from "../../session/messages"; +import type { SessionContext } from "../../session/session-manager"; type TextBlock = { type: "text"; text: string }; diff --git a/packages/coding-agent/src/patch/applicator.ts b/packages/coding-agent/src/patch/applicator.ts index 3d4d4ce64..b8d578f91 100644 --- a/packages/coding-agent/src/patch/applicator.ts +++ b/packages/coding-agent/src/patch/applicator.ts @@ -7,7 +7,7 @@ import { mkdirSync, unlinkSync } from "node:fs"; import { dirname } from "node:path"; -import { resolveToCwd } from "@oh-my-pi/pi-coding-agent/tools/path-utils"; +import { resolveToCwd } from "../tools/path-utils"; import { DEFAULT_FUZZY_THRESHOLD, findContextLine, findMatch, seekSequence } from "./fuzzy"; import { adjustIndentation, diff --git a/packages/coding-agent/src/patch/diff.ts b/packages/coding-agent/src/patch/diff.ts index 0b8da3470..ea18b518c 100644 --- a/packages/coding-agent/src/patch/diff.ts +++ b/packages/coding-agent/src/patch/diff.ts @@ -5,8 +5,8 @@ * used when not in patch mode. */ -import { resolveToCwd } from "@oh-my-pi/pi-coding-agent/tools/path-utils"; import * as Diff from "diff"; +import { resolveToCwd } from "../tools/path-utils"; import { previewPatch } from "./applicator"; import { DEFAULT_FUZZY_THRESHOLD, findMatch } from "./fuzzy"; import { adjustIndentation, normalizeToLF, stripBom } from "./normalize"; diff --git a/packages/coding-agent/src/patch/index.ts b/packages/coding-agent/src/patch/index.ts index f23712f33..878e97329 100644 --- a/packages/coding-agent/src/patch/index.ts +++ b/packages/coding-agent/src/patch/index.ts @@ -11,20 +11,20 @@ import { mkdir } from "node:fs/promises"; import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; import { StringEnum } from "@oh-my-pi/pi-ai"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; +import { Type } from "@sinclair/typebox"; +import { renderPromptTemplate } from "../config/prompt-templates"; import { createLspWritethrough, type FileDiagnosticsResult, flushLspWritethroughBatch, type WritethroughCallback, writethroughNoop, -} from "@oh-my-pi/pi-coding-agent/lsp"; -import patchDescription from "@oh-my-pi/pi-coding-agent/prompts/tools/patch.md" with { type: "text" }; -import replaceDescription from "@oh-my-pi/pi-coding-agent/prompts/tools/replace.md" with { type: "text" }; -import type { ToolSession } from "@oh-my-pi/pi-coding-agent/tools"; -import { outputMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; -import { resolveToCwd } from "@oh-my-pi/pi-coding-agent/tools/path-utils"; -import { Type } from "@sinclair/typebox"; +} from "../lsp"; +import patchDescription from "../prompts/tools/patch.md" with { type: "text" }; +import replaceDescription from "../prompts/tools/replace.md" with { type: "text" }; +import type { ToolSession } from "../tools"; +import { outputMeta } from "../tools/output-meta"; +import { resolveToCwd } from "../tools/path-utils"; import { applyPatch } from "./applicator"; import { generateDiffString, generateUnifiedDiffString, replaceText } from "./diff"; import { DEFAULT_FUZZY_THRESHOLD, findMatch } from "./fuzzy"; diff --git a/packages/coding-agent/src/patch/shared.ts b/packages/coding-agent/src/patch/shared.ts index c841fb76d..a3cde2af5 100644 --- a/packages/coding-agent/src/patch/shared.ts +++ b/packages/coding-agent/src/patch/shared.ts @@ -3,11 +3,13 @@ */ import type { ToolCallContext } from "@oh-my-pi/pi-agent-core"; -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import type { FileDiagnosticsResult } from "@oh-my-pi/pi-coding-agent/lsp"; -import { renderDiff as renderDiffColored } from "@oh-my-pi/pi-coding-agent/modes/components/diff"; -import { getLanguageFromPath, type Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { OutputMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; +import type { Component } from "@oh-my-pi/pi-tui"; +import { Text } from "@oh-my-pi/pi-tui"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import type { FileDiagnosticsResult } from "../lsp"; +import { renderDiff as renderDiffColored } from "../modes/components/diff"; +import { getLanguageFromPath, type Theme } from "../modes/theme/theme"; +import type { OutputMeta } from "../tools/output-meta"; import { formatExpandHint, formatStatusIcon, @@ -15,11 +17,9 @@ import { shortenPath, ToolUIKit, truncateDiffByHunk, -} from "@oh-my-pi/pi-coding-agent/tools/render-utils"; -import type { RenderCallOptions } from "@oh-my-pi/pi-coding-agent/tools/renderers"; -import { renderStatusLine } from "@oh-my-pi/pi-coding-agent/tui"; -import type { Component } from "@oh-my-pi/pi-tui"; -import { Text } from "@oh-my-pi/pi-tui"; +} from "../tools/render-utils"; +import type { RenderCallOptions } from "../tools/renderers"; +import { renderStatusLine } from "../tui"; import type { DiffError, DiffResult, Operation } from "./types"; // ═══════════════════════════════════════════════════════════════════════════ diff --git a/packages/coding-agent/src/sdk.ts b/packages/coding-agent/src/sdk.ts index c73366cd6..0b21c4398 100644 --- a/packages/coding-agent/src/sdk.ts +++ b/packages/coding-agent/src/sdk.ts @@ -31,24 +31,24 @@ import { rename } from "node:fs/promises"; import { join } from "node:path"; import { Agent, type AgentEvent, type AgentMessage, type AgentTool, type ThinkingLevel } from "@oh-my-pi/pi-agent-core"; import { type Message, type Model, supportsXhigh } from "@oh-my-pi/pi-ai"; -// Import discovery to register all providers on startup -import { loadCapability } from "@oh-my-pi/pi-coding-agent/capability"; -import { type Rule, ruleCapability } from "@oh-my-pi/pi-coding-agent/capability/rule"; -import { getAgentDir, getConfigDirPaths } from "@oh-my-pi/pi-coding-agent/config"; -import { CursorExecHandlers } from "@oh-my-pi/pi-coding-agent/cursor"; -import { initializeWithSettings } from "@oh-my-pi/pi-coding-agent/discovery"; -import { TtsrManager } from "@oh-my-pi/pi-coding-agent/export/ttsr"; -import { disposeAllKernelSessions } from "@oh-my-pi/pi-coding-agent/ipy/executor"; -import { closeAllConnections } from "@oh-my-pi/pi-coding-agent/ssh/connection-manager"; -import { unmountAll } from "@oh-my-pi/pi-coding-agent/ssh/sshfs-mount"; import type { Component } from "@oh-my-pi/pi-tui"; import { logger, postmortem } from "@oh-my-pi/pi-utils"; import { YAML } from "bun"; import chalk from "chalk"; +// Import discovery to register all providers on startup +import { loadCapability } from "./capability"; +import { type Rule, ruleCapability } from "./capability/rule"; +import { getAgentDir, getConfigDirPaths } from "./config"; import { ModelRegistry } from "./config/model-registry"; import { formatModelString, parseModelString } from "./config/model-resolver"; import { loadPromptTemplates as loadPromptTemplatesInternal, type PromptTemplate } from "./config/prompt-templates"; import { type Settings, SettingsManager, type SkillsSettings } from "./config/settings-manager"; +import { CursorExecHandlers } from "./cursor"; +import { initializeWithSettings } from "./discovery"; +import { TtsrManager } from "./export/ttsr"; +import { disposeAllKernelSessions } from "./ipy/executor"; +import { closeAllConnections } from "./ssh/connection-manager"; +import { unmountAll } from "./ssh/sshfs-mount"; import "./discovery"; import { type CustomCommandsLoadResult, @@ -205,22 +205,22 @@ export interface CreateAgentSessionResult { // Re-exports -export type { PromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -export type { Settings, SkillsSettings } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; +export type { PromptTemplate } from "./config/prompt-templates"; +export type { Settings, SkillsSettings } from "./config/settings-manager"; export type { CustomCommand, CustomCommandFactory, -} from "@oh-my-pi/pi-coding-agent/extensibility/custom-commands/types"; -export type { CustomTool, CustomToolFactory } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; +} from "./extensibility/custom-commands/types"; +export type { CustomTool, CustomToolFactory } from "./extensibility/custom-tools/types"; export type { ExtensionAPI, ExtensionCommandContext, ExtensionContext, ExtensionFactory, ToolDefinition, -} from "@oh-my-pi/pi-coding-agent/extensibility/extensions"; -export type { Skill } from "@oh-my-pi/pi-coding-agent/extensibility/skills"; -export type { FileSlashCommand } from "@oh-my-pi/pi-coding-agent/extensibility/slash-commands"; +} from "./extensibility/extensions"; +export type { Skill } from "./extensibility/skills"; +export type { FileSlashCommand } from "./extensibility/slash-commands"; export type { MCPManager, MCPServerConfig, MCPServerConnection, MCPToolsLoadResult } from "./mcp"; export type { Tool } from "./tools"; diff --git a/packages/coding-agent/src/session/agent-session.ts b/packages/coding-agent/src/session/agent-session.ts index dc58617d8..207ad33d1 100644 --- a/packages/coding-agent/src/session/agent-session.ts +++ b/packages/coding-agent/src/session/agent-session.ts @@ -26,21 +26,23 @@ import type { UsageReport, } from "@oh-my-pi/pi-ai"; import { isContextOverflow, modelsAreEqual, supportsXhigh } from "@oh-my-pi/pi-ai"; -import type { Rule } from "@oh-my-pi/pi-coding-agent/capability/rule"; -import { getAgentDbPath } from "@oh-my-pi/pi-coding-agent/config"; -import type { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry"; -import { parseModelString } from "@oh-my-pi/pi-coding-agent/config/model-resolver"; +import { abortableSleep, logger } from "@oh-my-pi/pi-utils"; +import { YAML } from "bun"; +import type { Rule } from "../capability/rule"; +import { getAgentDbPath } from "../config"; +import type { ModelRegistry } from "../config/model-registry"; +import { parseModelString } from "../config/model-resolver"; import { expandPromptTemplate, type PromptTemplate, parseCommandArgs, renderPromptTemplate, -} from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import type { SettingsManager, SkillsSettings } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import { type BashResult, executeBash as executeBashCommand } from "@oh-my-pi/pi-coding-agent/exec/bash-executor"; -import { exportSessionToHtml } from "@oh-my-pi/pi-coding-agent/export/html"; -import type { TtsrManager } from "@oh-my-pi/pi-coding-agent/export/ttsr"; -import type { LoadedCustomCommand } from "@oh-my-pi/pi-coding-agent/extensibility/custom-commands"; +} from "../config/prompt-templates"; +import type { SettingsManager, SkillsSettings } from "../config/settings-manager"; +import { type BashResult, executeBash as executeBashCommand } from "../exec/bash-executor"; +import { exportSessionToHtml } from "../export/html"; +import type { TtsrManager } from "../export/ttsr"; +import type { LoadedCustomCommand } from "../extensibility/custom-commands"; import type { ExtensionCommandContext, ExtensionRunner, @@ -52,23 +54,21 @@ import type { TreePreparation, TurnEndEvent, TurnStartEvent, -} from "@oh-my-pi/pi-coding-agent/extensibility/extensions"; -import type { CompactOptions, ContextUsage } from "@oh-my-pi/pi-coding-agent/extensibility/extensions/types"; -import type { HookCommandContext } from "@oh-my-pi/pi-coding-agent/extensibility/hooks/types"; -import type { Skill, SkillWarning } from "@oh-my-pi/pi-coding-agent/extensibility/skills"; -import { expandSlashCommand, type FileSlashCommand } from "@oh-my-pi/pi-coding-agent/extensibility/slash-commands"; -import { executePython as executePythonCommand, type PythonResult } from "@oh-my-pi/pi-coding-agent/ipy/executor"; -import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import { normalizeDiff, normalizeToLF, ParseError, previewPatch, stripBom } from "@oh-my-pi/pi-coding-agent/patch"; -import ttsrInterruptTemplate from "@oh-my-pi/pi-coding-agent/prompts/system/ttsr-interrupt.md" with { type: "text" }; -import { closeAllConnections } from "@oh-my-pi/pi-coding-agent/ssh/connection-manager"; -import { unmountAll } from "@oh-my-pi/pi-coding-agent/ssh/sshfs-mount"; -import { outputMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; -import { resolveToCwd } from "@oh-my-pi/pi-coding-agent/tools/path-utils"; -import type { TodoItem } from "@oh-my-pi/pi-coding-agent/tools/todo-write"; -import { extractFileMentions, generateFileMentionMessages } from "@oh-my-pi/pi-coding-agent/utils/file-mentions"; -import { abortableSleep, logger } from "@oh-my-pi/pi-utils"; -import { YAML } from "bun"; +} from "../extensibility/extensions"; +import type { CompactOptions, ContextUsage } from "../extensibility/extensions/types"; +import type { HookCommandContext } from "../extensibility/hooks/types"; +import type { Skill, SkillWarning } from "../extensibility/skills"; +import { expandSlashCommand, type FileSlashCommand } from "../extensibility/slash-commands"; +import { executePython as executePythonCommand, type PythonResult } from "../ipy/executor"; +import { theme } from "../modes/theme/theme"; +import { normalizeDiff, normalizeToLF, ParseError, previewPatch, stripBom } from "../patch"; +import ttsrInterruptTemplate from "../prompts/system/ttsr-interrupt.md" with { type: "text" }; +import { closeAllConnections } from "../ssh/connection-manager"; +import { unmountAll } from "../ssh/sshfs-mount"; +import { outputMeta } from "../tools/output-meta"; +import { resolveToCwd } from "../tools/path-utils"; +import type { TodoItem } from "../tools/todo-write"; +import { extractFileMentions, generateFileMentionMessages } from "../utils/file-mentions"; import { type CompactionResult, calculateContextTokens, diff --git a/packages/coding-agent/src/session/agent-storage.ts b/packages/coding-agent/src/session/agent-storage.ts index 81e020b63..3e889c21b 100644 --- a/packages/coding-agent/src/session/agent-storage.ts +++ b/packages/coding-agent/src/session/agent-storage.ts @@ -1,9 +1,9 @@ import { Database } from "bun:sqlite"; import { chmodSync, existsSync, mkdirSync } from "node:fs"; import { dirname } from "node:path"; -import { getAgentDbPath } from "@oh-my-pi/pi-coding-agent/config"; -import type { Settings } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; import { logger } from "@oh-my-pi/pi-utils"; +import { getAgentDbPath } from "../config"; +import type { Settings } from "../config/settings-manager"; import type { AuthCredential } from "./auth-storage"; /** Prepared SQLite statement type from bun:sqlite */ diff --git a/packages/coding-agent/src/session/auth-storage.ts b/packages/coding-agent/src/session/auth-storage.ts index 1d1adcbb9..f6cc3e8f8 100644 --- a/packages/coding-agent/src/session/auth-storage.ts +++ b/packages/coding-agent/src/session/auth-storage.ts @@ -32,8 +32,8 @@ import { type UsageReport, zaiUsageProvider, } from "@oh-my-pi/pi-ai"; -import { getAgentDbPath, getAuthPath } from "@oh-my-pi/pi-coding-agent/config"; import { logger } from "@oh-my-pi/pi-utils"; +import { getAgentDbPath, getAuthPath } from "../config"; import { AgentStorage } from "./agent-storage"; import { migrateJsonStorage } from "./storage-migration"; diff --git a/packages/coding-agent/src/session/compaction/branch-summarization.ts b/packages/coding-agent/src/session/compaction/branch-summarization.ts index 540cef111..9a0e00b16 100644 --- a/packages/coding-agent/src/session/compaction/branch-summarization.ts +++ b/packages/coding-agent/src/session/compaction/branch-summarization.ts @@ -8,18 +8,16 @@ import type { AgentMessage } from "@oh-my-pi/pi-agent-core"; import type { Model } from "@oh-my-pi/pi-ai"; import { completeSimple } from "@oh-my-pi/pi-ai"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import branchSummaryPrompt from "@oh-my-pi/pi-coding-agent/prompts/compaction/branch-summary.md" with { type: "text" }; -import branchSummaryPreamble from "@oh-my-pi/pi-coding-agent/prompts/compaction/branch-summary-preamble.md" with { - type: "text", -}; +import { renderPromptTemplate } from "../../config/prompt-templates"; +import branchSummaryPrompt from "../../prompts/compaction/branch-summary.md" with { type: "text" }; +import branchSummaryPreamble from "../../prompts/compaction/branch-summary-preamble.md" with { type: "text" }; import { convertToLlm, createBranchSummaryMessage, createCompactionSummaryMessage, createCustomMessage, -} from "@oh-my-pi/pi-coding-agent/session/messages"; -import type { ReadonlySessionManager, SessionEntry } from "@oh-my-pi/pi-coding-agent/session/session-manager"; +} from "../../session/messages"; +import type { ReadonlySessionManager, SessionEntry } from "../../session/session-manager"; import { estimateTokens } from "./compaction"; import { computeFileLists, diff --git a/packages/coding-agent/src/session/compaction/compaction.ts b/packages/coding-agent/src/session/compaction/compaction.ts index 93c456460..f8accaefd 100644 --- a/packages/coding-agent/src/session/compaction/compaction.ts +++ b/packages/coding-agent/src/session/compaction/compaction.ts @@ -8,22 +8,12 @@ import type { AgentMessage } from "@oh-my-pi/pi-agent-core"; import type { AssistantMessage, Model, Usage } from "@oh-my-pi/pi-ai"; import { completeSimple } from "@oh-my-pi/pi-ai"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import compactionSummaryPrompt from "@oh-my-pi/pi-coding-agent/prompts/compaction/compaction-summary.md" with { - type: "text", -}; -import compactionTurnPrefixPrompt from "@oh-my-pi/pi-coding-agent/prompts/compaction/compaction-turn-prefix.md" with { - type: "text", -}; -import compactionUpdateSummaryPrompt from "@oh-my-pi/pi-coding-agent/prompts/compaction/compaction-update-summary.md" with { - type: "text", -}; -import { - convertToLlm, - createBranchSummaryMessage, - createCustomMessage, -} from "@oh-my-pi/pi-coding-agent/session/messages"; -import type { CompactionEntry, SessionEntry } from "@oh-my-pi/pi-coding-agent/session/session-manager"; +import { renderPromptTemplate } from "../../config/prompt-templates"; +import compactionSummaryPrompt from "../../prompts/compaction/compaction-summary.md" with { type: "text" }; +import compactionTurnPrefixPrompt from "../../prompts/compaction/compaction-turn-prefix.md" with { type: "text" }; +import compactionUpdateSummaryPrompt from "../../prompts/compaction/compaction-update-summary.md" with { type: "text" }; +import { convertToLlm, createBranchSummaryMessage, createCustomMessage } from "../../session/messages"; +import type { CompactionEntry, SessionEntry } from "../../session/session-manager"; import { computeFileLists, createFileOps, diff --git a/packages/coding-agent/src/session/compaction/utils.ts b/packages/coding-agent/src/session/compaction/utils.ts index 8188fde35..5be94dd08 100644 --- a/packages/coding-agent/src/session/compaction/utils.ts +++ b/packages/coding-agent/src/session/compaction/utils.ts @@ -4,11 +4,9 @@ import type { AgentMessage } from "@oh-my-pi/pi-agent-core"; import type { Message } from "@oh-my-pi/pi-ai"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import fileOperationsTemplate from "@oh-my-pi/pi-coding-agent/prompts/system/file-operations.md" with { type: "text" }; -import summarizationSystemPrompt from "@oh-my-pi/pi-coding-agent/prompts/system/summarization-system.md" with { - type: "text", -}; +import { renderPromptTemplate } from "../../config/prompt-templates"; +import fileOperationsTemplate from "../../prompts/system/file-operations.md" with { type: "text" }; +import summarizationSystemPrompt from "../../prompts/system/summarization-system.md" with { type: "text" }; // ============================================================================ // File Operation Tracking diff --git a/packages/coding-agent/src/session/history-storage.ts b/packages/coding-agent/src/session/history-storage.ts index 665299d97..f32134d33 100644 --- a/packages/coding-agent/src/session/history-storage.ts +++ b/packages/coding-agent/src/session/history-storage.ts @@ -1,8 +1,8 @@ import { Database } from "bun:sqlite"; import { mkdirSync } from "node:fs"; import { dirname, join } from "node:path"; -import { getAgentDir } from "@oh-my-pi/pi-coding-agent/config"; import { logger } from "@oh-my-pi/pi-utils"; +import { getAgentDir } from "../config"; export interface HistoryEntry { id: number; diff --git a/packages/coding-agent/src/session/messages.ts b/packages/coding-agent/src/session/messages.ts index dd37843a3..76fbcb442 100644 --- a/packages/coding-agent/src/session/messages.ts +++ b/packages/coding-agent/src/session/messages.ts @@ -7,8 +7,8 @@ import type { AgentMessage } from "@oh-my-pi/pi-agent-core"; import type { ImageContent, Message, TextContent } from "@oh-my-pi/pi-ai"; -import type { OutputMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; -import { formatOutputNotice } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; +import type { OutputMeta } from "../tools/output-meta"; +import { formatOutputNotice } from "../tools/output-meta"; export const COMPACTION_SUMMARY_PREFIX = `The conversation history before this point was compacted into the following summary: diff --git a/packages/coding-agent/src/session/session-manager.ts b/packages/coding-agent/src/session/session-manager.ts index 240dfd4ec..0a4f18ba4 100644 --- a/packages/coding-agent/src/session/session-manager.ts +++ b/packages/coding-agent/src/session/session-manager.ts @@ -1,10 +1,10 @@ import { basename, join, resolve } from "node:path"; import type { AgentMessage } from "@oh-my-pi/pi-agent-core"; import type { ImageContent, Message, TextContent, Usage } from "@oh-my-pi/pi-ai"; -import { getAgentDir as getDefaultAgentDir } from "@oh-my-pi/pi-coding-agent/config"; -import { resizeImage } from "@oh-my-pi/pi-coding-agent/utils/image-resize"; import { logger } from "@oh-my-pi/pi-utils"; import { nanoid } from "nanoid"; +import { getAgentDir as getDefaultAgentDir } from "../config"; +import { resizeImage } from "../utils/image-resize"; import { type BashExecutionMessage, type CustomMessage, diff --git a/packages/coding-agent/src/session/storage-migration.ts b/packages/coding-agent/src/session/storage-migration.ts index 314489e94..d9e8100f1 100644 --- a/packages/coding-agent/src/session/storage-migration.ts +++ b/packages/coding-agent/src/session/storage-migration.ts @@ -7,8 +7,8 @@ * which migrates from both settings.json and agent.db to config.yaml. */ -import { getAgentDbPath } from "@oh-my-pi/pi-coding-agent/config"; import { logger } from "@oh-my-pi/pi-utils"; +import { getAgentDbPath } from "../config"; import { AgentStorage } from "./agent-storage"; import type { AuthCredential, AuthCredentialEntry, AuthStorageData } from "./auth-storage"; diff --git a/packages/coding-agent/src/session/streaming-output.ts b/packages/coding-agent/src/session/streaming-output.ts index 7611dc3fc..f1c1d40e5 100644 --- a/packages/coding-agent/src/session/streaming-output.ts +++ b/packages/coding-agent/src/session/streaming-output.ts @@ -1,5 +1,5 @@ -import { DEFAULT_MAX_BYTES } from "@oh-my-pi/pi-coding-agent/tools/truncate"; import { sanitizeText } from "@oh-my-pi/pi-utils"; +import { DEFAULT_MAX_BYTES } from "../tools/truncate"; export interface OutputSummary { output: string; diff --git a/packages/coding-agent/src/ssh/connection-manager.ts b/packages/coding-agent/src/ssh/connection-manager.ts index 453cbf0a3..074f03b0b 100644 --- a/packages/coding-agent/src/ssh/connection-manager.ts +++ b/packages/coding-agent/src/ssh/connection-manager.ts @@ -1,9 +1,9 @@ import { chmodSync, existsSync, mkdirSync, readFileSync, statSync } from "node:fs"; import { homedir } from "node:os"; import { join } from "node:path"; -import { CONFIG_DIR_NAME } from "@oh-my-pi/pi-coding-agent/config"; import { logger } from "@oh-my-pi/pi-utils"; import { $ } from "bun"; +import { CONFIG_DIR_NAME } from "../config"; export interface SSHConnectionTarget { name: string; diff --git a/packages/coding-agent/src/ssh/ssh-executor.ts b/packages/coding-agent/src/ssh/ssh-executor.ts index 86afd7db4..a234c1a44 100644 --- a/packages/coding-agent/src/ssh/ssh-executor.ts +++ b/packages/coding-agent/src/ssh/ssh-executor.ts @@ -1,5 +1,5 @@ -import { OutputSink } from "@oh-my-pi/pi-coding-agent/session/streaming-output"; import { cspawn, logger, ptree } from "@oh-my-pi/pi-utils"; +import { OutputSink } from "../session/streaming-output"; import { buildRemoteCommand, ensureConnection, ensureHostInfo, type SSHConnectionTarget } from "./connection-manager"; import { hasSshfs, mountRemote } from "./sshfs-mount"; diff --git a/packages/coding-agent/src/ssh/sshfs-mount.ts b/packages/coding-agent/src/ssh/sshfs-mount.ts index 784777265..520e2d8e3 100644 --- a/packages/coding-agent/src/ssh/sshfs-mount.ts +++ b/packages/coding-agent/src/ssh/sshfs-mount.ts @@ -1,9 +1,9 @@ import { chmodSync, existsSync, mkdirSync } from "node:fs"; import { homedir } from "node:os"; import { join } from "node:path"; -import { CONFIG_DIR_NAME } from "@oh-my-pi/pi-coding-agent/config"; import { logger } from "@oh-my-pi/pi-utils"; import { $ } from "bun"; +import { CONFIG_DIR_NAME } from "../config"; import { getControlDir, getControlPathTemplate, type SSHConnectionTarget } from "./connection-manager"; const REMOTE_DIR = join(homedir(), CONFIG_DIR_NAME, "remote"); diff --git a/packages/coding-agent/src/system-prompt.ts b/packages/coding-agent/src/system-prompt.ts index e6af7655b..bf96c2e7b 100644 --- a/packages/coding-agent/src/system-prompt.ts +++ b/packages/coding-agent/src/system-prompt.ts @@ -5,22 +5,16 @@ import { existsSync } from "node:fs"; import { homedir } from "node:os"; import { join } from "node:path"; -import { contextFileCapability } from "@oh-my-pi/pi-coding-agent/capability/context-file"; -import { systemPromptCapability } from "@oh-my-pi/pi-coding-agent/capability/system-prompt"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import type { SkillsSettings } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import { - type ContextFile, - loadCapability, - type SystemPrompt as SystemPromptFile, -} from "@oh-my-pi/pi-coding-agent/discovery"; -import { loadSkills, type Skill } from "@oh-my-pi/pi-coding-agent/extensibility/skills"; -import customSystemPromptTemplate from "@oh-my-pi/pi-coding-agent/prompts/system/custom-system-prompt.md" with { - type: "text", -}; -import systemPromptTemplate from "@oh-my-pi/pi-coding-agent/prompts/system/system-prompt.md" with { type: "text" }; import { $ } from "bun"; import chalk from "chalk"; +import { contextFileCapability } from "./capability/context-file"; +import { systemPromptCapability } from "./capability/system-prompt"; +import { renderPromptTemplate } from "./config/prompt-templates"; +import type { SkillsSettings } from "./config/settings-manager"; +import { type ContextFile, loadCapability, type SystemPrompt as SystemPromptFile } from "./discovery"; +import { loadSkills, type Skill } from "./extensibility/skills"; +import customSystemPromptTemplate from "./prompts/system/custom-system-prompt.md" with { type: "text" }; +import systemPromptTemplate from "./prompts/system/system-prompt.md" with { type: "text" }; import type { ToolName } from "./tools"; interface GitContext { diff --git a/packages/coding-agent/src/task/agents.ts b/packages/coding-agent/src/task/agents.ts index f0ab56c7c..4d9642172 100644 --- a/packages/coding-agent/src/task/agents.ts +++ b/packages/coding-agent/src/task/agents.ts @@ -4,15 +4,15 @@ * Agents are embedded at build time via Bun's import with { type: "text" }. */ -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import { parseAgentFields } from "@oh-my-pi/pi-coding-agent/discovery/helpers"; -import exploreMd from "@oh-my-pi/pi-coding-agent/prompts/agents/explore.md" with { type: "text" }; +import { renderPromptTemplate } from "../config/prompt-templates"; +import { parseAgentFields } from "../discovery/helpers"; +import exploreMd from "../prompts/agents/explore.md" with { type: "text" }; // Embed agent markdown files at build time -import agentFrontmatterTemplate from "@oh-my-pi/pi-coding-agent/prompts/agents/frontmatter.md" with { type: "text" }; -import planMd from "@oh-my-pi/pi-coding-agent/prompts/agents/plan.md" with { type: "text" }; -import reviewerMd from "@oh-my-pi/pi-coding-agent/prompts/agents/reviewer.md" with { type: "text" }; -import taskMd from "@oh-my-pi/pi-coding-agent/prompts/agents/task.md" with { type: "text" }; -import { parseFrontmatter } from "@oh-my-pi/pi-coding-agent/utils/frontmatter"; +import agentFrontmatterTemplate from "../prompts/agents/frontmatter.md" with { type: "text" }; +import planMd from "../prompts/agents/plan.md" with { type: "text" }; +import reviewerMd from "../prompts/agents/reviewer.md" with { type: "text" }; +import taskMd from "../prompts/agents/task.md" with { type: "text" }; +import { parseFrontmatter } from "../utils/frontmatter"; import type { AgentDefinition, AgentSource } from "./types"; interface AgentFrontmatter { diff --git a/packages/coding-agent/src/task/commands.ts b/packages/coding-agent/src/task/commands.ts index 9e4ae19dc..0422a9157 100644 --- a/packages/coding-agent/src/task/commands.ts +++ b/packages/coding-agent/src/task/commands.ts @@ -5,12 +5,12 @@ */ import * as path from "node:path"; -import { type SlashCommand, slashCommandCapability } from "@oh-my-pi/pi-coding-agent/capability/slash-command"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import { loadCapability } from "@oh-my-pi/pi-coding-agent/discovery"; +import { type SlashCommand, slashCommandCapability } from "../capability/slash-command"; +import { renderPromptTemplate } from "../config/prompt-templates"; +import { loadCapability } from "../discovery"; // Embed command markdown files at build time -import initMd from "@oh-my-pi/pi-coding-agent/prompts/agents/init.md" with { type: "text" }; -import { parseFrontmatter } from "@oh-my-pi/pi-coding-agent/utils/frontmatter"; +import initMd from "../prompts/agents/init.md" with { type: "text" }; +import { parseFrontmatter } from "../utils/frontmatter"; const EMBEDDED_COMMANDS: { name: string; content: string }[] = [ { name: "init.md", content: renderPromptTemplate(initMd) }, diff --git a/packages/coding-agent/src/task/discovery.ts b/packages/coding-agent/src/task/discovery.ts index 8424122e7..478f8406c 100644 --- a/packages/coding-agent/src/task/discovery.ts +++ b/packages/coding-agent/src/task/discovery.ts @@ -14,9 +14,9 @@ import * as fs from "node:fs"; import * as path from "node:path"; -import { findAllNearestProjectConfigDirs, getConfigDirs } from "@oh-my-pi/pi-coding-agent/config"; -import { parseAgentFields } from "@oh-my-pi/pi-coding-agent/discovery/helpers"; -import { parseFrontmatter } from "@oh-my-pi/pi-coding-agent/utils/frontmatter"; +import { findAllNearestProjectConfigDirs, getConfigDirs } from "../config"; +import { parseAgentFields } from "../discovery/helpers"; +import { parseFrontmatter } from "../utils/frontmatter"; import { loadBundledAgents } from "./agents"; import type { AgentDefinition, AgentSource } from "./types"; diff --git a/packages/coding-agent/src/task/executor.ts b/packages/coding-agent/src/task/executor.ts index a20f8c7d0..be332db8a 100644 --- a/packages/coding-agent/src/task/executor.ts +++ b/packages/coding-agent/src/task/executor.ts @@ -6,17 +6,17 @@ import path from "node:path"; import type { AgentEvent, ThinkingLevel } from "@oh-my-pi/pi-agent-core"; -import type { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry"; -import { formatModelString, parseModelPattern } from "@oh-my-pi/pi-coding-agent/config/model-resolver"; -import { checkPythonKernelAvailability } from "@oh-my-pi/pi-coding-agent/ipy/kernel"; -import { LspTool } from "@oh-my-pi/pi-coding-agent/lsp"; -import type { LspParams } from "@oh-my-pi/pi-coding-agent/lsp/types"; -import { callTool } from "@oh-my-pi/pi-coding-agent/mcp/client"; -import type { MCPManager } from "@oh-my-pi/pi-coding-agent/mcp/manager"; -import type { AuthStorage } from "@oh-my-pi/pi-coding-agent/session/auth-storage"; -import { PythonTool, type PythonToolParams } from "@oh-my-pi/pi-coding-agent/tools/python"; -import type { EventBus } from "@oh-my-pi/pi-coding-agent/utils/event-bus"; import type { ToolSession } from ".."; +import type { ModelRegistry } from "../config/model-registry"; +import { formatModelString, parseModelPattern } from "../config/model-resolver"; +import { checkPythonKernelAvailability } from "../ipy/kernel"; +import { LspTool } from "../lsp"; +import type { LspParams } from "../lsp/types"; +import { callTool } from "../mcp/client"; +import type { MCPManager } from "../mcp/manager"; +import type { AuthStorage } from "../session/auth-storage"; +import { PythonTool, type PythonToolParams } from "../tools/python"; +import type { EventBus } from "../utils/event-bus"; import { subprocessToolRegistry } from "./subprocess-tool-registry"; import { type AgentDefinition, diff --git a/packages/coding-agent/src/task/index.ts b/packages/coding-agent/src/task/index.ts index 1a15d91b9..09ab5e9cb 100644 --- a/packages/coding-agent/src/task/index.ts +++ b/packages/coding-agent/src/task/index.ts @@ -18,16 +18,16 @@ import { tmpdir } from "node:os"; import path from "node:path"; import type { AgentTool, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; import type { Usage } from "@oh-my-pi/pi-ai"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import taskDescriptionTemplate from "@oh-my-pi/pi-coding-agent/prompts/tools/task.md" with { type: "text" }; -import { AgentOutputManager } from "@oh-my-pi/pi-coding-agent/task/output-manager"; -import { formatDuration } from "@oh-my-pi/pi-coding-agent/tools/render-utils"; import { $ } from "bun"; import { nanoid } from "nanoid"; import type { ToolSession } from ".."; +import { renderPromptTemplate } from "../config/prompt-templates"; +import type { Theme } from "../modes/theme/theme"; +import taskDescriptionTemplate from "../prompts/tools/task.md" with { type: "text" }; +import { formatDuration } from "../tools/render-utils"; import { discoverAgents, getAgent } from "./discovery"; import { runSubprocess } from "./executor"; +import { AgentOutputManager } from "./output-manager"; import { mapWithConcurrencyLimit } from "./parallel"; import { renderCall, renderResult } from "./render"; import { renderTemplate } from "./template"; diff --git a/packages/coding-agent/src/task/render.ts b/packages/coding-agent/src/task/render.ts index 22626c507..3e942f1fb 100644 --- a/packages/coding-agent/src/task/render.ts +++ b/packages/coding-agent/src/task/render.ts @@ -6,8 +6,10 @@ */ import path from "node:path"; -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; +import type { Component } from "@oh-my-pi/pi-tui"; +import { Container, Text } from "@oh-my-pi/pi-tui"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import type { Theme } from "../modes/theme/theme"; import { formatBadge, formatDuration, @@ -15,17 +17,15 @@ import { formatStatusIcon, formatTokens, truncate, -} from "@oh-my-pi/pi-coding-agent/tools/render-utils"; +} from "../tools/render-utils"; import { type FindingPriority, getPriorityInfo, PRIORITY_LABELS, type ReportFindingDetails, type SubmitReviewDetails, -} from "@oh-my-pi/pi-coding-agent/tools/review"; -import { renderStatusLine } from "@oh-my-pi/pi-coding-agent/tui"; -import type { Component } from "@oh-my-pi/pi-tui"; -import { Container, Text } from "@oh-my-pi/pi-tui"; +} from "../tools/review"; +import { renderStatusLine } from "../tui"; import { subprocessToolRegistry } from "./subprocess-tool-registry"; import type { AgentProgress, SingleResult, TaskParams, TaskToolDetails } from "./types"; diff --git a/packages/coding-agent/src/task/subprocess-tool-registry.ts b/packages/coding-agent/src/task/subprocess-tool-registry.ts index 7c7680168..13462fa5e 100644 --- a/packages/coding-agent/src/task/subprocess-tool-registry.ts +++ b/packages/coding-agent/src/task/subprocess-tool-registry.ts @@ -7,8 +7,8 @@ * - Provide custom rendering for realtime/final display */ -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import type { Component } from "@oh-my-pi/pi-tui"; +import type { Theme } from "../modes/theme/theme"; /** Event from subprocess tool execution (parsed from JSONL) */ export interface SubprocessToolEvent { diff --git a/packages/coding-agent/src/task/worker-protocol.ts b/packages/coding-agent/src/task/worker-protocol.ts index e07388ab8..2604d3a12 100644 --- a/packages/coding-agent/src/task/worker-protocol.ts +++ b/packages/coding-agent/src/task/worker-protocol.ts @@ -1,7 +1,7 @@ import type { AgentEvent, ThinkingLevel } from "@oh-my-pi/pi-agent-core"; -import type { SerializedModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry"; -import type { Settings } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import type { SerializedAuthStorage } from "@oh-my-pi/pi-coding-agent/session/auth-storage"; +import type { SerializedModelRegistry } from "../config/model-registry"; +import type { Settings } from "../config/settings-manager"; +import type { SerializedAuthStorage } from "../session/auth-storage"; /** * MCP tool metadata passed from parent to worker for proxy tool creation. diff --git a/packages/coding-agent/src/task/worker.ts b/packages/coding-agent/src/task/worker.ts index 817e2e354..82380e1ce 100644 --- a/packages/coding-agent/src/task/worker.ts +++ b/packages/coding-agent/src/task/worker.ts @@ -15,26 +15,21 @@ import type { AgentEvent, ThinkingLevel } from "@oh-my-pi/pi-agent-core"; import type { Api, Model } from "@oh-my-pi/pi-ai"; -import { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry"; -import { parseModelPattern, parseModelString } from "@oh-my-pi/pi-coding-agent/config/model-resolver"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import { type LspToolDetails, lspSchema } from "@oh-my-pi/pi-coding-agent/lsp/types"; -import lspDescription from "@oh-my-pi/pi-coding-agent/prompts/tools/lsp.md" with { type: "text" }; -import { createAgentSession, discoverAuthStorage, discoverModels } from "@oh-my-pi/pi-coding-agent/sdk"; -import type { AgentSessionEvent } from "@oh-my-pi/pi-coding-agent/session/agent-session"; -import { AuthStorage } from "@oh-my-pi/pi-coding-agent/session/auth-storage"; -import { SessionManager } from "@oh-my-pi/pi-coding-agent/session/session-manager"; -import { - getPythonToolDescription, - type PythonToolDetails, - type PythonToolParams, - pythonSchema, -} from "@oh-my-pi/pi-coding-agent/tools/python"; -import { ToolAbortError } from "@oh-my-pi/pi-coding-agent/tools/tool-errors"; import { logger, postmortem, untilAborted } from "@oh-my-pi/pi-utils"; import type { TSchema } from "@sinclair/typebox"; +import { ModelRegistry } from "../config/model-registry"; +import { parseModelPattern, parseModelString } from "../config/model-resolver"; +import { renderPromptTemplate } from "../config/prompt-templates"; +import { SettingsManager } from "../config/settings-manager"; +import type { CustomTool } from "../extensibility/custom-tools/types"; +import { type LspToolDetails, lspSchema } from "../lsp/types"; +import lspDescription from "../prompts/tools/lsp.md" with { type: "text" }; +import { createAgentSession, discoverAuthStorage, discoverModels } from "../sdk"; +import type { AgentSessionEvent } from "../session/agent-session"; +import { AuthStorage } from "../session/auth-storage"; +import { SessionManager } from "../session/session-manager"; +import { getPythonToolDescription, type PythonToolDetails, type PythonToolParams, pythonSchema } from "../tools/python"; +import { ToolAbortError } from "../tools/tool-errors"; import type { LspToolCallResponse, MCPToolCallResponse, diff --git a/packages/coding-agent/src/tools/ask.ts b/packages/coding-agent/src/tools/ask.ts index b1c27d5e0..71fa048d6 100644 --- a/packages/coding-agent/src/tools/ask.ts +++ b/packages/coding-agent/src/tools/ask.ts @@ -16,14 +16,14 @@ */ import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import { type Theme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import askDescription from "@oh-my-pi/pi-coding-agent/prompts/tools/ask.md" with { type: "text" }; -import { renderStatusLine } from "@oh-my-pi/pi-coding-agent/tui"; import type { Component } from "@oh-my-pi/pi-tui"; import { Text } from "@oh-my-pi/pi-tui"; import { Type } from "@sinclair/typebox"; +import { renderPromptTemplate } from "../config/prompt-templates"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import { type Theme, theme } from "../modes/theme/theme"; +import askDescription from "../prompts/tools/ask.md" with { type: "text" }; +import { renderStatusLine } from "../tui"; import type { ToolSession } from "."; import { ToolUIKit } from "./render-utils"; diff --git a/packages/coding-agent/src/tools/bash-interceptor.ts b/packages/coding-agent/src/tools/bash-interceptor.ts index 6fa274475..e7f0735fe 100644 --- a/packages/coding-agent/src/tools/bash-interceptor.ts +++ b/packages/coding-agent/src/tools/bash-interceptor.ts @@ -6,10 +6,7 @@ * the specialized tools instead. */ -import { - type BashInterceptorRule, - DEFAULT_BASH_INTERCEPTOR_RULES, -} from "@oh-my-pi/pi-coding-agent/config/settings-manager"; +import { type BashInterceptorRule, DEFAULT_BASH_INTERCEPTOR_RULES } from "../config/settings-manager"; export interface InterceptionResult { /** If true, the bash command should be blocked */ diff --git a/packages/coding-agent/src/tools/bash.ts b/packages/coding-agent/src/tools/bash.ts index 4f5038644..833a17855 100644 --- a/packages/coding-agent/src/tools/bash.ts +++ b/packages/coding-agent/src/tools/bash.ts @@ -1,22 +1,22 @@ import { relative, resolve, sep } from "node:path"; import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import { type BashExecutorOptions, executeBash } from "@oh-my-pi/pi-coding-agent/exec/bash-executor"; -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import { truncateToVisualLines } from "@oh-my-pi/pi-coding-agent/modes/components/visual-truncate"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import bashDescription from "@oh-my-pi/pi-coding-agent/prompts/tools/bash.md" with { type: "text" }; -import type { OutputMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; -import { ToolError } from "@oh-my-pi/pi-coding-agent/tools/tool-errors"; -import { renderOutputBlock, renderStatusLine } from "@oh-my-pi/pi-coding-agent/tui"; import type { Component } from "@oh-my-pi/pi-tui"; import { Text } from "@oh-my-pi/pi-tui"; import { Type } from "@sinclair/typebox"; +import { renderPromptTemplate } from "../config/prompt-templates"; +import { type BashExecutorOptions, executeBash } from "../exec/bash-executor"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import { truncateToVisualLines } from "../modes/components/visual-truncate"; +import type { Theme } from "../modes/theme/theme"; +import bashDescription from "../prompts/tools/bash.md" with { type: "text" }; +import { renderOutputBlock, renderStatusLine } from "../tui"; import type { ToolSession } from "."; import { checkBashInterception, checkSimpleLsInterception } from "./bash-interceptor"; +import type { OutputMeta } from "./output-meta"; import { allocateOutputArtifact, createTailBuffer } from "./output-utils"; import { resolveToCwd } from "./path-utils"; import { formatBytes, wrapBrackets } from "./render-utils"; +import { ToolError } from "./tool-errors"; import { toolResult } from "./tool-result"; import { DEFAULT_MAX_BYTES } from "./truncate"; diff --git a/packages/coding-agent/src/tools/calculator.ts b/packages/coding-agent/src/tools/calculator.ts index 96cc9d7bf..8b62a7dba 100644 --- a/packages/coding-agent/src/tools/calculator.ts +++ b/packages/coding-agent/src/tools/calculator.ts @@ -1,13 +1,13 @@ import type { AgentTool, AgentToolResult } from "@oh-my-pi/pi-agent-core"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import calculatorDescription from "@oh-my-pi/pi-coding-agent/prompts/tools/calculator.md" with { type: "text" }; -import { renderStatusLine, renderTreeList } from "@oh-my-pi/pi-coding-agent/tui"; import type { Component } from "@oh-my-pi/pi-tui"; import { Text } from "@oh-my-pi/pi-tui"; import { untilAborted } from "@oh-my-pi/pi-utils"; import { Type } from "@sinclair/typebox"; +import { renderPromptTemplate } from "../config/prompt-templates"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import type { Theme } from "../modes/theme/theme"; +import calculatorDescription from "../prompts/tools/calculator.md" with { type: "text" }; +import { renderStatusLine, renderTreeList } from "../tui"; import type { ToolSession } from "."; import { formatCount, diff --git a/packages/coding-agent/src/tools/complete.ts b/packages/coding-agent/src/tools/complete.ts index 6720c37b7..6ff957320 100644 --- a/packages/coding-agent/src/tools/complete.ts +++ b/packages/coding-agent/src/tools/complete.ts @@ -6,10 +6,10 @@ import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; import { StringEnum } from "@oh-my-pi/pi-ai"; -import { subprocessToolRegistry } from "@oh-my-pi/pi-coding-agent/task/subprocess-tool-registry"; import type { Static, TObject } from "@sinclair/typebox"; import { Type } from "@sinclair/typebox"; import Ajv, { type ErrorObject, type ValidateFunction } from "ajv"; +import { subprocessToolRegistry } from "../task/subprocess-tool-registry"; import type { ToolSession } from "."; import { jtdToJsonSchema } from "./jtd-to-json-schema"; diff --git a/packages/coding-agent/src/tools/context.ts b/packages/coding-agent/src/tools/context.ts index 659f9a059..347e86174 100644 --- a/packages/coding-agent/src/tools/context.ts +++ b/packages/coding-agent/src/tools/context.ts @@ -1,6 +1,6 @@ import type { AgentToolContext, ToolCallContext } from "@oh-my-pi/pi-agent-core"; -import type { CustomToolContext } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import type { ExtensionUIContext } from "@oh-my-pi/pi-coding-agent/extensibility/extensions/types"; +import type { CustomToolContext } from "../extensibility/custom-tools/types"; +import type { ExtensionUIContext } from "../extensibility/extensions/types"; declare module "@oh-my-pi/pi-agent-core" { interface AgentToolContext extends CustomToolContext { diff --git a/packages/coding-agent/src/tools/fetch.ts b/packages/coding-agent/src/tools/fetch.ts index 3cc372680..f158df54b 100644 --- a/packages/coding-agent/src/tools/fetch.ts +++ b/packages/coding-agent/src/tools/fetch.ts @@ -1,27 +1,27 @@ import { mkdir, rm } from "node:fs/promises"; import * as path from "node:path"; import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import { type Theme, theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import fetchDescription from "@oh-my-pi/pi-coding-agent/prompts/tools/fetch.md" with { type: "text" }; -import type { OutputMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; -import { ToolAbortError } from "@oh-my-pi/pi-coding-agent/tools/tool-errors"; -import { renderOutputBlock, renderStatusLine } from "@oh-my-pi/pi-coding-agent/tui"; -import { ensureTool } from "@oh-my-pi/pi-coding-agent/utils/tools-manager"; -import { specialHandlers } from "@oh-my-pi/pi-coding-agent/web/scrapers"; -import type { RenderResult } from "@oh-my-pi/pi-coding-agent/web/scrapers/types"; -import { finalizeOutput, loadPage, MAX_OUTPUT_CHARS } from "@oh-my-pi/pi-coding-agent/web/scrapers/types"; -import { convertWithMarkitdown, fetchBinary } from "@oh-my-pi/pi-coding-agent/web/scrapers/utils"; import type { Component } from "@oh-my-pi/pi-tui"; import { Text } from "@oh-my-pi/pi-tui"; import { ptree } from "@oh-my-pi/pi-utils"; import { type Static, Type } from "@sinclair/typebox"; import { nanoid } from "nanoid"; import { parse as parseHtml } from "node-html-parser"; +import { renderPromptTemplate } from "../config/prompt-templates"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import { type Theme, theme } from "../modes/theme/theme"; +import fetchDescription from "../prompts/tools/fetch.md" with { type: "text" }; +import { renderOutputBlock, renderStatusLine } from "../tui"; +import { ensureTool } from "../utils/tools-manager"; +import { specialHandlers } from "../web/scrapers"; +import type { RenderResult } from "../web/scrapers/types"; +import { finalizeOutput, loadPage, MAX_OUTPUT_CHARS } from "../web/scrapers/types"; +import { convertWithMarkitdown, fetchBinary } from "../web/scrapers/utils"; import type { ToolSession } from "."; import { applyListLimit } from "./list-limit"; +import type { OutputMeta } from "./output-meta"; import { formatExpandHint } from "./render-utils"; +import { ToolAbortError } from "./tool-errors"; import { toolResult } from "./tool-result"; // ============================================================================= diff --git a/packages/coding-agent/src/tools/find.ts b/packages/coding-agent/src/tools/find.ts index 98e6cee91..934a20bf7 100644 --- a/packages/coding-agent/src/tools/find.ts +++ b/packages/coding-agent/src/tools/find.ts @@ -1,24 +1,23 @@ import path from "node:path"; import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; import { StringEnum } from "@oh-my-pi/pi-ai"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import findDescription from "@oh-my-pi/pi-coding-agent/prompts/tools/find.md" with { type: "text" }; -import type { OutputMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; -import { ToolAbortError, ToolError, throwIfAborted } from "@oh-my-pi/pi-coding-agent/tools/tool-errors"; -import { renderFileList, renderStatusLine, renderTreeList } from "@oh-my-pi/pi-coding-agent/tui"; -import { ensureTool } from "@oh-my-pi/pi-coding-agent/utils/tools-manager"; import type { Component } from "@oh-my-pi/pi-tui"; import { Text } from "@oh-my-pi/pi-tui"; import { ptree, untilAborted } from "@oh-my-pi/pi-utils"; import type { Static } from "@sinclair/typebox"; import { Type } from "@sinclair/typebox"; - +import { renderPromptTemplate } from "../config/prompt-templates"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import type { Theme } from "../modes/theme/theme"; +import findDescription from "../prompts/tools/find.md" with { type: "text" }; +import { renderFileList, renderStatusLine, renderTreeList } from "../tui"; +import { ensureTool } from "../utils/tools-manager"; import type { ToolSession } from "."; import { applyListLimit } from "./list-limit"; +import type { OutputMeta } from "./output-meta"; import { resolveToCwd } from "./path-utils"; import { formatCount, formatEmptyMessage, formatErrorMessage, PREVIEW_LIMITS } from "./render-utils"; +import { ToolAbortError, ToolError, throwIfAborted } from "./tool-errors"; import { toolResult } from "./tool-result"; import { type TruncationResult, truncateHead } from "./truncate"; diff --git a/packages/coding-agent/src/tools/gemini-image.ts b/packages/coding-agent/src/tools/gemini-image.ts index 1cce00be8..905354ec6 100644 --- a/packages/coding-agent/src/tools/gemini-image.ts +++ b/packages/coding-agent/src/tools/gemini-image.ts @@ -1,15 +1,15 @@ import { tmpdir } from "node:os"; import { join } from "node:path"; import { StringEnum } from "@oh-my-pi/pi-ai"; -import type { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import geminiImageDescription from "@oh-my-pi/pi-coding-agent/prompts/tools/gemini-image.md" with { type: "text" }; -import { detectSupportedImageMimeTypeFromFile } from "@oh-my-pi/pi-coding-agent/utils/mime"; -import { getEnv } from "@oh-my-pi/pi-coding-agent/web/search/auth"; import { untilAborted } from "@oh-my-pi/pi-utils"; import { type Static, Type } from "@sinclair/typebox"; import { nanoid } from "nanoid"; +import type { ModelRegistry } from "../config/model-registry"; +import { renderPromptTemplate } from "../config/prompt-templates"; +import type { CustomTool } from "../extensibility/custom-tools/types"; +import geminiImageDescription from "../prompts/tools/gemini-image.md" with { type: "text" }; +import { detectSupportedImageMimeTypeFromFile } from "../utils/mime"; +import { getEnv } from "../web/search/auth"; import { resolveReadPath } from "./path-utils"; const DEFAULT_MODEL = "gemini-3-pro-image-preview"; diff --git a/packages/coding-agent/src/tools/grep.ts b/packages/coding-agent/src/tools/grep.ts index b55b6bc47..b34c7b12c 100644 --- a/packages/coding-agent/src/tools/grep.ts +++ b/packages/coding-agent/src/tools/grep.ts @@ -1,24 +1,24 @@ import nodePath from "node:path"; import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; import { StringEnum } from "@oh-my-pi/pi-ai"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import grepDescription from "@oh-my-pi/pi-coding-agent/prompts/tools/grep.md" with { type: "text" }; -import type { OutputMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; -import { ToolAbortError, ToolError } from "@oh-my-pi/pi-coding-agent/tools/tool-errors"; -import { renderFileList, renderStatusLine, renderTreeList } from "@oh-my-pi/pi-coding-agent/tui"; -import { ensureTool } from "@oh-my-pi/pi-coding-agent/utils/tools-manager"; -import { untilAborted } from "@oh-my-pi/pi-coding-agent/utils/utils"; import type { Component } from "@oh-my-pi/pi-tui"; import { Text } from "@oh-my-pi/pi-tui"; import { ptree, readLines } from "@oh-my-pi/pi-utils"; import { Type } from "@sinclair/typebox"; import { $ } from "bun"; +import { renderPromptTemplate } from "../config/prompt-templates"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import type { Theme } from "../modes/theme/theme"; +import grepDescription from "../prompts/tools/grep.md" with { type: "text" }; +import { renderFileList, renderStatusLine, renderTreeList } from "../tui"; +import { ensureTool } from "../utils/tools-manager"; +import { untilAborted } from "../utils/utils"; import type { ToolSession } from "."; import { applyListLimit } from "./list-limit"; +import type { OutputMeta } from "./output-meta"; import { resolveToCwd } from "./path-utils"; import { formatCount, formatEmptyMessage, formatErrorMessage, PREVIEW_LIMITS } from "./render-utils"; +import { ToolAbortError, ToolError } from "./tool-errors"; import { toolResult } from "./tool-result"; import { DEFAULT_MAX_COLUMN, type TruncationResult, truncateHead, truncateLine } from "./truncate"; diff --git a/packages/coding-agent/src/tools/index.ts b/packages/coding-agent/src/tools/index.ts index 0089c19ed..d3f6126d3 100644 --- a/packages/coding-agent/src/tools/index.ts +++ b/packages/coding-agent/src/tools/index.ts @@ -1,6 +1,7 @@ // Exa MCP tools (22 tools) -export { exaTools } from "@oh-my-pi/pi-coding-agent/exa"; -export type { ExaRenderDetails, ExaSearchResponse, ExaSearchResult } from "@oh-my-pi/pi-coding-agent/exa/types"; + +export { exaTools } from "../exa"; +export type { ExaRenderDetails, ExaSearchResponse, ExaSearchResult } from "../exa/types"; export { type FileDiagnosticsResult, type FileFormatResult, @@ -11,9 +12,9 @@ export { type LspWarmupOptions, type LspWarmupResult, warmupLspServers, -} from "@oh-my-pi/pi-coding-agent/lsp"; -export { EditTool, type EditToolDetails } from "@oh-my-pi/pi-coding-agent/patch"; -export { BUNDLED_AGENTS, TaskTool } from "@oh-my-pi/pi-coding-agent/task"; +} from "../lsp"; +export { EditTool, type EditToolDetails } from "../patch"; +export { BUNDLED_AGENTS, TaskTool } from "../task"; export { companyWebSearchTools, exaWebSearchTools, @@ -31,7 +32,7 @@ export { webSearchCustomTool, webSearchDeepTool, webSearchLinkedinTool, -} from "@oh-my-pi/pi-coding-agent/web/search"; +} from "../web/search"; export { AskTool, type AskToolDetails } from "./ask"; export { BashTool, type BashToolDetails, type BashToolOptions } from "./bash"; export { CalculatorTool, type CalculatorToolDetails } from "./calculator"; @@ -60,18 +61,18 @@ export { export { WriteTool, type WriteToolDetails } from "./write"; import type { AgentTool } from "@oh-my-pi/pi-agent-core"; -import type { BashInterceptorRule } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; -import type { InternalUrlRouter } from "@oh-my-pi/pi-coding-agent/internal-urls"; -import { getPreludeDocs, warmPythonEnvironment } from "@oh-my-pi/pi-coding-agent/ipy/executor"; -import { checkPythonKernelAvailability } from "@oh-my-pi/pi-coding-agent/ipy/kernel"; -import { LspTool } from "@oh-my-pi/pi-coding-agent/lsp"; -import { EditTool } from "@oh-my-pi/pi-coding-agent/patch"; -import type { ArtifactManager } from "@oh-my-pi/pi-coding-agent/session/artifacts"; -import { TaskTool } from "@oh-my-pi/pi-coding-agent/task"; -import type { AgentOutputManager } from "@oh-my-pi/pi-coding-agent/task/output-manager"; -import type { EventBus } from "@oh-my-pi/pi-coding-agent/utils/event-bus"; -import { WebSearchTool } from "@oh-my-pi/pi-coding-agent/web/search"; import { logger } from "@oh-my-pi/pi-utils"; +import type { BashInterceptorRule } from "../config/settings-manager"; +import type { InternalUrlRouter } from "../internal-urls"; +import { getPreludeDocs, warmPythonEnvironment } from "../ipy/executor"; +import { checkPythonKernelAvailability } from "../ipy/kernel"; +import { LspTool } from "../lsp"; +import { EditTool } from "../patch"; +import type { ArtifactManager } from "../session/artifacts"; +import { TaskTool } from "../task"; +import type { AgentOutputManager } from "../task/output-manager"; +import type { EventBus } from "../utils/event-bus"; +import { WebSearchTool } from "../web/search"; import { AskTool } from "./ask"; import { BashTool } from "./bash"; import { CalculatorTool } from "./calculator"; diff --git a/packages/coding-agent/src/tools/list-limit.ts b/packages/coding-agent/src/tools/list-limit.ts index 5bdcfd15b..439edfcfd 100644 --- a/packages/coding-agent/src/tools/list-limit.ts +++ b/packages/coding-agent/src/tools/list-limit.ts @@ -1,4 +1,4 @@ -import type { LimitsMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; +import type { LimitsMeta } from "./output-meta"; export interface ListLimitResult { items: T[]; diff --git a/packages/coding-agent/src/tools/ls.ts b/packages/coding-agent/src/tools/ls.ts index 7047a2208..a7cad1d3d 100644 --- a/packages/coding-agent/src/tools/ls.ts +++ b/packages/coding-agent/src/tools/ls.ts @@ -1,15 +1,14 @@ import nodePath from "node:path"; import type { AgentTool, AgentToolResult } from "@oh-my-pi/pi-agent-core"; -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { OutputMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; -import { ToolError, throwIfAborted } from "@oh-my-pi/pi-coding-agent/tools/tool-errors"; -import { renderFileList, renderStatusLine } from "@oh-my-pi/pi-coding-agent/tui"; import { type Component, Text } from "@oh-my-pi/pi-tui"; import { untilAborted } from "@oh-my-pi/pi-utils"; import { Type } from "@sinclair/typebox"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import type { Theme } from "../modes/theme/theme"; +import { renderFileList, renderStatusLine } from "../tui"; import type { ToolSession } from "."; import { applyListLimit } from "./list-limit"; +import type { OutputMeta } from "./output-meta"; import { resolveToCwd } from "./path-utils"; import { formatAge, @@ -19,6 +18,7 @@ import { formatErrorMessage, PREVIEW_LIMITS, } from "./render-utils"; +import { ToolError, throwIfAborted } from "./tool-errors"; import { toolResult } from "./tool-result"; import { type TruncationResult, truncateHead } from "./truncate"; diff --git a/packages/coding-agent/src/tools/notebook.ts b/packages/coding-agent/src/tools/notebook.ts index 6764eeaa1..bcd457c36 100644 --- a/packages/coding-agent/src/tools/notebook.ts +++ b/packages/coding-agent/src/tools/notebook.ts @@ -1,13 +1,13 @@ import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; import { StringEnum } from "@oh-my-pi/pi-ai"; -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import type { ToolSession } from "@oh-my-pi/pi-coding-agent/sdk"; -import { renderCodeCell, renderStatusLine } from "@oh-my-pi/pi-coding-agent/tui"; import type { Component } from "@oh-my-pi/pi-tui"; import { Text } from "@oh-my-pi/pi-tui"; import { untilAborted } from "@oh-my-pi/pi-utils"; import { type Static, Type } from "@sinclair/typebox"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import type { Theme } from "../modes/theme/theme"; +import type { ToolSession } from "../sdk"; +import { renderCodeCell, renderStatusLine } from "../tui"; import { resolveToCwd } from "./path-utils"; import { formatCount, formatErrorMessage, PREVIEW_LIMITS } from "./render-utils"; diff --git a/packages/coding-agent/src/tools/output-meta.ts b/packages/coding-agent/src/tools/output-meta.ts index d24c489ef..3a5040051 100644 --- a/packages/coding-agent/src/tools/output-meta.ts +++ b/packages/coding-agent/src/tools/output-meta.ts @@ -7,10 +7,10 @@ import type { AgentTool, AgentToolResult } from "@oh-my-pi/pi-agent-core"; import type { ImageContent, TextContent } from "@oh-my-pi/pi-ai"; -import type { OutputSummary } from "@oh-my-pi/pi-coding-agent/session/streaming-output"; -import type { TruncationResult } from "@oh-my-pi/pi-coding-agent/tools/truncate"; -import { formatSize } from "@oh-my-pi/pi-coding-agent/tools/truncate"; +import type { OutputSummary } from "../session/streaming-output"; import { renderError } from "./tool-errors"; +import type { TruncationResult } from "./truncate"; +import { formatSize } from "./truncate"; /** * Truncation metadata for the output notice. diff --git a/packages/coding-agent/src/tools/output-utils.ts b/packages/coding-agent/src/tools/output-utils.ts index 3cc6464a0..5f4acc028 100644 --- a/packages/coding-agent/src/tools/output-utils.ts +++ b/packages/coding-agent/src/tools/output-utils.ts @@ -1,4 +1,4 @@ -import { ArtifactManager } from "@oh-my-pi/pi-coding-agent/session/artifacts"; +import { ArtifactManager } from "../session/artifacts"; import type { ToolSession } from "."; export interface TailBuffer { diff --git a/packages/coding-agent/src/tools/python.ts b/packages/coding-agent/src/tools/python.ts index 082a124a2..e538ec9c9 100644 --- a/packages/coding-agent/src/tools/python.ts +++ b/packages/coding-agent/src/tools/python.ts @@ -1,24 +1,24 @@ import { relative, resolve, sep } from "node:path"; import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; import type { ImageContent } from "@oh-my-pi/pi-ai"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import { executePython, getPreludeDocs, type PythonExecutorOptions } from "@oh-my-pi/pi-coding-agent/ipy/executor"; -import type { PreludeHelper, PythonStatusEvent } from "@oh-my-pi/pi-coding-agent/ipy/kernel"; -import { truncateToVisualLines } from "@oh-my-pi/pi-coding-agent/modes/components/visual-truncate"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import pythonDescription from "@oh-my-pi/pi-coding-agent/prompts/tools/python.md" with { type: "text" }; -import { OutputSink, type OutputSummary } from "@oh-my-pi/pi-coding-agent/session/streaming-output"; -import type { OutputMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; -import { ToolAbortError, ToolError } from "@oh-my-pi/pi-coding-agent/tools/tool-errors"; -import { getTreeBranch, getTreeContinuePrefix, renderCodeCell } from "@oh-my-pi/pi-coding-agent/tui"; import type { Component } from "@oh-my-pi/pi-tui"; import { Text, truncateToWidth } from "@oh-my-pi/pi-tui"; import { type Static, Type } from "@sinclair/typebox"; +import { renderPromptTemplate } from "../config/prompt-templates"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import { executePython, getPreludeDocs, type PythonExecutorOptions } from "../ipy/executor"; +import type { PreludeHelper, PythonStatusEvent } from "../ipy/kernel"; +import { truncateToVisualLines } from "../modes/components/visual-truncate"; +import type { Theme } from "../modes/theme/theme"; +import pythonDescription from "../prompts/tools/python.md" with { type: "text" }; +import { OutputSink, type OutputSummary } from "../session/streaming-output"; +import { getTreeBranch, getTreeContinuePrefix, renderCodeCell } from "../tui"; import type { ToolSession } from "."; +import type { OutputMeta } from "./output-meta"; import { allocateOutputArtifact, createTailBuffer } from "./output-utils"; import { resolveToCwd } from "./path-utils"; import { shortenPath, ToolUIKit, truncate } from "./render-utils"; +import { ToolAbortError, ToolError } from "./tool-errors"; import { toolResult } from "./tool-result"; import { DEFAULT_MAX_BYTES } from "./truncate"; diff --git a/packages/coding-agent/src/tools/read.ts b/packages/coding-agent/src/tools/read.ts index 61800eadf..a84c428e9 100644 --- a/packages/coding-agent/src/tools/read.ts +++ b/packages/coding-agent/src/tools/read.ts @@ -2,27 +2,27 @@ import { homedir } from "node:os"; import path from "node:path"; import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; import type { ImageContent, TextContent } from "@oh-my-pi/pi-ai"; -import { CONFIG_DIR_NAME } from "@oh-my-pi/pi-coding-agent/config"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import { getLanguageFromPath, type Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import readDescription from "@oh-my-pi/pi-coding-agent/prompts/tools/read.md" with { type: "text" }; -import type { ToolSession } from "@oh-my-pi/pi-coding-agent/sdk"; -import type { OutputMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; -import { ToolAbortError, ToolError, throwIfAborted } from "@oh-my-pi/pi-coding-agent/tools/tool-errors"; -import { renderCodeCell, renderOutputBlock, renderStatusLine } from "@oh-my-pi/pi-coding-agent/tui"; -import { formatDimensionNote, resizeImage } from "@oh-my-pi/pi-coding-agent/utils/image-resize"; -import { detectSupportedImageMimeTypeFromFile } from "@oh-my-pi/pi-coding-agent/utils/mime"; -import { ensureTool } from "@oh-my-pi/pi-coding-agent/utils/tools-manager"; import type { Component } from "@oh-my-pi/pi-tui"; import { Text } from "@oh-my-pi/pi-tui"; import { ptree } from "@oh-my-pi/pi-utils"; import { Type } from "@sinclair/typebox"; +import { CONFIG_DIR_NAME } from "../config"; +import { renderPromptTemplate } from "../config/prompt-templates"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import { getLanguageFromPath, type Theme } from "../modes/theme/theme"; +import readDescription from "../prompts/tools/read.md" with { type: "text" }; +import type { ToolSession } from "../sdk"; +import { renderCodeCell, renderOutputBlock, renderStatusLine } from "../tui"; +import { formatDimensionNote, resizeImage } from "../utils/image-resize"; +import { detectSupportedImageMimeTypeFromFile } from "../utils/mime"; +import { ensureTool } from "../utils/tools-manager"; import { runFd } from "./find"; import { applyListLimit } from "./list-limit"; import { LsTool } from "./ls"; +import type { OutputMeta } from "./output-meta"; import { resolveReadPath, resolveToCwd } from "./path-utils"; import { shortenPath, wrapBrackets } from "./render-utils"; +import { ToolAbortError, ToolError, throwIfAborted } from "./tool-errors"; import { toolResult } from "./tool-result"; import { DEFAULT_MAX_BYTES, diff --git a/packages/coding-agent/src/tools/render-utils.ts b/packages/coding-agent/src/tools/render-utils.ts index f0b562392..990d5cfe5 100644 --- a/packages/coding-agent/src/tools/render-utils.ts +++ b/packages/coding-agent/src/tools/render-utils.ts @@ -6,8 +6,8 @@ */ import { homedir } from "node:os"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import { getTreeBranch } from "@oh-my-pi/pi-coding-agent/tui/utils"; +import type { Theme } from "../modes/theme/theme"; +import { getTreeBranch } from "../tui/utils"; // ============================================================================= // Standardized Display Constants diff --git a/packages/coding-agent/src/tools/renderers.ts b/packages/coding-agent/src/tools/renderers.ts index f73e40d2a..cd6f2540b 100644 --- a/packages/coding-agent/src/tools/renderers.ts +++ b/packages/coding-agent/src/tools/renderers.ts @@ -4,13 +4,13 @@ * These provide rich visualization for tool calls and results in the TUI. */ -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import { lspToolRenderer } from "@oh-my-pi/pi-coding-agent/lsp/render"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import { editToolRenderer } from "@oh-my-pi/pi-coding-agent/patch"; -import { taskToolRenderer } from "@oh-my-pi/pi-coding-agent/task/render"; -import { webSearchToolRenderer } from "@oh-my-pi/pi-coding-agent/web/search/render"; import type { Component } from "@oh-my-pi/pi-tui"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import { lspToolRenderer } from "../lsp/render"; +import type { Theme } from "../modes/theme/theme"; +import { editToolRenderer } from "../patch"; +import { taskToolRenderer } from "../task/render"; +import { webSearchToolRenderer } from "../web/search/render"; import { askToolRenderer } from "./ask"; import { bashToolRenderer } from "./bash"; import { calculatorToolRenderer } from "./calculator"; diff --git a/packages/coding-agent/src/tools/review.ts b/packages/coding-agent/src/tools/review.ts index d52dd95de..c0db13d28 100644 --- a/packages/coding-agent/src/tools/review.ts +++ b/packages/coding-agent/src/tools/review.ts @@ -7,10 +7,10 @@ */ import type { AgentTool } from "@oh-my-pi/pi-agent-core"; -import type { Theme, ThemeColor } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import type { Component } from "@oh-my-pi/pi-tui"; import { Container, Text } from "@oh-my-pi/pi-tui"; import { Type } from "@sinclair/typebox"; +import type { Theme, ThemeColor } from "../modes/theme/theme"; export type FindingPriority = "P0" | "P1" | "P2" | "P3"; @@ -151,7 +151,7 @@ export type { ReportFindingDetails }; import path from "node:path"; import { StringEnum } from "@oh-my-pi/pi-ai"; -import { subprocessToolRegistry } from "@oh-my-pi/pi-coding-agent/task/subprocess-tool-registry"; +import { subprocessToolRegistry } from "../task/subprocess-tool-registry"; // Register report_finding handler subprocessToolRegistry.register("report_finding", { diff --git a/packages/coding-agent/src/tools/ssh.ts b/packages/coding-agent/src/tools/ssh.ts index 82c5142f6..71138d254 100644 --- a/packages/coding-agent/src/tools/ssh.ts +++ b/packages/coding-agent/src/tools/ssh.ts @@ -1,23 +1,23 @@ import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; -import type { SSHHost } from "@oh-my-pi/pi-coding-agent/capability/ssh"; -import { sshCapability } from "@oh-my-pi/pi-coding-agent/capability/ssh"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import { loadCapability } from "@oh-my-pi/pi-coding-agent/discovery"; -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import sshDescriptionBase from "@oh-my-pi/pi-coding-agent/prompts/tools/ssh.md" with { type: "text" }; -import type { SSHHostInfo } from "@oh-my-pi/pi-coding-agent/ssh/connection-manager"; -import { ensureHostInfo, getHostInfoForHost } from "@oh-my-pi/pi-coding-agent/ssh/connection-manager"; -import { executeSSH } from "@oh-my-pi/pi-coding-agent/ssh/ssh-executor"; -import type { OutputMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; -import { ToolError } from "@oh-my-pi/pi-coding-agent/tools/tool-errors"; -import { renderOutputBlock, renderStatusLine } from "@oh-my-pi/pi-coding-agent/tui"; import type { Component } from "@oh-my-pi/pi-tui"; import { Text } from "@oh-my-pi/pi-tui"; import { Type } from "@sinclair/typebox"; +import type { SSHHost } from "../capability/ssh"; +import { sshCapability } from "../capability/ssh"; +import { renderPromptTemplate } from "../config/prompt-templates"; +import { loadCapability } from "../discovery"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import type { Theme } from "../modes/theme/theme"; +import sshDescriptionBase from "../prompts/tools/ssh.md" with { type: "text" }; +import type { SSHHostInfo } from "../ssh/connection-manager"; +import { ensureHostInfo, getHostInfoForHost } from "../ssh/connection-manager"; +import { executeSSH } from "../ssh/ssh-executor"; +import { renderOutputBlock, renderStatusLine } from "../tui"; import type { ToolSession } from "."; +import type { OutputMeta } from "./output-meta"; import { allocateOutputArtifact, createTailBuffer } from "./output-utils"; import { formatBytes, wrapBrackets } from "./render-utils"; +import { ToolError } from "./tool-errors"; import { toolResult } from "./tool-result"; import { DEFAULT_MAX_BYTES } from "./truncate"; diff --git a/packages/coding-agent/src/tools/todo-write.ts b/packages/coding-agent/src/tools/todo-write.ts index 73a15a482..64f2aae7b 100644 --- a/packages/coding-agent/src/tools/todo-write.ts +++ b/packages/coding-agent/src/tools/todo-write.ts @@ -2,17 +2,17 @@ import { randomUUID } from "node:crypto"; import path from "node:path"; import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; import { StringEnum } from "@oh-my-pi/pi-ai"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import todoWriteDescription from "@oh-my-pi/pi-coding-agent/prompts/tools/todo-write.md" with { type: "text" }; -import type { ToolSession } from "@oh-my-pi/pi-coding-agent/sdk"; -import { renderStatusLine, renderTreeList } from "@oh-my-pi/pi-coding-agent/tui"; import type { Component } from "@oh-my-pi/pi-tui"; import { Text } from "@oh-my-pi/pi-tui"; import { logger } from "@oh-my-pi/pi-utils"; import { Type } from "@sinclair/typebox"; import chalk from "chalk"; +import { renderPromptTemplate } from "../config/prompt-templates"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import type { Theme } from "../modes/theme/theme"; +import todoWriteDescription from "../prompts/tools/todo-write.md" with { type: "text" }; +import type { ToolSession } from "../sdk"; +import { renderStatusLine, renderTreeList } from "../tui"; import { PREVIEW_LIMITS } from "./render-utils"; const todoWriteSchema = Type.Object({ diff --git a/packages/coding-agent/src/tools/tool-result.ts b/packages/coding-agent/src/tools/tool-result.ts index f67babe5d..f7a065d78 100644 --- a/packages/coding-agent/src/tools/tool-result.ts +++ b/packages/coding-agent/src/tools/tool-result.ts @@ -1,13 +1,8 @@ import type { AgentToolResult } from "@oh-my-pi/pi-agent-core"; import type { ImageContent, TextContent } from "@oh-my-pi/pi-ai"; -import type { OutputSummary } from "@oh-my-pi/pi-coding-agent/session/streaming-output"; -import type { - OutputMeta, - TruncationOptions, - TruncationSummaryOptions, - TruncationTextOptions, -} from "@oh-my-pi/pi-coding-agent/tools/output-meta"; -import { outputMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; +import type { OutputSummary } from "../session/streaming-output"; +import type { OutputMeta, TruncationOptions, TruncationSummaryOptions, TruncationTextOptions } from "./output-meta"; +import { outputMeta } from "./output-meta"; import type { TruncationResult } from "./truncate"; type ToolContent = Array; diff --git a/packages/coding-agent/src/tools/write.ts b/packages/coding-agent/src/tools/write.ts index 318165c26..94e3269dd 100644 --- a/packages/coding-agent/src/tools/write.ts +++ b/packages/coding-agent/src/tools/write.ts @@ -5,23 +5,18 @@ import type { AgentToolUpdateCallback, ToolCallContext, } from "@oh-my-pi/pi-agent-core"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import { - createLspWritethrough, - type FileDiagnosticsResult, - type WritethroughCallback, - writethroughNoop, -} from "@oh-my-pi/pi-coding-agent/lsp"; -import { getLanguageFromPath, type Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import writeDescription from "@oh-my-pi/pi-coding-agent/prompts/tools/write.md" with { type: "text" }; -import type { ToolSession } from "@oh-my-pi/pi-coding-agent/sdk"; -import { type OutputMeta, outputMeta } from "@oh-my-pi/pi-coding-agent/tools/output-meta"; -import { renderCodeCell, renderStatusLine } from "@oh-my-pi/pi-coding-agent/tui"; import type { Component } from "@oh-my-pi/pi-tui"; import { Text } from "@oh-my-pi/pi-tui"; import { untilAborted } from "@oh-my-pi/pi-utils"; import { Type } from "@sinclair/typebox"; +import { renderPromptTemplate } from "../config/prompt-templates"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import { createLspWritethrough, type FileDiagnosticsResult, type WritethroughCallback, writethroughNoop } from "../lsp"; +import { getLanguageFromPath, type Theme } from "../modes/theme/theme"; +import writeDescription from "../prompts/tools/write.md" with { type: "text" }; +import type { ToolSession } from "../sdk"; +import { renderCodeCell, renderStatusLine } from "../tui"; +import { type OutputMeta, outputMeta } from "./output-meta"; import { resolveToCwd } from "./path-utils"; import { formatDiagnostics, shortenPath } from "./render-utils"; import type { RenderCallOptions } from "./renderers"; diff --git a/packages/coding-agent/src/tui/code-cell.ts b/packages/coding-agent/src/tui/code-cell.ts index b13d1d076..e62102bcf 100644 --- a/packages/coding-agent/src/tui/code-cell.ts +++ b/packages/coding-agent/src/tui/code-cell.ts @@ -2,13 +2,8 @@ * Render a code cell with optional output section. */ -import { highlightCode, type Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import { - formatDuration, - formatExpandHint, - formatMoreItems, - replaceTabs, -} from "@oh-my-pi/pi-coding-agent/tools/render-utils"; +import { highlightCode, type Theme } from "../modes/theme/theme"; +import { formatDuration, formatExpandHint, formatMoreItems, replaceTabs } from "../tools/render-utils"; import { renderOutputBlock } from "./output-block"; import type { State } from "./types"; import { getStateIcon } from "./utils"; diff --git a/packages/coding-agent/src/tui/file-list.ts b/packages/coding-agent/src/tui/file-list.ts index 3edd296b0..8364a8771 100644 --- a/packages/coding-agent/src/tui/file-list.ts +++ b/packages/coding-agent/src/tui/file-list.ts @@ -2,8 +2,8 @@ * Render file listings with optional icons and metadata. */ -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import { getLanguageFromPath } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; +import type { Theme } from "../modes/theme/theme"; +import { getLanguageFromPath } from "../modes/theme/theme"; import { renderTreeList } from "./tree-list"; export interface FileEntry { diff --git a/packages/coding-agent/src/tui/output-block.ts b/packages/coding-agent/src/tui/output-block.ts index 4b755a019..49b2c7ea2 100644 --- a/packages/coding-agent/src/tui/output-block.ts +++ b/packages/coding-agent/src/tui/output-block.ts @@ -2,8 +2,8 @@ * Bordered output container with optional header and sections. */ -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { visibleWidth } from "@oh-my-pi/pi-tui"; +import type { Theme } from "../modes/theme/theme"; import type { State } from "./types"; import { getStateBgColor, padToWidth, truncateToWidth } from "./utils"; diff --git a/packages/coding-agent/src/tui/status-line.ts b/packages/coding-agent/src/tui/status-line.ts index 061cc5135..cfeeba14f 100644 --- a/packages/coding-agent/src/tui/status-line.ts +++ b/packages/coding-agent/src/tui/status-line.ts @@ -2,7 +2,7 @@ * Standardized status header rendering for tool output. */ -import type { Theme, ThemeColor } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; +import type { Theme, ThemeColor } from "../modes/theme/theme"; import type { IconType } from "./types"; import { getStateIcon } from "./utils"; diff --git a/packages/coding-agent/src/tui/tree-list.ts b/packages/coding-agent/src/tui/tree-list.ts index 464461e45..a4f2242af 100644 --- a/packages/coding-agent/src/tui/tree-list.ts +++ b/packages/coding-agent/src/tui/tree-list.ts @@ -2,8 +2,8 @@ * Hierarchical tree list rendering helper. */ -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import { formatMoreItems } from "@oh-my-pi/pi-coding-agent/tools/render-utils"; +import type { Theme } from "../modes/theme/theme"; +import { formatMoreItems } from "../tools/render-utils"; import type { TreeContext } from "./types"; import { getTreeBranch, getTreeContinuePrefix } from "./utils"; diff --git a/packages/coding-agent/src/tui/types.ts b/packages/coding-agent/src/tui/types.ts index ee983dc03..b71c560a2 100644 --- a/packages/coding-agent/src/tui/types.ts +++ b/packages/coding-agent/src/tui/types.ts @@ -2,7 +2,7 @@ * Shared types for TUI rendering components. */ -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; +import type { Theme } from "../modes/theme/theme"; export type State = "pending" | "running" | "success" | "error" | "warning"; export type IconType = "success" | "error" | "running" | "pending" | "warning" | "info"; diff --git a/packages/coding-agent/src/tui/utils.ts b/packages/coding-agent/src/tui/utils.ts index 12eabbd23..455c42233 100644 --- a/packages/coding-agent/src/tui/utils.ts +++ b/packages/coding-agent/src/tui/utils.ts @@ -2,8 +2,8 @@ * Shared helpers for tool-rendered UI components. */ -import type { Theme, ThemeBg } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; import { truncateToWidth as truncateToWidthBase, visibleWidth } from "@oh-my-pi/pi-tui"; +import type { Theme, ThemeBg } from "../modes/theme/theme"; import type { IconType, State } from "./types"; export function buildTreePrefix(ancestors: boolean[], theme: Theme): string { diff --git a/packages/coding-agent/src/utils/changelog.ts b/packages/coding-agent/src/utils/changelog.ts index 1589ca8e6..292644a76 100644 --- a/packages/coding-agent/src/utils/changelog.ts +++ b/packages/coding-agent/src/utils/changelog.ts @@ -96,4 +96,4 @@ export function getNewEntries(entries: ChangelogEntry[], lastVersion: string): C } // Re-export getChangelogPath from paths.ts for convenience -export { getChangelogPath } from "@oh-my-pi/pi-coding-agent/config"; +export { getChangelogPath } from "../config"; diff --git a/packages/coding-agent/src/utils/file-mentions.ts b/packages/coding-agent/src/utils/file-mentions.ts index 04694f60a..5fc3f954e 100644 --- a/packages/coding-agent/src/utils/file-mentions.ts +++ b/packages/coding-agent/src/utils/file-mentions.ts @@ -8,15 +8,10 @@ import path from "node:path"; import type { AgentMessage } from "@oh-my-pi/pi-agent-core"; -import type { FileMentionMessage } from "@oh-my-pi/pi-coding-agent/session/messages"; -import { resolveReadPath } from "@oh-my-pi/pi-coding-agent/tools/path-utils"; -import { formatAge } from "@oh-my-pi/pi-coding-agent/tools/render-utils"; -import { - DEFAULT_MAX_BYTES, - formatSize, - truncateHead, - truncateStringToBytesFromStart, -} from "@oh-my-pi/pi-coding-agent/tools/truncate"; +import type { FileMentionMessage } from "../session/messages"; +import { resolveReadPath } from "../tools/path-utils"; +import { formatAge } from "../tools/render-utils"; +import { DEFAULT_MAX_BYTES, formatSize, truncateHead, truncateStringToBytesFromStart } from "../tools/truncate"; /** Regex to match @filepath patterns in text */ const FILE_MENTION_REGEX = /@([^\s@]+)/g; diff --git a/packages/coding-agent/src/utils/image-convert.ts b/packages/coding-agent/src/utils/image-convert.ts index d5ddb0e86..897678ecf 100644 --- a/packages/coding-agent/src/utils/image-convert.ts +++ b/packages/coding-agent/src/utils/image-convert.ts @@ -1,4 +1,4 @@ -import * as photon from "@oh-my-pi/pi-coding-agent/vendor/photon"; +import * as photon from "../vendor/photon"; /** * Convert image to PNG format for terminal display. diff --git a/packages/coding-agent/src/utils/image-resize.ts b/packages/coding-agent/src/utils/image-resize.ts index bb7d1e2e5..2d4085553 100644 --- a/packages/coding-agent/src/utils/image-resize.ts +++ b/packages/coding-agent/src/utils/image-resize.ts @@ -1,5 +1,5 @@ import type { ImageContent } from "@oh-my-pi/pi-ai"; -import * as photon from "@oh-my-pi/pi-coding-agent/vendor/photon"; +import * as photon from "../vendor/photon"; export interface ImageResizeOptions { maxWidth?: number; // Default: 2000 diff --git a/packages/coding-agent/src/utils/shell.ts b/packages/coding-agent/src/utils/shell.ts index c43b5632d..b50277f9c 100644 --- a/packages/coding-agent/src/utils/shell.ts +++ b/packages/coding-agent/src/utils/shell.ts @@ -1,7 +1,7 @@ import { constants } from "node:fs"; import { access } from "node:fs/promises"; -import { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manager"; import { $ } from "bun"; +import { SettingsManager } from "../config/settings-manager"; export interface ShellConfig { shell: string; diff --git a/packages/coding-agent/src/utils/title-generator.ts b/packages/coding-agent/src/utils/title-generator.ts index 8c7c8e3f9..11843cc67 100644 --- a/packages/coding-agent/src/utils/title-generator.ts +++ b/packages/coding-agent/src/utils/title-generator.ts @@ -4,11 +4,11 @@ import type { Api, Model } from "@oh-my-pi/pi-ai"; import { completeSimple } from "@oh-my-pi/pi-ai"; -import type { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry"; -import { parseModelString, SMOL_MODEL_PRIORITY } from "@oh-my-pi/pi-coding-agent/config/model-resolver"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import titleSystemPrompt from "@oh-my-pi/pi-coding-agent/prompts/system/title-system.md" with { type: "text" }; import { logger } from "@oh-my-pi/pi-utils"; +import type { ModelRegistry } from "../config/model-registry"; +import { parseModelString, SMOL_MODEL_PRIORITY } from "../config/model-resolver"; +import { renderPromptTemplate } from "../config/prompt-templates"; +import titleSystemPrompt from "../prompts/system/title-system.md" with { type: "text" }; const TITLE_SYSTEM_PROMPT = renderPromptTemplate(titleSystemPrompt); diff --git a/packages/coding-agent/src/utils/tools-manager.ts b/packages/coding-agent/src/utils/tools-manager.ts index bc2453b8f..4af4b0758 100644 --- a/packages/coding-agent/src/utils/tools-manager.ts +++ b/packages/coding-agent/src/utils/tools-manager.ts @@ -1,9 +1,9 @@ import { chmod, mkdir, rename, rm } from "node:fs/promises"; import { arch, platform } from "node:os"; import { join } from "node:path"; -import { APP_NAME, getBinDir } from "@oh-my-pi/pi-coding-agent/config"; import { createTempDir, logger } from "@oh-my-pi/pi-utils"; import { $ } from "bun"; +import { APP_NAME, getBinDir } from "../config"; const TOOLS_DIR = getBinDir(); diff --git a/packages/coding-agent/src/vendor/photon/index.js b/packages/coding-agent/src/vendor/photon/index.js index 12060a415..af205e90b 100644 --- a/packages/coding-agent/src/vendor/photon/index.js +++ b/packages/coding-agent/src/vendor/photon/index.js @@ -5,173 +5,173 @@ * For use when communicating between JS and WASM, and also natively. */ export class PhotonImage { - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(PhotonImage.prototype); - obj.__wbg_ptr = ptr; - PhotonImageFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PhotonImageFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_photonimage_free(ptr, 0); - } - /** - * Convert the PhotonImage to base64. - * @returns {string} - */ - get_base64() { - let deferred1_0; - let deferred1_1; - try { - const ret = wasm.photonimage_get_base64(this.__wbg_ptr); - deferred1_0 = ret[0]; - deferred1_1 = ret[1]; - return getStringFromWasm0(ret[0], ret[1]); - } finally { - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Convert the PhotonImage to raw bytes. Returns PNG. - * @returns {Uint8Array} - */ - get_bytes() { - const ret = wasm.photonimage_get_bytes(this.__wbg_ptr); - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } - /** - * Convert the PhotonImage to raw bytes. Returns a JPEG. - * @param {number} quality - * @returns {Uint8Array} - */ - get_bytes_jpeg(quality) { - const ret = wasm.photonimage_get_bytes_jpeg(this.__wbg_ptr, quality); - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } - /** - * Convert the PhotonImage to raw bytes. Returns a WEBP. - * @returns {Uint8Array} - */ - get_bytes_webp() { - const ret = wasm.photonimage_get_bytes_webp(this.__wbg_ptr); - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } - /** - * Calculates estimated filesize and returns number of bytes - * @returns {bigint} - */ - get_estimated_filesize() { - const ret = wasm.photonimage_get_estimated_filesize(this.__wbg_ptr); - return BigInt.asUintN(64, ret); - } - /** - * Get the height of the PhotonImage. - * @returns {number} - */ - get_height() { - const ret = wasm.photonimage_get_height(this.__wbg_ptr); - return ret >>> 0; - } - /** - * Convert the PhotonImage's raw pixels to JS-compatible ImageData. - * @returns {ImageData} - */ - get_image_data() { - const ret = wasm.photonimage_get_image_data(this.__wbg_ptr); - return ret; - } - /** - * Get the PhotonImage's pixels as a Vec of u8s. - * @returns {Uint8Array} - */ - get_raw_pixels() { - const ret = wasm.photonimage_get_raw_pixels(this.__wbg_ptr); - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; - } - /** - * Get the width of the PhotonImage. - * @returns {number} - */ - get_width() { - const ret = wasm.photonimage_get_width(this.__wbg_ptr); - return ret >>> 0; - } - /** - * Create a new PhotonImage from a Vec of u8s, which represent raw pixels. - * @param {Uint8Array} raw_pixels - * @param {number} width - * @param {number} height - */ - constructor(raw_pixels, width, height) { - const ptr0 = passArray8ToWasm0(raw_pixels, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.photonimage_new(ptr0, len0, width, height); - this.__wbg_ptr = ret >>> 0; - PhotonImageFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Create a new PhotonImage from a base64 string. - * @param {string} base64 - * @returns {PhotonImage} - */ - static new_from_base64(base64) { - const ptr0 = passStringToWasm0(base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.base64_to_image(ptr0, len0); - return PhotonImage.__wrap(ret); - } - /** - * Create a new PhotonImage from a Blob/File. - * @param {Blob} blob - * @returns {PhotonImage} - */ - static new_from_blob(blob) { - const ret = wasm.photonimage_new_from_blob(blob); - return PhotonImage.__wrap(ret); - } - /** - * Create a new PhotonImage from a byteslice. - * @param {Uint8Array} vec - * @returns {PhotonImage} - */ - static new_from_byteslice(vec) { - const ptr0 = passArray8ToWasm0(vec, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.photonimage_new_from_byteslice(ptr0, len0); - return PhotonImage.__wrap(ret); - } - /** - * Create a new PhotonImage from a HTMLImageElement - * @param {HTMLImageElement} image - * @returns {PhotonImage} - */ - static new_from_image(image) { - const ret = wasm.photonimage_new_from_image(image); - return PhotonImage.__wrap(ret); - } - /** - * Convert ImageData to raw pixels, and update the PhotonImage's raw pixels to this. - * @param {ImageData} img_data - */ - set_imgdata(img_data) { - wasm.photonimage_set_imgdata(this.__wbg_ptr, img_data); - } + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(PhotonImage.prototype); + obj.__wbg_ptr = ptr; + PhotonImageFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + PhotonImageFinalization.unregister(this); + return ptr; + } + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_photonimage_free(ptr, 0); + } + /** + * Convert the PhotonImage to base64. + * @returns {string} + */ + get_base64() { + let deferred1_0; + let deferred1_1; + try { + const ret = wasm.photonimage_get_base64(this.__wbg_ptr); + deferred1_0 = ret[0]; + deferred1_1 = ret[1]; + return getStringFromWasm0(ret[0], ret[1]); + } finally { + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Convert the PhotonImage to raw bytes. Returns PNG. + * @returns {Uint8Array} + */ + get_bytes() { + const ret = wasm.photonimage_get_bytes(this.__wbg_ptr); + var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v1; + } + /** + * Convert the PhotonImage to raw bytes. Returns a JPEG. + * @param {number} quality + * @returns {Uint8Array} + */ + get_bytes_jpeg(quality) { + const ret = wasm.photonimage_get_bytes_jpeg(this.__wbg_ptr, quality); + var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v1; + } + /** + * Convert the PhotonImage to raw bytes. Returns a WEBP. + * @returns {Uint8Array} + */ + get_bytes_webp() { + const ret = wasm.photonimage_get_bytes_webp(this.__wbg_ptr); + var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v1; + } + /** + * Calculates estimated filesize and returns number of bytes + * @returns {bigint} + */ + get_estimated_filesize() { + const ret = wasm.photonimage_get_estimated_filesize(this.__wbg_ptr); + return BigInt.asUintN(64, ret); + } + /** + * Get the height of the PhotonImage. + * @returns {number} + */ + get_height() { + const ret = wasm.photonimage_get_height(this.__wbg_ptr); + return ret >>> 0; + } + /** + * Convert the PhotonImage's raw pixels to JS-compatible ImageData. + * @returns {ImageData} + */ + get_image_data() { + const ret = wasm.photonimage_get_image_data(this.__wbg_ptr); + return ret; + } + /** + * Get the PhotonImage's pixels as a Vec of u8s. + * @returns {Uint8Array} + */ + get_raw_pixels() { + const ret = wasm.photonimage_get_raw_pixels(this.__wbg_ptr); + var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v1; + } + /** + * Get the width of the PhotonImage. + * @returns {number} + */ + get_width() { + const ret = wasm.photonimage_get_width(this.__wbg_ptr); + return ret >>> 0; + } + /** + * Create a new PhotonImage from a Vec of u8s, which represent raw pixels. + * @param {Uint8Array} raw_pixels + * @param {number} width + * @param {number} height + */ + constructor(raw_pixels, width, height) { + const ptr0 = passArray8ToWasm0(raw_pixels, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.photonimage_new(ptr0, len0, width, height); + this.__wbg_ptr = ret >>> 0; + PhotonImageFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Create a new PhotonImage from a base64 string. + * @param {string} base64 + * @returns {PhotonImage} + */ + static new_from_base64(base64) { + const ptr0 = passStringToWasm0(base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.base64_to_image(ptr0, len0); + return PhotonImage.__wrap(ret); + } + /** + * Create a new PhotonImage from a Blob/File. + * @param {Blob} blob + * @returns {PhotonImage} + */ + static new_from_blob(blob) { + const ret = wasm.photonimage_new_from_blob(blob); + return PhotonImage.__wrap(ret); + } + /** + * Create a new PhotonImage from a byteslice. + * @param {Uint8Array} vec + * @returns {PhotonImage} + */ + static new_from_byteslice(vec) { + const ptr0 = passArray8ToWasm0(vec, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.photonimage_new_from_byteslice(ptr0, len0); + return PhotonImage.__wrap(ret); + } + /** + * Create a new PhotonImage from a HTMLImageElement + * @param {HTMLImageElement} image + * @returns {PhotonImage} + */ + static new_from_image(image) { + const ret = wasm.photonimage_new_from_image(image); + return PhotonImage.__wrap(ret); + } + /** + * Convert ImageData to raw pixels, and update the PhotonImage's raw pixels to this. + * @param {ImageData} img_data + */ + set_imgdata(img_data) { + wasm.photonimage_set_imgdata(this.__wbg_ptr, img_data); + } } if (Symbol.dispose) PhotonImage.prototype[Symbol.dispose] = PhotonImage.prototype.free; @@ -179,73 +179,73 @@ if (Symbol.dispose) PhotonImage.prototype[Symbol.dispose] = PhotonImage.prototyp * RGB color type. */ export class Rgb { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RgbFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_rgb_free(ptr, 0); - } - /** - * Get the Blue value. - * @returns {number} - */ - get_blue() { - const ret = wasm.rgb_get_blue(this.__wbg_ptr); - return ret; - } - /** - * Get the Green value. - * @returns {number} - */ - get_green() { - const ret = wasm.rgb_get_green(this.__wbg_ptr); - return ret; - } - /** - * Get the Red value. - * @returns {number} - */ - get_red() { - const ret = wasm.rgb_get_red(this.__wbg_ptr); - return ret; - } - /** - * Create a new RGB struct. - * @param {number} r - * @param {number} g - * @param {number} b - */ - constructor(r, g, b) { - const ret = wasm.rgb_new(r, g, b); - this.__wbg_ptr = ret >>> 0; - RgbFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Set the Blue value. - * @param {number} b - */ - set_blue(b) { - wasm.rgb_set_blue(this.__wbg_ptr, b); - } - /** - * Get the Green value. - * @param {number} g - */ - set_green(g) { - wasm.rgb_set_green(this.__wbg_ptr, g); - } - /** - * Set the Red value. - * @param {number} r - */ - set_red(r) { - wasm.rgb_set_red(this.__wbg_ptr, r); - } + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + RgbFinalization.unregister(this); + return ptr; + } + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_rgb_free(ptr, 0); + } + /** + * Get the Blue value. + * @returns {number} + */ + get_blue() { + const ret = wasm.rgb_get_blue(this.__wbg_ptr); + return ret; + } + /** + * Get the Green value. + * @returns {number} + */ + get_green() { + const ret = wasm.rgb_get_green(this.__wbg_ptr); + return ret; + } + /** + * Get the Red value. + * @returns {number} + */ + get_red() { + const ret = wasm.rgb_get_red(this.__wbg_ptr); + return ret; + } + /** + * Create a new RGB struct. + * @param {number} r + * @param {number} g + * @param {number} b + */ + constructor(r, g, b) { + const ret = wasm.rgb_new(r, g, b); + this.__wbg_ptr = ret >>> 0; + RgbFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Set the Blue value. + * @param {number} b + */ + set_blue(b) { + wasm.rgb_set_blue(this.__wbg_ptr, b); + } + /** + * Get the Green value. + * @param {number} g + */ + set_green(g) { + wasm.rgb_set_green(this.__wbg_ptr, g); + } + /** + * Set the Red value. + * @param {number} r + */ + set_red(r) { + wasm.rgb_set_red(this.__wbg_ptr, r); + } } if (Symbol.dispose) Rgb.prototype[Symbol.dispose] = Rgb.prototype.free; @@ -253,89 +253,89 @@ if (Symbol.dispose) Rgb.prototype[Symbol.dispose] = Rgb.prototype.free; * RGBA color type. */ export class Rgba { - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RgbaFinalization.unregister(this); - return ptr; - } - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_rgba_free(ptr, 0); - } - /** - * Get the alpha value for this color. - * @returns {number} - */ - get_alpha() { - const ret = wasm.rgba_get_alpha(this.__wbg_ptr); - return ret; - } - /** - * Get the Blue value. - * @returns {number} - */ - get_blue() { - const ret = wasm.rgb_get_blue(this.__wbg_ptr); - return ret; - } - /** - * Get the Green value. - * @returns {number} - */ - get_green() { - const ret = wasm.rgb_get_green(this.__wbg_ptr); - return ret; - } - /** - * Get the Red value. - * @returns {number} - */ - get_red() { - const ret = wasm.rgb_get_red(this.__wbg_ptr); - return ret; - } - /** - * Create a new RGBA struct. - * @param {number} r - * @param {number} g - * @param {number} b - * @param {number} a - */ - constructor(r, g, b, a) { - const ret = wasm.rgba_new(r, g, b, a); - this.__wbg_ptr = ret >>> 0; - RgbaFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Set the alpha value. - * @param {number} a - */ - set_alpha(a) { - wasm.rgba_set_alpha(this.__wbg_ptr, a); - } - /** - * Set the Blue value. - * @param {number} b - */ - set_blue(b) { - wasm.rgb_set_blue(this.__wbg_ptr, b); - } - /** - * Get the Green value. - * @param {number} g - */ - set_green(g) { - wasm.rgb_set_green(this.__wbg_ptr, g); - } - /** - * Set the Red value. - * @param {number} r - */ - set_red(r) { - wasm.rgb_set_red(this.__wbg_ptr, r); - } + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + RgbaFinalization.unregister(this); + return ptr; + } + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_rgba_free(ptr, 0); + } + /** + * Get the alpha value for this color. + * @returns {number} + */ + get_alpha() { + const ret = wasm.rgba_get_alpha(this.__wbg_ptr); + return ret; + } + /** + * Get the Blue value. + * @returns {number} + */ + get_blue() { + const ret = wasm.rgb_get_blue(this.__wbg_ptr); + return ret; + } + /** + * Get the Green value. + * @returns {number} + */ + get_green() { + const ret = wasm.rgb_get_green(this.__wbg_ptr); + return ret; + } + /** + * Get the Red value. + * @returns {number} + */ + get_red() { + const ret = wasm.rgb_get_red(this.__wbg_ptr); + return ret; + } + /** + * Create a new RGBA struct. + * @param {number} r + * @param {number} g + * @param {number} b + * @param {number} a + */ + constructor(r, g, b, a) { + const ret = wasm.rgba_new(r, g, b, a); + this.__wbg_ptr = ret >>> 0; + RgbaFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Set the alpha value. + * @param {number} a + */ + set_alpha(a) { + wasm.rgba_set_alpha(this.__wbg_ptr, a); + } + /** + * Set the Blue value. + * @param {number} b + */ + set_blue(b) { + wasm.rgb_set_blue(this.__wbg_ptr, b); + } + /** + * Get the Green value. + * @param {number} g + */ + set_green(g) { + wasm.rgb_set_green(this.__wbg_ptr, g); + } + /** + * Set the Red value. + * @param {number} r + */ + set_red(r) { + wasm.rgb_set_red(this.__wbg_ptr, r); + } } if (Symbol.dispose) Rgba.prototype[Symbol.dispose] = Rgba.prototype.free; @@ -343,11 +343,16 @@ if (Symbol.dispose) Rgba.prototype[Symbol.dispose] = Rgba.prototype.free; * @enum {1 | 2 | 3 | 4 | 5} */ export const SamplingFilter = Object.freeze({ - Nearest: 1, "1": "Nearest", - Triangle: 2, "2": "Triangle", - CatmullRom: 3, "3": "CatmullRom", - Gaussian: 4, "4": "Gaussian", - Lanczos3: 5, "5": "Lanczos3", + Nearest: 1, + 1: "Nearest", + Triangle: 2, + 2: "Triangle", + CatmullRom: 3, + 3: "CatmullRom", + Gaussian: 4, + 4: "Gaussian", + Lanczos3: 5, + 5: "Lanczos3", }); /** @@ -373,8 +378,8 @@ export const SamplingFilter = Object.freeze({ * @param {PhotonImage} photon_image */ export function add_noise_rand(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.add_noise_rand(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.add_noise_rand(photon_image.__wbg_ptr); } /** @@ -398,8 +403,8 @@ export function add_noise_rand(photon_image) { * @param {number} brightness */ export function adjust_brightness(photon_image, brightness) { - _assertClass(photon_image, PhotonImage); - wasm.adjust_brightness(photon_image.__wbg_ptr, brightness); + _assertClass(photon_image, PhotonImage); + wasm.adjust_brightness(photon_image.__wbg_ptr, brightness); } /** @@ -422,8 +427,8 @@ export function adjust_brightness(photon_image, brightness) { * @param {number} contrast */ export function adjust_contrast(photon_image, contrast) { - _assertClass(photon_image, PhotonImage); - wasm.adjust_contrast(photon_image.__wbg_ptr, contrast); + _assertClass(photon_image, PhotonImage); + wasm.adjust_contrast(photon_image.__wbg_ptr, contrast); } /** @@ -447,8 +452,8 @@ export function adjust_contrast(photon_image, contrast) { * @param {number} amt */ export function alter_blue_channel(img, amt) { - _assertClass(img, PhotonImage); - wasm.alter_blue_channel(img.__wbg_ptr, amt); + _assertClass(img, PhotonImage); + wasm.alter_blue_channel(img.__wbg_ptr, amt); } /** @@ -489,8 +494,8 @@ export function alter_blue_channel(img, amt) { * @param {number} amt */ export function alter_channel(img, channel, amt) { - _assertClass(img, PhotonImage); - wasm.alter_channel(img.__wbg_ptr, channel, amt); + _assertClass(img, PhotonImage); + wasm.alter_channel(img.__wbg_ptr, channel, amt); } /** @@ -519,8 +524,8 @@ export function alter_channel(img, channel, amt) { * @param {number} b_amt */ export function alter_channels(img, r_amt, g_amt, b_amt) { - _assertClass(img, PhotonImage); - wasm.alter_channels(img.__wbg_ptr, r_amt, g_amt, b_amt); + _assertClass(img, PhotonImage); + wasm.alter_channels(img.__wbg_ptr, r_amt, g_amt, b_amt); } /** @@ -544,8 +549,8 @@ export function alter_channels(img, r_amt, g_amt, b_amt) { * @param {number} amt */ export function alter_green_channel(img, amt) { - _assertClass(img, PhotonImage); - wasm.alter_green_channel(img.__wbg_ptr, amt); + _assertClass(img, PhotonImage); + wasm.alter_green_channel(img.__wbg_ptr, amt); } /** @@ -569,8 +574,8 @@ export function alter_green_channel(img, amt) { * @param {number} amt */ export function alter_red_channel(photon_image, amt) { - _assertClass(photon_image, PhotonImage); - wasm.alter_red_channel(photon_image.__wbg_ptr, amt); + _assertClass(photon_image, PhotonImage); + wasm.alter_red_channel(photon_image.__wbg_ptr, amt); } /** @@ -600,8 +605,8 @@ export function alter_red_channel(photon_image, amt) { * @param {number} amt2 */ export function alter_two_channels(img, channel1, amt1, channel2, amt2) { - _assertClass(img, PhotonImage); - wasm.alter_two_channels(img.__wbg_ptr, channel1, amt1, channel2, amt2); + _assertClass(img, PhotonImage); + wasm.alter_two_channels(img.__wbg_ptr, channel1, amt1, channel2, amt2); } /** @@ -609,8 +614,8 @@ export function alter_two_channels(img, channel1, amt1, channel2, amt2) { * @param {PhotonImage} image */ export function apply_gradient(image) { - _assertClass(image, PhotonImage); - wasm.apply_gradient(image.__wbg_ptr); + _assertClass(image, PhotonImage); + wasm.apply_gradient(image.__wbg_ptr); } /** @@ -631,8 +636,8 @@ export function apply_gradient(image) { * @param {PhotonImage} photon_image */ export function b_grayscale(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.b_grayscale(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.b_grayscale(photon_image.__wbg_ptr); } /** @@ -641,10 +646,10 @@ export function b_grayscale(photon_image) { * @returns {PhotonImage} */ export function base64_to_image(base64) { - const ptr0 = passStringToWasm0(base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.base64_to_image(ptr0, len0); - return PhotonImage.__wrap(ret); + const ptr0 = passStringToWasm0(base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.base64_to_image(ptr0, len0); + return PhotonImage.__wrap(ret); } /** @@ -653,12 +658,12 @@ export function base64_to_image(base64) { * @returns {Uint8Array} */ export function base64_to_vec(base64) { - const ptr0 = passStringToWasm0(base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.base64_to_vec(ptr0, len0); - var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v2; + const ptr0 = passStringToWasm0(base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.base64_to_vec(ptr0, len0); + var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v2; } /** @@ -690,11 +695,11 @@ export function base64_to_vec(base64) { * @param {string} blend_mode */ export function blend(photon_image, photon_image2, blend_mode) { - _assertClass(photon_image, PhotonImage); - _assertClass(photon_image2, PhotonImage); - const ptr0 = passStringToWasm0(blend_mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.blend(photon_image.__wbg_ptr, photon_image2.__wbg_ptr, ptr0, len0); + _assertClass(photon_image, PhotonImage); + _assertClass(photon_image2, PhotonImage); + const ptr0 = passStringToWasm0(blend_mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.blend(photon_image.__wbg_ptr, photon_image2.__wbg_ptr, ptr0, len0); } /** @@ -716,8 +721,8 @@ export function blend(photon_image, photon_image2, blend_mode) { * @param {PhotonImage} photon_image */ export function box_blur(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.box_blur(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.box_blur(photon_image.__wbg_ptr); } /** @@ -737,8 +742,8 @@ export function box_blur(photon_image) { * @param {PhotonImage} img */ export function cali(img) { - _assertClass(img, PhotonImage); - wasm.cali(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.cali(img.__wbg_ptr); } /** @@ -765,10 +770,10 @@ export function cali(img) { * @param {Rgb} color */ export function color_horizontal_strips(photon_image, num_strips, color) { - _assertClass(photon_image, PhotonImage); - _assertClass(color, Rgb); - var ptr0 = color.__destroy_into_raw(); - wasm.color_horizontal_strips(photon_image.__wbg_ptr, num_strips, ptr0); + _assertClass(photon_image, PhotonImage); + _assertClass(color, Rgb); + var ptr0 = color.__destroy_into_raw(); + wasm.color_horizontal_strips(photon_image.__wbg_ptr, num_strips, ptr0); } /** @@ -795,10 +800,10 @@ export function color_horizontal_strips(photon_image, num_strips, color) { * @param {Rgb} color */ export function color_vertical_strips(photon_image, num_strips, color) { - _assertClass(photon_image, PhotonImage); - _assertClass(color, Rgb); - var ptr0 = color.__destroy_into_raw(); - wasm.color_vertical_strips(photon_image.__wbg_ptr, num_strips, ptr0); + _assertClass(photon_image, PhotonImage); + _assertClass(color, Rgb); + var ptr0 = color.__destroy_into_raw(); + wasm.color_vertical_strips(photon_image.__wbg_ptr, num_strips, ptr0); } /** @@ -819,8 +824,8 @@ export function color_vertical_strips(photon_image, num_strips, color) { * @param {PhotonImage} photon_image */ export function colorize(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.colorize(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.colorize(photon_image.__wbg_ptr); } /** @@ -829,8 +834,8 @@ export function colorize(photon_image) { * @returns {PhotonImage} */ export function create_gradient(width, height) { - const ret = wasm.create_gradient(width, height); - return PhotonImage.__wrap(ret); + const ret = wasm.create_gradient(width, height); + return PhotonImage.__wrap(ret); } /** @@ -859,9 +864,9 @@ export function create_gradient(width, height) { * @returns {PhotonImage} */ export function crop(photon_image, x1, y1, x2, y2) { - _assertClass(photon_image, PhotonImage); - const ret = wasm.crop(photon_image.__wbg_ptr, x1, y1, x2, y2); - return PhotonImage.__wrap(ret); + _assertClass(photon_image, PhotonImage); + const ret = wasm.crop(photon_image.__wbg_ptr, x1, y1, x2, y2); + return PhotonImage.__wrap(ret); } /** @@ -873,8 +878,8 @@ export function crop(photon_image, x1, y1, x2, y2) { * @returns {HTMLCanvasElement} */ export function crop_img_browser(source_canvas, width, height, left, top) { - const ret = wasm.crop_img_browser(source_canvas, width, height, left, top); - return ret; + const ret = wasm.crop_img_browser(source_canvas, width, height, left, top); + return ret; } /** @@ -900,8 +905,8 @@ export function crop_img_browser(source_canvas, width, height, left, top) { * @param {number} level */ export function darken_hsl(img, level) { - _assertClass(img, PhotonImage); - wasm.darken_hsl(img.__wbg_ptr, level); + _assertClass(img, PhotonImage); + wasm.darken_hsl(img.__wbg_ptr, level); } /** @@ -927,8 +932,8 @@ export function darken_hsl(img, level) { * @param {number} level */ export function darken_hsluv(img, level) { - _assertClass(img, PhotonImage); - wasm.darken_hsluv(img.__wbg_ptr, level); + _assertClass(img, PhotonImage); + wasm.darken_hsluv(img.__wbg_ptr, level); } /** @@ -954,8 +959,8 @@ export function darken_hsluv(img, level) { * @param {number} level */ export function darken_hsv(img, level) { - _assertClass(img, PhotonImage); - wasm.darken_hsv(img.__wbg_ptr, level); + _assertClass(img, PhotonImage); + wasm.darken_hsv(img.__wbg_ptr, level); } /** @@ -981,8 +986,8 @@ export function darken_hsv(img, level) { * @param {number} level */ export function darken_lch(img, level) { - _assertClass(img, PhotonImage); - wasm.darken_lch(img.__wbg_ptr, level); + _assertClass(img, PhotonImage); + wasm.darken_lch(img.__wbg_ptr, level); } /** @@ -1005,8 +1010,8 @@ export function darken_lch(img, level) { * @param {number} brightness */ export function dec_brightness(photon_image, brightness) { - _assertClass(photon_image, PhotonImage); - wasm.dec_brightness(photon_image.__wbg_ptr, brightness); + _assertClass(photon_image, PhotonImage); + wasm.dec_brightness(photon_image.__wbg_ptr, brightness); } /** @@ -1028,8 +1033,8 @@ export function dec_brightness(photon_image, brightness) { * @param {PhotonImage} img */ export function decompose_max(img) { - _assertClass(img, PhotonImage); - wasm.decompose_max(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.decompose_max(img.__wbg_ptr); } /** @@ -1051,8 +1056,8 @@ export function decompose_max(img) { * @param {PhotonImage} img */ export function decompose_min(img) { - _assertClass(img, PhotonImage); - wasm.decompose_min(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.decompose_min(img.__wbg_ptr); } /** @@ -1073,8 +1078,8 @@ export function decompose_min(img) { * @param {PhotonImage} img */ export function desaturate(img) { - _assertClass(img, PhotonImage); - wasm.desaturate(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.desaturate(img.__wbg_ptr); } /** @@ -1100,8 +1105,8 @@ export function desaturate(img) { * @param {number} level */ export function desaturate_hsl(img, level) { - _assertClass(img, PhotonImage); - wasm.desaturate_hsl(img.__wbg_ptr, level); + _assertClass(img, PhotonImage); + wasm.desaturate_hsl(img.__wbg_ptr, level); } /** @@ -1127,8 +1132,8 @@ export function desaturate_hsl(img, level) { * @param {number} level */ export function desaturate_hsluv(img, level) { - _assertClass(img, PhotonImage); - wasm.desaturate_hsluv(img.__wbg_ptr, level); + _assertClass(img, PhotonImage); + wasm.desaturate_hsluv(img.__wbg_ptr, level); } /** @@ -1154,8 +1159,8 @@ export function desaturate_hsluv(img, level) { * @param {number} level */ export function desaturate_hsv(img, level) { - _assertClass(img, PhotonImage); - wasm.desaturate_hsv(img.__wbg_ptr, level); + _assertClass(img, PhotonImage); + wasm.desaturate_hsv(img.__wbg_ptr, level); } /** @@ -1181,8 +1186,8 @@ export function desaturate_hsv(img, level) { * @param {number} level */ export function desaturate_lch(img, level) { - _assertClass(img, PhotonImage); - wasm.desaturate_lch(img.__wbg_ptr, level); + _assertClass(img, PhotonImage); + wasm.desaturate_lch(img.__wbg_ptr, level); } /** @@ -1204,8 +1209,8 @@ export function desaturate_lch(img, level) { * @param {PhotonImage} photon_image */ export function detect_135_deg_lines(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.detect_135_deg_lines(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.detect_135_deg_lines(photon_image.__wbg_ptr); } /** @@ -1227,8 +1232,8 @@ export function detect_135_deg_lines(photon_image) { * @param {PhotonImage} photon_image */ export function detect_45_deg_lines(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.detect_45_deg_lines(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.detect_45_deg_lines(photon_image.__wbg_ptr); } /** @@ -1250,8 +1255,8 @@ export function detect_45_deg_lines(photon_image) { * @param {PhotonImage} photon_image */ export function detect_horizontal_lines(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.detect_horizontal_lines(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.detect_horizontal_lines(photon_image.__wbg_ptr); } /** @@ -1273,8 +1278,8 @@ export function detect_horizontal_lines(photon_image) { * @param {PhotonImage} photon_image */ export function detect_vertical_lines(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.detect_vertical_lines(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.detect_vertical_lines(photon_image.__wbg_ptr); } /** @@ -1298,8 +1303,8 @@ export function detect_vertical_lines(photon_image) { * @param {number} depth */ export function dither(photon_image, depth) { - _assertClass(photon_image, PhotonImage); - wasm.dither(photon_image.__wbg_ptr, depth); + _assertClass(photon_image, PhotonImage); + wasm.dither(photon_image.__wbg_ptr, depth); } /** @@ -1319,8 +1324,8 @@ export function dither(photon_image, depth) { * @param {PhotonImage} img */ export function dramatic(img) { - _assertClass(img, PhotonImage); - wasm.dramatic(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.dramatic(img.__wbg_ptr); } /** @@ -1353,10 +1358,10 @@ export function dramatic(img) { * @param {number} font_size */ export function draw_text(photon_img, text, x, y, font_size) { - _assertClass(photon_img, PhotonImage); - const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.draw_text(photon_img.__wbg_ptr, ptr0, len0, x, y, font_size); + _assertClass(photon_img, PhotonImage); + const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.draw_text(photon_img.__wbg_ptr, ptr0, len0, x, y, font_size); } /** @@ -1389,10 +1394,10 @@ export function draw_text(photon_img, text, x, y, font_size) { * @param {number} font_size */ export function draw_text_with_border(photon_img, text, x, y, font_size) { - _assertClass(photon_img, PhotonImage); - const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.draw_text_with_border(photon_img.__wbg_ptr, ptr0, len0, x, y, font_size); + _assertClass(photon_img, PhotonImage); + const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.draw_text_with_border(photon_img.__wbg_ptr, ptr0, len0, x, y, font_size); } /** @@ -1401,12 +1406,12 @@ export function draw_text_with_border(photon_img, text, x, y, font_size) { * @param {Rgb} color_b */ export function duotone(photon_image, color_a, color_b) { - _assertClass(photon_image, PhotonImage); - _assertClass(color_a, Rgb); - var ptr0 = color_a.__destroy_into_raw(); - _assertClass(color_b, Rgb); - var ptr1 = color_b.__destroy_into_raw(); - wasm.duotone(photon_image.__wbg_ptr, ptr0, ptr1); + _assertClass(photon_image, PhotonImage); + _assertClass(color_a, Rgb); + var ptr0 = color_a.__destroy_into_raw(); + _assertClass(color_b, Rgb); + var ptr1 = color_b.__destroy_into_raw(); + wasm.duotone(photon_image.__wbg_ptr, ptr0, ptr1); } /** @@ -1426,8 +1431,8 @@ export function duotone(photon_image, color_a, color_b) { * @param {PhotonImage} img */ export function duotone_horizon(img) { - _assertClass(img, PhotonImage); - wasm.duotone_horizon(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.duotone_horizon(img.__wbg_ptr); } /** @@ -1447,8 +1452,8 @@ export function duotone_horizon(img) { * @param {PhotonImage} img */ export function duotone_lilac(img) { - _assertClass(img, PhotonImage); - wasm.duotone_lilac(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.duotone_lilac(img.__wbg_ptr); } /** @@ -1468,8 +1473,8 @@ export function duotone_lilac(img) { * @param {PhotonImage} img */ export function duotone_ochre(img) { - _assertClass(img, PhotonImage); - wasm.duotone_ochre(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.duotone_ochre(img.__wbg_ptr); } /** @@ -1493,10 +1498,10 @@ export function duotone_ochre(img) { * @param {Rgb} rgb_color */ export function duotone_tint(img, rgb_color) { - _assertClass(img, PhotonImage); - _assertClass(rgb_color, Rgb); - var ptr0 = rgb_color.__destroy_into_raw(); - wasm.duotone_tint(img.__wbg_ptr, ptr0); + _assertClass(img, PhotonImage); + _assertClass(rgb_color, Rgb); + var ptr0 = rgb_color.__destroy_into_raw(); + wasm.duotone_tint(img.__wbg_ptr, ptr0); } /** @@ -1516,8 +1521,8 @@ export function duotone_tint(img, rgb_color) { * @param {PhotonImage} img */ export function duotone_violette(img) { - _assertClass(img, PhotonImage); - wasm.duotone_violette(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.duotone_violette(img.__wbg_ptr); } /** @@ -1539,8 +1544,8 @@ export function duotone_violette(img) { * @param {PhotonImage} photon_image */ export function edge_detection(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.edge_detection(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.edge_detection(photon_image.__wbg_ptr); } /** @@ -1562,8 +1567,8 @@ export function edge_detection(photon_image) { * @param {PhotonImage} photon_image */ export function edge_one(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.edge_one(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.edge_one(photon_image.__wbg_ptr); } /** @@ -1585,8 +1590,8 @@ export function edge_one(photon_image) { * @param {PhotonImage} photon_image */ export function emboss(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.emboss(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.emboss(photon_image.__wbg_ptr); } /** @@ -1624,10 +1629,10 @@ export function emboss(photon_image) { * @param {string} filter_name */ export function filter(img, filter_name) { - _assertClass(img, PhotonImage); - const ptr0 = passStringToWasm0(filter_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.filter(img.__wbg_ptr, ptr0, len0); + _assertClass(img, PhotonImage); + const ptr0 = passStringToWasm0(filter_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.filter(img.__wbg_ptr, ptr0, len0); } /** @@ -1647,8 +1652,8 @@ export function filter(img, filter_name) { * @param {PhotonImage} img */ export function firenze(img) { - _assertClass(img, PhotonImage); - wasm.firenze(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.firenze(img.__wbg_ptr); } /** @@ -1670,8 +1675,8 @@ export function firenze(img) { * @param {PhotonImage} photon_image */ export function fliph(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.fliph(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.fliph(photon_image.__wbg_ptr); } /** @@ -1693,8 +1698,8 @@ export function fliph(photon_image) { * @param {PhotonImage} photon_image */ export function flipv(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.flipv(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.flipv(photon_image.__wbg_ptr); } /** @@ -1715,8 +1720,8 @@ export function flipv(photon_image) { * @param {PhotonImage} photon_image */ export function frosted_glass(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.frosted_glass(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.frosted_glass(photon_image.__wbg_ptr); } /** @@ -1737,8 +1742,8 @@ export function frosted_glass(photon_image) { * @param {PhotonImage} photon_image */ export function g_grayscale(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.g_grayscale(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.g_grayscale(photon_image.__wbg_ptr); } /** @@ -1764,8 +1769,8 @@ export function g_grayscale(photon_image) { * @param {number} blue */ export function gamma_correction(photon_image, red, green, blue) { - _assertClass(photon_image, PhotonImage); - wasm.gamma_correction(photon_image.__wbg_ptr, red, green, blue); + _assertClass(photon_image, PhotonImage); + wasm.gamma_correction(photon_image.__wbg_ptr, red, green, blue); } /** @@ -1789,8 +1794,8 @@ export function gamma_correction(photon_image, red, green, blue) { * @param {number} radius */ export function gaussian_blur(photon_image, radius) { - _assertClass(photon_image, PhotonImage); - wasm.gaussian_blur(photon_image.__wbg_ptr, radius); + _assertClass(photon_image, PhotonImage); + wasm.gaussian_blur(photon_image.__wbg_ptr, radius); } /** @@ -1800,8 +1805,8 @@ export function gaussian_blur(photon_image, radius) { * @returns {ImageData} */ export function get_image_data(canvas, ctx) { - const ret = wasm.get_image_data(canvas, ctx); - return ret; + const ret = wasm.get_image_data(canvas, ctx); + return ret; } /** @@ -1821,8 +1826,8 @@ export function get_image_data(canvas, ctx) { * @param {PhotonImage} img */ export function golden(img) { - _assertClass(img, PhotonImage); - wasm.golden(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.golden(img.__wbg_ptr); } /** @@ -1843,8 +1848,8 @@ export function golden(img) { * @param {PhotonImage} img */ export function grayscale(img) { - _assertClass(img, PhotonImage); - wasm.grayscale(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.grayscale(img.__wbg_ptr); } /** @@ -1865,8 +1870,8 @@ export function grayscale(img) { * @param {PhotonImage} img */ export function grayscale_human_corrected(img) { - _assertClass(img, PhotonImage); - wasm.grayscale_human_corrected(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.grayscale_human_corrected(img.__wbg_ptr); } /** @@ -1890,8 +1895,8 @@ export function grayscale_human_corrected(img) { * @param {number} num_shades */ export function grayscale_shades(photon_image, num_shades) { - _assertClass(photon_image, PhotonImage); - wasm.grayscale_shades(photon_image.__wbg_ptr, num_shades); + _assertClass(photon_image, PhotonImage); + wasm.grayscale_shades(photon_image.__wbg_ptr, num_shades); } /** @@ -1912,8 +1917,8 @@ export function grayscale_shades(photon_image, num_shades) { * @param {PhotonImage} photon_image */ export function halftone(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.halftone(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.halftone(photon_image.__wbg_ptr); } /** @@ -1936,8 +1941,8 @@ export function halftone(photon_image) { * @param {number} num_strips */ export function horizontal_strips(photon_image, num_strips) { - _assertClass(photon_image, PhotonImage); - wasm.horizontal_strips(photon_image.__wbg_ptr, num_strips); + _assertClass(photon_image, PhotonImage); + wasm.horizontal_strips(photon_image.__wbg_ptr, num_strips); } /** @@ -1969,10 +1974,10 @@ export function horizontal_strips(photon_image, num_strips) { * @param {number} amt */ export function hsl(photon_image, mode, amt) { - _assertClass(photon_image, PhotonImage); - const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.hsl(photon_image.__wbg_ptr, ptr0, len0, amt); + _assertClass(photon_image, PhotonImage); + const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.hsl(photon_image.__wbg_ptr, ptr0, len0, amt); } /** @@ -2004,10 +2009,10 @@ export function hsl(photon_image, mode, amt) { * @param {number} amt */ export function hsluv(photon_image, mode, amt) { - _assertClass(photon_image, PhotonImage); - const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.hsluv(photon_image.__wbg_ptr, ptr0, len0, amt); + _assertClass(photon_image, PhotonImage); + const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.hsluv(photon_image.__wbg_ptr, ptr0, len0, amt); } /** @@ -2040,10 +2045,10 @@ export function hsluv(photon_image, mode, amt) { * @param {number} amt */ export function hsv(photon_image, mode, amt) { - _assertClass(photon_image, PhotonImage); - const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.hsv(photon_image.__wbg_ptr, ptr0, len0, amt); + _assertClass(photon_image, PhotonImage); + const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.hsv(photon_image.__wbg_ptr, ptr0, len0, amt); } /** @@ -2066,8 +2071,8 @@ export function hsv(photon_image, mode, amt) { * @param {number} degrees */ export function hue_rotate_hsl(img, degrees) { - _assertClass(img, PhotonImage); - wasm.hue_rotate_hsl(img.__wbg_ptr, degrees); + _assertClass(img, PhotonImage); + wasm.hue_rotate_hsl(img.__wbg_ptr, degrees); } /** @@ -2090,8 +2095,8 @@ export function hue_rotate_hsl(img, degrees) { * @param {number} degrees */ export function hue_rotate_hsluv(img, degrees) { - _assertClass(img, PhotonImage); - wasm.hue_rotate_hsluv(img.__wbg_ptr, degrees); + _assertClass(img, PhotonImage); + wasm.hue_rotate_hsluv(img.__wbg_ptr, degrees); } /** @@ -2114,8 +2119,8 @@ export function hue_rotate_hsluv(img, degrees) { * @param {number} degrees */ export function hue_rotate_hsv(img, degrees) { - _assertClass(img, PhotonImage); - wasm.hue_rotate_hsv(img.__wbg_ptr, degrees); + _assertClass(img, PhotonImage); + wasm.hue_rotate_hsv(img.__wbg_ptr, degrees); } /** @@ -2138,8 +2143,8 @@ export function hue_rotate_hsv(img, degrees) { * @param {number} degrees */ export function hue_rotate_lch(img, degrees) { - _assertClass(img, PhotonImage); - wasm.hue_rotate_lch(img.__wbg_ptr, degrees); + _assertClass(img, PhotonImage); + wasm.hue_rotate_lch(img.__wbg_ptr, degrees); } /** @@ -2161,8 +2166,8 @@ export function hue_rotate_lch(img, degrees) { * @param {PhotonImage} photon_image */ export function identity(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.identity(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.identity(photon_image.__wbg_ptr); } /** @@ -2184,8 +2189,8 @@ export function identity(photon_image) { * @param {number} brightness */ export function inc_brightness(photon_image, brightness) { - _assertClass(photon_image, PhotonImage); - wasm.inc_brightness(photon_image.__wbg_ptr, brightness); + _assertClass(photon_image, PhotonImage); + wasm.inc_brightness(photon_image.__wbg_ptr, brightness); } /** @@ -2205,8 +2210,8 @@ export function inc_brightness(photon_image, brightness) { * @param {PhotonImage} photon_image */ export function invert(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.invert(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.invert(photon_image.__wbg_ptr); } /** @@ -2228,8 +2233,8 @@ export function invert(photon_image) { * @param {PhotonImage} photon_image */ export function laplace(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.laplace(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.laplace(photon_image.__wbg_ptr); } /** @@ -2261,10 +2266,10 @@ export function laplace(photon_image) { * @param {number} amt */ export function lch(photon_image, mode, amt) { - _assertClass(photon_image, PhotonImage); - const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.lch(photon_image.__wbg_ptr, ptr0, len0, amt); + _assertClass(photon_image, PhotonImage); + const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.lch(photon_image.__wbg_ptr, ptr0, len0, amt); } /** @@ -2289,8 +2294,8 @@ export function lch(photon_image, mode, amt) { * @param {number} level */ export function lighten_hsl(img, level) { - _assertClass(img, PhotonImage); - wasm.lighten_hsl(img.__wbg_ptr, level); + _assertClass(img, PhotonImage); + wasm.lighten_hsl(img.__wbg_ptr, level); } /** @@ -2316,8 +2321,8 @@ export function lighten_hsl(img, level) { * @param {number} level */ export function lighten_hsluv(img, level) { - _assertClass(img, PhotonImage); - wasm.lighten_hsluv(img.__wbg_ptr, level); + _assertClass(img, PhotonImage); + wasm.lighten_hsluv(img.__wbg_ptr, level); } /** @@ -2343,8 +2348,8 @@ export function lighten_hsluv(img, level) { * @param {number} level */ export function lighten_hsv(img, level) { - _assertClass(img, PhotonImage); - wasm.lighten_hsv(img.__wbg_ptr, level); + _assertClass(img, PhotonImage); + wasm.lighten_hsv(img.__wbg_ptr, level); } /** @@ -2370,8 +2375,8 @@ export function lighten_hsv(img, level) { * @param {number} level */ export function lighten_lch(img, level) { - _assertClass(img, PhotonImage); - wasm.lighten_lch(img.__wbg_ptr, level); + _assertClass(img, PhotonImage); + wasm.lighten_lch(img.__wbg_ptr, level); } /** @@ -2391,8 +2396,8 @@ export function lighten_lch(img, level) { * @param {PhotonImage} photon_image */ export function lix(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.lix(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.lix(photon_image.__wbg_ptr); } /** @@ -2412,8 +2417,8 @@ export function lix(photon_image) { * @param {PhotonImage} img */ export function lofi(img) { - _assertClass(img, PhotonImage); - wasm.lofi(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.lofi(img.__wbg_ptr); } /** @@ -2445,10 +2450,10 @@ export function lofi(img) { * @param {number} opacity */ export function mix_with_colour(photon_image, mix_colour, opacity) { - _assertClass(photon_image, PhotonImage); - _assertClass(mix_colour, Rgb); - var ptr0 = mix_colour.__destroy_into_raw(); - wasm.mix_with_colour(photon_image.__wbg_ptr, ptr0, opacity); + _assertClass(photon_image, PhotonImage); + _assertClass(mix_colour, Rgb); + var ptr0 = mix_colour.__destroy_into_raw(); + wasm.mix_with_colour(photon_image.__wbg_ptr, ptr0, opacity); } /** @@ -2478,8 +2483,8 @@ export function mix_with_colour(photon_image, mix_colour, opacity) { * @param {number} b_offset */ export function monochrome(img, r_offset, g_offset, b_offset) { - _assertClass(img, PhotonImage); - wasm.monochrome(img.__wbg_ptr, r_offset, g_offset, b_offset); + _assertClass(img, PhotonImage); + wasm.monochrome(img.__wbg_ptr, r_offset, g_offset, b_offset); } /** @@ -2503,10 +2508,10 @@ export function monochrome(img, r_offset, g_offset, b_offset) { * @param {Rgb} rgb_color */ export function monochrome_tint(img, rgb_color) { - _assertClass(img, PhotonImage); - _assertClass(rgb_color, Rgb); - var ptr0 = rgb_color.__destroy_into_raw(); - wasm.monochrome_tint(img.__wbg_ptr, ptr0); + _assertClass(img, PhotonImage); + _assertClass(rgb_color, Rgb); + var ptr0 = rgb_color.__destroy_into_raw(); + wasm.monochrome_tint(img.__wbg_ptr, ptr0); } /** @@ -2531,8 +2536,8 @@ export function monochrome_tint(img, rgb_color) { * @param {number} channel_index2 */ export function multiple_offsets(photon_image, offset, channel_index, channel_index2) { - _assertClass(photon_image, PhotonImage); - wasm.multiple_offsets(photon_image.__wbg_ptr, offset, channel_index, channel_index2); + _assertClass(photon_image, PhotonImage); + wasm.multiple_offsets(photon_image.__wbg_ptr, offset, channel_index, channel_index2); } /** @@ -2552,8 +2557,8 @@ export function multiple_offsets(photon_image, offset, channel_index, channel_in * @param {PhotonImage} photon_image */ export function neue(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.neue(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.neue(photon_image.__wbg_ptr); } /** @@ -2576,8 +2581,8 @@ export function neue(photon_image) { * @param {PhotonImage} photon_image */ export function noise_reduction(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.noise_reduction(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.noise_reduction(photon_image.__wbg_ptr); } /** @@ -2599,8 +2604,8 @@ export function noise_reduction(photon_image) { * @param {PhotonImage} photon_image */ export function normalize(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.normalize(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.normalize(photon_image.__wbg_ptr); } /** @@ -2620,8 +2625,8 @@ export function normalize(photon_image) { * @param {PhotonImage} img */ export function obsidian(img) { - _assertClass(img, PhotonImage); - wasm.obsidian(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.obsidian(img.__wbg_ptr); } /** @@ -2648,8 +2653,8 @@ export function obsidian(img) { * @param {number} offset */ export function offset(photon_image, channel_index, offset) { - _assertClass(photon_image, PhotonImage); - wasm.offset(photon_image.__wbg_ptr, channel_index, offset); + _assertClass(photon_image, PhotonImage); + wasm.offset(photon_image.__wbg_ptr, channel_index, offset); } /** @@ -2672,8 +2677,8 @@ export function offset(photon_image, channel_index, offset) { * @param {number} offset_amt */ export function offset_blue(img, offset_amt) { - _assertClass(img, PhotonImage); - wasm.offset_blue(img.__wbg_ptr, offset_amt); + _assertClass(img, PhotonImage); + wasm.offset_blue(img.__wbg_ptr, offset_amt); } /** @@ -2696,8 +2701,8 @@ export function offset_blue(img, offset_amt) { * @param {number} offset_amt */ export function offset_green(img, offset_amt) { - _assertClass(img, PhotonImage); - wasm.offset_green(img.__wbg_ptr, offset_amt); + _assertClass(img, PhotonImage); + wasm.offset_green(img.__wbg_ptr, offset_amt); } /** @@ -2720,8 +2725,8 @@ export function offset_green(img, offset_amt) { * @param {number} offset_amt */ export function offset_red(img, offset_amt) { - _assertClass(img, PhotonImage); - wasm.offset_red(img.__wbg_ptr, offset_amt); + _assertClass(img, PhotonImage); + wasm.offset_red(img.__wbg_ptr, offset_amt); } /** @@ -2746,8 +2751,8 @@ export function offset_red(img, offset_amt) { * @param {number} intensity */ export function oil(photon_image, radius, intensity) { - _assertClass(photon_image, PhotonImage); - wasm.oil(photon_image.__wbg_ptr, radius, intensity); + _assertClass(photon_image, PhotonImage); + wasm.oil(photon_image.__wbg_ptr, radius, intensity); } /** @@ -2760,8 +2765,8 @@ export function oil(photon_image, radius, intensity) { * @returns {PhotonImage} */ export function open_image(canvas, ctx) { - const ret = wasm.open_image(canvas, ctx); - return PhotonImage.__wrap(ret); + const ret = wasm.open_image(canvas, ctx); + return PhotonImage.__wrap(ret); } /** @@ -2790,11 +2795,11 @@ export function open_image(canvas, ctx) { * @returns {PhotonImage} */ export function padding_bottom(img, padding, padding_rgba) { - _assertClass(img, PhotonImage); - _assertClass(padding_rgba, Rgba); - var ptr0 = padding_rgba.__destroy_into_raw(); - const ret = wasm.padding_bottom(img.__wbg_ptr, padding, ptr0); - return PhotonImage.__wrap(ret); + _assertClass(img, PhotonImage); + _assertClass(padding_rgba, Rgba); + var ptr0 = padding_rgba.__destroy_into_raw(); + const ret = wasm.padding_bottom(img.__wbg_ptr, padding, ptr0); + return PhotonImage.__wrap(ret); } /** @@ -2823,11 +2828,11 @@ export function padding_bottom(img, padding, padding_rgba) { * @returns {PhotonImage} */ export function padding_left(img, padding, padding_rgba) { - _assertClass(img, PhotonImage); - _assertClass(padding_rgba, Rgba); - var ptr0 = padding_rgba.__destroy_into_raw(); - const ret = wasm.padding_left(img.__wbg_ptr, padding, ptr0); - return PhotonImage.__wrap(ret); + _assertClass(img, PhotonImage); + _assertClass(padding_rgba, Rgba); + var ptr0 = padding_rgba.__destroy_into_raw(); + const ret = wasm.padding_left(img.__wbg_ptr, padding, ptr0); + return PhotonImage.__wrap(ret); } /** @@ -2856,11 +2861,11 @@ export function padding_left(img, padding, padding_rgba) { * @returns {PhotonImage} */ export function padding_right(img, padding, padding_rgba) { - _assertClass(img, PhotonImage); - _assertClass(padding_rgba, Rgba); - var ptr0 = padding_rgba.__destroy_into_raw(); - const ret = wasm.padding_right(img.__wbg_ptr, padding, ptr0); - return PhotonImage.__wrap(ret); + _assertClass(img, PhotonImage); + _assertClass(padding_rgba, Rgba); + var ptr0 = padding_rgba.__destroy_into_raw(); + const ret = wasm.padding_right(img.__wbg_ptr, padding, ptr0); + return PhotonImage.__wrap(ret); } /** @@ -2889,11 +2894,11 @@ export function padding_right(img, padding, padding_rgba) { * @returns {PhotonImage} */ export function padding_top(img, padding, padding_rgba) { - _assertClass(img, PhotonImage); - _assertClass(padding_rgba, Rgba); - var ptr0 = padding_rgba.__destroy_into_raw(); - const ret = wasm.padding_top(img.__wbg_ptr, padding, ptr0); - return PhotonImage.__wrap(ret); + _assertClass(img, PhotonImage); + _assertClass(padding_rgba, Rgba); + var ptr0 = padding_rgba.__destroy_into_raw(); + const ret = wasm.padding_top(img.__wbg_ptr, padding, ptr0); + return PhotonImage.__wrap(ret); } /** @@ -2922,11 +2927,11 @@ export function padding_top(img, padding, padding_rgba) { * @returns {PhotonImage} */ export function padding_uniform(img, padding, padding_rgba) { - _assertClass(img, PhotonImage); - _assertClass(padding_rgba, Rgba); - var ptr0 = padding_rgba.__destroy_into_raw(); - const ret = wasm.padding_uniform(img.__wbg_ptr, padding, ptr0); - return PhotonImage.__wrap(ret); + _assertClass(img, PhotonImage); + _assertClass(padding_rgba, Rgba); + var ptr0 = padding_rgba.__destroy_into_raw(); + const ret = wasm.padding_uniform(img.__wbg_ptr, padding, ptr0); + return PhotonImage.__wrap(ret); } /** @@ -2946,8 +2951,8 @@ export function padding_uniform(img, padding, padding_rgba) { * @param {PhotonImage} img */ export function pastel_pink(img) { - _assertClass(img, PhotonImage); - wasm.pastel_pink(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.pastel_pink(img.__wbg_ptr); } /** @@ -2971,8 +2976,8 @@ export function pastel_pink(img) { * @param {PhotonImage} photon_image */ export function pink_noise(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.pink_noise(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.pink_noise(photon_image.__wbg_ptr); } /** @@ -2995,8 +3000,8 @@ export function pink_noise(photon_image) { * @param {number} pixel_size */ export function pixelize(photon_image, pixel_size) { - _assertClass(photon_image, PhotonImage); - wasm.pixelize(photon_image.__wbg_ptr, pixel_size); + _assertClass(photon_image, PhotonImage); + wasm.pixelize(photon_image.__wbg_ptr, pixel_size); } /** @@ -3018,8 +3023,8 @@ export function pixelize(photon_image, pixel_size) { * @param {PhotonImage} photon_image */ export function prewitt_horizontal(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.prewitt_horizontal(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.prewitt_horizontal(photon_image.__wbg_ptr); } /** @@ -3040,8 +3045,8 @@ export function prewitt_horizontal(photon_image) { * @param {PhotonImage} img */ export function primary(img) { - _assertClass(img, PhotonImage); - wasm.primary(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.primary(img.__wbg_ptr); } /** @@ -3051,9 +3056,9 @@ export function primary(img) { * @param {PhotonImage} new_image */ export function putImageData(canvas, ctx, new_image) { - _assertClass(new_image, PhotonImage); - var ptr0 = new_image.__destroy_into_raw(); - wasm.putImageData(canvas, ctx, ptr0); + _assertClass(new_image, PhotonImage); + var ptr0 = new_image.__destroy_into_raw(); + wasm.putImageData(canvas, ctx, ptr0); } /** @@ -3074,8 +3079,8 @@ export function putImageData(canvas, ctx, new_image) { * @param {PhotonImage} photon_image */ export function r_grayscale(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.r_grayscale(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.r_grayscale(photon_image.__wbg_ptr); } /** @@ -3099,8 +3104,8 @@ export function r_grayscale(photon_image) { * @param {number} min_filter */ export function remove_blue_channel(img, min_filter) { - _assertClass(img, PhotonImage); - wasm.remove_blue_channel(img.__wbg_ptr, min_filter); + _assertClass(img, PhotonImage); + wasm.remove_blue_channel(img.__wbg_ptr, min_filter); } /** @@ -3128,8 +3133,8 @@ export function remove_blue_channel(img, min_filter) { * @param {number} min_filter */ export function remove_channel(img, channel, min_filter) { - _assertClass(img, PhotonImage); - wasm.remove_channel(img.__wbg_ptr, channel, min_filter); + _assertClass(img, PhotonImage); + wasm.remove_channel(img.__wbg_ptr, channel, min_filter); } /** @@ -3153,8 +3158,8 @@ export function remove_channel(img, channel, min_filter) { * @param {number} min_filter */ export function remove_green_channel(img, min_filter) { - _assertClass(img, PhotonImage); - wasm.remove_green_channel(img.__wbg_ptr, min_filter); + _assertClass(img, PhotonImage); + wasm.remove_green_channel(img.__wbg_ptr, min_filter); } /** @@ -3178,8 +3183,8 @@ export function remove_green_channel(img, min_filter) { * @param {number} min_filter */ export function remove_red_channel(img, min_filter) { - _assertClass(img, PhotonImage); - wasm.remove_red_channel(img.__wbg_ptr, min_filter); + _assertClass(img, PhotonImage); + wasm.remove_red_channel(img.__wbg_ptr, min_filter); } /** @@ -3206,9 +3211,9 @@ export function remove_red_channel(img, min_filter) { * @returns {PhotonImage} */ export function resample(img, dst_width, dst_height) { - _assertClass(img, PhotonImage); - const ret = wasm.resample(img.__wbg_ptr, dst_width, dst_height); - return PhotonImage.__wrap(ret); + _assertClass(img, PhotonImage); + const ret = wasm.resample(img.__wbg_ptr, dst_width, dst_height); + return PhotonImage.__wrap(ret); } /** @@ -3226,9 +3231,9 @@ export function resample(img, dst_width, dst_height) { * @returns {PhotonImage} */ export function resize(photon_img, width, height, sampling_filter) { - _assertClass(photon_img, PhotonImage); - const ret = wasm.resize(photon_img.__wbg_ptr, width, height, sampling_filter); - return PhotonImage.__wrap(ret); + _assertClass(photon_img, PhotonImage); + const ret = wasm.resize(photon_img.__wbg_ptr, width, height, sampling_filter); + return PhotonImage.__wrap(ret); } /** @@ -3246,9 +3251,9 @@ export function resize(photon_img, width, height, sampling_filter) { * @returns {HTMLCanvasElement} */ export function resize_img_browser(photon_img, width, height, sampling_filter) { - _assertClass(photon_img, PhotonImage); - const ret = wasm.resize_img_browser(photon_img.__wbg_ptr, width, height, sampling_filter); - return ret; + _assertClass(photon_img, PhotonImage); + const ret = wasm.resize_img_browser(photon_img.__wbg_ptr, width, height, sampling_filter); + return ret; } /** @@ -3274,19 +3279,19 @@ export function resize_img_browser(photon_img, width, height, sampling_filter) { * @returns {PhotonImage} */ export function rotate(photon_img, angle) { - _assertClass(photon_img, PhotonImage); - const ret = wasm.rotate(photon_img.__wbg_ptr, angle); - return PhotonImage.__wrap(ret); + _assertClass(photon_img, PhotonImage); + const ret = wasm.rotate(photon_img.__wbg_ptr, angle); + return PhotonImage.__wrap(ret); } /** * ! [temp] Check if WASM is supported. */ export function run() { - const ret = wasm.run(); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } + const ret = wasm.run(); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } } /** @@ -3306,8 +3311,8 @@ export function run() { * @param {PhotonImage} photon_image */ export function ryo(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.ryo(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.ryo(photon_image.__wbg_ptr); } /** @@ -3333,8 +3338,8 @@ export function ryo(photon_image) { * @param {number} level */ export function saturate_hsl(img, level) { - _assertClass(img, PhotonImage); - wasm.saturate_hsl(img.__wbg_ptr, level); + _assertClass(img, PhotonImage); + wasm.saturate_hsl(img.__wbg_ptr, level); } /** @@ -3359,8 +3364,8 @@ export function saturate_hsl(img, level) { * @param {number} level */ export function saturate_hsluv(img, level) { - _assertClass(img, PhotonImage); - wasm.saturate_hsluv(img.__wbg_ptr, level); + _assertClass(img, PhotonImage); + wasm.saturate_hsluv(img.__wbg_ptr, level); } /** @@ -3385,8 +3390,8 @@ export function saturate_hsluv(img, level) { * @param {number} level */ export function saturate_hsv(img, level) { - _assertClass(img, PhotonImage); - wasm.saturate_hsv(img.__wbg_ptr, level); + _assertClass(img, PhotonImage); + wasm.saturate_hsv(img.__wbg_ptr, level); } /** @@ -3411,8 +3416,8 @@ export function saturate_hsv(img, level) { * @param {number} level */ export function saturate_lch(img, level) { - _assertClass(img, PhotonImage); - wasm.saturate_lch(img.__wbg_ptr, level); + _assertClass(img, PhotonImage); + wasm.saturate_lch(img.__wbg_ptr, level); } /** @@ -3442,9 +3447,9 @@ export function saturate_lch(img, level) { * @returns {PhotonImage} */ export function seam_carve(img, width, height) { - _assertClass(img, PhotonImage); - const ret = wasm.seam_carve(img.__wbg_ptr, width, height); - return PhotonImage.__wrap(ret); + _assertClass(img, PhotonImage); + const ret = wasm.seam_carve(img.__wbg_ptr, width, height); + return PhotonImage.__wrap(ret); } /** @@ -3478,12 +3483,12 @@ export function seam_carve(img, width, height) { * @param {number} fraction */ export function selective_color_convert(photon_image, ref_color, new_color, fraction) { - _assertClass(photon_image, PhotonImage); - _assertClass(ref_color, Rgb); - var ptr0 = ref_color.__destroy_into_raw(); - _assertClass(new_color, Rgb); - var ptr1 = new_color.__destroy_into_raw(); - wasm.selective_color_convert(photon_image.__wbg_ptr, ptr0, ptr1, fraction); + _assertClass(photon_image, PhotonImage); + _assertClass(ref_color, Rgb); + var ptr0 = ref_color.__destroy_into_raw(); + _assertClass(new_color, Rgb); + var ptr1 = new_color.__destroy_into_raw(); + wasm.selective_color_convert(photon_image.__wbg_ptr, ptr0, ptr1, fraction); } /** @@ -3514,10 +3519,10 @@ export function selective_color_convert(photon_image, ref_color, new_color, frac * @param {number} amt */ export function selective_desaturate(img, ref_color, amt) { - _assertClass(img, PhotonImage); - _assertClass(ref_color, Rgb); - var ptr0 = ref_color.__destroy_into_raw(); - wasm.selective_desaturate(img.__wbg_ptr, ptr0, amt); + _assertClass(img, PhotonImage); + _assertClass(ref_color, Rgb); + var ptr0 = ref_color.__destroy_into_raw(); + wasm.selective_desaturate(img.__wbg_ptr, ptr0, amt); } /** @@ -3547,11 +3552,11 @@ export function selective_desaturate(img, ref_color, amt) { * @param {Rgb} ref_color */ export function selective_greyscale(photon_image, ref_color) { - _assertClass(photon_image, PhotonImage); - var ptr0 = photon_image.__destroy_into_raw(); - _assertClass(ref_color, Rgb); - var ptr1 = ref_color.__destroy_into_raw(); - wasm.selective_greyscale(ptr0, ptr1); + _assertClass(photon_image, PhotonImage); + var ptr0 = photon_image.__destroy_into_raw(); + _assertClass(ref_color, Rgb); + var ptr1 = ref_color.__destroy_into_raw(); + wasm.selective_greyscale(ptr0, ptr1); } /** @@ -3582,10 +3587,10 @@ export function selective_greyscale(photon_image, ref_color) { * @param {number} degrees */ export function selective_hue_rotate(photon_image, ref_color, degrees) { - _assertClass(photon_image, PhotonImage); - _assertClass(ref_color, Rgb); - var ptr0 = ref_color.__destroy_into_raw(); - wasm.selective_hue_rotate(photon_image.__wbg_ptr, ptr0, degrees); + _assertClass(photon_image, PhotonImage); + _assertClass(ref_color, Rgb); + var ptr0 = ref_color.__destroy_into_raw(); + wasm.selective_hue_rotate(photon_image.__wbg_ptr, ptr0, degrees); } /** @@ -3615,10 +3620,10 @@ export function selective_hue_rotate(photon_image, ref_color, degrees) { * @param {number} amt */ export function selective_lighten(img, ref_color, amt) { - _assertClass(img, PhotonImage); - _assertClass(ref_color, Rgb); - var ptr0 = ref_color.__destroy_into_raw(); - wasm.selective_lighten(img.__wbg_ptr, ptr0, amt); + _assertClass(img, PhotonImage); + _assertClass(ref_color, Rgb); + var ptr0 = ref_color.__destroy_into_raw(); + wasm.selective_lighten(img.__wbg_ptr, ptr0, amt); } /** @@ -3649,10 +3654,10 @@ export function selective_lighten(img, ref_color, amt) { * @param {number} amt */ export function selective_saturate(img, ref_color, amt) { - _assertClass(img, PhotonImage); - _assertClass(ref_color, Rgb); - var ptr0 = ref_color.__destroy_into_raw(); - wasm.selective_saturate(img.__wbg_ptr, ptr0, amt); + _assertClass(img, PhotonImage); + _assertClass(ref_color, Rgb); + var ptr0 = ref_color.__destroy_into_raw(); + wasm.selective_saturate(img.__wbg_ptr, ptr0, amt); } /** @@ -3673,8 +3678,8 @@ export function selective_saturate(img, ref_color, amt) { * @param {PhotonImage} img */ export function sepia(img) { - _assertClass(img, PhotonImage); - wasm.sepia(img.__wbg_ptr); + _assertClass(img, PhotonImage); + wasm.sepia(img.__wbg_ptr); } /** @@ -3697,8 +3702,8 @@ export function sepia(img) { * @param {PhotonImage} photon_image */ export function sharpen(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.sharpen(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.sharpen(photon_image.__wbg_ptr); } /** @@ -3724,9 +3729,9 @@ export function sharpen(photon_image) { * @returns {PhotonImage} */ export function shearx(photon_img, shear) { - _assertClass(photon_img, PhotonImage); - const ret = wasm.shearx(photon_img.__wbg_ptr, shear); - return PhotonImage.__wrap(ret); + _assertClass(photon_img, PhotonImage); + const ret = wasm.shearx(photon_img.__wbg_ptr, shear); + return PhotonImage.__wrap(ret); } /** @@ -3752,9 +3757,9 @@ export function shearx(photon_img, shear) { * @returns {PhotonImage} */ export function sheary(photon_img, shear) { - _assertClass(photon_img, PhotonImage); - const ret = wasm.sheary(photon_img.__wbg_ptr, shear); - return PhotonImage.__wrap(ret); + _assertClass(photon_img, PhotonImage); + const ret = wasm.sheary(photon_img.__wbg_ptr, shear); + return PhotonImage.__wrap(ret); } /** @@ -3777,8 +3782,8 @@ export function sheary(photon_img, shear) { * @param {number} channel */ export function single_channel_grayscale(photon_image, channel) { - _assertClass(photon_image, PhotonImage); - wasm.single_channel_grayscale(photon_image.__wbg_ptr, channel); + _assertClass(photon_image, PhotonImage); + wasm.single_channel_grayscale(photon_image.__wbg_ptr, channel); } /** @@ -3803,8 +3808,8 @@ export function single_channel_grayscale(photon_image, channel) { * @param {PhotonImage} photon_image */ export function sobel_global(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.sobel_global(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.sobel_global(photon_image.__wbg_ptr); } /** @@ -3826,8 +3831,8 @@ export function sobel_global(photon_image) { * @param {PhotonImage} photon_image */ export function sobel_horizontal(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.sobel_horizontal(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.sobel_horizontal(photon_image.__wbg_ptr); } /** @@ -3849,8 +3854,8 @@ export function sobel_horizontal(photon_image) { * @param {PhotonImage} photon_image */ export function sobel_vertical(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.sobel_vertical(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.sobel_vertical(photon_image.__wbg_ptr); } /** @@ -3871,8 +3876,8 @@ export function sobel_vertical(photon_image) { * @param {PhotonImage} photon_image */ export function solarize(photon_image) { - _assertClass(photon_image, PhotonImage); - wasm.solarize(photon_image.__wbg_ptr); + _assertClass(photon_image, PhotonImage); + wasm.solarize(photon_image.__wbg_ptr); } /** @@ -3895,9 +3900,9 @@ export function solarize(photon_image) { * @returns {PhotonImage} */ export function solarize_retimg(photon_image) { - _assertClass(photon_image, PhotonImage); - const ret = wasm.solarize_retimg(photon_image.__wbg_ptr); - return PhotonImage.__wrap(ret); + _assertClass(photon_image, PhotonImage); + const ret = wasm.solarize_retimg(photon_image.__wbg_ptr); + return PhotonImage.__wrap(ret); } /** @@ -3923,8 +3928,8 @@ export function solarize_retimg(photon_image) { * @param {number} channel2 */ export function swap_channels(img, channel1, channel2) { - _assertClass(img, PhotonImage); - wasm.swap_channels(img.__wbg_ptr, channel1, channel2); + _assertClass(img, PhotonImage); + wasm.swap_channels(img.__wbg_ptr, channel1, channel2); } /** @@ -3947,8 +3952,8 @@ export function swap_channels(img, channel1, channel2) { * @param {number} threshold */ export function threshold(img, threshold) { - _assertClass(img, PhotonImage); - wasm.threshold(img.__wbg_ptr, threshold); + _assertClass(img, PhotonImage); + wasm.threshold(img.__wbg_ptr, threshold); } /** @@ -3975,8 +3980,8 @@ export function threshold(img, threshold) { * @param {number} b_offset */ export function tint(photon_image, r_offset, g_offset, b_offset) { - _assertClass(photon_image, PhotonImage); - wasm.tint(photon_image.__wbg_ptr, r_offset, g_offset, b_offset); + _assertClass(photon_image, PhotonImage); + wasm.tint(photon_image.__wbg_ptr, r_offset, g_offset, b_offset); } /** @@ -3985,10 +3990,10 @@ export function tint(photon_image, r_offset, g_offset, b_offset) { * @returns {ImageData} */ export function to_image_data(photon_image) { - _assertClass(photon_image, PhotonImage); - var ptr0 = photon_image.__destroy_into_raw(); - const ret = wasm.to_image_data(ptr0); - return ret; + _assertClass(photon_image, PhotonImage); + var ptr0 = photon_image.__destroy_into_raw(); + const ret = wasm.to_image_data(ptr0); + return ret; } /** @@ -3997,10 +4002,10 @@ export function to_image_data(photon_image) { * @returns {Uint8Array} */ export function to_raw_pixels(imgdata) { - const ret = wasm.to_raw_pixels(imgdata); - var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v1; + const ret = wasm.to_raw_pixels(imgdata); + var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v1; } /** @@ -4023,8 +4028,8 @@ export function to_raw_pixels(imgdata) { * @param {number} num_strips */ export function vertical_strips(photon_image, num_strips) { - _assertClass(photon_image, PhotonImage); - wasm.vertical_strips(photon_image.__wbg_ptr, num_strips); + _assertClass(photon_image, PhotonImage); + wasm.vertical_strips(photon_image.__wbg_ptr, num_strips); } /** @@ -4052,401 +4057,428 @@ export function vertical_strips(photon_image, num_strips) { * @param {bigint} y */ export function watermark(img, watermark, x, y) { - _assertClass(img, PhotonImage); - _assertClass(watermark, PhotonImage); - wasm.watermark(img.__wbg_ptr, watermark.__wbg_ptr, x, y); + _assertClass(img, PhotonImage); + _assertClass(watermark, PhotonImage); + wasm.watermark(img.__wbg_ptr, watermark.__wbg_ptr, x, y); } function __wbg_get_imports() { - const import0 = { - __proto__: null, - __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) { - const ret = debugString(arg1); - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); - }, - __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) { - const ret = arg0 === undefined; - return ret; - }, - __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); - }, - __wbg_appendChild_dea38765a26d346d: function() { return handleError(function (arg0, arg1) { - const ret = arg0.appendChild(arg1); - return ret; - }, arguments); }, - __wbg_body_f67922363a220026: function(arg0) { - const ret = arg0.body; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); - }, - __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) { - const ret = arg0.call(arg1); - return ret; - }, arguments); }, - __wbg_createElement_49f60fdcaae809c8: function() { return handleError(function (arg0, arg1, arg2) { - const ret = arg0.createElement(getStringFromWasm0(arg1, arg2)); - return ret; - }, arguments); }, - __wbg_data_d52fd40cc1d7d4e8: function(arg0, arg1) { - const ret = arg1.data; - const ptr1 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); - }, - __wbg_document_ee35a3d3ae34ef6c: function(arg0) { - const ret = arg0.document; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); - }, - __wbg_drawImage_00302fc1908197cc: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) { - arg0.drawImage(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); - }, arguments); }, - __wbg_drawImage_51b6a9d03c34c5cc: function() { return handleError(function (arg0, arg1, arg2, arg3) { - arg0.drawImage(arg1, arg2, arg3); - }, arguments); }, - __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) { - let deferred0_0; - let deferred0_1; - try { - deferred0_0 = arg0; - deferred0_1 = arg1; - console.error(getStringFromWasm0(arg0, arg1)); - } finally { - wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); - } - }, - __wbg_getContext_2a5764d48600bc43: function() { return handleError(function (arg0, arg1, arg2) { - const ret = arg0.getContext(getStringFromWasm0(arg1, arg2)); - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); - }, arguments); }, - __wbg_getImageData_24d72830c218154d: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { - const ret = arg0.getImageData(arg1, arg2, arg3, arg4); - return ret; - }, arguments); }, - __wbg_height_38750dc6de41ee75: function(arg0) { - const ret = arg0.height; - return ret; - }, - __wbg_height_408f385de046f7e5: function(arg0) { - const ret = arg0.height; - return ret; - }, - __wbg_height_87250db2be5164b9: function(arg0) { - const ret = arg0.height; - return ret; - }, - __wbg_instanceof_CanvasRenderingContext2d_4bb052fd1c3d134d: function(arg0) { - let result; - try { - result = arg0 instanceof CanvasRenderingContext2D; - } catch (_) { - result = false; - } - const ret = result; - return ret; - }, - __wbg_instanceof_HtmlCanvasElement_3f2f6e1edb1c9792: function(arg0) { - let result; - try { - result = arg0 instanceof HTMLCanvasElement; - } catch (_) { - result = false; - } - const ret = result; - return ret; - }, - __wbg_instanceof_Window_ed49b2db8df90359: function(arg0) { - let result; - try { - result = arg0 instanceof Window; - } catch (_) { - result = false; - } - const ret = result; - return ret; - }, - __wbg_length_32ed9a279acd054c: function(arg0) { - const ret = arg0.length; - return ret; - }, - __wbg_new_8a6f238a6ece86ea: function() { - const ret = new Error(); - return ret; - }, - __wbg_new_dd2b680c8bf6ae29: function(arg0) { - const ret = new Uint8Array(arg0); - return ret; - }, - __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) { - const ret = new Function(getStringFromWasm0(arg0, arg1)); - return ret; - }, - __wbg_new_with_u8_clamped_array_and_sh_0c0b789ceb2eab31: function() { return handleError(function (arg0, arg1, arg2, arg3) { - const ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0); - return ret; - }, arguments); }, - __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) { - Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2); - }, - __wbg_putImageData_78318465ad96c2c3: function() { return handleError(function (arg0, arg1, arg2, arg3) { - arg0.putImageData(arg1, arg2, arg3); - }, arguments); }, - __wbg_set_height_f21f985387070100: function(arg0, arg1) { - arg0.height = arg1 >>> 0; - }, - __wbg_set_textContent_3e87dba095d9cdbc: function(arg0, arg1, arg2) { - arg0.textContent = arg1 === 0 ? undefined : getStringFromWasm0(arg1, arg2); - }, - __wbg_set_width_d60bc4f2f20c56a4: function(arg0, arg1) { - arg0.width = arg1 >>> 0; - }, - __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) { - const ret = arg1.stack; - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); - }, - __wbg_static_accessor_GLOBAL_12837167ad935116: function() { - const ret = typeof global === 'undefined' ? null : global; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); - }, - __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() { - const ret = typeof globalThis === 'undefined' ? null : globalThis; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); - }, - __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() { - const ret = typeof self === 'undefined' ? null : self; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); - }, - __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() { - const ret = typeof window === 'undefined' ? null : window; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); - }, - __wbg_width_5901d980713eb80b: function(arg0) { - const ret = arg0.width; - return ret; - }, - __wbg_width_5f66bde2e810fbde: function(arg0) { - const ret = arg0.width; - return ret; - }, - __wbg_width_be8f36d66d37751f: function(arg0) { - const ret = arg0.width; - return ret; - }, - __wbindgen_init_externref_table: function() { - const table = wasm.__wbindgen_externrefs; - const offset = table.grow(4); - table.set(0, undefined); - table.set(offset + 0, undefined); - table.set(offset + 1, null); - table.set(offset + 2, true); - table.set(offset + 3, false); - }, - }; - return { - __proto__: null, - "./photon_rs_bg.js": import0, - }; + const import0 = { + __proto__: null, + __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function (arg0, arg1) { + const ret = debugString(arg1); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); + }, + __wbg___wbindgen_is_undefined_9e4d92534c42d778: function (arg0) { + const ret = arg0 === undefined; + return ret; + }, + __wbg___wbindgen_throw_be289d5034ed271b: function (arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }, + __wbg_appendChild_dea38765a26d346d: function () { + return handleError(function (arg0, arg1) { + const ret = arg0.appendChild(arg1); + return ret; + }, arguments); + }, + __wbg_body_f67922363a220026: function (arg0) { + const ret = arg0.body; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, + __wbg_call_389efe28435a9388: function () { + return handleError(function (arg0, arg1) { + const ret = arg0.call(arg1); + return ret; + }, arguments); + }, + __wbg_createElement_49f60fdcaae809c8: function () { + return handleError(function (arg0, arg1, arg2) { + const ret = arg0.createElement(getStringFromWasm0(arg1, arg2)); + return ret; + }, arguments); + }, + __wbg_data_d52fd40cc1d7d4e8: function (arg0, arg1) { + const ret = arg1.data; + const ptr1 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); + }, + __wbg_document_ee35a3d3ae34ef6c: function (arg0) { + const ret = arg0.document; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, + __wbg_drawImage_00302fc1908197cc: function () { + return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) { + arg0.drawImage(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + }, arguments); + }, + __wbg_drawImage_51b6a9d03c34c5cc: function () { + return handleError(function (arg0, arg1, arg2, arg3) { + arg0.drawImage(arg1, arg2, arg3); + }, arguments); + }, + __wbg_error_7534b8e9a36f1ab4: function (arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }, + __wbg_getContext_2a5764d48600bc43: function () { + return handleError(function (arg0, arg1, arg2) { + const ret = arg0.getContext(getStringFromWasm0(arg1, arg2)); + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, arguments); + }, + __wbg_getImageData_24d72830c218154d: function () { + return handleError(function (arg0, arg1, arg2, arg3, arg4) { + const ret = arg0.getImageData(arg1, arg2, arg3, arg4); + return ret; + }, arguments); + }, + __wbg_height_38750dc6de41ee75: function (arg0) { + const ret = arg0.height; + return ret; + }, + __wbg_height_408f385de046f7e5: function (arg0) { + const ret = arg0.height; + return ret; + }, + __wbg_height_87250db2be5164b9: function (arg0) { + const ret = arg0.height; + return ret; + }, + __wbg_instanceof_CanvasRenderingContext2d_4bb052fd1c3d134d: function (arg0) { + let result; + try { + result = arg0 instanceof CanvasRenderingContext2D; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }, + __wbg_instanceof_HtmlCanvasElement_3f2f6e1edb1c9792: function (arg0) { + let result; + try { + result = arg0 instanceof HTMLCanvasElement; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }, + __wbg_instanceof_Window_ed49b2db8df90359: function (arg0) { + let result; + try { + result = arg0 instanceof Window; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }, + __wbg_length_32ed9a279acd054c: function (arg0) { + const ret = arg0.length; + return ret; + }, + __wbg_new_8a6f238a6ece86ea: function () { + const ret = new Error(); + return ret; + }, + __wbg_new_dd2b680c8bf6ae29: function (arg0) { + const ret = new Uint8Array(arg0); + return ret; + }, + __wbg_new_no_args_1c7c842f08d00ebb: function (arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return ret; + }, + __wbg_new_with_u8_clamped_array_and_sh_0c0b789ceb2eab31: function () { + return handleError(function (arg0, arg1, arg2, arg3) { + const ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0); + return ret; + }, arguments); + }, + __wbg_prototypesetcall_bdcdcc5842e4d77d: function (arg0, arg1, arg2) { + Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2); + }, + __wbg_putImageData_78318465ad96c2c3: function () { + return handleError(function (arg0, arg1, arg2, arg3) { + arg0.putImageData(arg1, arg2, arg3); + }, arguments); + }, + __wbg_set_height_f21f985387070100: function (arg0, arg1) { + arg0.height = arg1 >>> 0; + }, + __wbg_set_textContent_3e87dba095d9cdbc: function (arg0, arg1, arg2) { + arg0.textContent = arg1 === 0 ? undefined : getStringFromWasm0(arg1, arg2); + }, + __wbg_set_width_d60bc4f2f20c56a4: function (arg0, arg1) { + arg0.width = arg1 >>> 0; + }, + __wbg_stack_0ed75d68575b0f3c: function (arg0, arg1) { + const ret = arg1.stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); + }, + __wbg_static_accessor_GLOBAL_12837167ad935116: function () { + const ret = typeof global === "undefined" ? null : global; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, + __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function () { + const ret = typeof globalThis === "undefined" ? null : globalThis; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, + __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function () { + const ret = typeof self === "undefined" ? null : self; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, + __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function () { + const ret = typeof window === "undefined" ? null : window; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, + __wbg_width_5901d980713eb80b: function (arg0) { + const ret = arg0.width; + return ret; + }, + __wbg_width_5f66bde2e810fbde: function (arg0) { + const ret = arg0.width; + return ret; + }, + __wbg_width_be8f36d66d37751f: function (arg0) { + const ret = arg0.width; + return ret; + }, + __wbindgen_init_externref_table: function () { + const table = wasm.__wbindgen_externrefs; + const offset = table.grow(4); + table.set(0, undefined); + table.set(offset + 0, undefined); + table.set(offset + 1, null); + table.set(offset + 2, true); + table.set(offset + 3, false); + }, + }; + return { + __proto__: null, + "./photon_rs_bg.js": import0, + }; } -const PhotonImageFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_photonimage_free(ptr >>> 0, 1)); -const RgbFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_rgb_free(ptr >>> 0, 1)); -const RgbaFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_rgba_free(ptr >>> 0, 1)); +const PhotonImageFinalization = + typeof FinalizationRegistry === "undefined" + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry((ptr) => wasm.__wbg_photonimage_free(ptr >>> 0, 1)); +const RgbFinalization = + typeof FinalizationRegistry === "undefined" + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry((ptr) => wasm.__wbg_rgb_free(ptr >>> 0, 1)); +const RgbaFinalization = + typeof FinalizationRegistry === "undefined" + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry((ptr) => wasm.__wbg_rgba_free(ptr >>> 0, 1)); function addToExternrefTable0(obj) { - const idx = wasm.__externref_table_alloc(); - wasm.__wbindgen_externrefs.set(idx, obj); - return idx; + const idx = wasm.__externref_table_alloc(); + wasm.__wbindgen_externrefs.set(idx, obj); + return idx; } function _assertClass(instance, klass) { - if (!(instance instanceof klass)) { - throw new Error(`expected instance of ${klass.name}`); - } + if (!(instance instanceof klass)) { + throw new Error(`expected instance of ${klass.name}`); + } } function debugString(val) { - // primitive types - const type = typeof val; - if (type == 'number' || type == 'boolean' || val == null) { - return `${val}`; - } - if (type == 'string') { - return `"${val}"`; - } - if (type == 'symbol') { - const description = val.description; - if (description == null) { - return 'Symbol'; - } else { - return `Symbol(${description})`; - } - } - if (type == 'function') { - const name = val.name; - if (typeof name == 'string' && name.length > 0) { - return `Function(${name})`; - } else { - return 'Function'; - } - } - // objects - if (Array.isArray(val)) { - const length = val.length; - let debug = '['; - if (length > 0) { - debug += debugString(val[0]); - } - for(let i = 1; i < length; i++) { - debug += ', ' + debugString(val[i]); - } - debug += ']'; - return debug; - } - // Test for built-in - const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); - let className; - if (builtInMatches && builtInMatches.length > 1) { - className = builtInMatches[1]; - } else { - // Failed to match the standard '[object ClassName]' - return toString.call(val); - } - if (className == 'Object') { - // we're a user defined class or Object - // JSON.stringify avoids problems with cycles, and is generally much - // easier than looping through ownProperties of `val`. - try { - return 'Object(' + JSON.stringify(val) + ')'; - } catch (_) { - return 'Object'; - } - } - // errors - if (val instanceof Error) { - return `${val.name}: ${val.message}\n${val.stack}`; - } - // TODO we could test for more things here, like `Set`s and `Map`s. - return className; + // primitive types + const type = typeof val; + if (type == "number" || type == "boolean" || val == null) { + return `${val}`; + } + if (type == "string") { + return `"${val}"`; + } + if (type == "symbol") { + const description = val.description; + if (description == null) { + return "Symbol"; + } else { + return `Symbol(${description})`; + } + } + if (type == "function") { + const name = val.name; + if (typeof name == "string" && name.length > 0) { + return `Function(${name})`; + } else { + return "Function"; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = "["; + if (length > 0) { + debug += debugString(val[0]); + } + for (let i = 1; i < length; i++) { + debug += ", " + debugString(val[i]); + } + debug += "]"; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches && builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == "Object") { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return "Object(" + JSON.stringify(val) + ")"; + } catch (_) { + return "Object"; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; } function getArrayU8FromWasm0(ptr, len) { - ptr = ptr >>> 0; - return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); + ptr = ptr >>> 0; + return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); } function getClampedArrayU8FromWasm0(ptr, len) { - ptr = ptr >>> 0; - return getUint8ClampedArrayMemory0().subarray(ptr / 1, ptr / 1 + len); + ptr = ptr >>> 0; + return getUint8ClampedArrayMemory0().subarray(ptr / 1, ptr / 1 + len); } let cachedDataViewMemory0 = null; function getDataViewMemory0() { - if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { - cachedDataViewMemory0 = new DataView(wasm.memory.buffer); - } - return cachedDataViewMemory0; + if ( + cachedDataViewMemory0 === null || + cachedDataViewMemory0.buffer.detached === true || + (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer) + ) { + cachedDataViewMemory0 = new DataView(wasm.memory.buffer); + } + return cachedDataViewMemory0; } function getStringFromWasm0(ptr, len) { - ptr = ptr >>> 0; - return decodeText(ptr, len); + ptr = ptr >>> 0; + return decodeText(ptr, len); } let cachedUint8ArrayMemory0 = null; function getUint8ArrayMemory0() { - if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { - cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); - } - return cachedUint8ArrayMemory0; + if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { + cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8ArrayMemory0; } let cachedUint8ClampedArrayMemory0 = null; function getUint8ClampedArrayMemory0() { - if (cachedUint8ClampedArrayMemory0 === null || cachedUint8ClampedArrayMemory0.byteLength === 0) { - cachedUint8ClampedArrayMemory0 = new Uint8ClampedArray(wasm.memory.buffer); - } - return cachedUint8ClampedArrayMemory0; + if (cachedUint8ClampedArrayMemory0 === null || cachedUint8ClampedArrayMemory0.byteLength === 0) { + cachedUint8ClampedArrayMemory0 = new Uint8ClampedArray(wasm.memory.buffer); + } + return cachedUint8ClampedArrayMemory0; } function handleError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - const idx = addToExternrefTable0(e); - wasm.__wbindgen_exn_store(idx); - } + try { + return f.apply(this, args); + } catch (e) { + const idx = addToExternrefTable0(e); + wasm.__wbindgen_exn_store(idx); + } } function isLikeNone(x) { - return x === undefined || x === null; + return x === undefined || x === null; } function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1, 1) >>> 0; - getUint8ArrayMemory0().set(arg, ptr / 1); - WASM_VECTOR_LEN = arg.length; - return ptr; + const ptr = malloc(arg.length * 1, 1) >>> 0; + getUint8ArrayMemory0().set(arg, ptr / 1); + WASM_VECTOR_LEN = arg.length; + return ptr; } function passStringToWasm0(arg, malloc, realloc) { - if (realloc === undefined) { - const buf = cachedTextEncoder.encode(arg); - const ptr = malloc(buf.length, 1) >>> 0; - getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf); - WASM_VECTOR_LEN = buf.length; - return ptr; - } + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8ArrayMemory0() + .subarray(ptr, ptr + buf.length) + .set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } - let len = arg.length; - let ptr = malloc(len, 1) >>> 0; + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; - const mem = getUint8ArrayMemory0(); + const mem = getUint8ArrayMemory0(); - let offset = 0; + let offset = 0; - for (; offset < len; offset++) { - const code = arg.charCodeAt(offset); - if (code > 0x7F) break; - mem[ptr + offset] = code; - } - if (offset !== len) { - if (offset !== 0) { - arg = arg.slice(offset); - } - ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; - const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); - const ret = cachedTextEncoder.encodeInto(arg, view); + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7f) break; + mem[ptr + offset] = code; + } + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, (len = offset + arg.length * 3), 1) >>> 0; + const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); + const ret = cachedTextEncoder.encodeInto(arg, view); - offset += ret.written; - ptr = realloc(ptr, len, offset, 1) >>> 0; - } + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } - WASM_VECTOR_LEN = offset; - return ptr; + WASM_VECTOR_LEN = offset; + return ptr; } function takeFromExternrefTable0(idx) { - const value = wasm.__wbindgen_externrefs.get(idx); - wasm.__externref_table_dealloc(idx); - return value; + const value = wasm.__wbindgen_externrefs.get(idx); + wasm.__externref_table_dealloc(idx); + return value; } -let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); +let cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }); cachedTextDecoder.decode(); function decodeText(ptr, len) { - return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); + return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); } const cachedTextEncoder = new TextEncoder(); @@ -4457,24 +4489,32 @@ let WASM_VECTOR_LEN = 0; let wasmInstantiated; const imports = __wbg_get_imports(); -// Try .wasm file first (dev) - streaming is most efficient -let streamingError; -try { - const wasmPath = new URL("./photon_rs_bg.wasm", import.meta.url); - wasmInstantiated = await WebAssembly.instantiateStreaming(fetch(wasmPath), imports); -} catch (e) { - streamingError = e; -} +import wasmPath from "./photon_rs_bg.wasm"; -// Fall back to base64 (compiled binary/npm) -if (!wasmInstantiated) { - try { - const { default: wasmBase64 } = await import("./photon_rs_bg.wasm.b64.js"); - const wasmBytes = Uint8Array.from(atob(wasmBase64), c => c.charCodeAt(0)); - wasmInstantiated = await WebAssembly.instantiate(wasmBytes, imports); - } catch (b64Error) { - throw new Error(`Failed to load photon WASM:\n streaming: ${streamingError?.message}\n base64: ${b64Error.message}`); - } +try { + const url = import.meta.resolve(wasmPath); + wasmInstantiated = await WebAssembly.instantiateStreaming(fetch(url), imports); +} catch (e) { + const log = (message) => { + try { + process.stderr.write(`${message}\n`); + } catch { + console.error(message); + } + }; + log("============== PHOTON LOADER =============="); + if (error instanceof Error) { + log(`${error.name}: ${error.message}\n${error.stack}`); + } else { + log(`Unknown error: ${String(error)}`); + } + log("============== PHOTON LOADER =============="); + try { + process.stderr.end(); + } catch { + // Ignore + } + process.exit(3); } const wasm = wasmInstantiated.instance.exports; diff --git a/packages/coding-agent/src/vendor/photon/photon_rs_bg.wasm b/packages/coding-agent/src/vendor/photon/photon_rs_bg.wasm index a9b977643..82f04121c 100644 --- a/packages/coding-agent/src/vendor/photon/photon_rs_bg.wasm +++ b/packages/coding-agent/src/vendor/photon/photon_rs_bg.wasm @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:db2efcd06f94951a5f13736f4fc9b83c694aaa99f6699b9fbe6042d8c70d8146 -size 1939017 +oid sha256:e51491958652d0c0523cc2a974913d57aaf8bed537c0d244c01df32f9928b6f6 +size 1539011 diff --git a/packages/coding-agent/src/web/scrapers/choosealicense.ts b/packages/coding-agent/src/web/scrapers/choosealicense.ts index ca3875e27..edd310506 100644 --- a/packages/coding-agent/src/web/scrapers/choosealicense.ts +++ b/packages/coding-agent/src/web/scrapers/choosealicense.ts @@ -1,4 +1,4 @@ -import { parseFrontmatter } from "@oh-my-pi/pi-coding-agent/utils/frontmatter"; +import { parseFrontmatter } from "../../utils/frontmatter"; import type { RenderResult, SpecialHandler } from "./types"; import { finalizeOutput, loadPage } from "./types"; diff --git a/packages/coding-agent/src/web/scrapers/twitter.ts b/packages/coding-agent/src/web/scrapers/twitter.ts index 90e689e6d..335f56037 100644 --- a/packages/coding-agent/src/web/scrapers/twitter.ts +++ b/packages/coding-agent/src/web/scrapers/twitter.ts @@ -1,5 +1,5 @@ -import { ToolAbortError } from "@oh-my-pi/pi-coding-agent/tools/tool-errors"; import { parse as parseHtml } from "node-html-parser"; +import { ToolAbortError } from "../../tools/tool-errors"; import type { RenderResult, SpecialHandler } from "./types"; import { finalizeOutput, loadPage } from "./types"; diff --git a/packages/coding-agent/src/web/scrapers/types.ts b/packages/coding-agent/src/web/scrapers/types.ts index 8eaf95d27..89b3ea912 100644 --- a/packages/coding-agent/src/web/scrapers/types.ts +++ b/packages/coding-agent/src/web/scrapers/types.ts @@ -2,7 +2,7 @@ * Shared types and utilities for web-fetch handlers */ -import { ToolAbortError } from "@oh-my-pi/pi-coding-agent/tools/tool-errors"; +import { ToolAbortError } from "../../tools/tool-errors"; export interface RenderResult { url: string; diff --git a/packages/coding-agent/src/web/scrapers/utils.ts b/packages/coding-agent/src/web/scrapers/utils.ts index 5c19baa2e..35dab425f 100644 --- a/packages/coding-agent/src/web/scrapers/utils.ts +++ b/packages/coding-agent/src/web/scrapers/utils.ts @@ -1,9 +1,9 @@ import { rm } from "node:fs/promises"; import { tmpdir } from "node:os"; import * as path from "node:path"; -import { ensureTool } from "@oh-my-pi/pi-coding-agent/utils/tools-manager"; import { ptree } from "@oh-my-pi/pi-utils"; import { nanoid } from "nanoid"; +import { ensureTool } from "../../utils/tools-manager"; import { createRequestSignal } from "./types"; const MAX_BYTES = 50 * 1024 * 1024; // 50MB for binary files diff --git a/packages/coding-agent/src/web/scrapers/youtube.ts b/packages/coding-agent/src/web/scrapers/youtube.ts index 97b4d4e45..ac02dbc26 100644 --- a/packages/coding-agent/src/web/scrapers/youtube.ts +++ b/packages/coding-agent/src/web/scrapers/youtube.ts @@ -1,10 +1,10 @@ import { unlinkSync } from "node:fs"; import { tmpdir } from "node:os"; import path from "node:path"; -import { throwIfAborted } from "@oh-my-pi/pi-coding-agent/tools/tool-errors"; -import { ensureTool } from "@oh-my-pi/pi-coding-agent/utils/tools-manager"; import { cspawn } from "@oh-my-pi/pi-utils"; import { nanoid } from "nanoid"; +import { throwIfAborted } from "../../tools/tool-errors"; +import { ensureTool } from "../../utils/tools-manager"; import type { RenderResult, SpecialHandler } from "./types"; import { finalizeOutput } from "./types"; diff --git a/packages/coding-agent/src/web/search/auth.ts b/packages/coding-agent/src/web/search/auth.ts index 4b71e9353..c5ca88288 100644 --- a/packages/coding-agent/src/web/search/auth.ts +++ b/packages/coding-agent/src/web/search/auth.ts @@ -11,15 +11,11 @@ import * as os from "node:os"; import * as path from "node:path"; import { buildAnthropicHeaders as buildProviderAnthropicHeaders } from "@oh-my-pi/pi-ai"; -import { getAgentDbPath, getConfigDirPaths } from "@oh-my-pi/pi-coding-agent/config"; -import { AgentStorage } from "@oh-my-pi/pi-coding-agent/session/agent-storage"; -import type { - AuthCredential, - AuthCredentialEntry, - AuthStorageData, -} from "@oh-my-pi/pi-coding-agent/session/auth-storage"; -import { migrateJsonStorage } from "@oh-my-pi/pi-coding-agent/session/storage-migration"; import { logger } from "@oh-my-pi/pi-utils"; +import { getAgentDbPath, getConfigDirPaths } from "../../config"; +import { AgentStorage } from "../../session/agent-storage"; +import type { AuthCredential, AuthCredentialEntry, AuthStorageData } from "../../session/auth-storage"; +import { migrateJsonStorage } from "../../session/storage-migration"; import type { AnthropicAuthConfig, AnthropicOAuthCredential, ModelsJson } from "./types"; const DEFAULT_BASE_URL = "https://api.anthropic.com"; diff --git a/packages/coding-agent/src/web/search/index.ts b/packages/coding-agent/src/web/search/index.ts index fcfcfeda5..dd3b8289f 100644 --- a/packages/coding-agent/src/web/search/index.ts +++ b/packages/coding-agent/src/web/search/index.ts @@ -14,26 +14,17 @@ import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; import { StringEnum } from "@oh-my-pi/pi-ai"; -import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates"; -import { - callExaTool, - findApiKey as findExaKey, - formatSearchResults, - isSearchResponse, -} from "@oh-my-pi/pi-coding-agent/exa/mcp-client"; -import { renderExaCall, renderExaResult } from "@oh-my-pi/pi-coding-agent/exa/render"; -import type { ExaRenderDetails } from "@oh-my-pi/pi-coding-agent/exa/types"; -import type { - CustomTool, - CustomToolContext, - RenderResultOptions, -} from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; -import webSearchSystemPrompt from "@oh-my-pi/pi-coding-agent/prompts/system/web-search.md" with { type: "text" }; -import webSearchDescription from "@oh-my-pi/pi-coding-agent/prompts/tools/web-search.md" with { type: "text" }; -import type { ToolSession } from "@oh-my-pi/pi-coding-agent/tools"; -import { formatAge } from "@oh-my-pi/pi-coding-agent/tools/render-utils"; import { Type } from "@sinclair/typebox"; +import { renderPromptTemplate } from "../../config/prompt-templates"; +import { callExaTool, findApiKey as findExaKey, formatSearchResults, isSearchResponse } from "../../exa/mcp-client"; +import { renderExaCall, renderExaResult } from "../../exa/render"; +import type { ExaRenderDetails } from "../../exa/types"; +import type { CustomTool, CustomToolContext, RenderResultOptions } from "../../extensibility/custom-tools/types"; +import type { Theme } from "../../modes/theme/theme"; +import webSearchSystemPrompt from "../../prompts/system/web-search.md" with { type: "text" }; +import webSearchDescription from "../../prompts/tools/web-search.md" with { type: "text" }; +import type { ToolSession } from "../../tools"; +import { formatAge } from "../../tools/render-utils"; import { findAnthropicAuth } from "./auth"; import { searchAnthropic } from "./providers/anthropic"; import { searchExa } from "./providers/exa"; diff --git a/packages/coding-agent/src/web/search/providers/anthropic.ts b/packages/coding-agent/src/web/search/providers/anthropic.ts index 435eaceb8..cb1362254 100644 --- a/packages/coding-agent/src/web/search/providers/anthropic.ts +++ b/packages/coding-agent/src/web/search/providers/anthropic.ts @@ -6,12 +6,7 @@ */ import { applyClaudeToolPrefix, buildAnthropicSystemBlocks, stripClaudeToolPrefix } from "@oh-my-pi/pi-ai"; -import { - buildAnthropicHeaders, - buildAnthropicUrl, - findAnthropicAuth, - getEnv, -} from "@oh-my-pi/pi-coding-agent/web/search/auth"; +import { buildAnthropicHeaders, buildAnthropicUrl, findAnthropicAuth, getEnv } from "../../../web/search/auth"; import type { AnthropicApiResponse, AnthropicAuthConfig, @@ -19,8 +14,8 @@ import type { WebSearchCitation, WebSearchResponse, WebSearchSource, -} from "@oh-my-pi/pi-coding-agent/web/search/types"; -import { WebSearchProviderError } from "@oh-my-pi/pi-coding-agent/web/search/types"; +} from "../../../web/search/types"; +import { WebSearchProviderError } from "../../../web/search/types"; const DEFAULT_MODEL = "claude-haiku-4-5"; const DEFAULT_MAX_TOKENS = 4096; diff --git a/packages/coding-agent/src/web/search/providers/exa.ts b/packages/coding-agent/src/web/search/providers/exa.ts index 09177097d..d62b0405e 100644 --- a/packages/coding-agent/src/web/search/providers/exa.ts +++ b/packages/coding-agent/src/web/search/providers/exa.ts @@ -7,8 +7,8 @@ import { existsSync, readFileSync } from "node:fs"; import { homedir } from "node:os"; -import type { WebSearchResponse, WebSearchSource } from "@oh-my-pi/pi-coding-agent/web/search/types"; -import { WebSearchProviderError } from "@oh-my-pi/pi-coding-agent/web/search/types"; +import type { WebSearchResponse, WebSearchSource } from "../../../web/search/types"; +import { WebSearchProviderError } from "../../../web/search/types"; const EXA_API_URL = "https://api.exa.ai/search"; diff --git a/packages/coding-agent/src/web/search/providers/perplexity.ts b/packages/coding-agent/src/web/search/providers/perplexity.ts index 7be26e244..e9924d3cb 100644 --- a/packages/coding-agent/src/web/search/providers/perplexity.ts +++ b/packages/coding-agent/src/web/search/providers/perplexity.ts @@ -12,8 +12,8 @@ import type { WebSearchCitation, WebSearchResponse, WebSearchSource, -} from "@oh-my-pi/pi-coding-agent/web/search/types"; -import { WebSearchProviderError } from "@oh-my-pi/pi-coding-agent/web/search/types"; +} from "../../../web/search/types"; +import { WebSearchProviderError } from "../../../web/search/types"; const PERPLEXITY_API_URL = "https://api.perplexity.ai/chat/completions"; diff --git a/packages/coding-agent/src/web/search/render.ts b/packages/coding-agent/src/web/search/render.ts index deb63e90c..288faf336 100644 --- a/packages/coding-agent/src/web/search/render.ts +++ b/packages/coding-agent/src/web/search/render.ts @@ -4,8 +4,10 @@ * Tree-based rendering with collapsed/expanded states for web search results. */ -import type { RenderResultOptions } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types"; -import type { Theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme"; +import type { Component } from "@oh-my-pi/pi-tui"; +import { Text } from "@oh-my-pi/pi-tui"; +import type { RenderResultOptions } from "../../extensibility/custom-tools/types"; +import type { Theme } from "../../modes/theme/theme"; import { formatAge, formatCount, @@ -17,10 +19,8 @@ import { PREVIEW_LIMITS, TRUNCATE_LENGTHS, truncate, -} from "@oh-my-pi/pi-coding-agent/tools/render-utils"; -import { renderOutputBlock, renderStatusLine, renderTreeList } from "@oh-my-pi/pi-coding-agent/tui"; -import type { Component } from "@oh-my-pi/pi-tui"; -import { Text } from "@oh-my-pi/pi-tui"; +} from "../../tools/render-utils"; +import { renderOutputBlock, renderStatusLine, renderTreeList } from "../../tui"; import type { WebSearchResponse } from "./types"; const MAX_COLLAPSED_ANSWER_LINES = PREVIEW_LIMITS.COLLAPSED_LINES; diff --git a/packages/coding-agent/test/core/apply-patch-regression.test.ts b/packages/coding-agent/test/core/apply-patch-regression.test.ts index b7dffcbc9..a2484da74 100644 --- a/packages/coding-agent/test/core/apply-patch-regression.test.ts +++ b/packages/coding-agent/test/core/apply-patch-regression.test.ts @@ -1152,7 +1152,7 @@ describe("regression: bench edit failures (2026-01-19)", () => { ["@@ Line 3-5", 3], ["@@ line 3-5 @@", 3], ["@@ @@ line 3", 3], - ])("line hint variants (%s) target the correct line", async (header, targetLine) => { + ])("line hint variants (%s) target the correct line", async (header: string, targetLine: number) => { const filePath = join(tempDir, `line-hint-${targetLine}.txt`); await Bun.write(filePath, "line 1\nline 2\nline 3\nline 4\nline 5\n"); diff --git a/packages/coding-agent/test/core/python-kernel-env.test.ts b/packages/coding-agent/test/core/python-kernel-env.test.ts index edb574af1..76468fd8c 100644 --- a/packages/coding-agent/test/core/python-kernel-env.test.ts +++ b/packages/coding-agent/test/core/python-kernel-env.test.ts @@ -102,7 +102,7 @@ describe("PythonKernel.start (local gateway)", () => { using tempDir = createTempDirSync("@python-kernel-env-"); const kernel = await PythonKernel.start({ cwd: tempDir.path, env: { CUSTOM_VAR: "ok" } }); - const createCall = fetchSpy.mock.calls.find(([input, init]) => { + const createCall = fetchSpy.mock.calls.find(([input, init]: [string | URL, RequestInit?]) => { const url = typeof input === "string" ? input : input.toString(); return url.endsWith("/api/kernels") && init?.method === "POST"; }); diff --git a/packages/coding-agent/tsconfig.build.json b/packages/coding-agent/tsconfig.build.json index bf925a4eb..ea6be8e9a 100644 --- a/packages/coding-agent/tsconfig.build.json +++ b/packages/coding-agent/tsconfig.build.json @@ -1,9 +1,3 @@ { - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist", - "rootDir": "./src" - }, - "include": ["src/**/*.ts", "src/bun-imports.d.ts"], - "exclude": ["node_modules", "dist", "**/*.test.ts"] + "extends": "./tsconfig.json" } diff --git a/packages/coding-agent/tsconfig.check.json b/packages/coding-agent/tsconfig.check.json index 126064a0d..ea6be8e9a 100644 --- a/packages/coding-agent/tsconfig.check.json +++ b/packages/coding-agent/tsconfig.check.json @@ -1,5 +1,3 @@ { - "extends": "../../tsconfig.json", - "include": ["src/**/*.ts", "test/**/*.ts", "src/bun-imports.d.ts"], - "exclude": ["node_modules", "dist"] + "extends": "./tsconfig.json" } diff --git a/packages/coding-agent/tsconfig.json b/packages/coding-agent/tsconfig.json index 0d9fa126f..76e289af3 100644 --- a/packages/coding-agent/tsconfig.json +++ b/packages/coding-agent/tsconfig.json @@ -1,24 +1,8 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "noEmit": true, - "baseUrl": ".", - "paths": { - "@oh-my-pi/pi-ai": ["../ai/src/index.ts"], - "@oh-my-pi/pi-ai/*": ["../ai/src/*"], - "@oh-my-pi/pi-agent-core": ["../agent/src/index.ts"], - "@oh-my-pi/pi-agent-core/*": ["../agent/src/*"], - "@oh-my-pi/pi-utils": ["../pi-utils/src/index.ts"], - "@oh-my-pi/pi-utils/*": ["../pi-utils/src/*"], - "@oh-my-pi/pi-coding-agent": ["./src/index.ts"], - "@oh-my-pi/pi-coding-agent/hooks": ["./src/extensibility/hooks/index.ts"], - "@oh-my-pi/pi-coding-agent/*": ["./src/*"], - "@oh-my-pi/pi-tui": ["../tui/src/index.ts"], - "@oh-my-pi/pi-tui/*": ["../tui/src/*"], - "@oh-my-pi/pi-mom": ["../mom/src/index.ts"], - "@oh-my-pi/pi-mom/*": ["../mom/src/*"] - } + "noEmit": true }, - "include": ["src/**/*.ts", "src/bun-imports.d.ts"], - "exclude": ["node_modules", "dist", "**/*.test.ts", "test/**"] + "include": ["src/**/*.ts", "src/bun-imports.d.ts", "test/**/*.ts"], + "exclude": ["node_modules", "dist"] } diff --git a/packages/coding-agent/tsconfig.publish.json b/packages/coding-agent/tsconfig.publish.json index c32362384..ea6be8e9a 100644 --- a/packages/coding-agent/tsconfig.publish.json +++ b/packages/coding-agent/tsconfig.publish.json @@ -1,12 +1,3 @@ { - "compilerOptions": { - "noEmit": true, - "baseUrl": ".", - "paths": { - "@oh-my-pi/pi-coding-agent": ["./src/index.ts"], - "@oh-my-pi/pi-coding-agent/hooks": ["./src/extensibility/hooks/index.ts"], - "@oh-my-pi/pi-coding-agent/*": ["./src/*"] - } - }, - "include": ["src/**/*.ts", "src/bun-imports.d.ts"] + "extends": "./tsconfig.json" } diff --git a/packages/pi-utils/package.json b/packages/pi-utils/package.json index 54b93ca98..c611c3980 100644 --- a/packages/pi-utils/package.json +++ b/packages/pi-utils/package.json @@ -16,10 +16,8 @@ "README.md" ], "scripts": { - "check": "tsgo --noEmit", - "build": "tsgo -p tsconfig.build.json", - "test": "vitest --run", - "prepublishOnly": "cp tsconfig.publish.json tsconfig.json" + "check": "tsgo -p tsconfig.json", + "test": "bun test" }, "author": "Can Bölük", "license": "MIT", diff --git a/packages/pi-utils/tsconfig.build.json b/packages/pi-utils/tsconfig.build.json index 6089faa7f..c9011ba2a 100644 --- a/packages/pi-utils/tsconfig.build.json +++ b/packages/pi-utils/tsconfig.build.json @@ -1,9 +1,3 @@ { - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist", - "rootDir": "./src" - }, - "include": ["src/**/*.ts"], - "exclude": ["node_modules", "dist", "**/*.d.ts", "src/**/*.d.ts"] + "extends": "./tsconfig.json" } \ No newline at end of file diff --git a/packages/pi-utils/tsconfig.json b/packages/pi-utils/tsconfig.json new file mode 100644 index 000000000..41b5f2b67 --- /dev/null +++ b/packages/pi-utils/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "noEmit": true + }, + "include": ["src/**/*.ts", "test/**/*.ts"], + "exclude": ["node_modules", "dist"] +} diff --git a/packages/pi-utils/tsconfig.publish.json b/packages/pi-utils/tsconfig.publish.json index 6f0defa2b..ea6be8e9a 100644 --- a/packages/pi-utils/tsconfig.publish.json +++ b/packages/pi-utils/tsconfig.publish.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "noEmit": true, - "baseUrl": ".", - "paths": { - "@oh-my-pi/pi-utils": ["./src/index.ts"], - "@oh-my-pi/pi-utils/*": ["./src/*"] - } - }, - "include": ["src/**/*.ts"] + "extends": "./tsconfig.json" } diff --git a/packages/react-edit-benchmark/package.json b/packages/react-edit-benchmark/package.json index 2a1fe1605..1f95907d5 100644 --- a/packages/react-edit-benchmark/package.json +++ b/packages/react-edit-benchmark/package.json @@ -10,7 +10,8 @@ }, "scripts": { "start": "bun run index.ts", - "generate": "bun run generate.ts --react-dir /tmp/react-source --count-per-type 4" + "generate": "bun run generate.ts --react-dir /tmp/react-source --count-per-type 4", + "check": "tsgo -p tsconfig.json --noEmit" }, "dependencies": { "@oh-my-pi/pi-agent-core": "workspace:*", diff --git a/packages/react-edit-benchmark/tsconfig.json b/packages/react-edit-benchmark/tsconfig.json index 2bfd5204c..319f9d43e 100644 --- a/packages/react-edit-benchmark/tsconfig.json +++ b/packages/react-edit-benchmark/tsconfig.json @@ -1,9 +1,11 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + "noEmit": true, "rootDir": ".", "outDir": "dist", "types": ["bun-types"] }, - "include": ["*.ts", "test/**/*.ts"] + "include": ["*.ts", "test/**/*.ts"], + "exclude": ["dist", "node_modules"] } diff --git a/packages/stats/package.json b/packages/stats/package.json index 1ca3e8813..26ae2f3b8 100644 --- a/packages/stats/package.json +++ b/packages/stats/package.json @@ -6,7 +6,7 @@ "main": "./src/index.ts", "types": "./src/index.ts", "bin": { - "omp-stats": "./dist/index.js" + "omp-stats": "./src/index.ts" }, "exports": { ".": { @@ -23,7 +23,6 @@ } }, "files": [ - "dist", "src", "public", "README.md" @@ -38,9 +37,8 @@ ], "scripts": { "dev": "bun run src/index.ts", - "check": "tsgo --noEmit && tsgo --noEmit -p tsconfig.client.json", - "build": "bun run build.ts && tsgo -p tsconfig.build.json", - "prepublishOnly": "cp tsconfig.publish.json tsconfig.json && bun run build" + "check": "tsgo -p tsconfig.json && tsgo -p tsconfig.client.json", + "build": "bun run build.ts" }, "author": "Can Bölük", "license": "MIT", diff --git a/packages/stats/src/index.ts b/packages/stats/src/index.ts index e2ba18657..d57d0898e 100755 --- a/packages/stats/src/index.ts +++ b/packages/stats/src/index.ts @@ -145,7 +145,7 @@ Examples: // Start server const port = parseInt(values.port || "3847", 10); - const { port: actualPort } = startServer(port); + const { port: actualPort } = await startServer(port); console.log(`Dashboard available at: http://localhost:${actualPort}`); console.log("Press Ctrl+C to stop\n"); diff --git a/packages/stats/src/server.ts b/packages/stats/src/server.ts index 3bd09bb4f..e50745a06 100644 --- a/packages/stats/src/server.ts +++ b/packages/stats/src/server.ts @@ -1,3 +1,4 @@ +import { rm } from "node:fs/promises"; import { join } from "node:path"; import { getDashboardStats, @@ -8,8 +9,69 @@ import { syncAllSessions, } from "./aggregator"; +const CLIENT_DIR = join(import.meta.dir, "client"); const STATIC_DIR = join(import.meta.dir, "..", "dist", "client"); +const ensureClientBuild = async () => { + const indexFile = Bun.file(join(STATIC_DIR, "index.html")); + if (await indexFile.exists()) return; + + await rm(STATIC_DIR, { recursive: true, force: true }); + + const result = await Bun.build({ + entrypoints: [join(CLIENT_DIR, "index.tsx")], + outdir: STATIC_DIR, + minify: true, + naming: "[dir]/[name].[ext]", + }); + + if (!result.success) { + const errors = result.logs.map((log) => log.message).join("\n"); + throw new Error(`Failed to build stats client:\n${errors}`); + } + + const indexHtml = ` + + + + + AI Usage Statistics + + + +
+ + +`; + + await Bun.write(join(STATIC_DIR, "index.html"), indexHtml); +}; + /** * Handle API requests. */ @@ -93,7 +155,9 @@ async function handleStatic(path: string): Promise { /** * Start the HTTP server. */ -export function startServer(port = 3847): { port: number; stop: () => void } { +export async function startServer(port = 3847): Promise<{ port: number; stop: () => void }> { + await ensureClientBuild(); + const server = Bun.serve({ port, async fetch(req) { diff --git a/packages/stats/tsconfig.build.json b/packages/stats/tsconfig.build.json index b7ca8a1d1..ea6be8e9a 100644 --- a/packages/stats/tsconfig.build.json +++ b/packages/stats/tsconfig.build.json @@ -1,9 +1,3 @@ { - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist", - "rootDir": "./src" - }, - "include": ["src/**/*"], - "exclude": ["src/client/**/*"] + "extends": "./tsconfig.json" } diff --git a/packages/stats/tsconfig.json b/packages/stats/tsconfig.json index a4f1509c6..cf79120b5 100644 --- a/packages/stats/tsconfig.json +++ b/packages/stats/tsconfig.json @@ -1,8 +1,8 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { "noEmit": true }, - "include": ["src/**/*"], - "exclude": ["src/client/**/*"] + "include": ["src/**/*.ts", "test/**/*.ts"], + "exclude": ["src/client/**/*", "node_modules", "dist"] } diff --git a/packages/stats/tsconfig.publish.json b/packages/stats/tsconfig.publish.json index 2f918c94a..ea6be8e9a 100644 --- a/packages/stats/tsconfig.publish.json +++ b/packages/stats/tsconfig.publish.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "noEmit": true, - "baseUrl": ".", - "paths": { - "@oh-my-pi/omp-stats": ["./src/index.ts"], - "@oh-my-pi/omp-stats/*": ["./src/*"] - } - }, - "include": ["src/**/*.ts", "src/**/*.tsx"] + "extends": "./tsconfig.json" } diff --git a/packages/tui/package.json b/packages/tui/package.json index f8446472b..f4fde7225 100644 --- a/packages/tui/package.json +++ b/packages/tui/package.json @@ -3,10 +3,25 @@ "version": "8.1.0", "description": "Terminal User Interface library with differential rendering for efficient text-based applications", "type": "module", - "main": "src/index.ts", + "main": "./src/index.ts", + "types": "./src/index.ts", + "exports": { + ".": { + "types": "./src/index.ts", + "import": "./src/index.ts" + }, + "./components/*": { + "types": "./src/components/*.ts", + "import": "./src/components/*.ts" + }, + "./*": { + "types": "./src/*.ts", + "import": "./src/*.ts" + } + }, "scripts": { - "test": "bun test test/*.test.ts", - "prepublishOnly": "cp tsconfig.publish.json tsconfig.json" + "check": "tsgo -p tsconfig.json", + "test": "bun test test/*.test.ts" }, "files": [ "src/**/*", @@ -31,7 +46,6 @@ "engines": { "bun": ">=1.0.0" }, - "types": "./src/index.ts", "dependencies": { "@types/mime-types": "^2.1.4", "chalk": "^5.5.0", diff --git a/packages/tui/src/components/box.ts b/packages/tui/src/components/box.ts index 22cd0db80..da11eaa5e 100644 --- a/packages/tui/src/components/box.ts +++ b/packages/tui/src/components/box.ts @@ -1,5 +1,5 @@ -import type { Component } from "@oh-my-pi/pi-tui/tui"; -import { applyBackgroundToLine, visibleWidth } from "@oh-my-pi/pi-tui/utils"; +import type { Component } from "../tui"; +import { applyBackgroundToLine, visibleWidth } from "../utils"; /** * Box component - a container that applies padding and background to all children diff --git a/packages/tui/src/components/cancellable-loader.ts b/packages/tui/src/components/cancellable-loader.ts index 8d0a700ae..ec16447ae 100644 --- a/packages/tui/src/components/cancellable-loader.ts +++ b/packages/tui/src/components/cancellable-loader.ts @@ -1,4 +1,4 @@ -import { matchesKey } from "@oh-my-pi/pi-tui/keys"; +import { matchesKey } from "../keys"; import { Loader } from "./loader"; /** diff --git a/packages/tui/src/components/editor.ts b/packages/tui/src/components/editor.ts index fb8fd6c04..58ca3112a 100644 --- a/packages/tui/src/components/editor.ts +++ b/packages/tui/src/components/editor.ts @@ -1,14 +1,8 @@ -import type { AutocompleteProvider, CombinedAutocompleteProvider } from "@oh-my-pi/pi-tui/autocomplete"; -import { matchesKey } from "@oh-my-pi/pi-tui/keys"; -import type { SymbolTheme } from "@oh-my-pi/pi-tui/symbols"; -import { type Component, CURSOR_MARKER, type Focusable } from "@oh-my-pi/pi-tui/tui"; -import { - getSegmenter, - isPunctuationChar, - isWhitespaceChar, - truncateToWidth, - visibleWidth, -} from "@oh-my-pi/pi-tui/utils"; +import type { AutocompleteProvider, CombinedAutocompleteProvider } from "../autocomplete"; +import { matchesKey } from "../keys"; +import type { SymbolTheme } from "../symbols"; +import { type Component, CURSOR_MARKER, type Focusable } from "../tui"; +import { getSegmenter, isPunctuationChar, isWhitespaceChar, truncateToWidth, visibleWidth } from "../utils"; import { SelectList, type SelectListTheme } from "./select-list"; const segmenter = getSegmenter(); diff --git a/packages/tui/src/components/image.ts b/packages/tui/src/components/image.ts index 477705733..7676fb8b8 100644 --- a/packages/tui/src/components/image.ts +++ b/packages/tui/src/components/image.ts @@ -4,8 +4,8 @@ import { type ImageDimensions, imageFallback, renderImage, -} from "@oh-my-pi/pi-tui/terminal-image"; -import type { Component } from "@oh-my-pi/pi-tui/tui"; +} from "../terminal-image"; +import type { Component } from "../tui"; export interface ImageTheme { fallbackColor: (str: string) => string; diff --git a/packages/tui/src/components/input.ts b/packages/tui/src/components/input.ts index 7fef511cc..e029277b9 100644 --- a/packages/tui/src/components/input.ts +++ b/packages/tui/src/components/input.ts @@ -1,6 +1,6 @@ -import { getEditorKeybindings } from "@oh-my-pi/pi-tui/keybindings"; -import { type Component, CURSOR_MARKER, type Focusable } from "@oh-my-pi/pi-tui/tui"; -import { getSegmenter, isPunctuationChar, isWhitespaceChar, visibleWidth } from "@oh-my-pi/pi-tui/utils"; +import { getEditorKeybindings } from "../keybindings"; +import { type Component, CURSOR_MARKER, type Focusable } from "../tui"; +import { getSegmenter, isPunctuationChar, isWhitespaceChar, visibleWidth } from "../utils"; const segmenter = getSegmenter(); diff --git a/packages/tui/src/components/loader.ts b/packages/tui/src/components/loader.ts index a059a858e..42a20f009 100644 --- a/packages/tui/src/components/loader.ts +++ b/packages/tui/src/components/loader.ts @@ -1,4 +1,4 @@ -import type { TUI } from "@oh-my-pi/pi-tui/tui"; +import type { TUI } from "../tui"; import { Text } from "./text"; /** diff --git a/packages/tui/src/components/markdown.ts b/packages/tui/src/components/markdown.ts index fca663189..7bedd576f 100644 --- a/packages/tui/src/components/markdown.ts +++ b/packages/tui/src/components/markdown.ts @@ -1,9 +1,9 @@ -import type { MermaidImage } from "@oh-my-pi/pi-tui/mermaid"; -import type { SymbolTheme } from "@oh-my-pi/pi-tui/symbols"; -import { encodeITerm2, encodeKitty, getCapabilities, getCellDimensions } from "@oh-my-pi/pi-tui/terminal-image"; -import type { Component } from "@oh-my-pi/pi-tui/tui"; -import { applyBackgroundToLine, visibleWidth, wrapTextWithAnsi } from "@oh-my-pi/pi-tui/utils"; import { marked, type Token } from "marked"; +import type { MermaidImage } from "../mermaid"; +import type { SymbolTheme } from "../symbols"; +import { encodeITerm2, encodeKitty, getCapabilities, getCellDimensions } from "../terminal-image"; +import type { Component } from "../tui"; +import { applyBackgroundToLine, visibleWidth, wrapTextWithAnsi } from "../utils"; /** * Default text styling for markdown content. diff --git a/packages/tui/src/components/select-list.ts b/packages/tui/src/components/select-list.ts index 511b7a62c..bf5ed4e05 100644 --- a/packages/tui/src/components/select-list.ts +++ b/packages/tui/src/components/select-list.ts @@ -1,7 +1,7 @@ -import { matchesKey } from "@oh-my-pi/pi-tui/keys"; -import type { SymbolTheme } from "@oh-my-pi/pi-tui/symbols"; -import type { Component } from "@oh-my-pi/pi-tui/tui"; -import { truncateToWidth, visibleWidth } from "@oh-my-pi/pi-tui/utils"; +import { matchesKey } from "../keys"; +import type { SymbolTheme } from "../symbols"; +import type { Component } from "../tui"; +import { truncateToWidth, visibleWidth } from "../utils"; export interface SelectItem { value: string; diff --git a/packages/tui/src/components/settings-list.ts b/packages/tui/src/components/settings-list.ts index 570b5b193..319751231 100644 --- a/packages/tui/src/components/settings-list.ts +++ b/packages/tui/src/components/settings-list.ts @@ -1,6 +1,6 @@ -import { matchesKey } from "@oh-my-pi/pi-tui/keys"; -import type { Component } from "@oh-my-pi/pi-tui/tui"; -import { truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@oh-my-pi/pi-tui/utils"; +import { matchesKey } from "../keys"; +import type { Component } from "../tui"; +import { truncateToWidth, visibleWidth, wrapTextWithAnsi } from "../utils"; export interface SettingItem { /** Unique identifier for this setting */ diff --git a/packages/tui/src/components/spacer.ts b/packages/tui/src/components/spacer.ts index 0419839b1..ce21920ae 100644 --- a/packages/tui/src/components/spacer.ts +++ b/packages/tui/src/components/spacer.ts @@ -1,4 +1,4 @@ -import type { Component } from "@oh-my-pi/pi-tui/tui"; +import type { Component } from "../tui"; /** * Spacer component that renders empty lines diff --git a/packages/tui/src/components/tab-bar.ts b/packages/tui/src/components/tab-bar.ts index 8bb6db96f..e85c25f5c 100644 --- a/packages/tui/src/components/tab-bar.ts +++ b/packages/tui/src/components/tab-bar.ts @@ -9,9 +9,9 @@ * - Shift+Tab / Arrow Left: Previous tab (wraps around) */ -import { matchesKey } from "@oh-my-pi/pi-tui/keys"; -import type { Component } from "@oh-my-pi/pi-tui/tui"; -import { wrapTextWithAnsi } from "@oh-my-pi/pi-tui/utils"; +import { matchesKey } from "../keys"; +import type { Component } from "../tui"; +import { wrapTextWithAnsi } from "../utils"; /** Tab definition */ export interface Tab { diff --git a/packages/tui/src/components/text.ts b/packages/tui/src/components/text.ts index 3da34c63e..baa1d9bb1 100644 --- a/packages/tui/src/components/text.ts +++ b/packages/tui/src/components/text.ts @@ -1,5 +1,5 @@ -import type { Component } from "@oh-my-pi/pi-tui/tui"; -import { applyBackgroundToLine, wrapTextWithAnsi } from "@oh-my-pi/pi-tui/utils"; +import type { Component } from "../tui"; +import { applyBackgroundToLine, wrapTextWithAnsi } from "../utils"; /** * Text component - displays multi-line text with word wrapping diff --git a/packages/tui/src/components/truncated-text.ts b/packages/tui/src/components/truncated-text.ts index fff2351b4..861306e9f 100644 --- a/packages/tui/src/components/truncated-text.ts +++ b/packages/tui/src/components/truncated-text.ts @@ -1,5 +1,5 @@ -import type { Component } from "@oh-my-pi/pi-tui/tui"; -import { truncateToWidth } from "@oh-my-pi/pi-tui/utils"; +import type { Component } from "../tui"; +import { truncateToWidth } from "../utils"; /** * Text component that truncates to fit viewport width diff --git a/packages/tui/tsconfig.build.json b/packages/tui/tsconfig.build.json index 5ce430296..c9011ba2a 100644 --- a/packages/tui/tsconfig.build.json +++ b/packages/tui/tsconfig.build.json @@ -1,9 +1,3 @@ { - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist", - "rootDir": "./src" - }, - "include": ["src/**/*"], - "exclude": ["node_modules", "dist"] + "extends": "./tsconfig.json" } \ No newline at end of file diff --git a/packages/tui/tsconfig.json b/packages/tui/tsconfig.json index f9f4eda5e..41b5f2b67 100644 --- a/packages/tui/tsconfig.json +++ b/packages/tui/tsconfig.json @@ -1,21 +1,8 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "noEmit": true, - "baseUrl": ".", - "paths": { - "@oh-my-pi/pi-tui": ["./src/index.ts"], - "@oh-my-pi/pi-tui/*": ["./src/*"], - "@oh-my-pi/pi-ai": ["../ai/src/index.ts"], - "@oh-my-pi/pi-ai/*": ["../ai/src/*"], - "@oh-my-pi/pi-agent-core": ["../agent/src/index.ts"], - "@oh-my-pi/pi-agent-core/*": ["../agent/src/*"], - "@oh-my-pi/pi-utils": ["../pi-utils/src/index.ts"], - "@oh-my-pi/pi-utils/*": ["../pi-utils/src/*"], - "@oh-my-pi/pi-coding-agent": ["../coding-agent/src/index.ts"], - "@oh-my-pi/pi-coding-agent/*": ["../coding-agent/src/*"] - } + "noEmit": true }, - "include": ["src/**/*.ts"], + "include": ["src/**/*.ts", "test/**/*.ts"], "exclude": ["node_modules", "dist"] } diff --git a/packages/tui/tsconfig.publish.json b/packages/tui/tsconfig.publish.json index e69ed6f31..ea6be8e9a 100644 --- a/packages/tui/tsconfig.publish.json +++ b/packages/tui/tsconfig.publish.json @@ -1,11 +1,3 @@ { - "compilerOptions": { - "noEmit": true, - "baseUrl": ".", - "paths": { - "@oh-my-pi/pi-tui": ["./src/index.ts"], - "@oh-my-pi/pi-tui/*": ["./src/*"] - } - }, - "include": ["src/**/*.ts"] + "extends": "./tsconfig.json" } diff --git a/tsconfig.base.json b/tsconfig.base.json index 6dbd2c14d..a6cc2221b 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -14,10 +14,31 @@ "inlineSourceMap": false, "moduleResolution": "Bundler", "resolveJsonModule": true, + "allowArbitraryExtensions": true, "allowImportingTsExtensions": false, "experimentalDecorators": true, "emitDecoratorMetadata": true, "useDefineForClassFields": false, - "types": ["bun", "node"] - } + "types": ["bun", "node", "assets"], + "typeRoots": ["./types", "./node_modules/@types"], + "paths": { + "@oh-my-pi/pi-ai": ["./packages/ai/src/index.ts"], + "@oh-my-pi/pi-ai/*": ["./packages/ai/src/*"], + "@oh-my-pi/pi-agent-core": ["./packages/agent/src/index.ts"], + "@oh-my-pi/pi-agent-core/*": ["./packages/agent/src/*"], + "@oh-my-pi/pi-utils": ["./packages/pi-utils/src/index.ts"], + "@oh-my-pi/pi-utils/*": ["./packages/pi-utils/src/*"], + "@oh-my-pi/pi-coding-agent": ["./packages/coding-agent/src/index.ts"], + "@oh-my-pi/pi-coding-agent/hooks": ["./packages/coding-agent/src/extensibility/hooks/index.ts"], + "@oh-my-pi/pi-coding-agent/*": ["./packages/coding-agent/src/*"], + "@oh-my-pi/omp-stats": ["./packages/stats/src/index.ts"], + "@oh-my-pi/omp-stats/src/*": ["./packages/stats/src/*"], + "@oh-my-pi/omp-stats/*": ["./packages/stats/src/*"], + "@oh-my-pi/pi-tui": ["./packages/tui/src/index.ts"], + "@oh-my-pi/pi-tui/*": ["./packages/tui/src/*"], + "@sinclair/typebox": ["./node_modules/@sinclair/typebox/build/esm/index.d.mts"], + "@sinclair/typebox/*": ["./node_modules/@sinclair/typebox/build/esm/*"] + } + }, + "files": ["./types/assets/index.d.ts"] } diff --git a/tsconfig.json b/tsconfig.json index e92f16924..c378d5a3f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,26 +1,8 @@ { "extends": "./tsconfig.base.json", "compilerOptions": { - "noEmit": true, - "paths": { - "*": ["./*"], - "@oh-my-pi/pi-ai": ["./packages/ai/src/index.ts"], - "@oh-my-pi/pi-ai/*": ["./packages/ai/src/*"], - "@oh-my-pi/pi-agent-core": ["./packages/agent/src/index.ts"], - "@oh-my-pi/pi-agent-core/*": ["./packages/agent/src/*"], - "@oh-my-pi/pi-utils": ["./packages/pi-utils/src/index.ts"], - "@oh-my-pi/pi-utils/*": ["./packages/pi-utils/src/*"], - "@oh-my-pi/pi-coding-agent": ["./packages/coding-agent/src/index.ts"], - "@oh-my-pi/pi-coding-agent/hooks": ["./packages/coding-agent/src/extensibility/hooks/index.ts"], - "@oh-my-pi/pi-coding-agent/*": ["./packages/coding-agent/src/*"], - "@oh-my-pi/omp-stats": ["./packages/stats/src/index.ts"], - "@oh-my-pi/omp-stats/src/*": ["./packages/stats/src/*"], - "@oh-my-pi/omp-stats/*": ["./packages/stats/src/*"], - "@sinclair/typebox": ["./node_modules/@sinclair/typebox"], - "@oh-my-pi/pi-tui": ["./packages/tui/src/index.ts"], - "@oh-my-pi/pi-tui/*": ["./packages/tui/src/*"] - } + "noEmit": true }, - "include": ["packages/*/src/**/*", "packages/*/test/**/*", "packages/coding-agent/examples/**/*"], - "exclude": ["packages/web-ui/**/*", "**/dist/**"] + "include": ["packages/*/src/**/*", "packages/*/test/**/*"], + "exclude": ["packages/coding-agent/examples/**/*", "packages/stats/src/client/**/*", "packages/web-ui/**/*", "**/dist/**"] } diff --git a/types/assets/index.d.ts b/types/assets/index.d.ts new file mode 100644 index 000000000..d815b4c1b --- /dev/null +++ b/types/assets/index.d.ts @@ -0,0 +1,19 @@ +declare module "*.md" { + const content: string; + export default content; +} + +declare module "*.txt" { + const content: string; + export default content; +} + +declare module "*.py" { + const content: string; + export default content; +} + +declare module "*.wasm?raw" { + const content: string; + export default content; +}