autosnippet 3.2.7 → 3.2.9

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 (147) hide show
  1. package/bin/cli.js +13 -5
  2. package/dashboard/dist/assets/index-BTAsOZv2.js +128 -0
  3. package/dashboard/dist/assets/index-C_72Ct98.css +1 -0
  4. package/dashboard/dist/index.html +2 -2
  5. package/lib/cli/AiScanService.js +26 -29
  6. package/lib/cli/SetupService.js +1 -1
  7. package/lib/core/AstAnalyzer.js +27 -5
  8. package/lib/core/analysis/CallEdgeResolver.js +402 -0
  9. package/lib/core/analysis/CallGraphAnalyzer.js +367 -0
  10. package/lib/core/analysis/CallSiteExtractor.js +629 -0
  11. package/lib/core/analysis/DataFlowInferrer.js +57 -0
  12. package/lib/core/analysis/ImportPathResolver.js +189 -0
  13. package/lib/core/analysis/ImportRecord.js +105 -0
  14. package/lib/core/analysis/SymbolTableBuilder.js +211 -0
  15. package/lib/core/ast/ProjectGraph.js +8 -0
  16. package/lib/core/ast/lang-dart.js +352 -5
  17. package/lib/core/ast/lang-go.js +212 -10
  18. package/lib/core/ast/lang-java.js +205 -1
  19. package/lib/core/ast/lang-kotlin.js +330 -1
  20. package/lib/core/ast/lang-python.js +31 -2
  21. package/lib/core/ast/lang-rust.js +284 -3
  22. package/lib/core/ast/lang-swift.js +180 -1
  23. package/lib/core/ast/lang-typescript.js +290 -1
  24. package/lib/core/discovery/index.js +2 -2
  25. package/lib/external/ai/AiProvider.js +66 -172
  26. package/lib/external/ai/providers/GoogleGeminiProvider.js +23 -1
  27. package/lib/external/mcp/McpServer.js +1 -0
  28. package/lib/external/mcp/handlers/bootstrap/BootstrapSession.js +1 -1
  29. package/lib/external/mcp/handlers/bootstrap/ExternalSubmissionTracker.js +3 -3
  30. package/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.js +22 -1
  31. package/lib/external/mcp/handlers/bootstrap/pipeline/IncrementalBootstrap.js +1 -1
  32. package/lib/external/mcp/handlers/bootstrap/pipeline/dimension-configs.js +2 -1
  33. package/lib/external/mcp/handlers/bootstrap/pipeline/dimension-context.js +8 -8
  34. package/lib/external/mcp/handlers/bootstrap/pipeline/noAiFallback.js +1 -1
  35. package/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +311 -162
  36. package/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.js +102 -7
  37. package/lib/external/mcp/handlers/bootstrap/shared/dimension-sop.js +1 -1
  38. package/lib/external/mcp/handlers/bootstrap-external.js +9 -2
  39. package/lib/external/mcp/handlers/bootstrap-internal.js +19 -8
  40. package/lib/external/mcp/handlers/consolidated.js +9 -0
  41. package/lib/external/mcp/handlers/dimension-complete-external.js +6 -6
  42. package/lib/external/mcp/handlers/guard.js +3 -3
  43. package/lib/external/mcp/handlers/structure.js +62 -0
  44. package/lib/external/mcp/handlers/wiki-external.js +66 -3
  45. package/lib/external/mcp/tools.js +36 -1
  46. package/lib/http/HttpServer.js +1 -1
  47. package/lib/http/middleware/requestLogger.js +1 -0
  48. package/lib/http/routes/ai.js +240 -35
  49. package/lib/http/routes/candidates.js +2 -3
  50. package/lib/http/routes/extract.js +13 -11
  51. package/lib/http/routes/modules.js +2 -2
  52. package/lib/http/routes/recipes.js +9 -5
  53. package/lib/http/routes/remote.js +149 -270
  54. package/lib/http/routes/violations.js +0 -54
  55. package/lib/http/utils/sse-sessions.js +1 -1
  56. package/lib/infrastructure/logging/Logger.js +5 -4
  57. package/lib/infrastructure/monitoring/PerformanceMonitor.js +3 -2
  58. package/lib/injection/ServiceContainer.js +70 -28
  59. package/lib/platform/ScreenCaptureService.js +177 -0
  60. package/lib/platform/ios/index.js +2 -2
  61. package/lib/platform/ios/routes/spm.js +2 -2
  62. package/lib/platform/ios/spm/PackageSwiftParser.js +14 -3
  63. package/lib/platform/ios/spm/SpmDiscoverer.js +123 -17
  64. package/lib/platform/ios/spm/{SpmService.js → SpmHelper.js} +43 -675
  65. package/lib/platform/ios/xcode/XcodeWriteUtils.js +1 -1
  66. package/lib/service/agent/AgentEventBus.js +207 -0
  67. package/lib/service/agent/AgentFactory.js +490 -0
  68. package/lib/service/agent/AgentMessage.js +240 -0
  69. package/lib/service/agent/AgentRouter.js +228 -0
  70. package/lib/service/agent/AgentRuntime.js +1016 -0
  71. package/lib/service/agent/AgentState.js +217 -0
  72. package/lib/service/agent/IntentClassifier.js +331 -0
  73. package/lib/service/agent/LarkTransport.js +389 -0
  74. package/lib/service/agent/capabilities.js +408 -0
  75. package/lib/service/{chat → agent/context}/ContextWindow.js +37 -12
  76. package/lib/service/{chat → agent/context}/ExplorationTracker.js +77 -22
  77. package/lib/service/{chat → agent/core}/ChatAgentPrompts.js +14 -2
  78. package/lib/service/agent/core/LoopContext.js +170 -0
  79. package/lib/service/agent/core/MessageAdapter.js +223 -0
  80. package/lib/service/agent/core/ToolExecutionPipeline.js +376 -0
  81. package/lib/service/{chat → agent/domain}/ChatAgentTasks.js +19 -98
  82. package/lib/service/{chat → agent/domain}/EpisodicConsolidator.js +7 -7
  83. package/lib/service/{chat → agent/domain}/EvidenceCollector.js +4 -2
  84. package/lib/service/{chat/AnalystAgent.js → agent/domain/insight-analyst.js} +37 -172
  85. package/lib/service/{chat/HandoffProtocol.js → agent/domain/insight-gate.js} +91 -123
  86. package/lib/service/agent/domain/insight-producer.js +267 -0
  87. package/lib/service/agent/domain/scan-prompts.js +105 -0
  88. package/lib/service/agent/forced-summary.js +266 -0
  89. package/lib/service/agent/index.js +91 -0
  90. package/lib/service/{chat → agent}/memory/ActiveContext.js +3 -1
  91. package/lib/service/{chat → agent}/memory/MemoryCoordinator.js +7 -7
  92. package/lib/service/{chat/ProjectSemanticMemory.js → agent/memory/PersistentMemory.js} +359 -89
  93. package/lib/service/{chat → agent}/memory/SessionStore.js +5 -4
  94. package/lib/service/{chat → agent}/memory/index.js +1 -1
  95. package/lib/service/agent/policies.js +442 -0
  96. package/lib/service/agent/presets.js +303 -0
  97. package/lib/service/agent/strategies.js +717 -0
  98. package/lib/service/{chat → agent/tools}/ToolRegistry.js +3 -3
  99. package/lib/service/agent/tools/ai-analysis.js +75 -0
  100. package/lib/service/{chat → agent}/tools/ast-graph.js +229 -32
  101. package/lib/service/{chat → agent}/tools/composite.js +2 -1
  102. package/lib/service/{chat → agent}/tools/guard.js +1 -121
  103. package/lib/service/{chat → agent}/tools/index.js +33 -22
  104. package/lib/service/{chat → agent}/tools/infrastructure.js +6 -1
  105. package/lib/service/agent/tools/knowledge-graph.js +112 -0
  106. package/lib/service/agent/tools/scan-recipe.js +189 -0
  107. package/lib/service/agent/tools/system-interaction.js +476 -0
  108. package/lib/service/automation/DirectiveDetector.js +0 -1
  109. package/lib/service/automation/FileWatcher.js +0 -8
  110. package/lib/service/automation/handlers/CreateHandler.js +7 -3
  111. package/lib/service/automation/handlers/DraftHandler.js +7 -6
  112. package/lib/service/cursor/CursorDeliveryPipeline.js +167 -1
  113. package/lib/service/knowledge/CodeEntityGraph.js +327 -2
  114. package/lib/service/knowledge/KnowledgeService.js +5 -1
  115. package/lib/service/module/ModuleService.js +49 -73
  116. package/lib/service/skills/SignalCollector.js +26 -19
  117. package/lib/service/snippet/codecs/VSCodeCodec.js +1 -1
  118. package/lib/service/wiki/WikiGenerator.js +1 -1
  119. package/lib/shared/FieldSpec.js +1 -1
  120. package/lib/shared/PathGuard.js +1 -1
  121. package/lib/shared/StyleGuide.js +1 -1
  122. package/package.json +4 -1
  123. package/resources/native-ui/screenshot.swift +228 -0
  124. package/dashboard/dist/assets/index-BaGY7kJI.css +0 -1
  125. package/dashboard/dist/assets/index-DfHY_3ln.js +0 -128
  126. package/lib/core/discovery/SpmDiscoverer.js +0 -5
  127. package/lib/external/mcp/handlers/bootstrap/pipeline/EpisodicMemory.js +0 -749
  128. package/lib/external/mcp/handlers/bootstrap/pipeline/ToolResultCache.js +0 -277
  129. package/lib/http/routes/spm.js +0 -5
  130. package/lib/infrastructure/external/XcodeAutomation.js +0 -15
  131. package/lib/service/chat/ChatAgent.js +0 -1602
  132. package/lib/service/chat/Memory.js +0 -161
  133. package/lib/service/chat/ProducerAgent.js +0 -431
  134. package/lib/service/chat/ReasoningTrace.js +0 -523
  135. package/lib/service/chat/TaskPipeline.js +0 -357
  136. package/lib/service/chat/WorkingMemory.js +0 -357
  137. package/lib/service/chat/memory/PersistentMemory.js +0 -450
  138. package/lib/service/chat/tools/ai-analysis.js +0 -267
  139. package/lib/service/chat/tools/knowledge-graph.js +0 -234
  140. package/lib/service/chat/tools.js +0 -18
  141. package/lib/service/snippet/PlaceholderConverter.js +0 -5
  142. package/lib/service/snippet/codecs/XcodeCodec.js +0 -5
  143. /package/lib/service/{chat → agent}/ConversationStore.js +0 -0
  144. /package/lib/service/{chat → agent}/tools/_shared.js +0 -0
  145. /package/lib/service/{chat → agent}/tools/lifecycle.js +0 -0
  146. /package/lib/service/{chat → agent}/tools/project-access.js +0 -0
  147. /package/lib/service/{chat → agent}/tools/query.js +0 -0
@@ -1,277 +0,0 @@
1
- /**
2
- * ToolResultCache — 跨维度工具结果缓存
3
- *
4
- * @deprecated Phase 4: 已合并入 SessionStore (lib/service/chat/memory/SessionStore.js)
5
- * - LRU 缓存逻辑 (仅只读工具) 已迁入 SessionStore
6
- * - 本文件保留做向后兼容,新代码请使用 SessionStore
7
- *
8
- * 缓存 search_project_code 和 read_project_file 的调用结果,
9
- * 避免后续维度重复执行已知搜索/读取操作。
10
- *
11
- * 设计:
12
- * - 缓存粒度: 完整工具调用 (key = toolName + normalized args)
13
- * - 失效策略: TTL 过期 + 手动清理 (默认 30 分钟)
14
- * - 内存管理: 文件内容缓存上限 200 个,搜索结果上限 500 个
15
- *
16
- * 使用方式:
17
- * ToolRegistry handler 内检查 ctx.toolResultCache.get(key)
18
- * 命中则直接返回缓存 + "[cached]" 标记
19
- *
20
- * @module ToolResultCache
21
- */
22
-
23
- import Logger from '../../../../../infrastructure/logging/Logger.js';
24
- import { CACHE } from '../../../../../shared/constants.js';
25
-
26
- /** 最大缓存条目 */
27
- const MAX_FILE_CACHE = CACHE.MAX_FILE_ENTRIES;
28
- const MAX_SEARCH_CACHE = CACHE.MAX_SEARCH_ENTRIES;
29
- /** 缓存 TTL(毫秒),超过此时间的条目视为过期 */
30
- const DEFAULT_TTL_MS = CACHE.DEFAULT_TTL_MS;
31
-
32
- export class ToolResultCache {
33
- /** @type {Map<string, {result: any, cachedAt: number, hitCount: number}>} */
34
- #searchCache = new Map();
35
-
36
- /** @type {Map<string, {content: string, cachedAt: number, hitCount: number}>} */
37
- #fileCache = new Map();
38
-
39
- /** @type {import('../../../../../infrastructure/logging/Logger.js').default} */
40
- #logger;
41
-
42
- /** @type {{hits: number, misses: number, evictions: number}} */
43
- #stats = { hits: 0, misses: 0, evictions: 0 };
44
-
45
- /** @type {number} TTL in ms */
46
- #ttlMs;
47
-
48
- /** @type {ReturnType<typeof setInterval>|null} cleanup timer */
49
- #cleanupTimer = null;
50
-
51
- /**
52
- * @param {object} [options]
53
- * @param {number} [options.ttlMs] — 缓存 TTL(毫秒),默认取 CACHE.DEFAULT_TTL_MS
54
- * @param {number} [options.cleanupIntervalMs] — 清理周期(毫秒),默认 5 分钟
55
- */
56
- constructor(options = {}) {
57
- this.#logger = Logger.getInstance();
58
- this.#ttlMs = options.ttlMs ?? DEFAULT_TTL_MS;
59
-
60
- // 定期清理过期条目,避免内存膨胀
61
- const cleanupInterval = options.cleanupIntervalMs ?? 5 * 60 * 1000;
62
- if (this.#ttlMs > 0 && cleanupInterval > 0) {
63
- this.#cleanupTimer = setInterval(() => this.#evictExpired(), cleanupInterval);
64
- // 允许进程退出时不被 timer 阻塞
65
- if (this.#cleanupTimer.unref) {
66
- this.#cleanupTimer.unref();
67
- }
68
- }
69
- }
70
-
71
- // ─── 搜索结果缓存 ────────────────────────────────────
72
-
73
- /**
74
- * 缓存搜索结果
75
- * @param {string} pattern — 搜索模式
76
- * @param {*} results — 搜索结果
77
- */
78
- cacheSearch(pattern, results) {
79
- if (this.#searchCache.size >= MAX_SEARCH_CACHE) {
80
- // LRU: 移除最旧的条目
81
- const oldestKey = this.#searchCache.keys().next().value;
82
- this.#searchCache.delete(oldestKey);
83
- }
84
- this.#searchCache.set(pattern, {
85
- result: results,
86
- cachedAt: Date.now(),
87
- hitCount: 0,
88
- });
89
- }
90
-
91
- /**
92
- * 获取缓存的搜索结果
93
- * @param {string} pattern
94
- * @returns {*|null} — 缓存结果或 null
95
- */
96
- getCachedSearch(pattern) {
97
- const entry = this.#searchCache.get(pattern);
98
- if (entry) {
99
- // TTL 检查
100
- if (this.#ttlMs > 0 && Date.now() - entry.cachedAt > this.#ttlMs) {
101
- this.#searchCache.delete(pattern);
102
- this.#stats.evictions++;
103
- this.#stats.misses++;
104
- return null;
105
- }
106
- entry.hitCount++;
107
- this.#stats.hits++;
108
- return entry.result;
109
- }
110
- this.#stats.misses++;
111
- return null;
112
- }
113
-
114
- // ─── 文件内容缓存 ────────────────────────────────────
115
-
116
- /**
117
- * 缓存文件内容
118
- * @param {string} filePath
119
- * @param {string} content
120
- */
121
- cacheFile(filePath, content) {
122
- if (this.#fileCache.size >= MAX_FILE_CACHE) {
123
- const oldestKey = this.#fileCache.keys().next().value;
124
- this.#fileCache.delete(oldestKey);
125
- }
126
- this.#fileCache.set(filePath, {
127
- content,
128
- cachedAt: Date.now(),
129
- hitCount: 0,
130
- });
131
- }
132
-
133
- /**
134
- * 获取缓存的文件内容
135
- * @param {string} filePath
136
- * @returns {string|null}
137
- */
138
- getCachedFile(filePath) {
139
- const entry = this.#fileCache.get(filePath);
140
- if (entry) {
141
- // TTL 检查
142
- if (this.#ttlMs > 0 && Date.now() - entry.cachedAt > this.#ttlMs) {
143
- this.#fileCache.delete(filePath);
144
- this.#stats.evictions++;
145
- this.#stats.misses++;
146
- return null;
147
- }
148
- entry.hitCount++;
149
- this.#stats.hits++;
150
- return entry.content;
151
- }
152
- this.#stats.misses++;
153
- return null;
154
- }
155
-
156
- // ─── 通用缓存接口 ────────────────────────────────────
157
-
158
- /**
159
- * 检查是否有缓存 (搜索或文件)
160
- * @param {string} toolName
161
- * @param {object} args
162
- * @returns {*|null}
163
- */
164
- get(toolName, args) {
165
- if (toolName === 'search_project_code') {
166
- const pattern = args?.pattern || '';
167
- if (pattern) {
168
- return this.getCachedSearch(pattern);
169
- }
170
- }
171
- if (toolName === 'read_project_file') {
172
- const filePath = args?.filePath || '';
173
- if (filePath) {
174
- const cached = this.getCachedFile(filePath);
175
- if (cached !== null) {
176
- return { content: cached, path: filePath, cached: true };
177
- }
178
- }
179
- }
180
- return null;
181
- }
182
-
183
- /**
184
- * 写入缓存
185
- * @param {string} toolName
186
- * @param {object} args
187
- * @param {*} result
188
- */
189
- set(toolName, args, result) {
190
- if (toolName === 'search_project_code') {
191
- const pattern = args?.pattern || '';
192
- if (pattern) {
193
- this.cacheSearch(pattern, result);
194
- }
195
- }
196
- if (toolName === 'read_project_file') {
197
- const filePath = args?.filePath || '';
198
- const content = typeof result === 'object' ? result.content : String(result);
199
- if (filePath && content) {
200
- this.cacheFile(filePath, content);
201
- }
202
- }
203
- }
204
-
205
- // ─── 统计 ─────────────────────────────────────────────
206
-
207
- /**
208
- * 获取缓存统计
209
- * @returns {object}
210
- */
211
- getStats() {
212
- return {
213
- ...this.#stats,
214
- hitRate:
215
- this.#stats.hits + this.#stats.misses > 0
216
- ? `${((this.#stats.hits / (this.#stats.hits + this.#stats.misses)) * 100).toFixed(1)}%`
217
- : '0%',
218
- searchCacheSize: this.#searchCache.size,
219
- fileCacheSize: this.#fileCache.size,
220
- };
221
- }
222
-
223
- /**
224
- * 清空所有缓存
225
- */
226
- clear() {
227
- this.#searchCache.clear();
228
- this.#fileCache.clear();
229
- this.#stats = { hits: 0, misses: 0, evictions: 0 };
230
- }
231
-
232
- /**
233
- * 销毁缓存实例,释放定时器
234
- * 应在 Bootstrap 会话结束时调用
235
- */
236
- dispose() {
237
- this.clear();
238
- if (this.#cleanupTimer) {
239
- clearInterval(this.#cleanupTimer);
240
- this.#cleanupTimer = null;
241
- }
242
- }
243
-
244
- // ─── 内部 ─────────────────────────────────────────────
245
-
246
- /**
247
- * 清理两个 Map 中的过期条目
248
- * @private
249
- */
250
- #evictExpired() {
251
- if (this.#ttlMs <= 0) {
252
- return;
253
- }
254
- const now = Date.now();
255
- let evicted = 0;
256
-
257
- for (const [key, entry] of this.#searchCache) {
258
- if (now - entry.cachedAt > this.#ttlMs) {
259
- this.#searchCache.delete(key);
260
- evicted++;
261
- }
262
- }
263
- for (const [key, entry] of this.#fileCache) {
264
- if (now - entry.cachedAt > this.#ttlMs) {
265
- this.#fileCache.delete(key);
266
- evicted++;
267
- }
268
- }
269
-
270
- if (evicted > 0) {
271
- this.#stats.evictions += evicted;
272
- this.#logger.debug(`[ToolResultCache] evicted ${evicted} expired entries`);
273
- }
274
- }
275
- }
276
-
277
- export default ToolResultCache;
@@ -1,5 +0,0 @@
1
- /**
2
- * @deprecated Moved to lib/platform/ios/routes/spm.js
3
- * This re-export shim maintains backward compatibility.
4
- */
5
- export { default } from '../../platform/ios/routes/spm.js';
@@ -1,15 +0,0 @@
1
- /**
2
- * @deprecated Moved to lib/platform/ios/xcode/XcodeAutomation.js
3
- * This re-export shim maintains backward compatibility.
4
- */
5
- export {
6
- cutLineInXcode,
7
- deleteLineContentInXcode,
8
- insertAtLineStartInXcode,
9
- isXcodeFrontmost,
10
- isXcodeRunning,
11
- jumpToLineInXcode,
12
- pasteInXcode,
13
- saveActiveDocumentInXcode,
14
- selectAndPasteInXcode,
15
- } from '../../platform/ios/xcode/XcodeAutomation.js';