refactor(coding-agent): migrated import paths to relative imports and consolidated tool imports
- Migrated import paths from absolute package imports to relative imports throughout coding-agent modules. - Consolidated related imports in tools/index.ts to reduce import statement count. - Removed guideline about avoiding relative parent imports from AGENTS.md documentation. - Reformatted code examples in AGENTS.md for improved readability with multi-line formatting.
This commit is contained in:
@@ -24,7 +24,6 @@ This repo contains multiple packages, but **`packages/coding-agent/`** is the pr
|
||||
- **NEVER use inline imports** - no `await import("./foo.js")`, no `import("pkg").Type` in type positions, no dynamic imports for types. Always use standard top-level imports.
|
||||
- NEVER remove or downgrade code to fix type errors from outdated dependencies; upgrade the dependency instead
|
||||
- Always ask before removing functionality or code that appears to be intentional
|
||||
- **NEVER use relative parent imports** (`../xxx`) — always use configured path aliases (e.g., `@/utils`, `~/components`)
|
||||
- **NEVER build prompts in code** — no inline strings, no template literals, no string concatenation. Prompts live in static `.md` files; use Handlebars for any dynamic content.
|
||||
- **Import static text files via Bun** — use `import content from "./prompt.md" with { type: "text" }` instead of `readFileSync`
|
||||
|
||||
@@ -312,7 +311,9 @@ for await (const chunk of stream) {
|
||||
```typescript
|
||||
// BAD: External dependency or custom implementation
|
||||
import { getWidth } from "get-east-asian-width";
|
||||
function visibleWidth(str: string) { /* custom logic */ }
|
||||
function visibleWidth(str: string) {
|
||||
/* custom logic */
|
||||
}
|
||||
|
||||
// GOOD: Bun builtin (handles ANSI, emoji, CJK)
|
||||
const width = Bun.stringWidth(text);
|
||||
@@ -323,7 +324,9 @@ const widthNoAnsi = Bun.stringWidth(text, { countAnsiEscapeCodes: false });
|
||||
|
||||
```typescript
|
||||
// BAD: Custom ANSI-aware wrapping
|
||||
function wrapTextWithAnsi(text: string, width: number) { /* complex SGR tracking */ }
|
||||
function wrapTextWithAnsi(text: string, width: number) {
|
||||
/* complex SGR tracking */
|
||||
}
|
||||
|
||||
// GOOD: Bun builtin
|
||||
const wrapped = Bun.wrapAnsi(text, width, {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import * as path from "node:path";
|
||||
import { jtdToTypeScript } from "@oh-my-pi/pi-coding-agent/tools/jtd-to-typescript";
|
||||
import { logger } from "@oh-my-pi/pi-utils";
|
||||
import Handlebars from "handlebars";
|
||||
import { CONFIG_DIR_NAME, getPromptsDir } from "../config";
|
||||
import { jtdToTypeScript } from "../tools/jtd-to-typescript";
|
||||
import { parseFrontmatter } from "../utils/frontmatter";
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,26 +6,26 @@
|
||||
import path from "node:path";
|
||||
import type { AgentEvent, ThinkingLevel } from "@oh-my-pi/pi-agent-core";
|
||||
import type { Api, Model, ToolChoice } from "@oh-my-pi/pi-ai";
|
||||
import type { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry";
|
||||
import { parseModelPattern } from "@oh-my-pi/pi-coding-agent/config/model-resolver";
|
||||
import { type PromptTemplate, renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates";
|
||||
import { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manager";
|
||||
import type { CustomTool } from "@oh-my-pi/pi-coding-agent/extensibility/custom-tools/types";
|
||||
import type { Skill } from "@oh-my-pi/pi-coding-agent/extensibility/skills";
|
||||
import { callTool } from "@oh-my-pi/pi-coding-agent/mcp/client";
|
||||
import type { MCPManager } from "@oh-my-pi/pi-coding-agent/mcp/manager";
|
||||
import { createAgentSession, discoverAuthStorage, discoverModels } from "@oh-my-pi/pi-coding-agent/sdk";
|
||||
import type { AgentSession, AgentSessionEvent } from "@oh-my-pi/pi-coding-agent/session/agent-session";
|
||||
import type { AuthStorage } from "@oh-my-pi/pi-coding-agent/session/auth-storage";
|
||||
import { SessionManager } from "@oh-my-pi/pi-coding-agent/session/session-manager";
|
||||
import type { ContextFileEntry } from "@oh-my-pi/pi-coding-agent/tools";
|
||||
import { jtdToJsonSchema } from "@oh-my-pi/pi-coding-agent/tools/jtd-to-json-schema";
|
||||
import { ToolAbortError } from "@oh-my-pi/pi-coding-agent/tools/tool-errors";
|
||||
import type { EventBus } from "@oh-my-pi/pi-coding-agent/utils/event-bus";
|
||||
import { logger, untilAborted } from "@oh-my-pi/pi-utils";
|
||||
import type { TSchema } from "@sinclair/typebox";
|
||||
import Ajv, { type ValidateFunction } from "ajv";
|
||||
import type { ModelRegistry } from "../config/model-registry";
|
||||
import { parseModelPattern } from "../config/model-resolver";
|
||||
import { type PromptTemplate, renderPromptTemplate } from "../config/prompt-templates";
|
||||
import { SettingsManager } from "../config/settings-manager";
|
||||
import type { CustomTool } from "../extensibility/custom-tools/types";
|
||||
import type { Skill } from "../extensibility/skills";
|
||||
import { callTool } from "../mcp/client";
|
||||
import type { MCPManager } from "../mcp/manager";
|
||||
import subagentSystemPromptTemplate from "../prompts/system/subagent-system-prompt.md" with { type: "text" };
|
||||
import { createAgentSession, discoverAuthStorage, discoverModels } from "../sdk";
|
||||
import type { AgentSession, AgentSessionEvent } from "../session/agent-session";
|
||||
import type { AuthStorage } from "../session/auth-storage";
|
||||
import { SessionManager } from "../session/session-manager";
|
||||
import type { ContextFileEntry } from "../tools";
|
||||
import { jtdToJsonSchema } from "../tools/jtd-to-json-schema";
|
||||
import { ToolAbortError } from "../tools/tool-errors";
|
||||
import type { EventBus } from "../utils/event-bus";
|
||||
import { subprocessToolRegistry } from "./subprocess-tool-registry";
|
||||
import {
|
||||
type AgentDefinition,
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import type { AgentTool } from "@oh-my-pi/pi-agent-core";
|
||||
import type { SettingsManager } from "@oh-my-pi/pi-coding-agent/config/settings-manager";
|
||||
import { logger } from "@oh-my-pi/pi-utils";
|
||||
import type { PromptTemplate } from "../config/prompt-templates";
|
||||
import type { BashInterceptorRule } from "../config/settings-manager";
|
||||
import type { BashInterceptorRule, SettingsManager } from "../config/settings-manager";
|
||||
import type { Skill } from "../extensibility/skills";
|
||||
import type { InternalUrlRouter } from "../internal-urls";
|
||||
import { getPreludeDocs, warmPythonEnvironment } from "../ipy/executor";
|
||||
|
||||
Reference in New Issue
Block a user