@danypops/pi-lector 0.15.0 → 0.16.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GithubRepoSearchResult, NpmPackageCandidate,
|
|
1
|
+
import type { GithubRepoSearchResult, NpmPackageCandidate, SourcegraphCodeSearchResult } from "@danypops/lector";
|
|
2
2
|
import { invokeLectorVehicleOperation, type LectorVehicleCall } from "../vehicle-client.ts";
|
|
3
3
|
|
|
4
4
|
/** Matches EXTERNAL_SEARCH_PERMISSIONS' own declared value server-side (external-search/operation-registration.ts). */
|
|
@@ -12,7 +12,7 @@ const EXTERNAL_SEARCH_PERMISSIONS = ["external-search:read"];
|
|
|
12
12
|
export interface ExternalSearchOperations {
|
|
13
13
|
githubRepos(query: string, maxResults: number, call: LectorVehicleCall): Promise<GithubRepoSearchResult>;
|
|
14
14
|
npmPackages(query: string, maxResults: number, call: LectorVehicleCall): Promise<{ candidates: readonly NpmPackageCandidate[] }>;
|
|
15
|
-
sourcegraphCode(query: string, maxResults: number, call: LectorVehicleCall): Promise<
|
|
15
|
+
sourcegraphCode(query: string, maxResults: number, call: LectorVehicleCall): Promise<SourcegraphCodeSearchResult>;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export function createExternalSearchOperations(): ExternalSearchOperations {
|
|
@@ -29,12 +29,7 @@ export function createExternalSearchOperations(): ExternalSearchOperations {
|
|
|
29
29
|
);
|
|
30
30
|
},
|
|
31
31
|
sourcegraphCode(query, maxResults, call) {
|
|
32
|
-
return invokeLectorVehicleOperation<{
|
|
33
|
-
"search.sourcegraphCode",
|
|
34
|
-
{ query, maxResults },
|
|
35
|
-
EXTERNAL_SEARCH_PERMISSIONS,
|
|
36
|
-
call,
|
|
37
|
-
);
|
|
32
|
+
return invokeLectorVehicleOperation<SourcegraphCodeSearchResult>("search.sourcegraphCode", { query, maxResults }, EXTERNAL_SEARCH_PERMISSIONS, call);
|
|
38
33
|
},
|
|
39
34
|
};
|
|
40
35
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GithubRepoSearchResult, NpmPackageCandidate,
|
|
1
|
+
import type { GithubRepoSearchResult, NpmPackageCandidate, SourcegraphCodeSearchResult } from "@danypops/lector";
|
|
2
2
|
import type { LectorTheme } from "../lector-tui-theme.ts";
|
|
3
3
|
import { presentationTitle } from "../presentation/tool-presentation.ts";
|
|
4
4
|
|
|
@@ -45,17 +45,15 @@ export function formatNpmPackageSearchResult(
|
|
|
45
45
|
return lines.join("\n");
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export function formatSourcegraphCodeSearchResult(
|
|
49
|
-
result
|
|
50
|
-
expanded: boolean,
|
|
51
|
-
theme: LectorTheme,
|
|
52
|
-
): string {
|
|
53
|
-
if (!result || result.candidates.length === 0) return theme.fg("dim", "no code matches");
|
|
48
|
+
export function formatSourcegraphCodeSearchResult(result: SourcegraphCodeSearchResult | undefined, expanded: boolean, theme: LectorTheme): string {
|
|
49
|
+
if (!result) return theme.fg("dim", "no code matches");
|
|
54
50
|
const { visible, more } = boundedCandidates(result.candidates, expanded);
|
|
55
51
|
const lines = visible.map((candidate) => {
|
|
56
52
|
const matches = candidate.lineMatches.slice(0, expanded ? candidate.lineMatches.length : 3);
|
|
57
53
|
return `${theme.fg("accent", `${candidate.repository}/${candidate.path}`)}\n${matches.map((match) => ` ${match.line}: ${match.preview}`).join("\n")}`;
|
|
58
54
|
});
|
|
59
55
|
if (more > 0) lines.push(theme.fg("muted", `… ${more} more (expand to show)`));
|
|
56
|
+
if (result.truncated) lines.push(theme.fg("warning", `partial results · ${result.stopReason ?? "bounded"}`));
|
|
57
|
+
if (lines.length === 0) return theme.fg("dim", "no code matches");
|
|
60
58
|
return lines.join("\n");
|
|
61
59
|
}
|
package/extension/src/index.ts
CHANGED
|
@@ -21,7 +21,7 @@ import type {
|
|
|
21
21
|
PackageSourceOperationResult,
|
|
22
22
|
PopulateSymbolGraphResult,
|
|
23
23
|
RepoFetchResult,
|
|
24
|
-
|
|
24
|
+
SourcegraphCodeSearchResult,
|
|
25
25
|
SymbolAnnotation,
|
|
26
26
|
SymbolNode,
|
|
27
27
|
SymbolSearchResult,
|
|
@@ -2457,7 +2457,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
2457
2457
|
type ExternalSearchToolDetails =
|
|
2458
2458
|
| { readonly action: "github_repos"; readonly result: GithubRepoSearchResult }
|
|
2459
2459
|
| { readonly action: "npm_packages"; readonly result: { candidates: readonly NpmPackageCandidate[] } }
|
|
2460
|
-
| { readonly action: "sourcegraph_code"; readonly result:
|
|
2460
|
+
| { readonly action: "sourcegraph_code"; readonly result: SourcegraphCodeSearchResult };
|
|
2461
2461
|
|
|
2462
2462
|
const externalSearchOperations = createExternalSearchOperations();
|
|
2463
2463
|
registerLectorTool({
|
|
@@ -26,7 +26,16 @@ export function formatWorkspaceCacheCall(
|
|
|
26
26
|
|
|
27
27
|
function formatResultCounts(result: CacheResultCounts): string {
|
|
28
28
|
const failed = result.filesFailed > 0 ? `, ${result.filesFailed} failed` : "";
|
|
29
|
-
|
|
29
|
+
const reuse = result.filesReused === undefined ? "" : `, ${result.filesReused} reused, ${result.filesReprocessed ?? 0} reprocessed`;
|
|
30
|
+
const retries = result.staleRetries ? `, ${result.staleRetries} stale ${result.staleRetries === 1 ? "retry" : "retries"}` : "";
|
|
31
|
+
const coverage = result.sourceCoverage;
|
|
32
|
+
const scopes = coverage?.scopes
|
|
33
|
+
.slice(0, 3)
|
|
34
|
+
.map((entry) => `${entry.scope}:${entry.files}`)
|
|
35
|
+
.join(", ");
|
|
36
|
+
const omitted = coverage ? coverage.scopeOmittedCount + Math.max(0, coverage.scopes.length - 3) : 0;
|
|
37
|
+
const scopeSummary = scopes ? `; coverage ${scopes}${omitted > 0 ? ` (+${omitted} scopes)` : ""}${coverage?.truncated ? " [bounded]" : ""}` : "";
|
|
38
|
+
return `${result.filesProcessed}/${result.filesAttempted} files${failed}${reuse}${retries}, ${result.symbolsProcessed} symbols, ${result.nodesAdded} nodes, ${result.edgesAdded} edges${scopeSummary}`;
|
|
30
39
|
}
|
|
31
40
|
|
|
32
41
|
export function formatWorkspaceReleaseModelContent(outcome: OperationOutputs["workspace.release"]): string {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danypops/pi-lector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
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",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@danypops/vehicle-client-pi": "^0.45.0"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@danypops/lector": "^0.
|
|
25
|
+
"@danypops/lector": "^0.22.0",
|
|
26
26
|
"@danypops/vehicle-client": "^0.10.8",
|
|
27
27
|
"@danypops/vehicle-core": "^0.19.1",
|
|
28
28
|
"malevich-tui-components": "^0.32.1",
|