@narumitw/pi-starship 0.49.2 → 0.49.3

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 (84) hide show
  1. package/README.md +6 -4
  2. package/dist/chunks/chunk-CKNSOLSW.ts +10 -0
  3. package/dist/chunks/chunk-CKNSOLSW.ts.map +7 -0
  4. package/dist/chunks/chunk-G2GG2V6Q.ts +218 -0
  5. package/dist/chunks/chunk-G2GG2V6Q.ts.map +7 -0
  6. package/dist/chunks/chunk-Q6DLIM7H.ts +2492 -0
  7. package/dist/chunks/chunk-Q6DLIM7H.ts.map +7 -0
  8. package/dist/chunks/cloud-JBSZWTB6.ts +142 -0
  9. package/dist/chunks/cloud-JBSZWTB6.ts.map +7 -0
  10. package/dist/chunks/commands-BSQZ2R4M.ts +757 -0
  11. package/dist/chunks/commands-BSQZ2R4M.ts.map +7 -0
  12. package/dist/chunks/deployment-ZNYM4B6W.ts +172 -0
  13. package/dist/chunks/deployment-ZNYM4B6W.ts.map +7 -0
  14. package/dist/chunks/development-TNWZ5SRC.ts +132 -0
  15. package/dist/chunks/development-TNWZ5SRC.ts.map +7 -0
  16. package/dist/chunks/execution-QHAP4U33.ts +132 -0
  17. package/dist/chunks/execution-QHAP4U33.ts.map +7 -0
  18. package/dist/chunks/languages-DPWDCH6Q.ts +184 -0
  19. package/dist/chunks/languages-DPWDCH6Q.ts.map +7 -0
  20. package/dist/chunks/package-MXN2YFLX.ts +104 -0
  21. package/dist/chunks/package-MXN2YFLX.ts.map +7 -0
  22. package/dist/pi-starship.ts +1350 -0
  23. package/dist/pi-starship.ts.map +7 -0
  24. package/package.json +9 -5
  25. package/src/index.ts +1 -1
  26. package/src/command-contract.ts +0 -13
  27. package/src/command-inspector.ts +0 -198
  28. package/src/command-preview.ts +0 -206
  29. package/src/commands.ts +0 -575
  30. package/src/config.ts +0 -794
  31. package/src/format/formatter.ts +0 -275
  32. package/src/format/style.ts +0 -278
  33. package/src/modules/activity.ts +0 -38
  34. package/src/modules/brand.ts +0 -13
  35. package/src/modules/cache.ts +0 -23
  36. package/src/modules/catalog.ts +0 -124
  37. package/src/modules/cloud.ts +0 -74
  38. package/src/modules/context.ts +0 -33
  39. package/src/modules/cost.ts +0 -31
  40. package/src/modules/deployment.ts +0 -61
  41. package/src/modules/development.ts +0 -112
  42. package/src/modules/directory.ts +0 -151
  43. package/src/modules/display.ts +0 -14
  44. package/src/modules/execution.ts +0 -84
  45. package/src/modules/extension-status.ts +0 -93
  46. package/src/modules/fill.ts +0 -14
  47. package/src/modules/git/branch.ts +0 -31
  48. package/src/modules/git/commit.ts +0 -29
  49. package/src/modules/git/metrics.ts +0 -26
  50. package/src/modules/git/runtime.ts +0 -415
  51. package/src/modules/git/state.ts +0 -21
  52. package/src/modules/git/status.ts +0 -87
  53. package/src/modules/git/worktree.ts +0 -16
  54. package/src/modules/github-pr.ts +0 -24
  55. package/src/modules/helpers.ts +0 -5
  56. package/src/modules/index.ts +0 -31
  57. package/src/modules/inspection.ts +0 -138
  58. package/src/modules/languages.ts +0 -87
  59. package/src/modules/model.ts +0 -85
  60. package/src/modules/package.ts +0 -17
  61. package/src/modules/provider.ts +0 -13
  62. package/src/modules/render.ts +0 -166
  63. package/src/modules/terminal.ts +0 -60
  64. package/src/modules/thinking.ts +0 -13
  65. package/src/modules/time.ts +0 -20
  66. package/src/modules/tokens.ts +0 -18
  67. package/src/modules/truncation.ts +0 -37
  68. package/src/modules/turn.ts +0 -13
  69. package/src/modules/types.ts +0 -189
  70. package/src/modules/workspace-helpers.ts +0 -10
  71. package/src/pi-starship.ts +0 -609
  72. package/src/runtime/cloud.ts +0 -166
  73. package/src/runtime/command.ts +0 -123
  74. package/src/runtime/deployment.ts +0 -201
  75. package/src/runtime/development.ts +0 -153
  76. package/src/runtime/execution.ts +0 -151
  77. package/src/runtime/github-pr.ts +0 -332
  78. package/src/runtime/helpers.ts +0 -274
  79. package/src/runtime/languages.ts +0 -205
  80. package/src/runtime/package.ts +0 -112
  81. package/src/runtime/refresh-controller.ts +0 -107
  82. package/src/runtime/types.ts +0 -63
  83. package/src/runtime/workspace.ts +0 -147
  84. package/src/usage.ts +0 -53
@@ -1,63 +0,0 @@
1
- import type { StarshipConfig } from "../config.js";
2
- import type { ModuleName } from "../modules/catalog.js";
3
- import type { WorkspaceSnapshot } from "../modules/types.js";
4
-
5
- export interface WorkspaceExecResult {
6
- stdout: string;
7
- stderr: string;
8
- code: number;
9
- killed: boolean;
10
- }
11
-
12
- export type WorkspaceExec = (
13
- command: string,
14
- args: string[],
15
- options: {
16
- cwd: string;
17
- timeout: number;
18
- maxOutputBytes: number;
19
- signal?: AbortSignal;
20
- environment: Readonly<Record<string, string | undefined>>;
21
- },
22
- ) => Promise<WorkspaceExecResult>;
23
-
24
- export interface WorkspaceEntry {
25
- name: string;
26
- isFile: boolean;
27
- isDirectory: boolean;
28
- }
29
-
30
- export interface WorkspaceFileSystem {
31
- readFile(path: string, maxBytes: number): Promise<string | undefined>;
32
- readDirectory(path: string): Promise<readonly WorkspaceEntry[]>;
33
- fileExists(path: string): Promise<boolean>;
34
- }
35
-
36
- export interface WorkspaceRefreshInput {
37
- cwd: string;
38
- config: StarshipConfig;
39
- environment: Readonly<Record<string, string | undefined>>;
40
- homeDir: string;
41
- platform: NodeJS.Platform;
42
- hostname: string;
43
- username: string;
44
- exec: WorkspaceExec;
45
- fileSystem?: Partial<WorkspaceFileSystem>;
46
- fileExists?(path: string): Promise<boolean>;
47
- reason?: "initial" | "event" | "periodic";
48
- previous?: WorkspaceSnapshot;
49
- signal?: AbortSignal;
50
- }
51
-
52
- export interface CollectorContext {
53
- input: WorkspaceRefreshInput;
54
- fs: WorkspaceFileSystem;
55
- requirements: ReadonlyMap<ModuleName, ReadonlySet<string>>;
56
- entries(): Promise<readonly WorkspaceEntry[]>;
57
- options(name: ModuleName): Readonly<Record<string, unknown>>;
58
- needs(name: ModuleName, variable?: string): boolean;
59
- }
60
-
61
- export const PRIVATE_STYLE_SELECTOR = "__pi_style_selector";
62
-
63
- export type MutableModuleSnapshot = Record<string, Record<string, string>>;
@@ -1,147 +0,0 @@
1
- import type { ModuleName } from "../modules/catalog.js";
2
- import { reachableModuleRequirements } from "../modules/render.js";
3
- import type { WorkspaceSnapshot } from "../modules/types.js";
4
- import { createFileSystem } from "./helpers.js";
5
- import {
6
- type CollectorContext,
7
- type MutableModuleSnapshot,
8
- PRIVATE_STYLE_SELECTOR,
9
- type WorkspaceEntry,
10
- type WorkspaceRefreshInput,
11
- } from "./types.js";
12
-
13
- export type { WorkspaceExec, WorkspaceExecResult, WorkspaceRefreshInput } from "./types.js";
14
-
15
- export async function collectWorkspaceSnapshot(
16
- input: WorkspaceRefreshInput,
17
- ): Promise<WorkspaceSnapshot> {
18
- const requirements = reachableModuleRequirements(input.config);
19
- if (input.signal?.aborted || !hasWorkspaceRequirement(requirements)) return freezeSnapshot({});
20
- const fs = createFileSystem(input);
21
- let listing: Promise<readonly WorkspaceEntry[]> | undefined;
22
- const context: CollectorContext = {
23
- input,
24
- fs,
25
- requirements,
26
- entries() {
27
- listing ??= fs.readDirectory(input.cwd);
28
- return listing;
29
- },
30
- options(name) {
31
- return input.config.modules[name].options;
32
- },
33
- needs(name, variable) {
34
- const variables = requirements.get(name);
35
- return Boolean(variables && (variable === undefined || variables.has(variable)));
36
- },
37
- };
38
- const modules: MutableModuleSnapshot = {};
39
- if (requirements.has("package")) {
40
- const { collectPackage } = await import("./package.js");
41
- if (input.signal?.aborted) return freezeSnapshot({});
42
- const packageValues = await collectPackage(context);
43
- if (input.signal?.aborted) return freezeSnapshot({});
44
- if (packageValues) modules.package = packageValues;
45
- }
46
- for (const descriptor of COLLECTOR_GROUPS) {
47
- if (!descriptor.modules.some((name) => requirements.has(name))) continue;
48
- if (input.signal?.aborted) return freezeSnapshot({});
49
- const collector = await descriptor.load();
50
- if (input.signal?.aborted) return freezeSnapshot({});
51
- mergeModules(modules, await collector(context));
52
- }
53
- return input.signal?.aborted ? freezeSnapshot({}) : freezeSnapshot(modules);
54
- }
55
-
56
- export function workspaceSnapshotEqual(
57
- left: WorkspaceSnapshot | undefined,
58
- right: WorkspaceSnapshot | undefined,
59
- ): boolean {
60
- return JSON.stringify(left) === JSON.stringify(right);
61
- }
62
-
63
- function hasWorkspaceRequirement(
64
- requirements: ReadonlyMap<ModuleName, ReadonlySet<string>>,
65
- ): boolean {
66
- return [...requirements.keys()].some((name) => !BUILT_IN_ONLY_MODULES.has(name));
67
- }
68
-
69
- type WorkspaceCollector = (context: CollectorContext) => Promise<MutableModuleSnapshot>;
70
-
71
- const COLLECTOR_GROUPS: readonly {
72
- modules: readonly ModuleName[];
73
- load(): Promise<WorkspaceCollector>;
74
- }[] = [
75
- {
76
- modules: ["nodejs", "python", "rust", "golang", "bun", "deno"],
77
- load: async () => (await import("./languages.js")).collectLanguages,
78
- },
79
- {
80
- modules: ["mise", "direnv", "pixi", "conda", "nix_shell", "guix_shell"],
81
- load: async () => (await import("./development.js")).collectDevelopment,
82
- },
83
- {
84
- modules: ["docker_context", "kubernetes", "terraform"],
85
- load: async () => (await import("./deployment.js")).collectDeployment,
86
- },
87
- {
88
- modules: ["aws", "gcloud", "azure", "openstack"],
89
- load: async () => (await import("./cloud.js")).collectCloud,
90
- },
91
- {
92
- modules: ["container", "hostname", "os", "username"],
93
- load: async () => (await import("./execution.js")).collectExecution,
94
- },
95
- ];
96
-
97
- const BUILT_IN_ONLY_MODULES = new Set<ModuleName>([
98
- "brand",
99
- "provider",
100
- "model",
101
- "thinking",
102
- "directory",
103
- "git_worktree",
104
- "git_branch",
105
- "github_pr",
106
- "git_commit",
107
- "git_state",
108
- "git_metrics",
109
- "git_status",
110
- "activity",
111
- "context",
112
- "tokens",
113
- "cost",
114
- "time",
115
- "turn",
116
- "fill",
117
- "extension_status",
118
- ]);
119
-
120
- function mergeModules(target: MutableModuleSnapshot, source: MutableModuleSnapshot): void {
121
- for (const [name, values] of Object.entries(source)) {
122
- Object.defineProperty(target, name, {
123
- value: values,
124
- writable: true,
125
- enumerable: true,
126
- configurable: true,
127
- });
128
- }
129
- }
130
-
131
- function freezeSnapshot(modules: MutableModuleSnapshot): WorkspaceSnapshot {
132
- const styleSelectors: Record<string, string> = {};
133
- for (const [name, values] of Object.entries(modules)) {
134
- const selector = Object.hasOwn(values, PRIVATE_STYLE_SELECTOR)
135
- ? values[PRIVATE_STYLE_SELECTOR]
136
- : undefined;
137
- delete values[PRIVATE_STYLE_SELECTOR];
138
- if (selector !== undefined) styleSelectors[name] = selector;
139
- Object.freeze(values);
140
- }
141
- return Object.freeze({
142
- modules: Object.freeze(modules),
143
- ...(Object.keys(styleSelectors).length > 0
144
- ? { styleSelectors: Object.freeze(styleSelectors) }
145
- : {}),
146
- });
147
- }
package/src/usage.ts DELETED
@@ -1,53 +0,0 @@
1
- import type { SessionEntry } from "@earendil-works/pi-coding-agent";
2
-
3
- interface UsageLike {
4
- input?: number;
5
- output?: number;
6
- cacheRead?: number;
7
- cacheWrite?: number;
8
- cost?: { total?: number };
9
- }
10
-
11
- export interface FooterUsageSummary {
12
- input: number;
13
- output: number;
14
- cacheRead: number;
15
- cacheWrite: number;
16
- cost: number;
17
- latestCacheHitRate?: number;
18
- }
19
-
20
- export function summarizeFooterUsage(entries: readonly SessionEntry[]): FooterUsageSummary {
21
- const totals: FooterUsageSummary = {
22
- input: 0,
23
- output: 0,
24
- cacheRead: 0,
25
- cacheWrite: 0,
26
- cost: 0,
27
- };
28
-
29
- for (const entry of entries) {
30
- let usage: UsageLike | undefined;
31
- if (entry.type === "message" && entry.message.role === "assistant") {
32
- usage = entry.message.usage;
33
- const input = usage.input ?? 0;
34
- const cacheRead = usage.cacheRead ?? 0;
35
- const cacheWrite = usage.cacheWrite ?? 0;
36
- const promptTokens = input + cacheRead + cacheWrite;
37
- totals.latestCacheHitRate = promptTokens > 0 ? (cacheRead / promptTokens) * 100 : undefined;
38
- } else if (entry.type === "message" && entry.message.role === "toolResult") {
39
- usage = entry.message.usage;
40
- } else if (entry.type === "compaction" || entry.type === "branch_summary") {
41
- usage = entry.usage;
42
- }
43
- if (!usage) continue;
44
-
45
- totals.input += usage.input ?? 0;
46
- totals.output += usage.output ?? 0;
47
- totals.cacheRead += usage.cacheRead ?? 0;
48
- totals.cacheWrite += usage.cacheWrite ?? 0;
49
- totals.cost += usage.cost?.total ?? 0;
50
- }
51
-
52
- return totals;
53
- }