@mrclrchtr/supi-tree-sitter 7.3.1 → 8.0.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.
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +22 -4
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +110 -0
- package/node_modules/@mrclrchtr/supi-core/src/config.ts +6 -1
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +2 -1
- package/package.json +3 -3
|
@@ -14,7 +14,7 @@ export type {
|
|
|
14
14
|
StructuralProvider,
|
|
15
15
|
StructuralResult,
|
|
16
16
|
} from "./capability/types.ts";
|
|
17
|
-
export type { CodeQueryResult } from "./query-result.ts";
|
|
17
|
+
export type { CodeQueryPartialMetadata, CodeQueryResult } from "./query-result.ts";
|
|
18
18
|
// Shared query-result constructors and contract
|
|
19
19
|
export {
|
|
20
20
|
completedCodeQuery,
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/** Structured metadata for a partial query result. */
|
|
2
|
+
export interface CodeQueryPartialMetadata {
|
|
3
|
+
/** Automatic path-policy evidence removed from a collected result. */
|
|
4
|
+
readonly automaticPathExclusion?: {
|
|
5
|
+
readonly excludedCount: number;
|
|
6
|
+
readonly examples: readonly string[];
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
1
10
|
/**
|
|
2
11
|
* Result of a read-only code-provider query.
|
|
3
12
|
*
|
|
@@ -8,7 +17,12 @@
|
|
|
8
17
|
*/
|
|
9
18
|
export type CodeQueryResult<T> =
|
|
10
19
|
| { readonly kind: "completed"; readonly data: T }
|
|
11
|
-
| {
|
|
20
|
+
| {
|
|
21
|
+
readonly kind: "partial";
|
|
22
|
+
readonly data: T;
|
|
23
|
+
readonly reason: string;
|
|
24
|
+
readonly metadata?: CodeQueryPartialMetadata;
|
|
25
|
+
}
|
|
12
26
|
| { readonly kind: "unavailable"; readonly reason: string };
|
|
13
27
|
|
|
14
28
|
/** Construct a successfully completed code-query result, including empty data. */
|
|
@@ -17,8 +31,12 @@ export function completedCodeQuery<T>(data: T): CodeQueryResult<T> {
|
|
|
17
31
|
}
|
|
18
32
|
|
|
19
33
|
/** Construct a usable but incomplete code-query result. */
|
|
20
|
-
export function partialCodeQuery<T>(
|
|
21
|
-
|
|
34
|
+
export function partialCodeQuery<T>(
|
|
35
|
+
data: T,
|
|
36
|
+
reason: string,
|
|
37
|
+
metadata?: CodeQueryPartialMetadata,
|
|
38
|
+
): CodeQueryResult<T> {
|
|
39
|
+
return { kind: "partial", data, reason, ...(metadata ? { metadata } : {}) };
|
|
22
40
|
}
|
|
23
41
|
|
|
24
42
|
/** Construct a code-query result that could not be established. */
|
|
@@ -35,7 +53,7 @@ export function mapCodeQueryResult<T, U>(
|
|
|
35
53
|
case "completed":
|
|
36
54
|
return completedCodeQuery(map(result.data));
|
|
37
55
|
case "partial":
|
|
38
|
-
return partialCodeQuery(map(result.data), result.reason);
|
|
56
|
+
return partialCodeQuery(map(result.data), result.reason, result.metadata);
|
|
39
57
|
case "unavailable":
|
|
40
58
|
return unavailableCodeQuery(result.reason);
|
|
41
59
|
}
|
|
@@ -70,6 +70,116 @@ export interface SupiConfigOptions {
|
|
|
70
70
|
homeDir?: string;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/** Options for loading automatic code-intelligence exclusions. */
|
|
74
|
+
export interface AutomaticExclusionOptions extends SupiConfigOptions {
|
|
75
|
+
/** Whether the project config is trusted and can apply. Defaults to true. */
|
|
76
|
+
projectTrusted?: boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Load the one configured exclusion list shared by automatic LSP work and
|
|
81
|
+
* broad AST searches.
|
|
82
|
+
*
|
|
83
|
+
* Project values replace global values. An explicit empty project list clears
|
|
84
|
+
* the global list. The old `lsp.exclude` key is rejected in every applicable
|
|
85
|
+
* scope so automatic work cannot start without its former protection.
|
|
86
|
+
*/
|
|
87
|
+
export function loadAutomaticExclusionPatterns(
|
|
88
|
+
cwd: string,
|
|
89
|
+
options: AutomaticExclusionOptions = {},
|
|
90
|
+
): readonly string[] {
|
|
91
|
+
const projectTrusted = options.projectTrusted !== false;
|
|
92
|
+
const globalCodeIntelligence = loadSupiConfigSectionForScope("code-intelligence", cwd, {
|
|
93
|
+
scope: "global",
|
|
94
|
+
homeDir: options.homeDir,
|
|
95
|
+
});
|
|
96
|
+
const projectCodeIntelligence = projectTrusted
|
|
97
|
+
? loadSupiConfigSectionForScope("code-intelligence", cwd, { scope: "project" })
|
|
98
|
+
: null;
|
|
99
|
+
const globalLsp = loadSupiConfigSectionForScope("lsp", cwd, {
|
|
100
|
+
scope: "global",
|
|
101
|
+
homeDir: options.homeDir,
|
|
102
|
+
});
|
|
103
|
+
const projectLsp = projectTrusted
|
|
104
|
+
? loadSupiConfigSectionForScope("lsp", cwd, { scope: "project" })
|
|
105
|
+
: null;
|
|
106
|
+
|
|
107
|
+
const legacyPath = findLegacyExclusionPath(cwd, options, globalLsp, projectLsp);
|
|
108
|
+
if (legacyPath) {
|
|
109
|
+
throw new Error(
|
|
110
|
+
`Unsupported ${legacyPath.scope} configuration at ${legacyPath.path}: "lsp.exclude" was removed. Move its value to "code-intelligence.exclude". Automatic LSP and broad AST work did not start; reload after migration.`,
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const source = findExclusionSource(cwd, options, {
|
|
115
|
+
projectTrusted,
|
|
116
|
+
globalCodeIntelligence,
|
|
117
|
+
projectCodeIntelligence,
|
|
118
|
+
});
|
|
119
|
+
return validateExclusionSource(source);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
interface ExclusionSource {
|
|
123
|
+
value: unknown;
|
|
124
|
+
path: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface LegacyExclusionPath {
|
|
128
|
+
scope: "global" | "project";
|
|
129
|
+
path: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function findLegacyExclusionPath(
|
|
133
|
+
cwd: string,
|
|
134
|
+
options: AutomaticExclusionOptions,
|
|
135
|
+
globalLsp: Record<string, unknown> | null,
|
|
136
|
+
projectLsp: Record<string, unknown> | null,
|
|
137
|
+
): LegacyExclusionPath | null {
|
|
138
|
+
if (globalLsp && Object.hasOwn(globalLsp, "exclude")) {
|
|
139
|
+
return { scope: "global", path: getSupiConfigPath("global", cwd, options) };
|
|
140
|
+
}
|
|
141
|
+
if (projectLsp && Object.hasOwn(projectLsp, "exclude")) {
|
|
142
|
+
return { scope: "project", path: getSupiConfigPath("project", cwd) };
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function findExclusionSource(
|
|
148
|
+
cwd: string,
|
|
149
|
+
options: AutomaticExclusionOptions,
|
|
150
|
+
sections: {
|
|
151
|
+
projectTrusted: boolean;
|
|
152
|
+
globalCodeIntelligence: Record<string, unknown> | null;
|
|
153
|
+
projectCodeIntelligence: Record<string, unknown> | null;
|
|
154
|
+
},
|
|
155
|
+
): ExclusionSource | null {
|
|
156
|
+
const { projectTrusted, globalCodeIntelligence, projectCodeIntelligence } = sections;
|
|
157
|
+
if (
|
|
158
|
+
projectTrusted &&
|
|
159
|
+
projectCodeIntelligence &&
|
|
160
|
+
Object.hasOwn(projectCodeIntelligence, "exclude")
|
|
161
|
+
) {
|
|
162
|
+
return { value: projectCodeIntelligence.exclude, path: getSupiConfigPath("project", cwd) };
|
|
163
|
+
}
|
|
164
|
+
if (globalCodeIntelligence && Object.hasOwn(globalCodeIntelligence, "exclude")) {
|
|
165
|
+
return {
|
|
166
|
+
value: globalCodeIntelligence.exclude,
|
|
167
|
+
path: getSupiConfigPath("global", cwd, options),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function validateExclusionSource(source: ExclusionSource | null): readonly string[] {
|
|
174
|
+
if (!source) return Object.freeze([]);
|
|
175
|
+
if (!Array.isArray(source.value) || !source.value.every((entry) => typeof entry === "string")) {
|
|
176
|
+
throw new Error(
|
|
177
|
+
`Invalid "code-intelligence.exclude" in ${source.path}: expected an array of gitignore-style strings. Automatic LSP and broad AST work did not start.`,
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
return Object.freeze([...source.value]);
|
|
181
|
+
}
|
|
182
|
+
|
|
73
183
|
/**
|
|
74
184
|
* Load and merge config for a given extension section.
|
|
75
185
|
*
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
// supi-core config domain — config loading.
|
|
2
|
-
export type {
|
|
2
|
+
export type {
|
|
3
|
+
AutomaticExclusionOptions,
|
|
4
|
+
SupiConfigLocation,
|
|
5
|
+
SupiConfigOptions,
|
|
6
|
+
} from "./config/config.ts";
|
|
3
7
|
export {
|
|
4
8
|
getSupiConfigPath,
|
|
9
|
+
loadAutomaticExclusionPatterns,
|
|
5
10
|
loadSupiConfig,
|
|
6
11
|
loadSupiConfigForScope,
|
|
7
12
|
loadSupiConfigSectionForScope,
|
|
@@ -151,6 +151,7 @@ export interface CustomField extends BaseField {
|
|
|
151
151
|
cwd: string,
|
|
152
152
|
action: SettingsAction,
|
|
153
153
|
helpers: ConfigHelpers,
|
|
154
|
+
ctx?: ExtensionContext,
|
|
154
155
|
) => void | Promise<void>;
|
|
155
156
|
}
|
|
156
157
|
|
|
@@ -404,7 +405,7 @@ async function applyConfigAction(
|
|
|
404
405
|
const helpers = createConfigHelpers(options.section, scope, cwd, options.homeDir);
|
|
405
406
|
let storedValue: unknown;
|
|
406
407
|
if (field.kind === "custom") {
|
|
407
|
-
await field.persist(scope, cwd, action, helpers);
|
|
408
|
+
await field.persist(scope, cwd, action, helpers, ctx);
|
|
408
409
|
storedValue = action.kind === "set" ? action.value : undefined;
|
|
409
410
|
} else if (action.kind === "set") {
|
|
410
411
|
storedValue = parseTypedValue(action.value, field);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-tree-sitter",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.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": "
|
|
40
|
-
"@mrclrchtr/supi-core": "
|
|
39
|
+
"@mrclrchtr/supi-code-runtime": "8.0.0",
|
|
40
|
+
"@mrclrchtr/supi-core": "8.0.0"
|
|
41
41
|
},
|
|
42
42
|
"bundledDependencies": [
|
|
43
43
|
"@mrclrchtr/supi-code-runtime",
|