@narumitw/pi-starship 0.49.3 → 0.50.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 (100) hide show
  1. package/NOTICES.md +4 -2
  2. package/README.md +62 -16
  3. package/package.json +10 -11
  4. package/src/command-contract.ts +13 -0
  5. package/src/command-inspector.ts +198 -0
  6. package/src/command-preset-picker.ts +203 -0
  7. package/src/command-preview.ts +206 -0
  8. package/src/commands.ts +784 -0
  9. package/src/config.ts +794 -0
  10. package/src/format/formatter.ts +275 -0
  11. package/src/format/style.ts +278 -0
  12. package/src/index.ts +1 -1
  13. package/src/modules/activity.ts +38 -0
  14. package/src/modules/brand.ts +13 -0
  15. package/src/modules/cache.ts +23 -0
  16. package/src/modules/catalog.ts +124 -0
  17. package/src/modules/cloud.ts +74 -0
  18. package/src/modules/context.ts +33 -0
  19. package/src/modules/cost.ts +31 -0
  20. package/src/modules/deployment.ts +61 -0
  21. package/src/modules/development.ts +112 -0
  22. package/src/modules/directory.ts +151 -0
  23. package/src/modules/display.ts +14 -0
  24. package/src/modules/execution.ts +84 -0
  25. package/src/modules/extension-status.ts +93 -0
  26. package/src/modules/fill.ts +14 -0
  27. package/src/modules/git/branch.ts +31 -0
  28. package/src/modules/git/commit.ts +29 -0
  29. package/src/modules/git/metrics.ts +26 -0
  30. package/src/modules/git/runtime.ts +415 -0
  31. package/src/modules/git/state.ts +21 -0
  32. package/src/modules/git/status.ts +87 -0
  33. package/src/modules/git/worktree.ts +16 -0
  34. package/src/modules/github-pr.ts +24 -0
  35. package/src/modules/helpers.ts +5 -0
  36. package/src/modules/index.ts +31 -0
  37. package/src/modules/inspection.ts +138 -0
  38. package/src/modules/languages.ts +87 -0
  39. package/src/modules/model.ts +85 -0
  40. package/src/modules/package.ts +17 -0
  41. package/src/modules/provider.ts +13 -0
  42. package/src/modules/render.ts +166 -0
  43. package/src/modules/terminal.ts +60 -0
  44. package/src/modules/thinking.ts +13 -0
  45. package/src/modules/time.ts +20 -0
  46. package/src/modules/tokens.ts +18 -0
  47. package/src/modules/truncation.ts +37 -0
  48. package/src/modules/turn.ts +13 -0
  49. package/src/modules/types.ts +189 -0
  50. package/src/modules/workspace-helpers.ts +10 -0
  51. package/src/pi-starship.ts +619 -0
  52. package/src/presets/bracketed-segments.ts +45 -0
  53. package/src/presets/catalog.ts +138 -0
  54. package/src/presets/catppuccin-powerline.ts +90 -0
  55. package/src/presets/gruvbox-rainbow.ts +66 -0
  56. package/src/presets/jetpack.ts +51 -0
  57. package/src/presets/minimal.ts +23 -0
  58. package/src/presets/nerd-font-symbols.ts +27 -0
  59. package/src/presets/no-empty-icons.ts +47 -0
  60. package/src/presets/no-nerd-font.ts +51 -0
  61. package/src/presets/no-runtime-versions.ts +52 -0
  62. package/src/presets/pastel-powerline.ts +53 -0
  63. package/src/presets/plain-text-symbols.ts +52 -0
  64. package/src/presets/pure-preset.ts +55 -0
  65. package/src/presets/tokyo-night.ts +53 -0
  66. package/src/runtime/cloud.ts +166 -0
  67. package/src/runtime/command.ts +123 -0
  68. package/src/runtime/deployment.ts +201 -0
  69. package/src/runtime/development.ts +153 -0
  70. package/src/runtime/execution.ts +151 -0
  71. package/src/runtime/github-pr.ts +332 -0
  72. package/src/runtime/helpers.ts +274 -0
  73. package/src/runtime/languages.ts +205 -0
  74. package/src/runtime/package.ts +112 -0
  75. package/src/runtime/refresh-controller.ts +107 -0
  76. package/src/runtime/types.ts +63 -0
  77. package/src/runtime/workspace.ts +147 -0
  78. package/src/usage.ts +53 -0
  79. package/dist/chunks/chunk-CKNSOLSW.ts +0 -10
  80. package/dist/chunks/chunk-CKNSOLSW.ts.map +0 -7
  81. package/dist/chunks/chunk-G2GG2V6Q.ts +0 -218
  82. package/dist/chunks/chunk-G2GG2V6Q.ts.map +0 -7
  83. package/dist/chunks/chunk-Q6DLIM7H.ts +0 -2492
  84. package/dist/chunks/chunk-Q6DLIM7H.ts.map +0 -7
  85. package/dist/chunks/cloud-JBSZWTB6.ts +0 -142
  86. package/dist/chunks/cloud-JBSZWTB6.ts.map +0 -7
  87. package/dist/chunks/commands-BSQZ2R4M.ts +0 -757
  88. package/dist/chunks/commands-BSQZ2R4M.ts.map +0 -7
  89. package/dist/chunks/deployment-ZNYM4B6W.ts +0 -172
  90. package/dist/chunks/deployment-ZNYM4B6W.ts.map +0 -7
  91. package/dist/chunks/development-TNWZ5SRC.ts +0 -132
  92. package/dist/chunks/development-TNWZ5SRC.ts.map +0 -7
  93. package/dist/chunks/execution-QHAP4U33.ts +0 -132
  94. package/dist/chunks/execution-QHAP4U33.ts.map +0 -7
  95. package/dist/chunks/languages-DPWDCH6Q.ts +0 -184
  96. package/dist/chunks/languages-DPWDCH6Q.ts.map +0 -7
  97. package/dist/chunks/package-MXN2YFLX.ts +0 -104
  98. package/dist/chunks/package-MXN2YFLX.ts.map +0 -7
  99. package/dist/pi-starship.ts +0 -1350
  100. package/dist/pi-starship.ts.map +0 -7
@@ -0,0 +1,60 @@
1
+ export function sanitizeTerminalText(value: string): string {
2
+ let result = "";
3
+ for (let index = 0; index < value.length; ) {
4
+ const codePoint = value.codePointAt(index) ?? 0;
5
+ const character = String.fromCodePoint(codePoint);
6
+ if (codePoint === 0x1b || codePoint === 0x9b || codePoint === 0x9d) {
7
+ index = skipTerminalEscape(value, index, codePoint);
8
+ continue;
9
+ }
10
+ if (
11
+ codePoint <= 0x1f ||
12
+ (codePoint >= 0x7f && codePoint <= 0x9f) ||
13
+ codePoint === 0x2028 ||
14
+ codePoint === 0x2029
15
+ ) {
16
+ if (
17
+ codePoint === 0x09 ||
18
+ codePoint === 0x0a ||
19
+ codePoint === 0x0d ||
20
+ codePoint === 0x85 ||
21
+ codePoint === 0x2028 ||
22
+ codePoint === 0x2029
23
+ ) {
24
+ result += " ";
25
+ }
26
+ index += character.length;
27
+ continue;
28
+ }
29
+ result += character;
30
+ index += character.length;
31
+ }
32
+ return result;
33
+ }
34
+
35
+ function skipTerminalEscape(value: string, start: number, codePoint: number): number {
36
+ let index = start + 1;
37
+ const next = value.charCodeAt(index);
38
+ const isOsc = codePoint === 0x9d || (codePoint === 0x1b && next === 0x5d);
39
+ if (isOsc) {
40
+ if (codePoint === 0x1b) index += 1;
41
+ while (index < value.length) {
42
+ const current = value.charCodeAt(index);
43
+ if (current === 0x07 || current === 0x9c) return index + 1;
44
+ if (current === 0x1b && value.charCodeAt(index + 1) === 0x5c) return index + 2;
45
+ index += 1;
46
+ }
47
+ return index;
48
+ }
49
+ const isCsi = codePoint === 0x9b || (codePoint === 0x1b && next === 0x5b);
50
+ if (isCsi) {
51
+ if (codePoint === 0x1b) index += 1;
52
+ while (index < value.length) {
53
+ const current = value.charCodeAt(index);
54
+ index += 1;
55
+ if (current >= 0x40 && current <= 0x7e) break;
56
+ }
57
+ return index;
58
+ }
59
+ return Math.min(value.length, start + (codePoint === 0x1b ? 2 : 1));
60
+ }
@@ -0,0 +1,13 @@
1
+ import { defineModule } from "./types.js";
2
+
3
+ export const thinkingModule = defineModule({
4
+ name: "thinking",
5
+ variables: ["symbol", "level"],
6
+ defaults: {
7
+ format: "[$symbol $level ]($style)",
8
+ symbol: "🧠",
9
+ style: "bold purple",
10
+ disabled: false,
11
+ },
12
+ values: ({ runtime }) => ({ level: runtime.thinkingLevel }),
13
+ });
@@ -0,0 +1,20 @@
1
+ import { defineModule } from "./types.js";
2
+
3
+ export const timeModule = defineModule({
4
+ name: "time",
5
+ variables: ["symbol", "time"],
6
+ defaults: {
7
+ format: "[$symbol $time ]($style)",
8
+ symbol: "🕒",
9
+ style: "bold yellow",
10
+ disabled: false,
11
+ },
12
+ values: ({ runtime }) => ({ time: formatTime(runtime.now) }),
13
+ });
14
+
15
+ function formatTime(now: Date): string {
16
+ return `${now.getHours().toString().padStart(2, "0")}:${now
17
+ .getMinutes()
18
+ .toString()
19
+ .padStart(2, "0")}`;
20
+ }
@@ -0,0 +1,18 @@
1
+ import { formatCount } from "./helpers.js";
2
+ import { defineModule } from "./types.js";
3
+
4
+ export const tokensModule = defineModule({
5
+ name: "tokens",
6
+ variables: ["symbol", "input", "output", "total"],
7
+ defaults: {
8
+ format: "[$symbol ↑$input ↓$output ]($style)",
9
+ symbol: "🔢",
10
+ style: "bold cyan",
11
+ disabled: false,
12
+ },
13
+ values: ({ runtime }) => ({
14
+ input: formatCount(runtime.tokenTotals.input),
15
+ output: formatCount(runtime.tokenTotals.output),
16
+ total: formatCount(runtime.tokenTotals.input + runtime.tokenTotals.output),
17
+ }),
18
+ });
@@ -0,0 +1,37 @@
1
+ import { sep } from "node:path";
2
+
3
+ const graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
4
+
5
+ export function graphemes(value: string): string[] {
6
+ return [...graphemeSegmenter.segment(value)].map(({ segment }) => segment);
7
+ }
8
+
9
+ export function firstGrapheme(value: string): string {
10
+ return graphemes(value)[0] ?? "";
11
+ }
12
+
13
+ export function truncateLeadingGraphemes(value: string, length: number, symbol: string): string {
14
+ if (length <= 0) return value;
15
+ const parts = graphemes(value);
16
+ if (parts.length <= length) return value;
17
+ return `${parts.slice(0, length).join("")}${firstGrapheme(symbol)}`;
18
+ }
19
+
20
+ export function toSlashPath(value: string): string {
21
+ return sep === "\\" ? value.replaceAll("\\", "/") : value;
22
+ }
23
+
24
+ export function truncatePathComponents(
25
+ value: string,
26
+ length: number,
27
+ ): { value: string; truncated: boolean } {
28
+ if (length <= 0) return { value, truncated: false };
29
+ const normalized = toSlashPath(value);
30
+ const components = normalized.split("/").filter((component) => component.length > 0);
31
+ if (components.length <= length) return { value: normalized, truncated: false };
32
+ return { value: components.slice(-length).join("/"), truncated: true };
33
+ }
34
+
35
+ export function useNativePathSeparator(value: string): string {
36
+ return sep === "/" ? value : value.replaceAll("/", sep);
37
+ }
@@ -0,0 +1,13 @@
1
+ import { defineModule } from "./types.js";
2
+
3
+ export const turnModule = defineModule({
4
+ name: "turn",
5
+ variables: ["symbol", "count"],
6
+ defaults: {
7
+ format: "[$symbol #$count ]($style)",
8
+ symbol: "🔁",
9
+ style: "bold purple",
10
+ disabled: false,
11
+ },
12
+ values: ({ runtime }) => ({ count: `${runtime.turnCount}` }),
13
+ });
@@ -0,0 +1,189 @@
1
+ import type { StyledChunk } from "../format/style.js";
2
+
3
+ export interface GitBranchSnapshot {
4
+ name: string;
5
+ remoteName?: string;
6
+ remoteBranch?: string;
7
+ detached: boolean;
8
+ }
9
+
10
+ export interface GitCommitSnapshot {
11
+ hash: string;
12
+ tag?: string;
13
+ detached: boolean;
14
+ }
15
+
16
+ export interface GitStateSnapshot {
17
+ state: string;
18
+ progressCurrent?: number;
19
+ progressTotal?: number;
20
+ }
21
+
22
+ export interface GitMetricsSnapshot {
23
+ added: number;
24
+ deleted: number;
25
+ }
26
+
27
+ export interface GitStatusSnapshot {
28
+ ahead: number;
29
+ behind: number;
30
+ stashed: number;
31
+ conflicted: number;
32
+ deleted: number;
33
+ renamed: number;
34
+ modified: number;
35
+ staged: number;
36
+ typechanged: number;
37
+ untracked: number;
38
+ worktreeAdded: number;
39
+ worktreeDeleted: number;
40
+ worktreeModified: number;
41
+ worktreeTypechanged: number;
42
+ indexAdded: number;
43
+ indexDeleted: number;
44
+ indexModified: number;
45
+ indexTypechanged: number;
46
+ }
47
+
48
+ export interface GitWorktreeSnapshot {
49
+ name: string;
50
+ path: string;
51
+ }
52
+
53
+ export type GithubPrState = "open" | "draft" | "merged" | "closed";
54
+
55
+ export interface GithubPrSnapshot {
56
+ readonly number: string;
57
+ readonly link: string;
58
+ readonly state: GithubPrState;
59
+ readonly checks: string;
60
+ readonly review: string;
61
+ readonly status: string;
62
+ readonly expiresAt?: number;
63
+ }
64
+
65
+ export interface GitSnapshot {
66
+ root?: string;
67
+ branch?: GitBranchSnapshot;
68
+ commit?: GitCommitSnapshot;
69
+ state?: GitStateSnapshot;
70
+ metrics?: GitMetricsSnapshot;
71
+ status: GitStatusSnapshot;
72
+ worktree?: GitWorktreeSnapshot;
73
+ }
74
+
75
+ export interface WorkspaceSnapshot {
76
+ modules: Readonly<Record<string, Readonly<Record<string, string>>>>;
77
+ styleSelectors?: Readonly<Record<string, string>>;
78
+ }
79
+
80
+ export interface StarshipRuntimeSnapshot {
81
+ cwd: string;
82
+ homeDir?: string;
83
+ gitRoot?: string;
84
+ model?: { provider: string; id: string };
85
+ thinkingLevel: string;
86
+ turnCount: number;
87
+ activeTools: ReadonlyMap<string, number>;
88
+ isStreaming: boolean;
89
+ lastCompletedTool?: string;
90
+ contextUsage?: {
91
+ percent?: number | null;
92
+ tokens?: number | null;
93
+ contextWindow?: number | null;
94
+ };
95
+ tokenTotals: {
96
+ input: number;
97
+ output: number;
98
+ cacheRead: number;
99
+ cacheWrite: number;
100
+ cost: number;
101
+ latestCacheHitRate?: number;
102
+ };
103
+ usingSubscription: boolean;
104
+ gitBranch: string | null;
105
+ gitBranchDetails?: GitBranchSnapshot;
106
+ gitCommit?: GitCommitSnapshot;
107
+ gitState?: GitStateSnapshot;
108
+ gitMetrics?: GitMetricsSnapshot;
109
+ gitStatus?: GitStatusSnapshot;
110
+ gitWorktree?: GitWorktreeSnapshot;
111
+ githubPr?: GithubPrSnapshot;
112
+ extensionStatuses: ReadonlyMap<string, string>;
113
+ now: Date;
114
+ workspace?: WorkspaceSnapshot;
115
+ }
116
+
117
+ export interface ExtensionStatusPresentation {
118
+ separator: string;
119
+ maxStatuses: number;
120
+ icons: Readonly<Record<string, string>>;
121
+ }
122
+
123
+ export type ModuleOptionValue =
124
+ | string
125
+ | boolean
126
+ | number
127
+ | readonly string[]
128
+ | Readonly<Record<string, string>>;
129
+
130
+ export interface ModuleValueContext {
131
+ runtime: StarshipRuntimeSnapshot;
132
+ symbol: string;
133
+ options: Readonly<Record<string, ModuleOptionValue>>;
134
+ extensionStatus: ExtensionStatusPresentation;
135
+ }
136
+
137
+ export type ModuleOptionSchema =
138
+ | { kind: "string"; default: string; allowEmpty?: boolean }
139
+ | { kind: "string-enum"; default: string; values: readonly string[] }
140
+ | { kind: "boolean"; default: boolean }
141
+ | { kind: "integer"; default: number; minimum: number; maximum: number }
142
+ | { kind: "string-array"; default: readonly string[]; allowNegative?: boolean }
143
+ | { kind: "string-map"; default: Readonly<Record<string, string>> };
144
+
145
+ export interface ModuleDisplayConfig {
146
+ threshold: number;
147
+ style: string;
148
+ hidden: boolean;
149
+ }
150
+
151
+ export interface ModuleDefaults {
152
+ format: string;
153
+ symbol: string;
154
+ style: string;
155
+ disabled: boolean;
156
+ }
157
+
158
+ export interface ModuleStyleContext {
159
+ runtime: StarshipRuntimeSnapshot;
160
+ values: Readonly<Record<string, string>>;
161
+ style: string;
162
+ styles: Readonly<Record<string, string>>;
163
+ display: readonly ModuleDisplayConfig[];
164
+ }
165
+
166
+ export interface ModuleDefinition<Name extends string> {
167
+ name: Name;
168
+ variables: readonly string[];
169
+ defaults: ModuleDefaults;
170
+ styleDefaults?: Readonly<Record<string, string>>;
171
+ displayDefaults?: readonly ModuleDisplayConfig[];
172
+ styleVariables?: readonly string[];
173
+ resolveStyleVariables?(context: ModuleStyleContext): Readonly<Record<string, string>> | undefined;
174
+ options?: Readonly<Record<string, ModuleOptionSchema>>;
175
+ layout?: "fill";
176
+ values(context: ModuleValueContext): Record<string, string> | undefined;
177
+ }
178
+
179
+ export function defineModule<const Name extends string>(
180
+ definition: ModuleDefinition<Name>,
181
+ ): ModuleDefinition<Name> {
182
+ return definition;
183
+ }
184
+
185
+ export interface RenderedStatusline<Name extends string = string> {
186
+ ansi: string;
187
+ chunks: StyledChunk[];
188
+ modules: Record<Name, StyledChunk[]>;
189
+ }
@@ -0,0 +1,10 @@
1
+ import type { ModuleValueContext } from "./types.js";
2
+
3
+ export function workspaceModuleValues(
4
+ name: string,
5
+ context: ModuleValueContext,
6
+ ): Record<string, string> | undefined {
7
+ const values = context.runtime.workspace?.modules[name];
8
+ if (!values) return undefined;
9
+ return { ...values };
10
+ }