@yeseh/cortex-cli 0.6.4 → 0.6.5

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 (130) hide show
  1. package/dist/category/commands/create.d.ts +44 -0
  2. package/dist/category/commands/create.d.ts.map +1 -0
  3. package/dist/category/commands/create.spec.d.ts +7 -0
  4. package/dist/category/commands/create.spec.d.ts.map +1 -0
  5. package/dist/category/index.d.ts +19 -0
  6. package/dist/category/index.d.ts.map +1 -0
  7. package/dist/commands/init.d.ts +58 -0
  8. package/dist/commands/init.d.ts.map +1 -0
  9. package/dist/commands/init.spec.d.ts +2 -0
  10. package/dist/commands/init.spec.d.ts.map +1 -0
  11. package/dist/context.d.ts +18 -0
  12. package/dist/context.d.ts.map +1 -0
  13. package/dist/context.spec.d.ts +2 -0
  14. package/dist/context.spec.d.ts.map +1 -0
  15. package/dist/create-cli-command.d.ts +23 -0
  16. package/dist/create-cli-command.d.ts.map +1 -0
  17. package/dist/create-cli-command.spec.d.ts +10 -0
  18. package/dist/create-cli-command.spec.d.ts.map +1 -0
  19. package/dist/errors.d.ts +57 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/errors.spec.d.ts +2 -0
  22. package/dist/errors.spec.d.ts.map +1 -0
  23. package/dist/input.d.ts +42 -0
  24. package/dist/input.d.ts.map +1 -0
  25. package/dist/input.spec.d.ts +2 -0
  26. package/dist/input.spec.d.ts.map +1 -0
  27. package/dist/memory/commands/add.d.ts +62 -0
  28. package/dist/memory/commands/add.d.ts.map +1 -0
  29. package/dist/memory/commands/add.spec.d.ts +7 -0
  30. package/dist/memory/commands/add.spec.d.ts.map +1 -0
  31. package/dist/memory/commands/definitions.spec.d.ts +10 -0
  32. package/dist/memory/commands/definitions.spec.d.ts.map +1 -0
  33. package/dist/memory/commands/handlers.spec.d.ts +2 -0
  34. package/dist/memory/commands/handlers.spec.d.ts.map +1 -0
  35. package/dist/memory/commands/list.d.ts +119 -0
  36. package/dist/memory/commands/list.d.ts.map +1 -0
  37. package/dist/memory/commands/list.spec.d.ts +2 -0
  38. package/dist/memory/commands/list.spec.d.ts.map +1 -0
  39. package/dist/memory/commands/move.d.ts +42 -0
  40. package/dist/memory/commands/move.d.ts.map +1 -0
  41. package/dist/memory/commands/move.spec.d.ts +2 -0
  42. package/dist/memory/commands/move.spec.d.ts.map +1 -0
  43. package/dist/memory/commands/remove.d.ts +41 -0
  44. package/dist/memory/commands/remove.d.ts.map +1 -0
  45. package/dist/memory/commands/remove.spec.d.ts +2 -0
  46. package/dist/memory/commands/remove.spec.d.ts.map +1 -0
  47. package/dist/memory/commands/show.d.ts +81 -0
  48. package/dist/memory/commands/show.d.ts.map +1 -0
  49. package/dist/memory/commands/show.spec.d.ts +2 -0
  50. package/dist/memory/commands/show.spec.d.ts.map +1 -0
  51. package/dist/memory/commands/test-helpers.spec.d.ts +19 -0
  52. package/dist/memory/commands/test-helpers.spec.d.ts.map +1 -0
  53. package/dist/memory/commands/update.d.ts +73 -0
  54. package/dist/memory/commands/update.d.ts.map +1 -0
  55. package/dist/memory/commands/update.spec.d.ts +2 -0
  56. package/dist/memory/commands/update.spec.d.ts.map +1 -0
  57. package/dist/memory/index.d.ts +29 -0
  58. package/dist/memory/index.d.ts.map +1 -0
  59. package/dist/memory/index.spec.d.ts +10 -0
  60. package/dist/memory/index.spec.d.ts.map +1 -0
  61. package/dist/memory/parsing.d.ts +3 -0
  62. package/dist/memory/parsing.d.ts.map +1 -0
  63. package/dist/memory/parsing.spec.d.ts +7 -0
  64. package/dist/memory/parsing.spec.d.ts.map +1 -0
  65. package/dist/output.d.ts +87 -0
  66. package/dist/output.d.ts.map +1 -0
  67. package/dist/output.spec.d.ts +2 -0
  68. package/dist/output.spec.d.ts.map +1 -0
  69. package/dist/paths.d.ts +27 -0
  70. package/dist/paths.d.ts.map +1 -0
  71. package/dist/paths.spec.d.ts +7 -0
  72. package/dist/paths.spec.d.ts.map +1 -0
  73. package/dist/program.d.ts +41 -0
  74. package/dist/program.d.ts.map +1 -0
  75. package/dist/program.spec.d.ts +11 -0
  76. package/dist/program.spec.d.ts.map +1 -0
  77. package/dist/run.d.ts +7 -0
  78. package/dist/run.d.ts.map +1 -0
  79. package/dist/run.spec.d.ts +12 -0
  80. package/dist/run.spec.d.ts.map +1 -0
  81. package/dist/store/commands/add.d.ts +73 -0
  82. package/dist/store/commands/add.d.ts.map +1 -0
  83. package/dist/store/commands/add.spec.d.ts +17 -0
  84. package/dist/store/commands/add.spec.d.ts.map +1 -0
  85. package/dist/store/commands/init.d.ts +75 -0
  86. package/dist/store/commands/init.d.ts.map +1 -0
  87. package/dist/store/commands/init.spec.d.ts +7 -0
  88. package/dist/store/commands/init.spec.d.ts.map +1 -0
  89. package/dist/store/commands/list.d.ts +62 -0
  90. package/dist/store/commands/list.d.ts.map +1 -0
  91. package/dist/store/commands/list.spec.d.ts +7 -0
  92. package/dist/store/commands/list.spec.d.ts.map +1 -0
  93. package/dist/store/commands/prune.d.ts +92 -0
  94. package/dist/store/commands/prune.d.ts.map +1 -0
  95. package/dist/store/commands/prune.spec.d.ts +7 -0
  96. package/dist/store/commands/prune.spec.d.ts.map +1 -0
  97. package/dist/store/commands/reindexs.d.ts +54 -0
  98. package/dist/store/commands/reindexs.d.ts.map +1 -0
  99. package/dist/store/commands/reindexs.spec.d.ts +7 -0
  100. package/dist/store/commands/reindexs.spec.d.ts.map +1 -0
  101. package/dist/store/commands/remove.d.ts +63 -0
  102. package/dist/store/commands/remove.d.ts.map +1 -0
  103. package/dist/store/commands/remove.spec.d.ts +17 -0
  104. package/dist/store/commands/remove.spec.d.ts.map +1 -0
  105. package/dist/store/index.d.ts +32 -0
  106. package/dist/store/index.d.ts.map +1 -0
  107. package/dist/store/index.spec.d.ts +9 -0
  108. package/dist/store/index.spec.d.ts.map +1 -0
  109. package/dist/store/utils/resolve-store-name.d.ts +30 -0
  110. package/dist/store/utils/resolve-store-name.d.ts.map +1 -0
  111. package/dist/store/utils/resolve-store-name.spec.d.ts +2 -0
  112. package/dist/store/utils/resolve-store-name.spec.d.ts.map +1 -0
  113. package/dist/test-helpers.spec.d.ts +224 -0
  114. package/dist/test-helpers.spec.d.ts.map +1 -0
  115. package/dist/tests/cli.integration.spec.d.ts +11 -0
  116. package/dist/tests/cli.integration.spec.d.ts.map +1 -0
  117. package/dist/toon.d.ts +197 -0
  118. package/dist/toon.d.ts.map +1 -0
  119. package/dist/toon.spec.d.ts +9 -0
  120. package/dist/toon.spec.d.ts.map +1 -0
  121. package/dist/utils/git.d.ts +20 -0
  122. package/dist/utils/git.d.ts.map +1 -0
  123. package/dist/utils/git.spec.d.ts +7 -0
  124. package/dist/utils/git.spec.d.ts.map +1 -0
  125. package/package.json +3 -3
  126. package/src/run.ts +0 -0
  127. package/src/tests/cli.integration.spec.ts +79 -270
  128. package/src/utils/input.ts +4 -9
  129. package/src/utils/resolve-default-store.spec.ts +1 -1
  130. package/src/utils/resolve-default-store.ts +2 -6
@@ -0,0 +1,41 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=remove.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.spec.d.ts","sourceRoot":"","sources":["../../../src/memory/commands/remove.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,81 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=show.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"show.spec.d.ts","sourceRoot":"","sources":["../../../src/memory/commands/show.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Memory update command implementation using Commander.js.
3
+ *
4
+ * Updates an existing memory at the specified path with new content, tags,
5
+ * or expiration date.
6
+ *
7
+ * @example
8
+ * ```bash
9
+ * # Update memory content inline
10
+ * cortex memory update project/tech-stack --content "Updated stack: TypeScript"
11
+ *
12
+ * # Update memory content from a file
13
+ * cortex memory update project/notes --file ./updated-notes.md
14
+ *
15
+ * # Update tags
16
+ * cortex memory update project/tech-stack --tags "typescript,nodejs,updated"
17
+ *
18
+ * # Update expiration date
19
+ * cortex memory update project/temp --expires-at "2026-12-31T00:00:00Z"
20
+ *
21
+ * # Clear expiration date
22
+ * cortex memory update project/temp --no-expires-at
23
+ *
24
+ * # Update from a specific store
25
+ * cortex memory --store work update project/notes --content "New content"
26
+ * ```
27
+ */
28
+ import { Command } from '@commander-js/extra-typings';
29
+ import { type CortexContext } from '@yeseh/cortex-core';
30
+ /** Options parsed by Commander for the update command */
31
+ export interface UpdateCommandOptions {
32
+ content?: string;
33
+ file?: string;
34
+ tags?: string[];
35
+ /**
36
+ * Expiration date from Commander.js option parsing.
37
+ * - `string` — ISO 8601 date provided via `--expires-at <date>`
38
+ * - `false` — expiration cleared via `--no-expires-at` negation flag
39
+ * - `undefined` (omitted) — keep the existing value unchanged
40
+ */
41
+ expiresAt?: string | false;
42
+ citation?: string[];
43
+ format?: string;
44
+ }
45
+ /**
46
+ * Handler for the memory update command.
47
+ * Exported for direct testing without Commander parsing.
48
+ *
49
+ * @param ctx - CLI context containing Cortex client and streams
50
+ * @param storeName - Optional store name from parent command
51
+ * @param path - Memory path to update (e.g., "project/tech-stack")
52
+ * @param options - Command options from Commander
53
+ */
54
+ export declare function handleUpdate(ctx: CortexContext, storeName: string | undefined, path: string, options: UpdateCommandOptions): Promise<void>;
55
+ /**
56
+ * The `memory update` subcommand.
57
+ *
58
+ * Updates an existing memory at the specified path. Can update:
59
+ * - Content via `--content` flag for inline text or `--file` to read from a file
60
+ * - Tags via `--tags` flag (replaces existing tags)
61
+ * - Expiration via `--expires-at` or `--no-expires-at`
62
+ *
63
+ * The `--store` option is inherited from the parent `memory` command.
64
+ */
65
+ export declare const updateCommand: Command<[string], {
66
+ content?: string | undefined;
67
+ file?: string | undefined;
68
+ tags?: string[] | undefined;
69
+ expiresAt?: string | false | undefined;
70
+ citation?: string[] | undefined;
71
+ format?: string | undefined;
72
+ }, {}>;
73
+ //# sourceMappingURL=update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/memory/commands/update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,OAAO,EAAc,KAAK,aAAa,EAA0B,MAAM,oBAAoB,CAAC;AAM5F,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AA2ED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAC9B,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,oBAAoB,GAC9B,OAAO,CAAC,IAAI,CAAC,CA2Df;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa;;;;;;;MAkBpB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=update.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.spec.d.ts","sourceRoot":"","sources":["../../../src/memory/commands/update.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Memory command group for the CLI.
3
+ *
4
+ * This module defines the `memory` command group, which provides operations
5
+ * for managing memories in the Cortex memory system. The `--store` option
6
+ * is defined at the group level and inherited by all subcommands.
7
+ *
8
+ * @example
9
+ * ```bash
10
+ * # Use default store
11
+ * cortex memory add project/notes --content "Hello"
12
+ *
13
+ * # Use specific store
14
+ * cortex memory --store my-store add project/notes --content "Hello"
15
+ * cortex memory -s my-store list
16
+ * ```
17
+ */
18
+ import { Command } from '@commander-js/extra-typings';
19
+ /**
20
+ * The `memory` command group.
21
+ *
22
+ * Provides memory management operations. The `--store` option allows
23
+ * targeting a specific named store instead of the default store.
24
+ * This option is inherited by all subcommands.
25
+ */
26
+ export declare const memoryCommand: Command<[], {
27
+ store?: string | undefined;
28
+ }, {}>;
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memory/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAStD;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;MAEqC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Unit tests for memory command group wiring.
3
+ *
4
+ * Verifies that the `memory` command group is correctly configured with
5
+ * the expected name, description, options, and subcommands.
6
+ *
7
+ * @module cli/memory/index.spec
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=index.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../src/memory/index.spec.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -0,0 +1,3 @@
1
+ export declare const parseTags: (raw?: string[]) => string[];
2
+ export declare const parseExpiresAt: (raw?: string) => Date | undefined;
3
+ //# sourceMappingURL=parsing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parsing.d.ts","sourceRoot":"","sources":["../../src/memory/parsing.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,EAAE,KAAG,MAAM,EAMrC,CAAC;AAEb,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,IAAI,GAAG,SAWpD,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Unit tests for memory/parsing.ts
3
+ *
4
+ * @module cli/memory/parsing.spec
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=parsing.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parsing.spec.d.ts","sourceRoot":"","sources":["../../src/memory/parsing.spec.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Output format types and serialization helpers.
3
+ *
4
+ * This module provides type definitions for CLI output payloads and a thin
5
+ * wrapper around the core serialize function. Validation is expected to happen
6
+ * at object construction time, not during serialization.
7
+ */
8
+ import { type Result } from '@yeseh/cortex-core';
9
+ import { type OutputFormat } from '@yeseh/cortex-core';
10
+ export type { OutputFormat };
11
+ export interface OutputMemoryMetadata {
12
+ createdAt: Date;
13
+ updatedAt?: Date;
14
+ tags: string[];
15
+ source?: string;
16
+ tokenEstimate?: number;
17
+ expiresAt?: Date;
18
+ }
19
+ export interface OutputMemory {
20
+ path: string;
21
+ metadata: OutputMemoryMetadata;
22
+ content: string;
23
+ }
24
+ export interface OutputCategoryMemory {
25
+ path: string;
26
+ tokenEstimate?: number;
27
+ summary?: string;
28
+ }
29
+ export interface OutputSubcategory {
30
+ path: string;
31
+ memoryCount: number;
32
+ }
33
+ export interface OutputCategory {
34
+ path: string;
35
+ memories: OutputCategoryMemory[];
36
+ subcategories: OutputSubcategory[];
37
+ }
38
+ export interface OutputStore {
39
+ name: string;
40
+ path: string;
41
+ }
42
+ export interface OutputStoreRegistry {
43
+ stores: OutputStore[];
44
+ }
45
+ export interface OutputStoreInit {
46
+ path: string;
47
+ name: string;
48
+ }
49
+ export interface OutputInit {
50
+ path: string;
51
+ categories: string[];
52
+ }
53
+ export type OutputPayload = {
54
+ kind: 'memory';
55
+ value: OutputMemory;
56
+ } | {
57
+ kind: 'category';
58
+ value: OutputCategory;
59
+ } | {
60
+ kind: 'store';
61
+ value: OutputStore;
62
+ } | {
63
+ kind: 'store-registry';
64
+ value: OutputStoreRegistry;
65
+ } | {
66
+ kind: 'store-init';
67
+ value: OutputStoreInit;
68
+ } | {
69
+ kind: 'init';
70
+ value: OutputInit;
71
+ };
72
+ export interface OutputSerializeError {
73
+ code: 'INVALID_FORMAT' | 'SERIALIZE_FAILED';
74
+ message: string;
75
+ }
76
+ /**
77
+ * Serialize an output payload to the specified format.
78
+ *
79
+ * This is a thin wrapper around the core serialize function that extracts
80
+ * the value from the discriminated union and handles errors.
81
+ *
82
+ * @param payload - The output payload to serialize
83
+ * @param format - The output format ('yaml', 'json', or 'toon')
84
+ * @returns Result with serialized string or error
85
+ */
86
+ export declare const serializeOutput: (payload: unknown, format: OutputFormat) => Result<string, OutputSerializeError>;
87
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAa,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlE,YAAY,EAAE,YAAY,EAAE,CAAC;AAE7B,MAAM,WAAW,oBAAoB;IACjC,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,oBAAoB,EAAE,CAAC;IACjC,aAAa,EAAE,iBAAiB,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,WAAW,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,MAAM,aAAa,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,KAAK,EAAE,mBAAmB,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,eAAe,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CAAC;AAE1C,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAE,gBAAgB,GAAG,kBAAkB,CAAC;IAC5C,OAAO,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GACxB,SAAS,OAAO,EAChB,QAAQ,YAAY,KACrB,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAWrC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=output.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.spec.d.ts","sourceRoot":"","sources":["../src/output.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Path resolution utilities for CLI commands.
3
+ *
4
+ * Provides cross-platform path handling including:
5
+ * - Home directory (~) expansion
6
+ * - Absolute path detection (Unix, Windows drive, UNC)
7
+ * - Relative path resolution
8
+ */
9
+ /**
10
+ * Checks if a path is absolute.
11
+ * Handles Unix paths, Windows drive paths (C:\), and UNC paths (\\server).
12
+ */
13
+ export declare function isAbsolutePath(inputPath: string): boolean;
14
+ /**
15
+ * Resolves a user-provided path to an absolute path.
16
+ *
17
+ * Handles:
18
+ * - Home directory expansion (~)
19
+ * - Absolute paths (returned as-is, normalized)
20
+ * - Relative paths (resolved against cwd)
21
+ *
22
+ * @param inputPath - The path to resolve
23
+ * @param cwd - Current working directory for relative path resolution
24
+ * @returns Normalized absolute path
25
+ */
26
+ export declare function resolveUserPath(inputPath: string, cwd: string): string;
27
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAQzD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAYtE"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Unit tests for CLI path resolution utilities.
3
+ *
4
+ * @module cli/paths.spec
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=paths.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.spec.d.ts","sourceRoot":"","sources":["../src/paths.spec.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Commander.js program setup for Cortex CLI.
3
+ *
4
+ * This module sets up the main Commander program and wires together
5
+ * all command groups. It serves as the entry point for the CLI.
6
+ *
7
+ * @module cli/program
8
+ */
9
+ import { Command } from '@commander-js/extra-typings';
10
+ /**
11
+ * The main Commander program instance for Cortex CLI.
12
+ *
13
+ * Configured with:
14
+ * - Name: cortex
15
+ * - Description: Memory system for AI agents
16
+ * - Version: 0.1.0
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { program } from './program.ts';
21
+ * await program.parseAsync(process.argv);
22
+ * ```
23
+ */
24
+ declare const program: Command<[], {}, {}>;
25
+ export { program };
26
+ /**
27
+ * Runs the CLI program by parsing command-line arguments.
28
+ *
29
+ * This function handles errors gracefully and sets the appropriate
30
+ * exit code on failure.
31
+ *
32
+ * @returns A promise that resolves when the program completes
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * import { runProgram } from './program.ts';
37
+ * await runProgram();
38
+ * ```
39
+ */
40
+ export declare const runProgram: () => Promise<void>;
41
+ //# sourceMappingURL=program.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAOtD;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,OAAO,qBAGQ,CAAC;AAOtB,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,QAAa,OAAO,CAAC,IAAI,CAe/C,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Unit tests for the Commander.js program setup and runProgram entrypoint.
3
+ *
4
+ * Verifies that the program is correctly wired with the expected name,
5
+ * version, and top-level subcommands, and that `runProgram` is exported
6
+ * as a callable function.
7
+ *
8
+ * @module cli/program.spec
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=program.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program.spec.d.ts","sourceRoot":"","sources":["../src/program.spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
package/dist/run.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * CLI runner script for integration testing.
4
+ * This script is spawned as a subprocess by the integration tests.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":";AACA;;;GAGG"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Unit tests for the run.ts CLI entrypoint.
3
+ *
4
+ * `run.ts` is a side-effect-only module that calls `runProgram()` on import.
5
+ * Because importing it would immediately parse `process.argv`, we do NOT
6
+ * import it directly in tests. Instead we verify that the function it
7
+ * delegates to (`runProgram`) is correctly exported from `program.ts`.
8
+ *
9
+ * @module cli/run.spec
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=run.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.spec.d.ts","sourceRoot":"","sources":["../src/run.spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Store add command for registering a new store.
3
+ *
4
+ * This command registers a new store in the global registry with a given
5
+ * name and filesystem path. Paths are resolved relative to the current
6
+ * working directory, with support for tilde expansion.
7
+ *
8
+ * @example
9
+ * ```bash
10
+ * # Register a store with an absolute path
11
+ * cortex store add work /path/to/work/memories
12
+ *
13
+ * # Register a store with a relative path
14
+ * cortex store add project ./cortex
15
+ *
16
+ * # Register a store with tilde expansion
17
+ * cortex store add personal ~/memories
18
+ * ```
19
+ */
20
+ import { Command } from '@commander-js/extra-typings';
21
+ import { type CortexContext } from '@yeseh/cortex-core';
22
+ /**
23
+ * Options for the add command.
24
+ */
25
+ export interface AddCommandOptions {
26
+ /** Output format (yaml, json, toon) */
27
+ format?: string;
28
+ }
29
+ /**
30
+ * Dependencies for the add command handler.
31
+ * Allows injection for testing.
32
+ */
33
+ export interface AddHandlerDeps {
34
+ /** Output stream for writing results (defaults to process.stdout) */
35
+ stdout?: NodeJS.WritableStream;
36
+ }
37
+ /**
38
+ * Handles the add command execution.
39
+ *
40
+ * This function:
41
+ * 1. Validates the store name format
42
+ * 2. Validates and resolves the store path
43
+ * 3. Checks if store already exists in context
44
+ * 4. Reads current config file
45
+ * 5. Adds the store to the config and saves
46
+ * 6. Outputs the result
47
+ *
48
+ * @param ctx - The CortexContext with loaded configuration
49
+ * @param name - The store name to register
50
+ * @param storePath - The filesystem path to the store
51
+ * @param options - Command options (format)
52
+ * @param deps - Optional dependencies for testing
53
+ * @throws {InvalidArgumentError} When the store name or path is invalid
54
+ * @throws {CommanderError} When the store already exists or config operations fail
55
+ */
56
+ export declare function handleAdd(ctx: CortexContext, name: string, storePath: string, options?: AddCommandOptions, deps?: AddHandlerDeps): Promise<void>;
57
+ /**
58
+ * The `add` subcommand for registering a new store.
59
+ *
60
+ * Registers a store with the given name and filesystem path. The path is
61
+ * resolved relative to the current working directory, with support for
62
+ * tilde expansion.
63
+ *
64
+ * @example
65
+ * ```bash
66
+ * cortex store add work /path/to/work/memories
67
+ * cortex store add project ./cortex --format json
68
+ * ```
69
+ */
70
+ export declare const addCommand: Command<[string, string], {
71
+ format: string;
72
+ }, {}>;
73
+ //# sourceMappingURL=add.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/store/commands/add.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAKtD,OAAO,EAAqB,KAAK,aAAa,EAAoB,MAAM,oBAAoB,CAAC;AAG7F;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC3B,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;CAClC;AAwDD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,SAAS,CAC3B,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,iBAAsB,EAC/B,IAAI,GAAE,cAAmB,GAC1B,OAAO,CAAC,IAAI,CAAC,CA8Ef;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU;;MAWjB,CAAC"}