@narumitw/pi-starship 0.24.0 → 0.29.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/NOTICES.md +18 -1
- package/README.md +202 -16
- package/package.json +4 -3
- package/src/commands.ts +405 -22
- package/src/config.ts +113 -11
- package/src/format/formatter.ts +26 -11
- package/src/format/style.ts +13 -1
- package/src/index.ts +1 -0
- package/src/modules/catalog.ts +20 -0
- package/src/modules/cloud.ts +74 -0
- package/src/modules/deployment.ts +61 -0
- package/src/modules/development.ts +95 -0
- package/src/modules/execution.ts +73 -0
- package/src/modules/extension-status.ts +33 -1
- package/src/modules/fill.ts +14 -0
- package/src/modules/git/branch.ts +7 -3
- package/src/modules/git/commit.ts +22 -0
- package/src/modules/git/metrics.ts +20 -0
- package/src/modules/git/runtime.ts +320 -41
- package/src/modules/git/state.ts +21 -0
- package/src/modules/git/status.ts +62 -11
- package/src/modules/index.ts +7 -1
- package/src/modules/languages.ts +87 -0
- package/src/modules/package.ts +17 -0
- package/src/modules/render.ts +97 -9
- package/src/modules/types.ts +65 -2
- package/src/modules/workspace-helpers.ts +10 -0
- package/src/pi-starship.ts +230 -104
- package/src/runtime/cloud.ts +166 -0
- package/src/runtime/command.ts +85 -0
- package/src/runtime/deployment.ts +201 -0
- package/src/runtime/development.ts +154 -0
- package/src/runtime/execution.ts +141 -0
- package/src/runtime/helpers.ts +273 -0
- package/src/runtime/languages.ts +205 -0
- package/src/runtime/package.ts +112 -0
- package/src/runtime/refresh-controller.ts +85 -0
- package/src/runtime/types.ts +59 -0
- package/src/runtime/workspace.ts +110 -0
package/src/format/formatter.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type ColorPalette,
|
|
3
|
+
isFillChunk,
|
|
4
|
+
type LayoutChunk,
|
|
5
|
+
parseStyle,
|
|
6
|
+
type TextStyle,
|
|
7
|
+
} from "./style.js";
|
|
2
8
|
|
|
3
9
|
export type FormatNode =
|
|
4
10
|
| { type: "text"; value: string }
|
|
@@ -7,7 +13,7 @@ export type FormatNode =
|
|
|
7
13
|
| { type: "conditional"; children: FormatNode[] };
|
|
8
14
|
|
|
9
15
|
export type StyleNode = { type: "text"; value: string } | { type: "variable"; name: string };
|
|
10
|
-
export type FormatValue = string | readonly
|
|
16
|
+
export type FormatValue = string | readonly LayoutChunk[] | undefined;
|
|
11
17
|
|
|
12
18
|
export interface RenderFormatOptions {
|
|
13
19
|
variables: Readonly<Record<string, FormatValue>>;
|
|
@@ -191,7 +197,7 @@ export function styleVariables(nodes: readonly FormatNode[]): Set<string> {
|
|
|
191
197
|
export function renderFormat(
|
|
192
198
|
nodes: readonly FormatNode[],
|
|
193
199
|
options: RenderFormatOptions,
|
|
194
|
-
):
|
|
200
|
+
): LayoutChunk[] {
|
|
195
201
|
return renderNodes(nodes, options, undefined);
|
|
196
202
|
}
|
|
197
203
|
|
|
@@ -199,8 +205,8 @@ function renderNodes(
|
|
|
199
205
|
nodes: readonly FormatNode[],
|
|
200
206
|
options: RenderFormatOptions,
|
|
201
207
|
inheritedStyle: TextStyle | undefined,
|
|
202
|
-
):
|
|
203
|
-
const chunks:
|
|
208
|
+
): LayoutChunk[] {
|
|
209
|
+
const chunks: LayoutChunk[] = [];
|
|
204
210
|
for (const node of nodes) {
|
|
205
211
|
switch (node.type) {
|
|
206
212
|
case "text":
|
|
@@ -235,13 +241,20 @@ function ownValue<T>(record: Readonly<Record<string, T>> | undefined, key: strin
|
|
|
235
241
|
return record && Object.hasOwn(record, key) ? record[key] : undefined;
|
|
236
242
|
}
|
|
237
243
|
|
|
238
|
-
function chunksForValue(value: FormatValue, inheritedStyle: TextStyle | undefined):
|
|
244
|
+
function chunksForValue(value: FormatValue, inheritedStyle: TextStyle | undefined): LayoutChunk[] {
|
|
239
245
|
if (value === undefined) return [];
|
|
240
246
|
if (typeof value === "string") return [{ text: value, style: inheritedStyle }];
|
|
241
|
-
return value.map((chunk) =>
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
247
|
+
return value.map((chunk) =>
|
|
248
|
+
isFillChunk(chunk)
|
|
249
|
+
? {
|
|
250
|
+
type: "fill" as const,
|
|
251
|
+
pattern: chunk.pattern.map((part) => ({
|
|
252
|
+
...part,
|
|
253
|
+
style: part.style ?? inheritedStyle,
|
|
254
|
+
})),
|
|
255
|
+
}
|
|
256
|
+
: { ...chunk, style: chunk.style ?? inheritedStyle },
|
|
257
|
+
);
|
|
245
258
|
}
|
|
246
259
|
|
|
247
260
|
function conditionalVisible(
|
|
@@ -251,7 +264,9 @@ function conditionalVisible(
|
|
|
251
264
|
for (const variable of formatVariables(nodes)) {
|
|
252
265
|
const value = ownValue(variables, variable);
|
|
253
266
|
if (
|
|
254
|
-
typeof value === "string"
|
|
267
|
+
typeof value === "string"
|
|
268
|
+
? value.length > 0
|
|
269
|
+
: value?.some((chunk) => isFillChunk(chunk) || chunk.text.length > 0)
|
|
255
270
|
) {
|
|
256
271
|
return true;
|
|
257
272
|
}
|
package/src/format/style.ts
CHANGED
|
@@ -40,6 +40,17 @@ export interface StyledChunk {
|
|
|
40
40
|
style?: TextStyle;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
export interface FillChunk {
|
|
44
|
+
type: "fill";
|
|
45
|
+
pattern: readonly StyledChunk[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type LayoutChunk = StyledChunk | FillChunk;
|
|
49
|
+
|
|
50
|
+
export function isFillChunk(chunk: LayoutChunk): chunk is FillChunk {
|
|
51
|
+
return "type" in chunk && chunk.type === "fill";
|
|
52
|
+
}
|
|
53
|
+
|
|
43
54
|
export type ColorPalette = Readonly<Record<string, string>>;
|
|
44
55
|
|
|
45
56
|
const NAMED_COLORS = new Set<NamedColor>([
|
|
@@ -176,10 +187,11 @@ interface ResolvedStyle extends Omit<TextStyle, "foreground" | "background"> {
|
|
|
176
187
|
background?: Exclude<ColorSpec, { kind: "previous" }>;
|
|
177
188
|
}
|
|
178
189
|
|
|
179
|
-
export function renderChunksToAnsi(chunks: readonly
|
|
190
|
+
export function renderChunksToAnsi(chunks: readonly LayoutChunk[]): string {
|
|
180
191
|
const runs: Array<{ text: string; style: ResolvedStyle }> = [];
|
|
181
192
|
let previous: ResolvedStyle | undefined;
|
|
182
193
|
for (const chunk of chunks) {
|
|
194
|
+
if (isFillChunk(chunk)) continue;
|
|
183
195
|
const style = resolveStyle(chunk.style, previous);
|
|
184
196
|
const last = runs.at(-1);
|
|
185
197
|
if (chunk.text && last && stylesEqual(last.style, style)) last.text += chunk.text;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./pi-starship.js";
|
package/src/modules/catalog.ts
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import { activityModule } from "./activity.js";
|
|
2
2
|
import { brandModule } from "./brand.js";
|
|
3
|
+
import { cloudModules } from "./cloud.js";
|
|
3
4
|
import { contextModule } from "./context.js";
|
|
4
5
|
import { costModule } from "./cost.js";
|
|
6
|
+
import { deploymentModules } from "./deployment.js";
|
|
7
|
+
import { developmentModules } from "./development.js";
|
|
5
8
|
import { directoryModule } from "./directory.js";
|
|
9
|
+
import { executionModules } from "./execution.js";
|
|
6
10
|
import { extensionStatusModule } from "./extension-status.js";
|
|
11
|
+
import { fillModule } from "./fill.js";
|
|
7
12
|
import { gitBranchModule } from "./git/branch.js";
|
|
13
|
+
import { gitCommitModule } from "./git/commit.js";
|
|
14
|
+
import { gitMetricsModule } from "./git/metrics.js";
|
|
15
|
+
import { gitStateModule } from "./git/state.js";
|
|
8
16
|
import { gitStatusModule } from "./git/status.js";
|
|
9
17
|
import { gitWorktreeModule } from "./git/worktree.js";
|
|
18
|
+
import { languageModules } from "./languages.js";
|
|
10
19
|
import { modelModule } from "./model.js";
|
|
20
|
+
import { packageModule } from "./package.js";
|
|
11
21
|
import { providerModule } from "./provider.js";
|
|
12
22
|
import { thinkingModule } from "./thinking.js";
|
|
13
23
|
import { timeModule } from "./time.js";
|
|
@@ -23,13 +33,23 @@ export const MODULE_DEFINITIONS = [
|
|
|
23
33
|
directoryModule,
|
|
24
34
|
gitWorktreeModule,
|
|
25
35
|
gitBranchModule,
|
|
36
|
+
gitCommitModule,
|
|
37
|
+
gitStateModule,
|
|
38
|
+
gitMetricsModule,
|
|
26
39
|
gitStatusModule,
|
|
40
|
+
packageModule,
|
|
41
|
+
...languageModules,
|
|
42
|
+
...developmentModules,
|
|
43
|
+
...deploymentModules,
|
|
44
|
+
...cloudModules,
|
|
45
|
+
...executionModules,
|
|
27
46
|
activityModule,
|
|
28
47
|
contextModule,
|
|
29
48
|
tokensModule,
|
|
30
49
|
costModule,
|
|
31
50
|
timeModule,
|
|
32
51
|
turnModule,
|
|
52
|
+
fillModule,
|
|
33
53
|
// Render last so earlier modules can consume extension-owned status values.
|
|
34
54
|
extensionStatusModule,
|
|
35
55
|
] as const satisfies readonly ModuleDefinition<string>[];
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { defineModule, type ModuleDefinition, type ModuleOptionSchema } from "./types.js";
|
|
2
|
+
import { workspaceModuleValues } from "./workspace-helpers.js";
|
|
3
|
+
|
|
4
|
+
function cloudModule<const Name extends string>(definition: {
|
|
5
|
+
name: Name;
|
|
6
|
+
variables: readonly string[];
|
|
7
|
+
format: string;
|
|
8
|
+
symbol: string;
|
|
9
|
+
style: string;
|
|
10
|
+
options: Readonly<Record<string, ModuleOptionSchema>>;
|
|
11
|
+
}): ModuleDefinition<Name> {
|
|
12
|
+
return defineModule({
|
|
13
|
+
name: definition.name,
|
|
14
|
+
variables: ["symbol", ...definition.variables],
|
|
15
|
+
defaults: {
|
|
16
|
+
format: definition.format,
|
|
17
|
+
symbol: definition.symbol,
|
|
18
|
+
style: definition.style,
|
|
19
|
+
disabled: false,
|
|
20
|
+
},
|
|
21
|
+
options: definition.options,
|
|
22
|
+
values: (context) => workspaceModuleValues(definition.name, context),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const awsModule = cloudModule({
|
|
27
|
+
name: "aws",
|
|
28
|
+
variables: ["profile", "region"],
|
|
29
|
+
format: "on [$symbol($profile )(\\($region\\) )]($style)",
|
|
30
|
+
symbol: "☁️ ",
|
|
31
|
+
style: "bold yellow",
|
|
32
|
+
options: {
|
|
33
|
+
profile_aliases: { kind: "string-map", default: {} },
|
|
34
|
+
region_aliases: { kind: "string-map", default: {} },
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const gcloudModule = cloudModule({
|
|
39
|
+
name: "gcloud",
|
|
40
|
+
variables: ["active", "account", "domain", "project", "region"],
|
|
41
|
+
format: "on [$symbol$project]($style) ",
|
|
42
|
+
symbol: "☁️ ",
|
|
43
|
+
style: "bold blue",
|
|
44
|
+
options: {
|
|
45
|
+
project_aliases: { kind: "string-map", default: {} },
|
|
46
|
+
region_aliases: { kind: "string-map", default: {} },
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export const azureModule = cloudModule({
|
|
51
|
+
name: "azure",
|
|
52
|
+
variables: ["subscription", "username"],
|
|
53
|
+
format: "on [$symbol$subscription]($style) ",
|
|
54
|
+
symbol: " ",
|
|
55
|
+
style: "blue bold",
|
|
56
|
+
options: {
|
|
57
|
+
subscription_aliases: { kind: "string-map", default: {} },
|
|
58
|
+
show_username: { kind: "boolean", default: false },
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export const openstackModule = cloudModule({
|
|
63
|
+
name: "openstack",
|
|
64
|
+
variables: ["cloud", "project"],
|
|
65
|
+
format: "on [$symbol$cloud( \\($project\\))]($style) ",
|
|
66
|
+
symbol: "☁️ ",
|
|
67
|
+
style: "bold yellow",
|
|
68
|
+
options: {
|
|
69
|
+
cloud_aliases: { kind: "string-map", default: {} },
|
|
70
|
+
project_aliases: { kind: "string-map", default: {} },
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export const cloudModules = [awsModule, gcloudModule, azureModule, openstackModule] as const;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { defineModule } from "./types.js";
|
|
2
|
+
import { workspaceModuleValues } from "./workspace-helpers.js";
|
|
3
|
+
|
|
4
|
+
const directDetection = {
|
|
5
|
+
detect_files: { kind: "string-array", default: [] },
|
|
6
|
+
detect_extensions: { kind: "string-array", default: [] },
|
|
7
|
+
detect_folders: { kind: "string-array", default: [] },
|
|
8
|
+
} as const;
|
|
9
|
+
|
|
10
|
+
export const dockerContextModule = defineModule({
|
|
11
|
+
name: "docker_context",
|
|
12
|
+
variables: ["symbol", "context"],
|
|
13
|
+
defaults: {
|
|
14
|
+
format: "via [$symbol$context]($style) ",
|
|
15
|
+
symbol: " ",
|
|
16
|
+
style: "blue bold",
|
|
17
|
+
disabled: false,
|
|
18
|
+
},
|
|
19
|
+
options: {
|
|
20
|
+
...directDetection,
|
|
21
|
+
only_with_files: { kind: "boolean", default: false },
|
|
22
|
+
},
|
|
23
|
+
values: (context) => workspaceModuleValues("docker_context", context),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const kubernetesModule = defineModule({
|
|
27
|
+
name: "kubernetes",
|
|
28
|
+
variables: ["symbol", "context", "namespace", "cluster", "user"],
|
|
29
|
+
defaults: {
|
|
30
|
+
format: "on [$symbol$context( \\($namespace\\))]($style) ",
|
|
31
|
+
symbol: "☸ ",
|
|
32
|
+
style: "cyan bold",
|
|
33
|
+
disabled: false,
|
|
34
|
+
},
|
|
35
|
+
options: {
|
|
36
|
+
context_aliases: { kind: "string-map", default: {} },
|
|
37
|
+
namespace_aliases: { kind: "string-map", default: {} },
|
|
38
|
+
cluster_aliases: { kind: "string-map", default: {} },
|
|
39
|
+
user_aliases: { kind: "string-map", default: {} },
|
|
40
|
+
max_config_files: { kind: "integer", default: 8, minimum: 1, maximum: 32 },
|
|
41
|
+
},
|
|
42
|
+
values: (context) => workspaceModuleValues("kubernetes", context),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const terraformModule = defineModule({
|
|
46
|
+
name: "terraform",
|
|
47
|
+
variables: ["symbol", "workspace", "version"],
|
|
48
|
+
defaults: {
|
|
49
|
+
format: "via [$symbol$workspace]($style) ",
|
|
50
|
+
symbol: "💠 ",
|
|
51
|
+
style: "bold 105",
|
|
52
|
+
disabled: false,
|
|
53
|
+
},
|
|
54
|
+
options: {
|
|
55
|
+
...directDetection,
|
|
56
|
+
version_format: { kind: "string", default: "v$raw" },
|
|
57
|
+
},
|
|
58
|
+
values: (context) => workspaceModuleValues("terraform", context),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const deploymentModules = [dockerContextModule, kubernetesModule, terraformModule] as const;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { defineModule, type ModuleDefinition, type ModuleOptionSchema } from "./types.js";
|
|
2
|
+
import { workspaceModuleValues } from "./workspace-helpers.js";
|
|
3
|
+
|
|
4
|
+
function developmentModule<const Name extends string>(definition: {
|
|
5
|
+
name: Name;
|
|
6
|
+
variables: readonly string[];
|
|
7
|
+
format: string;
|
|
8
|
+
symbol: string;
|
|
9
|
+
style: string;
|
|
10
|
+
options?: Readonly<Record<string, ModuleOptionSchema>>;
|
|
11
|
+
}): ModuleDefinition<Name> {
|
|
12
|
+
return defineModule({
|
|
13
|
+
name: definition.name,
|
|
14
|
+
variables: ["symbol", ...definition.variables],
|
|
15
|
+
defaults: {
|
|
16
|
+
format: definition.format,
|
|
17
|
+
symbol: definition.symbol,
|
|
18
|
+
style: definition.style,
|
|
19
|
+
disabled: false,
|
|
20
|
+
},
|
|
21
|
+
options: definition.options,
|
|
22
|
+
values: (context) => workspaceModuleValues(definition.name, context),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const directDetection = {
|
|
27
|
+
detect_files: { kind: "string-array", default: [] },
|
|
28
|
+
detect_extensions: { kind: "string-array", default: [] },
|
|
29
|
+
detect_folders: { kind: "string-array", default: [] },
|
|
30
|
+
} as const;
|
|
31
|
+
|
|
32
|
+
export const miseModule = developmentModule({
|
|
33
|
+
name: "mise",
|
|
34
|
+
variables: ["health"],
|
|
35
|
+
format: "via [$symbol$health]($style) ",
|
|
36
|
+
symbol: "mise ",
|
|
37
|
+
style: "bold purple",
|
|
38
|
+
options: directDetection,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const direnvModule = developmentModule({
|
|
42
|
+
name: "direnv",
|
|
43
|
+
variables: ["rc_path", "allowed", "loaded"],
|
|
44
|
+
format: "[$symbol$loaded]($style) ",
|
|
45
|
+
symbol: "direnv ",
|
|
46
|
+
style: "bold 208",
|
|
47
|
+
options: directDetection,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export const condaModule = developmentModule({
|
|
51
|
+
name: "conda",
|
|
52
|
+
variables: ["environment"],
|
|
53
|
+
format: "via [$symbol$environment]($style) ",
|
|
54
|
+
symbol: "🅒 ",
|
|
55
|
+
style: "green bold",
|
|
56
|
+
options: { ignore_base: { kind: "boolean", default: true } },
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export const pixiModule = developmentModule({
|
|
60
|
+
name: "pixi",
|
|
61
|
+
variables: ["version", "environment", "project_name"],
|
|
62
|
+
format: "via [$symbol$environment]($style) ",
|
|
63
|
+
symbol: "🧚 ",
|
|
64
|
+
style: "yellow bold",
|
|
65
|
+
options: {
|
|
66
|
+
...directDetection,
|
|
67
|
+
version_format: { kind: "string", default: "v$raw" },
|
|
68
|
+
show_default_environment: { kind: "boolean", default: false },
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const nixShellModule = developmentModule({
|
|
73
|
+
name: "nix_shell",
|
|
74
|
+
variables: ["state", "name", "level"],
|
|
75
|
+
format: "via [$symbol$state( \\($name\\))]($style) ",
|
|
76
|
+
symbol: " ",
|
|
77
|
+
style: "bold blue",
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export const guixShellModule = developmentModule({
|
|
81
|
+
name: "guix_shell",
|
|
82
|
+
variables: ["state"],
|
|
83
|
+
format: "via [$symbol]($style) ",
|
|
84
|
+
symbol: "🐃 ",
|
|
85
|
+
style: "yellow bold",
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export const developmentModules = [
|
|
89
|
+
miseModule,
|
|
90
|
+
direnvModule,
|
|
91
|
+
condaModule,
|
|
92
|
+
pixiModule,
|
|
93
|
+
nixShellModule,
|
|
94
|
+
guixShellModule,
|
|
95
|
+
] as const;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { defineModule } from "./types.js";
|
|
2
|
+
import { workspaceModuleValues } from "./workspace-helpers.js";
|
|
3
|
+
|
|
4
|
+
export const osModule = defineModule({
|
|
5
|
+
name: "os",
|
|
6
|
+
variables: ["symbol", "type", "name", "version", "edition", "codename"],
|
|
7
|
+
defaults: {
|
|
8
|
+
format: "[$symbol($name )]($style)",
|
|
9
|
+
symbol: "",
|
|
10
|
+
style: "bold white",
|
|
11
|
+
disabled: true,
|
|
12
|
+
},
|
|
13
|
+
options: {
|
|
14
|
+
symbols: {
|
|
15
|
+
kind: "string-map",
|
|
16
|
+
default: { linux: "🐧 ", macos: "🍎 ", windows: " ", wsl: " " },
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
values: (context) => workspaceModuleValues("os", context),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const containerModule = defineModule({
|
|
23
|
+
name: "container",
|
|
24
|
+
variables: ["symbol", "name", "type"],
|
|
25
|
+
defaults: {
|
|
26
|
+
format: "[$symbol$name]($style) ",
|
|
27
|
+
symbol: "⬢ ",
|
|
28
|
+
style: "bold red dimmed",
|
|
29
|
+
disabled: false,
|
|
30
|
+
},
|
|
31
|
+
values: (context) => workspaceModuleValues("container", context),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const hostnameModule = defineModule({
|
|
35
|
+
name: "hostname",
|
|
36
|
+
variables: ["symbol", "hostname", "ssh_symbol"],
|
|
37
|
+
defaults: {
|
|
38
|
+
format: "[$ssh_symbol$hostname]($style) in ",
|
|
39
|
+
symbol: "",
|
|
40
|
+
style: "bold dimmed green",
|
|
41
|
+
disabled: false,
|
|
42
|
+
},
|
|
43
|
+
options: {
|
|
44
|
+
ssh_only: { kind: "boolean", default: true },
|
|
45
|
+
trim_at: { kind: "string", default: ".", allowEmpty: false },
|
|
46
|
+
aliases: { kind: "string-map", default: {} },
|
|
47
|
+
},
|
|
48
|
+
values: (context) => workspaceModuleValues("hostname", context),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export const usernameModule = defineModule({
|
|
52
|
+
name: "username",
|
|
53
|
+
variables: ["symbol", "user"],
|
|
54
|
+
defaults: {
|
|
55
|
+
format: "[$user]($style) in ",
|
|
56
|
+
symbol: "",
|
|
57
|
+
style: "yellow bold",
|
|
58
|
+
disabled: false,
|
|
59
|
+
},
|
|
60
|
+
options: {
|
|
61
|
+
show_always: { kind: "boolean", default: false },
|
|
62
|
+
aliases: { kind: "string-map", default: {} },
|
|
63
|
+
detect_env_vars: { kind: "string-array", default: [] },
|
|
64
|
+
},
|
|
65
|
+
values: (context) => workspaceModuleValues("username", context),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export const executionModules = [
|
|
69
|
+
osModule,
|
|
70
|
+
containerModule,
|
|
71
|
+
hostnameModule,
|
|
72
|
+
usernameModule,
|
|
73
|
+
] as const;
|
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
import { defineModule, type ExtensionStatusIconAliasMap } from "./types.js";
|
|
2
2
|
|
|
3
3
|
const DEFAULT_EXTENSION_STATUS_ICONS: Record<string, string> = {
|
|
4
|
+
accounts: "👤",
|
|
5
|
+
caffeinate: "💊",
|
|
4
6
|
"chrome-devtools": "🌐",
|
|
5
7
|
"codex-usage": "📊",
|
|
6
|
-
caffeinate: "💊",
|
|
7
8
|
firecrawl: "🔥",
|
|
8
9
|
"github-pr": "🔎",
|
|
9
10
|
goal: "🎯",
|
|
11
|
+
"google-genai": "✨",
|
|
10
12
|
lsp: "🧰",
|
|
11
13
|
"plan-mode": "📝",
|
|
14
|
+
retry: "🔁",
|
|
12
15
|
pisync: "🔄",
|
|
13
16
|
subagents: "🧑🤝🧑",
|
|
17
|
+
sync: "🔄",
|
|
18
|
+
usage: "📊",
|
|
14
19
|
"unknown-error-retry": "🔁",
|
|
15
20
|
};
|
|
16
21
|
|
|
22
|
+
const COMPATIBLE_STATUS_ICON_KEYS: Readonly<Record<string, string>> = {
|
|
23
|
+
retry: "unknown-error-retry",
|
|
24
|
+
sync: "pisync",
|
|
25
|
+
"unknown-error-retry": "retry",
|
|
26
|
+
pisync: "sync",
|
|
27
|
+
};
|
|
28
|
+
|
|
17
29
|
export const extensionStatusModule = defineModule({
|
|
18
30
|
name: "extension_status",
|
|
19
31
|
variables: ["symbol", "statuses", "count"],
|
|
@@ -64,6 +76,12 @@ function extensionStatusIcon(
|
|
|
64
76
|
aliases: ExtensionStatusIconAliasMap,
|
|
65
77
|
): string {
|
|
66
78
|
if (Object.hasOwn(configuredIcons, key)) return configuredIcons[key] ?? "";
|
|
79
|
+
const namespaceIcon = configuredNamespaceIcon(key, configuredIcons);
|
|
80
|
+
if (namespaceIcon !== undefined) return namespaceIcon;
|
|
81
|
+
const compatibleKey = COMPATIBLE_STATUS_ICON_KEYS[key];
|
|
82
|
+
if (compatibleKey && Object.hasOwn(configuredIcons, compatibleKey)) {
|
|
83
|
+
return configuredIcons[compatibleKey] ?? "";
|
|
84
|
+
}
|
|
67
85
|
for (const alias of extensionStatusAliasesForKey(key, aliases)) {
|
|
68
86
|
if (Object.hasOwn(configuredIcons, alias)) return configuredIcons[alias] ?? "";
|
|
69
87
|
}
|
|
@@ -76,6 +94,20 @@ function extensionStatusIcon(
|
|
|
76
94
|
return leadingIcon ?? defaultIcon ?? fallbackIcon ?? "🔌";
|
|
77
95
|
}
|
|
78
96
|
|
|
97
|
+
function configuredNamespaceIcon(
|
|
98
|
+
key: string,
|
|
99
|
+
configuredIcons: Readonly<Record<string, string>>,
|
|
100
|
+
): string | undefined {
|
|
101
|
+
let match: { baseLength: number; icon: string } | undefined;
|
|
102
|
+
for (const [selector, icon] of Object.entries(configuredIcons)) {
|
|
103
|
+
if (!selector.endsWith(":*")) continue;
|
|
104
|
+
const base = selector.slice(0, -2);
|
|
105
|
+
if (!base || !key.startsWith(`${base}:`)) continue;
|
|
106
|
+
if (!match || base.length > match.baseLength) match = { baseLength: base.length, icon };
|
|
107
|
+
}
|
|
108
|
+
return match?.icon;
|
|
109
|
+
}
|
|
110
|
+
|
|
79
111
|
function extensionStatusAliasesForKey(
|
|
80
112
|
key: string,
|
|
81
113
|
aliases: ExtensionStatusIconAliasMap,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineModule } from "./types.js";
|
|
2
|
+
|
|
3
|
+
export const fillModule = defineModule({
|
|
4
|
+
name: "fill",
|
|
5
|
+
variables: ["symbol"],
|
|
6
|
+
defaults: {
|
|
7
|
+
format: "[$symbol]($style)",
|
|
8
|
+
symbol: " ",
|
|
9
|
+
style: "none",
|
|
10
|
+
disabled: false,
|
|
11
|
+
},
|
|
12
|
+
layout: "fill",
|
|
13
|
+
values: () => ({}),
|
|
14
|
+
});
|
|
@@ -2,7 +2,7 @@ import { defineModule } from "../types.js";
|
|
|
2
2
|
|
|
3
3
|
export const gitBranchModule = defineModule({
|
|
4
4
|
name: "git_branch",
|
|
5
|
-
variables: ["symbol", "branch", "pr"],
|
|
5
|
+
variables: ["symbol", "branch", "remote_name", "remote_branch", "pr"],
|
|
6
6
|
defaults: {
|
|
7
7
|
format: "[ $symbol $branch( $pr) ]($style)",
|
|
8
8
|
symbol: "🌿",
|
|
@@ -10,9 +10,13 @@ export const gitBranchModule = defineModule({
|
|
|
10
10
|
disabled: false,
|
|
11
11
|
},
|
|
12
12
|
values: ({ runtime }) => {
|
|
13
|
-
|
|
13
|
+
const branch = runtime.gitBranchDetails;
|
|
14
|
+
const name = branch?.name ?? runtime.gitBranch;
|
|
15
|
+
if (!name) return undefined;
|
|
14
16
|
return {
|
|
15
|
-
branch:
|
|
17
|
+
branch: name,
|
|
18
|
+
remote_name: branch?.remoteName ?? "",
|
|
19
|
+
remote_branch: branch?.remoteBranch ?? "",
|
|
16
20
|
pr: prContextFromStatuses(runtime.extensionStatuses) ?? "",
|
|
17
21
|
};
|
|
18
22
|
},
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineModule } from "../types.js";
|
|
2
|
+
|
|
3
|
+
const DEFAULT_HASH_LENGTH = 7;
|
|
4
|
+
|
|
5
|
+
export const gitCommitModule = defineModule({
|
|
6
|
+
name: "git_commit",
|
|
7
|
+
variables: ["symbol", "hash", "tag"],
|
|
8
|
+
defaults: {
|
|
9
|
+
format: "[ ($hash) ]($style)",
|
|
10
|
+
symbol: "",
|
|
11
|
+
style: "fg:git_fg bg:git",
|
|
12
|
+
disabled: false,
|
|
13
|
+
},
|
|
14
|
+
values: ({ runtime }) => {
|
|
15
|
+
const commit = runtime.gitCommit;
|
|
16
|
+
if (!commit) return undefined;
|
|
17
|
+
return {
|
|
18
|
+
hash: commit.hash.slice(0, DEFAULT_HASH_LENGTH),
|
|
19
|
+
tag: commit.tag ? ` 🏷 ${commit.tag}` : "",
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineModule } from "../types.js";
|
|
2
|
+
|
|
3
|
+
export const gitMetricsModule = defineModule({
|
|
4
|
+
name: "git_metrics",
|
|
5
|
+
variables: ["symbol", "added", "deleted"],
|
|
6
|
+
defaults: {
|
|
7
|
+
format: "[(+$added)( -$deleted) ]($style)",
|
|
8
|
+
symbol: "",
|
|
9
|
+
style: "fg:git_fg bg:git",
|
|
10
|
+
disabled: true,
|
|
11
|
+
},
|
|
12
|
+
values: ({ runtime }) => {
|
|
13
|
+
const metrics = runtime.gitMetrics;
|
|
14
|
+
if (!metrics || (metrics.added === 0 && metrics.deleted === 0)) return undefined;
|
|
15
|
+
return {
|
|
16
|
+
added: metrics.added > 0 ? metrics.added.toString() : "",
|
|
17
|
+
deleted: metrics.deleted > 0 ? metrics.deleted.toString() : "",
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
});
|