@fractary/codex-cli 0.9.0 → 0.9.1
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/dist/cli.cjs +128 -4
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +128 -4
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -1023,6 +1023,106 @@ async function initializeUnifiedConfig(configPath, organization, project, option
|
|
|
1023
1023
|
};
|
|
1024
1024
|
}
|
|
1025
1025
|
|
|
1026
|
+
// src/config/gitignore-utils.ts
|
|
1027
|
+
init_cjs_shims();
|
|
1028
|
+
var DEFAULT_FRACTARY_GITIGNORE = `# .fractary/.gitignore
|
|
1029
|
+
# This file is managed by multiple plugins - each plugin manages its own section
|
|
1030
|
+
|
|
1031
|
+
# ===== fractary-codex (managed) =====
|
|
1032
|
+
codex/cache/
|
|
1033
|
+
# ===== end fractary-codex =====
|
|
1034
|
+
`;
|
|
1035
|
+
var DEFAULT_CACHE_DIR = "codex/cache/";
|
|
1036
|
+
async function readFractaryGitignore(projectRoot) {
|
|
1037
|
+
const gitignorePath = path4__namespace.join(projectRoot, ".fractary", ".gitignore");
|
|
1038
|
+
try {
|
|
1039
|
+
return await fs__namespace.readFile(gitignorePath, "utf-8");
|
|
1040
|
+
} catch (error) {
|
|
1041
|
+
if (error.code === "ENOENT") {
|
|
1042
|
+
return null;
|
|
1043
|
+
}
|
|
1044
|
+
throw error;
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
async function writeFractaryGitignore(projectRoot, content) {
|
|
1048
|
+
const gitignorePath = path4__namespace.join(projectRoot, ".fractary", ".gitignore");
|
|
1049
|
+
await fs__namespace.mkdir(path4__namespace.join(projectRoot, ".fractary"), { recursive: true });
|
|
1050
|
+
await fs__namespace.writeFile(gitignorePath, content, "utf-8");
|
|
1051
|
+
}
|
|
1052
|
+
function normalizeCachePath(cachePath) {
|
|
1053
|
+
let normalized = cachePath.replace(/\\/g, "/");
|
|
1054
|
+
normalized = normalized.replace(/^\.fractary\//, "");
|
|
1055
|
+
if (!normalized.endsWith("/")) {
|
|
1056
|
+
normalized += "/";
|
|
1057
|
+
}
|
|
1058
|
+
return normalized;
|
|
1059
|
+
}
|
|
1060
|
+
function isCachePathIgnored(gitignoreContent, cachePath) {
|
|
1061
|
+
const normalized = normalizeCachePath(cachePath);
|
|
1062
|
+
const lines = gitignoreContent.split("\n").map((l) => l.trim());
|
|
1063
|
+
return lines.some((line) => {
|
|
1064
|
+
if (line.startsWith("#") || line === "") return false;
|
|
1065
|
+
let normalizedLine = line.replace(/\\/g, "/");
|
|
1066
|
+
if (!normalizedLine.endsWith("/")) {
|
|
1067
|
+
normalizedLine += "/";
|
|
1068
|
+
}
|
|
1069
|
+
return normalizedLine === normalized;
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
function addCachePathToGitignore(gitignoreContent, cachePath, comment) {
|
|
1073
|
+
const normalized = normalizeCachePath(cachePath);
|
|
1074
|
+
if (isCachePathIgnored(gitignoreContent, cachePath)) {
|
|
1075
|
+
return gitignoreContent;
|
|
1076
|
+
}
|
|
1077
|
+
let addition = "";
|
|
1078
|
+
{
|
|
1079
|
+
addition += `
|
|
1080
|
+
# ${comment}
|
|
1081
|
+
`;
|
|
1082
|
+
}
|
|
1083
|
+
addition += normalized + "\n";
|
|
1084
|
+
return gitignoreContent.trimEnd() + addition;
|
|
1085
|
+
}
|
|
1086
|
+
async function ensureCachePathIgnored(projectRoot, cachePath) {
|
|
1087
|
+
const gitignorePath = path4__namespace.join(projectRoot, ".fractary", ".gitignore");
|
|
1088
|
+
let relativeCachePath = cachePath;
|
|
1089
|
+
if (path4__namespace.isAbsolute(cachePath)) {
|
|
1090
|
+
relativeCachePath = path4__namespace.relative(path4__namespace.join(projectRoot, ".fractary"), cachePath);
|
|
1091
|
+
}
|
|
1092
|
+
relativeCachePath = normalizeCachePath(relativeCachePath);
|
|
1093
|
+
let content = await readFractaryGitignore(projectRoot);
|
|
1094
|
+
const gitignoreExists = content !== null;
|
|
1095
|
+
if (!gitignoreExists) {
|
|
1096
|
+
content = DEFAULT_FRACTARY_GITIGNORE;
|
|
1097
|
+
if (!isCachePathIgnored(content, relativeCachePath)) {
|
|
1098
|
+
content = addCachePathToGitignore(content, relativeCachePath, "Custom cache directory");
|
|
1099
|
+
}
|
|
1100
|
+
await writeFractaryGitignore(projectRoot, content);
|
|
1101
|
+
return {
|
|
1102
|
+
created: true,
|
|
1103
|
+
updated: false,
|
|
1104
|
+
alreadyIgnored: false,
|
|
1105
|
+
gitignorePath
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
if (isCachePathIgnored(content, relativeCachePath)) {
|
|
1109
|
+
return {
|
|
1110
|
+
created: false,
|
|
1111
|
+
updated: false,
|
|
1112
|
+
alreadyIgnored: true,
|
|
1113
|
+
gitignorePath
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
content = addCachePathToGitignore(content, relativeCachePath, "Custom cache directory");
|
|
1117
|
+
await writeFractaryGitignore(projectRoot, content);
|
|
1118
|
+
return {
|
|
1119
|
+
created: false,
|
|
1120
|
+
updated: true,
|
|
1121
|
+
alreadyIgnored: false,
|
|
1122
|
+
gitignorePath
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1026
1126
|
// src/commands/config/init.ts
|
|
1027
1127
|
async function getOrgFromGitRemote() {
|
|
1028
1128
|
try {
|
|
@@ -1093,6 +1193,14 @@ function initCommand() {
|
|
|
1093
1193
|
await fs__namespace.mkdir(path4__namespace.join(process.cwd(), dir), { recursive: true });
|
|
1094
1194
|
console.log(chalk8__default.default.green("\u2713"), chalk8__default.default.dim(dir + "/"));
|
|
1095
1195
|
}
|
|
1196
|
+
const gitignoreResult = await ensureCachePathIgnored(process.cwd(), ".fractary/codex/cache");
|
|
1197
|
+
if (gitignoreResult.created) {
|
|
1198
|
+
console.log(chalk8__default.default.green("\u2713"), chalk8__default.default.dim(".fractary/.gitignore (created)"));
|
|
1199
|
+
} else if (gitignoreResult.updated) {
|
|
1200
|
+
console.log(chalk8__default.default.green("\u2713"), chalk8__default.default.dim(".fractary/.gitignore (updated)"));
|
|
1201
|
+
} else {
|
|
1202
|
+
console.log(chalk8__default.default.green("\u2713"), chalk8__default.default.dim(".fractary/.gitignore (exists)"));
|
|
1203
|
+
}
|
|
1096
1204
|
console.log("\nInitializing configuration...");
|
|
1097
1205
|
const result = await initializeUnifiedConfig(
|
|
1098
1206
|
configPath,
|
|
@@ -1181,8 +1289,9 @@ function migrateCommand() {
|
|
|
1181
1289
|
let legacyConfig;
|
|
1182
1290
|
try {
|
|
1183
1291
|
legacyConfig = JSON.parse(legacyContent);
|
|
1184
|
-
} catch {
|
|
1292
|
+
} catch (parseError) {
|
|
1185
1293
|
console.error(chalk8__default.default.red("Error:"), "Invalid JSON in legacy config file.");
|
|
1294
|
+
console.error(chalk8__default.default.dim("Details:"), parseError.message);
|
|
1186
1295
|
process.exit(1);
|
|
1187
1296
|
}
|
|
1188
1297
|
if (!options.json && !options.dryRun) {
|
|
@@ -1243,19 +1352,34 @@ function migrateCommand() {
|
|
|
1243
1352
|
}
|
|
1244
1353
|
if (!options.dryRun) {
|
|
1245
1354
|
await writeYamlConfig(migrationResult.yamlConfig, newConfigPath);
|
|
1246
|
-
const
|
|
1355
|
+
const configuredCacheDir = migrationResult.yamlConfig.cacheDir || ".fractary/codex/cache";
|
|
1356
|
+
const cacheDir = path4__namespace.join(process.cwd(), configuredCacheDir);
|
|
1247
1357
|
await fs__namespace.mkdir(cacheDir, { recursive: true });
|
|
1358
|
+
const gitignoreResult = await ensureCachePathIgnored(process.cwd(), configuredCacheDir);
|
|
1359
|
+
const isCustomCachePath = normalizeCachePath(configuredCacheDir) !== DEFAULT_CACHE_DIR;
|
|
1248
1360
|
if (!options.json) {
|
|
1249
1361
|
console.log(chalk8__default.default.green("\u2713"), "YAML configuration created");
|
|
1250
1362
|
console.log(chalk8__default.default.green("\u2713"), "Cache directory initialized");
|
|
1251
1363
|
if (migrationResult.backupPath) {
|
|
1252
1364
|
console.log(chalk8__default.default.green("\u2713"), "Legacy config backed up");
|
|
1253
1365
|
}
|
|
1366
|
+
if (gitignoreResult.created) {
|
|
1367
|
+
console.log(chalk8__default.default.green("\u2713"), ".fractary/.gitignore created");
|
|
1368
|
+
} else if (gitignoreResult.updated) {
|
|
1369
|
+
console.log(chalk8__default.default.green("\u2713"), ".fractary/.gitignore updated with cache path");
|
|
1370
|
+
} else if (gitignoreResult.alreadyIgnored) {
|
|
1371
|
+
console.log(chalk8__default.default.green("\u2713"), "Cache path already in .fractary/.gitignore");
|
|
1372
|
+
}
|
|
1373
|
+
if (isCustomCachePath) {
|
|
1374
|
+
console.log("");
|
|
1375
|
+
console.log(chalk8__default.default.yellow("\u26A0 Custom cache directory detected:"), chalk8__default.default.dim(configuredCacheDir));
|
|
1376
|
+
console.log(chalk8__default.default.dim(" Ensure .fractary/.gitignore includes this path to avoid committing cache files."));
|
|
1377
|
+
}
|
|
1254
1378
|
console.log("");
|
|
1255
1379
|
console.log(chalk8__default.default.bold("New Configuration:"));
|
|
1256
1380
|
console.log(chalk8__default.default.dim(` Path: ${newConfigPath}`));
|
|
1257
1381
|
console.log(chalk8__default.default.dim(` Organization: ${migrationResult.yamlConfig.organization}`));
|
|
1258
|
-
console.log(chalk8__default.default.dim(` Cache: ${
|
|
1382
|
+
console.log(chalk8__default.default.dim(` Cache: ${configuredCacheDir}`));
|
|
1259
1383
|
console.log(chalk8__default.default.dim(` Storage Providers: ${migrationResult.yamlConfig.storage?.length || 0}`));
|
|
1260
1384
|
console.log("");
|
|
1261
1385
|
console.log(chalk8__default.default.bold("Next Steps:"));
|
|
@@ -1826,7 +1950,7 @@ function syncCommand() {
|
|
|
1826
1950
|
const targetFiles = await Promise.all(
|
|
1827
1951
|
Array.from(matchedFilePaths).map(async (filePath) => {
|
|
1828
1952
|
const fullPath = path4__namespace.join(sourceDir, filePath);
|
|
1829
|
-
const stats = await import('fs/promises').then((
|
|
1953
|
+
const stats = await import('fs/promises').then((fs9) => fs9.stat(fullPath));
|
|
1830
1954
|
return {
|
|
1831
1955
|
path: filePath,
|
|
1832
1956
|
size: stats.size,
|