bluera-knowledge 0.9.32 → 0.9.34
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/.claude/hooks/post-edit-check.sh +5 -3
- package/.claude/skills/atomic-commits/SKILL.md +3 -1
- package/.husky/pre-commit +3 -2
- package/.prettierrc +9 -0
- package/.versionrc.json +1 -1
- package/CHANGELOG.md +33 -0
- package/CLAUDE.md +6 -0
- package/README.md +25 -13
- package/bun.lock +277 -33
- package/dist/{chunk-L2YVNC63.js → chunk-6FHWC36B.js} +9 -1
- package/dist/chunk-6FHWC36B.js.map +1 -0
- package/dist/{chunk-RST4XGRL.js → chunk-DC7CGSGT.js} +288 -241
- package/dist/chunk-DC7CGSGT.js.map +1 -0
- package/dist/{chunk-6PBP5DVD.js → chunk-WFNPNAAP.js} +3212 -3054
- package/dist/chunk-WFNPNAAP.js.map +1 -0
- package/dist/{chunk-WT2DAEO7.js → chunk-Z2KKVH45.js} +548 -482
- package/dist/chunk-Z2KKVH45.js.map +1 -0
- package/dist/index.js +871 -758
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +3 -3
- package/dist/watch.service-BJV3TI3F.js +7 -0
- package/dist/workers/background-worker-cli.js +46 -45
- package/dist/workers/background-worker-cli.js.map +1 -1
- package/eslint.config.js +43 -1
- package/package.json +18 -11
- package/plugin.json +8 -0
- package/python/requirements.txt +1 -1
- package/src/analysis/ast-parser.test.ts +12 -11
- package/src/analysis/ast-parser.ts +28 -22
- package/src/analysis/code-graph.test.ts +52 -62
- package/src/analysis/code-graph.ts +9 -13
- package/src/analysis/dependency-usage-analyzer.test.ts +91 -271
- package/src/analysis/dependency-usage-analyzer.ts +52 -24
- package/src/analysis/go-ast-parser.test.ts +22 -22
- package/src/analysis/go-ast-parser.ts +18 -25
- package/src/analysis/parser-factory.test.ts +9 -9
- package/src/analysis/parser-factory.ts +3 -3
- package/src/analysis/python-ast-parser.test.ts +27 -27
- package/src/analysis/python-ast-parser.ts +2 -2
- package/src/analysis/repo-url-resolver.test.ts +82 -82
- package/src/analysis/rust-ast-parser.test.ts +19 -19
- package/src/analysis/rust-ast-parser.ts +17 -27
- package/src/analysis/tree-sitter-parser.test.ts +3 -3
- package/src/analysis/tree-sitter-parser.ts +10 -16
- package/src/cli/commands/crawl.test.ts +40 -24
- package/src/cli/commands/crawl.ts +186 -166
- package/src/cli/commands/index-cmd.test.ts +90 -90
- package/src/cli/commands/index-cmd.ts +52 -36
- package/src/cli/commands/mcp.test.ts +6 -6
- package/src/cli/commands/mcp.ts +2 -2
- package/src/cli/commands/plugin-api.test.ts +16 -18
- package/src/cli/commands/plugin-api.ts +9 -6
- package/src/cli/commands/search.test.ts +16 -7
- package/src/cli/commands/search.ts +124 -87
- package/src/cli/commands/serve.test.ts +67 -25
- package/src/cli/commands/serve.ts +18 -3
- package/src/cli/commands/setup.test.ts +176 -101
- package/src/cli/commands/setup.ts +140 -117
- package/src/cli/commands/store.test.ts +82 -53
- package/src/cli/commands/store.ts +56 -37
- package/src/cli/program.ts +2 -2
- package/src/crawl/article-converter.test.ts +4 -1
- package/src/crawl/article-converter.ts +46 -31
- package/src/crawl/bridge.test.ts +240 -132
- package/src/crawl/bridge.ts +87 -30
- package/src/crawl/claude-client.test.ts +124 -56
- package/src/crawl/claude-client.ts +7 -15
- package/src/crawl/intelligent-crawler.test.ts +65 -22
- package/src/crawl/intelligent-crawler.ts +86 -53
- package/src/crawl/markdown-utils.ts +1 -4
- package/src/db/embeddings.ts +4 -6
- package/src/db/lance.test.ts +4 -4
- package/src/db/lance.ts +16 -12
- package/src/index.ts +26 -17
- package/src/logging/index.ts +1 -5
- package/src/logging/logger.ts +3 -5
- package/src/logging/payload.test.ts +1 -1
- package/src/logging/payload.ts +3 -5
- package/src/mcp/commands/index.ts +2 -2
- package/src/mcp/commands/job.commands.ts +12 -18
- package/src/mcp/commands/meta.commands.ts +13 -13
- package/src/mcp/commands/registry.ts +5 -8
- package/src/mcp/commands/store.commands.ts +19 -19
- package/src/mcp/handlers/execute.handler.test.ts +10 -10
- package/src/mcp/handlers/execute.handler.ts +4 -5
- package/src/mcp/handlers/index.ts +10 -14
- package/src/mcp/handlers/job.handler.test.ts +10 -10
- package/src/mcp/handlers/job.handler.ts +22 -25
- package/src/mcp/handlers/search.handler.test.ts +36 -65
- package/src/mcp/handlers/search.handler.ts +135 -104
- package/src/mcp/handlers/store.handler.test.ts +41 -52
- package/src/mcp/handlers/store.handler.ts +108 -88
- package/src/mcp/schemas/index.test.ts +73 -68
- package/src/mcp/schemas/index.ts +18 -12
- package/src/mcp/server.test.ts +1 -1
- package/src/mcp/server.ts +59 -46
- package/src/plugin/commands.test.ts +230 -95
- package/src/plugin/commands.ts +24 -25
- package/src/plugin/dependency-analyzer.test.ts +52 -52
- package/src/plugin/dependency-analyzer.ts +85 -22
- package/src/plugin/git-clone.test.ts +24 -13
- package/src/plugin/git-clone.ts +3 -7
- package/src/server/app.test.ts +109 -109
- package/src/server/app.ts +32 -23
- package/src/server/index.test.ts +64 -66
- package/src/services/chunking.service.test.ts +32 -32
- package/src/services/chunking.service.ts +16 -9
- package/src/services/code-graph.service.test.ts +30 -36
- package/src/services/code-graph.service.ts +24 -10
- package/src/services/code-unit.service.test.ts +55 -11
- package/src/services/code-unit.service.ts +85 -11
- package/src/services/config.service.test.ts +37 -18
- package/src/services/config.service.ts +30 -7
- package/src/services/index.service.test.ts +49 -18
- package/src/services/index.service.ts +98 -48
- package/src/services/index.ts +6 -9
- package/src/services/job.service.test.ts +22 -22
- package/src/services/job.service.ts +18 -18
- package/src/services/project-root.service.test.ts +1 -3
- package/src/services/search.service.test.ts +248 -120
- package/src/services/search.service.ts +286 -156
- package/src/services/services.test.ts +1 -1
- package/src/services/snippet.service.test.ts +14 -6
- package/src/services/snippet.service.ts +7 -5
- package/src/services/store.service.test.ts +68 -29
- package/src/services/store.service.ts +41 -12
- package/src/services/watch.service.test.ts +34 -14
- package/src/services/watch.service.ts +11 -1
- package/src/types/brands.test.ts +3 -1
- package/src/types/index.ts +2 -13
- package/src/types/search.ts +10 -8
- package/src/utils/type-guards.test.ts +20 -15
- package/src/utils/type-guards.ts +1 -1
- package/src/workers/background-worker-cli.ts +2 -2
- package/src/workers/background-worker.test.ts +54 -40
- package/src/workers/background-worker.ts +76 -60
- package/src/workers/spawn-worker.test.ts +22 -10
- package/src/workers/spawn-worker.ts +6 -6
- package/tests/analysis/ast-parser.test.ts +3 -3
- package/tests/analysis/code-graph.test.ts +5 -5
- package/tests/fixtures/code-snippets/api/error-handling.ts +4 -15
- package/tests/fixtures/code-snippets/api/rest-controller.ts +3 -9
- package/tests/fixtures/code-snippets/auth/jwt-auth.ts +5 -21
- package/tests/fixtures/code-snippets/auth/oauth-flow.ts +4 -4
- package/tests/fixtures/code-snippets/database/repository-pattern.ts +11 -3
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/aws-lambda/handler.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-pages/handler.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/adapter/cloudflare-workers/serve-static.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/client/client.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/client/types.ts +22 -20
- package/tests/fixtures/corpus/oss-repos/hono/src/context.ts +13 -10
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/accepts/accepts.ts +10 -7
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/adapter/index.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/css/index.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/factory/index.ts +16 -16
- package/tests/fixtures/corpus/oss-repos/hono/src/helper/ssg/ssg.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/hono-base.ts +3 -3
- package/tests/fixtures/corpus/oss-repos/hono/src/hono.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/css.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/intrinsic-element/components.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/dom/render.ts +7 -7
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/hooks/index.ts +3 -3
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/intrinsic-element/components.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/jsx/utils.ts +6 -6
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/jsx-renderer/index.ts +3 -3
- package/tests/fixtures/corpus/oss-repos/hono/src/middleware/serve-static/index.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/preset/quick.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/preset/tiny.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/router/pattern-router/router.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/node.ts +4 -4
- package/tests/fixtures/corpus/oss-repos/hono/src/router/reg-exp-router/router.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/router/trie-router/node.ts +1 -1
- package/tests/fixtures/corpus/oss-repos/hono/src/types.ts +166 -169
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/body.ts +8 -8
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/color.ts +3 -3
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/cookie.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/encode.ts +2 -2
- package/tests/fixtures/corpus/oss-repos/hono/src/utils/types.ts +30 -33
- package/tests/fixtures/corpus/oss-repos/hono/src/validator/validator.ts +2 -2
- package/tests/fixtures/test-server.ts +3 -2
- package/tests/helpers/performance-metrics.ts +8 -25
- package/tests/helpers/search-relevance.ts +14 -69
- package/tests/integration/cli-consistency.test.ts +5 -4
- package/tests/integration/python-bridge.test.ts +13 -3
- package/tests/mcp/server.test.ts +1 -1
- package/tests/services/code-unit.service.test.ts +48 -0
- package/tests/services/job.service.test.ts +124 -0
- package/tests/services/search.progressive-context.test.ts +2 -2
- package/.claude-plugin/plugin.json +0 -13
- package/dist/chunk-6PBP5DVD.js.map +0 -1
- package/dist/chunk-L2YVNC63.js.map +0 -1
- package/dist/chunk-RST4XGRL.js.map +0 -1
- package/dist/chunk-WT2DAEO7.js.map +0 -1
- package/dist/watch.service-YAIKKDCF.js +0 -7
- package/skills/atomic-commits/SKILL.md +0 -77
- /package/dist/{watch.service-YAIKKDCF.js.map → watch.service-BJV3TI3F.js.map} +0 -0
package/src/logging/index.ts
CHANGED
package/src/logging/logger.ts
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* - Child loggers per module for context
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import pino, { type Logger, type LoggerOptions } from 'pino';
|
|
12
|
-
import { homedir } from 'node:os';
|
|
13
11
|
import { mkdirSync, existsSync } from 'node:fs';
|
|
12
|
+
import { homedir } from 'node:os';
|
|
14
13
|
import { join } from 'node:path';
|
|
14
|
+
import pino, { type Logger, type LoggerOptions } from 'pino';
|
|
15
15
|
|
|
16
16
|
/** Valid log levels */
|
|
17
17
|
export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
|
|
@@ -47,9 +47,7 @@ function getLogLevel(): LogLevel {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
if (!isValidLogLevel(level)) {
|
|
50
|
-
throw new Error(
|
|
51
|
-
`Invalid LOG_LEVEL: "${level}". Valid values: ${VALID_LEVELS.join(', ')}`
|
|
52
|
-
);
|
|
50
|
+
throw new Error(`Invalid LOG_LEVEL: "${level}". Valid values: ${VALID_LEVELS.join(', ')}`);
|
|
53
51
|
}
|
|
54
52
|
|
|
55
53
|
return level;
|
|
@@ -6,7 +6,7 @@ import { tmpdir } from 'node:os';
|
|
|
6
6
|
// Mock logger module before importing payload
|
|
7
7
|
vi.mock('./logger.js', () => ({
|
|
8
8
|
getLogDirectory: vi.fn(),
|
|
9
|
-
isLevelEnabled: vi.fn()
|
|
9
|
+
isLevelEnabled: vi.fn(),
|
|
10
10
|
}));
|
|
11
11
|
|
|
12
12
|
import { summarizePayload, truncateForLog } from './payload.js';
|
package/src/logging/payload.ts
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* - Optionally dumping full content to separate files at trace level
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { createHash } from 'node:crypto';
|
|
9
10
|
import { writeFileSync, mkdirSync, existsSync } from 'node:fs';
|
|
10
11
|
import { join } from 'node:path';
|
|
11
|
-
import { createHash } from 'node:crypto';
|
|
12
12
|
import { getLogDirectory, isLevelEnabled } from './logger.js';
|
|
13
13
|
|
|
14
14
|
/** Maximum characters for log preview */
|
|
@@ -40,9 +40,7 @@ function getPayloadDir(): string {
|
|
|
40
40
|
|
|
41
41
|
/** Generate a safe filename from an identifier */
|
|
42
42
|
function safeFilename(identifier: string): string {
|
|
43
|
-
return identifier
|
|
44
|
-
.replace(/[^a-zA-Z0-9-]/g, '_')
|
|
45
|
-
.substring(0, 50);
|
|
43
|
+
return identifier.replace(/[^a-zA-Z0-9-]/g, '_').substring(0, 50);
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
/**
|
|
@@ -117,5 +115,5 @@ export function truncateForLog(content: string, maxLength: number = MAX_PREVIEW_
|
|
|
117
115
|
if (content.length <= maxLength) {
|
|
118
116
|
return content;
|
|
119
117
|
}
|
|
120
|
-
return content.substring(0, maxLength)
|
|
118
|
+
return `${content.substring(0, maxLength)}... [truncated]`;
|
|
121
119
|
}
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* Import this module to ensure all commands are available.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { commandRegistry } from './registry.js';
|
|
9
|
-
import { storeCommands } from './store.commands.js';
|
|
10
8
|
import { jobCommands } from './job.commands.js';
|
|
11
9
|
import { metaCommands } from './meta.commands.js';
|
|
10
|
+
import { commandRegistry } from './registry.js';
|
|
11
|
+
import { storeCommands } from './store.commands.js';
|
|
12
12
|
|
|
13
13
|
// Register all commands
|
|
14
14
|
commandRegistry.registerAll(storeCommands);
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { handleCheckJobStatus, handleListJobs, handleCancelJob } from '../handlers/job.handler.js';
|
|
2
3
|
import type { CommandDefinition } from './registry.js';
|
|
3
|
-
import type {
|
|
4
|
-
CheckJobStatusArgs,
|
|
5
|
-
ListJobsArgs,
|
|
6
|
-
CancelJobArgs
|
|
7
|
-
} from '../schemas/index.js';
|
|
8
|
-
import {
|
|
9
|
-
handleCheckJobStatus,
|
|
10
|
-
handleListJobs,
|
|
11
|
-
handleCancelJob
|
|
12
|
-
} from '../handlers/job.handler.js';
|
|
4
|
+
import type { CheckJobStatusArgs, ListJobsArgs, CancelJobArgs } from '../schemas/index.js';
|
|
13
5
|
|
|
14
6
|
/**
|
|
15
7
|
* Job management commands for the execute meta-tool
|
|
@@ -28,27 +20,29 @@ export const jobCommands: CommandDefinition[] = [
|
|
|
28
20
|
description: 'List all background jobs',
|
|
29
21
|
argsSchema: z.object({
|
|
30
22
|
activeOnly: z.boolean().optional().describe('Only show active jobs'),
|
|
31
|
-
status: z
|
|
23
|
+
status: z
|
|
24
|
+
.enum(['pending', 'running', 'completed', 'failed', 'cancelled'])
|
|
32
25
|
.optional()
|
|
33
|
-
.describe('Filter by job status')
|
|
26
|
+
.describe('Filter by job status'),
|
|
34
27
|
}),
|
|
35
|
-
handler: (args, context) => handleListJobs(args as unknown as ListJobsArgs, context)
|
|
28
|
+
handler: (args, context) => handleListJobs(args as unknown as ListJobsArgs, context),
|
|
36
29
|
},
|
|
37
30
|
{
|
|
38
31
|
name: 'job:status',
|
|
39
32
|
description: 'Check the status of a specific background job',
|
|
40
33
|
argsSchema: z.object({
|
|
41
|
-
jobId: z.string().min(1).describe('Job ID to check')
|
|
34
|
+
jobId: z.string().min(1).describe('Job ID to check'),
|
|
42
35
|
}),
|
|
43
|
-
handler: (args, context) =>
|
|
36
|
+
handler: (args, context) =>
|
|
37
|
+
handleCheckJobStatus(args as unknown as CheckJobStatusArgs, context),
|
|
44
38
|
},
|
|
45
39
|
{
|
|
46
40
|
name: 'job:cancel',
|
|
47
41
|
description: 'Cancel a running or pending background job',
|
|
48
42
|
argsSchema: z.object({
|
|
49
|
-
jobId: z.string().min(1).describe('Job ID to cancel')
|
|
43
|
+
jobId: z.string().min(1).describe('Job ID to cancel'),
|
|
50
44
|
}),
|
|
51
|
-
handler: (args, context) => handleCancelJob(args as unknown as CancelJobArgs, context)
|
|
52
|
-
}
|
|
45
|
+
handler: (args, context) => handleCancelJob(args as unknown as CancelJobArgs, context),
|
|
46
|
+
},
|
|
53
47
|
];
|
|
54
48
|
/* eslint-enable @typescript-eslint/consistent-type-assertions */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { commandRegistry, generateHelp } from './registry.js';
|
|
2
3
|
import type { CommandDefinition } from './registry.js';
|
|
3
4
|
import type { ToolResponse } from '../types.js';
|
|
4
|
-
import { commandRegistry, generateHelp } from './registry.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Meta commands for introspection and help
|
|
@@ -15,26 +15,26 @@ export const metaCommands: CommandDefinition[] = [
|
|
|
15
15
|
description: 'List all available commands',
|
|
16
16
|
handler: (): Promise<ToolResponse> => {
|
|
17
17
|
const commands = commandRegistry.all();
|
|
18
|
-
const commandList = commands.map(cmd => ({
|
|
18
|
+
const commandList = commands.map((cmd) => ({
|
|
19
19
|
name: cmd.name,
|
|
20
|
-
description: cmd.description
|
|
20
|
+
description: cmd.description,
|
|
21
21
|
}));
|
|
22
22
|
|
|
23
23
|
return Promise.resolve({
|
|
24
24
|
content: [
|
|
25
25
|
{
|
|
26
26
|
type: 'text' as const,
|
|
27
|
-
text: JSON.stringify({ commands: commandList }, null, 2)
|
|
28
|
-
}
|
|
29
|
-
]
|
|
27
|
+
text: JSON.stringify({ commands: commandList }, null, 2),
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
30
|
});
|
|
31
|
-
}
|
|
31
|
+
},
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
name: 'help',
|
|
35
35
|
description: 'Show help for a specific command or list all commands',
|
|
36
36
|
argsSchema: z.object({
|
|
37
|
-
command: z.string().optional().describe('Command name to get help for')
|
|
37
|
+
command: z.string().optional().describe('Command name to get help for'),
|
|
38
38
|
}),
|
|
39
39
|
handler: (args: Record<string, unknown>): Promise<ToolResponse> => {
|
|
40
40
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
@@ -45,10 +45,10 @@ export const metaCommands: CommandDefinition[] = [
|
|
|
45
45
|
content: [
|
|
46
46
|
{
|
|
47
47
|
type: 'text' as const,
|
|
48
|
-
text: helpText
|
|
49
|
-
}
|
|
50
|
-
]
|
|
48
|
+
text: helpText,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
51
|
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
54
|
];
|
|
@@ -121,9 +121,10 @@ export async function executeCommand(
|
|
|
121
121
|
|
|
122
122
|
// Validate args if schema provided (Zod parse returns unknown, safe to cast after validation)
|
|
123
123
|
/* eslint-disable @typescript-eslint/consistent-type-assertions */
|
|
124
|
-
const validatedArgs: Record<string, unknown> =
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
const validatedArgs: Record<string, unknown> =
|
|
125
|
+
command.argsSchema !== undefined
|
|
126
|
+
? (command.argsSchema.parse(args) as Record<string, unknown>)
|
|
127
|
+
: args;
|
|
127
128
|
/* eslint-enable @typescript-eslint/consistent-type-assertions */
|
|
128
129
|
|
|
129
130
|
return command.handler(validatedArgs, context);
|
|
@@ -139,11 +140,7 @@ export function generateHelp(commandName?: string): string {
|
|
|
139
140
|
throw new Error(`Unknown command: ${commandName}`);
|
|
140
141
|
}
|
|
141
142
|
|
|
142
|
-
const lines = [
|
|
143
|
-
`Command: ${command.name}`,
|
|
144
|
-
`Description: ${command.description}`,
|
|
145
|
-
''
|
|
146
|
-
];
|
|
143
|
+
const lines = [`Command: ${command.name}`, `Description: ${command.description}`, ''];
|
|
147
144
|
|
|
148
145
|
if (command.argsSchema !== undefined) {
|
|
149
146
|
lines.push('Arguments:');
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
handleListStores,
|
|
4
|
+
handleGetStoreInfo,
|
|
5
|
+
handleCreateStore,
|
|
6
|
+
handleIndexStore,
|
|
7
|
+
handleDeleteStore,
|
|
8
|
+
} from '../handlers/store.handler.js';
|
|
2
9
|
import type { CommandDefinition } from './registry.js';
|
|
3
10
|
import type {
|
|
4
11
|
ListStoresArgs,
|
|
5
12
|
GetStoreInfoArgs,
|
|
6
13
|
CreateStoreArgs,
|
|
7
14
|
IndexStoreArgs,
|
|
8
|
-
DeleteStoreArgs
|
|
15
|
+
DeleteStoreArgs,
|
|
9
16
|
} from '../schemas/index.js';
|
|
10
|
-
import {
|
|
11
|
-
handleListStores,
|
|
12
|
-
handleGetStoreInfo,
|
|
13
|
-
handleCreateStore,
|
|
14
|
-
handleIndexStore,
|
|
15
|
-
handleDeleteStore
|
|
16
|
-
} from '../handlers/store.handler.js';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Store management commands for the execute meta-tool
|
|
@@ -31,17 +31,17 @@ export const storeCommands: CommandDefinition[] = [
|
|
|
31
31
|
name: 'stores',
|
|
32
32
|
description: 'List all indexed knowledge stores',
|
|
33
33
|
argsSchema: z.object({
|
|
34
|
-
type: z.enum(['file', 'repo', 'web']).optional().describe('Filter by store type')
|
|
34
|
+
type: z.enum(['file', 'repo', 'web']).optional().describe('Filter by store type'),
|
|
35
35
|
}),
|
|
36
|
-
handler: (args, context) => handleListStores(args as unknown as ListStoresArgs, context)
|
|
36
|
+
handler: (args, context) => handleListStores(args as unknown as ListStoresArgs, context),
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
name: 'store:info',
|
|
40
40
|
description: 'Get detailed information about a specific store',
|
|
41
41
|
argsSchema: z.object({
|
|
42
|
-
store: z.string().min(1).describe('Store name or ID')
|
|
42
|
+
store: z.string().min(1).describe('Store name or ID'),
|
|
43
43
|
}),
|
|
44
|
-
handler: (args, context) => handleGetStoreInfo(args as unknown as GetStoreInfoArgs, context)
|
|
44
|
+
handler: (args, context) => handleGetStoreInfo(args as unknown as GetStoreInfoArgs, context),
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
name: 'store:create',
|
|
@@ -51,25 +51,25 @@ export const storeCommands: CommandDefinition[] = [
|
|
|
51
51
|
type: z.enum(['file', 'repo']).describe('Store type'),
|
|
52
52
|
source: z.string().min(1).describe('Git URL or local path'),
|
|
53
53
|
branch: z.string().optional().describe('Git branch (for repo type)'),
|
|
54
|
-
description: z.string().optional().describe('Store description')
|
|
54
|
+
description: z.string().optional().describe('Store description'),
|
|
55
55
|
}),
|
|
56
|
-
handler: (args, context) => handleCreateStore(args as unknown as CreateStoreArgs, context)
|
|
56
|
+
handler: (args, context) => handleCreateStore(args as unknown as CreateStoreArgs, context),
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
name: 'store:index',
|
|
60
60
|
description: 'Re-index a knowledge store to update search data',
|
|
61
61
|
argsSchema: z.object({
|
|
62
|
-
store: z.string().min(1).describe('Store name or ID')
|
|
62
|
+
store: z.string().min(1).describe('Store name or ID'),
|
|
63
63
|
}),
|
|
64
|
-
handler: (args, context) => handleIndexStore(args as unknown as IndexStoreArgs, context)
|
|
64
|
+
handler: (args, context) => handleIndexStore(args as unknown as IndexStoreArgs, context),
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
name: 'store:delete',
|
|
68
68
|
description: 'Delete a knowledge store and all associated data',
|
|
69
69
|
argsSchema: z.object({
|
|
70
|
-
store: z.string().min(1).describe('Store name or ID')
|
|
70
|
+
store: z.string().min(1).describe('Store name or ID'),
|
|
71
71
|
}),
|
|
72
|
-
handler: (args, context) => handleDeleteStore(args as unknown as DeleteStoreArgs, context)
|
|
73
|
-
}
|
|
72
|
+
handler: (args, context) => handleDeleteStore(args as unknown as DeleteStoreArgs, context),
|
|
73
|
+
},
|
|
74
74
|
];
|
|
75
75
|
/* eslint-enable @typescript-eslint/consistent-type-assertions */
|
|
@@ -19,13 +19,13 @@ describe('execute.handler', () => {
|
|
|
19
19
|
list: async () => [],
|
|
20
20
|
getByIdOrName: async () => undefined,
|
|
21
21
|
create: async () => ({ success: false, error: { message: 'Not implemented in test' } }),
|
|
22
|
-
delete: async () => ({ success: false, error: { message: 'Not implemented in test' } })
|
|
22
|
+
delete: async () => ({ success: false, error: { message: 'Not implemented in test' } }),
|
|
23
23
|
},
|
|
24
24
|
lance: {
|
|
25
|
-
deleteStore: async () => {}
|
|
26
|
-
}
|
|
25
|
+
deleteStore: async () => {},
|
|
26
|
+
},
|
|
27
27
|
} as unknown as HandlerContext['services'],
|
|
28
|
-
options: { dataDir: tempDir }
|
|
28
|
+
options: { dataDir: tempDir },
|
|
29
29
|
};
|
|
30
30
|
});
|
|
31
31
|
|
|
@@ -88,7 +88,7 @@ describe('execute.handler', () => {
|
|
|
88
88
|
it('should handle "store:info" command', async () => {
|
|
89
89
|
const args: ExecuteArgs = {
|
|
90
90
|
command: 'store:info',
|
|
91
|
-
args: { store: 'nonexistent' }
|
|
91
|
+
args: { store: 'nonexistent' },
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
// Should throw since store doesn't exist
|
|
@@ -113,12 +113,12 @@ describe('execute.handler', () => {
|
|
|
113
113
|
const job = jobService.createJob({
|
|
114
114
|
type: 'index',
|
|
115
115
|
details: { storeId: 'test-store' },
|
|
116
|
-
message: 'Testing...'
|
|
116
|
+
message: 'Testing...',
|
|
117
117
|
});
|
|
118
118
|
|
|
119
119
|
const args: ExecuteArgs = {
|
|
120
120
|
command: 'job:status',
|
|
121
|
-
args: { jobId: job.id }
|
|
121
|
+
args: { jobId: job.id },
|
|
122
122
|
};
|
|
123
123
|
const result = await handleExecute(args, mockContext);
|
|
124
124
|
|
|
@@ -134,12 +134,12 @@ describe('execute.handler', () => {
|
|
|
134
134
|
const job = jobService.createJob({
|
|
135
135
|
type: 'index',
|
|
136
136
|
details: { storeId: 'test-store' },
|
|
137
|
-
message: 'Testing...'
|
|
137
|
+
message: 'Testing...',
|
|
138
138
|
});
|
|
139
139
|
|
|
140
140
|
const args: ExecuteArgs = {
|
|
141
141
|
command: 'job:cancel',
|
|
142
|
-
args: { jobId: job.id }
|
|
142
|
+
args: { jobId: job.id },
|
|
143
143
|
};
|
|
144
144
|
const result = await handleExecute(args, mockContext);
|
|
145
145
|
|
|
@@ -168,7 +168,7 @@ describe('execute.handler', () => {
|
|
|
168
168
|
it('should throw for help on unknown command', async () => {
|
|
169
169
|
const args: ExecuteArgs = {
|
|
170
170
|
command: 'help',
|
|
171
|
-
args: { command: 'nonexistent' }
|
|
171
|
+
args: { command: 'nonexistent' },
|
|
172
172
|
};
|
|
173
173
|
|
|
174
174
|
await expect(handleExecute(args, mockContext)).rejects.toThrow(
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ExecuteArgs } from '../schemas/index.js';
|
|
3
|
-
import { ExecuteArgsSchema } from '../schemas/index.js';
|
|
4
|
-
// Import commands module to register all commands
|
|
5
|
-
import '../commands/index.js';
|
|
1
|
+
// Import commands module - side effect registers all commands, then use executeCommand
|
|
6
2
|
import { executeCommand } from '../commands/index.js';
|
|
3
|
+
import { ExecuteArgsSchema } from '../schemas/index.js';
|
|
4
|
+
import type { ExecuteArgs } from '../schemas/index.js';
|
|
5
|
+
import type { ToolHandler, ToolResponse } from '../types.js';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Handle execute requests
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { handleSearch, handleGetFullContext } from './search.handler.js';
|
|
3
|
+
import { SearchArgsSchema, GetFullContextArgsSchema } from '../schemas/index.js';
|
|
2
4
|
import type { ToolHandler } from '../types.js';
|
|
3
|
-
import {
|
|
4
|
-
SearchArgsSchema,
|
|
5
|
-
GetFullContextArgsSchema
|
|
6
|
-
} from '../schemas/index.js';
|
|
7
|
-
import {
|
|
8
|
-
handleSearch,
|
|
9
|
-
handleGetFullContext
|
|
10
|
-
} from './search.handler.js';
|
|
11
5
|
|
|
12
6
|
/**
|
|
13
7
|
* Tool definition with schema and handler
|
|
@@ -16,7 +10,7 @@ export interface ToolDefinition {
|
|
|
16
10
|
name: string;
|
|
17
11
|
description: string;
|
|
18
12
|
schema: z.ZodType;
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- heterogeneous tool registry requires any; schema provides runtime type safety via Zod validation
|
|
20
14
|
handler: ToolHandler<any>;
|
|
21
15
|
}
|
|
22
16
|
|
|
@@ -30,14 +24,16 @@ export interface ToolDefinition {
|
|
|
30
24
|
export const tools: ToolDefinition[] = [
|
|
31
25
|
{
|
|
32
26
|
name: 'search',
|
|
33
|
-
description:
|
|
27
|
+
description:
|
|
28
|
+
'Search all indexed knowledge stores with pattern detection and AI-optimized results. Returns structured code units with progressive context layers.',
|
|
34
29
|
schema: SearchArgsSchema,
|
|
35
|
-
handler: handleSearch
|
|
30
|
+
handler: handleSearch,
|
|
36
31
|
},
|
|
37
32
|
{
|
|
38
33
|
name: 'get_full_context',
|
|
39
|
-
description:
|
|
34
|
+
description:
|
|
35
|
+
'Get complete code and context for a specific search result by ID. Use this after search to get full implementation details.',
|
|
40
36
|
schema: GetFullContextArgsSchema,
|
|
41
|
-
handler: handleGetFullContext
|
|
42
|
-
}
|
|
37
|
+
handler: handleGetFullContext,
|
|
38
|
+
},
|
|
43
39
|
];
|
|
@@ -15,7 +15,7 @@ describe('job.handler', () => {
|
|
|
15
15
|
tempDir = mkdtempSync(join(tmpdir(), 'job-handler-test-'));
|
|
16
16
|
mockContext = {
|
|
17
17
|
services: {} as any,
|
|
18
|
-
options: { dataDir: tempDir }
|
|
18
|
+
options: { dataDir: tempDir },
|
|
19
19
|
};
|
|
20
20
|
});
|
|
21
21
|
|
|
@@ -29,7 +29,7 @@ describe('job.handler', () => {
|
|
|
29
29
|
const job = jobService.createJob({
|
|
30
30
|
type: 'index',
|
|
31
31
|
details: { storeId: 'test-store' },
|
|
32
|
-
message: 'Indexing...'
|
|
32
|
+
message: 'Indexing...',
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
const args: CheckJobStatusArgs = { jobId: job.id };
|
|
@@ -71,12 +71,12 @@ describe('job.handler', () => {
|
|
|
71
71
|
jobService.createJob({
|
|
72
72
|
type: 'index',
|
|
73
73
|
details: { storeId: 'store1' },
|
|
74
|
-
message: 'Indexing store1'
|
|
74
|
+
message: 'Indexing store1',
|
|
75
75
|
});
|
|
76
76
|
jobService.createJob({
|
|
77
77
|
type: 'clone',
|
|
78
78
|
details: { url: 'https://example.com' },
|
|
79
|
-
message: 'Cloning repo'
|
|
79
|
+
message: 'Cloning repo',
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
const args: ListJobsArgs = {};
|
|
@@ -92,12 +92,12 @@ describe('job.handler', () => {
|
|
|
92
92
|
const job1 = jobService.createJob({
|
|
93
93
|
type: 'index',
|
|
94
94
|
details: { storeId: 'store1' },
|
|
95
|
-
message: 'Indexing'
|
|
95
|
+
message: 'Indexing',
|
|
96
96
|
});
|
|
97
97
|
jobService.createJob({
|
|
98
98
|
type: 'clone',
|
|
99
99
|
details: { url: 'https://example.com' },
|
|
100
|
-
message: 'Cloning'
|
|
100
|
+
message: 'Cloning',
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
// Update job1 status
|
|
@@ -116,12 +116,12 @@ describe('job.handler', () => {
|
|
|
116
116
|
const job1 = jobService.createJob({
|
|
117
117
|
type: 'index',
|
|
118
118
|
details: { storeId: 'store1' },
|
|
119
|
-
message: 'Indexing'
|
|
119
|
+
message: 'Indexing',
|
|
120
120
|
});
|
|
121
121
|
jobService.createJob({
|
|
122
122
|
type: 'clone',
|
|
123
123
|
details: { url: 'https://example.com' },
|
|
124
|
-
message: 'Cloning'
|
|
124
|
+
message: 'Cloning',
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
jobService.updateJob(job1.id, { status: 'completed' });
|
|
@@ -141,7 +141,7 @@ describe('job.handler', () => {
|
|
|
141
141
|
const job = jobService.createJob({
|
|
142
142
|
type: 'index',
|
|
143
143
|
details: { storeId: 'test-store' },
|
|
144
|
-
message: 'Indexing...'
|
|
144
|
+
message: 'Indexing...',
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
const args: CancelJobArgs = { jobId: job.id };
|
|
@@ -170,7 +170,7 @@ describe('job.handler', () => {
|
|
|
170
170
|
const job = jobService.createJob({
|
|
171
171
|
type: 'index',
|
|
172
172
|
details: { storeId: 'test-store' },
|
|
173
|
-
message: 'Indexing...'
|
|
173
|
+
message: 'Indexing...',
|
|
174
174
|
});
|
|
175
175
|
|
|
176
176
|
jobService.updateJob(job.id, { status: 'completed' });
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
CheckJobStatusArgs,
|
|
4
|
-
ListJobsArgs,
|
|
5
|
-
CancelJobArgs
|
|
6
|
-
} from '../schemas/index.js';
|
|
1
|
+
import { JobService } from '../../services/job.service.js';
|
|
7
2
|
import {
|
|
8
3
|
CheckJobStatusArgsSchema,
|
|
9
4
|
ListJobsArgsSchema,
|
|
10
|
-
CancelJobArgsSchema
|
|
5
|
+
CancelJobArgsSchema,
|
|
11
6
|
} from '../schemas/index.js';
|
|
12
|
-
import {
|
|
7
|
+
import type { CheckJobStatusArgs, ListJobsArgs, CancelJobArgs } from '../schemas/index.js';
|
|
8
|
+
import type { ToolHandler, ToolResponse } from '../types.js';
|
|
13
9
|
|
|
14
10
|
/**
|
|
15
11
|
* Handle check_job_status requests
|
|
@@ -36,9 +32,9 @@ export const handleCheckJobStatus: ToolHandler<CheckJobStatusArgs> = (
|
|
|
36
32
|
content: [
|
|
37
33
|
{
|
|
38
34
|
type: 'text',
|
|
39
|
-
text: JSON.stringify(job, null, 2)
|
|
40
|
-
}
|
|
41
|
-
]
|
|
35
|
+
text: JSON.stringify(job, null, 2),
|
|
36
|
+
},
|
|
37
|
+
],
|
|
42
38
|
});
|
|
43
39
|
};
|
|
44
40
|
|
|
@@ -47,10 +43,7 @@ export const handleCheckJobStatus: ToolHandler<CheckJobStatusArgs> = (
|
|
|
47
43
|
*
|
|
48
44
|
* Lists all jobs with optional filtering by status or active status.
|
|
49
45
|
*/
|
|
50
|
-
export const handleListJobs: ToolHandler<ListJobsArgs> = (
|
|
51
|
-
args,
|
|
52
|
-
context
|
|
53
|
-
): Promise<ToolResponse> => {
|
|
46
|
+
export const handleListJobs: ToolHandler<ListJobsArgs> = (args, context): Promise<ToolResponse> => {
|
|
54
47
|
// Validate arguments with Zod
|
|
55
48
|
const validated = ListJobsArgsSchema.parse(args);
|
|
56
49
|
|
|
@@ -71,9 +64,9 @@ export const handleListJobs: ToolHandler<ListJobsArgs> = (
|
|
|
71
64
|
content: [
|
|
72
65
|
{
|
|
73
66
|
type: 'text',
|
|
74
|
-
text: JSON.stringify({ jobs }, null, 2)
|
|
75
|
-
}
|
|
76
|
-
]
|
|
67
|
+
text: JSON.stringify({ jobs }, null, 2),
|
|
68
|
+
},
|
|
69
|
+
],
|
|
77
70
|
});
|
|
78
71
|
};
|
|
79
72
|
|
|
@@ -105,12 +98,16 @@ export const handleCancelJob: ToolHandler<CancelJobArgs> = (
|
|
|
105
98
|
content: [
|
|
106
99
|
{
|
|
107
100
|
type: 'text',
|
|
108
|
-
text: JSON.stringify(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
101
|
+
text: JSON.stringify(
|
|
102
|
+
{
|
|
103
|
+
success: true,
|
|
104
|
+
job,
|
|
105
|
+
message: 'Job cancelled successfully',
|
|
106
|
+
},
|
|
107
|
+
null,
|
|
108
|
+
2
|
|
109
|
+
),
|
|
110
|
+
},
|
|
111
|
+
],
|
|
115
112
|
});
|
|
116
113
|
};
|