// offending code· 3 files flaggedpatterns: 12
--- install scripts ---
### postinstall
node scripts/postinstall.cjs
### prepublishOnly
npm run clean && npm run build
--- package/package.json (excerpt) ---
{
"name": "@phi-code-admin/phi-code",
"version": "0.76.13",
"description": "Coding agent CLI with persistent memory, sub-agents, intelligent routing, and orchestration",
"type": "module",
"piConfig": {
"name": "phi",
"configDir": ".phi"
},
"bin": {
"phi": "dist/cli.js"
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./hooks": {
"types": "./dist/core/hooks/index.d.ts",
"import": "./dist/core/hooks/index.js"
}
},
"files": [
"dist",
"docs",
"examples",
"skills",
"agents",
"extensions",
"README.md",
"LICENSE",
"CHANGELOG.md",
"scripts"
],
"scripts": {
"clean": "shx rm -rf dist",
"dev": "tsgo -p tsconfig.build.json --watch --preserveWatchOutput",
"build": "tsgo -p tsconfig.build.json && shx chmod +x dist/cli.js && npm run copy-assets",
"build:binary": "npm --prefix ../tui run build && npm --prefix ../ai run build && npm --prefix ../agent run build && npm run build && bun build --compile --external koffi ./dist/bun/cli.js --outfile dist/pi && npm run copy-binary-assets",
"copy-assets": "shx mkdir -p dist/modes/interactive/theme dist/core/export-html/vendor dist/core && shx cp src/modes/interactive/theme/*.json dist/modes/interactive/theme/ && shx cp src/core/default-models.json dist/core/ && shx cp src/core/export-html/template.html src/core/export-html/template.css src/core/export-html/template.js dist/core/export-html
--- package/scripts/postinstall.cjs (excerpt) ---
#!/usr/bin/env node
/**
* Post-install script: copies bundled extensions, agents, and skills
* to ~/.phi/agent/ and makes sigma packages resolvable from there.
*/
const { existsSync, mkdirSync, cpSync, readdirSync, symlinkSync, unlinkSync, readlinkSync } = require("fs");
const { join, dirname } = require("path");
const { homedir } = require("os");
const agentDir = join(homedir(), ".phi", "agent");
const packageDir = __dirname.replace(/[\\/]scripts$/, "");
// Opt-out / CI guard: skip the home-directory scaffolding under CI or sandbox
// installs (and when explicitly disabled) to avoid polluting ~/.phi there.
if (process.env.PHI_SKIP_POSTINSTALL || process.env.CI) {
process.exit(0);
}
// 1. Copy extensions, agents, skills
const copies = [
{ src: "extensions/phi", dest: join(agentDir, "extensions"), label: "extensions" },
{ src: "agents", dest: join(agentDir, "agents"), label: "agents" },
{ src: "skills", dest: join(agentDir, "skills"), label: "skills" },
];
for (const { src, dest, label } of copies) {
const srcDir = join(packageDir, src);
if (!existsSync(srcDir)) continue;
mkdirSync(dest, { recursive: true });
const files = readdirSync(srcDir);
let copied = 0;
const failures = [];
for (const file of files) {
try {
cpSync(join(srcDir, file), join(dest, file), { recursive: true, force: true });
copied++;
} catch (e) {
failures.push({ file, err: e && e.message ? e.message : String(e) });
}
}
if (copied > 0) console.log(
--- package/extensions/phi/benchmark.ts (excerpt) ---
/**
* Benchmark Extension - Production-grade model performance testing
*
* Tests AI models across 6 categories:
* 1. Code Generation — Write a function from a spec
* 2. Debugging — Find and fix a bug
* 3. Planning — Create an implementation plan
* 4. Tool Calling — Generate structured JSON output
* 5. Speed — Response latency measurement
* 6. Orchestration — Multi-step reasoning task
*
* Usage:
* - /benchmark — Run benchmark on current model
* - /benchmark all — Run on all available models
* - /benchmark results — Show saved results
* - /benchmark compare — Side-by-side model comparison
* - /benchmark clear — Clear all results
*/
import type { ExtensionAPI, ExtensionContext } from "phi-code";
import { writeFile, mkdir, readFile, access } from "node:fs/promises";
import { join } from "node:path";
import { homedir } from "node:os";
// ─── Types ───────────────────────────────────────────────────────────────
interface TestCase {
category: "code-gen" | "debug" | "planning" | "tool-calling" | "speed" | "orchestration";
name: string;
prompt: string;
validate: (response: string) => TestResult;
weight: number; // Score weight (1-3)
}
interface TestResult {
passed: boolean;
score: number; // 0-100
details: string;
}
interface ModelBenchmark {
modelId: string;
modelName: string;
provider: string;
timestamp: string;
categories: {
[key: string]: {
score: number;
timeMs: number;
details: string;
};
};
totalScor
--- dynamic destinations ---
→ coding-intl.dashscope.aliyuncs.com (via hostname-var)
→ opencode.ai (via hostname-var)