@danypops/pi-lector 0.9.3 → 0.9.4
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/extension/src/apply-patch-operations.ts +1 -1
- package/extension/src/code-intelligence-operations.ts +1 -1
- package/extension/src/edit-operations.ts +1 -1
- package/extension/src/lector-client.ts +9 -1
- package/extension/src/line-edit-operations.ts +1 -1
- package/extension/src/mutation-history-operations.ts +1 -1
- package/extension/src/package-source-operations.ts +3 -3
- package/extension/src/reference-based-rename-operations.ts +1 -1
- package/extension/src/rename-operations.ts +1 -1
- package/extension/src/repo-cache-evict-operations.ts +1 -1
- package/extension/src/repo-fetch-operations.ts +1 -1
- package/extension/src/symbol-annotation-operations.ts +6 -6
- package/extension/src/workspace-cache-operations.ts +1 -1
- package/extension/src/write-operations.ts +1 -1
- package/package.json +2 -2
|
@@ -21,7 +21,7 @@ export function createLectorApplyPatchOperations(): ApplyPatchOperations {
|
|
|
21
21
|
async ({ workspaceId, root }) => {
|
|
22
22
|
const client = await lectorClient();
|
|
23
23
|
const relativePath = toWorkspaceRelativePath(root, path);
|
|
24
|
-
return client.
|
|
24
|
+
return client.callOnce("workspace.applyPatch", { workspaceId, path: relativePath, expectedHash, patchText });
|
|
25
25
|
},
|
|
26
26
|
);
|
|
27
27
|
},
|
|
@@ -140,7 +140,7 @@ export function createLectorCodeIntelligenceOperations(): CodeIntelligenceOperat
|
|
|
140
140
|
() => workspaceForPathOrDirectory(path),
|
|
141
141
|
async ({ workspaceId }) => {
|
|
142
142
|
const client = await lectorClient();
|
|
143
|
-
const { job } = await client.
|
|
143
|
+
const { job } = await client.callOnce("job.submit", {
|
|
144
144
|
operation: "workspace.populateSymbolGraph",
|
|
145
145
|
input: { workspaceId, maxFiles, maxSymbolsPerFile },
|
|
146
146
|
waitMs,
|
|
@@ -50,7 +50,7 @@ export function createLectorEditOperations(): EditOperations {
|
|
|
50
50
|
const client = await lectorClient();
|
|
51
51
|
const relativePath = toWorkspaceRelativePath(root, absolutePath);
|
|
52
52
|
try {
|
|
53
|
-
await client.
|
|
53
|
+
await client.callOnce("workspace.exactEdit", { workspaceId, path: relativePath, expectedHash, content });
|
|
54
54
|
} catch (error) {
|
|
55
55
|
if (remoteErrorIs(error, "StaleExpectedHash")) {
|
|
56
56
|
throw new Error(`"${relativePath}" changed on disk since it was last read; re-read the file and retry the edit.`);
|
|
@@ -53,7 +53,14 @@ export function setNewWorkspaceObserver(observer: ((root: string) => void) | und
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export interface RetryingLectorClient {
|
|
56
|
+
/** Transparently retries once on a stale connection -- right for a read-only or genuinely idempotent operation. */
|
|
56
57
|
call<Name extends OperationName>(operation: Name, input: OperationInputs[Name]): Promise<OperationOutputs[Name]>;
|
|
58
|
+
/**
|
|
59
|
+
* Like call(), but never retries the operation itself after a failure -- only the underlying
|
|
60
|
+
* connection resets, so the *next* call()/callOnce() reconnects. Use for a mutating/non-idempotent
|
|
61
|
+
* operation, where transparently re-running it after a transport failure could double the side effect.
|
|
62
|
+
*/
|
|
63
|
+
callOnce<Name extends OperationName>(operation: Name, input: OperationInputs[Name]): Promise<OperationOutputs[Name]>;
|
|
57
64
|
}
|
|
58
65
|
|
|
59
66
|
// Kept async even though its own body has no await: every call site across this package does
|
|
@@ -62,6 +69,7 @@ export interface RetryingLectorClient {
|
|
|
62
69
|
export async function lectorClient(): Promise<RetryingLectorClient> {
|
|
63
70
|
return {
|
|
64
71
|
call: (operation, input) => retryingClient.call((client) => client.call(operation, input)),
|
|
72
|
+
callOnce: (operation, input) => retryingClient.callOnce((client) => client.call(operation, input)),
|
|
65
73
|
};
|
|
66
74
|
}
|
|
67
75
|
|
|
@@ -75,7 +83,7 @@ async function workspaceForRoot(root: string): Promise<ResolvedWorkspace> {
|
|
|
75
83
|
const cached = workspaceIdByRoot.get(root);
|
|
76
84
|
if (cached) return { workspaceId: cached, root };
|
|
77
85
|
const client = await lectorClient();
|
|
78
|
-
const { workspaceId } = await client.
|
|
86
|
+
const { workspaceId } = await client.callOnce("workspace.registerPath", { path: root });
|
|
79
87
|
workspaceIdByRoot.set(root, workspaceId);
|
|
80
88
|
onNewWorkspace?.(root);
|
|
81
89
|
return { workspaceId, root };
|
|
@@ -23,7 +23,7 @@ export function createLectorLineEditOperations(): LineEditOperations {
|
|
|
23
23
|
async ({ workspaceId, root }) => {
|
|
24
24
|
const client = await lectorClient();
|
|
25
25
|
const relativePath = toWorkspaceRelativePath(root, path);
|
|
26
|
-
return client.
|
|
26
|
+
return client.callOnce("workspace.lineEdit", { workspaceId, path: relativePath, edits });
|
|
27
27
|
},
|
|
28
28
|
);
|
|
29
29
|
},
|
|
@@ -26,7 +26,7 @@ export function createMutationHistoryOperations(): MutationHistoryOperations {
|
|
|
26
26
|
() => workspaceForPath(absolutePath),
|
|
27
27
|
async ({ workspaceId }) => {
|
|
28
28
|
const client = await lectorClient();
|
|
29
|
-
return client.
|
|
29
|
+
return client.callOnce("workspace.revertMutation", { workspaceId, entryId });
|
|
30
30
|
},
|
|
31
31
|
);
|
|
32
32
|
},
|
|
@@ -17,7 +17,7 @@ export function createLectorPackageSourceOperations(): PackageSourceOperations {
|
|
|
17
17
|
return {
|
|
18
18
|
async resolve(directory, name, requestedVersion, registry) {
|
|
19
19
|
const client = await lectorClient();
|
|
20
|
-
return client.
|
|
20
|
+
return client.callOnce("package.resolveSource", {
|
|
21
21
|
request: {
|
|
22
22
|
projectRoot: directory,
|
|
23
23
|
coordinate: { ecosystem: "npm", registry, name, requestedVersion },
|
|
@@ -31,11 +31,11 @@ export function createLectorPackageSourceOperations(): PackageSourceOperations {
|
|
|
31
31
|
},
|
|
32
32
|
async remove(ecosystem, registry, name, resolvedVersion) {
|
|
33
33
|
const client = await lectorClient();
|
|
34
|
-
return client.
|
|
34
|
+
return client.callOnce("package.removeSource", { ecosystem, registry, name, resolvedVersion });
|
|
35
35
|
},
|
|
36
36
|
async clean(ecosystem) {
|
|
37
37
|
const client = await lectorClient();
|
|
38
|
-
return client.
|
|
38
|
+
return client.callOnce("package.cleanSources", { ecosystem });
|
|
39
39
|
},
|
|
40
40
|
};
|
|
41
41
|
}
|
|
@@ -18,7 +18,7 @@ export function createReferenceBasedRenameOperations(): ReferenceBasedRenameOper
|
|
|
18
18
|
() => workspaceForCodeIntelligencePath(fromPath),
|
|
19
19
|
async ({ workspaceId }) => {
|
|
20
20
|
const client = await lectorClient();
|
|
21
|
-
return client.
|
|
21
|
+
return client.callOnce("workspace.referenceBasedRename", { workspaceId, fromPath, toPath, maxFiles, maxSymbolsPerFile });
|
|
22
22
|
},
|
|
23
23
|
);
|
|
24
24
|
},
|
|
@@ -28,7 +28,7 @@ export function createRenameOperations(): RenameOperations {
|
|
|
28
28
|
() => workspaceForCodeIntelligencePath(path),
|
|
29
29
|
async ({ workspaceId }) => {
|
|
30
30
|
const client = await lectorClient();
|
|
31
|
-
return client.
|
|
31
|
+
return client.callOnce("workspace.rename", { workspaceId, path, line, character, newName });
|
|
32
32
|
},
|
|
33
33
|
);
|
|
34
34
|
},
|
|
@@ -13,7 +13,7 @@ export function createRepoCacheEvictOperations(): RepoCacheEvictOperations {
|
|
|
13
13
|
return {
|
|
14
14
|
async evict(host, owner, repo, ref) {
|
|
15
15
|
const client = await lectorClient();
|
|
16
|
-
return client.
|
|
16
|
+
return client.callOnce("repo.evictCache", { host, owner, repo, ref });
|
|
17
17
|
},
|
|
18
18
|
};
|
|
19
19
|
}
|
|
@@ -14,7 +14,7 @@ export function createLectorRepoFetchOperations(): RepoFetchOperations {
|
|
|
14
14
|
return {
|
|
15
15
|
async fetch(host, owner, repo, ref, forceRefresh) {
|
|
16
16
|
const client = await lectorClient();
|
|
17
|
-
return client.
|
|
17
|
+
return client.callOnce("repo.fetch", { host, owner, repo, ref, forceRefresh });
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
20
|
}
|
|
@@ -49,7 +49,7 @@ export function createLectorSymbolAnnotationOperations(): SymbolAnnotationOperat
|
|
|
49
49
|
() => workspaceForCodeIntelligencePath(path),
|
|
50
50
|
async ({ workspaceId }) => {
|
|
51
51
|
const client = await lectorClient();
|
|
52
|
-
return client.
|
|
52
|
+
return client.callOnce("workspace.createAnnotation", { workspaceId, subtype, title, body, anchors });
|
|
53
53
|
},
|
|
54
54
|
);
|
|
55
55
|
},
|
|
@@ -82,7 +82,7 @@ export function createLectorSymbolAnnotationOperations(): SymbolAnnotationOperat
|
|
|
82
82
|
() => workspaceForCodeIntelligencePath(path),
|
|
83
83
|
async ({ workspaceId }) => {
|
|
84
84
|
const client = await lectorClient();
|
|
85
|
-
return client.
|
|
85
|
+
return client.callOnce("workspace.refreshAnnotation", { workspaceId, id, subtype, title, body, anchors });
|
|
86
86
|
},
|
|
87
87
|
);
|
|
88
88
|
},
|
|
@@ -91,7 +91,7 @@ export function createLectorSymbolAnnotationOperations(): SymbolAnnotationOperat
|
|
|
91
91
|
() => workspaceForCodeIntelligencePath(path),
|
|
92
92
|
async ({ workspaceId }) => {
|
|
93
93
|
const client = await lectorClient();
|
|
94
|
-
return client.
|
|
94
|
+
return client.callOnce("workspace.scrubAnnotation", { workspaceId, id });
|
|
95
95
|
},
|
|
96
96
|
);
|
|
97
97
|
},
|
|
@@ -100,7 +100,7 @@ export function createLectorSymbolAnnotationOperations(): SymbolAnnotationOperat
|
|
|
100
100
|
() => workspaceForCodeIntelligencePath(path),
|
|
101
101
|
async ({ workspaceId }) => {
|
|
102
102
|
const client = await lectorClient();
|
|
103
|
-
return client.
|
|
103
|
+
return client.callOnce("workspace.restoreAnnotation", { workspaceId, id });
|
|
104
104
|
},
|
|
105
105
|
);
|
|
106
106
|
},
|
|
@@ -109,7 +109,7 @@ export function createLectorSymbolAnnotationOperations(): SymbolAnnotationOperat
|
|
|
109
109
|
() => workspaceForCodeIntelligencePath(path),
|
|
110
110
|
async ({ workspaceId }) => {
|
|
111
111
|
const client = await lectorClient();
|
|
112
|
-
return client.
|
|
112
|
+
return client.callOnce("workspace.containAnnotation", { workspaceId, parentId, childId });
|
|
113
113
|
},
|
|
114
114
|
);
|
|
115
115
|
},
|
|
@@ -118,7 +118,7 @@ export function createLectorSymbolAnnotationOperations(): SymbolAnnotationOperat
|
|
|
118
118
|
() => workspaceForCodeIntelligencePath(path),
|
|
119
119
|
async ({ workspaceId }) => {
|
|
120
120
|
const client = await lectorClient();
|
|
121
|
-
return client.
|
|
121
|
+
return client.callOnce("workspace.uncontainAnnotation", { workspaceId, parentId, childId });
|
|
122
122
|
},
|
|
123
123
|
);
|
|
124
124
|
},
|
|
@@ -23,7 +23,7 @@ export function createWorkspaceCacheOperations(): WorkspaceCacheOperations {
|
|
|
23
23
|
() => workspaceForDirectory(directory),
|
|
24
24
|
async ({ workspaceId }) => {
|
|
25
25
|
const client = await lectorClient();
|
|
26
|
-
const { job } = await client.
|
|
26
|
+
const { job } = await client.callOnce("job.submit", {
|
|
27
27
|
operation: "workspace.populateSymbolGraph",
|
|
28
28
|
input: { workspaceId, maxFiles, maxSymbolsPerFile },
|
|
29
29
|
waitMs: 0,
|
|
@@ -41,7 +41,7 @@ export function createLectorWriteOperations(): WriteOperations {
|
|
|
41
41
|
|
|
42
42
|
for (let attempt = 0; attempt < MAX_STALE_HASH_RETRIES; attempt++) {
|
|
43
43
|
try {
|
|
44
|
-
await client.
|
|
44
|
+
await client.callOnce("workspace.exactEdit", { workspaceId, path: relativePath, expectedHash, content });
|
|
45
45
|
return;
|
|
46
46
|
} catch (error) {
|
|
47
47
|
if (!remoteErrorIs(error, "StaleExpectedHash") || attempt === MAX_STALE_HASH_RETRIES - 1) throw error;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danypops/pi-lector",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
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/vehicle-client": "^0.
|
|
21
|
+
"@danypops/vehicle-client": "^0.2.0",
|
|
22
22
|
"@danypops/lector": "^0.12.0",
|
|
23
23
|
"malevich-tui-components": "^0.19.0"
|
|
24
24
|
},
|