@mrclrchtr/supi-code-intelligence 8.0.1 → 9.1.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 (76) hide show
  1. package/README.md +3 -2
  2. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  3. package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +10 -1
  4. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  5. package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +9 -4
  6. package/node_modules/@mrclrchtr/supi-core/src/session-capabilities.ts +55 -1
  7. package/node_modules/@mrclrchtr/supi-core/src/session-capability-profiles.ts +240 -0
  8. package/node_modules/@mrclrchtr/supi-core/src/session.ts +22 -0
  9. package/node_modules/@mrclrchtr/supi-lsp/README.md +1 -0
  10. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  11. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +10 -1
  12. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  13. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +9 -4
  14. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session-capabilities.ts +55 -1
  15. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session-capability-profiles.ts +240 -0
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +22 -0
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/README.md +6 -9
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/index.js +202 -106
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/legacy.js +164 -88
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/package.json +1 -1
  21. package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
  22. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +14 -3
  23. package/node_modules/@mrclrchtr/supi-lsp/src/config/defaults.json +6 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +1 -1
  25. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +1 -1
  26. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +1 -0
  27. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-normalizer.ts +1 -1
  28. package/node_modules/@mrclrchtr/supi-lsp/src/utils.ts +2 -0
  29. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +12 -3
  30. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  31. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +10 -1
  32. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  33. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +9 -4
  34. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session-capabilities.ts +55 -1
  35. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session-capability-profiles.ts +240 -0
  36. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +22 -0
  37. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm +0 -0
  38. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm.map +7 -7
  39. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +1 -1
  40. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm +0 -0
  41. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm.map +7 -7
  42. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +6 -4
  43. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm.json +1 -1
  44. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/latex/LICENSE +21 -0
  45. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/latex/tree-sitter-latex.wasm +0 -0
  46. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/latex/tree-sitter-latex.wasm.json +17 -0
  47. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +1 -1
  48. package/node_modules/@mrclrchtr/supi-tree-sitter/src/language.ts +5 -1
  49. package/node_modules/@mrclrchtr/supi-tree-sitter/src/operation-support.ts +6 -0
  50. package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +2 -0
  51. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +45 -34
  52. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-process.ts +122 -0
  53. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-protocol.ts +1 -1
  54. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +1 -0
  55. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/imports.ts +55 -1
  56. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-latex.ts +288 -0
  57. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-polyglot.ts +8 -1
  58. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline.ts +18 -4
  59. package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +11 -3
  60. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/process-host.mjs +92 -0
  61. package/package.json +5 -5
  62. package/src/analysis/refactor/latex-section-rename.ts +343 -0
  63. package/src/analysis/target/anchored-structural.ts +148 -0
  64. package/src/analysis/target/anchored.ts +15 -124
  65. package/src/analysis/target/file-refinement.ts +51 -0
  66. package/src/analysis/target/file.ts +49 -47
  67. package/src/analysis/target/identity.ts +147 -29
  68. package/src/analysis/target/latex-label-container.ts +137 -0
  69. package/src/analysis/target/latex-section-anchor.ts +116 -0
  70. package/src/analysis/target/latex-target-anchor.ts +17 -0
  71. package/src/overview/overview-data.ts +1 -0
  72. package/src/session/inspect/collect.ts +3 -1
  73. package/src/session/refactor-plans.ts +3 -1
  74. package/src/session/refactor-workflow.ts +127 -49
  75. package/src/tool/code_inspect/markdown.ts +1 -1
  76. package/src/tool/result/refactor.ts +24 -6
@@ -0,0 +1,240 @@
1
+ /** Exact names to exclude. Omitted configuration lists mean empty sets. */
2
+ export interface SessionCapabilityProfileDefinition {
3
+ excludedTools?: string[];
4
+ hiddenSkills?: string[];
5
+ }
6
+
7
+ /** Validated exclusion sets. Names need not match the current inventory. */
8
+ export interface SessionCapabilityProfile {
9
+ excludedTools: string[];
10
+ hiddenSkills: string[];
11
+ }
12
+
13
+ /** A profile is available only when validation has no errors. */
14
+ export interface SessionCapabilityProfileValidation {
15
+ profile?: SessionCapabilityProfile;
16
+ errors: string[];
17
+ }
18
+
19
+ function isRecord(value: unknown): value is Record<string, unknown> {
20
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
21
+ const prototype = Object.getPrototypeOf(value);
22
+ return prototype === Object.prototype || prototype === null;
23
+ }
24
+
25
+ function readNames(value: unknown): string[] | undefined {
26
+ if (!Array.isArray(value)) return undefined;
27
+ const names: unknown[] = [...new Set(value)];
28
+ return names.every((name): name is string => typeof name === "string") ? names : undefined;
29
+ }
30
+
31
+ /** Validate and copy a complete definition. Do not check inventory or expand patterns. */
32
+ export function validateSessionCapabilityProfile(
33
+ value: unknown,
34
+ ): SessionCapabilityProfileValidation {
35
+ if (!isRecord(value)) return { errors: ["Profile must be an object."] };
36
+ const excludedTools = Object.hasOwn(value, "excludedTools") ? readNames(value.excludedTools) : [];
37
+ const hiddenSkills = Object.hasOwn(value, "hiddenSkills") ? readNames(value.hiddenSkills) : [];
38
+ const errors = Object.keys(value)
39
+ .filter((key) => key !== "excludedTools" && key !== "hiddenSkills")
40
+ .map((key) => `Unknown profile field: ${key}.`);
41
+ if (!excludedTools) errors.push("excludedTools must be an array of strings.");
42
+ if (!hiddenSkills) errors.push("hiddenSkills must be an array of strings.");
43
+ if (errors.length || !excludedTools || !hiddenSkills) return { errors };
44
+ return { profile: { excludedTools, hiddenSkills }, errors };
45
+ }
46
+
47
+ /** Configuration scope that supplied a profile or default. */
48
+ export type SessionCapabilityProfileScope = "global" | "project";
49
+
50
+ /** Configuration values for the sessionCapabilities section. */
51
+ export interface SessionCapabilityProfilesSection {
52
+ profiles?: Record<string, SessionCapabilityProfileDefinition>;
53
+ defaultProfile?: string | null;
54
+ }
55
+
56
+ /** Session-owned identity and original exclusion sets, independent of configuration. */
57
+ export interface SessionCapabilityProfileSnapshot extends SessionCapabilityProfile {
58
+ id: string;
59
+ source: SessionCapabilityProfileScope;
60
+ }
61
+
62
+ /** A configuration error with a scope and field path for display. */
63
+ export interface SessionCapabilityProfileDiagnostic {
64
+ scope: SessionCapabilityProfileScope;
65
+ path: string;
66
+ message: string;
67
+ }
68
+
69
+ /** A scoped definition, including invalid definitions and hidden global definitions. */
70
+ export interface SessionCapabilityProfileEntry {
71
+ id: string;
72
+ source: SessionCapabilityProfileScope;
73
+ shadowed: boolean;
74
+ profile?: SessionCapabilityProfile;
75
+ errors: SessionCapabilityProfileDiagnostic[];
76
+ }
77
+
78
+ /** Default selection source can differ from the effective profile source. */
79
+ export type SessionCapabilityProfileDefault =
80
+ | { status: "none"; source?: SessionCapabilityProfileScope }
81
+ | {
82
+ status: "resolved";
83
+ source: SessionCapabilityProfileScope;
84
+ id: string;
85
+ profile: SessionCapabilityProfileSnapshot;
86
+ }
87
+ | { status: "invalid"; source: SessionCapabilityProfileScope; id?: string };
88
+
89
+ /** Raw sections, not merged configuration. Callers must check trust before project reads. */
90
+ export interface ResolveSessionCapabilityProfilesOptions {
91
+ global?: unknown;
92
+ project?: unknown;
93
+ projectTrusted: boolean;
94
+ }
95
+
96
+ /** Data for profile rows, scoped actions, and default warnings. No I/O is performed. */
97
+ export interface SessionCapabilityProfilesResolution {
98
+ entries: SessionCapabilityProfileEntry[];
99
+ effectiveProfiles: SessionCapabilityProfileSnapshot[];
100
+ default: SessionCapabilityProfileDefault;
101
+ errors: SessionCapabilityProfileDiagnostic[];
102
+ }
103
+
104
+ /** IDs contain lowercase ASCII words separated by single hyphens. */
105
+ export function isSessionCapabilityProfileId(value: unknown): value is string {
106
+ return typeof value === "string" && /^[a-z]+(?:-[a-z]+)*$/.test(value);
107
+ }
108
+
109
+ /** Validate and copy stored identity and original lists. Invalid metadata has no identity. */
110
+ export function decodeSessionCapabilityProfileSnapshot(
111
+ value: unknown,
112
+ ): SessionCapabilityProfileSnapshot | undefined {
113
+ if (!isRecord(value) || !isSessionCapabilityProfileId(value.id)) return undefined;
114
+ if (value.source !== "global" && value.source !== "project") return undefined;
115
+ const { id, source, ...definition } = value;
116
+ if (!Object.hasOwn(definition, "excludedTools") || !Object.hasOwn(definition, "hiddenSkills"))
117
+ return undefined;
118
+ const result = validateSessionCapabilityProfile(definition);
119
+ return result.profile ? { id, source, ...result.profile } : undefined;
120
+ }
121
+
122
+ function readEntries(
123
+ value: unknown,
124
+ source: SessionCapabilityProfileScope,
125
+ ): SessionCapabilityProfileEntry[] {
126
+ if (!isRecord(value) || !isRecord(value.profiles)) return [];
127
+ return Object.entries(value.profiles).map(([id, definition]) => {
128
+ const result = validateSessionCapabilityProfile(definition);
129
+ if (!isSessionCapabilityProfileId(id))
130
+ result.errors.push("Invalid profile ID: use lowercase words with single hyphens.");
131
+ return {
132
+ id,
133
+ source,
134
+ shadowed: false,
135
+ profile: result.errors.length ? undefined : result.profile,
136
+ errors: result.errors.map((message) => ({ scope: source, path: `profiles.${id}`, message })),
137
+ };
138
+ });
139
+ }
140
+
141
+ type DefaultReference =
142
+ | SessionCapabilityProfileDefault
143
+ | { status: "pending"; source: SessionCapabilityProfileScope; id: string };
144
+
145
+ function readDefault(
146
+ value: unknown,
147
+ source: SessionCapabilityProfileScope,
148
+ errors: SessionCapabilityProfileDiagnostic[],
149
+ ): DefaultReference | undefined {
150
+ if (!isRecord(value) || !Object.hasOwn(value, "defaultProfile")) return undefined;
151
+ if (value.defaultProfile === null) return { status: "none", source };
152
+ if (isSessionCapabilityProfileId(value.defaultProfile)) {
153
+ return { status: "pending", source, id: value.defaultProfile };
154
+ }
155
+ errors.push({
156
+ scope: source,
157
+ path: "defaultProfile",
158
+ message: "defaultProfile must be null or a valid profile ID.",
159
+ });
160
+ return { status: "invalid", source };
161
+ }
162
+
163
+ function resolveDefault(
164
+ selected: DefaultReference | undefined,
165
+ profiles: SessionCapabilityProfileSnapshot[],
166
+ errors: SessionCapabilityProfileDiagnostic[],
167
+ ): SessionCapabilityProfileDefault {
168
+ if (!selected) return { status: "none" };
169
+ if (selected.status !== "pending") return selected;
170
+ const { source, id } = selected;
171
+ const profile = profiles.find((entry) => entry.id === id);
172
+ if (profile) return { status: "resolved", source, id, profile };
173
+ errors.push({
174
+ scope: source,
175
+ path: "defaultProfile",
176
+ message: `Default profile ${id} is missing or invalid. No profile will be applied.`,
177
+ });
178
+ return { status: "invalid", source, id };
179
+ }
180
+
181
+ interface ScopedProfiles {
182
+ entries: SessionCapabilityProfileEntry[];
183
+ errors: SessionCapabilityProfileDiagnostic[];
184
+ default?: DefaultReference;
185
+ }
186
+
187
+ /** Reject malformed sections, but retain known IDs to prevent global fallback. */
188
+ function readSection(value: unknown, scope: SessionCapabilityProfileScope): ScopedProfiles {
189
+ if (value === undefined) return { entries: [], errors: [] };
190
+ if (!isRecord(value)) {
191
+ return {
192
+ entries: [],
193
+ default: { status: "invalid", source: scope },
194
+ errors: [
195
+ { scope, path: "sessionCapabilities", message: "sessionCapabilities must be an object." },
196
+ ],
197
+ };
198
+ }
199
+ const sectionErrors = Object.keys(value)
200
+ .filter((key) => key !== "profiles" && key !== "defaultProfile")
201
+ .map((key) => ({ scope, path: key, message: `Unknown section field: ${key}.` }));
202
+ if (Object.hasOwn(value, "profiles") && !isRecord(value.profiles)) {
203
+ sectionErrors.push({ scope, path: "profiles", message: "profiles must be an object." });
204
+ }
205
+ const entries = readEntries(value, scope);
206
+ const errors = [...sectionErrors, ...entries.flatMap((entry) => entry.errors)];
207
+ const selection = readDefault(value, scope, errors);
208
+ if (sectionErrors.length) {
209
+ for (const entry of entries) {
210
+ entry.profile = undefined;
211
+ entry.errors.push(...sectionErrors);
212
+ }
213
+ return { entries, errors, default: { status: "invalid", source: scope } };
214
+ }
215
+ return { entries, errors, default: selection };
216
+ }
217
+
218
+ /**
219
+ * Resolve whole profiles by ID. Ignore project data unless projectTrusted is true.
220
+ * An absent section is undefined. Malformed sections cannot supply profiles or a default.
221
+ */
222
+ export function resolveSessionCapabilityProfiles(
223
+ options: ResolveSessionCapabilityProfilesOptions,
224
+ ): SessionCapabilityProfilesResolution {
225
+ const global = readSection(options.global, "global");
226
+ const project = readSection(options.projectTrusted ? options.project : undefined, "project");
227
+ const entries = [...global.entries, ...project.entries];
228
+ const errors = [...global.errors, ...project.errors];
229
+ const selected = new Map(entries.map((entry) => [entry.id, entry]));
230
+ for (const entry of entries) entry.shadowed = selected.get(entry.id) !== entry;
231
+ const effectiveProfiles = [...selected.values()].flatMap((entry) =>
232
+ entry.profile ? [{ id: entry.id, source: entry.source, ...entry.profile }] : [],
233
+ );
234
+ return {
235
+ entries,
236
+ effectiveProfiles,
237
+ default: resolveDefault(project.default ?? global.default, effectiveProfiles, errors),
238
+ errors,
239
+ };
240
+ }
@@ -7,17 +7,39 @@ export type {
7
7
  SessionCapabilityState,
8
8
  } from "./session-capabilities.ts";
9
9
  export {
10
+ applySessionCapabilityProfile,
11
+ captureSessionCapabilityExclusions,
10
12
  clearPendingSessionCapabilityForks,
11
13
  createEmptySessionCapabilityState,
12
14
  decodeSessionCapabilities,
13
15
  findSessionCapabilities,
14
16
  getSessionCapabilitySkillProvider,
17
+ isSessionCapabilityProfileModified,
15
18
  readPendingSessionCapabilityFork,
16
19
  registerSessionCapabilitySkillProvider,
17
20
  SESSION_CAPABILITIES_ENTRY,
18
21
  sessionCapabilityState,
19
22
  setPendingSessionCapabilityFork,
20
23
  } from "./session-capabilities.ts";
24
+ export type {
25
+ ResolveSessionCapabilityProfilesOptions,
26
+ SessionCapabilityProfile,
27
+ SessionCapabilityProfileDefault,
28
+ SessionCapabilityProfileDefinition,
29
+ SessionCapabilityProfileDiagnostic,
30
+ SessionCapabilityProfileEntry,
31
+ SessionCapabilityProfileScope,
32
+ SessionCapabilityProfileSnapshot,
33
+ SessionCapabilityProfilesResolution,
34
+ SessionCapabilityProfilesSection,
35
+ SessionCapabilityProfileValidation,
36
+ } from "./session-capability-profiles.ts";
37
+ export {
38
+ decodeSessionCapabilityProfileSnapshot,
39
+ isSessionCapabilityProfileId,
40
+ resolveSessionCapabilityProfiles,
41
+ validateSessionCapabilityProfile,
42
+ } from "./session-capability-profiles.ts";
21
43
  export type { SessionNameTrackerHost } from "./session-utils.ts";
22
44
  export {
23
45
  createSessionNameTracker,
@@ -426,15 +426,12 @@ behavior. If you need the globstar, write `**`.
426
426
 
427
427
  ### `checkIgnore()` and a directory passed with a trailing slash
428
428
 
429
- `git check-ignore` treats its arguments as plain strings: handed `a/`, it
430
- computes an empty basename, with surprising results — `a/**` matches `a/`
431
- itself, and a negated basename pattern like `!a` fails to match it. During
432
- an actual traversal git behaves differently: `a/**` does **not** exclude
433
- the directory `a` (that is what allows it to descend and exclude the
434
- contents), and `!a` negates it normally. `ignore` models the traversal
435
- semantics: `'a/'` means *the directory a*, with its basename `a/`. Where
436
- the two disagree, `ignore` sides with what `git status` actually does
437
- rather than with the string-level quirks of `check-ignore`.
429
+ `.checkIgnore('a/')` follows `git check-ignore -- a/`, which differs from a
430
+ traversal. If the directory `a` is excluded, by itself or by an ancestor,
431
+ that is the answer. Otherwise git matches the literal string `a/`, where the
432
+ basename is empty: `a/*` and `a/**` match `a/` itself, and a pattern like
433
+ `!a` or `!a/` does not. `.ignores('a/')` and `.test('a/')` keep the
434
+ traversal semantics, where `a/**` does **not** exclude the directory `a`.
438
435
 
439
436
  ## Upgrade 4.x -> 5.x
440
437