Documentation
¶
Overview ¶
pi: src/config.ts — install/package detection, package asset paths, app config constants, and user config paths.
Segment deviations:
- APP_NAME / PACKAGE_NAME / VERSION: pi reads pkg.piConfig from package.json (build-time injection); pig is a Go binary with no package.json — the constants are pinned. VERSION ldflags injection arrives with the packaging batch (Phase 8) if ever needed.
- Package Detection (isBunBinary/isBunRuntime) and the whole Install Method / self-update segment (detectInstallMethod, getSelfUpdateCommand, getUpdateInstruction, ...) are Node package-manager machinery (npm / pnpm / yarn / bun) with no Go counterpart: pig ships as a single static binary, where "update" means re-downloading from releases. Deferred to the packaging batch; the segment position is kept below.
- getPackageDir: pi distinguishes Bun binary (dirname(execPath)) vs Node (findNodePackageDir(__dirname)); pig is always a compiled binary → dirname(os.Executable()), with the PI_PACKAGE_DIR override kept. The src/dist distinction in getThemesDir/getExportTemplateDir/ getInteractiveAssetsDir collapses to the Bun-binary branch shape (assets shipped next to the executable).
- process.env access is direct os.Getenv.
Package codingagent corresponds to pi's packages/coding-agent/src.
Index ¶
- Constants
- func ExpandTildePath(path string) string
- func FindNodePackageDir(startDir string) string
- func GetAgentDir() string
- func GetAuthPath() string
- func GetBinDir() string
- func GetBundledInteractiveAssetPath(name string) string
- func GetChangelogPath() string
- func GetCustomThemesDir() string
- func GetDebugLogPath() string
- func GetDocsPath() string
- func GetExamplesPath() string
- func GetExportTemplateDir() string
- func GetInteractiveAssetsDir() string
- func GetMCPPath() string
- func GetModelsPath() string
- func GetPackageDir() string
- func GetPackageJsonPath() string
- func GetPromptsDir() string
- func GetReadmePath() string
- func GetSessionsDir() string
- func GetSettingsPath() string
- func GetShareViewerURL(gistID string) string
- func GetThemesDir() string
- func GetToolsDir() string
- func NormalizePackageDir(path string) string
Constants ¶
const AppName = "pig"
AppName is the product name (pi: APP_NAME = piConfig.name || "pi"; pig deviates: "pig" — per user decision 2026-09-10, pig rebrands its own product name instead of keeping pi's).
const AppTitle = "π"
AppTitle is the display title (pi: APP_TITLE = piConfig.name ? APP_NAME : "π"; pig has no piConfig rename hook → the "π" branch).
const ConfigDirName = ".pig"
ConfigDirName is the per-project config directory (pi: CONFIG_DIR_NAME = piConfig.configDir || ".pi"; pig deviates: ".pig" — per user decision 2026-09-10, pig uses its own config dir instead of sharing pi's).
const EnvAgentDir = "PIG_CODING_AGENT_DIR"
EnvAgentDir is the env var overriding the agent config dir (pi: ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`; pig deviates: PIG_ prefix — no data migration, pig has its own config dir).
const EnvSessionDir = "PIG_CODING_AGENT_SESSION_DIR"
EnvSessionDir is the env var overriding the session dir (pi: ENV_SESSION_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_SESSION_DIR`).
const IssuesURL = "https://github.com/ZoroSpace/pig/issues"
IssuesURL is the pig issue tracker (pig-only: pi has no counterpart — pig removed /bug and the Pi Radius bug-report chain per user decision 2026-09-30; crash hints and error hints point here instead, see docs/fix/2026-09-30-remove-bug-command.md).
const PackageName = "@earendil-works/pi-coding-agent"
PackageName is the package identity (pi: PACKAGE_NAME = pkg.name || "@earendil-works/pi-coding-agent"; pig pins the pi value — the Go module has no npm name).
const Version = "1.0.1"
Version is the product version (pi: VERSION = pkg.version || "0.0.0"; pig pins the pi baseline version it tracks — user decision 2026-09-10; ldflags injection arrives with the packaging batch). Bump discipline: MUST be updated in the same batch as every pi baseline sync (S7 missed the v0.86.1 bump; pinned by TestVersionTracksPiBaseline).
Variables ¶
This section is empty.
Functions ¶
func ExpandTildePath ¶
ExpandTildePath expands a leading ~ (pi: expandTildePath → normalizePath's tilde expansion).
func FindNodePackageDir ¶
FindNodePackageDir returns the base directory for resolving package assets (pi: findNodePackageDir). Kept for parity: walks up from startDir for a package.json, skipping Bun binary metadata copied into dist/. A Go binary typically has no package.json anywhere, so this returns startDir.
func GetAgentDir ¶
func GetAgentDir() string
GetAgentDir returns the agent config directory (pi: getAgentDir).
func GetAuthPath ¶
func GetAuthPath() string
GetAuthPath returns the path to auth.json (pi: getAuthPath).
func GetBinDir ¶
func GetBinDir() string
GetBinDir returns the managed binaries directory (pi: getBinDir).
func GetBundledInteractiveAssetPath ¶
GetBundledInteractiveAssetPath returns the path to one bundled interactive asset (pi: getBundledInteractiveAssetPath).
func GetChangelogPath ¶
func GetChangelogPath() string
GetChangelogPath returns the path to CHANGELOG.md (pi: getChangelogPath).
func GetCustomThemesDir ¶
func GetCustomThemesDir() string
GetCustomThemesDir returns the user's custom themes directory (pi: getCustomThemesDir).
func GetDebugLogPath ¶
func GetDebugLogPath() string
GetDebugLogPath returns the path to the debug log file (pi: getDebugLogPath).
func GetDocsPath ¶
func GetDocsPath() string
GetDocsPath returns the path to the docs directory (pi: getDocsPath).
func GetExamplesPath ¶
func GetExamplesPath() string
GetExamplesPath returns the path to the examples directory (pi: getExamplesPath).
func GetExportTemplateDir ¶
func GetExportTemplateDir() string
GetExportTemplateDir returns the HTML export template directory (pi: getExportTemplateDir, Bun-binary branch shape: export-html/ next to the executable).
func GetInteractiveAssetsDir ¶
func GetInteractiveAssetsDir() string
GetInteractiveAssetsDir returns the built-in interactive assets directory (pi: getInteractiveAssetsDir, Bun-binary branch shape: assets/ next to the executable).
func GetMCPPath ¶ added in v1.0.0
func GetMCPPath() string
GetMCPPath returns the path to the user-level mcp.json (pig-only; pi has no native MCP).
func GetModelsPath ¶
func GetModelsPath() string
GetModelsPath returns the path to models.json (pi: getModelsPath).
func GetPackageDir ¶
func GetPackageDir() string
GetPackageDir returns the directory the executable ships in (pi: getPackageDir). PI_PACKAGE_DIR overrides (useful for Nix/Guix where store paths tokenize poorly).
func GetPackageJsonPath ¶
func GetPackageJsonPath() string
GetPackageJsonPath returns the path to package.json (pi: getPackageJsonPath). pig has no package.json; kept for path parity.
func GetPromptsDir ¶
func GetPromptsDir() string
GetPromptsDir returns the path to the prompt templates directory (pi: getPromptsDir).
func GetReadmePath ¶
func GetReadmePath() string
GetReadmePath returns the path to README.md (pi: getReadmePath; path.resolve → absolute).
func GetSessionsDir ¶
func GetSessionsDir() string
GetSessionsDir returns the root directory holding all per-project session directories (pi: getSessionsDir).
func GetSettingsPath ¶
func GetSettingsPath() string
GetSettingsPath returns the path to settings.json (pi: getSettingsPath).
func GetShareViewerURL ¶
GetShareViewerURL returns the share viewer URL for a gist ID (pi: getShareViewerUrl).
func GetThemesDir ¶
func GetThemesDir() string
GetThemesDir returns the built-in themes directory (pi: getThemesDir, Bun-binary branch shape: theme/ next to the executable).
func GetToolsDir ¶
func GetToolsDir() string
GetToolsDir returns the path to the tools directory (pi: getToolsDir).
func NormalizePackageDir ¶
NormalizePackageDir normalizes a package dir override (pi: normalizePath(envDir) → utils/paths.ts; pig uses the shared tilde/URL expansion).
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package assets embeds the coding-agent binary assets (pi: files shipped next to the Bun-compiled binary — theme/ etc.; pig embeds them so the single static binary is self-contained).
|
Package assets embeds the coding-agent binary assets (pi: files shipped next to the Bun-compiled binary — theme/ etc.; pig embeds them so the single static binary is self-contained). |
|
pi: src/cli/args.ts — CLI argument parsing and help display.
|
pi: src/cli/args.ts — CLI argument parsing and help display. |
|
Package client corresponds to pi's packages/coding-agent/src/client.
|
Package client corresponds to pi's packages/coding-agent/src/client. |
|
pi: src/core/agent-session.ts — AgentSession, the core abstraction for agent lifecycle and session management shared between all run modes (interactive, print, rpc).
|
pi: src/core/agent-session.ts — AgentSession, the core abstraction for agent lifecycle and session management shared between all run modes (interactive, print, rpc). |
|
compaction
Package compaction corresponds to pi's packages/coding-agent/src/core/compaction.
|
Package compaction corresponds to pi's packages/coding-agent/src/core/compaction. |
|
exporthtml
ansi_to_html.go (pi: core/export-html/ansi-to-html.ts, v0.86.0)
|
ansi_to_html.go (pi: core/export-html/ansi-to-html.ts, v0.86.0) |
|
tools
pi: src/core/tools/bash.ts — the coding-agent shell tool (shared by bash and powershell via createShellToolDefinition).
|
pi: src/core/tools/bash.ts — the coding-agent shell tool (shared by bash and powershell via createShellToolDefinition). |
|
Package extensions corresponds to pi's packages/coding-agent/src/extensions.
|
Package extensions corresponds to pi's packages/coding-agent/src/extensions. |
|
Package modes corresponds to pi's packages/coding-agent/src/modes.
|
Package modes corresponds to pi's packages/coding-agent/src/modes. |
|
interactive
chat_viewport.go (pi: modes/interactive/chat-viewport.ts, v0.85.1) — shared fullscreen transcript and fixed input-dock layout.
|
chat_viewport.go (pi: modes/interactive/chat-viewport.ts, v0.85.1) — shared fullscreen transcript and fixed input-dock layout. |
|
interactive/components
armin.go (pi: components/armin.ts) — "Armin says hi!" easter egg with animated half-block XBM art and 7 random effects.
|
armin.go (pi: components/armin.ts) — "Armin says hi!" easter egg with animated half-block XBM art and 7 random effects. |
|
interactive/theme
fs_watch.go (pi: src/modes/interactive/theme — theme file watching).
|
fs_watch.go (pi: src/modes/interactive/theme — theme file watching). |
|
rpc
Package rpc corresponds to pi's packages/coding-agent/src/modes/rpc.
|
Package rpc corresponds to pi's packages/coding-agent/src/modes/rpc. |
|
Package server corresponds to pi's packages/coding-agent/src/server.
|
Package server corresponds to pi's packages/coding-agent/src/server. |
|
pi: src/utils/ansi.ts — strip ANSI escape sequences.
|
pi: src/utils/ansi.ts — strip ANSI escape sequences. |