@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,12 @@
1
+ /**
2
+ * Friction List Handler
3
+ *
4
+ * Handles the friction list subcommand.
5
+ */
6
+ import type { CommandResult } from "../../command-result.js";
7
+ import type { FrictionExecuteOptions } from "./types.js";
8
+ import type { FrictionService } from "../../../../application/services/friction-service.js";
9
+ /**
10
+ * Handle the list action.
11
+ */
12
+ export declare function handleList(service: FrictionService, options: FrictionExecuteOptions): Promise<CommandResult>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Friction Log Handler
3
+ *
4
+ * Handles the friction log subcommand.
5
+ */
6
+ import type { CommandResult } from "../../command-result.js";
7
+ import type { FrictionExecuteOptions } from "./types.js";
8
+ import type { FrictionService } from "../../../../application/services/friction-service.js";
9
+ /**
10
+ * Handle the log action.
11
+ */
12
+ export declare function handleLog(service: FrictionService, options: FrictionExecuteOptions): Promise<CommandResult>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Friction Purge Handler
3
+ *
4
+ * Handles the friction purge subcommand.
5
+ */
6
+ import type { CommandResult } from "../../command-result.js";
7
+ import type { FrictionExecuteOptions } from "./types.js";
8
+ import type { FrictionService } from "../../../../application/services/friction-service.js";
9
+ /**
10
+ * Handle the purge action.
11
+ */
12
+ export declare function handlePurge(service: FrictionService, options: FrictionExecuteOptions): Promise<CommandResult>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Friction Resolve Handler
3
+ *
4
+ * Handles the friction resolve subcommand.
5
+ */
6
+ import type { CommandResult } from "../../command-result.js";
7
+ import type { FrictionExecuteOptions } from "./types.js";
8
+ import type { FrictionService } from "../../../../application/services/friction-service.js";
9
+ /**
10
+ * Handle the resolve action.
11
+ */
12
+ export declare function handleResolve(service: FrictionService, options: FrictionExecuteOptions): Promise<CommandResult>;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Friction Command Types
3
+ *
4
+ * Type definitions and interfaces for friction command handlers.
5
+ */
6
+ /**
7
+ * Function type for opening a file in the system browser.
8
+ */
9
+ export type BrowserOpener = (filePath: string) => void;
10
+ /**
11
+ * Runtime dependencies for executeFrictionCommand.
12
+ *
13
+ * Operational dependencies that tests substitute for isolation.
14
+ * Defaults to production resolution when omitted.
15
+ */
16
+ export interface FrictionCommandDeps {
17
+ /** Database path. Defaults to getDefaultDbPath(). */
18
+ dbPath?: string;
19
+ /** Browser opener for --html mode. Defaults to system default. */
20
+ openInBrowser?: BrowserOpener;
21
+ }
22
+ /**
23
+ * Base options shared by all friction subcommands.
24
+ */
25
+ export interface FrictionCommandOptions {
26
+ json?: boolean;
27
+ /** Output format: default or ai */
28
+ format?: "default" | "ai";
29
+ }
30
+ /**
31
+ * Options for the friction log subcommand.
32
+ */
33
+ export interface FrictionLogOptions extends FrictionCommandOptions {
34
+ severity?: string;
35
+ category?: string;
36
+ source?: string;
37
+ context?: string;
38
+ tool?: string;
39
+ }
40
+ /**
41
+ * Options for the friction list subcommand.
42
+ */
43
+ export interface FrictionListOptions extends FrictionCommandOptions {
44
+ all?: boolean;
45
+ status?: string;
46
+ category?: string;
47
+ tool?: string;
48
+ limit?: string;
49
+ }
50
+ /**
51
+ * Options for the friction resolve/wont-fix subcommands.
52
+ */
53
+ export interface FrictionResolveOptions extends FrictionCommandOptions {
54
+ resolution: string;
55
+ }
56
+ /**
57
+ * Options for the friction purge subcommand.
58
+ */
59
+ export interface FrictionPurgeOptions extends FrictionCommandOptions {
60
+ dryRun?: boolean;
61
+ force?: boolean;
62
+ }
63
+ /**
64
+ * Options passed to executeFrictionCommand.
65
+ */
66
+ export interface FrictionExecuteOptions {
67
+ action: "log" | "list" | "resolve" | "wont-fix" | "dashboard" | "purge";
68
+ description?: string;
69
+ pattern?: string;
70
+ id?: string;
71
+ json?: boolean;
72
+ /** Output format: default or ai */
73
+ format?: "default" | "ai";
74
+ severity?: string;
75
+ category?: string;
76
+ source?: string;
77
+ context?: string;
78
+ all?: boolean;
79
+ status?: string;
80
+ limit?: string;
81
+ resolution?: string;
82
+ tool?: string;
83
+ html?: boolean;
84
+ dryRun?: boolean;
85
+ force?: boolean;
86
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Friction Won't-Fix Handler
3
+ *
4
+ * Handles the friction wont-fix subcommand.
5
+ */
6
+ import type { CommandResult } from "../../command-result.js";
7
+ import type { FrictionExecuteOptions } from "./types.js";
8
+ import type { FrictionService } from "../../../../application/services/friction-service.js";
9
+ /**
10
+ * Handle the wont-fix action.
11
+ */
12
+ export declare function handleWontFix(service: FrictionService, options: FrictionExecuteOptions): Promise<CommandResult>;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Import Command Handler
3
+ *
4
+ * CLI command for importing database from a JSON backup file.
5
+ * Supports clear option, quiet mode, and JSON output for scripting.
6
+ */
7
+ import { Command } from "commander";
8
+ import type { CommandResult } from "../command-result.js";
9
+ /**
10
+ * Options for the import command.
11
+ */
12
+ export interface ImportOptions {
13
+ /** Clear existing data before import */
14
+ clear?: boolean;
15
+ /** Suppress output except errors */
16
+ quiet?: boolean;
17
+ /** Output stats as JSON */
18
+ json?: boolean;
19
+ /** Skip confirmation when merging with existing data */
20
+ force?: boolean;
21
+ }
22
+ /**
23
+ * Create the import command for Commander.js.
24
+ *
25
+ * @returns Configured Command instance
26
+ */
27
+ export declare function createImportCommand(): Command;
28
+ /**
29
+ * Execute the import command programmatically.
30
+ *
31
+ * Imports a previously exported JSON database file. Handles its own
32
+ * database initialization and teardown.
33
+ *
34
+ * @param inputFile - Source file path for the JSON backup
35
+ * @param options - Import command options
36
+ * @returns CommandResult with exitCode 0 (success) or 1 (file not found/error)
37
+ */
38
+ export declare function executeImportCommand(inputFile: string, options?: ImportOptions): Promise<CommandResult>;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * CLI Commands
3
+ *
4
+ * Command handlers for the memory CLI.
5
+ */
6
+ export type { CommandResult } from "../command-result.js";
7
+ export { createSyncCommand, executeSyncCommand } from "./sync/index.js";
8
+ export { createSearchCommand, executeSearchCommand } from "./search.js";
9
+ export { createListCommand, executeListCommand } from "./list.js";
10
+ export { createStatsCommand, executeStatsCommand } from "./stats.js";
11
+ export { createContextCommand, executeContextCommand } from "./context.js";
12
+ export { createRelatedCommand, executeRelatedCommand } from "./related.js";
13
+ export { createShowCommand, executeShowCommand } from "./show.js";
14
+ export { createBrowseCommand, executeBrowseCommand } from "./browse.js";
15
+ export { createQueryCommand, executeQueryCommand } from "./query.js";
16
+ export { createRemoteCommand, executeRemoteSetCommand, executeRemoteRemoveCommand, executeRemoteStatusCommand } from "./remote.js";
17
+ export { createInstallCommand, executeInstallCommand } from "./install.js";
18
+ export { createUninstallCommand, executeUninstallCommand } from "./uninstall.js";
19
+ export { createStatusCommand, executeStatusCommand } from "./status.js";
20
+ export { createDoctorCommand, executeDoctorCommand } from "./doctor.js";
21
+ export { createPurgeCommand, executePurgeCommand } from "./purge.js";
22
+ export { createMigrateCommand, executeMigrateCommand } from "./migrate.js";
23
+ export { createExportCommand, executeExportCommand } from "./export.js";
24
+ export { createImportCommand, executeImportCommand } from "./import.js";
25
+ export { createCompletionCommand, executeCompletionCommand } from "./completion.js";
26
+ export { createFrictionCommand, executeFrictionCommand } from "./friction/index.js";
27
+ export { createBackfillCommand, executeBackfillCommand } from "./backfill.js";
28
+ export { createExtractCommand, executeExtractCommand } from "./extract.js";
29
+ export { createFactsCommand, executeFactsCommand } from "./facts.js";
30
+ export type { SyncCommandOptions } from "./sync/index.js";
31
+ export type { EmbeddingPassDeps, BackgroundModeDeps } from "./sync/index.js";
32
+ export type { SearchCommandOptions } from "./search.js";
33
+ export type { ListCommandOptions } from "./list.js";
34
+ export type { StatsCommandOptions } from "./stats.js";
35
+ export type { ContextCommandOptions } from "./context.js";
36
+ export type { RelatedCommandOptions } from "./related.js";
37
+ export type { ShowCommandOptions } from "./show.js";
38
+ export type { QueryCommandOptions } from "./query.js";
39
+ export type { RemoteCommandOptions } from "./remote.js";
40
+ export type { BrowseCommandOptions } from "./browse.js";
41
+ export type { InstallOptions } from "./install.js";
42
+ export type { UninstallOptions } from "./uninstall.js";
43
+ export type { DoctorOptions } from "./doctor.js";
44
+ export type { PurgeCommandOptions, PurgeResult } from "./purge.js";
45
+ export type { ExportOptions } from "./export.js";
46
+ export type { ImportOptions } from "./import.js";
47
+ export type { ShellType } from "./completion.js";
48
+ export type { StatusOptions, StatusInfo, EmbeddingStatus, GatherStatusOptions } from "./status.js";
49
+ export type { FrictionCommandOptions, FrictionLogOptions, FrictionListOptions, FrictionResolveOptions, FrictionExecuteOptions, } from "./friction/index.js";
50
+ export type { BackfillCommandOptions, BackfillServiceDeps, } from "./backfill.js";
51
+ export type { MigrateCommandOptions } from "./migrate.js";
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Install Command Handler
3
+ *
4
+ * CLI command for installing Claude Code hooks.
5
+ * Copies hook script and modifies settings.json.
6
+ */
7
+ import { Command } from "commander";
8
+ import type { CommandResult } from "../command-result.js";
9
+ /**
10
+ * Options for the install command.
11
+ */
12
+ export interface InstallOptions {
13
+ /** Reinstall even if hooks are already installed */
14
+ force?: boolean;
15
+ }
16
+ /**
17
+ * Runtime dependencies for executeInstallCommand.
18
+ *
19
+ * Operational dependencies that tests substitute for isolation.
20
+ * Defaults to production resolution (multi-path candidate search) when omitted.
21
+ */
22
+ export interface InstallCommandDeps {
23
+ /**
24
+ * Override the hook script source path. When set, findHookScriptSource
25
+ * checks only this path. Used by tests to point at a fixture file.
26
+ */
27
+ hookScriptSourceOverride?: string;
28
+ /**
29
+ * Override settings/backup/hook-script paths used by settings-manager.
30
+ * When set, all settings-manager calls use these paths.
31
+ */
32
+ hookOverrides?: import("../../../infrastructure/hooks/settings-manager.js").PathOverrides;
33
+ }
34
+ /**
35
+ * Create the install command for Commander.js.
36
+ *
37
+ * @returns Configured Command instance
38
+ */
39
+ export declare function createInstallCommand(): Command;
40
+ /**
41
+ * Execute the install command programmatically.
42
+ *
43
+ * Installs Claude Code hooks for automatic session sync on session end.
44
+ * Copies the hook script and modifies settings.json. Idempotent: returns
45
+ * exitCode 0 if hooks are already installed. Handles its own setup.
46
+ *
47
+ * @param options - Install command options
48
+ * @returns CommandResult with exitCode 0 (success/already installed) or 1 (error)
49
+ */
50
+ export declare function executeInstallCommand(options: InstallOptions, deps?: InstallCommandDeps): Promise<CommandResult>;
51
+ /**
52
+ * Scan settings.json for stale memory-nexus hook references.
53
+ *
54
+ * After hook installation, checks if any hook commands still reference
55
+ * the old "memory-nexus" binary name. Prints a warning to stderr if found.
56
+ */
57
+ export declare function warnStaleHookReferences(overrides?: import("../../../infrastructure/hooks/settings-manager.js").PathOverrides): void;
58
+ /**
59
+ * Find the hook script source file.
60
+ *
61
+ * Checks common locations for the built hook script. When `override` is
62
+ * provided, checks only that path (used by tests to point at a fixture).
63
+ *
64
+ * @param override Optional explicit path to use instead of candidate search
65
+ * @returns Path to hook script or null if not found
66
+ */
67
+ export declare function findHookScriptSource(override?: string): string | null;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * List Command Handler
3
+ *
4
+ * CLI command for listing sessions with filtering.
5
+ * Supports project name filter and date range filters.
6
+ */
7
+ import { Command } from "commander";
8
+ import type { CommandResult } from "../command-result.js";
9
+ /**
10
+ * Options for the list command.
11
+ */
12
+ export interface ListCommandOptions {
13
+ /** Maximum sessions to return (as string, parsed to integer) */
14
+ limit?: string;
15
+ /** Filter by project name */
16
+ project?: string;
17
+ /** Sessions after date (e.g., 'yesterday', '2 weeks ago') */
18
+ since?: string;
19
+ /** Sessions before date */
20
+ before?: string;
21
+ /** Sessions from last N days (includes today) */
22
+ days?: number;
23
+ /** Output as JSON */
24
+ json?: boolean;
25
+ /** Show detailed output */
26
+ verbose?: boolean;
27
+ /** Minimal output (session IDs only) */
28
+ quiet?: boolean;
29
+ /**
30
+ * Output format. Phase 32 (CLI-03) normalized choices: `brief`,
31
+ * `ai`. `default` retained as deprecated alias (one-minor cadence;
32
+ * CHANGELOG documents removal). Undefined = no-flag default
33
+ * (backward compatible).
34
+ */
35
+ format?: "brief" | "ai" | "default";
36
+ }
37
+ /**
38
+ * Runtime dependencies for executeListCommand.
39
+ *
40
+ * Separated from ListCommandOptions because these are not user-facing
41
+ * CLI flags — they are operational dependencies that tests substitute
42
+ * to achieve isolation. Defaults to production resolution
43
+ * (getDefaultDbPath()) when omitted.
44
+ *
45
+ * Parity with executeShowCommand (added Plan 32-02 per Codex HIGH-3).
46
+ */
47
+ export interface ListCommandDeps {
48
+ /** Database path. Defaults to getDefaultDbPath(). */
49
+ dbPath?: string;
50
+ }
51
+ /**
52
+ * Create the list command for Commander.js.
53
+ *
54
+ * @returns Configured Command instance
55
+ */
56
+ export declare function createListCommand(): Command;
57
+ export declare function executeListCommand(options: ListCommandOptions, deps?: ListCommandDeps): Promise<CommandResult>;
58
+ /**
59
+ * Internal implementation of the list query execution.
60
+ */
61
+ export declare function runListInternal(options: ListCommandOptions, deps?: ListCommandDeps): Promise<CommandResult>;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Database Migration Command
3
+ *
4
+ * Handles cross-environment migrations, checking structural integrity,
5
+ * checkpointing WAL logs, purging stale sync locks, and natively re-installing hooks.
6
+ */
7
+ import { Command } from "commander";
8
+ import type { CommandResult } from "../command-result.js";
9
+ /**
10
+ * Options for the migrate command.
11
+ */
12
+ export interface MigrateCommandOptions {
13
+ /** Migrate database from Windows host env */
14
+ fromWindows?: boolean;
15
+ }
16
+ /**
17
+ * Test overrides and programmatic dependencies.
18
+ */
19
+ export interface MigrateCommandDeps {
20
+ /** Database path. Defaults to getDefaultDbPath(). */
21
+ dbPath?: string;
22
+ /** Data directory. Defaults to getDataDir(). */
23
+ dataDir?: string;
24
+ /** Custom uninstall hooks handler. */
25
+ uninstallHooks?: () => any;
26
+ /** Custom install hooks handler. */
27
+ installHooks?: () => any;
28
+ }
29
+ /**
30
+ * Create the migrate command for Commander.js.
31
+ */
32
+ export declare function createMigrateCommand(): Command;
33
+ /**
34
+ * Execute the migrate command programmatically.
35
+ */
36
+ export declare function executeMigrateCommand(_options: MigrateCommandOptions, deps?: MigrateCommandDeps): Promise<CommandResult>;
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Purge Command Handler
3
+ *
4
+ * CLI command for removing old sessions from the database.
5
+ * Supports age filtering, dry-run mode, and force (skip confirmation).
6
+ */
7
+ import { Command } from "commander";
8
+ import type { CommandResult } from "../command-result.js";
9
+ /**
10
+ * Options for the purge command.
11
+ */
12
+ export interface PurgeCommandOptions {
13
+ /** Duration threshold (e.g., "30d", "6m", "1y") -- sessions older than this are purged */
14
+ olderThan?: string;
15
+ /** Purge orphaned sessions whose project workspaces no longer exist */
16
+ orphans?: boolean;
17
+ /** Skip confirmation prompt */
18
+ force?: boolean;
19
+ /** Preview purge without modifying the database */
20
+ dryRun?: boolean;
21
+ /** Output results as JSON */
22
+ json?: boolean;
23
+ /** Suppress non-essential output */
24
+ quiet?: boolean;
25
+ }
26
+ /**
27
+ * Result of a purge operation.
28
+ */
29
+ export interface PurgeResult {
30
+ /** Number of sessions deleted (0 if dryRun) */
31
+ sessionsDeleted: number;
32
+ /** ISO date string of the cutoff threshold */
33
+ cutoffDate?: string;
34
+ /** Whether this was a dry-run (preview only) */
35
+ dryRun: boolean;
36
+ }
37
+ /**
38
+ * Parse duration string into a cutoff Date.
39
+ *
40
+ * Supported formats:
41
+ * - "30d" - 30 days
42
+ * - "6m" - 6 months
43
+ * - "1y" - 1 year
44
+ *
45
+ * @param duration - Duration string (e.g., "90d", "6m", "1y")
46
+ * @returns Date representing the cutoff time
47
+ * @throws Error if duration format is invalid
48
+ */
49
+ export declare function parseDuration(duration: string): Date;
50
+ /**
51
+ * Runtime dependencies for executePurgeCommand.
52
+ *
53
+ * Operational dependencies that tests substitute for isolation.
54
+ * Defaults to production resolution when omitted.
55
+ */
56
+ export interface PurgeCommandDeps {
57
+ /** Database path. Defaults to getDefaultDbPath(). */
58
+ dbPath?: string;
59
+ /** Default database path resolver. Defaults to getDefaultDbPath(). */
60
+ getDefaultDbPath?: () => string;
61
+ /** Database initializer. Defaults to initializeDatabase(). */
62
+ initializeDatabase?: (config: {
63
+ path: string;
64
+ }) => {
65
+ db: any;
66
+ };
67
+ /** Database closer. Defaults to closeDatabase(). */
68
+ closeDatabase?: (db: any) => void;
69
+ /** Session repository factory. Defaults to SqliteSessionRepository. */
70
+ createSessionRepository?: (db: any) => {
71
+ findOlderThan(cutoffDate: Date): Promise<any[]>;
72
+ findFiltered(options: {
73
+ limit: number;
74
+ }): Promise<any[]>;
75
+ delete(id: string): void;
76
+ };
77
+ /** Confirmation prompt. Defaults to readline-based askConfirmation. */
78
+ askConfirmation?: (message: string) => Promise<boolean>;
79
+ /** File existence checker function. Defaults to existsSync from fs. */
80
+ existsSync?: (path: string) => boolean;
81
+ }
82
+ /**
83
+ * Create the purge command for Commander.js.
84
+ *
85
+ * @returns Configured Command instance
86
+ */
87
+ export declare function createPurgeCommand(): Command;
88
+ /**
89
+ * Execute the purge command programmatically.
90
+ *
91
+ * Purges sessions from the database older than the specified duration,
92
+ * or orphaned sessions whose workspaces no longer exist.
93
+ * Use dryRun to preview without deleting. Handles its own database
94
+ * initialization and teardown.
95
+ *
96
+ * @param options - Purge command options
97
+ * @param deps - Runtime dependencies
98
+ * @returns CommandResult with exitCode 0 (success) or 1/2 (error)
99
+ */
100
+ export declare function executePurgeCommand(options: PurgeCommandOptions, deps?: PurgeCommandDeps): Promise<CommandResult>;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Unified Query Command Handler (Phase 32.5 Surface Consolidation)
3
+ *
4
+ * Single command interface for all read-oriented query commands.
5
+ * Unifies search, context, related, list, and show under a single primitive
6
+ * while preserving full backward compatibility.
7
+ */
8
+ import { Command } from "commander";
9
+ import type { CommandResult } from "../command-result.js";
10
+ /**
11
+ * Options for the query command.
12
+ */
13
+ export interface QueryCommandOptions {
14
+ /** Discriminator envelope scope: global or project */
15
+ scope?: "global" | "project" | undefined;
16
+ /** Filter by project name */
17
+ project?: string | undefined;
18
+ /** Resource kind: message, session, file, stats, context, related */
19
+ kind?: "message" | "session" | "file" | "stats" | "context" | "related" | undefined;
20
+ /** Search mode: fts, vector, hybrid, auto */
21
+ mode?: "fts" | "vector" | "hybrid" | "auto" | undefined;
22
+ /** Maximum results to return */
23
+ limit?: string | undefined;
24
+ /** Output format */
25
+ format?: "brief" | "ai" | "default" | "detailed" | undefined;
26
+ /** Output as JSON envelope */
27
+ json?: boolean | undefined;
28
+ /** Age filter in days */
29
+ days?: number | undefined;
30
+ /** Projects limit count in stats */
31
+ projects?: string | undefined;
32
+ /** Show verbose execution logs */
33
+ verbose?: boolean | undefined;
34
+ /** Suppress headers and decorations */
35
+ quiet?: boolean | undefined;
36
+ /** Database path override (for tests) */
37
+ dbPath?: string | undefined;
38
+ }
39
+ /**
40
+ * Create the query command for Commander.js.
41
+ *
42
+ * @returns Configured Command instance
43
+ */
44
+ export declare function createQueryCommand(): Command;
45
+ /**
46
+ * Execute the query command programmatically.
47
+ *
48
+ * Routes query to respective underlying commands dynamically to avoid top-level
49
+ * circular imports, setting the JSON envelope command name override as needed.
50
+ */
51
+ export declare function executeQueryCommand(argument: string | undefined, options: QueryCommandOptions): Promise<CommandResult>;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Related Command Handler
3
+ *
4
+ * CLI command for finding sessions related through shared topics/entities.
5
+ * Uses SqliteLinkRepository's findRelatedWithHops() for graph traversal.
6
+ */
7
+ import { Command } from "commander";
8
+ import type { CommandResult } from "../command-result.js";
9
+ /**
10
+ * Options for the related command.
11
+ */
12
+ export interface RelatedCommandOptions {
13
+ /** Maximum results to return */
14
+ limit?: number;
15
+ /** Traversal depth (1-3) */
16
+ hops?: number;
17
+ /** Entity type of the ID: session, message, or topic */
18
+ type?: "session" | "message" | "topic";
19
+ /**
20
+ * Output format. Phase 32 (CLI-03) normalized choices: `brief`,
21
+ * `ai`. `detailed` retained as deprecated alias (one-minor cadence;
22
+ * CHANGELOG documents removal). Undefined = no-flag default
23
+ * (existing brief behavior preserved for backward compatibility).
24
+ */
25
+ format?: "brief" | "ai" | "detailed";
26
+ /** Output as JSON */
27
+ json?: boolean;
28
+ /** Show detailed output with timing */
29
+ verbose?: boolean;
30
+ /** Minimal output (session IDs only) */
31
+ quiet?: boolean;
32
+ /** Override database path (for testing) */
33
+ dbPath?: string;
34
+ }
35
+ /**
36
+ * Create the related command for Commander.js.
37
+ *
38
+ * @returns Configured Command instance
39
+ */
40
+ export declare function createRelatedCommand(): Command;
41
+ export declare function executeRelatedCommand(id: string, options: RelatedCommandOptions): Promise<CommandResult>;
42
+ /**
43
+ * Internal implementation of the related query execution.
44
+ */
45
+ export declare function runRelatedInternal(id: string, options: RelatedCommandOptions, deps?: {
46
+ dbPath?: string;
47
+ }): Promise<CommandResult>;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Remote Command Handler
3
+ *
4
+ * CLI command for managing multi-device private Git transport synchronization.
5
+ * Supports set, remove, and status subcommands.
6
+ */
7
+ import { Command } from "commander";
8
+ import type { CommandResult } from "../command-result.js";
9
+ import { loadConfig, saveConfig } from "../../../infrastructure/hooks/config-manager.js";
10
+ import { GitSyncer } from "../../../infrastructure/hooks/git-syncer.js";
11
+ /**
12
+ * Options/parameters for remote subcommands.
13
+ */
14
+ export interface RemoteCommandOptions {
15
+ configPathOverride?: string;
16
+ eventsDirOverride?: string;
17
+ loadConfig?: typeof loadConfig;
18
+ saveConfig?: typeof saveConfig;
19
+ createGitSyncer?: (eventsDir?: string) => Pick<GitSyncer, "isGitRepo" | "initRepo" | "configureRemote" | "removeRemote" | "getRemoteUrl">;
20
+ }
21
+ /**
22
+ * Create the remote command group for Commander.js.
23
+ */
24
+ export declare function createRemoteCommand(opts?: RemoteCommandOptions): Command;
25
+ /**
26
+ * Configure the remote sync repository.
27
+ */
28
+ export declare function executeRemoteSetCommand(repositoryUrl: string, opts?: RemoteCommandOptions): Promise<CommandResult>;
29
+ /**
30
+ * Remove remote sync configuration.
31
+ */
32
+ export declare function executeRemoteRemoveCommand(opts?: RemoteCommandOptions): Promise<CommandResult>;
33
+ /**
34
+ * Display current remote sync configurations and status.
35
+ */
36
+ export declare function executeRemoteStatusCommand(opts?: RemoteCommandOptions): Promise<CommandResult>;