@fractary/codex-cli 0.10.13 → 0.10.15
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 +41 -315
- package/dist/cli.cjs +109 -18
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +110 -19
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
66
|
-
```bash
|
|
67
|
-
# Fetch with caching
|
|
17
|
+
# Fetch a document
|
|
68
18
|
fractary-codex fetch codex://myorg/myproject/README.md
|
|
69
19
|
|
|
70
|
-
#
|
|
71
|
-
fractary-codex
|
|
20
|
+
# Check cache status
|
|
21
|
+
fractary-codex cache stats
|
|
72
22
|
|
|
73
|
-
#
|
|
74
|
-
fractary-codex
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
Manage the document cache with subcommands for listing, clearing, and viewing statistics.
|
|
27
|
+
## Commands Overview
|
|
83
28
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
43
|
+
## Documentation
|
|
94
44
|
|
|
95
|
-
|
|
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
|
-
|
|
176
|
-
-
|
|
177
|
-
-
|
|
178
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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
|
-
|
|
79
|
+
# Test
|
|
335
80
|
npm test
|
|
336
|
-
```
|
|
337
81
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
```bash
|
|
82
|
+
# Type check
|
|
341
83
|
npm run typecheck
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
### Link for Local Testing
|
|
345
84
|
|
|
346
|
-
|
|
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
|
-
##
|
|
93
|
+
## See Also
|
|
367
94
|
|
|
368
|
-
- [
|
|
369
|
-
- [
|
|
370
|
-
- [
|
|
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
|
package/dist/cli.cjs
CHANGED
|
@@ -823,7 +823,7 @@ function getDefaultUnifiedConfig(organization, project, codexRepo) {
|
|
|
823
823
|
const sanitizedProject = sanitizeForS3BucketName(project);
|
|
824
824
|
return {
|
|
825
825
|
file: {
|
|
826
|
-
schema_version:
|
|
826
|
+
schema_version: codex.CONFIG_SCHEMA_VERSION,
|
|
827
827
|
sources: {
|
|
828
828
|
specs: {
|
|
829
829
|
type: "s3",
|
|
@@ -860,11 +860,16 @@ function getDefaultUnifiedConfig(organization, project, codexRepo) {
|
|
|
860
860
|
}
|
|
861
861
|
},
|
|
862
862
|
codex: {
|
|
863
|
-
schema_version:
|
|
863
|
+
schema_version: codex.CONFIG_SCHEMA_VERSION,
|
|
864
864
|
organization,
|
|
865
865
|
project,
|
|
866
866
|
codex_repo: codexRepo,
|
|
867
|
-
|
|
867
|
+
remotes: {
|
|
868
|
+
// The codex repository - uses same token as git operations
|
|
869
|
+
[`${organization}/${codexRepo}`]: {
|
|
870
|
+
token: "${GITHUB_TOKEN}"
|
|
871
|
+
}
|
|
872
|
+
}
|
|
868
873
|
}
|
|
869
874
|
};
|
|
870
875
|
}
|
|
@@ -895,7 +900,7 @@ function mergeUnifiedConfigs(existing, updates) {
|
|
|
895
900
|
const merged = {};
|
|
896
901
|
if (updates.file || existing.file) {
|
|
897
902
|
merged.file = {
|
|
898
|
-
schema_version: updates.file?.schema_version || existing.file?.schema_version ||
|
|
903
|
+
schema_version: updates.file?.schema_version || existing.file?.schema_version || codex.CONFIG_SCHEMA_VERSION,
|
|
899
904
|
sources: {
|
|
900
905
|
...existing.file?.sources || {},
|
|
901
906
|
...updates.file?.sources || {}
|
|
@@ -904,13 +909,13 @@ function mergeUnifiedConfigs(existing, updates) {
|
|
|
904
909
|
}
|
|
905
910
|
if (updates.codex || existing.codex) {
|
|
906
911
|
merged.codex = {
|
|
907
|
-
schema_version: updates.codex?.schema_version || existing.codex?.schema_version ||
|
|
912
|
+
schema_version: updates.codex?.schema_version || existing.codex?.schema_version || codex.CONFIG_SCHEMA_VERSION,
|
|
908
913
|
organization: updates.codex?.organization || existing.codex?.organization || "default",
|
|
909
914
|
project: updates.codex?.project || existing.codex?.project || "default",
|
|
910
915
|
codex_repo: updates.codex?.codex_repo || existing.codex?.codex_repo || "",
|
|
911
|
-
|
|
912
|
-
...existing.codex?.
|
|
913
|
-
...updates.codex?.
|
|
916
|
+
remotes: {
|
|
917
|
+
...existing.codex?.remotes || {},
|
|
918
|
+
...updates.codex?.remotes || {}
|
|
914
919
|
}
|
|
915
920
|
};
|
|
916
921
|
}
|
|
@@ -1124,9 +1129,64 @@ async function fileExists(filePath) {
|
|
|
1124
1129
|
return false;
|
|
1125
1130
|
}
|
|
1126
1131
|
}
|
|
1132
|
+
async function installMcpServer(projectRoot, configPath = ".fractary/config.yaml", options = {}) {
|
|
1133
|
+
const mcpJsonPath = path4__namespace.join(projectRoot, ".mcp.json");
|
|
1134
|
+
const { backup = true } = options;
|
|
1135
|
+
let existingConfig = { mcpServers: {} };
|
|
1136
|
+
let backupPath;
|
|
1137
|
+
let migrated = false;
|
|
1138
|
+
if (await fileExists(mcpJsonPath)) {
|
|
1139
|
+
try {
|
|
1140
|
+
const content = await fs__namespace.readFile(mcpJsonPath, "utf-8");
|
|
1141
|
+
existingConfig = JSON.parse(content);
|
|
1142
|
+
if (backup) {
|
|
1143
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "").slice(0, 18);
|
|
1144
|
+
const suffix = Math.random().toString(36).substring(2, 6);
|
|
1145
|
+
backupPath = `${mcpJsonPath}.backup.${timestamp}-${suffix}`;
|
|
1146
|
+
await fs__namespace.writeFile(backupPath, content);
|
|
1147
|
+
}
|
|
1148
|
+
} catch {
|
|
1149
|
+
console.log(chalk7__default.default.yellow("\u26A0 Warning: .mcp.json contains invalid JSON, starting fresh"));
|
|
1150
|
+
existingConfig = { mcpServers: {} };
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
if (!existingConfig.mcpServers) {
|
|
1154
|
+
existingConfig.mcpServers = {};
|
|
1155
|
+
}
|
|
1156
|
+
const existing = existingConfig.mcpServers["fractary-codex"];
|
|
1157
|
+
if (existing) {
|
|
1158
|
+
const existingCommand = existing.command;
|
|
1159
|
+
const existingArgs = existing.args || [];
|
|
1160
|
+
if (existingCommand === "npx" && existingArgs.includes("@fractary/codex-mcp")) {
|
|
1161
|
+
return {
|
|
1162
|
+
installed: false,
|
|
1163
|
+
migrated: false,
|
|
1164
|
+
alreadyInstalled: true,
|
|
1165
|
+
backupPath
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
if (existingCommand === "node" || existingArgs.includes("@fractary/codex")) {
|
|
1169
|
+
migrated = true;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
existingConfig.mcpServers["fractary-codex"] = {
|
|
1173
|
+
command: "npx",
|
|
1174
|
+
args: ["-y", "@fractary/codex-mcp", "--config", configPath]
|
|
1175
|
+
};
|
|
1176
|
+
await fs__namespace.writeFile(
|
|
1177
|
+
mcpJsonPath,
|
|
1178
|
+
JSON.stringify(existingConfig, null, 2) + "\n"
|
|
1179
|
+
);
|
|
1180
|
+
return {
|
|
1181
|
+
installed: true,
|
|
1182
|
+
migrated,
|
|
1183
|
+
alreadyInstalled: false,
|
|
1184
|
+
backupPath
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1127
1187
|
function initCommand() {
|
|
1128
1188
|
const cmd = new commander.Command("init");
|
|
1129
|
-
cmd.description("Initialize unified Fractary configuration (.fractary/config.yaml)").option("--org <slug>", 'Organization slug (e.g., "fractary")').option("--project <name>", "Project name (default: derived from directory)").option("--codex-repo <name>", 'Codex repository name (e.g., "codex.fractary.com")').option("--force", "Overwrite existing configuration").action(async (options) => {
|
|
1189
|
+
cmd.description("Initialize unified Fractary configuration (.fractary/config.yaml)").option("--org <slug>", 'Organization slug (e.g., "fractary")').option("--project <name>", "Project name (default: derived from directory)").option("--codex-repo <name>", 'Codex repository name (e.g., "codex.fractary.com")').option("--force", "Overwrite existing configuration").option("--no-mcp", "Skip MCP server installation").action(async (options) => {
|
|
1130
1190
|
try {
|
|
1131
1191
|
console.log(chalk7__default.default.blue("Initializing unified Fractary configuration...\n"));
|
|
1132
1192
|
let org = options.org;
|
|
@@ -1238,6 +1298,20 @@ function initCommand() {
|
|
|
1238
1298
|
} else if (result.merged) {
|
|
1239
1299
|
console.log(chalk7__default.default.green("\u2713"), chalk7__default.default.dim(".fractary/config.yaml (merged with existing)"));
|
|
1240
1300
|
}
|
|
1301
|
+
if (options.mcp !== false) {
|
|
1302
|
+
console.log("\nConfiguring MCP server...");
|
|
1303
|
+
const mcpResult = await installMcpServer(process.cwd(), ".fractary/config.yaml");
|
|
1304
|
+
if (mcpResult.alreadyInstalled) {
|
|
1305
|
+
console.log(chalk7__default.default.green("\u2713"), chalk7__default.default.dim(".mcp.json (already configured)"));
|
|
1306
|
+
} else if (mcpResult.migrated) {
|
|
1307
|
+
console.log(chalk7__default.default.green("\u2713"), chalk7__default.default.dim(".mcp.json (migrated from old format)"));
|
|
1308
|
+
if (mcpResult.backupPath) {
|
|
1309
|
+
console.log(chalk7__default.default.dim(` Backup: ${path4__namespace.basename(mcpResult.backupPath)}`));
|
|
1310
|
+
}
|
|
1311
|
+
} else if (mcpResult.installed) {
|
|
1312
|
+
console.log(chalk7__default.default.green("\u2713"), chalk7__default.default.dim(".mcp.json (created)"));
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1241
1315
|
console.log(chalk7__default.default.green("\n\u2713 Unified configuration initialized successfully!\n"));
|
|
1242
1316
|
console.log(chalk7__default.default.bold("Configuration:"));
|
|
1243
1317
|
console.log(chalk7__default.default.dim(` Organization: ${org}`));
|
|
@@ -1249,18 +1323,19 @@ function initCommand() {
|
|
|
1249
1323
|
console.log(chalk7__default.default.dim(" - logs: .fractary/logs/ \u2192 S3"));
|
|
1250
1324
|
console.log(chalk7__default.default.bold("\nCodex plugin:"));
|
|
1251
1325
|
console.log(chalk7__default.default.dim(" - Cache: .fractary/codex/cache/"));
|
|
1252
|
-
console.log(chalk7__default.default.dim(" -
|
|
1326
|
+
console.log(chalk7__default.default.dim(" - MCP Server: @fractary/codex-mcp (via npx)"));
|
|
1327
|
+
console.log(chalk7__default.default.dim(" - Remotes: codex repo configured"));
|
|
1253
1328
|
console.log(chalk7__default.default.bold("\nGit Authentication:"));
|
|
1254
1329
|
console.log(chalk7__default.default.dim(" Codex sync uses your existing git credentials."));
|
|
1255
1330
|
console.log(chalk7__default.default.dim(" Ensure you have access to the codex repository:"));
|
|
1256
1331
|
console.log(chalk7__default.default.dim(` gh repo view ${org}/${codexRepo}`));
|
|
1257
1332
|
console.log(chalk7__default.default.dim(" Or set GITHUB_TOKEN environment variable."));
|
|
1258
1333
|
console.log(chalk7__default.default.bold("\nNext steps:"));
|
|
1259
|
-
console.log(chalk7__default.default.dim(" 1.
|
|
1260
|
-
console.log(chalk7__default.default.dim(" 2.
|
|
1261
|
-
console.log(chalk7__default.default.dim(" 3.
|
|
1262
|
-
console.log(chalk7__default.default.dim(" 4.
|
|
1263
|
-
console.log(chalk7__default.default.dim(" 5.
|
|
1334
|
+
console.log(chalk7__default.default.dim(" 1. Restart Claude Code to load the MCP server"));
|
|
1335
|
+
console.log(chalk7__default.default.dim(" 2. Verify codex repository access: gh repo view " + org + "/" + codexRepo));
|
|
1336
|
+
console.log(chalk7__default.default.dim(" 3. Configure AWS credentials for S3 access (if using file plugin)"));
|
|
1337
|
+
console.log(chalk7__default.default.dim(" 4. Edit .fractary/config.yaml to add external project remotes"));
|
|
1338
|
+
console.log(chalk7__default.default.dim(" 5. Reference docs via codex:// URIs (auto-fetched by MCP)"));
|
|
1264
1339
|
} catch (error) {
|
|
1265
1340
|
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
1266
1341
|
process.exit(1);
|
|
@@ -1723,7 +1798,7 @@ function formatDuration(ms) {
|
|
|
1723
1798
|
}
|
|
1724
1799
|
function syncCommand() {
|
|
1725
1800
|
const cmd = new commander.Command("sync");
|
|
1726
|
-
cmd.description("Sync single project with codex repository").argument("[name]", "Project name (auto-detected if not provided)").option("--env <env>", "Target environment (dev/test/staging/prod)", "prod").option("--dry-run", "Show what would sync without executing").option("--direction <dir>", "Sync direction (to-codex/from-codex/bidirectional)", "bidirectional").option("--include <pattern>", "Include files matching pattern (can be used multiple times)", (val, prev) => prev.concat([val]), []).option("--exclude <pattern>", "Exclude files matching pattern (can be used multiple times)", (val, prev) => prev.concat([val]), []).option("--force", "Force sync without checking timestamps").option("--json", "Output as JSON").action(async (name, options) => {
|
|
1801
|
+
cmd.description("Sync single project with codex repository").argument("[name]", "Project name (auto-detected if not provided)").option("--env <env>", "Target environment (dev/test/staging/prod)", "prod").option("--dry-run", "Show what would sync without executing").option("--direction <dir>", "Sync direction (to-codex/from-codex/bidirectional)", "bidirectional").option("--include <pattern>", "Include files matching pattern (can be used multiple times)", (val, prev) => prev.concat([val]), []).option("--exclude <pattern>", "Exclude files matching pattern (can be used multiple times)", (val, prev) => prev.concat([val]), []).option("--force", "Force sync without checking timestamps").option("--json", "Output as JSON").option("--work-id <id>", "GitHub issue number or URL to scope sync to").action(async (name, options) => {
|
|
1727
1802
|
try {
|
|
1728
1803
|
const configPath = path4__namespace.join(process.cwd(), ".fractary", "config.yaml");
|
|
1729
1804
|
let config;
|
|
@@ -1907,8 +1982,11 @@ function syncCommand() {
|
|
|
1907
1982
|
console.log(JSON.stringify({
|
|
1908
1983
|
project: projectName,
|
|
1909
1984
|
organization: config.organization,
|
|
1985
|
+
workId: options.workId || null,
|
|
1910
1986
|
files: [],
|
|
1911
|
-
synced: 0
|
|
1987
|
+
synced: 0,
|
|
1988
|
+
status: "success",
|
|
1989
|
+
message: "No files to sync"
|
|
1912
1990
|
}, null, 2));
|
|
1913
1991
|
} else {
|
|
1914
1992
|
console.log(chalk7__default.default.yellow("No files to sync."));
|
|
@@ -1923,6 +2001,7 @@ function syncCommand() {
|
|
|
1923
2001
|
branch: targetBranch,
|
|
1924
2002
|
direction,
|
|
1925
2003
|
dryRun: options.dryRun || false,
|
|
2004
|
+
workId: options.workId || null,
|
|
1926
2005
|
plan: {
|
|
1927
2006
|
totalFiles: plan.totalFiles,
|
|
1928
2007
|
totalBytes: plan.totalBytes,
|
|
@@ -1937,12 +2016,24 @@ function syncCommand() {
|
|
|
1937
2016
|
}))
|
|
1938
2017
|
};
|
|
1939
2018
|
if (options.dryRun) {
|
|
1940
|
-
console.log(JSON.stringify(
|
|
2019
|
+
console.log(JSON.stringify({
|
|
2020
|
+
...output,
|
|
2021
|
+
status: "success"
|
|
2022
|
+
}, null, 2));
|
|
1941
2023
|
return;
|
|
1942
2024
|
}
|
|
1943
2025
|
const result2 = await syncManager.executePlan(plan, syncOptions);
|
|
2026
|
+
let status;
|
|
2027
|
+
if (!result2.success && result2.synced === 0) {
|
|
2028
|
+
status = "failure";
|
|
2029
|
+
} else if (!result2.success || result2.failed > 0 || plan.conflicts.length > 0) {
|
|
2030
|
+
status = "warning";
|
|
2031
|
+
} else {
|
|
2032
|
+
status = "success";
|
|
2033
|
+
}
|
|
1944
2034
|
console.log(JSON.stringify({
|
|
1945
2035
|
...output,
|
|
2036
|
+
status,
|
|
1946
2037
|
result: {
|
|
1947
2038
|
success: result2.success,
|
|
1948
2039
|
synced: result2.synced,
|