refactor(coding-agent): flattened directory structure, eliminated core/ folder

- Eliminated core/ directory (252 files, 23 subdirs → distributed)
- Reduced max nesting from 9 levels to 5 levels
- Promoted tool subdirs to top level: exa/, lsp/, patch/, task/, web/
- Merged web-scrapers/ + web-search/ into web/{scrapers,search}/
- Flattened modes/interactive/ to modes/
- Split execution/ into: ipy/ (python), exec/ (bash), ssh/
- Renamed ipy/python-*.ts to ipy/*.ts (executor, kernel, etc.)
- Flattened cursor/exec-bridge.ts to cursor.ts
- Created logical groupings: config/, session/, extensibility/, export/
- Updated all imports across 500+ files
This commit is contained in:
can1357
2026-01-23 12:05:24 +01:00
parent 7b5af2dd9f
commit cb5bbbf382
531 changed files with 1316 additions and 1322 deletions
+239 -142
View File
@@ -15,14 +15,14 @@ The coding-agent is structured into distinct layers:
▼
┌─────────────────────────────────────────────────────────────┐
│ Mode Layer │
│ modes/interactive/ modes/print-mode.ts modes/rpc/ │
│ modes/interactive-mode.ts modes/print-mode.ts modes/rpc/│
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Core Layer │
│ core/agent-session.ts, core/sdk.ts (SDK wrapper) │
│ core/session-manager.ts, core/model-resolver.ts, etc. │
│ session/agent-session.ts, sdk.ts (SDK wrapper) │
│ session/session-manager.ts, config/model-resolver.ts, etc.│
└─────────────────────────────────────────────────────────────┘
│
▼
@@ -43,6 +43,9 @@ src/
├── index.ts # Public API exports (SDK)
├── config.ts # APP_NAME, VERSION, paths (getAgentDir, etc.)
├── migrations.ts # Session/config migration logic
├── sdk.ts # SDK wrapper for programmatic usage
├── system-prompt.ts # buildSystemPrompt(), loadProjectContextFiles()
├── cursor.ts # Cursor exec bridge (flattened from execution/cursor/)
├── cli/ # CLI-specific utilities
│ ├── args.ts # parseArgs(), printHelp(), Args interface
@@ -66,6 +69,13 @@ src/
│ ├── system-prompt.ts # System prompt capability
│ └── tool.ts # Tool capability
├── config/ # Configuration management
│ ├── keybindings.ts # Keybinding configuration
│ ├── model-registry.ts # Model registry and configuration
│ ├── model-resolver.ts # resolveModelScope(), restoreModelFromSession()
│ ├── prompt-templates.ts # Prompt template loading and rendering
│ └── settings-manager.ts # SettingsManager class - user preferences
├── discovery/ # Extension discovery from multiple sources
│ ├── index.ts # Main discovery orchestration
│ ├── builtin.ts # Built-in extensions
@@ -80,41 +90,30 @@ src/
│ ├── windsurf.ts # Windsurf discovery
│ └── helpers.ts # Discovery helper functions
├── prompts/ # Prompt templates
│ ├── system-prompt.md # Main system prompt
│ ├── task.md # Task agent prompt
│ ├── init.md # Initialization prompt
│ ├── compaction-*.md # Compaction prompts
│ └── tools/ # Tool-specific prompts
├── exa/ # Exa MCP tools (22 tools)
│ ├── index.ts # Exa tools exports
│ ├── company.ts # Company search
│ ├── linkedin.ts # LinkedIn search
│ ├── mcp-client.ts # MCP client for Exa
│ ├── render.ts # Exa result rendering
│ ├── researcher.ts # Research tools
│ ├── search.ts # Search tools
│ ├── types.ts # Exa types
│ └── websets.ts # Websets tools
├── core/ # Core business logic (mode-agnostic)
│ ├── index.ts # Core exports
│ ├── agent-session.ts # AgentSession class - THE central abstraction
│ ├── sdk.ts # SDK wrapper for programmatic usage
│ ├── auth-storage.ts # AuthStorage class - API keys and OAuth tokens
├── exec/ # Bash/shell execution
│ ├── bash-executor.ts # executeBash() with streaming, abort
│ ├── event-bus.ts # Event bus for tool communication
│ ├── exec.ts # Process execution utilities
│ ├── file-mentions.ts # File mention detection
│ ├── keybindings.ts # Keybinding configuration
│ ├── logger.ts # Winston-based logging
│ ├── messages.ts # BashExecutionMessage, messageTransformer
│ ├── model-registry.ts # Model registry and configuration
│ ├── model-resolver.ts # resolveModelScope(), restoreModelFromSession()
│ ├── prompt-templates.ts # Prompt template loading and rendering
│ ├── session-manager.ts # SessionManager class - JSONL persistence
│ ├── settings-manager.ts # SettingsManager class - user preferences
│ ├── skills.ts # loadSkills(), skill discovery from multiple locations
│ ├── slash-commands.ts # loadSlashCommands() from ~/.omp/agent/commands/
│ ├── system-prompt.ts # buildSystemPrompt(), loadProjectContextFiles()
│ ├── terminal-notify.ts # Terminal notification utilities
│ ├── timings.ts # Performance timing utilities
│ ├── title-generator.ts # Session title generation
│ └── exec.ts # Process execution utilities
├── export/ # Export functionality
│ ├── custom-share.ts # Custom sharing
│ ├── ttsr.ts # Text-to-speech/speech-to-text utilities
│ ├── utils.ts # Generic utilities
│ │
│ ├── compaction/ # Context compaction system
│ │ └── index.ts # Compaction logic, summary generation
│ └── html/ # Session export to HTML
│ └── index.ts # HTML export logic
├── extensibility/ # Extension and customization systems
│ ├── skills.ts # loadSkills(), skill discovery
│ ├── slash-commands.ts # loadSlashCommands()
│ │
│ ├── custom-commands/ # Custom command loading system
│ │ └── types.ts # CustomCommand types
@@ -122,114 +121,213 @@ src/
│ ├── custom-tools/ # Custom tool loading system
│ │ ├── index.ts # Custom tool exports
│ │ ├── types.ts # CustomToolFactory, CustomToolDefinition
│ │ ├── loader.ts # loadCustomTools() from multiple locations
│ │ ├── loader.ts # loadCustomTools()
│ │ └── wrapper.ts # Tool wrapper utilities
│ │
│ ├── export-html/ # Session export to HTML
│ │ └── (export logic)
│ │
│ ├── extensions/ # Extension system
│ │ └── (extension loading and execution)
│ │ ├── index.ts # Extension exports
│ │ ├── types.ts # Extension types
│ │ ├── loader.ts # Extension loading
│ │ ├── runner.ts # Extension event dispatch
│ │ └── wrapper.ts # Extension wrappers
│ │
│ ├── hooks/ # Hook system for extending behavior
│ ├── hooks/ # Hook system
│ │ ├── index.ts # Hook exports
│ │ ├── types.ts # HookAPI, HookContext, event types
│ │ ├── loader.ts # loadHooks() from multiple locations
│ │ ├── runner.ts # runHook() event dispatch
│ │ └── tool-wrapper.ts # wrapToolsWithHooks() for tool_call events
│ │ ├── loader.ts # loadHooks()
│ │ └── runner.ts # runHook() event dispatch
│ │
│ ├── mcp/ # MCP (Model Context Protocol) integration
│ │ └── (MCP client/server logic)
│ │
│ ├── plugins/ # Plugin system
│ │ └── (plugin loading and management)
│ │
│ └── tools/ # Built-in tool implementations
│ ├── index.ts # Tool exports, BUILTIN_TOOLS, createTools
│ ├── ask.ts # User input tool
│ ├── bash.ts # Bash command execution
│ ├── bash-interceptor.ts # Bash command interception
│ ├── context.ts # Tool context utilities
│ ├── edit.ts # Surgical file editing
│ ├── edit-diff.ts # Diff-based editing
│ ├── find.ts # File search by glob
│ ├── gemini-image.ts # Gemini image generation
│ ├── git.ts # Git operations
│ ├── grep.ts # Content search (regex/literal)
│ ├── ls.ts # Directory listing
│ ├── notebook.ts # Jupyter notebook editing
│ ├── output.ts # Output/logging tool
│ ├── read.ts # File reading (text and images)
│ ├── review.ts # Code review tools
│ ├── rulebook.ts # Rulebook tool
│ ├── write.ts # File writing
│ ├── fetch.ts # URL content fetching
│ ├── exa/ # Exa MCP tools (22 tools)
│ ├── lsp/ # LSP integration tools
│ ├── task/ # Task/subagent spawning
│ ├── web-search/ # Web search tools
│ ├── path-utils.ts # Path resolution utilities
│ ├── renderers.ts # Tool output renderers
│ ├── render-utils.ts # Rendering utilities
│ └── truncate.ts # Output truncation utilities
│ └── plugins/ # Plugin system
│ └── (plugin loading and management)
├── internal-urls/ # Internal URL protocol handlers
│ ├── index.ts # Router and exports
│ ├── rule-protocol.ts # Rule protocol handler
│ └── skill-protocol.ts # Skill protocol handler
├── ipy/ # Python/Jupyter execution
│ ├── executor.ts # executePython(), kernel execution
│ ├── gateway-coordinator.ts # Gateway coordination
│ ├── kernel.ts # PythonKernel class
│ ├── modules.ts # Python module discovery
│ ├── prelude.ts # Python prelude (TS bindings)
│ └── prelude.py # Python prelude script
├── lsp/ # LSP integration
│ ├── index.ts # LSP exports
│ ├── client.ts # LSP client
│ ├── config.ts # LSP configuration
│ ├── render.ts # LSP result rendering
│ ├── utils.ts # LSP utilities
│ └── clients/ # Language-specific clients
│ ├── index.ts # Client exports
│ ├── biome-client.ts # Biome LSP
│ └── lsp-linter-client.ts # Generic linter
├── mcp/ # MCP (Model Context Protocol) integration
│ ├── index.ts # MCP exports
│ ├── config.ts # MCP configuration
│ ├── loader.ts # MCP server loading
│ ├── manager.ts # MCPManager class
│ ├── tool-bridge.ts # Tool bridging
│ ├── tool-cache.ts # Tool caching
│ ├── types.ts # MCP types
│ └── transports/ # MCP transports
│ ├── http.ts # HTTP transport
│ └── stdio.ts # Stdio transport
├── modes/ # Run mode implementations
│ ├── index.ts # Re-exports InteractiveMode, runPrintMode, runRpcMode, RpcClient
│ ├── print-mode.ts # Non-interactive: process messages, print output, exit
│ ├── index.ts # Re-exports InteractiveMode, runPrintMode, runRpcMode
│ ├── interactive-mode.ts # InteractiveMode class (main TUI)
│ ├── print-mode.ts # Non-interactive mode
│ ├── types.ts # Mode types
│ │
│ ├── rpc/ # RPC mode for programmatic control
│ │ ├── rpc-mode.ts # runRpcMode() - JSON stdin/stdout protocol
│ │ ├── rpc-types.ts # RpcCommand, RpcResponse, RpcSessionState types
│ │ └── rpc-client.ts # RpcClient class for spawning/controlling agent
│ ├── components/ # TUI components
│ │ ├── index.ts # Component exports
│ │ ├── assistant-message.ts # Agent response rendering
│ │ ├── bash-execution.ts # Bash output display
│ │ ├── custom-editor.ts # Multi-line input editor
│ │ ├── dynamic-border.ts # Adaptive border rendering
│ │ ├── footer.ts # Status bar / footer
│ │ ├── hook-input.ts # Hook input dialog
│ │ ├── hook-selector.ts # Hook selection UI
│ │ ├── login-dialog.ts # OAuth login dialog
│ │ ├── model-selector.ts # Model picker
│ │ ├── session-selector.ts # Session browser for --resume
│ │ ├── theme-selector.ts # Theme picker
│ │ ├── thinking-selector.ts # Thinking level picker
│ │ ├── tool-execution.ts # Tool call/result rendering
│ │ ├── user-message.ts # User message rendering
│ │ ├── status-line/ # Status line components
│ │ └── extensions/ # Extension UI components
│ │
│ └── interactive/ # Interactive TUI mode
│ ├── interactive-mode.ts # InteractiveMode class
│ │
│ ├── components/ # TUI components
│ │ ├── assistant-message.ts # Agent response rendering
│ │ ├── bash-execution.ts # Bash output display
│ │ ├── compaction.ts # Compaction status display
│ │ ├── countdown-timer.ts # Reusable countdown for dialogs
│ │ ├── custom-editor.ts # Multi-line input editor
│ │ ├── dynamic-border.ts # Adaptive border rendering
│ │ ├── footer.ts # Status bar / footer
│ │ ├── hook-input.ts # Hook input dialog
│ │ ├── hook-selector.ts # Hook selection UI
│ │ ├── index.ts # Component exports
│ │ ├── login-dialog.ts # OAuth login dialog
│ │ ├── model-selector.ts # Model picker
│ │ ├── oauth-selector.ts # OAuth provider picker
│ │ ├── queue-mode-selector.ts # Message queue mode picker
│ │ ├── session-selector.ts # Session browser for --resume
│ │ ├── show-images-selector.ts # Image display toggle
│ │ ├── theme-selector.ts # Theme picker
│ │ ├── thinking-selector.ts # Thinking level picker
│ │ ├── tool-execution.ts # Tool call/result rendering
│ │ ├── user-message-selector.ts # Message selector for /branch
│ │ └── user-message.ts # User message rendering
│ │
│ └── theme/
│ ├── theme.ts # Theme loading, getEditorTheme(), etc.
│ ├── dark.json
│ ├── light.json
│ └── theme-schema.json
│ ├── controllers/ # TUI controllers
│ │ ├── command-controller.ts # Command handling
│ │ ├── event-controller.ts # Event handling
│ │ ├── input-controller.ts # Input handling
│ │ └── selector-controller.ts # Selector handling
│ │
│ ├── theme/ # Theme system
│ │ ├── theme.ts # Theme loading, getEditorTheme()
│ │ └── defaults/ # Default themes
│ │
│ ├── utils/ # Mode utilities
│ │ └── ui-helpers.ts # UI helper functions
│ │
│ └── rpc/ # RPC mode for programmatic control
│ ├── rpc-mode.ts # runRpcMode() - JSON stdin/stdout protocol
│ ├── rpc-types.ts # RpcCommand, RpcResponse types
│ └── rpc-client.ts # RpcClient class
└── utils/ # Generic utilities
├── changelog.ts # parseChangelog(), getNewEntries()
├── clipboard.ts # copyToClipboard()
├── fuzzy.ts # Fuzzy string matching
├── image-convert.ts # Image format conversion
├── image-magick.ts # ImageMagick integration
├── image-resize.ts # Image resizing utilities
├── mime.ts # MIME type detection
├── shell.ts # getShellConfig()
├── shell-snapshot.ts # Shell state snapshotting
└── tools-manager.ts # ensureTool() - download fd, etc.
├── patch/ # File patching/editing
│ ├── index.ts # EditTool and exports
│ ├── applicator.ts # Patch application
│ ├── diff.ts # Diff utilities
│ ├── shared.ts # Shared utilities
│ └── render.ts # Patch rendering
├── prompts/ # Prompt templates
│ ├── system/ # System prompts
│ ├── agents/ # Agent-specific prompts
│ ├── compaction/ # Compaction prompts
│ └── tools/ # Tool-specific prompts
├── session/ # Session management
│ ├── agent-session.ts # AgentSession class - THE central abstraction
│ ├── agent-storage.ts # Agent storage utilities
│ ├── auth-storage.ts # AuthStorage class - API keys and OAuth
│ ├── artifacts.ts # Artifact management
│ ├── history-storage.ts # History storage
│ ├── messages.ts # Message types and transformers
│ ├── session-manager.ts # SessionManager class - JSONL persistence
│ ├── session-storage.ts # Session storage utilities
│ ├── storage-migration.ts # Storage migration
│ ├── streaming-output.ts # Streaming output handling
│ └── compaction/ # Context compaction system
│ └── index.ts # Compaction logic, summary generation
├── ssh/ # SSH execution
│ ├── connection-manager.ts # SSH connection management
│ ├── ssh-executor.ts # executeSSH() with streaming
│ └── sshfs-mount.ts # SSHFS mounting
├── task/ # Task/subagent spawning
│ ├── index.ts # TaskTool exports
│ ├── agents.ts # Agent definitions
│ ├── commands.ts # Task commands
│ ├── discovery.ts # Task discovery
│ ├── executor.ts # Task execution
│ ├── render.ts # Task rendering
│ ├── subprocess-tool-registry.ts # Subprocess tool registry
│ ├── worker-protocol.ts # Worker protocol
│ └── worker.ts # Task worker
├── tools/ # Built-in tool implementations
│ ├── index.ts # Tool exports, BUILTIN_TOOLS, createTools
│ ├── ask.ts # User input tool
│ ├── bash.ts # Bash command execution
│ ├── bash-interceptor.ts # Bash command interception
│ ├── calculator.ts # Calculator tool
│ ├── complete.ts # Completion tool
│ ├── context.ts # Tool context utilities
│ ├── fetch.ts # URL content fetching
│ ├── find.ts # File search by glob
│ ├── gemini-image.ts # Gemini image generation
│ ├── grep.ts # Content search (regex/literal)
│ ├── ls.ts # Directory listing
│ ├── notebook.ts # Jupyter notebook editing
│ ├── output-meta.ts # Output metadata
│ ├── output-utils.ts # Output utilities
│ ├── path-utils.ts # Path resolution utilities
│ ├── python.ts # Python tool (delegates to ipy/)
│ ├── read.ts # File reading (text and images)
│ ├── renderers.ts # Tool output renderers
│ ├── render-utils.ts # Rendering utilities
│ ├── review.ts # Code review tools
│ ├── ssh.ts # SSH tool (delegates to ssh/)
│ ├── todo-write.ts # Todo management
│ ├── tool-errors.ts # Tool error types
│ ├── tool-result.ts # Tool result utilities
│ ├── truncate.ts # Output truncation utilities
│ └── write.ts # File writing
├── utils/ # Generic utilities
│ ├── changelog.ts # parseChangelog(), getNewEntries()
│ ├── event-bus.ts # Event bus for tool communication
│ ├── file-mentions.ts # File mention detection
│ ├── frontmatter.ts # Frontmatter parsing
│ ├── image-convert.ts # Image format conversion
│ ├── image-resize.ts # Image resizing utilities
│ ├── mime.ts # MIME type detection
│ ├── shell.ts # getShellConfig()
│ ├── terminal-notify.ts # Terminal notification utilities
│ ├── timings.ts # Performance timing utilities
│ ├── title-generator.ts # Session title generation
│ ├── tools-manager.ts # ensureTool() - download fd, etc.
│ └── utils.ts # Generic utilities
├── vendor/ # Vendored dependencies
│ └── photon/ # Photon image processing
└── web/ # Web tools (merged web-scrapers + web-search)
├── scrapers/ # Web scraping
│ ├── index.ts # Scraper exports
│ ├── types.ts # Scraper types
│ ├── utils.ts # Scraper utilities
│ └── (domain-specific scrapers)
└── search/ # Web search
├── index.ts # WebSearchTool exports
├── auth.ts # Search auth
├── render.ts # Search result rendering
└── providers/ # Search providers
├── anthropic.ts # Anthropic search
├── exa.ts # Exa search
└── perplexity.ts # Perplexity search
```
## Key Abstractions
### AgentSession (core/agent-session.ts)
### AgentSession (session/agent-session.ts)
The central abstraction that wraps the SDK Agent with:
@@ -245,11 +343,11 @@ The central abstraction that wraps the SDK Agent with:
All three modes (interactive, print, rpc) use AgentSession.
### SDK (core/sdk.ts)
### SDK (sdk.ts)
Wrapper around `@oh-my-pi/pi-agent-core` that provides a simplified interface for creating and managing agents programmatically. Used by AgentSession and available as a public API through index.ts exports.
### InteractiveMode (modes/interactive/interactive-mode.ts)
### InteractiveMode (modes/interactive-mode.ts)
Handles TUI rendering and user interaction:
@@ -268,7 +366,7 @@ Headless operation via JSON protocol over stdin/stdout:
The RPC mode exposes the full AgentSession API via JSON commands. See [docs/rpc.md](docs/rpc.md) for protocol documentation.
### SessionManager (core/session-manager.ts)
### SessionManager (session/session-manager.ts)
Handles session persistence:
@@ -277,7 +375,7 @@ Handles session persistence:
- Message loading/saving
- Model/thinking level persistence
### SettingsManager (core/settings-manager.ts)
### SettingsManager (config/settings-manager.ts)
Handles user preferences:
@@ -290,13 +388,12 @@ Handles user preferences:
- Thinking budgets (`thinkingBudgets` setting for custom token budgets per level)
- Image blocking (`blockImages` setting to prevent images from being sent to LLM)
### Hook System (core/hooks/)
### Hook System (extensibility/hooks/)
Extensibility layer for intercepting agent behavior:
- **loader.ts**: Discovers and loads hooks from `~/.omp/agent/hooks/`, `.omp/hooks/`, and CLI
- **runner.ts**: Dispatches events to registered hooks
- **tool-wrapper.ts**: Wraps tools to emit `tool_call` and `tool_result` events
- **types.ts**: Event types (`session`, `tool_call`, `tool_result`, `message`, `error`, `user_bash`)
See [docs/hooks.md](docs/hooks.md) for full documentation.
@@ -305,7 +402,7 @@ See [docs/hooks.md](docs/hooks.md) for full documentation.
The extension system uses a shared runtime pattern:
1. **ExtensionRuntime** (`core/extensions/types.ts`): Shared state and action handlers for all extensions
1. **ExtensionRuntime** (`extensibility/extensions/types.ts`): Shared state and action handlers for all extensions
2. **Extension**: Per-extension registration data (handlers, tools, commands, shortcuts)
3. **ExtensionAPI**: Per-extension API that writes registrations to Extension and delegates actions to runtime
4. **ExtensionRunner**: Orchestrates event dispatch and provides context to handlers
@@ -316,7 +413,7 @@ Key extension events:
- `user_bash`: Intercept `!`/`!!` commands for custom execution (e.g., remote SSH)
- `session_shutdown`: Cleanup notification before exit
### Custom Tools (core/custom-tools/)
### Custom Tools (extensibility/custom-tools/)
System for adding LLM-callable tools:
@@ -325,7 +422,7 @@ System for adding LLM-callable tools:
See [docs/custom-tools.md](docs/custom-tools.md) for full documentation.
### Skills (core/skills.ts)
### Skills (extensibility/skills.ts)
On-demand capability packages:
@@ -412,15 +509,15 @@ Tools like `fd` and `rg` are auto-downloaded to `~/.omp/bin/` (migrated from `~/
### Adding a New Tool
1. Create tool factory in `core/tools/` following existing patterns (e.g., `createMyTool(session: ToolSession)`)
2. Export factory and types from `core/tools/index.ts`
3. Add to `BUILTIN_TOOLS` map in `core/tools/index.ts`
1. Create tool factory in `tools/` following existing patterns (e.g., `createMyTool(session: ToolSession)`)
2. Export factory and types from `tools/index.ts`
3. Add to `BUILTIN_TOOLS` map in `tools/index.ts`
4. Add tool prompt template to `prompts/tools/` if needed
5. Tool will automatically be included in system prompt
### Adding a New Hook Event
1. Add event type to hook event types in `core/hooks/types.ts`
1. Add event type to hook event types in `extensibility/hooks/types.ts`
2. Add emission point in relevant code (AgentSession, tool wrapper, etc.)
3. Update `docs/hooks.md` with the new event type
@@ -434,7 +531,7 @@ Tools like `fd` and `rg` are auto-downloaded to `~/.omp/bin/` (migrated from `~/
### Adding a New Selector
1. Create component in `modes/interactive/components/`
1. Create component in `modes/components/`
2. Use `showSelector()` helper in `interactive-mode.ts`:
```typescript
@@ -474,7 +571,7 @@ private showMySelector(): void {
### Adding a New Keybinding
1. Add the action name to `AppAction` type in `core/keybindings.ts`
1. Add the action name to `AppAction` type in `config/keybindings.ts`
2. Add default binding to `DEFAULT_APP_KEYBINDINGS`
3. Add to `APP_ACTIONS` array
4. Handle the action in `CustomEditor` or `InteractiveMode`
+1 -1
View File
@@ -5,7 +5,7 @@
import type { ThinkingLevel } from "@oh-my-pi/pi-agent-core";
import chalk from "chalk";
import { APP_NAME, CONFIG_DIR_NAME, ENV_AGENT_DIR } from "$c/config";
import { BUILTIN_TOOLS } from "$c/core/tools/index";
import { BUILTIN_TOOLS } from "$c/tools/index";
export type Mode = "text" | "json" | "rpc";
+3 -3
View File
@@ -7,9 +7,9 @@
import chalk from "chalk";
import { APP_NAME, getAgentDir } from "$c/config";
import { SettingsManager } from "$c/core/settings-manager";
import { SETTINGS_DEFS, type SettingDef } from "$c/modes/interactive/components/settings-defs";
import { theme } from "$c/modes/interactive/theme/theme";
import { SettingsManager } from "$c/config/settings-manager";
import { SETTINGS_DEFS, type SettingDef } from "$c/modes/components/settings-defs";
import { theme } from "$c/modes/theme/theme";
// =============================================================================
// Types
@@ -6,7 +6,7 @@ import { existsSync, readFileSync, statSync } from "node:fs";
import { resolve } from "node:path";
import type { ImageContent } from "@oh-my-pi/pi-ai";
import chalk from "chalk";
import { resolveReadPath } from "$c/core/tools/path-utils";
import { resolveReadPath } from "$c/tools/path-utils";
import { formatDimensionNote, resizeImage } from "$c/utils/image-resize";
import { detectSupportedImageMimeTypeFromFile } from "$c/utils/mime";
+1 -1
View File
@@ -3,7 +3,7 @@
*/
import type { Api, Model } from "@oh-my-pi/pi-ai";
import type { ModelRegistry } from "$c/core/model-registry";
import type { ModelRegistry } from "$c/config/model-registry";
import { fuzzyFilter } from "$c/utils/fuzzy";
/**
+2 -2
View File
@@ -6,8 +6,8 @@
import chalk from "chalk";
import { APP_NAME } from "$c/config";
import { PluginManager, parseSettingValue, validateSetting } from "$c/core/plugins/index";
import { theme } from "$c/modes/interactive/theme/theme";
import { PluginManager, parseSettingValue, validateSetting } from "$c/extensibility/plugins/index";
import { theme } from "$c/modes/theme/theme";
// =============================================================================
// Types
@@ -3,8 +3,8 @@
*/
import { ProcessTerminal, TUI } from "@oh-my-pi/pi-tui";
import type { SessionInfo } from "$c/core/session-manager";
import { SessionSelectorComponent } from "$c/modes/interactive/components/session-selector";
import { SessionSelectorComponent } from "$c/modes/components/session-selector";
import type { SessionInfo } from "$c/session/session-manager";
/** Show TUI session selector and return selected session path or null if cancelled */
export async function selectSession(sessions: SessionInfo[]): Promise<string | null> {
+1 -1
View File
@@ -7,7 +7,7 @@
import { $ } from "bun";
import chalk from "chalk";
import { APP_NAME } from "$c/config";
import { theme } from "$c/modes/interactive/theme/theme";
import { theme } from "$c/modes/theme/theme";
export type SetupComponent = "python";
+1 -1
View File
@@ -12,7 +12,7 @@ import { Readable } from "node:stream";
import { pipeline } from "node:stream/promises";
import chalk from "chalk";
import { APP_NAME, VERSION } from "$c/config";
import { theme } from "$c/modes/interactive/theme/theme";
import { theme } from "$c/modes/theme/theme";
/**
* Detect if we're running as a Bun compiled binary.
@@ -14,7 +14,7 @@ import {
import { logger } from "@oh-my-pi/pi-utils";
import { type Static, Type } from "@sinclair/typebox";
import AjvModule from "ajv";
import type { AuthStorage } from "./auth-storage";
import type { AuthStorage } from "$c/session/auth-storage";
const Ajv = (AjvModule as any).default || AjvModule;
@@ -2,7 +2,7 @@ import { join, resolve } from "node:path";
import { logger } from "@oh-my-pi/pi-utils";
import Handlebars from "handlebars";
import { CONFIG_DIR_NAME, getPromptsDir } from "$c/config";
import { parseFrontmatter } from "./frontmatter";
import { parseFrontmatter } from "$c/utils/frontmatter";
/**
* Represents a prompt template loaded from a markdown file
@@ -4,8 +4,8 @@ import { logger } from "@oh-my-pi/pi-utils";
import { type Settings as SettingsItem, settingsCapability } from "$c/capability/settings";
import { getAgentDbPath, getAgentDir } from "$c/config";
import { loadCapability } from "$c/discovery";
import type { SymbolPreset } from "$c/modes/interactive/theme/theme";
import { AgentStorage } from "./agent-storage";
import type { SymbolPreset } from "$c/modes/theme/theme";
import { AgentStorage } from "$c/session/agent-storage";
export interface CompactionSettings {
enabled?: boolean; // default: true
-71
View File
@@ -1,71 +0,0 @@
/**
* Core modules shared between all run modes.
*/
export {
AgentSession,
type AgentSessionConfig,
type AgentSessionEvent,
type AgentSessionEventListener,
type ModelCycleResult,
type PromptOptions,
type SessionStats,
} from "./agent-session";
export { ArtifactManager } from "./artifacts";
export { type BashExecutorOptions, type BashResult, executeBash } from "./bash-executor";
export type { CompactionResult } from "./compaction/index";
export {
discoverAndLoadExtensions,
type ExtensionAPI,
type ExtensionCommandContext,
type ExtensionContext,
type ExtensionFactory,
ExtensionRunner,
type ExtensionUIContext,
type ExtensionUIDialogOptions,
loadExtensionFromFactory,
type ToolDefinition,
} from "./extensions/index";
export { HistoryStorage } from "./history-storage";
export {
createMCPManager,
discoverAndLoadMCPTools,
loadAllMCPConfigs,
type MCPConfigFile,
type MCPLoadResult,
MCPManager,
type MCPServerConfig,
type MCPServerConnection,
MCPToolCache,
type MCPToolDefinition,
type MCPToolDetails,
type MCPToolsLoadResult,
type MCPTransport,
} from "./mcp/index";
export {
type DiagnosticMeta,
type LimitsMeta,
type OutputMeta,
OutputMetaBuilder,
outputMeta,
type SourceMeta,
type TruncationMeta,
type TruncationOptions,
wrapToolsWithMetaNotice,
wrapToolWithMetaNotice,
} from "./output-meta";
export {
buildRemoteCommand,
closeAllConnections,
closeConnection,
ensureConnection,
getControlDir,
getControlPathTemplate,
type SSHConnectionTarget,
} from "./ssh/connection-manager";
export { executeSSH, type SSHExecutorOptions, type SSHResult } from "./ssh/ssh-executor";
export { hasSshfs, isMounted, mountRemote, unmountAll, unmountRemote } from "./ssh/sshfs-mount";
export { OutputSink, type OutputSinkOptions, type OutputSummary } from "./streaming-output";
export { type ErrorEntry, MultiError, renderError, ToolError } from "./tool-errors";
export * as utils from "./utils";
@@ -1,3 +0,0 @@
import pythonPrelude from "./python-prelude.py" with { type: "text" };
export const PYTHON_PRELUDE = pythonPrelude;
@@ -1,5 +0,0 @@
/**
* Backwards-compatible re-export for SSH execution.
*/
export { executeSSH, type SSHExecutorOptions, type SSHResult } from "./ssh/ssh-executor";
@@ -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 "$c/core/tools/path-utils";
import { resolveToCwd } from "$c/tools/path-utils";
interface CursorExecBridgeOptions {
cwd: string;
@@ -22,7 +22,7 @@ import { type SlashCommand, slashCommandCapability } from "$c/capability/slash-c
import { type SystemPrompt, systemPromptCapability } from "$c/capability/system-prompt";
import { type CustomTool, toolCapability } from "$c/capability/tool";
import type { LoadContext, LoadResult } from "$c/capability/types";
import { parseFrontmatter } from "$c/core/frontmatter";
import { parseFrontmatter } from "$c/utils/frontmatter";
import {
createSourceMeta,
discoverExtensionModulePaths,
+1 -1
View File
@@ -11,7 +11,7 @@ import { registerProvider } from "$c/capability/index";
import type { Rule } from "$c/capability/rule";
import { ruleCapability } from "$c/capability/rule";
import type { LoadContext, LoadResult } from "$c/capability/types";
import { parseFrontmatter } from "$c/core/frontmatter";
import { parseFrontmatter } from "$c/utils/frontmatter";
import { createSourceMeta, loadFilesFromDir } from "./helpers";
const PROVIDER_ID = "cline";
+1 -1
View File
@@ -30,7 +30,7 @@ import { slashCommandCapability } from "$c/capability/slash-command";
import type { CustomTool } from "$c/capability/tool";
import { toolCapability } from "$c/capability/tool";
import type { LoadContext, LoadResult } from "$c/capability/types";
import { parseFrontmatter } from "$c/core/frontmatter";
import { parseFrontmatter } from "$c/utils/frontmatter";
import {
createSourceMeta,
discoverExtensionModulePaths,
@@ -22,7 +22,7 @@ import { ruleCapability } from "$c/capability/rule";
import type { Settings } from "$c/capability/settings";
import { settingsCapability } from "$c/capability/settings";
import type { LoadContext, LoadResult } from "$c/capability/types";
import { parseFrontmatter } from "$c/core/frontmatter";
import { parseFrontmatter } from "$c/utils/frontmatter";
import {
createSourceMeta,
expandEnvVarsDeep,
@@ -18,7 +18,7 @@ import { readFile } from "$c/capability/fs";
import { registerProvider } from "$c/capability/index";
import { type Instruction, instructionCapability } from "$c/capability/instruction";
import type { LoadContext, LoadResult, SourceMeta } from "$c/capability/types";
import { parseFrontmatter } from "$c/core/frontmatter";
import { parseFrontmatter } from "$c/utils/frontmatter";
import { calculateDepth, createSourceMeta, getProjectPath, loadFilesFromDir } from "./helpers";
const PROVIDER_ID = "github";
@@ -8,7 +8,7 @@ import type { ThinkingLevel } from "@oh-my-pi/pi-agent-core";
import { readDirEntries, readFile } from "$c/capability/fs";
import type { Skill, SkillFrontmatter } from "$c/capability/skill";
import type { LoadContext, LoadResult, SourceMeta } from "$c/capability/types";
import { parseFrontmatter } from "$c/core/frontmatter";
import { parseFrontmatter } from "$c/utils/frontmatter";
const VALID_THINKING_LEVELS: readonly string[] = ["off", "minimal", "low", "medium", "high", "xhigh"];
const UNICODE_SPACES = /[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;
@@ -16,7 +16,7 @@ import { registerProvider } from "$c/capability/index";
import { type MCPServer, mcpCapability } from "$c/capability/mcp";
import { type Rule, ruleCapability } from "$c/capability/rule";
import type { LoadContext, LoadResult } from "$c/capability/types";
import { parseFrontmatter } from "$c/core/frontmatter";
import { parseFrontmatter } from "$c/utils/frontmatter";
import {
createSourceMeta,
expandEnvVarsDeep,
@@ -5,7 +5,7 @@
*/
import { Type } from "@sinclair/typebox";
import type { CustomTool } from "$c/core/custom-tools/types";
import type { CustomTool } from "$c/extensibility/custom-tools/types";
import { callExaTool, findApiKey, formatSearchResults, isSearchResponse } from "./mcp-client";
import type { ExaRenderDetails } from "./types";
@@ -9,8 +9,8 @@
* - 14 websets tools (CRUD, items, search, enrichment, monitor)
*/
import type { CustomTool } from "$c/core/custom-tools/types";
import type { ExaSettings } from "$c/core/settings-manager";
import type { ExaSettings } from "$c/config/settings-manager";
import type { CustomTool } from "$c/extensibility/custom-tools/types";
import { companyTool } from "./company";
import { linkedinTool } from "./linkedin";
import { researcherTools } from "./researcher";
@@ -5,7 +5,7 @@
*/
import { Type } from "@sinclair/typebox";
import type { CustomTool } from "$c/core/custom-tools/types";
import type { CustomTool } from "$c/extensibility/custom-tools/types";
import { callExaTool, findApiKey, formatSearchResults, isSearchResponse } from "./mcp-client";
import type { ExaRenderDetails } from "./types";
@@ -8,8 +8,8 @@ import { existsSync, readFileSync } from "node:fs";
import { homedir } from "node:os";
import { logger } from "@oh-my-pi/pi-utils";
import type { TSchema } from "@sinclair/typebox";
import type { CustomTool, CustomToolResult } from "$c/core/custom-tools/types";
import { callMCP } from "$c/core/mcp/json-rpc";
import type { CustomTool, CustomToolResult } from "$c/extensibility/custom-tools/types";
import { callMCP } from "$c/mcp/json-rpc";
import type {
ExaRenderDetails,
ExaSearchResponse,
@@ -7,7 +7,8 @@
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 "$c/core/custom-tools/types";
import type { RenderResultOptions } from "$c/extensibility/custom-tools/types";
import type { Theme } from "$c/modes/theme/theme";
import {
formatCount,
formatExpandHint,
@@ -18,8 +19,7 @@ import {
PREVIEW_LIMITS,
TRUNCATE_LENGTHS,
truncate,
} from "$c/core/tools/render-utils";
import type { Theme } from "$c/modes/interactive/theme/theme";
} from "$c/tools/render-utils";
import type { ExaRenderDetails } from "./types";
const COLLAPSED_PREVIEW_LINES = PREVIEW_LIMITS.COLLAPSED_LINES;
@@ -5,7 +5,7 @@
*/
import { Type } from "@sinclair/typebox";
import type { CustomTool } from "$c/core/custom-tools/types";
import type { CustomTool } from "$c/extensibility/custom-tools/types";
import { callExaTool, findApiKey } from "./mcp-client";
import type { ExaRenderDetails } from "./types";
@@ -6,7 +6,7 @@
import { StringEnum } from "@oh-my-pi/pi-ai";
import { Type } from "@sinclair/typebox";
import type { CustomTool } from "$c/core/custom-tools/types";
import type { CustomTool } from "$c/extensibility/custom-tools/types";
import { callExaTool, findApiKey, formatSearchResults, isSearchResponse } from "./mcp-client";
import type { ExaRenderDetails } from "./types";
@@ -5,7 +5,7 @@
*/
import { Type } from "@sinclair/typebox";
import type { CustomTool } from "$c/core/custom-tools/types";
import type { CustomTool } from "$c/extensibility/custom-tools/types";
import { callWebsetsTool, findApiKey } from "./mcp-client";
import type { ExaRenderDetails } from "./types";
@@ -5,9 +5,9 @@
*/
import { cspawn, Exception, ptree } from "@oh-my-pi/pi-utils";
import { OutputSink } from "$c/session/streaming-output";
import { getShellConfig } from "$c/utils/shell";
import { getOrCreateSnapshot, getSnapshotSourceCommand } from "$c/utils/shell-snapshot";
import { OutputSink } from "./streaming-output";
export interface BashExecutorOptions {
cwd?: string;
@@ -2,8 +2,8 @@ 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 "$c/config";
import { SessionManager } from "$c/core/session-manager";
import { getResolvedThemeColors, getThemeExportColors } from "$c/modes/interactive/theme/theme";
import { getResolvedThemeColors, getThemeExportColors } from "$c/modes/theme/theme";
import { SessionManager } from "$c/session/session-manager";
// Pre-generated template (created by scripts/generate-template.ts at publish time)
import { TEMPLATE } from "./template.generated";
File diff suppressed because one or more lines are too long
@@ -8,7 +8,7 @@
import { logger } from "@oh-my-pi/pi-utils";
import type { Rule } from "$c/capability/rule";
import type { TtsrSettings } from "./settings-manager";
import type { TtsrSettings } from "$c/config/settings-manager";
interface TtsrEntry {
rule: Rule;
@@ -12,9 +12,9 @@
* multiple reviewer agents based on diff weight and locality.
*/
import type { CustomCommand, CustomCommandAPI } from "$c/core/custom-commands/types";
import type { HookCommandContext } from "$c/core/hooks/types";
import { renderPromptTemplate } from "$c/core/prompt-templates";
import { renderPromptTemplate } from "$c/config/prompt-templates";
import type { CustomCommand, CustomCommandAPI } from "$c/extensibility/custom-commands/types";
import type { HookCommandContext } from "$c/extensibility/hooks/types";
import reviewRequestTemplate from "$c/prompts/review-request.md" with { type: "text" };
// ─────────────────────────────────────────────────────────────────────────────
@@ -10,7 +10,7 @@ import * as path from "node:path";
import { logger } from "@oh-my-pi/pi-utils";
import * as typebox from "@sinclair/typebox";
import { getAgentDir, getConfigDirs } from "$c/config";
import { execCommand } from "$c/core/exec";
import { execCommand } from "$c/exec/exec";
import * as piCodingAgent from "$c/index";
import { ReviewCommand } from "./bundled/review";
import type {
@@ -6,7 +6,7 @@
* arbitrary logic with full access to the hook context.
*/
import type { ExecOptions, ExecResult, HookCommandContext } from "$c/core/hooks/types";
import type { ExecOptions, ExecResult, HookCommandContext } from "$c/extensibility/hooks/types";
// Re-export for custom commands to use
export type { ExecOptions, ExecResult, HookCommandContext };
@@ -9,14 +9,14 @@ import * as path from "node:path";
import { logger } from "@oh-my-pi/pi-utils";
import * as typebox from "@sinclair/typebox";
import { toolCapability } from "$c/capability/tool";
import type { ExecOptions } from "$c/core/exec";
import { execCommand } from "$c/core/exec";
import type { HookUIContext } from "$c/core/hooks/types";
import { getAllPluginToolPaths } from "$c/core/plugins/loader";
import { type CustomTool, loadCapability } from "$c/discovery";
import { expandPath } from "$c/discovery/helpers";
import type { ExecOptions } from "$c/exec/exec";
import { execCommand } from "$c/exec/exec";
import type { HookUIContext } from "$c/extensibility/hooks/types";
import { getAllPluginToolPaths } from "$c/extensibility/plugins/loader";
import * as piCodingAgent from "$c/index";
import { theme } from "$c/modes/interactive/theme/theme";
import { theme } from "$c/modes/theme/theme";
import type { CustomToolAPI, CustomToolFactory, LoadedCustomTool, ToolLoadError } from "./types";
/**
@@ -9,11 +9,11 @@ import type { AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agen
import type { Model } from "@oh-my-pi/pi-ai";
import type { Component } from "@oh-my-pi/pi-tui";
import type { Static, TSchema } from "@sinclair/typebox";
import type { ExecOptions, ExecResult } from "$c/core/exec";
import type { HookUIContext } from "$c/core/hooks/types";
import type { ModelRegistry } from "$c/core/model-registry";
import type { ReadonlySessionManager } from "$c/core/session-manager";
import type { Theme } from "$c/modes/interactive/theme/theme";
import type { ModelRegistry } from "$c/config/model-registry";
import type { ExecOptions, ExecResult } from "$c/exec/exec";
import type { HookUIContext } from "$c/extensibility/hooks/types";
import type { Theme } from "$c/modes/theme/theme";
import type { ReadonlySessionManager } from "$c/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 "$c/core/exec";
export type { ExecOptions, ExecResult } from "$c/exec/exec";
/** API passed to custom tool factory (stable across session changes) */
export interface CustomToolAPI {
@@ -5,7 +5,7 @@
import type { AgentTool, AgentToolResult, AgentToolUpdateCallback, RenderResultOptions } from "@oh-my-pi/pi-agent-core";
import type { Component } from "@oh-my-pi/pi-tui";
import type { Static, TSchema } from "@sinclair/typebox";
import type { Theme } from "$c/modes/interactive/theme/theme";
import type { Theme } from "$c/modes/theme/theme";
import type { CustomTool, CustomToolContext, LoadedCustomTool } from "./types";
export class CustomToolAdapter<TParams extends TSchema = TSchema, TDetails = any, TTheme extends Theme = Theme>
@@ -11,13 +11,13 @@ 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 "$c/capability/extension-module";
import { EventBus } from "$c/core/event-bus";
import type { ExecOptions } from "$c/core/exec";
import { execCommand } from "$c/core/exec";
import type { CustomMessage } from "$c/core/messages";
import { loadCapability } from "$c/discovery";
import { expandPath, getExtensionNameFromPath } from "$c/discovery/helpers";
import type { ExecOptions } from "$c/exec/exec";
import { execCommand } from "$c/exec/exec";
import * as piCodingAgent from "$c/index";
import type { CustomMessage } from "$c/session/messages";
import { EventBus } from "$c/utils/event-bus";
import type {
Extension,
ExtensionAPI,
@@ -6,9 +6,9 @@ import type { AgentMessage } from "@oh-my-pi/pi-agent-core";
import type { ImageContent, Model } from "@oh-my-pi/pi-ai";
import type { KeyId } from "@oh-my-pi/pi-tui";
import { logger } from "@oh-my-pi/pi-utils";
import type { ModelRegistry } from "$c/core/model-registry";
import type { SessionManager } from "$c/core/session-manager";
import { type Theme, theme } from "$c/modes/interactive/theme/theme";
import type { ModelRegistry } from "$c/config/model-registry";
import { type Theme, theme } from "$c/modes/theme/theme";
import type { SessionManager } from "$c/session/session-manager";
import type {
BeforeAgentStartEvent,
BeforeAgentStartEventResult,
@@ -12,28 +12,28 @@ import type { AgentMessage, AgentToolResult, AgentToolUpdateCallback, ThinkingLe
import type { ImageContent, Model, TextContent, ToolResultMessage } from "@oh-my-pi/pi-ai";
import type { AutocompleteItem, Component, EditorComponent, EditorTheme, KeyId, TUI } from "@oh-my-pi/pi-tui";
import type { Static, TSchema } from "@sinclair/typebox";
import type { BashResult } from "$c/core/bash-executor";
import type { CompactionPreparation, CompactionResult } from "$c/core/compaction";
import type { EventBus } from "$c/core/event-bus";
import type { ExecOptions, ExecResult } from "$c/core/exec";
import type { KeybindingsManager } from "$c/core/keybindings";
import type { CustomMessage } from "$c/core/messages";
import type { ModelRegistry } from "$c/core/model-registry";
import type { PythonResult } from "$c/core/python-executor";
import type { KeybindingsManager } from "$c/config/keybindings";
import type { ModelRegistry } from "$c/config/model-registry";
import type { BashResult } from "$c/exec/bash-executor";
import type { ExecOptions, ExecResult } from "$c/exec/exec";
import type * as piCodingAgent from "$c/index";
import type { PythonResult } from "$c/ipy/executor";
import type { Theme } from "$c/modes/theme/theme";
import type { EditToolDetails } from "$c/patch";
import type { CompactionPreparation, CompactionResult } from "$c/session/compaction";
import type { CustomMessage } from "$c/session/messages";
import type {
BranchSummaryEntry,
CompactionEntry,
ReadonlySessionManager,
SessionEntry,
SessionManager,
} from "$c/core/session-manager";
import type { BashToolDetails, FindToolDetails, GrepToolDetails, LsToolDetails, ReadToolDetails } from "$c/core/tools";
import type { EditToolDetails } from "$c/core/tools/patch";
import type * as piCodingAgent from "$c/index";
import type { Theme } from "$c/modes/interactive/theme/theme";
} from "$c/session/session-manager";
import type { BashToolDetails, FindToolDetails, GrepToolDetails, LsToolDetails, ReadToolDetails } from "$c/tools";
import type { EventBus } from "$c/utils/event-bus";
export type { ExecOptions, ExecResult } from "$c/core/exec";
export type { AppAction, KeybindingsManager } from "$c/core/keybindings";
export type { AppAction, KeybindingsManager } from "$c/config/keybindings";
export type { ExecOptions, ExecResult } from "$c/exec/exec";
export type { AgentToolResult, AgentToolUpdateCallback };
// ============================================================================
@@ -5,7 +5,7 @@
import type { AgentTool, AgentToolContext, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
import type { ImageContent, TextContent } from "@oh-my-pi/pi-ai";
import type { Static, TSchema } from "@sinclair/typebox";
import type { Theme } from "$c/modes/interactive/theme/theme";
import type { Theme } from "$c/modes/theme/theme";
import type { ExtensionRunner } from "./runner";
import type { RegisteredTool, ToolCallEventResult, ToolResultEventResult } from "./types";
@@ -1,5 +1,5 @@
// biome-ignore assist/source/organizeImports: biome is not smart
export type { ReadonlySessionManager, UsageStatistics } from "$c/core/session-manager";
export type { ReadonlySessionManager, UsageStatistics } from "$c/session/session-manager";
export {
discoverAndLoadHooks,
loadHooks,
@@ -6,12 +6,12 @@ import * as path from "node:path";
import { logger } from "@oh-my-pi/pi-utils";
import * as typebox from "@sinclair/typebox";
import { hookCapability } from "$c/capability/hook";
import type { HookMessage } from "$c/core/messages";
import type { SessionManager } from "$c/core/session-manager";
import type { Hook } from "$c/discovery";
import { loadCapability } from "$c/discovery";
import { expandPath } from "$c/discovery/helpers";
import * as piCodingAgent from "$c/index";
import type { HookMessage } from "$c/session/messages";
import type { SessionManager } from "$c/session/session-manager";
import { execCommand } from "./runner";
import type { ExecOptions, HookAPI, HookFactory, HookMessageRenderer, RegisteredCommand } from "./types";
@@ -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 "$c/core/model-registry";
import type { SessionManager } from "$c/core/session-manager";
import { theme } from "$c/modes/interactive/theme/theme";
import type { ModelRegistry } from "$c/config/model-registry";
import { theme } from "$c/modes/theme/theme";
import type { SessionManager } from "$c/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 "$c/core/exec";
export { execCommand } from "$c/exec/exec";
/** No-op UI context used when no UI is available */
const noOpUIContext: HookUIContext = {
@@ -8,29 +8,23 @@
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 { Component, TUI } from "@oh-my-pi/pi-tui";
import type { CompactionPreparation, CompactionResult } from "$c/core/compaction/index";
import type { ExecOptions, ExecResult } from "$c/core/exec";
import type { HookMessage } from "$c/core/messages";
import type { ModelRegistry } from "$c/core/model-registry";
import type { ModelRegistry } from "$c/config/model-registry";
import type { ExecOptions, ExecResult } from "$c/exec/exec";
import type { Theme } from "$c/modes/theme/theme";
import type { EditToolDetails } from "$c/patch";
import type { CompactionPreparation, CompactionResult } from "$c/session/compaction/index";
import type { HookMessage } from "$c/session/messages";
import type {
BranchSummaryEntry,
CompactionEntry,
ReadonlySessionManager,
SessionEntry,
SessionManager,
} from "$c/core/session-manager";
import type {
BashToolDetails,
FindToolDetails,
GrepToolDetails,
LsToolDetails,
ReadToolDetails,
} from "$c/core/tools/index";
import type { EditToolDetails } from "$c/core/tools/patch";
import type { Theme } from "$c/modes/interactive/theme/theme";
} from "$c/session/session-manager";
import type { BashToolDetails, FindToolDetails, GrepToolDetails, LsToolDetails, ReadToolDetails } from "$c/tools/index";
// Re-export for backward compatibility
export type { ExecOptions, ExecResult } from "$c/core/exec";
export type { ExecOptions, ExecResult } from "$c/exec/exec";
/**
* UI context for hooks to request interactive UI from the harness.
@@ -1,4 +1,4 @@
import { theme } from "$c/modes/interactive/theme/theme";
import { theme } from "$c/modes/theme/theme";
import type { DoctorCheck } from "./types";
export async function runDoctorChecks(): Promise<DoctorCheck[]> {
@@ -4,10 +4,10 @@ import { basename, join } from "node:path";
import { logger } from "@oh-my-pi/pi-utils";
import { skillCapability } from "$c/capability/skill";
import type { SourceMeta } from "$c/capability/types";
import type { SkillsSettings } from "$c/config/settings-manager";
import type { Skill as CapabilitySkill, SkillFrontmatter as ImportedSkillFrontmatter } from "$c/discovery";
import { loadCapability } from "$c/discovery";
import { parseFrontmatter } from "./frontmatter";
import type { SkillsSettings } from "./settings-manager";
import { parseFrontmatter } from "$c/utils/frontmatter";
// Re-export SkillFrontmatter for backward compatibility
export type { ImportedSkillFrontmatter as SkillFrontmatter };
@@ -1,9 +1,9 @@
import { slashCommandCapability } from "$c/capability/slash-command";
import { renderPromptTemplate } from "$c/config/prompt-templates";
import type { SlashCommand } from "$c/discovery";
import { loadCapability } from "$c/discovery";
import { parseFrontmatter } from "./frontmatter";
import { renderPromptTemplate } from "./prompt-templates";
import { EMBEDDED_COMMAND_TEMPLATES } from "./tools/task/commands";
import { EMBEDDED_COMMAND_TEMPLATES } from "$c/task/commands";
import { parseFrontmatter } from "$c/utils/frontmatter";
/**
* Represents a custom slash command loaded from a file
+226 -226
View File
@@ -7,230 +7,7 @@ export { StringEnum } from "@oh-my-pi/pi-ai";
export { Container, Markdown, Spacer, Text } from "@oh-my-pi/pi-tui";
// Logging
export { logger } from "@oh-my-pi/pi-utils";
export { getAgentDir, VERSION } from "./config";
export {
AgentSession,
type AgentSessionConfig,
type AgentSessionEvent,
type AgentSessionEventListener,
type ModelCycleResult,
type PromptOptions,
type SessionStats,
} from "./core/agent-session";
// Auth and model registry
export { type ApiKeyCredential, type AuthCredential, AuthStorage, type OAuthCredential } from "./core/auth-storage";
// Compaction
export {
type BranchPreparation,
type BranchSummaryResult,
type CollectEntriesResult,
type CompactionResult,
type CutPointResult,
calculateContextTokens,
collectEntriesForBranchSummary,
compact,
DEFAULT_COMPACTION_SETTINGS,
estimateTokens,
type FileOperations,
findCutPoint,
findTurnStartIndex,
type GenerateBranchSummaryOptions,
generateBranchSummary,
generateSummary,
getLastAssistantUsage,
prepareBranchEntries,
serializeConversation,
shouldCompact,
} from "./core/compaction/index";
// Custom commands
export type {
CustomCommand,
CustomCommandAPI,
CustomCommandFactory,
CustomCommandSource,
CustomCommandsLoadResult,
LoadedCustomCommand,
} from "./core/custom-commands/types";
export type {
AgentToolUpdateCallback,
CustomTool,
CustomToolAPI,
CustomToolContext,
CustomToolFactory,
CustomToolSessionEvent,
CustomToolsLoadResult,
CustomToolUIContext,
ExecResult,
LoadedCustomTool,
RenderResultOptions,
} from "./core/custom-tools/index";
// Custom tools
export { CustomToolLoader, discoverAndLoadCustomTools, loadCustomTools } from "./core/custom-tools/index";
export type {
AppAction,
Extension,
ExtensionActions,
ExtensionAPI,
ExtensionCommandContext,
ExtensionCommandContextActions,
ExtensionContext,
ExtensionContextActions,
ExtensionError,
ExtensionEvent,
ExtensionFactory,
ExtensionFlag,
ExtensionHandler,
ExtensionShortcut,
ExtensionUIContext,
ExtensionUIDialogOptions,
InputEvent,
InputEventResult,
KeybindingsManager,
LoadExtensionsResult,
MessageRenderer,
MessageRenderOptions,
RegisteredCommand,
ToolResultEvent,
TurnEndEvent,
TurnStartEvent,
UserBashEvent,
UserBashEventResult,
UserPythonEvent,
UserPythonEventResult,
} from "./core/extensions/index";
// Extension types and utilities
export {
discoverAndLoadExtensions,
ExtensionRunner,
ExtensionRuntime,
isBashToolResult,
isEditToolResult,
isFindToolResult,
isGrepToolResult,
isLsToolResult,
isReadToolResult,
isWriteToolResult,
} from "./core/extensions/index";
// Hook system types (legacy re-export)
export type * from "./core/hooks/index";
export { formatKeyHint, formatKeyHints } from "./core/keybindings";
export { convertToLlm } from "./core/messages";
export { ModelRegistry } from "./core/model-registry";
// Prompt templates
export type { PromptTemplate } from "./core/prompt-templates";
// SDK for programmatic usage
export {
// Factory
BashTool,
// Tool factories
BUILTIN_TOOLS,
type BuildSystemPromptOptions,
buildSystemPrompt,
type CreateAgentSessionOptions,
type CreateAgentSessionResult,
createAgentSession,
createTools,
// Discovery
discoverAuthStorage,
discoverContextFiles,
discoverCustomTSCommands,
discoverExtensions,
discoverMCPServers,
discoverModels,
discoverPromptTemplates,
discoverSkills,
EditTool,
FindTool,
GrepTool,
LsTool,
loadSettings,
loadSshTool,
PythonTool,
ReadTool,
type ToolSession,
WriteTool,
} from "./core/sdk";
export {
type BranchSummaryEntry,
buildSessionContext,
type CompactionEntry,
CURRENT_SESSION_VERSION,
type CustomEntry,
type CustomMessageEntry,
type FileEntry,
getLatestCompactionEntry,
type ModelChangeEntry,
migrateSessionEntries,
type NewSessionOptions,
parseSessionEntries,
type SessionContext,
type SessionEntry,
type SessionEntryBase,
type SessionHeader,
type SessionInfo,
SessionManager,
type SessionMessageEntry,
type ThinkingLevelChangeEntry,
} from "./core/session-manager";
export {
type CompactionSettings,
type ImageSettings,
type LspSettings,
type RetrySettings,
type Settings,
SettingsManager,
type SkillsSettings,
} from "./core/settings-manager";
// Skills
export {
type LoadSkillsFromDirOptions,
type LoadSkillsResult,
loadSkills,
loadSkillsFromDir,
type Skill,
type SkillFrontmatter,
type SkillWarning,
} from "./core/skills";
// Slash commands
export { type FileSlashCommand, loadSlashCommands as discoverSlashCommands } from "./core/slash-commands";
// Tools (detail types and utilities)
export {
type BashToolDetails,
DEFAULT_MAX_BYTES,
DEFAULT_MAX_LINES,
type FindOperations,
type FindToolDetails,
type FindToolOptions,
formatSize,
type GrepOperations,
type GrepToolDetails,
type GrepToolOptions,
type LsOperations,
type LsToolDetails,
type LsToolOptions,
type PythonToolDetails,
type ReadToolDetails,
type TruncationOptions,
type TruncationResult,
truncateHead,
truncateLine,
truncateTail,
type WriteToolDetails,
} from "./core/tools/index";
export type { FileDiagnosticsResult } from "./core/tools/lsp/index";
// Main entry point
export { main } from "./main";
// Run modes for programmatic SDK usage
export {
InteractiveMode,
type InteractiveModeOptions,
type PrintModeOptions,
RpcClient,
type RpcClientOptions,
type RpcEventListener,
runPrintMode,
runRpcMode,
} from "./modes/index";
export type { FileDiagnosticsResult } from "$c/lsp/index";
// UI components for extensions
export {
ArminComponent,
@@ -264,7 +41,7 @@ export {
UserMessageComponent,
UserMessageSelectorComponent,
type VisualTruncateResult,
} from "./modes/interactive/components/index";
} from "$c/modes/components/index";
// Theme utilities for custom tools
export {
getLanguageFromPath,
@@ -275,5 +52,228 @@ export {
initTheme,
Theme,
type ThemeColor,
} from "./modes/interactive/theme/theme";
} from "$c/modes/theme/theme";
export { getAgentDir, VERSION } from "./config";
export { formatKeyHint, formatKeyHints } from "./config/keybindings";
export { ModelRegistry } from "./config/model-registry";
// Prompt templates
export type { PromptTemplate } from "./config/prompt-templates";
export {
type CompactionSettings,
type ImageSettings,
type LspSettings,
type RetrySettings,
type Settings,
SettingsManager,
type SkillsSettings,
} from "./config/settings-manager";
// Custom commands
export type {
CustomCommand,
CustomCommandAPI,
CustomCommandFactory,
CustomCommandSource,
CustomCommandsLoadResult,
LoadedCustomCommand,
} from "./extensibility/custom-commands/types";
export type {
AgentToolUpdateCallback,
CustomTool,
CustomToolAPI,
CustomToolContext,
CustomToolFactory,
CustomToolSessionEvent,
CustomToolsLoadResult,
CustomToolUIContext,
ExecResult,
LoadedCustomTool,
RenderResultOptions,
} from "./extensibility/custom-tools/index";
// Custom tools
export { CustomToolLoader, discoverAndLoadCustomTools, loadCustomTools } from "./extensibility/custom-tools/index";
export type {
AppAction,
Extension,
ExtensionActions,
ExtensionAPI,
ExtensionCommandContext,
ExtensionCommandContextActions,
ExtensionContext,
ExtensionContextActions,
ExtensionError,
ExtensionEvent,
ExtensionFactory,
ExtensionFlag,
ExtensionHandler,
ExtensionShortcut,
ExtensionUIContext,
ExtensionUIDialogOptions,
InputEvent,
InputEventResult,
KeybindingsManager,
LoadExtensionsResult,
MessageRenderer,
MessageRenderOptions,
RegisteredCommand,
ToolResultEvent,
TurnEndEvent,
TurnStartEvent,
UserBashEvent,
UserBashEventResult,
UserPythonEvent,
UserPythonEventResult,
} from "./extensibility/extensions/index";
// Extension types and utilities
export {
discoverAndLoadExtensions,
ExtensionRunner,
ExtensionRuntime,
isBashToolResult,
isEditToolResult,
isFindToolResult,
isGrepToolResult,
isLsToolResult,
isReadToolResult,
isWriteToolResult,
} from "./extensibility/extensions/index";
// Hook system types (legacy re-export)
export type * from "./extensibility/hooks/index";
// Skills
export {
type LoadSkillsFromDirOptions,
type LoadSkillsResult,
loadSkills,
loadSkillsFromDir,
type Skill,
type SkillFrontmatter,
type SkillWarning,
} from "./extensibility/skills";
// Slash commands
export { type FileSlashCommand, loadSlashCommands as discoverSlashCommands } from "./extensibility/slash-commands";
// Main entry point
export { main } from "./main";
// Run modes for programmatic SDK usage
export {
InteractiveMode,
type InteractiveModeOptions,
type PrintModeOptions,
RpcClient,
type RpcClientOptions,
type RpcEventListener,
runPrintMode,
runRpcMode,
} from "./modes/index";
// SDK for programmatic usage
export {
// Factory
BashTool,
// Tool factories
BUILTIN_TOOLS,
type BuildSystemPromptOptions,
buildSystemPrompt,
type CreateAgentSessionOptions,
type CreateAgentSessionResult,
createAgentSession,
createTools,
// Discovery
discoverAuthStorage,
discoverContextFiles,
discoverCustomTSCommands,
discoverExtensions,
discoverMCPServers,
discoverModels,
discoverPromptTemplates,
discoverSkills,
EditTool,
FindTool,
GrepTool,
LsTool,
loadSettings,
loadSshTool,
PythonTool,
ReadTool,
type ToolSession,
WriteTool,
} from "./sdk";
export {
AgentSession,
type AgentSessionConfig,
type AgentSessionEvent,
type AgentSessionEventListener,
type ModelCycleResult,
type PromptOptions,
type SessionStats,
} from "./session/agent-session";
// Auth and model registry
export { type ApiKeyCredential, type AuthCredential, AuthStorage, type OAuthCredential } from "./session/auth-storage";
// Compaction
export {
type BranchPreparation,
type BranchSummaryResult,
type CollectEntriesResult,
type CompactionResult,
type CutPointResult,
calculateContextTokens,
collectEntriesForBranchSummary,
compact,
DEFAULT_COMPACTION_SETTINGS,
estimateTokens,
type FileOperations,
findCutPoint,
findTurnStartIndex,
type GenerateBranchSummaryOptions,
generateBranchSummary,
generateSummary,
getLastAssistantUsage,
prepareBranchEntries,
serializeConversation,
shouldCompact,
} from "./session/compaction/index";
export { convertToLlm } from "./session/messages";
export {
type BranchSummaryEntry,
buildSessionContext,
type CompactionEntry,
CURRENT_SESSION_VERSION,
type CustomEntry,
type CustomMessageEntry,
type FileEntry,
getLatestCompactionEntry,
type ModelChangeEntry,
migrateSessionEntries,
type NewSessionOptions,
parseSessionEntries,
type SessionContext,
type SessionEntry,
type SessionEntryBase,
type SessionHeader,
type SessionInfo,
SessionManager,
type SessionMessageEntry,
type ThinkingLevelChangeEntry,
} from "./session/session-manager";
// Tools (detail types and utilities)
export {
type BashToolDetails,
DEFAULT_MAX_BYTES,
DEFAULT_MAX_LINES,
type FindOperations,
type FindToolDetails,
type FindToolOptions,
formatSize,
type GrepOperations,
type GrepToolDetails,
type GrepToolOptions,
type LsOperations,
type LsToolDetails,
type LsToolOptions,
type PythonToolDetails,
type ReadToolDetails,
type TruncationOptions,
type TruncationResult,
truncateHead,
truncateLine,
truncateTail,
type WriteToolDetails,
} from "./tools/index";
export { getShellConfig } from "./utils/shell";
@@ -9,7 +9,7 @@
*/
import * as path from "node:path";
import type { Skill } from "$c/core/skills";
import type { Skill } from "$c/extensibility/skills";
import type { InternalResource, InternalUrl, ProtocolHandler } from "./types";
export interface SkillProtocolOptions {
@@ -6,8 +6,8 @@ import {
type KernelExecuteResult,
type PreludeHelper,
PythonKernel,
} from "./python-kernel";
import { OutputSink } from "./streaming-output";
} from "$c/ipy/kernel";
import { OutputSink } from "$c/session/streaming-output";
export type PythonKernelMode = "session" | "per-call";
export interface PythonExecutorOptions {
@@ -5,10 +5,10 @@ import { $, type Subprocess } from "bun";
import { nanoid } from "nanoid";
import { getShellConfig, killProcessTree } from "$c/utils/shell";
import { getOrCreateSnapshot } from "$c/utils/shell-snapshot";
import { acquireSharedGateway, releaseSharedGateway } from "./python-gateway-coordinator";
import { loadPythonModules } from "./python-modules";
import { PYTHON_PRELUDE } from "./python-prelude";
import { htmlToBasicMarkdown } from "./tools/web-scrapers/types";
import { htmlToBasicMarkdown } from "$c/web/scrapers/types";
import { acquireSharedGateway, releaseSharedGateway } from "./gateway-coordinator";
import { loadPythonModules } from "./modules";
import { PYTHON_PRELUDE } from "./prelude";
const TEXT_ENCODER = new TextEncoder();
const TEXT_DECODER = new TextDecoder();
+3
View File
@@ -0,0 +1,3 @@
import pythonPrelude from "./prelude.py" with { type: "text" };
export const PYTHON_PRELUDE = pythonPrelude;
@@ -1,6 +1,6 @@
import * as fs from "node:fs";
import { logger } from "@oh-my-pi/pi-utils";
import { ToolAbortError, throwIfAborted } from "$c/core/tool-errors";
import { ToolAbortError, throwIfAborted } from "$c/tools/tool-errors";
import { applyWorkspaceEdit } from "./edits";
import { getLspmuxCommand, isLspmuxSupported } from "./lspmux";
import type {
@@ -4,7 +4,7 @@
*/
import path from "node:path";
import type { Diagnostic, DiagnosticSeverity, LinterClient, ServerConfig } from "$c/core/tools/lsp/types";
import type { Diagnostic, DiagnosticSeverity, LinterClient, ServerConfig } from "$c/lsp/types";
// =============================================================================
// Biome JSON Output Types
@@ -8,7 +8,7 @@
export { BiomeClient } from "./biome-client";
export { LspLinterClient } from "./lsp-linter-client";
import type { LinterClient, ServerConfig } from "$c/core/tools/lsp/types";
import type { LinterClient, ServerConfig } from "$c/lsp/types";
import { LspLinterClient } from "./lsp-linter-client";
// Cache of linter clients by server name + cwd
@@ -3,10 +3,10 @@
* Uses the Language Server Protocol for formatting and diagnostics.
*/
import { getOrCreateClient, notifySaved, sendRequest, syncContent } from "$c/core/tools/lsp/client";
import { applyTextEditsToString } from "$c/core/tools/lsp/edits";
import type { Diagnostic, LinterClient, LspClient, ServerConfig, TextEdit } from "$c/core/tools/lsp/types";
import { fileToUri } from "$c/core/tools/lsp/utils";
import { getOrCreateClient, notifySaved, sendRequest, syncContent } from "$c/lsp/client";
import { applyTextEditsToString } from "$c/lsp/edits";
import type { Diagnostic, LinterClient, LspClient, ServerConfig, TextEdit } from "$c/lsp/types";
import { fileToUri } from "$c/lsp/utils";
/** Default formatting options for LSP */
const DEFAULT_FORMAT_OPTIONS = {
@@ -4,12 +4,12 @@ import path from "node:path";
import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
import { logger, once, untilAborted } from "@oh-my-pi/pi-utils";
import type { BunFile } from "bun";
import { renderPromptTemplate } from "$c/core/prompt-templates";
import { throwIfAborted } from "$c/core/tool-errors";
import type { ToolSession } from "$c/core/tools/index";
import { resolveToCwd } from "$c/core/tools/path-utils";
import { type Theme, theme } from "$c/modes/interactive/theme/theme";
import { renderPromptTemplate } from "$c/config/prompt-templates";
import { type Theme, theme } from "$c/modes/theme/theme";
import lspDescription from "$c/prompts/tools/lsp.md" with { type: "text" };
import type { ToolSession } from "$c/tools/index";
import { resolveToCwd } from "$c/tools/path-utils";
import { throwIfAborted } from "$c/tools/tool-errors";
import {
ensureFileOpen,
getActiveClients,
@@ -11,8 +11,8 @@
import type { AgentToolResult, RenderResultOptions } from "@oh-my-pi/pi-agent-core";
import { Text } from "@oh-my-pi/pi-tui";
import { highlight, supportsLanguage } from "cli-highlight";
import { formatExpandHint, formatMoreItems, TRUNCATE_LENGTHS, truncate } from "$c/core/tools/render-utils";
import { getLanguageFromPath, type Theme } from "$c/modes/interactive/theme/theme";
import { getLanguageFromPath, type Theme } from "$c/modes/theme/theme";
import { formatExpandHint, formatMoreItems, TRUNCATE_LENGTHS, truncate } from "$c/tools/render-utils";
import type { LspParams, LspToolDetails } from "./types";
// =============================================================================

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