snow-ai 0.3.6 → 0.3.8
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/dist/agents/compactAgent.js +7 -3
- package/dist/agents/reviewAgent.d.ts +50 -0
- package/dist/agents/reviewAgent.js +264 -0
- package/dist/agents/summaryAgent.d.ts +34 -8
- package/dist/agents/summaryAgent.js +167 -164
- package/dist/api/anthropic.d.ts +1 -0
- package/dist/api/anthropic.js +118 -78
- package/dist/api/chat.d.ts +2 -1
- package/dist/api/chat.js +82 -52
- package/dist/api/gemini.d.ts +1 -0
- package/dist/api/gemini.js +110 -64
- package/dist/api/responses.d.ts +10 -1
- package/dist/api/responses.js +127 -79
- package/dist/api/systemPrompt.d.ts +1 -1
- package/dist/api/systemPrompt.js +36 -7
- package/dist/api/types.d.ts +8 -0
- package/dist/app.js +15 -2
- package/dist/hooks/useCommandHandler.d.ts +1 -0
- package/dist/hooks/useCommandHandler.js +102 -1
- package/dist/hooks/useCommandPanel.d.ts +2 -1
- package/dist/hooks/useCommandPanel.js +19 -1
- package/dist/hooks/useConversation.d.ts +4 -1
- package/dist/hooks/useConversation.js +91 -29
- package/dist/hooks/useKeyboardInput.js +19 -0
- package/dist/hooks/useSnapshotState.d.ts +2 -0
- package/dist/hooks/useTerminalFocus.js +13 -3
- package/dist/mcp/aceCodeSearch.d.ts +2 -76
- package/dist/mcp/aceCodeSearch.js +31 -467
- package/dist/mcp/bash.d.ts +1 -8
- package/dist/mcp/bash.js +20 -40
- package/dist/mcp/filesystem.d.ts +131 -111
- package/dist/mcp/filesystem.js +212 -375
- package/dist/mcp/ideDiagnostics.js +2 -4
- package/dist/mcp/todo.d.ts +1 -17
- package/dist/mcp/todo.js +11 -15
- package/dist/mcp/types/aceCodeSearch.types.d.ts +92 -0
- package/dist/mcp/types/aceCodeSearch.types.js +4 -0
- package/dist/mcp/types/bash.types.d.ts +13 -0
- package/dist/mcp/types/bash.types.js +4 -0
- package/dist/mcp/types/filesystem.types.d.ts +135 -0
- package/dist/mcp/types/filesystem.types.js +4 -0
- package/dist/mcp/types/todo.types.d.ts +27 -0
- package/dist/mcp/types/todo.types.js +4 -0
- package/dist/mcp/types/websearch.types.d.ts +30 -0
- package/dist/mcp/types/websearch.types.js +4 -0
- package/dist/mcp/utils/aceCodeSearch/filesystem.utils.d.ts +34 -0
- package/dist/mcp/utils/aceCodeSearch/filesystem.utils.js +146 -0
- package/dist/mcp/utils/aceCodeSearch/language.utils.d.ts +14 -0
- package/dist/mcp/utils/aceCodeSearch/language.utils.js +99 -0
- package/dist/mcp/utils/aceCodeSearch/search.utils.d.ts +31 -0
- package/dist/mcp/utils/aceCodeSearch/search.utils.js +136 -0
- package/dist/mcp/utils/aceCodeSearch/symbol.utils.d.ts +20 -0
- package/dist/mcp/utils/aceCodeSearch/symbol.utils.js +141 -0
- package/dist/mcp/utils/bash/security.utils.d.ts +20 -0
- package/dist/mcp/utils/bash/security.utils.js +34 -0
- package/dist/mcp/utils/filesystem/batch-operations.utils.d.ts +39 -0
- package/dist/mcp/utils/filesystem/batch-operations.utils.js +182 -0
- package/dist/mcp/utils/filesystem/code-analysis.utils.d.ts +18 -0
- package/dist/mcp/utils/filesystem/code-analysis.utils.js +165 -0
- package/dist/mcp/utils/filesystem/match-finder.utils.d.ts +16 -0
- package/dist/mcp/utils/filesystem/match-finder.utils.js +85 -0
- package/dist/mcp/utils/filesystem/similarity.utils.d.ts +22 -0
- package/dist/mcp/utils/filesystem/similarity.utils.js +75 -0
- package/dist/mcp/utils/todo/date.utils.d.ts +9 -0
- package/dist/mcp/utils/todo/date.utils.js +14 -0
- package/dist/mcp/utils/websearch/browser.utils.d.ts +8 -0
- package/dist/mcp/utils/websearch/browser.utils.js +58 -0
- package/dist/mcp/utils/websearch/text.utils.d.ts +16 -0
- package/dist/mcp/utils/websearch/text.utils.js +39 -0
- package/dist/mcp/websearch.d.ts +1 -31
- package/dist/mcp/websearch.js +21 -97
- package/dist/ui/components/ChatInput.d.ts +3 -1
- package/dist/ui/components/ChatInput.js +12 -5
- package/dist/ui/components/CommandPanel.d.ts +2 -1
- package/dist/ui/components/CommandPanel.js +18 -3
- package/dist/ui/components/MarkdownRenderer.d.ts +1 -2
- package/dist/ui/components/MarkdownRenderer.js +25 -153
- package/dist/ui/components/MessageList.js +5 -5
- package/dist/ui/components/PendingMessages.js +1 -1
- package/dist/ui/components/PendingToolCalls.d.ts +11 -0
- package/dist/ui/components/PendingToolCalls.js +35 -0
- package/dist/ui/components/SessionListScreen.js +37 -17
- package/dist/ui/components/ToolResultPreview.d.ts +1 -1
- package/dist/ui/components/ToolResultPreview.js +119 -155
- package/dist/ui/components/UsagePanel.d.ts +2 -0
- package/dist/ui/components/UsagePanel.js +360 -0
- package/dist/ui/pages/ChatScreen.d.ts +5 -0
- package/dist/ui/pages/ChatScreen.js +164 -85
- package/dist/ui/pages/ConfigScreen.js +23 -19
- package/dist/ui/pages/HeadlessModeScreen.js +2 -4
- package/dist/ui/pages/SubAgentConfigScreen.js +17 -17
- package/dist/ui/pages/SystemPromptConfigScreen.js +7 -6
- package/dist/utils/chatExporter.d.ts +9 -0
- package/dist/utils/chatExporter.js +126 -0
- package/dist/utils/commandExecutor.d.ts +3 -3
- package/dist/utils/commandExecutor.js +4 -4
- package/dist/utils/commands/export.d.ts +2 -0
- package/dist/utils/commands/export.js +12 -0
- package/dist/utils/commands/home.d.ts +2 -0
- package/dist/utils/commands/home.js +12 -0
- package/dist/utils/commands/init.js +3 -3
- package/dist/utils/commands/review.d.ts +2 -0
- package/dist/utils/commands/review.js +81 -0
- package/dist/utils/commands/role.d.ts +2 -0
- package/dist/utils/commands/role.js +37 -0
- package/dist/utils/commands/usage.d.ts +2 -0
- package/dist/utils/commands/usage.js +12 -0
- package/dist/utils/contextCompressor.js +99 -367
- package/dist/utils/fileDialog.d.ts +9 -0
- package/dist/utils/fileDialog.js +74 -0
- package/dist/utils/incrementalSnapshot.d.ts +7 -0
- package/dist/utils/incrementalSnapshot.js +35 -0
- package/dist/utils/mcpToolsManager.js +12 -12
- package/dist/utils/messageFormatter.js +89 -6
- package/dist/utils/proxyUtils.d.ts +15 -0
- package/dist/utils/proxyUtils.js +50 -0
- package/dist/utils/retryUtils.d.ts +27 -0
- package/dist/utils/retryUtils.js +114 -2
- package/dist/utils/sessionConverter.js +11 -0
- package/dist/utils/sessionManager.d.ts +7 -5
- package/dist/utils/sessionManager.js +60 -82
- package/dist/utils/terminal.js +4 -3
- package/dist/utils/toolDisplayConfig.d.ts +16 -0
- package/dist/utils/toolDisplayConfig.js +42 -0
- package/dist/utils/usageLogger.d.ts +11 -0
- package/dist/utils/usageLogger.js +99 -0
- package/package.json +3 -7
|
@@ -44,9 +44,7 @@ export class IdeDiagnosticsMCPService {
|
|
|
44
44
|
// Add summary
|
|
45
45
|
const counts = [
|
|
46
46
|
grouped.error.length > 0 ? `${grouped.error.length} errors` : null,
|
|
47
|
-
grouped.warning.length > 0
|
|
48
|
-
? `${grouped.warning.length} warnings`
|
|
49
|
-
: null,
|
|
47
|
+
grouped.warning.length > 0 ? `${grouped.warning.length} warnings` : null,
|
|
50
48
|
grouped.info.length > 0 ? `${grouped.info.length} info` : null,
|
|
51
49
|
grouped.hint.length > 0 ? `${grouped.hint.length} hints` : null,
|
|
52
50
|
].filter(Boolean);
|
|
@@ -76,7 +74,7 @@ export const ideDiagnosticsService = new IdeDiagnosticsMCPService();
|
|
|
76
74
|
// Export MCP tool definitions
|
|
77
75
|
export const mcpTools = [
|
|
78
76
|
{
|
|
79
|
-
name: '
|
|
77
|
+
name: 'ide-get_diagnostics',
|
|
80
78
|
description: '🔍 Get diagnostics (errors, warnings, hints) for a specific file from the connected IDE. Works with both VSCode and JetBrains IDEs. Returns array of diagnostic information including severity, line number, character position, message, and source. Requires IDE plugin to be installed and running.',
|
|
81
79
|
inputSchema: {
|
|
82
80
|
type: 'object',
|
package/dist/mcp/todo.d.ts
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
import { Tool, type CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
-
|
|
3
|
-
id: string;
|
|
4
|
-
content: string;
|
|
5
|
-
status: 'pending' | 'completed';
|
|
6
|
-
createdAt: string;
|
|
7
|
-
updatedAt: string;
|
|
8
|
-
parentId?: string;
|
|
9
|
-
}
|
|
10
|
-
interface TodoList {
|
|
11
|
-
sessionId: string;
|
|
12
|
-
todos: TodoItem[];
|
|
13
|
-
createdAt: string;
|
|
14
|
-
updatedAt: string;
|
|
15
|
-
}
|
|
16
|
-
type GetCurrentSessionId = () => string | null;
|
|
2
|
+
import type { TodoItem, TodoList, GetCurrentSessionId } from './types/todo.types.js';
|
|
17
3
|
/**
|
|
18
4
|
* TODO 管理服务 - 支持创建、查询、更新 TODO
|
|
19
5
|
*/
|
|
@@ -23,7 +9,6 @@ export declare class TodoService {
|
|
|
23
9
|
constructor(baseDir: string, getCurrentSessionId: GetCurrentSessionId);
|
|
24
10
|
initialize(): Promise<void>;
|
|
25
11
|
private getTodoPath;
|
|
26
|
-
private formatDateForFolder;
|
|
27
12
|
private ensureTodoDir;
|
|
28
13
|
/**
|
|
29
14
|
* 创建或更新会话的 TODO List
|
|
@@ -59,4 +44,3 @@ export declare class TodoService {
|
|
|
59
44
|
*/
|
|
60
45
|
executeTool(toolName: string, args: Record<string, unknown>): Promise<CallToolResult>;
|
|
61
46
|
}
|
|
62
|
-
export {};
|
package/dist/mcp/todo.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
// Utility functions
|
|
4
|
+
import { formatDateForFolder } from './utils/todo/date.utils.js';
|
|
3
5
|
/**
|
|
4
6
|
* TODO 管理服务 - 支持创建、查询、更新 TODO
|
|
5
7
|
*/
|
|
@@ -25,21 +27,15 @@ export class TodoService {
|
|
|
25
27
|
}
|
|
26
28
|
getTodoPath(sessionId, date) {
|
|
27
29
|
const sessionDate = date || new Date();
|
|
28
|
-
const dateFolder =
|
|
30
|
+
const dateFolder = formatDateForFolder(sessionDate);
|
|
29
31
|
const todoDir = path.join(this.todoDir, dateFolder);
|
|
30
32
|
return path.join(todoDir, `${sessionId}.json`);
|
|
31
33
|
}
|
|
32
|
-
formatDateForFolder(date) {
|
|
33
|
-
const year = date.getFullYear();
|
|
34
|
-
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
35
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
36
|
-
return `${year}-${month}-${day}`;
|
|
37
|
-
}
|
|
38
34
|
async ensureTodoDir(date) {
|
|
39
35
|
try {
|
|
40
36
|
await fs.mkdir(this.todoDir, { recursive: true });
|
|
41
37
|
if (date) {
|
|
42
|
-
const dateFolder =
|
|
38
|
+
const dateFolder = formatDateForFolder(date);
|
|
43
39
|
const todoDir = path.join(this.todoDir, dateFolder);
|
|
44
40
|
await fs.mkdir(todoDir, { recursive: true });
|
|
45
41
|
}
|
|
@@ -151,7 +147,7 @@ export class TodoService {
|
|
|
151
147
|
const todoList = await this.getTodoList(sessionId);
|
|
152
148
|
const now = new Date().toISOString();
|
|
153
149
|
const newTodo = {
|
|
154
|
-
id: `
|
|
150
|
+
id: `todo-${Date.now()}_${Math.random().toString(36).slice(2, 9)}`,
|
|
155
151
|
content,
|
|
156
152
|
status: 'pending',
|
|
157
153
|
createdAt: now,
|
|
@@ -420,12 +416,12 @@ Deleting a parent task automatically deletes all its subtasks (parentId relation
|
|
|
420
416
|
}
|
|
421
417
|
try {
|
|
422
418
|
switch (toolName) {
|
|
423
|
-
case '
|
|
419
|
+
case 'create': {
|
|
424
420
|
const { todos } = args;
|
|
425
421
|
const todoItems = todos.map(t => {
|
|
426
422
|
const now = new Date().toISOString();
|
|
427
423
|
return {
|
|
428
|
-
id: `
|
|
424
|
+
id: `todo-${Date.now()}_${Math.random()
|
|
429
425
|
.toString(36)
|
|
430
426
|
.slice(2, 9)}`,
|
|
431
427
|
content: t.content,
|
|
@@ -446,7 +442,7 @@ Deleting a parent task automatically deletes all its subtasks (parentId relation
|
|
|
446
442
|
],
|
|
447
443
|
};
|
|
448
444
|
}
|
|
449
|
-
case '
|
|
445
|
+
case 'get': {
|
|
450
446
|
const result = await this.getTodoList(sessionId);
|
|
451
447
|
return {
|
|
452
448
|
content: [
|
|
@@ -459,7 +455,7 @@ Deleting a parent task automatically deletes all its subtasks (parentId relation
|
|
|
459
455
|
],
|
|
460
456
|
};
|
|
461
457
|
}
|
|
462
|
-
case '
|
|
458
|
+
case 'update': {
|
|
463
459
|
const { todoId, status, content } = args;
|
|
464
460
|
const updates = {};
|
|
465
461
|
if (status)
|
|
@@ -478,7 +474,7 @@ Deleting a parent task automatically deletes all its subtasks (parentId relation
|
|
|
478
474
|
],
|
|
479
475
|
};
|
|
480
476
|
}
|
|
481
|
-
case '
|
|
477
|
+
case 'add': {
|
|
482
478
|
const { content, parentId } = args;
|
|
483
479
|
const result = await this.addTodoItem(sessionId, content, parentId);
|
|
484
480
|
return {
|
|
@@ -490,7 +486,7 @@ Deleting a parent task automatically deletes all its subtasks (parentId relation
|
|
|
490
486
|
],
|
|
491
487
|
};
|
|
492
488
|
}
|
|
493
|
-
case '
|
|
489
|
+
case 'delete': {
|
|
494
490
|
const { todoId } = args;
|
|
495
491
|
const result = await this.deleteTodoItem(sessionId, todoId);
|
|
496
492
|
return {
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for ACE Code Search Service
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Code symbol types
|
|
6
|
+
*/
|
|
7
|
+
export type SymbolType = 'function' | 'class' | 'method' | 'variable' | 'constant' | 'interface' | 'type' | 'enum' | 'import' | 'export';
|
|
8
|
+
/**
|
|
9
|
+
* Code symbol information
|
|
10
|
+
*/
|
|
11
|
+
export interface CodeSymbol {
|
|
12
|
+
name: string;
|
|
13
|
+
type: SymbolType;
|
|
14
|
+
filePath: string;
|
|
15
|
+
line: number;
|
|
16
|
+
column: number;
|
|
17
|
+
endLine?: number;
|
|
18
|
+
endColumn?: number;
|
|
19
|
+
signature?: string;
|
|
20
|
+
scope?: string;
|
|
21
|
+
language: string;
|
|
22
|
+
context?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Code reference types
|
|
26
|
+
*/
|
|
27
|
+
export type ReferenceType = 'definition' | 'usage' | 'import' | 'type';
|
|
28
|
+
/**
|
|
29
|
+
* Code reference information
|
|
30
|
+
*/
|
|
31
|
+
export interface CodeReference {
|
|
32
|
+
symbol: string;
|
|
33
|
+
filePath: string;
|
|
34
|
+
line: number;
|
|
35
|
+
column: number;
|
|
36
|
+
context: string;
|
|
37
|
+
referenceType: ReferenceType;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Semantic search result
|
|
41
|
+
*/
|
|
42
|
+
export interface SemanticSearchResult {
|
|
43
|
+
query: string;
|
|
44
|
+
symbols: CodeSymbol[];
|
|
45
|
+
references: CodeReference[];
|
|
46
|
+
totalResults: number;
|
|
47
|
+
searchTime: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* AST node structure
|
|
51
|
+
*/
|
|
52
|
+
export interface ASTNode {
|
|
53
|
+
type: string;
|
|
54
|
+
name?: string;
|
|
55
|
+
line: number;
|
|
56
|
+
column: number;
|
|
57
|
+
endLine?: number;
|
|
58
|
+
endColumn?: number;
|
|
59
|
+
children?: ASTNode[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Text search result
|
|
63
|
+
*/
|
|
64
|
+
export interface TextSearchResult {
|
|
65
|
+
filePath: string;
|
|
66
|
+
line: number;
|
|
67
|
+
column: number;
|
|
68
|
+
content: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Language configuration
|
|
72
|
+
*/
|
|
73
|
+
export interface LanguageConfig {
|
|
74
|
+
extensions: string[];
|
|
75
|
+
parser: string;
|
|
76
|
+
symbolPatterns: {
|
|
77
|
+
function: RegExp;
|
|
78
|
+
class: RegExp;
|
|
79
|
+
variable?: RegExp;
|
|
80
|
+
import?: RegExp;
|
|
81
|
+
export?: RegExp;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Index statistics
|
|
86
|
+
*/
|
|
87
|
+
export interface IndexStats {
|
|
88
|
+
totalFiles: number;
|
|
89
|
+
totalSymbols: number;
|
|
90
|
+
languageBreakdown: Record<string, number>;
|
|
91
|
+
cacheAge: number;
|
|
92
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for Filesystem MCP Service
|
|
3
|
+
*/
|
|
4
|
+
import type { Diagnostic } from '../../utils/vscodeConnection.js';
|
|
5
|
+
/**
|
|
6
|
+
* Structure analysis result for code validation
|
|
7
|
+
*/
|
|
8
|
+
export interface StructureAnalysis {
|
|
9
|
+
bracketBalance: {
|
|
10
|
+
curly: {
|
|
11
|
+
open: number;
|
|
12
|
+
close: number;
|
|
13
|
+
balanced: boolean;
|
|
14
|
+
};
|
|
15
|
+
round: {
|
|
16
|
+
open: number;
|
|
17
|
+
close: number;
|
|
18
|
+
balanced: boolean;
|
|
19
|
+
};
|
|
20
|
+
square: {
|
|
21
|
+
open: number;
|
|
22
|
+
close: number;
|
|
23
|
+
balanced: boolean;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
htmlTags?: {
|
|
27
|
+
unclosedTags: string[];
|
|
28
|
+
unopenedTags: string[];
|
|
29
|
+
balanced: boolean;
|
|
30
|
+
};
|
|
31
|
+
indentationWarnings: string[];
|
|
32
|
+
codeBlockBoundary?: {
|
|
33
|
+
isInCompleteBlock: boolean;
|
|
34
|
+
suggestion?: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Match candidate for fuzzy search
|
|
39
|
+
*/
|
|
40
|
+
export interface MatchCandidate {
|
|
41
|
+
startLine: number;
|
|
42
|
+
endLine: number;
|
|
43
|
+
similarity: number;
|
|
44
|
+
preview: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* File read configuration
|
|
48
|
+
*/
|
|
49
|
+
export interface FileReadConfig {
|
|
50
|
+
path: string;
|
|
51
|
+
startLine?: number;
|
|
52
|
+
endLine?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Edit by search configuration
|
|
56
|
+
*/
|
|
57
|
+
export interface EditBySearchConfig {
|
|
58
|
+
path: string;
|
|
59
|
+
searchContent: string;
|
|
60
|
+
replaceContent: string;
|
|
61
|
+
occurrence?: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Edit by line range configuration
|
|
65
|
+
*/
|
|
66
|
+
export interface EditByLineConfig {
|
|
67
|
+
path: string;
|
|
68
|
+
startLine: number;
|
|
69
|
+
endLine: number;
|
|
70
|
+
newContent: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Single file edit result (common fields)
|
|
74
|
+
*/
|
|
75
|
+
export interface SingleFileEditResult {
|
|
76
|
+
message: string;
|
|
77
|
+
oldContent: string;
|
|
78
|
+
newContent: string;
|
|
79
|
+
contextStartLine: number;
|
|
80
|
+
contextEndLine: number;
|
|
81
|
+
totalLines: number;
|
|
82
|
+
structureAnalysis?: StructureAnalysis;
|
|
83
|
+
diagnostics?: Diagnostic[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Edit by search single file result
|
|
87
|
+
*/
|
|
88
|
+
export interface EditBySearchSingleResult extends SingleFileEditResult {
|
|
89
|
+
replacedContent: string;
|
|
90
|
+
matchLocation: {
|
|
91
|
+
startLine: number;
|
|
92
|
+
endLine: number;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Edit by line single file result
|
|
97
|
+
*/
|
|
98
|
+
export interface EditByLineSingleResult extends SingleFileEditResult {
|
|
99
|
+
replacedLines: string;
|
|
100
|
+
linesModified: number;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Batch operation result item (generic)
|
|
104
|
+
*/
|
|
105
|
+
export interface BatchResultItem {
|
|
106
|
+
path: string;
|
|
107
|
+
success: boolean;
|
|
108
|
+
error?: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Edit by search batch result item
|
|
112
|
+
*/
|
|
113
|
+
export type EditBySearchBatchResultItem = BatchResultItem & Partial<EditBySearchSingleResult>;
|
|
114
|
+
/**
|
|
115
|
+
* Edit by line batch result item
|
|
116
|
+
*/
|
|
117
|
+
export type EditByLineBatchResultItem = BatchResultItem & Partial<EditByLineSingleResult>;
|
|
118
|
+
/**
|
|
119
|
+
* Batch operation result (generic)
|
|
120
|
+
*/
|
|
121
|
+
export interface BatchOperationResult<T extends BatchResultItem> {
|
|
122
|
+
message: string;
|
|
123
|
+
results: T[];
|
|
124
|
+
totalFiles: number;
|
|
125
|
+
successCount: number;
|
|
126
|
+
failureCount: number;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Edit by search return type
|
|
130
|
+
*/
|
|
131
|
+
export type EditBySearchResult = EditBySearchSingleResult | BatchOperationResult<EditBySearchBatchResultItem>;
|
|
132
|
+
/**
|
|
133
|
+
* Edit by line return type
|
|
134
|
+
*/
|
|
135
|
+
export type EditByLineResult = EditByLineSingleResult | BatchOperationResult<EditByLineBatchResultItem>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for TODO Service
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* TODO item
|
|
6
|
+
*/
|
|
7
|
+
export interface TodoItem {
|
|
8
|
+
id: string;
|
|
9
|
+
content: string;
|
|
10
|
+
status: 'pending' | 'completed';
|
|
11
|
+
createdAt: string;
|
|
12
|
+
updatedAt: string;
|
|
13
|
+
parentId?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* TODO list for a session
|
|
17
|
+
*/
|
|
18
|
+
export interface TodoList {
|
|
19
|
+
sessionId: string;
|
|
20
|
+
todos: TodoItem[];
|
|
21
|
+
createdAt: string;
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Callback function type for getting current session ID
|
|
26
|
+
*/
|
|
27
|
+
export type GetCurrentSessionId = () => string | null;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for Web Search Service
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Search result item
|
|
6
|
+
*/
|
|
7
|
+
export interface SearchResult {
|
|
8
|
+
title: string;
|
|
9
|
+
url: string;
|
|
10
|
+
snippet: string;
|
|
11
|
+
displayUrl: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Search response
|
|
15
|
+
*/
|
|
16
|
+
export interface SearchResponse {
|
|
17
|
+
query: string;
|
|
18
|
+
results: SearchResult[];
|
|
19
|
+
totalResults: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Web page content
|
|
23
|
+
*/
|
|
24
|
+
export interface WebPageContent {
|
|
25
|
+
url: string;
|
|
26
|
+
title: string;
|
|
27
|
+
content: string;
|
|
28
|
+
textLength: number;
|
|
29
|
+
contentPreview: string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem utilities for ACE Code Search
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Default exclusion directories
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_EXCLUDES: string[];
|
|
8
|
+
/**
|
|
9
|
+
* Check if a directory should be excluded based on exclusion patterns
|
|
10
|
+
* @param dirName - Directory name
|
|
11
|
+
* @param fullPath - Full path to directory
|
|
12
|
+
* @param basePath - Base path for relative path calculation
|
|
13
|
+
* @param customExcludes - Custom exclusion patterns
|
|
14
|
+
* @param regexCache - Cache for compiled regex patterns
|
|
15
|
+
* @returns True if directory should be excluded
|
|
16
|
+
*/
|
|
17
|
+
export declare function shouldExcludeDirectory(dirName: string, fullPath: string, basePath: string, customExcludes: string[], regexCache: Map<string, RegExp>): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Load custom exclusion patterns from .gitignore and .snowignore
|
|
20
|
+
* @param basePath - Base path to search for ignore files
|
|
21
|
+
* @returns Array of exclusion patterns
|
|
22
|
+
*/
|
|
23
|
+
export declare function loadExclusionPatterns(basePath: string): Promise<string[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Read file with LRU cache to reduce repeated file system access
|
|
26
|
+
* @param filePath - Path to file
|
|
27
|
+
* @param fileContentCache - Cache for file contents
|
|
28
|
+
* @param maxCacheSize - Maximum cache size
|
|
29
|
+
* @returns File content
|
|
30
|
+
*/
|
|
31
|
+
export declare function readFileWithCache(filePath: string, fileContentCache: Map<string, {
|
|
32
|
+
content: string;
|
|
33
|
+
mtime: number;
|
|
34
|
+
}>, maxCacheSize?: number): Promise<string>;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem utilities for ACE Code Search
|
|
3
|
+
*/
|
|
4
|
+
import { promises as fs } from 'fs';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
/**
|
|
7
|
+
* Default exclusion directories
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_EXCLUDES = [
|
|
10
|
+
'node_modules',
|
|
11
|
+
'.git',
|
|
12
|
+
'dist',
|
|
13
|
+
'build',
|
|
14
|
+
'__pycache__',
|
|
15
|
+
'target',
|
|
16
|
+
'.next',
|
|
17
|
+
'.nuxt',
|
|
18
|
+
'coverage',
|
|
19
|
+
'out',
|
|
20
|
+
'.cache',
|
|
21
|
+
'vendor',
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Check if a directory should be excluded based on exclusion patterns
|
|
25
|
+
* @param dirName - Directory name
|
|
26
|
+
* @param fullPath - Full path to directory
|
|
27
|
+
* @param basePath - Base path for relative path calculation
|
|
28
|
+
* @param customExcludes - Custom exclusion patterns
|
|
29
|
+
* @param regexCache - Cache for compiled regex patterns
|
|
30
|
+
* @returns True if directory should be excluded
|
|
31
|
+
*/
|
|
32
|
+
export function shouldExcludeDirectory(dirName, fullPath, basePath, customExcludes, regexCache) {
|
|
33
|
+
// Check default excludes
|
|
34
|
+
if (DEFAULT_EXCLUDES.includes(dirName)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
// Check hidden directories
|
|
38
|
+
if (dirName.startsWith('.')) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
// Check custom exclusion patterns
|
|
42
|
+
const relativePath = path.relative(basePath, fullPath);
|
|
43
|
+
for (const pattern of customExcludes) {
|
|
44
|
+
// Simple pattern matching: exact match or glob-style wildcards
|
|
45
|
+
if (pattern.includes('*')) {
|
|
46
|
+
// Use cached regex to avoid recompilation
|
|
47
|
+
let regex = regexCache.get(pattern);
|
|
48
|
+
if (!regex) {
|
|
49
|
+
const regexPattern = pattern
|
|
50
|
+
.replace(/\./g, '\\.')
|
|
51
|
+
.replace(/\*/g, '.*');
|
|
52
|
+
regex = new RegExp(`^${regexPattern}$`);
|
|
53
|
+
regexCache.set(pattern, regex);
|
|
54
|
+
}
|
|
55
|
+
if (regex.test(relativePath) || regex.test(dirName)) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// Exact match
|
|
61
|
+
if (relativePath === pattern ||
|
|
62
|
+
dirName === pattern ||
|
|
63
|
+
relativePath.startsWith(pattern + '/')) {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Load custom exclusion patterns from .gitignore and .snowignore
|
|
72
|
+
* @param basePath - Base path to search for ignore files
|
|
73
|
+
* @returns Array of exclusion patterns
|
|
74
|
+
*/
|
|
75
|
+
export async function loadExclusionPatterns(basePath) {
|
|
76
|
+
const patterns = [];
|
|
77
|
+
// Load .gitignore if exists
|
|
78
|
+
const gitignorePath = path.join(basePath, '.gitignore');
|
|
79
|
+
try {
|
|
80
|
+
const gitignoreContent = await fs.readFile(gitignorePath, 'utf-8');
|
|
81
|
+
const lines = gitignoreContent.split('\n');
|
|
82
|
+
for (const line of lines) {
|
|
83
|
+
const trimmed = line.trim();
|
|
84
|
+
// Skip empty lines and comments
|
|
85
|
+
if (trimmed && !trimmed.startsWith('#')) {
|
|
86
|
+
// Remove leading slash and trailing slash
|
|
87
|
+
const pattern = trimmed.replace(/^\//, '').replace(/\/$/, '');
|
|
88
|
+
if (pattern) {
|
|
89
|
+
patterns.push(pattern);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
// .gitignore doesn't exist or cannot be read, skip
|
|
96
|
+
}
|
|
97
|
+
// Load .snowignore if exists
|
|
98
|
+
const snowignorePath = path.join(basePath, '.snowignore');
|
|
99
|
+
try {
|
|
100
|
+
const snowignoreContent = await fs.readFile(snowignorePath, 'utf-8');
|
|
101
|
+
const lines = snowignoreContent.split('\n');
|
|
102
|
+
for (const line of lines) {
|
|
103
|
+
const trimmed = line.trim();
|
|
104
|
+
// Skip empty lines and comments
|
|
105
|
+
if (trimmed && !trimmed.startsWith('#')) {
|
|
106
|
+
// Remove leading slash and trailing slash
|
|
107
|
+
const pattern = trimmed.replace(/^\//, '').replace(/\/$/, '');
|
|
108
|
+
if (pattern) {
|
|
109
|
+
patterns.push(pattern);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
// .snowignore doesn't exist or cannot be read, skip
|
|
116
|
+
}
|
|
117
|
+
return patterns;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Read file with LRU cache to reduce repeated file system access
|
|
121
|
+
* @param filePath - Path to file
|
|
122
|
+
* @param fileContentCache - Cache for file contents
|
|
123
|
+
* @param maxCacheSize - Maximum cache size
|
|
124
|
+
* @returns File content
|
|
125
|
+
*/
|
|
126
|
+
export async function readFileWithCache(filePath, fileContentCache, maxCacheSize = 50) {
|
|
127
|
+
const stats = await fs.stat(filePath);
|
|
128
|
+
const mtime = stats.mtimeMs;
|
|
129
|
+
// Check cache
|
|
130
|
+
const cached = fileContentCache.get(filePath);
|
|
131
|
+
if (cached && cached.mtime === mtime) {
|
|
132
|
+
return cached.content;
|
|
133
|
+
}
|
|
134
|
+
// Read file
|
|
135
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
136
|
+
// Manage cache size (simple LRU: remove oldest if over limit)
|
|
137
|
+
if (fileContentCache.size >= maxCacheSize) {
|
|
138
|
+
const firstKey = fileContentCache.keys().next().value;
|
|
139
|
+
if (firstKey) {
|
|
140
|
+
fileContentCache.delete(firstKey);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Cache the content
|
|
144
|
+
fileContentCache.set(filePath, { content, mtime });
|
|
145
|
+
return content;
|
|
146
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language configuration utilities for ACE Code Search
|
|
3
|
+
*/
|
|
4
|
+
import type { LanguageConfig } from '../../types/aceCodeSearch.types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Language-specific parsers configuration
|
|
7
|
+
*/
|
|
8
|
+
export declare const LANGUAGE_CONFIG: Record<string, LanguageConfig>;
|
|
9
|
+
/**
|
|
10
|
+
* Detect programming language from file extension
|
|
11
|
+
* @param filePath - File path to detect language from
|
|
12
|
+
* @returns Language name or null if not supported
|
|
13
|
+
*/
|
|
14
|
+
export declare function detectLanguage(filePath: string): string | null;
|