pi-readseek 0.11.1 → 0.11.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/dist/index.ts +64 -11
- package/package.json +3 -3
package/dist/index.ts
CHANGED
|
@@ -5604,7 +5604,7 @@ async function executeDef(opts) {
|
|
|
5604
5604
|
return {
|
|
5605
5605
|
content: [{ type: "text", text: "no definitions found" }],
|
|
5606
5606
|
details: {
|
|
5607
|
-
readSeekValue: { tool: "def", ok: true, path: searchPath, definitions: [] }
|
|
5607
|
+
readSeekValue: { tool: "def", ok: true, path: searchPath, definitions: [], files: [] }
|
|
5608
5608
|
}
|
|
5609
5609
|
};
|
|
5610
5610
|
}
|
|
@@ -5633,7 +5633,7 @@ async function executeDef(opts) {
|
|
|
5633
5633
|
content: [{ type: "text", text: textParts.join(`
|
|
5634
5634
|
`) }],
|
|
5635
5635
|
details: {
|
|
5636
|
-
readSeekValue: { tool: "def", ok: true, path: searchPath, definitions }
|
|
5636
|
+
readSeekValue: { tool: "def", ok: true, path: searchPath, definitions, files: fileList }
|
|
5637
5637
|
}
|
|
5638
5638
|
};
|
|
5639
5639
|
} catch (err) {
|
|
@@ -5676,7 +5676,7 @@ function registerDefTool(pi, options = {}) {
|
|
|
5676
5676
|
}
|
|
5677
5677
|
|
|
5678
5678
|
// src/access.ts
|
|
5679
|
-
import { Text as Text7 } from "@earendil-works/pi-tui";
|
|
5679
|
+
import { Text as Text7, wrapTextWithAnsi as wrapTextWithAnsi2 } from "@earendil-works/pi-tui";
|
|
5680
5680
|
import { Type as Type11 } from "@sinclair/typebox";
|
|
5681
5681
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
5682
5682
|
var operations = {
|
|
@@ -5709,6 +5709,48 @@ function resolveNonShowSummary(tool, envelope) {
|
|
|
5709
5709
|
return "text recognized";
|
|
5710
5710
|
return "complete";
|
|
5711
5711
|
}
|
|
5712
|
+
var SOURCE_ROW_RE = /^(\d+)(:[0-9a-fA-F]+)? \| (.*)$/;
|
|
5713
|
+
function renderShowPresentation(summary, body, extras, expanded, theme, fallbackWidth) {
|
|
5714
|
+
const fg = typeof theme?.fg === "function" ? (style, value) => theme.fg(style, value) : (_style, value) => value;
|
|
5715
|
+
const rawBodyLines = expanded && body ? body.split(`
|
|
5716
|
+
`) : [];
|
|
5717
|
+
let maxDigits = 0;
|
|
5718
|
+
for (const line of rawBodyLines) {
|
|
5719
|
+
const match = line.match(SOURCE_ROW_RE);
|
|
5720
|
+
if (match && match[1].length > maxDigits)
|
|
5721
|
+
maxDigits = match[1].length;
|
|
5722
|
+
}
|
|
5723
|
+
return {
|
|
5724
|
+
invalidate() {},
|
|
5725
|
+
render(renderWidth) {
|
|
5726
|
+
const normalized = normalizeWidth(renderWidth, fallbackWidth ?? 80);
|
|
5727
|
+
const out = [...wrapTextWithAnsi2(summary, normalized)];
|
|
5728
|
+
if (!expanded)
|
|
5729
|
+
return out;
|
|
5730
|
+
for (const line of rawBodyLines) {
|
|
5731
|
+
if (!line && maxDigits > 0)
|
|
5732
|
+
continue;
|
|
5733
|
+
const match = line.match(SOURCE_ROW_RE);
|
|
5734
|
+
if (match) {
|
|
5735
|
+
const anchor = `${match[1].padStart(maxDigits, " ")}${match[2] ?? ""}`;
|
|
5736
|
+
const prefix = ` ${fg("dim", `${anchor} | `)}`;
|
|
5737
|
+
out.push(...wrapWithHangingIndent(prefix, match[3] ?? "", normalized));
|
|
5738
|
+
} else if (line.startsWith("Cursor: ")) {
|
|
5739
|
+
out.push(...wrapWithHangingIndent(" ", fg("dim", line), normalized));
|
|
5740
|
+
} else {
|
|
5741
|
+
out.push(...wrapTextWithAnsi2(line, normalized));
|
|
5742
|
+
}
|
|
5743
|
+
}
|
|
5744
|
+
for (const extra of extras) {
|
|
5745
|
+
for (const line of extra.split(`
|
|
5746
|
+
`)) {
|
|
5747
|
+
out.push(...wrapTextWithAnsi2(fg("warning", line), normalized));
|
|
5748
|
+
}
|
|
5749
|
+
}
|
|
5750
|
+
return out;
|
|
5751
|
+
}
|
|
5752
|
+
};
|
|
5753
|
+
}
|
|
5712
5754
|
function hasAnchors(value) {
|
|
5713
5755
|
if (!value || typeof value !== "object")
|
|
5714
5756
|
return false;
|
|
@@ -5796,8 +5838,18 @@ function registerAccessTools(pi, options = {}) {
|
|
|
5796
5838
|
const label = renderToolLabel(theme, registeredName);
|
|
5797
5839
|
const filePath = typeof args?.path === "string" ? args.path : args?.path ? String(args.path) : "";
|
|
5798
5840
|
const renderedPath = filePath ? linkToolPath(theme?.fg ? theme.fg("accent", filePath) : filePath, filePath, cwd) : "";
|
|
5799
|
-
const atBadge = args?.at ? theme?.fg ? theme.fg("dim",
|
|
5800
|
-
const
|
|
5841
|
+
const atBadge = args?.at ? theme?.fg ? theme.fg("dim", `@ ${args.at}`) : `@ ${args.at}` : "";
|
|
5842
|
+
const flags = [
|
|
5843
|
+
args?.limit !== undefined && `limit=${args.limit}`,
|
|
5844
|
+
args?.end !== undefined && `end=${args.end}`,
|
|
5845
|
+
args?.depth !== undefined && `depth=${args.depth}`,
|
|
5846
|
+
args?.kind && `kind=${args.kind}`,
|
|
5847
|
+
args?.outline && "outline",
|
|
5848
|
+
args?.noAnchors && "no-anchors",
|
|
5849
|
+
args?.level && `level=${args.level}`
|
|
5850
|
+
].filter(Boolean);
|
|
5851
|
+
const flagsBadge = flags.length > 0 ? theme?.fg ? theme.fg("dim", `[${flags.join(",")}]`) : `[${flags.join(",")}]` : "";
|
|
5852
|
+
const text = clampLineToWidth([label, renderedPath, atBadge, flagsBadge].filter(Boolean).join(" "), context.width);
|
|
5801
5853
|
return upsertTextComponent(context.lastComponent, text);
|
|
5802
5854
|
},
|
|
5803
5855
|
renderResult(result, renderOptions, theme, ...rest) {
|
|
@@ -5808,15 +5860,16 @@ function registerAccessTools(pi, options = {}) {
|
|
|
5808
5860
|
if (isError || result.isError)
|
|
5809
5861
|
return renderErrorResult(text, { expanded, width, fallback: `${registeredName} failed`, theme });
|
|
5810
5862
|
const presentation = result.details?.readSeekValue?.presentation;
|
|
5863
|
+
const envelope = result.details?.readSeekValue?.envelope;
|
|
5811
5864
|
if (presentation) {
|
|
5812
|
-
const
|
|
5813
|
-
const notes = presentation.notices.map((notice) => `Note: ${notice}`);
|
|
5865
|
+
const warning = typeof envelope?.warning === "string" && envelope.warning ? presentation.notices.at(-1) : undefined;
|
|
5814
5866
|
const attachments = result.content?.filter((item) => item.type === "text").slice(1).map((item) => item.text) ?? [];
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5867
|
+
const extras = [...warning ? [`Note: ${warning}`] : [], ...attachments];
|
|
5868
|
+
const hasWarning = extras.length > 0;
|
|
5869
|
+
const hasExpandable = Boolean(presentation.body) || hasWarning;
|
|
5870
|
+
const summary = summaryLine(presentation.summary, { hidden: hasExpandable && !expanded, theme, style: hasWarning ? "warning" : "success" });
|
|
5871
|
+
return renderShowPresentation(summary, presentation.body, extras, expanded, theme, width);
|
|
5818
5872
|
}
|
|
5819
|
-
const envelope = result.details?.readSeekValue?.envelope;
|
|
5820
5873
|
const nonShowSummary = resolveNonShowSummary(name, envelope);
|
|
5821
5874
|
const summary = summaryLine(nonShowSummary, { hidden: !!text && !expanded, theme, style: "success" });
|
|
5822
5875
|
return new Text7(clampLinesToWidth((expanded ? `${summary}\\n${text}` : summary).split(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-readseek",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"description": "Pi extension for LINE:HASH-anchored file operations and structural code navigation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"node": ">=20.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@jarkkojs/readseek": "^0.11.
|
|
43
|
-
"@jarkkojs/readseek-api": "^0.11.
|
|
42
|
+
"@jarkkojs/readseek": "^0.11.2",
|
|
43
|
+
"@jarkkojs/readseek-api": "^0.11.2",
|
|
44
44
|
"diff": "^9.0.0",
|
|
45
45
|
"xxhash-wasm": "^1.1.0"
|
|
46
46
|
},
|