@chude/memory 4.0.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 (184) hide show
  1. package/README.md +294 -0
  2. package/dist/application/index.d.ts +6 -0
  3. package/dist/application/services/ambient-context-service.d.ts +90 -0
  4. package/dist/application/services/backfill-service.d.ts +71 -0
  5. package/dist/application/services/budget-allocator.d.ts +57 -0
  6. package/dist/application/services/embedding-service.d.ts +131 -0
  7. package/dist/application/services/export-service.d.ts +225 -0
  8. package/dist/application/services/extraction-pipeline.d.ts +50 -0
  9. package/dist/application/services/friction-service.d.ts +148 -0
  10. package/dist/application/services/fts-sanitizer.d.ts +25 -0
  11. package/dist/application/services/index.d.ts +34 -0
  12. package/dist/application/services/llm-extractor.d.ts +96 -0
  13. package/dist/application/services/memory-file-sync-service.d.ts +58 -0
  14. package/dist/application/services/pattern-extractor.d.ts +95 -0
  15. package/dist/application/services/recovery-service.d.ts +81 -0
  16. package/dist/application/services/rrf-fusion.d.ts +53 -0
  17. package/dist/application/services/smart-context-service.d.ts +126 -0
  18. package/dist/application/services/sync-service.d.ts +157 -0
  19. package/dist/application/services/temporal-decay.d.ts +62 -0
  20. package/dist/domain/entities/backfill-state.d.ts +56 -0
  21. package/dist/domain/entities/entity.d.ts +131 -0
  22. package/dist/domain/entities/extraction-state.d.ts +128 -0
  23. package/dist/domain/entities/fact.d.ts +59 -0
  24. package/dist/domain/entities/friction-entry.d.ts +84 -0
  25. package/dist/domain/entities/index.d.ts +15 -0
  26. package/dist/domain/entities/link.d.ts +74 -0
  27. package/dist/domain/entities/memory-file.d.ts +78 -0
  28. package/dist/domain/entities/message.d.ts +70 -0
  29. package/dist/domain/entities/session.d.ts +93 -0
  30. package/dist/domain/entities/tool-use.d.ts +85 -0
  31. package/dist/domain/errors/error-codes.d.ts +37 -0
  32. package/dist/domain/errors/index.d.ts +8 -0
  33. package/dist/domain/errors/memory-error.d.ts +52 -0
  34. package/dist/domain/errors/unknown-error.d.ts +9 -0
  35. package/dist/domain/index.d.ts +11 -0
  36. package/dist/domain/ports/embedding.d.ts +96 -0
  37. package/dist/domain/ports/extraction.d.ts +13 -0
  38. package/dist/domain/ports/index.d.ts +14 -0
  39. package/dist/domain/ports/redactor.d.ts +17 -0
  40. package/dist/domain/ports/repositories.d.ts +658 -0
  41. package/dist/domain/ports/services.d.ts +180 -0
  42. package/dist/domain/ports/signals.d.ts +82 -0
  43. package/dist/domain/ports/sources.d.ts +122 -0
  44. package/dist/domain/ports/types.d.ts +150 -0
  45. package/dist/domain/services/content-extractor.d.ts +61 -0
  46. package/dist/domain/services/index.d.ts +8 -0
  47. package/dist/domain/services/path-decoder.d.ts +56 -0
  48. package/dist/domain/services/query-parser.d.ts +47 -0
  49. package/dist/domain/value-objects/embedding-config.d.ts +56 -0
  50. package/dist/domain/value-objects/embedding-result.d.ts +46 -0
  51. package/dist/domain/value-objects/index.d.ts +10 -0
  52. package/dist/domain/value-objects/project-path.d.ts +92 -0
  53. package/dist/domain/value-objects/search-query.d.ts +30 -0
  54. package/dist/domain/value-objects/search-result.d.ts +92 -0
  55. package/dist/index.d.ts +15 -0
  56. package/dist/index.js +1548 -0
  57. package/dist/infrastructure/database/connection.d.ts +161 -0
  58. package/dist/infrastructure/database/event-log.d.ts +22 -0
  59. package/dist/infrastructure/database/health-checker.d.ts +248 -0
  60. package/dist/infrastructure/database/index.d.ts +11 -0
  61. package/dist/infrastructure/database/repositories/backfill-state-repository.d.ts +19 -0
  62. package/dist/infrastructure/database/repositories/embedding-repository.d.ts +121 -0
  63. package/dist/infrastructure/database/repositories/entity-repository.d.ts +73 -0
  64. package/dist/infrastructure/database/repositories/extraction-log-repository.d.ts +17 -0
  65. package/dist/infrastructure/database/repositories/extraction-state-repository.d.ts +52 -0
  66. package/dist/infrastructure/database/repositories/fact-repository.d.ts +25 -0
  67. package/dist/infrastructure/database/repositories/friction-repository.d.ts +41 -0
  68. package/dist/infrastructure/database/repositories/index.d.ts +17 -0
  69. package/dist/infrastructure/database/repositories/link-repository.d.ts +64 -0
  70. package/dist/infrastructure/database/repositories/memory-file-repository.d.ts +28 -0
  71. package/dist/infrastructure/database/repositories/message-repository.d.ts +87 -0
  72. package/dist/infrastructure/database/repositories/session-repository.d.ts +125 -0
  73. package/dist/infrastructure/database/repositories/tool-use-repository.d.ts +72 -0
  74. package/dist/infrastructure/database/schema.d.ts +203 -0
  75. package/dist/infrastructure/database/services/context-service.d.ts +93 -0
  76. package/dist/infrastructure/database/services/hybrid-search-service.d.ts +156 -0
  77. package/dist/infrastructure/database/services/index.d.ts +10 -0
  78. package/dist/infrastructure/database/services/search-service.d.ts +57 -0
  79. package/dist/infrastructure/database/services/stats-service.d.ts +36 -0
  80. package/dist/infrastructure/embedding/background-embedder.d.ts +125 -0
  81. package/dist/infrastructure/embedding/embedding-provider-factory.d.ts +44 -0
  82. package/dist/infrastructure/embedding/index.d.ts +5 -0
  83. package/dist/infrastructure/embedding/ollama-provider.d.ts +41 -0
  84. package/dist/infrastructure/embedding/openai-provider.d.ts +38 -0
  85. package/dist/infrastructure/embedding/transformers-js-provider.d.ts +34 -0
  86. package/dist/infrastructure/external/index.d.ts +7 -0
  87. package/dist/infrastructure/external/qmd-runner.d.ts +36 -0
  88. package/dist/infrastructure/hooks/auto-memory-writer.d.ts +52 -0
  89. package/dist/infrastructure/hooks/config-manager.d.ts +237 -0
  90. package/dist/infrastructure/hooks/git-syncer.d.ts +44 -0
  91. package/dist/infrastructure/hooks/hook-runner.d.ts +126 -0
  92. package/dist/infrastructure/hooks/index.d.ts +12 -0
  93. package/dist/infrastructure/hooks/log-writer.d.ts +106 -0
  94. package/dist/infrastructure/hooks/settings-manager.d.ts +163 -0
  95. package/dist/infrastructure/hooks/sync-hook-script.d.ts +83 -0
  96. package/dist/infrastructure/hooks/sync-logger-adapter.d.ts +17 -0
  97. package/dist/infrastructure/index.d.ts +11 -0
  98. package/dist/infrastructure/llm/anthropic-extractor.d.ts +20 -0
  99. package/dist/infrastructure/llm/claude-cli-extractor.d.ts +14 -0
  100. package/dist/infrastructure/llm/claude-summary-generator.d.ts +14 -0
  101. package/dist/infrastructure/llm/extraction-helper.d.ts +16 -0
  102. package/dist/infrastructure/llm/ollama-extractor.d.ts +20 -0
  103. package/dist/infrastructure/llm/openai-extractor.d.ts +23 -0
  104. package/dist/infrastructure/migration.d.ts +103 -0
  105. package/dist/infrastructure/parsers/event-classifier.d.ts +111 -0
  106. package/dist/infrastructure/parsers/index.d.ts +8 -0
  107. package/dist/infrastructure/parsers/jsonl-parser.d.ts +25 -0
  108. package/dist/infrastructure/parsers/timestamp.d.ts +18 -0
  109. package/dist/infrastructure/paths.d.ts +129 -0
  110. package/dist/infrastructure/providers/provider-defaults.d.ts +11 -0
  111. package/dist/infrastructure/providers/provider-registry.d.ts +28 -0
  112. package/dist/infrastructure/security/pattern-redactor.d.ts +6 -0
  113. package/dist/infrastructure/signals/adapters.d.ts +27 -0
  114. package/dist/infrastructure/signals/checkpoint-manager.d.ts +83 -0
  115. package/dist/infrastructure/signals/index.d.ts +8 -0
  116. package/dist/infrastructure/signals/signal-handler.d.ts +113 -0
  117. package/dist/infrastructure/sources/index.d.ts +8 -0
  118. package/dist/infrastructure/sources/memory-file-scanner.d.ts +23 -0
  119. package/dist/infrastructure/sources/project-name-resolver.d.ts +67 -0
  120. package/dist/infrastructure/sources/session-source.d.ts +70 -0
  121. package/dist/presentation/cli/command-result.d.ts +10 -0
  122. package/dist/presentation/cli/commands/_helpers/capture-json.d.ts +36 -0
  123. package/dist/presentation/cli/commands/_helpers/deprecation-warning.d.ts +41 -0
  124. package/dist/presentation/cli/commands/backfill.d.ts +56 -0
  125. package/dist/presentation/cli/commands/browse.d.ts +55 -0
  126. package/dist/presentation/cli/commands/completion.d.ts +61 -0
  127. package/dist/presentation/cli/commands/context.d.ts +53 -0
  128. package/dist/presentation/cli/commands/doctor.d.ts +55 -0
  129. package/dist/presentation/cli/commands/export.d.ts +36 -0
  130. package/dist/presentation/cli/commands/extract.d.ts +40 -0
  131. package/dist/presentation/cli/commands/facts.d.ts +17 -0
  132. package/dist/presentation/cli/commands/friction/dashboard.d.ts +18 -0
  133. package/dist/presentation/cli/commands/friction/index.d.ts +12 -0
  134. package/dist/presentation/cli/commands/friction/list.d.ts +12 -0
  135. package/dist/presentation/cli/commands/friction/log.d.ts +12 -0
  136. package/dist/presentation/cli/commands/friction/purge.d.ts +12 -0
  137. package/dist/presentation/cli/commands/friction/resolve.d.ts +12 -0
  138. package/dist/presentation/cli/commands/friction/types.d.ts +86 -0
  139. package/dist/presentation/cli/commands/friction/wontfix.d.ts +12 -0
  140. package/dist/presentation/cli/commands/import.d.ts +38 -0
  141. package/dist/presentation/cli/commands/index.d.ts +51 -0
  142. package/dist/presentation/cli/commands/install.d.ts +67 -0
  143. package/dist/presentation/cli/commands/list.d.ts +61 -0
  144. package/dist/presentation/cli/commands/migrate.d.ts +36 -0
  145. package/dist/presentation/cli/commands/purge.d.ts +100 -0
  146. package/dist/presentation/cli/commands/query.d.ts +51 -0
  147. package/dist/presentation/cli/commands/related.d.ts +47 -0
  148. package/dist/presentation/cli/commands/remote.d.ts +36 -0
  149. package/dist/presentation/cli/commands/search.d.ts +100 -0
  150. package/dist/presentation/cli/commands/show.d.ts +51 -0
  151. package/dist/presentation/cli/commands/stats.d.ts +38 -0
  152. package/dist/presentation/cli/commands/status.d.ts +152 -0
  153. package/dist/presentation/cli/commands/sync/ambient.d.ts +22 -0
  154. package/dist/presentation/cli/commands/sync/background.d.ts +23 -0
  155. package/dist/presentation/cli/commands/sync/embedding-pass.d.ts +32 -0
  156. package/dist/presentation/cli/commands/sync/helpers.d.ts +25 -0
  157. package/dist/presentation/cli/commands/sync/index.d.ts +17 -0
  158. package/dist/presentation/cli/commands/sync/memory-files.d.ts +26 -0
  159. package/dist/presentation/cli/commands/sync/types.d.ts +163 -0
  160. package/dist/presentation/cli/commands/uninstall.d.ts +44 -0
  161. package/dist/presentation/cli/db-startup.d.ts +61 -0
  162. package/dist/presentation/cli/formatters/ai-formatter.d.ts +38 -0
  163. package/dist/presentation/cli/formatters/color.d.ts +82 -0
  164. package/dist/presentation/cli/formatters/context-formatter.d.ts +55 -0
  165. package/dist/presentation/cli/formatters/dto-helpers.d.ts +176 -0
  166. package/dist/presentation/cli/formatters/envelope.d.ts +136 -0
  167. package/dist/presentation/cli/formatters/error-formatter.d.ts +41 -0
  168. package/dist/presentation/cli/formatters/friction-dashboard.d.ts +46 -0
  169. package/dist/presentation/cli/formatters/index.d.ts +17 -0
  170. package/dist/presentation/cli/formatters/list-formatter.d.ts +48 -0
  171. package/dist/presentation/cli/formatters/output-formatter.d.ts +98 -0
  172. package/dist/presentation/cli/formatters/related-formatter.d.ts +57 -0
  173. package/dist/presentation/cli/formatters/show-formatter.d.ts +63 -0
  174. package/dist/presentation/cli/formatters/stats-formatter.d.ts +54 -0
  175. package/dist/presentation/cli/formatters/text-width.d.ts +37 -0
  176. package/dist/presentation/cli/formatters/timestamp-formatter.d.ts +38 -0
  177. package/dist/presentation/cli/index.d.ts +10 -0
  178. package/dist/presentation/cli/index.js +1664 -0
  179. package/dist/presentation/cli/parsers/date-parser.d.ts +28 -0
  180. package/dist/presentation/cli/parsers/index.d.ts +6 -0
  181. package/dist/presentation/cli/pickers/index.d.ts +6 -0
  182. package/dist/presentation/cli/pickers/session-picker.d.ts +59 -0
  183. package/dist/presentation/cli/progress-reporter.d.ts +199 -0
  184. package/package.json +94 -0
@@ -0,0 +1,17 @@
1
+ /**
2
+ * CLI Formatters Barrel Export
3
+ *
4
+ * Output formatting utilities for CLI commands.
5
+ */
6
+ export { formatTimestamp, formatRelativeTime, formatAbsoluteTime, } from "./timestamp-formatter.js";
7
+ export { shouldUseColor, bold, dim, green, red, yellow, type ColorOptions, } from "./color.js";
8
+ export { createOutputFormatter, CONTEXT_BUDGET, type OutputMode, type FormatOptions, type ExecutionDetails, type SummaryStats, type OutputFormatter, } from "./output-formatter.js";
9
+ export { createListFormatter, type ListOutputMode, type ListFormatOptions, type ListFormatter, } from "./list-formatter.js";
10
+ export { createStatsFormatter, type StatsOutputMode, type StatsFormatOptions, type StatsFormatter, } from "./stats-formatter.js";
11
+ export { createContextFormatter, type ContextOutputMode, type ContextFormatOptions, type ContextFormatter, } from "./context-formatter.js";
12
+ export { createRelatedFormatter, type RelatedOutputMode, type RelatedFormatOptions, type RelatedFormatter, type RelatedSession, } from "./related-formatter.js";
13
+ export { createShowFormatter, summarizeToolResult, type ShowOutputMode, type SessionDetail, type ShowFormatOptions, type ShowFormatter, } from "./show-formatter.js";
14
+ export { formatError, formatErrorJson, getSuggestion, type ErrorFormatOptions, } from "./error-formatter.js";
15
+ export { formatFrictionDashboard, generateFrictionHtml, } from "./friction-dashboard.js";
16
+ export { stripAnsi, estimateTokens, formatForAi, } from "./ai-formatter.js";
17
+ export { ENVELOPE_SCHEMA_VERSION, QUERY_COMMAND_NAMES, QUERY_RESULT_KINDS, buildEnvelope, buildErrorEnvelope, emitJsonEnvelope, emitJsonErrorEnvelope, type QueryCommandName, type QueryResultKind, type EnvelopeScope, type QueryResultEnvelope, type QueryErrorEnvelope, } from "./envelope.js";
@@ -0,0 +1,48 @@
1
+ /**
2
+ * List Formatter
3
+ *
4
+ * Strategy pattern for formatting session list results.
5
+ * Supports default, JSON, quiet, and verbose output modes.
6
+ */
7
+ import type { Session } from "../../../domain/entities/session.js";
8
+ /**
9
+ * Output mode for list formatter.
10
+ *
11
+ * Phase 32 (CLI-03) extension: `brief` produces single-line-per-session
12
+ * output for AI/script consumption. See {@link BriefListFormatter}.
13
+ */
14
+ export type ListOutputMode = "default" | "json" | "quiet" | "verbose" | "brief";
15
+ /**
16
+ * Options for formatting session list.
17
+ */
18
+ export interface ListFormatOptions {
19
+ /** Execution time in milliseconds */
20
+ executionTimeMs?: number;
21
+ /** List of filters that were applied */
22
+ filtersApplied?: string[];
23
+ }
24
+ /**
25
+ * List formatter interface.
26
+ */
27
+ export interface ListFormatter {
28
+ /**
29
+ * Format sessions for display.
30
+ */
31
+ formatSessions(sessions: Session[], options?: ListFormatOptions): string;
32
+ /**
33
+ * Format an error message.
34
+ */
35
+ formatError(error: Error): string;
36
+ /**
37
+ * Format empty result message.
38
+ */
39
+ formatEmpty(): string;
40
+ }
41
+ /**
42
+ * Create a list formatter for the given mode.
43
+ *
44
+ * @param mode Output mode
45
+ * @param useColor Whether to use ANSI colors
46
+ * @returns ListFormatter instance
47
+ */
48
+ export declare function createListFormatter(mode: ListOutputMode, useColor: boolean): ListFormatter;
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Output Formatter
3
+ *
4
+ * Strategy pattern for formatting search results.
5
+ * Supports default, JSON, quiet, and verbose output modes.
6
+ * JSON mode supports hybrid search metadata envelope (additive, backward-compatible).
7
+ */
8
+ import type { SearchResult } from "../../../domain/value-objects/search-result.js";
9
+ /**
10
+ * Context budget for Claude consumption (50K characters).
11
+ */
12
+ export declare const CONTEXT_BUDGET = 50000;
13
+ /**
14
+ * Output mode enum.
15
+ *
16
+ * Phase 32 (CLI-03) extension: `brief` produces single-line-per-record
17
+ * output for AI/script consumption. See {@link BriefOutputFormatter}.
18
+ */
19
+ export type OutputMode = "default" | "json" | "quiet" | "verbose" | "brief";
20
+ /**
21
+ * Execution details for verbose mode.
22
+ */
23
+ export interface ExecutionDetails {
24
+ timeMs?: number;
25
+ ftsQuery?: string;
26
+ filtersApplied?: string[];
27
+ }
28
+ /**
29
+ * Hybrid search metadata for output formatting.
30
+ * Re-exported from HybridSearchService for formatter consumption.
31
+ */
32
+ export interface SearchMetaInfo {
33
+ /** The effective search mode used */
34
+ mode: string;
35
+ /** Reason for the mode selection */
36
+ modeReason: string;
37
+ /** Whether the search degraded from requested mode */
38
+ degraded: boolean;
39
+ /** Reason for degradation, if any */
40
+ degradationReason?: string | undefined;
41
+ /** Fraction of messages with embeddings (0-1) */
42
+ embeddingCoverage: number;
43
+ /** System capabilities for this search */
44
+ capabilities: {
45
+ fts: boolean;
46
+ vector: boolean;
47
+ hybrid: boolean;
48
+ };
49
+ /** Total search time in milliseconds */
50
+ timingMs: number;
51
+ }
52
+ /**
53
+ * Options for formatting results.
54
+ */
55
+ export interface FormatOptions {
56
+ query?: string | undefined;
57
+ executionDetails?: ExecutionDetails | undefined;
58
+ contextBudget?: number | undefined;
59
+ /** Hybrid search metadata (additive: when absent, output is backward-compatible) */
60
+ searchMeta?: SearchMetaInfo | undefined;
61
+ }
62
+ /**
63
+ * Summary statistics.
64
+ */
65
+ export interface SummaryStats {
66
+ found: number;
67
+ shown: number;
68
+ truncated?: boolean;
69
+ }
70
+ /**
71
+ * Output formatter interface.
72
+ */
73
+ export interface OutputFormatter {
74
+ formatResults(results: SearchResult[], options?: FormatOptions): string;
75
+ formatError(error: Error): string;
76
+ formatSummary(stats: SummaryStats): string;
77
+ }
78
+ /**
79
+ * Create an output formatter for the given mode.
80
+ *
81
+ * @param mode Output mode
82
+ * @param useColor Whether to use ANSI colors
83
+ * @returns OutputFormatter instance
84
+ */
85
+ export declare function createOutputFormatter(mode: OutputMode, useColor: boolean): OutputFormatter;
86
+ /**
87
+ * Extract highlight positions from a snippet containing <mark> tags.
88
+ *
89
+ * Parses <mark>...</mark> tags and returns offset/length pairs
90
+ * relative to the clean (tag-free) text.
91
+ *
92
+ * @param snippet Raw snippet with <mark> tags
93
+ * @returns Array of { offset, length } highlight positions
94
+ */
95
+ export declare function extractHighlights(snippet: string): Array<{
96
+ offset: number;
97
+ length: number;
98
+ }>;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Related Formatter
3
+ *
4
+ * Strategy pattern for formatting related sessions output.
5
+ * Supports default, brief, detailed, JSON, quiet, and verbose output modes.
6
+ */
7
+ import type { Session } from "../../../domain/entities/session.js";
8
+ /**
9
+ * Output mode for related formatter.
10
+ */
11
+ export type RelatedOutputMode = "default" | "json" | "brief" | "detailed" | "quiet" | "verbose";
12
+ /**
13
+ * A session with its relationship weight and hop count.
14
+ */
15
+ export interface RelatedSession {
16
+ session: Session;
17
+ weight: number;
18
+ hops: number;
19
+ }
20
+ /**
21
+ * Options for formatting related sessions.
22
+ */
23
+ export interface RelatedFormatOptions {
24
+ /** The source ID used for the query */
25
+ sourceId: string;
26
+ /** Execution time in milliseconds */
27
+ executionTimeMs?: number;
28
+ }
29
+ /**
30
+ * Related formatter interface.
31
+ */
32
+ export interface RelatedFormatter {
33
+ /**
34
+ * Format related sessions for display.
35
+ */
36
+ formatRelated(sessions: RelatedSession[], options?: RelatedFormatOptions): string;
37
+ /**
38
+ * Format an error message.
39
+ */
40
+ formatError(error: Error): string;
41
+ /**
42
+ * Format empty result message (no relationships found for ID).
43
+ */
44
+ formatEmpty(sourceId: string): string;
45
+ /**
46
+ * Format message when links table is empty.
47
+ */
48
+ formatNoLinks(): string;
49
+ }
50
+ /**
51
+ * Create a related formatter for the given mode.
52
+ *
53
+ * @param mode Output mode
54
+ * @param useColor Whether to use ANSI colors
55
+ * @returns RelatedFormatter instance
56
+ */
57
+ export declare function createRelatedFormatter(mode: RelatedOutputMode, useColor: boolean): RelatedFormatter;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Show Formatter
3
+ *
4
+ * Strategy pattern for formatting session detail with conversation thread display.
5
+ * Supports default, JSON, quiet, verbose, and tools output modes.
6
+ */
7
+ import type { Session } from "../../../domain/entities/session.js";
8
+ import type { Message } from "../../../domain/entities/message.js";
9
+ import type { ToolUse } from "../../../domain/entities/tool-use.js";
10
+ /**
11
+ * Output mode for show formatter.
12
+ *
13
+ * Phase 32 (CLI-03) extension: `brief` produces single-line session
14
+ * header for AI/script consumption. See {@link BriefShowFormatter}.
15
+ */
16
+ export type ShowOutputMode = "default" | "json" | "quiet" | "verbose" | "tools" | "brief";
17
+ /**
18
+ * Session detail containing session, messages, and tool uses.
19
+ */
20
+ export interface SessionDetail {
21
+ session: Session;
22
+ messages: Message[];
23
+ toolUses: Map<string, ToolUse>;
24
+ }
25
+ /**
26
+ * Options for formatting session detail.
27
+ */
28
+ export interface ShowFormatOptions {
29
+ /** Execution time in milliseconds */
30
+ executionTimeMs?: number;
31
+ }
32
+ /**
33
+ * Show formatter interface.
34
+ */
35
+ export interface ShowFormatter {
36
+ /**
37
+ * Format session detail for display.
38
+ */
39
+ formatSession(detail: SessionDetail, options?: ShowFormatOptions): string;
40
+ /**
41
+ * Format an error message.
42
+ */
43
+ formatError(error: Error): string;
44
+ /**
45
+ * Format session not found message.
46
+ */
47
+ formatNotFound(sessionId: string): string;
48
+ }
49
+ /**
50
+ * Create a show formatter for the given mode.
51
+ *
52
+ * @param mode Output mode
53
+ * @param useColor Whether to use ANSI colors
54
+ * @returns ShowFormatter instance
55
+ */
56
+ export declare function createShowFormatter(mode: ShowOutputMode, useColor: boolean): ShowFormatter;
57
+ /**
58
+ * Summarize a tool result for inline display.
59
+ *
60
+ * @param tool Tool use to summarize
61
+ * @returns Brief summary string
62
+ */
63
+ export declare function summarizeToolResult(tool: ToolUse): string;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Stats Formatter
3
+ *
4
+ * Strategy pattern for formatting stats results.
5
+ * Supports default, JSON, quiet, and verbose output modes.
6
+ */
7
+ import type { StatsResult } from "../../../domain/ports/services.js";
8
+ /**
9
+ * Output mode for stats formatting.
10
+ *
11
+ * Phase 32 (CLI-03) extension: `brief` produces top-line counters only,
12
+ * bounded to <=5 lines (W5 / Pitfall 4 Option A). See
13
+ * {@link BriefStatsFormatter}.
14
+ */
15
+ export type StatsOutputMode = "default" | "json" | "quiet" | "verbose" | "brief";
16
+ /**
17
+ * Hook status summary for stats display.
18
+ */
19
+ export interface HooksSummary {
20
+ /** Hooks are installed in Claude Code */
21
+ installed: boolean;
22
+ /** Auto-sync is enabled in config */
23
+ autoSync: boolean;
24
+ /** Number of sessions not yet synced */
25
+ pendingSessions: number;
26
+ }
27
+ /**
28
+ * Extended stats result with optional hook summary.
29
+ */
30
+ export interface ExtendedStatsResult extends StatsResult {
31
+ hooks?: HooksSummary;
32
+ }
33
+ /**
34
+ * Options for formatting stats.
35
+ */
36
+ export interface StatsFormatOptions {
37
+ executionTimeMs?: number;
38
+ }
39
+ /**
40
+ * Stats formatter interface.
41
+ */
42
+ export interface StatsFormatter {
43
+ formatStats(stats: ExtendedStatsResult, options?: StatsFormatOptions): string;
44
+ formatError(error: Error): string;
45
+ formatEmpty(): string;
46
+ }
47
+ /**
48
+ * Create a stats formatter for the given mode.
49
+ *
50
+ * @param mode Output mode
51
+ * @param useColor Whether to use ANSI colors
52
+ * @returns StatsFormatter instance
53
+ */
54
+ export declare function createStatsFormatter(mode: StatsOutputMode, useColor: boolean): StatsFormatter;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Text Width Utilities
3
+ *
4
+ * Width-aware string measurement, truncation, and padding.
5
+ * Uses string-width for accurate display width calculation that accounts
6
+ * for CJK double-width characters, emoji, and ANSI escape codes.
7
+ */
8
+ /**
9
+ * Measure the visual display width of a string.
10
+ * Accounts for CJK double-width characters, emoji, and ANSI escape codes.
11
+ */
12
+ export declare function measureWidth(text: string): number;
13
+ /**
14
+ * Truncate a string to fit within a maximum visual width.
15
+ * Appends "..." if truncation occurs. Returns original string if it fits.
16
+ */
17
+ export declare function truncateToWidth(text: string, maxWidth: number): string;
18
+ /**
19
+ * Pad a string with spaces to reach a target visual width.
20
+ * If the string is already at or beyond the target, return it unchanged.
21
+ */
22
+ export declare function padToWidth(text: string, targetWidth: number): string;
23
+ /**
24
+ * Get the current terminal width, falling back to 80 columns.
25
+ * Returns 80 in non-TTY environments (piped output, CI).
26
+ */
27
+ export declare function getTerminalWidth(): number;
28
+ /**
29
+ * Truncate text to fit within the terminal width minus a prefix.
30
+ * Derives the available width from the actual prefix string to avoid
31
+ * coupling between indent characters and a hardcoded number.
32
+ *
33
+ * @param text The text to potentially truncate
34
+ * @param prefix The literal prefix string (e.g., " ") used to compute available width
35
+ * @param minWidth Minimum width to allow (prevents degenerate truncation on tiny terminals)
36
+ */
37
+ export declare function truncateForTerminal(text: string, prefix: string, minWidth?: number): string;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Timestamp Formatter
3
+ *
4
+ * Formats timestamps with both relative and absolute components.
5
+ * Uses Intl.RelativeTimeFormat for localized relative time display.
6
+ */
7
+ /**
8
+ * Format a date as relative time (e.g., "2 days ago", "yesterday").
9
+ *
10
+ * Automatically selects the appropriate unit:
11
+ * - < 1 hour: minutes
12
+ * - < 1 day: hours
13
+ * - < 1 week: days
14
+ * - < 1 month: weeks
15
+ * - >= 1 month: months
16
+ *
17
+ * @param date Date to format
18
+ * @param reference Reference date (defaults to now)
19
+ * @returns Relative time string
20
+ */
21
+ export declare function formatRelativeTime(date: Date, reference?: Date): string;
22
+ /**
23
+ * Format a date as absolute time (YYYY-MM-DD HH:mm).
24
+ *
25
+ * @param date Date to format
26
+ * @returns Absolute time string
27
+ */
28
+ export declare function formatAbsoluteTime(date: Date): string;
29
+ /**
30
+ * Format a timestamp with both relative and absolute components.
31
+ *
32
+ * Output format: "2 days ago (2026-01-27 14:30)"
33
+ *
34
+ * @param date Date to format
35
+ * @param reference Reference date for relative calculation (defaults to now)
36
+ * @returns Combined timestamp string
37
+ */
38
+ export declare function formatTimestamp(date: Date, reference?: Date): string;
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * Memory CLI Entry Point
4
+ *
5
+ * Cross-project context persistence for Claude Code sessions.
6
+ * Provides commands for syncing, searching, and retrieving session context.
7
+ */
8
+ import { Command } from "commander";
9
+ declare const program: Command;
10
+ export { program };