@xynogen/pix-optimizer 1.1.12 → 1.1.14
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/README.md +17 -2
- package/package.json +3 -2
- package/src/opt.ts +1 -1
- package/src/persist.ts +15 -7
- package/src/rtk.ts +1 -1
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ There is no text-arg form: the overlay is the only UI. Selecting a value calls
|
|
|
21
21
|
the tool's `run()` handler, which persists the new value and repaints the
|
|
22
22
|
shared status cell. Headless/test fallbacks print a plain status summary.
|
|
23
23
|
|
|
24
|
-
State persists to `~/.pi/agent/optimizer.json` (caveman/rtk/toon/ponytail).
|
|
24
|
+
State persists to `~/.pi/agent/optimizer.json` (caveman/rtk/toon/ponytail). **Initial values** for a new session can be set in the `optimizer` section of `~/.pi/agent/pix.json` — the runtime toggle via `/optimizer` still persists changes to `optimizer.json` as before.
|
|
25
25
|
|
|
26
26
|
## Status bar
|
|
27
27
|
|
|
@@ -118,6 +118,21 @@ works. Validation, error handling, security, and accessibility are never cut.
|
|
|
118
118
|
**No install required** — pure prompt injection, no external binary or PATH
|
|
119
119
|
dependency (unlike RTK and TOON).
|
|
120
120
|
|
|
121
|
+
## Configuration via `pix.json`
|
|
122
|
+
|
|
123
|
+
Set the initial optimizer state for new sessions in `~/.pi/agent/pix.json`. These values are applied once at session start; subsequent changes via `/optimizer` persist to `optimizer.json` and take precedence.
|
|
124
|
+
|
|
125
|
+
```jsonc
|
|
126
|
+
{
|
|
127
|
+
"optimizer": {
|
|
128
|
+
"caveman": "lite", // off | lite | full | ultra | micro
|
|
129
|
+
"rtk": true,
|
|
130
|
+
"toon": false,
|
|
131
|
+
"ponytail": "off" // off | lite | full | ultra
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
121
136
|
## Installation
|
|
122
137
|
|
|
123
138
|
```bash
|
|
@@ -141,7 +156,7 @@ pi install npm:@xynogen/pix-optimizer
|
|
|
141
156
|
| `src/rtk.ts` | RTK prompt + bash command rewriting |
|
|
142
157
|
| `src/json.ts` | jq+TOON guidance, heuristics, system-prompt injection |
|
|
143
158
|
| `src/ponytail.ts` | Ponytail logic, levels, prompt |
|
|
144
|
-
| `src/persist.ts` | Disk-backed `~/.pi/agent/optimizer.json` persistence
|
|
159
|
+
| `src/persist.ts` | Disk-backed `~/.pi/agent/optimizer.json` persistence; seeds initial state from `pix.json` |
|
|
145
160
|
| `src/tool-result-filter.ts` | Strips model-guidance warnings from tool_result |
|
|
146
161
|
|
|
147
162
|
Each tool registers its own lifecycle hooks and exposes an `OptimizerHandle`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xynogen/pix-optimizer",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.14",
|
|
4
4
|
"description": "Performance optimization suite for Pi Coding Agent - caveman mode + RTK tool rewriting + jq/TOON JSON compression + ponytail lazy-dev mode",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@xynogen/pix-pretty": "^1.7.9"
|
|
51
|
+
"@xynogen/pix-pretty": "^1.7.9",
|
|
52
|
+
"@xynogen/pix-data": "workspace:*"
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|
|
54
55
|
"@earendil-works/pi-coding-agent": "*",
|
package/src/opt.ts
CHANGED
|
@@ -136,7 +136,7 @@ export function registerOptCommand(
|
|
|
136
136
|
const values = handles[tool].values;
|
|
137
137
|
const cur = values.indexOf(handles[tool].current());
|
|
138
138
|
const next = (cur + direction + values.length) % values.length;
|
|
139
|
-
handles[tool].run(values[next]
|
|
139
|
+
handles[tool].run(values[next] ?? "", ctx);
|
|
140
140
|
};
|
|
141
141
|
|
|
142
142
|
const move = (direction: -1 | 1) => {
|
package/src/persist.ts
CHANGED
|
@@ -12,29 +12,37 @@
|
|
|
12
12
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
13
13
|
import { dirname, join } from "node:path";
|
|
14
14
|
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
15
|
+
import { pixConfig } from "@xynogen/pix-data/pix-config";
|
|
15
16
|
import type { OptimizerTool } from "./status.ts";
|
|
16
17
|
|
|
17
|
-
type
|
|
18
|
+
type OptimizerFileConfig = Partial<Record<OptimizerTool, string>>;
|
|
18
19
|
|
|
19
20
|
function getStatePath(): string {
|
|
20
21
|
return join(getAgentDir(), "optimizer.json");
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
function
|
|
24
|
+
function readFile(): OptimizerFileConfig {
|
|
24
25
|
try {
|
|
25
26
|
const sp = getStatePath();
|
|
26
27
|
if (!existsSync(sp)) return {};
|
|
27
|
-
const raw = JSON.parse(readFileSync(sp, "utf-8")) as
|
|
28
|
+
const raw = JSON.parse(readFileSync(sp, "utf-8")) as OptimizerFileConfig;
|
|
28
29
|
return raw && typeof raw === "object" ? raw : {};
|
|
29
30
|
} catch {
|
|
30
|
-
// Missing, corrupt, or no getAgentDir (tests/headless) — start clean.
|
|
31
31
|
return {};
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Read a single tool's persisted value.
|
|
37
|
+
* Precedence: optimizer.json (runtime toggle) → pix.json → undefined
|
|
38
|
+
*/
|
|
36
39
|
export function loadOptValue(tool: OptimizerTool): string | undefined {
|
|
37
|
-
|
|
40
|
+
const fromFile = readFile()[tool];
|
|
41
|
+
if (fromFile !== undefined) return fromFile;
|
|
42
|
+
// Fall back to pix.json
|
|
43
|
+
const pix = pixConfig().optimizer;
|
|
44
|
+
const val = pix[tool as keyof typeof pix];
|
|
45
|
+
return val && val !== "off" ? val : undefined;
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
/** Persist a single tool's value, merging into the shared config file. */
|
|
@@ -42,7 +50,7 @@ export function saveOptValue(tool: OptimizerTool, value: string): void {
|
|
|
42
50
|
try {
|
|
43
51
|
const sp = getStatePath();
|
|
44
52
|
mkdirSync(dirname(sp), { recursive: true });
|
|
45
|
-
const next = { ...
|
|
53
|
+
const next = { ...readFile(), [tool]: value };
|
|
46
54
|
writeFileSync(sp, JSON.stringify(next, null, 2), "utf-8");
|
|
47
55
|
} catch (err) {
|
|
48
56
|
console.warn(`optimizer: persist ${tool} failed:`, err);
|
package/src/rtk.ts
CHANGED
|
@@ -156,7 +156,7 @@ export function splitChain(command: string): string[] | null {
|
|
|
156
156
|
let quote: "'" | '"' | null = null;
|
|
157
157
|
|
|
158
158
|
for (let i = 0; i < command.length; i++) {
|
|
159
|
-
const c = command[i]
|
|
159
|
+
const c = command[i] ?? "";
|
|
160
160
|
const next = command[i + 1];
|
|
161
161
|
|
|
162
162
|
if (quote) {
|