@mrclrchtr/supi-code-intelligence 11.0.1 → 11.2.0

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 (200) hide show
  1. package/README.md +68 -6
  2. package/gradle-helper/README.md +48 -0
  3. package/gradle-helper/build.sh +73 -0
  4. package/gradle-helper/lib/gradle-tooling-api-9.4.0.jar +0 -0
  5. package/gradle-helper/lib/slf4j-api-2.0.17.jar +0 -0
  6. package/gradle-helper/lib/slf4j-simple-2.0.17.jar +0 -0
  7. package/gradle-helper/lib/supi-gradle-observation.jar +0 -0
  8. package/gradle-helper/licenses/DEPENDENCIES.md +11 -0
  9. package/gradle-helper/licenses/LICENSE-gradle-tooling-api.txt +422 -0
  10. package/gradle-helper/licenses/LICENSE-slf4j.txt +21 -0
  11. package/gradle-helper/licenses/NOTICE-gradle.txt +21 -0
  12. package/gradle-helper/src/GradleObservation.java +597 -0
  13. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  14. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  15. package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
  16. package/node_modules/@mrclrchtr/supi-lsp/README.md +43 -6
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/LICENSE +15 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/README.md +680 -0
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/bin/semver.js +195 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/comparator.js +143 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/index.js +7 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/range.js +577 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/semver.js +350 -0
  27. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/clean.js +8 -0
  28. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/cmp.js +54 -0
  29. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/coerce.js +62 -0
  30. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-build.js +9 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-loose.js +5 -0
  32. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare.js +7 -0
  33. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/diff.js +60 -0
  34. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/eq.js +5 -0
  35. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gt.js +5 -0
  36. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gte.js +5 -0
  37. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/inc.js +21 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lt.js +5 -0
  39. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lte.js +5 -0
  40. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/major.js +5 -0
  41. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/minor.js +5 -0
  42. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/neq.js +5 -0
  43. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/parse.js +18 -0
  44. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/patch.js +5 -0
  45. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/prerelease.js +8 -0
  46. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rcompare.js +5 -0
  47. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rsort.js +5 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/satisfies.js +12 -0
  49. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/sort.js +5 -0
  50. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/truncate.js +48 -0
  51. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/valid.js +8 -0
  52. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/index.js +93 -0
  53. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +37 -0
  54. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/debug.js +11 -0
  55. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/identifiers.js +29 -0
  56. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/lrucache.js +42 -0
  57. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/parse-options.js +17 -0
  58. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/re.js +223 -0
  59. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/package.json +78 -0
  60. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/preload.js +4 -0
  61. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/range.bnf +17 -0
  62. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/gtr.js +6 -0
  63. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/intersects.js +9 -0
  64. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/ltr.js +6 -0
  65. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/max-satisfying.js +27 -0
  66. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-satisfying.js +26 -0
  67. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-version.js +63 -0
  68. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/outside.js +82 -0
  69. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/simplify.js +49 -0
  70. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/subset.js +249 -0
  71. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/to-comparators.js +10 -0
  72. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/valid.js +13 -0
  73. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/README.md +5 -0
  74. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/browser/ril.js +8 -0
  75. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/common/connection.js +7 -2
  76. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/common/ral.d.ts +8 -0
  77. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/main.d.ts +14 -0
  78. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/main.js +6 -4
  79. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/ril.js +5 -1
  80. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/package.json +4 -2
  81. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/package.json +4 -3
  82. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/lib/esm/main.js +2 -2
  83. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/lib/umd/main.js +2 -2
  84. package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/package.json +2 -1
  85. package/node_modules/@mrclrchtr/supi-lsp/package.json +8 -6
  86. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +44 -5
  87. package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +53 -2
  88. package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +19 -4
  89. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +22 -0
  90. package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-launch.ts +276 -0
  91. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +22 -10
  92. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +53 -20
  93. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +4 -3
  94. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +2 -2
  95. package/node_modules/@mrclrchtr/supi-lsp/src/session/scanner.ts +27 -15
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +1 -0
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  98. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  99. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +5 -3
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/LICENSE +21 -0
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +19 -2
  104. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/LICENSE +21 -0
  105. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
  106. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +19 -2
  107. package/node_modules/ignore/README.md +36 -10
  108. package/node_modules/ignore/index.d.ts +3 -2
  109. package/node_modules/ignore/index.js +57 -53
  110. package/node_modules/ignore/legacy.js +50 -46
  111. package/node_modules/ignore/package.json +1 -1
  112. package/package.json +11 -6
  113. package/src/analysis/capability/capability-warnings.ts +18 -12
  114. package/src/analysis/gradle/query.ts +273 -0
  115. package/src/analysis/gradle/runtime.ts +173 -0
  116. package/src/analysis/gradle/types.ts +65 -0
  117. package/src/analysis/health/check.ts +115 -0
  118. package/src/analysis/health/diagnostics.ts +3 -0
  119. package/src/analysis/health/file-scope.ts +2 -3
  120. package/src/analysis/health/semantic-state.ts +38 -0
  121. package/src/analysis/health/server-status.ts +8 -0
  122. package/src/analysis/health/signals.ts +2 -0
  123. package/src/analysis/health/status.ts +82 -0
  124. package/src/analysis/read-next.ts +1 -4
  125. package/src/analysis/refactor/apply.ts +19 -10
  126. package/src/analysis/refactor/mutation-authority.ts +4 -1
  127. package/src/analysis/search/ast-scan.ts +143 -18
  128. package/src/analysis/workspace/safe-path.ts +14 -2
  129. package/src/analysis/workspace/types.ts +2 -0
  130. package/src/extension.ts +10 -1
  131. package/src/gradle/consent.ts +279 -0
  132. package/src/headless.ts +3 -0
  133. package/src/overview/collect.ts +11 -3
  134. package/src/session/health-types.ts +7 -0
  135. package/src/session/health-workflow.ts +8 -43
  136. package/src/session/orientation/collect.ts +138 -12
  137. package/src/session/orientation/context-facts.ts +27 -2
  138. package/src/session/orientation/context-sections.ts +47 -0
  139. package/src/session/orientation/facts.ts +124 -0
  140. package/src/session/orientation/gather.ts +98 -11
  141. package/src/session/orientation/workspace-context.ts +59 -28
  142. package/src/session/orientation-types.ts +16 -1
  143. package/src/session/orientation-workflow.ts +5 -2
  144. package/src/session/refactor-plans.ts +5 -2
  145. package/src/session/refactor-workflow.ts +4 -3
  146. package/src/session/session.ts +8 -0
  147. package/src/tool/code_find/execute.ts +1 -1
  148. package/src/tool/code_find/guidance.ts +1 -1
  149. package/src/tool/code_find/markdown.ts +24 -17
  150. package/src/tool/code_find/result.ts +18 -5
  151. package/src/tool/code_find/spec.ts +2 -0
  152. package/src/tool/code_find/structured.ts +161 -0
  153. package/src/tool/code_graph/result.ts +32 -15
  154. package/src/tool/code_graph/spec.ts +2 -0
  155. package/src/tool/code_graph/structured.ts +142 -0
  156. package/src/tool/code_health/markdown.ts +17 -17
  157. package/src/tool/code_health/result.ts +15 -2
  158. package/src/tool/code_health/spec.ts +2 -0
  159. package/src/tool/code_health/structured-schema.ts +250 -0
  160. package/src/tool/code_health/structured.ts +256 -0
  161. package/src/tool/code_inspect/markdown.ts +19 -11
  162. package/src/tool/code_inspect/result.ts +12 -5
  163. package/src/tool/code_inspect/spec.ts +2 -0
  164. package/src/tool/code_inspect/structured.ts +232 -0
  165. package/src/tool/code_orientation/directory-navigation.ts +66 -0
  166. package/src/tool/code_orientation/gradle-sections.ts +68 -0
  167. package/src/tool/code_orientation/markdown.ts +19 -8
  168. package/src/tool/code_orientation/result.ts +95 -11
  169. package/src/tool/code_orientation/spec.ts +2 -0
  170. package/src/tool/code_orientation/structured-schema.ts +607 -0
  171. package/src/tool/code_orientation/structured-workspace.ts +193 -0
  172. package/src/tool/code_orientation/structured.ts +195 -0
  173. package/src/tool/code_orientation/workspace-format.ts +2 -1
  174. package/src/tool/code_orientation/workspace-observations.ts +81 -0
  175. package/src/tool/code_orientation/workspace-output.ts +45 -13
  176. package/src/tool/code_orientation/workspace-projects.ts +180 -75
  177. package/src/tool/code_orientation/workspace-sections.ts +46 -31
  178. package/src/tool/code_refactor_apply/execute.ts +1 -1
  179. package/src/tool/code_refactor_apply/result.ts +13 -5
  180. package/src/tool/code_refactor_apply/spec.ts +2 -0
  181. package/src/tool/code_refactor_apply/structured.ts +49 -0
  182. package/src/tool/code_refactor_plan/result.ts +16 -8
  183. package/src/tool/code_refactor_plan/spec.ts +2 -0
  184. package/src/tool/code_refactor_plan/structured.ts +128 -0
  185. package/src/tool/code_resolve/markdown.ts +4 -10
  186. package/src/tool/code_resolve/result.ts +2 -0
  187. package/src/tool/code_resolve/spec.ts +2 -0
  188. package/src/tool/code_resolve/structured.ts +103 -0
  189. package/src/tool/infra/truncate.ts +12 -4
  190. package/src/tool/register.ts +10 -6
  191. package/src/tool/result/display.ts +17 -0
  192. package/src/tool/result/model-budget.ts +195 -0
  193. package/src/tool/result/structured.ts +62 -0
  194. package/src/tool/result/types.ts +10 -2
  195. package/src/tool/schemas.ts +7 -1
  196. package/src/tool/specs.ts +2 -0
  197. package/src/types/execution.ts +5 -1
  198. package/src/ui/status-command.ts +110 -321
  199. package/src/ui/status-overlay.ts +564 -420
  200. package/src/ui/tui/display.ts +10 -4
@@ -14,6 +14,8 @@ export interface DebugRegistryConfig {
14
14
  enabled: boolean;
15
15
  /** What the agent-callable debug tool may return. */
16
16
  agentAccess: DebugAgentAccess;
17
+ /** Whether Agent Run retrospective capture is explicitly enabled. */
18
+ agentRunRetrospectivesEnabled: boolean;
17
19
  /** Maximum number of session-local events to keep in memory. */
18
20
  maxEvents: number;
19
21
  }
@@ -21,6 +23,7 @@ export interface DebugRegistryConfig {
21
23
  export const DEBUG_REGISTRY_DEFAULTS: DebugRegistryConfig = {
22
24
  enabled: false,
23
25
  agentAccess: "sanitized",
26
+ agentRunRetrospectivesEnabled: false,
24
27
  maxEvents: 100,
25
28
  };
26
29
 
@@ -75,6 +78,9 @@ export interface DebugEventQueryResult {
75
78
  /** Receives a sanitized event whenever the registry records one. */
76
79
  export type DebugEventListener = (event: DebugEventView) => void;
77
80
 
81
+ /** Receives sanitized events for persistence; separate from ordinary event subscriptions. */
82
+ export type DebugPersistenceSink = (event: DebugEventView) => void;
83
+
78
84
  export interface DebugSummary {
79
85
  total: number;
80
86
  byLevel: Partial<Record<DebugLevel, number>>;
@@ -85,6 +91,7 @@ interface DebugRegistryState {
85
91
  config: DebugRegistryConfig;
86
92
  events: DebugEvent[];
87
93
  listeners: Set<DebugEventListener>;
94
+ persistenceSinks: Set<DebugPersistenceSink>;
88
95
  nextId: number;
89
96
  }
90
97
 
@@ -111,13 +118,15 @@ function getState(): DebugRegistryState {
111
118
  config: cloneConfig(DEBUG_REGISTRY_DEFAULTS),
112
119
  events: [],
113
120
  listeners: new Set(),
121
+ persistenceSinks: new Set(),
114
122
  nextId: 1,
115
123
  };
116
124
  (globalThis as Record<symbol, unknown>)[REGISTRY_KEY] = state;
117
125
  }
118
126
  // Keep the shared registry compatible with extension reloads that reuse an
119
- // instance created before listeners existed.
127
+ // instance created before listener sets existed.
120
128
  if (!state.listeners) state.listeners = new Set();
129
+ if (!state.persistenceSinks) state.persistenceSinks = new Set();
121
130
  return state;
122
131
  }
123
132
 
@@ -200,6 +209,19 @@ export function isDebugRegistryEnabled(): boolean {
200
209
  return getState().config.enabled;
201
210
  }
202
211
 
212
+ /**
213
+ * Return whether a retrospective can be captured: Debug and its explicit opt-in
214
+ * must be enabled, and at least one persistence sink must be registered.
215
+ */
216
+ export function canRecordAgentRunRetrospective(): boolean {
217
+ const state = getState();
218
+ return (
219
+ state.config.enabled &&
220
+ state.config.agentRunRetrospectivesEnabled &&
221
+ state.persistenceSinks.size > 0
222
+ );
223
+ }
224
+
203
225
  /** Best-effort redaction helper for data exposed through sanitized debug views. */
204
226
  export function redactDebugData<T>(value: T): T {
205
227
  return redactValue(value, 8) as T;
@@ -226,6 +248,16 @@ export function subscribeDebugEvents(listener: DebugEventListener): () => void {
226
248
  return () => state.listeners.delete(listener);
227
249
  }
228
250
 
251
+ /**
252
+ * Register a sanitized event persistence sink. Sinks are tracked separately from
253
+ * ordinary listeners so eligibility checks only succeed when logging is active.
254
+ */
255
+ export function subscribeDebugPersistence(sink: DebugPersistenceSink): () => void {
256
+ const state = getState();
257
+ state.persistenceSinks.add(sink);
258
+ return () => state.persistenceSinks.delete(sink);
259
+ }
260
+
229
261
  /** Record a session-local debug event if debugging is enabled. */
230
262
  export function recordDebugEvent(input: DebugEventInput): DebugEvent | null {
231
263
  const state = getState();
@@ -251,6 +283,13 @@ export function recordDebugEvent(input: DebugEventInput): DebugEvent | null {
251
283
  // Debug-event consumers must not alter producer behavior.
252
284
  }
253
285
  }
286
+ for (const sink of state.persistenceSinks) {
287
+ try {
288
+ sink(toSanitizedView(event));
289
+ } catch {
290
+ // Persistence failures must not alter producer behavior.
291
+ }
292
+ }
254
293
  return {
255
294
  ...event,
256
295
  data: event.data === undefined ? undefined : redactDebugData(event.data),
@@ -309,5 +348,6 @@ export function resetDebugRegistry(): void {
309
348
  state.config = cloneConfig(DEBUG_REGISTRY_DEFAULTS);
310
349
  state.events = [];
311
350
  state.listeners.clear();
351
+ state.persistenceSinks.clear();
312
352
  state.nextId = 1;
313
353
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-tree-sitter",
3
- "version": "11.0.1",
3
+ "version": "11.2.0",
4
4
  "description": "Structural AST analysis for SuPi code intelligence",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -36,8 +36,8 @@
36
36
  "dependencies": {
37
37
  "jiti": "^2.7.0",
38
38
  "web-tree-sitter": "^0.27.0",
39
- "@mrclrchtr/supi-code-runtime": "11.0.1",
40
- "@mrclrchtr/supi-core": "11.0.1"
39
+ "@mrclrchtr/supi-code-runtime": "11.2.0",
40
+ "@mrclrchtr/supi-core": "11.2.0"
41
41
  },
42
42
  "bundledDependencies": [
43
43
  "@mrclrchtr/supi-code-runtime",
@@ -56,6 +56,8 @@
56
56
  "check:wasm": "node scripts/vendor-wasm.mjs --check",
57
57
  "check:all-wasm": "node scripts/check-all-wasm.mjs",
58
58
  "generate:all-wasm": "node scripts/generate-all-wasm.mjs",
59
+ "generate:typescript-wasm": "node scripts/generate-typescript-wasm.mjs",
60
+ "check:typescript-wasm": "node scripts/generate-typescript-wasm.mjs --check",
59
61
  "generate:kotlin-wasm": "node scripts/generate-kotlin-wasm.mjs",
60
62
  "check:kotlin-wasm": "node scripts/generate-kotlin-wasm.mjs --check",
61
63
  "generate:sql-wasm": "node scripts/generate-sql-wasm.mjs",
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Max Brunsfeld
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,7 +1,24 @@
1
1
  {
2
2
  "source": {
3
3
  "npmPackage": "tree-sitter-typescript",
4
- "version": "0.23.2"
4
+ "version": "0.23.2",
5
+ "repository": "https://github.com/tree-sitter/tree-sitter-typescript",
6
+ "dependencies": {
7
+ "tree-sitter-javascript": "0.23.1"
8
+ }
5
9
  },
6
- "sha256": "79e5da75ea62855a0cd67177685f0164eac87d5f630b3cbe1e0a099751ad30f8"
10
+ "generatedWith": {
11
+ "treeSitterCli": "0.27.1"
12
+ },
13
+ "patches": [
14
+ {
15
+ "id": "type-only-star-reexports-v1",
16
+ "file": "common/define-grammar.js"
17
+ },
18
+ {
19
+ "id": "import-types-as-primary-types-v1",
20
+ "file": "common/define-grammar.js"
21
+ }
22
+ ],
23
+ "sha256": "c5101ee00725c52a8aa083afa4749b598a5ff884482f80ed114fca18e88629a6"
7
24
  }
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Max Brunsfeld
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,7 +1,24 @@
1
1
  {
2
2
  "source": {
3
3
  "npmPackage": "tree-sitter-typescript",
4
- "version": "0.23.2"
4
+ "version": "0.23.2",
5
+ "repository": "https://github.com/tree-sitter/tree-sitter-typescript",
6
+ "dependencies": {
7
+ "tree-sitter-javascript": "0.23.1"
8
+ }
5
9
  },
6
- "sha256": "778025db5a8be0e70f8ccc3671e486dfeddd048c25d9e8a70c26de2e1bf6f97d"
10
+ "generatedWith": {
11
+ "treeSitterCli": "0.27.1"
12
+ },
13
+ "patches": [
14
+ {
15
+ "id": "type-only-star-reexports-v1",
16
+ "file": "common/define-grammar.js"
17
+ },
18
+ {
19
+ "id": "import-types-as-primary-types-v1",
20
+ "file": "common/define-grammar.js"
21
+ }
22
+ ],
23
+ "sha256": "db071e260bcfec92f4b11997516dec49393c5086775eb8f090217d38de300c0d"
7
24
  }
@@ -282,6 +282,12 @@ Returns `function(path)` the filter function.
282
282
 
283
283
  > New in 5.0.0
284
284
 
285
+ **This method is NOT meant for ordinary users or everyday use.** If all you need is to tell whether a `pathname` is ignored, this is not the method you are looking for.
286
+
287
+ `.test()` is meant for packages that build upon `ignore`. Besides whether a `pathname` is ignored, it tells whether a negative pattern unignored it, which such a package can use to control its own caching, such as what to cache and when a cached result can be reused.
288
+
289
+ If you only need to know whether a `pathname` should be ignored, use `.ignores()` instead. It returns that answer as a boolean, and always agrees with `.test(pathname).ignored`.
290
+
285
291
  Returns `TestResult`
286
292
 
287
293
  ```ts
@@ -291,7 +297,8 @@ interface TestResult {
291
297
  // true if a negative pattern matched the `pathname` itself, and no parent
292
298
  // directory of it is ignored -- see "When both are false" below
293
299
  unignored: boolean
294
- // The `IgnoreRule` which ignores the pathname
300
+ // The `IgnoreRule` which ignores the pathname: the last rule to match, the
301
+ // one `git check-ignore -v` reports
295
302
  rule?: IgnoreRule
296
303
  }
297
304
 
@@ -339,13 +346,15 @@ To tell the two situations apart, test the parent directories of the `pathname`,
339
346
  ['foobar/'].some(dir => ig2.test(dir).unignored) // true
340
347
  ```
341
348
 
342
- `unignored` is meant for packages that implement their own caching mechanism upon `node-ignore`. To simply tell whether a `pathname` is ignored, use `.ignores()` or check `TestResult::ignored`.
343
-
344
349
  ## .checkIgnore(target: string): TestResult
345
350
 
346
351
  > new in 7.0.0
347
352
 
348
- Debugs gitignore / exclude files, which is equivalent to `git check-ignore -v`. Usually this method is used for other packages to implement the function of `git check-ignore -v` upon `node-ignore`
353
+ Debugs gitignore / exclude files the way `git check-ignore -v` does. Usually this method is used for other packages to implement the function of `git check-ignore -v` upon `node-ignore`. Apart from the [known differences](#known-differences-from-git):
354
+
355
+ - `ignored` is what `git check-ignore` answers for `target`.
356
+ - When `ignored` is `true`, `rule` is the rule `git check-ignore -v` reports. Its `pattern` is the pattern as it was added, so trailing spaces that git trims are still there.
357
+ - When the last pattern to match is a negative one, `git check-ignore -v` reports it, while `.checkIgnore()` returns `unignored: true` and no `rule`. For a directory passed with a trailing slash, `unignored` is also `true` when a negative pattern re-includes the directory itself, which `git check-ignore -v` does not report.
349
358
 
350
359
  - **target** `string` the target to test.
351
360
 
@@ -471,13 +480,30 @@ not in `git`. For ASCII paths and patterns there is no difference.
471
480
  code runs against a real repository, pass the value of the repository's
472
481
  `core.ignorecase` explicitly.
473
482
 
474
- ### `***` and friends follow the documentation, not the binary
483
+ ### A run of asterisks
484
+
485
+ `git` reads a run of two or more asterisks as a globstar whenever the run
486
+ fills a path segment: it starts the pattern or follows a `/`, and it ends
487
+ the pattern or comes before a `/`. `ignore` does the same, so `***/foo`,
488
+ `a/***` and `a/***/b` behave exactly as `**/foo`, `a/**` and `a/**/b`.
489
+
490
+ `git` takes two more cases as a globstar, and `ignore` does not:
491
+
492
+ - **A run right after a literal prefix**, as in `a**/b` or `a***/b`. Before
493
+ matching, `git` strips the part of a pattern that holds no wildcard, and
494
+ the run then starts what is left. gitignore(5) lists the positions where
495
+ `**` is special and calls every other run "regular asterisks", which is
496
+ what `ignore` does here.
497
+ - **A run next to an escaped slash**, as in `**\/b` or `x\/**/b`.
498
+
499
+ ```js
500
+ ignore().add('a**/b').ignores('axy/z/b') // false; git: true
501
+ ignore().add('**\\/b').ignores('x/y/b') // false; git: true
502
+ ignore().add('x\\/**/b').ignores('x/y/z/b') // false; git: true
503
+ ```
475
504
 
476
- gitignore(5) says a run of more than two asterisks is "considered regular
477
- asterisks". The `git` binary, however, strips the literal prefix of a
478
- pattern before matching, which makes patterns like `***/foo`, `a/***` and
479
- `a**/b` behave as `**` globstars there. `ignore` follows the documented
480
- behavior. If you need the globstar, write `**`.
505
+ To get a globstar in either case, give the run a segment of its own, such as
506
+ `a*/**/b`.
481
507
 
482
508
  ### `checkIgnore()` and a directory passed with a trailing slash
483
509
 
@@ -50,8 +50,9 @@ declare namespace ignore {
50
50
  */
51
51
  unignored: boolean
52
52
  /**
53
- * The rule that ignores the pathname. Present exactly when `ignored` is
54
- * true.
53
+ * The rule that ignores the pathname, or the parent directory it is
54
+ * ignored with: the last rule to match, which is the rule
55
+ * `git check-ignore -v` reports. Present exactly when `ignored` is true.
55
56
  */
56
57
  rule?: IgnoreRule
57
58
  }
@@ -15,6 +15,8 @@ const ESCAPE = '\\'
15
15
  const REGEX_LITERAL_SPECIAL = /[.*+?()[\]{}^$|\\/]/
16
16
  const BOM = '\uFEFF'
17
17
  const REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/
18
+ // A run of two or more asterisks is a globstar (#175)
19
+ const REGEX_ANCHORED_GLOBSTAR = /^\/\*{2,}$/
18
20
  const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/
19
21
  const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/
20
22
  const REGEX_SPLITALL_CRLF = /\r?\n/g
@@ -423,6 +425,21 @@ const REPLACERS = [
423
425
  ESCAPE + SPACE
424
426
  ],
425
427
 
428
+ // git's wildmatch() reads a run of two or more asterisks as one globstar
429
+ // whenever the run fills a path segment: it starts the pattern or follows
430
+ // a `/`, and it ends the pattern or comes before a `/`. A run of two is
431
+ // already `**`; a longer one is folded into `**` here, so the steps
432
+ // below only ever have to know `**`.
433
+ // `***/foo` -> `**/foo`, `a/***/b` -> `a/**/b`, `a/***` -> `a/**`
434
+ // git also takes a run beside a literal prefix (`a***/b`) or beside an
435
+ // escaped slash (`***\/b`) as a globstar, and this does not; the README
436
+ // lists both, under "A run of asterisks".
437
+ [
438
+ /(^|\/)\*{3,}(?=\/|$)/g,
439
+ (_, start) => `${start}**`,
440
+ '*'
441
+ ],
442
+
426
443
  // Escape metacharacters
427
444
  // which is written down by users but means special for regular expressions.
428
445
 
@@ -853,6 +870,15 @@ const pinWildcards = source => {
853
870
 
854
871
  // @param {pattern}
855
872
  const makeRegexPrefix = pattern => {
873
+ // `/**` matches every path, as `**` does. The translation below only finds
874
+ // a globstar beside a slash it keeps, and the leading one is turned into
875
+ // an anchor, so `/**` would come out as `/*` and match one level only.
876
+ // Here rather than in `createRule`, so that `checkSourceOf`, which
877
+ // compiles `/**/` again without its trailing slash, gets it too.
878
+ if (REGEX_ANCHORED_GLOBSTAR.test(pattern)) {
879
+ pattern = '**'
880
+ }
881
+
856
882
  const {source, sources} = extractBrackets(pattern)
857
883
 
858
884
  const replaced = REPLACERS.reduce(
@@ -1271,17 +1297,10 @@ class RuleManager {
1271
1297
 
1272
1298
  // Test one single path without recursively checking parent directories
1273
1299
  //
1274
- // - checkUnignored `boolean` whether should check if the path is unignored,
1275
- // setting `checkUnignored` to `false` could reduce additional
1276
- // path matching.
1277
- // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
1278
-
1279
- // @returns {TestResult} true if a file is ignored
1280
- test (path, checkUnignored, mode) {
1281
- let ignored = false
1282
- let unignored = false
1283
- let matchedRule
1300
+ // - mode `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
1284
1301
 
1302
+ // @returns {TestResult}
1303
+ test (path, mode) {
1285
1304
  // Most of a .gitignore is patterns with no slash in them, and running
1286
1305
  // those against the whole path makes the regular expression engine walk
1287
1306
  // every directory name on the way to the only segment that could match.
@@ -1296,52 +1315,40 @@ class RuleManager {
1296
1315
  ? basenameOf(path)
1297
1316
  : path
1298
1317
 
1318
+ // The last rule to match decides, as in git, and it is the rule
1319
+ // `git check-ignore -v` reports, so the scan runs from the end and stops
1320
+ // at the first match.
1299
1321
  // A plain loop rather than `forEach`, so that `path`, `basename` and
1300
1322
  // `shortcut` are locals. As a callback they became closure variables,
1301
1323
  // and reaching for one of those once per rule cost 10% of a scan over a
1302
1324
  // large rule set -- more than the shortcut they were there to serve.
1303
- for (let index = 0; index < length; index ++) {
1325
+ for (let index = length - 1; index >= 0; index --) {
1304
1326
  const rule = rules[index]
1305
- const {negative} = rule
1306
-
1307
- // | ignored : unignored
1308
- // -------- | ---------------------------------------
1309
- // negative | 0:0 | 0:1 | 1:0 | 1:1
1310
- // -------- | ------- | ------- | ------- | --------
1311
- // 0 | TEST | TEST | SKIP | X
1312
- // 1 | TESTIF | SKIP | TEST | X
1313
-
1314
- // - SKIP: always skip
1315
- // - TEST: always test
1316
- // - TESTIF: only test if checkUnignored
1317
- // - X: that never happen
1318
- const skip = unignored === negative && ignored !== unignored
1319
- || negative && !ignored && !unignored && !checkUnignored
1320
-
1321
- if (!skip && rule[mode].test(
1327
+
1328
+ if (rule[mode].test(
1322
1329
  shortcut && rule._basenameOnly
1323
1330
  ? basename
1324
1331
  : path
1325
1332
  )) {
1326
- ignored = !negative
1327
- unignored = negative
1333
+ const {negative} = rule
1328
1334
 
1329
- matchedRule = negative
1330
- ? UNDEFINED
1331
- : rule
1332
- }
1333
- }
1335
+ const ret = {
1336
+ ignored: !negative,
1337
+ unignored: negative
1338
+ }
1334
1339
 
1335
- const ret = {
1336
- ignored,
1337
- unignored
1338
- }
1340
+ if (!negative) {
1341
+ ret.rule = rule
1342
+ }
1339
1343
 
1340
- if (matchedRule) {
1341
- ret.rule = matchedRule
1344
+ return ret
1345
+ }
1342
1346
  }
1343
1347
 
1344
- return ret
1348
+ return {
1349
+ ignored: false,
1350
+ unignored: false
1351
+ }
1345
1352
  }
1346
1353
  }
1347
1354
 
@@ -1457,7 +1464,7 @@ class Ignore {
1457
1464
  }
1458
1465
 
1459
1466
  // @returns {TestResult}
1460
- _test (originalPath, cache, checkUnignored) {
1467
+ _test (originalPath, cache) {
1461
1468
  const path = originalPath
1462
1469
  // Supports nullable path
1463
1470
  && checkPath.convert(originalPath)
@@ -1470,7 +1477,7 @@ class Ignore {
1470
1477
  : RETURN_FALSE
1471
1478
  )
1472
1479
 
1473
- return this._t(path, cache, checkUnignored)
1480
+ return this._t(path, cache)
1474
1481
  }
1475
1482
 
1476
1483
  checkIgnore (path) {
@@ -1483,7 +1490,7 @@ class Ignore {
1483
1490
  // Like `git check-ignore`: a directory excluded by itself or by an
1484
1491
  // ancestor settles it, and only then is the literal 'abc/' matched
1485
1492
  // against the rules (see `checkSourceOf`).
1486
- const dir = this._t(path, this._testCache, true)
1493
+ const dir = this._t(path, this._testCache)
1487
1494
 
1488
1495
  if (dir.ignored) {
1489
1496
  return dir
@@ -1501,10 +1508,7 @@ class Ignore {
1501
1508
  path,
1502
1509
 
1503
1510
  // The cache for the result of a certain checking
1504
- cache,
1505
-
1506
- // Whether should check if the path is unignored
1507
- checkUnignored
1511
+ cache
1508
1512
  ) {
1509
1513
  if (path in cache) {
1510
1514
  return cache[path]
@@ -1514,18 +1518,18 @@ class Ignore {
1514
1518
 
1515
1519
  // If the path contains a parent directory, check the parent first
1516
1520
  const parent = parentPath
1517
- ? this._t(parentPath, cache, checkUnignored)
1521
+ ? this._t(parentPath, cache)
1518
1522
  : UNDEFINED
1519
1523
 
1520
1524
  return cache[path] = parent && parent.ignored
1521
1525
  // > It is not possible to re-include a file if a parent directory of
1522
1526
  // > that file is excluded.
1523
1527
  ? parent
1524
- : this._rules.test(path, checkUnignored, MODE_IGNORE)
1528
+ : this._rules.test(path, MODE_IGNORE)
1525
1529
  }
1526
1530
 
1527
1531
  ignores (path) {
1528
- return this._test(path, this._ignoreCache, false).ignored
1532
+ return this._test(path, this._ignoreCache).ignored
1529
1533
  }
1530
1534
 
1531
1535
  createFilter () {
@@ -1538,7 +1542,7 @@ class Ignore {
1538
1542
 
1539
1543
  // @returns {TestResult}
1540
1544
  test (path) {
1541
- return this._test(path, this._testCache, true)
1545
+ return this._test(path, this._testCache)
1542
1546
  }
1543
1547
  }
1544
1548