@mrclrchtr/supi-code-intelligence 11.1.0 → 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.
- package/README.md +29 -4
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/README.md +42 -5
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/LICENSE +15 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/README.md +680 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/bin/semver.js +195 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/comparator.js +143 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/index.js +7 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/range.js +577 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/semver.js +350 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/clean.js +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/cmp.js +54 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/coerce.js +62 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-build.js +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-loose.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare.js +7 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/diff.js +60 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/eq.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gt.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gte.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/inc.js +21 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lt.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lte.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/major.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/minor.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/neq.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/parse.js +18 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/patch.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/prerelease.js +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rcompare.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rsort.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/satisfies.js +12 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/sort.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/truncate.js +48 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/valid.js +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/index.js +93 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +37 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/debug.js +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/identifiers.js +29 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/lrucache.js +42 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/parse-options.js +17 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/re.js +223 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/package.json +78 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/preload.js +4 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/range.bnf +17 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/gtr.js +6 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/intersects.js +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/ltr.js +6 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-version.js +63 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/outside.js +82 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/simplify.js +49 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/subset.js +249 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/to-comparators.js +10 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/valid.js +13 -0
- package/node_modules/@mrclrchtr/supi-lsp/package.json +5 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +23 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +53 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +19 -4
- package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +22 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-launch.ts +276 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +22 -10
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +52 -19
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +4 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/session/scanner.ts +27 -15
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
- package/package.json +5 -5
- package/src/analysis/capability/capability-warnings.ts +18 -12
- package/src/analysis/health/check.ts +115 -0
- package/src/analysis/health/diagnostics.ts +3 -0
- package/src/analysis/health/file-scope.ts +2 -3
- package/src/analysis/health/semantic-state.ts +38 -0
- package/src/analysis/health/server-status.ts +8 -0
- package/src/analysis/health/signals.ts +2 -0
- package/src/analysis/health/status.ts +82 -0
- package/src/analysis/refactor/apply.ts +17 -8
- package/src/session/health-types.ts +7 -0
- package/src/session/health-workflow.ts +8 -43
- package/src/session/orientation/collect.ts +138 -12
- package/src/session/orientation/context-facts.ts +27 -2
- package/src/session/orientation/context-sections.ts +47 -0
- package/src/session/orientation/facts.ts +124 -0
- package/src/session/orientation/gather.ts +98 -11
- package/src/session/orientation/workspace-context.ts +16 -6
- package/src/session/orientation-types.ts +5 -0
- package/src/session/orientation-workflow.ts +3 -2
- package/src/session/refactor-plans.ts +5 -2
- package/src/session/refactor-workflow.ts +4 -3
- package/src/tool/code_find/guidance.ts +1 -1
- package/src/tool/code_health/markdown.ts +12 -2
- package/src/tool/code_health/result.ts +15 -2
- package/src/tool/code_health/spec.ts +2 -0
- package/src/tool/code_health/structured-schema.ts +250 -0
- package/src/tool/code_health/structured.ts +256 -0
- package/src/tool/code_inspect/result.ts +11 -5
- package/src/tool/code_inspect/spec.ts +2 -0
- package/src/tool/code_inspect/structured.ts +232 -0
- package/src/tool/code_orientation/result.ts +10 -4
- package/src/tool/code_orientation/spec.ts +2 -0
- package/src/tool/code_orientation/structured-schema.ts +607 -0
- package/src/tool/code_orientation/structured-workspace.ts +193 -0
- package/src/tool/code_orientation/structured.ts +195 -0
- package/src/tool/code_orientation/workspace-observations.ts +81 -0
- package/src/tool/code_orientation/workspace-output.ts +5 -0
- package/src/tool/code_orientation/workspace-projects.ts +16 -31
- package/src/tool/code_orientation/workspace-sections.ts +43 -30
- package/src/tool/code_refactor_apply/execute.ts +1 -1
- package/src/tool/code_refactor_apply/result.ts +13 -5
- package/src/tool/code_refactor_apply/spec.ts +2 -0
- package/src/tool/code_refactor_apply/structured.ts +49 -0
- package/src/tool/code_refactor_plan/result.ts +16 -8
- package/src/tool/code_refactor_plan/spec.ts +2 -0
- package/src/tool/code_refactor_plan/structured.ts +128 -0
- package/src/tool/schemas.ts +7 -1
- package/src/ui/status-command.ts +110 -321
- package/src/ui/status-overlay.ts +564 -420
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
isScopedFile,
|
|
21
21
|
} from "../analysis/health/diagnostics.ts";
|
|
22
22
|
import { describeStructuralState } from "../analysis/health/recovery.ts";
|
|
23
|
+
import { deriveWorkspaceSemanticHealthState } from "../analysis/health/semantic-state.ts";
|
|
23
24
|
import { collectServers } from "../analysis/health/signals.ts";
|
|
24
25
|
import { SEMANTIC_READINESS_TIMEOUT_REASON } from "../analysis/readiness.ts";
|
|
25
26
|
import { resolveScope } from "../analysis/search/paths.ts";
|
|
@@ -175,55 +176,19 @@ async function establishSemanticHealthState(
|
|
|
175
176
|
options.control,
|
|
176
177
|
)
|
|
177
178
|
: null);
|
|
178
|
-
if (!readiness)
|
|
179
|
+
if (!readiness)
|
|
180
|
+
return deriveWorkspaceSemanticHealthState(options.lspState, options.capabilityState, []);
|
|
179
181
|
if (readiness.kind === "ready") return { kind: "ready" };
|
|
180
182
|
if (readiness.kind === "timeout") {
|
|
181
183
|
return { kind: "pending", reason: SEMANTIC_READINESS_TIMEOUT_REASON };
|
|
182
184
|
}
|
|
183
185
|
return { kind: "unavailable", reason: readiness.reason };
|
|
184
186
|
}
|
|
185
|
-
|
|
186
|
-
options.
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
)
|
|
190
|
-
return { kind: "ready" };
|
|
191
|
-
}
|
|
192
|
-
return deriveNonReadySemanticState(options.lspState, options.capabilityState);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function deriveNonReadySemanticState(
|
|
196
|
-
lspState: WorkspaceLspRuntimeState,
|
|
197
|
-
capabilityState: CapabilityState,
|
|
198
|
-
): Exclude<SemanticHealthState, { kind: "ready" }> {
|
|
199
|
-
switch (lspState.kind) {
|
|
200
|
-
case "pending":
|
|
201
|
-
return { kind: "pending", reason: "LSP is starting" };
|
|
202
|
-
case "inactive":
|
|
203
|
-
return { kind: "inactive", reason: "Inactive on the current session branch" };
|
|
204
|
-
case "disabled":
|
|
205
|
-
return { kind: "disabled", reason: "Disabled by configuration" };
|
|
206
|
-
case "unavailable":
|
|
207
|
-
return { kind: "unavailable", reason: lspState.reason };
|
|
208
|
-
case "ready":
|
|
209
|
-
return deriveReadyOwnerWithoutServerState(capabilityState);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
function deriveReadyOwnerWithoutServerState(
|
|
214
|
-
capabilityState: CapabilityState,
|
|
215
|
-
): Exclude<SemanticHealthState, { kind: "ready" }> {
|
|
216
|
-
switch (capabilityState.kind) {
|
|
217
|
-
case "inactive":
|
|
218
|
-
return { kind: "inactive", reason: "Inactive on the current session branch" };
|
|
219
|
-
case "disabled":
|
|
220
|
-
return { kind: "disabled", reason: "Disabled by configuration" };
|
|
221
|
-
case "unavailable":
|
|
222
|
-
return { kind: "unavailable", reason: capabilityState.reason };
|
|
223
|
-
case "pending":
|
|
224
|
-
case "ready":
|
|
225
|
-
return { kind: "pending", reason: "No active, ready project servers" };
|
|
226
|
-
}
|
|
187
|
+
return deriveWorkspaceSemanticHealthState(
|
|
188
|
+
options.lspState,
|
|
189
|
+
options.capabilityState,
|
|
190
|
+
options.runtime?.getProjectServers() ?? [],
|
|
191
|
+
);
|
|
227
192
|
}
|
|
228
193
|
|
|
229
194
|
function collectCapabilityWarnings(
|
|
@@ -36,6 +36,7 @@ interface TargetSectionCollection {
|
|
|
36
36
|
readonly reason: string | null;
|
|
37
37
|
readonly evidenceLists: readonly EvidenceListMetadata[];
|
|
38
38
|
readonly errorRanges?: readonly SourceRange[];
|
|
39
|
+
readonly facts?: import("./facts.ts").OrientationFacts;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
const DEFAULT_TARGET_SECTIONS: OrientationSection[] = ["defs", "docs", "diagnostics"];
|
|
@@ -141,11 +142,29 @@ async function buildRequestedSection(options: {
|
|
|
141
142
|
switch (section) {
|
|
142
143
|
case "defs": {
|
|
143
144
|
const result = await buildEnrichedDefsSection(target, deps, treeContext, limit);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
const contextFacts = targetContextFacts(treeContext, limit);
|
|
146
|
+
const operations = treeContext?.operations;
|
|
147
|
+
const semanticObserved =
|
|
148
|
+
result.hasSemanticEvidence ||
|
|
149
|
+
(operations &&
|
|
150
|
+
[operations.hover, operations.definition].some(
|
|
151
|
+
({ status }) => status === "complete" || status === "partial",
|
|
152
|
+
));
|
|
153
|
+
const structuralObserved =
|
|
154
|
+
operations &&
|
|
155
|
+
[operations.nodeAt, operations.outline, operations.imports, operations.exports].some(
|
|
156
|
+
({ status }) => status === "complete" || status === "partial",
|
|
157
|
+
);
|
|
158
|
+
return targetSectionResult(
|
|
159
|
+
section,
|
|
160
|
+
{ ...result, facts: { ...contextFacts, ...result.facts } },
|
|
161
|
+
[
|
|
162
|
+
...(semanticObserved ? [{ source: "semantic" as const, capability: "LSP" }] : []),
|
|
163
|
+
...(structuralObserved
|
|
164
|
+
? [{ source: "structural" as const, capability: "tree-sitter" }]
|
|
165
|
+
: []),
|
|
166
|
+
],
|
|
167
|
+
);
|
|
149
168
|
}
|
|
150
169
|
case "docs":
|
|
151
170
|
return targetSectionResult(section, await buildDocsSection(target, deps, limit), [
|
|
@@ -158,6 +177,75 @@ async function buildRequestedSection(options: {
|
|
|
158
177
|
}
|
|
159
178
|
}
|
|
160
179
|
|
|
180
|
+
/** Select the independently gathered source observations without rendering them. */
|
|
181
|
+
function targetContextFacts(
|
|
182
|
+
treeContext: Awaited<ReturnType<typeof maybeGatherTreeContext>>,
|
|
183
|
+
limit: number,
|
|
184
|
+
) {
|
|
185
|
+
return treeContext
|
|
186
|
+
? {
|
|
187
|
+
node: treeContext.nodeInfo
|
|
188
|
+
? {
|
|
189
|
+
type: treeContext.nodeInfo.type,
|
|
190
|
+
text: treeContext.nodeInfo.text,
|
|
191
|
+
startLine: treeContext.nodeInfo.startLine,
|
|
192
|
+
startCharacter: treeContext.nodeInfo.startCharacter,
|
|
193
|
+
endLine: treeContext.nodeInfo.endLine,
|
|
194
|
+
endCharacter: treeContext.nodeInfo.endCharacter,
|
|
195
|
+
ancestry: treeContext.nodeInfo.ancestry.map(
|
|
196
|
+
({ type, startLine, startCharacter, endLine, endCharacter }) => ({
|
|
197
|
+
type,
|
|
198
|
+
startLine,
|
|
199
|
+
startCharacter,
|
|
200
|
+
endLine,
|
|
201
|
+
endCharacter,
|
|
202
|
+
}),
|
|
203
|
+
),
|
|
204
|
+
}
|
|
205
|
+
: null,
|
|
206
|
+
nodeObservation: { ...treeContext.operations.nodeAt },
|
|
207
|
+
hoverObservation: { ...treeContext.operations.hover },
|
|
208
|
+
hover: treeContext.hover
|
|
209
|
+
? {
|
|
210
|
+
contents: treeContext.hover.contents,
|
|
211
|
+
...(treeContext.hover.range
|
|
212
|
+
? {
|
|
213
|
+
range: publicRange(treeContext.hover.range),
|
|
214
|
+
}
|
|
215
|
+
: {}),
|
|
216
|
+
}
|
|
217
|
+
: null,
|
|
218
|
+
recovery: treeContext.recovery.map(({ operation, file, reason, errorRanges }) => ({
|
|
219
|
+
operation,
|
|
220
|
+
file,
|
|
221
|
+
reason,
|
|
222
|
+
errorRanges: errorRanges.map(publicRange),
|
|
223
|
+
})),
|
|
224
|
+
contextDefinitions: {
|
|
225
|
+
...treeContext.operations.definition,
|
|
226
|
+
...(treeContext.definition !== null
|
|
227
|
+
? {
|
|
228
|
+
entries: treeContext.definition
|
|
229
|
+
.slice(0, limit)
|
|
230
|
+
.map(({ uri, range }) => ({ uri, range: publicRange(range) })),
|
|
231
|
+
collectedCount: treeContext.definition.length,
|
|
232
|
+
omittedCount: Math.max(0, treeContext.definition.length - limit),
|
|
233
|
+
}
|
|
234
|
+
: {}),
|
|
235
|
+
},
|
|
236
|
+
sourceContext: {
|
|
237
|
+
outline: sourceSelection(treeContext.operations.outline, treeContext.outline, limit),
|
|
238
|
+
imports: sourceSelection(
|
|
239
|
+
treeContext.operations.imports,
|
|
240
|
+
treeContext.imports.map(({ moduleSpecifier }) => ({ moduleSpecifier })),
|
|
241
|
+
limit,
|
|
242
|
+
),
|
|
243
|
+
exports: sourceSelection(treeContext.operations.exports, treeContext.exports, limit),
|
|
244
|
+
},
|
|
245
|
+
}
|
|
246
|
+
: {};
|
|
247
|
+
}
|
|
248
|
+
|
|
161
249
|
/** Build enriched defs section: tree-sitter definitions + LSP definition targets. */
|
|
162
250
|
async function buildEnrichedDefsSection(
|
|
163
251
|
target: Readonly<TargetStoreEntry> | null | undefined,
|
|
@@ -252,6 +340,7 @@ function mergeDefinitionCollection(input: {
|
|
|
252
340
|
reason:
|
|
253
341
|
[input.recoveryReason || null, input.definitions.reason].filter(Boolean).join(" ") || null,
|
|
254
342
|
evidenceLists: input.definitions.evidenceLists,
|
|
343
|
+
...(input.definitions.facts ? { facts: input.definitions.facts } : {}),
|
|
255
344
|
...(input.recoveryRanges.length > 0 ? { errorRanges: [...input.recoveryRanges] } : {}),
|
|
256
345
|
};
|
|
257
346
|
}
|
|
@@ -263,7 +352,7 @@ async function collectDefinitionTargets(
|
|
|
263
352
|
): Promise<
|
|
264
353
|
Pick<
|
|
265
354
|
TargetSectionCollection,
|
|
266
|
-
"items" | "hasSemanticEvidence" | "status" | "reason" | "evidenceLists"
|
|
355
|
+
"items" | "hasSemanticEvidence" | "status" | "reason" | "evidenceLists" | "facts"
|
|
267
356
|
>
|
|
268
357
|
> {
|
|
269
358
|
if (!deps.provider?.definition) {
|
|
@@ -289,11 +378,10 @@ async function collectDefinitionTargets(
|
|
|
289
378
|
evidenceLists: [],
|
|
290
379
|
};
|
|
291
380
|
}
|
|
292
|
-
const locations = result.data.map((definition) => {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
});
|
|
381
|
+
const locations = result.data.map((definition) => ({
|
|
382
|
+
file: path.relative(deps.cwd, uriToFile(definition.uri)),
|
|
383
|
+
range: publicRange(definition.range),
|
|
384
|
+
}));
|
|
297
385
|
const evidence =
|
|
298
386
|
result.kind === "partial"
|
|
299
387
|
? createPartialEvidenceList({
|
|
@@ -308,7 +396,11 @@ async function collectDefinitionTargets(
|
|
|
308
396
|
maxResults: limit,
|
|
309
397
|
});
|
|
310
398
|
return {
|
|
311
|
-
items: evidence.items.map((location) => ({
|
|
399
|
+
items: evidence.items.map((location) => ({
|
|
400
|
+
kind: "paragraph",
|
|
401
|
+
text: `\`${location.file}:${location.range.start.line + 1}:${location.range.start.character + 1}\``,
|
|
402
|
+
})),
|
|
403
|
+
facts: { definitions: evidence.items },
|
|
312
404
|
hasSemanticEvidence: true,
|
|
313
405
|
status: result.kind === "partial" ? "partial" : "complete",
|
|
314
406
|
reason: result.kind === "partial" ? result.reason : null,
|
|
@@ -384,6 +476,15 @@ async function buildDiagnosticsSection(
|
|
|
384
476
|
: evidence.items.map((diagnostic) => formatDiagnosticItem(diagnostic)),
|
|
385
477
|
hasStructuralEvidence: false,
|
|
386
478
|
hasSemanticEvidence: true,
|
|
479
|
+
facts: {
|
|
480
|
+
diagnostics: evidence.items.map((diagnostic) => ({
|
|
481
|
+
range: publicRange(diagnostic.range),
|
|
482
|
+
severity: diagnostic.severity ?? null,
|
|
483
|
+
message: diagnosticMessageString(diagnostic),
|
|
484
|
+
source: diagnostic.source ?? null,
|
|
485
|
+
code: diagnostic.code ?? null,
|
|
486
|
+
})),
|
|
487
|
+
},
|
|
387
488
|
status: result.kind === "partial" ? "partial" : "complete",
|
|
388
489
|
reason: result.kind === "partial" ? result.reason : null,
|
|
389
490
|
evidenceLists: [evidence.metadata],
|
|
@@ -409,6 +510,7 @@ function formatDiagnosticItem(diagnostic: Diagnostic): OrientationItem {
|
|
|
409
510
|
function completedDocsSection(
|
|
410
511
|
items: OrientationItem[],
|
|
411
512
|
evidenceLists: readonly EvidenceListMetadata[],
|
|
513
|
+
documentation: readonly string[] = [],
|
|
412
514
|
): TargetSectionCollection {
|
|
413
515
|
return {
|
|
414
516
|
items,
|
|
@@ -417,6 +519,7 @@ function completedDocsSection(
|
|
|
417
519
|
status: "complete",
|
|
418
520
|
reason: null,
|
|
419
521
|
evidenceLists,
|
|
522
|
+
facts: { documentation },
|
|
420
523
|
};
|
|
421
524
|
}
|
|
422
525
|
|
|
@@ -529,6 +632,7 @@ async function buildDocsSection(
|
|
|
529
632
|
return completedDocsSection(
|
|
530
633
|
[{ kind: "code", language: "ts", lines: evidence.items }],
|
|
531
634
|
[evidence.metadata],
|
|
635
|
+
evidence.items,
|
|
532
636
|
);
|
|
533
637
|
} catch (error) {
|
|
534
638
|
return unavailableTargetSection(
|
|
@@ -555,6 +659,27 @@ async function maybeGatherTreeContext(
|
|
|
555
659
|
);
|
|
556
660
|
}
|
|
557
661
|
|
|
662
|
+
function publicRange(range: SourceRange): SourceRange {
|
|
663
|
+
return {
|
|
664
|
+
start: { line: range.start.line, character: range.start.character },
|
|
665
|
+
end: { line: range.end.line, character: range.end.character },
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/** These best-effort lists preserve availability separately from collected counts. */
|
|
670
|
+
function sourceSelection<T>(
|
|
671
|
+
status: { status: "complete" | "partial" | "unavailable"; reason: string | null },
|
|
672
|
+
entries: readonly T[],
|
|
673
|
+
limit: number,
|
|
674
|
+
) {
|
|
675
|
+
return {
|
|
676
|
+
...status,
|
|
677
|
+
entries: entries.slice(0, limit),
|
|
678
|
+
collectedCount: entries.length,
|
|
679
|
+
omittedCount: Math.max(0, entries.length - limit),
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
|
|
558
683
|
function uniqueRecoveryRanges(
|
|
559
684
|
recovery: readonly { errorRanges: readonly SourceRange[] }[],
|
|
560
685
|
): SourceRange[] {
|
|
@@ -754,6 +879,7 @@ function targetSectionResult(
|
|
|
754
879
|
provenance,
|
|
755
880
|
evidenceLists: collection.evidenceLists,
|
|
756
881
|
...(collection.errorRanges ? { errorRanges: [...collection.errorRanges] } : {}),
|
|
882
|
+
...(collection.facts ? { facts: collection.facts } : {}),
|
|
757
883
|
items: collection.items,
|
|
758
884
|
},
|
|
759
885
|
hasStructuralEvidence: collection.hasStructuralEvidence,
|
|
@@ -110,8 +110,9 @@ async function collectFileFacts(
|
|
|
110
110
|
appendList(builder, {
|
|
111
111
|
key: "filesystem.file",
|
|
112
112
|
title: "Filesystem facts",
|
|
113
|
-
items: [
|
|
114
|
-
render: (item) => item
|
|
113
|
+
items: [byteSize],
|
|
114
|
+
render: (item) => `Size: ${item} bytes`,
|
|
115
|
+
facts: (items) => (items.length ? { fileSizeBytes: items[0] } : {}),
|
|
115
116
|
confidence: "unavailable",
|
|
116
117
|
provenance: [filesystemProvenance(input.cwd, focus)],
|
|
117
118
|
});
|
|
@@ -225,6 +226,7 @@ function appendPackageContext(
|
|
|
225
226
|
title: "Containing package",
|
|
226
227
|
items: [module],
|
|
227
228
|
render: packageLabel,
|
|
229
|
+
facts: (items) => (items[0] ? { package: packageFact(items[0]) } : {}),
|
|
228
230
|
confidence: "unavailable",
|
|
229
231
|
provenance: [{ source: "manifest", detail: module.manifestPath }],
|
|
230
232
|
});
|
|
@@ -243,6 +245,7 @@ function appendPackageFacts(
|
|
|
243
245
|
title,
|
|
244
246
|
items: identity,
|
|
245
247
|
render: (item) => item,
|
|
248
|
+
facts: () => ({ package: packageFact(module) }),
|
|
246
249
|
confidence: "unavailable",
|
|
247
250
|
provenance: [{ source: "manifest", detail: module.manifestPath }],
|
|
248
251
|
});
|
|
@@ -253,6 +256,7 @@ function appendPackageFacts(
|
|
|
253
256
|
title: "Manifest declarations",
|
|
254
257
|
items: module.fields,
|
|
255
258
|
render: (field) => `\`${field.field}\`: ${formatManifestValue(field.value)}`,
|
|
259
|
+
facts: (items) => ({ manifestFields: items.map(({ field, value }) => ({ field, value })) }),
|
|
256
260
|
confidence: "unavailable",
|
|
257
261
|
provenance: [{ source: "manifest", detail: module.manifestPath }],
|
|
258
262
|
});
|
|
@@ -272,6 +276,9 @@ function appendDependencySection(
|
|
|
272
276
|
title: `Manifest ${section.field}`,
|
|
273
277
|
items: section.entries,
|
|
274
278
|
render: (dependency) => `\`${dependency.name}\`: ${formatManifestValue(dependency.specifier)}`,
|
|
279
|
+
facts: (items) => ({
|
|
280
|
+
dependencies: items.map(({ field, name, specifier }) => ({ field, name, value: specifier })),
|
|
281
|
+
}),
|
|
275
282
|
confidence: "unavailable",
|
|
276
283
|
provenance: [{ source: "manifest", detail: `${module.manifestPath}#${section.field}` }],
|
|
277
284
|
});
|
|
@@ -293,6 +300,15 @@ function appendRelationshipFacts(
|
|
|
293
300
|
items: input.edges,
|
|
294
301
|
render: (edge) =>
|
|
295
302
|
`\`${edge.from}\` → \`${edge.to}\` — \`${edge.manifestPath}#${edge.field}\`: ${formatManifestValue(edge.specifier)}`,
|
|
303
|
+
facts: (items) => ({
|
|
304
|
+
relationships: items.map(({ from, to, field, manifestPath, specifier }) => ({
|
|
305
|
+
from,
|
|
306
|
+
to,
|
|
307
|
+
field,
|
|
308
|
+
manifestPath,
|
|
309
|
+
value: specifier,
|
|
310
|
+
})),
|
|
311
|
+
}),
|
|
296
312
|
confidence: "unavailable",
|
|
297
313
|
provenance: [{ source: "manifest", detail: "package dependency fields" }],
|
|
298
314
|
status: input.status,
|
|
@@ -315,6 +331,15 @@ function topologyProvenance(
|
|
|
315
331
|
: { source: "configuration", detail: "supported workspace metadata" };
|
|
316
332
|
}
|
|
317
333
|
|
|
334
|
+
function packageFact(module: ModuleInfo) {
|
|
335
|
+
return {
|
|
336
|
+
name: module.name,
|
|
337
|
+
description: module.description,
|
|
338
|
+
manifestPath: module.manifestPath,
|
|
339
|
+
directory: module.relativePath,
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
|
|
318
343
|
function packageLabel(module: ModuleInfo): string {
|
|
319
344
|
const name = module.name ? `\`${module.name}\`` : "Unnamed package manifest";
|
|
320
345
|
return `${name} — \`${module.relativePath}\` (\`${module.manifestPath}\`)`;
|
|
@@ -39,6 +39,7 @@ export interface ListSectionInput<T> {
|
|
|
39
39
|
readonly unknownRemainder?: boolean;
|
|
40
40
|
readonly partialReason?: EvidencePartialReason;
|
|
41
41
|
readonly errorRanges?: readonly SourceRange[];
|
|
42
|
+
readonly facts?: (items: readonly T[]) => import("./facts.ts").OrientationFacts;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
/** Start a context-Oriented document with one factual focus title. */
|
|
@@ -78,6 +79,7 @@ export function appendList<T>(
|
|
|
78
79
|
provenance: input.provenance,
|
|
79
80
|
evidenceLists: [{ ...metadata, key: input.key }],
|
|
80
81
|
items: list.items.map((item) => ({ kind: "list-item", text: input.render(item) })),
|
|
82
|
+
...(input.facts ? { facts: input.facts(list.items) } : {}),
|
|
81
83
|
...(input.errorRanges ? { errorRanges: [...input.errorRanges] } : {}),
|
|
82
84
|
});
|
|
83
85
|
}
|
|
@@ -175,6 +177,16 @@ export async function appendStructuralFileFacts(
|
|
|
175
177
|
collect: () => provider.outline(file, requestControl),
|
|
176
178
|
requestControl,
|
|
177
179
|
render: (item) => `\`${item.name}\` (${item.kind}, L${item.startLine}–L${item.endLine})`,
|
|
180
|
+
facts: (items) => ({
|
|
181
|
+
outline: items.map(({ name, kind, startLine, startCharacter, endLine, endCharacter }) => ({
|
|
182
|
+
name,
|
|
183
|
+
kind,
|
|
184
|
+
startLine,
|
|
185
|
+
startCharacter,
|
|
186
|
+
endLine,
|
|
187
|
+
endCharacter,
|
|
188
|
+
})),
|
|
189
|
+
}),
|
|
178
190
|
});
|
|
179
191
|
await appendStructuralList(builder, {
|
|
180
192
|
key: "structural.imports",
|
|
@@ -182,6 +194,17 @@ export async function appendStructuralFileFacts(
|
|
|
182
194
|
collect: () => provider.imports(file, requestControl),
|
|
183
195
|
requestControl,
|
|
184
196
|
render: (item) => `\`${item.moduleSpecifier}\``,
|
|
197
|
+
facts: (items) => ({
|
|
198
|
+
imports: items.map(
|
|
199
|
+
({ moduleSpecifier, startLine, startCharacter, endLine, endCharacter }) => ({
|
|
200
|
+
moduleSpecifier,
|
|
201
|
+
startLine,
|
|
202
|
+
startCharacter,
|
|
203
|
+
endLine,
|
|
204
|
+
endCharacter,
|
|
205
|
+
}),
|
|
206
|
+
),
|
|
207
|
+
}),
|
|
185
208
|
});
|
|
186
209
|
await appendStructuralList(builder, {
|
|
187
210
|
key: "structural.exports",
|
|
@@ -189,6 +212,19 @@ export async function appendStructuralFileFacts(
|
|
|
189
212
|
collect: () => provider.exports(file, requestControl),
|
|
190
213
|
requestControl,
|
|
191
214
|
render: (item) => `\`${item.name}\` (${item.kind})`,
|
|
215
|
+
facts: (items) => ({
|
|
216
|
+
exports: items.map(
|
|
217
|
+
({ name, kind, startLine, startCharacter, endLine, endCharacter, moduleSpecifier }) => ({
|
|
218
|
+
name,
|
|
219
|
+
kind,
|
|
220
|
+
startLine,
|
|
221
|
+
startCharacter,
|
|
222
|
+
endLine,
|
|
223
|
+
endCharacter,
|
|
224
|
+
...(moduleSpecifier === undefined ? {} : { moduleSpecifier }),
|
|
225
|
+
}),
|
|
226
|
+
),
|
|
227
|
+
}),
|
|
192
228
|
});
|
|
193
229
|
}
|
|
194
230
|
|
|
@@ -214,6 +250,7 @@ async function appendStructuralList<T>(
|
|
|
214
250
|
title: string;
|
|
215
251
|
collect: () => Promise<CodeResult<T[]>>;
|
|
216
252
|
render: (item: T) => string;
|
|
253
|
+
facts: (items: readonly T[]) => import("./facts.ts").OrientationFacts;
|
|
217
254
|
requestControl?: CodeRequestControl;
|
|
218
255
|
},
|
|
219
256
|
): Promise<void> {
|
|
@@ -252,6 +289,7 @@ async function appendStructuralList<T>(
|
|
|
252
289
|
title: input.title,
|
|
253
290
|
items: result.data,
|
|
254
291
|
render: input.render,
|
|
292
|
+
facts: input.facts,
|
|
255
293
|
confidence: "structural",
|
|
256
294
|
provenance: [{ source: "structural", capability: "tree-sitter" }],
|
|
257
295
|
...(result.kind === "partial"
|
|
@@ -296,6 +334,15 @@ export function appendPrioritySignals(
|
|
|
296
334
|
return `Diagnostics: \`${displayPath(input.cwd, entry.file)}\` (${parts.join(", ")})`;
|
|
297
335
|
},
|
|
298
336
|
confidence: "semantic",
|
|
337
|
+
facts: (items) => ({
|
|
338
|
+
diagnosticSnapshot: items.map(({ file, total, errors, warnings }) => ({
|
|
339
|
+
file: displayPath(input.cwd, file),
|
|
340
|
+
total,
|
|
341
|
+
errors,
|
|
342
|
+
warnings,
|
|
343
|
+
})),
|
|
344
|
+
snapshotCurrent: snapshot.current,
|
|
345
|
+
}),
|
|
299
346
|
provenance: [{ source: "semantic", capability: "LSP diagnostic snapshot" }],
|
|
300
347
|
status: "partial",
|
|
301
348
|
reason: snapshot.current
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { SourceRange } from "@mrclrchtr/supi-code-runtime/api";
|
|
2
|
+
|
|
3
|
+
/** Named, selected observations retained independently of their text rendering. */
|
|
4
|
+
export interface OrientationFacts {
|
|
5
|
+
readonly fileSizeBytes?: number;
|
|
6
|
+
readonly package?: {
|
|
7
|
+
readonly name: string | null;
|
|
8
|
+
readonly description: string | null;
|
|
9
|
+
readonly manifestPath: string;
|
|
10
|
+
readonly directory: string;
|
|
11
|
+
};
|
|
12
|
+
readonly manifestFields?: readonly { readonly field: string; readonly value: unknown }[];
|
|
13
|
+
readonly dependencies?: readonly {
|
|
14
|
+
readonly field: string;
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly value: unknown;
|
|
17
|
+
}[];
|
|
18
|
+
readonly relationships?: readonly {
|
|
19
|
+
readonly from: string;
|
|
20
|
+
readonly to: string;
|
|
21
|
+
readonly field: string;
|
|
22
|
+
readonly manifestPath: string;
|
|
23
|
+
readonly value: unknown;
|
|
24
|
+
}[];
|
|
25
|
+
readonly outline?: readonly {
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly kind: string;
|
|
28
|
+
readonly startLine: number;
|
|
29
|
+
readonly startCharacter: number;
|
|
30
|
+
readonly endLine: number;
|
|
31
|
+
readonly endCharacter: number;
|
|
32
|
+
}[];
|
|
33
|
+
readonly imports?: readonly {
|
|
34
|
+
readonly moduleSpecifier: string;
|
|
35
|
+
readonly startLine: number;
|
|
36
|
+
readonly startCharacter: number;
|
|
37
|
+
readonly endLine: number;
|
|
38
|
+
readonly endCharacter: number;
|
|
39
|
+
}[];
|
|
40
|
+
readonly exports?: readonly {
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly kind: string;
|
|
43
|
+
readonly startLine: number;
|
|
44
|
+
readonly startCharacter: number;
|
|
45
|
+
readonly endLine: number;
|
|
46
|
+
readonly endCharacter: number;
|
|
47
|
+
readonly moduleSpecifier?: string;
|
|
48
|
+
}[];
|
|
49
|
+
readonly diagnosticSnapshot?: readonly {
|
|
50
|
+
readonly file: string;
|
|
51
|
+
readonly total: number;
|
|
52
|
+
readonly errors: number;
|
|
53
|
+
readonly warnings: number;
|
|
54
|
+
}[];
|
|
55
|
+
readonly snapshotCurrent?: boolean;
|
|
56
|
+
readonly node?: {
|
|
57
|
+
readonly type: string;
|
|
58
|
+
readonly text: string;
|
|
59
|
+
readonly startLine: number;
|
|
60
|
+
readonly startCharacter: number;
|
|
61
|
+
readonly endLine: number;
|
|
62
|
+
readonly endCharacter: number;
|
|
63
|
+
readonly ancestry: readonly {
|
|
64
|
+
readonly type: string;
|
|
65
|
+
readonly startLine: number;
|
|
66
|
+
readonly startCharacter: number;
|
|
67
|
+
readonly endLine: number;
|
|
68
|
+
readonly endCharacter: number;
|
|
69
|
+
}[];
|
|
70
|
+
} | null;
|
|
71
|
+
/** Distinguish position-strict withholding, failure, and successful observations. */
|
|
72
|
+
readonly nodeObservation?: import("./gather.ts").ContextObservationStatus;
|
|
73
|
+
readonly hover?: { readonly contents: string; readonly range?: SourceRange } | null;
|
|
74
|
+
readonly hoverObservation?: import("./gather.ts").ContextObservationStatus;
|
|
75
|
+
readonly definitions?: readonly { readonly file: string; readonly range: SourceRange }[];
|
|
76
|
+
/** Independent context query; unavailable observations have no manufactured entries or counts. */
|
|
77
|
+
readonly contextDefinitions?: import("./gather.ts").ContextObservationStatus & {
|
|
78
|
+
readonly entries?: readonly { readonly uri: string; readonly range: SourceRange }[];
|
|
79
|
+
readonly collectedCount?: number;
|
|
80
|
+
readonly omittedCount?: number;
|
|
81
|
+
};
|
|
82
|
+
readonly recovery?: readonly {
|
|
83
|
+
readonly operation: string;
|
|
84
|
+
readonly file: string;
|
|
85
|
+
readonly reason: string;
|
|
86
|
+
readonly errorRanges: readonly SourceRange[];
|
|
87
|
+
}[];
|
|
88
|
+
readonly sourceContext?: {
|
|
89
|
+
readonly outline: {
|
|
90
|
+
readonly status: "complete" | "partial" | "unavailable";
|
|
91
|
+
readonly reason: string | null;
|
|
92
|
+
readonly entries: readonly {
|
|
93
|
+
readonly name: string;
|
|
94
|
+
readonly kind: string;
|
|
95
|
+
readonly startLine: number;
|
|
96
|
+
readonly endLine: number;
|
|
97
|
+
}[];
|
|
98
|
+
readonly collectedCount: number;
|
|
99
|
+
readonly omittedCount: number;
|
|
100
|
+
};
|
|
101
|
+
readonly imports: {
|
|
102
|
+
readonly status: "complete" | "partial" | "unavailable";
|
|
103
|
+
readonly reason: string | null;
|
|
104
|
+
readonly entries: readonly { readonly moduleSpecifier: string }[];
|
|
105
|
+
readonly collectedCount: number;
|
|
106
|
+
readonly omittedCount: number;
|
|
107
|
+
};
|
|
108
|
+
readonly exports: {
|
|
109
|
+
readonly status: "complete" | "partial" | "unavailable";
|
|
110
|
+
readonly reason: string | null;
|
|
111
|
+
readonly entries: readonly { readonly name: string; readonly kind: string }[];
|
|
112
|
+
readonly collectedCount: number;
|
|
113
|
+
readonly omittedCount: number;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
readonly documentation?: readonly string[];
|
|
117
|
+
readonly diagnostics?: readonly {
|
|
118
|
+
readonly range: SourceRange;
|
|
119
|
+
readonly severity: number | null;
|
|
120
|
+
readonly message: string;
|
|
121
|
+
readonly source: string | null;
|
|
122
|
+
readonly code: string | number | null;
|
|
123
|
+
}[];
|
|
124
|
+
}
|