@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/src/modules/types.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface GitBranchSnapshot {
|
|
|
7
7
|
remoteName?: string;
|
|
8
8
|
remoteBranch?: string;
|
|
9
9
|
detached: boolean;
|
|
10
|
+
bare?: boolean;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export interface GitCommitSnapshot {
|
|
@@ -27,6 +28,7 @@ export interface GitMetricsSnapshot {
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export interface GitStatusSnapshot {
|
|
31
|
+
upToDate?: boolean;
|
|
30
32
|
ahead: number;
|
|
31
33
|
behind: number;
|
|
32
34
|
stashed: number;
|
|
@@ -74,6 +76,12 @@ export interface GitSnapshot {
|
|
|
74
76
|
worktree?: GitWorktreeSnapshot;
|
|
75
77
|
}
|
|
76
78
|
|
|
79
|
+
export interface JujutsuBookmark {
|
|
80
|
+
readonly name: string;
|
|
81
|
+
readonly remote: string;
|
|
82
|
+
readonly diverged: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
77
85
|
export interface WorkspaceSnapshot {
|
|
78
86
|
modules: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
79
87
|
styleSelectors?: Readonly<Record<string, string>>;
|
|
@@ -124,23 +132,51 @@ export interface ExtensionStatusPresentation {
|
|
|
124
132
|
styles: Readonly<Record<string, string>>;
|
|
125
133
|
}
|
|
126
134
|
|
|
127
|
-
export
|
|
135
|
+
export interface ModuleContextRule {
|
|
136
|
+
readonly context_pattern: string;
|
|
137
|
+
readonly user_pattern?: string;
|
|
138
|
+
readonly symbol?: string;
|
|
139
|
+
readonly style?: string;
|
|
140
|
+
readonly context_alias?: string;
|
|
141
|
+
readonly user_alias?: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface ModuleSubstitution {
|
|
145
|
+
readonly from: string;
|
|
146
|
+
readonly to: string;
|
|
147
|
+
readonly regex?: boolean;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export type ModuleOptionValue =
|
|
151
|
+
| string
|
|
152
|
+
| boolean
|
|
153
|
+
| number
|
|
154
|
+
| readonly string[]
|
|
155
|
+
| Readonly<Record<string, string>>
|
|
156
|
+
| readonly ModuleContextRule[]
|
|
157
|
+
| readonly ModuleSubstitution[]
|
|
158
|
+
| readonly (string | readonly string[])[];
|
|
128
159
|
|
|
129
160
|
export interface ModuleValueContext {
|
|
130
161
|
runtime: StarshipRuntimeSnapshot;
|
|
131
162
|
palette: ColorPalette;
|
|
132
163
|
symbol: string;
|
|
164
|
+
styles?: Readonly<Record<string, string>>;
|
|
165
|
+
requestedVariables?: ReadonlySet<string>;
|
|
133
166
|
options: Readonly<Record<string, ModuleOptionValue>>;
|
|
134
167
|
extensionStatus: ExtensionStatusPresentation;
|
|
135
168
|
}
|
|
136
169
|
|
|
137
170
|
export type ModuleOptionSchema =
|
|
138
|
-
| { kind: "string"; default: string; allowEmpty?: boolean }
|
|
171
|
+
| { kind: "string"; default: string; allowEmpty?: boolean; templateVariables?: readonly string[] }
|
|
139
172
|
| { kind: "string-enum"; default: string; values: readonly string[] }
|
|
140
173
|
| { kind: "boolean"; default: boolean }
|
|
141
|
-
| { kind: "integer"; default: number; minimum: number; maximum: number }
|
|
174
|
+
| { kind: "integer" | "number"; default: number; minimum: number; maximum: number }
|
|
142
175
|
| { kind: "string-array"; default: readonly string[]; allowNegative?: boolean }
|
|
143
|
-
| { kind: "string-map"; default: Readonly<Record<string, string>> }
|
|
176
|
+
| { kind: "string-map"; default: Readonly<Record<string, string>> }
|
|
177
|
+
| { kind: "command-alternatives"; default: readonly (string | readonly string[])[] }
|
|
178
|
+
| { kind: "context-rules"; default: readonly ModuleContextRule[] }
|
|
179
|
+
| { kind: "substitutions"; default: Readonly<Record<string, string>> | readonly ModuleSubstitution[] };
|
|
144
180
|
|
|
145
181
|
export interface ModuleDisplayConfig {
|
|
146
182
|
threshold: number;
|
|
@@ -165,6 +201,7 @@ export interface ModuleStyleContext {
|
|
|
165
201
|
style: string;
|
|
166
202
|
styles: Readonly<Record<string, string>>;
|
|
167
203
|
display: readonly ModuleDisplayConfig[];
|
|
204
|
+
options: Readonly<Record<string, ModuleOptionValue>>;
|
|
168
205
|
}
|
|
169
206
|
|
|
170
207
|
export type ModuleStyleSelector = (context: ModuleStyleContext) => string | undefined;
|
|
@@ -181,6 +218,7 @@ export interface ModuleDefinition<Name extends string> {
|
|
|
181
218
|
resolveStyleVariables?(context: ModuleStyleContext): Readonly<Record<string, string>> | undefined;
|
|
182
219
|
options?: Readonly<Record<string, ModuleOptionSchema>>;
|
|
183
220
|
layout?: "fill";
|
|
221
|
+
resolveFormat?(context: ModuleValueContext, values: Readonly<Record<string, FormatValue>>): string | undefined;
|
|
184
222
|
values(context: ModuleValueContext): Record<string, FormatValue> | undefined;
|
|
185
223
|
}
|
|
186
224
|
|
package/src/pi-starship.ts
CHANGED
|
@@ -76,6 +76,7 @@ interface GitRefreshInput {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
interface PiStarshipOptions {
|
|
79
|
+
gitExec?: WorkspaceExec;
|
|
79
80
|
githubPrExec?: WorkspaceExec;
|
|
80
81
|
}
|
|
81
82
|
|
|
@@ -91,8 +92,12 @@ export default function piStarship(pi: ExtensionAPI, options: PiStarshipOptions
|
|
|
91
92
|
let sessionGeneration = 0;
|
|
92
93
|
let menuController = new AbortController();
|
|
93
94
|
let commandInFlight: object | undefined;
|
|
95
|
+
let chatCleanup: (() => Promise<void>) | undefined;
|
|
94
96
|
let sessionOwner: ExtensionContext["sessionManager"] | undefined;
|
|
95
97
|
let activeTarget: RefreshTarget | undefined;
|
|
98
|
+
let footerContext: ExtensionContext | undefined;
|
|
99
|
+
let disposeFooter: (() => void) | undefined;
|
|
100
|
+
let footerCollecting = false;
|
|
96
101
|
let eventDebounceTimer: ReturnType<typeof setTimeout> | undefined;
|
|
97
102
|
let githubPrRefreshTimer: ReturnType<typeof setInterval> | undefined;
|
|
98
103
|
let githubPrExpiryTimer: ReturnType<typeof setTimeout> | undefined;
|
|
@@ -106,12 +111,23 @@ export default function piStarship(pi: ExtensionAPI, options: PiStarshipOptions
|
|
|
106
111
|
const requirements = reachableModuleRequirements(input.config);
|
|
107
112
|
const gitReachable =
|
|
108
113
|
[...requirements.keys()].some((name) => name.startsWith("git_")) ||
|
|
109
|
-
(requirements.has("directory") &&
|
|
114
|
+
(requirements.has("directory") &&
|
|
115
|
+
(input.config.modules.directory.options.truncate_to_repo === true ||
|
|
116
|
+
Boolean(input.config.modules.directory.options.repo_root_format) ||
|
|
117
|
+
Boolean(input.config.modules.directory.styles.repo_root_style)));
|
|
110
118
|
if (!gitReachable) return undefined;
|
|
111
119
|
try {
|
|
112
120
|
return await readGitSnapshot(pi, input.cwd, {
|
|
113
121
|
includeMetrics: requirements.has("git_metrics"),
|
|
114
|
-
includeTag:
|
|
122
|
+
includeTag:
|
|
123
|
+
(requirements.get("git_commit")?.has("tag") ?? false) &&
|
|
124
|
+
input.config.modules.git_commit.options.tag_disabled !== true,
|
|
125
|
+
statusIgnoreSubmodules: input.config.modules.git_status.options.ignore_submodules === true,
|
|
126
|
+
metricsIgnoreSubmodules: input.config.modules.git_metrics.options.ignore_submodules === true,
|
|
127
|
+
tagMaxCandidates: input.config.modules.git_commit.options.tag_max_candidates as number,
|
|
128
|
+
inspectBare:
|
|
129
|
+
requirements.has("git_branch") && input.config.modules.git_branch.options.ignore_bare_repo === false,
|
|
130
|
+
exec: options.gitExec ?? execWorkspaceCommand,
|
|
115
131
|
signal,
|
|
116
132
|
});
|
|
117
133
|
} catch {
|
|
@@ -153,20 +169,22 @@ export default function piStarship(pi: ExtensionAPI, options: PiStarshipOptions
|
|
|
153
169
|
clearTimeout(eventDebounceTimer);
|
|
154
170
|
eventDebounceTimer = undefined;
|
|
155
171
|
};
|
|
156
|
-
const isActiveTarget = (target: RefreshTarget) =>
|
|
157
|
-
activeTarget?.cwd === target.cwd &&
|
|
158
|
-
activeTarget.generation === target.generation &&
|
|
159
|
-
activeTarget.sessionManager === target.sessionManager &&
|
|
160
|
-
target.generation === sessionGeneration;
|
|
172
|
+
const isActiveTarget = (target: RefreshTarget) => activeTarget === target && target.generation === sessionGeneration;
|
|
161
173
|
|
|
162
174
|
const requestRefresh = (target: RefreshTarget, reason: WorkspaceRefreshInput["reason"] = "event") => {
|
|
163
|
-
if (!loaded || !isActiveTarget(target)) return;
|
|
175
|
+
if (!loaded || isNativeFooter(loaded) || !isActiveTarget(target)) return;
|
|
164
176
|
gitController.request({ cwd: target.cwd, config: loaded.config });
|
|
165
177
|
workspaceController.request(workspaceInput(target.cwd, loaded.config, reason, runtime.workspace));
|
|
166
178
|
};
|
|
167
179
|
const scheduleRefresh = (ctx: ExtensionContext) => {
|
|
168
180
|
const target = activeTarget;
|
|
169
|
-
if (
|
|
181
|
+
if (
|
|
182
|
+
!loaded ||
|
|
183
|
+
isNativeFooter(loaded) ||
|
|
184
|
+
!target ||
|
|
185
|
+
target.cwd !== ctx.cwd ||
|
|
186
|
+
target.sessionManager !== ctx.sessionManager
|
|
187
|
+
) {
|
|
170
188
|
return;
|
|
171
189
|
}
|
|
172
190
|
clearDebounce();
|
|
@@ -177,7 +195,7 @@ export default function piStarship(pi: ExtensionAPI, options: PiStarshipOptions
|
|
|
177
195
|
};
|
|
178
196
|
|
|
179
197
|
function restartLocalControllers(target: RefreshTarget) {
|
|
180
|
-
if (!isActiveTarget(target)) return;
|
|
198
|
+
if (!loaded || isNativeFooter(loaded) || !isActiveTarget(target)) return;
|
|
181
199
|
gitController.start(target.generation);
|
|
182
200
|
workspaceController.start(target.generation);
|
|
183
201
|
}
|
|
@@ -196,7 +214,7 @@ export default function piStarship(pi: ExtensionAPI, options: PiStarshipOptions
|
|
|
196
214
|
}
|
|
197
215
|
|
|
198
216
|
function githubPrReachable(): boolean {
|
|
199
|
-
return Boolean(loaded && reachableModuleRequirements(loaded.config).has("github_pr"));
|
|
217
|
+
return Boolean(loaded && !isNativeFooter(loaded) && reachableModuleRequirements(loaded.config).has("github_pr"));
|
|
200
218
|
}
|
|
201
219
|
|
|
202
220
|
function startGithubPr(target: RefreshTarget): boolean {
|
|
@@ -240,14 +258,14 @@ export default function piStarship(pi: ExtensionAPI, options: PiStarshipOptions
|
|
|
240
258
|
githubPrExpiryTimer.unref?.();
|
|
241
259
|
}
|
|
242
260
|
|
|
243
|
-
const
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
261
|
+
const releaseFooter = () => {
|
|
262
|
+
const context = footerContext;
|
|
263
|
+
footerContext = undefined;
|
|
264
|
+
const dispose = disposeFooter;
|
|
265
|
+
disposeFooter = undefined;
|
|
266
|
+
footerCollecting = false;
|
|
267
|
+
dispose?.();
|
|
268
|
+
activeTarget = undefined;
|
|
251
269
|
clearDebounce();
|
|
252
270
|
gitController.stop();
|
|
253
271
|
workspaceController.stop();
|
|
@@ -258,12 +276,32 @@ export default function piStarship(pi: ExtensionAPI, options: PiStarshipOptions
|
|
|
258
276
|
runtime.renderPreview = undefined;
|
|
259
277
|
runtime.inspect = undefined;
|
|
260
278
|
runtime.footerWidth = undefined;
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
279
|
+
context?.ui.setFooter(undefined);
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
const syncFooter = (ctx: ExtensionContext) => {
|
|
283
|
+
const current = previewLoaded ?? loaded;
|
|
284
|
+
if (ctx.mode !== "tui" || !current || isNativeFooter(current)) {
|
|
285
|
+
releaseFooter();
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
// A preview can replace the visible footer, but only applied settings own collectors.
|
|
289
|
+
const collect = Boolean(loaded && !isNativeFooter(loaded));
|
|
290
|
+
if (activeTarget && footerCollecting === collect) return;
|
|
291
|
+
if (activeTarget) releaseFooter();
|
|
292
|
+
footerCollecting = collect;
|
|
293
|
+
const target: RefreshTarget = {
|
|
294
|
+
cwd: ctx.cwd,
|
|
295
|
+
generation: sessionGeneration,
|
|
296
|
+
sessionManager: ctx.sessionManager,
|
|
297
|
+
};
|
|
298
|
+
activeTarget = target;
|
|
299
|
+
footerContext = ctx;
|
|
300
|
+
if (collect) {
|
|
301
|
+
gitController.start(target.generation);
|
|
302
|
+
workspaceController.start(target.generation);
|
|
303
|
+
startGithubPr(target);
|
|
304
|
+
}
|
|
267
305
|
|
|
268
306
|
ctx.ui.setFooter((tui, theme, footerData) => {
|
|
269
307
|
runtime.requestRender = () => tui.requestRender();
|
|
@@ -278,6 +316,10 @@ export default function piStarship(pi: ExtensionAPI, options: PiStarshipOptions
|
|
|
278
316
|
inspectStatuslineModules(current.config, runtimeSnapshot(ctx, footerData, runtime), runtime.footerWidth ?? 80);
|
|
279
317
|
const unsubscribe = footerData.onBranchChange(() => {
|
|
280
318
|
if (!isActiveTarget(target)) return;
|
|
319
|
+
if (!collect) {
|
|
320
|
+
tui.requestRender();
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
281
323
|
runtime.git = undefined;
|
|
282
324
|
restartLocalControllers(target);
|
|
283
325
|
clearDebounce();
|
|
@@ -294,52 +336,67 @@ export default function piStarship(pi: ExtensionAPI, options: PiStarshipOptions
|
|
|
294
336
|
width: number;
|
|
295
337
|
}
|
|
296
338
|
| undefined;
|
|
297
|
-
const timer =
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
lastRender.
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
339
|
+
const timer = collect
|
|
340
|
+
? setInterval(() => {
|
|
341
|
+
if (!isActiveTarget(target)) return;
|
|
342
|
+
clearDebounce();
|
|
343
|
+
requestRefresh(target, "periodic");
|
|
344
|
+
// Collectors publish only changed snapshots. The clock is the sole value
|
|
345
|
+
// that changes without publication; reuse the last render's session data.
|
|
346
|
+
if (!lastRender) return;
|
|
347
|
+
const clock = reachableModuleRequirements(lastRender.config).get("time");
|
|
348
|
+
const range = lastRender.config.modules.time.options.time_range;
|
|
349
|
+
if (!clock || (!clock.has("time") && (!range || range === "-"))) return;
|
|
350
|
+
const now = new Date();
|
|
351
|
+
const previous = lastRender.snapshot.now;
|
|
352
|
+
if (
|
|
353
|
+
!lastRender.config.modules.time.options.time_format &&
|
|
354
|
+
lastRender.config.modules.time.options.utc_time_offset === "local" &&
|
|
355
|
+
(!range || range === "-") &&
|
|
356
|
+
now.getHours() === previous.getHours() &&
|
|
357
|
+
now.getMinutes() === previous.getMinutes()
|
|
358
|
+
)
|
|
359
|
+
return;
|
|
360
|
+
const lines = wrapFormattedStatusline(
|
|
361
|
+
renderStatusline(
|
|
362
|
+
lastRender.config,
|
|
363
|
+
{ ...lastRender.snapshot, now },
|
|
364
|
+
lastRender.width,
|
|
365
|
+
getCapabilities().trueColor,
|
|
366
|
+
theme.colors,
|
|
367
|
+
).ansi,
|
|
368
|
+
lastRender.width,
|
|
369
|
+
);
|
|
370
|
+
const previousLines = lastRender.lines;
|
|
371
|
+
if (lines.length !== previousLines.length || lines.some((line, index) => line !== previousLines[index]))
|
|
372
|
+
tui.requestRender();
|
|
373
|
+
}, REFRESH_INTERVAL_MS)
|
|
374
|
+
: undefined;
|
|
321
375
|
let disposed = false;
|
|
322
376
|
|
|
377
|
+
const dispose = () => {
|
|
378
|
+
if (disposed) return;
|
|
379
|
+
disposed = true;
|
|
380
|
+
unsubscribe();
|
|
381
|
+
clearInterval(timer);
|
|
382
|
+
if (isActiveTarget(target)) {
|
|
383
|
+
activeTarget = undefined;
|
|
384
|
+
footerCollecting = false;
|
|
385
|
+
clearDebounce();
|
|
386
|
+
gitController.stop();
|
|
387
|
+
workspaceController.stop();
|
|
388
|
+
stopGithubPr();
|
|
389
|
+
runtime.git = undefined;
|
|
390
|
+
runtime.workspace = undefined;
|
|
391
|
+
runtime.requestRender = undefined;
|
|
392
|
+
runtime.renderPreview = undefined;
|
|
393
|
+
runtime.inspect = undefined;
|
|
394
|
+
runtime.footerWidth = undefined;
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
disposeFooter = dispose;
|
|
323
398
|
return {
|
|
324
|
-
dispose
|
|
325
|
-
if (disposed) return;
|
|
326
|
-
disposed = true;
|
|
327
|
-
unsubscribe();
|
|
328
|
-
clearInterval(timer);
|
|
329
|
-
if (isActiveTarget(target)) {
|
|
330
|
-
activeTarget = undefined;
|
|
331
|
-
clearDebounce();
|
|
332
|
-
gitController.stop();
|
|
333
|
-
workspaceController.stop();
|
|
334
|
-
stopGithubPr();
|
|
335
|
-
runtime.git = undefined;
|
|
336
|
-
runtime.workspace = undefined;
|
|
337
|
-
runtime.requestRender = undefined;
|
|
338
|
-
runtime.renderPreview = undefined;
|
|
339
|
-
runtime.inspect = undefined;
|
|
340
|
-
runtime.footerWidth = undefined;
|
|
341
|
-
}
|
|
342
|
-
},
|
|
399
|
+
dispose,
|
|
343
400
|
invalidate() {},
|
|
344
401
|
render(width: number): string[] {
|
|
345
402
|
runtime.footerWidth = width;
|
|
@@ -359,9 +416,27 @@ export default function piStarship(pi: ExtensionAPI, options: PiStarshipOptions
|
|
|
359
416
|
requestGithubPr(target);
|
|
360
417
|
};
|
|
361
418
|
|
|
419
|
+
const installFooter = (ctx: ExtensionContext) => {
|
|
420
|
+
releaseFooter();
|
|
421
|
+
sessionGeneration += 1;
|
|
422
|
+
commandInFlight = undefined;
|
|
423
|
+
sessionOwner = ctx.sessionManager;
|
|
424
|
+
previewLoaded = undefined;
|
|
425
|
+
menuController.abort(new DOMException("Starship session context replaced", "AbortError"));
|
|
426
|
+
menuController = new AbortController();
|
|
427
|
+
ctx.ui.setStatus("starship", undefined);
|
|
428
|
+
syncFooter(ctx);
|
|
429
|
+
};
|
|
430
|
+
|
|
362
431
|
const configPath = settingsFilePath(getAgentDir());
|
|
363
432
|
const commandOptions: StarshipCommandOptions = {
|
|
364
433
|
settingsPath: configPath,
|
|
434
|
+
registerChatCleanup(cleanup) {
|
|
435
|
+
chatCleanup = cleanup;
|
|
436
|
+
return () => {
|
|
437
|
+
if (chatCleanup === cleanup) chatCleanup = undefined;
|
|
438
|
+
};
|
|
439
|
+
},
|
|
365
440
|
getLoaded: () => loaded ?? loadStarshipConfig(configPath),
|
|
366
441
|
getLoadedRevision: () => loadedRevision,
|
|
367
442
|
getInspection: () => {
|
|
@@ -382,8 +457,10 @@ export default function piStarship(pi: ExtensionAPI, options: PiStarshipOptions
|
|
|
382
457
|
previewLoaded = undefined;
|
|
383
458
|
loaded = next;
|
|
384
459
|
loadedRevision += 1;
|
|
460
|
+
const previousTarget = activeTarget;
|
|
461
|
+
syncFooter(ctx);
|
|
385
462
|
const target = activeTarget;
|
|
386
|
-
if (target) {
|
|
463
|
+
if (target && target === previousTarget) {
|
|
387
464
|
restartLocalControllers(target);
|
|
388
465
|
startGithubPr(target);
|
|
389
466
|
requestRefresh(target);
|
|
@@ -394,14 +471,35 @@ export default function piStarship(pi: ExtensionAPI, options: PiStarshipOptions
|
|
|
394
471
|
preview(next, ctx) {
|
|
395
472
|
if (sessionOwner !== ctx.sessionManager) return;
|
|
396
473
|
previewLoaded = next;
|
|
474
|
+
syncFooter(ctx);
|
|
397
475
|
refresh();
|
|
398
476
|
},
|
|
399
|
-
renderPreview(preview, width) {
|
|
400
|
-
|
|
477
|
+
renderPreview(preview, width, ctx) {
|
|
478
|
+
if (isNativeFooter(preview)) return ["Pi built-in footer"];
|
|
479
|
+
if (runtime.renderPreview) return runtime.renderPreview(preview, width);
|
|
480
|
+
// Native mode has no custom footer provider. Render the candidate with
|
|
481
|
+
// session data only; collectors start when a custom footer is installed.
|
|
482
|
+
return wrapFormattedStatusline(
|
|
483
|
+
renderStatusline(
|
|
484
|
+
preview.config,
|
|
485
|
+
runtimeSnapshot(
|
|
486
|
+
ctx,
|
|
487
|
+
{
|
|
488
|
+
getGitBranch: () => null,
|
|
489
|
+
getExtensionStatuses: () => new Map(),
|
|
490
|
+
},
|
|
491
|
+
runtime,
|
|
492
|
+
),
|
|
493
|
+
width,
|
|
494
|
+
getCapabilities().trueColor,
|
|
495
|
+
ctx.ui.theme.colors,
|
|
496
|
+
).ansi,
|
|
497
|
+
width,
|
|
498
|
+
);
|
|
401
499
|
},
|
|
402
500
|
};
|
|
403
501
|
pi.registerCommand("starship", {
|
|
404
|
-
description: "
|
|
502
|
+
description: "Configure the footer with agent, presets, profiles, and recovery",
|
|
405
503
|
getArgumentCompletions: completeStarshipArguments,
|
|
406
504
|
handler: async (args, ctx) => {
|
|
407
505
|
const interactive = ctx.mode === "tui" && (!args.trim() || args.trim().toLowerCase() === "settings");
|
|
@@ -441,20 +539,14 @@ export default function piStarship(pi: ExtensionAPI, options: PiStarshipOptions
|
|
|
441
539
|
refresh();
|
|
442
540
|
});
|
|
443
541
|
|
|
444
|
-
pi.on("session_shutdown", (_event, ctx) => {
|
|
542
|
+
pi.on("session_shutdown", async (_event, ctx) => {
|
|
445
543
|
if (sessionOwner !== ctx.sessionManager) return;
|
|
446
544
|
sessionOwner = undefined;
|
|
447
545
|
commandInFlight = undefined;
|
|
448
546
|
previewLoaded = undefined;
|
|
449
547
|
sessionGeneration += 1;
|
|
450
548
|
menuController.abort(new DOMException("Starship session shut down", "AbortError"));
|
|
451
|
-
|
|
452
|
-
clearDebounce();
|
|
453
|
-
gitController.stop();
|
|
454
|
-
workspaceController.stop();
|
|
455
|
-
stopGithubPr();
|
|
456
|
-
runtime.git = undefined;
|
|
457
|
-
runtime.workspace = undefined;
|
|
549
|
+
releaseFooter();
|
|
458
550
|
runtime.activeTools.clear();
|
|
459
551
|
runtime.isStreaming = false;
|
|
460
552
|
runtime.uiPrompt = undefined;
|
|
@@ -463,8 +555,10 @@ export default function piStarship(pi: ExtensionAPI, options: PiStarshipOptions
|
|
|
463
555
|
runtime.renderPreview = undefined;
|
|
464
556
|
runtime.inspect = undefined;
|
|
465
557
|
runtime.footerWidth = undefined;
|
|
466
|
-
ctx.ui.setFooter(undefined);
|
|
467
558
|
ctx.ui.setStatus("starship", undefined);
|
|
559
|
+
const cleanup = chatCleanup;
|
|
560
|
+
chatCleanup = undefined;
|
|
561
|
+
await cleanup?.();
|
|
468
562
|
});
|
|
469
563
|
|
|
470
564
|
pi.on("model_select", () => refresh());
|
|
@@ -515,6 +609,10 @@ export default function piStarship(pi: ExtensionAPI, options: PiStarshipOptions
|
|
|
515
609
|
});
|
|
516
610
|
}
|
|
517
611
|
|
|
612
|
+
function isNativeFooter(loaded: LoadedStarshipConfig): boolean {
|
|
613
|
+
return loaded.rawDocument === undefined && loaded.diagnostics.length === 0;
|
|
614
|
+
}
|
|
615
|
+
|
|
518
616
|
function workspaceInput(
|
|
519
617
|
cwd: string,
|
|
520
618
|
config: StarshipConfig,
|
|
@@ -576,12 +674,24 @@ const ENVIRONMENT_ALLOWLIST = [
|
|
|
576
674
|
|
|
577
675
|
function allowlistedEnvironment(config: StarshipConfig): Record<string, string | undefined> {
|
|
578
676
|
const result: Record<string, string | undefined> = {};
|
|
579
|
-
const configured = config.modules
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
677
|
+
const configured = Object.values(config.modules)
|
|
678
|
+
.flatMap((module) => {
|
|
679
|
+
const names = module.options.detect_env_vars;
|
|
680
|
+
return Array.isArray(names) ? names.filter((name): name is string => typeof name === "string") : [];
|
|
681
|
+
})
|
|
682
|
+
.map((name) => name.replace(/^!/u, ""))
|
|
683
|
+
.filter((name) => /^[A-Za-z_][A-Za-z0-9_]*$/u.test(name));
|
|
684
|
+
const names = new Set([...ENVIRONMENT_ALLOWLIST, ...configured]);
|
|
685
|
+
for (const name of names) {
|
|
686
|
+
const value =
|
|
687
|
+
Object.hasOwn(process.env, name) && typeof process.env[name] === "string" ? process.env[name] : undefined;
|
|
688
|
+
Object.defineProperty(result, name, {
|
|
689
|
+
value,
|
|
690
|
+
enumerable: true,
|
|
691
|
+
configurable: true,
|
|
692
|
+
writable: true,
|
|
693
|
+
});
|
|
694
|
+
}
|
|
585
695
|
return result;
|
|
586
696
|
}
|
|
587
697
|
|
|
@@ -595,7 +705,7 @@ function safeUsername(): string {
|
|
|
595
705
|
|
|
596
706
|
function runtimeSnapshot(
|
|
597
707
|
ctx: ExtensionContext,
|
|
598
|
-
footerData: ReadonlyFooterDataProvider,
|
|
708
|
+
footerData: Pick<ReadonlyFooterDataProvider, "getGitBranch" | "getExtensionStatuses">,
|
|
599
709
|
runtime: RuntimeState,
|
|
600
710
|
): StarshipRuntimeSnapshot {
|
|
601
711
|
return {
|
package/src/profile-store.ts
CHANGED
|
@@ -213,6 +213,11 @@ export function readProfile(settingsPath: string, name: string): ProfileDocument
|
|
|
213
213
|
});
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
+
/** Reject a removed, replaced, or edited profile before applying its reviewed snapshot. */
|
|
217
|
+
export function assertProfileUnchanged(settingsPath: string, expected: ProfileDocument): void {
|
|
218
|
+
assertExpected(readProfile(settingsPath, expected.name), expected);
|
|
219
|
+
}
|
|
220
|
+
|
|
216
221
|
export function listProfiles(settingsPath: string): ProfileDocument[] {
|
|
217
222
|
const directory = profileDirectory(settingsPath);
|
|
218
223
|
if (!checkedDirectory(directory)) return [];
|
package/src/runtime/cloud.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { parse as parseYaml } from "yaml";
|
|
3
3
|
import {
|
|
4
|
+
detectEnvironment,
|
|
4
5
|
exactAlias,
|
|
5
6
|
isRecord,
|
|
6
7
|
joinHome,
|
|
7
8
|
MAX_METADATA_FILE_BYTES,
|
|
8
9
|
optionBoolean,
|
|
9
10
|
optionMap,
|
|
11
|
+
optionStrings,
|
|
10
12
|
parseIni,
|
|
11
13
|
safeMetadata,
|
|
12
14
|
} from "./helpers.js";
|
|
@@ -55,6 +57,7 @@ async function collectAws(context: CollectorContext): Promise<Record<string, str
|
|
|
55
57
|
|
|
56
58
|
async function collectGcloud(context: CollectorContext): Promise<Record<string, string> | undefined> {
|
|
57
59
|
const env = context.input.environment;
|
|
60
|
+
if (!detectEnvironment(env, optionStrings(context, "gcloud", "detect_env_vars"))) return undefined;
|
|
58
61
|
const directory = safeMetadata(env.CLOUDSDK_CONFIG, 1_024) ?? joinHome(context.input, ".config", "gcloud");
|
|
59
62
|
const active =
|
|
60
63
|
safeMetadata(env.CLOUDSDK_ACTIVE_CONFIG_NAME) ??
|
package/src/runtime/command.ts
CHANGED
|
@@ -107,7 +107,7 @@ export const execWorkspaceCommand: WorkspaceExec = async (command, args, options
|
|
|
107
107
|
function explicitEnvironment(source: Readonly<Record<string, string | undefined>>): NodeJS.ProcessEnv {
|
|
108
108
|
const result: NodeJS.ProcessEnv = Object.create(null);
|
|
109
109
|
for (const [name, value] of Object.entries(source)) {
|
|
110
|
-
if (!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(name) || value
|
|
110
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(name) || typeof value !== "string" || value.includes("\0")) {
|
|
111
111
|
continue;
|
|
112
112
|
}
|
|
113
113
|
Object.defineProperty(result, name, {
|