dsh-plugin-codegraph-sqlite 0.6.3 → 0.6.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/lib/database.d.ts +8 -0
- package/lib/database.js +21 -0
- package/lib/index.js +33 -19
- package/package.json +2 -2
package/lib/database.d.ts
CHANGED
|
@@ -61,6 +61,14 @@ export declare class GraphPool {
|
|
|
61
61
|
* @returns the open, version-checked connection, current as of this call.
|
|
62
62
|
*/
|
|
63
63
|
acquire(projectRoot: string): DatabaseSync;
|
|
64
|
+
/**
|
|
65
|
+
* Drop the cached connection for one root, so a re-index may replace its file.
|
|
66
|
+
*
|
|
67
|
+
* A connection kept past the query is what breaks a Windows re-index: the writer
|
|
68
|
+
* replaces the graph with rename(), and Windows refuses to rename over a file that
|
|
69
|
+
* is open, while the design above assumes POSIX unlink semantics.
|
|
70
|
+
*/
|
|
71
|
+
forget(projectRoot: string): void;
|
|
64
72
|
/** Close every open connection; further {@link acquire} calls fail as `CODEGRAPH_DISPOSED`. */
|
|
65
73
|
close(): void;
|
|
66
74
|
/** Close least-recently-used connections until the pool fits its capacity. */
|
package/lib/database.js
CHANGED
|
@@ -151,6 +151,27 @@ export class GraphPool {
|
|
|
151
151
|
this.evictOverflow();
|
|
152
152
|
return db;
|
|
153
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Drop the cached connection for one root, so a re-index may replace its file.
|
|
156
|
+
*
|
|
157
|
+
* A connection kept past the query is what breaks a Windows re-index: the writer
|
|
158
|
+
* replaces the graph with rename(), and Windows refuses to rename over a file that
|
|
159
|
+
* is open, while the design above assumes POSIX unlink semantics.
|
|
160
|
+
*/
|
|
161
|
+
forget(projectRoot) {
|
|
162
|
+
const entry = this.open.get(projectRoot);
|
|
163
|
+
if (entry === undefined)
|
|
164
|
+
return;
|
|
165
|
+
// Tolerate a connection the caller already closed: the store closes it first and
|
|
166
|
+
// then forgets it, and node:sqlite throws "database is not open" on a second close.
|
|
167
|
+
try {
|
|
168
|
+
entry.db.close();
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
// already closed by the caller
|
|
172
|
+
}
|
|
173
|
+
this.open.delete(projectRoot);
|
|
174
|
+
}
|
|
154
175
|
/** Close every open connection; further {@link acquire} calls fail as `CODEGRAPH_DISPOSED`. */
|
|
155
176
|
close() {
|
|
156
177
|
this.disposed = true;
|
package/lib/index.js
CHANGED
|
@@ -88,25 +88,39 @@ export function apply(ctx, config) {
|
|
|
88
88
|
*/
|
|
89
89
|
function run(pool, config, request) {
|
|
90
90
|
const db = pool.acquire(request.projectRoot);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
91
|
+
try {
|
|
92
|
+
switch (request.operation) {
|
|
93
|
+
case 'search':
|
|
94
|
+
return search(db, request);
|
|
95
|
+
case 'node':
|
|
96
|
+
return node(db, request);
|
|
97
|
+
case 'callers':
|
|
98
|
+
case 'callees':
|
|
99
|
+
return relations(db, request);
|
|
100
|
+
case 'impact':
|
|
101
|
+
return impact(db, request, (origin, depth) => walkImpact(db, origin, depth, config.maxTraversalNodes));
|
|
102
|
+
case 'trace':
|
|
103
|
+
return trace(db, request, (from, to, maxDepth, maxPaths) => walkTrace(db, from, to, maxDepth, maxPaths, config.maxTraversalNodes));
|
|
104
|
+
case 'files':
|
|
105
|
+
return files(db, request);
|
|
106
|
+
case 'status':
|
|
107
|
+
return status(db, request.projectRoot, config.maxStalenessChecks);
|
|
108
|
+
/* v8 ignore next -- exhaustive over the seam's closed operation union; unreachable. */
|
|
109
|
+
default:
|
|
110
|
+
return assertNever(request, 'codegraph-sqlite request');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
// Every operation above is synchronous, so the connection goes back the moment the
|
|
115
|
+
// answer exists. That is what fixes the Windows EPERM: the writer may only replace
|
|
116
|
+
// the file when nobody has it open.
|
|
117
|
+
try {
|
|
118
|
+
db.close();
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
// already closed
|
|
122
|
+
}
|
|
123
|
+
pool.forget(request.projectRoot);
|
|
110
124
|
}
|
|
111
125
|
}
|
|
112
126
|
/** Reject a non-positive-integer config value at load, so misconfiguration fails loud. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-codegraph-sqlite",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "Read-only SQLite store for the DeepSeek Harness code-graph seam — serves structural queries from the schema-v4 graph at .codegraph/codegraph.db, the same on-disk format the codegraph CLI writes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@deepseek-ai/schemastery": "^3.18.1",
|
|
50
|
-
"dsh-plugin-codegraph-service": "^0.6.
|
|
50
|
+
"dsh-plugin-codegraph-service": "^0.6.4"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@deepseek-ai/cordis": ">=4.0.1",
|