minovative-mind-cli 2.13.5 → 2.14.1
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.md +104 -39
- package/dist/services/agent/slashCommands.js +57 -8
- package/dist/services/agent/syntaxAgent.js +13 -0
- package/dist/services/agent-tools.d.ts +1 -1
- package/dist/services/agent-tools.js +2 -2
- package/dist/services/agent.js +119 -7
- package/dist/services/ai.d.ts +19 -0
- package/dist/services/ai.js +97 -5
- package/dist/services/contextAgent.js +23 -0
- package/dist/services/investigationComplexity.js +1 -1
- package/dist/services/mentionEngine.d.ts +385 -0
- package/dist/services/mentionEngine.js +1395 -0
- package/dist/services/orchestration/investigationAgent.js +6 -2
- package/dist/services/orchestration/messageBus.d.ts +26 -3
- package/dist/services/orchestration/messageBus.js +204 -14
- package/dist/services/orchestration/orchestrator.js +4 -0
- package/dist/services/orchestration/scopedTools.js +16 -2
- package/dist/services/orchestration/subAgent.js +14 -2
- package/dist/services/proxyClient.d.ts +38 -2
- package/dist/services/proxyClient.js +42 -24
- package/dist/utils/config.d.ts +75 -0
- package/dist/utils/config.js +93 -0
- package/dist/utils/contextPrompts.d.ts +28 -4
- package/dist/utils/contextPrompts.js +70 -1
- package/dist/utils/historyPrompt.d.ts +166 -7
- package/dist/utils/historyPrompt.js +775 -30
- package/dist/utils/symbolExtractor.d.ts +111 -8
- package/dist/utils/symbolExtractor.js +616 -64
- package/dist/utils/systemPrompts.d.ts +3 -3
- package/dist/utils/systemPrompts.js +5 -3
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Context Mentions and Autocomplete Engine for Minovative Mind CLI.
|
|
3
|
+
*
|
|
4
|
+
* This service provides:
|
|
5
|
+
* 1. **Autocomplete Suggestions**: Real-time suggestion generation for `@files`, `@symbols`,
|
|
6
|
+
* `@git` context helpers, `@workspace` aliases, and `@diagnostics` / special mentions.
|
|
7
|
+
* 2. **Mention Parsing**: Robust parsing of `@mention` tokens in user prompts with support for
|
|
8
|
+
* line ranges (`:10-50`), scoped symbol targets (`@symbol:foo`), git modifiers (`@git:diff`),
|
|
9
|
+
* and cross-workspace references (`@alias/path`).
|
|
10
|
+
* 3. **Context Resolution**: Resolves all mentions in a prompt into structured, sanitized,
|
|
11
|
+
* token-budgeted XML injection blocks ready for LLM consumption.
|
|
12
|
+
*/
|
|
13
|
+
import { SymbolKind } from '../utils/symbolExtractor.js';
|
|
14
|
+
/**
|
|
15
|
+
* Types of context mentions supported by the engine.
|
|
16
|
+
*/
|
|
17
|
+
export type MentionType = 'file' | 'symbol' | 'git' | 'workspace' | 'diagnostics' | 'terminal';
|
|
18
|
+
/**
|
|
19
|
+
* Represents a parsed `@mention` token extracted from a user prompt.
|
|
20
|
+
*/
|
|
21
|
+
export interface ParsedMention {
|
|
22
|
+
/** The full raw matched mention string (e.g. `@src/utils/config.ts`, `@git:diff`, `@symbol:runAgent`) */
|
|
23
|
+
raw: string;
|
|
24
|
+
/** The classified type of mention */
|
|
25
|
+
type: MentionType;
|
|
26
|
+
/** The primary target identifier (e.g. `src/utils/config.ts`, `runAgent`, `diff`, `backend`) */
|
|
27
|
+
target: string;
|
|
28
|
+
/** Optional secondary target (e.g. symbol name if format is `@symbol:file.ts:symbolName`) */
|
|
29
|
+
subTarget?: string;
|
|
30
|
+
/** Optional external workspace alias if referencing a registered external workspace */
|
|
31
|
+
workspaceAlias?: string | null;
|
|
32
|
+
/** Optional line range specified in file mention (1-indexed) */
|
|
33
|
+
lineRange?: {
|
|
34
|
+
start: number;
|
|
35
|
+
end: number;
|
|
36
|
+
};
|
|
37
|
+
/** The 0-based character offsets [start, end] of the mention token in the original prompt */
|
|
38
|
+
range: [number, number];
|
|
39
|
+
/** Whether the mention parsed into a structurally valid format */
|
|
40
|
+
valid: boolean;
|
|
41
|
+
/** Optional parse or resolution warning */
|
|
42
|
+
error?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* An autocomplete suggestion item presented to the user during interactive typing.
|
|
46
|
+
*/
|
|
47
|
+
export interface MentionSuggestion {
|
|
48
|
+
/** The display label shown in autocomplete dropdown */
|
|
49
|
+
label: string;
|
|
50
|
+
/** The text inserted/replaced when this suggestion is selected */
|
|
51
|
+
value: string;
|
|
52
|
+
/** The mention classification type */
|
|
53
|
+
type: MentionType;
|
|
54
|
+
/** Optional category badge for styling (e.g. 'file', 'lines', 'sym', 'git', 'ws', 'diag', 'term') */
|
|
55
|
+
category?: 'file' | 'lines' | 'symbol' | 'sym' | 'git' | 'workspace' | 'ws' | 'diagnostics' | 'diag' | 'terminal' | 'term' | 'doc' | string;
|
|
56
|
+
/** A concise human-readable description (e.g. "Git working tree diff", "File (4.2 KB)") */
|
|
57
|
+
description: string;
|
|
58
|
+
/** Detailed metadata or subtitle */
|
|
59
|
+
detail?: string;
|
|
60
|
+
/** Descriptive helper label indicating category/parsing status */
|
|
61
|
+
helperLabel?: string;
|
|
62
|
+
/** Display icon / glyph */
|
|
63
|
+
icon?: string;
|
|
64
|
+
/** Relevance ranking score (higher is better) */
|
|
65
|
+
score?: number;
|
|
66
|
+
/** External workspace alias if applicable */
|
|
67
|
+
workspaceAlias?: string | null;
|
|
68
|
+
/** Associated file path if applicable */
|
|
69
|
+
filePath?: string;
|
|
70
|
+
/** Associated symbol kind if applicable */
|
|
71
|
+
symbolKind?: SymbolKind | string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Configuration options for generating autocomplete suggestions.
|
|
75
|
+
*/
|
|
76
|
+
export interface MentionSuggestionOptions {
|
|
77
|
+
/** The primary workspace root directory (defaults to process.cwd()) */
|
|
78
|
+
workspaceRoot?: string;
|
|
79
|
+
/** The active search query typed after the `@` symbol */
|
|
80
|
+
query?: string;
|
|
81
|
+
/** The 0-based cursor position in the input string */
|
|
82
|
+
cursorPosition?: number;
|
|
83
|
+
/** Maximum number of suggestions to return (defaults to 25) */
|
|
84
|
+
maxSuggestions?: number;
|
|
85
|
+
/** Filter to specific mention types (e.g. only ['file', 'symbol']) */
|
|
86
|
+
includeTypes?: MentionType[];
|
|
87
|
+
/** Optional pre-computed file list to accelerate suggestion generation */
|
|
88
|
+
cachedFileList?: string[];
|
|
89
|
+
/** Maximum number of files to scan for symbols */
|
|
90
|
+
maxSymbolFiles?: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Result of resolving a single mention's contents.
|
|
94
|
+
*/
|
|
95
|
+
export interface ResolvedMentionContext {
|
|
96
|
+
/** The original parsed mention */
|
|
97
|
+
mention: ParsedMention;
|
|
98
|
+
/** Whether resolution succeeded without fatal errors */
|
|
99
|
+
resolved: boolean;
|
|
100
|
+
/** The structured XML context block representing the resolved content */
|
|
101
|
+
content: string;
|
|
102
|
+
/** Estimated token count of the content block */
|
|
103
|
+
tokenEstimate: number;
|
|
104
|
+
/** Error message if resolution failed */
|
|
105
|
+
error?: string;
|
|
106
|
+
/** Concise status label indicating resolution summary (e.g. "lines 10-50, 420 chars") */
|
|
107
|
+
statusLabel?: string;
|
|
108
|
+
/** Descriptive helper badge/label for status and parsing details */
|
|
109
|
+
helperLabel?: string;
|
|
110
|
+
/** Supplementary structured metadata */
|
|
111
|
+
metadata?: {
|
|
112
|
+
absolutePath?: string;
|
|
113
|
+
relativePath?: string;
|
|
114
|
+
sizeBytes?: number;
|
|
115
|
+
charCount?: number;
|
|
116
|
+
linesCount?: number;
|
|
117
|
+
totalLines?: number;
|
|
118
|
+
lineRange?: {
|
|
119
|
+
start: number;
|
|
120
|
+
end: number;
|
|
121
|
+
};
|
|
122
|
+
isSliced?: boolean;
|
|
123
|
+
workspaceAlias?: string | null;
|
|
124
|
+
symbol?: string;
|
|
125
|
+
filePath?: string;
|
|
126
|
+
kind?: string;
|
|
127
|
+
signature?: string;
|
|
128
|
+
startLine?: number;
|
|
129
|
+
endLine?: number;
|
|
130
|
+
gitSubCommand?: string;
|
|
131
|
+
contextType?: string;
|
|
132
|
+
outputLines?: number;
|
|
133
|
+
isClean?: boolean;
|
|
134
|
+
alias?: string;
|
|
135
|
+
path?: string;
|
|
136
|
+
profile?: string;
|
|
137
|
+
filesCount?: number;
|
|
138
|
+
filesChecked?: number;
|
|
139
|
+
issuesCount?: number;
|
|
140
|
+
issues?: string[];
|
|
141
|
+
platform?: string;
|
|
142
|
+
arch?: string;
|
|
143
|
+
nodeVersion?: string;
|
|
144
|
+
cwd?: string;
|
|
145
|
+
statusLabel?: string;
|
|
146
|
+
helperLabel?: string;
|
|
147
|
+
category?: string;
|
|
148
|
+
[key: string]: any;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Options configuring mention content resolution.
|
|
153
|
+
*/
|
|
154
|
+
export interface ResolveMentionsOptions {
|
|
155
|
+
/** Maximum total character budget for resolved context injection */
|
|
156
|
+
maxChars?: number;
|
|
157
|
+
/** Whether to use AST-scoped outlines for large source files */
|
|
158
|
+
useScopedOutline?: boolean;
|
|
159
|
+
/** Git command execution timeout in milliseconds (defaults to 5000) */
|
|
160
|
+
gitTimeoutMs?: number;
|
|
161
|
+
/** Maximum lines per extracted symbol definition (defaults to 300) */
|
|
162
|
+
symbolMaxLines?: number;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Comprehensive result of parsing and resolving all mentions in a prompt.
|
|
166
|
+
*/
|
|
167
|
+
export interface ResolvedMentionsResult {
|
|
168
|
+
/** The original prompt string as provided by the user */
|
|
169
|
+
originalPrompt: string;
|
|
170
|
+
/** Cleaned prompt string with mentions intact */
|
|
171
|
+
cleanedPrompt: string;
|
|
172
|
+
/** Array of individual resolved mention blocks */
|
|
173
|
+
mentions: ResolvedMentionContext[];
|
|
174
|
+
/** The unified XML context injection block `<context_mentions>...</context_mentions>` */
|
|
175
|
+
formattedContext: string;
|
|
176
|
+
/** Total estimated token count across all resolved mentions */
|
|
177
|
+
totalTokens: number;
|
|
178
|
+
/** Indicates whether any valid mentions were found and processed */
|
|
179
|
+
hasMentions: boolean;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Context Mentions Engine.
|
|
183
|
+
*
|
|
184
|
+
* Core engine responsible for parsing `@` tokens, providing fast autocomplete suggestions,
|
|
185
|
+
* and resolving file, symbol, git, workspace, and diagnostic mentions into structured context.
|
|
186
|
+
*/
|
|
187
|
+
export declare class MentionEngine {
|
|
188
|
+
/** In-memory cache for workspace file listings (TTL: 15 seconds) */
|
|
189
|
+
private fileListCache;
|
|
190
|
+
/** In-memory cache for parsed symbol indexes per file path */
|
|
191
|
+
private symbolIndexCache;
|
|
192
|
+
/** Cache TTL in milliseconds */
|
|
193
|
+
private readonly CACHE_TTL_MS;
|
|
194
|
+
/**
|
|
195
|
+
* Parses all `@mention` tokens from a user prompt text string.
|
|
196
|
+
*
|
|
197
|
+
* Correctly ignores email addresses (e.g. `user@domain.com`) and supports:
|
|
198
|
+
* - `@file:<path>` or `@<path>` (e.g. `@src/index.ts`, `@src/index.ts:10-50`)
|
|
199
|
+
* - `@symbol:<name>` or `@#<name>` or `@symbol:<filePath>:<name>`
|
|
200
|
+
* - `@git:diff`, `@git:staged`, `@git:branch`, `@git:log`, `@git:status`, `@diff`
|
|
201
|
+
* - `@<alias>` or `@<alias>/<path>` for registered external workspaces
|
|
202
|
+
* - `@diagnostics`, `@problems`, `@errors`
|
|
203
|
+
*
|
|
204
|
+
* @param prompt - The input prompt text.
|
|
205
|
+
* @param workspaceRoot - Optional workspace root for alias and file disambiguation.
|
|
206
|
+
* @returns Array of ParsedMention objects.
|
|
207
|
+
*/
|
|
208
|
+
parseMentions(prompt: string, workspaceRoot?: string): ParsedMention[];
|
|
209
|
+
/**
|
|
210
|
+
* Classifies a raw mention token into its appropriate MentionType and targets.
|
|
211
|
+
*
|
|
212
|
+
* @private
|
|
213
|
+
*/
|
|
214
|
+
private classifyMentionToken;
|
|
215
|
+
/**
|
|
216
|
+
* Extracts line range numbers from a path string (e.g. `src/index.ts:10-50` or `src/index.ts#10-50` or `src/index.ts:25`).
|
|
217
|
+
*
|
|
218
|
+
* @private
|
|
219
|
+
*/
|
|
220
|
+
private parseLineRange;
|
|
221
|
+
/**
|
|
222
|
+
* Determines the active mention query at a specific cursor position in an input string.
|
|
223
|
+
*
|
|
224
|
+
* @param input - The current input text.
|
|
225
|
+
* @param cursorPosition - The 0-based cursor offset.
|
|
226
|
+
* @returns Object describing the active mention query and range.
|
|
227
|
+
*/
|
|
228
|
+
getActiveMentionQuery(input: string, cursorPosition: number): {
|
|
229
|
+
query: string;
|
|
230
|
+
startIndex: number;
|
|
231
|
+
endIndex: number;
|
|
232
|
+
isMention: boolean;
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Generates ranked autocomplete suggestions based on the current prompt text and cursor position.
|
|
236
|
+
*
|
|
237
|
+
* @param input - Full prompt input text.
|
|
238
|
+
* @param cursorPosition - Cursor index.
|
|
239
|
+
* @param options - Suggestion configuration options.
|
|
240
|
+
* @returns Array of ranked MentionSuggestion objects.
|
|
241
|
+
*/
|
|
242
|
+
getSuggestions(input: string, cursorPosition: number, options?: Partial<MentionSuggestionOptions>): Promise<MentionSuggestion[]>;
|
|
243
|
+
/**
|
|
244
|
+
* Generates autocomplete suggestions for a given raw query string (the text after '@').
|
|
245
|
+
*
|
|
246
|
+
* @param query - The query string typed after '@'.
|
|
247
|
+
* @param options - Configuration options.
|
|
248
|
+
* @returns Array of ranked MentionSuggestion objects.
|
|
249
|
+
*/
|
|
250
|
+
getSuggestionsForQuery(query?: string, options?: Partial<MentionSuggestionOptions>): Promise<MentionSuggestion[]>;
|
|
251
|
+
/**
|
|
252
|
+
* Generates built-in git, diagnostics, terminal, and symbol template suggestions.
|
|
253
|
+
*
|
|
254
|
+
* @private
|
|
255
|
+
*/
|
|
256
|
+
private getSpecialSuggestions;
|
|
257
|
+
/**
|
|
258
|
+
* Generates registered workspace alias suggestions.
|
|
259
|
+
*
|
|
260
|
+
* @private
|
|
261
|
+
*/
|
|
262
|
+
private getWorkspaceSuggestions;
|
|
263
|
+
/**
|
|
264
|
+
* Generates workspace file suggestions with fast fuzzy/prefix matching.
|
|
265
|
+
*
|
|
266
|
+
* @private
|
|
267
|
+
*/
|
|
268
|
+
private getFileSuggestions;
|
|
269
|
+
/**
|
|
270
|
+
* Generates symbol suggestions across indexed source files.
|
|
271
|
+
*
|
|
272
|
+
* @private
|
|
273
|
+
*/
|
|
274
|
+
private getSymbolSuggestions;
|
|
275
|
+
/**
|
|
276
|
+
* Calculates a match score between a user query and candidate keywords.
|
|
277
|
+
* Higher scores represent stronger matches.
|
|
278
|
+
*
|
|
279
|
+
* @private
|
|
280
|
+
*/
|
|
281
|
+
private calculateMatchScore;
|
|
282
|
+
/**
|
|
283
|
+
* Returns a cached recursive list of all relative file paths in the workspace.
|
|
284
|
+
*
|
|
285
|
+
* @param workspaceRoot - Root directory path.
|
|
286
|
+
* @param maxFiles - Safety ceiling on maximum files returned (defaults to 3000).
|
|
287
|
+
* @returns Array of relative file paths.
|
|
288
|
+
*/
|
|
289
|
+
getFileList(workspaceRoot: string, maxFiles?: number): Promise<string[]>;
|
|
290
|
+
/**
|
|
291
|
+
* Extracts and returns all declared symbols across workspace source files.
|
|
292
|
+
*
|
|
293
|
+
* @param workspaceRoot - Workspace root path.
|
|
294
|
+
* @param maxFiles - Maximum source files to scan.
|
|
295
|
+
* @returns Array of symbol entries.
|
|
296
|
+
*/
|
|
297
|
+
getSymbolIndex(workspaceRoot: string, maxFiles?: number): Promise<Array<{
|
|
298
|
+
symbol: string;
|
|
299
|
+
kind?: SymbolKind;
|
|
300
|
+
filePath: string;
|
|
301
|
+
signature?: string;
|
|
302
|
+
startLine: number;
|
|
303
|
+
endLine: number;
|
|
304
|
+
}>>;
|
|
305
|
+
/**
|
|
306
|
+
* Resolves all mentions in a prompt string into structured context injection blocks.
|
|
307
|
+
*
|
|
308
|
+
* @param prompt - The user prompt containing `@mentions`.
|
|
309
|
+
* @param workspaceRoot - The primary workspace root path.
|
|
310
|
+
* @param options - Resolution and token budgeting options.
|
|
311
|
+
* @returns Comprehensive ResolvedMentionsResult containing structured XML blocks.
|
|
312
|
+
*/
|
|
313
|
+
resolveMentions(prompt: string, workspaceRoot?: string, options?: ResolveMentionsOptions): Promise<ResolvedMentionsResult>;
|
|
314
|
+
/**
|
|
315
|
+
* Resolves a single parsed mention into its structured XML context block.
|
|
316
|
+
*
|
|
317
|
+
* @private
|
|
318
|
+
*/
|
|
319
|
+
private resolveSingleMention;
|
|
320
|
+
/**
|
|
321
|
+
* Resolves a file mention (`@file:src/index.ts` or `@src/index.ts:10-50`).
|
|
322
|
+
*
|
|
323
|
+
* @private
|
|
324
|
+
*/
|
|
325
|
+
private resolveFileMention;
|
|
326
|
+
/**
|
|
327
|
+
* Resolves a symbol mention (`@symbol:extractSymbols` or `@#extractSymbols`).
|
|
328
|
+
*
|
|
329
|
+
* @private
|
|
330
|
+
*/
|
|
331
|
+
private resolveSymbolMention;
|
|
332
|
+
/**
|
|
333
|
+
* Resolves a git mention (`@git:diff`, `@git:staged`, `@git:branch`, `@git:log`, `@git:status`, `@diff`).
|
|
334
|
+
*
|
|
335
|
+
* @private
|
|
336
|
+
*/
|
|
337
|
+
private resolveGitMention;
|
|
338
|
+
/**
|
|
339
|
+
* Resolves a registered workspace alias mention (`@effortlist-ai`).
|
|
340
|
+
*
|
|
341
|
+
* @private
|
|
342
|
+
*/
|
|
343
|
+
private resolveWorkspaceMention;
|
|
344
|
+
/**
|
|
345
|
+
* Resolves diagnostics / problems mention (`@diagnostics`, `@problems`, `@errors`).
|
|
346
|
+
*
|
|
347
|
+
* @private
|
|
348
|
+
*/
|
|
349
|
+
private resolveDiagnosticsMention;
|
|
350
|
+
/**
|
|
351
|
+
* Resolves terminal / console mention (`@terminal`, `@console`).
|
|
352
|
+
*
|
|
353
|
+
* @private
|
|
354
|
+
*/
|
|
355
|
+
private resolveTerminalMention;
|
|
356
|
+
/**
|
|
357
|
+
* Formats resolved mention blocks into a unified XML context injection string,
|
|
358
|
+
* respecting character budget limits.
|
|
359
|
+
*
|
|
360
|
+
* @param resolvedMentions - Array of resolved mention blocks.
|
|
361
|
+
* @param maxChars - Optional maximum character budget.
|
|
362
|
+
* @returns Unified XML context block.
|
|
363
|
+
*/
|
|
364
|
+
formatMentionsContext(resolvedMentions: ResolvedMentionContext[], maxChars?: number): string;
|
|
365
|
+
/**
|
|
366
|
+
* Helper to get an icon glyph corresponding to a file extension.
|
|
367
|
+
*
|
|
368
|
+
* @private
|
|
369
|
+
*/
|
|
370
|
+
private getFileIcon;
|
|
371
|
+
/**
|
|
372
|
+
* Helper to get an icon glyph corresponding to a symbol kind.
|
|
373
|
+
*
|
|
374
|
+
* @private
|
|
375
|
+
*/
|
|
376
|
+
private getSymbolIcon;
|
|
377
|
+
/**
|
|
378
|
+
* Clears in-memory caches for file listings and symbols.
|
|
379
|
+
*/
|
|
380
|
+
clearCaches(): void;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Singleton instance of the MentionEngine.
|
|
384
|
+
*/
|
|
385
|
+
export declare const mentionEngine: MentionEngine;
|