aspectcode 0.4.1 → 1.0.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.
Files changed (248) hide show
  1. package/README.md +2 -2
  2. package/dist/agentsMdRenderer.d.ts +16 -0
  3. package/dist/agentsMdRenderer.d.ts.map +1 -0
  4. package/dist/agentsMdRenderer.js +137 -0
  5. package/dist/agentsMdRenderer.js.map +1 -0
  6. package/dist/auth.d.ts +31 -0
  7. package/dist/auth.d.ts.map +1 -0
  8. package/dist/auth.js +386 -0
  9. package/dist/auth.js.map +1 -0
  10. package/dist/autoResolve.d.ts +41 -0
  11. package/dist/autoResolve.d.ts.map +1 -0
  12. package/dist/autoResolve.js +196 -0
  13. package/dist/autoResolve.js.map +1 -0
  14. package/dist/changeEvaluator.d.ts +56 -0
  15. package/dist/changeEvaluator.d.ts.map +1 -0
  16. package/dist/changeEvaluator.js +674 -0
  17. package/dist/changeEvaluator.js.map +1 -0
  18. package/dist/cli.d.ts +3 -1
  19. package/dist/cli.d.ts.map +1 -1
  20. package/dist/cli.js +1 -1
  21. package/dist/cli.js.map +1 -1
  22. package/dist/config.d.ts +37 -17
  23. package/dist/config.d.ts.map +1 -1
  24. package/dist/config.js +50 -2
  25. package/dist/config.js.map +1 -1
  26. package/dist/dreamCycle.d.ts +57 -0
  27. package/dist/dreamCycle.d.ts.map +1 -0
  28. package/dist/dreamCycle.js +334 -0
  29. package/dist/dreamCycle.js.map +1 -0
  30. package/dist/kbBuilder.d.ts +1 -2
  31. package/dist/kbBuilder.d.ts.map +1 -1
  32. package/dist/kbBuilder.js +1 -2
  33. package/dist/kbBuilder.js.map +1 -1
  34. package/dist/main.d.ts +2 -1
  35. package/dist/main.d.ts.map +1 -1
  36. package/dist/main.js +148 -7
  37. package/dist/main.js.map +1 -1
  38. package/dist/optimize.d.ts +13 -6
  39. package/dist/optimize.d.ts.map +1 -1
  40. package/dist/optimize.js +433 -142
  41. package/dist/optimize.js.map +1 -1
  42. package/dist/pipeline.d.ts +19 -21
  43. package/dist/pipeline.d.ts.map +1 -1
  44. package/dist/pipeline.js +1093 -160
  45. package/dist/pipeline.js.map +1 -1
  46. package/dist/preferences.d.ts +80 -0
  47. package/dist/preferences.d.ts.map +1 -0
  48. package/dist/preferences.js +238 -0
  49. package/dist/preferences.js.map +1 -0
  50. package/dist/runtimeState.d.ts +30 -0
  51. package/dist/runtimeState.d.ts.map +1 -0
  52. package/dist/runtimeState.js +39 -0
  53. package/dist/runtimeState.js.map +1 -0
  54. package/dist/scopedRules.d.ts +84 -0
  55. package/dist/scopedRules.d.ts.map +1 -0
  56. package/dist/scopedRules.js +449 -0
  57. package/dist/scopedRules.js.map +1 -0
  58. package/dist/ui/Dashboard.d.ts +4 -16
  59. package/dist/ui/Dashboard.d.ts.map +1 -1
  60. package/dist/ui/Dashboard.js +339 -140
  61. package/dist/ui/Dashboard.js.map +1 -1
  62. package/dist/ui/MemoryMap.d.ts +16 -0
  63. package/dist/ui/MemoryMap.d.ts.map +1 -0
  64. package/dist/ui/MemoryMap.js +266 -0
  65. package/dist/ui/MemoryMap.js.map +1 -0
  66. package/dist/ui/SettingsPanel.d.ts +18 -0
  67. package/dist/ui/SettingsPanel.d.ts.map +1 -0
  68. package/dist/ui/SettingsPanel.js +241 -0
  69. package/dist/ui/SettingsPanel.js.map +1 -0
  70. package/dist/ui/prompts.d.ts +7 -0
  71. package/dist/ui/prompts.d.ts.map +1 -1
  72. package/dist/ui/prompts.js +63 -0
  73. package/dist/ui/prompts.js.map +1 -1
  74. package/dist/ui/store.d.ts +154 -18
  75. package/dist/ui/store.d.ts.map +1 -1
  76. package/dist/ui/store.js +154 -24
  77. package/dist/ui/store.js.map +1 -1
  78. package/dist/ui/theme.d.ts +1 -8
  79. package/dist/ui/theme.d.ts.map +1 -1
  80. package/dist/ui/theme.js +2 -21
  81. package/dist/ui/theme.js.map +1 -1
  82. package/dist/updateChecker.d.ts +13 -0
  83. package/dist/updateChecker.d.ts.map +1 -0
  84. package/dist/updateChecker.js +66 -0
  85. package/dist/updateChecker.js.map +1 -0
  86. package/dist/usageTracker.d.ts +12 -0
  87. package/dist/usageTracker.d.ts.map +1 -0
  88. package/dist/usageTracker.js +89 -0
  89. package/dist/usageTracker.js.map +1 -0
  90. package/dist/writer.d.ts +1 -7
  91. package/dist/writer.d.ts.map +1 -1
  92. package/dist/writer.js +1 -11
  93. package/dist/writer.js.map +1 -1
  94. package/node_modules/@aspectcode/core/dist/analysis/repo.d.ts.map +1 -1
  95. package/node_modules/@aspectcode/core/dist/analysis/repo.js +13 -2
  96. package/node_modules/@aspectcode/core/dist/analysis/repo.js.map +1 -1
  97. package/node_modules/@aspectcode/core/dist/index.d.ts +1 -3
  98. package/node_modules/@aspectcode/core/dist/index.d.ts.map +1 -1
  99. package/node_modules/@aspectcode/core/dist/index.js +1 -3
  100. package/node_modules/@aspectcode/core/dist/index.js.map +1 -1
  101. package/node_modules/@aspectcode/core/dist/parsers/genericExtractors.d.ts +14 -0
  102. package/node_modules/@aspectcode/core/dist/parsers/genericExtractors.d.ts.map +1 -0
  103. package/node_modules/@aspectcode/core/dist/parsers/genericExtractors.js +191 -0
  104. package/node_modules/@aspectcode/core/dist/parsers/genericExtractors.js.map +1 -0
  105. package/node_modules/@aspectcode/core/dist/parsers/index.d.ts +1 -0
  106. package/node_modules/@aspectcode/core/dist/parsers/index.d.ts.map +1 -1
  107. package/node_modules/@aspectcode/core/dist/parsers/index.js +6 -1
  108. package/node_modules/@aspectcode/core/dist/parsers/index.js.map +1 -1
  109. package/node_modules/@aspectcode/core/dist/parsers/languages.d.ts +20 -0
  110. package/node_modules/@aspectcode/core/dist/parsers/languages.d.ts.map +1 -1
  111. package/node_modules/@aspectcode/core/dist/parsers/languages.js +25 -0
  112. package/node_modules/@aspectcode/core/dist/parsers/languages.js.map +1 -1
  113. package/node_modules/@aspectcode/core/dist/parsers/tsJsExtractors.d.ts.map +1 -1
  114. package/node_modules/@aspectcode/core/dist/parsers/tsJsExtractors.js +4 -1
  115. package/node_modules/@aspectcode/core/dist/parsers/tsJsExtractors.js.map +1 -1
  116. package/node_modules/@aspectcode/core/package.json +2 -2
  117. package/node_modules/@aspectcode/core/parsers/cpp.wasm +0 -0
  118. package/node_modules/@aspectcode/core/parsers/go.wasm +0 -0
  119. package/node_modules/@aspectcode/core/parsers/php.wasm +0 -0
  120. package/node_modules/@aspectcode/core/parsers/ruby.wasm +0 -0
  121. package/node_modules/@aspectcode/core/parsers/rust.wasm +0 -0
  122. package/node_modules/@aspectcode/emitters/dist/index.d.ts +1 -17
  123. package/node_modules/@aspectcode/emitters/dist/index.d.ts.map +1 -1
  124. package/node_modules/@aspectcode/emitters/dist/index.js +2 -90
  125. package/node_modules/@aspectcode/emitters/dist/index.js.map +1 -1
  126. package/node_modules/@aspectcode/emitters/dist/instructions/index.d.ts +0 -2
  127. package/node_modules/@aspectcode/emitters/dist/instructions/index.d.ts.map +1 -1
  128. package/node_modules/@aspectcode/emitters/dist/instructions/index.js +1 -7
  129. package/node_modules/@aspectcode/emitters/dist/instructions/index.js.map +1 -1
  130. package/node_modules/@aspectcode/emitters/dist/kb/analyzers.d.ts +0 -18
  131. package/node_modules/@aspectcode/emitters/dist/kb/analyzers.d.ts.map +1 -1
  132. package/node_modules/@aspectcode/emitters/dist/kb/analyzers.js +0 -57
  133. package/node_modules/@aspectcode/emitters/dist/kb/analyzers.js.map +1 -1
  134. package/node_modules/@aspectcode/emitters/dist/kb/conventions.d.ts +0 -18
  135. package/node_modules/@aspectcode/emitters/dist/kb/conventions.d.ts.map +1 -1
  136. package/node_modules/@aspectcode/emitters/dist/kb/conventions.js +0 -130
  137. package/node_modules/@aspectcode/emitters/dist/kb/conventions.js.map +1 -1
  138. package/node_modules/@aspectcode/emitters/dist/kb/index.d.ts +2 -4
  139. package/node_modules/@aspectcode/emitters/dist/kb/index.d.ts.map +1 -1
  140. package/node_modules/@aspectcode/emitters/dist/kb/index.js +1 -11
  141. package/node_modules/@aspectcode/emitters/dist/kb/index.js.map +1 -1
  142. package/node_modules/@aspectcode/emitters/package.json +3 -3
  143. package/node_modules/@aspectcode/evaluator/dist/apply.d.ts +55 -0
  144. package/node_modules/@aspectcode/evaluator/dist/apply.d.ts.map +1 -0
  145. package/node_modules/@aspectcode/evaluator/dist/apply.js +368 -0
  146. package/node_modules/@aspectcode/evaluator/dist/apply.js.map +1 -0
  147. package/node_modules/@aspectcode/evaluator/dist/diagnosis.d.ts +16 -25
  148. package/node_modules/@aspectcode/evaluator/dist/diagnosis.d.ts.map +1 -1
  149. package/node_modules/@aspectcode/evaluator/dist/diagnosis.js +115 -138
  150. package/node_modules/@aspectcode/evaluator/dist/diagnosis.js.map +1 -1
  151. package/node_modules/@aspectcode/evaluator/dist/index.d.ts +8 -43
  152. package/node_modules/@aspectcode/evaluator/dist/index.d.ts.map +1 -1
  153. package/node_modules/@aspectcode/evaluator/dist/index.js +15 -61
  154. package/node_modules/@aspectcode/evaluator/dist/index.js.map +1 -1
  155. package/node_modules/@aspectcode/evaluator/dist/judge.d.ts +32 -0
  156. package/node_modules/@aspectcode/evaluator/dist/judge.d.ts.map +1 -0
  157. package/node_modules/@aspectcode/evaluator/dist/judge.js +165 -0
  158. package/node_modules/@aspectcode/evaluator/dist/judge.js.map +1 -0
  159. package/node_modules/@aspectcode/evaluator/dist/llmUtil.d.ts +15 -0
  160. package/node_modules/@aspectcode/evaluator/dist/llmUtil.d.ts.map +1 -0
  161. package/node_modules/@aspectcode/evaluator/dist/llmUtil.js +41 -0
  162. package/node_modules/@aspectcode/evaluator/dist/llmUtil.js.map +1 -0
  163. package/node_modules/@aspectcode/evaluator/dist/probes.d.ts +20 -47
  164. package/node_modules/@aspectcode/evaluator/dist/probes.d.ts.map +1 -1
  165. package/node_modules/@aspectcode/evaluator/dist/probes.js +188 -278
  166. package/node_modules/@aspectcode/evaluator/dist/probes.js.map +1 -1
  167. package/node_modules/@aspectcode/evaluator/dist/runner.d.ts +7 -32
  168. package/node_modules/@aspectcode/evaluator/dist/runner.d.ts.map +1 -1
  169. package/node_modules/@aspectcode/evaluator/dist/runner.js +21 -146
  170. package/node_modules/@aspectcode/evaluator/dist/runner.js.map +1 -1
  171. package/node_modules/@aspectcode/evaluator/dist/types.d.ts +141 -99
  172. package/node_modules/@aspectcode/evaluator/dist/types.d.ts.map +1 -1
  173. package/node_modules/@aspectcode/evaluator/dist/types.js +10 -2
  174. package/node_modules/@aspectcode/evaluator/dist/types.js.map +1 -1
  175. package/node_modules/@aspectcode/evaluator/package.json +4 -4
  176. package/node_modules/@aspectcode/optimizer/dist/index.d.ts +3 -10
  177. package/node_modules/@aspectcode/optimizer/dist/index.d.ts.map +1 -1
  178. package/node_modules/@aspectcode/optimizer/dist/index.js +1 -19
  179. package/node_modules/@aspectcode/optimizer/dist/index.js.map +1 -1
  180. package/node_modules/@aspectcode/optimizer/dist/providers/anthropic.d.ts.map +1 -1
  181. package/node_modules/@aspectcode/optimizer/dist/providers/anthropic.js +40 -0
  182. package/node_modules/@aspectcode/optimizer/dist/providers/anthropic.js.map +1 -1
  183. package/node_modules/@aspectcode/optimizer/dist/providers/aspectcode.d.ts +9 -0
  184. package/node_modules/@aspectcode/optimizer/dist/providers/aspectcode.d.ts.map +1 -0
  185. package/node_modules/@aspectcode/optimizer/dist/providers/aspectcode.js +83 -0
  186. package/node_modules/@aspectcode/optimizer/dist/providers/aspectcode.js.map +1 -0
  187. package/node_modules/@aspectcode/optimizer/dist/providers/index.d.ts +4 -3
  188. package/node_modules/@aspectcode/optimizer/dist/providers/index.d.ts.map +1 -1
  189. package/node_modules/@aspectcode/optimizer/dist/providers/index.js +24 -10
  190. package/node_modules/@aspectcode/optimizer/dist/providers/index.js.map +1 -1
  191. package/node_modules/@aspectcode/optimizer/dist/providers/openai.d.ts.map +1 -1
  192. package/node_modules/@aspectcode/optimizer/dist/providers/openai.js +22 -0
  193. package/node_modules/@aspectcode/optimizer/dist/providers/openai.js.map +1 -1
  194. package/node_modules/@aspectcode/optimizer/dist/providers/retry.d.ts +14 -0
  195. package/node_modules/@aspectcode/optimizer/dist/providers/retry.d.ts.map +1 -1
  196. package/node_modules/@aspectcode/optimizer/dist/providers/retry.js +1 -0
  197. package/node_modules/@aspectcode/optimizer/dist/providers/retry.js.map +1 -1
  198. package/node_modules/@aspectcode/optimizer/dist/types.d.ts +14 -0
  199. package/node_modules/@aspectcode/optimizer/dist/types.d.ts.map +1 -1
  200. package/node_modules/@aspectcode/optimizer/dist/types.js.map +1 -1
  201. package/node_modules/@aspectcode/optimizer/package.json +2 -2
  202. package/node_modules/web-tree-sitter/LICENSE +21 -0
  203. package/node_modules/web-tree-sitter/README.md +198 -0
  204. package/node_modules/web-tree-sitter/package.json +36 -0
  205. package/node_modules/web-tree-sitter/tree-sitter-web.d.ts +204 -0
  206. package/node_modules/web-tree-sitter/tree-sitter.js +1 -0
  207. package/node_modules/web-tree-sitter/tree-sitter.wasm +0 -0
  208. package/package.json +8 -8
  209. package/dist/complaintProcessor.d.ts +0 -16
  210. package/dist/complaintProcessor.d.ts.map +0 -1
  211. package/dist/complaintProcessor.js +0 -134
  212. package/dist/complaintProcessor.js.map +0 -1
  213. package/node_modules/@aspectcode/emitters/dist/emitter.d.ts +0 -72
  214. package/node_modules/@aspectcode/emitters/dist/emitter.d.ts.map +0 -1
  215. package/node_modules/@aspectcode/emitters/dist/emitter.js +0 -10
  216. package/node_modules/@aspectcode/emitters/dist/emitter.js.map +0 -1
  217. package/node_modules/@aspectcode/emitters/dist/instructions/content.d.ts +0 -26
  218. package/node_modules/@aspectcode/emitters/dist/instructions/content.d.ts.map +0 -1
  219. package/node_modules/@aspectcode/emitters/dist/instructions/content.js +0 -501
  220. package/node_modules/@aspectcode/emitters/dist/instructions/content.js.map +0 -1
  221. package/node_modules/@aspectcode/emitters/dist/instructions/detection.d.ts +0 -13
  222. package/node_modules/@aspectcode/emitters/dist/instructions/detection.d.ts.map +0 -1
  223. package/node_modules/@aspectcode/emitters/dist/instructions/detection.js +0 -55
  224. package/node_modules/@aspectcode/emitters/dist/instructions/detection.js.map +0 -1
  225. package/node_modules/@aspectcode/emitters/dist/instructions/instructionsEmitter.d.ts +0 -9
  226. package/node_modules/@aspectcode/emitters/dist/instructions/instructionsEmitter.d.ts.map +0 -1
  227. package/node_modules/@aspectcode/emitters/dist/instructions/instructionsEmitter.js +0 -30
  228. package/node_modules/@aspectcode/emitters/dist/instructions/instructionsEmitter.js.map +0 -1
  229. package/node_modules/@aspectcode/emitters/dist/kb/kbEmitter.d.ts +0 -21
  230. package/node_modules/@aspectcode/emitters/dist/kb/kbEmitter.d.ts.map +0 -1
  231. package/node_modules/@aspectcode/emitters/dist/kb/kbEmitter.js +0 -125
  232. package/node_modules/@aspectcode/emitters/dist/kb/kbEmitter.js.map +0 -1
  233. package/node_modules/@aspectcode/emitters/dist/manifest.d.ts +0 -37
  234. package/node_modules/@aspectcode/emitters/dist/manifest.d.ts.map +0 -1
  235. package/node_modules/@aspectcode/emitters/dist/manifest.js +0 -50
  236. package/node_modules/@aspectcode/emitters/dist/manifest.js.map +0 -1
  237. package/node_modules/@aspectcode/emitters/dist/report.d.ts +0 -22
  238. package/node_modules/@aspectcode/emitters/dist/report.d.ts.map +0 -1
  239. package/node_modules/@aspectcode/emitters/dist/report.js +0 -3
  240. package/node_modules/@aspectcode/emitters/dist/report.js.map +0 -1
  241. package/node_modules/@aspectcode/emitters/dist/stableJson.d.ts +0 -14
  242. package/node_modules/@aspectcode/emitters/dist/stableJson.d.ts.map +0 -1
  243. package/node_modules/@aspectcode/emitters/dist/stableJson.js +0 -40
  244. package/node_modules/@aspectcode/emitters/dist/stableJson.js.map +0 -1
  245. package/node_modules/@aspectcode/emitters/dist/transaction.d.ts +0 -29
  246. package/node_modules/@aspectcode/emitters/dist/transaction.d.ts.map +0 -1
  247. package/node_modules/@aspectcode/emitters/dist/transaction.js +0 -104
  248. package/node_modules/@aspectcode/emitters/dist/transaction.js.map +0 -1
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Autonomous assessment resolution — LLM judges warnings
3
+ * and auto-resolves high-confidence ones without user input.
4
+ *
5
+ * Batched: multiple assessments are sent in a single LLM call,
6
+ * deduplicated by rule+directory to minimize token usage.
7
+ */
8
+ import type { LlmProvider } from '@aspectcode/optimizer';
9
+ import type { ChangeAssessment } from './changeEvaluator';
10
+ import type { PreferencesStore } from './preferences';
11
+ export interface AutoResolveResult {
12
+ assessment: ChangeAssessment;
13
+ decision: 'allow' | 'deny';
14
+ confidence: number;
15
+ reasoning: string;
16
+ autoResolved: boolean;
17
+ }
18
+ export interface LlmRecommendation {
19
+ decision: 'allow' | 'deny';
20
+ confidence: number;
21
+ reasoning: string;
22
+ }
23
+ /**
24
+ * Check if an existing preference already covers this assessment.
25
+ * If so, skip the LLM entirely and return the cached decision.
26
+ */
27
+ export declare function matchExistingPreference(assessment: ChangeAssessment, preferences: PreferencesStore): AutoResolveResult | null;
28
+ /**
29
+ * Batch-resolve multiple assessments in a single LLM call.
30
+ * Deduplicates by rule+directory for token efficiency.
31
+ */
32
+ export declare function autoResolveBatch(assessments: ChangeAssessment[], preferences: PreferencesStore, provider: LlmProvider, options?: {
33
+ threshold?: number;
34
+ }): Promise<AutoResolveResult[]>;
35
+ /**
36
+ * Single-assessment resolve (kept for backward compat / tests).
37
+ */
38
+ export declare function autoResolveAssessment(assessment: ChangeAssessment, preferences: PreferencesStore, provider: LlmProvider, options?: {
39
+ threshold?: number;
40
+ }): Promise<AutoResolveResult>;
41
+ //# sourceMappingURL=autoResolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autoResolve.d.ts","sourceRoot":"","sources":["../src/autoResolve.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AA8FD;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,gBAAgB,EAC5B,WAAW,EAAE,gBAAgB,GAC5B,iBAAiB,GAAG,IAAI,CAsB1B;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,gBAAgB,EAAE,EAC/B,WAAW,EAAE,gBAAgB,EAC7B,QAAQ,EAAE,WAAW,EACrB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACnC,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAyD9B;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,gBAAgB,EAC5B,WAAW,EAAE,gBAAgB,EAC7B,QAAQ,EAAE,WAAW,EACrB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACnC,OAAO,CAAC,iBAAiB,CAAC,CAM5B"}
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ /**
3
+ * Autonomous assessment resolution — LLM judges warnings
4
+ * and auto-resolves high-confidence ones without user input.
5
+ *
6
+ * Batched: multiple assessments are sent in a single LLM call,
7
+ * deduplicated by rule+directory to minimize token usage.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.matchExistingPreference = matchExistingPreference;
11
+ exports.autoResolveBatch = autoResolveBatch;
12
+ exports.autoResolveAssessment = autoResolveAssessment;
13
+ const BATCH_SYSTEM = `You evaluate code change assessments for a developer. Given a list of assessments and the previous preferences, decide for each: should this be ALLOWED (suppress future warnings) or DENIED (enforce this rule)?
14
+
15
+ Output ONLY a JSON array. Each element: { "id": <number>, "decision": "allow" or "deny", "confidence": 0.0 to 1.0, "reasoning": "one sentence" }
16
+
17
+ Confidence guide:
18
+ - 0.9+: Obviously trivial or obviously important (hub with 20+ dependents)
19
+ - 0.7-0.9: Likely correct based on pattern matching with preferences
20
+ - 0.5-0.7: Ambiguous
21
+ - <0.5: Novel, unclear — let the user decide
22
+
23
+ If multiple assessments share the same rule and directory, they likely deserve the same decision. Lean toward "allow" for naming/convention. Lean toward "deny" for dependency/hub safety.`;
24
+ function formatPreferenceSummary(prefs) {
25
+ const top = [...prefs.preferences]
26
+ .sort((a, b) => (b.hitCount ?? 0) - (a.hitCount ?? 0))
27
+ .slice(0, 10);
28
+ if (top.length === 0)
29
+ return 'No existing preferences.';
30
+ return top.map((p) => {
31
+ const scope = p.file ? p.file : p.directory ? `${p.directory}*` : 'project-wide';
32
+ return `- ${p.disposition} ${p.rule} in ${scope} (used ${p.hitCount ?? 0}x)`;
33
+ }).join('\n');
34
+ }
35
+ /** Build a compact batch prompt, deduplicating by rule+directory. */
36
+ function buildBatchPrompt(assessments, prefs) {
37
+ let prompt = `Previous preferences:\n${formatPreferenceSummary(prefs)}\n\nAssessments:\n`;
38
+ // Group by rule + directory for deduplication hint
39
+ const groups = new Map();
40
+ for (let i = 0; i < assessments.length; i++) {
41
+ const a = assessments[i];
42
+ const dir = a.file ? a.file.substring(0, a.file.lastIndexOf('/') + 1) : '';
43
+ const key = `${a.rule}|${dir}`;
44
+ const g = groups.get(key);
45
+ if (g) {
46
+ g.indices.push(i);
47
+ }
48
+ else {
49
+ groups.set(key, { indices: [i], sample: a });
50
+ }
51
+ }
52
+ // If a group has multiple identical-rule assessments, compact them
53
+ for (const [, g] of groups) {
54
+ if (g.indices.length === 1) {
55
+ const i = g.indices[0];
56
+ const a = assessments[i];
57
+ prompt += `[${i}] Rule: ${a.rule} | File: ${a.file} | ${a.message}`;
58
+ if (a.details)
59
+ prompt += ` | ${a.details}`;
60
+ prompt += '\n';
61
+ }
62
+ else {
63
+ const a = g.sample;
64
+ const files = g.indices.map((i) => assessments[i].file).join(', ');
65
+ prompt += `[${g.indices.join(',')}] Rule: ${a.rule} | ${g.indices.length} files: ${files} | ${a.message}\n`;
66
+ }
67
+ }
68
+ return prompt;
69
+ }
70
+ function parseBatchResponse(raw, count) {
71
+ try {
72
+ const cleaned = raw.replace(/<think>[\s\S]*?<\/think>/g, '').trim();
73
+ const match = cleaned.match(/\[[\s\S]*\]/);
74
+ if (!match)
75
+ return null;
76
+ const arr = JSON.parse(match[0]);
77
+ if (!Array.isArray(arr))
78
+ return null;
79
+ const results = [];
80
+ for (const item of arr) {
81
+ if (item.decision !== 'allow' && item.decision !== 'deny')
82
+ continue;
83
+ const confidence = typeof item.confidence === 'number' ? Math.max(0, Math.min(1, item.confidence)) : 0.5;
84
+ const reasoning = typeof item.reasoning === 'string' ? item.reasoning.slice(0, 200) : '';
85
+ // id can be a single number or comma-separated group
86
+ const ids = typeof item.id === 'number' ? [item.id]
87
+ : typeof item.id === 'string' ? item.id.split(',').map((s) => parseInt(s.trim(), 10)).filter((n) => !isNaN(n))
88
+ : [];
89
+ for (const id of ids) {
90
+ if (id >= 0 && id < count) {
91
+ results.push({ id, decision: item.decision, confidence, reasoning });
92
+ }
93
+ }
94
+ }
95
+ return results.length > 0 ? results : null;
96
+ }
97
+ catch {
98
+ return null;
99
+ }
100
+ }
101
+ /**
102
+ * Check if an existing preference already covers this assessment.
103
+ * If so, skip the LLM entirely and return the cached decision.
104
+ */
105
+ function matchExistingPreference(assessment, preferences) {
106
+ const dir = assessment.file
107
+ ? assessment.file.substring(0, assessment.file.lastIndexOf('/') + 1)
108
+ : null;
109
+ for (const p of preferences.preferences) {
110
+ if (p.rule !== assessment.rule)
111
+ continue;
112
+ const scopeMatch = (p.directory && dir && dir.startsWith(p.directory)) ||
113
+ (p.file && p.file === assessment.file) ||
114
+ (!p.directory && !p.file);
115
+ if (!scopeMatch)
116
+ continue;
117
+ return {
118
+ assessment,
119
+ decision: p.disposition === 'allow' ? 'allow' : 'deny',
120
+ confidence: 1.0,
121
+ reasoning: `Matched existing preference: ${p.disposition} ${p.rule}`,
122
+ autoResolved: true,
123
+ };
124
+ }
125
+ return null;
126
+ }
127
+ /**
128
+ * Batch-resolve multiple assessments in a single LLM call.
129
+ * Deduplicates by rule+directory for token efficiency.
130
+ */
131
+ async function autoResolveBatch(assessments, preferences, provider, options = {}) {
132
+ if (assessments.length === 0)
133
+ return [];
134
+ const threshold = options.threshold ?? 0.8;
135
+ const messages = [
136
+ { role: 'system', content: BATCH_SYSTEM },
137
+ { role: 'user', content: buildBatchPrompt(assessments, preferences) },
138
+ ];
139
+ try {
140
+ const response = provider.chatWithOptions
141
+ ? await provider.chatWithOptions(messages, { temperature: 0 })
142
+ : await provider.chat(messages);
143
+ const parsed = parseBatchResponse(response, assessments.length);
144
+ if (!parsed) {
145
+ // Parsing failed — return all as unresolved
146
+ return assessments.map((a) => ({
147
+ assessment: a,
148
+ decision: 'allow',
149
+ confidence: 0,
150
+ reasoning: 'Could not parse batch response',
151
+ autoResolved: false,
152
+ }));
153
+ }
154
+ // Map results back to assessments
155
+ const resultMap = new Map();
156
+ for (const r of parsed) {
157
+ resultMap.set(r.id, r);
158
+ }
159
+ return assessments.map((a, i) => {
160
+ const r = resultMap.get(i);
161
+ if (!r) {
162
+ return { assessment: a, decision: 'allow', confidence: 0, reasoning: 'Not in batch response', autoResolved: false };
163
+ }
164
+ return {
165
+ assessment: a,
166
+ decision: r.decision,
167
+ confidence: r.confidence,
168
+ reasoning: r.reasoning,
169
+ autoResolved: r.confidence >= threshold,
170
+ };
171
+ });
172
+ }
173
+ catch (err) {
174
+ // Re-throw tier exhaustion
175
+ if (err?.tierExhausted)
176
+ throw err;
177
+ return assessments.map((a) => ({
178
+ assessment: a,
179
+ decision: 'allow',
180
+ confidence: 0,
181
+ reasoning: 'LLM unavailable',
182
+ autoResolved: false,
183
+ }));
184
+ }
185
+ }
186
+ /**
187
+ * Single-assessment resolve (kept for backward compat / tests).
188
+ */
189
+ async function autoResolveAssessment(assessment, preferences, provider, options = {}) {
190
+ const cached = matchExistingPreference(assessment, preferences);
191
+ if (cached)
192
+ return cached;
193
+ const results = await autoResolveBatch([assessment], preferences, provider, options);
194
+ return results[0];
195
+ }
196
+ //# sourceMappingURL=autoResolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autoResolve.js","sourceRoot":"","sources":["../src/autoResolve.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAoHH,0DAyBC;AAMD,4CA8DC;AAKD,sDAWC;AA7MD,MAAM,YAAY,GAAG;;;;;;;;;;2LAUsK,CAAC;AAE5L,SAAS,uBAAuB,CAAC,KAAuB;IACtD,MAAM,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC;SAC/B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC;SACrD,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEhB,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,0BAA0B,CAAC;IAExD,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACnB,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC;QACjF,OAAO,KAAK,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,IAAI,OAAO,KAAK,UAAU,CAAC,CAAC,QAAQ,IAAI,CAAC,IAAI,C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,OAAO,CAAC,CAAC;IACrF,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Change evaluator — real-time assessment of file changes against the
3
+ * current AnalysisModel and learned preferences.
4
+ *
5
+ * All checks are pure functions. No LLM calls, no file reads beyond
6
+ * what's already in RuntimeState, no tree-sitter. Fast enough to run
7
+ * on every file save.
8
+ */
9
+ import type { AnalysisModel } from '@aspectcode/core';
10
+ import type { PreferencesStore } from './preferences';
11
+ export interface TimestampedChange {
12
+ type: 'add' | 'change' | 'unlink';
13
+ path: string;
14
+ timestamp: number;
15
+ }
16
+ export interface ChangeAssessment {
17
+ file: string;
18
+ type: 'ok' | 'warning' | 'violation';
19
+ rule: string;
20
+ message: string;
21
+ details?: string;
22
+ suggestion?: string;
23
+ dependencyContext?: string;
24
+ dismissable: boolean;
25
+ /** LLM auto-resolve recommendation (attached when auto-resolve is active). */
26
+ llmRecommendation?: {
27
+ decision: 'allow' | 'deny';
28
+ confidence: number;
29
+ reasoning: string;
30
+ };
31
+ }
32
+ export interface ChangeContext {
33
+ model: AnalysisModel;
34
+ agentsContent: string;
35
+ preferences: PreferencesStore;
36
+ recentChanges: TimestampedChange[];
37
+ fileContents?: ReadonlyMap<string, string>;
38
+ /** Hub inDegree counts from previous analysis (for new-hub detection). */
39
+ previousHubCounts?: ReadonlyMap<string, number>;
40
+ }
41
+ export declare function trackChange(event: {
42
+ type: string;
43
+ path: string;
44
+ }): void;
45
+ export declare function getRecentChanges(): TimestampedChange[];
46
+ export declare function clearRecentChanges(): void;
47
+ export declare function evaluateChange(event: {
48
+ type: string;
49
+ path: string;
50
+ }, ctx: ChangeContext): ChangeAssessment[];
51
+ export declare function extractExportNames(content: string, _language: string): string[];
52
+ export declare function hasPathInGraph(from: string, to: string, edges: {
53
+ source: string;
54
+ target: string;
55
+ }[], maxDepth?: number): string[] | null;
56
+ //# sourceMappingURL=changeEvaluator.d.ts.map
@@ -0,0 +1 @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