@mrclrchtr/supi-lsp 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 +58 -39
- 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-core/src/{context-provider-registry.ts → 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-core/src/{settings-registry.ts → settings/settings-registry.ts} +1 -1
- package/package.json +3 -2
- package/src/api.ts +16 -3
- package/src/client/client-refresh.ts +1 -1
- package/src/client/client.ts +27 -3
- package/src/client/transport.ts +61 -5
- package/src/config/tsconfig-scope.ts +244 -0
- package/src/{types.ts → config/types.ts} +4 -2
- package/src/coordinates.ts +11 -0
- package/src/diagnostics/diagnostic-augmentation.ts +5 -5
- package/src/diagnostics/diagnostic-context.ts +115 -0
- package/src/diagnostics/diagnostic-display.ts +1 -1
- package/src/diagnostics/diagnostic-summary.ts +3 -2
- package/src/diagnostics/diagnostics.ts +1 -1
- package/src/diagnostics/stale-diagnostics.ts +1 -1
- package/src/diagnostics/suppression-diagnostics.ts +1 -1
- package/src/{workspace-sentinels.ts → diagnostics/workspace-sentinels.ts} +2 -2
- package/src/format.ts +2 -23
- package/src/index.ts +18 -5
- package/src/lsp.ts +72 -120
- package/src/manager/manager-diagnostics.ts +1 -1
- package/src/manager/manager-helpers.ts +4 -2
- package/src/manager/manager-project-info.ts +10 -21
- package/src/manager/manager-workspace-recovery.ts +1 -1
- package/src/manager/manager-workspace-symbol.ts +158 -6
- package/src/manager/manager.ts +202 -43
- package/src/{lsp-state.ts → session/lsp-state.ts} +22 -11
- package/src/{scanner.ts → session/scanner.ts} +3 -3
- package/src/{service-registry.ts → session/service-registry.ts} +109 -33
- package/src/{settings-registration.ts → session/settings-registration.ts} +1 -1
- package/src/session/tree-persist.ts +75 -0
- package/src/summary.ts +1 -1
- package/src/tool/guidance.ts +78 -0
- package/src/tool/names.ts +19 -0
- package/src/{overrides.ts → tool/overrides.ts} +55 -24
- package/src/tool/register-tools.ts +71 -0
- package/src/tool/service-actions.ts +258 -0
- package/src/tool/tool-specs.ts +248 -0
- package/src/{ui.ts → ui/ui.ts} +4 -4
- package/src/utils.ts +5 -23
- package/src/guidance.ts +0 -163
- package/src/search-fallback.ts +0 -98
- package/src/tool-actions.ts +0 -430
- package/src/tree-persist.ts +0 -48
- package/src/tsconfig-scope.ts +0 -156
- /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/src/{capabilities.ts → config/capabilities.ts} +0 -0
- /package/src/{config.ts → config/config.ts} +0 -0
- /package/src/{defaults.json → config/defaults.json} +0 -0
- /package/src/{renderer.ts → ui/renderer.ts} +0 -0
package/src/tree-persist.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
// LSP tree navigation persistence — restores tool activation state across /tree navigation.
|
|
2
|
-
|
|
3
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
|
|
5
|
-
/** Shape of the entry persisted via `pi.appendEntry()`. */
|
|
6
|
-
export interface LspStateEntry {
|
|
7
|
-
active: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/** Restore LSP activation state from the current branch after /tree navigation. */
|
|
11
|
-
export function registerTreePersistHandlers(pi: ExtensionAPI, state: { lspActive: boolean }): void {
|
|
12
|
-
pi.on("session_tree", async (_event, ctx) => {
|
|
13
|
-
const branch = ctx.sessionManager.getBranch();
|
|
14
|
-
let lastEntry: LspStateEntry | undefined;
|
|
15
|
-
|
|
16
|
-
for (const entry of branch) {
|
|
17
|
-
if (entry.type === "custom" && entry.customType === "lsp-active") {
|
|
18
|
-
lastEntry = entry.data as LspStateEntry | undefined;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (lastEntry?.active) {
|
|
23
|
-
const activeTools = pi.getActiveTools();
|
|
24
|
-
if (!activeTools.includes("lsp")) {
|
|
25
|
-
pi.setActiveTools([...activeTools, "lsp"]);
|
|
26
|
-
}
|
|
27
|
-
state.lspActive = true;
|
|
28
|
-
} else {
|
|
29
|
-
const activeTools = pi.getActiveTools();
|
|
30
|
-
if (activeTools.includes("lsp")) {
|
|
31
|
-
pi.setActiveTools(activeTools.filter((t) => t !== "lsp"));
|
|
32
|
-
}
|
|
33
|
-
state.lspActive = false;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** Persist that LSP is active in the session tree. */
|
|
39
|
-
export function persistLspActiveState(pi: ExtensionAPI, state: { lspActive: boolean }): void {
|
|
40
|
-
state.lspActive = true;
|
|
41
|
-
pi.appendEntry<LspStateEntry>("lsp-active", { active: true });
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** Persist that LSP is inactive in the session tree. */
|
|
45
|
-
export function persistLspInactiveState(pi: ExtensionAPI, state: { lspActive: boolean }): void {
|
|
46
|
-
state.lspActive = false;
|
|
47
|
-
pi.appendEntry<LspStateEntry>("lsp-active", { active: false });
|
|
48
|
-
}
|
package/src/tsconfig-scope.ts
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
// tsconfig-aware file scope detection.
|
|
2
|
-
//
|
|
3
|
-
// Determines whether a file is within the compilation scope of its nearest
|
|
4
|
-
// tsconfig.json by checking `include` and `exclude` patterns. Used by the
|
|
5
|
-
// diagnostic filter to suppress LSP errors on files that TypeScript itself
|
|
6
|
-
// would not type-check.
|
|
7
|
-
|
|
8
|
-
import * as fs from "node:fs";
|
|
9
|
-
import * as path from "node:path";
|
|
10
|
-
|
|
11
|
-
interface TsconfigInfo {
|
|
12
|
-
dir: string;
|
|
13
|
-
include: string[] | undefined;
|
|
14
|
-
exclude: string[] | undefined;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const cache = new Map<string, TsconfigInfo | null>();
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Check whether a file is excluded by its nearest tsconfig.json.
|
|
21
|
-
*
|
|
22
|
-
* @param filePath - Project-relative file path (e.g., "packages/foo/__tests__/x.test.ts")
|
|
23
|
-
* @param cwd - Absolute project root directory
|
|
24
|
-
* @returns `true` if the file is excluded from compilation scope
|
|
25
|
-
*/
|
|
26
|
-
export function isFileExcludedByTsconfig(filePath: string, cwd: string): boolean {
|
|
27
|
-
const absolutePath = path.resolve(cwd, filePath);
|
|
28
|
-
const tsconfig = findNearestTsconfig(path.dirname(absolutePath), cwd);
|
|
29
|
-
if (!tsconfig) return false;
|
|
30
|
-
|
|
31
|
-
const relativeToTsconfig = path.relative(tsconfig.dir, absolutePath).replaceAll("\\", "/");
|
|
32
|
-
|
|
33
|
-
// Check exclude patterns first
|
|
34
|
-
if (tsconfig.exclude) {
|
|
35
|
-
for (const pattern of tsconfig.exclude) {
|
|
36
|
-
if (matchesPattern(relativeToTsconfig, pattern)) return true;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// If include is specified, the file must match at least one pattern
|
|
41
|
-
if (tsconfig.include) {
|
|
42
|
-
let included = false;
|
|
43
|
-
for (const pattern of tsconfig.include) {
|
|
44
|
-
if (matchesPattern(relativeToTsconfig, pattern)) {
|
|
45
|
-
included = true;
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (!included) return true;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Find the nearest tsconfig.json walking upward from `startDir`,
|
|
57
|
-
* stopping at `rootDir`.
|
|
58
|
-
*/
|
|
59
|
-
function findNearestTsconfig(startDir: string, rootDir: string): TsconfigInfo | null {
|
|
60
|
-
let dir = startDir;
|
|
61
|
-
while (true) {
|
|
62
|
-
const cached = cache.get(dir);
|
|
63
|
-
if (cached !== undefined) return cached;
|
|
64
|
-
|
|
65
|
-
const tsconfigPath = path.join(dir, "tsconfig.json");
|
|
66
|
-
if (fs.existsSync(tsconfigPath)) {
|
|
67
|
-
const info = parseTsconfig(dir, tsconfigPath);
|
|
68
|
-
cache.set(dir, info);
|
|
69
|
-
return info;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (path.relative(rootDir, dir).startsWith("..") || dir === rootDir) {
|
|
73
|
-
// Don't look above the project root
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const parent = path.dirname(dir);
|
|
78
|
-
if (parent === dir) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
dir = parent;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function parseTsconfig(dir: string, tsconfigPath: string): TsconfigInfo | null {
|
|
86
|
-
try {
|
|
87
|
-
const raw = fs.readFileSync(tsconfigPath, "utf-8");
|
|
88
|
-
// Strip comments without touching content inside double-quoted strings.
|
|
89
|
-
const cleaned = raw
|
|
90
|
-
.replace(/("(?:\\.|[^"\\])*")|\/\/.*$/gm, "$1")
|
|
91
|
-
.replace(/("(?:\\.|[^"\\])*")|\/[\s\S]*?\*\//g, "$1");
|
|
92
|
-
const json = JSON.parse(cleaned);
|
|
93
|
-
return {
|
|
94
|
-
dir,
|
|
95
|
-
include: json.include as string[] | undefined,
|
|
96
|
-
exclude: json.exclude as string[] | undefined,
|
|
97
|
-
};
|
|
98
|
-
} catch {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Lightweight pattern matching for tsconfig include/exclude patterns.
|
|
105
|
-
* Handles directory names, extensions, recursive globs, and literal paths.
|
|
106
|
-
*/
|
|
107
|
-
function matchesPattern(filePath: string, pattern: string): boolean {
|
|
108
|
-
const normalizedPattern = pattern.replaceAll("\\", "/");
|
|
109
|
-
|
|
110
|
-
// Directory-prefixed recursive glob: prefix/**/*.ext
|
|
111
|
-
if (normalizedPattern.includes("/**/")) {
|
|
112
|
-
const idx = normalizedPattern.indexOf("/**/");
|
|
113
|
-
const prefix = normalizedPattern.slice(0, idx);
|
|
114
|
-
const suffix = normalizedPattern.slice(idx + 4);
|
|
115
|
-
return (
|
|
116
|
-
filePath.startsWith(`${prefix}/`) && matchesPattern(filePath.slice(prefix.length + 1), suffix)
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Recursive glob: **/*.ext
|
|
121
|
-
if (normalizedPattern.startsWith("**/")) {
|
|
122
|
-
const suffix = normalizedPattern.slice(3); // e.g., "*.ts"
|
|
123
|
-
return matchesPattern(filePath, suffix) || filePath.includes(`/${suffix}`);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Directory match: pattern has no glob chars and no "."
|
|
127
|
-
// e.g., "node_modules" or "__tests__"
|
|
128
|
-
if (!normalizedPattern.includes("*") && !normalizedPattern.includes(".")) {
|
|
129
|
-
return (
|
|
130
|
-
filePath === normalizedPattern ||
|
|
131
|
-
filePath.startsWith(`${normalizedPattern}/`) ||
|
|
132
|
-
filePath.includes(`/${normalizedPattern}/`)
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Simple glob: *.ext — match basename
|
|
137
|
-
if (normalizedPattern.startsWith("*.")) {
|
|
138
|
-
const ext = normalizedPattern.slice(1); // e.g., ".ts"
|
|
139
|
-
return filePath.endsWith(ext) && !filePath.includes("/", filePath.length - ext.length - 1);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Literal path
|
|
143
|
-
if (!normalizedPattern.includes("*")) {
|
|
144
|
-
return filePath === normalizedPattern || filePath.startsWith(`${normalizedPattern}/`);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Fallback: path contains the pattern segment
|
|
148
|
-
return filePath.includes(`/${normalizedPattern}`) || filePath === normalizedPattern;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Clear the tsconfig cache. Useful for testing or after filesystem changes.
|
|
153
|
-
*/
|
|
154
|
-
export function clearTsconfigCache(): void {
|
|
155
|
-
cache.clear();
|
|
156
|
-
}
|
|
File without changes
|
/package/node_modules/@mrclrchtr/supi-core/src/{context-messages.ts → context/context-messages.ts}
RENAMED
|
File without changes
|
|
File without changes
|
/package/node_modules/@mrclrchtr/supi-core/src/{settings-command.ts → settings/settings-command.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|