@fractary/codex-cli 0.2.2

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/README.md ADDED
@@ -0,0 +1,336 @@
1
+ # Fractary Codex CLI
2
+
3
+ Command-line interface for Fractary Codex knowledge management system.
4
+
5
+ ## Installation
6
+
7
+ ### Global Installation
8
+
9
+ ```bash
10
+ npm install -g @fractary/codex-cli
11
+ ```
12
+
13
+ ### Local Development
14
+
15
+ ```bash
16
+ # From repository root
17
+ npm install
18
+ cd cli
19
+ npm run build
20
+ npm link
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```bash
26
+ fractary-codex [command] [options]
27
+ ```
28
+
29
+ ## Commands
30
+
31
+ ### `init` - Initialize Configuration
32
+
33
+ Initialize Codex v3.0 with YAML configuration in your project.
34
+
35
+ ```bash
36
+ fractary-codex init [options]
37
+
38
+ Options:
39
+ --force Overwrite existing configuration
40
+ ```
41
+
42
+ **Example:**
43
+ ```bash
44
+ fractary-codex init
45
+ # Creates .fractary/codex.yaml and .codex-cache/
46
+ ```
47
+
48
+ ### `fetch` - Fetch Documents
49
+
50
+ Fetch documents by `codex://` URI reference with intelligent caching.
51
+
52
+ ```bash
53
+ fractary-codex fetch <uri> [options]
54
+
55
+ Arguments:
56
+ uri Codex URI (e.g., codex://org/project/path/file.md)
57
+
58
+ Options:
59
+ --bypass-cache Fetch directly from storage, bypassing cache
60
+ --ttl <seconds> Override default TTL
61
+ --json Output as JSON with metadata
62
+ --output <file> Write content to file instead of stdout
63
+ ```
64
+
65
+ **Examples:**
66
+ ```bash
67
+ # Fetch with caching
68
+ fractary-codex fetch codex://myorg/myproject/README.md
69
+
70
+ # Bypass cache
71
+ fractary-codex fetch codex://myorg/myproject/README.md --bypass-cache
72
+
73
+ # JSON output with metadata
74
+ fractary-codex fetch codex://myorg/myproject/README.md --json
75
+
76
+ # Save to file
77
+ fractary-codex fetch codex://myorg/myproject/README.md --output local-README.md
78
+ ```
79
+
80
+ ### `cache` - Cache Management
81
+
82
+ Manage the document cache with subcommands for listing, clearing, and viewing statistics.
83
+
84
+ #### `cache list` - List Cache Information
85
+
86
+ ```bash
87
+ fractary-codex cache list [options]
88
+
89
+ Options:
90
+ --json Output as JSON
91
+ ```
92
+
93
+ #### `cache clear` - Clear Cache Entries
94
+
95
+ ```bash
96
+ fractary-codex cache clear [options]
97
+
98
+ Options:
99
+ --all Clear entire cache
100
+ --pattern <glob> Clear entries matching pattern
101
+ --dry-run Preview without clearing
102
+ ```
103
+
104
+ **Examples:**
105
+ ```bash
106
+ # Clear all cache entries
107
+ fractary-codex cache clear --all
108
+
109
+ # Clear specific pattern
110
+ fractary-codex cache clear --pattern "myorg/myproject/**"
111
+
112
+ # Preview clearing
113
+ fractary-codex cache clear --all --dry-run
114
+ ```
115
+
116
+ #### `cache stats` - Cache Statistics
117
+
118
+ ```bash
119
+ fractary-codex cache stats [options]
120
+
121
+ Options:
122
+ --json Output as JSON
123
+ ```
124
+
125
+ ### `sync` - Bidirectional Synchronization
126
+
127
+ Synchronize files with codex repository.
128
+
129
+ #### `sync project` - Sync Single Project
130
+
131
+ ```bash
132
+ fractary-codex sync project [project-name] [options]
133
+
134
+ Options:
135
+ --to-codex Sync from project to codex (one-way)
136
+ --from-codex Sync from codex to project (one-way)
137
+ --bidirectional Two-way sync (default)
138
+ --dry-run Preview changes without syncing
139
+ --env <environment> Environment branch mapping
140
+ ```
141
+
142
+ #### `sync org` - Sync Organization
143
+
144
+ ```bash
145
+ fractary-codex sync org [options]
146
+
147
+ Options:
148
+ --to-codex Sync from projects to codex
149
+ --from-codex Sync from codex to projects
150
+ --bidirectional Two-way sync (default)
151
+ --dry-run Preview changes
152
+ --exclude <pattern> Exclude repositories matching pattern
153
+ --parallel <n> Number of parallel sync operations (default: 3)
154
+ ```
155
+
156
+ ### `types` - Type Registry Management
157
+
158
+ Manage custom artifact types for classification and caching.
159
+
160
+ #### `types list` - List All Types
161
+
162
+ ```bash
163
+ fractary-codex types list [options]
164
+
165
+ Options:
166
+ --custom-only Show only custom types
167
+ --builtin-only Show only built-in types
168
+ --json Output as JSON
169
+ ```
170
+
171
+ #### `types show` - Show Type Details
172
+
173
+ ```bash
174
+ fractary-codex types show <type-name> [options]
175
+
176
+ Options:
177
+ --json Output as JSON
178
+ ```
179
+
180
+ #### `types add` - Add Custom Type
181
+
182
+ ```bash
183
+ fractary-codex types add <type-name> [options]
184
+
185
+ Options:
186
+ --pattern <glob> File pattern (required)
187
+ --ttl <duration> Cache TTL (default: 24h)
188
+ --description <text> Type description
189
+ ```
190
+
191
+ **Example:**
192
+ ```bash
193
+ fractary-codex types add api-schema --pattern "**/*.openapi.{yaml,json}" --ttl 48h --description "OpenAPI schemas"
194
+ ```
195
+
196
+ #### `types remove` - Remove Custom Type
197
+
198
+ ```bash
199
+ fractary-codex types remove <type-name> [options]
200
+
201
+ Options:
202
+ --json Output as JSON
203
+ ```
204
+
205
+ ### `health` - Diagnostics
206
+
207
+ Run comprehensive diagnostics on codex setup.
208
+
209
+ ```bash
210
+ fractary-codex health [options]
211
+
212
+ Options:
213
+ --json Output as JSON for CI/CD integration
214
+ ```
215
+
216
+ **Checks:**
217
+ - Configuration validity
218
+ - SDK client initialization
219
+ - Cache health and statistics
220
+ - Storage provider availability
221
+ - Type registry status
222
+
223
+ ### `migrate` - Configuration Migration
224
+
225
+ Migrate legacy v2.x JSON configuration to v3.0 YAML format.
226
+
227
+ ```bash
228
+ fractary-codex migrate [options]
229
+
230
+ Options:
231
+ --dry-run Preview migration without writing
232
+ --json Output as JSON
233
+ ```
234
+
235
+ ## Configuration
236
+
237
+ Codex uses `.fractary/codex.yaml` for configuration:
238
+
239
+ ```yaml
240
+ organization: myorg
241
+ cacheDir: .codex-cache
242
+
243
+ storage:
244
+ - type: github
245
+ owner: myorg
246
+ repo: codex-core
247
+ ref: main
248
+ token: ${GITHUB_TOKEN}
249
+ priority: 50
250
+
251
+ - type: local
252
+ path: ./codex-local
253
+ priority: 10
254
+
255
+ types:
256
+ custom:
257
+ api-schema:
258
+ description: OpenAPI API schemas
259
+ patterns:
260
+ - "**/*.openapi.yaml"
261
+ - "**/*.openapi.json"
262
+ defaultTtl: 172800 # 48 hours
263
+
264
+ permissions:
265
+ default: read
266
+ rules:
267
+ - pattern: "sensitive/**"
268
+ permission: admin
269
+ users: ["admin-user"]
270
+
271
+ sync:
272
+ bidirectional: true
273
+ conflictResolution: latest
274
+ exclude:
275
+ - "node_modules/**"
276
+ - ".git/**"
277
+
278
+ mcp:
279
+ enabled: true
280
+ port: 3000
281
+ ```
282
+
283
+ ## Environment Variables
284
+
285
+ - `GITHUB_TOKEN` - GitHub personal access token for private repositories
286
+ - `CODEX_CACHE_DIR` - Override default cache directory
287
+ - `CODEX_ORG` - Override organization slug
288
+
289
+ ## Development
290
+
291
+ ### Build
292
+
293
+ ```bash
294
+ npm run build
295
+ ```
296
+
297
+ ### Test
298
+
299
+ ```bash
300
+ npm test
301
+ ```
302
+
303
+ ### Type Check
304
+
305
+ ```bash
306
+ npm run typecheck
307
+ ```
308
+
309
+ ### Link for Local Testing
310
+
311
+ ```bash
312
+ npm link
313
+ fractary-codex --help
314
+ ```
315
+
316
+ ## Architecture
317
+
318
+ The CLI is built on top of the `@fractary/codex` SDK and uses:
319
+
320
+ - **Commander.js** for command-line parsing
321
+ - **Chalk** for colored output
322
+ - **js-yaml** for YAML configuration
323
+ - **Dynamic imports** for fast cold-start performance
324
+
325
+ All commands use lazy-loading to avoid SDK initialization overhead for simple operations like `--help`.
326
+
327
+ ## License
328
+
329
+ MIT
330
+
331
+ ## Links
332
+
333
+ - [GitHub Repository](https://github.com/fractary/codex)
334
+ - [Documentation](https://github.com/fractary/codex/tree/main/docs)
335
+ - [SDK Package](https://github.com/fractary/codex/tree/main/sdk/js)
336
+ - [Issue Tracker](https://github.com/fractary/codex/issues)