@yeseh/cortex-cli 0.6.0 → 0.6.3

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 (142) hide show
  1. package/package.json +3 -3
  2. package/src/category/commands/create.ts +7 -3
  3. package/src/context.ts +15 -20
  4. package/src/memory/commands/add.ts +2 -1
  5. package/src/memory/commands/list.ts +2 -1
  6. package/src/memory/commands/move.ts +6 -2
  7. package/src/memory/commands/remove.ts +6 -2
  8. package/src/memory/commands/show.ts +3 -2
  9. package/src/memory/commands/update.ts +2 -1
  10. package/src/run.ts +0 -0
  11. package/src/store/commands/init.spec.ts +62 -78
  12. package/src/store/commands/init.ts +31 -15
  13. package/src/store/commands/prune.ts +4 -4
  14. package/src/store/commands/reindexs.ts +4 -3
  15. package/src/tests/cli.integration.spec.ts +136 -0
  16. package/src/utils/input.ts +9 -4
  17. package/src/utils/resolve-default-store.spec.ts +135 -0
  18. package/src/utils/resolve-default-store.ts +74 -0
  19. package/dist/category/commands/create.d.ts +0 -44
  20. package/dist/category/commands/create.d.ts.map +0 -1
  21. package/dist/category/commands/create.spec.d.ts +0 -7
  22. package/dist/category/commands/create.spec.d.ts.map +0 -1
  23. package/dist/category/index.d.ts +0 -19
  24. package/dist/category/index.d.ts.map +0 -1
  25. package/dist/commands/init.d.ts +0 -58
  26. package/dist/commands/init.d.ts.map +0 -1
  27. package/dist/commands/init.spec.d.ts +0 -2
  28. package/dist/commands/init.spec.d.ts.map +0 -1
  29. package/dist/context.d.ts +0 -18
  30. package/dist/context.d.ts.map +0 -1
  31. package/dist/context.spec.d.ts +0 -2
  32. package/dist/context.spec.d.ts.map +0 -1
  33. package/dist/create-cli-command.d.ts +0 -23
  34. package/dist/create-cli-command.d.ts.map +0 -1
  35. package/dist/create-cli-command.spec.d.ts +0 -10
  36. package/dist/create-cli-command.spec.d.ts.map +0 -1
  37. package/dist/errors.d.ts +0 -57
  38. package/dist/errors.d.ts.map +0 -1
  39. package/dist/errors.spec.d.ts +0 -2
  40. package/dist/errors.spec.d.ts.map +0 -1
  41. package/dist/input.d.ts +0 -42
  42. package/dist/input.d.ts.map +0 -1
  43. package/dist/input.spec.d.ts +0 -2
  44. package/dist/input.spec.d.ts.map +0 -1
  45. package/dist/memory/commands/add.d.ts +0 -62
  46. package/dist/memory/commands/add.d.ts.map +0 -1
  47. package/dist/memory/commands/add.spec.d.ts +0 -7
  48. package/dist/memory/commands/add.spec.d.ts.map +0 -1
  49. package/dist/memory/commands/definitions.spec.d.ts +0 -10
  50. package/dist/memory/commands/definitions.spec.d.ts.map +0 -1
  51. package/dist/memory/commands/handlers.spec.d.ts +0 -2
  52. package/dist/memory/commands/handlers.spec.d.ts.map +0 -1
  53. package/dist/memory/commands/list.d.ts +0 -119
  54. package/dist/memory/commands/list.d.ts.map +0 -1
  55. package/dist/memory/commands/list.spec.d.ts +0 -2
  56. package/dist/memory/commands/list.spec.d.ts.map +0 -1
  57. package/dist/memory/commands/move.d.ts +0 -42
  58. package/dist/memory/commands/move.d.ts.map +0 -1
  59. package/dist/memory/commands/move.spec.d.ts +0 -2
  60. package/dist/memory/commands/move.spec.d.ts.map +0 -1
  61. package/dist/memory/commands/remove.d.ts +0 -41
  62. package/dist/memory/commands/remove.d.ts.map +0 -1
  63. package/dist/memory/commands/remove.spec.d.ts +0 -2
  64. package/dist/memory/commands/remove.spec.d.ts.map +0 -1
  65. package/dist/memory/commands/show.d.ts +0 -81
  66. package/dist/memory/commands/show.d.ts.map +0 -1
  67. package/dist/memory/commands/show.spec.d.ts +0 -2
  68. package/dist/memory/commands/show.spec.d.ts.map +0 -1
  69. package/dist/memory/commands/test-helpers.spec.d.ts +0 -19
  70. package/dist/memory/commands/test-helpers.spec.d.ts.map +0 -1
  71. package/dist/memory/commands/update.d.ts +0 -73
  72. package/dist/memory/commands/update.d.ts.map +0 -1
  73. package/dist/memory/commands/update.spec.d.ts +0 -2
  74. package/dist/memory/commands/update.spec.d.ts.map +0 -1
  75. package/dist/memory/index.d.ts +0 -29
  76. package/dist/memory/index.d.ts.map +0 -1
  77. package/dist/memory/index.spec.d.ts +0 -10
  78. package/dist/memory/index.spec.d.ts.map +0 -1
  79. package/dist/memory/parsing.d.ts +0 -3
  80. package/dist/memory/parsing.d.ts.map +0 -1
  81. package/dist/memory/parsing.spec.d.ts +0 -7
  82. package/dist/memory/parsing.spec.d.ts.map +0 -1
  83. package/dist/output.d.ts +0 -87
  84. package/dist/output.d.ts.map +0 -1
  85. package/dist/output.spec.d.ts +0 -2
  86. package/dist/output.spec.d.ts.map +0 -1
  87. package/dist/paths.d.ts +0 -27
  88. package/dist/paths.d.ts.map +0 -1
  89. package/dist/paths.spec.d.ts +0 -7
  90. package/dist/paths.spec.d.ts.map +0 -1
  91. package/dist/program.d.ts +0 -41
  92. package/dist/program.d.ts.map +0 -1
  93. package/dist/program.spec.d.ts +0 -11
  94. package/dist/program.spec.d.ts.map +0 -1
  95. package/dist/run.d.ts +0 -7
  96. package/dist/run.d.ts.map +0 -1
  97. package/dist/run.spec.d.ts +0 -12
  98. package/dist/run.spec.d.ts.map +0 -1
  99. package/dist/store/commands/add.d.ts +0 -73
  100. package/dist/store/commands/add.d.ts.map +0 -1
  101. package/dist/store/commands/add.spec.d.ts +0 -17
  102. package/dist/store/commands/add.spec.d.ts.map +0 -1
  103. package/dist/store/commands/init.d.ts +0 -75
  104. package/dist/store/commands/init.d.ts.map +0 -1
  105. package/dist/store/commands/init.spec.d.ts +0 -7
  106. package/dist/store/commands/init.spec.d.ts.map +0 -1
  107. package/dist/store/commands/list.d.ts +0 -62
  108. package/dist/store/commands/list.d.ts.map +0 -1
  109. package/dist/store/commands/list.spec.d.ts +0 -7
  110. package/dist/store/commands/list.spec.d.ts.map +0 -1
  111. package/dist/store/commands/prune.d.ts +0 -92
  112. package/dist/store/commands/prune.d.ts.map +0 -1
  113. package/dist/store/commands/prune.spec.d.ts +0 -7
  114. package/dist/store/commands/prune.spec.d.ts.map +0 -1
  115. package/dist/store/commands/reindexs.d.ts +0 -54
  116. package/dist/store/commands/reindexs.d.ts.map +0 -1
  117. package/dist/store/commands/reindexs.spec.d.ts +0 -7
  118. package/dist/store/commands/reindexs.spec.d.ts.map +0 -1
  119. package/dist/store/commands/remove.d.ts +0 -63
  120. package/dist/store/commands/remove.d.ts.map +0 -1
  121. package/dist/store/commands/remove.spec.d.ts +0 -17
  122. package/dist/store/commands/remove.spec.d.ts.map +0 -1
  123. package/dist/store/index.d.ts +0 -32
  124. package/dist/store/index.d.ts.map +0 -1
  125. package/dist/store/index.spec.d.ts +0 -9
  126. package/dist/store/index.spec.d.ts.map +0 -1
  127. package/dist/store/utils/resolve-store-name.d.ts +0 -30
  128. package/dist/store/utils/resolve-store-name.d.ts.map +0 -1
  129. package/dist/store/utils/resolve-store-name.spec.d.ts +0 -2
  130. package/dist/store/utils/resolve-store-name.spec.d.ts.map +0 -1
  131. package/dist/test-helpers.spec.d.ts +0 -224
  132. package/dist/test-helpers.spec.d.ts.map +0 -1
  133. package/dist/tests/cli.integration.spec.d.ts +0 -11
  134. package/dist/tests/cli.integration.spec.d.ts.map +0 -1
  135. package/dist/toon.d.ts +0 -197
  136. package/dist/toon.d.ts.map +0 -1
  137. package/dist/toon.spec.d.ts +0 -9
  138. package/dist/toon.spec.d.ts.map +0 -1
  139. package/dist/utils/git.d.ts +0 -20
  140. package/dist/utils/git.d.ts.map +0 -1
  141. package/dist/utils/git.spec.d.ts +0 -7
  142. package/dist/utils/git.spec.d.ts.map +0 -1
@@ -1,10 +0,0 @@
1
- /**
2
- * Unit tests for create-cli-command.ts — validateStorePath.
3
- *
4
- * Verifies that absolute paths pass validation and relative paths
5
- * produce a typed INVALID_STORE_PATH error result.
6
- *
7
- * @module cli/create-cli-command.spec
8
- */
9
- export {};
10
- //# sourceMappingURL=create-cli-command.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-cli-command.spec.d.ts","sourceRoot":"","sources":["../src/create-cli-command.spec.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
package/dist/errors.d.ts DELETED
@@ -1,57 +0,0 @@
1
- /**
2
- * Error mapping utilities for CLI commands.
3
- *
4
- * This module provides utilities to map core Result errors to Commander.js
5
- * exceptions. Commander.js uses specific exception types to control error
6
- * output and exit codes:
7
- *
8
- * - `InvalidArgumentError` - For user input validation errors (shows usage help)
9
- * - `CommanderError` - For other errors (shows error message only)
10
- *
11
- * @example
12
- * ```ts
13
- * const result = await runAddCommand(options);
14
- * if (!result.ok()) {
15
- * mapCoreError(result.error);
16
- * }
17
- * ```
18
- */
19
- /**
20
- * Represents a core error with a code and message.
21
- *
22
- * This interface matches the error shape used throughout the CLI commands,
23
- * allowing consistent error handling across all command implementations.
24
- */
25
- export interface CoreError {
26
- code: string;
27
- message: string;
28
- cause?: unknown;
29
- }
30
- /**
31
- * Maps a core error to a Commander.js exception and throws it.
32
- *
33
- * This function examines the error code to determine the appropriate
34
- * Commander.js exception type:
35
- *
36
- * - **Argument errors** (`InvalidArgumentError`): For errors caused by invalid
37
- * user input. Commander.js displays usage help for these errors.
38
- *
39
- * - **Other errors** (`CommanderError`): For system errors, missing resources,
40
- * or internal failures. Commander.js displays only the error message.
41
- *
42
- * @param error - The core error to map
43
- * @throws {InvalidArgumentError} When the error code indicates invalid input
44
- * @throws {CommanderError} For all other error codes
45
- *
46
- * @example
47
- * ```ts
48
- * // In a command action handler
49
- * const result = await runShowCommand(options);
50
- * if (!result.ok()) {
51
- * mapCoreError(result.error);
52
- * // Never reaches here - mapCoreError always throws
53
- * }
54
- * ```
55
- */
56
- export declare function throwCliError(error: CoreError): never;
57
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAyCD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,KAAK,CAMrD"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=errors.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.spec.d.ts","sourceRoot":"","sources":["../src/errors.spec.ts"],"names":[],"mappings":""}
package/dist/input.d.ts DELETED
@@ -1,42 +0,0 @@
1
- /**
2
- * CLI helpers for resolving memory content input.
3
- */
4
- import { type Result } from '@yeseh/cortex-core';
5
- export type MemoryContentSource = 'flag' | 'file' | 'stdin' | 'none';
6
- export type InputSource = {
7
- content?: string;
8
- filePath?: string;
9
- /**
10
- * stdin stream to read from.
11
- *
12
- * NOTE: Passing a stream does not necessarily mean stdin is intended as an input
13
- * source. Use `stdinRequested: true` when a command semantics include reading from
14
- * stdin by default (e.g. `memory add`), typically when piping.
15
- */
16
- stream?: NodeJS.ReadableStream;
17
- /**
18
- * Explicitly indicates stdin should be considered as an input source.
19
- *
20
- * This is `false` by default so that inheriting a non-TTY stdin in test harnesses
21
- * or subprocess environments does not accidentally count as providing `--stdin`.
22
- */
23
- stdinRequested?: boolean;
24
- };
25
- export interface InputContent {
26
- content: string | null;
27
- source: MemoryContentSource;
28
- }
29
- export type InputErrorCode = 'MULTIPLE_CONTENT_SOURCES' | 'FILE_READ_FAILED' | 'MISSING_CONTENT' | 'INVALID_FILE_PATH';
30
- export interface InputError {
31
- code: InputErrorCode;
32
- message: string;
33
- path?: string;
34
- cause?: unknown;
35
- }
36
- type InputResult = Result<InputContent, InputError>;
37
- type OptionalContentResult = Result<InputContent | null, InputError>;
38
- export declare const readContentFromFile: (filePath: string | undefined) => Promise<OptionalContentResult>;
39
- export declare const readContentFromStream: (stream: NodeJS.ReadableStream) => Promise<OptionalContentResult>;
40
- export declare const resolveInput: (source: InputSource) => Promise<InputResult>;
41
- export {};
42
- //# sourceMappingURL=input.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../src/input.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAErE,MAAM,MAAM,WAAW,GAAG;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC/B;;;;;OAKG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,WAAW,YAAY;IACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,mBAAmB,CAAC;CAC/B;AAED,MAAM,MAAM,cAAc,GACpB,0BAA0B,GAC1B,kBAAkB,GAClB,iBAAiB,GACjB,mBAAmB,CAAC;AAE1B,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,KAAK,WAAW,GAAG,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AACpD,KAAK,qBAAqB,GAAG,MAAM,CAAC,YAAY,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC;AAErE,eAAO,MAAM,mBAAmB,GAC5B,UAAU,MAAM,GAAG,SAAS,KAC7B,OAAO,CAAC,qBAAqB,CAsB/B,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAC9B,QAAQ,MAAM,CAAC,cAAc,KAC9B,OAAO,CAAC,qBAAqB,CAgB/B,CAAC;AAKF,eAAO,MAAM,YAAY,GAAU,QAAQ,WAAW,KAAG,OAAO,CAAC,WAAW,CA6C3E,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=input.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"input.spec.d.ts","sourceRoot":"","sources":["../src/input.spec.ts"],"names":[],"mappings":""}
@@ -1,62 +0,0 @@
1
- /**
2
- * Memory add command implementation using Commander.js.
3
- *
4
- * Creates a new memory at the specified path with content from inline text,
5
- * a file, or stdin.
6
- *
7
- * @example
8
- * ```bash
9
- * # Add memory with inline content
10
- * cortex memory add project/tech-stack --content "Using TypeScript and Node.js"
11
- *
12
- * # Add memory from a file
13
- * cortex memory add project/notes --file ./notes.md
14
- *
15
- * # Add memory from stdin
16
- * echo "My notes" | cortex memory add project/notes
17
- *
18
- * # Add memory with tags and expiration
19
- * cortex memory add project/temp --content "Temporary note" \
20
- * --tags "temp,cleanup" --expires-at "2025-12-31T00:00:00Z"
21
- * ```
22
- */
23
- import { Command } from '@commander-js/extra-typings';
24
- import { type CortexContext } from '@yeseh/cortex-core';
25
- /** Options parsed by Commander for the add command */
26
- export interface AddCommandOptions {
27
- content?: string;
28
- file?: string;
29
- tags?: string[];
30
- expiresAt?: string;
31
- citations?: string[];
32
- format?: string;
33
- }
34
- /**
35
- * Handler for the memory add command.
36
- * Exported for direct testing without Commander parsing.
37
- *
38
- * @param path - Memory path (e.g., "project/tech-stack")
39
- * @param options - Command options from Commander
40
- * @param storeName - Optional store name from parent command
41
- * @param deps - Injectable dependencies for testing
42
- */
43
- export declare function handleAdd(ctx: CortexContext, storeName: string | undefined, path: string, options: AddCommandOptions): Promise<void>;
44
- /**
45
- * The `memory add` subcommand.
46
- *
47
- * Creates a new memory at the specified path. Content can be provided via:
48
- * - `--content` flag for inline text
49
- * - `--file` flag to read from a file
50
- * - stdin when piped
51
- *
52
- * The `--store` option is inherited from the parent `memory` command.
53
- */
54
- export declare const addCommand: Command<[string], {
55
- content?: string | undefined;
56
- file?: string | undefined;
57
- tags?: string[] | undefined;
58
- expiresAt?: string | undefined;
59
- citation?: string[] | undefined;
60
- format?: string | undefined;
61
- }, {}>;
62
- //# sourceMappingURL=add.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/memory/commands/add.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMxD,sDAAsD;AACtD,MAAM,WAAW,iBAAiB;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AACD;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAC3B,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,iBAAiB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAyEf;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU;;;;;;;MAiBjB,CAAC"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Unit tests for the handleAdd command handler.
3
- *
4
- * @module cli/memory/commands/add.spec
5
- */
6
- export {};
7
- //# sourceMappingURL=add.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"add.spec.d.ts","sourceRoot":"","sources":["../../../src/memory/commands/add.spec.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -1,10 +0,0 @@
1
- /**
2
- * Unit tests for memory command definitions.
3
- *
4
- * Verifies that memory subcommands expose the expected names,
5
- * arguments, and options.
6
- *
7
- * @module cli/memory/commands/definitions.spec
8
- */
9
- export {};
10
- //# sourceMappingURL=definitions.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"definitions.spec.d.ts","sourceRoot":"","sources":["../../../src/memory/commands/definitions.spec.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=handlers.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handlers.spec.d.ts","sourceRoot":"","sources":["../../../src/memory/commands/handlers.spec.ts"],"names":[],"mappings":""}
@@ -1,119 +0,0 @@
1
- /**
2
- * Memory list command for browsing memories with optional filtering.
3
- *
4
- * Lists all memories in a category, or all memories across all categories
5
- * if no category is specified. Expired memories are excluded by default
6
- * unless the `--include-expired` flag is provided.
7
- *
8
- * When no category is specified, the command dynamically discovers all
9
- * root categories from the store's index rather than using a hardcoded list.
10
- *
11
- * @example
12
- * ```bash
13
- * # List all memories
14
- * cortex memory list
15
- *
16
- * # List memories in a specific category
17
- * cortex memory list project/cortex
18
- *
19
- * # Include expired memories
20
- * cortex memory list --include-expired
21
- *
22
- * # Output in JSON format
23
- * cortex memory list --format json
24
- *
25
- * # Use a specific store (either placement works)
26
- * cortex memory list -s my-store
27
- * cortex memory -s my-store list
28
- * ```
29
- */
30
- import { Command } from '@commander-js/extra-typings';
31
- import { type CortexContext } from '@yeseh/cortex-core';
32
- /**
33
- * Options for the list command.
34
- */
35
- export interface ListCommandOptions {
36
- /** Include expired memories in the output */
37
- includeExpired?: boolean;
38
- /** Output format (yaml, json, toon) */
39
- format?: string;
40
- /** Store name (can be specified on subcommand or parent) */
41
- store?: string;
42
- }
43
- /**
44
- * Dependencies for the list command handler.
45
- * Allows injection for testing.
46
- */
47
- export interface ListHandlerDeps {
48
- /** Output stream for writing results (defaults to process.stdout) */
49
- stdout?: NodeJS.WritableStream;
50
- /** Current time for expiration checks */
51
- now?: Date;
52
- }
53
- /**
54
- * Entry representing a memory in the list output.
55
- */
56
- export interface ListMemoryEntry {
57
- path: string;
58
- tokenEstimate: number;
59
- summary?: string;
60
- expiresAt?: Date;
61
- isExpired: boolean;
62
- }
63
- /**
64
- * Entry representing a subcategory in the list output.
65
- */
66
- export interface ListSubcategoryEntry {
67
- path: string;
68
- memoryCount: number;
69
- description?: string;
70
- }
71
- /**
72
- * Result of the list command containing memories and subcategories.
73
- */
74
- export interface ListResult {
75
- memories: ListMemoryEntry[];
76
- subcategories: ListSubcategoryEntry[];
77
- }
78
- /**
79
- * Handles the list command execution.
80
- *
81
- * This function:
82
- * 1. Resolves the store context
83
- * 2. Loads category index (or all categories if none specified)
84
- * 3. Collects memories and subcategories, filtering expired if needed
85
- * 4. Formats and outputs the result
86
- *
87
- * @param category - Optional category path to list (lists all if omitted)
88
- * @param options - Command options (includeExpired, format)
89
- * @param storeName - Optional store name from parent command
90
- * @param deps - Optional dependencies for testing
91
- * @throws {InvalidArgumentError} When arguments are invalid
92
- * @throws {CommanderError} When read or parse fails
93
- */
94
- export declare function handleList(ctx: CortexContext, storeName: string | undefined, category: string | undefined, options: ListCommandOptions, deps?: ListHandlerDeps): Promise<void>;
95
- /**
96
- * The `list` subcommand for browsing memories.
97
- *
98
- * Lists memories in a category, or all memories across all root categories
99
- * if no category is specified. By default, expired memories are excluded.
100
- *
101
- * The `--store` option can be specified either on this command or on the
102
- * parent `memory` command for flexibility.
103
- *
104
- * @example
105
- * ```bash
106
- * cortex memory list
107
- * cortex memory list project/cortex
108
- * cortex memory list --include-expired
109
- * cortex memory list --format json
110
- * cortex memory list -s my-store
111
- * cortex memory -s my-store list
112
- * ```
113
- */
114
- export declare const listCommand: Command<[string | undefined], {
115
- store?: string | undefined;
116
- includeExpired?: true | undefined;
117
- format: string;
118
- }, {}>;
119
- //# sourceMappingURL=list.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/memory/commands/list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAItD,OAAO,EAAa,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,6CAA6C;IAC7C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC5B,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC/B,yCAAyC;IACzC,GAAG,CAAC,EAAE,IAAI,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,aAAa,EAAE,oBAAoB,EAAE,CAAC;CACzC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,UAAU,CAC5B,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,OAAO,EAAE,kBAAkB,EAC3B,IAAI,GAAE,eAAoB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAsHf;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,WAAW;;;;MAgBlB,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=list.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"list.spec.d.ts","sourceRoot":"","sources":["../../../src/memory/commands/list.spec.ts"],"names":[],"mappings":""}
@@ -1,42 +0,0 @@
1
- /**
2
- * Memory move command implementation using Commander.js.
3
- *
4
- * Moves a memory from one path to another within the same store.
5
- *
6
- * @example
7
- * ```bash
8
- * # Move a memory to a new location
9
- * cortex memory move project/old-name project/new-name
10
- *
11
- * # Move with explicit store
12
- * cortex memory --store my-store move project/old project/new
13
- * ```\n */
14
- import { Command } from '@commander-js/extra-typings';
15
- import { type CortexContext } from '@yeseh/cortex-core';
16
- /** Options for the move command. */
17
- export interface MoveCommandOptions {
18
- /** Output format (yaml, json, toon) */
19
- format?: string;
20
- }
21
- /**
22
- * Handler for the memory move command.
23
- * Exported for direct testing without Commander parsing.
24
- *
25
- * @param ctx - CLI context containing Cortex client and streams
26
- * @param storeName - Optional store name from parent command
27
- * @param from - Source memory path
28
- * @param to - Destination memory path
29
- */
30
- export declare function handleMove(ctx: CortexContext, storeName: string | undefined, from: string, to: string, options?: MoveCommandOptions): Promise<void>;
31
- /**
32
- * The `memory move` subcommand.
33
- *
34
- * Moves a memory from one path to another within the store.
35
- * Both paths must be valid memory slug paths.
36
- *
37
- * The `--store` option is inherited from the parent `memory` command.
38
- */
39
- export declare const moveCommand: Command<[string, string], {
40
- format?: string | undefined;
41
- }, {}>;
42
- //# sourceMappingURL=move.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"move.d.ts","sourceRoot":"","sources":["../../../src/memory/commands/move.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;WAYW;AAEX,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIpE,oCAAoC;AACpC,MAAM,WAAW,kBAAkB;IAC/B,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAC5B,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,kBAAuB,GACjC,OAAO,CAAC,IAAI,CAAC,CAkDf;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW;;MAalB,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=move.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"move.spec.d.ts","sourceRoot":"","sources":["../../../src/memory/commands/move.spec.ts"],"names":[],"mappings":""}
@@ -1,41 +0,0 @@
1
- /**
2
- * Memory remove command implementation using Commander.js.
3
- *
4
- * Deletes an existing memory at the specified path.
5
- *
6
- * @example
7
- * ```bash
8
- * # Remove a memory
9
- * cortex memory remove project/tech-stack
10
- *
11
- * # Remove memory from a specific store
12
- * cortex memory --store work remove project/notes
13
- * ```
14
- */
15
- import { Command } from '@commander-js/extra-typings';
16
- import { type CortexContext } from '@yeseh/cortex-core';
17
- /** Options for the remove command. */
18
- export interface RemoveCommandOptions {
19
- /** Output format (yaml, json, toon) */
20
- format?: string;
21
- }
22
- /**
23
- * Handler for the memory remove command.
24
- * Exported for direct testing without Commander parsing.
25
- *
26
- * @param ctx - CLI context containing Cortex client and streams
27
- * @param storeName - Optional store name from parent command
28
- * @param path - Memory path to remove (e.g., "project/tech-stack")
29
- */
30
- export declare function handleRemove(ctx: CortexContext, storeName: string | undefined, path: string, options?: RemoveCommandOptions): Promise<void>;
31
- /**
32
- * The `memory remove` subcommand.
33
- *
34
- * Deletes an existing memory at the specified path.
35
- *
36
- * The `--store` option is inherited from the parent `memory` command.
37
- */
38
- export declare const removeCommand: Command<[string], {
39
- format?: string | undefined;
40
- }, {}>;
41
- //# sourceMappingURL=remove.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/memory/commands/remove.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIpE,sCAAsC;AACtC,MAAM,WAAW,oBAAoB;IACjC,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAC9B,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,oBAAyB,GACnC,OAAO,CAAC,IAAI,CAAC,CA0Cf;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;MAYpB,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=remove.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remove.spec.d.ts","sourceRoot":"","sources":["../../../src/memory/commands/remove.spec.ts"],"names":[],"mappings":""}
@@ -1,81 +0,0 @@
1
- /**
2
- * Memory show command for displaying a memory's content and metadata.
3
- *
4
- * This command reads a memory from the store and displays it in the
5
- * specified format. Expired memories are excluded by default unless
6
- * the `--include-expired` flag is provided.
7
- *
8
- * @example
9
- * ```bash
10
- * # Show a memory in YAML format (default)
11
- * cortex memory show project/notes
12
- *
13
- * # Show a memory in JSON format
14
- * cortex memory show project/notes --format json
15
- *
16
- * # Include expired memories
17
- * cortex memory show project/notes --include-expired
18
- *
19
- * # Use a specific store
20
- * cortex memory --store my-store show project/notes
21
- * ```
22
- */
23
- import { Command } from '@commander-js/extra-typings';
24
- import { type CortexContext } from '@yeseh/cortex-core';
25
- import { type StoreClient } from '@yeseh/cortex-core/store';
26
- /**
27
- * Options for the show command.
28
- */
29
- export interface ShowCommandOptions {
30
- /** Include expired memories in the output */
31
- includeExpired?: boolean;
32
- /** Output format (yaml, json, toon) */
33
- format?: string;
34
- }
35
- /**
36
- * Dependencies for the show command handler.
37
- * Allows injection for testing.
38
- */
39
- export interface ShowHandlerDeps {
40
- /** Output stream for writing results (defaults to process.stdout) */
41
- stdout?: NodeJS.WritableStream;
42
- /** Pre-resolved store client for testing */
43
- store?: StoreClient;
44
- }
45
- /**
46
- * Handles the show command execution.
47
- *
48
- * This function:
49
- * 1. Resolves the store context
50
- * 2. Validates the memory path
51
- * 3. Reads the memory file from storage
52
- * 4. Parses the memory content and frontmatter
53
- * 5. Checks expiration status (unless --include-expired)
54
- * 6. Serializes and outputs the result
55
- *
56
- * @param path - The memory path to show (e.g., "project/notes")
57
- * @param options - Command options (includeExpired, format)
58
- * @param storeName - Optional store name from parent command
59
- * @param deps - Optional dependencies for testing
60
- * @throws {InvalidArgumentError} When the path is invalid
61
- * @throws {CommanderError} When the memory is not found or read fails
62
- */
63
- export declare function handleShow(ctx: CortexContext, storeName: string | undefined, path: string, options: ShowCommandOptions, deps?: ShowHandlerDeps): Promise<void>;
64
- /**
65
- * The `show` subcommand for displaying a memory.
66
- *
67
- * Reads a memory from the store and displays its content and metadata
68
- * in the specified format. By default, expired memories are excluded.
69
- *
70
- * @example
71
- * ```bash
72
- * cortex memory show project/notes
73
- * cortex memory show project/notes --format json
74
- * cortex memory show project/notes --include-expired
75
- * ```
76
- */
77
- export declare const showCommand: Command<[string], {
78
- includeExpired?: true | undefined;
79
- format: string;
80
- }, {}>;
81
- //# sourceMappingURL=show.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../../src/memory/commands/show.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAGtD,OAAO,EAAgC,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAI5D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,6CAA6C;IAC7C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC5B,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC/B,4CAA4C;IAC5C,KAAK,CAAC,EAAE,WAAW,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,UAAU,CAC5B,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,kBAAkB,EAC3B,IAAI,GAAE,eAAoB,GAC3B,OAAO,CAAC,IAAI,CAAC,CA2Df;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW;;;MAalB,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=show.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"show.spec.d.ts","sourceRoot":"","sources":["../../../src/memory/commands/show.spec.ts"],"names":[],"mappings":""}
@@ -1,19 +0,0 @@
1
- import { PassThrough } from 'node:stream';
2
- import { Memory, type AdapterFactory, type ConfigStores, type CortexContext, type CortexSettings, type MemoryMetadata, type StorageAdapter } from '@yeseh/cortex-core';
3
- export declare const createMockMemoryCommandAdapter: (overrides?: Record<string, unknown>) => StorageAdapter;
4
- export declare const createMemoryCommandContext: (options: {
5
- adapter: StorageAdapter;
6
- storePath: string;
7
- stdout?: PassThrough;
8
- stdin?: PassThrough;
9
- stores?: ConfigStores;
10
- settings?: CortexSettings;
11
- now?: () => Date;
12
- adapterFactory?: AdapterFactory;
13
- }) => CortexContext;
14
- export declare const createCaptureStream: () => {
15
- stream: PassThrough;
16
- getOutput: () => string;
17
- };
18
- export declare const createMemoryFixture: (path: string, overrides?: Partial<MemoryMetadata>, content?: string) => Memory;
19
- //# sourceMappingURL=test-helpers.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-helpers.spec.d.ts","sourceRoot":"","sources":["../../../src/memory/commands/test-helpers.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAEH,MAAM,EAEN,KAAK,cAAc,EAEnB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACtB,MAAM,oBAAoB,CAAC;AAE5B,eAAO,MAAM,8BAA8B,GACvC,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,KACxC,cAwBgC,CAAC;AAEpC,eAAO,MAAM,0BAA0B,GAAI,SAAS;IAChD,OAAO,EAAE,cAAc,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,cAAc,CAAC,EAAE,cAAc,CAAC;CACnC,KAAG,aAsCH,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAAO;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,MAAM,MAAM,CAAA;CAYpF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC5B,MAAM,MAAM,EACZ,YAAW,OAAO,CAAC,cAAc,CAAM,EACvC,gBAA0B,KAC3B,MAiBF,CAAC"}