pi-one-ui 0.1.1
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/LICENSE +21 -0
- package/README.md +106 -0
- package/extensions/app/config/renderer.ts +452 -0
- package/extensions/app/config/shell.ts +2484 -0
- package/extensions/app/ownership.ts +18 -0
- package/extensions/app/panel.ts +533 -0
- package/extensions/app/presets.ts +36 -0
- package/extensions/features/agent-summary/core.ts +194 -0
- package/extensions/features/agent-summary/index.ts +37 -0
- package/extensions/features/compact-thinking.ts +1262 -0
- package/extensions/features/context.ts +857 -0
- package/extensions/features/reference/index.ts +643 -0
- package/extensions/features/reference/session.ts +278 -0
- package/extensions/features/reference/subagent.ts +218 -0
- package/extensions/features/shell/aliases.ts +28 -0
- package/extensions/features/shell/flush-docked-bash.ts +39 -0
- package/extensions/features/shell/startup-header.ts +357 -0
- package/extensions/features/shell/working-message.ts +226 -0
- package/extensions/index.ts +52 -0
- package/extensions/shell/accent-rail-editor.ts +112 -0
- package/extensions/shell/accent-rail-layout-patch.ts +530 -0
- package/extensions/shell/completion-menu.ts +186 -0
- package/extensions/shell/editor-metadata-format.ts +287 -0
- package/extensions/shell/editor-transfer.ts +73 -0
- package/extensions/shell/extension-status.ts +102 -0
- package/extensions/shell/footer-format.ts +388 -0
- package/extensions/shell/footer-layout.ts +144 -0
- package/extensions/shell/footer.ts +1035 -0
- package/extensions/shell/format.ts +577 -0
- package/extensions/shell/git.ts +434 -0
- package/extensions/shell/icons.ts +261 -0
- package/extensions/shell/index.ts +1659 -0
- package/extensions/shell/interaction-summary.ts +1194 -0
- package/extensions/shell/live-context.ts +82 -0
- package/extensions/shell/minimalist-editor.ts +548 -0
- package/extensions/shell/package-version.ts +675 -0
- package/extensions/shell/project-refresh.ts +130 -0
- package/extensions/shell/project-state.ts +60 -0
- package/extensions/shell/prototype-patch-registry.ts +183 -0
- package/extensions/shell/runtime.ts +915 -0
- package/extensions/shell/selector-border.ts +109 -0
- package/extensions/shell/session-lifecycle.ts +60 -0
- package/extensions/shell/settings-command.ts +2144 -0
- package/extensions/shell/settings-previews.ts +137 -0
- package/extensions/shell/state.ts +83 -0
- package/extensions/shell/style.ts +480 -0
- package/extensions/shell/telemetry.ts +90 -0
- package/extensions/shell/ui.ts +1326 -0
- package/extensions/shell/user-message-osc.ts +279 -0
- package/extensions/shell/user-message-styles.ts +266 -0
- package/extensions/shell/user-message.ts +226 -0
- package/extensions/shell/working-line-messages.ts +24 -0
- package/extensions/shell/working-line-spinners.ts +54 -0
- package/extensions/shell/working-line.ts +1603 -0
- package/extensions/tools/ansi-color.ts +44 -0
- package/extensions/tools/ansi-text.ts +52 -0
- package/extensions/tools/component-tree.ts +37 -0
- package/extensions/tools/format.ts +28 -0
- package/extensions/tools/fullscreen-detect.ts +11 -0
- package/extensions/tools/patch-keys.ts +158 -0
- package/extensions/tools/sgr-mouse.ts +59 -0
- package/extensions/tools/tool-loading-icon.ts +20 -0
- package/extensions/tools/tool-result-sanitize.ts +27 -0
- package/extensions/transcript/index.ts +65 -0
- package/extensions/transcript/renderer/compact-mode.ts +1443 -0
- package/extensions/transcript/renderer/default-mode.ts +735 -0
- package/extensions/transcript/renderer/index.ts +286 -0
- package/extensions/transcript/renderer/markdown-enhance.ts +325 -0
- package/extensions/transcript/renderer/mouse/hover.ts +175 -0
- package/extensions/transcript/renderer/mouse/interaction.ts +1016 -0
- package/extensions/transcript/renderer/mouse/layout.ts +207 -0
- package/extensions/transcript/renderer/mouse/packets.ts +96 -0
- package/extensions/transcript/renderer/mouse/scroll.ts +211 -0
- package/extensions/transcript/renderer/tool/diff/ATTRIBUTION.md +28 -0
- package/extensions/transcript/renderer/tool/diff/ansi-utils.ts +128 -0
- package/extensions/transcript/renderer/tool/diff/diff-component.ts +112 -0
- package/extensions/transcript/renderer/tool/diff/diff-edit-render.ts +255 -0
- package/extensions/transcript/renderer/tool/diff/diff-header.ts +184 -0
- package/extensions/transcript/renderer/tool/diff/diff-highlight.ts +131 -0
- package/extensions/transcript/renderer/tool/diff/diff-inline.ts +350 -0
- package/extensions/transcript/renderer/tool/diff/diff-layout.ts +870 -0
- package/extensions/transcript/renderer/tool/diff/diff-limits.ts +189 -0
- package/extensions/transcript/renderer/tool/diff/diff-palette.ts +436 -0
- package/extensions/transcript/renderer/tool/diff/diff-parse.ts +536 -0
- package/extensions/transcript/renderer/tool/diff/diff-presentation.ts +79 -0
- package/extensions/transcript/renderer/tool/diff/diff-renderer.ts +29 -0
- package/extensions/transcript/renderer/tool/diff/diff-text.ts +57 -0
- package/extensions/transcript/renderer/tool/diff/diff-write-render.ts +629 -0
- package/extensions/transcript/renderer/tool/diff/index.ts +147 -0
- package/extensions/transcript/renderer/tool/diff/line-width-safety.ts +100 -0
- package/extensions/transcript/renderer/tool/diff/shiki-highlight.ts +104 -0
- package/extensions/transcript/renderer/tool/diff/write-execution.ts +124 -0
- package/extensions/transcript/renderer/tool/grouping.ts +619 -0
- package/extensions/transcript/renderer/tool/message-display.ts +183 -0
- package/extensions/transcript/renderer/tool/names.ts +195 -0
- package/extensions/transcript/renderer/tool/result.ts +842 -0
- package/extensions/transcript/renderer/tool/show-more-hint.ts +42 -0
- package/extensions/transcript/renderer/transcript-refresh.ts +79 -0
- package/package.json +58 -0
- package/themes/cc-dark.json +91 -0
- package/themes/cc-light.json +91 -0
|
@@ -0,0 +1,915 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
|
|
6
|
+
const execFileAsync = promisify(execFile);
|
|
7
|
+
const VERSION_TIMEOUT_MS = 2500;
|
|
8
|
+
|
|
9
|
+
export type RuntimeMetadata = {
|
|
10
|
+
name: string;
|
|
11
|
+
symbol: string;
|
|
12
|
+
style: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type RuntimeInfo = Pick<RuntimeMetadata, "name" | "symbol" | "style"> & {
|
|
16
|
+
version?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type RuntimeReadResult =
|
|
20
|
+
| { kind: "ok"; runtime?: RuntimeInfo }
|
|
21
|
+
| { kind: "error" };
|
|
22
|
+
|
|
23
|
+
type RuntimeCacheEntry = {
|
|
24
|
+
fingerprint: string;
|
|
25
|
+
runtime: RuntimeInfo | undefined;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const RUNTIME_CACHE_MAX = 32;
|
|
29
|
+
const runtimeInfoCache = new Map<string, RuntimeCacheEntry>();
|
|
30
|
+
|
|
31
|
+
export function clearRuntimeInfoCache(): void {
|
|
32
|
+
runtimeInfoCache.clear();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function topLevelFingerprint(entries: readonly string[]): string {
|
|
36
|
+
return entries.slice().sort().join("\0");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function cacheRuntimeInfo(
|
|
40
|
+
cwd: string,
|
|
41
|
+
fingerprint: string,
|
|
42
|
+
runtime: RuntimeInfo | undefined,
|
|
43
|
+
): void {
|
|
44
|
+
// Drop prior fingerprints for the same cwd so stale marker sets do not linger.
|
|
45
|
+
for (const key of runtimeInfoCache.keys()) {
|
|
46
|
+
if (key === cwd || key.startsWith(`${cwd}\0`)) runtimeInfoCache.delete(key);
|
|
47
|
+
}
|
|
48
|
+
const key = `${cwd}\0${fingerprint}`;
|
|
49
|
+
runtimeInfoCache.set(key, { fingerprint, runtime });
|
|
50
|
+
while (runtimeInfoCache.size > RUNTIME_CACHE_MAX) {
|
|
51
|
+
const oldest = runtimeInfoCache.keys().next().value;
|
|
52
|
+
if (oldest === undefined) break;
|
|
53
|
+
runtimeInfoCache.delete(oldest);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type RuntimeEnvironment = Record<string, string | undefined>;
|
|
58
|
+
|
|
59
|
+
type DetectionSpec = {
|
|
60
|
+
extensions?: readonly string[];
|
|
61
|
+
files?: readonly string[];
|
|
62
|
+
folders?: readonly string[];
|
|
63
|
+
env?: (env: RuntimeEnvironment) => boolean;
|
|
64
|
+
excludedFiles?: readonly string[];
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
type VersionCommand = {
|
|
68
|
+
command: string;
|
|
69
|
+
args?: readonly string[];
|
|
70
|
+
pattern?: RegExp;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
type RuntimeDef = RuntimeMetadata & {
|
|
74
|
+
priority: number;
|
|
75
|
+
detect: DetectionSpec;
|
|
76
|
+
version: (cwd: string) => Promise<string | undefined>;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// --- Detection utilities ---
|
|
80
|
+
|
|
81
|
+
function hasAnyFile(cwd: string, names: readonly string[]): boolean {
|
|
82
|
+
return names.some((name) => existsSync(join(cwd, name)));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function hasAnyFolder(cwd: string, names: readonly string[]): boolean {
|
|
86
|
+
return names.some((name) => {
|
|
87
|
+
try {
|
|
88
|
+
return statSync(join(cwd, name)).isDirectory();
|
|
89
|
+
} catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function entryExtensions(entry: string): string[] {
|
|
96
|
+
const baseName = entry.split(/[\\/]/).pop() ?? entry;
|
|
97
|
+
if (!baseName || baseName.startsWith(".")) return [];
|
|
98
|
+
|
|
99
|
+
const firstDot = baseName.indexOf(".");
|
|
100
|
+
if (firstDot === -1) return [];
|
|
101
|
+
|
|
102
|
+
const extensions = [baseName.slice(firstDot + 1)];
|
|
103
|
+
const lastDot = baseName.lastIndexOf(".");
|
|
104
|
+
if (lastDot !== firstDot) extensions.push(baseName.slice(lastDot + 1));
|
|
105
|
+
return extensions;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function hasAnyExtension(
|
|
109
|
+
entries: readonly string[],
|
|
110
|
+
extensions: readonly string[],
|
|
111
|
+
): boolean {
|
|
112
|
+
const extensionSet = new Set(extensions);
|
|
113
|
+
return entries.some((entry) =>
|
|
114
|
+
entryExtensions(entry).some((extension) => extensionSet.has(extension)),
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function matchesDetection(
|
|
119
|
+
cwd: string,
|
|
120
|
+
entries: string[],
|
|
121
|
+
spec: DetectionSpec,
|
|
122
|
+
env: RuntimeEnvironment,
|
|
123
|
+
): boolean {
|
|
124
|
+
if (spec.excludedFiles && hasAnyFile(cwd, spec.excludedFiles)) return false;
|
|
125
|
+
return Boolean(
|
|
126
|
+
(spec.files && hasAnyFile(cwd, spec.files)) ||
|
|
127
|
+
(spec.folders && hasAnyFolder(cwd, spec.folders)) ||
|
|
128
|
+
(spec.extensions && hasAnyExtension(entries, spec.extensions)) ||
|
|
129
|
+
spec.env?.(env),
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// --- Version utilities ---
|
|
134
|
+
|
|
135
|
+
async function runVersion(
|
|
136
|
+
command: string,
|
|
137
|
+
args: readonly string[] = [],
|
|
138
|
+
cwd?: string,
|
|
139
|
+
): Promise<string | undefined> {
|
|
140
|
+
try {
|
|
141
|
+
const { stdout, stderr } = await execFileAsync(command, [...args], {
|
|
142
|
+
cwd,
|
|
143
|
+
timeout: VERSION_TIMEOUT_MS,
|
|
144
|
+
});
|
|
145
|
+
const text =
|
|
146
|
+
`${typeof stdout === "string" ? stdout : String(stdout)}\n${typeof stderr === "string" ? stderr : String(stderr)}`.trim();
|
|
147
|
+
return text || undefined;
|
|
148
|
+
} catch {
|
|
149
|
+
return undefined;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function prefixVersion(version: string | undefined): string | undefined {
|
|
154
|
+
if (!version) return undefined;
|
|
155
|
+
return version.startsWith("v") ? version : `v${version}`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function extractVersion(
|
|
159
|
+
output: string | undefined,
|
|
160
|
+
pattern?: RegExp,
|
|
161
|
+
): string | undefined {
|
|
162
|
+
if (!output) return undefined;
|
|
163
|
+
const match = output.match(
|
|
164
|
+
pattern ?? /(?:version\s*)?v?([0-9]+(?:\.[0-9A-Za-z][0-9A-Za-z.+_-]*)*)/i,
|
|
165
|
+
);
|
|
166
|
+
return prefixVersion(match?.[1]);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function versionFromCommands(
|
|
170
|
+
commands: readonly VersionCommand[],
|
|
171
|
+
): () => Promise<string | undefined> {
|
|
172
|
+
return async () => {
|
|
173
|
+
for (const { command, args = [], pattern } of commands) {
|
|
174
|
+
const version = extractVersion(await runVersion(command, args), pattern);
|
|
175
|
+
if (version) return version;
|
|
176
|
+
}
|
|
177
|
+
return undefined;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function noVersion(): Promise<undefined> {
|
|
182
|
+
return Promise.resolve(undefined);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// --- Priority levels ---
|
|
186
|
+
// 10 = build-system runtimes (checked first to avoid language false-positives)
|
|
187
|
+
// 50 = common runtimes (bun, deno, node, python, etc.)
|
|
188
|
+
// 100 = default (everything else, checked in definition order)
|
|
189
|
+
|
|
190
|
+
const PRIORITY_BUILD_SYSTEM = 10;
|
|
191
|
+
const PRIORITY_COMMON = 50;
|
|
192
|
+
const PRIORITY_DEFAULT = 100;
|
|
193
|
+
|
|
194
|
+
// --- Runtime definitions ---
|
|
195
|
+
|
|
196
|
+
const runtimes: RuntimeDef[] = [
|
|
197
|
+
{
|
|
198
|
+
name: "xmake",
|
|
199
|
+
symbol: "",
|
|
200
|
+
style: "bold green",
|
|
201
|
+
priority: PRIORITY_BUILD_SYSTEM,
|
|
202
|
+
detect: { files: ["xmake.lua"] },
|
|
203
|
+
version: versionFromCommands([{ command: "xmake", args: ["--version"] }]),
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: "maven",
|
|
207
|
+
symbol: "",
|
|
208
|
+
style: "bold bright-cyan",
|
|
209
|
+
priority: PRIORITY_BUILD_SYSTEM,
|
|
210
|
+
detect: { files: ["pom.xml"] },
|
|
211
|
+
version: versionFromCommands([
|
|
212
|
+
{
|
|
213
|
+
command: "mvn",
|
|
214
|
+
args: ["--version"],
|
|
215
|
+
pattern: /Apache Maven\s+([0-9][^\s]*)/i,
|
|
216
|
+
},
|
|
217
|
+
]),
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: "gradle",
|
|
221
|
+
symbol: "",
|
|
222
|
+
style: "bold bright-cyan",
|
|
223
|
+
priority: PRIORITY_BUILD_SYSTEM,
|
|
224
|
+
detect: {
|
|
225
|
+
files: ["build.gradle", "build.gradle.kts"],
|
|
226
|
+
folders: ["gradle"],
|
|
227
|
+
},
|
|
228
|
+
version: versionFromCommands([
|
|
229
|
+
{
|
|
230
|
+
command: "gradle",
|
|
231
|
+
args: ["--version"],
|
|
232
|
+
pattern: /Gradle\s+([0-9][^\s]*)/i,
|
|
233
|
+
},
|
|
234
|
+
]),
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: "bun",
|
|
238
|
+
symbol: "",
|
|
239
|
+
style: "bold red",
|
|
240
|
+
priority: PRIORITY_COMMON,
|
|
241
|
+
detect: { files: ["bun.lock", "bun.lockb"] },
|
|
242
|
+
version: async () => prefixVersion(await runVersion("bun", ["--version"])),
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
name: "deno",
|
|
246
|
+
symbol: "",
|
|
247
|
+
style: "green bold",
|
|
248
|
+
priority: PRIORITY_COMMON,
|
|
249
|
+
detect: { files: ["deno.json", "deno.jsonc", "deno.lock"] },
|
|
250
|
+
version: async () =>
|
|
251
|
+
extractVersion(
|
|
252
|
+
await runVersion("deno", ["--version"]),
|
|
253
|
+
/deno\s+([0-9][^\s]*)/i,
|
|
254
|
+
),
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
name: "lua",
|
|
258
|
+
symbol: "",
|
|
259
|
+
style: "bold blue",
|
|
260
|
+
priority: PRIORITY_COMMON,
|
|
261
|
+
detect: {
|
|
262
|
+
extensions: ["lua"],
|
|
263
|
+
files: [
|
|
264
|
+
"stylua.toml",
|
|
265
|
+
".stylua.toml",
|
|
266
|
+
".luarc.json",
|
|
267
|
+
".luarc.jsonc",
|
|
268
|
+
"init.lua",
|
|
269
|
+
".lua-version",
|
|
270
|
+
],
|
|
271
|
+
folders: ["lua"],
|
|
272
|
+
excludedFiles: ["xmake.lua"],
|
|
273
|
+
},
|
|
274
|
+
version: async () => {
|
|
275
|
+
const lua = await runVersion("lua", ["-v"]);
|
|
276
|
+
const luaMatch = lua?.match(/Lua\s+([0-9][^\s]*)/i);
|
|
277
|
+
if (luaMatch?.[1]) return prefixVersion(luaMatch[1]);
|
|
278
|
+
const luajit = await runVersion("luajit", ["-v"]);
|
|
279
|
+
const luajitMatch = luajit?.match(/LuaJIT\s+([0-9][^\s]*)/i);
|
|
280
|
+
return prefixVersion(luajitMatch?.[1]);
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
name: "nodejs",
|
|
285
|
+
symbol: "",
|
|
286
|
+
style: "bold green",
|
|
287
|
+
priority: PRIORITY_COMMON,
|
|
288
|
+
detect: {
|
|
289
|
+
files: ["package.json", ".node-version", ".nvmrc"],
|
|
290
|
+
excludedFiles: ["bunfig.toml", "bun.lock", "bun.lockb"],
|
|
291
|
+
},
|
|
292
|
+
version: async () => prefixVersion(await runVersion("node", ["--version"])),
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
name: "python",
|
|
296
|
+
symbol: "",
|
|
297
|
+
style: "yellow bold",
|
|
298
|
+
priority: PRIORITY_COMMON,
|
|
299
|
+
detect: {
|
|
300
|
+
files: [
|
|
301
|
+
"requirements.txt",
|
|
302
|
+
".python-version",
|
|
303
|
+
"pyproject.toml",
|
|
304
|
+
"Pipfile",
|
|
305
|
+
"setup.py",
|
|
306
|
+
"setup.cfg",
|
|
307
|
+
],
|
|
308
|
+
},
|
|
309
|
+
version: async () => {
|
|
310
|
+
const python3 = await runVersion("python3", ["--version"]);
|
|
311
|
+
const python3Match = python3?.match(/Python\s+([0-9][^\s]*)/i);
|
|
312
|
+
if (python3Match?.[1]) return prefixVersion(python3Match[1]);
|
|
313
|
+
const python = await runVersion("python", ["--version"]);
|
|
314
|
+
const pythonMatch = python?.match(/Python\s+([0-9][^\s]*)/i);
|
|
315
|
+
return prefixVersion(pythonMatch?.[1]);
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
name: "golang",
|
|
320
|
+
symbol: "",
|
|
321
|
+
style: "bold cyan",
|
|
322
|
+
priority: PRIORITY_COMMON,
|
|
323
|
+
detect: { files: ["go.mod"] },
|
|
324
|
+
version: async () =>
|
|
325
|
+
extractVersion(
|
|
326
|
+
await runVersion("go", ["version"]),
|
|
327
|
+
/go version go([0-9][^\s]*)/i,
|
|
328
|
+
),
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
name: "rust",
|
|
332
|
+
symbol: "",
|
|
333
|
+
style: "bold red",
|
|
334
|
+
priority: PRIORITY_COMMON,
|
|
335
|
+
detect: { files: ["Cargo.toml"] },
|
|
336
|
+
version: async () =>
|
|
337
|
+
extractVersion(
|
|
338
|
+
await runVersion("rustc", ["--version"]),
|
|
339
|
+
/rustc\s+([0-9][^\s]*)/i,
|
|
340
|
+
),
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
name: "java",
|
|
344
|
+
symbol: "",
|
|
345
|
+
style: "red dimmed",
|
|
346
|
+
priority: PRIORITY_COMMON,
|
|
347
|
+
detect: { files: [".java-version"] },
|
|
348
|
+
version: async () => {
|
|
349
|
+
const output = await runVersion("java", ["-version"]);
|
|
350
|
+
const quoted = output?.match(/"([0-9][^"]*)"/);
|
|
351
|
+
if (quoted?.[1]) return prefixVersion(quoted[1]);
|
|
352
|
+
const plain = output?.match(/version\s+([0-9][^\s]*)/i);
|
|
353
|
+
return prefixVersion(plain?.[1]);
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
name: "ruby",
|
|
358
|
+
symbol: "",
|
|
359
|
+
style: "bold red",
|
|
360
|
+
priority: PRIORITY_COMMON,
|
|
361
|
+
detect: { files: ["Gemfile", ".ruby-version"] },
|
|
362
|
+
version: async () =>
|
|
363
|
+
extractVersion(
|
|
364
|
+
await runVersion("ruby", ["--version"]),
|
|
365
|
+
/ruby\s+([0-9][^\s]*)/i,
|
|
366
|
+
),
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
name: "php",
|
|
370
|
+
symbol: "",
|
|
371
|
+
style: "147 bold",
|
|
372
|
+
priority: PRIORITY_COMMON,
|
|
373
|
+
detect: { files: ["composer.json"] },
|
|
374
|
+
version: async () =>
|
|
375
|
+
extractVersion(
|
|
376
|
+
await runVersion("php", ["--version"]),
|
|
377
|
+
/PHP\s+([0-9][^\s]*)/i,
|
|
378
|
+
),
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
name: "buf",
|
|
382
|
+
symbol: "",
|
|
383
|
+
style: "bold blue",
|
|
384
|
+
priority: PRIORITY_DEFAULT,
|
|
385
|
+
detect: { files: ["buf.yaml", "buf.gen.yaml", "buf.work.yaml"] },
|
|
386
|
+
version: versionFromCommands([{ command: "buf", args: ["--version"] }]),
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
name: "cmake",
|
|
390
|
+
symbol: "",
|
|
391
|
+
style: "bold blue",
|
|
392
|
+
priority: PRIORITY_DEFAULT,
|
|
393
|
+
detect: { files: ["CMakeLists.txt", "CMakeCache.txt"] },
|
|
394
|
+
version: versionFromCommands([{ command: "cmake", args: ["--version"] }]),
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
name: "cpp",
|
|
398
|
+
symbol: "",
|
|
399
|
+
style: "bold 149",
|
|
400
|
+
priority: PRIORITY_DEFAULT,
|
|
401
|
+
detect: {
|
|
402
|
+
extensions: ["cpp", "cc", "cxx", "c++", "hpp", "hh", "hxx", "h++", "tcc"],
|
|
403
|
+
},
|
|
404
|
+
version: versionFromCommands([
|
|
405
|
+
{ command: "c++", args: ["--version"] },
|
|
406
|
+
{ command: "g++", args: ["--version"] },
|
|
407
|
+
{ command: "clang++", args: ["--version"] },
|
|
408
|
+
]),
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
name: "c",
|
|
412
|
+
symbol: "",
|
|
413
|
+
style: "bold 149",
|
|
414
|
+
priority: PRIORITY_DEFAULT,
|
|
415
|
+
detect: { extensions: ["c", "h"] },
|
|
416
|
+
version: versionFromCommands([
|
|
417
|
+
{ command: "cc", args: ["--version"] },
|
|
418
|
+
{ command: "gcc", args: ["--version"] },
|
|
419
|
+
{ command: "clang", args: ["--version"] },
|
|
420
|
+
]),
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
name: "cobol",
|
|
424
|
+
symbol: "",
|
|
425
|
+
style: "bold blue",
|
|
426
|
+
priority: PRIORITY_DEFAULT,
|
|
427
|
+
detect: { extensions: ["cbl", "cob", "CBL", "COB"] },
|
|
428
|
+
version: versionFromCommands([{ command: "cobc", args: ["--version"] }]),
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
name: "conda",
|
|
432
|
+
symbol: "",
|
|
433
|
+
style: "bold green",
|
|
434
|
+
priority: PRIORITY_DEFAULT,
|
|
435
|
+
detect: {
|
|
436
|
+
env: (env) =>
|
|
437
|
+
Boolean(env.CONDA_DEFAULT_ENV?.trim()) && !env.PIXI_ENVIRONMENT_NAME,
|
|
438
|
+
},
|
|
439
|
+
version: noVersion,
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
name: "crystal",
|
|
443
|
+
symbol: "",
|
|
444
|
+
style: "bold red",
|
|
445
|
+
priority: PRIORITY_DEFAULT,
|
|
446
|
+
detect: { extensions: ["cr"], files: ["shard.yml"] },
|
|
447
|
+
version: versionFromCommands([{ command: "crystal", args: ["--version"] }]),
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
name: "dart",
|
|
451
|
+
symbol: "",
|
|
452
|
+
style: "bold blue",
|
|
453
|
+
priority: PRIORITY_DEFAULT,
|
|
454
|
+
detect: {
|
|
455
|
+
extensions: ["dart"],
|
|
456
|
+
files: ["pubspec.yaml", "pubspec.yml", "pubspec.lock"],
|
|
457
|
+
folders: [".dart_tool"],
|
|
458
|
+
},
|
|
459
|
+
version: versionFromCommands([{ command: "dart", args: ["--version"] }]),
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
name: "dotnet",
|
|
463
|
+
symbol: "",
|
|
464
|
+
style: "bold blue",
|
|
465
|
+
priority: PRIORITY_DEFAULT,
|
|
466
|
+
detect: {
|
|
467
|
+
extensions: ["csproj", "fsproj", "xproj"],
|
|
468
|
+
files: [
|
|
469
|
+
"global.json",
|
|
470
|
+
"project.json",
|
|
471
|
+
"Directory.Build.props",
|
|
472
|
+
"Directory.Build.targets",
|
|
473
|
+
"Packages.props",
|
|
474
|
+
],
|
|
475
|
+
},
|
|
476
|
+
version: versionFromCommands([{ command: "dotnet", args: ["--version"] }]),
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
name: "elixir",
|
|
480
|
+
symbol: "",
|
|
481
|
+
style: "bold purple",
|
|
482
|
+
priority: PRIORITY_DEFAULT,
|
|
483
|
+
detect: { files: ["mix.exs"] },
|
|
484
|
+
version: versionFromCommands([
|
|
485
|
+
{
|
|
486
|
+
command: "elixir",
|
|
487
|
+
args: ["--version"],
|
|
488
|
+
pattern: /Elixir\s+([0-9][^\s]*)/i,
|
|
489
|
+
},
|
|
490
|
+
]),
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
name: "elm",
|
|
494
|
+
symbol: "",
|
|
495
|
+
style: "cyan bold",
|
|
496
|
+
priority: PRIORITY_DEFAULT,
|
|
497
|
+
detect: {
|
|
498
|
+
extensions: ["elm"],
|
|
499
|
+
files: ["elm.json", "elm-package.json", ".elm-version"],
|
|
500
|
+
folders: ["elm-stuff"],
|
|
501
|
+
},
|
|
502
|
+
version: versionFromCommands([{ command: "elm", args: ["--version"] }]),
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
name: "erlang",
|
|
506
|
+
symbol: "",
|
|
507
|
+
style: "bold red",
|
|
508
|
+
priority: PRIORITY_DEFAULT,
|
|
509
|
+
detect: { files: ["rebar.config", "erlang.mk"] },
|
|
510
|
+
version: versionFromCommands([{ command: "erl", args: ["-version"] }]),
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
name: "fennel",
|
|
514
|
+
symbol: "",
|
|
515
|
+
style: "bold green",
|
|
516
|
+
priority: PRIORITY_DEFAULT,
|
|
517
|
+
detect: { extensions: ["fnl"] },
|
|
518
|
+
version: versionFromCommands([{ command: "fennel", args: ["--version"] }]),
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
name: "fortran",
|
|
522
|
+
symbol: "",
|
|
523
|
+
style: "bold purple",
|
|
524
|
+
priority: PRIORITY_DEFAULT,
|
|
525
|
+
detect: {
|
|
526
|
+
extensions: [
|
|
527
|
+
"f",
|
|
528
|
+
"F",
|
|
529
|
+
"for",
|
|
530
|
+
"FOR",
|
|
531
|
+
"ftn",
|
|
532
|
+
"FTN",
|
|
533
|
+
"f77",
|
|
534
|
+
"F77",
|
|
535
|
+
"f90",
|
|
536
|
+
"F90",
|
|
537
|
+
"f95",
|
|
538
|
+
"F95",
|
|
539
|
+
"f03",
|
|
540
|
+
"F03",
|
|
541
|
+
"f08",
|
|
542
|
+
"F08",
|
|
543
|
+
"f18",
|
|
544
|
+
"F18",
|
|
545
|
+
],
|
|
546
|
+
files: ["fpm.toml"],
|
|
547
|
+
},
|
|
548
|
+
version: versionFromCommands([
|
|
549
|
+
{ command: "gfortran", args: ["--version"] },
|
|
550
|
+
{ command: "flang", args: ["--version"] },
|
|
551
|
+
{ command: "flang-new", args: ["--version"] },
|
|
552
|
+
]),
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
name: "gleam",
|
|
556
|
+
symbol: "",
|
|
557
|
+
style: "bold #FFAFF3",
|
|
558
|
+
priority: PRIORITY_DEFAULT,
|
|
559
|
+
detect: { extensions: ["gleam"], files: ["gleam.toml"] },
|
|
560
|
+
version: versionFromCommands([{ command: "gleam", args: ["--version"] }]),
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
name: "guix_shell",
|
|
564
|
+
symbol: "",
|
|
565
|
+
style: "yellow bold",
|
|
566
|
+
priority: PRIORITY_DEFAULT,
|
|
567
|
+
detect: { env: (env) => Boolean(env.GUIX_ENVIRONMENT?.trim()) },
|
|
568
|
+
version: noVersion,
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
name: "haskell",
|
|
572
|
+
symbol: "",
|
|
573
|
+
style: "bold purple",
|
|
574
|
+
priority: PRIORITY_DEFAULT,
|
|
575
|
+
detect: {
|
|
576
|
+
extensions: ["hs", "cabal", "hs-boot"],
|
|
577
|
+
files: ["stack.yaml", "cabal.project"],
|
|
578
|
+
},
|
|
579
|
+
version: versionFromCommands([
|
|
580
|
+
{ command: "ghc", args: ["--numeric-version"] },
|
|
581
|
+
]),
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
name: "haxe",
|
|
585
|
+
symbol: "",
|
|
586
|
+
style: "bold fg:202",
|
|
587
|
+
priority: PRIORITY_DEFAULT,
|
|
588
|
+
detect: {
|
|
589
|
+
extensions: ["hx", "hxml"],
|
|
590
|
+
files: ["haxelib.json", "hxformat.json", ".haxerc"],
|
|
591
|
+
folders: [".haxelib", "haxe_libraries"],
|
|
592
|
+
},
|
|
593
|
+
version: versionFromCommands([{ command: "haxe", args: ["--version"] }]),
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
name: "helm",
|
|
597
|
+
symbol: "",
|
|
598
|
+
style: "bold white",
|
|
599
|
+
priority: PRIORITY_DEFAULT,
|
|
600
|
+
detect: { files: ["helmfile.yaml", "Chart.yaml"] },
|
|
601
|
+
version: versionFromCommands([
|
|
602
|
+
{ command: "helm", args: ["version", "--short"] },
|
|
603
|
+
]),
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
name: "julia",
|
|
607
|
+
symbol: "",
|
|
608
|
+
style: "bold purple",
|
|
609
|
+
priority: PRIORITY_DEFAULT,
|
|
610
|
+
detect: { extensions: ["jl"], files: ["Project.toml", "Manifest.toml"] },
|
|
611
|
+
version: versionFromCommands([{ command: "julia", args: ["--version"] }]),
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
name: "kotlin",
|
|
615
|
+
symbol: "",
|
|
616
|
+
style: "bold blue",
|
|
617
|
+
priority: PRIORITY_DEFAULT,
|
|
618
|
+
detect: { extensions: ["kt", "kts"] },
|
|
619
|
+
version: versionFromCommands([{ command: "kotlin", args: ["-version"] }]),
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
name: "meson",
|
|
623
|
+
symbol: "",
|
|
624
|
+
style: "blue bold",
|
|
625
|
+
priority: PRIORITY_DEFAULT,
|
|
626
|
+
detect: {
|
|
627
|
+
env: (env) =>
|
|
628
|
+
env.MESON_DEVENV === "1" && Boolean(env.MESON_PROJECT_NAME?.trim()),
|
|
629
|
+
},
|
|
630
|
+
version: noVersion,
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
name: "mojo",
|
|
634
|
+
symbol: "",
|
|
635
|
+
style: "bold 208",
|
|
636
|
+
priority: PRIORITY_DEFAULT,
|
|
637
|
+
detect: { extensions: ["mojo", "🔥"] },
|
|
638
|
+
version: versionFromCommands([{ command: "mojo", args: ["--version"] }]),
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
name: "nim",
|
|
642
|
+
symbol: "",
|
|
643
|
+
style: "bold yellow",
|
|
644
|
+
priority: PRIORITY_DEFAULT,
|
|
645
|
+
detect: { extensions: ["nim", "nims", "nimble"], files: ["nim.cfg"] },
|
|
646
|
+
version: versionFromCommands([{ command: "nim", args: ["--version"] }]),
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
name: "nix_shell",
|
|
650
|
+
symbol: "",
|
|
651
|
+
style: "bold blue",
|
|
652
|
+
priority: PRIORITY_DEFAULT,
|
|
653
|
+
detect: {
|
|
654
|
+
env: (env) =>
|
|
655
|
+
env.IN_NIX_SHELL === "pure" || env.IN_NIX_SHELL === "impure",
|
|
656
|
+
},
|
|
657
|
+
version: noVersion,
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
name: "ocaml",
|
|
661
|
+
symbol: "",
|
|
662
|
+
style: "bold yellow",
|
|
663
|
+
priority: PRIORITY_DEFAULT,
|
|
664
|
+
detect: {
|
|
665
|
+
extensions: ["opam", "ml", "mli", "re", "rei"],
|
|
666
|
+
files: ["dune", "dune-project", "jbuild", "jbuild-ignore", ".merlin"],
|
|
667
|
+
folders: ["_opam", "esy.lock"],
|
|
668
|
+
},
|
|
669
|
+
version: versionFromCommands([{ command: "ocaml", args: ["-version"] }]),
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
name: "odin",
|
|
673
|
+
symbol: "",
|
|
674
|
+
style: "bold bright-blue",
|
|
675
|
+
priority: PRIORITY_DEFAULT,
|
|
676
|
+
detect: { extensions: ["odin"] },
|
|
677
|
+
version: versionFromCommands([{ command: "odin", args: ["version"] }]),
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
name: "opa",
|
|
681
|
+
symbol: "",
|
|
682
|
+
style: "bold blue",
|
|
683
|
+
priority: PRIORITY_DEFAULT,
|
|
684
|
+
detect: { extensions: ["rego"] },
|
|
685
|
+
version: versionFromCommands([{ command: "opa", args: ["version"] }]),
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
name: "perl",
|
|
689
|
+
symbol: "",
|
|
690
|
+
style: "bold 149",
|
|
691
|
+
priority: PRIORITY_DEFAULT,
|
|
692
|
+
detect: {
|
|
693
|
+
extensions: ["pl", "pm", "pod"],
|
|
694
|
+
files: [
|
|
695
|
+
"Makefile.PL",
|
|
696
|
+
"Build.PL",
|
|
697
|
+
"cpanfile",
|
|
698
|
+
"cpanfile.snapshot",
|
|
699
|
+
"META.json",
|
|
700
|
+
"META.yml",
|
|
701
|
+
".perl-version",
|
|
702
|
+
],
|
|
703
|
+
},
|
|
704
|
+
version: versionFromCommands([{ command: "perl", args: ["--version"] }]),
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
name: "pixi",
|
|
708
|
+
symbol: "",
|
|
709
|
+
style: "yellow bold",
|
|
710
|
+
priority: PRIORITY_DEFAULT,
|
|
711
|
+
detect: {
|
|
712
|
+
files: ["pixi.toml", "pixi.lock"],
|
|
713
|
+
env: (env) => Boolean(env.PIXI_ENVIRONMENT_NAME?.trim()),
|
|
714
|
+
},
|
|
715
|
+
version: versionFromCommands([{ command: "pixi", args: ["--version"] }]),
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
name: "pulumi",
|
|
719
|
+
symbol: "",
|
|
720
|
+
style: "bold 5",
|
|
721
|
+
priority: PRIORITY_DEFAULT,
|
|
722
|
+
detect: { files: ["Pulumi.yaml", "Pulumi.yml"] },
|
|
723
|
+
version: versionFromCommands([{ command: "pulumi", args: ["version"] }]),
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
name: "purescript",
|
|
727
|
+
symbol: "",
|
|
728
|
+
style: "bold white",
|
|
729
|
+
priority: PRIORITY_DEFAULT,
|
|
730
|
+
detect: {
|
|
731
|
+
extensions: ["purs"],
|
|
732
|
+
files: ["spago.dhall", "spago.yaml", "spago.lock"],
|
|
733
|
+
},
|
|
734
|
+
version: versionFromCommands([{ command: "purs", args: ["--version"] }]),
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
name: "raku",
|
|
738
|
+
symbol: "",
|
|
739
|
+
style: "bold 149",
|
|
740
|
+
priority: PRIORITY_DEFAULT,
|
|
741
|
+
detect: {
|
|
742
|
+
extensions: ["p6", "pm6", "pod6", "raku", "rakumod"],
|
|
743
|
+
files: ["META6.json"],
|
|
744
|
+
},
|
|
745
|
+
version: versionFromCommands([{ command: "raku", args: ["--version"] }]),
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
name: "red",
|
|
749
|
+
symbol: "",
|
|
750
|
+
style: "red bold",
|
|
751
|
+
priority: PRIORITY_DEFAULT,
|
|
752
|
+
detect: { extensions: ["red", "reds"] },
|
|
753
|
+
version: versionFromCommands([{ command: "red", args: ["--version"] }]),
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
name: "rlang",
|
|
757
|
+
symbol: "",
|
|
758
|
+
style: "blue bold",
|
|
759
|
+
priority: PRIORITY_DEFAULT,
|
|
760
|
+
detect: {
|
|
761
|
+
extensions: ["R", "Rd", "Rmd", "Rproj", "Rsx"],
|
|
762
|
+
files: ["DESCRIPTION"],
|
|
763
|
+
folders: [".Rproj.user"],
|
|
764
|
+
},
|
|
765
|
+
version: versionFromCommands([{ command: "R", args: ["--version"] }]),
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
name: "scala",
|
|
769
|
+
symbol: "",
|
|
770
|
+
style: "red dimmed",
|
|
771
|
+
priority: PRIORITY_DEFAULT,
|
|
772
|
+
detect: {
|
|
773
|
+
extensions: ["sbt", "scala"],
|
|
774
|
+
files: [".scalaenv", ".sbtenv", "build.sbt"],
|
|
775
|
+
folders: [".metals"],
|
|
776
|
+
},
|
|
777
|
+
version: versionFromCommands([{ command: "scala", args: ["-version"] }]),
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
name: "solidity",
|
|
781
|
+
symbol: "",
|
|
782
|
+
style: "bold blue",
|
|
783
|
+
priority: PRIORITY_DEFAULT,
|
|
784
|
+
detect: { extensions: ["sol"] },
|
|
785
|
+
version: versionFromCommands([{ command: "solc", args: ["--version"] }]),
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
name: "spack",
|
|
789
|
+
symbol: "",
|
|
790
|
+
style: "bold blue",
|
|
791
|
+
priority: PRIORITY_DEFAULT,
|
|
792
|
+
detect: { env: (env) => Boolean(env.SPACK_ENV?.trim()) },
|
|
793
|
+
version: noVersion,
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
name: "swift",
|
|
797
|
+
symbol: "",
|
|
798
|
+
style: "bold 202",
|
|
799
|
+
priority: PRIORITY_DEFAULT,
|
|
800
|
+
detect: { extensions: ["swift"], files: ["Package.swift"] },
|
|
801
|
+
version: versionFromCommands([
|
|
802
|
+
{
|
|
803
|
+
command: "swift",
|
|
804
|
+
args: ["--version"],
|
|
805
|
+
pattern: /Swift version\s+([0-9][^\s]*)/i,
|
|
806
|
+
},
|
|
807
|
+
]),
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
name: "terraform",
|
|
811
|
+
symbol: "",
|
|
812
|
+
style: "bold 105",
|
|
813
|
+
priority: PRIORITY_DEFAULT,
|
|
814
|
+
detect: {
|
|
815
|
+
extensions: ["tf", "tfplan", "tfstate"],
|
|
816
|
+
folders: [".terraform"],
|
|
817
|
+
},
|
|
818
|
+
version: versionFromCommands([
|
|
819
|
+
{ command: "terraform", args: ["version"] },
|
|
820
|
+
{ command: "tofu", args: ["version"] },
|
|
821
|
+
]),
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
name: "typst",
|
|
825
|
+
symbol: "",
|
|
826
|
+
style: "bold #0093A7",
|
|
827
|
+
priority: PRIORITY_DEFAULT,
|
|
828
|
+
detect: { extensions: ["typ"], files: ["template.typ"] },
|
|
829
|
+
version: versionFromCommands([{ command: "typst", args: ["--version"] }]),
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
name: "vagrant",
|
|
833
|
+
symbol: "",
|
|
834
|
+
style: "cyan bold",
|
|
835
|
+
priority: PRIORITY_DEFAULT,
|
|
836
|
+
detect: { files: ["Vagrantfile"] },
|
|
837
|
+
version: versionFromCommands([{ command: "vagrant", args: ["--version"] }]),
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
name: "vlang",
|
|
841
|
+
symbol: "",
|
|
842
|
+
style: "blue bold",
|
|
843
|
+
priority: PRIORITY_DEFAULT,
|
|
844
|
+
detect: {
|
|
845
|
+
extensions: ["v"],
|
|
846
|
+
files: ["v.mod", "vpkg.json", ".vpkg-lock.json"],
|
|
847
|
+
},
|
|
848
|
+
version: versionFromCommands([{ command: "v", args: ["version"] }]),
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
name: "zig",
|
|
852
|
+
symbol: "",
|
|
853
|
+
style: "bold yellow",
|
|
854
|
+
priority: PRIORITY_DEFAULT,
|
|
855
|
+
detect: { extensions: ["zig"], files: ["build.zig"] },
|
|
856
|
+
version: versionFromCommands([{ command: "zig", args: ["version"] }]),
|
|
857
|
+
},
|
|
858
|
+
];
|
|
859
|
+
|
|
860
|
+
// Sort once at module load — stable sort preserves definition order within same priority
|
|
861
|
+
const sortedRuntimes = [...runtimes].sort((a, b) => a.priority - b.priority);
|
|
862
|
+
|
|
863
|
+
export const runtimeMetadata: RuntimeMetadata[] = runtimes.map(
|
|
864
|
+
({ name, symbol, style }) => ({
|
|
865
|
+
name,
|
|
866
|
+
symbol,
|
|
867
|
+
style,
|
|
868
|
+
}),
|
|
869
|
+
);
|
|
870
|
+
|
|
871
|
+
export function detectRuntime(
|
|
872
|
+
cwd: string,
|
|
873
|
+
entries: string[],
|
|
874
|
+
env: RuntimeEnvironment = process.env,
|
|
875
|
+
): RuntimeDef | undefined {
|
|
876
|
+
for (const runtime of sortedRuntimes) {
|
|
877
|
+
if (matchesDetection(cwd, entries, runtime.detect, env)) return runtime;
|
|
878
|
+
}
|
|
879
|
+
return undefined;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
export async function readRuntimeInfo(cwd: string): Promise<RuntimeReadResult> {
|
|
883
|
+
let entries: string[];
|
|
884
|
+
try {
|
|
885
|
+
entries = readdirSync(cwd);
|
|
886
|
+
} catch {
|
|
887
|
+
// readdir failure is treated as a transient error so last-good can be kept.
|
|
888
|
+
return { kind: "error" };
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
const fingerprint = topLevelFingerprint(entries);
|
|
892
|
+
const cacheKey = `${cwd}\0${fingerprint}`;
|
|
893
|
+
const cached = runtimeInfoCache.get(cacheKey);
|
|
894
|
+
if (cached && cached.fingerprint === fingerprint) {
|
|
895
|
+
return { kind: "ok", runtime: cached.runtime };
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
try {
|
|
899
|
+
const runtime = detectRuntime(cwd, entries);
|
|
900
|
+
if (!runtime) {
|
|
901
|
+
cacheRuntimeInfo(cwd, fingerprint, undefined);
|
|
902
|
+
return { kind: "ok", runtime: undefined };
|
|
903
|
+
}
|
|
904
|
+
const info: RuntimeInfo = {
|
|
905
|
+
name: runtime.name,
|
|
906
|
+
symbol: runtime.symbol,
|
|
907
|
+
style: runtime.style,
|
|
908
|
+
version: await runtime.version(cwd),
|
|
909
|
+
};
|
|
910
|
+
cacheRuntimeInfo(cwd, fingerprint, info);
|
|
911
|
+
return { kind: "ok", runtime: info };
|
|
912
|
+
} catch {
|
|
913
|
+
return { kind: "error" };
|
|
914
|
+
}
|
|
915
|
+
}
|