@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.
- package/README.md +2 -0
- package/dist/chunks/{chunk-UX6PBXVK.js → chunk-SD7TUSSU.js} +113 -113
- package/dist/chunks/chunk-SD7TUSSU.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-MJCAK6JL.js} +18 -42
- package/dist/chunks/commands-MJCAK6JL.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/SKILL.md +18 -4
- package/skills/configuring-pi-starship/references/configuration.md +70 -2
- package/skills/configuring-pi-starship/references/module-catalog.md +21 -0
- package/skills/configuring-pi-starship/references/modules.md +2 -0
- package/skills/configuring-pi-starship/scripts/apply.mjs +48 -47
- package/skills/configuring-pi-starship/scripts/backup.mjs +118 -0
- 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 +590 -618
- package/src/config.ts +635 -660
- package/src/effective-config.ts +49 -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 +105 -108
- package/src/modules/languages.ts +52 -59
- package/src/modules/model.ts +61 -67
- package/src/modules/package.ts +12 -12
- package/src/modules/provider.ts +25 -24
- package/src/modules/render.ts +131 -141
- package/src/modules/style-rules.ts +21 -0
- package/src/modules/thinking.ts +31 -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 +133 -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
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ The extension parses and renders the footer itself, so it does not need the `sta
|
|
|
12
12
|
|
|
13
13
|
- Starts with a readable built-in footer and offers Starship presets plus a Pi-native Minimal preset.
|
|
14
14
|
- Supports root and module formats, conditional groups, `$all`, styles, palettes, and width-aware `$fill` alignment.
|
|
15
|
+
- Selects provider, model, and thinking styles from exact runtime values with ordered module rules.
|
|
15
16
|
- Provides Pi, model, usage, Git, pull request, package, language, environment, deployment, cloud, and execution modules.
|
|
16
17
|
- Wraps native multiline layouts to terminal width instead of truncating them.
|
|
17
18
|
- Keeps rendering pure while refreshing filesystem, process, and network-derived data through bounded caches.
|
|
@@ -95,6 +96,7 @@ format = "$model$directory$git_branch"
|
|
|
95
96
|
style = "bold blue"
|
|
96
97
|
```
|
|
97
98
|
|
|
99
|
+
Provider, model, and thinking modules also accept ordered exact-match `style_rules`; see [Configuration and format](./skills/configuring-pi-starship/references/configuration.md).
|
|
98
100
|
Use `/starship` for interactive configuration, preview, diagnostics, presets, and recovery.
|
|
99
101
|
Manual file edits load at the next `session_start`, including `/reload`.
|
|
100
102
|
|
|
@@ -15,15 +15,7 @@ function completeStarshipArguments(prefix) {
|
|
|
15
15
|
|
|
16
16
|
// src/config.ts
|
|
17
17
|
import { randomUUID } from "node:crypto";
|
|
18
|
-
import {
|
|
19
|
-
existsSync,
|
|
20
|
-
lstatSync,
|
|
21
|
-
mkdirSync,
|
|
22
|
-
readFileSync,
|
|
23
|
-
renameSync,
|
|
24
|
-
rmSync,
|
|
25
|
-
writeFileSync
|
|
26
|
-
} from "node:fs";
|
|
18
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
27
19
|
import { createRequire } from "node:module";
|
|
28
20
|
import { dirname, join } from "node:path";
|
|
29
21
|
|
|
@@ -401,9 +393,7 @@ function renderNodes(nodes, options, inheritedStyle) {
|
|
|
401
393
|
}
|
|
402
394
|
break;
|
|
403
395
|
case "group": {
|
|
404
|
-
const styleString = node.style.map(
|
|
405
|
-
(part) => part.type === "text" ? part.value : ownValue(options.styleVariables, part.name) ?? ""
|
|
406
|
-
).join("");
|
|
396
|
+
const styleString = node.style.map((part) => part.type === "text" ? part.value : ownValue(options.styleVariables, part.name) ?? "").join("");
|
|
407
397
|
const style = parseStyle(styleString, options.palette);
|
|
408
398
|
const rendered = renderNodes(node.children, options, style);
|
|
409
399
|
if (node.children.length === 0) chunks.push({ text: "", style });
|
|
@@ -929,10 +919,7 @@ var directoryModule = defineModule({
|
|
|
929
919
|
for (const [from, to] of Object.entries(substitutions)) {
|
|
930
920
|
if (from) path = path.replaceAll(from, to);
|
|
931
921
|
}
|
|
932
|
-
const componentResult = truncatePathComponents(
|
|
933
|
-
path,
|
|
934
|
-
numberOption(options, "truncation_length", 3)
|
|
935
|
-
);
|
|
922
|
+
const componentResult = truncatePathComponents(path, numberOption(options, "truncation_length", 3));
|
|
936
923
|
path = componentResult.value;
|
|
937
924
|
truncated ||= componentResult.truncated;
|
|
938
925
|
if (truncated) {
|
|
@@ -1069,12 +1056,7 @@ var usernameModule = defineModule({
|
|
|
1069
1056
|
},
|
|
1070
1057
|
values: (context) => workspaceModuleValues("username", context)
|
|
1071
1058
|
});
|
|
1072
|
-
var executionModules = [
|
|
1073
|
-
osModule,
|
|
1074
|
-
containerModule,
|
|
1075
|
-
hostnameModule,
|
|
1076
|
-
usernameModule
|
|
1077
|
-
];
|
|
1059
|
+
var executionModules = [osModule, containerModule, hostnameModule, usernameModule];
|
|
1078
1060
|
|
|
1079
1061
|
// src/modules/extension-status.ts
|
|
1080
1062
|
var extensionStatusModule = defineModule({
|
|
@@ -1435,14 +1417,7 @@ var denoModule = languageModule({
|
|
|
1435
1417
|
symbol: "\u{1F995} ",
|
|
1436
1418
|
style: "green bold"
|
|
1437
1419
|
});
|
|
1438
|
-
var languageModules = [
|
|
1439
|
-
nodejsModule,
|
|
1440
|
-
pythonModule,
|
|
1441
|
-
rustModule,
|
|
1442
|
-
golangModule,
|
|
1443
|
-
bunModule,
|
|
1444
|
-
denoModule
|
|
1445
|
-
];
|
|
1420
|
+
var languageModules = [nodejsModule, pythonModule, rustModule, golangModule, bunModule, denoModule];
|
|
1446
1421
|
|
|
1447
1422
|
// src/modules/model.ts
|
|
1448
1423
|
import { sanitizeTerminalText as sanitizeTerminalText3 } from "@narumitw/pi-tui-kit/terminal-text";
|
|
@@ -1457,6 +1432,10 @@ var modelModule = defineModule({
|
|
|
1457
1432
|
style: "bold blue",
|
|
1458
1433
|
disabled: false
|
|
1459
1434
|
},
|
|
1435
|
+
styleRuleSelectors: {
|
|
1436
|
+
provider: ({ runtime }) => runtime.model?.provider,
|
|
1437
|
+
model: ({ runtime }) => runtime.model?.id
|
|
1438
|
+
},
|
|
1460
1439
|
options: {
|
|
1461
1440
|
truncation_length: { kind: "integer", default: 0, minimum: 0, maximum: 1e3 },
|
|
1462
1441
|
truncation_symbol: { kind: "string", default: "\u2026" },
|
|
@@ -1534,6 +1513,9 @@ var providerModule = defineModule({
|
|
|
1534
1513
|
style: "bold blue",
|
|
1535
1514
|
disabled: false
|
|
1536
1515
|
},
|
|
1516
|
+
styleRuleSelectors: {
|
|
1517
|
+
provider: ({ runtime }) => runtime.model?.provider
|
|
1518
|
+
},
|
|
1537
1519
|
options: {
|
|
1538
1520
|
[PROVIDER_ALIASES_KEY]: { kind: "string-map", default: {} }
|
|
1539
1521
|
},
|
|
@@ -1568,11 +1550,13 @@ var thinkingModule = defineModule({
|
|
|
1568
1550
|
style: "bold purple",
|
|
1569
1551
|
disabled: false
|
|
1570
1552
|
},
|
|
1571
|
-
styleDefaults: Object.fromEntries(
|
|
1572
|
-
THINKING_LEVELS.map((level) => [`style_${level}`, ""])
|
|
1573
|
-
),
|
|
1553
|
+
styleDefaults: Object.fromEntries(THINKING_LEVELS.map((level) => [`style_${level}`, ""])),
|
|
1574
1554
|
fallbackStyle: true,
|
|
1575
1555
|
styleVariables: ["style"],
|
|
1556
|
+
styleRuleSelectors: {
|
|
1557
|
+
provider: ({ runtime }) => runtime.model?.provider,
|
|
1558
|
+
level: ({ runtime }) => runtime.thinkingLevel
|
|
1559
|
+
},
|
|
1576
1560
|
resolveStyleVariables: ({ runtime, styles, style }) => {
|
|
1577
1561
|
const level = thinkingLevelOf(runtime.thinkingLevel);
|
|
1578
1562
|
return { style: level && styles[`style_${level}`] || style };
|
|
@@ -1704,15 +1688,11 @@ var MODULE_DESCRIPTIONS = {
|
|
|
1704
1688
|
turn: "Current user-turn count.",
|
|
1705
1689
|
username: "Current user identity when configured to display."
|
|
1706
1690
|
};
|
|
1707
|
-
var MODULE_DEFINITIONS = MODULE_IMPLEMENTATIONS.map(
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
);
|
|
1713
|
-
var MODULE_NAMES = MODULE_IMPLEMENTATIONS.map(
|
|
1714
|
-
(definition) => definition.name
|
|
1715
|
-
);
|
|
1691
|
+
var MODULE_DEFINITIONS = MODULE_IMPLEMENTATIONS.map((definition) => ({
|
|
1692
|
+
...definition,
|
|
1693
|
+
description: MODULE_DESCRIPTIONS[definition.name]
|
|
1694
|
+
}));
|
|
1695
|
+
var MODULE_NAMES = MODULE_IMPLEMENTATIONS.map((definition) => definition.name);
|
|
1716
1696
|
|
|
1717
1697
|
// src/config.ts
|
|
1718
1698
|
var CONFIG_FILE_NAME = "pi-starship.toml";
|
|
@@ -1737,12 +1717,10 @@ var BUILT_IN_MODULES = Object.fromEntries(
|
|
|
1737
1717
|
...defaults,
|
|
1738
1718
|
formatAst: parseFormat(defaults.format),
|
|
1739
1719
|
styles: { ...styleDefaults },
|
|
1720
|
+
styleRules: [],
|
|
1740
1721
|
display: structuredClone(displayDefaults ?? []),
|
|
1741
1722
|
options: Object.fromEntries(
|
|
1742
|
-
Object.entries(options ?? {}).map(([key, schema]) => [
|
|
1743
|
-
key,
|
|
1744
|
-
cloneOptionValue(schema.default)
|
|
1745
|
-
])
|
|
1723
|
+
Object.entries(options ?? {}).map(([key, schema]) => [key, cloneOptionValue(schema.default)])
|
|
1746
1724
|
)
|
|
1747
1725
|
}
|
|
1748
1726
|
])
|
|
@@ -1828,9 +1806,7 @@ function normalizeConfig(value) {
|
|
|
1828
1806
|
config.formatAst = parseFormat(value.format);
|
|
1829
1807
|
config.format = value.format;
|
|
1830
1808
|
} catch (error) {
|
|
1831
|
-
diagnostics.push(
|
|
1832
|
-
diagnostic("warning", "format", `Invalid format; using built-in: ${formatError(error)}`)
|
|
1833
|
-
);
|
|
1809
|
+
diagnostics.push(diagnostic("warning", "format", `Invalid format; using built-in: ${formatError(error)}`));
|
|
1834
1810
|
}
|
|
1835
1811
|
}
|
|
1836
1812
|
}
|
|
@@ -1866,9 +1842,7 @@ function normalizeConfig(value) {
|
|
|
1866
1842
|
else {
|
|
1867
1843
|
config.palette = value.palette;
|
|
1868
1844
|
if (!Object.hasOwn(config.palettes, value.palette)) {
|
|
1869
|
-
diagnostics.push(
|
|
1870
|
-
diagnostic("warning", "palette", `Unknown palette ${JSON.stringify(value.palette)}`)
|
|
1871
|
-
);
|
|
1845
|
+
diagnostics.push(diagnostic("warning", "palette", `Unknown palette ${JSON.stringify(value.palette)}`));
|
|
1872
1846
|
}
|
|
1873
1847
|
}
|
|
1874
1848
|
}
|
|
@@ -1881,24 +1855,14 @@ function normalizeConfig(value) {
|
|
|
1881
1855
|
}
|
|
1882
1856
|
normalizeModule(name, moduleValue, config, diagnostics);
|
|
1883
1857
|
}
|
|
1884
|
-
validateFormatVariables(
|
|
1885
|
-
config.formatAst,
|
|
1886
|
-
/* @__PURE__ */ new Set([...MODULE_NAMES, "all"]),
|
|
1887
|
-
"format",
|
|
1888
|
-
diagnostics
|
|
1889
|
-
);
|
|
1858
|
+
validateFormatVariables(config.formatAst, /* @__PURE__ */ new Set([...MODULE_NAMES, "all"]), "format", diagnostics);
|
|
1890
1859
|
validateStyleVariables(config.formatAst, /* @__PURE__ */ new Set(), "format", diagnostics);
|
|
1891
1860
|
const palette = activePalette(config);
|
|
1892
1861
|
validateLiteralStyles(config.formatAst, palette, "format", diagnostics);
|
|
1893
1862
|
for (const definition of MODULE_DEFINITIONS) {
|
|
1894
1863
|
const name = definition.name;
|
|
1895
1864
|
const module = config.modules[name];
|
|
1896
|
-
validateFormatVariables(
|
|
1897
|
-
module.formatAst,
|
|
1898
|
-
new Set(MODULE_CONTENT_VARIABLES[name]),
|
|
1899
|
-
`${name}.format`,
|
|
1900
|
-
diagnostics
|
|
1901
|
-
);
|
|
1865
|
+
validateFormatVariables(module.formatAst, new Set(MODULE_CONTENT_VARIABLES[name]), `${name}.format`, diagnostics);
|
|
1902
1866
|
validateStyleVariables(
|
|
1903
1867
|
module.formatAst,
|
|
1904
1868
|
new Set(definition.styleVariables ?? ["style"]),
|
|
@@ -1929,6 +1893,7 @@ function normalizeModule(name, value, config, diagnostics) {
|
|
|
1929
1893
|
for (const field of Object.keys(definition.styleDefaults)) known.add(field);
|
|
1930
1894
|
} else if (!definition.displayDefaults) known.add("style");
|
|
1931
1895
|
if (definition.displayDefaults) known.add("display");
|
|
1896
|
+
if (definition.styleRuleSelectors) known.add("style_rules");
|
|
1932
1897
|
if (name === "extension_status") {
|
|
1933
1898
|
known.add("separator");
|
|
1934
1899
|
known.add("max_statuses");
|
|
@@ -1939,19 +1904,14 @@ function normalizeModule(name, value, config, diagnostics) {
|
|
|
1939
1904
|
}
|
|
1940
1905
|
const module = config.modules[name];
|
|
1941
1906
|
if (value.format !== void 0) {
|
|
1942
|
-
if (typeof value.format !== "string")
|
|
1943
|
-
diagnostics.push(typeDiagnostic(`${name}.format`, "string"));
|
|
1907
|
+
if (typeof value.format !== "string") diagnostics.push(typeDiagnostic(`${name}.format`, "string"));
|
|
1944
1908
|
else {
|
|
1945
1909
|
try {
|
|
1946
1910
|
module.formatAst = parseFormat(value.format);
|
|
1947
1911
|
module.format = value.format;
|
|
1948
1912
|
} catch (error) {
|
|
1949
1913
|
diagnostics.push(
|
|
1950
|
-
diagnostic(
|
|
1951
|
-
"warning",
|
|
1952
|
-
`${name}.format`,
|
|
1953
|
-
`Invalid format; using module default: ${formatError(error)}`
|
|
1954
|
-
)
|
|
1914
|
+
diagnostic("warning", `${name}.format`, `Invalid format; using module default: ${formatError(error)}`)
|
|
1955
1915
|
);
|
|
1956
1916
|
}
|
|
1957
1917
|
}
|
|
@@ -1987,6 +1947,15 @@ function normalizeModule(name, value, config, diagnostics) {
|
|
|
1987
1947
|
diagnostics
|
|
1988
1948
|
);
|
|
1989
1949
|
}
|
|
1950
|
+
if (definition.styleRuleSelectors && value.style_rules !== void 0) {
|
|
1951
|
+
module.styleRules = normalizeStyleRules(
|
|
1952
|
+
name,
|
|
1953
|
+
value.style_rules,
|
|
1954
|
+
new Set(Object.keys(definition.styleRuleSelectors)),
|
|
1955
|
+
activePalette(config),
|
|
1956
|
+
diagnostics
|
|
1957
|
+
);
|
|
1958
|
+
}
|
|
1990
1959
|
if (value.disabled !== void 0) {
|
|
1991
1960
|
if (typeof value.disabled !== "boolean") {
|
|
1992
1961
|
diagnostics.push(typeDiagnostic(`${name}.disabled`, "boolean"));
|
|
@@ -2007,11 +1976,7 @@ function normalizeModule(name, value, config, diagnostics) {
|
|
|
2007
1976
|
if (value.max_statuses !== void 0) {
|
|
2008
1977
|
if (typeof value.max_statuses !== "number" || !Number.isInteger(value.max_statuses) || value.max_statuses < 0 || value.max_statuses > 100) {
|
|
2009
1978
|
diagnostics.push(
|
|
2010
|
-
diagnostic(
|
|
2011
|
-
"warning",
|
|
2012
|
-
"extension_status.max_statuses",
|
|
2013
|
-
"Expected an integer from 0 through 100"
|
|
2014
|
-
)
|
|
1979
|
+
diagnostic("warning", "extension_status.max_statuses", "Expected an integer from 0 through 100")
|
|
2015
1980
|
);
|
|
2016
1981
|
} else config.extensionStatus.maxStatuses = value.max_statuses;
|
|
2017
1982
|
}
|
|
@@ -2057,10 +2022,7 @@ function atomicRestoreConfigDocument(settingsPath, rawDocument, overrides = {})
|
|
|
2057
2022
|
atomicWriteConfigDocument(settingsPath, rawDocument, overrides);
|
|
2058
2023
|
}
|
|
2059
2024
|
function removeConfigDocumentIfMatches(settingsPath, expectedRawDocument, expectedIdentity, overrides = {}) {
|
|
2060
|
-
const quarantinePath = join(
|
|
2061
|
-
dirname(settingsPath),
|
|
2062
|
-
`.${CONFIG_FILE_NAME}.${randomUUID()}.rollback`
|
|
2063
|
-
);
|
|
2025
|
+
const quarantinePath = join(dirname(settingsPath), `.${CONFIG_FILE_NAME}.${randomUUID()}.rollback`);
|
|
2064
2026
|
const before = lstatSync(settingsPath);
|
|
2065
2027
|
if (before.dev !== expectedIdentity.dev || before.ino !== expectedIdentity.ino) {
|
|
2066
2028
|
throw new Error("Starship settings changed concurrently; the newer file was preserved");
|
|
@@ -2114,6 +2076,7 @@ function cloneBuiltInConfig() {
|
|
|
2114
2076
|
...BUILT_IN_CONFIG.modules[name],
|
|
2115
2077
|
formatAst: structuredClone(BUILT_IN_CONFIG.modules[name].formatAst),
|
|
2116
2078
|
styles: { ...BUILT_IN_CONFIG.modules[name].styles },
|
|
2079
|
+
styleRules: structuredClone(BUILT_IN_CONFIG.modules[name].styleRules),
|
|
2117
2080
|
display: structuredClone(BUILT_IN_CONFIG.modules[name].display),
|
|
2118
2081
|
options: structuredClone(BUILT_IN_CONFIG.modules[name].options)
|
|
2119
2082
|
}
|
|
@@ -2129,11 +2092,7 @@ function validateFormatVariables(ast, allowed, path, diagnostics) {
|
|
|
2129
2092
|
for (const variable of formatVariables(ast)) {
|
|
2130
2093
|
if (allowed.has(variable)) continue;
|
|
2131
2094
|
diagnostics.push(
|
|
2132
|
-
diagnostic(
|
|
2133
|
-
"warning",
|
|
2134
|
-
path,
|
|
2135
|
-
`Unknown variable ${JSON.stringify(variable)} in ${path} was ignored`
|
|
2136
|
-
)
|
|
2095
|
+
diagnostic("warning", path, `Unknown variable ${JSON.stringify(variable)} in ${path} was ignored`)
|
|
2137
2096
|
);
|
|
2138
2097
|
}
|
|
2139
2098
|
}
|
|
@@ -2141,11 +2100,7 @@ function validateStyleVariables(ast, allowed, path, diagnostics) {
|
|
|
2141
2100
|
for (const variable of styleVariables(ast)) {
|
|
2142
2101
|
if (allowed.has(variable)) continue;
|
|
2143
2102
|
diagnostics.push(
|
|
2144
|
-
diagnostic(
|
|
2145
|
-
"warning",
|
|
2146
|
-
path,
|
|
2147
|
-
`Unknown style variable ${JSON.stringify(variable)} in ${path} was ignored`
|
|
2148
|
-
)
|
|
2103
|
+
diagnostic("warning", path, `Unknown style variable ${JSON.stringify(variable)} in ${path} was ignored`)
|
|
2149
2104
|
);
|
|
2150
2105
|
}
|
|
2151
2106
|
}
|
|
@@ -2153,11 +2108,7 @@ function validateModuleStyleField(name, field, module, palette, diagnostics) {
|
|
|
2153
2108
|
const style = field === "style" ? module.style : module.styles[field];
|
|
2154
2109
|
if (style === void 0 || isValidStyle(style, palette)) return;
|
|
2155
2110
|
diagnostics.push(
|
|
2156
|
-
diagnostic(
|
|
2157
|
-
"warning",
|
|
2158
|
-
`${name}.${field}`,
|
|
2159
|
-
`Invalid style ${JSON.stringify(style)}; using the module default`
|
|
2160
|
-
)
|
|
2111
|
+
diagnostic("warning", `${name}.${field}`, `Invalid style ${JSON.stringify(style)}; using the module default`)
|
|
2161
2112
|
);
|
|
2162
2113
|
if (field === "style") module.style = BUILT_IN_CONFIG.modules[name].style;
|
|
2163
2114
|
else {
|
|
@@ -2165,6 +2116,41 @@ function validateModuleStyleField(name, field, module, palette, diagnostics) {
|
|
|
2165
2116
|
if (fallback !== void 0) module.styles[field] = fallback;
|
|
2166
2117
|
}
|
|
2167
2118
|
}
|
|
2119
|
+
function normalizeStyleRules(name, value, allowedSelectors, palette, diagnostics) {
|
|
2120
|
+
if (!Array.isArray(value)) {
|
|
2121
|
+
diagnostics.push(typeDiagnostic(`${name}.style_rules`, "array of tables"));
|
|
2122
|
+
return [];
|
|
2123
|
+
}
|
|
2124
|
+
const result = [];
|
|
2125
|
+
for (const [index, entry] of value.entries()) {
|
|
2126
|
+
const path = `${name}.style_rules.${index}`;
|
|
2127
|
+
if (!isRecord(entry)) {
|
|
2128
|
+
diagnostics.push(diagnostic("warning", path, "Expected a table; rule ignored"));
|
|
2129
|
+
continue;
|
|
2130
|
+
}
|
|
2131
|
+
let valid = true;
|
|
2132
|
+
for (const field of Object.keys(entry)) {
|
|
2133
|
+
if (field !== "style" && !allowedSelectors.has(field)) {
|
|
2134
|
+
diagnostics.push(diagnostic("warning", `${path}.${field}`, "Unknown style-rule field; rule ignored"));
|
|
2135
|
+
valid = false;
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
if (typeof entry.style !== "string" || !isValidStyle(entry.style, palette)) {
|
|
2139
|
+
diagnostics.push(diagnostic("warning", `${path}.style`, "Expected a valid Starship style string; rule ignored"));
|
|
2140
|
+
valid = false;
|
|
2141
|
+
}
|
|
2142
|
+
const selectors = {};
|
|
2143
|
+
for (const selector of allowedSelectors) {
|
|
2144
|
+
if (entry[selector] === void 0) continue;
|
|
2145
|
+
if (typeof entry[selector] !== "string") {
|
|
2146
|
+
diagnostics.push(diagnostic("warning", `${path}.${selector}`, "Expected string; rule ignored"));
|
|
2147
|
+
valid = false;
|
|
2148
|
+
} else setOwn(selectors, selector, entry[selector]);
|
|
2149
|
+
}
|
|
2150
|
+
if (valid) result.push({ style: entry.style, selectors });
|
|
2151
|
+
}
|
|
2152
|
+
return result;
|
|
2153
|
+
}
|
|
2168
2154
|
function normalizeDisplay(name, value, defaults, palette, diagnostics) {
|
|
2169
2155
|
if (!Array.isArray(value)) {
|
|
2170
2156
|
diagnostics.push(typeDiagnostic(`${name}.display`, "array of tables"));
|
|
@@ -2188,9 +2174,7 @@ function normalizeDisplay(name, value, defaults, palette, diagnostics) {
|
|
|
2188
2174
|
valid = false;
|
|
2189
2175
|
}
|
|
2190
2176
|
if (typeof entry.style !== "string" || !isValidStyle(entry.style, palette)) {
|
|
2191
|
-
diagnostics.push(
|
|
2192
|
-
diagnostic("warning", `${path}.style`, "Expected a valid Starship style string")
|
|
2193
|
-
);
|
|
2177
|
+
diagnostics.push(diagnostic("warning", `${path}.style`, "Expected a valid Starship style string"));
|
|
2194
2178
|
valid = false;
|
|
2195
2179
|
}
|
|
2196
2180
|
if (typeof entry.hidden !== "boolean") {
|
|
@@ -2206,9 +2190,7 @@ function normalizeDisplay(name, value, defaults, palette, diagnostics) {
|
|
|
2206
2190
|
}
|
|
2207
2191
|
}
|
|
2208
2192
|
if (result.length > 0) return result;
|
|
2209
|
-
diagnostics.push(
|
|
2210
|
-
diagnostic("warning", `${name}.display`, "Expected at least one valid entry; using defaults")
|
|
2211
|
-
);
|
|
2193
|
+
diagnostics.push(diagnostic("warning", `${name}.display`, "Expected at least one valid entry; using defaults"));
|
|
2212
2194
|
return defaults.map((entry) => ({ ...entry }));
|
|
2213
2195
|
}
|
|
2214
2196
|
function validateLiteralStyles(ast, palette, path, diagnostics) {
|
|
@@ -2217,11 +2199,7 @@ function validateLiteralStyles(ast, palette, path, diagnostics) {
|
|
|
2217
2199
|
const style = node.style.map((part) => part.type === "text" ? part.value : "").join("");
|
|
2218
2200
|
if (!isValidStyle(style, palette)) {
|
|
2219
2201
|
diagnostics.push(
|
|
2220
|
-
diagnostic(
|
|
2221
|
-
"warning",
|
|
2222
|
-
path,
|
|
2223
|
-
`Invalid literal style ${JSON.stringify(style)}; rendered unstyled`
|
|
2224
|
-
)
|
|
2202
|
+
diagnostic("warning", path, `Invalid literal style ${JSON.stringify(style)}; rendered unstyled`)
|
|
2225
2203
|
);
|
|
2226
2204
|
}
|
|
2227
2205
|
}
|
|
@@ -2314,6 +2292,25 @@ import { stripVTControlCharacters } from "node:util";
|
|
|
2314
2292
|
|
|
2315
2293
|
// src/modules/render.ts
|
|
2316
2294
|
import { visibleWidth as visibleWidth2 } from "@earendil-works/pi-tui";
|
|
2295
|
+
|
|
2296
|
+
// src/modules/style-rules.ts
|
|
2297
|
+
function resolveStyleRule(rules, selectors, context) {
|
|
2298
|
+
for (const rule of rules) {
|
|
2299
|
+
let matches = true;
|
|
2300
|
+
for (const name in rule.selectors) {
|
|
2301
|
+
if (!Object.hasOwn(rule.selectors, name)) continue;
|
|
2302
|
+
const selector = Object.hasOwn(selectors, name) ? selectors[name] : void 0;
|
|
2303
|
+
if (!selector || selector(context) !== rule.selectors[name]) {
|
|
2304
|
+
matches = false;
|
|
2305
|
+
break;
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
if (matches) return rule.style;
|
|
2309
|
+
}
|
|
2310
|
+
return void 0;
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
// src/modules/render.ts
|
|
2317
2314
|
function renderStatusline(config, runtime, width = 80, trueColor = true) {
|
|
2318
2315
|
const palette = activePalette(config);
|
|
2319
2316
|
const modules = {};
|
|
@@ -2327,14 +2324,17 @@ function renderStatusline(config, runtime, width = 80, trueColor = true) {
|
|
|
2327
2324
|
const module = config.modules[name];
|
|
2328
2325
|
const values = definition.values(valueContext(config, name, runtime));
|
|
2329
2326
|
if (!values) continue;
|
|
2330
|
-
const
|
|
2327
|
+
const styleContext = {
|
|
2331
2328
|
runtime,
|
|
2332
2329
|
values,
|
|
2333
2330
|
style: module.style,
|
|
2334
2331
|
styles: module.styles,
|
|
2335
2332
|
display: module.display
|
|
2336
|
-
}
|
|
2337
|
-
|
|
2333
|
+
};
|
|
2334
|
+
const baseStyleVariables = definition.resolveStyleVariables ? definition.resolveStyleVariables(styleContext) : { style: module.style };
|
|
2335
|
+
if (!baseStyleVariables) continue;
|
|
2336
|
+
const ruleStyle = definition.styleRuleSelectors ? resolveStyleRule(module.styleRules, definition.styleRuleSelectors, styleContext) : void 0;
|
|
2337
|
+
const styleVariables2 = ruleStyle === void 0 ? baseStyleVariables : { ...baseStyleVariables, style: ruleStyle };
|
|
2338
2338
|
const contentValues = Object.fromEntries(
|
|
2339
2339
|
definition.variables.flatMap(
|
|
2340
2340
|
(variable) => variable !== "symbol" && Object.hasOwn(values, variable) ? [[variable, values[variable]]] : []
|
|
@@ -2448,9 +2448,7 @@ function inspectStatuslineModules(config, runtime, width = 80) {
|
|
|
2448
2448
|
const modules = MODULE_DEFINITIONS.map((definition) => {
|
|
2449
2449
|
const module = config.modules[definition.name];
|
|
2450
2450
|
const reachable = requirements.has(definition.name);
|
|
2451
|
-
const preview = plainPreview(
|
|
2452
|
-
rendered.modules[definition.name].map((chunk) => chunk.text).join("")
|
|
2453
|
-
);
|
|
2451
|
+
const preview = plainPreview(rendered.modules[definition.name].map((chunk) => chunk.text).join(""));
|
|
2454
2452
|
const state = module.disabled ? "Disabled" : !reachable ? "Not in format" : preview.length > 0 ? "Showing" : "Empty";
|
|
2455
2453
|
return moduleInspection(
|
|
2456
2454
|
config,
|
|
@@ -2496,6 +2494,8 @@ function moduleInspection(config, definition, state, preview, rootReferenced, re
|
|
|
2496
2494
|
preview,
|
|
2497
2495
|
variables: [...definition.variables],
|
|
2498
2496
|
styleFields: ["style", ...Object.keys(module.styles)],
|
|
2497
|
+
styleRuleSelectors: Object.keys(definition.styleRuleSelectors ?? {}),
|
|
2498
|
+
styleRuleCount: module.styleRules.length,
|
|
2499
2499
|
displayRules: module.display.map(
|
|
2500
2500
|
(rule) => `${rule.threshold}: ${rule.hidden ? "hidden" : rule.style || "unstyled"}`
|
|
2501
2501
|
),
|
|
@@ -2542,4 +2542,4 @@ export {
|
|
|
2542
2542
|
inspectStatuslineModules,
|
|
2543
2543
|
inspectUnavailableModules
|
|
2544
2544
|
};
|
|
2545
|
-
//# sourceMappingURL=chunk-
|
|
2545
|
+
//# sourceMappingURL=chunk-SD7TUSSU.js.map
|