@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.
- package/dist/category/commands/create.d.ts +44 -0
- package/dist/category/commands/create.d.ts.map +1 -0
- package/dist/category/commands/create.spec.d.ts +7 -0
- package/dist/category/commands/create.spec.d.ts.map +1 -0
- package/dist/category/index.d.ts +19 -0
- package/dist/category/index.d.ts.map +1 -0
- package/dist/commands/init.d.ts +58 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.spec.d.ts +2 -0
- package/dist/commands/init.spec.d.ts.map +1 -0
- package/dist/context.d.ts +18 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.spec.d.ts +2 -0
- package/dist/context.spec.d.ts.map +1 -0
- package/dist/create-cli-command.d.ts +23 -0
- package/dist/create-cli-command.d.ts.map +1 -0
- package/dist/create-cli-command.spec.d.ts +10 -0
- package/dist/create-cli-command.spec.d.ts.map +1 -0
- package/dist/errors.d.ts +57 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.spec.d.ts +2 -0
- package/dist/errors.spec.d.ts.map +1 -0
- package/dist/input.d.ts +42 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/input.spec.d.ts +2 -0
- package/dist/input.spec.d.ts.map +1 -0
- package/dist/memory/commands/add.d.ts +62 -0
- package/dist/memory/commands/add.d.ts.map +1 -0
- package/dist/memory/commands/add.spec.d.ts +7 -0
- package/dist/memory/commands/add.spec.d.ts.map +1 -0
- package/dist/memory/commands/definitions.spec.d.ts +10 -0
- package/dist/memory/commands/definitions.spec.d.ts.map +1 -0
- package/dist/memory/commands/handlers.spec.d.ts +2 -0
- package/dist/memory/commands/handlers.spec.d.ts.map +1 -0
- package/dist/memory/commands/list.d.ts +119 -0
- package/dist/memory/commands/list.d.ts.map +1 -0
- package/dist/memory/commands/list.spec.d.ts +2 -0
- package/dist/memory/commands/list.spec.d.ts.map +1 -0
- package/dist/memory/commands/move.d.ts +42 -0
- package/dist/memory/commands/move.d.ts.map +1 -0
- package/dist/memory/commands/move.spec.d.ts +2 -0
- package/dist/memory/commands/move.spec.d.ts.map +1 -0
- package/dist/memory/commands/remove.d.ts +41 -0
- package/dist/memory/commands/remove.d.ts.map +1 -0
- package/dist/memory/commands/remove.spec.d.ts +2 -0
- package/dist/memory/commands/remove.spec.d.ts.map +1 -0
- package/dist/memory/commands/show.d.ts +81 -0
- package/dist/memory/commands/show.d.ts.map +1 -0
- package/dist/memory/commands/show.spec.d.ts +2 -0
- package/dist/memory/commands/show.spec.d.ts.map +1 -0
- package/dist/memory/commands/test-helpers.spec.d.ts +19 -0
- package/dist/memory/commands/test-helpers.spec.d.ts.map +1 -0
- package/dist/memory/commands/update.d.ts +73 -0
- package/dist/memory/commands/update.d.ts.map +1 -0
- package/dist/memory/commands/update.spec.d.ts +2 -0
- package/dist/memory/commands/update.spec.d.ts.map +1 -0
- package/dist/memory/index.d.ts +29 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.spec.d.ts +10 -0
- package/dist/memory/index.spec.d.ts.map +1 -0
- package/dist/memory/parsing.d.ts +3 -0
- package/dist/memory/parsing.d.ts.map +1 -0
- package/dist/memory/parsing.spec.d.ts +7 -0
- package/dist/memory/parsing.spec.d.ts.map +1 -0
- package/dist/output.d.ts +87 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.spec.d.ts +2 -0
- package/dist/output.spec.d.ts.map +1 -0
- package/dist/paths.d.ts +27 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.spec.d.ts +7 -0
- package/dist/paths.spec.d.ts.map +1 -0
- package/dist/program.d.ts +41 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.spec.d.ts +11 -0
- package/dist/program.spec.d.ts.map +1 -0
- package/dist/run.d.ts +7 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.spec.d.ts +12 -0
- package/dist/run.spec.d.ts.map +1 -0
- package/dist/store/commands/add.d.ts +73 -0
- package/dist/store/commands/add.d.ts.map +1 -0
- package/dist/store/commands/add.spec.d.ts +17 -0
- package/dist/store/commands/add.spec.d.ts.map +1 -0
- package/dist/store/commands/init.d.ts +75 -0
- package/dist/store/commands/init.d.ts.map +1 -0
- package/dist/store/commands/init.spec.d.ts +7 -0
- package/dist/store/commands/init.spec.d.ts.map +1 -0
- package/dist/store/commands/list.d.ts +62 -0
- package/dist/store/commands/list.d.ts.map +1 -0
- package/dist/store/commands/list.spec.d.ts +7 -0
- package/dist/store/commands/list.spec.d.ts.map +1 -0
- package/dist/store/commands/prune.d.ts +92 -0
- package/dist/store/commands/prune.d.ts.map +1 -0
- package/dist/store/commands/prune.spec.d.ts +7 -0
- package/dist/store/commands/prune.spec.d.ts.map +1 -0
- package/dist/store/commands/reindexs.d.ts +54 -0
- package/dist/store/commands/reindexs.d.ts.map +1 -0
- package/dist/store/commands/reindexs.spec.d.ts +7 -0
- package/dist/store/commands/reindexs.spec.d.ts.map +1 -0
- package/dist/store/commands/remove.d.ts +63 -0
- package/dist/store/commands/remove.d.ts.map +1 -0
- package/dist/store/commands/remove.spec.d.ts +17 -0
- package/dist/store/commands/remove.spec.d.ts.map +1 -0
- package/dist/store/index.d.ts +32 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.spec.d.ts +9 -0
- package/dist/store/index.spec.d.ts.map +1 -0
- package/dist/store/utils/resolve-store-name.d.ts +30 -0
- package/dist/store/utils/resolve-store-name.d.ts.map +1 -0
- package/dist/store/utils/resolve-store-name.spec.d.ts +2 -0
- package/dist/store/utils/resolve-store-name.spec.d.ts.map +1 -0
- package/dist/test-helpers.spec.d.ts +224 -0
- package/dist/test-helpers.spec.d.ts.map +1 -0
- package/dist/tests/cli.integration.spec.d.ts +11 -0
- package/dist/tests/cli.integration.spec.d.ts.map +1 -0
- package/dist/toon.d.ts +197 -0
- package/dist/toon.d.ts.map +1 -0
- package/dist/toon.spec.d.ts +9 -0
- package/dist/toon.spec.d.ts.map +1 -0
- package/dist/utils/git.d.ts +20 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.spec.d.ts +7 -0
- package/dist/utils/git.spec.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/run.ts +0 -0
- package/src/tests/cli.integration.spec.ts +79 -270
- package/src/utils/input.ts +4 -9
- package/src/utils/resolve-default-store.spec.ts +1 -1
- package/src/utils/resolve-default-store.ts +2 -6
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for the store add command handler.
|
|
3
|
+
*
|
|
4
|
+
* Note: `handleAdd` 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 (e.g. 'INVALID' → 'invalid', 'my store' → 'my-store'). Only
|
|
12
|
+
* empty/whitespace strings fail `Slug.from()` and produce `InvalidArgumentError`.
|
|
13
|
+
*
|
|
14
|
+
* @module cli/store/commands/add.spec
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=add.spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.spec.d.ts","sourceRoot":"","sources":["../../../src/store/commands/add.spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Store init command for initializing a new memory store.
|
|
3
|
+
*
|
|
4
|
+
* This command creates a new memory store at the specified path (or current
|
|
5
|
+
* directory) and registers it in the global registry. The store name is
|
|
6
|
+
* either explicitly provided via --name or auto-detected from the git
|
|
7
|
+
* repository name.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```bash
|
|
11
|
+
* # Initialize store with auto-detected name from git repo
|
|
12
|
+
* cortex store init
|
|
13
|
+
*
|
|
14
|
+
* # Initialize store with explicit name
|
|
15
|
+
* cortex store init --name my-project
|
|
16
|
+
*
|
|
17
|
+
* # Initialize store at a specific path
|
|
18
|
+
* cortex store init ./my-store --name my-project
|
|
19
|
+
*
|
|
20
|
+
* # Initialize store with tilde expansion
|
|
21
|
+
* cortex store init ~/memories --name personal
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
import { Command } from '@commander-js/extra-typings';
|
|
25
|
+
import { type CategoryMode, type CortexContext } from '@yeseh/cortex-core';
|
|
26
|
+
/**
|
|
27
|
+
* Options for the init command.
|
|
28
|
+
*/
|
|
29
|
+
export interface InitCommandOptions {
|
|
30
|
+
/** Explicit store name (otherwise auto-detected from git) */
|
|
31
|
+
name?: string;
|
|
32
|
+
/** Category mode for the store */
|
|
33
|
+
categoryMode?: CategoryMode;
|
|
34
|
+
/** Output format (yaml, json, toon) */
|
|
35
|
+
format?: string;
|
|
36
|
+
/** Optional description for the store */
|
|
37
|
+
description?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Handles the init command execution.
|
|
41
|
+
*
|
|
42
|
+
* This function:
|
|
43
|
+
* 1. Resolves the store name (explicit or git detection)
|
|
44
|
+
* 2. Resolves target path (default to .cortex in cwd)
|
|
45
|
+
* 3. Uses initializeStore to create directory, index, and register
|
|
46
|
+
* 4. Outputs the result
|
|
47
|
+
*
|
|
48
|
+
* @param targetPath - Optional path for the store (defaults to .cortex in cwd)
|
|
49
|
+
* @param options - Command options (name, format)
|
|
50
|
+
* @param deps - Optional dependencies for testing
|
|
51
|
+
* @throws {InvalidArgumentError} When the store name is invalid
|
|
52
|
+
* @throws {CommanderError} When the store already exists or init fails
|
|
53
|
+
*/
|
|
54
|
+
export declare function handleInit(ctx: CortexContext, targetPath: string | undefined, options?: InitCommandOptions): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* The `init` subcommand for initializing a new memory store.
|
|
57
|
+
*
|
|
58
|
+
* Creates a new store at the specified path (or .cortex in current directory)
|
|
59
|
+
* and registers it in the global registry. The store name is auto-detected
|
|
60
|
+
* from the git repository name or can be explicitly provided.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```bash
|
|
64
|
+
* cortex store init # Auto-detect name from git
|
|
65
|
+
* cortex store init --name my-project # Explicit name
|
|
66
|
+
* cortex store init ./store --name custom # Custom path and name
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare const initCommand: Command<[string | undefined], {
|
|
70
|
+
name?: string | undefined;
|
|
71
|
+
description?: string | undefined;
|
|
72
|
+
categoryMode: string;
|
|
73
|
+
format: string;
|
|
74
|
+
}, {}>;
|
|
75
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/store/commands/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAKtD,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAK3E;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAqBD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,UAAU,CAC5B,GAAG,EAAE,aAAa,EAClB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,GAAE,kBAAuB,GACjC,OAAO,CAAC,IAAI,CAAC,CAkCf;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW;;;;;MAmBlB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.spec.d.ts","sourceRoot":"","sources":["../../../src/store/commands/init.spec.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Store list command for displaying all registered stores.
|
|
3
|
+
*
|
|
4
|
+
* This command reads the store registry and displays all registered
|
|
5
|
+
* stores sorted alphabetically by name.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```bash
|
|
9
|
+
* # List all stores in YAML format (default)
|
|
10
|
+
* cortex store list
|
|
11
|
+
*
|
|
12
|
+
* # List all stores in JSON format
|
|
13
|
+
* cortex store list --format json
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
import { Command } from '@commander-js/extra-typings';
|
|
17
|
+
import { type CortexContext } from '@yeseh/cortex-core';
|
|
18
|
+
/**
|
|
19
|
+
* Options for the list command.
|
|
20
|
+
*/
|
|
21
|
+
export interface ListCommandOptions {
|
|
22
|
+
/** Output format (yaml, json, toon) */
|
|
23
|
+
format?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Dependencies for the list command handler.
|
|
27
|
+
* Allows injection for testing.
|
|
28
|
+
*/
|
|
29
|
+
export interface ListHandlerDeps {
|
|
30
|
+
/** Output stream for writing results (defaults to process.stdout) */
|
|
31
|
+
stdout?: NodeJS.WritableStream;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Handles the list command execution.
|
|
35
|
+
*
|
|
36
|
+
* This function:
|
|
37
|
+
* 1. Gets stores from the context
|
|
38
|
+
* 2. Formats the stores as a sorted list
|
|
39
|
+
* 3. Serializes and outputs the result
|
|
40
|
+
*
|
|
41
|
+
* @param ctx - The Cortex context containing stores configuration
|
|
42
|
+
* @param options - Command options (format)
|
|
43
|
+
* @param deps - Optional dependencies for testing
|
|
44
|
+
* @throws {CommanderError} When serialization fails
|
|
45
|
+
*/
|
|
46
|
+
export declare function handleList(ctx: CortexContext, options: ListCommandOptions, deps?: ListHandlerDeps): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* The `list` subcommand for displaying all registered stores.
|
|
49
|
+
*
|
|
50
|
+
* Reads the store registry and displays all stores sorted alphabetically
|
|
51
|
+
* by name in the specified format.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```bash
|
|
55
|
+
* cortex store list
|
|
56
|
+
* cortex store list --format json
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare const listCommand: Command<[], {
|
|
60
|
+
format: string;
|
|
61
|
+
}, {}>;
|
|
62
|
+
//# sourceMappingURL=list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/store/commands/list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKxD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC5B,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;CAClC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,UAAU,CAC5B,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,kBAAkB,EAC3B,IAAI,GAAE,eAAoB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAsBf;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW;;MASlB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.spec.d.ts","sourceRoot":"","sources":["../../../src/store/commands/list.spec.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prune.spec.d.ts","sourceRoot":"","sources":["../../../src/store/commands/prune.spec.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reindexs.spec.d.ts","sourceRoot":"","sources":["../../../src/store/commands/reindexs.spec.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove.spec.d.ts","sourceRoot":"","sources":["../../../src/store/commands/remove.spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../src/store/index.spec.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-store-name.spec.d.ts","sourceRoot":"","sources":["../../../src/store/utils/resolve-store-name.spec.ts"],"names":[],"mappings":""}
|