--- install scripts ---
### prepack
bun scripts/generate-docs-index.ts
--- package/package.json (excerpt) ---
{
"type": "module",
"name": "@yuechou/pi-coding-agent",
"version": "15.8.3-patched.6",
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
"homepage": "https://omp.sh",
"author": "Can Boluk",
"contributors": [
"Mario Zechner"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/can1357/oh-my-pi.git",
"directory": "packages/coding-agent"
},
"bugs": {
"url": "https://github.com/can1357/oh-my-pi/issues"
},
"keywords": [
"coding-agent",
"ai",
"llm",
"cli",
"tui",
"agent"
],
"main": "./src/index.ts",
"types": "./src/index.ts",
"bin": {
"omp": "src/cli.ts"
},
"scripts": {
"build": "bun scripts/build-binary.ts",
"check": "biome check . && bun run check:types",
"check:types": "tsgo -p tsconfig.json --noEmit",
"lint": "biome lint .",
"test": "bun test --parallel",
"fix": "biome check --write --unsafe . && bun run format-prompts && bun run generate-docs-index",
"fmt": "biome format --write . && bun run format-prompts",
"format-prompts": "bun scripts/format-prompts.ts",
"generate-docs-index": "bun scripts/generate-docs-index.ts",
"prepack": "bun scripts/generate-docs-index.ts",
"generate-template": "bun scripts/generate-template.ts"
},
"dependencies": {
"@agentclientprotocol/sdk": "0.22.1",
"@babel/parser": "^7.29.7",
"@mozilla/readability": "^0.6.0",
"@yuechou/hashline": "15.8.3-patched.6",
"@yuechou/omp-stats": "15.8.3-patched.6",
"@yue
--- package/src/cli.ts (excerpt) ---
#!/usr/bin/env bun
// Strip macOS malloc-stack-logging vars in the parent entrypoint, before any
// subprocess/worker spawn. libmalloc reads MallocStackLogging /
// MallocStackLoggingNoCompact during malloc bootstrap (pre-main) in every child
// and warns when they're present but set to "off"; a child cannot suppress its
// own warning, so the only fix is to keep them out of the inherited env here.
// (They must be unset, not set — presence is the trigger.)
try {
delete process.env.MallocStackLogging;
delete process.env.MallocStackLoggingNoCompact;
} catch {}
/**
* CLI entry point — registers all commands explicitly and delegates to the
* lightweight CLI runner from pi-utils.
*/
import { type CliConfig, run } from "@yuechou/pi-utils/cli";
import { APP_NAME, MIN_BUN_VERSION, VERSION } from "@yuechou/pi-utils/dirs";
import { commands, isSubcommand } from "./cli-commands";
if (Bun.semver.order(Bun.version, MIN_BUN_VERSION) < 0) {
process.stderr.write(
`error: Bun runtime must be >= ${MIN_BUN_VERSION} (found v${Bun.version}). Please upgrade: bun upgrade\n`,
);
process.exit(1);
}
process.title = APP_NAME;
async function showHelp(config: CliConfig): Promise<void> {
const { renderRootHelp } = await import("@yuechou/pi-utils/cli");
const { getExtraHelpText } = await import("./cli/args");
renderRootHelp(config);
const extra = getExtraHelpText();
if (extra.trim().length > 0) {
process.stdout.write(`\n${extra}\n`);
}
}
/**
* Smoke-test entry. Spawns bundled worker
--- package/src/config.ts (excerpt) ---
import * as fs from "node:fs";
import * as os from "node:os";
import * as path from "node:path";
import { CONFIG_DIR_NAME, getConfigAgentDirName, getProjectDir } from "@yuechou/pi-utils";
import { expandTilde } from "./tools/path-utils";
export * from "./config/config-file";
const priorityList = [
{ dir: CONFIG_DIR_NAME, globalAgentDir: getConfigAgentDirName },
{ dir: ".claude" },
{ dir: ".codex" },
{ dir: ".gemini" },
];
// =============================================================================
// Package Directory (for optional external docs/examples)
// =============================================================================
/**
* Walk up from `startDir` looking for a `package.json`. Returns the directory
* containing the marker, or `undefined` when the walk hits the filesystem root
* without finding one.
*
* Exported for unit-testing the resolution contract from arbitrary start
* directories (notably the `bun --compile` case where `import.meta.dir`
* resolves to `/$bunfs/root` and no owning package is locatable — issue
* #1423). Production callers should use {@link getPackageDir} instead.
*/
export function walkUpForPackageDir(startDir: string): string | undefined {
let dir = startDir;
while (dir !== path.dirname(dir)) {
if (fs.existsSync(path.join(dir, "package.json"))) {
return dir;
}
dir = path.dirname(dir);
}
return undefined;
}
/**
* Get the base directory for resolving optional package assets (docs, examples, CHANGELOG.md).