@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
package/dist/toon.d.ts DELETED
@@ -1,197 +0,0 @@
1
- /**
2
- * TOON (Token-Oriented Object Notation) encoder.
3
- *
4
- * A compact serialization format optimized for LLM context consumption,
5
- * achieving approximately 40% token reduction compared to JSON while
6
- * improving parsing accuracy from 70% to 74% in LLM benchmarks.
7
- *
8
- * ## Key Features
9
- *
10
- * - **Tab delimiters** - Uses tabs between key-value pairs instead of JSON's
11
- * commas and braces, maximizing token efficiency
12
- * - **Key folding** - Collapses nested object paths to dotted notation
13
- * (e.g., `user.profile.name` instead of nested objects)
14
- * - **Tabular arrays** - Uniform object arrays use a compact header+rows format,
15
- * dramatically reducing repetition
16
- *
17
- * ## Format Specification
18
- *
19
- * | JSON Construct | TOON Equivalent |
20
- * |----------------|-----------------|
21
- * | `{"key": "value"}` | `key:value` |
22
- * | `{"a": 1, "b": 2}` | `a:1\tb:2` |
23
- * | Nested object | `parent.child:value` (with key folding) |
24
- * | Uniform array | `items[N]{col1\tcol2}:\n\tval1\tval2` |
25
- *
26
- * ## Token Efficiency
27
- *
28
- * TOON reduces token count through:
29
- * 1. Eliminating JSON syntax tokens (`{`, `}`, `[`, `]`, `,`, `"`)
30
- * 2. Using single-character delimiters (tabs, colons)
31
- * 3. Deduplicating keys in tabular array format
32
- *
33
- * Typical savings:
34
- * - Simple objects: ~30% reduction
35
- * - Nested objects with key folding: ~40% reduction
36
- * - Arrays of uniform objects: ~50% reduction
37
- *
38
- * @module cli/toon
39
- *
40
- * @example Basic object encoding
41
- * ```ts
42
- * import { encode } from './toon';
43
- *
44
- * encode({ name: 'test', count: 42 });
45
- * // Output: "name:test\tcount:42"
46
- * ```
47
- *
48
- * @example Key folding for nested objects
49
- * ```ts
50
- * encode(
51
- * { user: { name: 'Alice', role: 'admin' } },
52
- * { keyFolding: 'safe' }
53
- * );
54
- * // Output: "user.name:Alice\tuser.role:admin"
55
- * //
56
- * // Without key folding:
57
- * // "user:{name:Alice\trole:admin}"
58
- * ```
59
- *
60
- * @example Tabular arrays (automatic for uniform object arrays)
61
- * ```ts
62
- * encode({
63
- * items: [
64
- * { id: 1, name: 'Widget' },
65
- * { id: 2, name: 'Gadget' },
66
- * ]
67
- * });
68
- * // Output:
69
- * // "items[2]{id\tname}:
70
- * // \t1\tWidget
71
- * // \t2\tGadget"
72
- * //
73
- * // Equivalent JSON (32 tokens):
74
- * // {"items":[{"id":1,"name":"Widget"},{"id":2,"name":"Gadget"}]}
75
- * // TOON version (18 tokens): ~44% reduction
76
- * ```
77
- *
78
- * @see {@link ToonOptions} for configuration options
79
- * @see {@link encode} for the main encoding function
80
- */
81
- /**
82
- * Configuration options for TOON encoding.
83
- *
84
- * @example Using custom delimiter
85
- * ```ts
86
- * encode({ a: 1, b: 2 }, { delimiter: '|' });
87
- * // Output: "a:1|b:2"
88
- * ```
89
- *
90
- * @example Enabling key folding
91
- * ```ts
92
- * encode({ config: { debug: true } }, { keyFolding: 'safe' });
93
- * // Output: "config.debug:true"
94
- * ```
95
- */
96
- export interface ToonOptions {
97
- /**
98
- * Character used to separate key-value pairs.
99
- *
100
- * The tab character (`\t`) is used by default as it provides optimal
101
- * token efficiency in most LLM tokenizers (single token per delimiter).
102
- *
103
- * @default '\t'
104
- */
105
- delimiter?: string;
106
- /**
107
- * Controls how nested objects are serialized.
108
- *
109
- * - `'none'` - Nested objects are serialized inline with braces:
110
- * `parent:{child:value}`
111
- * - `'safe'` - Nested paths are collapsed to dotted notation:
112
- * `parent.child:value`
113
- *
114
- * Key folding (`'safe'`) typically produces more compact output and is
115
- * easier for LLMs to parse, but may cause key collisions if object
116
- * keys contain dots.
117
- *
118
- * @default 'none'
119
- */
120
- keyFolding?: 'safe' | 'none';
121
- }
122
- /**
123
- * Encodes a value to TOON format.
124
- *
125
- * TOON (Token-Oriented Object Notation) is a compact serialization format
126
- * designed to minimize token consumption in LLM contexts while remaining
127
- * human-readable and easily parseable by language models.
128
- *
129
- * @param value - The value to encode (must be JSON-serializable)
130
- * @param options - Encoding options for customizing output format
131
- * @returns TOON-encoded string representation
132
- *
133
- * @example Basic object encoding
134
- * ```ts
135
- * const data = { name: 'test', count: 42 };
136
- * encode(data);
137
- * // Returns: "name:test\tcount:42"
138
- * //
139
- * // Equivalent JSON: {"name":"test","count":42}
140
- * // Token savings: ~35%
141
- * ```
142
- *
143
- * @example Nested objects with key folding
144
- * ```ts
145
- * const nested = {
146
- * user: {
147
- * profile: { name: 'Alice', email: 'alice@example.com' },
148
- * settings: { theme: 'dark' }
149
- * }
150
- * };
151
- *
152
- * // Without key folding (default):
153
- * encode(nested);
154
- * // Returns: "user:{profile:{name:Alice\temail:alice@example.com}\tsettings:{theme:dark}}"
155
- *
156
- * // With key folding:
157
- * encode(nested, { keyFolding: 'safe' });
158
- * // Returns: "user.profile.name:Alice\tuser.profile.email:alice@example.com\tuser.settings.theme:dark"
159
- * ```
160
- *
161
- * @example Tabular arrays (automatic for uniform object arrays)
162
- * ```ts
163
- * const users = {
164
- * users: [
165
- * { id: 1, name: 'Alice', role: 'admin' },
166
- * { id: 2, name: 'Bob', role: 'user' },
167
- * { id: 3, name: 'Charlie', role: 'user' },
168
- * ]
169
- * };
170
- *
171
- * encode(users);
172
- * // Returns:
173
- * // "users[3]{id\tname\trole}:
174
- * // \t1\tAlice\tadmin
175
- * // \t2\tBob\tuser
176
- * // \t3\tCharlie\tuser"
177
- * //
178
- * // Equivalent JSON (87 chars, ~25 tokens):
179
- * // {"users":[{"id":1,"name":"Alice","role":"admin"},{"id":2,"name":"Bob","role":"user"},{"id":3,"name":"Charlie","role":"user"}]}
180
- * //
181
- * // TOON (67 chars, ~15 tokens): ~40% token reduction
182
- * ```
183
- *
184
- * @example Mixed content
185
- * ```ts
186
- * encode({
187
- * title: 'Report',
188
- * metadata: { version: 1 },
189
- * tags: ['urgent', 'review'] // Non-uniform arrays use JSON format
190
- * }, { keyFolding: 'safe' });
191
- * // Returns: "title:Report\tmetadata.version:1\ttags:[\"urgent\",\"review\"]"
192
- * ```
193
- *
194
- * @see {@link ToonOptions} for available configuration options
195
- */
196
- export declare const encode: (value: unknown, options?: ToonOptions) => string;
197
- //# sourceMappingURL=toon.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toon.d.ts","sourceRoot":"","sources":["../src/toon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AAEH;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,WAAW;IACxB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAChC;AAkQD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,OAAO,EAAE,UAAU,WAAW,KAAG,MAO9D,CAAC"}
@@ -1,9 +0,0 @@
1
- /**
2
- * Unit tests for toon.ts
3
- *
4
- * TOON (Token-Oriented Object Notation) encoder.
5
- *
6
- * @module cli/toon.spec
7
- */
8
- export {};
9
- //# sourceMappingURL=toon.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toon.spec.d.ts","sourceRoot":"","sources":["../src/toon.spec.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -1,20 +0,0 @@
1
- /**
2
- * Executes a git command and returns the trimmed stdout.
3
- */
4
- export declare const runGitCommand: (args: string[], cwd: string) => Promise<{
5
- ok: true;
6
- value: string;
7
- } | {
8
- ok: false;
9
- }>;
10
- /**
11
- * Detects the git repository name from the current working directory.
12
- *
13
- * Uses `git rev-parse --show-toplevel` to find the repository root,
14
- * then extracts the directory name as the repository name.
15
- *
16
- * @param cwd - The current working directory to check for git repository
17
- * @returns The repository directory name, or `null` if not in a git repository
18
- */
19
- export declare const detectGitRepoName: (cwd: string) => Promise<string | null>;
20
- //# sourceMappingURL=git.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,aAAa,GACtB,MAAM,MAAM,EAAE,EACd,KAAK,MAAM,KACZ,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAA;CAAE,CAoBrD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAQ1E,CAAC"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Unit tests for utils/git.ts
3
- *
4
- * @module cli/utils/git.spec
5
- */
6
- export {};
7
- //# sourceMappingURL=git.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git.spec.d.ts","sourceRoot":"","sources":["../../src/utils/git.spec.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}