@narumitw/pi-starship 0.60.0 → 0.62.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 +63 -6
- package/dist/chunks/chunk-43VIENBN.ts +1586 -0
- package/dist/chunks/chunk-43VIENBN.ts.map +7 -0
- package/dist/chunks/chunk-HPZTMIZS.ts +646 -0
- package/dist/chunks/chunk-HPZTMIZS.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-KZZKGGFW.ts → chunk-PWTSHSP3.ts} +853 -1001
- package/dist/chunks/chunk-PWTSHSP3.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/{cloud-EPAEV4ZB.ts → cloud-J2ZOE3HE.ts} +6 -2
- package/dist/chunks/cloud-J2ZOE3HE.ts.map +7 -0
- package/dist/chunks/command-configuration-menu-S2LXCOJG.ts +147 -0
- package/dist/chunks/command-configuration-menu-S2LXCOJG.ts.map +7 -0
- package/dist/chunks/command-settings-chat-O34BEU4X.ts +1041 -0
- package/dist/chunks/command-settings-chat-O34BEU4X.ts.map +7 -0
- package/dist/chunks/commands-ZYIJVIEJ.ts +1022 -0
- package/dist/chunks/commands-ZYIJVIEJ.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 +558 -150
- package/dist/index.ts.map +4 -4
- package/package.json +5 -1
- package/skills/configure-pi-starship/SKILL.md +29 -1
- package/skills/configure-pi-starship/references/configuration.md +109 -24
- 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/skills/configure-pi-starship/scripts/config-path.mjs +63 -3
- package/src/command-configuration-menu.ts +155 -0
- package/src/command-configuration.ts +9 -84
- package/src/command-preview.ts +3 -3
- package/src/command-settings-chat.ts +210 -0
- package/src/commands.ts +54 -98
- package/src/config/module-options.ts +112 -0
- package/src/config.ts +17 -53
- 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 +56 -12
- 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 +140 -0
- package/src/settings-chat-ui.ts +426 -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-PWTSHSP3.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-ZYIJVIEJ.ts").catch((error) => {
|
|
831
1212
|
starshipCommandsPromise = void 0;
|
|
832
1213
|
throw error;
|
|
833
1214
|
});
|
|
@@ -846,6 +1227,7 @@ 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;
|
|
851
1233
|
let eventDebounceTimer;
|
|
@@ -858,12 +1240,17 @@ function piStarship(pi, options = {}) {
|
|
|
858
1240
|
const gitController = new AsyncRefreshController({
|
|
859
1241
|
async read(input, signal) {
|
|
860
1242
|
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;
|
|
1243
|
+
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
1244
|
if (!gitReachable) return void 0;
|
|
863
1245
|
try {
|
|
864
1246
|
return await readGitSnapshot(pi, input.cwd, {
|
|
865
1247
|
includeMetrics: requirements.has("git_metrics"),
|
|
866
|
-
includeTag: requirements.get("git_commit")?.has("tag") ?? false,
|
|
1248
|
+
includeTag: (requirements.get("git_commit")?.has("tag") ?? false) && input.config.modules.git_commit.options.tag_disabled !== true,
|
|
1249
|
+
statusIgnoreSubmodules: input.config.modules.git_status.options.ignore_submodules === true,
|
|
1250
|
+
metricsIgnoreSubmodules: input.config.modules.git_metrics.options.ignore_submodules === true,
|
|
1251
|
+
tagMaxCandidates: input.config.modules.git_commit.options.tag_max_candidates,
|
|
1252
|
+
inspectBare: requirements.has("git_branch") && input.config.modules.git_branch.options.ignore_bare_repo === false,
|
|
1253
|
+
exec: options.gitExec ?? execWorkspaceCommand,
|
|
867
1254
|
signal
|
|
868
1255
|
});
|
|
869
1256
|
} catch {
|
|
@@ -1027,10 +1414,14 @@ function piStarship(pi, options = {}) {
|
|
|
1027
1414
|
if (!isActiveTarget(target)) return;
|
|
1028
1415
|
clearDebounce();
|
|
1029
1416
|
requestRefresh(target, "periodic");
|
|
1030
|
-
if (!lastRender
|
|
1417
|
+
if (!lastRender) return;
|
|
1418
|
+
const clock = reachableModuleRequirements(lastRender.config).get("time");
|
|
1419
|
+
const range = lastRender.config.modules.time.options.time_range;
|
|
1420
|
+
if (!clock || !clock.has("time") && (!range || range === "-")) return;
|
|
1031
1421
|
const now = /* @__PURE__ */ new Date();
|
|
1032
1422
|
const previous = lastRender.snapshot.now;
|
|
1033
|
-
if (now.getHours() === previous.getHours() && now.getMinutes() === previous.getMinutes())
|
|
1423
|
+
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())
|
|
1424
|
+
return;
|
|
1034
1425
|
const lines = wrapFormattedStatusline(
|
|
1035
1426
|
renderStatusline(
|
|
1036
1427
|
lastRender.config,
|
|
@@ -1088,6 +1479,12 @@ function piStarship(pi, options = {}) {
|
|
|
1088
1479
|
const configPath = settingsFilePath(getAgentDir());
|
|
1089
1480
|
const commandOptions = {
|
|
1090
1481
|
settingsPath: configPath,
|
|
1482
|
+
registerChatCleanup(cleanup) {
|
|
1483
|
+
chatCleanup = cleanup;
|
|
1484
|
+
return () => {
|
|
1485
|
+
if (chatCleanup === cleanup) chatCleanup = void 0;
|
|
1486
|
+
};
|
|
1487
|
+
},
|
|
1091
1488
|
getLoaded: () => loaded ?? loadStarshipConfig(configPath),
|
|
1092
1489
|
getLoadedRevision: () => loadedRevision,
|
|
1093
1490
|
getInspection: () => {
|
|
@@ -1127,7 +1524,7 @@ function piStarship(pi, options = {}) {
|
|
|
1127
1524
|
}
|
|
1128
1525
|
};
|
|
1129
1526
|
pi.registerCommand("starship", {
|
|
1130
|
-
description: "
|
|
1527
|
+
description: "Configure the footer with agent, presets, profiles, and recovery",
|
|
1131
1528
|
getArgumentCompletions: completeStarshipArguments,
|
|
1132
1529
|
handler: async (args, ctx) => {
|
|
1133
1530
|
const interactive = ctx.mode === "tui" && (!args.trim() || args.trim().toLowerCase() === "settings");
|
|
@@ -1164,7 +1561,7 @@ function piStarship(pi, options = {}) {
|
|
|
1164
1561
|
installFooter(ctx);
|
|
1165
1562
|
refresh();
|
|
1166
1563
|
});
|
|
1167
|
-
pi.on("session_shutdown", (_event, ctx) => {
|
|
1564
|
+
pi.on("session_shutdown", async (_event, ctx) => {
|
|
1168
1565
|
if (sessionOwner !== ctx.sessionManager) return;
|
|
1169
1566
|
sessionOwner = void 0;
|
|
1170
1567
|
commandInFlight = void 0;
|
|
@@ -1188,6 +1585,9 @@ function piStarship(pi, options = {}) {
|
|
|
1188
1585
|
runtime.footerWidth = void 0;
|
|
1189
1586
|
ctx.ui.setFooter(void 0);
|
|
1190
1587
|
ctx.ui.setStatus("starship", void 0);
|
|
1588
|
+
const cleanup = chatCleanup;
|
|
1589
|
+
chatCleanup = void 0;
|
|
1590
|
+
await cleanup?.();
|
|
1191
1591
|
});
|
|
1192
1592
|
pi.on("model_select", () => refresh());
|
|
1193
1593
|
pi.on("thinking_level_select", (event) => {
|
|
@@ -1290,12 +1690,20 @@ var ENVIRONMENT_ALLOWLIST = [
|
|
|
1290
1690
|
];
|
|
1291
1691
|
function allowlistedEnvironment(config) {
|
|
1292
1692
|
const result = {};
|
|
1293
|
-
const configured = config.modules.
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
]);
|
|
1298
|
-
for (const name of names)
|
|
1693
|
+
const configured = Object.values(config.modules).flatMap((module) => {
|
|
1694
|
+
const names2 = module.options.detect_env_vars;
|
|
1695
|
+
return Array.isArray(names2) ? names2.filter((name) => typeof name === "string") : [];
|
|
1696
|
+
}).map((name) => name.replace(/^!/u, "")).filter((name) => /^[A-Za-z_][A-Za-z0-9_]*$/u.test(name));
|
|
1697
|
+
const names = /* @__PURE__ */ new Set([...ENVIRONMENT_ALLOWLIST, ...configured]);
|
|
1698
|
+
for (const name of names) {
|
|
1699
|
+
const value = Object.hasOwn(process.env, name) && typeof process.env[name] === "string" ? process.env[name] : void 0;
|
|
1700
|
+
Object.defineProperty(result, name, {
|
|
1701
|
+
value,
|
|
1702
|
+
enumerable: true,
|
|
1703
|
+
configurable: true,
|
|
1704
|
+
writable: true
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1299
1707
|
return result;
|
|
1300
1708
|
}
|
|
1301
1709
|
function safeUsername() {
|