minovative-mind-cli 2.14.1 → 2.14.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.
Files changed (47) hide show
  1. package/README.md +40 -59
  2. package/dist/services/agent/slashCommands.js +144 -13
  3. package/dist/services/agent/toolLoop.js +11 -2
  4. package/dist/services/agent/types.d.ts +9 -2
  5. package/dist/services/agent-tools.d.ts +20 -1
  6. package/dist/services/agent-tools.js +272 -47
  7. package/dist/services/agent.js +43 -18
  8. package/dist/services/ai.d.ts +9 -0
  9. package/dist/services/ai.js +71 -21
  10. package/dist/services/chatHistoryService.d.ts +5 -0
  11. package/dist/services/contextAgent.d.ts +14 -6
  12. package/dist/services/contextAgent.js +36 -10
  13. package/dist/services/orchestration/investigationAgent.js +31 -7
  14. package/dist/services/orchestration/investigationCache.js +19 -9
  15. package/dist/services/orchestration/readCache.d.ts +1 -0
  16. package/dist/services/orchestration/readCache.js +5 -2
  17. package/dist/services/orchestration/scopedTools.js +37 -10
  18. package/dist/services/orchestration/subAgent.js +16 -2
  19. package/dist/services/proxyClient.d.ts +6 -0
  20. package/dist/services/proxyClient.js +24 -10
  21. package/dist/services/sessionSettings.d.ts +66 -0
  22. package/dist/services/sessionSettings.js +126 -0
  23. package/dist/services/userProfileService.d.ts +14 -0
  24. package/dist/services/userProfileService.js +105 -3
  25. package/dist/services/verificationService.js +24 -2
  26. package/dist/utils/analysisRunner.d.ts +120 -8
  27. package/dist/utils/analysisRunner.js +946 -125
  28. package/dist/utils/antiCheatingGuard.d.ts +21 -0
  29. package/dist/utils/antiCheatingGuard.js +554 -0
  30. package/dist/utils/contextPrompts.d.ts +39 -0
  31. package/dist/utils/contextPrompts.js +81 -9
  32. package/dist/utils/contextRanker.d.ts +216 -0
  33. package/dist/utils/contextRanker.js +603 -0
  34. package/dist/utils/dependencyTracer/modules/graph.d.ts +4 -1
  35. package/dist/utils/dependencyTracer/modules/graph.js +11 -0
  36. package/dist/utils/dependencyTracer/modules/types.d.ts +10 -0
  37. package/dist/utils/dependencyTracer.d.ts +40 -2
  38. package/dist/utils/dependencyTracer.js +95 -3
  39. package/dist/utils/fileReadCache.d.ts +58 -0
  40. package/dist/utils/fileReadCache.js +162 -0
  41. package/dist/utils/projectStorage.js +2 -1
  42. package/dist/utils/symbolExtractor.d.ts +12 -0
  43. package/dist/utils/symbolExtractor.js +111 -15
  44. package/dist/utils/systemPrompts.d.ts +4 -3
  45. package/dist/utils/systemPrompts.js +66 -8
  46. package/oclif.manifest.json +1 -1
  47. package/package.json +1 -1
@@ -149,8 +149,13 @@ export async function runVerification(workspaceRoot, abortSignal) {
149
149
  const MAX_VERIFY_OUTPUT = 50_000; // 50KB cap on verification output
150
150
  debugLog(`Running project-level verification command: ${command}`);
151
151
  try {
152
+ const cleanEnv = { ...process.env };
153
+ delete cleanEnv.NEXT_DISABLE_ESLINT;
154
+ delete cleanEnv.TSC_COMPILE_ON_ERROR;
155
+ delete cleanEnv.ESLINT_NO_DEV_ERRORS;
152
156
  const { stdout, stderr } = await execAsync(command, {
153
157
  cwd: workspaceRoot,
158
+ env: cleanEnv,
154
159
  timeout: 120_000, // 120s (2 mins) - builds can take a while (e.g., Next.js, Gradle)
155
160
  maxBuffer: 1024 * 1024, // 1 MB buffer
156
161
  signal: abortSignal,
@@ -235,6 +240,7 @@ ${result.errors.join('\n')}
235
240
  Please fix these errors using the modify_file tool.`;
236
241
  }
237
242
  import { auditFilePerformance, formatAuditForModel, formatAuditForTerminal, isAuditableFile, } from '../utils/performanceAuditor.js';
243
+ import { detectAntiCheatingViolations } from '../utils/antiCheatingGuard.js';
238
244
  export async function verifyChangedFiles(workspaceRoot, filePaths, abortSignal) {
239
245
  if (process.env.MMCLI_SKIP_VERIFICATION === 'true' || process.env.SKIP_VERIFICATION === '1') {
240
246
  return { errors: null, warnings: null };
@@ -267,10 +273,26 @@ export async function verifyChangedFiles(workspaceRoot, filePaths, abortSignal)
267
273
  if (buildResult.aborted) {
268
274
  return '[Verification Aborted]';
269
275
  }
270
- const buildErrorMsg = `[Build Error: ${buildResult.command}]\n${buildResult.errors.join('\n').substring(0, 5000)}`;
276
+ const buildErrorMsg = `[Build Error: ${buildResult.command}]\n${buildResult.errors.join('\n').substring(0, 5000)}\n\nCRITICAL DIRECTIVE: Do NOT modify configuration files (such as next.config.*, tsconfig.json, or package.json) to disable, ignore, or bypass these errors (e.g. ignoreBuildErrors, ignoreDuringBuilds). You MUST fix these errors directly in the source code.`;
271
277
  errors.push(buildErrorMsg);
272
278
  }
273
- // 2. Performance Audit
279
+ // 2. Anti-Cheating Invariant Scan: Ensure no modified files introduced bypass flags
280
+ for (const file of filePaths) {
281
+ if (abortSignal?.aborted)
282
+ return '[Verification Aborted]';
283
+ try {
284
+ const absolutePath = path.resolve(workspaceRoot, file);
285
+ const content = await fs.readFile(absolutePath, 'utf-8');
286
+ const antiCheatViolation = detectAntiCheatingViolations(file, content);
287
+ if (antiCheatViolation) {
288
+ errors.push(`[Verification Rejected - Anti-Cheating Violation in "${file}"]\n${antiCheatViolation}`);
289
+ }
290
+ }
291
+ catch {
292
+ // File might have been deleted or inaccessible
293
+ }
294
+ }
295
+ // 3. Performance Audit
274
296
  // We run this even if the build failed, so the model gets all feedback at once
275
297
  for (const file of filePaths) {
276
298
  if (abortSignal?.aborted)
@@ -2,6 +2,7 @@ export interface EphemeralScriptResult {
2
2
  stdout: string;
3
3
  stderr: string;
4
4
  exitCode: number;
5
+ structuredResult?: unknown;
5
6
  }
6
7
  export interface EphemeralScriptOptions {
7
8
  /** Execution timeout in milliseconds. Defaults to 60,000 (60s). */
@@ -12,6 +13,8 @@ export interface EphemeralScriptOptions {
12
13
  abortSignal?: AbortSignal;
13
14
  /** Optional custom environment variables to merge into execution environment. */
14
15
  env?: Record<string, string>;
16
+ /** Whether to automatically inject sandbox query helpers (emitResult, inspectSymbols). Defaults to true. */
17
+ injectHelpers?: boolean;
15
18
  }
16
19
  export interface PropertyTestConfig {
17
20
  numRuns?: number;
@@ -28,6 +31,34 @@ export interface PropertyTestResult extends EphemeralScriptResult {
28
31
  /** Supported canonical language names list. */
29
32
  export declare const SUPPORTED_LANGUAGES: readonly ["node", "ts-node", "python", "bash", "go", "rust", "c", "cpp", "ruby", "php", "java"];
30
33
  export type SupportedLanguage = (typeof SUPPORTED_LANGUAGES)[number];
34
+ export interface CacheEntry<T> {
35
+ value: T;
36
+ expiresAt: number;
37
+ }
38
+ /**
39
+ * High-performance Least-Recently-Used (LRU) environment and runner cache with per-item TTL.
40
+ * Prevents repetitive filesystem traversal and binary probing across ephemeral executions.
41
+ */
42
+ export declare class EnvironmentLRUCache<T> {
43
+ private readonly cache;
44
+ private readonly max;
45
+ private readonly ttlMs;
46
+ constructor(max?: number, ttlMs?: number);
47
+ get size(): number;
48
+ clear(): void;
49
+ delete(key: string): boolean;
50
+ get(key: string): T | undefined;
51
+ has(key: string): boolean;
52
+ set(key: string, value: T, ttlMs?: number): void;
53
+ }
54
+ /**
55
+ * Clears cached environment and runner resolution data.
56
+ * If workspaceRoot is provided, invalidates cache entries for that workspace;
57
+ * otherwise, clears all cached runner environments globally.
58
+ *
59
+ * @param workspaceRoot - Optional workspace root directory to invalidate.
60
+ */
61
+ export declare function clearRunnerCache(workspaceRoot?: string): void;
31
62
  /**
32
63
  * Normalizes user/AI provided language string to a standard runtime identifier.
33
64
  */
@@ -42,6 +73,7 @@ export declare function normalizeLanguage(lang: string): string;
42
73
  export declare function detectLanguageFromCode(code: string): string;
43
74
  /**
44
75
  * Detects the dominant programming language / runtime for a workspace based on project manifest files.
76
+ * Caches results per workspace root via LRU cache.
45
77
  *
46
78
  * @param workspaceRoot - Path to the workspace root directory.
47
79
  * @returns Detected runtime identifier (e.g., 'rust', 'go', 'python', 'cpp', 'ts-node', 'node').
@@ -58,7 +90,7 @@ export declare function detectProjectRuntime(workspaceRoot: string): Promise<str
58
90
  export declare function resolveEffectiveRuntime(workspaceRoot: string, language?: string, code?: string): Promise<string>;
59
91
  /**
60
92
  * Detects whether the workspace package.json specifies `"type": "module"`.
61
- * Returns `'module'` or `'commonjs'`.
93
+ * Returns `'module'` or `'commonjs'`. Caches results per workspace root via LRU cache.
62
94
  */
63
95
  export declare function detectWorkspaceModuleType(workspaceRoot: string): Promise<'module' | 'commonjs'>;
64
96
  /**
@@ -67,15 +99,87 @@ export declare function detectWorkspaceModuleType(workspaceRoot: string): Promis
67
99
  */
68
100
  export declare function resolveScriptExtension(workspaceRoot: string, language: string, code: string): Promise<string>;
69
101
  /**
70
- * Write a disposable analysis script to a temporary file, execute it using the
102
+ * Information about the resolved TypeScript execution runner for a workspace.
103
+ */
104
+ export interface TypeScriptRunnerInfo {
105
+ runnerType: 'local-tsx' | 'local-ts-node-esm' | 'local-ts-node' | 'npx-tsx' | 'npx-ts-node';
106
+ command: string;
107
+ binaryPath?: string;
108
+ tsconfigPath?: string;
109
+ }
110
+ /**
111
+ * Probes the workspace for available TypeScript runners (tsx, ts-node-esm, ts-node)
112
+ * and resolves tsconfig.json configuration for path aliases.
113
+ * Caches results per workspace root via LRU cache.
114
+ *
115
+ * @param workspaceRoot - Path to the root directory of the workspace.
116
+ * @returns Runner info with executable command and tsconfig path if available.
117
+ */
118
+ export declare function findTypeScriptRunner(workspaceRoot: string): Promise<TypeScriptRunnerInfo>;
119
+ /**
120
+ * Information about the detected Python environment for a workspace.
121
+ */
122
+ export interface PythonEnvironmentInfo {
123
+ pythonBin: string;
124
+ isVenv: boolean;
125
+ venvDir?: string;
126
+ binDir?: string;
127
+ }
128
+ /**
129
+ * Probes the workspace for virtual environments (.venv, venv, env, .env, virtualenv)
130
+ * and resolves the appropriate Python binary path and environment directories.
131
+ * Caches results per workspace root via LRU cache.
132
+ *
133
+ * @param workspaceRoot - Path to workspace root directory.
134
+ * @returns Detected Python interpreter binary and virtual environment metadata.
135
+ */
136
+ export declare function findPythonBinary(workspaceRoot: string): Promise<PythonEnvironmentInfo>;
137
+ /**
138
+ * Injects sandbox query helpers into user/agent script source code.
139
+ * Provides preloaded `emitResult` / `__emitResult` (structured JSON emission via dedicated FD-3 with stdout fallback)
140
+ * and `inspectSymbols` / `inspectObject` (reflection & AST property analysis).
141
+ *
142
+ * Preserves 1:1 source line offsets so compiler/runtime stack traces and syntax diagnostics
143
+ * accurately align with original source lines.
144
+ *
145
+ * @param code - Raw source code of the script.
146
+ * @param language - Target runtime language.
147
+ * @returns Source code augmented with runtime-specific helper preambles.
148
+ */
149
+ export declare function injectSandboxHelpers(code: string, language: string): string;
150
+ /**
151
+ * Parses universal structured result markers (__MINO_RESULT__) from stdout stream.
152
+ * Returns the cleaned human-readable stdout and the parsed structured result object/primitive.
153
+ *
154
+ * @param stdout - Captured standard output text.
155
+ */
156
+ export declare function parseStructuredResult(stdout: string): {
157
+ cleanedStdout: string;
158
+ structuredResult?: unknown;
159
+ };
160
+ /**
161
+ * Diagnostic-first error middleware for sandbox script execution.
162
+ * Intercepts common sandbox execution traps (module resolution, ESM/CJS mismatch,
163
+ * Python import errors, TypeScript compile failures, linker errors) and produces
164
+ * actionable remediation advisories.
165
+ *
166
+ * @param stderr - Standard error output.
167
+ * @param stdout - Standard output text.
168
+ * @param language - Runtime language identifier.
169
+ * @param workspaceRoot - Path to workspace root directory.
170
+ * @returns Formatted diagnostic advisory string or null if no matching pattern.
171
+ */
172
+ export declare function diagnoseSandboxError(stderr: string, stdout: string, language: string, workspaceRoot: string): string | null;
173
+ /**
174
+ * Write a disposable analysis script or stream it directly via stdin, execute it using the
71
175
  * specified language runtime, capture its output, and guarantee cleanup.
72
176
  *
73
- * Scripts are written to `os.tmpdir()` never to the workspace directory to
74
- * prevent pollution, `.gitignore` conflicts, and interference with the user's project.
177
+ * For interpreted runtimes (Node, Python, Bash, Ruby, PHP), zero-disk stdin streaming is used
178
+ * to eliminate disk I/O, watcher churn, and temporary file artifacts.
75
179
  *
76
180
  * @param workspaceRoot - The workspace root, used as the `cwd` for script execution
77
181
  * so relative file paths in the script resolve correctly.
78
- * @param language - The runtime to use: "node", "ts-node", "python", "bash", "go", or "rust".
182
+ * @param language - The runtime to use: "node", "ts-node", "python", "bash", "go", "rust", etc.
79
183
  * @param code - The script source code to execute.
80
184
  * @param options - Optional timeout, output cap, and abort signal.
81
185
  * @returns Captured stdout, stderr, and exit code.
@@ -98,7 +202,7 @@ export declare function generatePBTScriptTemplate(language: string, targetFuncti
98
202
  /**
99
203
  * Runs an ephemeral Property-Based Test script and extracts failure counterexamples and shrink results.
100
204
  */
101
- export declare function runPropertyBasedTest(workspaceRoot: string, code: string, language?: string | EphemeralScriptOptions, config?: PropertyTestConfig & EphemeralScriptOptions): Promise<PropertyTestResult>;
205
+ export declare function runPropertyBasedTest(workspaceRoot: string, code: string, language?: string | EphemeralScriptOptions, config?: EphemeralScriptOptions & PropertyTestConfig): Promise<PropertyTestResult>;
102
206
  export interface FuzzProbeConfig {
103
207
  iterations?: number;
104
208
  maxInputLength?: number;
@@ -151,7 +255,7 @@ export declare function generateFuzzScriptTemplate(language: string, targetFeatu
151
255
  /**
152
256
  * Runs a fuzz probing analysis script and parses failure counterexamples and crash statistics.
153
257
  */
154
- export declare function runFuzzProbe(workspaceRoot: string, code: string, language?: string | EphemeralScriptOptions, config?: FuzzProbeConfig & EphemeralScriptOptions): Promise<FuzzProbeResult>;
258
+ export declare function runFuzzProbe(workspaceRoot: string, code: string, language?: string | EphemeralScriptOptions, config?: EphemeralScriptOptions & FuzzProbeConfig): Promise<FuzzProbeResult>;
155
259
  /**
156
260
  * Generates an ephemeral memory heap analysis script template tailored to the target language.
157
261
  */
@@ -159,8 +263,16 @@ export declare function generateHeapCheckScriptTemplate(language: string, target
159
263
  /**
160
264
  * Runs a memory heap inspection script and extracts heap growth, leak indicators, and memory delta statistics.
161
265
  */
162
- export declare function checkHeapDelta(workspaceRoot: string, code: string, language?: string | EphemeralScriptOptions, config?: HeapDeltaConfig & EphemeralScriptOptions): Promise<HeapDeltaResult>;
266
+ export declare function checkHeapDelta(workspaceRoot: string, code: string, language?: string | EphemeralScriptOptions, config?: EphemeralScriptOptions & HeapDeltaConfig): Promise<HeapDeltaResult>;
163
267
  /**
164
268
  * Executes baseline and candidate scripts, comparing outputs and return values to detect behavioral drift.
165
269
  */
166
270
  export declare function checkBehavioralDrift(workspaceRoot: string, baselineCode: string, candidateCode: string, language?: string | EphemeralScriptOptions, config?: BehavioralDriftConfig & EphemeralScriptOptions): Promise<BehavioralDriftResult>;
271
+ /**
272
+ * Runs a heap delta memory profiling script and evaluates memory growth characteristics.
273
+ */
274
+ export declare function runHeapDeltaCheck(workspaceRoot: string, code: string, language?: string | EphemeralScriptOptions, config?: BehavioralDriftConfig & EphemeralScriptOptions & HeapDeltaConfig): Promise<HeapDeltaResult>;
275
+ /**
276
+ * Runs two scripts (baseline vs candidate) and compares output for behavioral drift.
277
+ */
278
+ export declare function runBehavioralDriftCheck(workspaceRoot: string, baselineCode: string, candidateCode: string, language?: string | EphemeralScriptOptions, config?: BehavioralDriftConfig & EphemeralScriptOptions): Promise<BehavioralDriftResult>;