refactor: consolidated module import paths

- Removed custom TypeScript path aliases and the associated transformation script.
- Replaced aliased imports with direct `@oh-my-pi` package imports for improved clarity.
- Simplified internal module references by removing explicit `/index` suffixes.
This commit is contained in:
can1357
2026-01-23 12:48:06 +00:00
parent 0cab1fbce9
commit fcbfab765b
159 changed files with 307 additions and 406 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ This repo contains multiple packages, but **`packages/coding-agent/`** is the pr
| `packages/agent` | Agent runtime with tool calling and state management |
| `packages/coding-agent` | Main CLI application (primary focus) |
| `packages/tui` | Terminal UI library with differential rendering |
| `packages/omp-stats` | Local observability dashboard (`omp stats`) |
| `packages/stats` | Local observability dashboard (`omp stats`) |
| `packages/pi-utils` | Shared utilities (logger, streams, temp files) |
## Code Quality
+15 -1
View File
@@ -78,6 +78,18 @@ Download binaries directly from [GitHub Releases](https://github.com/can1357/oh-
---
## + Commit Tool (AI-Powered Git Commits)
AI-powered conventional commit generation with intelligent change analysis:
- **Agentic mode**: Tool-based git inspection with `git-overview`, `git-file-diff`, `git-hunk` for fine-grained analysis
- **Split commits**: Automatically separates unrelated changes into atomic commits with dependency ordering
- **Hunk-level staging**: Stage individual hunks when changes span multiple concerns
- **Changelog generation**: Proposes and applies changelog entries to `CHANGELOG.md` files
- **Commit validation**: Detects filler words, meta phrases, and enforces conventional commit format
- **Legacy mode**: `--legacy` flag for deterministic pipeline when preferred
- Run via `omp commit` with options: `--push`, `--dry-run`, `--no-changelog`, `--context`
## + Python Tool (IPython Kernel)
<p align="center">
@@ -93,6 +105,7 @@ Execute Python code with a persistent IPython kernel and 30+ shell-like helpers:
- **Shared gateway**: Resource-efficient kernel reuse across sessions (`python.sharedGateway` setting)
- **Custom modules**: Load extensions from `.omp/modules/` and `.pi/modules/` directories
- **Rich output**: Supports `display()` for HTML, Markdown, images, and interactive JSON trees
- **Mermaid diagrams**: Renders mermaid code blocks as inline graphics in iTerm2/Kitty terminals
- Install dependencies via `omp setup python`
## + LSP Integration (Language Server Protocol)
@@ -151,6 +164,7 @@ Parallel execution framework with specialized agents and real-time streaming:
- **Parallel exploration**: Reviewer agent can spawn explore agents for large codebase analysis
- **Real-time artifact streaming**: Task outputs stream as they're created, not just at completion
- **Output tool**: Read full agent outputs by ID when truncated previews aren't sufficient
- **Isolated execution**: `isolated: true` runs tasks in git worktrees, generates patches, and applies cleanly
- User-level (`~/.omp/agent/agents/`) and project-level (`.omp/agents/`) custom agents
- Concurrency-limited batch execution with progress tracking
@@ -331,7 +345,7 @@ Handles whitespace and indentation variance automatically:
| **[@oh-my-pi/pi-agent-core](packages/agent)** | Agent runtime with tool calling and state management |
| **[@oh-my-pi/pi-coding-agent](packages/coding-agent)** | Interactive coding agent CLI |
| **[@oh-my-pi/pi-tui](packages/tui)** | Terminal UI library with differential rendering |
| **[@oh-my-pi/omp-stats](packages/omp-stats)** | Local observability dashboard for AI usage statistics |
| **[@oh-my-pi/omp-stats](packages/stats)** | Local observability dashboard for AI usage statistics |
---
+8 -8
View File
@@ -22,7 +22,7 @@
},
"packages/agent": {
"name": "@oh-my-pi/pi-agent-core",
"version": "8.0.0",
"version": "8.1.0",
"dependencies": {
"@oh-my-pi/pi-ai": "workspace:*",
"@oh-my-pi/pi-tui": "workspace:*",
@@ -36,7 +36,7 @@
},
"packages/ai": {
"name": "@oh-my-pi/pi-ai",
"version": "8.0.0",
"version": "8.1.0",
"bin": {
"pi-ai": "./src/cli.ts",
},
@@ -64,7 +64,7 @@
},
"packages/coding-agent": {
"name": "@oh-my-pi/pi-coding-agent",
"version": "8.0.0",
"version": "8.1.0",
"bin": {
"omp": "src/cli.ts",
},
@@ -100,9 +100,9 @@
"ms": "^2.1.3",
},
},
"packages/omp-stats": {
"packages/stats": {
"name": "@oh-my-pi/omp-stats",
"version": "8.0.0",
"version": "8.1.0",
"bin": {
"omp-stats": "./src/index.ts",
},
@@ -122,7 +122,7 @@
},
"packages/pi-utils": {
"name": "@oh-my-pi/pi-utils",
"version": "8.0.0",
"version": "8.1.0",
"dependencies": {
"strip-ansi": "^7.1.2",
"winston": "^3.17.0",
@@ -151,7 +151,7 @@
},
"packages/tui": {
"name": "@oh-my-pi/pi-tui",
"version": "8.0.0",
"version": "8.1.0",
"dependencies": {
"@types/mime-types": "^2.1.4",
"chalk": "^5.5.0",
@@ -340,7 +340,7 @@
"@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=="],
"@oh-my-pi/omp-stats": ["@oh-my-pi/omp-stats@workspace:packages/omp-stats"],
"@oh-my-pi/omp-stats": ["@oh-my-pi/omp-stats@workspace:packages/stats"],
"@oh-my-pi/pi-agent-core": ["@oh-my-pi/pi-agent-core@workspace:packages/agent"],
+1 -1
View File
@@ -9,7 +9,7 @@
"install:dev": "bun install && bun packages/coding-agent/scripts/generate-wasm-b64.ts && 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/omp-stats run check",
"check": "biome check --write . && bun --cwd=packages/coding-agent run check && bun --cwd=packages/stats run check",
"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",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@oh-my-pi/pi-agent-core",
"version": "8.0.0",
"version": "8.1.0",
"description": "General-purpose agent with transport abstraction, state management, and attachment support",
"type": "module",
"main": "./src/index.ts",
+10 -10
View File
@@ -1,3 +1,13 @@
import { agentLoop, agentLoopContinue } from "@oh-my-pi/pi-agent-core/agent-loop";
import type {
AgentContext,
AgentEvent,
AgentLoopConfig,
AgentMessage,
AgentTool,
AgentToolContext,
ToolCallContext,
} from "@oh-my-pi/pi-agent-core/types";
import {
type AssistantMessage,
type AssistantMessageEvent,
@@ -8,16 +18,6 @@ import {
} from "@oh-my-pi/pi-ai";
import { Type } from "@sinclair/typebox";
import { describe, expect, it } from "vitest";
import { agentLoop, agentLoopContinue } from "$agent/agent-loop";
import type {
AgentContext,
AgentEvent,
AgentLoopConfig,
AgentMessage,
AgentTool,
AgentToolContext,
ToolCallContext,
} from "$agent/types";
// Mock stream for testing - mimics MockAssistantStream
class MockAssistantStream extends EventStream<AssistantMessageEvent, AssistantMessage> {
+1 -1
View File
@@ -1,3 +1,4 @@
import { Agent } from "@oh-my-pi/pi-agent-core";
import {
type AssistantMessage,
type AssistantMessageEvent,
@@ -7,7 +8,6 @@ import {
type Usage,
} from "@oh-my-pi/pi-ai";
import { describe, expect, it } from "vitest";
import { Agent } from "$agent/index";
class MockAssistantStream extends EventStream<AssistantMessageEvent, AssistantMessage> {
constructor() {
+1 -1
View File
@@ -1,7 +1,7 @@
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 { Agent } from "$agent/index";
import { calculateTool } from "./utils/calculate";
async function basicPrompt(model: Model<any>) {
+1 -1
View File
@@ -1,5 +1,5 @@
import type { AgentTool, AgentToolResult } from "@oh-my-pi/pi-agent-core/types";
import { type Static, Type } from "@sinclair/typebox";
import type { AgentTool, AgentToolResult } from "$agent/types";
export interface CalculateResult extends AgentToolResult<undefined> {
content: Array<{ type: "text"; text: string }>;
@@ -1,5 +1,5 @@
import type { AgentTool, AgentToolResult } from "@oh-my-pi/pi-agent-core/types";
import { type Static, Type } from "@sinclair/typebox";
import type { AgentTool, AgentToolResult } from "$agent/types";
export interface GetCurrentTimeResult extends AgentToolResult<{ utcTimestamp: number }> {}
-5
View File
@@ -4,11 +4,6 @@
"noEmit": true,
"baseUrl": ".",
"paths": {
"$agent/*": ["./src/*"],
"$ai/*": ["../ai/src/*"],
"$c/*": ["../coding-agent/src/*"],
"$tui/*": ["../tui/src/*"],
"$stats/*": ["../omp-stats/src/*"],
"@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"],
+5 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@oh-my-pi/pi-ai",
"version": "8.0.0",
"version": "8.1.0",
"description": "Unified LLM API with automatic model discovery and provider configuration",
"type": "module",
"main": "./src/index.ts",
@@ -20,16 +20,18 @@
}
},
"bin": {
"pi-ai": "./src/cli.ts"
"pi-ai": "./dist/cli.js"
},
"files": [
"dist",
"src",
"README.md"
],
"scripts": {
"build": "tsgo -p tsconfig.build.json",
"generate-models": "bun scripts/generate-models.ts",
"test": "bun test",
"prepublishOnly": "cp tsconfig.publish.json tsconfig.json"
"prepublishOnly": "cp tsconfig.publish.json tsconfig.json && bun run build"
},
"dependencies": {
"@oh-my-pi/pi-utils": "workspace:*",
+1 -1
View File
@@ -2,12 +2,12 @@
import { createInterface } from "readline";
import { CliAuthStorage } from "./storage";
import "./utils/migrate-env";
import { getOAuthProviders } from "./utils/oauth";
import { loginAnthropic } from "./utils/oauth/anthropic";
import { loginCursor } from "./utils/oauth/cursor";
import { loginGitHubCopilot } from "./utils/oauth/github-copilot";
import { loginAntigravity } from "./utils/oauth/google-antigravity";
import { loginGeminiCli } from "./utils/oauth/google-gemini-cli";
import { getOAuthProviders } from "./utils/oauth/index";
import { loginOpenAICodex } from "./utils/oauth/openai-codex";
import type { OAuthCredentials, OAuthProvider } from "./utils/oauth/types";
+1 -1
View File
@@ -18,7 +18,7 @@ export * from "./usage/google-antigravity";
export * from "./usage/openai-codex";
export * from "./usage/zai";
export * from "./utils/event-stream";
export * from "./utils/oauth/index";
export * from "./utils/oauth";
export * from "./utils/overflow";
export * from "./utils/retry";
export * from "./utils/typebox-helpers";
+2 -2
View File
@@ -1,7 +1,7 @@
import { readFileSync } from "node:fs";
import { join } from "node:path";
import type { Api, Context, Model, Tool, ToolResultMessage } from "@oh-my-pi/pi-ai/index";
import { complete, getModel } from "@oh-my-pi/pi-ai/index";
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";
+1 -1
View File
@@ -6,7 +6,7 @@
*/
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { getOAuthApiKey } from "@oh-my-pi/pi-ai/utils/oauth/index";
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";
import { dirname, join } from "path";
-5
View File
@@ -4,11 +4,6 @@
"noEmit": true,
"baseUrl": ".",
"paths": {
"$ai/*": ["./src/*"],
"$c/*": ["../coding-agent/src/*"],
"$tui/*": ["../tui/src/*"],
"$agent/*": ["../agent/src/*"],
"$stats/*": ["../omp-stats/src/*"],
"@oh-my-pi/pi-ai": ["./src/index.ts"],
"@oh-my-pi/pi-ai/*": ["./src/*"],
"@oh-my-pi/pi-agent-core": ["../agent/src/index.ts"],
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@oh-my-pi/pi-coding-agent",
"version": "8.0.0",
"version": "8.1.0",
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
"type": "module",
"ompConfig": {
@@ -5,7 +5,7 @@
* persistent guidance to the agent.
*/
import { defineCapability } from "./index";
import { defineCapability } from ".";
import type { SourceMeta } from "./types";
/**
@@ -4,7 +4,7 @@
* TypeScript/JavaScript extension modules loaded by the extension system.
*/
import { defineCapability } from "./index";
import { defineCapability } from ".";
import type { SourceMeta } from "./types";
/**
@@ -4,7 +4,7 @@
* Gemini-style extensions that provide MCP servers, tools, and context.
*/
import { defineCapability } from "./index";
import { defineCapability } from ".";
import type { MCPServer } from "./mcp";
import type { SourceMeta } from "./types";
+1 -1
View File
@@ -4,7 +4,7 @@
* Pre/post tool execution hooks defined as shell scripts.
*/
import { defineCapability } from "./index";
import { defineCapability } from ".";
import type { SourceMeta } from "./types";
/**
@@ -4,7 +4,7 @@
* GitHub Copilot-style instructions with optional file pattern matching.
*/
import { defineCapability } from "./index";
import { defineCapability } from ".";
import type { SourceMeta } from "./types";
/**
+1 -1
View File
@@ -5,7 +5,7 @@
* All providers translate their native format to this shape.
*/
import { defineCapability } from "./index";
import { defineCapability } from ".";
import type { SourceMeta } from "./types";
/**
@@ -4,7 +4,7 @@
* Reusable prompt templates (Codex format) available via /prompts: menu.
*/
import { defineCapability } from "./index";
import { defineCapability } from ".";
import type { SourceMeta } from "./types";
/**
+1 -1
View File
@@ -5,7 +5,7 @@
* Translated to a canonical shape regardless of source format.
*/
import { defineCapability } from "./index";
import { defineCapability } from ".";
import type { SourceMeta } from "./types";
/**
@@ -4,7 +4,7 @@
* Configuration settings from various sources (JSON, TOML, etc.)
*/
import { defineCapability } from "./index";
import { defineCapability } from ".";
import type { SourceMeta } from "./types";
/**
@@ -4,7 +4,7 @@
* Skills provide specialized knowledge or workflows that extend agent capabilities.
*/
import { defineCapability } from "./index";
import { defineCapability } from ".";
import type { SourceMeta } from "./types";
/**
@@ -4,7 +4,7 @@
* File-based slash commands defined as markdown files.
*/
import { defineCapability } from "./index";
import { defineCapability } from ".";
import type { SourceMeta } from "./types";
/**
+1 -1
View File
@@ -4,7 +4,7 @@
* Canonical shape for SSH host entries, regardless of source format.
*/
import { defineCapability } from "./index";
import { defineCapability } from ".";
import type { SourceMeta } from "./types";
/**
@@ -5,7 +5,7 @@
* Distinct from context-files which are user instructions shown in conversation.
*/
import { defineCapability } from "./index";
import { defineCapability } from ".";
import type { SourceMeta } from "./types";
/**
+1 -1
View File
@@ -4,7 +4,7 @@
* User-defined tools that extend agent capabilities.
*/
import { defineCapability } from "./index";
import { defineCapability } from ".";
import type { SourceMeta } from "./types";
/**
+1 -1
View File
@@ -4,7 +4,7 @@
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/index";
import { BUILTIN_TOOLS } from "@oh-my-pi/pi-coding-agent/tools";
import chalk from "chalk";
export type Mode = "text" | "json" | "rpc";
+1 -5
View File
@@ -5,11 +5,7 @@
*/
import { APP_NAME } from "@oh-my-pi/pi-coding-agent/config";
import {
PluginManager,
parseSettingValue,
validateSetting,
} from "@oh-my-pi/pi-coding-agent/extensibility/plugins/index";
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";
@@ -9,7 +9,7 @@ import type { CustomTool, CustomToolContext } from "@oh-my-pi/pi-coding-agent/ex
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/index";
import type { ToolSession } from "@oh-my-pi/pi-coding-agent/tools";
import { Type } from "@sinclair/typebox";
const analyzeFileSchema = Type.Object({
-10
View File
@@ -79,16 +79,6 @@ export function getAuthPath(): string {
return join(getAgentDir(), "auth.json");
}
/** Get path to settings.json (legacy, use getConfigPath for config.yaml) */
export function getLegacySettingsPath(): string {
return join(getAgentDir(), "settings.json");
}
/** Get path to config.yml (user settings) */
export function getConfigPath(): string {
return join(getAgentDir(), "config.yml");
}
/**
* Gets the path to agent.db (SQLite database for settings and auth storage).
* @param agentDir - Base agent directory, defaults to ~/.omp/agent
@@ -2,7 +2,7 @@ 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, getConfigPath } from "@oh-my-pi/pi-coding-agent/config";
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";
@@ -503,7 +503,7 @@ export class SettingsManager {
* @returns Configured SettingsManager with merged global and user settings
*/
static async create(cwd: string = process.cwd(), agentDir: string = getAgentDir()): Promise<SettingsManager> {
const configPath = getConfigPath();
const configPath = join(agentDir, "config.yml");
const storage = await AgentStorage.open(getAgentDbPath(agentDir));
// Migrate from legacy storage if config.yml doesn't exist
@@ -7,9 +7,9 @@
*/
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 { registerProvider } from "@oh-my-pi/pi-coding-agent/capability/index";
import type { LoadContext, LoadResult } from "@oh-my-pi/pi-coding-agent/capability/types";
import { calculateDepth, createSourceMeta } from "./helpers";
@@ -5,6 +5,7 @@
* .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,
@@ -14,7 +15,6 @@ import {
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 { registerProvider } from "@oh-my-pi/pi-coding-agent/capability/index";
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";
@@ -6,11 +6,11 @@
*/
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 { registerProvider } from "@oh-my-pi/pi-coding-agent/capability/index";
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";
+1 -1
View File
@@ -6,8 +6,8 @@
*/
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 { registerProvider } from "@oh-my-pi/pi-coding-agent/capability/index";
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";
+1 -1
View File
@@ -8,13 +8,13 @@
*/
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 { registerProvider } from "@oh-my-pi/pi-coding-agent/capability/index";
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";
@@ -14,8 +14,8 @@
* - 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 { registerProvider } from "@oh-my-pi/pi-coding-agent/capability/index";
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";
@@ -17,6 +17,7 @@
*/
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,
@@ -25,7 +26,6 @@ import {
} 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 { registerProvider } from "@oh-my-pi/pi-coding-agent/capability/index";
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";
@@ -13,9 +13,9 @@
*/
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 { registerProvider } from "@oh-my-pi/pi-coding-agent/capability/index";
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";
+12 -12
View File
@@ -17,28 +17,24 @@ import "../capability/rule";
import "../capability/settings";
import "../capability/skill";
import "../capability/slash-command";
import "../capability/system-prompt";
import "../capability/ssh";
import "../capability/system-prompt";
import "../capability/tool";
// Import providers (each registers itself on import)
import "./agents-md";
import "./builtin";
import "./claude";
import "./codex";
import "./gemini";
import "./cursor";
import "./windsurf";
import "./cline";
import "./codex";
import "./cursor";
import "./gemini";
import "./github";
import "./vscode";
import "./agents-md";
import "./mcp-json";
import "./ssh";
import "./vscode";
import "./windsurf";
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";
// Re-export the main API from capability registry
export {
cacheStats,
@@ -62,7 +58,11 @@ export {
// Cache management
reset,
setDisabledProviders,
} from "@oh-my-pi/pi-coding-agent/capability/index";
} 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";
// Re-export capability item types
export type { MCPServer } from "@oh-my-pi/pi-coding-agent/capability/mcp";
@@ -8,8 +8,8 @@
*/
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 { registerProvider } from "@oh-my-pi/pi-coding-agent/capability/index";
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 { createSourceMeta, expandEnvVarsDeep, parseJSON } from "./helpers";
+1 -1
View File
@@ -6,8 +6,8 @@
*/
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 { registerProvider } from "@oh-my-pi/pi-coding-agent/capability/index";
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 { createSourceMeta, expandEnvVarsDeep, parseJSON } from "./helpers";
@@ -5,8 +5,8 @@
* 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 { registerProvider } from "@oh-my-pi/pi-coding-agent/capability/index";
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 { createSourceMeta, expandEnvVarsDeep, getProjectPath, parseJSON } from "./helpers";
@@ -11,8 +11,8 @@
* - 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 { registerProvider } from "@oh-my-pi/pi-coding-agent/capability/index";
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";
@@ -7,9 +7,9 @@
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 * as piCodingAgent from "@oh-my-pi/pi-coding-agent/index";
import { logger } from "@oh-my-pi/pi-utils";
import * as typebox from "@sinclair/typebox";
import { ReviewCommand } from "./bundled/review";
@@ -23,7 +23,7 @@ export interface CustomCommandAPI {
/** Injected @sinclair/typebox module */
typebox: typeof import("@sinclair/typebox");
/** Injected pi-coding-agent exports */
pi: typeof import("../../index");
pi: typeof import("../..");
}
/**
@@ -6,6 +6,7 @@
*/
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";
@@ -13,7 +14,6 @@ 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 * as piCodingAgent from "@oh-my-pi/pi-coding-agent/index";
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";
@@ -39,7 +39,7 @@ export interface CustomToolAPI {
/** Injected @sinclair/typebox module */
typebox: typeof import("@sinclair/typebox");
/** Injected pi-coding-agent exports */
pi: typeof import("../../index");
pi: typeof import("../..");
}
/**
@@ -6,12 +6,12 @@ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
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 * as piCodingAgent from "@oh-my-pi/pi-coding-agent/index";
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";
@@ -10,11 +10,11 @@
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 * as piCodingAgent from "@oh-my-pi/pi-coding-agent/index";
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";
@@ -3,11 +3,11 @@
*/
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 * as piCodingAgent from "@oh-my-pi/pi-coding-agent/index";
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";
@@ -11,7 +11,7 @@ import type { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-regis
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/index";
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 {
BranchSummaryEntry,
@@ -26,7 +26,7 @@ import type {
GrepToolDetails,
LsToolDetails,
ReadToolDetails,
} from "@oh-my-pi/pi-coding-agent/tools/index";
} from "@oh-my-pi/pi-coding-agent/tools";
import type { Component, TUI } from "@oh-my-pi/pi-tui";
// Re-export for backward compatibility
@@ -752,7 +752,7 @@ export interface HookAPI {
/** Injected @sinclair/typebox module */
typebox: typeof import("@sinclair/typebox");
/** Injected pi-coding-agent exports */
pi: typeof import("../../index");
pi: typeof import("../..");
}
/**
+10 -10
View File
@@ -3,7 +3,7 @@
// 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/index";
export type { FileDiagnosticsResult } from "@oh-my-pi/pi-coding-agent/lsp";
// UI components for extensions
export {
ArminComponent,
@@ -37,7 +37,7 @@ export {
UserMessageComponent,
UserMessageSelectorComponent,
type VisualTruncateResult,
} from "@oh-my-pi/pi-coding-agent/modes/components/index";
} from "@oh-my-pi/pi-coding-agent/modes/components";
// Theme utilities for custom tools
export {
getLanguageFromPath,
@@ -88,9 +88,9 @@ export type {
ExecResult,
LoadedCustomTool,
RenderResultOptions,
} from "./extensibility/custom-tools/index";
} from "./extensibility/custom-tools";
// Custom tools
export { CustomToolLoader, discoverAndLoadCustomTools, loadCustomTools } from "./extensibility/custom-tools/index";
export { CustomToolLoader, discoverAndLoadCustomTools, loadCustomTools } from "./extensibility/custom-tools";
export type {
AppAction,
Extension,
@@ -122,7 +122,7 @@ export type {
UserBashEventResult,
UserPythonEvent,
UserPythonEventResult,
} from "./extensibility/extensions/index";
} from "./extensibility/extensions";
// Extension types and utilities
export {
discoverAndLoadExtensions,
@@ -135,9 +135,9 @@ export {
isLsToolResult,
isReadToolResult,
isWriteToolResult,
} from "./extensibility/extensions/index";
} from "./extensibility/extensions";
// Hook system types (legacy re-export)
export type * from "./extensibility/hooks/index";
export type * from "./extensibility/hooks";
// Skills
export {
type LoadSkillsFromDirOptions,
@@ -162,7 +162,7 @@ export {
type RpcEventListener,
runPrintMode,
runRpcMode,
} from "./modes/index";
} from "./modes";
// SDK for programmatic usage
export {
// Factory
@@ -228,7 +228,7 @@ export {
prepareBranchEntries,
serializeConversation,
shouldCompact,
} from "./session/compaction/index";
} from "./session/compaction";
export { convertToLlm } from "./session/messages";
export {
type BranchSummaryEntry,
@@ -275,5 +275,5 @@ export {
truncateLine,
truncateTail,
type WriteToolDetails,
} from "./tools/index";
} from "./tools";
export { getShellConfig } from "./utils/shell";
+1 -1
View File
@@ -5,7 +5,7 @@ import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallb
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/index";
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";
+3 -3
View File
@@ -28,10 +28,10 @@ import type { ModelRegistry } from "./config/model-registry";
import { parseModelPattern, parseModelString, resolveModelScope, type ScopedModel } from "./config/model-resolver";
import { SettingsManager } from "./config/settings-manager";
import { initializeWithSettings } from "./discovery";
import { exportFromFile } from "./export/html/index";
import { exportFromFile } from "./export/html";
import type { ExtensionUIContext } from "./extensibility/extensions/types";
import { runMigrations, showDeprecationWarnings } from "./migrations";
import { InteractiveMode, runPrintMode, runRpcMode } from "./modes/index";
import { InteractiveMode, runPrintMode, runRpcMode } from "./modes";
import { type CreateAgentSessionOptions, createAgentSession, discoverAuthStorage, discoverModels } from "./sdk";
import type { AgentSession } from "./session/agent-session";
import { type SessionInfo, SessionManager } from "./session/session-manager";
@@ -87,7 +87,7 @@ async function runInteractiveMode(
initialMessages: string[],
setExtensionUIContext: (uiContext: ExtensionUIContext, hasUI: boolean) => void,
lspServers: Array<{ name: string; status: "ready" | "error"; fileTypes: string[] }> | undefined,
mcpManager: import("./mcp/index").MCPManager | undefined,
mcpManager: import("./mcp").MCPManager | undefined,
initialMessage?: string,
initialImages?: ImageContent[],
): Promise<void> {
@@ -821,7 +821,7 @@ export class TreeSelectorComponent extends Container {
new TruncatedText(
theme.fg(
"muted",
" Up/Down: move. Left/Right: page. Shift+L: label. Ctrl+O/Shift+Ctrl+O: filter. Alt+D/T/U/L/A: filter. Type to search",
"Up/Down: move. Left/Right: page. Shift+L: label. Ctrl+O/Shift+Ctrl+O: filter. Alt+D/T/U/L/A: filter. Type to search",
),
0,
0,
@@ -5,7 +5,7 @@ import type {
ExtensionContextActions,
ExtensionError,
ExtensionUIContext,
} from "@oh-my-pi/pi-coding-agent/extensibility/extensions/index";
} 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";
@@ -21,7 +21,7 @@ import {
} 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/index";
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";
@@ -8,7 +8,7 @@ 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/index";
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";
@@ -125,7 +125,7 @@ export class InteractiveMode implements InteractiveModeContext {
private readonly changelogMarkdown: string | undefined;
public readonly lspServers: Array<{ name: string; status: "ready" | "error"; fileTypes: string[] }> | undefined =
undefined;
public mcpManager?: import("@oh-my-pi/pi-coding-agent/mcp/index").MCPManager;
public mcpManager?: import("@oh-my-pi/pi-coding-agent/mcp").MCPManager;
private readonly toolUiContextSetter: (uiContext: ExtensionUIContext, hasUI: boolean) => void;
private readonly commandController: CommandController;
@@ -141,7 +141,7 @@ export class InteractiveMode implements InteractiveModeContext {
changelogMarkdown: string | undefined = undefined,
setToolUIContext: (uiContext: ExtensionUIContext, hasUI: boolean) => void = () => {},
lspServers: Array<{ name: string; status: "ready" | "error"; fileTypes: string[] }> | undefined = undefined,
mcpManager?: import("@oh-my-pi/pi-coding-agent/mcp/index").MCPManager,
mcpManager?: import("@oh-my-pi/pi-coding-agent/mcp").MCPManager,
) {
this.session = session;
this.sessionManager = session.sessionManager;
@@ -8,7 +8,7 @@ import type { AgentEvent, AgentMessage, ThinkingLevel } from "@oh-my-pi/pi-agent
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/index";
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 { RpcCommand, RpcResponse, RpcSessionState } from "./rpc-types";
@@ -11,10 +11,7 @@
* - 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/index";
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";
@@ -9,7 +9,7 @@ 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/index";
import type { CompactionResult } from "@oh-my-pi/pi-coding-agent/session/compaction";
// ============================================================================
// RPC Commands (stdin)
+2 -2
View File
@@ -2,9 +2,9 @@ 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/index";
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/index";
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";
+3 -9
View File
@@ -18,10 +18,10 @@ import {
flushLspWritethroughBatch,
type WritethroughCallback,
writethroughNoop,
} from "@oh-my-pi/pi-coding-agent/lsp/index";
} 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/index";
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";
@@ -48,13 +48,7 @@ export { computeEditDiff, computePatchDiff, generateDiffString, generateUnifiedD
export { DEFAULT_FUZZY_THRESHOLD, findContextLine, findMatch as findEditMatch, findMatch, seekSequence } from "./fuzzy";
// Normalization
export {
adjustIndentation,
detectLineEnding,
normalizeToLF,
restoreLineEndings,
stripBom,
} from "./normalize";
export { adjustIndentation, detectLineEnding, normalizeToLF, restoreLineEndings, stripBom } from "./normalize";
// Parsing
export { normalizeCreateContent, normalizeDiff, parseHunks as parseDiffHunks } from "./parser";
+1 -1
View File
@@ -4,7 +4,7 @@
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/index";
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";
+10 -10
View File
@@ -32,7 +32,7 @@ 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/index";
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";
@@ -53,7 +53,7 @@ import "./discovery";
import {
type CustomCommandsLoadResult,
loadCustomCommands as loadCustomCommandsInternal,
} from "./extensibility/custom-commands/index";
} from "./extensibility/custom-commands";
import type { CustomTool, CustomToolContext, CustomToolSessionEvent } from "./extensibility/custom-tools/types";
import {
discoverAndLoadExtensions,
@@ -67,7 +67,7 @@ import {
loadExtensions,
type ToolDefinition,
wrapRegisteredTools,
} from "./extensibility/extensions/index";
} from "./extensibility/extensions";
import { loadSkills as loadSkillsInternal, type Skill, type SkillWarning } from "./extensibility/skills";
import { type FileSlashCommand, loadSlashCommands as loadSlashCommandsInternal } from "./extensibility/slash-commands";
import {
@@ -77,7 +77,7 @@ import {
RuleProtocolHandler,
SkillProtocolHandler,
} from "./internal-urls";
import { discoverAndLoadMCPTools, type MCPManager, type MCPToolsLoadResult } from "./mcp/index";
import { discoverAndLoadMCPTools, type MCPManager, type MCPToolsLoadResult } from "./mcp";
import { AgentSession } from "./session/agent-session";
import { AuthStorage } from "./session/auth-storage";
import { convertToLlm } from "./session/messages";
@@ -88,8 +88,6 @@ import {
loadProjectContextFiles as loadContextFilesInternal,
} from "./system-prompt";
import { AgentOutputManager } from "./task/output-manager";
import { ToolContextStore } from "./tools/context";
import { getGeminiImageTools } from "./tools/gemini-image";
import {
BashTool,
BUILTIN_TOOLS,
@@ -108,7 +106,9 @@ import {
type ToolSession,
WriteTool,
warmupLspServers,
} from "./tools/index";
} from "./tools";
import { ToolContextStore } from "./tools/context";
import { getGeminiImageTools } from "./tools/gemini-image";
import { wrapToolsWithMetaNotice } from "./tools/output-meta";
import { EventBus } from "./utils/event-bus";
import { time } from "./utils/timings";
@@ -218,11 +218,11 @@ export type {
ExtensionContext,
ExtensionFactory,
ToolDefinition,
} from "@oh-my-pi/pi-coding-agent/extensibility/extensions/index";
} 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";
export type { MCPManager, MCPServerConfig, MCPServerConnection, MCPToolsLoadResult } from "./mcp/index";
export type { Tool } from "./tools/index";
export type { MCPManager, MCPServerConfig, MCPServerConnection, MCPToolsLoadResult } from "./mcp";
export type { Tool } from "./tools";
export {
// Individual tool classes (for custom usage)
@@ -38,9 +38,9 @@ import {
} 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/index";
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/index";
import type { LoadedCustomCommand } from "@oh-my-pi/pi-coding-agent/extensibility/custom-commands";
import type {
ExtensionCommandContext,
ExtensionRunner,
@@ -78,7 +78,7 @@ import {
generateBranchSummary,
prepareCompaction,
shouldCompact,
} from "./compaction/index";
} from "./compaction";
import {
type BashExecutionMessage,
type BranchSummaryMessage,
+2 -2
View File
@@ -13,7 +13,7 @@ import {
type ContextFile,
loadCapability,
type SystemPrompt as SystemPromptFile,
} from "@oh-my-pi/pi-coding-agent/discovery/index";
} 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",
@@ -21,7 +21,7 @@ import customSystemPromptTemplate from "@oh-my-pi/pi-coding-agent/prompts/system
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 type { ToolName } from "./tools/index";
import type { ToolName } from "./tools";
interface GitContext {
isRepo: boolean;
+1 -1
View File
@@ -9,7 +9,7 @@ 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/index";
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";
+1 -1
View File
@@ -24,7 +24,7 @@ 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 type { ToolSession } from "./index";
import type { ToolSession } from ".";
import { ToolUIKit } from "./render-utils";
// =============================================================================
+1 -2
View File
@@ -12,9 +12,8 @@ import { renderOutputBlock, renderStatusLine } from "@oh-my-pi/pi-coding-agent/t
import type { Component } from "@oh-my-pi/pi-tui";
import { Text } from "@oh-my-pi/pi-tui";
import { Type } from "@sinclair/typebox";
import type { ToolSession } from ".";
import { checkBashInterception, checkSimpleLsInterception } from "./bash-interceptor";
import type { ToolSession } from "./index";
import { allocateOutputArtifact, createTailBuffer } from "./output-utils";
import { resolveToCwd } from "./path-utils";
import { formatBytes, wrapBrackets } from "./render-utils";
@@ -8,7 +8,7 @@ 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 type { ToolSession } from "./index";
import type { ToolSession } from ".";
import {
formatCount,
formatEmptyMessage,
+1 -1
View File
@@ -10,7 +10,7 @@ import { subprocessToolRegistry } from "@oh-my-pi/pi-coding-agent/task/subproces
import type { Static, TObject } from "@sinclair/typebox";
import { Type } from "@sinclair/typebox";
import Ajv, { type ErrorObject, type ValidateFunction } from "ajv";
import type { ToolSession } from "./index";
import type { ToolSession } from ".";
import { jtdToJsonSchema } from "./jtd-to-json-schema";
export interface CompleteDetails {
+2 -2
View File
@@ -9,7 +9,7 @@ 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/index";
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";
@@ -19,7 +19,7 @@ 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 type { ToolSession } from "./index";
import type { ToolSession } from ".";
import { applyListLimit } from "./list-limit";
import { formatExpandHint } from "./render-utils";
import { toolResult } from "./tool-result";
+1 -1
View File
@@ -15,7 +15,7 @@ import { ptree, untilAborted } from "@oh-my-pi/pi-utils";
import type { Static } from "@sinclair/typebox";
import { Type } from "@sinclair/typebox";
import type { ToolSession } from "./index";
import type { ToolSession } from ".";
import { applyListLimit } from "./list-limit";
import { resolveToCwd } from "./path-utils";
import { formatCount, formatEmptyMessage, formatErrorMessage, PREVIEW_LIMITS } from "./render-utils";
+1 -1
View File
@@ -15,7 +15,7 @@ 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 type { ToolSession } from "./index";
import type { ToolSession } from ".";
import { applyListLimit } from "./list-limit";
import { resolveToCwd } from "./path-utils";
import { formatCount, formatEmptyMessage, formatErrorMessage, PREVIEW_LIMITS } from "./render-utils";
+7 -7
View File
@@ -1,5 +1,5 @@
// Exa MCP tools (22 tools)
export { exaTools } from "@oh-my-pi/pi-coding-agent/exa/index";
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 {
type FileDiagnosticsResult,
@@ -11,9 +11,9 @@ export {
type LspWarmupOptions,
type LspWarmupResult,
warmupLspServers,
} from "@oh-my-pi/pi-coding-agent/lsp/index";
} 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/index";
export { BUNDLED_AGENTS, TaskTool } from "@oh-my-pi/pi-coding-agent/task";
export {
companyWebSearchTools,
exaWebSearchTools,
@@ -31,7 +31,7 @@ export {
webSearchCustomTool,
webSearchDeepTool,
webSearchLinkedinTool,
} from "@oh-my-pi/pi-coding-agent/web/search/index";
} from "@oh-my-pi/pi-coding-agent/web/search";
export { AskTool, type AskToolDetails } from "./ask";
export { BashTool, type BashToolDetails, type BashToolOptions } from "./bash";
export { CalculatorTool, type CalculatorToolDetails } from "./calculator";
@@ -64,13 +64,13 @@ import type { BashInterceptorRule } from "@oh-my-pi/pi-coding-agent/config/setti
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/index";
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/index";
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/index";
import { WebSearchTool } from "@oh-my-pi/pi-coding-agent/web/search";
import { logger } from "@oh-my-pi/pi-utils";
import { AskTool } from "./ask";
import { BashTool } from "./bash";
+1 -1
View File
@@ -8,7 +8,7 @@ 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 { ToolSession } from "./index";
import type { ToolSession } from ".";
import { applyListLimit } from "./list-limit";
import { resolveToCwd } from "./path-utils";
import {
@@ -1,5 +1,5 @@
import { ArtifactManager } from "@oh-my-pi/pi-coding-agent/session/artifacts";
import type { ToolSession } from "./index";
import type { ToolSession } from ".";
export interface TailBuffer {
append(chunk: string): void;
+1 -1
View File
@@ -15,7 +15,7 @@ import { getTreeBranch, getTreeContinuePrefix, renderCodeCell } from "@oh-my-pi/
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 type { ToolSession } from "./index";
import type { ToolSession } from ".";
import { allocateOutputArtifact, createTailBuffer } from "./output-utils";
import { resolveToCwd } from "./path-utils";
import { shortenPath, ToolUIKit, truncate } from "./render-utils";
+2 -2
View File
@@ -2,7 +2,7 @@ import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallb
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/index";
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" };
@@ -15,7 +15,7 @@ import { renderOutputBlock, renderStatusLine } from "@oh-my-pi/pi-coding-agent/t
import type { Component } from "@oh-my-pi/pi-tui";
import { Text } from "@oh-my-pi/pi-tui";
import { Type } from "@sinclair/typebox";
import type { ToolSession } from "./index";
import type { ToolSession } from ".";
import { allocateOutputArtifact, createTailBuffer } from "./output-utils";
import { formatBytes, wrapBrackets } from "./render-utils";
import { toolResult } from "./tool-result";
+1 -1
View File
@@ -12,7 +12,7 @@ import {
type FileDiagnosticsResult,
type WritethroughCallback,
writethroughNoop,
} from "@oh-my-pi/pi-coding-agent/lsp/index";
} 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";
@@ -21,8 +21,15 @@ export function renderOutputBlock(options: OutputBlockOptions, theme: Theme): st
const v = theme.boxSharp.vertical;
const cap = h.repeat(3);
const lineWidth = Math.max(0, width);
const borderColor =
state === "error" ? "error" : state === "success" ? "success" : state === "warning" ? "warning" : "dim";
// Border colors: running/pending use accent, success uses dim (gray), error/warning keep their colors
const borderColor: "error" | "warning" | "accent" | "dim" =
state === "error"
? "error"
: state === "warning"
? "warning"
: state === "running" || state === "pending"
? "accent"
: "dim";
const border = (text: string) => theme.fg(borderColor, text);
const bgFn = state ? (text: string) => theme.bg(getStateBgColor(state), text) : undefined;
+1 -1
View File
@@ -40,7 +40,7 @@ export function getStateIcon(icon: IconType, theme: Theme, spinnerFrame?: number
if (icon === "error") return theme.styledSymbol("status.error", "error");
if (icon === "warning") return theme.styledSymbol("status.warning", "warning");
if (icon === "info") return theme.styledSymbol("status.info", "accent");
if (icon === "pending") return theme.styledSymbol("status.pending", "muted");
if (icon === "pending") return theme.styledSymbol("status.pending", "accent");
if (spinnerFrame !== undefined) {
const frames = theme.spinnerFrames;
return frames[spinnerFrame % frames.length];
@@ -31,7 +31,7 @@ import type {
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/index";
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 { findAnthropicAuth } from "./auth";
@@ -18,7 +18,7 @@ import { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manag
import { AgentSession } 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 { createTools, type ToolSession } from "@oh-my-pi/pi-coding-agent/tools/index";
import { createTools, type ToolSession } from "@oh-my-pi/pi-coding-agent/tools";
import { nanoid } from "nanoid";
import { API_KEY } from "./utilities";
@@ -18,7 +18,7 @@ import { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manag
import { AgentSession, 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 { createTools, type ToolSession } from "@oh-my-pi/pi-coding-agent/tools/index";
import { createTools, type ToolSession } from "@oh-my-pi/pi-coding-agent/tools";
import { nanoid } from "nanoid";
import { API_KEY } from "./utilities";
@@ -4,7 +4,7 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import { processFileArguments } from "@oh-my-pi/pi-coding-agent/cli/file-processor";
import { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manager";
import type { ToolSession } from "@oh-my-pi/pi-coding-agent/tools/index";
import type { ToolSession } from "@oh-my-pi/pi-coding-agent/tools";
import { ReadTool } from "@oh-my-pi/pi-coding-agent/tools/read";
// 1x1 red PNG image as base64 (smallest valid PNG)
@@ -7,7 +7,7 @@ import type {
HookAPI,
SessionBeforeCompactEvent,
SessionCompactEvent,
} from "@oh-my-pi/pi-coding-agent/extensibility/hooks/index";
} from "@oh-my-pi/pi-coding-agent/extensibility/hooks";
describe("Documentation example", () => {
it("custom compaction example should type-check correctly", () => {
@@ -16,12 +16,12 @@ import {
type SessionBeforeCompactEvent,
type SessionCompactEvent,
type SessionEvent,
} from "@oh-my-pi/pi-coding-agent/extensibility/hooks/index";
} from "@oh-my-pi/pi-coding-agent/extensibility/hooks";
import { theme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme";
import { AgentSession } 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 { createTools, type ToolSession } from "@oh-my-pi/pi-coding-agent/tools/index";
import { createTools, type ToolSession } from "@oh-my-pi/pi-coding-agent/tools";
import { nanoid } from "nanoid";
const API_KEY = process.env.ANTHROPIC_OAUTH_TOKEN || process.env.ANTHROPIC_API_KEY;
@@ -19,7 +19,7 @@ import { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manag
import { AgentSession } 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 { createTools, type ToolSession } from "@oh-my-pi/pi-coding-agent/tools/index";
import { createTools, type ToolSession } from "@oh-my-pi/pi-coding-agent/tools";
import { nanoid } from "nanoid";
import { API_KEY } from "./utilities";
@@ -13,7 +13,7 @@ import {
getLastAssistantUsage,
prepareCompaction,
shouldCompact,
} from "@oh-my-pi/pi-coding-agent/session/compaction/index";
} from "@oh-my-pi/pi-coding-agent/session/compaction";
import {
buildSessionContext,
type CompactionEntry,
@@ -4,7 +4,7 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import * as pythonExecutor from "@oh-my-pi/pi-coding-agent/ipy/executor";
import * as pythonKernel from "@oh-my-pi/pi-coding-agent/ipy/kernel";
import { createTools, type ToolSession } from "@oh-my-pi/pi-coding-agent/tools/index";
import { createTools, type ToolSession } from "@oh-my-pi/pi-coding-agent/tools";
import { PythonTool } from "@oh-my-pi/pi-coding-agent/tools/python";
function createSettings(overrides?: Partial<ToolSession["settings"]>): ToolSession["settings"] {
@@ -1,9 +1,8 @@
import { afterEach, beforeEach, describe, expect, it } from "bun:test";
import { existsSync, mkdirSync, rmSync } from "node:fs";
import { join } from "node:path";
import { getAgentDbPath } from "@oh-my-pi/pi-coding-agent/config";
import { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manager";
import { AgentStorage } from "@oh-my-pi/pi-coding-agent/session/agent-storage";
import { YAML } from "bun";
describe("SettingsManager", () => {
let testDir: string;
@@ -23,6 +22,21 @@ describe("SettingsManager", () => {
mkdirSync(join(projectDir, ".pi"), { recursive: true });
});
const getConfigPath = () => join(agentDir, "config.yml");
const writeSettings = async (settings: Record<string, unknown>) => {
await Bun.write(getConfigPath(), YAML.stringify(settings, null, 2));
};
const readSettings = async (): Promise<Record<string, unknown>> => {
const file = Bun.file(getConfigPath());
if (!(await file.exists())) return {};
const content = await file.text();
const parsed = YAML.parse(content);
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
return parsed as Record<string, unknown>;
};
afterEach(() => {
if (existsSync(testDir)) {
rmSync(testDir, { recursive: true });
@@ -33,9 +47,8 @@ describe("SettingsManager", () => {
// This ensures external edits (via AgentStorage directly) aren't lost when the app saves.
describe("preserves externally added settings", () => {
it("should preserve enabledModels when changing thinking level", async () => {
// Seed initial settings in DB
const storage = await AgentStorage.open(getAgentDbPath(agentDir));
storage.saveSettings({
// Seed initial settings in config.yml
await writeSettings({
theme: "dark",
modelRoles: { default: "claude-sonnet" },
});
@@ -44,60 +57,58 @@ describe("SettingsManager", () => {
const manager = await SettingsManager.create(projectDir, agentDir);
// Simulate external edit (e.g., user modifying DB directly or another process)
storage.saveSettings({
await writeSettings({
theme: "dark",
modelRoles: { default: "claude-sonnet" },
enabledModels: ["claude-opus-4-5", "gpt-5.2-codex"],
});
// Manager saves a change - should merge, not overwrite
manager.setDefaultThinkingLevel("high");
await manager.setDefaultThinkingLevel("high");
const savedSettings = storage.getSettings() ?? {};
const savedSettings = await readSettings();
expect(savedSettings.enabledModels).toEqual(["claude-opus-4-5", "gpt-5.2-codex"]);
expect(savedSettings.defaultThinkingLevel).toBe("high");
expect(savedSettings.theme).toBe("dark");
expect(savedSettings.modelRoles?.default).toBe("claude-sonnet");
expect((savedSettings.modelRoles as { default?: string } | undefined)?.default).toBe("claude-sonnet");
});
it("should preserve custom settings when changing theme", async () => {
const storage = await AgentStorage.open(getAgentDbPath(agentDir));
storage.saveSettings({
await writeSettings({
modelRoles: { default: "claude-sonnet" },
});
const manager = await SettingsManager.create(projectDir, agentDir);
storage.saveSettings({
await writeSettings({
modelRoles: { default: "claude-sonnet" },
shellPath: "/bin/zsh",
extensions: ["/path/to/extension.ts"],
});
manager.setTheme("light");
await manager.setTheme("light");
const savedSettings = storage.getSettings() ?? {};
const savedSettings = await readSettings();
expect(savedSettings.shellPath).toBe("/bin/zsh");
expect(savedSettings.extensions).toEqual(["/path/to/extension.ts"]);
expect(savedSettings.theme).toBe("light");
});
it("should let in-memory changes override file changes for same key", async () => {
const storage = await AgentStorage.open(getAgentDbPath(agentDir));
storage.saveSettings({
await writeSettings({
theme: "dark",
});
const manager = await SettingsManager.create(projectDir, agentDir);
storage.saveSettings({
await writeSettings({
theme: "dark",
defaultThinkingLevel: "low",
});
manager.setDefaultThinkingLevel("high");
await manager.setDefaultThinkingLevel("high");
const savedSettings = storage.getSettings() ?? {};
const savedSettings = await readSettings();
expect(savedSettings.defaultThinkingLevel).toBe("high");
});
});

Some files were not shown because too many files have changed in this diff Show More