pi-lean-ctx 1.0.1 → 1.0.2
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/extensions/index.ts +23 -5
- package/package.json +1 -1
package/extensions/index.ts
CHANGED
|
@@ -18,6 +18,11 @@ import { homedir, platform } from "node:os";
|
|
|
18
18
|
const CODE_EXTENSIONS = new Set([
|
|
19
19
|
".rs", ".ts", ".tsx", ".js", ".jsx", ".php", ".py", ".go",
|
|
20
20
|
".java", ".c", ".cc", ".cpp", ".cxx", ".cs", ".kt", ".swift", ".rb",
|
|
21
|
+
".vue", ".svelte", ".astro", ".html", ".css", ".scss", ".sass", ".less",
|
|
22
|
+
".lua", ".zig", ".nim", ".ex", ".exs", ".erl", ".hs", ".ml", ".mli",
|
|
23
|
+
".r", ".jl", ".dart", ".scala", ".groovy", ".pl", ".pm", ".sh", ".bash",
|
|
24
|
+
".zsh", ".fish", ".ps1", ".bat", ".cmd", ".sql", ".graphql", ".gql",
|
|
25
|
+
".proto", ".thrift", ".tf", ".hcl", ".nix", ".dhall",
|
|
21
26
|
]);
|
|
22
27
|
|
|
23
28
|
const FULL_READ_EXTENSIONS = new Set([
|
|
@@ -346,11 +351,24 @@ export default function (pi: ExtensionAPI) {
|
|
|
346
351
|
const absolutePath = resolve(ctx.cwd, requestedPath);
|
|
347
352
|
|
|
348
353
|
if (params.offset !== undefined || params.limit !== undefined) {
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
+
const startLine = params.offset ?? 1;
|
|
355
|
+
const endLine = params.limit ? startLine + params.limit - 1 : 999999;
|
|
356
|
+
const args = ["read", absolutePath, "-m", `lines:${startLine}-${endLine}`];
|
|
357
|
+
try {
|
|
358
|
+
const output = await execLeanCtx(pi, args);
|
|
359
|
+
const originalSlice = await readSlice(absolutePath, params.offset, params.limit);
|
|
360
|
+
const decorated = withFooter(output, { originalText: originalSlice.text, always: true, preferEstimate: true });
|
|
361
|
+
return {
|
|
362
|
+
content: [{ type: "text", text: decorated.text }],
|
|
363
|
+
details: { path: absolutePath, lines: originalSlice.lines, source: "lean-ctx", mode: `lines:${startLine}-${endLine}`, compression: decorated.stats },
|
|
364
|
+
};
|
|
365
|
+
} catch {
|
|
366
|
+
const sliced = await readSlice(absolutePath, params.offset, params.limit);
|
|
367
|
+
return {
|
|
368
|
+
content: [{ type: "text", text: sliced.text }],
|
|
369
|
+
details: { path: absolutePath, lines: sliced.lines, source: "local-slice-fallback", truncated: sliced.truncated },
|
|
370
|
+
};
|
|
371
|
+
}
|
|
354
372
|
}
|
|
355
373
|
|
|
356
374
|
if (IMAGE_EXTENSIONS.has(extname(absolutePath).toLowerCase())) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-lean-ctx",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Pi Coding Agent extension that routes bash, read, grep, find, and ls through lean-ctx for 60-90% token savings",
|
|
5
5
|
"keywords": ["pi-package", "lean-ctx", "token-optimization", "compression"],
|
|
6
6
|
"license": "MIT",
|