pi-squeeze 0.1.0 → 0.2.0
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 +24 -5
- package/extensions/core/adb.ts +231 -0
- package/extensions/core/compact.ts +138 -13
- package/extensions/core/docker.ts +58 -0
- package/extensions/core/files.ts +15 -1
- package/extensions/core/generic.ts +4 -1
- package/extensions/core/gradle.ts +233 -37
- package/extensions/core/gradlereports.ts +78 -0
- package/extensions/core/install.ts +122 -0
- package/extensions/core/javac.ts +44 -0
- package/extensions/core/jest.ts +38 -0
- package/extensions/core/jvm.ts +18 -0
- package/extensions/core/lint.ts +199 -0
- package/extensions/core/logs.ts +106 -0
- package/extensions/core/maven.ts +122 -0
- package/extensions/core/pytest.ts +37 -0
- package/extensions/core/tree.ts +14 -7
- package/extensions/core/xcode.ts +123 -0
- package/extensions/squeeze.ts +19 -8
- package/package.json +2 -2
package/extensions/squeeze.ts
CHANGED
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Pure logic lives in core/ and command/ (tested directly); this file only wires it to pi.
|
|
5
5
|
* Output is only ever replaced when the result is clearly smaller, and a truncated result
|
|
6
|
-
* says where the full output was saved.
|
|
6
|
+
* says where the full output was saved. When pi itself cut a long output to its tail, the
|
|
7
|
+
* full output pi saved is compacted instead (a build's tail alone often misses its errors). Settings persist in <agent dir>/squeeze.json.
|
|
7
8
|
*/
|
|
8
9
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
9
10
|
import { completions, parseCommand } from "./command/parse.ts";
|
|
10
11
|
import { compact, KINDS } from "./core/compact.ts";
|
|
11
12
|
import { type Config, DEFAULT_CONFIG, optionsOf, readConfig, saveConfig } from "./core/config.ts";
|
|
12
13
|
import { rewrite } from "./core/rtk.ts";
|
|
13
|
-
import { fileIn } from "./core/files.ts";
|
|
14
|
+
import { fileIn, readFullOutput } from "./core/files.ts";
|
|
14
15
|
import { saveFull } from "./core/save.ts";
|
|
15
16
|
import { emptyStats, record, saved, summary, tokens } from "./core/stats.ts";
|
|
16
17
|
|
|
@@ -49,17 +50,27 @@ export default function (pi: ExtensionAPI) {
|
|
|
49
50
|
if (!config.enabled || event.toolName !== "bash") return;
|
|
50
51
|
const command = (event.input as { command?: unknown }).command;
|
|
51
52
|
if (typeof command !== "string") return;
|
|
52
|
-
// pi already truncated this one: its text is not the tool's own format any more.
|
|
53
|
-
if ((event.details as { truncation?: unknown } | undefined)?.truncation) return;
|
|
54
53
|
const blocks = event.content;
|
|
55
54
|
if (blocks.length !== 1 || blocks[0]!.type !== "text") return;
|
|
56
|
-
const
|
|
55
|
+
const shown = blocks[0]!.text;
|
|
56
|
+
// pi cut this one to its tail and saved the whole of it: compact the whole, not the tail.
|
|
57
|
+
const details = event.details as { truncation?: unknown; fullOutputPath?: unknown } | undefined;
|
|
58
|
+
const fullPath = details?.truncation ? details.fullOutputPath : undefined;
|
|
59
|
+
let original = shown;
|
|
60
|
+
if (details?.truncation) {
|
|
61
|
+
const full = readFullOutput(fullPath);
|
|
62
|
+
if (full === undefined) return;
|
|
63
|
+
// The exit status pi appends to a failed run's text.
|
|
64
|
+
original = full + (/\n\nCommand exited with code \d+$/.exec(shown)?.[0] ?? "");
|
|
65
|
+
}
|
|
57
66
|
|
|
58
67
|
const r = compact(command, original, { ...optionsOf(config), failed: event.isError, isFile: fileIn(ctx.cwd) });
|
|
59
|
-
|
|
60
|
-
|
|
68
|
+
// Never more than pi would have shown.
|
|
69
|
+
if (!r || r.text.length >= shown.length) return;
|
|
70
|
+
record(stats, { ...r, before: shown.length });
|
|
61
71
|
showStatus(ctx);
|
|
62
|
-
const
|
|
72
|
+
const where = fullPath ?? (r.truncated ? saveFull(original) : undefined);
|
|
73
|
+
const text = where ? `${r.text}\n[squeeze: output shortened; full output: ${where}]` : r.text;
|
|
63
74
|
return { content: [{ type: "text", text }] };
|
|
64
75
|
});
|
|
65
76
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-squeeze",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Shrinks bash output before it reaches the agent's context: native compactors for git, cargo,
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Shrinks bash output before it reaches the agent's context: native compactors for git, search, listings, tests, builds (cargo, gradle, Maven, javac, Xcode, tsc, docker), Android (adb, lint, detekt), linters, package installs and logs, plus rtk when installed. Full output stays one temp file away.",
|
|
5
5
|
"keywords": ["pi-package", "pi-extension", "pi", "tokens", "context", "compaction", "rtk"],
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Sorin Albu-Irimies",
|