dsh-gitnexus-plus 0.1.1 → 0.1.3
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/README-CN.md +174 -0
- package/README.md +184 -447
- package/lib/bin/search-helper.d.ts +22 -0
- package/lib/bin/search-helper.d.ts.map +1 -0
- package/lib/bin/search-helper.js +57 -0
- package/lib/bin/search-helper.js.map +1 -0
- package/lib/client.js +978 -122
- package/lib/gitnexus/analyze.d.ts +27 -2
- package/lib/gitnexus/analyze.d.ts.map +1 -1
- package/lib/gitnexus/analyze.js +71 -6
- package/lib/gitnexus/analyze.js.map +1 -1
- package/lib/gitnexus/commands.d.ts +41 -8
- package/lib/gitnexus/commands.d.ts.map +1 -1
- package/lib/gitnexus/commands.js +62 -9
- package/lib/gitnexus/commands.js.map +1 -1
- package/lib/gitnexus/coverage.d.ts +16 -0
- package/lib/gitnexus/coverage.d.ts.map +1 -1
- package/lib/gitnexus/coverage.js +61 -2
- package/lib/gitnexus/coverage.js.map +1 -1
- package/lib/gitnexus/git-activity.d.ts +85 -0
- package/lib/gitnexus/git-activity.d.ts.map +1 -1
- package/lib/gitnexus/git-activity.js +286 -1
- package/lib/gitnexus/git-activity.js.map +1 -1
- package/lib/gitnexus/index-meta.d.ts +15 -5
- package/lib/gitnexus/index-meta.d.ts.map +1 -1
- package/lib/gitnexus/index-meta.js +25 -5
- package/lib/gitnexus/index-meta.js.map +1 -1
- package/lib/gitnexus/languages.d.ts +7 -0
- package/lib/gitnexus/languages.d.ts.map +1 -1
- package/lib/gitnexus/languages.js +82 -2
- package/lib/gitnexus/languages.js.map +1 -1
- package/lib/gitnexus/root.d.ts +6 -0
- package/lib/gitnexus/root.d.ts.map +1 -1
- package/lib/gitnexus/root.js +6 -0
- package/lib/gitnexus/root.js.map +1 -1
- package/lib/gitnexus/scan.d.ts +3 -0
- package/lib/gitnexus/scan.d.ts.map +1 -1
- package/lib/gitnexus/scan.js +6 -3
- package/lib/gitnexus/scan.js.map +1 -1
- package/lib/gitnexus/search.d.ts +167 -0
- package/lib/gitnexus/search.d.ts.map +1 -0
- package/lib/gitnexus/search.js +517 -0
- package/lib/gitnexus/search.js.map +1 -0
- package/lib/index.d.ts +32 -13
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +68 -21
- package/lib/index.js.map +1 -1
- package/lib/routes/analyze.d.ts +8 -2
- package/lib/routes/analyze.d.ts.map +1 -1
- package/lib/routes/analyze.js +5 -1
- package/lib/routes/analyze.js.map +1 -1
- package/lib/routes/coverage.d.ts +15 -6
- package/lib/routes/coverage.d.ts.map +1 -1
- package/lib/routes/coverage.js +77 -12
- package/lib/routes/coverage.js.map +1 -1
- package/lib/routes/file-history.d.ts +21 -0
- package/lib/routes/file-history.d.ts.map +1 -0
- package/lib/routes/file-history.js +69 -0
- package/lib/routes/file-history.js.map +1 -0
- package/lib/routes/search.d.ts +27 -0
- package/lib/routes/search.d.ts.map +1 -0
- package/lib/routes/search.js +77 -0
- package/lib/routes/search.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `GET /api/gitnexus/search?repo=<project>&q=<keyword>` — keyword search.
|
|
3
|
+
*
|
|
4
|
+
* The fourth route, and the first that is neither a reading of the index manifest
|
|
5
|
+
* nor a maintenance action: it queries the graph's symbol names and file paths.
|
|
6
|
+
* It is read-only in the strongest sense this plugin can offer — the engine opens
|
|
7
|
+
* LadybugDB with `readOnly: true` and takes no write lock — so the method policy is
|
|
8
|
+
* the read-only one (GET/HEAD), not the analyze route's wider set.
|
|
9
|
+
*
|
|
10
|
+
* The bound is the same project-root check the coverage route uses: a directory
|
|
11
|
+
* that is neither indexed nor a `.git` root is refused, so the route cannot be used
|
|
12
|
+
* to enumerate a filesystem. Search itself additionally requires a complete index
|
|
13
|
+
* store and returns a typed error when the graph is missing.
|
|
14
|
+
*/
|
|
15
|
+
import path from 'node:path';
|
|
16
|
+
import { guardHandler, passGuard, answerHead, sendJson } from './guard.js';
|
|
17
|
+
import { isProjectRoot } from '../gitnexus/index-meta.js';
|
|
18
|
+
import { SearchError } from '../gitnexus/search.js';
|
|
19
|
+
const SEARCH_METHODS = new Set(['GET', 'HEAD']);
|
|
20
|
+
/**
|
|
21
|
+
* @returns disposer that unregisters the route
|
|
22
|
+
*/
|
|
23
|
+
export function mountSearchRoute(webServer, deps) {
|
|
24
|
+
const handler = guardHandler(async (req, res) => {
|
|
25
|
+
if (!passGuard(req, res, SEARCH_METHODS))
|
|
26
|
+
return;
|
|
27
|
+
const url = new URL(req.url ?? '/', 'http://127.0.0.1');
|
|
28
|
+
const repo = url.searchParams.get('repo');
|
|
29
|
+
if (repo === null || repo.trim() === '') {
|
|
30
|
+
sendJson(res, 400, { ok: false, code: 'missing-repo', message: 'repo query parameter is required' });
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const query = url.searchParams.get('q');
|
|
34
|
+
if (query === null || query.trim() === '') {
|
|
35
|
+
sendJson(res, 400, { ok: false, code: 'missing-query', message: 'q query parameter is required' });
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const absRepo = path.resolve(repo);
|
|
39
|
+
// The same boundary as the coverage route: a search must not become a way to
|
|
40
|
+
// ask whether an arbitrary directory exists. The engine repeats this check for
|
|
41
|
+
// direct callers; at the HTTP edge it saves opening a database to say no.
|
|
42
|
+
if (!(await isProjectRoot(absRepo))) {
|
|
43
|
+
sendJson(res, 404, {
|
|
44
|
+
ok: false,
|
|
45
|
+
code: 'not-a-project',
|
|
46
|
+
message: 'directory is neither a GitNexus index nor a git repository root',
|
|
47
|
+
});
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (answerHead(req, res))
|
|
51
|
+
return;
|
|
52
|
+
// `limit` is optional; the engine clamps it. A malformed value is treated as
|
|
53
|
+
// absent rather than as an error — the search itself does not depend on it.
|
|
54
|
+
const rawLimit = url.searchParams.get('limit');
|
|
55
|
+
const parsed = rawLimit === null ? Number.NaN : Number.parseInt(rawLimit, 10);
|
|
56
|
+
const limit = Number.isFinite(parsed) ? parsed : undefined;
|
|
57
|
+
try {
|
|
58
|
+
const report = await deps.search(absRepo, query, { limit });
|
|
59
|
+
sendJson(res, 200, {
|
|
60
|
+
ok: true,
|
|
61
|
+
...report,
|
|
62
|
+
readAt: new Date().toISOString(),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (error instanceof SearchError) {
|
|
67
|
+
sendJson(res, error.status, { ok: false, code: error.code, message: error.message });
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// `guardHandler` turns anything else into a 500; rethrow so its single error
|
|
71
|
+
// path stays the only place that formats an unexpected failure.
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return webServer.register({ kind: 'prefix', path: '/api/gitnexus/search', handler });
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/routes/search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3E,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAqB,MAAM,uBAAuB,CAAC;AAEvE,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAOrE;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAA2B,EAAE,IAAqB;IACjF,MAAM,OAAO,GAAG,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QAC9C,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,G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|
4
|
-
"description": "DSH plugin: visualize a GitNexus project index, report what it left out, and run its incremental refresh from a sidebar panel — including detecting a missing GitNexus and installing one on request.",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "DSH plugin: visualize a GitNexus project index, search its symbols by keyword, report what it left out, and run its incremental refresh from a sidebar panel — including detecting a missing GitNexus and installing one on request.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"scripts/link-runtime.mjs",
|
|
39
39
|
"cordis.patch.yml",
|
|
40
40
|
"README.md",
|
|
41
|
+
"README-CN.md",
|
|
41
42
|
"LICENSE"
|
|
42
43
|
],
|
|
43
44
|
"engines": {
|