dsh-locator 0.6.2 → 0.7.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.
- package/CHANGELOG.md +14 -0
- package/README.en.md +2 -2
- package/README.md +11 -7
- package/bin/darwin-arm64/indexd +0 -0
- package/bin/darwin-x64/indexd +0 -0
- package/bin/linux-arm64/indexd +0 -0
- package/bin/linux-x64/indexd +0 -0
- package/bin/win32-arm64/indexd.exe +0 -0
- package/bin/win32-x64/indexd.exe +0 -0
- package/docs/assets/panel-en.png +0 -0
- package/docs/assets/panel-zh.png +0 -0
- package/lib/config.d.ts +4 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +5 -3
- package/lib/config.js.map +1 -1
- package/lib/content.d.ts +40 -20
- package/lib/content.d.ts.map +1 -1
- package/lib/content.js +257 -131
- package/lib/content.js.map +1 -1
- package/lib/find.d.ts.map +1 -1
- package/lib/find.js +1 -0
- package/lib/find.js.map +1 -1
- package/lib/http.d.ts.map +1 -1
- package/lib/http.js +9 -0
- package/lib/http.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -4
- package/lib/index.js.map +1 -1
- package/lib/reindex.d.ts +3 -0
- package/lib/reindex.d.ts.map +1 -0
- package/lib/reindex.js +39 -0
- package/lib/reindex.js.map +1 -0
- package/package.json +1 -1
- package/src/config.ts +9 -3
- package/src/content.ts +233 -104
- package/src/find.ts +1 -0
- package/src/http.ts +9 -0
- package/src/index.ts +10 -4
- package/src/reindex.ts +39 -0
package/src/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type { Config } from './config.ts'
|
|
|
10
10
|
import { ContentIndex } from './content.ts'
|
|
11
11
|
import { makeExportTool } from './export.ts'
|
|
12
12
|
import { makeFindTool } from './find.ts'
|
|
13
|
+
import { makeReindexTool } from './reindex.ts'
|
|
13
14
|
import { registerHttp } from './http.ts'
|
|
14
15
|
import { resolveBinary, resolveRoots, resolveStateDir } from './paths.ts'
|
|
15
16
|
import { LocatorRuntime } from './runtime.ts'
|
|
@@ -39,8 +40,9 @@ export function apply(ctx: Context, config: Config): void {
|
|
|
39
40
|
const content = config.contentIndex
|
|
40
41
|
? new ContentIndex(rt, {
|
|
41
42
|
stateDir,
|
|
42
|
-
sessionDirs: config.contentSessionDirs,
|
|
43
|
+
sessionDirs: config.contentSessionDirs.length > 0 ? config.contentSessionDirs : undefined,
|
|
43
44
|
maxFileBytes: config.contentMaxFileBytes,
|
|
45
|
+
maxTotalBytes: config.contentMaxTotalBytes,
|
|
44
46
|
maxFiles: config.contentMaxFiles,
|
|
45
47
|
maxSessions: config.contentMaxSessions,
|
|
46
48
|
})
|
|
@@ -51,7 +53,7 @@ export function apply(ctx: Context, config: Config): void {
|
|
|
51
53
|
const timer = setTimeout(() => {
|
|
52
54
|
rt.start()
|
|
53
55
|
logger.info(`index roots: ${roots.join(', ')} (state ${stateDir})`)
|
|
54
|
-
if (content !== undefined) void startContent(rt, content, logger)
|
|
56
|
+
if (content !== undefined) void startContent(rt, content, logger, config.contentRefreshMs)
|
|
55
57
|
}, 1500)
|
|
56
58
|
return () => {
|
|
57
59
|
clearTimeout(timer)
|
|
@@ -64,14 +66,17 @@ export function apply(ctx: Context, config: Config): void {
|
|
|
64
66
|
ctx.tools.register(makeStatusTool(rt))
|
|
65
67
|
ctx.tools.register(makeRebuildTool(rt))
|
|
66
68
|
ctx.tools.register(makeExportTool(rt))
|
|
67
|
-
if (content !== undefined)
|
|
69
|
+
if (content !== undefined) {
|
|
70
|
+
ctx.tools.register(makeFindTool(content))
|
|
71
|
+
ctx.tools.register(makeReindexTool(content))
|
|
72
|
+
}
|
|
68
73
|
|
|
69
74
|
// The Web GUI panel is optional: profiles without a Web server keep the
|
|
70
75
|
// three tools and never mount an HTTP route.
|
|
71
76
|
registerHttp(ctx, rt, content)
|
|
72
77
|
}
|
|
73
78
|
|
|
74
|
-
async function startContent(rt: LocatorRuntime, content: ContentIndex, logger: { info(message: string): void }): Promise<void> {
|
|
79
|
+
async function startContent(rt: LocatorRuntime, content: ContentIndex, logger: { info(message: string): void }, refreshMs: number): Promise<void> {
|
|
75
80
|
try {
|
|
76
81
|
await rt.waitReady()
|
|
77
82
|
for (let i = 0; i < 900; i++) {
|
|
@@ -80,6 +85,7 @@ async function startContent(rt: LocatorRuntime, content: ContentIndex, logger: {
|
|
|
80
85
|
await new Promise(resolve => setTimeout(resolve, 2_000))
|
|
81
86
|
}
|
|
82
87
|
content.start()
|
|
88
|
+
content.startAutoRefresh(refreshMs)
|
|
83
89
|
logger.info('content index started')
|
|
84
90
|
} catch (error) {
|
|
85
91
|
logger.info(`content index skipped: ${error instanceof Error ? error.message : String(error)}`)
|
package/src/reindex.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** locator_reindex — full or incremental content-index maintenance. */
|
|
2
|
+
import { defineTool } from '@deepseek-ai/dsh-tools'
|
|
3
|
+
import type { ContentIndex } from './content.ts'
|
|
4
|
+
|
|
5
|
+
export function makeReindexTool(content: ContentIndex) {
|
|
6
|
+
return defineTool({
|
|
7
|
+
name: 'locator_reindex',
|
|
8
|
+
description: [
|
|
9
|
+
'Rebuild or refresh the dsh-locator content index (file bodies + DSH session messages).',
|
|
10
|
+
'',
|
|
11
|
+
'`full: true` drops the content database and re-reads everything; `full: false` (default) only re-reads files/sessions whose mtime changed. Name/path search keeps working during either mode. Use `locator_status` or the content state in `locator_find` to watch progress.',
|
|
12
|
+
].join('\n'),
|
|
13
|
+
parameters: {
|
|
14
|
+
full: { type: 'boolean', description: 'Drop and rebuild the content database (default false = incremental).' },
|
|
15
|
+
},
|
|
16
|
+
output: {
|
|
17
|
+
schema: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
additionalProperties: false,
|
|
20
|
+
properties: {
|
|
21
|
+
ok: { type: 'boolean', required: true },
|
|
22
|
+
started: { type: 'boolean' },
|
|
23
|
+
full: { type: 'boolean' },
|
|
24
|
+
error: { type: 'string' },
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
render: (_args, value) => {
|
|
28
|
+
const v = value as { ok: boolean; started?: boolean; full?: boolean; error?: string }
|
|
29
|
+
return [{ type: 'text', text: v.ok ? `${v.full ? 'Full' : 'Incremental'} content rebuild started.` : `locator_reindex failed: ${v.error ?? 'unknown'}` }]
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
async execute(args) {
|
|
33
|
+
const full = args.full === true
|
|
34
|
+
const started = full ? content.rebuild() : content.refreshNow()
|
|
35
|
+
if (!started) return { ok: false as const, error: 'a content build is already running' }
|
|
36
|
+
return { ok: true as const, started: true, full }
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
}
|