ultimate-pi 0.2.7 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/harness-eval/SKILL.md +1 -1
- package/.agents/skills/harness-governor/SKILL.md +2 -2
- package/.agents/skills/harness-spec/SKILL.md +1 -1
- package/.pi/PACKAGING.md +3 -2
- package/.pi/extensions/custom-header.ts +0 -17
- package/.pi/extensions/pi-model-router-harness.ts +42 -0
- package/.pi/extensions/policy-gate.ts +18 -0
- package/.pi/extensions/provider-payload-sanitize.ts +66 -0
- package/.pi/extensions/sentrux-rules-sync.ts +0 -18
- package/.pi/harness/README.md +3 -2
- package/.pi/harness/docs/adrs/0004-defer-ci-agent-smoke.md +1 -1
- package/.pi/harness/docs/adrs/0006-sentrux-dual-layer.md +1 -1
- package/.pi/harness/docs/adrs/0009-sentrux-rules-lifecycle.md +2 -2
- package/.pi/harness/evals/smoke/README.md +1 -1
- package/.pi/harness/evolution/README.md +1 -1
- package/.pi/harness/evolution/chaos-drill.md +1 -1
- package/.pi/prompts/harness-setup.md +42 -35
- package/.pi/scripts/README.md +25 -9
- package/.pi/scripts/harness-cli-verify.sh +4 -2
- package/.pi/scripts/harness-seed-project-contracts.mjs +49 -0
- package/.pi/scripts/harness-sync-model-router.mjs +84 -0
- package/.pi/scripts/harness-verify.mjs +5 -3
- package/.pi/scripts/sentrux-rules-sync.mjs +2 -2
- package/.pi/scripts/vendor-sync-pi-model-router.sh +47 -0
- package/.pi/settings.example.json +0 -1
- package/.sentrux/rules.toml +1 -1
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +62 -0
- package/README.md +1 -1
- package/THIRD_PARTY_NOTICES.md +8 -0
- package/biome.json +2 -1
- package/package.json +9 -10
- package/vendor/pi-model-router/.prettierignore +4 -0
- package/vendor/pi-model-router/.prettierrc +5 -0
- package/vendor/pi-model-router/AGENTS.md +39 -0
- package/vendor/pi-model-router/LICENSE +21 -0
- package/vendor/pi-model-router/README.md +99 -0
- package/vendor/pi-model-router/UPSTREAM_PIN.md +8 -0
- package/vendor/pi-model-router/docs/ARCHITECTURE.md +54 -0
- package/vendor/pi-model-router/extensions/commands.ts +720 -0
- package/vendor/pi-model-router/extensions/config.ts +348 -0
- package/vendor/pi-model-router/extensions/constants.ts +1 -0
- package/vendor/pi-model-router/extensions/index.ts +457 -0
- package/vendor/pi-model-router/extensions/provider.ts +529 -0
- package/vendor/pi-model-router/extensions/routing.ts +416 -0
- package/vendor/pi-model-router/extensions/state.ts +49 -0
- package/vendor/pi-model-router/extensions/types.ts +86 -0
- package/vendor/pi-model-router/extensions/ui.ts +130 -0
- package/vendor/pi-model-router/model-router.example.json +48 -0
- package/vendor/pi-model-router/package.json +48 -0
- package/vendor/pi-model-router/tsconfig.json +16 -0
- package/.pi/extensions/model-router-bootstrap.ts +0 -174
- package/.sentrux/.harness-rules-meta.json +0 -5
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"defaultProfile": "auto",
|
|
3
|
+
"debug": false,
|
|
4
|
+
"classifierModel": "google/gemini-flash-latest",
|
|
5
|
+
"phaseBias": 0.5,
|
|
6
|
+
"maxSessionBudget": 1.0,
|
|
7
|
+
"largeContextThreshold": 100000,
|
|
8
|
+
"rules": [
|
|
9
|
+
{
|
|
10
|
+
"matches": ["deploy", "production", "release"],
|
|
11
|
+
"tier": "high",
|
|
12
|
+
"reason": "Safety check for production tasks"
|
|
13
|
+
},
|
|
14
|
+
{ "matches": "changelog", "tier": "low" }
|
|
15
|
+
],
|
|
16
|
+
"profiles": {
|
|
17
|
+
"auto": {
|
|
18
|
+
"high": {
|
|
19
|
+
"model": "openai/gpt-5.4-pro",
|
|
20
|
+
"thinking": "high",
|
|
21
|
+
"fallbacks": ["anthropic/claude-3-5-sonnet-20241022"]
|
|
22
|
+
},
|
|
23
|
+
"medium": { "model": "google/gemini-flash-latest", "thinking": "medium" },
|
|
24
|
+
"low": { "model": "openai/gpt-5.4-nano", "thinking": "low" }
|
|
25
|
+
},
|
|
26
|
+
"cheap": {
|
|
27
|
+
"high": { "model": "google/gemini-flash-latest", "thinking": "low" },
|
|
28
|
+
"medium": { "model": "openai/gpt-5.4-nano", "thinking": "off" },
|
|
29
|
+
"low": { "model": "google/gemini-flash-lite-latest", "thinking": "off" }
|
|
30
|
+
},
|
|
31
|
+
"deep": {
|
|
32
|
+
"high": { "model": "openai/o1-preview", "thinking": "xhigh" },
|
|
33
|
+
"medium": { "model": "openai/gpt-5.4-pro", "thinking": "medium" },
|
|
34
|
+
"low": { "model": "google/gemini-flash-latest", "thinking": "low" }
|
|
35
|
+
},
|
|
36
|
+
"anthropic": {
|
|
37
|
+
"high": {
|
|
38
|
+
"model": "anthropic/claude-3-5-sonnet-20241022",
|
|
39
|
+
"thinking": "high"
|
|
40
|
+
},
|
|
41
|
+
"medium": {
|
|
42
|
+
"model": "anthropic/claude-3-5-sonnet-20241022",
|
|
43
|
+
"thinking": "medium"
|
|
44
|
+
},
|
|
45
|
+
"low": { "model": "anthropic/claude-3-haiku-20240307", "thinking": "low" }
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yeliu84/pi-model-router",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Intelligent per-turn model router extension for the pi coding agent",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"pi-package",
|
|
8
|
+
"pi",
|
|
9
|
+
"model-router",
|
|
10
|
+
"llm",
|
|
11
|
+
"coding-agent",
|
|
12
|
+
"extension"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "Ye Liu",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/yeliu84/pi-model-router.git"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/yeliu84/pi-model-router#readme",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/yeliu84/pi-model-router/issues"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": "./extensions/index.ts"
|
|
26
|
+
},
|
|
27
|
+
"pi": {
|
|
28
|
+
"extensions": [
|
|
29
|
+
"./extensions/index.ts"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"tsc": "tsc --noEmit",
|
|
34
|
+
"build": "tsc",
|
|
35
|
+
"prepublishOnly": "npm run tsc"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@mariozechner/pi-agent-core": "*",
|
|
39
|
+
"@mariozechner/pi-ai": "*",
|
|
40
|
+
"@mariozechner/pi-coding-agent": "*",
|
|
41
|
+
"@mariozechner/pi-tui": "*",
|
|
42
|
+
"@sinclair/typebox": "*"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"prettier": "^3.8.1",
|
|
46
|
+
"typescript": "^6.0.2"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"allowSyntheticDefaultImports": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"noEmit": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["extensions/**/*"]
|
|
16
|
+
}
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Ensures .pi/model-router.json exists before pi-model-router reads config at
|
|
3
|
-
* extension init (which otherwise falls back to openai/gpt-5.4-pro).
|
|
4
|
-
*
|
|
5
|
-
* Runs synchronously in the extension factory so dotenv-loader can run first
|
|
6
|
-
* (alphabetically: dotenv-loader < model-router-bootstrap < sentrux / router pkg).
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
10
|
-
import { join } from "node:path";
|
|
11
|
-
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
12
|
-
|
|
13
|
-
const ROUTER_PATH = ".pi/model-router.json";
|
|
14
|
-
|
|
15
|
-
function model(prefix: string, name: string): string {
|
|
16
|
-
return `${prefix}/${name}`;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function buildRouterConfig(): Record<string, unknown> | null {
|
|
20
|
-
const hasOpenCode = process.env.OPENAI_API_BASE?.includes("opencode.ai");
|
|
21
|
-
const hasOpenAI = !!process.env.OPENAI_API_KEY;
|
|
22
|
-
const hasAnthropic = !!process.env.ANTHROPIC_API_KEY;
|
|
23
|
-
const hasGoogle = !!process.env.GOOGLE_API_KEY;
|
|
24
|
-
|
|
25
|
-
if (!hasOpenCode && !hasOpenAI && !hasAnthropic && !hasGoogle) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const highModel = hasOpenCode
|
|
30
|
-
? model("opencode-go", "deepseek-v4-pro")
|
|
31
|
-
: hasAnthropic
|
|
32
|
-
? "anthropic/claude-sonnet-4-20250514"
|
|
33
|
-
: hasGoogle
|
|
34
|
-
? "google/gemini-2.5-flash-001"
|
|
35
|
-
: hasOpenAI
|
|
36
|
-
? model("openai", "gpt-4o")
|
|
37
|
-
: null;
|
|
38
|
-
|
|
39
|
-
const mediumModel = hasOpenCode
|
|
40
|
-
? model("opencode-go", "qwen3.6-plus")
|
|
41
|
-
: hasAnthropic
|
|
42
|
-
? "anthropic/claude-sonnet-4-20250514"
|
|
43
|
-
: hasGoogle
|
|
44
|
-
? "google/gemini-flash-latest"
|
|
45
|
-
: hasOpenAI
|
|
46
|
-
? model("openai", "gpt-4o-mini")
|
|
47
|
-
: null;
|
|
48
|
-
|
|
49
|
-
const lowModel = hasOpenCode
|
|
50
|
-
? model("opencode-go", "deepseek-v4-flash")
|
|
51
|
-
: hasAnthropic
|
|
52
|
-
? "anthropic/claude-3-5-haiku-20241022"
|
|
53
|
-
: hasGoogle
|
|
54
|
-
? "google/gemini-flash-lite-latest"
|
|
55
|
-
: hasOpenAI
|
|
56
|
-
? model("openai", "gpt-4o-mini")
|
|
57
|
-
: null;
|
|
58
|
-
|
|
59
|
-
if (!highModel || !mediumModel || !lowModel) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const fallbacks: string[] = [];
|
|
64
|
-
if (hasAnthropic && !highModel.startsWith("anthropic/")) {
|
|
65
|
-
fallbacks.push("anthropic/claude-sonnet-4-20250514");
|
|
66
|
-
}
|
|
67
|
-
if (hasGoogle && !highModel.startsWith("google/")) {
|
|
68
|
-
fallbacks.push("google/gemini-flash-latest");
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
defaultProfile: "auto",
|
|
73
|
-
debug: false,
|
|
74
|
-
classifierModel: mediumModel,
|
|
75
|
-
phaseBias: 0.5,
|
|
76
|
-
maxSessionBudget: 1.0,
|
|
77
|
-
largeContextThreshold: 100000,
|
|
78
|
-
rules: [
|
|
79
|
-
{
|
|
80
|
-
matches: ["deploy", "production", "release"],
|
|
81
|
-
tier: "high",
|
|
82
|
-
reason: "Safety check for production tasks",
|
|
83
|
-
},
|
|
84
|
-
{ matches: "changelog", tier: "low" },
|
|
85
|
-
],
|
|
86
|
-
profiles: {
|
|
87
|
-
auto: {
|
|
88
|
-
high: { model: highModel, thinking: "high", fallbacks },
|
|
89
|
-
medium: { model: mediumModel, thinking: "medium" },
|
|
90
|
-
low: { model: lowModel, thinking: "low" },
|
|
91
|
-
},
|
|
92
|
-
cheap: {
|
|
93
|
-
high: { model: mediumModel, thinking: "low" },
|
|
94
|
-
medium: { model: lowModel, thinking: "off" },
|
|
95
|
-
low: { model: lowModel, thinking: "off" },
|
|
96
|
-
},
|
|
97
|
-
deep: {
|
|
98
|
-
high: { model: highModel, thinking: "xhigh", fallbacks },
|
|
99
|
-
medium: { model: mediumModel, thinking: "medium" },
|
|
100
|
-
low: { model: lowModel, thinking: "low" },
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function ensureModelRouterConfig(cwd: string): boolean {
|
|
107
|
-
const projectPath = join(cwd, ROUTER_PATH);
|
|
108
|
-
// #region agent log
|
|
109
|
-
fetch("http://127.0.0.1:7928/ingest/a5d40896-34cb-4f12-97db-df7ada0b22f0", {
|
|
110
|
-
method: "POST",
|
|
111
|
-
headers: {
|
|
112
|
-
"Content-Type": "application/json",
|
|
113
|
-
"X-Debug-Session-Id": "7737a8",
|
|
114
|
-
},
|
|
115
|
-
body: JSON.stringify({
|
|
116
|
-
sessionId: "7737a8",
|
|
117
|
-
hypothesisId: "A",
|
|
118
|
-
location: "model-router-bootstrap.ts:ensure",
|
|
119
|
-
message: "router bootstrap check",
|
|
120
|
-
data: {
|
|
121
|
-
projectPath,
|
|
122
|
-
exists: existsSync(projectPath),
|
|
123
|
-
hasOpenCode: !!process.env.OPENAI_API_BASE?.includes("opencode.ai"),
|
|
124
|
-
hasOpenAI: !!process.env.OPENAI_API_KEY,
|
|
125
|
-
},
|
|
126
|
-
timestamp: Date.now(),
|
|
127
|
-
}),
|
|
128
|
-
}).catch(() => {});
|
|
129
|
-
// #endregion
|
|
130
|
-
|
|
131
|
-
if (existsSync(projectPath)) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const config = buildRouterConfig();
|
|
136
|
-
if (!config) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
mkdirSync(join(cwd, ".pi"), { recursive: true });
|
|
141
|
-
writeFileSync(projectPath, `${JSON.stringify(config, null, 2)}\n`);
|
|
142
|
-
|
|
143
|
-
// #region agent log
|
|
144
|
-
fetch("http://127.0.0.1:7928/ingest/a5d40896-34cb-4f12-97db-df7ada0b22f0", {
|
|
145
|
-
method: "POST",
|
|
146
|
-
headers: {
|
|
147
|
-
"Content-Type": "application/json",
|
|
148
|
-
"X-Debug-Session-Id": "7737a8",
|
|
149
|
-
},
|
|
150
|
-
body: JSON.stringify({
|
|
151
|
-
sessionId: "7737a8",
|
|
152
|
-
hypothesisId: "A",
|
|
153
|
-
location: "model-router-bootstrap.ts:write",
|
|
154
|
-
message: "wrote model-router.json",
|
|
155
|
-
data: {
|
|
156
|
-
high: (config.profiles as { auto: { high: { model: string } } }).auto
|
|
157
|
-
.high.model,
|
|
158
|
-
},
|
|
159
|
-
timestamp: Date.now(),
|
|
160
|
-
}),
|
|
161
|
-
}).catch(() => {});
|
|
162
|
-
// #endregion
|
|
163
|
-
|
|
164
|
-
return true;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export default function modelRouterBootstrap(_pi: ExtensionAPI) {
|
|
168
|
-
const wrote = ensureModelRouterConfig(process.cwd());
|
|
169
|
-
if (wrote) {
|
|
170
|
-
console.warn(
|
|
171
|
-
"[ultimate-pi] Created .pi/model-router.json from detected providers (avoids gpt-5.4-pro fallback). Run /reload if router was already loaded.",
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
}
|