@felan-ai/ext-powerline 0.13.0 → 0.14.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 (58) hide show
  1. package/README.md +76 -58
  2. package/dist/config.d.ts +4 -51
  3. package/dist/config.d.ts.map +1 -1
  4. package/dist/config.js +7 -184
  5. package/dist/config.js.map +1 -1
  6. package/dist/core-services.d.ts +5 -0
  7. package/dist/core-services.d.ts.map +1 -0
  8. package/dist/core-services.js +66 -0
  9. package/dist/core-services.js.map +1 -0
  10. package/dist/data.d.ts +60 -0
  11. package/dist/data.d.ts.map +1 -0
  12. package/dist/data.js +40 -0
  13. package/dist/data.js.map +1 -0
  14. package/dist/extension.d.ts +7 -0
  15. package/dist/extension.d.ts.map +1 -0
  16. package/dist/extension.js +23 -0
  17. package/dist/extension.js.map +1 -0
  18. package/dist/generic.d.ts +8 -0
  19. package/dist/generic.d.ts.map +1 -0
  20. package/dist/generic.js +130 -0
  21. package/dist/generic.js.map +1 -0
  22. package/dist/git.d.ts +7 -2
  23. package/dist/git.d.ts.map +1 -1
  24. package/dist/git.js +32 -8
  25. package/dist/git.js.map +1 -1
  26. package/dist/index.d.ts +5 -29
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +5 -142
  29. package/dist/index.js.map +1 -1
  30. package/dist/runtime.d.ts +32 -0
  31. package/dist/runtime.d.ts.map +1 -0
  32. package/dist/runtime.js +215 -0
  33. package/dist/runtime.js.map +1 -0
  34. package/dist/subscription.d.ts +2 -4
  35. package/dist/subscription.d.ts.map +1 -1
  36. package/dist/subscription.js +2 -14
  37. package/dist/subscription.js.map +1 -1
  38. package/dist/usage.d.ts +4 -0
  39. package/dist/usage.d.ts.map +1 -0
  40. package/dist/usage.js +20 -0
  41. package/dist/usage.js.map +1 -0
  42. package/package.json +20 -10
  43. package/dist/colors.d.ts +0 -18
  44. package/dist/colors.d.ts.map +0 -1
  45. package/dist/colors.js +0 -42
  46. package/dist/colors.js.map +0 -1
  47. package/dist/footer.d.ts +0 -37
  48. package/dist/footer.d.ts.map +0 -1
  49. package/dist/footer.js +0 -146
  50. package/dist/footer.js.map +0 -1
  51. package/dist/segments.d.ts +0 -39
  52. package/dist/segments.d.ts.map +0 -1
  53. package/dist/segments.js +0 -344
  54. package/dist/segments.js.map +0 -1
  55. package/dist/symbols.d.ts +0 -27
  56. package/dist/symbols.d.ts.map +0 -1
  57. package/dist/symbols.js +0 -17
  58. package/dist/symbols.js.map +0 -1
package/dist/colors.js DELETED
@@ -1,42 +0,0 @@
1
- const ROLE_COLORS = {
2
- directory: { fg: 'accent', bg: 'customMessageBg' },
3
- git: { fg: 'text', bg: 'customMessageBg' },
4
- model: { fg: 'muted', bg: 'customMessageBg' },
5
- session: { fg: 'text', bg: 'customMessageBg' },
6
- subscription: { fg: 'muted', bg: 'customMessageBg' },
7
- savings: { fg: 'accent', bg: 'customMessageBg' },
8
- context: { fg: 'muted', bg: 'customMessageBg' },
9
- status: { fg: 'muted', bg: 'customMessageBg' },
10
- version: { fg: 'muted', bg: 'customMessageBg' },
11
- warning: { fg: 'warning', bg: 'toolPendingBg' },
12
- critical: { fg: 'error', bg: 'toolErrorBg' },
13
- muted: { fg: 'muted', bg: 'customMessageBg' },
14
- extensionStatus1: { fg: 'accent', bg: 'customMessageBg' },
15
- extensionStatus2: { fg: 'muted', bg: 'customMessageBg' },
16
- extensionStatus3: { fg: 'success', bg: 'customMessageBg' },
17
- extensionStatus4: { fg: 'warning', bg: 'customMessageBg' },
18
- };
19
- export function getThemePalette(theme) {
20
- return {
21
- colors: Object.fromEntries(Object.entries(ROLE_COLORS).map(([key, role]) => [key, {
22
- fg: theme.getFgAnsi(role.fg),
23
- bg: theme.getBgAnsi(role.bg),
24
- }])),
25
- };
26
- }
27
- export function colorBlock(text, pair, _mode) {
28
- if (_mode === 'none')
29
- return text;
30
- return `${pair.fg}${pair.bg}${text}\x1b[0m`;
31
- }
32
- export function colorForeground(text, ansi, _mode) {
33
- if (_mode === 'none')
34
- return text;
35
- return `${ansi}${text}\x1b[39m`;
36
- }
37
- export function colorPairText(text, pair, _mode) {
38
- if (_mode === 'none')
39
- return text;
40
- return `${pair.fg}${text}\x1b[39m`;
41
- }
42
- //# sourceMappingURL=colors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"colors.js","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,GAAgH;IAC/H,SAAS,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,iBAAiB,EAAE;IAClD,GAAG,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,iBAAiB,EAAE;IAC1C,KAAK,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE;IAC7C,OAAO,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,iBAAiB,EAAE;IAC9C,YAAY,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE;IACpD,OAAO,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,iBAAiB,EAAE;IAChD,OAAO,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE;IAC/C,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE;IAC9C,OAAO,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE;IAC/C,OAAO,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,eAAe,EAAE;IAC/C,QAAQ,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE;IAC5C,KAAK,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE;IAC7C,gBAAgB,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE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CAAC;AACrC,CAAC"}
package/dist/footer.d.ts DELETED
@@ -1,37 +0,0 @@
1
- import type { ExtensionContext, FelanExtensionAPI } from '@felan-ai/agent-core';
2
- import { type Component, type TUI } from '@earendil-works/pi-tui';
3
- import { getThemePalette, type ColorMode, type ThemePalette } from './colors.js';
4
- import type { PowerlineConfig } from './config.js';
5
- import { type FooterDataLike, type RenderedSegment, type SessionUsageTotals } from './segments.js';
6
- import type { SubscriptionState } from './subscription.js';
7
- import type { SavingsState } from './savings.js';
8
- import { type PowerlineSymbols } from './symbols.js';
9
- export type FooterRowsRenderer = (width: number) => readonly string[];
10
- export interface PowerlineFooterOptions {
11
- pi: FelanExtensionAPI;
12
- ctx: ExtensionContext;
13
- tui: TUI;
14
- footerData: FooterDataLike;
15
- theme: Parameters<typeof getThemePalette>[0];
16
- config: PowerlineConfig;
17
- felanVersion?: string;
18
- subscription: SubscriptionState;
19
- savings?: SavingsState | (() => SavingsState);
20
- additionalSessionUsage?: SessionUsageTotals | (() => SessionUsageTotals);
21
- footerRows?: FooterRowsRenderer;
22
- }
23
- export declare class PowerlineFooter implements Component {
24
- private readonly options;
25
- private readonly gitCache;
26
- private readonly unsubscribeBranch;
27
- private disposed;
28
- constructor(options: PowerlineFooterOptions);
29
- invalidate(): void;
30
- dispose(): void;
31
- render(width: number): string[];
32
- private refreshGit;
33
- private requestRender;
34
- }
35
- export declare function renderFooterLine(segments: RenderedSegment[], config: PowerlineConfig, palette: ThemePalette, mode: ColorMode, symbols: PowerlineSymbols, width: number): string[];
36
- export declare function renderStyledSegments(segments: RenderedSegment[], config: PowerlineConfig, palette: ThemePalette, mode: ColorMode, symbols: PowerlineSymbols): string;
37
- //# sourceMappingURL=footer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../src/footer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO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OAAO,CAAC,QAAQ,CAAS;gBAEI,OAAO,EAAE,sBAAsB;IAM5D,UAAU,IAAI,IAAI;IAKlB,OAAO,IAAI,IAAI;IAOf,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAsC/B,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,aAAa;CAGtB;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,eAAe,EAAE,EAC3B,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,MAAM,GACZ,MAAM,EAAE,CAmBV;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,eAAe,EAAE,EAC3B,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,gBAAgB,GACxB,MAAM,CAIR"}
package/dist/footer.js DELETED
@@ -1,146 +0,0 @@
1
- import { truncateToWidth, visibleWidth } from '@earendil-works/pi-tui';
2
- import { colorBlock, colorForeground, colorPairText, getThemePalette, } from './colors.js';
3
- import { GitCache } from './git.js';
4
- import { renderSegments, } from './segments.js';
5
- import { getSymbols } from './symbols.js';
6
- export class PowerlineFooter {
7
- options;
8
- gitCache;
9
- unsubscribeBranch;
10
- disposed = false;
11
- constructor(options) {
12
- this.options = options;
13
- this.gitCache = new GitCache(options.pi, options.ctx.cwd);
14
- this.unsubscribeBranch = options.footerData.onBranchChange(() => this.invalidate());
15
- this.refreshGit();
16
- }
17
- invalidate() {
18
- this.refreshGit();
19
- this.requestRender();
20
- }
21
- dispose() {
22
- if (this.disposed)
23
- return;
24
- this.disposed = true;
25
- this.unsubscribeBranch();
26
- this.gitCache.dispose();
27
- }
28
- render(width) {
29
- const safeWidth = Math.max(0, Math.floor(width));
30
- if (safeWidth === 0)
31
- return [''];
32
- const { config } = this.options;
33
- const symbols = getSymbols(config.display.charset);
34
- // Read the context theme on every render so Pi theme changes are reflected
35
- // without requiring the footer factory to be installed again.
36
- const palette = getThemePalette(this.options.ctx.ui.theme);
37
- const mode = 'truecolor';
38
- const lines = [];
39
- for (const line of config.display.lines) {
40
- const gitDetails = this.gitCache.get();
41
- const segments = renderSegments(line, {
42
- ctx: this.options.ctx,
43
- ...(this.options.felanVersion === undefined ? {} : { felanVersion: this.options.felanVersion }),
44
- footerData: this.options.footerData,
45
- ...(gitDetails === undefined ? {} : { gitDetails }),
46
- subscription: this.options.subscription,
47
- ...(typeof this.options.savings === 'function'
48
- ? { savings: this.options.savings() }
49
- : this.options.savings === undefined ? {} : { savings: this.options.savings }),
50
- ...(typeof this.options.additionalSessionUsage === 'function'
51
- ? { additionalSessionUsage: this.options.additionalSessionUsage() }
52
- : this.options.additionalSessionUsage === undefined
53
- ? {}
54
- : { additionalSessionUsage: this.options.additionalSessionUsage }),
55
- symbols,
56
- });
57
- if (segments.length > 0)
58
- lines.push(...renderFooterLine(segments, config, palette, mode, symbols, safeWidth));
59
- }
60
- const footerLines = lines.length > 0 ? lines : [''];
61
- const extraRows = this.options.footerRows?.(safeWidth) ?? [];
62
- return [...footerLines, ...extraRows].map((line) => ensureWidth(line, safeWidth));
63
- }
64
- refreshGit() {
65
- void this.gitCache.refresh().then(() => this.requestRender());
66
- }
67
- requestRender() {
68
- if (!this.disposed)
69
- this.options.tui.requestRender();
70
- }
71
- }
72
- export function renderFooterLine(segments, config, palette, mode, symbols, width) {
73
- const left = segments.filter((segment) => segment.align === 'left');
74
- const right = segments.filter((segment) => segment.align === 'right');
75
- if (right.length > 0)
76
- return [renderAlignedLine(left, right, config, palette, mode, symbols, width)];
77
- if (!config.display.autoWrap)
78
- return [ensureWidth(renderStyledSegments(segments, config, palette, mode, symbols), width)];
79
- const lines = [];
80
- let current = [];
81
- for (const segment of segments) {
82
- const candidate = [...current, segment];
83
- if (current.length > 0 && visibleWidth(renderStyledSegments(candidate, config, palette, mode, symbols)) > width) {
84
- lines.push(ensureWidth(renderStyledSegments(current, config, palette, mode, symbols), width));
85
- current = [segment];
86
- }
87
- else {
88
- current = candidate;
89
- }
90
- }
91
- if (current.length > 0)
92
- lines.push(ensureWidth(renderStyledSegments(current, config, palette, mode, symbols), width));
93
- return lines;
94
- }
95
- export function renderStyledSegments(segments, config, palette, mode, symbols) {
96
- if (config.display.style === 'minimal')
97
- return renderMinimal(segments, config, palette, mode, symbols);
98
- if (config.display.style === 'capsule')
99
- return renderCapsule(segments, config, palette, mode, symbols);
100
- return renderPowerline(segments, config, palette, mode, symbols);
101
- }
102
- function renderAlignedLine(leftSegments, rightSegments, config, palette, mode, symbols, width) {
103
- const right = ensureWidth(renderStyledSegments(rightSegments, config, palette, mode, symbols), width);
104
- const rightWidth = visibleWidth(right);
105
- const leftAvailable = Math.max(0, width - rightWidth - (leftSegments.length > 0 ? 1 : 0));
106
- const left = leftAvailable > 0
107
- ? ensureWidth(renderStyledSegments(leftSegments, config, palette, mode, symbols), leftAvailable)
108
- : '';
109
- if (!left)
110
- return ' '.repeat(Math.max(0, width - rightWidth)) + right;
111
- return ensureWidth(left + ' '.repeat(Math.max(1, width - visibleWidth(left) - rightWidth)) + right, width);
112
- }
113
- function renderMinimal(segments, config, palette, mode, symbols) {
114
- const separator = colorForeground(` ${symbols.separatorThin} `, palette.colors.muted.fg, mode);
115
- return segments
116
- .map((segment) => colorPairText(pad(segment.text, config.display.padding), palette.colors[segment.colorKey], mode))
117
- .join(separator);
118
- }
119
- function renderPowerline(segments, config, palette, mode, symbols) {
120
- let output = '';
121
- for (let index = 0; index < segments.length; index += 1) {
122
- const segment = segments[index];
123
- const pair = palette.colors[segment.colorKey];
124
- const next = segments[index + 1];
125
- output += colorBlock(pad(segment.text, config.display.padding), pair, mode);
126
- output += next
127
- ? colorBlock(symbols.separator, { fg: pair.bg, bg: palette.colors[next.colorKey].bg }, mode)
128
- : colorForeground(symbols.separator, pair.bg, mode);
129
- }
130
- return output;
131
- }
132
- function renderCapsule(segments, config, palette, mode, symbols) {
133
- return segments.map((segment) => {
134
- const pair = palette.colors[segment.colorKey];
135
- return colorForeground(symbols.capsuleLeft, pair.bg, mode)
136
- + colorBlock(pad(segment.text, config.display.padding), pair, mode)
137
- + colorForeground(symbols.capsuleRight, pair.bg, mode);
138
- }).join(' ');
139
- }
140
- function pad(text, padding) {
141
- return padding > 0 ? `${' '.repeat(padding)}${text}${' '.repeat(padding)}` : text;
142
- }
143
- function ensureWidth(line, width) {
144
- return visibleWidth(line) <= width ? line : truncateToWidth(line, width, '…');
145
- }
146
- //# sourceMappingURL=footer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"footer.js","sourceRoot":"","sources":["../src/footer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,YAAY,EAA4B,MAAM,wBAAwB,CAAC;AACjG,OAAO,EACL,UAAU,EACV,eAAe,EACf,aAAa,EACb,eAAe,GAGhB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EACL,cAAc,GAIf,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,UAAU,EAAyB,MAAM,cAAc,CAAC;AAkBjE,MAAM,OAAO,eAAe;IAKG;IAJZ,QAAQ,CAAW;IACnB,iBAAiB,CAAa;IACvC,QAAQ,GAAG,KAAK,CAAC;IAEzB,YAA6B,OAA+B;QAA/B,YAAO,GAAP,OAAO,CAAwB;QAC1D,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC1D,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QACpF,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAED,UAAU;QACR,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,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AAChB,CAAC;AAED,SAAS,aAAa,CACpB,QAA2B,EAC3B,MAAuB,EACvB,OAAqB,EACrB,IAAe,EACf,OAAyB;IAEzB,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QAC9B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC9C,OAAO,eAAe,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC;cACtD,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC;cACjE,eAAe,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED,SAAS,GAAG,CAAC,IAAY,EAAE,OAAe;IACxC,OAAO,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACpF,CAAC;AAED,SAAS,WAAW,CAAC,IAAY,EAAE,KAAa;IAC9C,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AAChF,CAAC"}
@@ -1,39 +0,0 @@
1
- import type { ExtensionContext } from '@felan-ai/agent-core';
2
- import type { DisplayLineConfig, SegmentName, ThemeColorKey } from './config.js';
3
- import type { SavingsState } from './savings.js';
4
- import type { GitDetails } from './git.js';
5
- import { type SubscriptionState } from './subscription.js';
6
- import { type PowerlineSymbols } from './symbols.js';
7
- export interface FooterDataLike {
8
- getGitBranch(): string | null;
9
- getExtensionStatuses(): ReadonlyMap<string, string>;
10
- getAvailableProviderCount(): number;
11
- onBranchChange(callback: () => void): () => void;
12
- }
13
- export interface SegmentRenderContext {
14
- ctx: ExtensionContext;
15
- felanVersion?: string;
16
- footerData: FooterDataLike;
17
- gitDetails?: GitDetails;
18
- subscription: SubscriptionState;
19
- savings?: SavingsState;
20
- additionalSessionUsage?: SessionUsageTotals;
21
- symbols: PowerlineSymbols;
22
- }
23
- export interface RenderedSegment {
24
- name: SegmentName;
25
- colorKey: ThemeColorKey;
26
- text: string;
27
- align: 'left' | 'right';
28
- }
29
- export interface SessionUsageTotals {
30
- input: number;
31
- output: number;
32
- cacheRead: number;
33
- cacheWrite: number;
34
- cost: number;
35
- }
36
- export declare function renderSegments(line: DisplayLineConfig, context: SegmentRenderContext): RenderedSegment[];
37
- export declare function sanitizePlainText(value: string): string;
38
- export declare function formatTokens(count: number): string;
39
- //# sourceMappingURL=segments.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"segments.d.ts","sourceRoot":"","sources":["../src/segments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAiB,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAChG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAKL,KAAK,iBAAiB,EACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAc,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEjE,MAAM,WAAW,cAAc;IAC7B,YAAY,IAAI,MAAM,GAAG,IAAI,CAAC;IAC9B,oBAAoB,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpD,yBAAyB,IAAI,MAAM,CAAC;IACpC,cAAc,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CAClD;AAED,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,gBAAgB,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,cAAc,CAAC;IAC3B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,YAAY,EAAE,iBAAiB,CAAC;IAChC,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,sBAAsB,CAAC,EAAE,kBAAkB,CAAC;IAC5C,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAKD,wBAAgB,cAAc,CAAC,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,oBAAoB,GAAG,eAAe,EAAE,CAWxG;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOvD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMlD"}
package/dist/segments.js DELETED
@@ -1,344 +0,0 @@
1
- import { formatReset, prioritizeWindowsForModel, } from './subscription.js';
2
- import { BAR_LEVELS } from './symbols.js';
3
- const ANSI_PATTERN = /\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g;
4
- const EXTENSION_STATUS_COLORS = ['extensionStatus1', 'extensionStatus2', 'extensionStatus3', 'extensionStatus4'];
5
- export function renderSegments(line, context) {
6
- const segments = [];
7
- for (const [name, config] of Object.entries(line.segments)) {
8
- if (!config.enabled)
9
- continue;
10
- const rendered = renderSegment(name, config, context);
11
- const values = Array.isArray(rendered) ? rendered : rendered ? [rendered] : [];
12
- for (const segment of values) {
13
- if (segment.text.trim())
14
- segments.push({ ...segment, align: config.align ?? 'left' });
15
- }
16
- }
17
- return segments;
18
- }
19
- export function sanitizePlainText(value) {
20
- return value
21
- .replace(ANSI_PATTERN, '')
22
- .replace(/[\r\n\t]/g, ' ')
23
- .replace(/[\x00-\x1F\x7F]/g, ' ')
24
- .replace(/ +/g, ' ')
25
- .trim();
26
- }
27
- export function formatTokens(count) {
28
- if (count < 1_000)
29
- return String(count);
30
- if (count < 10_000)
31
- return `${(count / 1_000).toFixed(1)}k`;
32
- if (count < 1_000_000)
33
- return `${Math.round(count / 1_000)}k`;
34
- if (count < 10_000_000)
35
- return `${(count / 1_000_000).toFixed(1)}M`;
36
- return `${Math.round(count / 1_000_000)}M`;
37
- }
38
- function renderSegment(name, config, context) {
39
- switch (name) {
40
- case 'directory': return renderDirectory(config, context);
41
- case 'git': return renderGit(config, context);
42
- case 'model': return renderModel(context);
43
- case 'session': return renderSession(config, context);
44
- case 'subscription': return renderSubscription(config, context);
45
- case 'savings': return renderSavings(config, context);
46
- case 'context': return renderContext(config, context);
47
- case 'status': return renderStatus(context);
48
- case 'version': return context.felanVersion
49
- ? { name: 'version', colorKey: 'version', text: `Felan ${sanitizePlainText(context.felanVersion)}` }
50
- : undefined;
51
- }
52
- }
53
- function renderDirectory(config, context) {
54
- const style = config.style ?? 'fish';
55
- const cwd = context.ctx.cwd;
56
- const text = style === 'basename' ? basename(cwd) : style === 'full' ? cwd : fishPath(cwd);
57
- return { name: 'directory', colorKey: 'directory', text: sanitizePlainText(text) };
58
- }
59
- function renderGit(config, context) {
60
- const details = context.gitDetails;
61
- const branch = sanitizePlainText(context.footerData.getGitBranch() ?? details?.branch ?? '');
62
- const parts = [];
63
- if (config.showRepoName && details?.repoName)
64
- parts.push(sanitizePlainText(details.repoName));
65
- if (branch)
66
- parts.push(formatWithOptionalSymbol(context.symbols.branch, branch));
67
- if (config.showSha && details?.sha)
68
- parts.push(formatWithOptionalSymbol(context.symbols.sha, sanitizePlainText(details.sha)));
69
- if (config.showWorkingTree && details) {
70
- const workingTree = formatWorkingTree(details, context.symbols);
71
- if (workingTree)
72
- parts.push(workingTree);
73
- }
74
- if (config.showTag && details?.tag)
75
- parts.push(`${context.symbols.tag} ${sanitizePlainText(details.tag)}`);
76
- if (config.showTimeSinceCommit && details?.timeSinceCommit)
77
- parts.push(`${context.symbols.clock} ${details.timeSinceCommit}`.trim());
78
- if (config.showStashCount && details?.stashCount)
79
- parts.push(`${context.symbols.stash} ${details.stashCount}`);
80
- if (config.showUpstream && details?.upstream) {
81
- const upstream = [];
82
- if (details.upstream.name)
83
- upstream.push(sanitizePlainText(details.upstream.name));
84
- if (details.upstream.ahead)
85
- upstream.push(`${context.symbols.ahead}${details.upstream.ahead}`);
86
- if (details.upstream.behind)
87
- upstream.push(`${context.symbols.behind}${details.upstream.behind}`);
88
- if (upstream.length > 0)
89
- parts.push(upstream.join(' '));
90
- }
91
- return parts.length > 0 ? { name: 'git', colorKey: 'git', text: parts.join(' ') } : undefined;
92
- }
93
- function renderModel(context) {
94
- const model = context.ctx.model;
95
- let text = model?.id ?? 'no-model';
96
- if (model && context.footerData.getAvailableProviderCount() > 1)
97
- text = `(${model.provider}) ${text}`;
98
- if (model?.reasoning && context.ctx.thinkingLevel)
99
- text = `${text} • ${context.ctx.thinkingLevel}`;
100
- return { name: 'model', colorKey: 'model', text: sanitizePlainText(text) };
101
- }
102
- function renderSession(config, context) {
103
- const totals = getUsageTotals(context.ctx, context.additionalSessionUsage);
104
- const tokenText = `${context.symbols.tokensIn}${formatTokens(totals.input)} ${context.symbols.tokensOut}${formatTokens(totals.output)}`;
105
- const cacheText = `${context.symbols.cacheRead}${formatTokens(totals.cacheRead)} ${context.symbols.cacheWrite}${formatTokens(totals.cacheWrite)}`;
106
- const costText = `$${totals.cost.toFixed(3)}`;
107
- const type = config.type ?? 'tokens';
108
- const text = type === 'cost'
109
- ? costText
110
- : type === 'both'
111
- ? `${tokenText} ${costText}`
112
- : type === 'breakdown'
113
- ? `${tokenText} ${cacheText} ${costText}`
114
- : tokenText;
115
- return { name: 'session', colorKey: 'session', text };
116
- }
117
- function renderSavings(config, context) {
118
- const savings = context.savings ?? { loading: false };
119
- if (savings.loading && !savings.result)
120
- return { name: 'savings', colorKey: 'savings', text: 'savings …' };
121
- if (!savings.result)
122
- return undefined;
123
- const amount = savings.result.savedCostUsd;
124
- const estimate = `${savings.result.hasUnpricedMeasurements ? '~' : ''}${amount < 0 ? '-' : ''}$${Math.abs(amount).toFixed(2)}`;
125
- return { name: 'savings', colorKey: 'savings', text: `Est. Savings(${config.periodDays ?? 7}d): ${estimate}` };
126
- }
127
- function renderSubscription(config, context) {
128
- const provider = context.subscription.provider;
129
- if (!provider)
130
- return undefined;
131
- const label = getSubscriptionProviderLabel(provider);
132
- const usage = context.subscription.usage;
133
- if (context.subscription.loading && (!usage || usage.windows.length === 0)) {
134
- return { name: 'subscription', colorKey: 'subscription', text: sanitizePlainText(`${label} …`) };
135
- }
136
- if (!usage)
137
- return undefined;
138
- if (usage.error?.code === 'NO_CREDENTIALS') {
139
- return { name: 'subscription', colorKey: 'warning', text: sanitizePlainText(`${label} no OAuth`) };
140
- }
141
- if (usage.error?.code === 'COMPANION_UNAVAILABLE') {
142
- return { name: 'subscription', colorKey: 'warning', text: 'ChatGPT usage: web only' };
143
- }
144
- const maxWindows = clampInteger(config.maxWindows ?? 3, 1, 8);
145
- const windows = prioritizeWindowsForModel(usage.windows, context.ctx.model)
146
- .filter((window) => !isCodexModelSpecificWindow(provider, window))
147
- .slice(0, maxWindows);
148
- if (windows.length === 0) {
149
- if (!usage.error)
150
- return undefined;
151
- return {
152
- name: 'subscription',
153
- colorKey: 'warning',
154
- text: sanitizePlainText(`${label} ${formatSubscriptionError(usage.error)}`),
155
- };
156
- }
157
- const parts = windows.map((window) => formatSubscriptionWindow(provider, window, config)).filter(Boolean);
158
- const text = [config.showProviderName ?? true ? label : '', parts.join(' * ')].filter(Boolean).join(' ');
159
- if (!text.trim())
160
- return undefined;
161
- return {
162
- name: 'subscription',
163
- colorKey: usage.error ? 'warning' : 'subscription',
164
- text: sanitizePlainText(text),
165
- };
166
- }
167
- function renderContext(config, context) {
168
- const usage = context.ctx.getContextUsage();
169
- const contextWindow = usage?.contextWindow ?? context.ctx.model?.contextWindow;
170
- if (!contextWindow)
171
- return undefined;
172
- const percent = usage?.percent ?? null;
173
- const tokens = usage?.tokens ?? null;
174
- const percentText = percent === null ? '?' : `${percent.toFixed(1)}%`;
175
- const ratio = percent === null ? 0 : clamp(percent / 100, 0, 1);
176
- const width = config.width ?? 10;
177
- const usageText = tokens === null ? `?/${formatTokens(contextWindow)}` : `${formatTokens(tokens)}/${formatTokens(contextWindow)}`;
178
- const style = config.displayStyle ?? 'bar';
179
- let text;
180
- if (config.showTokensOnly)
181
- text = `ctx ${usageText}`;
182
- else if (config.showPercentageOnly)
183
- text = `ctx ${percentText}`;
184
- else if (style === 'text')
185
- text = `ctx ${usageText} ${percentText}`;
186
- else if (style === 'dots')
187
- text = `ctx ${percentText} ${repeatProgress(context.symbols.dotFull, context.symbols.dotEmpty, ratio, width)}`;
188
- else if (style === 'blocks-line')
189
- text = renderBlockLine(ratio, width, context.symbols);
190
- else if (style === 'blocks')
191
- text = `ctx ${percentText} ${renderBlockLine(ratio, width, context.symbols)}`;
192
- else
193
- text = `ctx ${percentText} ${repeatProgress(context.symbols.blockFull, context.symbols.blockEmpty, ratio, width)}`;
194
- const warning = config.warningThreshold ?? 70;
195
- const critical = config.criticalThreshold ?? 90;
196
- const colorKey = percent !== null && percent >= critical
197
- ? 'critical'
198
- : percent !== null && percent >= warning ? 'warning' : 'context';
199
- return { name: 'context', colorKey, text };
200
- }
201
- function renderStatus(context) {
202
- const statuses = [...context.footerData.getExtensionStatuses().entries()]
203
- .sort(([left], [right]) => left.localeCompare(right))
204
- .map(([, text]) => sanitizePlainText(text))
205
- .filter(Boolean);
206
- return statuses.length === 0 ? undefined : statuses.map((text, index) => ({
207
- name: 'status',
208
- colorKey: EXTENSION_STATUS_COLORS[index % EXTENSION_STATUS_COLORS.length],
209
- text,
210
- }));
211
- }
212
- function getSubscriptionProviderLabel(provider) {
213
- if (provider === 'openai')
214
- return 'ChatGPT';
215
- if (provider === 'codex')
216
- return 'Codex';
217
- if (provider === 'xai')
218
- return 'Grok';
219
- return 'Claude';
220
- }
221
- function formatSubscriptionWindow(provider, window, config) {
222
- if (provider === 'openai' || provider === 'codex' || provider === 'xai') {
223
- return formatCompactSubscriptionWindow(window, config, 100 - window.usedPercent);
224
- }
225
- return formatAnthropicWindow(window, config);
226
- }
227
- function formatAnthropicWindow(window, config) {
228
- if (window.label.toLowerCase().startsWith('extra [')) {
229
- const reset = config.showReset ?? true ? formatWindowReset(window) : undefined;
230
- return reset ? `${window.label} | ${reset}` : window.label;
231
- }
232
- return formatCompactSubscriptionWindow(window, config, window.usedPercent);
233
- }
234
- function formatCompactSubscriptionWindow(window, config, percent) {
235
- const parts = [formatSubscriptionLabel(window.label)];
236
- if (config.showPercentage ?? true)
237
- parts.push(`${Math.round(clamp(percent, 0, 100))}%`);
238
- const text = parts.join(' ');
239
- const reset = config.showReset ?? true ? formatWindowReset(window) : undefined;
240
- return reset ? `${text} | ${reset}` : text;
241
- }
242
- function formatSubscriptionLabel(label) {
243
- const normalized = normalizeCodexWindowLabel(label);
244
- if (normalized === 'Week')
245
- return '7d';
246
- if (normalized === 'Day')
247
- return '24h';
248
- return normalized;
249
- }
250
- function formatWindowReset(window) {
251
- if (window.resetDescription === '__ACTIVE__')
252
- return undefined;
253
- if (window.resetAt) {
254
- const resetAt = new Date(window.resetAt);
255
- if (Number.isFinite(resetAt.getTime()))
256
- return formatReset(resetAt);
257
- }
258
- return window.resetDescription;
259
- }
260
- function isCodexModelSpecificWindow(provider, window) {
261
- return provider === 'codex' && normalizeCodexWindowLabel(window.label) !== window.label;
262
- }
263
- function normalizeCodexWindowLabel(label) {
264
- return label.match(/(?:^| )(5h|\d+h|Day|Week)$/)?.[1] ?? label;
265
- }
266
- function formatSubscriptionError(error) {
267
- if (error.code === 'COMPANION_UNAVAILABLE')
268
- return 'usage: web only';
269
- if (error.code === 'HTTP_ERROR' && error.httpStatus === 429)
270
- return 'usage unavailable';
271
- if (error.code === 'HTTP_ERROR' && error.httpStatus)
272
- return `HTTP ${error.httpStatus}`;
273
- return 'fetch failed';
274
- }
275
- function clampInteger(value, min, max) {
276
- return Math.min(max, Math.max(min, Math.round(value)));
277
- }
278
- function getUsageTotals(context, additional) {
279
- const totals = {
280
- input: additional?.input ?? 0,
281
- output: additional?.output ?? 0,
282
- cacheRead: additional?.cacheRead ?? 0,
283
- cacheWrite: additional?.cacheWrite ?? 0,
284
- cost: additional?.cost ?? 0,
285
- };
286
- for (const entry of context.sessionManager.getEntries()) {
287
- if (entry.type !== 'message' || entry.message.role !== 'assistant')
288
- continue;
289
- totals.input += entry.message.usage.input;
290
- totals.output += entry.message.usage.output;
291
- totals.cacheRead += entry.message.usage.cacheRead;
292
- totals.cacheWrite += entry.message.usage.cacheWrite;
293
- totals.cost += entry.message.usage.cost.total;
294
- }
295
- return totals;
296
- }
297
- function basename(path) {
298
- const parts = path.replace(/\\/g, '/').split('/').filter(Boolean);
299
- return parts.at(-1) ?? path;
300
- }
301
- function fishPath(path) {
302
- const normalized = path.replace(/\\/g, '/');
303
- if (!normalized.includes('/'))
304
- return normalized;
305
- const prefix = normalized.startsWith('/') ? '/' : '';
306
- const parts = normalized.replace(/^\//, '').split('/').filter(Boolean);
307
- if (parts.length <= 1)
308
- return `${prefix}${parts.join('/')}`;
309
- return `${prefix}${[...parts.slice(0, -1).map((part) => part[0] ?? part), parts.at(-1)].join('/')}`;
310
- }
311
- function formatWithOptionalSymbol(symbol, text) {
312
- return symbol ? `${symbol} ${text}` : text;
313
- }
314
- function formatWorkingTree(details, symbols) {
315
- if (details.dirty === undefined)
316
- return undefined;
317
- if (!details.dirty)
318
- return symbols.clean || undefined;
319
- if (details.changedFiles !== undefined && details.changedFiles > 0) {
320
- return symbols.dirty ? `${symbols.dirty} ${details.changedFiles}` : String(details.changedFiles);
321
- }
322
- return symbols.dirty || undefined;
323
- }
324
- function repeatProgress(full, empty, ratio, width) {
325
- const filled = Math.round(width * ratio);
326
- return `${full.repeat(filled)}${empty.repeat(Math.max(0, width - filled))}`;
327
- }
328
- function renderBlockLine(ratio, width, symbols) {
329
- if (width <= 0)
330
- return '';
331
- if (symbols.blockFull !== '█')
332
- return repeatProgress(symbols.blockFull, symbols.blockEmpty, ratio, width);
333
- const exact = ratio * width;
334
- const fullBlocks = Math.floor(exact);
335
- const remainder = exact - fullBlocks;
336
- const partial = remainder > 0 && fullBlocks < width
337
- ? BAR_LEVELS[Math.max(0, Math.ceil(remainder * BAR_LEVELS.length) - 1)]
338
- : '';
339
- return `${symbols.blockFull.repeat(fullBlocks)}${partial}${symbols.blockEmpty.repeat(Math.max(0, width - fullBlocks - (partial ? 1 : 0)))}`;
340
- }
341
- function clamp(value, min, max) {
342
- return Math.min(max, Math.max(min, value));
343
- }
344
- //# sourceMappingURL=segments.js.map