@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 +0,0 @@
1
- {"version":3,"file":"list.spec.d.ts","sourceRoot":"","sources":["../../../src/store/commands/list.spec.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -1,92 +0,0 @@
1
- /**
2
- * Store prune command for removing expired memories.
3
- *
4
- * This command removes expired memories from the current store or a specified
5
- * store. It supports a dry-run mode to preview what would be deleted.
6
- *
7
- * @module cli/commands/store/prune
8
- *
9
- * @example
10
- * ```bash
11
- * # Prune expired memories from the current store
12
- * cortex store prune
13
- *
14
- * # Preview what would be pruned (dry-run)
15
- * cortex store prune --dry-run
16
- *
17
- * # Prune from a specific store
18
- * cortex --store work store prune
19
- * ```
20
- */
21
- import { Command } from '@commander-js/extra-typings';
22
- import { type CortexContext } from '@yeseh/cortex-core';
23
- /**
24
- * Options for the prune command.
25
- */
26
- export interface PruneCommandOptions {
27
- /** Show what would be pruned without actually deleting */
28
- dryRun?: boolean;
29
- }
30
- /**
31
- * Dependencies for the prune command handler.
32
- * Allows injection for testing.
33
- */
34
- export interface PruneHandlerDeps {
35
- /** Output stream for writing results (defaults to process.stdout) */
36
- stdout?: NodeJS.WritableStream;
37
- /** Current time for expiry checks (defaults to ctx.now()) */
38
- now?: Date;
39
- }
40
- /**
41
- * Handles the prune command execution.
42
- *
43
- * Thin CLI handler that delegates all business logic to the core
44
- * prune operation via CategoryClient. This handler is responsible
45
- * only for:
46
- * 1. Resolving the store via CortexContext
47
- * 2. Calling the category prune operation
48
- * 3. Formatting output for the CLI (dry-run preview vs. deletion summary)
49
- *
50
- * After pruning, the core operation automatically triggers a reindex to
51
- * clean up category indexes for removed memories.
52
- *
53
- * @module cli/commands/store/prune
54
- *
55
- * @param ctx - CortexContext providing access to Cortex client
56
- * @param storeName - Optional store name from the parent `--store` flag;
57
- * when `undefined`, resolves the default store
58
- * @param options - Command options controlling pruning behavior
59
- * @param options.dryRun - When `true`, lists expired memories without deleting
60
- * @param deps - Optional injected dependencies for testing
61
- * @throws {InvalidArgumentError} When the store cannot be resolved
62
- * (e.g., store name does not exist)
63
- * @throws {CommanderError} When the core prune operation fails
64
- * (e.g., I/O errors, serialization failures)
65
- *
66
- * @example
67
- * ```typescript
68
- * // Direct invocation in tests
69
- * const out = new PassThrough();
70
- * await handlePrune(ctx, 'my-store', { dryRun: true }, {
71
- * stdout: out,
72
- * now: new Date('2025-01-01'),
73
- * });
74
- * ```
75
- */
76
- export declare function handlePrune(ctx: CortexContext, storeName: string | undefined, options: PruneCommandOptions, deps?: PruneHandlerDeps): Promise<void>;
77
- /**
78
- * The `prune` subcommand for removing expired memories.
79
- *
80
- * Removes all expired memories from the store. Use --dry-run to preview
81
- * what would be deleted without actually removing anything.
82
- *
83
- * @example
84
- * ```bash
85
- * cortex store prune
86
- * cortex store prune --dry-run
87
- * ```
88
- */
89
- export declare const pruneCommand: Command<[], {
90
- dryRun?: true | undefined;
91
- }, {}>;
92
- //# sourceMappingURL=prune.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../../../src/store/commands/prune.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,0DAA0D;IAC1D,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC7B,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC/B,6DAA6D;IAC7D,GAAG,CAAC,EAAE,IAAI,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAsB,WAAW,CAC7B,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,OAAO,EAAE,mBAAmB,EAC5B,IAAI,GAAE,gBAAqB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAyCf;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY;;MAUnB,CAAC"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Unit tests for the store prune command handler.
3
- *
4
- * @module cli/store/commands/prune.spec
5
- */
6
- export {};
7
- //# sourceMappingURL=prune.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prune.spec.d.ts","sourceRoot":"","sources":["../../../src/store/commands/prune.spec.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -1,54 +0,0 @@
1
- /**
2
- * Store reindex command for rebuilding category indexes.
3
- *
4
- * This command rebuilds the category indexes for a store, which can help
5
- * repair corrupted indexes or synchronize them after manual file changes.
6
- *
7
- * @example
8
- * ```bash
9
- * # Reindex the default store
10
- * cortex store reindex
11
- *
12
- * # Reindex a specific named store
13
- * cortex store --store work reindex
14
- * ```
15
- */
16
- import { Command } from '@commander-js/extra-typings';
17
- import { type CortexContext } from '@yeseh/cortex-core';
18
- /**
19
- * Dependencies for the reindex command handler.
20
- * Allows injection for testing.
21
- */
22
- export interface ReindexHandlerDeps {
23
- /** Output stream for writing results (defaults to process.stdout) */
24
- stdout?: NodeJS.WritableStream;
25
- }
26
- /**
27
- * Handles the reindex command execution.
28
- *
29
- * This function:
30
- * 1. Resolves the store context (from --store option or default resolution)
31
- * 2. Gets the root category for the store
32
- * 3. Rebuilds the category indexes
33
- * 4. Outputs the result
34
- *
35
- * @param ctx - The Cortex context
36
- * @param storeName - Optional store name from parent --store option
37
- * @param deps - Optional dependencies for testing
38
- * @throws {CommanderError} When store resolution or reindexing fails
39
- */
40
- export declare function handleReindex(ctx: CortexContext, storeName: string | undefined, deps?: ReindexHandlerDeps): Promise<void>;
41
- /**
42
- * The `reindex` subcommand for rebuilding category indexes.
43
- *
44
- * Rebuilds the category indexes for a store, which can help repair corrupted
45
- * indexes or synchronize them after manual file changes.
46
- *
47
- * @example
48
- * ```bash
49
- * cortex store reindex
50
- * cortex store --store work reindex
51
- * ```
52
- */
53
- export declare const reindexCommand: Command<[], {}, {}>;
54
- //# sourceMappingURL=reindexs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reindexs.d.ts","sourceRoot":"","sources":["../../../src/store/commands/reindexs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAC/B,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;CAClC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,aAAa,CAC/B,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,IAAI,GAAE,kBAAuB,GAC9B,OAAO,CAAC,IAAI,CAAC,CAwBf;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,qBASrB,CAAC"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Unit tests for the store reindex command handler.
3
- *
4
- * @module cli/store/commands/reindexs.spec
5
- */
6
- export {};
7
- //# sourceMappingURL=reindexs.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reindexs.spec.d.ts","sourceRoot":"","sources":["../../../src/store/commands/reindexs.spec.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -1,63 +0,0 @@
1
- /**
2
- * Store remove command for unregistering a store.
3
- *
4
- * This command removes a store from the global registry. Note that this
5
- * only unregisters the store - it does not delete the actual data.
6
- *
7
- * @example
8
- * ```bash
9
- * # Remove a store from the registry
10
- * cortex store remove work
11
- * ```
12
- */
13
- import { Command } from '@commander-js/extra-typings';
14
- import { type CortexContext } from '@yeseh/cortex-core';
15
- /**
16
- * Options for the remove command.
17
- */
18
- export interface RemoveCommandOptions {
19
- /** Output format (yaml, json, toon) */
20
- format?: string;
21
- }
22
- /**
23
- * Dependencies for the remove command handler.
24
- * Allows injection for testing.
25
- */
26
- export interface RemoveHandlerDeps {
27
- /** Output stream for writing results (defaults to process.stdout) */
28
- stdout?: NodeJS.WritableStream;
29
- }
30
- /**
31
- * Handles the remove command execution.
32
- *
33
- * This function:
34
- * 1. Validates the store name format
35
- * 2. Checks that the store exists in context
36
- * 3. Reads current config file
37
- * 4. Removes the store from the config and saves
38
- * 5. Outputs the result
39
- *
40
- * @param ctx - The Cortex context
41
- * @param name - The store name to unregister
42
- * @param options - Command options (format)
43
- * @param deps - Optional dependencies for testing
44
- * @throws {InvalidArgumentError} When the store name is invalid
45
- * @throws {CommanderError} When the store doesn't exist or config operations fail
46
- */
47
- export declare function handleRemove(ctx: CortexContext, name: string, options?: RemoveCommandOptions, deps?: RemoveHandlerDeps): Promise<void>;
48
- /**
49
- * The `remove` subcommand for unregistering a store.
50
- *
51
- * Removes a store from the registry. This only unregisters the store
52
- * from the global registry - it does not delete the actual data.
53
- *
54
- * @example
55
- * ```bash
56
- * cortex store remove work
57
- * cortex store remove project --format json
58
- * ```
59
- */
60
- export declare const removeCommand: Command<[string], {
61
- format: string;
62
- }, {}>;
63
- //# sourceMappingURL=remove.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/store/commands/remove.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAItD,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAG3E;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAC9B,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;CAClC;AAwCD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,YAAY,CAC9B,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,oBAAyB,EAClC,IAAI,GAAE,iBAAsB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAmEf;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa;;MAUpB,CAAC"}
@@ -1,17 +0,0 @@
1
- /**
2
- * Unit tests for the store remove command handler.
3
- *
4
- * Note: `handleRemove` reads and writes the global config file via `Bun.file()` and
5
- * `Bun.write()`. These I/O calls are not dependency-injected, so the success
6
- * path is not testable at the unit level without filesystem mocking (prohibited
7
- * by project rules). Only the validation paths that throw before any I/O are
8
- * covered here.
9
- *
10
- * Slug normalization behavior: `Slug.from()` normalizes most inputs rather than
11
- * rejecting them. Only empty/whitespace strings fail `Slug.from()` and produce
12
- * `InvalidArgumentError`.
13
- *
14
- * @module cli/store/commands/remove.spec
15
- */
16
- export {};
17
- //# sourceMappingURL=remove.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remove.spec.d.ts","sourceRoot":"","sources":["../../../src/store/commands/remove.spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
@@ -1,32 +0,0 @@
1
- /**
2
- * Store command group for the Cortex CLI.
3
- *
4
- * Provides store management operations including listing, adding, removing,
5
- * and initializing memory stores. Also includes maintenance commands for
6
- * pruning expired memories and reindexing stores.
7
- *
8
- * The `--store` option is defined at the group level and inherited by all
9
- * subcommands, allowing users to specify which store to operate on.
10
- *
11
- * @example
12
- * ```bash
13
- * cortex store list # List all registered stores
14
- * cortex store add <name> <path> # Register a store
15
- * cortex store remove <name> # Unregister a store
16
- * cortex store init [path] # Initialize a new store
17
- * cortex store prune # Remove expired memories
18
- * cortex store reindex # Rebuild store indexes
19
- * ```
20
- */
21
- import { Command } from '@commander-js/extra-typings';
22
- export { resolveStoreName } from './utils/resolve-store-name.ts';
23
- /**
24
- * Store command group.
25
- *
26
- * The `--store` option is inherited by all subcommands, allowing operations
27
- * to target a specific named store rather than using automatic store resolution.
28
- */
29
- export declare const storeCommand: Command<[], {
30
- store?: string | undefined;
31
- }, {}>;
32
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAWtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,YAAY;;MAEsC,CAAC"}
@@ -1,9 +0,0 @@
1
- /**
2
- * Unit tests for store command group wiring.
3
- *
4
- * Verifies that the `store` command group is correctly configured.
5
- *
6
- * @module cli/store/index.spec
7
- */
8
- export {};
9
- //# sourceMappingURL=index.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../src/store/index.spec.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -1,30 +0,0 @@
1
- /**
2
- * Utility for resolving the store name using a priority-based strategy.
3
- *
4
- * Extracted into its own module to avoid a circular dependency:
5
- * store/commands/init.ts → store/index.ts → store/commands/init.ts
6
- *
7
- * @module cli/store/utils/resolve-store-name
8
- */
9
- /**
10
- * Resolves the store name using a priority-based strategy.
11
- *
12
- * Name resolution follows this precedence:
13
- * 1. **Explicit name** - If `--name` option is provided, use it directly
14
- * 2. **Git detection** - Auto-detect from git repository directory name
15
- * 3. **Folder name** - Use the current folder name if git detection fails
16
- * 4. **Error** - Fail with guidance to use `--name` flag
17
- *
18
- * Git repository names are normalized to valid store name format:
19
- * - Converted to lowercase
20
- * - Non-alphanumeric characters replaced with hyphens
21
- * - Leading/trailing hyphens removed
22
- *
23
- * @param cwd - Current working directory
24
- * @param explicitName - Optional explicit name provided via `--name` option
25
- * @returns The validated store name
26
- * @throws {InvalidArgumentError} When the name is invalid
27
- * @throws {CommanderError} When git detection fails and no name provided
28
- */
29
- export declare function resolveStoreName(cwd: string, explicitName?: string): Promise<string>;
30
- //# sourceMappingURL=resolve-store-name.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve-store-name.d.ts","sourceRoot":"","sources":["../../../src/store/utils/resolve-store-name.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA4C1F"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=resolve-store-name.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve-store-name.spec.d.ts","sourceRoot":"","sources":["../../../src/store/utils/resolve-store-name.spec.ts"],"names":[],"mappings":""}
@@ -1,224 +0,0 @@
1
- /**
2
- * Shared test helpers for CLI package unit tests.
3
- *
4
- * Exports reusable primitives for result construction, stream capture,
5
- * clock fixtures, CLI error assertions, and mock adapter/context factories.
6
- * All other spec files in this package import from this module.
7
- *
8
- * @module cli/_test-helpers
9
- */
10
- import { PassThrough } from 'node:stream';
11
- import type { StorageAdapter, MemoryStorage, IndexStorage, CategoryStorage, ConfigStores, CortexContext } from '@yeseh/cortex-core';
12
- /**
13
- * Constructs a minimal ok-shaped result for use in mock return values.
14
- *
15
- * @param value - The success value
16
- * @returns A plain object compatible with ok result checks
17
- *
18
- * @example
19
- * ```typescript
20
- * const result = okResult('hello');
21
- * expect(result.ok()).toBe(true);
22
- * expect(result.value).toBe('hello');
23
- * ```
24
- */
25
- export declare const okResult: <T>(value: T) => {
26
- ok: () => true;
27
- value: T;
28
- };
29
- /**
30
- * Constructs a minimal err-shaped result for use in mock return values.
31
- *
32
- * @param error - The error value
33
- * @returns A plain object compatible with err result checks
34
- *
35
- * @example
36
- * ```typescript
37
- * const result = errResult({ code: 'NOT_FOUND', message: 'not found' });
38
- * expect(result.ok()).toBe(false);
39
- * ```
40
- */
41
- export declare const errResult: <E>(error: E) => {
42
- ok: () => false;
43
- error: E;
44
- };
45
- /**
46
- * Creates a writable PassThrough stream and a helper to capture written text.
47
- *
48
- * @returns An object containing the stream and a `getOutput` function
49
- *
50
- * @example
51
- * ```typescript
52
- * const { stream, getOutput } = createWritableCapture();
53
- * stream.write('hello');
54
- * expect(getOutput()).toBe('hello');
55
- * ```
56
- */
57
- export declare function createWritableCapture(): {
58
- stream: PassThrough;
59
- getOutput: () => string;
60
- };
61
- /**
62
- * Creates a readable PassThrough stream pre-loaded with text.
63
- *
64
- * @param text - The text to pre-load into the stream
65
- * @returns A PassThrough stream with the given text already written
66
- *
67
- * @example
68
- * ```typescript
69
- * const stream = createReadableFromText('user input\n');
70
- * ```
71
- */
72
- export declare function createReadableFromText(text: string): PassThrough;
73
- /** ISO 8601 string for the fixed test clock date */
74
- export declare const FIXED_NOW_ISO = "2025-06-01T12:00:00.000Z";
75
- /** Fixed Date instance for use in tests */
76
- export declare const FIXED_NOW: Date;
77
- /**
78
- * Returns a `now` function that always returns the given ISO date.
79
- *
80
- * @param iso - ISO 8601 string (defaults to {@link FIXED_NOW_ISO})
81
- * @returns A zero-argument function returning the fixed Date
82
- *
83
- * @example
84
- * ```typescript
85
- * const ctx = createMockContext({ now: fixedNow('2025-01-01T00:00:00.000Z') });
86
- * ```
87
- */
88
- export declare const fixedNow: (iso?: string) => (() => Date);
89
- /**
90
- * Asserts that the given function throws an `InvalidArgumentError`.
91
- *
92
- * @param fn - Sync or async function expected to throw
93
- * @param messagePart - Optional substring the error message must contain
94
- *
95
- * @example
96
- * ```typescript
97
- * await expectInvalidArgumentError(
98
- * () => parseMemoryPath(''),
99
- * 'must not be empty',
100
- * );
101
- * ```
102
- */
103
- export declare function expectInvalidArgumentError(fn: () => Promise<unknown> | unknown, messagePart?: string): Promise<void>;
104
- /**
105
- * Asserts that the given function throws a `CommanderError`.
106
- *
107
- * @param fn - Sync or async function expected to throw
108
- * @param codePart - Optional substring the error's `.code` must contain
109
- * @param messagePart - Optional substring the error message must contain
110
- *
111
- * @example
112
- * ```typescript
113
- * await expectCommanderError(
114
- * () => handleAdd(ctx, args, 'missing-store'),
115
- * 'commander.storeNotFound',
116
- * );
117
- * ```
118
- */
119
- export declare function expectCommanderError(fn: () => Promise<unknown> | unknown, codePart?: string, messagePart?: string): Promise<void>;
120
- /**
121
- * Creates a minimal mock MemoryStorage with sensible defaults.
122
- *
123
- * @param overrides - Partial overrides for individual methods
124
- * @returns A fully-typed MemoryStorage mock
125
- *
126
- * @example
127
- * ```typescript
128
- * const memories = createMockMemoryStorage({
129
- * load: async () => ok(sampleMemory),
130
- * });
131
- * ```
132
- */
133
- export declare function createMockMemoryStorage(overrides?: Partial<MemoryStorage>): MemoryStorage;
134
- /**
135
- * Creates a minimal mock IndexStorage with sensible defaults.
136
- *
137
- * @param overrides - Partial overrides for individual methods
138
- * @returns A fully-typed IndexStorage mock
139
- *
140
- * @example
141
- * ```typescript
142
- * const indexes = createMockIndexStorage({
143
- * load: async () => ok({ memories: [], subcategories: [] }),
144
- * });
145
- * ```
146
- */
147
- export declare function createMockIndexStorage(overrides?: Partial<IndexStorage>): IndexStorage;
148
- /**
149
- * Creates a minimal mock CategoryStorage with sensible defaults.
150
- *
151
- * @param overrides - Partial overrides for individual methods
152
- * @returns A fully-typed CategoryStorage mock
153
- *
154
- * @example
155
- * ```typescript
156
- * const categories = createMockCategoryStorage({
157
- * exists: async () => ok(true),
158
- * });
159
- * ```
160
- */
161
- export declare function createMockCategoryStorage(overrides?: Partial<CategoryStorage>): CategoryStorage;
162
- /**
163
- * Creates a minimal mock StorageAdapter composed of mock sub-adapters.
164
- *
165
- * @param overrides - Partial overrides for individual sub-adapters
166
- * @returns A fully-typed StorageAdapter mock
167
- *
168
- * @example
169
- * ```typescript
170
- * const adapter = createMockStorageAdapter({
171
- * memories: createMockMemoryStorage({ load: async () => ok(null) }),
172
- * });
173
- * ```
174
- */
175
- export declare function createMockStorageAdapter(overrides?: Partial<StorageAdapter>): StorageAdapter;
176
- /** Options for {@link createMockContext} */
177
- export interface MockContextOptions {
178
- /** Override the storage adapter (defaults to {@link createMockStorageAdapter}) */
179
- adapter?: StorageAdapter;
180
- /** Override the store configuration (defaults to a single in-memory mock store) */
181
- stores?: ConfigStores;
182
- /** Override the clock (defaults to {@link fixedNow}) */
183
- now?: () => Date;
184
- /** Override the current working directory */
185
- cwd?: string;
186
- }
187
- /** Result of {@link createMockContext} */
188
- export interface MockContextResult {
189
- ctx: CortexContext;
190
- stdout: PassThrough;
191
- stdin: PassThrough;
192
- }
193
- /**
194
- * Creates a {@link CortexContext} backed by a real Cortex.init() with a mock adapter.
195
- *
196
- * @param overrides - Optional overrides for adapter, stores, clock, and cwd
197
- * @returns An object with the context and the raw stdout/stdin PassThrough streams
198
- *
199
- * @example
200
- * ```typescript
201
- * const { ctx, stdout } = createMockContext();
202
- * await handleAdd(ctx, args, 'default', {});
203
- * expect(captureOutput(stdout)).toContain('Memory added');
204
- * ```
205
- */
206
- export declare function createMockContext(overrides?: MockContextOptions): MockContextResult;
207
- /**
208
- * Reads all buffered output from a PassThrough stream synchronously.
209
- *
210
- * Drains already-buffered data without consuming future writes.
211
- * Useful for asserting output after a handler has finished writing.
212
- *
213
- * @param stream - The PassThrough stream to drain
214
- * @returns The concatenated string of all buffered chunks
215
- *
216
- * @example
217
- * ```typescript
218
- * const { ctx, stdout } = createMockContext();
219
- * await handleList(ctx, {}, 'default', {});
220
- * expect(captureOutput(stdout)).toContain('No memories found');
221
- * ```
222
- */
223
- export declare function captureOutput(stream: PassThrough): string;
224
- //# sourceMappingURL=test-helpers.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-helpers.spec.d.ts","sourceRoot":"","sources":["../src/test-helpers.spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EACR,cAAc,EACd,aAAa,EACb,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,aAAa,EAChB,MAAM,oBAAoB,CAAC;AAO5B;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG;IAAE,EAAE,EAAE,MAAM,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAG/D,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG;IAAE,EAAE,EAAE,MAAM,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAGjE,CAAC;AAMH;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,IAAI;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,MAAM,MAAM,CAAA;CAAE,CAOxF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAIhE;AAMD,oDAAoD;AACpD,eAAO,MAAM,aAAa,6BAA6B,CAAC;AAExD,2CAA2C;AAC3C,eAAO,MAAM,SAAS,MAA0B,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,GAChB,MAAK,MAAsB,KAAG,CAAC,MAAM,IAAI,CAEzB,CAAC;AAMtB;;;;;;;;;;;;;GAaG;AACH,wBAAsB,0BAA0B,CAC5C,EAAE,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,EACpC,WAAW,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAcf;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,oBAAoB,CACtC,EAAE,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,EACpC,QAAQ,CAAC,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAiBf;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,GAAE,OAAO,CAAC,aAAa,CAAM,GAAG,aAAa,CAY7F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,GAAE,OAAO,CAAC,YAAY,CAAM,GAAG,YAAY,CAQ1F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CACrC,SAAS,GAAE,OAAO,CAAC,eAAe,CAAM,GACzC,eAAe,CAQjB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,GAAE,OAAO,CAAC,cAAc,CAAM,GAAG,cAAc,CAkBhG;AAED,4CAA4C;AAC5C,MAAM,WAAW,kBAAkB;IAC/B,kFAAkF;IAClF,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,mFAAmF;IACnF,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,6CAA6C;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,0CAA0C;AAC1C,MAAM,WAAW,iBAAiB;IAC9B,GAAG,EAAE,aAAa,CAAC;IACnB,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,CAAC,EAAE,kBAAkB,GAAG,iBAAiB,CA2BnF;AAMD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAOzD"}
@@ -1,11 +0,0 @@
1
- /**
2
- * Comprehensive integration tests for the Cortex CLI with Commander.js.
3
- *
4
- * These tests spawn the CLI as a subprocess using Bun shell to test
5
- * the CLI like a user would interact with it.
6
- *
7
- * The tests use local store resolution by creating a project directory
8
- * with a `.cortex/memory` subdirectory structure.
9
- */
10
- export {};
11
- //# sourceMappingURL=cli.integration.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.integration.spec.d.ts","sourceRoot":"","sources":["../../src/tests/cli.integration.spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}