@mrclrchtr/supi-code-intelligence 1.3.1 → 1.5.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 +70 -32
- package/node_modules/@mrclrchtr/supi-core/README.md +52 -41
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/api.ts +15 -13
- package/node_modules/@mrclrchtr/supi-core/src/{config-settings.ts → config/config-settings.ts} +2 -2
- package/node_modules/@mrclrchtr/{supi-lsp/node_modules/@mrclrchtr/supi-core/src → supi-core/src/context}/context-provider-registry.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/extension.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/index.ts +15 -13
- package/node_modules/@mrclrchtr/supi-core/src/path-utils.ts +40 -0
- package/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +42 -10
- package/node_modules/@mrclrchtr/{supi-lsp/node_modules/@mrclrchtr/supi-core/src → supi-core/src/settings}/settings-registry.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/README.md +58 -39
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/README.md +52 -41
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/api.ts +15 -13
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/{config-settings.ts → config/config-settings.ts} +2 -2
- package/node_modules/@mrclrchtr/{supi-core/src → supi-lsp/node_modules/@mrclrchtr/supi-core/src/context}/context-provider-registry.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/extension.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/index.ts +15 -13
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/path-utils.ts +40 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +42 -10
- package/node_modules/@mrclrchtr/{supi-core/src → supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings}/settings-registry.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +16 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-refresh.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +27 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +61 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +244 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/{types.ts → config/types.ts} +4 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/coordinates.ts +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/diagnostic-augmentation.ts +5 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/diagnostic-context.ts +115 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/diagnostic-display.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/diagnostic-summary.ts +3 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/diagnostics.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/stale-diagnostics.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/suppression-diagnostics.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/{workspace-sentinels.ts → diagnostics/workspace-sentinels.ts} +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/format.ts +2 -23
- package/node_modules/@mrclrchtr/supi-lsp/src/index.ts +18 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/lsp.ts +72 -120
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-diagnostics.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-helpers.ts +4 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +10 -21
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-recovery.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +158 -6
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +202 -43
- package/node_modules/@mrclrchtr/supi-lsp/src/{lsp-state.ts → session/lsp-state.ts} +22 -11
- package/node_modules/@mrclrchtr/supi-lsp/src/{scanner.ts → session/scanner.ts} +3 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/{service-registry.ts → session/service-registry.ts} +109 -33
- package/node_modules/@mrclrchtr/supi-lsp/src/{settings-registration.ts → session/settings-registration.ts} +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/session/tree-persist.ts +75 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/summary.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/tool/guidance.ts +78 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/tool/names.ts +19 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/{overrides.ts → tool/overrides.ts} +55 -24
- package/node_modules/@mrclrchtr/supi-lsp/src/tool/register-tools.ts +71 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/tool/service-actions.ts +258 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/tool/tool-specs.ts +248 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/{ui.ts → ui/ui.ts} +4 -4
- package/node_modules/@mrclrchtr/supi-lsp/src/utils.ts +5 -23
- package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +58 -39
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/README.md +107 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +44 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +85 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +76 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config.ts +186 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/context/context-messages.ts +119 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/context/context-provider-registry.ts +36 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +31 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +255 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/extension.ts +1 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/index.ts +85 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/path-utils.ts +40 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/project-roots.ts +170 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +86 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session-utils.ts +29 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-command.ts +15 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +41 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +226 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/terminal.ts +60 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +8 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/api.ts +6 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/index.ts +6 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/{runtime.ts → session/runtime.ts} +6 -5
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/service-registry.ts +30 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/{session.ts → session/session.ts} +20 -12
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/action-specs.ts +92 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/{callees.ts → tool/callees.ts} +3 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/{exports.ts → tool/exports.ts} +4 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/{formatting.ts → tool/formatting.ts} +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/guidance.ts +31 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/{imports.ts → tool/imports.ts} +4 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/{node-at.ts → tool/node-at.ts} +3 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/{outline.ts → tool/outline.ts} +3 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tree-sitter.ts +118 -91
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +13 -2
- package/package.json +4 -4
- package/src/actions/affected-action.ts +4 -4
- package/src/actions/brief-action.ts +12 -13
- package/src/actions/callees-action.ts +14 -10
- package/src/actions/callers-action.ts +4 -4
- package/src/actions/implementations-action.ts +4 -4
- package/src/code-intelligence.ts +4 -11
- package/src/pattern-structured.ts +20 -22
- package/src/providers/semantic-provider.ts +34 -0
- package/src/providers/structural-provider.ts +26 -0
- package/src/search-helpers.ts +4 -15
- package/src/target-resolution.ts +26 -35
- package/src/tool/action-specs.ts +66 -0
- package/src/tool/guidance.ts +18 -0
- package/src/tool-actions.ts +23 -40
- package/node_modules/@mrclrchtr/supi-lsp/src/guidance.ts +0 -163
- package/node_modules/@mrclrchtr/supi-lsp/src/search-fallback.ts +0 -98
- package/node_modules/@mrclrchtr/supi-lsp/src/tool-actions.ts +0 -430
- package/node_modules/@mrclrchtr/supi-lsp/src/tree-persist.ts +0 -48
- package/node_modules/@mrclrchtr/supi-lsp/src/tsconfig-scope.ts +0 -156
- package/src/guidance.ts +0 -42
- /package/node_modules/@mrclrchtr/supi-core/src/{config.ts → config/config.ts} +0 -0
- /package/node_modules/@mrclrchtr/supi-core/src/{context-messages.ts → context/context-messages.ts} +0 -0
- /package/node_modules/@mrclrchtr/supi-core/src/{context-tag.ts → context/context-tag.ts} +0 -0
- /package/node_modules/@mrclrchtr/supi-core/src/{settings-command.ts → settings/settings-command.ts} +0 -0
- /package/node_modules/@mrclrchtr/supi-core/src/{settings-ui.ts → settings/settings-ui.ts} +0 -0
- /package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/{config.ts → config/config.ts} +0 -0
- /package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/{context-messages.ts → context/context-messages.ts} +0 -0
- /package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/{context-tag.ts → context/context-tag.ts} +0 -0
- /package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/{settings-command.ts → settings/settings-command.ts} +0 -0
- /package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/{settings-ui.ts → settings/settings-ui.ts} +0 -0
- /package/node_modules/@mrclrchtr/supi-lsp/src/{capabilities.ts → config/capabilities.ts} +0 -0
- /package/node_modules/@mrclrchtr/supi-lsp/src/{config.ts → config/config.ts} +0 -0
- /package/node_modules/@mrclrchtr/supi-lsp/src/{defaults.json → config/defaults.json} +0 -0
- /package/node_modules/@mrclrchtr/supi-lsp/src/{renderer.ts → ui/renderer.ts} +0 -0
- /package/node_modules/@mrclrchtr/supi-tree-sitter/src/{structure.ts → tool/structure.ts} +0 -0
package/src/tool-actions.ts
CHANGED
|
@@ -9,16 +9,14 @@ import { executeImplementationsAction } from "./actions/implementations-action.t
|
|
|
9
9
|
import { executeIndexAction } from "./actions/index-action.ts";
|
|
10
10
|
import { executePatternAction } from "./actions/pattern-action.ts";
|
|
11
11
|
import { normalizePath } from "./search-helpers.ts";
|
|
12
|
+
import {
|
|
13
|
+
type CodeIntelAction,
|
|
14
|
+
formatCodeIntelActionList,
|
|
15
|
+
isCodeIntelAction,
|
|
16
|
+
} from "./tool/action-specs.ts";
|
|
12
17
|
import type { CodeIntelResult } from "./types.ts";
|
|
13
18
|
|
|
14
|
-
export type CodeIntelAction
|
|
15
|
-
| "brief"
|
|
16
|
-
| "callers"
|
|
17
|
-
| "callees"
|
|
18
|
-
| "implementations"
|
|
19
|
-
| "affected"
|
|
20
|
-
| "pattern"
|
|
21
|
-
| "index";
|
|
19
|
+
export type { CodeIntelAction } from "./tool/action-specs.ts";
|
|
22
20
|
|
|
23
21
|
/** Flat parameter bag shared by `code_intel` action handlers. */
|
|
24
22
|
export interface ActionParams {
|
|
@@ -40,15 +38,20 @@ export interface ActionParams {
|
|
|
40
38
|
summary?: boolean;
|
|
41
39
|
}
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
type ActionHandler = (
|
|
42
|
+
params: ActionParams,
|
|
43
|
+
cwd: string,
|
|
44
|
+
) => CodeIntelResult | Promise<CodeIntelResult>;
|
|
45
|
+
|
|
46
|
+
const ACTION_HANDLERS: Record<CodeIntelAction, ActionHandler> = {
|
|
47
|
+
brief: executeBriefAction,
|
|
48
|
+
callers: executeCallersAction,
|
|
49
|
+
callees: executeCalleesAction,
|
|
50
|
+
implementations: executeImplementationsAction,
|
|
51
|
+
affected: executeAffectedAction,
|
|
52
|
+
pattern: executePatternAction,
|
|
53
|
+
index: (_params, cwd) => executeIndexAction(cwd),
|
|
54
|
+
};
|
|
52
55
|
|
|
53
56
|
/**
|
|
54
57
|
* Main action dispatcher — validates params and routes to specific action handlers.
|
|
@@ -62,32 +65,12 @@ export async function executeAction(
|
|
|
62
65
|
const error = validateParams(params, cwd);
|
|
63
66
|
if (error) return { content: error, details: undefined };
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
case "brief":
|
|
67
|
-
return executeBriefAction(params, cwd);
|
|
68
|
-
case "callers":
|
|
69
|
-
return executeCallersAction(params, cwd);
|
|
70
|
-
case "callees":
|
|
71
|
-
return executeCalleesAction(params, cwd);
|
|
72
|
-
case "implementations":
|
|
73
|
-
return executeImplementationsAction(params, cwd);
|
|
74
|
-
case "affected":
|
|
75
|
-
return executeAffectedAction(params, cwd);
|
|
76
|
-
case "pattern":
|
|
77
|
-
return executePatternAction(params, cwd);
|
|
78
|
-
case "index":
|
|
79
|
-
return executeIndexAction(cwd);
|
|
80
|
-
default:
|
|
81
|
-
return {
|
|
82
|
-
content: `**Error:** Unknown action \`${params.action}\`.`,
|
|
83
|
-
details: undefined,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
68
|
+
return ACTION_HANDLERS[params.action](params, cwd);
|
|
86
69
|
}
|
|
87
70
|
|
|
88
71
|
function validateParams(params: ActionParams, cwd: string): string | null {
|
|
89
|
-
if (!params.action || !
|
|
90
|
-
return `**Error:** Unknown action \`${params.action ?? "(none)"}\`. Supported:
|
|
72
|
+
if (!params.action || !isCodeIntelAction(params.action)) {
|
|
73
|
+
return `**Error:** Unknown action \`${params.action ?? "(none)"}\`. Supported: ${formatCodeIntelActionList({ fenced: true })}.`;
|
|
91
74
|
}
|
|
92
75
|
|
|
93
76
|
if (params.path && (params.line != null || params.character != null)) {
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import * as path from "node:path";
|
|
2
|
-
import { splitSuppressionDiagnostics } from "./diagnostics/suppression-diagnostics.ts";
|
|
3
|
-
import type { OutstandingDiagnosticSummaryEntry } from "./manager/manager-types.ts";
|
|
4
|
-
import type { Diagnostic, ProjectServerInfo } from "./types.ts";
|
|
5
|
-
|
|
6
|
-
export const lspPromptSnippet =
|
|
7
|
-
"Use semantic code intelligence for hover, definitions, references, symbols, rename planning, code actions, and diagnostics in supported languages.";
|
|
8
|
-
|
|
9
|
-
export const lspPromptGuidelines = [
|
|
10
|
-
"Prefer the lsp tool over bash text search for supported source files when the task is semantic code navigation or diagnostics.",
|
|
11
|
-
"Use lsp for hover, definitions, references, document symbols, rename planning, code actions, and diagnostics before falling back to grep-style shell search.",
|
|
12
|
-
"Fall back to bash/read when LSP is unavailable, the file type is unsupported, or the task is plain-text search across docs, config files, or string literals.",
|
|
13
|
-
"Diagnostics are automatically delivered: inline after every write/edit tool result, and as context before each agent turn. You do not need to call the lsp tool to check them — they are already in your context.",
|
|
14
|
-
"When delivered diagnostics show errors, decide: (a) expected temporary state from a planned multi-step change — continue your sequence, then verify at the end; (b) unexpected 'Cannot find module', unresolved imports, or type mismatches — stop and fix the root cause before editing more files.",
|
|
15
|
-
"When the SAME error pattern appears across MULTIPLE files after you changed imports, dependencies, or shared types, it is a systemic root-cause issue (missing install, broken import path, wrong dependency version). Do not patch each file individually — find and fix the root cause first.",
|
|
16
|
-
"When diagnostics look stale after package.json, lockfile, tsconfig, or generated-type changes, use lsp recover before editing more files.",
|
|
17
|
-
"After changing package.json dependencies, imports, or peer dependencies, run the package manager install command (e.g., pnpm install) before concluding that module resolution errors are real code bugs.",
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Build per-project `promptGuidelines` for the `lsp` tool registration.
|
|
22
|
-
* These guidelines are part of pi's stable system prompt after session-start
|
|
23
|
-
* tool registration, avoiding per-turn `before_agent_start` prompt overrides.
|
|
24
|
-
*/
|
|
25
|
-
export function buildProjectGuidelines(servers: ProjectServerInfo[], cwd: string): string[] {
|
|
26
|
-
const dynamic = servers.map((server) => {
|
|
27
|
-
const root = displayRoot(server.root, cwd);
|
|
28
|
-
const fileTypes = server.fileTypes.map((entry) => `.${entry}`).join(", ");
|
|
29
|
-
const actions = server.supportedActions.join(", ");
|
|
30
|
-
const status = server.status === "running" ? "active" : "unavailable";
|
|
31
|
-
const actionText = actions.length > 0 ? ` | actions: ${actions}` : "";
|
|
32
|
-
return `LSP ${status}: ${server.name} | root: ${root} | files: ${fileTypes}${actionText}`;
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
return [
|
|
36
|
-
...lspPromptGuidelines.slice(0, 2),
|
|
37
|
-
"Use lsp before grep/rg/find for understanding code, finding usages, diagnostics, symbol lookup, and refactors in supported languages.",
|
|
38
|
-
...dynamic,
|
|
39
|
-
"Use lsp actions by task: hover/definition/references/symbols for understanding code, references/workspace_symbol/search for usages, diagnostics/hover/code_actions for issues, and rename/code_actions for refactors.",
|
|
40
|
-
...lspPromptGuidelines.slice(2),
|
|
41
|
-
].filter(Boolean);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const MAX_DETAILED_DIAGNOSTICS = 5;
|
|
45
|
-
const MAX_DETAIL_LINES_PER_FILE = 3;
|
|
46
|
-
|
|
47
|
-
interface DetailedDiagnostics {
|
|
48
|
-
file: string;
|
|
49
|
-
diagnostics: Diagnostic[];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function formatDiagnosticsContext(
|
|
53
|
-
diagnostics: OutstandingDiagnosticSummaryEntry[],
|
|
54
|
-
maxFiles: number = 3,
|
|
55
|
-
detailed?: DetailedDiagnostics[],
|
|
56
|
-
staleWarning?: string | null,
|
|
57
|
-
): string | null {
|
|
58
|
-
if (diagnostics.length === 0) return null;
|
|
59
|
-
|
|
60
|
-
const totalDiags = diagnostics.reduce((sum, d) => sum + d.total, 0);
|
|
61
|
-
const detailMap = buildDetailMap(diagnostics, totalDiags, detailed);
|
|
62
|
-
|
|
63
|
-
const lines: string[] = [];
|
|
64
|
-
if (staleWarning) lines.push(staleWarning);
|
|
65
|
-
const visible = diagnostics.slice(0, maxFiles);
|
|
66
|
-
|
|
67
|
-
for (const entry of visible) {
|
|
68
|
-
lines.push(`- ${entry.file}: ${formatCounts(entry)}`);
|
|
69
|
-
appendDetailLines(lines, detailMap?.get(entry.file));
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const remaining = diagnostics.length - visible.length;
|
|
73
|
-
if (remaining > 0) {
|
|
74
|
-
lines.push(`- +${remaining} more file${remaining === 1 ? "" : "s"}`);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
appendSuppressionCleanup(
|
|
78
|
-
lines,
|
|
79
|
-
visible.map((entry) => entry.file),
|
|
80
|
-
detailMap,
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
return [
|
|
84
|
-
'<extension-context source="supi-lsp">',
|
|
85
|
-
"Outstanding diagnostics — fix these before proceeding:",
|
|
86
|
-
...lines,
|
|
87
|
-
"</extension-context>",
|
|
88
|
-
].join("\n");
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function buildDetailMap(
|
|
92
|
-
_diagnostics: OutstandingDiagnosticSummaryEntry[],
|
|
93
|
-
totalDiags: number,
|
|
94
|
-
detailed?: DetailedDiagnostics[],
|
|
95
|
-
): Map<string, Diagnostic[]> | null {
|
|
96
|
-
if (totalDiags > MAX_DETAILED_DIAGNOSTICS || !detailed || detailed.length === 0) return null;
|
|
97
|
-
return new Map(detailed.map((d) => [d.file, d.diagnostics]));
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function appendDetailLines(lines: string[], details?: Diagnostic[]): void {
|
|
101
|
-
if (!details) return;
|
|
102
|
-
for (const d of details.slice(0, MAX_DETAIL_LINES_PER_FILE)) {
|
|
103
|
-
const line = d.range.start.line + 1;
|
|
104
|
-
const char = d.range.start.character + 1;
|
|
105
|
-
const source = d.source ? ` ${d.source}` : "";
|
|
106
|
-
lines.push(` L${line} C${char}${source}: ${d.message}`);
|
|
107
|
-
}
|
|
108
|
-
if (details.length > MAX_DETAIL_LINES_PER_FILE) {
|
|
109
|
-
const extra = details.length - MAX_DETAIL_LINES_PER_FILE;
|
|
110
|
-
lines.push(` +${extra} more`);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function appendSuppressionCleanup(
|
|
115
|
-
lines: string[],
|
|
116
|
-
visibleFiles: string[],
|
|
117
|
-
detailMap: Map<string, Diagnostic[]> | null,
|
|
118
|
-
): void {
|
|
119
|
-
if (!detailMap) return;
|
|
120
|
-
|
|
121
|
-
const suppressionLines: string[] = [];
|
|
122
|
-
for (const file of visibleFiles) {
|
|
123
|
-
const diagnostics = detailMap.get(file);
|
|
124
|
-
if (!diagnostics) continue;
|
|
125
|
-
|
|
126
|
-
const { suppressions } = splitSuppressionDiagnostics(diagnostics, 1);
|
|
127
|
-
if (suppressions.length === 0) continue;
|
|
128
|
-
|
|
129
|
-
suppressionLines.push(`- ${file}`);
|
|
130
|
-
appendDetailLines(suppressionLines, suppressions);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (suppressionLines.length === 0) return;
|
|
134
|
-
lines.push("", "Stale suppression comments — clean these up:", ...suppressionLines);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export function diagnosticsContextFingerprint(content: string | null): string | null {
|
|
138
|
-
return content;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// reorderDiagnosticContextMessages, getContextToken, and findLastUserMessageIndex
|
|
142
|
-
// have been extracted to supi-core/context-messages.ts.
|
|
143
|
-
// Use pruneAndReorderContextMessages(messages, "lsp-context", activeToken) instead.
|
|
144
|
-
|
|
145
|
-
function formatCounts(entry: OutstandingDiagnosticSummaryEntry): string {
|
|
146
|
-
const counts: string[] = [];
|
|
147
|
-
if (entry.errors > 0) counts.push(pluralize(entry.errors, "error"));
|
|
148
|
-
if (entry.warnings > 0) counts.push(pluralize(entry.warnings, "warning"));
|
|
149
|
-
if (entry.information > 0) counts.push(pluralize(entry.information, "info"));
|
|
150
|
-
if (entry.hints > 0) counts.push(pluralize(entry.hints, "hint"));
|
|
151
|
-
return counts.join(", ");
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function displayRoot(root: string, cwd: string): string {
|
|
155
|
-
const relative = path.relative(cwd, root);
|
|
156
|
-
if (relative === "") return ".";
|
|
157
|
-
if (relative.startsWith(`..${path.sep}`) || relative === "..") return root;
|
|
158
|
-
return relative.replaceAll(path.sep, "/");
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function pluralize(count: number, word: string): string {
|
|
162
|
-
return `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
163
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
|
|
4
|
-
export interface GrepMatch {
|
|
5
|
-
file: string;
|
|
6
|
-
line: number;
|
|
7
|
-
text: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const IGNORE_DIRS = new Set([
|
|
11
|
-
"node_modules",
|
|
12
|
-
".git",
|
|
13
|
-
"dist",
|
|
14
|
-
"build",
|
|
15
|
-
".next",
|
|
16
|
-
"coverage",
|
|
17
|
-
"tmp",
|
|
18
|
-
".pnpm",
|
|
19
|
-
]);
|
|
20
|
-
|
|
21
|
-
const SOURCE_EXTENSIONS = new Set([
|
|
22
|
-
".ts",
|
|
23
|
-
".tsx",
|
|
24
|
-
".js",
|
|
25
|
-
".jsx",
|
|
26
|
-
".mjs",
|
|
27
|
-
".cjs",
|
|
28
|
-
".py",
|
|
29
|
-
".rs",
|
|
30
|
-
".go",
|
|
31
|
-
".java",
|
|
32
|
-
".kt",
|
|
33
|
-
".swift",
|
|
34
|
-
".rb",
|
|
35
|
-
".c",
|
|
36
|
-
".cpp",
|
|
37
|
-
".h",
|
|
38
|
-
".hpp",
|
|
39
|
-
]);
|
|
40
|
-
|
|
41
|
-
/** Simple recursive text search in project source files. */
|
|
42
|
-
export function fallbackGrep(projectRoot: string, query: string): GrepMatch[] {
|
|
43
|
-
const results: GrepMatch[] = [];
|
|
44
|
-
walk(projectRoot, projectRoot, query, results);
|
|
45
|
-
return results;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function walk(dir: string, projectRoot: string, query: string, results: GrepMatch[]): void {
|
|
49
|
-
let entries: fs.Dirent[];
|
|
50
|
-
try {
|
|
51
|
-
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
52
|
-
} catch {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
for (const entry of entries) {
|
|
57
|
-
if (entry.isDirectory()) {
|
|
58
|
-
if (!IGNORE_DIRS.has(entry.name)) {
|
|
59
|
-
walk(path.join(dir, entry.name), projectRoot, query, results);
|
|
60
|
-
}
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (!entry.isFile() || !SOURCE_EXTENSIONS.has(path.extname(entry.name))) {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const filePath = path.join(dir, entry.name);
|
|
69
|
-
searchFile(filePath, projectRoot, query, results);
|
|
70
|
-
if (results.length >= 20) return;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function searchFile(
|
|
75
|
-
filePath: string,
|
|
76
|
-
projectRoot: string,
|
|
77
|
-
query: string,
|
|
78
|
-
results: GrepMatch[],
|
|
79
|
-
): void {
|
|
80
|
-
let content: string;
|
|
81
|
-
try {
|
|
82
|
-
content = fs.readFileSync(filePath, "utf-8");
|
|
83
|
-
} catch {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const lines = content.split("\n");
|
|
88
|
-
for (let i = 0; i < lines.length; i++) {
|
|
89
|
-
if (lines[i].includes(query)) {
|
|
90
|
-
results.push({
|
|
91
|
-
file: path.relative(projectRoot, filePath),
|
|
92
|
-
line: i + 1,
|
|
93
|
-
text: lines[i].trim(),
|
|
94
|
-
});
|
|
95
|
-
if (results.length >= 20) return;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|