@fractary/codex-cli 0.3.1 → 0.4.0
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 +3 -13
- package/dist/cli.cjs +58 -31
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +58 -31
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -61,7 +61,7 @@ async function migrateConfig(legacyConfigPath, options) {
|
|
|
61
61
|
organization: legacy.organization || legacy.organizationSlug || "default"
|
|
62
62
|
};
|
|
63
63
|
if (legacy.cache) {
|
|
64
|
-
yamlConfig.cacheDir = legacy.cache.directory || ".codex
|
|
64
|
+
yamlConfig.cacheDir = legacy.cache.directory || ".fractary/codex/cache";
|
|
65
65
|
}
|
|
66
66
|
if (legacy.storage?.providers) {
|
|
67
67
|
yamlConfig.storage = [];
|
|
@@ -170,7 +170,7 @@ async function writeYamlConfig(config, outputPath) {
|
|
|
170
170
|
function getDefaultYamlConfig(organization) {
|
|
171
171
|
return {
|
|
172
172
|
organization,
|
|
173
|
-
cacheDir: ".codex
|
|
173
|
+
cacheDir: ".fractary/codex/cache",
|
|
174
174
|
storage: [
|
|
175
175
|
{
|
|
176
176
|
type: "local",
|
|
@@ -738,24 +738,18 @@ function initCommand() {
|
|
|
738
738
|
console.log(chalk8.dim(`Organization: ${chalk8.cyan(org)}
|
|
739
739
|
`));
|
|
740
740
|
}
|
|
741
|
-
const configDir = path4.join(process.cwd(), ".fractary");
|
|
742
|
-
const configPath = path4.join(configDir, "
|
|
741
|
+
const configDir = path4.join(process.cwd(), ".fractary", "codex");
|
|
742
|
+
const configPath = path4.join(configDir, "config.yaml");
|
|
743
743
|
const configExists = await fileExists(configPath);
|
|
744
|
-
const legacyConfigPath = path4.join(process.cwd(), ".fractary", "plugins", "codex", "config.json");
|
|
745
|
-
const legacyExists = await fileExists(legacyConfigPath);
|
|
746
744
|
if (configExists && !options.force) {
|
|
747
|
-
console.log(chalk8.yellow("\u26A0 Configuration already exists at .fractary/codex.yaml"));
|
|
745
|
+
console.log(chalk8.yellow("\u26A0 Configuration already exists at .fractary/codex/config.yaml"));
|
|
748
746
|
console.log(chalk8.dim("Use --force to overwrite"));
|
|
749
747
|
process.exit(1);
|
|
750
748
|
}
|
|
751
|
-
if (legacyExists && !configExists) {
|
|
752
|
-
console.log(chalk8.yellow("\u26A0 Legacy configuration detected at .fractary/plugins/codex/config.json"));
|
|
753
|
-
console.log(chalk8.dim('Run "fractary codex migrate" to upgrade to YAML format\n'));
|
|
754
|
-
}
|
|
755
749
|
console.log("Creating directory structure...");
|
|
756
750
|
const dirs = [
|
|
757
|
-
".fractary",
|
|
758
|
-
".codex
|
|
751
|
+
".fractary/codex",
|
|
752
|
+
".fractary/codex/cache"
|
|
759
753
|
];
|
|
760
754
|
for (const dir of dirs) {
|
|
761
755
|
await fs.mkdir(path4.join(process.cwd(), dir), { recursive: true });
|
|
@@ -767,12 +761,12 @@ function initCommand() {
|
|
|
767
761
|
config.mcp.enabled = true;
|
|
768
762
|
}
|
|
769
763
|
await writeYamlConfig(config, configPath);
|
|
770
|
-
console.log(chalk8.green("\u2713"), chalk8.dim(".fractary/codex.yaml"));
|
|
771
|
-
console.log(chalk8.green("\n\u2713 Codex
|
|
764
|
+
console.log(chalk8.green("\u2713"), chalk8.dim(".fractary/codex/config.yaml"));
|
|
765
|
+
console.log(chalk8.green("\n\u2713 Codex v4.0 initialized successfully!\n"));
|
|
772
766
|
console.log(chalk8.bold("Configuration:"));
|
|
773
767
|
console.log(chalk8.dim(` Organization: ${org}`));
|
|
774
|
-
console.log(chalk8.dim(` Cache: .codex
|
|
775
|
-
console.log(chalk8.dim(` Config: .fractary/codex.yaml`));
|
|
768
|
+
console.log(chalk8.dim(` Cache: .fractary/codex/cache/`));
|
|
769
|
+
console.log(chalk8.dim(` Config: .fractary/codex/config.yaml`));
|
|
776
770
|
if (options.mcp) {
|
|
777
771
|
console.log(chalk8.dim(` MCP Server: Enabled (port 3000)`));
|
|
778
772
|
}
|
|
@@ -782,13 +776,9 @@ function initCommand() {
|
|
|
782
776
|
console.log(chalk8.dim(" - HTTP endpoint"));
|
|
783
777
|
console.log(chalk8.bold("\nNext steps:"));
|
|
784
778
|
console.log(chalk8.dim(' 1. Set your GitHub token: export GITHUB_TOKEN="your_token"'));
|
|
785
|
-
console.log(chalk8.dim(" 2. Edit .fractary/codex.yaml to configure storage providers"));
|
|
779
|
+
console.log(chalk8.dim(" 2. Edit .fractary/codex/config.yaml to configure storage providers"));
|
|
786
780
|
console.log(chalk8.dim(" 3. Fetch a document: fractary codex fetch codex://org/project/path"));
|
|
787
781
|
console.log(chalk8.dim(" 4. Check cache: fractary codex cache list"));
|
|
788
|
-
if (legacyExists) {
|
|
789
|
-
console.log(chalk8.yellow("\n\u26A0 Legacy config detected:"));
|
|
790
|
-
console.log(chalk8.dim(' Run "fractary codex migrate" to convert your existing config'));
|
|
791
|
-
}
|
|
792
782
|
} catch (error) {
|
|
793
783
|
console.error(chalk8.red("Error:"), error.message);
|
|
794
784
|
process.exit(1);
|
|
@@ -1421,7 +1411,7 @@ function syncCommand() {
|
|
|
1421
1411
|
let projectName = name;
|
|
1422
1412
|
if (!projectName) {
|
|
1423
1413
|
const detected = detectCurrentProject();
|
|
1424
|
-
projectName = detected.project ||
|
|
1414
|
+
projectName = detected.project || void 0;
|
|
1425
1415
|
}
|
|
1426
1416
|
if (!projectName) {
|
|
1427
1417
|
console.error(chalk8.red("Error:"), "Could not determine project name.");
|
|
@@ -1444,7 +1434,7 @@ function syncCommand() {
|
|
|
1444
1434
|
config: config.sync,
|
|
1445
1435
|
manifestPath: path4.join(process.cwd(), ".fractary", ".codex-sync-manifest.json")
|
|
1446
1436
|
});
|
|
1447
|
-
const defaultPatterns =
|
|
1437
|
+
const defaultPatterns = [
|
|
1448
1438
|
"docs/**/*.md",
|
|
1449
1439
|
"specs/**/*.md",
|
|
1450
1440
|
".fractary/standards/**",
|
|
@@ -1479,13 +1469,36 @@ function syncCommand() {
|
|
|
1479
1469
|
include: includePatterns,
|
|
1480
1470
|
exclude: excludePatterns
|
|
1481
1471
|
};
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1472
|
+
let plan;
|
|
1473
|
+
let routingScan;
|
|
1474
|
+
if (direction === "from-codex") {
|
|
1475
|
+
const codexRepoPath = config.cacheDir || path4.join(process.cwd(), ".fractary", "codex-cache");
|
|
1476
|
+
if (options.json) {
|
|
1477
|
+
console.log(JSON.stringify({
|
|
1478
|
+
info: "Routing-aware sync: scanning entire codex repository for files targeting this project",
|
|
1479
|
+
codexPath: codexRepoPath
|
|
1480
|
+
}, null, 2));
|
|
1481
|
+
} else {
|
|
1482
|
+
console.log(chalk8.blue("\u2139 Using routing-aware sync"));
|
|
1483
|
+
console.log(chalk8.dim(" Scanning entire codex for files routing to this project...\n"));
|
|
1484
|
+
}
|
|
1485
|
+
const planWithRouting = await syncManager.createRoutingAwarePlan(
|
|
1486
|
+
config.organization,
|
|
1487
|
+
projectName,
|
|
1488
|
+
codexRepoPath,
|
|
1489
|
+
syncOptions
|
|
1490
|
+
);
|
|
1491
|
+
plan = planWithRouting;
|
|
1492
|
+
routingScan = planWithRouting.routingScan;
|
|
1493
|
+
} else {
|
|
1494
|
+
plan = await syncManager.createPlan(
|
|
1495
|
+
config.organization,
|
|
1496
|
+
projectName,
|
|
1497
|
+
sourceDir,
|
|
1498
|
+
targetFiles,
|
|
1499
|
+
syncOptions
|
|
1500
|
+
);
|
|
1501
|
+
}
|
|
1489
1502
|
if (plan.totalFiles === 0) {
|
|
1490
1503
|
if (options.json) {
|
|
1491
1504
|
console.log(JSON.stringify({
|
|
@@ -1548,6 +1561,20 @@ function syncCommand() {
|
|
|
1548
1561
|
if (plan.estimatedTime) {
|
|
1549
1562
|
console.log(` Est. time: ${chalk8.dim(formatDuration(plan.estimatedTime))}`);
|
|
1550
1563
|
}
|
|
1564
|
+
if (routingScan) {
|
|
1565
|
+
console.log("");
|
|
1566
|
+
console.log(chalk8.bold("Routing Statistics\n"));
|
|
1567
|
+
console.log(` Scanned: ${chalk8.cyan(routingScan.stats.totalScanned.toString())} files`);
|
|
1568
|
+
console.log(` Matched: ${chalk8.cyan(routingScan.stats.totalMatched.toString())} files`);
|
|
1569
|
+
console.log(` Source projects: ${chalk8.cyan(routingScan.stats.sourceProjects.length.toString())}`);
|
|
1570
|
+
if (routingScan.stats.sourceProjects.length > 0) {
|
|
1571
|
+
console.log(chalk8.dim(` ${routingScan.stats.sourceProjects.slice(0, 5).join(", ")}`));
|
|
1572
|
+
if (routingScan.stats.sourceProjects.length > 5) {
|
|
1573
|
+
console.log(chalk8.dim(` ... and ${routingScan.stats.sourceProjects.length - 5} more`));
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
console.log(` Scan time: ${chalk8.dim(formatDuration(routingScan.stats.durationMs))}`);
|
|
1577
|
+
}
|
|
1551
1578
|
console.log("");
|
|
1552
1579
|
if (plan.conflicts.length > 0) {
|
|
1553
1580
|
console.log(chalk8.yellow(`\u26A0 ${plan.conflicts.length} conflicts detected:`));
|