@danypops/pi-lector 0.1.8 → 0.1.10
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SymbolSearchResult, TextSearchResult, WorkspaceQueryOutcome } from "@danypops/lector";
|
|
2
2
|
import { keyHint } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { describeFindSymbolSources } from "./find-symbols-rendering.ts";
|
|
3
4
|
import type { LectorTheme } from "./lector-tui-theme.ts";
|
|
4
5
|
|
|
5
6
|
const DEFAULT_VISIBLE_PER_WORKSPACE = 10;
|
|
@@ -29,6 +30,7 @@ export function formatFindSymbolsAcrossProjectsResult(
|
|
|
29
30
|
lines.push(
|
|
30
31
|
theme.fg("muted", ` ${outcome.result.provenance.fidelity} via ${outcome.result.provenance.backend}${outcome.result.truncated ? " (truncated)" : ""}`),
|
|
31
32
|
);
|
|
33
|
+
for (const source of describeFindSymbolSources(outcome.result)) lines.push(theme.fg("muted", ` ${source}`));
|
|
32
34
|
if (outcome.result.symbols.length === 0) {
|
|
33
35
|
lines.push(theme.fg("dim", " no symbols matched"));
|
|
34
36
|
continue;
|
|
@@ -24,6 +24,16 @@ export function formatFindSymbolsCall(args: { query?: unknown; directory?: unkno
|
|
|
24
24
|
return content;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
export function describeFindSymbolSources(result: SymbolSearchResult): readonly string[] {
|
|
28
|
+
return (result.sources ?? []).map((source) => {
|
|
29
|
+
const identity = `${source.provenance.languageId}: ${source.status} via ${source.provenance.backend}`;
|
|
30
|
+
if (source.status === "failed") {
|
|
31
|
+
return source.error ? `${identity} [${source.error.code}] ${source.error.message}` : identity;
|
|
32
|
+
}
|
|
33
|
+
return `${identity} (${source.symbolCount} symbol${source.symbolCount === 1 ? "" : "s"}${source.truncated ? ", truncated" : ""})`;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
27
37
|
/** One result line, kind-padded to the widest kind actually present so the name column lines up. */
|
|
28
38
|
function formatSymbolLine(symbol: WorkspaceSymbol, theme: FindSymbolsTheme, kindColumnWidth: number): string {
|
|
29
39
|
const kind = theme.fg(colorForKind(symbol.kind), symbol.kind.padEnd(kindColumnWidth));
|
|
@@ -36,13 +46,18 @@ export function formatFindSymbolsResult(result: SymbolSearchResult | undefined,
|
|
|
36
46
|
if (!result) return theme.fg("dim", `No symbols found matching "${query}".`);
|
|
37
47
|
const { symbols, provenance, truncated } = result;
|
|
38
48
|
const source = `${provenance.fidelity} via ${provenance.backend}${truncated ? " (truncated)" : ""}`;
|
|
49
|
+
const sourceLines = describeFindSymbolSources(result).map((line) => theme.fg("muted", line));
|
|
39
50
|
if (symbols.length === 0) {
|
|
40
|
-
return
|
|
51
|
+
return [theme.fg("muted", source), ...sourceLines, theme.fg("dim", `No symbols found matching "${query}".`)].join("\n");
|
|
41
52
|
}
|
|
42
53
|
|
|
43
54
|
const kindColumnWidth = Math.max(...symbols.map((symbol) => symbol.kind.length));
|
|
44
55
|
const displayCount = expanded ? symbols.length : Math.min(symbols.length, DEFAULT_VISIBLE_RESULTS);
|
|
45
|
-
const lines = [
|
|
56
|
+
const lines = [
|
|
57
|
+
theme.fg("muted", source),
|
|
58
|
+
...sourceLines,
|
|
59
|
+
theme.fg("muted", `${symbols.length} symbol${symbols.length === 1 ? "" : "s"} matching "${query}":`),
|
|
60
|
+
];
|
|
46
61
|
|
|
47
62
|
for (const symbol of symbols.slice(0, displayCount)) {
|
|
48
63
|
lines.push(formatSymbolLine(symbol, theme, kindColumnWidth));
|
package/extension/src/index.ts
CHANGED
|
@@ -53,7 +53,7 @@ import { createLectorCrossWorkspaceSearchOperations } from "./cross-workspace-se
|
|
|
53
53
|
import { formatCrossWorkspaceCall, formatFindSymbolsAcrossProjectsResult, formatSearchTextAcrossProjectsResult } from "./cross-workspace-search-rendering.ts";
|
|
54
54
|
import { createLectorEditOperations } from "./edit-operations.ts";
|
|
55
55
|
import { createLectorFindSymbolsOperations } from "./find-symbols-operations.ts";
|
|
56
|
-
import { formatFindSymbolsCall, formatFindSymbolsResult } from "./find-symbols-rendering.ts";
|
|
56
|
+
import { describeFindSymbolSources, formatFindSymbolsCall, formatFindSymbolsResult } from "./find-symbols-rendering.ts";
|
|
57
57
|
import { createLectorGitOperations } from "./git-operations.ts";
|
|
58
58
|
import { formatGitDiffCall, formatGitDiffResult, formatGitLogCall, formatGitLogResult, formatGitStatusCall, formatGitStatusResult } from "./git-rendering.ts";
|
|
59
59
|
import { nearestGitRoot } from "./nearest-workspace-root.ts";
|
|
@@ -64,7 +64,13 @@ import { createLectorRepoFetchOperations } from "./repo-fetch-operations.ts";
|
|
|
64
64
|
import { formatRepoFetchCall, formatRepoFetchResult } from "./repo-fetch-rendering.ts";
|
|
65
65
|
import { createLectorSearchOperations } from "./search-operations.ts";
|
|
66
66
|
import { formatSearchCall, formatSearchResult } from "./search-rendering.ts";
|
|
67
|
-
import {
|
|
67
|
+
import {
|
|
68
|
+
type CachePresentationState,
|
|
69
|
+
cacheContextMessage,
|
|
70
|
+
createWorkspaceCacheOperations,
|
|
71
|
+
describeCacheState,
|
|
72
|
+
monitorWorkspaceCache,
|
|
73
|
+
} from "./workspace-cache-operations.ts";
|
|
68
74
|
import { createLectorWriteOperations } from "./write-operations.ts";
|
|
69
75
|
|
|
70
76
|
function describeIntelligenceSource(provenance: IntelligenceProvenance): string {
|
|
@@ -99,13 +105,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
99
105
|
let cacheState: CachePresentationState | undefined;
|
|
100
106
|
let lastInjectedCacheState: string | undefined;
|
|
101
107
|
|
|
102
|
-
function describeCacheState(state: CachePresentationState): string {
|
|
103
|
-
if (state.status === "not-cached") return `not cached (${state.reason})`;
|
|
104
|
-
if (state.status === "caching") return `caching (job ${state.jobId})`;
|
|
105
|
-
if (state.status === "finished-caching") return `finished caching (job ${state.job.id})`;
|
|
106
|
-
return "cached";
|
|
107
|
-
}
|
|
108
|
-
|
|
109
108
|
pi.on("before_agent_start", () => {
|
|
110
109
|
if (!cacheState) return;
|
|
111
110
|
const description = describeCacheState(cacheState);
|
|
@@ -114,7 +113,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
114
113
|
return {
|
|
115
114
|
message: {
|
|
116
115
|
customType: "lector-cache-status",
|
|
117
|
-
content:
|
|
116
|
+
content: cacheContextMessage(cacheState),
|
|
118
117
|
display: false,
|
|
119
118
|
},
|
|
120
119
|
};
|
|
@@ -187,10 +186,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
187
186
|
const result = await findSymbolsOperations.findSymbols(params.query, directory);
|
|
188
187
|
const { symbols, provenance, truncated } = result;
|
|
189
188
|
const source = `${provenance.fidelity} via ${provenance.backend}${truncated ? " (truncated)" : ""}`;
|
|
189
|
+
const sourceDetails = describeFindSymbolSources(result);
|
|
190
|
+
const heading = [source, ...sourceDetails].join("\n");
|
|
190
191
|
const text =
|
|
191
192
|
symbols.length === 0
|
|
192
|
-
? `${
|
|
193
|
-
: `${
|
|
193
|
+
? `${heading}\nNo symbols found matching "${params.query}".`
|
|
194
|
+
: `${heading}\n${symbols
|
|
194
195
|
.map((symbol) => `${symbol.kind} ${symbol.name} -- ${symbol.location.path}:${symbol.location.line}:${symbol.location.character}`)
|
|
195
196
|
.join("\n")}`;
|
|
196
197
|
return { content: [{ type: "text", text }], details: result };
|
|
@@ -46,6 +46,20 @@ export type CachePresentationState =
|
|
|
46
46
|
| { readonly status: "finished-caching"; readonly job: JobSnapshot<PopulateSymbolGraphResult> & { readonly status: "succeeded" } }
|
|
47
47
|
| { readonly status: "cached" };
|
|
48
48
|
|
|
49
|
+
export function describeCacheState(state: CachePresentationState): string {
|
|
50
|
+
if (state.status === "not-cached") return `not cached (${state.reason})`;
|
|
51
|
+
if (state.status === "caching") return `caching (job ${state.jobId})`;
|
|
52
|
+
if (state.status === "finished-caching") return `finished caching (job ${state.job.id})`;
|
|
53
|
+
return "cached";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function cacheContextMessage(state: CachePresentationState): string {
|
|
57
|
+
const prefix = `Lector workspace cache: ${describeCacheState(state)}.`;
|
|
58
|
+
if (state.status === "not-cached") return `${prefix} Live code-intelligence operations remain available.`;
|
|
59
|
+
if (state.status === "caching") return `${prefix} The cached graph is still building; use live code-intelligence operations until it is ready.`;
|
|
60
|
+
return `${prefix} The cached graph is ready.`;
|
|
61
|
+
}
|
|
62
|
+
|
|
49
63
|
export interface MonitorWorkspaceCacheOptions {
|
|
50
64
|
readonly directory: string;
|
|
51
65
|
readonly maxFiles: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danypops/pi-lector",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Pi host adapter for Lector: overrides read/write/edit with a daemon-backed, hash-guarded filesystem",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"typebox": "*"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@danypops/lector": "^0.1.
|
|
21
|
+
"@danypops/lector": "^0.1.9"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@earendil-works/pi-ai": "^0.81.1",
|