@narumitw/pi-starship 0.55.1 → 0.55.2
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/dist/chunks/{chunk-UX6PBXVK.js → chunk-JO5PH6FN.js} +28 -110
- package/dist/chunks/chunk-JO5PH6FN.js.map +7 -0
- package/dist/chunks/{chunk-P4XMFSQW.js → chunk-YWY5RIDQ.js} +3 -7
- package/dist/chunks/chunk-YWY5RIDQ.js.map +7 -0
- package/dist/chunks/{chunk-EOGXAMTA.js → chunk-ZQZSXXPI.js} +1 -1
- package/dist/chunks/chunk-ZQZSXXPI.js.map +7 -0
- package/dist/chunks/{cloud-BKHYWCTA.js → cloud-C4VU3TX3.js} +7 -14
- package/dist/chunks/cloud-C4VU3TX3.js.map +7 -0
- package/dist/chunks/{commands-53ZO2JUK.js → commands-ATILSUVK.js} +13 -42
- package/dist/chunks/commands-ATILSUVK.js.map +7 -0
- package/dist/chunks/{deployment-RKKOEQQ2.js → deployment-FMNTYRBW.js} +6 -21
- package/dist/chunks/deployment-FMNTYRBW.js.map +7 -0
- package/dist/chunks/{development-BERD42HW.js → development-OUYXDPBS.js} +4 -8
- package/dist/chunks/development-OUYXDPBS.js.map +7 -0
- package/dist/chunks/{execution-42JTEY3N.js → execution-HJOGLMWD.js} +3 -3
- package/dist/chunks/execution-HJOGLMWD.js.map +7 -0
- package/dist/chunks/{languages-RMP6DW7H.js → languages-WXMF4GOF.js} +6 -22
- package/dist/chunks/languages-WXMF4GOF.js.map +7 -0
- package/dist/chunks/{package-LG5H7BBM.js → package-YXRZQAOV.js} +5 -14
- package/dist/chunks/package-YXRZQAOV.js.map +7 -0
- package/dist/index.ts +20 -55
- package/dist/index.ts.map +2 -2
- package/package.json +60 -61
- package/skills/configuring-pi-starship/scripts/apply.mjs +43 -47
- package/skills/configuring-pi-starship/scripts/config-path.mjs +3 -3
- package/skills/configuring-pi-starship/scripts/script-support.mjs +6 -6
- package/skills/configuring-pi-starship/scripts/validate.mjs +18 -18
- package/src/command-configuration.ts +267 -286
- package/src/command-contract.ts +6 -6
- package/src/command-inspector.ts +27 -27
- package/src/command-preset-picker.ts +45 -50
- package/src/command-preview.ts +153 -166
- package/src/commands.ts +588 -618
- package/src/config.ts +580 -660
- package/src/effective-config.ts +46 -48
- package/src/format/formatter.ts +211 -227
- package/src/format/style.ts +205 -216
- package/src/modules/activity.ts +74 -74
- package/src/modules/brand.ts +9 -9
- package/src/modules/cache.ts +18 -18
- package/src/modules/catalog.ts +79 -83
- package/src/modules/cloud.ts +54 -54
- package/src/modules/context.ts +27 -27
- package/src/modules/cost.ts +23 -23
- package/src/modules/deployment.ts +45 -45
- package/src/modules/development.ts +80 -81
- package/src/modules/directory.ts +89 -113
- package/src/modules/display.ts +9 -9
- package/src/modules/execution.ts +62 -69
- package/src/modules/extension-status.ts +59 -64
- package/src/modules/fill.ts +10 -10
- package/src/modules/git/branch.ts +26 -26
- package/src/modules/git/commit.ts +21 -23
- package/src/modules/git/metrics.ts +22 -22
- package/src/modules/git/runtime.ts +299 -334
- package/src/modules/git/state.ts +17 -17
- package/src/modules/git/status.ts +77 -79
- package/src/modules/git/worktree.ts +10 -12
- package/src/modules/github-pr.ts +20 -20
- package/src/modules/helpers.ts +3 -3
- package/src/modules/index.ts +21 -21
- package/src/modules/inspection.ts +101 -108
- package/src/modules/languages.ts +52 -59
- package/src/modules/model.ts +57 -67
- package/src/modules/package.ts +12 -12
- package/src/modules/provider.ts +22 -24
- package/src/modules/render.ts +124 -140
- package/src/modules/thinking.ts +27 -26
- package/src/modules/time.ts +10 -13
- package/src/modules/tokens.ts +13 -13
- package/src/modules/truncation.ts +14 -17
- package/src/modules/turn.ts +9 -9
- package/src/modules/types.ts +125 -132
- package/src/modules/workspace-helpers.ts +4 -7
- package/src/pi-starship.ts +567 -603
- package/src/presets/catalog.ts +113 -113
- package/src/runtime/cloud.ts +122 -150
- package/src/runtime/command.ts +106 -108
- package/src/runtime/deployment.ts +150 -179
- package/src/runtime/development.ts +107 -124
- package/src/runtime/execution.ts +110 -124
- package/src/runtime/github-pr.ts +223 -252
- package/src/runtime/helpers.ts +186 -199
- package/src/runtime/languages.ts +149 -180
- package/src/runtime/package.ts +74 -87
- package/src/runtime/refresh-controller.ts +82 -86
- package/src/runtime/types.ts +38 -38
- package/src/runtime/workspace.ts +108 -116
- package/src/usage.ts +40 -40
- package/dist/chunks/chunk-EOGXAMTA.js.map +0 -7
- package/dist/chunks/chunk-P4XMFSQW.js.map +0 -7
- package/dist/chunks/chunk-UX6PBXVK.js.map +0 -7
- package/dist/chunks/cloud-BKHYWCTA.js.map +0 -7
- package/dist/chunks/commands-53ZO2JUK.js.map +0 -7
- package/dist/chunks/deployment-RKKOEQQ2.js.map +0 -7
- package/dist/chunks/development-BERD42HW.js.map +0 -7
- package/dist/chunks/execution-42JTEY3N.js.map +0 -7
- package/dist/chunks/languages-RMP6DW7H.js.map +0 -7
- 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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
105
|
+
miseModule,
|
|
106
|
+
direnvModule,
|
|
107
|
+
condaModule,
|
|
108
|
+
pixiModule,
|
|
109
|
+
nixShellModule,
|
|
110
|
+
guixShellModule,
|
|
112
111
|
] as const;
|
package/src/modules/directory.ts
CHANGED
|
@@ -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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
for (const [from, to] of Object.entries(substitutions)) {
|
|
40
|
+
if (from) path = path.replaceAll(from, to);
|
|
41
|
+
}
|
|
47
42
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
87
|
+
return relative(left, right) === "";
|
|
96
88
|
}
|
|
97
89
|
|
|
98
90
|
function fishPrefix(source: string, displayed: string, length: number): string {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
118
|
-
|
|
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
|
-
|
|
127
|
-
|
|
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
|
-
|
|
136
|
-
|
|
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
|
-
|
|
145
|
-
|
|
122
|
+
options: Readonly<Record<string, ModuleOptionValue>>,
|
|
123
|
+
name: string,
|
|
146
124
|
): Readonly<Record<string, string>> {
|
|
147
|
-
|
|
148
|
-
|
|
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
|
}
|
package/src/modules/display.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { ModuleDisplayConfig } from "./types.js";
|
|
2
2
|
|
|
3
3
|
export function resolveDisplayStyle(
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
display: readonly ModuleDisplayConfig[],
|
|
5
|
+
value: number | null | undefined,
|
|
6
6
|
): string | undefined {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
}
|
package/src/modules/execution.ts
CHANGED
|
@@ -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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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;
|