@oh-my-pi/pi-coding-agent 3.14.0 → 3.15.1

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 (213) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/docs/theme.md +38 -5
  3. package/examples/sdk/11-sessions.ts +2 -2
  4. package/package.json +7 -4
  5. package/src/cli/file-processor.ts +51 -2
  6. package/src/cli/plugin-cli.ts +25 -19
  7. package/src/cli/update-cli.ts +4 -3
  8. package/src/core/agent-session.ts +31 -4
  9. package/src/core/compaction/branch-summarization.ts +4 -32
  10. package/src/core/compaction/compaction.ts +6 -84
  11. package/src/core/compaction/utils.ts +2 -3
  12. package/src/core/custom-tools/types.ts +2 -0
  13. package/src/core/export-html/index.ts +1 -1
  14. package/src/core/hooks/tool-wrapper.ts +0 -1
  15. package/src/core/hooks/types.ts +2 -2
  16. package/src/core/plugins/doctor.ts +9 -1
  17. package/src/core/sdk.ts +2 -1
  18. package/src/core/session-manager.ts +518 -40
  19. package/src/core/settings-manager.ts +174 -0
  20. package/src/core/system-prompt.ts +9 -14
  21. package/src/core/title-generator.ts +2 -8
  22. package/src/core/tools/ask.ts +19 -37
  23. package/src/core/tools/bash.ts +2 -37
  24. package/src/core/tools/edit.ts +2 -9
  25. package/src/core/tools/exa/render.ts +52 -48
  26. package/src/core/tools/find.ts +10 -8
  27. package/src/core/tools/grep.ts +45 -17
  28. package/src/core/tools/ls.ts +22 -2
  29. package/src/core/tools/lsp/clients/biome-client.ts +207 -0
  30. package/src/core/tools/lsp/clients/index.ts +49 -0
  31. package/src/core/tools/lsp/clients/lsp-linter-client.ts +98 -0
  32. package/src/core/tools/lsp/config.ts +3 -0
  33. package/src/core/tools/lsp/index.ts +107 -55
  34. package/src/core/tools/lsp/render.ts +192 -79
  35. package/src/core/tools/lsp/types.ts +27 -0
  36. package/src/core/tools/lsp/utils.ts +62 -22
  37. package/src/core/tools/notebook.ts +9 -1
  38. package/src/core/tools/output.ts +37 -14
  39. package/src/core/tools/read.ts +349 -34
  40. package/src/core/tools/renderers.ts +290 -89
  41. package/src/core/tools/review.ts +12 -5
  42. package/src/core/tools/task/agents.ts +5 -5
  43. package/src/core/tools/task/commands.ts +3 -3
  44. package/src/core/tools/task/executor.ts +33 -1
  45. package/src/core/tools/task/index.ts +93 -6
  46. package/src/core/tools/task/render.ts +147 -66
  47. package/src/core/tools/task/types.ts +14 -9
  48. package/src/core/tools/web-fetch.ts +242 -103
  49. package/src/core/tools/web-search/index.ts +64 -20
  50. package/src/core/tools/web-search/providers/exa.ts +68 -172
  51. package/src/core/tools/web-search/render.ts +264 -74
  52. package/src/core/tools/write.ts +2 -8
  53. package/src/main.ts +10 -6
  54. package/src/modes/cleanup.ts +23 -0
  55. package/src/modes/index.ts +9 -4
  56. package/src/modes/interactive/components/bash-execution.ts +6 -3
  57. package/src/modes/interactive/components/branch-summary-message.ts +1 -1
  58. package/src/modes/interactive/components/compaction-summary-message.ts +1 -1
  59. package/src/modes/interactive/components/dynamic-border.ts +1 -1
  60. package/src/modes/interactive/components/extensions/extension-dashboard.ts +4 -5
  61. package/src/modes/interactive/components/extensions/extension-list.ts +18 -16
  62. package/src/modes/interactive/components/extensions/inspector-panel.ts +8 -8
  63. package/src/modes/interactive/components/hook-editor.ts +1 -0
  64. package/src/modes/interactive/components/hook-message.ts +2 -2
  65. package/src/modes/interactive/components/hook-selector.ts +1 -1
  66. package/src/modes/interactive/components/model-selector.ts +22 -9
  67. package/src/modes/interactive/components/oauth-selector.ts +20 -4
  68. package/src/modes/interactive/components/plugin-settings.ts +4 -2
  69. package/src/modes/interactive/components/session-selector.ts +9 -6
  70. package/src/modes/interactive/components/settings-defs.ts +285 -1
  71. package/src/modes/interactive/components/settings-selector.ts +176 -3
  72. package/src/modes/interactive/components/status-line/index.ts +4 -0
  73. package/src/modes/interactive/components/status-line/presets.ts +94 -0
  74. package/src/modes/interactive/components/status-line/segments.ts +350 -0
  75. package/src/modes/interactive/components/status-line/separators.ts +55 -0
  76. package/src/modes/interactive/components/status-line/types.ts +81 -0
  77. package/src/modes/interactive/components/status-line-segment-editor.ts +357 -0
  78. package/src/modes/interactive/components/status-line.ts +172 -223
  79. package/src/modes/interactive/components/tool-execution.ts +446 -211
  80. package/src/modes/interactive/components/tree-selector.ts +17 -6
  81. package/src/modes/interactive/components/ttsr-notification.ts +4 -4
  82. package/src/modes/interactive/components/welcome.ts +27 -19
  83. package/src/modes/interactive/interactive-mode.ts +99 -13
  84. package/src/modes/interactive/theme/dark.json +3 -2
  85. package/src/modes/interactive/theme/defaults/alabaster.json +99 -0
  86. package/src/modes/interactive/theme/defaults/amethyst.json +103 -0
  87. package/src/modes/interactive/theme/defaults/anthracite.json +100 -0
  88. package/src/modes/interactive/theme/defaults/basalt.json +90 -0
  89. package/src/modes/interactive/theme/defaults/birch.json +101 -0
  90. package/src/modes/interactive/theme/defaults/dark-abyss.json +97 -0
  91. package/src/modes/interactive/theme/defaults/dark-arctic.json +111 -0
  92. package/src/modes/interactive/theme/defaults/dark-aurora.json +94 -0
  93. package/src/modes/interactive/theme/defaults/dark-catppuccin.json +106 -0
  94. package/src/modes/interactive/theme/defaults/dark-cavern.json +97 -0
  95. package/src/modes/interactive/theme/defaults/dark-copper.json +94 -0
  96. package/src/modes/interactive/theme/defaults/dark-cosmos.json +96 -0
  97. package/src/modes/interactive/theme/defaults/dark-cyberpunk.json +109 -0
  98. package/src/modes/interactive/theme/defaults/dark-dracula.json +105 -0
  99. package/src/modes/interactive/theme/defaults/dark-eclipse.json +97 -0
  100. package/src/modes/interactive/theme/defaults/dark-ember.json +94 -0
  101. package/src/modes/interactive/theme/defaults/dark-equinox.json +96 -0
  102. package/src/modes/interactive/theme/defaults/dark-forest.json +103 -0
  103. package/src/modes/interactive/theme/defaults/dark-github.json +112 -0
  104. package/src/modes/interactive/theme/defaults/dark-gruvbox.json +119 -0
  105. package/src/modes/interactive/theme/defaults/dark-lavender.json +94 -0
  106. package/src/modes/interactive/theme/defaults/dark-lunar.json +95 -0
  107. package/src/modes/interactive/theme/defaults/dark-midnight.json +94 -0
  108. package/src/modes/interactive/theme/defaults/dark-monochrome.json +101 -0
  109. package/src/modes/interactive/theme/defaults/dark-monokai.json +105 -0
  110. package/src/modes/interactive/theme/defaults/dark-nebula.json +96 -0
  111. package/src/modes/interactive/theme/defaults/dark-nord.json +104 -0
  112. package/src/modes/interactive/theme/defaults/dark-ocean.json +108 -0
  113. package/src/modes/interactive/theme/defaults/dark-one.json +107 -0
  114. package/src/modes/interactive/theme/defaults/dark-rainforest.json +97 -0
  115. package/src/modes/interactive/theme/defaults/dark-reef.json +97 -0
  116. package/src/modes/interactive/theme/defaults/dark-retro.json +99 -0
  117. package/src/modes/interactive/theme/defaults/dark-rose-pine.json +95 -0
  118. package/src/modes/interactive/theme/defaults/dark-sakura.json +94 -0
  119. package/src/modes/interactive/theme/defaults/dark-slate.json +94 -0
  120. package/src/modes/interactive/theme/defaults/dark-solarized.json +96 -0
  121. package/src/modes/interactive/theme/defaults/dark-solstice.json +96 -0
  122. package/src/modes/interactive/theme/defaults/dark-starfall.json +97 -0
  123. package/src/modes/interactive/theme/defaults/dark-sunset.json +106 -0
  124. package/src/modes/interactive/theme/defaults/dark-swamp.json +96 -0
  125. package/src/modes/interactive/theme/defaults/dark-synthwave.json +102 -0
  126. package/src/modes/interactive/theme/defaults/dark-taiga.json +97 -0
  127. package/src/modes/interactive/theme/defaults/dark-terminal.json +94 -0
  128. package/src/modes/interactive/theme/defaults/dark-tokyo-night.json +108 -0
  129. package/src/modes/interactive/theme/defaults/dark-tundra.json +97 -0
  130. package/src/modes/interactive/theme/defaults/dark-twilight.json +97 -0
  131. package/src/modes/interactive/theme/defaults/dark-volcanic.json +97 -0
  132. package/src/modes/interactive/theme/defaults/graphite.json +99 -0
  133. package/src/modes/interactive/theme/defaults/index.ts +195 -0
  134. package/src/modes/interactive/theme/defaults/light-arctic.json +106 -0
  135. package/src/modes/interactive/theme/defaults/light-aurora-day.json +97 -0
  136. package/src/modes/interactive/theme/defaults/light-canyon.json +97 -0
  137. package/src/modes/interactive/theme/defaults/light-catppuccin.json +105 -0
  138. package/src/modes/interactive/theme/defaults/light-cirrus.json +96 -0
  139. package/src/modes/interactive/theme/defaults/light-coral.json +94 -0
  140. package/src/modes/interactive/theme/defaults/light-cyberpunk.json +103 -0
  141. package/src/modes/interactive/theme/defaults/light-dawn.json +96 -0
  142. package/src/modes/interactive/theme/defaults/light-dunes.json +97 -0
  143. package/src/modes/interactive/theme/defaults/light-eucalyptus.json +94 -0
  144. package/src/modes/interactive/theme/defaults/light-forest.json +107 -0
  145. package/src/modes/interactive/theme/defaults/light-frost.json +94 -0
  146. package/src/modes/interactive/theme/defaults/light-github.json +114 -0
  147. package/src/modes/interactive/theme/defaults/light-glacier.json +97 -0
  148. package/src/modes/interactive/theme/defaults/light-gruvbox.json +115 -0
  149. package/src/modes/interactive/theme/defaults/light-haze.json +96 -0
  150. package/src/modes/interactive/theme/defaults/light-honeycomb.json +94 -0
  151. package/src/modes/interactive/theme/defaults/light-lagoon.json +97 -0
  152. package/src/modes/interactive/theme/defaults/light-lavender.json +94 -0
  153. package/src/modes/interactive/theme/defaults/light-meadow.json +97 -0
  154. package/src/modes/interactive/theme/defaults/light-mint.json +94 -0
  155. package/src/modes/interactive/theme/defaults/light-monochrome.json +100 -0
  156. package/src/modes/interactive/theme/defaults/light-ocean.json +106 -0
  157. package/src/modes/interactive/theme/defaults/light-one.json +105 -0
  158. package/src/modes/interactive/theme/defaults/light-opal.json +97 -0
  159. package/src/modes/interactive/theme/defaults/light-orchard.json +97 -0
  160. package/src/modes/interactive/theme/defaults/light-paper.json +94 -0
  161. package/src/modes/interactive/theme/defaults/light-prism.json +96 -0
  162. package/src/modes/interactive/theme/defaults/light-retro.json +105 -0
  163. package/src/modes/interactive/theme/defaults/light-sand.json +94 -0
  164. package/src/modes/interactive/theme/defaults/light-savanna.json +97 -0
  165. package/src/modes/interactive/theme/defaults/light-solarized.json +101 -0
  166. package/src/modes/interactive/theme/defaults/light-soleil.json +96 -0
  167. package/src/modes/interactive/theme/defaults/light-sunset.json +106 -0
  168. package/src/modes/interactive/theme/defaults/light-synthwave.json +105 -0
  169. package/src/modes/interactive/theme/defaults/light-tokyo-night.json +118 -0
  170. package/src/modes/interactive/theme/defaults/light-wetland.json +97 -0
  171. package/src/modes/interactive/theme/defaults/light-zenith.json +95 -0
  172. package/src/modes/interactive/theme/defaults/limestone.json +100 -0
  173. package/src/modes/interactive/theme/defaults/mahogany.json +104 -0
  174. package/src/modes/interactive/theme/defaults/marble.json +99 -0
  175. package/src/modes/interactive/theme/defaults/obsidian.json +90 -0
  176. package/src/modes/interactive/theme/defaults/onyx.json +90 -0
  177. package/src/modes/interactive/theme/defaults/pearl.json +99 -0
  178. package/src/modes/interactive/theme/defaults/porcelain.json +90 -0
  179. package/src/modes/interactive/theme/defaults/quartz.json +102 -0
  180. package/src/modes/interactive/theme/defaults/sandstone.json +101 -0
  181. package/src/modes/interactive/theme/defaults/titanium.json +89 -0
  182. package/src/modes/interactive/theme/light.json +3 -2
  183. package/src/modes/interactive/theme/theme-schema.json +120 -4
  184. package/src/modes/interactive/theme/theme.ts +1228 -14
  185. package/src/prompts/branch-summary-preamble.md +3 -0
  186. package/src/prompts/branch-summary.md +28 -0
  187. package/src/prompts/compaction-summary.md +34 -0
  188. package/src/prompts/compaction-turn-prefix.md +16 -0
  189. package/src/prompts/compaction-update-summary.md +41 -0
  190. package/src/prompts/init.md +30 -0
  191. package/src/{core/tools/task/bundled-agents → prompts}/reviewer.md +6 -0
  192. package/src/prompts/summarization-system.md +3 -0
  193. package/src/prompts/system-prompt.md +27 -0
  194. package/src/{core/tools/task/bundled-agents → prompts}/task.md +2 -0
  195. package/src/prompts/title-system.md +8 -0
  196. package/src/prompts/tools/ask.md +24 -0
  197. package/src/prompts/tools/bash.md +23 -0
  198. package/src/prompts/tools/edit.md +9 -0
  199. package/src/prompts/tools/find.md +6 -0
  200. package/src/prompts/tools/grep.md +12 -0
  201. package/src/prompts/tools/lsp.md +14 -0
  202. package/src/prompts/tools/output.md +23 -0
  203. package/src/prompts/tools/read.md +25 -0
  204. package/src/prompts/tools/web-fetch.md +8 -0
  205. package/src/prompts/tools/web-search.md +10 -0
  206. package/src/prompts/tools/write.md +10 -0
  207. package/src/commands/init.md +0 -20
  208. /package/src/{core/tools/task/bundled-commands → prompts}/architect-plan.md +0 -0
  209. /package/src/{core/tools/task/bundled-agents → prompts}/browser.md +0 -0
  210. /package/src/{core/tools/task/bundled-agents → prompts}/explore.md +0 -0
  211. /package/src/{core/tools/task/bundled-commands → prompts}/implement-with-critic.md +0 -0
  212. /package/src/{core/tools/task/bundled-commands → prompts}/implement.md +0 -0
  213. /package/src/{core/tools/task/bundled-agents → prompts}/plan.md +0 -0
@@ -0,0 +1,94 @@
1
+ import type { PresetDef, StatusLinePreset } from "./types";
2
+
3
+ export const STATUS_LINE_PRESETS: Record<StatusLinePreset, PresetDef> = {
4
+ default: {
5
+ // Matches current behavior
6
+ leftSegments: ["pi", "model", "path", "git", "context_pct", "token_total", "cost"],
7
+ rightSegments: [],
8
+ separator: "powerline-thin",
9
+ segmentOptions: {
10
+ model: { showThinkingLevel: true },
11
+ path: { abbreviate: true, maxLength: 40, stripWorkPrefix: true },
12
+ git: { showBranch: true, showStaged: true, showUnstaged: true, showUntracked: true },
13
+ },
14
+ },
15
+
16
+ minimal: {
17
+ leftSegments: ["path", "git"],
18
+ rightSegments: ["context_pct"],
19
+ separator: "slash",
20
+ segmentOptions: {
21
+ path: { abbreviate: true, maxLength: 30 },
22
+ git: { showBranch: true, showStaged: false, showUnstaged: false, showUntracked: false },
23
+ },
24
+ },
25
+
26
+ compact: {
27
+ leftSegments: ["model", "git"],
28
+ rightSegments: ["cost", "context_pct"],
29
+ separator: "powerline-thin",
30
+ segmentOptions: {
31
+ model: { showThinkingLevel: false },
32
+ git: { showBranch: true, showStaged: true, showUnstaged: true, showUntracked: false },
33
+ },
34
+ },
35
+
36
+ full: {
37
+ leftSegments: ["pi", "hostname", "model", "path", "git", "subagents"],
38
+ rightSegments: ["token_in", "token_out", "cache_read", "cost", "context_pct", "time_spent", "time"],
39
+ separator: "powerline",
40
+ segmentOptions: {
41
+ model: { showThinkingLevel: true },
42
+ path: { abbreviate: true, maxLength: 50 },
43
+ git: { showBranch: true, showStaged: true, showUnstaged: true, showUntracked: true },
44
+ time: { format: "24h", showSeconds: false },
45
+ },
46
+ },
47
+
48
+ nerd: {
49
+ // Full preset with all Nerd Font icons
50
+ leftSegments: ["pi", "hostname", "model", "path", "git", "session", "subagents"],
51
+ rightSegments: [
52
+ "token_in",
53
+ "token_out",
54
+ "cache_read",
55
+ "cache_write",
56
+ "cost",
57
+ "context_pct",
58
+ "context_total",
59
+ "time_spent",
60
+ "time",
61
+ ],
62
+ separator: "powerline",
63
+ segmentOptions: {
64
+ model: { showThinkingLevel: true },
65
+ path: { abbreviate: true, maxLength: 60 },
66
+ git: { showBranch: true, showStaged: true, showUnstaged: true, showUntracked: true },
67
+ time: { format: "24h", showSeconds: true },
68
+ },
69
+ },
70
+
71
+ ascii: {
72
+ // No Nerd Font dependencies
73
+ leftSegments: ["model", "path", "git"],
74
+ rightSegments: ["token_total", "cost", "context_pct"],
75
+ separator: "ascii",
76
+ segmentOptions: {
77
+ model: { showThinkingLevel: true },
78
+ path: { abbreviate: true, maxLength: 40 },
79
+ git: { showBranch: true, showStaged: true, showUnstaged: true, showUntracked: true },
80
+ },
81
+ },
82
+
83
+ custom: {
84
+ // User-defined - these are just defaults that get overridden
85
+ leftSegments: ["model", "path", "git"],
86
+ rightSegments: ["token_total", "cost", "context_pct"],
87
+ separator: "powerline-thin",
88
+ segmentOptions: {},
89
+ },
90
+ };
91
+
92
+ export function getPreset(name: StatusLinePreset): PresetDef {
93
+ return STATUS_LINE_PRESETS[name] ?? STATUS_LINE_PRESETS.default;
94
+ }
@@ -0,0 +1,350 @@
1
+ import { hostname as osHostname } from "node:os";
2
+ import { theme } from "../../theme/theme";
3
+ import type { RenderedSegment, SegmentContext, StatusLineSegment, StatusLineSegmentId } from "./types";
4
+
5
+ export type { SegmentContext } from "./types";
6
+
7
+ // ═══════════════════════════════════════════════════════════════════════════
8
+ // Helpers
9
+ // ═══════════════════════════════════════════════════════════════════════════
10
+
11
+ function withIcon(icon: string, text: string): string {
12
+ return icon ? `${icon} ${text}` : text;
13
+ }
14
+
15
+ function formatTokens(n: number): string {
16
+ if (n < 1000) return n.toString();
17
+ if (n < 10000) return `${(n / 1000).toFixed(1)}k`;
18
+ if (n < 1000000) return `${Math.round(n / 1000)}k`;
19
+ if (n < 10000000) return `${(n / 1000000).toFixed(1)}M`;
20
+ return `${Math.round(n / 1000000)}M`;
21
+ }
22
+
23
+ function formatDuration(ms: number): string {
24
+ const seconds = Math.floor(ms / 1000);
25
+ const minutes = Math.floor(seconds / 60);
26
+ const hours = Math.floor(minutes / 60);
27
+
28
+ if (hours > 0) return `${hours}h${minutes % 60}m`;
29
+ if (minutes > 0) return `${minutes}m${seconds % 60}s`;
30
+ return `${seconds}s`;
31
+ }
32
+
33
+ // ═══════════════════════════════════════════════════════════════════════════
34
+ // Segment Implementations
35
+ // ═══════════════════════════════════════════════════════════════════════════
36
+
37
+ const piSegment: StatusLineSegment = {
38
+ id: "pi",
39
+ render(_ctx) {
40
+ const content = theme.icon.pi ? `${theme.icon.pi} ` : "";
41
+ return { content: theme.fg("accent", content), visible: true };
42
+ },
43
+ };
44
+
45
+ const modelSegment: StatusLineSegment = {
46
+ id: "model",
47
+ render(ctx) {
48
+ const state = ctx.session.state;
49
+ const opts = ctx.options.model ?? {};
50
+
51
+ let modelName = state.model?.name || state.model?.id || "no-model";
52
+ if (modelName.startsWith("Claude ")) {
53
+ modelName = modelName.slice(7);
54
+ }
55
+
56
+ let content = withIcon(theme.icon.model, modelName);
57
+
58
+ // Add thinking level with dot separator
59
+ if (opts.showThinkingLevel !== false && state.model?.reasoning) {
60
+ const level = state.thinkingLevel || "off";
61
+ if (level !== "off") {
62
+ const thinkingText = theme.thinking[level as keyof typeof theme.thinking];
63
+ if (thinkingText) {
64
+ content += `${theme.sep.dot}${thinkingText}`;
65
+ }
66
+ }
67
+ }
68
+
69
+ return { content: theme.fg("statusLineModel", content), visible: true };
70
+ },
71
+ };
72
+
73
+ const pathSegment: StatusLineSegment = {
74
+ id: "path",
75
+ render(ctx) {
76
+ const opts = ctx.options.path ?? {};
77
+
78
+ let pwd = process.cwd();
79
+ const home = process.env.HOME || process.env.USERPROFILE;
80
+
81
+ if (opts.abbreviate !== false && home && pwd.startsWith(home)) {
82
+ pwd = `~${pwd.slice(home.length)}`;
83
+ }
84
+ if (opts.stripWorkPrefix !== false && pwd.startsWith("/work/")) {
85
+ pwd = pwd.slice(6);
86
+ }
87
+
88
+ const maxLen = opts.maxLength ?? 40;
89
+ if (pwd.length > maxLen) {
90
+ const ellipsis = theme.format.ellipsis;
91
+ const sliceLen = Math.max(0, maxLen - ellipsis.length);
92
+ pwd = `${ellipsis}${pwd.slice(-sliceLen)}`;
93
+ }
94
+
95
+ const content = withIcon(theme.icon.folder, pwd);
96
+ return { content: theme.fg("statusLinePath", content), visible: true };
97
+ },
98
+ };
99
+
100
+ const gitSegment: StatusLineSegment = {
101
+ id: "git",
102
+ render(ctx) {
103
+ const { branch, status } = ctx.git;
104
+ if (!branch && !status) return { content: "", visible: false };
105
+
106
+ const opts = ctx.options.git ?? {};
107
+ const gitStatus = status;
108
+ const isDirty = gitStatus && (gitStatus.staged > 0 || gitStatus.unstaged > 0 || gitStatus.untracked > 0);
109
+
110
+ const showBranch = opts.showBranch !== false;
111
+ let content = "";
112
+ if (showBranch && branch) {
113
+ content = withIcon(theme.icon.branch, branch);
114
+ }
115
+
116
+ // Add status indicators
117
+ if (gitStatus) {
118
+ const indicators: string[] = [];
119
+ if (opts.showUnstaged !== false && gitStatus.unstaged > 0) {
120
+ indicators.push(theme.fg("statusLineDirty", `*${gitStatus.unstaged}`));
121
+ }
122
+ if (opts.showStaged !== false && gitStatus.staged > 0) {
123
+ indicators.push(theme.fg("statusLineStaged", `+${gitStatus.staged}`));
124
+ }
125
+ if (opts.showUntracked !== false && gitStatus.untracked > 0) {
126
+ indicators.push(theme.fg("statusLineUntracked", `?${gitStatus.untracked}`));
127
+ }
128
+ if (indicators.length > 0) {
129
+ const indicatorText = indicators.join(" ");
130
+ if (!content && showBranch === false) {
131
+ content = withIcon(theme.icon.git, indicatorText);
132
+ } else {
133
+ content += content ? ` ${indicatorText}` : indicatorText;
134
+ }
135
+ }
136
+ }
137
+
138
+ if (!content) return { content: "", visible: false };
139
+
140
+ const colorName = isDirty ? "statusLineGitDirty" : "statusLineGitClean";
141
+ return { content: theme.fg(colorName, content), visible: true };
142
+ },
143
+ };
144
+
145
+ const subagentsSegment: StatusLineSegment = {
146
+ id: "subagents",
147
+ render(ctx) {
148
+ if (ctx.subagentCount === 0) {
149
+ return { content: "", visible: false };
150
+ }
151
+ const content = withIcon(theme.icon.agents, `${ctx.subagentCount}`);
152
+ return { content: theme.fg("statusLineSubagents", content), visible: true };
153
+ },
154
+ };
155
+
156
+ const tokenInSegment: StatusLineSegment = {
157
+ id: "token_in",
158
+ render(ctx) {
159
+ const { input } = ctx.usageStats;
160
+ if (!input) return { content: "", visible: false };
161
+
162
+ const content = withIcon(theme.icon.input, formatTokens(input));
163
+ return { content: theme.fg("statusLineSpend", content), visible: true };
164
+ },
165
+ };
166
+
167
+ const tokenOutSegment: StatusLineSegment = {
168
+ id: "token_out",
169
+ render(ctx) {
170
+ const { output } = ctx.usageStats;
171
+ if (!output) return { content: "", visible: false };
172
+
173
+ const content = withIcon(theme.icon.output, formatTokens(output));
174
+ return { content: theme.fg("statusLineOutput", content), visible: true };
175
+ },
176
+ };
177
+
178
+ const tokenTotalSegment: StatusLineSegment = {
179
+ id: "token_total",
180
+ render(ctx) {
181
+ const { input, output, cacheRead, cacheWrite } = ctx.usageStats;
182
+ const total = input + output + cacheRead + cacheWrite;
183
+ if (!total) return { content: "", visible: false };
184
+
185
+ const content = withIcon(theme.icon.tokens, formatTokens(total));
186
+ return { content: theme.fg("statusLineSpend", content), visible: true };
187
+ },
188
+ };
189
+
190
+ const costSegment: StatusLineSegment = {
191
+ id: "cost",
192
+ render(ctx) {
193
+ const { cost } = ctx.usageStats;
194
+ const state = ctx.session.state;
195
+ const usingSubscription = state.model ? ctx.session.modelRegistry.isUsingOAuth(state.model) : false;
196
+
197
+ if (!cost && !usingSubscription) {
198
+ return { content: "", visible: false };
199
+ }
200
+
201
+ const costDisplay = usingSubscription ? "(sub)" : `$${cost.toFixed(2)}`;
202
+ return { content: theme.fg("statusLineCost", costDisplay), visible: true };
203
+ },
204
+ };
205
+
206
+ const contextPctSegment: StatusLineSegment = {
207
+ id: "context_pct",
208
+ render(ctx) {
209
+ const pct = ctx.contextPercent;
210
+ const window = ctx.contextWindow;
211
+
212
+ const autoIcon = ctx.autoCompactEnabled && theme.icon.auto ? ` ${theme.icon.auto}` : "";
213
+ const text = `${pct.toFixed(1)}%/${formatTokens(window)}${autoIcon}`;
214
+
215
+ let content: string;
216
+ if (pct > 90) {
217
+ content = withIcon(theme.icon.context, theme.fg("error", text));
218
+ } else if (pct > 70) {
219
+ content = withIcon(theme.icon.context, theme.fg("warning", text));
220
+ } else {
221
+ const colored = theme.fg("statusLineContext", text);
222
+ content = withIcon(theme.icon.context, colored);
223
+ }
224
+
225
+ return { content, visible: true };
226
+ },
227
+ };
228
+
229
+ const contextTotalSegment: StatusLineSegment = {
230
+ id: "context_total",
231
+ render(ctx) {
232
+ const window = ctx.contextWindow;
233
+ if (!window) return { content: "", visible: false };
234
+ return {
235
+ content: theme.fg("statusLineContext", withIcon(theme.icon.context, formatTokens(window))),
236
+ visible: true,
237
+ };
238
+ },
239
+ };
240
+
241
+ const timeSpentSegment: StatusLineSegment = {
242
+ id: "time_spent",
243
+ render(ctx) {
244
+ const elapsed = Date.now() - ctx.sessionStartTime;
245
+ if (elapsed < 1000) return { content: "", visible: false };
246
+
247
+ return { content: withIcon(theme.icon.time, formatDuration(elapsed)), visible: true };
248
+ },
249
+ };
250
+
251
+ const timeSegment: StatusLineSegment = {
252
+ id: "time",
253
+ render(ctx) {
254
+ const opts = ctx.options.time ?? {};
255
+ const now = new Date();
256
+
257
+ let hours = now.getHours();
258
+ let suffix = "";
259
+ if (opts.format === "12h") {
260
+ suffix = hours >= 12 ? "pm" : "am";
261
+ hours = hours % 12 || 12;
262
+ }
263
+
264
+ const mins = now.getMinutes().toString().padStart(2, "0");
265
+ let timeStr = `${hours}:${mins}`;
266
+ if (opts.showSeconds) {
267
+ timeStr += `:${now.getSeconds().toString().padStart(2, "0")}`;
268
+ }
269
+ timeStr += suffix;
270
+
271
+ return { content: withIcon(theme.icon.time, timeStr), visible: true };
272
+ },
273
+ };
274
+
275
+ const sessionSegment: StatusLineSegment = {
276
+ id: "session",
277
+ render(ctx) {
278
+ const sessionManager = ctx.session.sessionManager;
279
+ const sessionId = sessionManager?.getSessionId?.();
280
+ const display = sessionId?.slice(0, 8) || "new";
281
+
282
+ return { content: withIcon(theme.icon.session, display), visible: true };
283
+ },
284
+ };
285
+
286
+ const hostnameSegment: StatusLineSegment = {
287
+ id: "hostname",
288
+ render(_ctx) {
289
+ const name = osHostname().split(".")[0];
290
+ return { content: withIcon(theme.icon.host, name), visible: true };
291
+ },
292
+ };
293
+
294
+ const cacheReadSegment: StatusLineSegment = {
295
+ id: "cache_read",
296
+ render(ctx) {
297
+ const { cacheRead } = ctx.usageStats;
298
+ if (!cacheRead) return { content: "", visible: false };
299
+
300
+ const parts = [theme.icon.cache, theme.icon.input, formatTokens(cacheRead)].filter(Boolean);
301
+ const content = parts.join(" ");
302
+ return { content: theme.fg("statusLineSpend", content), visible: true };
303
+ },
304
+ };
305
+
306
+ const cacheWriteSegment: StatusLineSegment = {
307
+ id: "cache_write",
308
+ render(ctx) {
309
+ const { cacheWrite } = ctx.usageStats;
310
+ if (!cacheWrite) return { content: "", visible: false };
311
+
312
+ const parts = [theme.icon.cache, theme.icon.output, formatTokens(cacheWrite)].filter(Boolean);
313
+ const content = parts.join(" ");
314
+ return { content: theme.fg("statusLineOutput", content), visible: true };
315
+ },
316
+ };
317
+
318
+ // ═══════════════════════════════════════════════════════════════════════════
319
+ // Segment Registry
320
+ // ═══════════════════════════════════════════════════════════════════════════
321
+
322
+ export const SEGMENTS: Record<StatusLineSegmentId, StatusLineSegment> = {
323
+ pi: piSegment,
324
+ model: modelSegment,
325
+ path: pathSegment,
326
+ git: gitSegment,
327
+ subagents: subagentsSegment,
328
+ token_in: tokenInSegment,
329
+ token_out: tokenOutSegment,
330
+ token_total: tokenTotalSegment,
331
+ cost: costSegment,
332
+ context_pct: contextPctSegment,
333
+ context_total: contextTotalSegment,
334
+ time_spent: timeSpentSegment,
335
+ time: timeSegment,
336
+ session: sessionSegment,
337
+ hostname: hostnameSegment,
338
+ cache_read: cacheReadSegment,
339
+ cache_write: cacheWriteSegment,
340
+ };
341
+
342
+ export function renderSegment(id: StatusLineSegmentId, ctx: SegmentContext): RenderedSegment {
343
+ const segment = SEGMENTS[id];
344
+ if (!segment) {
345
+ return { content: "", visible: false };
346
+ }
347
+ return segment.render(ctx);
348
+ }
349
+
350
+ export const ALL_SEGMENT_IDS: StatusLineSegmentId[] = Object.keys(SEGMENTS) as StatusLineSegmentId[];
@@ -0,0 +1,55 @@
1
+ import type { Theme } from "../../theme/theme";
2
+ import type { SeparatorDef, StatusLineSeparatorStyle } from "./types";
3
+
4
+ function trimSep(value: string): string {
5
+ return value.trim();
6
+ }
7
+
8
+ export function getSeparator(style: StatusLineSeparatorStyle, theme: Theme): SeparatorDef {
9
+ switch (style) {
10
+ case "powerline":
11
+ return {
12
+ left: theme.sep.powerlineLeft,
13
+ right: theme.sep.powerlineRight,
14
+ endCaps: {
15
+ left: theme.sep.powerlineRight,
16
+ right: theme.sep.powerlineLeft,
17
+ useBgAsFg: true,
18
+ },
19
+ };
20
+ case "powerline-thin":
21
+ return {
22
+ left: theme.sep.powerlineThinLeft,
23
+ right: theme.sep.powerlineThinRight,
24
+ endCaps: {
25
+ left: theme.sep.powerlineRight,
26
+ right: theme.sep.powerlineLeft,
27
+ useBgAsFg: true,
28
+ },
29
+ };
30
+ case "slash": {
31
+ const slash = trimSep(theme.sep.slash);
32
+ return { left: slash, right: slash };
33
+ }
34
+ case "pipe": {
35
+ const pipe = trimSep(theme.sep.pipe);
36
+ return { left: pipe, right: pipe };
37
+ }
38
+ case "block":
39
+ return { left: theme.sep.block, right: theme.sep.block };
40
+ case "none":
41
+ return { left: theme.sep.space, right: theme.sep.space };
42
+ case "ascii":
43
+ return { left: theme.sep.asciiLeft, right: theme.sep.asciiRight };
44
+ default:
45
+ return {
46
+ left: theme.sep.powerlineThinLeft,
47
+ right: theme.sep.powerlineThinRight,
48
+ endCaps: {
49
+ left: theme.sep.powerlineRight,
50
+ right: theme.sep.powerlineLeft,
51
+ useBgAsFg: true,
52
+ },
53
+ };
54
+ }
55
+ }
@@ -0,0 +1,81 @@
1
+ import type { AgentSession } from "../../../../core/agent-session";
2
+ import type {
3
+ StatusLinePreset,
4
+ StatusLineSegmentId,
5
+ StatusLineSegmentOptions,
6
+ StatusLineSeparatorStyle,
7
+ StatusLineSettings,
8
+ } from "../../../../core/settings-manager";
9
+
10
+ // Re-export types from settings-manager (single source of truth)
11
+ export type {
12
+ StatusLinePreset,
13
+ StatusLineSegmentId,
14
+ StatusLineSegmentOptions,
15
+ StatusLineSeparatorStyle,
16
+ StatusLineSettings,
17
+ };
18
+
19
+ // ═══════════════════════════════════════════════════════════════════════════
20
+ // Segment Rendering
21
+ // ═══════════════════════════════════════════════════════════════════════════
22
+
23
+ export type RGB = readonly [number, number, number];
24
+
25
+ export interface SegmentContext {
26
+ session: AgentSession;
27
+ width: number;
28
+ options: StatusLineSegmentOptions;
29
+ // Cached values for performance (computed once per render)
30
+ usageStats: {
31
+ input: number;
32
+ output: number;
33
+ cacheRead: number;
34
+ cacheWrite: number;
35
+ cost: number;
36
+ };
37
+ contextPercent: number;
38
+ contextWindow: number;
39
+ autoCompactEnabled: boolean;
40
+ subagentCount: number;
41
+ sessionStartTime: number;
42
+ git: {
43
+ branch: string | null;
44
+ status: { staged: number; unstaged: number; untracked: number } | null;
45
+ };
46
+ }
47
+
48
+ export interface RenderedSegment {
49
+ content: string; // The segment text (may include ANSI color codes)
50
+ visible: boolean; // Whether to render (e.g., git hidden when not in repo)
51
+ }
52
+
53
+ export interface StatusLineSegment {
54
+ id: StatusLineSegmentId;
55
+ render(ctx: SegmentContext): RenderedSegment;
56
+ }
57
+
58
+ // ═══════════════════════════════════════════════════════════════════════════
59
+ // Separator Definition
60
+ // ═══════════════════════════════════════════════════════════════════════════
61
+
62
+ export interface SeparatorDef {
63
+ left: string; // Character for left→right segments
64
+ right: string; // Character for right→left segments (reversed)
65
+ endCaps?: {
66
+ left: string; // Cap for right segments (points left)
67
+ right: string; // Cap for left segments (points right)
68
+ useBgAsFg: boolean;
69
+ };
70
+ }
71
+
72
+ // ═══════════════════════════════════════════════════════════════════════════
73
+ // Preset Definition
74
+ // ═══════════════════════════════════════════════════════════════════════════
75
+
76
+ export interface PresetDef {
77
+ leftSegments: StatusLineSegmentId[];
78
+ rightSegments: StatusLineSegmentId[];
79
+ separator: StatusLineSeparatorStyle;
80
+ segmentOptions?: StatusLineSegmentOptions;
81
+ }