@narumitw/pi-starship 0.60.1 → 0.63.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 +67 -9
- package/dist/chunks/chunk-63R6R5DH.ts +679 -0
- package/dist/chunks/chunk-63R6R5DH.ts.map +7 -0
- package/dist/chunks/{chunk-KZZKGGFW.ts → chunk-A65IOGL6.ts} +858 -1007
- package/dist/chunks/chunk-A65IOGL6.ts.map +7 -0
- package/dist/chunks/chunk-IYDZ3R2T.ts +69 -0
- package/dist/chunks/chunk-IYDZ3R2T.ts.map +7 -0
- package/dist/chunks/chunk-KP33I6BR.ts +579 -0
- package/dist/chunks/chunk-KP33I6BR.ts.map +7 -0
- package/dist/chunks/{chunk-PD457PX5.ts → chunk-S2KBLHE2.ts} +75 -10
- package/dist/chunks/chunk-S2KBLHE2.ts.map +7 -0
- package/dist/chunks/chunk-XQUIQO2G.ts +20 -0
- package/dist/chunks/chunk-XQUIQO2G.ts.map +7 -0
- package/dist/chunks/{chunk-ADX4CY27.ts → chunk-XTLQ4WUL.ts} +1 -1
- package/dist/chunks/chunk-XTLQ4WUL.ts.map +7 -0
- package/dist/chunks/chunk-Y24TJYG6.ts +1586 -0
- package/dist/chunks/chunk-Y24TJYG6.ts.map +7 -0
- package/dist/chunks/{cloud-EPAEV4ZB.ts → cloud-J2ZOE3HE.ts} +6 -2
- package/dist/chunks/cloud-J2ZOE3HE.ts.map +7 -0
- package/dist/chunks/command-configuration-menu-YOLN2SPR.ts +147 -0
- package/dist/chunks/command-configuration-menu-YOLN2SPR.ts.map +7 -0
- package/dist/chunks/command-settings-chat-5AHP3JGV.ts +1124 -0
- package/dist/chunks/command-settings-chat-5AHP3JGV.ts.map +7 -0
- package/dist/chunks/commands-IOG2PL67.ts +1026 -0
- package/dist/chunks/commands-IOG2PL67.ts.map +7 -0
- package/dist/chunks/{deployment-7J54EHNR.ts → deployment-NOJ2KCLI.ts} +85 -5
- package/dist/chunks/deployment-NOJ2KCLI.ts.map +7 -0
- package/dist/chunks/{development-IWJAAAEV.ts → development-T3XXVVDP.ts} +67 -15
- package/dist/chunks/development-T3XXVVDP.ts.map +7 -0
- package/dist/chunks/directory-OX6BWJZA.ts +31 -0
- package/dist/chunks/directory-OX6BWJZA.ts.map +7 -0
- package/dist/chunks/{execution-P4WZALW2.ts → execution-R2OHIP2L.ts} +8 -4
- package/dist/chunks/execution-R2OHIP2L.ts.map +7 -0
- package/dist/chunks/jujutsu-XLDYKSX2.ts +174 -0
- package/dist/chunks/jujutsu-XLDYKSX2.ts.map +7 -0
- package/dist/chunks/languages-CBQNNYXM.ts +262 -0
- package/dist/chunks/languages-CBQNNYXM.ts.map +7 -0
- package/dist/chunks/{package-H24VJEX3.ts → package-7KVAK3TC.ts} +6 -2
- package/dist/chunks/package-7KVAK3TC.ts.map +7 -0
- package/dist/chunks/system-574MHB4R.ts +165 -0
- package/dist/chunks/system-574MHB4R.ts.map +7 -0
- package/dist/index.ts +670 -206
- package/dist/index.ts.map +4 -4
- package/package.json +5 -1
- package/skills/configure-pi-starship/SKILL.md +17 -1
- package/skills/configure-pi-starship/references/configuration.md +119 -32
- package/skills/configure-pi-starship/references/module-catalog.md +278 -25
- package/skills/configure-pi-starship/references/modules.md +213 -36
- package/skills/configure-pi-starship/references/runtime-and-security.md +88 -28
- package/src/command-commit.ts +41 -7
- package/src/command-configuration-menu.ts +155 -0
- package/src/command-configuration.ts +15 -94
- package/src/command-preview.ts +3 -3
- package/src/command-settings-chat.ts +168 -0
- package/src/commands.ts +76 -124
- package/src/config/module-options.ts +112 -0
- package/src/config.ts +23 -59
- package/src/effective-config.ts +5 -4
- package/src/format/bounded-regex.ts +66 -0
- package/src/format/version.ts +24 -0
- package/src/modules/catalog.ts +10 -0
- package/src/modules/cloud.ts +1 -0
- package/src/modules/deployment.ts +8 -0
- package/src/modules/development.ts +20 -2
- package/src/modules/directory.ts +171 -51
- package/src/modules/execution.ts +2 -0
- package/src/modules/git/branch.ts +19 -4
- package/src/modules/git/commit.ts +9 -2
- package/src/modules/git/metrics.ts +9 -4
- package/src/modules/git/runtime.ts +122 -33
- package/src/modules/git/state.ts +23 -2
- package/src/modules/git/status-templates.ts +58 -0
- package/src/modules/git/status.ts +96 -30
- package/src/modules/jujutsu.ts +225 -0
- package/src/modules/languages.ts +26 -2
- package/src/modules/package.ts +1 -0
- package/src/modules/render.ts +42 -16
- package/src/modules/system.ts +54 -0
- package/src/modules/time-format.ts +188 -0
- package/src/modules/time.ts +11 -5
- package/src/modules/types.ts +42 -4
- package/src/pi-starship.ts +198 -88
- package/src/profile-store.ts +5 -0
- package/src/runtime/cloud.ts +3 -0
- package/src/runtime/command.ts +1 -1
- package/src/runtime/deployment.ts +120 -4
- package/src/runtime/development.ts +86 -13
- package/src/runtime/directory.ts +33 -0
- package/src/runtime/execution.ts +12 -2
- package/src/runtime/helpers.ts +57 -8
- package/src/runtime/jujutsu.ts +225 -0
- package/src/runtime/languages.ts +106 -19
- package/src/runtime/package.ts +3 -0
- package/src/runtime/system.ts +202 -0
- package/src/runtime/types.ts +3 -0
- package/src/runtime/version-requirements.ts +30 -0
- package/src/runtime/workspace.ts +12 -1
- package/src/settings-agent.ts +80 -0
- package/src/settings-chat-transcript.ts +192 -0
- package/src/settings-chat-ui.ts +526 -0
- package/src/settings-draft.ts +260 -0
- package/src/settings-snapshots.ts +41 -0
- package/dist/chunks/chunk-ADX4CY27.ts.map +0 -7
- package/dist/chunks/chunk-KZZKGGFW.ts.map +0 -7
- package/dist/chunks/chunk-PD457PX5.ts.map +0 -7
- package/dist/chunks/cloud-EPAEV4ZB.ts.map +0 -7
- package/dist/chunks/commands-C2VJ6ZBN.ts +0 -3374
- package/dist/chunks/commands-C2VJ6ZBN.ts.map +0 -7
- package/dist/chunks/deployment-7J54EHNR.ts.map +0 -7
- package/dist/chunks/development-IWJAAAEV.ts.map +0 -7
- package/dist/chunks/execution-P4WZALW2.ts.map +0 -7
- package/dist/chunks/languages-JO6R2PHL.ts +0 -168
- package/dist/chunks/languages-JO6R2PHL.ts.map +0 -7
- package/dist/chunks/package-H24VJEX3.ts.map +0 -7
- package/src/command-inspector.ts +0 -41
package/dist/index.ts
CHANGED
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
2
|
// @ts-nocheck -- the generated entry uses a .ts extension for Pi's Jiti loader.
|
|
3
|
+
import {
|
|
4
|
+
completeStarshipArguments
|
|
5
|
+
} from "./chunks/chunk-XQUIQO2G.ts";
|
|
6
|
+
import {
|
|
7
|
+
MODULE_DEFINITIONS,
|
|
8
|
+
MODULE_NAMES,
|
|
9
|
+
activePalette,
|
|
10
|
+
directoryAlternateFormat,
|
|
11
|
+
loadStarshipConfig,
|
|
12
|
+
settingsFilePath
|
|
13
|
+
} from "./chunks/chunk-A65IOGL6.ts";
|
|
14
|
+
import "./chunks/chunk-IYDZ3R2T.ts";
|
|
3
15
|
import {
|
|
4
16
|
PRIVATE_STYLE_SELECTOR
|
|
5
|
-
} from "./chunks/chunk-
|
|
17
|
+
} from "./chunks/chunk-XTLQ4WUL.ts";
|
|
6
18
|
import {
|
|
19
|
+
MAX_COMMAND_OUTPUT_BYTES,
|
|
7
20
|
createFileSystem
|
|
8
|
-
} from "./chunks/chunk-
|
|
21
|
+
} from "./chunks/chunk-S2KBLHE2.ts";
|
|
9
22
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} from "./chunks/chunk-
|
|
23
|
+
formatVariables,
|
|
24
|
+
isFillChunk,
|
|
25
|
+
parseFormat,
|
|
26
|
+
renderChunksToAnsi,
|
|
27
|
+
renderFormat,
|
|
28
|
+
sanitizeFormatText
|
|
29
|
+
} from "./chunks/chunk-KP33I6BR.ts";
|
|
17
30
|
|
|
18
31
|
// src/pi-starship.ts
|
|
19
32
|
import { homedir, hostname, userInfo } from "node:os";
|
|
@@ -25,35 +38,157 @@ import { getCapabilities as getCapabilities2, wrapTextWithAnsi } from "@earendil
|
|
|
25
38
|
// src/modules/git/runtime.ts
|
|
26
39
|
import { existsSync, readFileSync } from "node:fs";
|
|
27
40
|
import { basename, isAbsolute, join, resolve } from "node:path";
|
|
41
|
+
|
|
42
|
+
// src/runtime/command.ts
|
|
43
|
+
import { spawn } from "node:child_process";
|
|
44
|
+
var FORCE_KILL_DELAY_MS = 250;
|
|
45
|
+
var execWorkspaceCommand = async (command, args, options) => new Promise((resolve2) => {
|
|
46
|
+
if (options.signal?.aborted) {
|
|
47
|
+
resolve2({ stdout: "", stderr: "", code: 1, killed: true });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
let child;
|
|
51
|
+
try {
|
|
52
|
+
child = spawn(command, args, {
|
|
53
|
+
cwd: options.cwd,
|
|
54
|
+
detached: process.platform !== "win32",
|
|
55
|
+
env: explicitEnvironment(options.environment),
|
|
56
|
+
shell: false,
|
|
57
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
58
|
+
windowsHide: true
|
|
59
|
+
});
|
|
60
|
+
} catch {
|
|
61
|
+
resolve2({ stdout: "", stderr: "", code: 1, killed: false });
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const stdout = [];
|
|
65
|
+
const stderr = [];
|
|
66
|
+
let outputBytes = 0;
|
|
67
|
+
let killed = false;
|
|
68
|
+
let settled = false;
|
|
69
|
+
let forceKillTimer;
|
|
70
|
+
let timeoutTimer;
|
|
71
|
+
const finish = (code) => {
|
|
72
|
+
if (settled) return;
|
|
73
|
+
settled = true;
|
|
74
|
+
if (timeoutTimer) clearTimeout(timeoutTimer);
|
|
75
|
+
if (forceKillTimer) clearTimeout(forceKillTimer);
|
|
76
|
+
options.signal?.removeEventListener("abort", terminate);
|
|
77
|
+
resolve2({
|
|
78
|
+
stdout: Buffer.concat(stdout).toString("utf8"),
|
|
79
|
+
stderr: Buffer.concat(stderr).toString("utf8"),
|
|
80
|
+
code,
|
|
81
|
+
killed
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const signalProcessTree = (signal) => {
|
|
85
|
+
const pid = child.pid;
|
|
86
|
+
if (pid === void 0) return;
|
|
87
|
+
if (process.platform !== "win32") {
|
|
88
|
+
try {
|
|
89
|
+
process.kill(-pid, signal);
|
|
90
|
+
return;
|
|
91
|
+
} catch {
|
|
92
|
+
child.kill(signal);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
const killer = spawn("taskkill.exe", ["/pid", String(pid), "/t", "/f"], {
|
|
98
|
+
stdio: "ignore",
|
|
99
|
+
windowsHide: true
|
|
100
|
+
});
|
|
101
|
+
killer.once("error", () => child.kill(signal));
|
|
102
|
+
killer.unref();
|
|
103
|
+
} catch {
|
|
104
|
+
child.kill(signal);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
function terminate() {
|
|
108
|
+
if (killed || settled) return;
|
|
109
|
+
killed = true;
|
|
110
|
+
signalProcessTree("SIGTERM");
|
|
111
|
+
forceKillTimer = setTimeout(() => {
|
|
112
|
+
signalProcessTree("SIGKILL");
|
|
113
|
+
child.stdout?.destroy();
|
|
114
|
+
child.stderr?.destroy();
|
|
115
|
+
finish(1);
|
|
116
|
+
}, FORCE_KILL_DELAY_MS);
|
|
117
|
+
}
|
|
118
|
+
const collect = (target) => (data) => {
|
|
119
|
+
const chunk = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
120
|
+
const remaining = Math.max(0, options.maxOutputBytes - outputBytes);
|
|
121
|
+
if (remaining > 0) target.push(chunk.subarray(0, remaining));
|
|
122
|
+
outputBytes += chunk.byteLength;
|
|
123
|
+
if (outputBytes > options.maxOutputBytes) terminate();
|
|
124
|
+
};
|
|
125
|
+
child.stdout?.on("data", collect(stdout));
|
|
126
|
+
child.stderr?.on("data", collect(stderr));
|
|
127
|
+
child.once("error", () => {
|
|
128
|
+
if (!killed) finish(1);
|
|
129
|
+
});
|
|
130
|
+
child.once("close", (code) => {
|
|
131
|
+
if (!killed) finish(code ?? 1);
|
|
132
|
+
});
|
|
133
|
+
options.signal?.addEventListener("abort", terminate, { once: true });
|
|
134
|
+
if (options.signal?.aborted) terminate();
|
|
135
|
+
timeoutTimer = setTimeout(terminate, options.timeout);
|
|
136
|
+
});
|
|
137
|
+
function explicitEnvironment(source) {
|
|
138
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
139
|
+
for (const [name, value] of Object.entries(source)) {
|
|
140
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(name) || typeof value !== "string" || value.includes("\0")) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
Object.defineProperty(result, name, {
|
|
144
|
+
value,
|
|
145
|
+
writable: true,
|
|
146
|
+
enumerable: true,
|
|
147
|
+
configurable: true
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// src/modules/git/runtime.ts
|
|
28
154
|
var GIT_TIMEOUT_MS = 3e3;
|
|
29
155
|
async function readGitSnapshot(pi, cwd, options) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
156
|
+
if (options.signal?.aborted) return void 0;
|
|
157
|
+
const run = (args) => runGit(pi, cwd, args, options);
|
|
158
|
+
const statusArgs = [
|
|
159
|
+
"--no-optional-locks",
|
|
160
|
+
"status",
|
|
161
|
+
"--porcelain=v2",
|
|
162
|
+
"--branch",
|
|
163
|
+
"--show-stash",
|
|
164
|
+
"--untracked-files=normal"
|
|
165
|
+
];
|
|
166
|
+
if (options.statusIgnoreSubmodules) statusArgs.push("--ignore-submodules=dirty");
|
|
167
|
+
const statusPromise = run(statusArgs);
|
|
168
|
+
const metadataPromise = run([
|
|
169
|
+
"rev-parse",
|
|
170
|
+
"--path-format=absolute",
|
|
171
|
+
"--show-toplevel",
|
|
172
|
+
"--git-common-dir",
|
|
173
|
+
"--git-dir"
|
|
174
|
+
]);
|
|
175
|
+
const metricsArgs = ["--no-optional-locks", "diff", "--shortstat"];
|
|
176
|
+
if (options.metricsIgnoreSubmodules) metricsArgs.push("--ignore-submodules=all", "--no-ext-diff", "--no-textconv");
|
|
177
|
+
metricsArgs.push("HEAD", "--");
|
|
178
|
+
const metricsPromise = options.includeMetrics ? run(metricsArgs) : Promise.resolve(void 0);
|
|
179
|
+
const candidates = options.tagMaxCandidates;
|
|
180
|
+
const tagArgs = Number.isSafeInteger(candidates) && (candidates ?? 0) > 0 && (candidates ?? 0) <= 100 ? ["describe", "--tags", "--first-parent", "--abbrev=0", `--candidates=${candidates}`, "HEAD"] : ["describe", "--tags", "--exact-match", "HEAD"];
|
|
181
|
+
const tagPromise = options.includeTag ? run(tagArgs) : Promise.resolve(void 0);
|
|
50
182
|
const [statusResult, metadataResult, metricsResult, tagResult] = await Promise.all([
|
|
51
183
|
statusPromise,
|
|
52
184
|
metadataPromise,
|
|
53
185
|
metricsPromise,
|
|
54
186
|
tagPromise
|
|
55
187
|
]);
|
|
56
|
-
if (
|
|
188
|
+
if (options.signal?.aborted || statusResult.killed) return void 0;
|
|
189
|
+
if (statusResult.code !== 0) {
|
|
190
|
+
return options.inspectBare ? readBareSnapshot(pi, cwd, options, tagResult) : void 0;
|
|
191
|
+
}
|
|
57
192
|
const parsed = parseGitStatusPorcelainV2(statusResult.stdout);
|
|
58
193
|
const metadata = metadataResult.code === 0 && !metadataResult.killed ? parseGitRepositoryMetadata(metadataResult.stdout) : void 0;
|
|
59
194
|
const commit = withTag(parsed.commit, tagResult);
|
|
@@ -67,6 +202,52 @@ async function readGitSnapshot(pi, cwd, options) {
|
|
|
67
202
|
worktree: metadata?.worktree
|
|
68
203
|
};
|
|
69
204
|
}
|
|
205
|
+
async function runGit(pi, cwd, args, options) {
|
|
206
|
+
const failed = { stdout: "", stderr: "", code: 1, killed: options.signal?.aborted ?? false };
|
|
207
|
+
if (options.signal?.aborted) return failed;
|
|
208
|
+
try {
|
|
209
|
+
const result = options.exec ? await options.exec("git", args, {
|
|
210
|
+
cwd,
|
|
211
|
+
timeout: GIT_TIMEOUT_MS,
|
|
212
|
+
maxOutputBytes: MAX_COMMAND_OUTPUT_BYTES,
|
|
213
|
+
signal: options.signal,
|
|
214
|
+
environment: process.env
|
|
215
|
+
}) : await pi.exec("git", args, { cwd, signal: options.signal, timeout: GIT_TIMEOUT_MS });
|
|
216
|
+
if (options.signal?.aborted) return { ...failed, killed: true };
|
|
217
|
+
if (Buffer.byteLength(result.stdout) + Buffer.byteLength(result.stderr) > MAX_COMMAND_OUTPUT_BYTES) {
|
|
218
|
+
return { ...failed, killed: true };
|
|
219
|
+
}
|
|
220
|
+
return result;
|
|
221
|
+
} catch {
|
|
222
|
+
return failed;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
async function readBareSnapshot(pi, cwd, options, tagResult) {
|
|
226
|
+
const boundedOptions = { ...options, exec: options.exec ?? execWorkspaceCommand };
|
|
227
|
+
const run = (args) => runGit(pi, cwd, args, boundedOptions);
|
|
228
|
+
const bare = await run(["rev-parse", "--is-bare-repository"]);
|
|
229
|
+
if (options.signal?.aborted || bare.killed || bare.code !== 0 || bare.stdout.trim() !== "true") return void 0;
|
|
230
|
+
const [head, hash] = await Promise.all([
|
|
231
|
+
run(["symbolic-ref", "--short", "HEAD"]),
|
|
232
|
+
run(["rev-parse", "--verify", "HEAD"])
|
|
233
|
+
]);
|
|
234
|
+
if (options.signal?.aborted || head.killed || hash.killed) return void 0;
|
|
235
|
+
const name = head.code === 0 ? head.stdout.trim() : "";
|
|
236
|
+
const commitHash = hash.code === 0 ? hash.stdout.trim() : "";
|
|
237
|
+
const validHash = /^[a-fA-F0-9]{4,64}$/u.test(commitHash);
|
|
238
|
+
if (!name && !validHash) return void 0;
|
|
239
|
+
const detached = name === "";
|
|
240
|
+
const reference = `refs/heads/${name}`;
|
|
241
|
+
const upstreamResult = name ? await run(["for-each-ref", "--count=1", "--format=%(refname)%00%(upstream:short)", reference]) : void 0;
|
|
242
|
+
if (options.signal?.aborted) return void 0;
|
|
243
|
+
const upstreamFields = upstreamResult?.code === 0 && !upstreamResult.killed ? upstreamResult.stdout.trimEnd().split("\0") : [];
|
|
244
|
+
const remote = upstreamFields[0] === reference ? splitUpstream(upstreamFields[1]) : {};
|
|
245
|
+
return {
|
|
246
|
+
branch: { name: name || "HEAD", detached, bare: true, ...remote },
|
|
247
|
+
commit: validHash ? withTag({ hash: commitHash, detached }, tagResult) : void 0,
|
|
248
|
+
status: emptyGitStatus()
|
|
249
|
+
};
|
|
250
|
+
}
|
|
70
251
|
function parseGitStatusPorcelainV2(output) {
|
|
71
252
|
const status = emptyGitStatus();
|
|
72
253
|
let branchName;
|
|
@@ -89,8 +270,13 @@ function parseGitStatusPorcelainV2(output) {
|
|
|
89
270
|
}
|
|
90
271
|
if (line.startsWith("# branch.ab ")) {
|
|
91
272
|
const match = /^# branch\.ab \+(\d+) -(\d+)$/u.exec(line);
|
|
92
|
-
|
|
93
|
-
|
|
273
|
+
const ahead = Number(match?.[1]);
|
|
274
|
+
const behind = Number(match?.[2]);
|
|
275
|
+
const valid = Number.isSafeInteger(ahead) && Number.isSafeInteger(behind);
|
|
276
|
+
status.ahead = valid ? ahead : 0;
|
|
277
|
+
status.behind = valid ? behind : 0;
|
|
278
|
+
if (valid && ahead === 0 && behind === 0) status.upToDate = true;
|
|
279
|
+
else delete status.upToDate;
|
|
94
280
|
continue;
|
|
95
281
|
}
|
|
96
282
|
if (line.startsWith("# stash ")) {
|
|
@@ -249,117 +435,301 @@ function gitSnapshotEqual(left, right) {
|
|
|
249
435
|
return JSON.stringify(left) === JSON.stringify(right);
|
|
250
436
|
}
|
|
251
437
|
|
|
252
|
-
// src/
|
|
253
|
-
import {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
438
|
+
// src/modules/inspection.ts
|
|
439
|
+
import { stripVTControlCharacters } from "node:util";
|
|
440
|
+
|
|
441
|
+
// src/modules/render.ts
|
|
442
|
+
import { visibleWidth } from "@earendil-works/pi-tui";
|
|
443
|
+
import { sanitizeTerminalText } from "@narumitw/pi-tui-kit/terminal-text";
|
|
444
|
+
|
|
445
|
+
// src/modules/style-rules.ts
|
|
446
|
+
function resolveStyleRule(rules, selectors, context) {
|
|
447
|
+
for (const rule of rules) {
|
|
448
|
+
let matches = true;
|
|
449
|
+
for (const name in rule.selectors) {
|
|
450
|
+
if (!Object.hasOwn(rule.selectors, name)) continue;
|
|
451
|
+
const selector = Object.hasOwn(selectors, name) ? selectors[name] : void 0;
|
|
452
|
+
if (!selector || selector(context) !== rule.selectors[name]) {
|
|
453
|
+
matches = false;
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
if (matches) return rule.style;
|
|
259
458
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
resolve2({ stdout: "", stderr: "", code: 1, killed: false });
|
|
272
|
-
return;
|
|
459
|
+
return void 0;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// src/modules/render.ts
|
|
463
|
+
function renderStatusline(config, runtime, width = 80, trueColor = true, themeColors) {
|
|
464
|
+
const palette = activePalette(config);
|
|
465
|
+
const modules = {};
|
|
466
|
+
const layoutModules = {};
|
|
467
|
+
for (const name of MODULE_NAMES) {
|
|
468
|
+
modules[name] = [];
|
|
469
|
+
layoutModules[name] = [];
|
|
273
470
|
}
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
471
|
+
for (const definition of MODULE_DEFINITIONS) {
|
|
472
|
+
const name = definition.name;
|
|
473
|
+
const module = config.modules[name];
|
|
474
|
+
const context = valueContext(config, name, runtime, palette);
|
|
475
|
+
const values = definition.values(context);
|
|
476
|
+
if (!values) continue;
|
|
477
|
+
const styleContext = {
|
|
478
|
+
runtime,
|
|
479
|
+
style: module.style,
|
|
480
|
+
styles: module.styles,
|
|
481
|
+
display: module.display,
|
|
482
|
+
options: context.options
|
|
483
|
+
};
|
|
484
|
+
const baseStyleVariables = definition.resolveStyleVariables ? definition.resolveStyleVariables(styleContext) : { style: module.style };
|
|
485
|
+
if (!baseStyleVariables) continue;
|
|
486
|
+
const ruleStyle = definition.styleRuleSelectors ? resolveStyleRule(module.styleRules, definition.styleRuleSelectors, styleContext) : void 0;
|
|
487
|
+
const styleVariables = ruleStyle === void 0 ? baseStyleVariables : { ...baseStyleVariables, style: ruleStyle };
|
|
488
|
+
const contentValues = Object.fromEntries(
|
|
489
|
+
definition.variables.flatMap(
|
|
490
|
+
(variable) => Object.hasOwn(values, variable) ? [[variable, values[variable]]] : []
|
|
491
|
+
)
|
|
492
|
+
);
|
|
493
|
+
const alternate = definition.resolveFormat?.(context, values);
|
|
494
|
+
const rendered = renderModule(
|
|
495
|
+
alternate === void 0 ? module : { ...module, formatAst: parseFormat(alternate) },
|
|
496
|
+
contentValues,
|
|
497
|
+
styleVariables,
|
|
498
|
+
palette
|
|
499
|
+
);
|
|
500
|
+
modules[name] = rendered;
|
|
501
|
+
layoutModules[name] = definition.layout === "fill" && !module.disabled ? [{ type: "fill", pattern: rendered }] : rendered;
|
|
502
|
+
}
|
|
503
|
+
const explicitModules = formatVariables(config.formatAst);
|
|
504
|
+
const all = MODULE_NAMES.flatMap(
|
|
505
|
+
(name) => explicitModules.has(name) || config.modules[name].disabled ? [] : layoutModules[name]
|
|
506
|
+
);
|
|
507
|
+
const rootVariables = { all };
|
|
508
|
+
for (const name of MODULE_NAMES) rootVariables[name] = layoutModules[name];
|
|
509
|
+
const layout = renderFormat(config.formatAst, { variables: rootVariables, palette });
|
|
510
|
+
const chunks = resolveFillLayout(layout, width);
|
|
511
|
+
return {
|
|
512
|
+
ansi: renderChunksToAnsi(chunks, trueColor, themeColors),
|
|
513
|
+
chunks,
|
|
514
|
+
modules
|
|
293
515
|
};
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
516
|
+
}
|
|
517
|
+
function valueContext(config, name, runtime, palette) {
|
|
518
|
+
return {
|
|
519
|
+
runtime: runtimeForDisplay(name, runtime),
|
|
520
|
+
palette,
|
|
521
|
+
symbol: sanitizeFormatText(config.modules[name].symbol),
|
|
522
|
+
styles: config.modules[name].styles,
|
|
523
|
+
requestedVariables: formatVariables(config.modules[name].formatAst),
|
|
524
|
+
options: Object.fromEntries(
|
|
525
|
+
Object.entries(config.modules[name].options).map(([key, value]) => [key, sanitizeOption(value)])
|
|
526
|
+
),
|
|
527
|
+
extensionStatus: {
|
|
528
|
+
...config.extensionStatus,
|
|
529
|
+
separator: sanitizeFormatText(config.extensionStatus.separator),
|
|
530
|
+
icons: Object.fromEntries(
|
|
531
|
+
Object.entries(config.extensionStatus.icons).map(([key, value]) => [key, sanitizeFormatText(value)])
|
|
532
|
+
)
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
function sanitizeOption(value) {
|
|
537
|
+
if (typeof value === "string") return sanitizeTerminalText(value);
|
|
538
|
+
if (Array.isArray(value)) return value.map((item) => sanitizeOption(item));
|
|
539
|
+
if (value && typeof value === "object") {
|
|
540
|
+
return Object.fromEntries(
|
|
541
|
+
Object.entries(value).map(([key, item]) => [key, sanitizeOption(item)])
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
return value;
|
|
545
|
+
}
|
|
546
|
+
function sanitizeFields(value) {
|
|
547
|
+
return Object.fromEntries(
|
|
548
|
+
Object.entries(value).map(([key, item]) => [key, typeof item === "string" ? sanitizeTerminalText(item) : item])
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
function runtimeForDisplay(name, runtime) {
|
|
552
|
+
switch (name) {
|
|
553
|
+
case "directory":
|
|
554
|
+
return {
|
|
555
|
+
...runtime,
|
|
556
|
+
...sanitizeFields({ cwd: runtime.cwd, homeDir: runtime.homeDir, gitRoot: runtime.gitRoot })
|
|
557
|
+
};
|
|
558
|
+
case "git_branch":
|
|
559
|
+
return {
|
|
560
|
+
...runtime,
|
|
561
|
+
gitBranch: runtime.gitBranch === null ? null : sanitizeTerminalText(runtime.gitBranch),
|
|
562
|
+
gitBranchDetails: runtime.gitBranchDetails ? sanitizeFields(runtime.gitBranchDetails) : void 0
|
|
563
|
+
};
|
|
564
|
+
case "git_commit":
|
|
565
|
+
return { ...runtime, gitCommit: runtime.gitCommit ? sanitizeFields(runtime.gitCommit) : void 0 };
|
|
566
|
+
case "conda": {
|
|
567
|
+
const values = runtime.workspace?.modules.conda;
|
|
568
|
+
return values && runtime.workspace ? {
|
|
569
|
+
...runtime,
|
|
570
|
+
workspace: {
|
|
571
|
+
...runtime.workspace,
|
|
572
|
+
modules: { ...runtime.workspace.modules, conda: sanitizeFields(values) }
|
|
573
|
+
}
|
|
574
|
+
} : runtime;
|
|
575
|
+
}
|
|
576
|
+
case "extension_status":
|
|
577
|
+
return {
|
|
578
|
+
...runtime,
|
|
579
|
+
extensionStatuses: new Map(
|
|
580
|
+
[...runtime.extensionStatuses].map(([key, value]) => [key, sanitizeTerminalText(value)])
|
|
581
|
+
)
|
|
582
|
+
};
|
|
583
|
+
default:
|
|
584
|
+
return runtime;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
function renderModule(module, values, styleVariables, palette) {
|
|
588
|
+
if (module.disabled) return [];
|
|
589
|
+
return renderFormat(module.formatAst, {
|
|
590
|
+
variables: { symbol: module.symbol, ...values },
|
|
591
|
+
styleVariables,
|
|
592
|
+
palette
|
|
593
|
+
}).filter((chunk) => !isFillChunk(chunk));
|
|
594
|
+
}
|
|
595
|
+
function reachableModuleRequirements(config) {
|
|
596
|
+
const rootVariables = formatVariables(config.formatAst);
|
|
597
|
+
const includeAll = rootVariables.has("all");
|
|
598
|
+
const requirements = /* @__PURE__ */ new Map();
|
|
599
|
+
for (const definition of MODULE_DEFINITIONS) {
|
|
600
|
+
if (config.modules[definition.name].disabled) continue;
|
|
601
|
+
if (!includeAll && !rootVariables.has(definition.name)) continue;
|
|
602
|
+
const variables = formatVariables(config.modules[definition.name].formatAst);
|
|
603
|
+
if (definition.name === "directory") {
|
|
604
|
+
const alternate = directoryAlternateFormat(config.modules.directory.options, config.modules.directory.styles);
|
|
605
|
+
if (alternate) {
|
|
606
|
+
for (const variable of formatVariables(parseFormat(alternate))) variables.add(variable);
|
|
304
607
|
}
|
|
305
608
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
609
|
+
requirements.set(definition.name, variables);
|
|
610
|
+
}
|
|
611
|
+
return requirements;
|
|
612
|
+
}
|
|
613
|
+
function resolveFillLayout(layout, width) {
|
|
614
|
+
const lines = splitLogicalLines(layout);
|
|
615
|
+
const resolved = [];
|
|
616
|
+
for (const [lineIndex, line] of lines.entries()) {
|
|
617
|
+
const fills = line.filter(isFillChunk);
|
|
618
|
+
const fixedWidth = line.reduce(
|
|
619
|
+
(total, chunk) => total + (isFillChunk(chunk) ? 0 : visibleWidth(renderChunksToAnsi([chunk]))),
|
|
620
|
+
0
|
|
621
|
+
);
|
|
622
|
+
const remaining = Math.max(0, width - fixedWidth);
|
|
623
|
+
const base = fills.length > 0 ? Math.floor(remaining / fills.length) : 0;
|
|
624
|
+
let remainder = fills.length > 0 ? remaining % fills.length : 0;
|
|
625
|
+
for (const chunk of line) {
|
|
626
|
+
if (!isFillChunk(chunk)) {
|
|
627
|
+
resolved.push(chunk);
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
const allocation = base + (remainder > 0 ? 1 : 0);
|
|
631
|
+
if (remainder > 0) remainder -= 1;
|
|
632
|
+
resolved.push(...expandFill(chunk.pattern, allocation));
|
|
315
633
|
}
|
|
316
|
-
|
|
317
|
-
function terminate() {
|
|
318
|
-
if (killed || settled) return;
|
|
319
|
-
killed = true;
|
|
320
|
-
signalProcessTree("SIGTERM");
|
|
321
|
-
forceKillTimer = setTimeout(() => {
|
|
322
|
-
signalProcessTree("SIGKILL");
|
|
323
|
-
child.stdout?.destroy();
|
|
324
|
-
child.stderr?.destroy();
|
|
325
|
-
finish(1);
|
|
326
|
-
}, FORCE_KILL_DELAY_MS);
|
|
634
|
+
if (lineIndex < lines.length - 1) resolved.push({ text: "\n" });
|
|
327
635
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
if (
|
|
334
|
-
|
|
335
|
-
child.stdout?.on("data", collect(stdout));
|
|
336
|
-
child.stderr?.on("data", collect(stderr));
|
|
337
|
-
child.once("error", () => {
|
|
338
|
-
if (!killed) finish(1);
|
|
339
|
-
});
|
|
340
|
-
child.once("close", (code) => {
|
|
341
|
-
if (!killed) finish(code ?? 1);
|
|
342
|
-
});
|
|
343
|
-
options.signal?.addEventListener("abort", terminate, { once: true });
|
|
344
|
-
if (options.signal?.aborted) terminate();
|
|
345
|
-
timeoutTimer = setTimeout(terminate, options.timeout);
|
|
346
|
-
});
|
|
347
|
-
function explicitEnvironment(source) {
|
|
348
|
-
const result = /* @__PURE__ */ Object.create(null);
|
|
349
|
-
for (const [name, value] of Object.entries(source)) {
|
|
350
|
-
if (!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(name) || value === void 0 || value.includes("\0")) {
|
|
636
|
+
return resolved;
|
|
637
|
+
}
|
|
638
|
+
function splitLogicalLines(layout) {
|
|
639
|
+
const lines = [[]];
|
|
640
|
+
for (const chunk of layout) {
|
|
641
|
+
if (isFillChunk(chunk)) {
|
|
642
|
+
lines.at(-1)?.push(chunk);
|
|
351
643
|
continue;
|
|
352
644
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
645
|
+
const parts = chunk.text.split("\n");
|
|
646
|
+
for (const [index, text] of parts.entries()) {
|
|
647
|
+
if (text) lines.at(-1)?.push({ ...chunk, text });
|
|
648
|
+
if (index < parts.length - 1) lines.push([]);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
return lines;
|
|
652
|
+
}
|
|
653
|
+
function expandFill(pattern, width) {
|
|
654
|
+
if (width <= 0) return [];
|
|
655
|
+
const patternWidth = visibleWidth(renderChunksToAnsi(pattern));
|
|
656
|
+
if (patternWidth <= 0) return [{ text: " ".repeat(width), style: pattern[0]?.style }];
|
|
657
|
+
const repetitions = Math.floor(width / patternWidth);
|
|
658
|
+
const result = [];
|
|
659
|
+
for (let index = 0; index < repetitions; index += 1) {
|
|
660
|
+
result.push(...pattern.map((chunk) => ({ ...chunk })));
|
|
359
661
|
}
|
|
662
|
+
const remainder = width - repetitions * patternWidth;
|
|
663
|
+
if (remainder > 0) result.push({ text: " ".repeat(remainder), style: pattern.at(-1)?.style });
|
|
360
664
|
return result;
|
|
361
665
|
}
|
|
362
666
|
|
|
667
|
+
// src/modules/inspection.ts
|
|
668
|
+
function inspectStatuslineModules(config, runtime, width = 80) {
|
|
669
|
+
const rendered = renderStatusline(config, runtime, width);
|
|
670
|
+
const requirements = reachableModuleRequirements(config);
|
|
671
|
+
const rootVariables = formatVariables(config.formatAst);
|
|
672
|
+
const includeAll = rootVariables.has("all");
|
|
673
|
+
const modules = MODULE_DEFINITIONS.map((definition) => {
|
|
674
|
+
const module = config.modules[definition.name];
|
|
675
|
+
const reachable = requirements.has(definition.name);
|
|
676
|
+
const preview = plainPreview(rendered.modules[definition.name].map((chunk) => chunk.text).join(""));
|
|
677
|
+
const state = module.disabled ? "Disabled" : !reachable ? "Not in format" : preview.length > 0 ? "Showing" : "Empty";
|
|
678
|
+
return moduleInspection(
|
|
679
|
+
config,
|
|
680
|
+
definition,
|
|
681
|
+
state,
|
|
682
|
+
preview,
|
|
683
|
+
includeAll || rootVariables.has(definition.name),
|
|
684
|
+
reachable
|
|
685
|
+
);
|
|
686
|
+
});
|
|
687
|
+
return {
|
|
688
|
+
modules,
|
|
689
|
+
showing: modules.filter((module) => module.state === "Showing")
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
function moduleInspection(config, definition, state, preview, rootReferenced, reachable) {
|
|
693
|
+
const module = config.modules[definition.name];
|
|
694
|
+
return {
|
|
695
|
+
name: definition.name,
|
|
696
|
+
description: definition.description,
|
|
697
|
+
state,
|
|
698
|
+
preview,
|
|
699
|
+
variables: [...definition.variables],
|
|
700
|
+
styleFields: ["style", ...Object.keys(module.styles)],
|
|
701
|
+
styleRuleSelectors: Object.keys(definition.styleRuleSelectors ?? {}),
|
|
702
|
+
styleRuleCount: module.styleRules.length,
|
|
703
|
+
displayRules: module.display.map(
|
|
704
|
+
(rule) => `${rule.threshold}: ${rule.hidden ? "hidden" : rule.style || "unstyled"}`
|
|
705
|
+
),
|
|
706
|
+
rootReferenced,
|
|
707
|
+
reachable,
|
|
708
|
+
reason: inspectionReason(state)
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
function inspectionReason(state) {
|
|
712
|
+
switch (state) {
|
|
713
|
+
case "Showing":
|
|
714
|
+
return "Rendered in the current footer.";
|
|
715
|
+
case "Empty":
|
|
716
|
+
return "Referenced by the root format, but the current snapshot produced no output.";
|
|
717
|
+
case "Disabled":
|
|
718
|
+
return "Disabled by this module's configuration.";
|
|
719
|
+
case "Not in format":
|
|
720
|
+
return "Not referenced by the root format or $all.";
|
|
721
|
+
case "Unavailable":
|
|
722
|
+
return "Current footer inspection is unavailable; no collector failure was inferred.";
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
function plainPreview(value) {
|
|
726
|
+
return Array.from(stripVTControlCharacters(value), (character) => {
|
|
727
|
+
const codePoint = character.codePointAt(0) ?? 0;
|
|
728
|
+
if (character === "\n") return character;
|
|
729
|
+
return codePoint <= 31 || codePoint >= 127 && codePoint <= 159 ? " " : character;
|
|
730
|
+
}).join("");
|
|
731
|
+
}
|
|
732
|
+
|
|
363
733
|
// src/runtime/github-pr.ts
|
|
364
734
|
import { getCapabilities } from "@earendil-works/pi-tui";
|
|
365
735
|
var GH_TIMEOUT_MS = 1e4;
|
|
@@ -697,7 +1067,7 @@ async function collectWorkspaceSnapshot(input) {
|
|
|
697
1067
|
};
|
|
698
1068
|
const modules = {};
|
|
699
1069
|
if (requirements.has("package")) {
|
|
700
|
-
const { collectPackage } = await import("./chunks/package-
|
|
1070
|
+
const { collectPackage } = await import("./chunks/package-7KVAK3TC.ts");
|
|
701
1071
|
if (input.signal?.aborted) return freezeSnapshot({});
|
|
702
1072
|
const packageValues = await collectPackage(context);
|
|
703
1073
|
if (input.signal?.aborted) return freezeSnapshot({});
|
|
@@ -719,25 +1089,37 @@ function hasWorkspaceRequirement(requirements) {
|
|
|
719
1089
|
return [...requirements.keys()].some((name) => !BUILT_IN_ONLY_MODULES.has(name));
|
|
720
1090
|
}
|
|
721
1091
|
var COLLECTOR_GROUPS = [
|
|
1092
|
+
{
|
|
1093
|
+
modules: ["directory"],
|
|
1094
|
+
load: async () => (await import("./chunks/directory-OX6BWJZA.ts")).collectDirectory
|
|
1095
|
+
},
|
|
1096
|
+
{
|
|
1097
|
+
modules: ["jj_bookmark", "jj_change", "jj_metrics", "jj_status"],
|
|
1098
|
+
load: async () => (await import("./chunks/jujutsu-XLDYKSX2.ts")).collectJujutsu
|
|
1099
|
+
},
|
|
1100
|
+
{
|
|
1101
|
+
modules: ["memory_usage", "battery"],
|
|
1102
|
+
load: async () => (await import("./chunks/system-574MHB4R.ts")).collectSystem
|
|
1103
|
+
},
|
|
722
1104
|
{
|
|
723
1105
|
modules: ["nodejs", "python", "rust", "golang", "bun", "deno"],
|
|
724
|
-
load: async () => (await import("./chunks/languages-
|
|
1106
|
+
load: async () => (await import("./chunks/languages-CBQNNYXM.ts")).collectLanguages
|
|
725
1107
|
},
|
|
726
1108
|
{
|
|
727
1109
|
modules: ["mise", "direnv", "pixi", "conda", "nix_shell", "guix_shell"],
|
|
728
|
-
load: async () => (await import("./chunks/development-
|
|
1110
|
+
load: async () => (await import("./chunks/development-T3XXVVDP.ts")).collectDevelopment
|
|
729
1111
|
},
|
|
730
1112
|
{
|
|
731
1113
|
modules: ["docker_context", "kubernetes", "terraform"],
|
|
732
|
-
load: async () => (await import("./chunks/deployment-
|
|
1114
|
+
load: async () => (await import("./chunks/deployment-NOJ2KCLI.ts")).collectDeployment
|
|
733
1115
|
},
|
|
734
1116
|
{
|
|
735
1117
|
modules: ["aws", "gcloud", "azure", "openstack"],
|
|
736
|
-
load: async () => (await import("./chunks/cloud-
|
|
1118
|
+
load: async () => (await import("./chunks/cloud-J2ZOE3HE.ts")).collectCloud
|
|
737
1119
|
},
|
|
738
1120
|
{
|
|
739
1121
|
modules: ["container", "hostname", "os", "username"],
|
|
740
|
-
load: async () => (await import("./chunks/execution-
|
|
1122
|
+
load: async () => (await import("./chunks/execution-R2OHIP2L.ts")).collectExecution
|
|
741
1123
|
}
|
|
742
1124
|
];
|
|
743
1125
|
var BUILT_IN_ONLY_MODULES = /* @__PURE__ */ new Set([
|
|
@@ -745,7 +1127,6 @@ var BUILT_IN_ONLY_MODULES = /* @__PURE__ */ new Set([
|
|
|
745
1127
|
"provider",
|
|
746
1128
|
"model",
|
|
747
1129
|
"thinking",
|
|
748
|
-
"directory",
|
|
749
1130
|
"git_worktree",
|
|
750
1131
|
"git_branch",
|
|
751
1132
|
"github_pr",
|
|
@@ -827,7 +1208,7 @@ var MAX_TIMER_DELAY_MS = 2147483647;
|
|
|
827
1208
|
var starshipCommandsPromise;
|
|
828
1209
|
function loadStarshipCommands() {
|
|
829
1210
|
if (!starshipCommandsPromise) {
|
|
830
|
-
starshipCommandsPromise = import("./chunks/commands-
|
|
1211
|
+
starshipCommandsPromise = import("./chunks/commands-IOG2PL67.ts").catch((error) => {
|
|
831
1212
|
starshipCommandsPromise = void 0;
|
|
832
1213
|
throw error;
|
|
833
1214
|
});
|
|
@@ -846,8 +1227,12 @@ function piStarship(pi, options = {}) {
|
|
|
846
1227
|
let sessionGeneration = 0;
|
|
847
1228
|
let menuController = new AbortController();
|
|
848
1229
|
let commandInFlight;
|
|
1230
|
+
let chatCleanup;
|
|
849
1231
|
let sessionOwner;
|
|
850
1232
|
let activeTarget;
|
|
1233
|
+
let footerContext;
|
|
1234
|
+
let disposeFooter;
|
|
1235
|
+
let footerCollecting = false;
|
|
851
1236
|
let eventDebounceTimer;
|
|
852
1237
|
let githubPrRefreshTimer;
|
|
853
1238
|
let githubPrExpiryTimer;
|
|
@@ -858,12 +1243,17 @@ function piStarship(pi, options = {}) {
|
|
|
858
1243
|
const gitController = new AsyncRefreshController({
|
|
859
1244
|
async read(input, signal) {
|
|
860
1245
|
const requirements = reachableModuleRequirements(input.config);
|
|
861
|
-
const gitReachable = [...requirements.keys()].some((name) => name.startsWith("git_")) || requirements.has("directory") && input.config.modules.directory.options.truncate_to_repo === true;
|
|
1246
|
+
const gitReachable = [...requirements.keys()].some((name) => name.startsWith("git_")) || requirements.has("directory") && (input.config.modules.directory.options.truncate_to_repo === true || Boolean(input.config.modules.directory.options.repo_root_format) || Boolean(input.config.modules.directory.styles.repo_root_style));
|
|
862
1247
|
if (!gitReachable) return void 0;
|
|
863
1248
|
try {
|
|
864
1249
|
return await readGitSnapshot(pi, input.cwd, {
|
|
865
1250
|
includeMetrics: requirements.has("git_metrics"),
|
|
866
|
-
includeTag: requirements.get("git_commit")?.has("tag") ?? false,
|
|
1251
|
+
includeTag: (requirements.get("git_commit")?.has("tag") ?? false) && input.config.modules.git_commit.options.tag_disabled !== true,
|
|
1252
|
+
statusIgnoreSubmodules: input.config.modules.git_status.options.ignore_submodules === true,
|
|
1253
|
+
metricsIgnoreSubmodules: input.config.modules.git_metrics.options.ignore_submodules === true,
|
|
1254
|
+
tagMaxCandidates: input.config.modules.git_commit.options.tag_max_candidates,
|
|
1255
|
+
inspectBare: requirements.has("git_branch") && input.config.modules.git_branch.options.ignore_bare_repo === false,
|
|
1256
|
+
exec: options.gitExec ?? execWorkspaceCommand,
|
|
867
1257
|
signal
|
|
868
1258
|
});
|
|
869
1259
|
} catch {
|
|
@@ -904,15 +1294,15 @@ function piStarship(pi, options = {}) {
|
|
|
904
1294
|
clearTimeout(eventDebounceTimer);
|
|
905
1295
|
eventDebounceTimer = void 0;
|
|
906
1296
|
};
|
|
907
|
-
const isActiveTarget = (target) => activeTarget
|
|
1297
|
+
const isActiveTarget = (target) => activeTarget === target && target.generation === sessionGeneration;
|
|
908
1298
|
const requestRefresh = (target, reason = "event") => {
|
|
909
|
-
if (!loaded || !isActiveTarget(target)) return;
|
|
1299
|
+
if (!loaded || isNativeFooter(loaded) || !isActiveTarget(target)) return;
|
|
910
1300
|
gitController.request({ cwd: target.cwd, config: loaded.config });
|
|
911
1301
|
workspaceController.request(workspaceInput(target.cwd, loaded.config, reason, runtime.workspace));
|
|
912
1302
|
};
|
|
913
1303
|
const scheduleRefresh = (ctx) => {
|
|
914
1304
|
const target = activeTarget;
|
|
915
|
-
if (!target || target.cwd !== ctx.cwd || target.sessionManager !== ctx.sessionManager) {
|
|
1305
|
+
if (!loaded || isNativeFooter(loaded) || !target || target.cwd !== ctx.cwd || target.sessionManager !== ctx.sessionManager) {
|
|
916
1306
|
return;
|
|
917
1307
|
}
|
|
918
1308
|
clearDebounce();
|
|
@@ -922,7 +1312,7 @@ function piStarship(pi, options = {}) {
|
|
|
922
1312
|
}, EVENT_DEBOUNCE_MS);
|
|
923
1313
|
};
|
|
924
1314
|
function restartLocalControllers(target) {
|
|
925
|
-
if (!isActiveTarget(target)) return;
|
|
1315
|
+
if (!loaded || isNativeFooter(loaded) || !isActiveTarget(target)) return;
|
|
926
1316
|
gitController.start(target.generation);
|
|
927
1317
|
workspaceController.start(target.generation);
|
|
928
1318
|
}
|
|
@@ -938,7 +1328,7 @@ function piStarship(pi, options = {}) {
|
|
|
938
1328
|
runtime.githubPr = void 0;
|
|
939
1329
|
}
|
|
940
1330
|
function githubPrReachable() {
|
|
941
|
-
return Boolean(loaded && reachableModuleRequirements(loaded.config).has("github_pr"));
|
|
1331
|
+
return Boolean(loaded && !isNativeFooter(loaded) && reachableModuleRequirements(loaded.config).has("github_pr"));
|
|
942
1332
|
}
|
|
943
1333
|
function startGithubPr(target) {
|
|
944
1334
|
if (!isActiveTarget(target)) return false;
|
|
@@ -978,14 +1368,14 @@ function piStarship(pi, options = {}) {
|
|
|
978
1368
|
);
|
|
979
1369
|
githubPrExpiryTimer.unref?.();
|
|
980
1370
|
}
|
|
981
|
-
const
|
|
982
|
-
const
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1371
|
+
const releaseFooter = () => {
|
|
1372
|
+
const context = footerContext;
|
|
1373
|
+
footerContext = void 0;
|
|
1374
|
+
const dispose = disposeFooter;
|
|
1375
|
+
disposeFooter = void 0;
|
|
1376
|
+
footerCollecting = false;
|
|
1377
|
+
dispose?.();
|
|
1378
|
+
activeTarget = void 0;
|
|
989
1379
|
clearDebounce();
|
|
990
1380
|
gitController.stop();
|
|
991
1381
|
workspaceController.stop();
|
|
@@ -996,12 +1386,30 @@ function piStarship(pi, options = {}) {
|
|
|
996
1386
|
runtime.renderPreview = void 0;
|
|
997
1387
|
runtime.inspect = void 0;
|
|
998
1388
|
runtime.footerWidth = void 0;
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1389
|
+
context?.ui.setFooter(void 0);
|
|
1390
|
+
};
|
|
1391
|
+
const syncFooter = (ctx) => {
|
|
1392
|
+
const current = previewLoaded ?? loaded;
|
|
1393
|
+
if (ctx.mode !== "tui" || !current || isNativeFooter(current)) {
|
|
1394
|
+
releaseFooter();
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
const collect = Boolean(loaded && !isNativeFooter(loaded));
|
|
1398
|
+
if (activeTarget && footerCollecting === collect) return;
|
|
1399
|
+
if (activeTarget) releaseFooter();
|
|
1400
|
+
footerCollecting = collect;
|
|
1401
|
+
const target = {
|
|
1402
|
+
cwd: ctx.cwd,
|
|
1403
|
+
generation: sessionGeneration,
|
|
1404
|
+
sessionManager: ctx.sessionManager
|
|
1405
|
+
};
|
|
1406
|
+
activeTarget = target;
|
|
1407
|
+
footerContext = ctx;
|
|
1408
|
+
if (collect) {
|
|
1409
|
+
gitController.start(target.generation);
|
|
1410
|
+
workspaceController.start(target.generation);
|
|
1411
|
+
startGithubPr(target);
|
|
1412
|
+
}
|
|
1005
1413
|
ctx.ui.setFooter((tui, theme, footerData) => {
|
|
1006
1414
|
runtime.requestRender = () => tui.requestRender();
|
|
1007
1415
|
runtime.renderPreview = (preview, width) => {
|
|
@@ -1011,9 +1419,13 @@ function piStarship(pi, options = {}) {
|
|
|
1011
1419
|
width
|
|
1012
1420
|
);
|
|
1013
1421
|
};
|
|
1014
|
-
runtime.inspect = (
|
|
1422
|
+
runtime.inspect = (current2) => inspectStatuslineModules(current2.config, runtimeSnapshot(ctx, footerData, runtime), runtime.footerWidth ?? 80);
|
|
1015
1423
|
const unsubscribe = footerData.onBranchChange(() => {
|
|
1016
1424
|
if (!isActiveTarget(target)) return;
|
|
1425
|
+
if (!collect) {
|
|
1426
|
+
tui.requestRender();
|
|
1427
|
+
return;
|
|
1428
|
+
}
|
|
1017
1429
|
runtime.git = void 0;
|
|
1018
1430
|
restartLocalControllers(target);
|
|
1019
1431
|
clearDebounce();
|
|
@@ -1023,14 +1435,18 @@ function piStarship(pi, options = {}) {
|
|
|
1023
1435
|
tui.requestRender();
|
|
1024
1436
|
});
|
|
1025
1437
|
let lastRender;
|
|
1026
|
-
const timer = setInterval(() => {
|
|
1438
|
+
const timer = collect ? setInterval(() => {
|
|
1027
1439
|
if (!isActiveTarget(target)) return;
|
|
1028
1440
|
clearDebounce();
|
|
1029
1441
|
requestRefresh(target, "periodic");
|
|
1030
|
-
if (!lastRender
|
|
1442
|
+
if (!lastRender) return;
|
|
1443
|
+
const clock = reachableModuleRequirements(lastRender.config).get("time");
|
|
1444
|
+
const range = lastRender.config.modules.time.options.time_range;
|
|
1445
|
+
if (!clock || !clock.has("time") && (!range || range === "-")) return;
|
|
1031
1446
|
const now = /* @__PURE__ */ new Date();
|
|
1032
1447
|
const previous = lastRender.snapshot.now;
|
|
1033
|
-
if (now.getHours() === previous.getHours() && now.getMinutes() === previous.getMinutes())
|
|
1448
|
+
if (!lastRender.config.modules.time.options.time_format && lastRender.config.modules.time.options.utc_time_offset === "local" && (!range || range === "-") && now.getHours() === previous.getHours() && now.getMinutes() === previous.getMinutes())
|
|
1449
|
+
return;
|
|
1034
1450
|
const lines = wrapFormattedStatusline(
|
|
1035
1451
|
renderStatusline(
|
|
1036
1452
|
lastRender.config,
|
|
@@ -1044,40 +1460,43 @@ function piStarship(pi, options = {}) {
|
|
|
1044
1460
|
const previousLines = lastRender.lines;
|
|
1045
1461
|
if (lines.length !== previousLines.length || lines.some((line, index) => line !== previousLines[index]))
|
|
1046
1462
|
tui.requestRender();
|
|
1047
|
-
}, REFRESH_INTERVAL_MS);
|
|
1463
|
+
}, REFRESH_INTERVAL_MS) : void 0;
|
|
1048
1464
|
let disposed = false;
|
|
1465
|
+
const dispose = () => {
|
|
1466
|
+
if (disposed) return;
|
|
1467
|
+
disposed = true;
|
|
1468
|
+
unsubscribe();
|
|
1469
|
+
clearInterval(timer);
|
|
1470
|
+
if (isActiveTarget(target)) {
|
|
1471
|
+
activeTarget = void 0;
|
|
1472
|
+
footerCollecting = false;
|
|
1473
|
+
clearDebounce();
|
|
1474
|
+
gitController.stop();
|
|
1475
|
+
workspaceController.stop();
|
|
1476
|
+
stopGithubPr();
|
|
1477
|
+
runtime.git = void 0;
|
|
1478
|
+
runtime.workspace = void 0;
|
|
1479
|
+
runtime.requestRender = void 0;
|
|
1480
|
+
runtime.renderPreview = void 0;
|
|
1481
|
+
runtime.inspect = void 0;
|
|
1482
|
+
runtime.footerWidth = void 0;
|
|
1483
|
+
}
|
|
1484
|
+
};
|
|
1485
|
+
disposeFooter = dispose;
|
|
1049
1486
|
return {
|
|
1050
|
-
dispose
|
|
1051
|
-
if (disposed) return;
|
|
1052
|
-
disposed = true;
|
|
1053
|
-
unsubscribe();
|
|
1054
|
-
clearInterval(timer);
|
|
1055
|
-
if (isActiveTarget(target)) {
|
|
1056
|
-
activeTarget = void 0;
|
|
1057
|
-
clearDebounce();
|
|
1058
|
-
gitController.stop();
|
|
1059
|
-
workspaceController.stop();
|
|
1060
|
-
stopGithubPr();
|
|
1061
|
-
runtime.git = void 0;
|
|
1062
|
-
runtime.workspace = void 0;
|
|
1063
|
-
runtime.requestRender = void 0;
|
|
1064
|
-
runtime.renderPreview = void 0;
|
|
1065
|
-
runtime.inspect = void 0;
|
|
1066
|
-
runtime.footerWidth = void 0;
|
|
1067
|
-
}
|
|
1068
|
-
},
|
|
1487
|
+
dispose,
|
|
1069
1488
|
invalidate() {
|
|
1070
1489
|
},
|
|
1071
1490
|
render(width) {
|
|
1072
1491
|
runtime.footerWidth = width;
|
|
1073
|
-
const
|
|
1074
|
-
if (!
|
|
1492
|
+
const current2 = previewLoaded ?? loaded;
|
|
1493
|
+
if (!current2) return [];
|
|
1075
1494
|
const snapshot = runtimeSnapshot(ctx, footerData, runtime);
|
|
1076
1495
|
const lines = wrapFormattedStatusline(
|
|
1077
|
-
renderStatusline(
|
|
1496
|
+
renderStatusline(current2.config, snapshot, width, getCapabilities2().trueColor, theme.colors).ansi,
|
|
1078
1497
|
width
|
|
1079
1498
|
);
|
|
1080
|
-
lastRender = { snapshot, lines, config:
|
|
1499
|
+
lastRender = { snapshot, lines, config: current2.config, width };
|
|
1081
1500
|
return lines;
|
|
1082
1501
|
}
|
|
1083
1502
|
};
|
|
@@ -1085,9 +1504,26 @@ function piStarship(pi, options = {}) {
|
|
|
1085
1504
|
requestRefresh(target, "initial");
|
|
1086
1505
|
requestGithubPr(target);
|
|
1087
1506
|
};
|
|
1507
|
+
const installFooter = (ctx) => {
|
|
1508
|
+
releaseFooter();
|
|
1509
|
+
sessionGeneration += 1;
|
|
1510
|
+
commandInFlight = void 0;
|
|
1511
|
+
sessionOwner = ctx.sessionManager;
|
|
1512
|
+
previewLoaded = void 0;
|
|
1513
|
+
menuController.abort(new DOMException("Starship session context replaced", "AbortError"));
|
|
1514
|
+
menuController = new AbortController();
|
|
1515
|
+
ctx.ui.setStatus("starship", void 0);
|
|
1516
|
+
syncFooter(ctx);
|
|
1517
|
+
};
|
|
1088
1518
|
const configPath = settingsFilePath(getAgentDir());
|
|
1089
1519
|
const commandOptions = {
|
|
1090
1520
|
settingsPath: configPath,
|
|
1521
|
+
registerChatCleanup(cleanup) {
|
|
1522
|
+
chatCleanup = cleanup;
|
|
1523
|
+
return () => {
|
|
1524
|
+
if (chatCleanup === cleanup) chatCleanup = void 0;
|
|
1525
|
+
};
|
|
1526
|
+
},
|
|
1091
1527
|
getLoaded: () => loaded ?? loadStarshipConfig(configPath),
|
|
1092
1528
|
getLoadedRevision: () => loadedRevision,
|
|
1093
1529
|
getInspection: () => {
|
|
@@ -1108,8 +1544,10 @@ function piStarship(pi, options = {}) {
|
|
|
1108
1544
|
previewLoaded = void 0;
|
|
1109
1545
|
loaded = next;
|
|
1110
1546
|
loadedRevision += 1;
|
|
1547
|
+
const previousTarget = activeTarget;
|
|
1548
|
+
syncFooter(ctx);
|
|
1111
1549
|
const target = activeTarget;
|
|
1112
|
-
if (target) {
|
|
1550
|
+
if (target && target === previousTarget) {
|
|
1113
1551
|
restartLocalControllers(target);
|
|
1114
1552
|
startGithubPr(target);
|
|
1115
1553
|
requestRefresh(target);
|
|
@@ -1120,14 +1558,33 @@ function piStarship(pi, options = {}) {
|
|
|
1120
1558
|
preview(next, ctx) {
|
|
1121
1559
|
if (sessionOwner !== ctx.sessionManager) return;
|
|
1122
1560
|
previewLoaded = next;
|
|
1561
|
+
syncFooter(ctx);
|
|
1123
1562
|
refresh();
|
|
1124
1563
|
},
|
|
1125
|
-
renderPreview(preview, width) {
|
|
1126
|
-
|
|
1564
|
+
renderPreview(preview, width, ctx) {
|
|
1565
|
+
if (isNativeFooter(preview)) return ["Pi built-in footer"];
|
|
1566
|
+
if (runtime.renderPreview) return runtime.renderPreview(preview, width);
|
|
1567
|
+
return wrapFormattedStatusline(
|
|
1568
|
+
renderStatusline(
|
|
1569
|
+
preview.config,
|
|
1570
|
+
runtimeSnapshot(
|
|
1571
|
+
ctx,
|
|
1572
|
+
{
|
|
1573
|
+
getGitBranch: () => null,
|
|
1574
|
+
getExtensionStatuses: () => /* @__PURE__ */ new Map()
|
|
1575
|
+
},
|
|
1576
|
+
runtime
|
|
1577
|
+
),
|
|
1578
|
+
width,
|
|
1579
|
+
getCapabilities2().trueColor,
|
|
1580
|
+
ctx.ui.theme.colors
|
|
1581
|
+
).ansi,
|
|
1582
|
+
width
|
|
1583
|
+
);
|
|
1127
1584
|
}
|
|
1128
1585
|
};
|
|
1129
1586
|
pi.registerCommand("starship", {
|
|
1130
|
-
description: "
|
|
1587
|
+
description: "Configure the footer with agent, presets, profiles, and recovery",
|
|
1131
1588
|
getArgumentCompletions: completeStarshipArguments,
|
|
1132
1589
|
handler: async (args, ctx) => {
|
|
1133
1590
|
const interactive = ctx.mode === "tui" && (!args.trim() || args.trim().toLowerCase() === "settings");
|
|
@@ -1164,20 +1621,14 @@ function piStarship(pi, options = {}) {
|
|
|
1164
1621
|
installFooter(ctx);
|
|
1165
1622
|
refresh();
|
|
1166
1623
|
});
|
|
1167
|
-
pi.on("session_shutdown", (_event, ctx) => {
|
|
1624
|
+
pi.on("session_shutdown", async (_event, ctx) => {
|
|
1168
1625
|
if (sessionOwner !== ctx.sessionManager) return;
|
|
1169
1626
|
sessionOwner = void 0;
|
|
1170
1627
|
commandInFlight = void 0;
|
|
1171
1628
|
previewLoaded = void 0;
|
|
1172
1629
|
sessionGeneration += 1;
|
|
1173
1630
|
menuController.abort(new DOMException("Starship session shut down", "AbortError"));
|
|
1174
|
-
|
|
1175
|
-
clearDebounce();
|
|
1176
|
-
gitController.stop();
|
|
1177
|
-
workspaceController.stop();
|
|
1178
|
-
stopGithubPr();
|
|
1179
|
-
runtime.git = void 0;
|
|
1180
|
-
runtime.workspace = void 0;
|
|
1631
|
+
releaseFooter();
|
|
1181
1632
|
runtime.activeTools.clear();
|
|
1182
1633
|
runtime.isStreaming = false;
|
|
1183
1634
|
runtime.uiPrompt = void 0;
|
|
@@ -1186,8 +1637,10 @@ function piStarship(pi, options = {}) {
|
|
|
1186
1637
|
runtime.renderPreview = void 0;
|
|
1187
1638
|
runtime.inspect = void 0;
|
|
1188
1639
|
runtime.footerWidth = void 0;
|
|
1189
|
-
ctx.ui.setFooter(void 0);
|
|
1190
1640
|
ctx.ui.setStatus("starship", void 0);
|
|
1641
|
+
const cleanup = chatCleanup;
|
|
1642
|
+
chatCleanup = void 0;
|
|
1643
|
+
await cleanup?.();
|
|
1191
1644
|
});
|
|
1192
1645
|
pi.on("model_select", () => refresh());
|
|
1193
1646
|
pi.on("thinking_level_select", (event) => {
|
|
@@ -1236,6 +1689,9 @@ function piStarship(pi, options = {}) {
|
|
|
1236
1689
|
refresh();
|
|
1237
1690
|
});
|
|
1238
1691
|
}
|
|
1692
|
+
function isNativeFooter(loaded) {
|
|
1693
|
+
return loaded.rawDocument === void 0 && loaded.diagnostics.length === 0;
|
|
1694
|
+
}
|
|
1239
1695
|
function workspaceInput(cwd, config, reason, previous) {
|
|
1240
1696
|
return {
|
|
1241
1697
|
cwd,
|
|
@@ -1290,12 +1746,20 @@ var ENVIRONMENT_ALLOWLIST = [
|
|
|
1290
1746
|
];
|
|
1291
1747
|
function allowlistedEnvironment(config) {
|
|
1292
1748
|
const result = {};
|
|
1293
|
-
const configured = config.modules.
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
]);
|
|
1298
|
-
for (const name of names)
|
|
1749
|
+
const configured = Object.values(config.modules).flatMap((module) => {
|
|
1750
|
+
const names2 = module.options.detect_env_vars;
|
|
1751
|
+
return Array.isArray(names2) ? names2.filter((name) => typeof name === "string") : [];
|
|
1752
|
+
}).map((name) => name.replace(/^!/u, "")).filter((name) => /^[A-Za-z_][A-Za-z0-9_]*$/u.test(name));
|
|
1753
|
+
const names = /* @__PURE__ */ new Set([...ENVIRONMENT_ALLOWLIST, ...configured]);
|
|
1754
|
+
for (const name of names) {
|
|
1755
|
+
const value = Object.hasOwn(process.env, name) && typeof process.env[name] === "string" ? process.env[name] : void 0;
|
|
1756
|
+
Object.defineProperty(result, name, {
|
|
1757
|
+
value,
|
|
1758
|
+
enumerable: true,
|
|
1759
|
+
configurable: true,
|
|
1760
|
+
writable: true
|
|
1761
|
+
});
|
|
1762
|
+
}
|
|
1299
1763
|
return result;
|
|
1300
1764
|
}
|
|
1301
1765
|
function safeUsername() {
|