@narumitw/pi-starship 0.55.1 → 0.56.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.
Files changed (106) hide show
  1. package/README.md +2 -0
  2. package/dist/chunks/{chunk-UX6PBXVK.js → chunk-SD7TUSSU.js} +113 -113
  3. package/dist/chunks/chunk-SD7TUSSU.js.map +7 -0
  4. package/dist/chunks/{chunk-P4XMFSQW.js → chunk-YWY5RIDQ.js} +3 -7
  5. package/dist/chunks/chunk-YWY5RIDQ.js.map +7 -0
  6. package/dist/chunks/{chunk-EOGXAMTA.js → chunk-ZQZSXXPI.js} +1 -1
  7. package/dist/chunks/chunk-ZQZSXXPI.js.map +7 -0
  8. package/dist/chunks/{cloud-BKHYWCTA.js → cloud-C4VU3TX3.js} +7 -14
  9. package/dist/chunks/cloud-C4VU3TX3.js.map +7 -0
  10. package/dist/chunks/{commands-53ZO2JUK.js → commands-MJCAK6JL.js} +18 -42
  11. package/dist/chunks/commands-MJCAK6JL.js.map +7 -0
  12. package/dist/chunks/{deployment-RKKOEQQ2.js → deployment-FMNTYRBW.js} +6 -21
  13. package/dist/chunks/deployment-FMNTYRBW.js.map +7 -0
  14. package/dist/chunks/{development-BERD42HW.js → development-OUYXDPBS.js} +4 -8
  15. package/dist/chunks/development-OUYXDPBS.js.map +7 -0
  16. package/dist/chunks/{execution-42JTEY3N.js → execution-HJOGLMWD.js} +3 -3
  17. package/dist/chunks/execution-HJOGLMWD.js.map +7 -0
  18. package/dist/chunks/{languages-RMP6DW7H.js → languages-WXMF4GOF.js} +6 -22
  19. package/dist/chunks/languages-WXMF4GOF.js.map +7 -0
  20. package/dist/chunks/{package-LG5H7BBM.js → package-YXRZQAOV.js} +5 -14
  21. package/dist/chunks/package-YXRZQAOV.js.map +7 -0
  22. package/dist/index.ts +20 -55
  23. package/dist/index.ts.map +2 -2
  24. package/package.json +60 -61
  25. package/skills/configuring-pi-starship/SKILL.md +18 -4
  26. package/skills/configuring-pi-starship/references/configuration.md +70 -2
  27. package/skills/configuring-pi-starship/references/module-catalog.md +21 -0
  28. package/skills/configuring-pi-starship/references/modules.md +2 -0
  29. package/skills/configuring-pi-starship/scripts/apply.mjs +48 -47
  30. package/skills/configuring-pi-starship/scripts/backup.mjs +118 -0
  31. package/skills/configuring-pi-starship/scripts/config-path.mjs +3 -3
  32. package/skills/configuring-pi-starship/scripts/script-support.mjs +6 -6
  33. package/skills/configuring-pi-starship/scripts/validate.mjs +18 -18
  34. package/src/command-configuration.ts +267 -286
  35. package/src/command-contract.ts +6 -6
  36. package/src/command-inspector.ts +27 -27
  37. package/src/command-preset-picker.ts +45 -50
  38. package/src/command-preview.ts +153 -166
  39. package/src/commands.ts +590 -618
  40. package/src/config.ts +635 -660
  41. package/src/effective-config.ts +49 -48
  42. package/src/format/formatter.ts +211 -227
  43. package/src/format/style.ts +205 -216
  44. package/src/modules/activity.ts +74 -74
  45. package/src/modules/brand.ts +9 -9
  46. package/src/modules/cache.ts +18 -18
  47. package/src/modules/catalog.ts +79 -83
  48. package/src/modules/cloud.ts +54 -54
  49. package/src/modules/context.ts +27 -27
  50. package/src/modules/cost.ts +23 -23
  51. package/src/modules/deployment.ts +45 -45
  52. package/src/modules/development.ts +80 -81
  53. package/src/modules/directory.ts +89 -113
  54. package/src/modules/display.ts +9 -9
  55. package/src/modules/execution.ts +62 -69
  56. package/src/modules/extension-status.ts +59 -64
  57. package/src/modules/fill.ts +10 -10
  58. package/src/modules/git/branch.ts +26 -26
  59. package/src/modules/git/commit.ts +21 -23
  60. package/src/modules/git/metrics.ts +22 -22
  61. package/src/modules/git/runtime.ts +299 -334
  62. package/src/modules/git/state.ts +17 -17
  63. package/src/modules/git/status.ts +77 -79
  64. package/src/modules/git/worktree.ts +10 -12
  65. package/src/modules/github-pr.ts +20 -20
  66. package/src/modules/helpers.ts +3 -3
  67. package/src/modules/index.ts +21 -21
  68. package/src/modules/inspection.ts +105 -108
  69. package/src/modules/languages.ts +52 -59
  70. package/src/modules/model.ts +61 -67
  71. package/src/modules/package.ts +12 -12
  72. package/src/modules/provider.ts +25 -24
  73. package/src/modules/render.ts +131 -141
  74. package/src/modules/style-rules.ts +21 -0
  75. package/src/modules/thinking.ts +31 -26
  76. package/src/modules/time.ts +10 -13
  77. package/src/modules/tokens.ts +13 -13
  78. package/src/modules/truncation.ts +14 -17
  79. package/src/modules/turn.ts +9 -9
  80. package/src/modules/types.ts +133 -132
  81. package/src/modules/workspace-helpers.ts +4 -7
  82. package/src/pi-starship.ts +567 -603
  83. package/src/presets/catalog.ts +113 -113
  84. package/src/runtime/cloud.ts +122 -150
  85. package/src/runtime/command.ts +106 -108
  86. package/src/runtime/deployment.ts +150 -179
  87. package/src/runtime/development.ts +107 -124
  88. package/src/runtime/execution.ts +110 -124
  89. package/src/runtime/github-pr.ts +223 -252
  90. package/src/runtime/helpers.ts +186 -199
  91. package/src/runtime/languages.ts +149 -180
  92. package/src/runtime/package.ts +74 -87
  93. package/src/runtime/refresh-controller.ts +82 -86
  94. package/src/runtime/types.ts +38 -38
  95. package/src/runtime/workspace.ts +108 -116
  96. package/src/usage.ts +40 -40
  97. package/dist/chunks/chunk-EOGXAMTA.js.map +0 -7
  98. package/dist/chunks/chunk-P4XMFSQW.js.map +0 -7
  99. package/dist/chunks/chunk-UX6PBXVK.js.map +0 -7
  100. package/dist/chunks/cloud-BKHYWCTA.js.map +0 -7
  101. package/dist/chunks/commands-53ZO2JUK.js.map +0 -7
  102. package/dist/chunks/deployment-RKKOEQQ2.js.map +0 -7
  103. package/dist/chunks/development-BERD42HW.js.map +0 -7
  104. package/dist/chunks/execution-42JTEY3N.js.map +0 -7
  105. package/dist/chunks/languages-RMP6DW7H.js.map +0 -7
  106. package/dist/chunks/package-LG5H7BBM.js.map +0 -7
@@ -3,110 +3,109 @@ import { defineModule, type ModuleDefinition, type ModuleOptionSchema } from "./
3
3
  import { workspaceModuleValues } from "./workspace-helpers.js";
4
4
 
5
5
  function developmentModule<const Name extends string>(definition: {
6
- name: Name;
7
- variables: readonly string[];
8
- format: string;
9
- symbol: string;
10
- style: string;
11
- options?: Readonly<Record<string, ModuleOptionSchema>>;
6
+ name: Name;
7
+ variables: readonly string[];
8
+ format: string;
9
+ symbol: string;
10
+ style: string;
11
+ options?: Readonly<Record<string, ModuleOptionSchema>>;
12
12
  }): ModuleDefinition<Name> {
13
- return defineModule({
14
- name: definition.name,
15
- variables: ["symbol", ...definition.variables],
16
- defaults: {
17
- format: definition.format,
18
- symbol: definition.symbol,
19
- style: definition.style,
20
- disabled: false,
21
- },
22
- options: definition.options,
23
- values: (context) => workspaceModuleValues(definition.name, context),
24
- });
13
+ return defineModule({
14
+ name: definition.name,
15
+ variables: ["symbol", ...definition.variables],
16
+ defaults: {
17
+ format: definition.format,
18
+ symbol: definition.symbol,
19
+ style: definition.style,
20
+ disabled: false,
21
+ },
22
+ options: definition.options,
23
+ values: (context) => workspaceModuleValues(definition.name, context),
24
+ });
25
25
  }
26
26
 
27
27
  const directDetection = {
28
- detect_files: { kind: "string-array", default: [] },
29
- detect_extensions: { kind: "string-array", default: [] },
30
- detect_folders: { kind: "string-array", default: [] },
28
+ detect_files: { kind: "string-array", default: [] },
29
+ detect_extensions: { kind: "string-array", default: [] },
30
+ detect_folders: { kind: "string-array", default: [] },
31
31
  } as const;
32
32
 
33
33
  export const miseModule = developmentModule({
34
- name: "mise",
35
- variables: ["health"],
36
- format: "via [$symbol$health]($style) ",
37
- symbol: "mise ",
38
- style: "bold purple",
39
- options: directDetection,
34
+ name: "mise",
35
+ variables: ["health"],
36
+ format: "via [$symbol$health]($style) ",
37
+ symbol: "mise ",
38
+ style: "bold purple",
39
+ options: directDetection,
40
40
  });
41
41
 
42
42
  export const direnvModule = developmentModule({
43
- name: "direnv",
44
- variables: ["rc_path", "allowed", "loaded"],
45
- format: "[$symbol$loaded]($style) ",
46
- symbol: "direnv ",
47
- style: "bold bright-yellow",
48
- options: directDetection,
43
+ name: "direnv",
44
+ variables: ["rc_path", "allowed", "loaded"],
45
+ format: "[$symbol$loaded]($style) ",
46
+ symbol: "direnv ",
47
+ style: "bold bright-yellow",
48
+ options: directDetection,
49
49
  });
50
50
 
51
51
  export const condaModule = defineModule({
52
- name: "conda",
53
- variables: ["symbol", "environment"],
54
- defaults: {
55
- format: "via [$symbol$environment]($style) ",
56
- symbol: "🅒 ",
57
- style: "green bold",
58
- disabled: false,
59
- },
60
- options: {
61
- ignore_base: { kind: "boolean", default: true },
62
- truncation_length: { kind: "integer", default: 1, minimum: 0, maximum: 1_000_000 },
63
- },
64
- values: (context) => {
65
- const values = workspaceModuleValues("conda", context);
66
- const environment = values?.environment;
67
- if (!environment) return undefined;
68
- const length =
69
- typeof context.options.truncation_length === "number" ? context.options.truncation_length : 1;
70
- return {
71
- environment: truncatePathComponents(environment, length).value,
72
- };
73
- },
52
+ name: "conda",
53
+ variables: ["symbol", "environment"],
54
+ defaults: {
55
+ format: "via [$symbol$environment]($style) ",
56
+ symbol: "🅒 ",
57
+ style: "green bold",
58
+ disabled: false,
59
+ },
60
+ options: {
61
+ ignore_base: { kind: "boolean", default: true },
62
+ truncation_length: { kind: "integer", default: 1, minimum: 0, maximum: 1_000_000 },
63
+ },
64
+ values: (context) => {
65
+ const values = workspaceModuleValues("conda", context);
66
+ const environment = values?.environment;
67
+ if (!environment) return undefined;
68
+ const length = typeof context.options.truncation_length === "number" ? context.options.truncation_length : 1;
69
+ return {
70
+ environment: truncatePathComponents(environment, length).value,
71
+ };
72
+ },
74
73
  });
75
74
 
76
75
  export const pixiModule = developmentModule({
77
- name: "pixi",
78
- variables: ["version", "environment", "project_name"],
79
- format: "via [$symbol$environment]($style) ",
80
- symbol: "🧚 ",
81
- style: "yellow bold",
82
- options: {
83
- ...directDetection,
84
- version_format: { kind: "string", default: "v$raw" },
85
- show_default_environment: { kind: "boolean", default: false },
86
- },
76
+ name: "pixi",
77
+ variables: ["version", "environment", "project_name"],
78
+ format: "via [$symbol$environment]($style) ",
79
+ symbol: "🧚 ",
80
+ style: "yellow bold",
81
+ options: {
82
+ ...directDetection,
83
+ version_format: { kind: "string", default: "v$raw" },
84
+ show_default_environment: { kind: "boolean", default: false },
85
+ },
87
86
  });
88
87
 
89
88
  export const nixShellModule = developmentModule({
90
- name: "nix_shell",
91
- variables: ["state", "name", "level"],
92
- format: "via [$symbol$state( \\($name\\))]($style) ",
93
- symbol: " ",
94
- style: "bold blue",
89
+ name: "nix_shell",
90
+ variables: ["state", "name", "level"],
91
+ format: "via [$symbol$state( \\($name\\))]($style) ",
92
+ symbol: " ",
93
+ style: "bold blue",
95
94
  });
96
95
 
97
96
  export const guixShellModule = developmentModule({
98
- name: "guix_shell",
99
- variables: ["state"],
100
- format: "via [$symbol]($style) ",
101
- symbol: "🐃 ",
102
- style: "yellow bold",
97
+ name: "guix_shell",
98
+ variables: ["state"],
99
+ format: "via [$symbol]($style) ",
100
+ symbol: "🐃 ",
101
+ style: "yellow bold",
103
102
  });
104
103
 
105
104
  export const developmentModules = [
106
- miseModule,
107
- direnvModule,
108
- condaModule,
109
- pixiModule,
110
- nixShellModule,
111
- guixShellModule,
105
+ miseModule,
106
+ direnvModule,
107
+ condaModule,
108
+ pixiModule,
109
+ nixShellModule,
110
+ guixShellModule,
112
111
  ] as const;
@@ -1,151 +1,127 @@
1
1
  import { basename, isAbsolute, relative, sep } from "node:path";
2
2
  import { sanitizeTerminalText } from "@narumitw/pi-tui-kit/terminal-text";
3
- import {
4
- graphemes,
5
- toSlashPath,
6
- truncatePathComponents,
7
- useNativePathSeparator,
8
- } from "./truncation.js";
3
+ import { graphemes, toSlashPath, truncatePathComponents, useNativePathSeparator } from "./truncation.js";
9
4
  import { defineModule, type ModuleOptionValue } from "./types.js";
10
5
 
11
6
  export const directoryModule = defineModule({
12
- name: "directory",
13
- variables: ["symbol", "path", "full_path"],
14
- defaults: {
15
- format: "[ $symbol $path ]($style)",
16
- symbol: "📁",
17
- style: "cyan bold",
18
- disabled: false,
19
- },
20
- options: {
21
- truncation_length: { kind: "integer", default: 3, minimum: 0, maximum: 1_000_000 },
22
- truncate_to_repo: { kind: "boolean", default: true },
23
- fish_style_pwd_dir_length: { kind: "integer", default: 0, minimum: 0, maximum: 1_000 },
24
- truncation_symbol: { kind: "string", default: "" },
25
- home_symbol: { kind: "string", default: "~" },
26
- use_os_path_sep: { kind: "boolean", default: true },
27
- substitutions: { kind: "string-map", default: {} },
28
- },
29
- values: ({ runtime, options }) => {
30
- const fullPath = runtime.cwd;
31
- const home = runtime.homeDir;
32
- const repoRoot = runtime.gitRoot;
33
- const homeSymbol = stringOption(options, "home_symbol", "~");
34
- const truncateToRepo = booleanOption(options, "truncate_to_repo", true);
35
- const substitutions = mapOption(options, "substitutions");
36
- const homeContracted = contractPath(fullPath, home, homeSymbol);
37
- const repoContracted =
38
- truncateToRepo && repoRoot && (!home || !samePath(repoRoot, home))
39
- ? contractRepositoryPath(fullPath, repoRoot)
40
- : undefined;
41
- let path = sanitizeTerminalText(repoContracted ?? homeContracted);
42
- let truncated = repoContracted !== undefined;
7
+ name: "directory",
8
+ variables: ["symbol", "path", "full_path"],
9
+ defaults: {
10
+ format: "[ $symbol $path ]($style)",
11
+ symbol: "📁",
12
+ style: "cyan bold",
13
+ disabled: false,
14
+ },
15
+ options: {
16
+ truncation_length: { kind: "integer", default: 3, minimum: 0, maximum: 1_000_000 },
17
+ truncate_to_repo: { kind: "boolean", default: true },
18
+ fish_style_pwd_dir_length: { kind: "integer", default: 0, minimum: 0, maximum: 1_000 },
19
+ truncation_symbol: { kind: "string", default: "" },
20
+ home_symbol: { kind: "string", default: "~" },
21
+ use_os_path_sep: { kind: "boolean", default: true },
22
+ substitutions: { kind: "string-map", default: {} },
23
+ },
24
+ values: ({ runtime, options }) => {
25
+ const fullPath = runtime.cwd;
26
+ const home = runtime.homeDir;
27
+ const repoRoot = runtime.gitRoot;
28
+ const homeSymbol = stringOption(options, "home_symbol", "~");
29
+ const truncateToRepo = booleanOption(options, "truncate_to_repo", true);
30
+ const substitutions = mapOption(options, "substitutions");
31
+ const homeContracted = contractPath(fullPath, home, homeSymbol);
32
+ const repoContracted =
33
+ truncateToRepo && repoRoot && (!home || !samePath(repoRoot, home))
34
+ ? contractRepositoryPath(fullPath, repoRoot)
35
+ : undefined;
36
+ let path = sanitizeTerminalText(repoContracted ?? homeContracted);
37
+ let truncated = repoContracted !== undefined;
43
38
 
44
- for (const [from, to] of Object.entries(substitutions)) {
45
- if (from) path = path.replaceAll(from, to);
46
- }
39
+ for (const [from, to] of Object.entries(substitutions)) {
40
+ if (from) path = path.replaceAll(from, to);
41
+ }
47
42
 
48
- const componentResult = truncatePathComponents(
49
- path,
50
- numberOption(options, "truncation_length", 3),
51
- );
52
- path = componentResult.value;
53
- truncated ||= componentResult.truncated;
43
+ const componentResult = truncatePathComponents(path, numberOption(options, "truncation_length", 3));
44
+ path = componentResult.value;
45
+ truncated ||= componentResult.truncated;
54
46
 
55
- if (truncated) {
56
- const fishLength = numberOption(options, "fish_style_pwd_dir_length", 0);
57
- if (fishLength > 0 && Object.keys(substitutions).length === 0) {
58
- path = `${fishPrefix(homeContracted, path, fishLength)}${path}`;
59
- } else {
60
- path = `${stringOption(options, "truncation_symbol", "")}${path}`;
61
- }
62
- }
47
+ if (truncated) {
48
+ const fishLength = numberOption(options, "fish_style_pwd_dir_length", 0);
49
+ if (fishLength > 0 && Object.keys(substitutions).length === 0) {
50
+ path = `${fishPrefix(homeContracted, path, fishLength)}${path}`;
51
+ } else {
52
+ path = `${stringOption(options, "truncation_symbol", "")}${path}`;
53
+ }
54
+ }
63
55
 
64
- if (booleanOption(options, "use_os_path_sep", true)) path = useNativePathSeparator(path);
65
- const fallback = basename(fullPath) || fullPath;
66
- return {
67
- path: sanitizeTerminalText(path || fallback),
68
- full_path: sanitizeTerminalText(fullPath),
69
- };
70
- },
56
+ if (booleanOption(options, "use_os_path_sep", true)) path = useNativePathSeparator(path);
57
+ const fallback = basename(fullPath) || fullPath;
58
+ return {
59
+ path: sanitizeTerminalText(path || fallback),
60
+ full_path: sanitizeTerminalText(fullPath),
61
+ };
62
+ },
71
63
  });
72
64
 
73
65
  function contractPath(path: string, root: string | undefined, replacement: string): string {
74
- if (!root) return toSlashPath(path);
75
- const child = relativeWithin(path, root);
76
- if (child === undefined) return toSlashPath(path);
77
- return child ? `${replacement}/${child}` : replacement;
66
+ if (!root) return toSlashPath(path);
67
+ const child = relativeWithin(path, root);
68
+ if (child === undefined) return toSlashPath(path);
69
+ return child ? `${replacement}/${child}` : replacement;
78
70
  }
79
71
 
80
72
  function contractRepositoryPath(path: string, root: string): string | undefined {
81
- const child = relativeWithin(path, root);
82
- if (child === undefined) return undefined;
83
- const name = basename(root) || toSlashPath(root);
84
- return child ? `${name}/${child}` : name;
73
+ const child = relativeWithin(path, root);
74
+ if (child === undefined) return undefined;
75
+ const name = basename(root) || toSlashPath(root);
76
+ return child ? `${name}/${child}` : name;
85
77
  }
86
78
 
87
79
  function relativeWithin(path: string, root: string): string | undefined {
88
- const child = relative(root, path);
89
- if (child === "") return "";
90
- if (child === ".." || child.startsWith(`..${sep}`) || isAbsolute(child)) return undefined;
91
- return toSlashPath(child);
80
+ const child = relative(root, path);
81
+ if (child === "") return "";
82
+ if (child === ".." || child.startsWith(`..${sep}`) || isAbsolute(child)) return undefined;
83
+ return toSlashPath(child);
92
84
  }
93
85
 
94
86
  function samePath(left: string, right: string): boolean {
95
- return relative(left, right) === "";
87
+ return relative(left, right) === "";
96
88
  }
97
89
 
98
90
  function fishPrefix(source: string, displayed: string, length: number): string {
99
- const prefix = source.endsWith(displayed) ? source.slice(0, -displayed.length) : "";
100
- if (!prefix) return "";
101
- return prefix
102
- .split("/")
103
- .map((component) => abbreviateComponent(component, length))
104
- .join("/");
91
+ const prefix = source.endsWith(displayed) ? source.slice(0, -displayed.length) : "";
92
+ if (!prefix) return "";
93
+ return prefix
94
+ .split("/")
95
+ .map((component) => abbreviateComponent(component, length))
96
+ .join("/");
105
97
  }
106
98
 
107
99
  function abbreviateComponent(component: string, length: number): string {
108
- if (!component) return "";
109
- const parts = graphemes(component);
110
- if (parts.length <= length) return component;
111
- return component.startsWith(".")
112
- ? parts.slice(0, length + 1).join("")
113
- : parts.slice(0, length).join("");
100
+ if (!component) return "";
101
+ const parts = graphemes(component);
102
+ if (parts.length <= length) return component;
103
+ return component.startsWith(".") ? parts.slice(0, length + 1).join("") : parts.slice(0, length).join("");
114
104
  }
115
105
 
116
- function numberOption(
117
- options: Readonly<Record<string, ModuleOptionValue>>,
118
- name: string,
119
- fallback: number,
120
- ): number {
121
- const value = options[name];
122
- return typeof value === "number" ? value : fallback;
106
+ function numberOption(options: Readonly<Record<string, ModuleOptionValue>>, name: string, fallback: number): number {
107
+ const value = options[name];
108
+ return typeof value === "number" ? value : fallback;
123
109
  }
124
110
 
125
- function stringOption(
126
- options: Readonly<Record<string, ModuleOptionValue>>,
127
- name: string,
128
- fallback: string,
129
- ): string {
130
- const value = options[name];
131
- return typeof value === "string" ? value : fallback;
111
+ function stringOption(options: Readonly<Record<string, ModuleOptionValue>>, name: string, fallback: string): string {
112
+ const value = options[name];
113
+ return typeof value === "string" ? value : fallback;
132
114
  }
133
115
 
134
- function booleanOption(
135
- options: Readonly<Record<string, ModuleOptionValue>>,
136
- name: string,
137
- fallback: boolean,
138
- ): boolean {
139
- const value = options[name];
140
- return typeof value === "boolean" ? value : fallback;
116
+ function booleanOption(options: Readonly<Record<string, ModuleOptionValue>>, name: string, fallback: boolean): boolean {
117
+ const value = options[name];
118
+ return typeof value === "boolean" ? value : fallback;
141
119
  }
142
120
 
143
121
  function mapOption(
144
- options: Readonly<Record<string, ModuleOptionValue>>,
145
- name: string,
122
+ options: Readonly<Record<string, ModuleOptionValue>>,
123
+ name: string,
146
124
  ): Readonly<Record<string, string>> {
147
- const value = options[name];
148
- return value && typeof value === "object" && !Array.isArray(value)
149
- ? (value as Readonly<Record<string, string>>)
150
- : {};
125
+ const value = options[name];
126
+ return value && typeof value === "object" && !Array.isArray(value) ? (value as Readonly<Record<string, string>>) : {};
151
127
  }
@@ -1,14 +1,14 @@
1
1
  import type { ModuleDisplayConfig } from "./types.js";
2
2
 
3
3
  export function resolveDisplayStyle(
4
- display: readonly ModuleDisplayConfig[],
5
- value: number | null | undefined,
4
+ display: readonly ModuleDisplayConfig[],
5
+ value: number | null | undefined,
6
6
  ): string | undefined {
7
- if (value === null || value === undefined || !Number.isFinite(value)) return undefined;
8
- let selected: ModuleDisplayConfig | undefined;
9
- for (const entry of display) {
10
- if (entry.threshold > value) continue;
11
- if (!selected || entry.threshold >= selected.threshold) selected = entry;
12
- }
13
- return selected && !selected.hidden ? selected.style : undefined;
7
+ if (value === null || value === undefined || !Number.isFinite(value)) return undefined;
8
+ let selected: ModuleDisplayConfig | undefined;
9
+ for (const entry of display) {
10
+ if (entry.threshold > value) continue;
11
+ if (!selected || entry.threshold >= selected.threshold) selected = entry;
12
+ }
13
+ return selected && !selected.hidden ? selected.style : undefined;
14
14
  }
@@ -2,83 +2,76 @@ import { defineModule } from "./types.js";
2
2
  import { workspaceModuleValues } from "./workspace-helpers.js";
3
3
 
4
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),
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
20
  });
21
21
 
22
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),
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
32
  });
33
33
 
34
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: "." },
46
- aliases: { kind: "string-map", default: {} },
47
- },
48
- values: (context) => workspaceModuleValues("hostname", context),
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: "." },
46
+ aliases: { kind: "string-map", default: {} },
47
+ },
48
+ values: (context) => workspaceModuleValues("hostname", context),
49
49
  });
50
50
 
51
51
  export const usernameModule = defineModule({
52
- name: "username",
53
- variables: ["symbol", "user"],
54
- defaults: {
55
- format: "[$user]($style) in ",
56
- symbol: "",
57
- style: "none",
58
- disabled: false,
59
- },
60
- styleDefaults: {
61
- style_user: "yellow bold",
62
- style_root: "red bold",
63
- },
64
- styleVariables: ["style"],
65
- resolveStyleVariables: ({ runtime, styles }) => ({
66
- style:
67
- runtime.workspace?.styleSelectors?.username === "root"
68
- ? (styles.style_root ?? "")
69
- : (styles.style_user ?? ""),
70
- }),
71
- options: {
72
- show_always: { kind: "boolean", default: false },
73
- aliases: { kind: "string-map", default: {} },
74
- detect_env_vars: { kind: "string-array", default: [] },
75
- },
76
- values: (context) => workspaceModuleValues("username", context),
52
+ name: "username",
53
+ variables: ["symbol", "user"],
54
+ defaults: {
55
+ format: "[$user]($style) in ",
56
+ symbol: "",
57
+ style: "none",
58
+ disabled: false,
59
+ },
60
+ styleDefaults: {
61
+ style_user: "yellow bold",
62
+ style_root: "red bold",
63
+ },
64
+ styleVariables: ["style"],
65
+ resolveStyleVariables: ({ runtime, styles }) => ({
66
+ style:
67
+ runtime.workspace?.styleSelectors?.username === "root" ? (styles.style_root ?? "") : (styles.style_user ?? ""),
68
+ }),
69
+ options: {
70
+ show_always: { kind: "boolean", default: false },
71
+ aliases: { kind: "string-map", default: {} },
72
+ detect_env_vars: { kind: "string-array", default: [] },
73
+ },
74
+ values: (context) => workspaceModuleValues("username", context),
77
75
  });
78
76
 
79
- export const executionModules = [
80
- osModule,
81
- containerModule,
82
- hostnameModule,
83
- usernameModule,
84
- ] as const;
77
+ export const executionModules = [osModule, containerModule, hostnameModule, usernameModule] as const;