@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
package/src/ui/status-command.ts
CHANGED
|
@@ -1,31 +1,12 @@
|
|
|
1
|
-
// Code Intelligence status command — toggleable center dialog with persistent
|
|
2
|
-
// status bar, custom footer, and below-editor widget for LSP + structural awareness.
|
|
3
|
-
|
|
4
1
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
5
|
-
import { truncateToWidth } from "@earendil-works/pi-tui";
|
|
6
2
|
import { getDefaultWorkspaceRuntime } from "@mrclrchtr/supi-code-runtime/api";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from "
|
|
12
|
-
import {
|
|
13
|
-
type CapabilityWarningMissingServerSource,
|
|
14
|
-
evaluateCapabilityWarnings,
|
|
15
|
-
gatherCapabilityWarningInput,
|
|
16
|
-
} from "../analysis/capability/capability-warnings.ts";
|
|
17
|
-
import { countProjectServerRouteStatuses } from "../analysis/health/server-status.ts";
|
|
18
|
-
import { type CiStatusData, createCiStatusDialog } from "./status-overlay.ts";
|
|
19
|
-
|
|
20
|
-
const STATUS_KEY = "code-intelligence";
|
|
21
|
-
const WIDGET_KEY = "code-intelligence";
|
|
22
|
-
|
|
23
|
-
interface InspectorState {
|
|
24
|
-
handle: unknown;
|
|
25
|
-
close: (() => void) | null;
|
|
26
|
-
}
|
|
3
|
+
import { type AutomaticLspPathPolicy, getWorkspaceLspRuntime } from "@mrclrchtr/supi-lsp/api";
|
|
4
|
+
import type { CapabilityWarningMissingServerSource } from "../analysis/capability/capability-warnings.ts";
|
|
5
|
+
import { checkWorkspaceDiagnostics } from "../analysis/health/check.ts";
|
|
6
|
+
import { observeWorkspaceStatus } from "../analysis/health/status.ts";
|
|
7
|
+
import { type CiStatusDialog, createCiStatusDialog } from "./status-overlay.ts";
|
|
27
8
|
|
|
28
|
-
/** Owned LSP facts used by the status warning collector. */
|
|
9
|
+
/** Owned LSP facts used by the passive status warning collector. */
|
|
29
10
|
export interface CiStatusWarningSource {
|
|
30
11
|
get(cwd: string): {
|
|
31
12
|
lspController: CapabilityWarningMissingServerSource | null;
|
|
@@ -33,317 +14,125 @@ export interface CiStatusWarningSource {
|
|
|
33
14
|
};
|
|
34
15
|
}
|
|
35
16
|
|
|
36
|
-
|
|
17
|
+
async function collectStatusData(
|
|
18
|
+
pi: ExtensionAPI,
|
|
19
|
+
ctx: ExtensionContext,
|
|
20
|
+
homeDir?: string,
|
|
21
|
+
warningSource?: CiStatusWarningSource,
|
|
22
|
+
) {
|
|
23
|
+
const workspace = getDefaultWorkspaceRuntime().getWorkspace(ctx.cwd);
|
|
24
|
+
const facts = warningSource?.get(ctx.cwd);
|
|
25
|
+
return {
|
|
26
|
+
...(await observeWorkspaceStatus({
|
|
27
|
+
cwd: ctx.cwd,
|
|
28
|
+
lspState: getWorkspaceLspRuntime(ctx.cwd),
|
|
29
|
+
semanticState: workspace.semantic.state,
|
|
30
|
+
structuralState: workspace.structural.state,
|
|
31
|
+
projectTrusted: ctx.isProjectTrusted(),
|
|
32
|
+
homeDir,
|
|
33
|
+
lspController: facts?.lspController,
|
|
34
|
+
automaticPathPolicy: facts?.automaticPathPolicy,
|
|
35
|
+
})),
|
|
36
|
+
activeTools: pi.getActiveTools().filter((tool) => tool.startsWith("code_")),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function readDiagnosticDetails(cwd: string) {
|
|
41
|
+
const lsp = getWorkspaceLspRuntime(cwd);
|
|
42
|
+
if (lsp.kind !== "ready") throw new Error("LSP diagnostics are unavailable");
|
|
43
|
+
return lsp.runtime.getOutstandingDiagnostics(2);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface StatusInteraction {
|
|
47
|
+
cancelled: boolean;
|
|
48
|
+
close?: () => void;
|
|
49
|
+
dialog?: CiStatusDialog;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Register the terminal inspector. Persistent footer contributions have a separate owner. */
|
|
37
53
|
export function registerCiStatusCommand(
|
|
38
54
|
pi: ExtensionAPI,
|
|
39
55
|
homeDir?: string,
|
|
40
56
|
warningSource?: CiStatusWarningSource,
|
|
41
57
|
): void {
|
|
42
|
-
|
|
58
|
+
let interaction: StatusInteraction | undefined;
|
|
59
|
+
const close = () => {
|
|
60
|
+
if (!interaction) return;
|
|
61
|
+
interaction.cancelled = true;
|
|
62
|
+
interaction.dialog?.dispose();
|
|
63
|
+
interaction.close?.();
|
|
64
|
+
};
|
|
65
|
+
pi.on("session_shutdown", close);
|
|
66
|
+
pi.on("session_start", close);
|
|
67
|
+
|
|
43
68
|
pi.registerCommand("supi-ci-status", {
|
|
44
|
-
description: "Toggle code intelligence
|
|
45
|
-
handler: async (_args
|
|
46
|
-
if (
|
|
47
|
-
|
|
69
|
+
description: "Toggle the code intelligence inspector (passive health snapshot)",
|
|
70
|
+
handler: async (_args, ctx) => {
|
|
71
|
+
if (ctx.mode !== "tui") {
|
|
72
|
+
ctx.ui.notify(
|
|
73
|
+
"The status inspector requires a terminal UI. Use code_health instead.",
|
|
74
|
+
"warning",
|
|
75
|
+
);
|
|
48
76
|
return;
|
|
49
77
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
78
|
+
if (interaction) {
|
|
79
|
+
close();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const current: StatusInteraction = { cancelled: false };
|
|
83
|
+
interaction = current;
|
|
84
|
+
const observe = () => collectStatusData(pi, ctx, homeDir, warningSource);
|
|
85
|
+
let checkOffset = 0;
|
|
86
|
+
const check = async (signal: AbortSignal) => {
|
|
87
|
+
const lsp = getWorkspaceLspRuntime(ctx.cwd);
|
|
88
|
+
if (lsp.kind !== "ready")
|
|
89
|
+
throw new Error(`LSP runtime is ${lsp.kind}; diagnostics cannot be checked.`);
|
|
90
|
+
pi.events.emit("supi:working:start", { source: "supi-code-intelligence" });
|
|
91
|
+
try {
|
|
92
|
+
const diagnosticCheck = await checkWorkspaceDiagnostics({
|
|
93
|
+
runtime: lsp.runtime,
|
|
94
|
+
cwd: ctx.cwd,
|
|
95
|
+
offset: checkOffset,
|
|
96
|
+
control: { signal, deadline: Date.now() + 30_000 },
|
|
97
|
+
});
|
|
98
|
+
const snapshot = await observe();
|
|
99
|
+
checkOffset = diagnosticCheck.nextOffset;
|
|
100
|
+
return { ...snapshot, diagnosticCheck };
|
|
101
|
+
} finally {
|
|
102
|
+
pi.events.emit("supi:working:end", { source: "supi-code-intelligence" });
|
|
103
|
+
}
|
|
59
104
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
invalidate(): void {},
|
|
68
|
-
}));
|
|
69
|
-
|
|
70
|
-
void ctx.ui
|
|
71
|
-
.custom<void>(
|
|
72
|
-
(tui, theme, _kb, done) => {
|
|
73
|
-
inspector.close = () => done(undefined);
|
|
74
|
-
return createCiStatusDialog(dataRef.current, {
|
|
75
|
-
theme: theme as unknown as import("./status-overlay.ts").CiDialogTheme,
|
|
76
|
-
done: () => done(undefined),
|
|
105
|
+
try {
|
|
106
|
+
const data = await observe();
|
|
107
|
+
if (current.cancelled) return;
|
|
108
|
+
await ctx.ui.custom<void>(
|
|
109
|
+
(tui, theme, keybindings, done) => {
|
|
110
|
+
current.close = () => done(undefined);
|
|
111
|
+
const dialog = createCiStatusDialog(data, {
|
|
77
112
|
tui,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const fresh = await gatherCiStatusData({
|
|
85
|
-
cwd: ctx.cwd,
|
|
86
|
-
pi,
|
|
87
|
-
projectTrusted: ctx.isProjectTrusted(),
|
|
88
|
-
homeDir,
|
|
89
|
-
warningSource,
|
|
90
|
-
});
|
|
91
|
-
dataRef.current = fresh;
|
|
92
|
-
updateStatusAndWidget(ctx, fresh);
|
|
93
|
-
return fresh;
|
|
94
|
-
},
|
|
113
|
+
theme,
|
|
114
|
+
keybindings,
|
|
115
|
+
done: current.close,
|
|
116
|
+
onRefresh: observe,
|
|
117
|
+
onCheck: check,
|
|
118
|
+
fetchDetailedDiagnostics: () => readDiagnosticDetails(ctx.cwd),
|
|
95
119
|
});
|
|
120
|
+
current.dialog = dialog;
|
|
121
|
+
if (current.cancelled) current.close();
|
|
122
|
+
return dialog;
|
|
96
123
|
},
|
|
97
124
|
{
|
|
98
125
|
overlay: true,
|
|
99
|
-
overlayOptions: {
|
|
100
|
-
anchor: "center",
|
|
101
|
-
width: "66%",
|
|
102
|
-
minWidth: 60,
|
|
103
|
-
maxHeight: "85%",
|
|
104
|
-
visible: (termWidth: number) => termWidth >= 60,
|
|
105
|
-
},
|
|
106
|
-
onHandle: (handle) => {
|
|
107
|
-
inspector.handle = handle;
|
|
108
|
-
},
|
|
126
|
+
overlayOptions: { anchor: "center", width: "85%", maxHeight: "85%" },
|
|
109
127
|
},
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
128
|
+
);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
if (!current.cancelled)
|
|
131
|
+
ctx.ui.notify(`Unable to open code intelligence status: ${String(error)}`, "error");
|
|
132
|
+
} finally {
|
|
133
|
+
current.dialog?.dispose();
|
|
134
|
+
if (interaction === current) interaction = undefined;
|
|
135
|
+
}
|
|
117
136
|
},
|
|
118
137
|
});
|
|
119
138
|
}
|
|
120
|
-
|
|
121
|
-
/** Inputs for one status dialog snapshot. */
|
|
122
|
-
interface GatherCiStatusOptions {
|
|
123
|
-
cwd: string;
|
|
124
|
-
pi: ExtensionAPI;
|
|
125
|
-
projectTrusted: boolean;
|
|
126
|
-
homeDir?: string;
|
|
127
|
-
warningSource?: CiStatusWarningSource;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/** Gather a snapshot of LSP and structural state for the dialog. */
|
|
131
|
-
async function gatherCiStatusData(options: GatherCiStatusOptions): Promise<CiStatusData> {
|
|
132
|
-
const { cwd, pi, projectTrusted, homeDir, warningSource } = options;
|
|
133
|
-
const workspace = getDefaultWorkspaceRuntime().getWorkspace(cwd);
|
|
134
|
-
const lspState = getWorkspaceLspRuntime(cwd);
|
|
135
|
-
const serverInventoryAvailable = lspState.kind === "ready" || lspState.kind === "disabled";
|
|
136
|
-
const servers = lspState.kind === "ready" ? lspState.runtime.getProjectServers() : [];
|
|
137
|
-
const semanticAvailable = servers.some(
|
|
138
|
-
(server) => server.status === "running" && server.ready === true,
|
|
139
|
-
);
|
|
140
|
-
const diagnosticSnapshot =
|
|
141
|
-
lspState.kind === "ready" && semanticAvailable
|
|
142
|
-
? lspState.runtime.getOutstandingDiagnosticSummary(1)
|
|
143
|
-
: { entries: [], current: false };
|
|
144
|
-
const diagnostics = diagnosticSnapshot.entries;
|
|
145
|
-
const semanticState = deriveSemanticCapabilityState(workspace, lspState, semanticAvailable);
|
|
146
|
-
|
|
147
|
-
// Sort: errors desc, warnings desc, info desc, hints desc
|
|
148
|
-
diagnostics.sort((a, b) => {
|
|
149
|
-
if (b.errors !== a.errors) return b.errors - a.errors;
|
|
150
|
-
if (b.warnings !== a.warnings) return b.warnings - a.warnings;
|
|
151
|
-
if (b.information !== a.information) return b.information - a.information;
|
|
152
|
-
return b.hints - a.hints;
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
const structState = workspace.structural.state;
|
|
156
|
-
const structKind = structState.kind;
|
|
157
|
-
const structReason = structState.kind === "unavailable" ? structState.reason : undefined;
|
|
158
|
-
|
|
159
|
-
const activeTools = pi.getActiveTools().filter((t) => t.startsWith("code_"));
|
|
160
|
-
|
|
161
|
-
// Evaluate current Capability Warnings from available data.
|
|
162
|
-
const warningFacts = warningSource?.get(cwd);
|
|
163
|
-
const capabilityWarnings = evaluateCapabilityWarnings(
|
|
164
|
-
gatherCapabilityWarningInput(cwd, warningFacts?.lspController ?? null, {
|
|
165
|
-
projectTrusted,
|
|
166
|
-
homeDir,
|
|
167
|
-
automaticPathPolicy: warningFacts?.automaticPathPolicy ?? undefined,
|
|
168
|
-
}),
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
return {
|
|
172
|
-
workspaceRoot: cwd,
|
|
173
|
-
servers,
|
|
174
|
-
diagnostics,
|
|
175
|
-
serverInventoryAvailable,
|
|
176
|
-
semanticAvailable,
|
|
177
|
-
diagnosticSnapshotCurrent: diagnosticSnapshot.current,
|
|
178
|
-
capabilities: {
|
|
179
|
-
semantic: semanticState,
|
|
180
|
-
structural: {
|
|
181
|
-
kind: structKind,
|
|
182
|
-
reason: structReason,
|
|
183
|
-
providerAvailable: structState.kind === "ready",
|
|
184
|
-
},
|
|
185
|
-
refactorAvailable: workspace.semantic.refactorAvailable,
|
|
186
|
-
},
|
|
187
|
-
activeTools,
|
|
188
|
-
capabilityWarnings: capabilityWarnings.hasWarnings ? capabilityWarnings : undefined,
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function deriveSemanticCapabilityState(
|
|
193
|
-
workspace: {
|
|
194
|
-
semantic: {
|
|
195
|
-
state: { kind: string };
|
|
196
|
-
provider: unknown | null;
|
|
197
|
-
};
|
|
198
|
-
},
|
|
199
|
-
lspState: WorkspaceLspRuntimeState,
|
|
200
|
-
semanticAvailable: boolean,
|
|
201
|
-
): CiStatusData["capabilities"]["semantic"] {
|
|
202
|
-
if (lspState.kind === "ready") {
|
|
203
|
-
return semanticAvailable
|
|
204
|
-
? {
|
|
205
|
-
kind: "ready",
|
|
206
|
-
providerAvailable: workspace.semantic.provider !== null,
|
|
207
|
-
}
|
|
208
|
-
: {
|
|
209
|
-
kind: "pending",
|
|
210
|
-
reason: "No active, ready project servers",
|
|
211
|
-
providerAvailable: workspace.semantic.provider !== null,
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
if (workspace.semantic.state.kind === "pending" || lspState.kind === "pending") {
|
|
215
|
-
return {
|
|
216
|
-
kind: "pending",
|
|
217
|
-
providerAvailable: workspace.semantic.provider !== null,
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
if (lspState.kind === "inactive") {
|
|
221
|
-
return { kind: "inactive", providerAvailable: workspace.semantic.provider !== null };
|
|
222
|
-
}
|
|
223
|
-
if (lspState.kind === "disabled") {
|
|
224
|
-
return {
|
|
225
|
-
kind: "disabled",
|
|
226
|
-
reason: "LSP is disabled in settings",
|
|
227
|
-
providerAvailable: workspace.semantic.provider !== null,
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
return {
|
|
231
|
-
kind: workspace.semantic.state.kind,
|
|
232
|
-
reason: "reason" in lspState ? lspState.reason : "No LSP service",
|
|
233
|
-
providerAvailable: workspace.semantic.provider !== null,
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/** Render the custom footer line. */
|
|
238
|
-
function renderFooterLine(ctx: ExtensionContext, data: CiStatusData): string {
|
|
239
|
-
const t = ctx.ui.theme;
|
|
240
|
-
const parts: string[] = [];
|
|
241
|
-
const running = data.servers.filter((s) => s.status === "running").length;
|
|
242
|
-
if (running > 0) {
|
|
243
|
-
parts.push(
|
|
244
|
-
t.fg("accent", "λ ci") + t.fg("dim", ` ${running} server${running === 1 ? "" : "s"}`),
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
const totalErrors = data.diagnostics.reduce((sum, d) => sum + d.errors, 0);
|
|
248
|
-
if (totalErrors > 0) {
|
|
249
|
-
parts.push(t.fg("error", `${totalErrors} error${totalErrors === 1 ? "" : "s"}`));
|
|
250
|
-
}
|
|
251
|
-
const totalWarnings = data.diagnostics.reduce((sum, d) => sum + d.warnings, 0);
|
|
252
|
-
if (totalWarnings > 0) {
|
|
253
|
-
parts.push(t.fg("warning", `${totalWarnings} warning${totalWarnings === 1 ? "" : "s"}`));
|
|
254
|
-
}
|
|
255
|
-
addProjectServerRouteCounts(parts, data, t);
|
|
256
|
-
const structKind = data.capabilities.structural.kind;
|
|
257
|
-
if (structKind === "ready") parts.push(t.fg("success", "✓ ts"));
|
|
258
|
-
if (parts.length === 0) return t.fg("dim", "CI — no data available");
|
|
259
|
-
return parts.join(t.fg("dim", " "));
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function addProjectServerRouteCounts(
|
|
263
|
-
parts: string[],
|
|
264
|
-
data: CiStatusData,
|
|
265
|
-
theme: ExtensionContext["ui"]["theme"],
|
|
266
|
-
): void {
|
|
267
|
-
const counts = countProjectServerRouteStatuses(data.servers);
|
|
268
|
-
if (counts.recovering > 0) {
|
|
269
|
-
parts.push(
|
|
270
|
-
theme.fg(
|
|
271
|
-
"warning",
|
|
272
|
-
`${counts.recovering} route${counts.recovering === 1 ? "" : "s"} recovering`,
|
|
273
|
-
),
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
if (counts.error > 0) {
|
|
277
|
-
parts.push(theme.fg("error", `${counts.error} route error${counts.error === 1 ? "" : "s"}`));
|
|
278
|
-
}
|
|
279
|
-
if (counts.unavailable > 0) {
|
|
280
|
-
parts.push(
|
|
281
|
-
theme.fg(
|
|
282
|
-
"warning",
|
|
283
|
-
`${counts.unavailable} route${counts.unavailable === 1 ? "" : "s"} unavailable`,
|
|
284
|
-
),
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
function truncateFooterLine(line: string, width: number): string {
|
|
290
|
-
return truncateToWidth(line, width, "…");
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/** Update the persistent status bar and below-editor widget. */
|
|
294
|
-
function updateStatusAndWidget(ctx: ExtensionContext, data: CiStatusData): void {
|
|
295
|
-
const t = ctx.ui.theme;
|
|
296
|
-
|
|
297
|
-
// Status bar: concise one-liner
|
|
298
|
-
const parts: string[] = [t.fg("accent", "λ ci")];
|
|
299
|
-
const runningServers = data.servers.filter((s) => s.status === "running").length;
|
|
300
|
-
if (runningServers > 0) {
|
|
301
|
-
parts.push(t.fg("dim", `${runningServers} server${runningServers === 1 ? "" : "s"}`));
|
|
302
|
-
}
|
|
303
|
-
const totalErrors = data.diagnostics.reduce((sum, d) => sum + d.errors, 0);
|
|
304
|
-
if (totalErrors > 0) {
|
|
305
|
-
parts.push(t.fg("error", `${totalErrors} error${totalErrors === 1 ? "" : "s"}`));
|
|
306
|
-
}
|
|
307
|
-
const totalWarnings = data.diagnostics.reduce((sum, d) => sum + d.warnings, 0);
|
|
308
|
-
if (totalWarnings > 0) {
|
|
309
|
-
parts.push(t.fg("warning", `${totalWarnings} warning${totalWarnings === 1 ? "" : "s"}`));
|
|
310
|
-
}
|
|
311
|
-
addProjectServerRouteCounts(parts, data, t);
|
|
312
|
-
const structKind = data.capabilities.structural.kind;
|
|
313
|
-
if (structKind === "ready") parts.push(t.fg("success", "✓ ts"));
|
|
314
|
-
|
|
315
|
-
const statusText = parts.length > 1 ? parts.join(t.fg("dim", " · ")) : undefined;
|
|
316
|
-
ctx.ui.setStatus(STATUS_KEY, statusText);
|
|
317
|
-
|
|
318
|
-
// Widget (below editor) — top problem files
|
|
319
|
-
if (data.diagnostics.length > 0) {
|
|
320
|
-
const top = data.diagnostics.slice(0, 2);
|
|
321
|
-
const fileLines = top.map((d) => {
|
|
322
|
-
const counts: string[] = [];
|
|
323
|
-
if (d.errors > 0) {
|
|
324
|
-
counts.push(t.fg("error", `${d.errors} error${d.errors === 1 ? "" : "s"}`));
|
|
325
|
-
}
|
|
326
|
-
if (d.warnings > 0) {
|
|
327
|
-
counts.push(t.fg("warning", `${d.warnings} warning${d.warnings === 1 ? "" : "s"}`));
|
|
328
|
-
}
|
|
329
|
-
return ` ${d.file} (${counts.join(", ")})`;
|
|
330
|
-
});
|
|
331
|
-
const more = data.diagnostics.length - top.length;
|
|
332
|
-
const moreSuffix = more > 0 ? t.fg("dim", ` +${more} more`) : "";
|
|
333
|
-
ctx.ui.setWidget(
|
|
334
|
-
WIDGET_KEY,
|
|
335
|
-
[
|
|
336
|
-
t.fg("accent", `λ CI — ${data.diagnostics.length} files with issues`) + moreSuffix,
|
|
337
|
-
...fileLines,
|
|
338
|
-
],
|
|
339
|
-
{ placement: "belowEditor" },
|
|
340
|
-
);
|
|
341
|
-
} else {
|
|
342
|
-
ctx.ui.setWidget(WIDGET_KEY, undefined);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
function clearStatusAndWidget(ctx: ExtensionContext): void {
|
|
347
|
-
ctx.ui.setStatus(STATUS_KEY, undefined);
|
|
348
|
-
ctx.ui.setWidget(WIDGET_KEY, undefined);
|
|
349
|
-
}
|