@fractary/codex-cli 0.10.11 → 0.10.14

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 CHANGED
@@ -4,272 +4,54 @@ Command-line interface for Fractary Codex knowledge management system.
4
4
 
5
5
  ## Installation
6
6
 
7
- ### Global Installation
8
-
9
7
  ```bash
10
8
  npm install -g @fractary/codex-cli
11
9
  ```
12
10
 
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
- ```
11
+ ## Quick Start
41
12
 
42
- **Example:**
43
13
  ```bash
14
+ # Initialize configuration
44
15
  fractary-codex init
45
- # Creates .fractary/config.yaml and .fractary/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
16
 
65
- **Examples:**
66
- ```bash
67
- # Fetch with caching
17
+ # Fetch a document
68
18
  fractary-codex fetch codex://myorg/myproject/README.md
69
19
 
70
- # Bypass cache
71
- fractary-codex fetch codex://myorg/myproject/README.md --bypass-cache
20
+ # Check cache status
21
+ fractary-codex cache stats
72
22
 
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
23
+ # Run health check
24
+ fractary-codex health
78
25
  ```
79
26
 
80
- ### `cache` - Cache Management
81
-
82
- Manage the document cache with subcommands for listing, clearing, and viewing statistics.
27
+ ## Commands Overview
83
28
 
84
- #### `cache list` - List Cache Information
85
-
86
- ```bash
87
- fractary-codex cache list [options]
88
-
89
- Options:
90
- --json Output as JSON
91
- ```
29
+ | Command | Description |
30
+ |---------|-------------|
31
+ | `init` | Initialize configuration |
32
+ | `fetch <uri>` | Fetch documents by codex:// URI |
33
+ | `cache list` | List cached documents |
34
+ | `cache clear` | Clear cache entries |
35
+ | `cache stats` | Show cache statistics |
36
+ | `sync project` | Sync single project |
37
+ | `sync org` | Sync entire organization |
38
+ | `types list` | List artifact types |
39
+ | `types add` | Add custom type |
40
+ | `health` | Run diagnostics |
41
+ | `migrate` | Migrate v2.x config to v3.0 |
92
42
 
93
- #### `cache clear` - Clear Cache Entries
43
+ ## Documentation
94
44
 
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
- **Routing-Aware Sync (v4.1+):**
157
-
158
- When using `--from-codex` direction, the sync command uses **routing-aware file discovery** to find all files across the entire codex that should sync to your project based on `codex_sync_include` frontmatter patterns.
159
-
160
- How it works:
161
- 1. Clones the entire codex repository to a temporary directory (`/tmp/fractary-codex-clone/`)
162
- 2. Scans ALL markdown files in the codex recursively
163
- 3. Evaluates `codex_sync_include` patterns in each file's frontmatter
164
- 4. Returns only files that match your project name or pattern
165
-
166
- **Example frontmatter in source files:**
167
- ```yaml
168
- ---
169
- codex_sync_include: ['*'] # Syncs to ALL projects
170
- codex_sync_include: ['lake-*', 'api-*'] # Syncs to lake-* and api-* projects
171
- codex_sync_exclude: ['*-test'] # Except *-test projects
172
- ---
173
- ```
45
+ **Full documentation**: [docs/cli/](../docs/cli/)
174
46
 
175
- **Trade-offs:**
176
- - **Efficient for discovery**: Finds all relevant files across hundreds of projects
177
- - **Inefficient for execution**: Clones entire codex repository (uses shallow clone for speed)
178
- - **Best practice**: Use `codex://` URI references + cache purging for most workflows; use sync occasionally when needed
179
-
180
- **Recommended workflow:**
181
- ```bash
182
- # Primary: Reference files via codex:// URIs (no sync needed)
183
- fractary-codex fetch codex://org/project/path/file.md
184
-
185
- # When you need latest versions: Purge cache
186
- fractary-codex cache clear --pattern "codex://org/project/*"
187
-
188
- # Then MCP will re-fetch fresh content automatically
189
- ```
190
-
191
- ### `types` - Type Registry Management
192
-
193
- Manage custom artifact types for classification and caching.
194
-
195
- #### `types list` - List All Types
196
-
197
- ```bash
198
- fractary-codex types list [options]
199
-
200
- Options:
201
- --custom-only Show only custom types
202
- --builtin-only Show only built-in types
203
- --json Output as JSON
204
- ```
205
-
206
- #### `types show` - Show Type Details
207
-
208
- ```bash
209
- fractary-codex types show <type-name> [options]
210
-
211
- Options:
212
- --json Output as JSON
213
- ```
214
-
215
- #### `types add` - Add Custom Type
216
-
217
- ```bash
218
- fractary-codex types add <type-name> [options]
219
-
220
- Options:
221
- --pattern <glob> File pattern (required)
222
- --ttl <duration> Cache TTL (default: 24h)
223
- --description <text> Type description
224
- ```
225
-
226
- **Example:**
227
- ```bash
228
- fractary-codex types add api-schema --pattern "**/*.openapi.{yaml,json}" --ttl 48h --description "OpenAPI schemas"
229
- ```
230
-
231
- #### `types remove` - Remove Custom Type
232
-
233
- ```bash
234
- fractary-codex types remove <type-name> [options]
235
-
236
- Options:
237
- --json Output as JSON
238
- ```
239
-
240
- ### `health` - Diagnostics
241
-
242
- Run comprehensive diagnostics on codex setup.
243
-
244
- ```bash
245
- fractary-codex health [options]
246
-
247
- Options:
248
- --json Output as JSON for CI/CD integration
249
- ```
250
-
251
- **Checks:**
252
- - Configuration validity
253
- - SDK client initialization
254
- - Cache health and statistics
255
- - Storage provider availability
256
- - Type registry status
257
-
258
- ### `migrate` - Configuration Migration
259
-
260
- Migrate legacy v2.x JSON configuration to v3.0 YAML format.
261
-
262
- ```bash
263
- fractary-codex migrate [options]
264
-
265
- Options:
266
- --dry-run Preview migration without writing
267
- --json Output as JSON
268
- ```
47
+ - [Commands Reference](../docs/cli/#commands-reference)
48
+ - [Integration Patterns](../docs/cli/#integration-patterns)
49
+ - [Troubleshooting](../docs/cli/#troubleshooting)
50
+ - [Configuration Guide](../docs/configuration.md)
269
51
 
270
52
  ## Configuration
271
53
 
272
- Codex uses `.fractary/config.yaml` for configuration:
54
+ Uses `.fractary/config.yaml`:
273
55
 
274
56
  ```yaml
275
57
  organization: myorg
@@ -277,95 +59,39 @@ cacheDir: .fractary/codex/cache
277
59
 
278
60
  storage:
279
61
  - type: github
280
- owner: myorg
281
- repo: codex-core
282
- ref: main
283
62
  token: ${GITHUB_TOKEN}
284
- priority: 50
285
-
286
- - type: local
287
- path: ./codex-local
288
- priority: 10
289
-
290
- types:
291
- custom:
292
- api-schema:
293
- description: OpenAPI API schemas
294
- patterns:
295
- - "**/*.openapi.yaml"
296
- - "**/*.openapi.json"
297
- defaultTtl: 172800 # 48 hours
298
-
299
- permissions:
300
- default: read
301
- rules:
302
- - pattern: "sensitive/**"
303
- permission: admin
304
- users: ["admin-user"]
305
-
306
- sync:
307
- bidirectional: true
308
- conflictResolution: latest
309
- exclude:
310
- - "node_modules/**"
311
- - ".git/**"
312
-
313
- mcp:
314
- enabled: true
315
- port: 3000
316
63
  ```
317
64
 
318
65
  ## Environment Variables
319
66
 
320
- - `GITHUB_TOKEN` - GitHub personal access token for private repositories
321
- - `CODEX_CACHE_DIR` - Override default cache directory
322
- - `CODEX_ORG` - Override organization slug
67
+ | Variable | Description |
68
+ |----------|-------------|
69
+ | `GITHUB_TOKEN` | GitHub access token |
70
+ | `CODEX_CACHE_DIR` | Override cache directory |
71
+ | `CODEX_ORG` | Override organization |
323
72
 
324
73
  ## Development
325
74
 
326
- ### Build
327
-
328
75
  ```bash
76
+ # Build
329
77
  npm run build
330
- ```
331
-
332
- ### Test
333
78
 
334
- ```bash
79
+ # Test
335
80
  npm test
336
- ```
337
81
 
338
- ### Type Check
339
-
340
- ```bash
82
+ # Type check
341
83
  npm run typecheck
342
- ```
343
-
344
- ### Link for Local Testing
345
84
 
346
- ```bash
85
+ # Link for local testing
347
86
  npm link
348
- fractary-codex --help
349
87
  ```
350
88
 
351
- ## Architecture
352
-
353
- The CLI is built on top of the `@fractary/codex` SDK and uses:
354
-
355
- - **Commander.js** for command-line parsing
356
- - **Chalk** for colored output
357
- - **js-yaml** for YAML configuration
358
- - **Dynamic imports** for fast cold-start performance
359
-
360
- All commands use lazy-loading to avoid SDK initialization overhead for simple operations like `--help`.
361
-
362
89
  ## License
363
90
 
364
91
  MIT
365
92
 
366
- ## Links
93
+ ## See Also
367
94
 
368
- - [GitHub Repository](https://github.com/fractary/codex)
369
- - [Documentation](https://github.com/fractary/codex/tree/main/docs)
370
- - [SDK Package](https://github.com/fractary/codex/tree/main/sdk/js)
371
- - [Issue Tracker](https://github.com/fractary/codex/issues)
95
+ - [SDK Package](../sdk/js/) - Core JavaScript SDK
96
+ - [MCP Server](../mcp/server/) - AI agent integration
97
+ - [Documentation](../docs/) - Full documentation