memorix 1.1.7 → 1.1.8

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 (174) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/CLAUDE.md +6 -1
  3. package/README.md +21 -0
  4. package/README.zh-CN.md +21 -0
  5. package/TEAM.md +86 -86
  6. package/dist/cli/index.js +730 -150
  7. package/dist/cli/index.js.map +1 -1
  8. package/dist/dashboard/static/index.html +201 -201
  9. package/dist/dashboard/static/style.css +3584 -3584
  10. package/dist/index.js +15 -8
  11. package/dist/index.js.map +1 -1
  12. package/dist/memcode-runtime/CHANGELOG.md +13 -0
  13. package/dist/memcode-runtime/package.json +4 -4
  14. package/dist/sdk.js +15 -8
  15. package/dist/sdk.js.map +1 -1
  16. package/docs/AGENT_OPERATOR_PLAYBOOK.md +18 -0
  17. package/docs/DESIGN_DECISIONS.md +357 -357
  18. package/docs/SETUP.md +10 -0
  19. package/docs/dev-log/progress.txt +35 -26
  20. package/package.json +1 -1
  21. package/src/audit/index.ts +156 -156
  22. package/src/cli/commands/agent-integrations.ts +623 -0
  23. package/src/cli/commands/audit-list.ts +89 -89
  24. package/src/cli/commands/background.ts +659 -659
  25. package/src/cli/commands/cleanup.ts +255 -255
  26. package/src/cli/commands/doctor.ts +23 -0
  27. package/src/cli/commands/formation.ts +48 -48
  28. package/src/cli/commands/git-hook-install.ts +111 -111
  29. package/src/cli/commands/handoff.ts +66 -66
  30. package/src/cli/commands/hooks-status.ts +63 -63
  31. package/src/cli/commands/ingest-commit.ts +153 -153
  32. package/src/cli/commands/ingest-image.ts +73 -73
  33. package/src/cli/commands/ingest-log.ts +180 -180
  34. package/src/cli/commands/ingest.ts +44 -44
  35. package/src/cli/commands/integrate-shared.ts +15 -15
  36. package/src/cli/commands/lock.ts +96 -96
  37. package/src/cli/commands/message.ts +121 -121
  38. package/src/cli/commands/poll.ts +70 -70
  39. package/src/cli/commands/purge-all-memory.ts +85 -85
  40. package/src/cli/commands/purge-project-memory.ts +83 -83
  41. package/src/cli/commands/reasoning.ts +132 -132
  42. package/src/cli/commands/repair.ts +60 -0
  43. package/src/cli/commands/retention.ts +108 -108
  44. package/src/cli/commands/serve-shared.ts +118 -118
  45. package/src/cli/commands/setup.ts +3 -3
  46. package/src/cli/commands/skills.ts +123 -123
  47. package/src/cli/commands/task.ts +192 -192
  48. package/src/cli/commands/transfer.ts +73 -73
  49. package/src/cli/commands/uninstall-project-artifacts.ts +85 -85
  50. package/src/cli/index.ts +3 -1
  51. package/src/cli/tui/ChatView.tsx +234 -234
  52. package/src/cli/tui/CommandBar.tsx +312 -312
  53. package/src/cli/tui/ContextRail.tsx +118 -118
  54. package/src/cli/tui/HeaderBar.tsx +72 -72
  55. package/src/cli/tui/LogoBanner.tsx +51 -51
  56. package/src/cli/tui/Panels.tsx +632 -632
  57. package/src/cli/tui/Sidebar.tsx +179 -179
  58. package/src/cli/tui/chat-service.ts +742 -742
  59. package/src/cli/tui/data.ts +547 -547
  60. package/src/cli/tui/index.ts +41 -41
  61. package/src/cli/tui/markdown-render.tsx +371 -371
  62. package/src/cli/tui/theme.ts +178 -178
  63. package/src/cli/tui/use-mouse.ts +157 -157
  64. package/src/cli/tui/useNavigation.ts +56 -56
  65. package/src/cli/update-checker.ts +211 -211
  66. package/src/cli/version.ts +7 -7
  67. package/src/cli/workbench.ts +1 -1
  68. package/src/codegraph/context-pack.ts +5 -1
  69. package/src/codegraph/lite-provider.ts +5 -1
  70. package/src/codegraph/project-context.ts +5 -1
  71. package/src/compact/token-budget.ts +74 -74
  72. package/src/config/behavior.ts +59 -59
  73. package/src/dashboard/project-classification.ts +64 -64
  74. package/src/dashboard/static/index.html +201 -201
  75. package/src/dashboard/static/style.css +3584 -3584
  76. package/src/embedding/fastembed-provider.ts +142 -142
  77. package/src/embedding/transformers-provider.ts +111 -111
  78. package/src/git/extractor.ts +209 -209
  79. package/src/git/hooks-path.ts +85 -85
  80. package/src/git/noise-filter.ts +210 -210
  81. package/src/hooks/installers/index.ts +4 -4
  82. package/src/hooks/official-skills.ts +1 -1
  83. package/src/hooks/pattern-detector.ts +173 -173
  84. package/src/hooks/rules/memorix-agent-rules.md +2 -2
  85. package/src/hooks/significance-filter.ts +250 -250
  86. package/src/llm/memory-manager.ts +328 -328
  87. package/src/llm/provider.ts +885 -885
  88. package/src/llm/quality.ts +248 -248
  89. package/src/memory/attribution-guard.ts +249 -249
  90. package/src/memory/auto-relations.ts +107 -107
  91. package/src/memory/consolidation.ts +302 -302
  92. package/src/memory/disclosure-policy.ts +141 -141
  93. package/src/memory/entity-extractor.ts +197 -197
  94. package/src/memory/formation/evaluate.ts +217 -217
  95. package/src/memory/formation/extract.ts +361 -361
  96. package/src/memory/formation/index.ts +417 -417
  97. package/src/memory/formation/resolve.ts +344 -344
  98. package/src/memory/formation/types.ts +315 -315
  99. package/src/memory/freshness.ts +122 -122
  100. package/src/memory/graph.ts +197 -197
  101. package/src/memory/refs.ts +94 -94
  102. package/src/memory/retention.ts +433 -433
  103. package/src/memory/secret-filter.ts +79 -79
  104. package/src/memory/session.ts +523 -523
  105. package/src/multimodal/image-loader.ts +143 -143
  106. package/src/orchestrate/adapters/claude-stream.ts +192 -192
  107. package/src/orchestrate/adapters/claude.ts +111 -111
  108. package/src/orchestrate/adapters/codex-stream.ts +134 -134
  109. package/src/orchestrate/adapters/codex.ts +41 -41
  110. package/src/orchestrate/adapters/gemini-stream.ts +166 -166
  111. package/src/orchestrate/adapters/gemini.ts +42 -42
  112. package/src/orchestrate/adapters/index.ts +73 -73
  113. package/src/orchestrate/adapters/opencode-stream.ts +143 -143
  114. package/src/orchestrate/adapters/opencode.ts +47 -47
  115. package/src/orchestrate/adapters/spawn-helper.ts +286 -286
  116. package/src/orchestrate/adapters/types.ts +77 -77
  117. package/src/orchestrate/capability-router.ts +284 -284
  118. package/src/orchestrate/context-compact.ts +188 -188
  119. package/src/orchestrate/cost-tracker.ts +219 -219
  120. package/src/orchestrate/error-recovery.ts +191 -191
  121. package/src/orchestrate/evidence.ts +140 -140
  122. package/src/orchestrate/ledger.ts +110 -110
  123. package/src/orchestrate/memorix-bridge.ts +380 -380
  124. package/src/orchestrate/output-budget.ts +80 -80
  125. package/src/orchestrate/permission.ts +152 -152
  126. package/src/orchestrate/pipeline-trace.ts +131 -131
  127. package/src/orchestrate/prompt-builder.ts +155 -155
  128. package/src/orchestrate/ring-buffer.ts +37 -37
  129. package/src/orchestrate/task-graph.ts +389 -389
  130. package/src/orchestrate/verify-gate.ts +219 -219
  131. package/src/orchestrate/worktree.ts +232 -232
  132. package/src/project/aliases.ts +374 -374
  133. package/src/project/detector.ts +268 -268
  134. package/src/rules/adapters/claude-code.ts +99 -99
  135. package/src/rules/adapters/codex.ts +97 -97
  136. package/src/rules/adapters/copilot.ts +124 -124
  137. package/src/rules/adapters/cursor.ts +114 -114
  138. package/src/rules/adapters/kiro.ts +126 -126
  139. package/src/rules/adapters/trae.ts +56 -56
  140. package/src/rules/adapters/windsurf.ts +83 -83
  141. package/src/rules/syncer.ts +235 -235
  142. package/src/sdk.ts +327 -327
  143. package/src/search/intent-detector.ts +289 -289
  144. package/src/search/query-expansion.ts +52 -52
  145. package/src/server/formation-timeout.ts +27 -27
  146. package/src/skills/mini-skills.ts +386 -386
  147. package/src/store/chat-store.ts +119 -119
  148. package/src/store/file-lock.ts +100 -100
  149. package/src/store/graph-store.ts +249 -249
  150. package/src/store/mini-skill-store.ts +349 -349
  151. package/src/store/obs-store.ts +255 -255
  152. package/src/store/persistence-json.ts +212 -212
  153. package/src/store/persistence.ts +291 -291
  154. package/src/store/project-affinity.ts +195 -195
  155. package/src/store/session-store.ts +259 -259
  156. package/src/store/sqlite-store.ts +339 -339
  157. package/src/team/event-bus.ts +76 -76
  158. package/src/team/file-locks.ts +173 -173
  159. package/src/team/handoff.ts +167 -167
  160. package/src/team/messages.ts +203 -203
  161. package/src/team/poll.ts +132 -132
  162. package/src/team/tasks.ts +211 -211
  163. package/src/wiki/generator.ts +237 -237
  164. package/src/wiki/knowledge-graph.ts +334 -334
  165. package/src/wiki/types.ts +85 -85
  166. package/src/workspace/mcp-adapters/codex.ts +191 -191
  167. package/src/workspace/mcp-adapters/copilot.ts +105 -105
  168. package/src/workspace/mcp-adapters/cursor.ts +53 -53
  169. package/src/workspace/mcp-adapters/kiro.ts +64 -64
  170. package/src/workspace/mcp-adapters/opencode.ts +123 -123
  171. package/src/workspace/mcp-adapters/trae.ts +134 -134
  172. package/src/workspace/mcp-adapters/windsurf.ts +91 -91
  173. package/src/workspace/sanitizer.ts +60 -60
  174. package/src/workspace/workflow-sync.ts +131 -131
@@ -1,632 +1,632 @@
1
- /**
2
- * Content views for the Memorix TUI.
3
- *
4
- * Modern design: Unicode separators, status dots, upgraded type icons,
5
- * brand-colored section headers, logo banner in HomeView.
6
- */
7
-
8
- import React from 'react';
9
- import { Box, Text } from 'ink';
10
- import { COLORS, TYPE_ICONS, SEP, STATUS_DOTS, SYMBOLS } from './theme.js';
11
- import { LogoBanner } from './LogoBanner.js';
12
- import type {
13
- MemoryItem,
14
- SearchResult,
15
- DoctorResult,
16
- ProjectInfo,
17
- BackgroundInfo,
18
- HealthInfo,
19
- } from './data.js';
20
- import type { ProjectKnowledgeOverview } from '../../wiki/types.js';
21
-
22
- function separator(width = 50): string {
23
- return SEP.thin.repeat(width);
24
- }
25
-
26
- function truncate(text: string, max = 60): string {
27
- if (text.length <= max) return text;
28
- return `${text.slice(0, max)}…`;
29
- }
30
-
31
- interface HomeViewProps {
32
- project: ProjectInfo | null;
33
- health: HealthInfo;
34
- background: BackgroundInfo;
35
- loading: boolean;
36
- contentWidth?: number;
37
- }
38
-
39
- export function HomeView({ project, health, background, contentWidth = 80 }: HomeViewProps): React.ReactElement {
40
- // ── No-project empty state: guidance only, no misleading status ──
41
- if (!project) {
42
- return (
43
- <Box flexDirection="column" paddingX={1}>
44
- <LogoBanner width={contentWidth} />
45
- <Box flexDirection="column" marginBottom={1} marginTop={1}>
46
- <Text color={COLORS.warning} bold>{STATUS_DOTS.warn} No project detected</Text>
47
- <Text color={COLORS.border}>{separator()}</Text>
48
- <Text color={COLORS.muted}>Memorix works best inside a git repository.</Text>
49
- <Text color={COLORS.muted}>Navigate to your project directory and re-launch, or:</Text>
50
- </Box>
51
-
52
- <Box flexDirection="column" marginBottom={1}>
53
- <Text color={COLORS.brand} bold>Getting Started</Text>
54
- <Text color={COLORS.border}>{separator()}</Text>
55
- <Text color={COLORS.textDim}> git init Initialize a git repo in this directory</Text>
56
- <Text color={COLORS.textDim}> c /configure Set up LLM + embedding providers</Text>
57
- <Text color={COLORS.textDim}> d /doctor Run diagnostics</Text>
58
- </Box>
59
-
60
- <Box flexDirection="column">
61
- <Text color={COLORS.brand} bold>Global Services</Text>
62
- <Text color={COLORS.border}>{separator()}</Text>
63
- <Box>
64
- <Text color={COLORS.muted}>{'Background'.padEnd(12)}</Text>
65
- <Text color={background.healthy ? COLORS.success : background.running ? COLORS.warning : COLORS.muted}>
66
- {background.healthy ? `${STATUS_DOTS.running} Running` : background.running ? `${STATUS_DOTS.warn} Unhealthy` : `${STATUS_DOTS.stopped} Stopped`}
67
- </Text>
68
- {background.port && <Text color={COLORS.textDim}> :{background.port}</Text>}
69
- </Box>
70
- <Text color={COLORS.textDim}> b /background Manage control plane</Text>
71
- </Box>
72
- </Box>
73
- );
74
- }
75
-
76
- // ── Project detected: full status view ──
77
- return (
78
- <Box flexDirection="column" paddingX={1}>
79
- <LogoBanner width={contentWidth} />
80
- <Box flexDirection="column" marginBottom={1} marginTop={1}>
81
- <Text color={COLORS.brand} bold>Project</Text>
82
- <Text color={COLORS.border}>{separator()}</Text>
83
- <Box flexDirection="column">
84
- <Box>
85
- <Text color={COLORS.muted}>{'Name'.padEnd(10)}</Text>
86
- <Text color={COLORS.text}>{project.name}</Text>
87
- </Box>
88
- <Box>
89
- <Text color={COLORS.muted}>{'Root'.padEnd(10)}</Text>
90
- <Text color={COLORS.textDim}>{project.rootPath}</Text>
91
- </Box>
92
- <Box>
93
- <Text color={COLORS.muted}>{'Remote'.padEnd(10)}</Text>
94
- <Text color={COLORS.textDim}>{project.gitRemote}</Text>
95
- </Box>
96
- </Box>
97
- </Box>
98
-
99
- <Box flexDirection="column" marginBottom={1}>
100
- <Text color={COLORS.brand} bold>Status</Text>
101
- <Text color={COLORS.border}>{separator()}</Text>
102
- <Box>
103
- <Text color={COLORS.muted}>{'Memories'.padEnd(12)}</Text>
104
- <Text color={COLORS.text}>{health.activeMemories} active</Text>
105
- </Box>
106
- <Box>
107
- <Text color={COLORS.muted}>{'Embedding'.padEnd(12)}</Text>
108
- <Text
109
- color={
110
- health.embeddingProvider === 'ready'
111
- ? COLORS.success
112
- : health.embeddingProvider === 'unavailable'
113
- ? COLORS.warning
114
- : COLORS.muted
115
- }
116
- >
117
- {health.embeddingProvider === 'ready' ? STATUS_DOTS.ok : health.embeddingProvider === 'unavailable' ? STATUS_DOTS.warn : STATUS_DOTS.off}{' '}
118
- {health.embeddingLabel}
119
- </Text>
120
- </Box>
121
- {health.embeddingProviderName && (
122
- <Box>
123
- <Text color={COLORS.muted}>{'Provider'.padEnd(12)}</Text>
124
- <Text color={COLORS.textDim}>{health.embeddingProviderName}</Text>
125
- </Box>
126
- )}
127
- <Box>
128
- <Text color={COLORS.muted}>{'Search Mode'.padEnd(12)}</Text>
129
- <Text color={health.searchModeLabel.toLowerCase().includes('hybrid') ? COLORS.success : COLORS.warning}>
130
- {STATUS_DOTS.ok} {health.searchModeLabel}
131
- </Text>
132
- </Box>
133
- {health.searchDiagnostic && (
134
- <Box>
135
- <Text color={COLORS.muted}>{''.padEnd(12)}</Text>
136
- <Text color={COLORS.textDim}>{health.searchDiagnostic}</Text>
137
- </Box>
138
- )}
139
- <Box>
140
- <Text color={COLORS.muted}>{'Background'.padEnd(12)}</Text>
141
- <Text color={background.healthy ? COLORS.success : background.running ? COLORS.warning : COLORS.muted}>
142
- {background.healthy ? `${STATUS_DOTS.running} Running` : background.running ? `${STATUS_DOTS.warn} Unhealthy` : `${STATUS_DOTS.stopped} Stopped`}
143
- </Text>
144
- {background.port && <Text color={COLORS.textDim}> :{background.port}</Text>}
145
- </Box>
146
- </Box>
147
-
148
- <Text color={COLORS.muted}>{SYMBOLS.arrow} Use /recent to view recent memory activity</Text>
149
- </Box>
150
- );
151
- }
152
-
153
- interface RecentViewProps {
154
- recentMemories: MemoryItem[];
155
- loading: boolean;
156
- }
157
-
158
- const DEV_NOISE_PATTERNS = [
159
- /^Revert\s+"feat:/i,
160
- /^Revert\s+"fix:/i,
161
- /^fix:.*TUI/i,
162
- /^feat:.*TUI.*moderniz/i,
163
- /^feat:.*center-first/i,
164
- /^feat:.*full TUI/i,
165
- ];
166
-
167
- export function RecentView({ recentMemories, loading }: RecentViewProps): React.ReactElement {
168
- const filtered = recentMemories.filter((memory) => !DEV_NOISE_PATTERNS.some((pattern) => pattern.test(memory.title)));
169
-
170
- return (
171
- <Box flexDirection="column" paddingX={1}>
172
- <Text color={COLORS.brand} bold>Recent Memory Activity{filtered.length < recentMemories.length ? ' (filtered)' : ''}</Text>
173
- <Text color={COLORS.border}>{separator()}</Text>
174
- {loading ? (
175
- <Text color={COLORS.muted}>Loading…</Text>
176
- ) : filtered.length === 0 ? (
177
- <Text color={COLORS.muted}>No recent activity. Use /remember to store a memory.</Text>
178
- ) : (
179
- filtered.map((memory) => (
180
- <Box key={memory.id}>
181
- <Text color={COLORS.muted}>{TYPE_ICONS[memory.type] || SYMBOLS.bullet} </Text>
182
- <Text color={COLORS.textDim}>#{memory.id} </Text>
183
- <Text color={COLORS.text}>{truncate(memory.title)}</Text>
184
- </Box>
185
- ))
186
- )}
187
- {filtered.length < recentMemories.length && (
188
- <Text color={COLORS.textDim}>({recentMemories.length - filtered.length} dev/noise entries hidden)</Text>
189
- )}
190
- {!loading && filtered.length > 0 && (
191
- <Box marginTop={1}><Text color={COLORS.muted}>{SYMBOLS.arrow} /search {'<'}query{'>'} │ /doctor │ /home</Text></Box>
192
- )}
193
- </Box>
194
- );
195
- }
196
-
197
- interface SearchResultsViewProps {
198
- results: SearchResult[];
199
- query: string;
200
- loading: boolean;
201
- }
202
-
203
- export function SearchResultsView({ results, query, loading }: SearchResultsViewProps): React.ReactElement {
204
- // Normalize scores relative to top result for relevance dots
205
- const topScore = results.length > 0 ? Math.max(...results.map(r => r.score)) : 1;
206
- const relevanceBar = (score: number): string => {
207
- const ratio = topScore > 0 ? score / topScore : 0;
208
- const filled = Math.round(ratio * 3);
209
- return '#'.repeat(filled) + '-'.repeat(3 - filled);
210
- };
211
-
212
- return (
213
- <Box flexDirection="column" paddingX={1}>
214
- <Box>
215
- <Text color={COLORS.brand} bold>Search: </Text>
216
- <Text color={COLORS.text}>"{query}"</Text>
217
- {!loading && <Text color={COLORS.muted}> │ {results.length} results</Text>}
218
- </Box>
219
- <Text color={COLORS.border}>{separator()}</Text>
220
-
221
- {loading ? (
222
- <Text color={COLORS.muted}>Searching…</Text>
223
- ) : results.length === 0 ? (
224
- <Text color={COLORS.muted}>No results found.</Text>
225
- ) : (
226
- results.map((result) => (
227
- <Box key={result.id}>
228
- <Text color={COLORS.muted}>{result.icon} </Text>
229
- <Text color={COLORS.textDim}>#{result.id} </Text>
230
- <Text color={COLORS.text}>{truncate(result.title)}</Text>
231
- <Text color={COLORS.accent}> {relevanceBar(result.score)}</Text>
232
- </Box>
233
- ))
234
- )}
235
- {!loading && results.length > 0 && (
236
- <Box marginTop={1} flexDirection="column">
237
- <Text color={COLORS.muted}>{SYMBOLS.arrow} /search {'<'}other query{'>'} │ /recent │ /home</Text>
238
- </Box>
239
- )}
240
- </Box>
241
- );
242
- }
243
-
244
- interface DoctorViewProps {
245
- doctor: DoctorResult | null;
246
- loading: boolean;
247
- }
248
-
249
- const STATUS_COLORS: Record<string, string> = {
250
- ok: COLORS.success,
251
- warn: COLORS.warning,
252
- error: COLORS.error,
253
- info: COLORS.textDim,
254
- };
255
-
256
- const STATUS_ICONS: Record<string, string> = {
257
- ok: SYMBOLS.check,
258
- warn: STATUS_DOTS.warn,
259
- error: SYMBOLS.cross,
260
- info: SYMBOLS.info,
261
- };
262
-
263
- export function DoctorView({ doctor, loading }: DoctorViewProps): React.ReactElement {
264
- return (
265
- <Box flexDirection="column" paddingX={1}>
266
- <Text color={COLORS.brand} bold>Diagnostics</Text>
267
- <Text color={COLORS.border}>{separator()}</Text>
268
-
269
- {loading ? (
270
- <Text color={COLORS.muted}>Running diagnostics...</Text>
271
- ) : !doctor ? (
272
- <Text color={COLORS.warning}>Failed to run diagnostics.</Text>
273
- ) : (
274
- <Box flexDirection="column">
275
- {doctor.sections.map((section, index) => (
276
- <Box key={index} flexDirection="column" marginBottom={1}>
277
- <Text color={COLORS.text} bold>{section.title}</Text>
278
- {section.items.map((item, itemIndex) => (
279
- <Box key={itemIndex}>
280
- <Text color={STATUS_COLORS[item.status] || COLORS.muted}>
281
- {STATUS_ICONS[item.status] || '.'}{' '}
282
- </Text>
283
- <Text color={COLORS.muted}>{item.label.padEnd(12)}</Text>
284
- <Text color={COLORS.text}>{item.value}</Text>
285
- </Box>
286
- ))}
287
- </Box>
288
- ))}
289
-
290
- <Box marginTop={1} flexDirection="column">
291
- <Text color={COLORS.brand} bold>Next</Text>
292
- <Text color={COLORS.muted}> /dashboard │ /background │ /search │ /recent</Text>
293
- </Box>
294
- </Box>
295
- )}
296
- </Box>
297
- );
298
- }
299
-
300
- interface ProjectViewProps {
301
- project: ProjectInfo | null;
302
- }
303
-
304
- export function ProjectView({ project }: ProjectViewProps): React.ReactElement {
305
- return (
306
- <Box flexDirection="column" paddingX={1}>
307
- <Text color={COLORS.brand} bold>Project Details</Text>
308
- <Text color={COLORS.border}>{separator()}</Text>
309
-
310
- {!project ? (
311
- <Text color={COLORS.warning}>No project detected. Run git init first.</Text>
312
- ) : (
313
- <Box flexDirection="column">
314
- {([
315
- ['Name', project.name],
316
- ['ID', project.id],
317
- ['Root', project.rootPath],
318
- ['Remote', project.gitRemote],
319
- ] as const).map(([label, value]) => (
320
- <Box key={label}>
321
- <Text color={COLORS.muted}>{String(label).padEnd(10)}</Text>
322
- <Text color={COLORS.text}>{value}</Text>
323
- </Box>
324
- ))}
325
- </Box>
326
- )}
327
- </Box>
328
- );
329
- }
330
-
331
- interface BackgroundViewProps {
332
- background: BackgroundInfo;
333
- loading: boolean;
334
- }
335
-
336
- export function BackgroundView({ background, loading }: BackgroundViewProps): React.ReactElement {
337
- return (
338
- <Box flexDirection="column" paddingX={1}>
339
- <Text color={COLORS.brand} bold>Background Control Plane</Text>
340
- <Text color={COLORS.border}>{separator()}</Text>
341
-
342
- {loading ? (
343
- <Text color={COLORS.muted}>Checking status…</Text>
344
- ) : (
345
- <Box flexDirection="column">
346
- <Box>
347
- <Text color={COLORS.muted}>{'Status'.padEnd(12)}</Text>
348
- <Text color={background.healthy ? COLORS.success : background.running ? COLORS.warning : COLORS.muted}>
349
- {background.healthy ? `${STATUS_DOTS.running} Running & healthy` : background.running ? `${STATUS_DOTS.warn} Running (unhealthy)` : `${STATUS_DOTS.stopped} Not running`}
350
- </Text>
351
- </Box>
352
- {background.pid && (
353
- <Box>
354
- <Text color={COLORS.muted}>{'PID'.padEnd(12)}</Text>
355
- <Text color={COLORS.text}>{background.pid}</Text>
356
- </Box>
357
- )}
358
- {background.port && (
359
- <>
360
- <Box>
361
- <Text color={COLORS.muted}>{'Port'.padEnd(12)}</Text>
362
- <Text color={COLORS.text}>{background.port}</Text>
363
- </Box>
364
- <Box>
365
- <Text color={COLORS.muted}>{'Dashboard'.padEnd(12)}</Text>
366
- <Text color={COLORS.accent}>{background.dashboard}</Text>
367
- </Box>
368
- <Box>
369
- <Text color={COLORS.muted}>{'MCP'.padEnd(12)}</Text>
370
- <Text color={COLORS.accent}>{background.mcp}</Text>
371
- </Box>
372
- </>
373
- )}
374
- {background.startedAt && (
375
- <Box>
376
- <Text color={COLORS.muted}>{'Started'.padEnd(12)}</Text>
377
- <Text color={COLORS.text}>{background.startedAt}</Text>
378
- </Box>
379
- )}
380
- {background.agents != null && (
381
- <Box>
382
- <Text color={COLORS.muted}>{'Agents'.padEnd(12)}</Text>
383
- <Text color={COLORS.text}>{background.agents}</Text>
384
- </Box>
385
- )}
386
- {background.sessions != null && (
387
- <Box>
388
- <Text color={COLORS.muted}>{'Sessions'.padEnd(12)}</Text>
389
- <Text color={COLORS.text}>{background.sessions}</Text>
390
- </Box>
391
- )}
392
- {background.message && (
393
- <Box marginTop={1}>
394
- <Text color={COLORS.muted}>{background.message}</Text>
395
- </Box>
396
- )}
397
-
398
- <Box marginTop={1} flexDirection="column">
399
- <Text color={COLORS.brand} bold>Actions</Text>
400
- <Text color={COLORS.border}>{separator()}</Text>
401
- {background.running ? (
402
- <Box flexDirection="column">
403
- {background.dashboard && (
404
- <Box>
405
- <Text color={COLORS.brand}> w Open dashboard </Text>
406
- <Text color={COLORS.textDim}>{background.dashboard}</Text>
407
- </Box>
408
- )}
409
- <Box><Text color={COLORS.text}> 1 Restart control plane</Text></Box>
410
- <Box><Text color={COLORS.text}> 2 Stop control plane</Text></Box>
411
- <Box><Text color={COLORS.text}> 3 View logs</Text></Box>
412
- {background.mcp && (
413
- <Box><Text color={COLORS.muted}> MCP: {background.mcp}</Text></Box>
414
- )}
415
- </Box>
416
- ) : (
417
- <Box flexDirection="column">
418
- <Box><Text color={COLORS.success}>{SYMBOLS.arrow} 1 Start control plane</Text></Box>
419
- <Box><Text color={COLORS.text}> 2 Launch standalone dashboard</Text></Box>
420
- </Box>
421
- )}
422
- </Box>
423
- </Box>
424
- )}
425
- </Box>
426
- );
427
- }
428
-
429
- interface DashboardViewProps {
430
- background: BackgroundInfo;
431
- }
432
-
433
- export function DashboardView({ background }: DashboardViewProps): React.ReactElement {
434
- return (
435
- <Box flexDirection="column" paddingX={1}>
436
- <Text color={COLORS.brand} bold>Dashboard</Text>
437
- <Text color={COLORS.border}>{separator()}</Text>
438
-
439
- {background.healthy && background.dashboard ? (
440
- <Box flexDirection="column">
441
- <Box marginBottom={1}>
442
- <Text color={COLORS.muted}>{'URL'.padEnd(12)}</Text>
443
- <Text color={COLORS.accent} bold>{background.dashboard}</Text>
444
- </Box>
445
- <Text color={COLORS.brand} bold>Actions</Text>
446
- <Text color={COLORS.border}>{separator()}</Text>
447
- <Box><Text color={COLORS.brand}> 1 Open {background.dashboard} in browser</Text></Box>
448
- <Box><Text color={COLORS.text}> 2 Launch standalone dashboard</Text></Box>
449
- </Box>
450
- ) : (
451
- <Box flexDirection="column">
452
- <Box marginBottom={1}>
453
- <Text color={COLORS.warning}>No running control plane</Text>
454
- </Box>
455
- <Text color={COLORS.brand} bold>Actions</Text>
456
- <Text color={COLORS.border}>{separator()}</Text>
457
- <Box>
458
- <Text color={COLORS.success}>{SYMBOLS.arrow} 1 Start control plane </Text>
459
- <Text color={COLORS.muted}>(then open dashboard)</Text>
460
- </Box>
461
- <Box><Text color={COLORS.text}> 2 Launch standalone dashboard</Text></Box>
462
- </Box>
463
- )}
464
- </Box>
465
- );
466
- }
467
-
468
- interface CleanupViewProps {
469
- onAction: (action: string) => void;
470
- statusText: string;
471
- }
472
-
473
- export function CleanupView({ statusText }: CleanupViewProps): React.ReactElement {
474
- return (
475
- <Box flexDirection="column" paddingX={1}>
476
- <Text color={COLORS.brand} bold>Cleanup & Purge</Text>
477
- <Text color={COLORS.border}>{separator()}</Text>
478
- <Box flexDirection="column" marginTop={1}>
479
- <Box><Text color={COLORS.text}> 1 Uninstall project artifacts</Text></Box>
480
- <Box><Text color={COLORS.text}> 2 Purge current project memory</Text></Box>
481
- <Box><Text color={COLORS.error}>{SYMBOLS.cross} 3 Purge ALL memory (danger)</Text></Box>
482
- <Box><Text color={COLORS.muted}> h Back to home</Text></Box>
483
- </Box>
484
- {statusText && (
485
- <Box marginTop={1}><Text color={COLORS.muted}>{statusText}</Text></Box>
486
- )}
487
- </Box>
488
- );
489
- }
490
-
491
- interface IngestViewProps {
492
- onAction: (action: string) => void;
493
- statusText: string;
494
- }
495
-
496
- export function IngestView({ statusText }: IngestViewProps): React.ReactElement {
497
- return (
498
- <Box flexDirection="column" paddingX={1}>
499
- <Text color={COLORS.brand} bold>Git {'>'} Memory</Text>
500
- <Text color={COLORS.border}>{separator()}</Text>
501
- <Box flexDirection="column" marginTop={1}>
502
- <Box><Text color={COLORS.text}> 1 Ingest latest commit</Text></Box>
503
- <Box><Text color={COLORS.text}> 2 Batch ingest recent git log</Text></Box>
504
- <Box><Text color={COLORS.text}> 3 Install post-commit hook</Text></Box>
505
- <Box><Text color={COLORS.text}> 4 Uninstall post-commit hook</Text></Box>
506
- <Box><Text color={COLORS.muted}> h Back to home</Text></Box>
507
- </Box>
508
- {statusText && (
509
- <Box marginTop={1}><Text color={COLORS.muted}>{statusText}</Text></Box>
510
- )}
511
- </Box>
512
- );
513
- }
514
-
515
- interface IntegrateViewProps {
516
- statusText: string;
517
- }
518
-
519
- export function IntegrateView({ statusText }: IntegrateViewProps): React.ReactElement {
520
- return (
521
- <Box flexDirection="column" paddingX={1}>
522
- <Text color={COLORS.brand} bold>Integrate IDE</Text>
523
- <Text color={COLORS.border}>{separator()}</Text>
524
- <Box flexDirection="column" marginTop={1}>
525
- <Box><Text color={COLORS.text}> 1 Claude Code</Text></Box>
526
- <Box><Text color={COLORS.text}> 2 Windsurf</Text></Box>
527
- <Box><Text color={COLORS.text}> 3 Cursor</Text></Box>
528
- <Box><Text color={COLORS.text}> 4 GitHub Copilot</Text></Box>
529
- <Box><Text color={COLORS.text}> 5 Kiro</Text></Box>
530
- <Box><Text color={COLORS.text}> 6 Codex</Text></Box>
531
- <Box><Text color={COLORS.text}> 7 Antigravity</Text></Box>
532
- <Box><Text color={COLORS.text}> 8 OpenCode</Text></Box>
533
- <Box><Text color={COLORS.text}> 9 Trae</Text></Box>
534
- <Box><Text color={COLORS.text}> 0 Gemini CLI</Text></Box>
535
- <Box><Text color={COLORS.muted}> h Back to home</Text></Box>
536
- </Box>
537
- <Box marginTop={1}>
538
- <Text color={COLORS.textDim}>Installs only for the current project.</Text>
539
- </Box>
540
- {statusText && (
541
- <Box marginTop={1}><Text color={COLORS.muted}>{statusText}</Text></Box>
542
- )}
543
- </Box>
544
- );
545
- }
546
-
547
- interface WikiViewProps {
548
- knowledge: ProjectKnowledgeOverview | null;
549
- loading: boolean;
550
- }
551
-
552
- export function WikiView({ knowledge, loading }: WikiViewProps): React.ReactElement {
553
- if (loading) {
554
- return (
555
- <Box flexDirection="column" paddingX={1}>
556
- <Text color={COLORS.brand} bold>Knowledge Base</Text>
557
- <Text color={COLORS.muted}> LLM Wiki</Text>
558
- <Text color={COLORS.border}>{separator()}</Text>
559
- <Text color={COLORS.muted}>Loading...</Text>
560
- </Box>
561
- );
562
- }
563
-
564
- if (!knowledge) {
565
- return (
566
- <Box flexDirection="column" paddingX={1}>
567
- <Text color={COLORS.brand} bold>Knowledge Base</Text>
568
- <Text color={COLORS.muted}> LLM Wiki</Text>
569
- <Text color={COLORS.border}>{separator()}</Text>
570
- <Text color={COLORS.warning}>No knowledge available for this project.</Text>
571
- <Text color={COLORS.textDim}>Store memories with /remember or /chat to build your Knowledge Base.</Text>
572
- </Box>
573
- );
574
- }
575
-
576
- return (
577
- <Box flexDirection="column" paddingX={1}>
578
- <Text color={COLORS.brand} bold>Knowledge Base</Text>
579
- <Text color={COLORS.muted}> LLM Wiki</Text>
580
- <Box>
581
- <Text color={COLORS.textDim}> Project: {knowledge.projectId}</Text>
582
- <Text color={COLORS.muted}> │ {knowledge.stats.observationsUsed} obs, {knowledge.stats.miniSkillsUsed} skills</Text>
583
- </Box>
584
- <Text color={COLORS.border}>{separator()}</Text>
585
-
586
- {knowledge.sections.map((section) => (
587
- <Box key={section.id} flexDirection="column" marginBottom={1}>
588
- <Text color={COLORS.brandDim} bold>{section.title}</Text>
589
- {section.empty ? (
590
- <Text color={COLORS.textDim}> (empty)</Text>
591
- ) : (
592
- section.items.map((item, idx) => (
593
- <Box key={idx} flexDirection="column">
594
- <Box>
595
- <Text color={COLORS.muted}>{SYMBOLS.bullet} </Text>
596
- <Text color={COLORS.text}>{truncate(item.title)}</Text>
597
- {item.entityName && <Text color={COLORS.textDim}> [{item.entityName}]</Text>}
598
- </Box>
599
- <Text color={COLORS.textDim}> {truncate(item.summary, 80)}</Text>
600
- <Text color={COLORS.muted}> refs: {item.refs.map((r) => r.id).join(', ')}</Text>
601
- </Box>
602
- ))
603
- )}
604
- </Box>
605
- ))}
606
-
607
- <Box marginTop={1}>
608
- <Text color={COLORS.muted}>{SYMBOLS.arrow} Esc to return home</Text>
609
- </Box>
610
- </Box>
611
- );
612
- }
613
-
614
- interface StatusMessageProps {
615
- message: string;
616
- type: 'success' | 'error' | 'info';
617
- }
618
-
619
- export function StatusMessage({ message, type }: StatusMessageProps): React.ReactElement {
620
- const color = type === 'success' ? COLORS.success : type === 'error' ? COLORS.error : COLORS.muted;
621
- const icon = type === 'success' ? SYMBOLS.check : type === 'error' ? SYMBOLS.cross : SYMBOLS.info;
622
- const lines = message.split('\n');
623
- return (
624
- <Box paddingX={1} flexDirection="column">
625
- {lines.map((line, index) => (
626
- <Text key={index} color={color} wrap="truncate-end">
627
- {index === 0 ? `${icon} ${line}` : ` ${line}`}
628
- </Text>
629
- ))}
630
- </Box>
631
- );
632
- }
1
+ /**
2
+ * Content views for the Memorix TUI.
3
+ *
4
+ * Modern design: Unicode separators, status dots, upgraded type icons,
5
+ * brand-colored section headers, logo banner in HomeView.
6
+ */
7
+
8
+ import React from 'react';
9
+ import { Box, Text } from 'ink';
10
+ import { COLORS, TYPE_ICONS, SEP, STATUS_DOTS, SYMBOLS } from './theme.js';
11
+ import { LogoBanner } from './LogoBanner.js';
12
+ import type {
13
+ MemoryItem,
14
+ SearchResult,
15
+ DoctorResult,
16
+ ProjectInfo,
17
+ BackgroundInfo,
18
+ HealthInfo,
19
+ } from './data.js';
20
+ import type { ProjectKnowledgeOverview } from '../../wiki/types.js';
21
+
22
+ function separator(width = 50): string {
23
+ return SEP.thin.repeat(width);
24
+ }
25
+
26
+ function truncate(text: string, max = 60): string {
27
+ if (text.length <= max) return text;
28
+ return `${text.slice(0, max)}…`;
29
+ }
30
+
31
+ interface HomeViewProps {
32
+ project: ProjectInfo | null;
33
+ health: HealthInfo;
34
+ background: BackgroundInfo;
35
+ loading: boolean;
36
+ contentWidth?: number;
37
+ }
38
+
39
+ export function HomeView({ project, health, background, contentWidth = 80 }: HomeViewProps): React.ReactElement {
40
+ // ── No-project empty state: guidance only, no misleading status ──
41
+ if (!project) {
42
+ return (
43
+ <Box flexDirection="column" paddingX={1}>
44
+ <LogoBanner width={contentWidth} />
45
+ <Box flexDirection="column" marginBottom={1} marginTop={1}>
46
+ <Text color={COLORS.warning} bold>{STATUS_DOTS.warn} No project detected</Text>
47
+ <Text color={COLORS.border}>{separator()}</Text>
48
+ <Text color={COLORS.muted}>Memorix works best inside a git repository.</Text>
49
+ <Text color={COLORS.muted}>Navigate to your project directory and re-launch, or:</Text>
50
+ </Box>
51
+
52
+ <Box flexDirection="column" marginBottom={1}>
53
+ <Text color={COLORS.brand} bold>Getting Started</Text>
54
+ <Text color={COLORS.border}>{separator()}</Text>
55
+ <Text color={COLORS.textDim}> git init Initialize a git repo in this directory</Text>
56
+ <Text color={COLORS.textDim}> c /configure Set up LLM + embedding providers</Text>
57
+ <Text color={COLORS.textDim}> d /doctor Run diagnostics</Text>
58
+ </Box>
59
+
60
+ <Box flexDirection="column">
61
+ <Text color={COLORS.brand} bold>Global Services</Text>
62
+ <Text color={COLORS.border}>{separator()}</Text>
63
+ <Box>
64
+ <Text color={COLORS.muted}>{'Background'.padEnd(12)}</Text>
65
+ <Text color={background.healthy ? COLORS.success : background.running ? COLORS.warning : COLORS.muted}>
66
+ {background.healthy ? `${STATUS_DOTS.running} Running` : background.running ? `${STATUS_DOTS.warn} Unhealthy` : `${STATUS_DOTS.stopped} Stopped`}
67
+ </Text>
68
+ {background.port && <Text color={COLORS.textDim}> :{background.port}</Text>}
69
+ </Box>
70
+ <Text color={COLORS.textDim}> b /background Manage control plane</Text>
71
+ </Box>
72
+ </Box>
73
+ );
74
+ }
75
+
76
+ // ── Project detected: full status view ──
77
+ return (
78
+ <Box flexDirection="column" paddingX={1}>
79
+ <LogoBanner width={contentWidth} />
80
+ <Box flexDirection="column" marginBottom={1} marginTop={1}>
81
+ <Text color={COLORS.brand} bold>Project</Text>
82
+ <Text color={COLORS.border}>{separator()}</Text>
83
+ <Box flexDirection="column">
84
+ <Box>
85
+ <Text color={COLORS.muted}>{'Name'.padEnd(10)}</Text>
86
+ <Text color={COLORS.text}>{project.name}</Text>
87
+ </Box>
88
+ <Box>
89
+ <Text color={COLORS.muted}>{'Root'.padEnd(10)}</Text>
90
+ <Text color={COLORS.textDim}>{project.rootPath}</Text>
91
+ </Box>
92
+ <Box>
93
+ <Text color={COLORS.muted}>{'Remote'.padEnd(10)}</Text>
94
+ <Text color={COLORS.textDim}>{project.gitRemote}</Text>
95
+ </Box>
96
+ </Box>
97
+ </Box>
98
+
99
+ <Box flexDirection="column" marginBottom={1}>
100
+ <Text color={COLORS.brand} bold>Status</Text>
101
+ <Text color={COLORS.border}>{separator()}</Text>
102
+ <Box>
103
+ <Text color={COLORS.muted}>{'Memories'.padEnd(12)}</Text>
104
+ <Text color={COLORS.text}>{health.activeMemories} active</Text>
105
+ </Box>
106
+ <Box>
107
+ <Text color={COLORS.muted}>{'Embedding'.padEnd(12)}</Text>
108
+ <Text
109
+ color={
110
+ health.embeddingProvider === 'ready'
111
+ ? COLORS.success
112
+ : health.embeddingProvider === 'unavailable'
113
+ ? COLORS.warning
114
+ : COLORS.muted
115
+ }
116
+ >
117
+ {health.embeddingProvider === 'ready' ? STATUS_DOTS.ok : health.embeddingProvider === 'unavailable' ? STATUS_DOTS.warn : STATUS_DOTS.off}{' '}
118
+ {health.embeddingLabel}
119
+ </Text>
120
+ </Box>
121
+ {health.embeddingProviderName && (
122
+ <Box>
123
+ <Text color={COLORS.muted}>{'Provider'.padEnd(12)}</Text>
124
+ <Text color={COLORS.textDim}>{health.embeddingProviderName}</Text>
125
+ </Box>
126
+ )}
127
+ <Box>
128
+ <Text color={COLORS.muted}>{'Search Mode'.padEnd(12)}</Text>
129
+ <Text color={health.searchModeLabel.toLowerCase().includes('hybrid') ? COLORS.success : COLORS.warning}>
130
+ {STATUS_DOTS.ok} {health.searchModeLabel}
131
+ </Text>
132
+ </Box>
133
+ {health.searchDiagnostic && (
134
+ <Box>
135
+ <Text color={COLORS.muted}>{''.padEnd(12)}</Text>
136
+ <Text color={COLORS.textDim}>{health.searchDiagnostic}</Text>
137
+ </Box>
138
+ )}
139
+ <Box>
140
+ <Text color={COLORS.muted}>{'Background'.padEnd(12)}</Text>
141
+ <Text color={background.healthy ? COLORS.success : background.running ? COLORS.warning : COLORS.muted}>
142
+ {background.healthy ? `${STATUS_DOTS.running} Running` : background.running ? `${STATUS_DOTS.warn} Unhealthy` : `${STATUS_DOTS.stopped} Stopped`}
143
+ </Text>
144
+ {background.port && <Text color={COLORS.textDim}> :{background.port}</Text>}
145
+ </Box>
146
+ </Box>
147
+
148
+ <Text color={COLORS.muted}>{SYMBOLS.arrow} Use /recent to view recent memory activity</Text>
149
+ </Box>
150
+ );
151
+ }
152
+
153
+ interface RecentViewProps {
154
+ recentMemories: MemoryItem[];
155
+ loading: boolean;
156
+ }
157
+
158
+ const DEV_NOISE_PATTERNS = [
159
+ /^Revert\s+"feat:/i,
160
+ /^Revert\s+"fix:/i,
161
+ /^fix:.*TUI/i,
162
+ /^feat:.*TUI.*moderniz/i,
163
+ /^feat:.*center-first/i,
164
+ /^feat:.*full TUI/i,
165
+ ];
166
+
167
+ export function RecentView({ recentMemories, loading }: RecentViewProps): React.ReactElement {
168
+ const filtered = recentMemories.filter((memory) => !DEV_NOISE_PATTERNS.some((pattern) => pattern.test(memory.title)));
169
+
170
+ return (
171
+ <Box flexDirection="column" paddingX={1}>
172
+ <Text color={COLORS.brand} bold>Recent Memory Activity{filtered.length < recentMemories.length ? ' (filtered)' : ''}</Text>
173
+ <Text color={COLORS.border}>{separator()}</Text>
174
+ {loading ? (
175
+ <Text color={COLORS.muted}>Loading…</Text>
176
+ ) : filtered.length === 0 ? (
177
+ <Text color={COLORS.muted}>No recent activity. Use /remember to store a memory.</Text>
178
+ ) : (
179
+ filtered.map((memory) => (
180
+ <Box key={memory.id}>
181
+ <Text color={COLORS.muted}>{TYPE_ICONS[memory.type] || SYMBOLS.bullet} </Text>
182
+ <Text color={COLORS.textDim}>#{memory.id} </Text>
183
+ <Text color={COLORS.text}>{truncate(memory.title)}</Text>
184
+ </Box>
185
+ ))
186
+ )}
187
+ {filtered.length < recentMemories.length && (
188
+ <Text color={COLORS.textDim}>({recentMemories.length - filtered.length} dev/noise entries hidden)</Text>
189
+ )}
190
+ {!loading && filtered.length > 0 && (
191
+ <Box marginTop={1}><Text color={COLORS.muted}>{SYMBOLS.arrow} /search {'<'}query{'>'} │ /doctor │ /home</Text></Box>
192
+ )}
193
+ </Box>
194
+ );
195
+ }
196
+
197
+ interface SearchResultsViewProps {
198
+ results: SearchResult[];
199
+ query: string;
200
+ loading: boolean;
201
+ }
202
+
203
+ export function SearchResultsView({ results, query, loading }: SearchResultsViewProps): React.ReactElement {
204
+ // Normalize scores relative to top result for relevance dots
205
+ const topScore = results.length > 0 ? Math.max(...results.map(r => r.score)) : 1;
206
+ const relevanceBar = (score: number): string => {
207
+ const ratio = topScore > 0 ? score / topScore : 0;
208
+ const filled = Math.round(ratio * 3);
209
+ return '#'.repeat(filled) + '-'.repeat(3 - filled);
210
+ };
211
+
212
+ return (
213
+ <Box flexDirection="column" paddingX={1}>
214
+ <Box>
215
+ <Text color={COLORS.brand} bold>Search: </Text>
216
+ <Text color={COLORS.text}>"{query}"</Text>
217
+ {!loading && <Text color={COLORS.muted}> │ {results.length} results</Text>}
218
+ </Box>
219
+ <Text color={COLORS.border}>{separator()}</Text>
220
+
221
+ {loading ? (
222
+ <Text color={COLORS.muted}>Searching…</Text>
223
+ ) : results.length === 0 ? (
224
+ <Text color={COLORS.muted}>No results found.</Text>
225
+ ) : (
226
+ results.map((result) => (
227
+ <Box key={result.id}>
228
+ <Text color={COLORS.muted}>{result.icon} </Text>
229
+ <Text color={COLORS.textDim}>#{result.id} </Text>
230
+ <Text color={COLORS.text}>{truncate(result.title)}</Text>
231
+ <Text color={COLORS.accent}> {relevanceBar(result.score)}</Text>
232
+ </Box>
233
+ ))
234
+ )}
235
+ {!loading && results.length > 0 && (
236
+ <Box marginTop={1} flexDirection="column">
237
+ <Text color={COLORS.muted}>{SYMBOLS.arrow} /search {'<'}other query{'>'} │ /recent │ /home</Text>
238
+ </Box>
239
+ )}
240
+ </Box>
241
+ );
242
+ }
243
+
244
+ interface DoctorViewProps {
245
+ doctor: DoctorResult | null;
246
+ loading: boolean;
247
+ }
248
+
249
+ const STATUS_COLORS: Record<string, string> = {
250
+ ok: COLORS.success,
251
+ warn: COLORS.warning,
252
+ error: COLORS.error,
253
+ info: COLORS.textDim,
254
+ };
255
+
256
+ const STATUS_ICONS: Record<string, string> = {
257
+ ok: SYMBOLS.check,
258
+ warn: STATUS_DOTS.warn,
259
+ error: SYMBOLS.cross,
260
+ info: SYMBOLS.info,
261
+ };
262
+
263
+ export function DoctorView({ doctor, loading }: DoctorViewProps): React.ReactElement {
264
+ return (
265
+ <Box flexDirection="column" paddingX={1}>
266
+ <Text color={COLORS.brand} bold>Diagnostics</Text>
267
+ <Text color={COLORS.border}>{separator()}</Text>
268
+
269
+ {loading ? (
270
+ <Text color={COLORS.muted}>Running diagnostics...</Text>
271
+ ) : !doctor ? (
272
+ <Text color={COLORS.warning}>Failed to run diagnostics.</Text>
273
+ ) : (
274
+ <Box flexDirection="column">
275
+ {doctor.sections.map((section, index) => (
276
+ <Box key={index} flexDirection="column" marginBottom={1}>
277
+ <Text color={COLORS.text} bold>{section.title}</Text>
278
+ {section.items.map((item, itemIndex) => (
279
+ <Box key={itemIndex}>
280
+ <Text color={STATUS_COLORS[item.status] || COLORS.muted}>
281
+ {STATUS_ICONS[item.status] || '.'}{' '}
282
+ </Text>
283
+ <Text color={COLORS.muted}>{item.label.padEnd(12)}</Text>
284
+ <Text color={COLORS.text}>{item.value}</Text>
285
+ </Box>
286
+ ))}
287
+ </Box>
288
+ ))}
289
+
290
+ <Box marginTop={1} flexDirection="column">
291
+ <Text color={COLORS.brand} bold>Next</Text>
292
+ <Text color={COLORS.muted}> /dashboard │ /background │ /search │ /recent</Text>
293
+ </Box>
294
+ </Box>
295
+ )}
296
+ </Box>
297
+ );
298
+ }
299
+
300
+ interface ProjectViewProps {
301
+ project: ProjectInfo | null;
302
+ }
303
+
304
+ export function ProjectView({ project }: ProjectViewProps): React.ReactElement {
305
+ return (
306
+ <Box flexDirection="column" paddingX={1}>
307
+ <Text color={COLORS.brand} bold>Project Details</Text>
308
+ <Text color={COLORS.border}>{separator()}</Text>
309
+
310
+ {!project ? (
311
+ <Text color={COLORS.warning}>No project detected. Run git init first.</Text>
312
+ ) : (
313
+ <Box flexDirection="column">
314
+ {([
315
+ ['Name', project.name],
316
+ ['ID', project.id],
317
+ ['Root', project.rootPath],
318
+ ['Remote', project.gitRemote],
319
+ ] as const).map(([label, value]) => (
320
+ <Box key={label}>
321
+ <Text color={COLORS.muted}>{String(label).padEnd(10)}</Text>
322
+ <Text color={COLORS.text}>{value}</Text>
323
+ </Box>
324
+ ))}
325
+ </Box>
326
+ )}
327
+ </Box>
328
+ );
329
+ }
330
+
331
+ interface BackgroundViewProps {
332
+ background: BackgroundInfo;
333
+ loading: boolean;
334
+ }
335
+
336
+ export function BackgroundView({ background, loading }: BackgroundViewProps): React.ReactElement {
337
+ return (
338
+ <Box flexDirection="column" paddingX={1}>
339
+ <Text color={COLORS.brand} bold>Background Control Plane</Text>
340
+ <Text color={COLORS.border}>{separator()}</Text>
341
+
342
+ {loading ? (
343
+ <Text color={COLORS.muted}>Checking status…</Text>
344
+ ) : (
345
+ <Box flexDirection="column">
346
+ <Box>
347
+ <Text color={COLORS.muted}>{'Status'.padEnd(12)}</Text>
348
+ <Text color={background.healthy ? COLORS.success : background.running ? COLORS.warning : COLORS.muted}>
349
+ {background.healthy ? `${STATUS_DOTS.running} Running & healthy` : background.running ? `${STATUS_DOTS.warn} Running (unhealthy)` : `${STATUS_DOTS.stopped} Not running`}
350
+ </Text>
351
+ </Box>
352
+ {background.pid && (
353
+ <Box>
354
+ <Text color={COLORS.muted}>{'PID'.padEnd(12)}</Text>
355
+ <Text color={COLORS.text}>{background.pid}</Text>
356
+ </Box>
357
+ )}
358
+ {background.port && (
359
+ <>
360
+ <Box>
361
+ <Text color={COLORS.muted}>{'Port'.padEnd(12)}</Text>
362
+ <Text color={COLORS.text}>{background.port}</Text>
363
+ </Box>
364
+ <Box>
365
+ <Text color={COLORS.muted}>{'Dashboard'.padEnd(12)}</Text>
366
+ <Text color={COLORS.accent}>{background.dashboard}</Text>
367
+ </Box>
368
+ <Box>
369
+ <Text color={COLORS.muted}>{'MCP'.padEnd(12)}</Text>
370
+ <Text color={COLORS.accent}>{background.mcp}</Text>
371
+ </Box>
372
+ </>
373
+ )}
374
+ {background.startedAt && (
375
+ <Box>
376
+ <Text color={COLORS.muted}>{'Started'.padEnd(12)}</Text>
377
+ <Text color={COLORS.text}>{background.startedAt}</Text>
378
+ </Box>
379
+ )}
380
+ {background.agents != null && (
381
+ <Box>
382
+ <Text color={COLORS.muted}>{'Agents'.padEnd(12)}</Text>
383
+ <Text color={COLORS.text}>{background.agents}</Text>
384
+ </Box>
385
+ )}
386
+ {background.sessions != null && (
387
+ <Box>
388
+ <Text color={COLORS.muted}>{'Sessions'.padEnd(12)}</Text>
389
+ <Text color={COLORS.text}>{background.sessions}</Text>
390
+ </Box>
391
+ )}
392
+ {background.message && (
393
+ <Box marginTop={1}>
394
+ <Text color={COLORS.muted}>{background.message}</Text>
395
+ </Box>
396
+ )}
397
+
398
+ <Box marginTop={1} flexDirection="column">
399
+ <Text color={COLORS.brand} bold>Actions</Text>
400
+ <Text color={COLORS.border}>{separator()}</Text>
401
+ {background.running ? (
402
+ <Box flexDirection="column">
403
+ {background.dashboard && (
404
+ <Box>
405
+ <Text color={COLORS.brand}> w Open dashboard </Text>
406
+ <Text color={COLORS.textDim}>{background.dashboard}</Text>
407
+ </Box>
408
+ )}
409
+ <Box><Text color={COLORS.text}> 1 Restart control plane</Text></Box>
410
+ <Box><Text color={COLORS.text}> 2 Stop control plane</Text></Box>
411
+ <Box><Text color={COLORS.text}> 3 View logs</Text></Box>
412
+ {background.mcp && (
413
+ <Box><Text color={COLORS.muted}> MCP: {background.mcp}</Text></Box>
414
+ )}
415
+ </Box>
416
+ ) : (
417
+ <Box flexDirection="column">
418
+ <Box><Text color={COLORS.success}>{SYMBOLS.arrow} 1 Start control plane</Text></Box>
419
+ <Box><Text color={COLORS.text}> 2 Launch standalone dashboard</Text></Box>
420
+ </Box>
421
+ )}
422
+ </Box>
423
+ </Box>
424
+ )}
425
+ </Box>
426
+ );
427
+ }
428
+
429
+ interface DashboardViewProps {
430
+ background: BackgroundInfo;
431
+ }
432
+
433
+ export function DashboardView({ background }: DashboardViewProps): React.ReactElement {
434
+ return (
435
+ <Box flexDirection="column" paddingX={1}>
436
+ <Text color={COLORS.brand} bold>Dashboard</Text>
437
+ <Text color={COLORS.border}>{separator()}</Text>
438
+
439
+ {background.healthy && background.dashboard ? (
440
+ <Box flexDirection="column">
441
+ <Box marginBottom={1}>
442
+ <Text color={COLORS.muted}>{'URL'.padEnd(12)}</Text>
443
+ <Text color={COLORS.accent} bold>{background.dashboard}</Text>
444
+ </Box>
445
+ <Text color={COLORS.brand} bold>Actions</Text>
446
+ <Text color={COLORS.border}>{separator()}</Text>
447
+ <Box><Text color={COLORS.brand}> 1 Open {background.dashboard} in browser</Text></Box>
448
+ <Box><Text color={COLORS.text}> 2 Launch standalone dashboard</Text></Box>
449
+ </Box>
450
+ ) : (
451
+ <Box flexDirection="column">
452
+ <Box marginBottom={1}>
453
+ <Text color={COLORS.warning}>No running control plane</Text>
454
+ </Box>
455
+ <Text color={COLORS.brand} bold>Actions</Text>
456
+ <Text color={COLORS.border}>{separator()}</Text>
457
+ <Box>
458
+ <Text color={COLORS.success}>{SYMBOLS.arrow} 1 Start control plane </Text>
459
+ <Text color={COLORS.muted}>(then open dashboard)</Text>
460
+ </Box>
461
+ <Box><Text color={COLORS.text}> 2 Launch standalone dashboard</Text></Box>
462
+ </Box>
463
+ )}
464
+ </Box>
465
+ );
466
+ }
467
+
468
+ interface CleanupViewProps {
469
+ onAction: (action: string) => void;
470
+ statusText: string;
471
+ }
472
+
473
+ export function CleanupView({ statusText }: CleanupViewProps): React.ReactElement {
474
+ return (
475
+ <Box flexDirection="column" paddingX={1}>
476
+ <Text color={COLORS.brand} bold>Cleanup & Purge</Text>
477
+ <Text color={COLORS.border}>{separator()}</Text>
478
+ <Box flexDirection="column" marginTop={1}>
479
+ <Box><Text color={COLORS.text}> 1 Uninstall project artifacts</Text></Box>
480
+ <Box><Text color={COLORS.text}> 2 Purge current project memory</Text></Box>
481
+ <Box><Text color={COLORS.error}>{SYMBOLS.cross} 3 Purge ALL memory (danger)</Text></Box>
482
+ <Box><Text color={COLORS.muted}> h Back to home</Text></Box>
483
+ </Box>
484
+ {statusText && (
485
+ <Box marginTop={1}><Text color={COLORS.muted}>{statusText}</Text></Box>
486
+ )}
487
+ </Box>
488
+ );
489
+ }
490
+
491
+ interface IngestViewProps {
492
+ onAction: (action: string) => void;
493
+ statusText: string;
494
+ }
495
+
496
+ export function IngestView({ statusText }: IngestViewProps): React.ReactElement {
497
+ return (
498
+ <Box flexDirection="column" paddingX={1}>
499
+ <Text color={COLORS.brand} bold>Git {'>'} Memory</Text>
500
+ <Text color={COLORS.border}>{separator()}</Text>
501
+ <Box flexDirection="column" marginTop={1}>
502
+ <Box><Text color={COLORS.text}> 1 Ingest latest commit</Text></Box>
503
+ <Box><Text color={COLORS.text}> 2 Batch ingest recent git log</Text></Box>
504
+ <Box><Text color={COLORS.text}> 3 Install post-commit hook</Text></Box>
505
+ <Box><Text color={COLORS.text}> 4 Uninstall post-commit hook</Text></Box>
506
+ <Box><Text color={COLORS.muted}> h Back to home</Text></Box>
507
+ </Box>
508
+ {statusText && (
509
+ <Box marginTop={1}><Text color={COLORS.muted}>{statusText}</Text></Box>
510
+ )}
511
+ </Box>
512
+ );
513
+ }
514
+
515
+ interface IntegrateViewProps {
516
+ statusText: string;
517
+ }
518
+
519
+ export function IntegrateView({ statusText }: IntegrateViewProps): React.ReactElement {
520
+ return (
521
+ <Box flexDirection="column" paddingX={1}>
522
+ <Text color={COLORS.brand} bold>Integrate IDE</Text>
523
+ <Text color={COLORS.border}>{separator()}</Text>
524
+ <Box flexDirection="column" marginTop={1}>
525
+ <Box><Text color={COLORS.text}> 1 Claude Code</Text></Box>
526
+ <Box><Text color={COLORS.text}> 2 Windsurf</Text></Box>
527
+ <Box><Text color={COLORS.text}> 3 Cursor</Text></Box>
528
+ <Box><Text color={COLORS.text}> 4 GitHub Copilot</Text></Box>
529
+ <Box><Text color={COLORS.text}> 5 Kiro</Text></Box>
530
+ <Box><Text color={COLORS.text}> 6 Codex</Text></Box>
531
+ <Box><Text color={COLORS.text}> 7 Antigravity</Text></Box>
532
+ <Box><Text color={COLORS.text}> 8 OpenCode</Text></Box>
533
+ <Box><Text color={COLORS.text}> 9 Trae</Text></Box>
534
+ <Box><Text color={COLORS.text}> 0 Gemini CLI</Text></Box>
535
+ <Box><Text color={COLORS.muted}> h Back to home</Text></Box>
536
+ </Box>
537
+ <Box marginTop={1}>
538
+ <Text color={COLORS.textDim}>Installs only for the current project.</Text>
539
+ </Box>
540
+ {statusText && (
541
+ <Box marginTop={1}><Text color={COLORS.muted}>{statusText}</Text></Box>
542
+ )}
543
+ </Box>
544
+ );
545
+ }
546
+
547
+ interface WikiViewProps {
548
+ knowledge: ProjectKnowledgeOverview | null;
549
+ loading: boolean;
550
+ }
551
+
552
+ export function WikiView({ knowledge, loading }: WikiViewProps): React.ReactElement {
553
+ if (loading) {
554
+ return (
555
+ <Box flexDirection="column" paddingX={1}>
556
+ <Text color={COLORS.brand} bold>Knowledge Base</Text>
557
+ <Text color={COLORS.muted}> LLM Wiki</Text>
558
+ <Text color={COLORS.border}>{separator()}</Text>
559
+ <Text color={COLORS.muted}>Loading...</Text>
560
+ </Box>
561
+ );
562
+ }
563
+
564
+ if (!knowledge) {
565
+ return (
566
+ <Box flexDirection="column" paddingX={1}>
567
+ <Text color={COLORS.brand} bold>Knowledge Base</Text>
568
+ <Text color={COLORS.muted}> LLM Wiki</Text>
569
+ <Text color={COLORS.border}>{separator()}</Text>
570
+ <Text color={COLORS.warning}>No knowledge available for this project.</Text>
571
+ <Text color={COLORS.textDim}>Store memories with /remember or /chat to build your Knowledge Base.</Text>
572
+ </Box>
573
+ );
574
+ }
575
+
576
+ return (
577
+ <Box flexDirection="column" paddingX={1}>
578
+ <Text color={COLORS.brand} bold>Knowledge Base</Text>
579
+ <Text color={COLORS.muted}> LLM Wiki</Text>
580
+ <Box>
581
+ <Text color={COLORS.textDim}> Project: {knowledge.projectId}</Text>
582
+ <Text color={COLORS.muted}> │ {knowledge.stats.observationsUsed} obs, {knowledge.stats.miniSkillsUsed} skills</Text>
583
+ </Box>
584
+ <Text color={COLORS.border}>{separator()}</Text>
585
+
586
+ {knowledge.sections.map((section) => (
587
+ <Box key={section.id} flexDirection="column" marginBottom={1}>
588
+ <Text color={COLORS.brandDim} bold>{section.title}</Text>
589
+ {section.empty ? (
590
+ <Text color={COLORS.textDim}> (empty)</Text>
591
+ ) : (
592
+ section.items.map((item, idx) => (
593
+ <Box key={idx} flexDirection="column">
594
+ <Box>
595
+ <Text color={COLORS.muted}>{SYMBOLS.bullet} </Text>
596
+ <Text color={COLORS.text}>{truncate(item.title)}</Text>
597
+ {item.entityName && <Text color={COLORS.textDim}> [{item.entityName}]</Text>}
598
+ </Box>
599
+ <Text color={COLORS.textDim}> {truncate(item.summary, 80)}</Text>
600
+ <Text color={COLORS.muted}> refs: {item.refs.map((r) => r.id).join(', ')}</Text>
601
+ </Box>
602
+ ))
603
+ )}
604
+ </Box>
605
+ ))}
606
+
607
+ <Box marginTop={1}>
608
+ <Text color={COLORS.muted}>{SYMBOLS.arrow} Esc to return home</Text>
609
+ </Box>
610
+ </Box>
611
+ );
612
+ }
613
+
614
+ interface StatusMessageProps {
615
+ message: string;
616
+ type: 'success' | 'error' | 'info';
617
+ }
618
+
619
+ export function StatusMessage({ message, type }: StatusMessageProps): React.ReactElement {
620
+ const color = type === 'success' ? COLORS.success : type === 'error' ? COLORS.error : COLORS.muted;
621
+ const icon = type === 'success' ? SYMBOLS.check : type === 'error' ? SYMBOLS.cross : SYMBOLS.info;
622
+ const lines = message.split('\n');
623
+ return (
624
+ <Box paddingX={1} flexDirection="column">
625
+ {lines.map((line, index) => (
626
+ <Text key={index} color={color} wrap="truncate-end">
627
+ {index === 0 ? `${icon} ${line}` : ` ${line}`}
628
+ </Text>
629
+ ))}
630
+ </Box>
631
+ );
632
+ }