@fractary/codex-cli 0.9.1 → 0.10.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/README.md +2 -2
- package/dist/cli.cjs +361 -412
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +360 -411
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -8,7 +8,7 @@ var codex = require('@fractary/codex');
|
|
|
8
8
|
var os = require('os');
|
|
9
9
|
var child_process = require('child_process');
|
|
10
10
|
var commander = require('commander');
|
|
11
|
-
var
|
|
11
|
+
var chalk7 = require('chalk');
|
|
12
12
|
var crypto = require('crypto');
|
|
13
13
|
var fs = require('fs');
|
|
14
14
|
var url = require('url');
|
|
@@ -37,7 +37,7 @@ var fs__namespace = /*#__PURE__*/_interopNamespace(fs$1);
|
|
|
37
37
|
var path4__namespace = /*#__PURE__*/_interopNamespace(path4);
|
|
38
38
|
var yaml__namespace = /*#__PURE__*/_interopNamespace(yaml);
|
|
39
39
|
var os__namespace = /*#__PURE__*/_interopNamespace(os);
|
|
40
|
-
var
|
|
40
|
+
var chalk7__default = /*#__PURE__*/_interopDefault(chalk7);
|
|
41
41
|
var crypto__namespace = /*#__PURE__*/_interopNamespace(crypto);
|
|
42
42
|
|
|
43
43
|
var __defProp = Object.defineProperty;
|
|
@@ -829,14 +829,14 @@ function fetchCommand() {
|
|
|
829
829
|
try {
|
|
830
830
|
const { validateUri } = await import('@fractary/codex');
|
|
831
831
|
if (!validateUri(uri)) {
|
|
832
|
-
console.error(
|
|
833
|
-
console.log(
|
|
834
|
-
console.log(
|
|
832
|
+
console.error(chalk7__default.default.red("Error: Invalid URI format"));
|
|
833
|
+
console.log(chalk7__default.default.dim("Expected: codex://org/project/path/to/file.md"));
|
|
834
|
+
console.log(chalk7__default.default.dim("Example: codex://fractary/codex/docs/api.md"));
|
|
835
835
|
process.exit(1);
|
|
836
836
|
}
|
|
837
837
|
const client = await getClient();
|
|
838
838
|
if (!options.json && !options.bypassCache) {
|
|
839
|
-
console.error(
|
|
839
|
+
console.error(chalk7__default.default.dim(`Fetching ${uri}...`));
|
|
840
840
|
}
|
|
841
841
|
const result = await client.fetch(uri, {
|
|
842
842
|
bypassCache: options.bypassCache,
|
|
@@ -857,30 +857,30 @@ function fetchCommand() {
|
|
|
857
857
|
console.log(JSON.stringify(output, null, 2));
|
|
858
858
|
} else if (options.output) {
|
|
859
859
|
await fs__namespace.writeFile(options.output, result.content);
|
|
860
|
-
console.log(
|
|
861
|
-
console.log(
|
|
860
|
+
console.log(chalk7__default.default.green("\u2713"), `Written to ${options.output}`);
|
|
861
|
+
console.log(chalk7__default.default.dim(` Size: ${result.content.length} bytes`));
|
|
862
862
|
if (result.fromCache) {
|
|
863
|
-
console.log(
|
|
863
|
+
console.log(chalk7__default.default.dim(" Source: cache"));
|
|
864
864
|
} else {
|
|
865
|
-
console.log(
|
|
865
|
+
console.log(chalk7__default.default.dim(" Source: storage"));
|
|
866
866
|
}
|
|
867
867
|
} else {
|
|
868
868
|
if (result.fromCache && !options.bypassCache) {
|
|
869
|
-
console.error(
|
|
869
|
+
console.error(chalk7__default.default.green("\u2713"), chalk7__default.default.dim("from cache\n"));
|
|
870
870
|
} else {
|
|
871
|
-
console.error(
|
|
871
|
+
console.error(chalk7__default.default.green("\u2713"), chalk7__default.default.dim("fetched\n"));
|
|
872
872
|
}
|
|
873
873
|
console.log(result.content.toString("utf-8"));
|
|
874
874
|
}
|
|
875
875
|
} catch (error) {
|
|
876
|
-
console.error(
|
|
876
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
877
877
|
if (error.message.includes("Failed to load configuration")) {
|
|
878
|
-
console.log(
|
|
878
|
+
console.log(chalk7__default.default.dim('\nRun "fractary codex init" to create a configuration.'));
|
|
879
879
|
} else if (error.message.includes("GITHUB_TOKEN")) {
|
|
880
|
-
console.log(
|
|
880
|
+
console.log(chalk7__default.default.dim('\nSet your GitHub token: export GITHUB_TOKEN="your_token"'));
|
|
881
881
|
} else if (error.message.includes("not found") || error.message.includes("404")) {
|
|
882
|
-
console.log(
|
|
883
|
-
console.log(
|
|
882
|
+
console.log(chalk7__default.default.dim("\nThe document may not exist or you may not have access."));
|
|
883
|
+
console.log(chalk7__default.default.dim("Check the URI and ensure your storage providers are configured correctly."));
|
|
884
884
|
}
|
|
885
885
|
process.exit(1);
|
|
886
886
|
}
|
|
@@ -907,7 +907,7 @@ init_cjs_shims();
|
|
|
907
907
|
function sanitizeForS3BucketName(name) {
|
|
908
908
|
return name.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/^-+|-+$/g, "").replace(/-+/g, "-").substring(0, 63);
|
|
909
909
|
}
|
|
910
|
-
function getDefaultUnifiedConfig(organization, project) {
|
|
910
|
+
function getDefaultUnifiedConfig(organization, project, codexRepo) {
|
|
911
911
|
const sanitizedProject = sanitizeForS3BucketName(project);
|
|
912
912
|
return {
|
|
913
913
|
file: {
|
|
@@ -951,6 +951,7 @@ function getDefaultUnifiedConfig(organization, project) {
|
|
|
951
951
|
schema_version: "2.0",
|
|
952
952
|
organization,
|
|
953
953
|
project,
|
|
954
|
+
codex_repo: codexRepo,
|
|
954
955
|
dependencies: {}
|
|
955
956
|
}
|
|
956
957
|
};
|
|
@@ -994,6 +995,7 @@ function mergeUnifiedConfigs(existing, updates) {
|
|
|
994
995
|
schema_version: updates.codex?.schema_version || existing.codex?.schema_version || "2.0",
|
|
995
996
|
organization: updates.codex?.organization || existing.codex?.organization || "default",
|
|
996
997
|
project: updates.codex?.project || existing.codex?.project || "default",
|
|
998
|
+
codex_repo: updates.codex?.codex_repo || existing.codex?.codex_repo || "",
|
|
997
999
|
dependencies: {
|
|
998
1000
|
...existing.codex?.dependencies || {},
|
|
999
1001
|
...updates.codex?.dependencies || {}
|
|
@@ -1002,10 +1004,10 @@ function mergeUnifiedConfigs(existing, updates) {
|
|
|
1002
1004
|
}
|
|
1003
1005
|
return merged;
|
|
1004
1006
|
}
|
|
1005
|
-
async function initializeUnifiedConfig(configPath, organization, project, options) {
|
|
1007
|
+
async function initializeUnifiedConfig(configPath, organization, project, codexRepo, options) {
|
|
1006
1008
|
const existingConfig = await readUnifiedConfig(configPath);
|
|
1007
1009
|
if (existingConfig && !options?.force) {
|
|
1008
|
-
const defaultConfig = getDefaultUnifiedConfig(organization, project);
|
|
1010
|
+
const defaultConfig = getDefaultUnifiedConfig(organization, project, codexRepo);
|
|
1009
1011
|
const merged = mergeUnifiedConfigs(existingConfig, defaultConfig);
|
|
1010
1012
|
await writeUnifiedConfig(merged, configPath);
|
|
1011
1013
|
return {
|
|
@@ -1014,7 +1016,7 @@ async function initializeUnifiedConfig(configPath, organization, project, option
|
|
|
1014
1016
|
config: merged
|
|
1015
1017
|
};
|
|
1016
1018
|
}
|
|
1017
|
-
const config = getDefaultUnifiedConfig(organization, project);
|
|
1019
|
+
const config = getDefaultUnifiedConfig(organization, project, codexRepo);
|
|
1018
1020
|
await writeUnifiedConfig(config, configPath);
|
|
1019
1021
|
return {
|
|
1020
1022
|
created: true,
|
|
@@ -1032,7 +1034,6 @@ var DEFAULT_FRACTARY_GITIGNORE = `# .fractary/.gitignore
|
|
|
1032
1034
|
codex/cache/
|
|
1033
1035
|
# ===== end fractary-codex =====
|
|
1034
1036
|
`;
|
|
1035
|
-
var DEFAULT_CACHE_DIR = "codex/cache/";
|
|
1036
1037
|
async function readFractaryGitignore(projectRoot) {
|
|
1037
1038
|
const gitignorePath = path4__namespace.join(projectRoot, ".fractary", ".gitignore");
|
|
1038
1039
|
try {
|
|
@@ -1124,6 +1125,20 @@ async function ensureCachePathIgnored(projectRoot, cachePath) {
|
|
|
1124
1125
|
}
|
|
1125
1126
|
|
|
1126
1127
|
// src/commands/config/init.ts
|
|
1128
|
+
function validateNameFormat(name, type) {
|
|
1129
|
+
if (!name || typeof name !== "string") {
|
|
1130
|
+
throw new Error(`${type} name is required`);
|
|
1131
|
+
}
|
|
1132
|
+
if (name.length > 100) {
|
|
1133
|
+
throw new Error(`${type} name too long (max 100 characters)`);
|
|
1134
|
+
}
|
|
1135
|
+
const safePattern = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
1136
|
+
if (!safePattern.test(name)) {
|
|
1137
|
+
throw new Error(
|
|
1138
|
+
`Invalid ${type} name format: "${name}". Must start with alphanumeric and contain only: a-z, A-Z, 0-9, ., -, _`
|
|
1139
|
+
);
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1127
1142
|
async function getOrgFromGitRemote() {
|
|
1128
1143
|
try {
|
|
1129
1144
|
const { execSync } = __require("child_process");
|
|
@@ -1135,6 +1150,60 @@ async function getOrgFromGitRemote() {
|
|
|
1135
1150
|
return null;
|
|
1136
1151
|
}
|
|
1137
1152
|
}
|
|
1153
|
+
async function discoverCodexRepo(org) {
|
|
1154
|
+
try {
|
|
1155
|
+
validateNameFormat(org, "organization");
|
|
1156
|
+
} catch (error) {
|
|
1157
|
+
return { repo: null, error: "unknown", message: error.message };
|
|
1158
|
+
}
|
|
1159
|
+
try {
|
|
1160
|
+
const { execSync } = __require("child_process");
|
|
1161
|
+
try {
|
|
1162
|
+
execSync("gh --version", { encoding: "utf-8", stdio: "pipe" });
|
|
1163
|
+
} catch {
|
|
1164
|
+
return {
|
|
1165
|
+
repo: null,
|
|
1166
|
+
error: "gh_not_installed",
|
|
1167
|
+
message: "GitHub CLI (gh) is not installed. Install from https://cli.github.com/"
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
try {
|
|
1171
|
+
execSync("gh auth status", { encoding: "utf-8", stdio: "pipe" });
|
|
1172
|
+
} catch {
|
|
1173
|
+
return {
|
|
1174
|
+
repo: null,
|
|
1175
|
+
error: "auth_failed",
|
|
1176
|
+
message: "GitHub CLI not authenticated. Run: gh auth login"
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
const result = execSync(
|
|
1180
|
+
`gh repo list ${org} --json name --jq '.[].name | select(startswith("codex."))' 2>&1`,
|
|
1181
|
+
{ encoding: "utf-8" }
|
|
1182
|
+
).trim();
|
|
1183
|
+
if (result.includes("Could not resolve to an Organization") || result.includes("Not Found")) {
|
|
1184
|
+
return {
|
|
1185
|
+
repo: null,
|
|
1186
|
+
error: "org_not_found",
|
|
1187
|
+
message: `Organization '${org}' not found on GitHub`
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
const repos = result.split("\n").filter(Boolean);
|
|
1191
|
+
if (repos.length === 0) {
|
|
1192
|
+
return {
|
|
1193
|
+
repo: null,
|
|
1194
|
+
error: "no_repos_found",
|
|
1195
|
+
message: `No codex.* repositories found in organization '${org}'`
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
1198
|
+
return { repo: repos[0] };
|
|
1199
|
+
} catch (error) {
|
|
1200
|
+
return {
|
|
1201
|
+
repo: null,
|
|
1202
|
+
error: "unknown",
|
|
1203
|
+
message: error.message || "Unknown error during discovery"
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1138
1207
|
async function fileExists(filePath) {
|
|
1139
1208
|
try {
|
|
1140
1209
|
await fs__namespace.access(filePath);
|
|
@@ -1145,9 +1214,9 @@ async function fileExists(filePath) {
|
|
|
1145
1214
|
}
|
|
1146
1215
|
function initCommand() {
|
|
1147
1216
|
const cmd = new commander.Command("init");
|
|
1148
|
-
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("--force", "Overwrite existing configuration").action(async (options) => {
|
|
1217
|
+
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) => {
|
|
1149
1218
|
try {
|
|
1150
|
-
console.log(
|
|
1219
|
+
console.log(chalk7__default.default.blue("Initializing unified Fractary configuration...\n"));
|
|
1151
1220
|
let org = options.org;
|
|
1152
1221
|
if (!org) {
|
|
1153
1222
|
org = await getOrgFromGitRemote();
|
|
@@ -1163,23 +1232,66 @@ function initCommand() {
|
|
|
1163
1232
|
}
|
|
1164
1233
|
if (!org) {
|
|
1165
1234
|
org = path4__namespace.basename(process.cwd()).split("-")[0] || "default";
|
|
1166
|
-
console.log(
|
|
1167
|
-
console.log(
|
|
1235
|
+
console.log(chalk7__default.default.yellow(`\u26A0 Could not detect organization, using: ${org}`));
|
|
1236
|
+
console.log(chalk7__default.default.dim(" Use --org <slug> to specify explicitly\n"));
|
|
1168
1237
|
} else {
|
|
1169
|
-
console.log(
|
|
1238
|
+
console.log(chalk7__default.default.dim(`Organization: ${chalk7__default.default.cyan(org)}
|
|
1170
1239
|
`));
|
|
1171
1240
|
}
|
|
1241
|
+
try {
|
|
1242
|
+
validateNameFormat(org, "organization");
|
|
1243
|
+
} catch (error) {
|
|
1244
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
1245
|
+
process.exit(1);
|
|
1246
|
+
}
|
|
1172
1247
|
let project = options.project;
|
|
1173
1248
|
if (!project) {
|
|
1174
1249
|
project = path4__namespace.basename(process.cwd());
|
|
1175
|
-
console.log(
|
|
1250
|
+
console.log(chalk7__default.default.dim(`Project: ${chalk7__default.default.cyan(project)}
|
|
1251
|
+
`));
|
|
1252
|
+
}
|
|
1253
|
+
let codexRepo = options.codexRepo;
|
|
1254
|
+
if (codexRepo) {
|
|
1255
|
+
try {
|
|
1256
|
+
validateNameFormat(codexRepo, "repository");
|
|
1257
|
+
} catch (error) {
|
|
1258
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
1259
|
+
process.exit(1);
|
|
1260
|
+
}
|
|
1261
|
+
console.log(chalk7__default.default.dim(`Codex repository: ${chalk7__default.default.cyan(codexRepo)}
|
|
1262
|
+
`));
|
|
1263
|
+
} else {
|
|
1264
|
+
const discoveryResult = await discoverCodexRepo(org);
|
|
1265
|
+
if (discoveryResult.repo) {
|
|
1266
|
+
codexRepo = discoveryResult.repo;
|
|
1267
|
+
console.log(chalk7__default.default.dim(`Codex repository: ${chalk7__default.default.cyan(codexRepo)} (auto-discovered)
|
|
1268
|
+
`));
|
|
1269
|
+
} else {
|
|
1270
|
+
if (discoveryResult.error === "gh_not_installed") {
|
|
1271
|
+
console.log(chalk7__default.default.dim(` Note: ${discoveryResult.message}
|
|
1272
|
+
`));
|
|
1273
|
+
} else if (discoveryResult.error === "auth_failed") {
|
|
1274
|
+
console.log(chalk7__default.default.dim(` Note: ${discoveryResult.message}
|
|
1275
|
+
`));
|
|
1276
|
+
} else if (discoveryResult.error === "org_not_found") {
|
|
1277
|
+
console.log(chalk7__default.default.dim(` Note: ${discoveryResult.message}
|
|
1278
|
+
`));
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
if (!codexRepo) {
|
|
1283
|
+
console.log(chalk7__default.default.yellow(`\u26A0 Could not discover codex repository in organization '${org}'`));
|
|
1284
|
+
console.log(chalk7__default.default.dim(" Use --codex-repo <name> to specify explicitly"));
|
|
1285
|
+
console.log(chalk7__default.default.dim(" Expected naming convention: codex.{org}.{tld} (e.g., codex.fractary.com)\n"));
|
|
1286
|
+
codexRepo = `codex.${org}.com`;
|
|
1287
|
+
console.log(chalk7__default.default.dim(` Using default: ${chalk7__default.default.cyan(codexRepo)}
|
|
1176
1288
|
`));
|
|
1177
1289
|
}
|
|
1178
1290
|
const configPath = path4__namespace.join(process.cwd(), ".fractary", "config.yaml");
|
|
1179
1291
|
const configExists = await fileExists(configPath);
|
|
1180
1292
|
if (configExists && !options.force) {
|
|
1181
|
-
console.log(
|
|
1182
|
-
console.log(
|
|
1293
|
+
console.log(chalk7__default.default.yellow(`\u26A0 Configuration already exists at .fractary/config.yaml`));
|
|
1294
|
+
console.log(chalk7__default.default.dim("Merging with existing configuration...\n"));
|
|
1183
1295
|
}
|
|
1184
1296
|
console.log("Creating directory structure...");
|
|
1185
1297
|
const dirs = [
|
|
@@ -1191,216 +1303,54 @@ function initCommand() {
|
|
|
1191
1303
|
];
|
|
1192
1304
|
for (const dir of dirs) {
|
|
1193
1305
|
await fs__namespace.mkdir(path4__namespace.join(process.cwd(), dir), { recursive: true });
|
|
1194
|
-
console.log(
|
|
1306
|
+
console.log(chalk7__default.default.green("\u2713"), chalk7__default.default.dim(dir + "/"));
|
|
1195
1307
|
}
|
|
1196
1308
|
const gitignoreResult = await ensureCachePathIgnored(process.cwd(), ".fractary/codex/cache");
|
|
1197
1309
|
if (gitignoreResult.created) {
|
|
1198
|
-
console.log(
|
|
1310
|
+
console.log(chalk7__default.default.green("\u2713"), chalk7__default.default.dim(".fractary/.gitignore (created)"));
|
|
1199
1311
|
} else if (gitignoreResult.updated) {
|
|
1200
|
-
console.log(
|
|
1312
|
+
console.log(chalk7__default.default.green("\u2713"), chalk7__default.default.dim(".fractary/.gitignore (updated)"));
|
|
1201
1313
|
} else {
|
|
1202
|
-
console.log(
|
|
1314
|
+
console.log(chalk7__default.default.green("\u2713"), chalk7__default.default.dim(".fractary/.gitignore (exists)"));
|
|
1203
1315
|
}
|
|
1204
1316
|
console.log("\nInitializing configuration...");
|
|
1205
1317
|
const result = await initializeUnifiedConfig(
|
|
1206
1318
|
configPath,
|
|
1207
1319
|
org,
|
|
1208
1320
|
project,
|
|
1321
|
+
codexRepo,
|
|
1209
1322
|
{ force: options.force }
|
|
1210
1323
|
);
|
|
1211
1324
|
if (result.created) {
|
|
1212
|
-
console.log(
|
|
1325
|
+
console.log(chalk7__default.default.green("\u2713"), chalk7__default.default.dim(".fractary/config.yaml (created)"));
|
|
1213
1326
|
} else if (result.merged) {
|
|
1214
|
-
console.log(
|
|
1215
|
-
}
|
|
1216
|
-
console.log(
|
|
1217
|
-
console.log(
|
|
1218
|
-
console.log(
|
|
1219
|
-
console.log(
|
|
1220
|
-
console.log(
|
|
1221
|
-
console.log(
|
|
1222
|
-
console.log(
|
|
1223
|
-
console.log(
|
|
1224
|
-
console.log(
|
|
1225
|
-
console.log(
|
|
1226
|
-
console.log(
|
|
1227
|
-
console.log(
|
|
1228
|
-
console.log(
|
|
1229
|
-
console.log(
|
|
1230
|
-
console.log(
|
|
1231
|
-
console.log(
|
|
1232
|
-
|
|
1233
|
-
console.
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
// src/commands/config/migrate.ts
|
|
1241
|
-
init_cjs_shims();
|
|
1242
|
-
init_migrate_config();
|
|
1243
|
-
async function fileExists2(filePath) {
|
|
1244
|
-
try {
|
|
1245
|
-
await fs__namespace.access(filePath);
|
|
1246
|
-
return true;
|
|
1247
|
-
} catch {
|
|
1248
|
-
return false;
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
async function readFileContent(filePath) {
|
|
1252
|
-
return fs__namespace.readFile(filePath, "utf-8");
|
|
1253
|
-
}
|
|
1254
|
-
function migrateCommand() {
|
|
1255
|
-
const cmd = new commander.Command("migrate");
|
|
1256
|
-
cmd.description("Migrate legacy JSON configuration to v3.0 YAML format").option("--dry-run", "Show migration plan without executing").option("--no-backup", "Skip creating backup of old config").option("--json", "Output as JSON").action(async (options) => {
|
|
1257
|
-
try {
|
|
1258
|
-
const legacyConfigPath = path4__namespace.join(process.cwd(), ".fractary", "plugins", "codex", "config.json");
|
|
1259
|
-
const newConfigPath = path4__namespace.join(process.cwd(), ".fractary", "codex", "config.yaml");
|
|
1260
|
-
if (!await fileExists2(legacyConfigPath)) {
|
|
1261
|
-
if (options.json) {
|
|
1262
|
-
console.log(JSON.stringify({
|
|
1263
|
-
status: "no_config",
|
|
1264
|
-
message: "No legacy configuration file found",
|
|
1265
|
-
path: legacyConfigPath
|
|
1266
|
-
}));
|
|
1267
|
-
} else {
|
|
1268
|
-
console.log(chalk8__default.default.yellow("\u26A0 No legacy configuration file found."));
|
|
1269
|
-
console.log(chalk8__default.default.dim(` Expected: ${legacyConfigPath}`));
|
|
1270
|
-
console.log(chalk8__default.default.dim('\nRun "fractary codex init" to create a new v3.0 YAML configuration.'));
|
|
1271
|
-
}
|
|
1272
|
-
return;
|
|
1273
|
-
}
|
|
1274
|
-
if (await fileExists2(newConfigPath) && !options.dryRun) {
|
|
1275
|
-
if (options.json) {
|
|
1276
|
-
console.log(JSON.stringify({
|
|
1277
|
-
status: "already_migrated",
|
|
1278
|
-
message: "YAML configuration already exists",
|
|
1279
|
-
path: newConfigPath
|
|
1280
|
-
}));
|
|
1281
|
-
} else {
|
|
1282
|
-
console.log(chalk8__default.default.yellow("\u26A0 YAML configuration already exists."));
|
|
1283
|
-
console.log(chalk8__default.default.dim(` Path: ${newConfigPath}`));
|
|
1284
|
-
console.log(chalk8__default.default.dim('\nUse "fractary codex init --force" to recreate.'));
|
|
1285
|
-
}
|
|
1286
|
-
return;
|
|
1287
|
-
}
|
|
1288
|
-
const legacyContent = await readFileContent(legacyConfigPath);
|
|
1289
|
-
let legacyConfig;
|
|
1290
|
-
try {
|
|
1291
|
-
legacyConfig = JSON.parse(legacyContent);
|
|
1292
|
-
} catch (parseError) {
|
|
1293
|
-
console.error(chalk8__default.default.red("Error:"), "Invalid JSON in legacy config file.");
|
|
1294
|
-
console.error(chalk8__default.default.dim("Details:"), parseError.message);
|
|
1295
|
-
process.exit(1);
|
|
1296
|
-
}
|
|
1297
|
-
if (!options.json && !options.dryRun) {
|
|
1298
|
-
console.log(chalk8__default.default.blue("Migrating Codex configuration to v3.0 YAML format...\n"));
|
|
1299
|
-
}
|
|
1300
|
-
const migrationResult = await migrateConfig(
|
|
1301
|
-
legacyConfigPath,
|
|
1302
|
-
{
|
|
1303
|
-
createBackup: options.backup !== false,
|
|
1304
|
-
backupSuffix: (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")
|
|
1305
|
-
}
|
|
1306
|
-
);
|
|
1307
|
-
if (!options.json) {
|
|
1308
|
-
console.log(chalk8__default.default.bold("Legacy Configuration:"));
|
|
1309
|
-
console.log(chalk8__default.default.dim(` Path: ${legacyConfigPath}`));
|
|
1310
|
-
console.log(chalk8__default.default.dim(` Organization: ${legacyConfig.organization || legacyConfig.organizationSlug || "unknown"}`));
|
|
1311
|
-
console.log("");
|
|
1312
|
-
console.log(chalk8__default.default.bold("Migration Changes:"));
|
|
1313
|
-
console.log(chalk8__default.default.green(" + Format: JSON \u2192 YAML"));
|
|
1314
|
-
console.log(chalk8__default.default.green(" + Location: .fractary/plugins/codex/ \u2192 .fractary/"));
|
|
1315
|
-
console.log(chalk8__default.default.green(" + File: config.json \u2192 codex.yaml"));
|
|
1316
|
-
console.log(chalk8__default.default.green(" + Storage: Multi-provider configuration"));
|
|
1317
|
-
console.log(chalk8__default.default.green(" + Cache: Modern cache management"));
|
|
1318
|
-
console.log(chalk8__default.default.green(" + Types: Custom type registry"));
|
|
1319
|
-
if (migrationResult.warnings.length > 0) {
|
|
1320
|
-
console.log("");
|
|
1321
|
-
console.log(chalk8__default.default.yellow("Warnings:"));
|
|
1322
|
-
for (const warning of migrationResult.warnings) {
|
|
1323
|
-
console.log(chalk8__default.default.yellow(" \u26A0"), chalk8__default.default.dim(warning));
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
console.log("");
|
|
1327
|
-
if (options.dryRun) {
|
|
1328
|
-
console.log(chalk8__default.default.blue("Dry run - no changes made."));
|
|
1329
|
-
console.log(chalk8__default.default.dim("Run without --dry-run to execute migration."));
|
|
1330
|
-
return;
|
|
1331
|
-
}
|
|
1332
|
-
}
|
|
1333
|
-
if (options.json) {
|
|
1334
|
-
const output = {
|
|
1335
|
-
status: options.dryRun ? "migration_ready" : "migrated",
|
|
1336
|
-
dryRun: options.dryRun || false,
|
|
1337
|
-
legacyConfig: {
|
|
1338
|
-
path: legacyConfigPath,
|
|
1339
|
-
organization: legacyConfig.organization || legacyConfig.organizationSlug
|
|
1340
|
-
},
|
|
1341
|
-
newConfig: {
|
|
1342
|
-
path: newConfigPath,
|
|
1343
|
-
organization: migrationResult.yamlConfig.organization
|
|
1344
|
-
},
|
|
1345
|
-
warnings: migrationResult.warnings,
|
|
1346
|
-
backupPath: migrationResult.backupPath
|
|
1347
|
-
};
|
|
1348
|
-
console.log(JSON.stringify(output, null, 2));
|
|
1349
|
-
if (options.dryRun) {
|
|
1350
|
-
return;
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
if (!options.dryRun) {
|
|
1354
|
-
await writeYamlConfig(migrationResult.yamlConfig, newConfigPath);
|
|
1355
|
-
const configuredCacheDir = migrationResult.yamlConfig.cacheDir || ".fractary/codex/cache";
|
|
1356
|
-
const cacheDir = path4__namespace.join(process.cwd(), configuredCacheDir);
|
|
1357
|
-
await fs__namespace.mkdir(cacheDir, { recursive: true });
|
|
1358
|
-
const gitignoreResult = await ensureCachePathIgnored(process.cwd(), configuredCacheDir);
|
|
1359
|
-
const isCustomCachePath = normalizeCachePath(configuredCacheDir) !== DEFAULT_CACHE_DIR;
|
|
1360
|
-
if (!options.json) {
|
|
1361
|
-
console.log(chalk8__default.default.green("\u2713"), "YAML configuration created");
|
|
1362
|
-
console.log(chalk8__default.default.green("\u2713"), "Cache directory initialized");
|
|
1363
|
-
if (migrationResult.backupPath) {
|
|
1364
|
-
console.log(chalk8__default.default.green("\u2713"), "Legacy config backed up");
|
|
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
|
-
}
|
|
1378
|
-
console.log("");
|
|
1379
|
-
console.log(chalk8__default.default.bold("New Configuration:"));
|
|
1380
|
-
console.log(chalk8__default.default.dim(` Path: ${newConfigPath}`));
|
|
1381
|
-
console.log(chalk8__default.default.dim(` Organization: ${migrationResult.yamlConfig.organization}`));
|
|
1382
|
-
console.log(chalk8__default.default.dim(` Cache: ${configuredCacheDir}`));
|
|
1383
|
-
console.log(chalk8__default.default.dim(` Storage Providers: ${migrationResult.yamlConfig.storage?.length || 0}`));
|
|
1384
|
-
console.log("");
|
|
1385
|
-
console.log(chalk8__default.default.bold("Next Steps:"));
|
|
1386
|
-
console.log(chalk8__default.default.dim(" 1. Review the new configuration: .fractary/codex/config.yaml"));
|
|
1387
|
-
console.log(chalk8__default.default.dim(' 2. Set your GitHub token: export GITHUB_TOKEN="your_token"'));
|
|
1388
|
-
console.log(chalk8__default.default.dim(" 3. Test fetching: fractary codex fetch codex://org/project/path"));
|
|
1389
|
-
if (migrationResult.backupPath) {
|
|
1390
|
-
console.log("");
|
|
1391
|
-
console.log(chalk8__default.default.dim(`Backup saved: ${path4__namespace.basename(migrationResult.backupPath)}`));
|
|
1392
|
-
}
|
|
1393
|
-
}
|
|
1394
|
-
}
|
|
1327
|
+
console.log(chalk7__default.default.green("\u2713"), chalk7__default.default.dim(".fractary/config.yaml (merged with existing)"));
|
|
1328
|
+
}
|
|
1329
|
+
console.log(chalk7__default.default.green("\n\u2713 Unified configuration initialized successfully!\n"));
|
|
1330
|
+
console.log(chalk7__default.default.bold("Configuration:"));
|
|
1331
|
+
console.log(chalk7__default.default.dim(` Organization: ${org}`));
|
|
1332
|
+
console.log(chalk7__default.default.dim(` Project: ${project}`));
|
|
1333
|
+
console.log(chalk7__default.default.dim(` Codex Repository: ${codexRepo}`));
|
|
1334
|
+
console.log(chalk7__default.default.dim(` Config: .fractary/config.yaml`));
|
|
1335
|
+
console.log(chalk7__default.default.bold("\nFile plugin sources:"));
|
|
1336
|
+
console.log(chalk7__default.default.dim(" - specs: .fractary/specs/ \u2192 S3"));
|
|
1337
|
+
console.log(chalk7__default.default.dim(" - logs: .fractary/logs/ \u2192 S3"));
|
|
1338
|
+
console.log(chalk7__default.default.bold("\nCodex plugin:"));
|
|
1339
|
+
console.log(chalk7__default.default.dim(" - Cache: .fractary/codex/cache/"));
|
|
1340
|
+
console.log(chalk7__default.default.dim(" - Dependencies: (none configured)"));
|
|
1341
|
+
console.log(chalk7__default.default.bold("\nGit Authentication:"));
|
|
1342
|
+
console.log(chalk7__default.default.dim(" Codex sync uses your existing git credentials."));
|
|
1343
|
+
console.log(chalk7__default.default.dim(" Ensure you have access to the codex repository:"));
|
|
1344
|
+
console.log(chalk7__default.default.dim(` gh repo view ${org}/${codexRepo}`));
|
|
1345
|
+
console.log(chalk7__default.default.dim(" Or set GITHUB_TOKEN environment variable."));
|
|
1346
|
+
console.log(chalk7__default.default.bold("\nNext steps:"));
|
|
1347
|
+
console.log(chalk7__default.default.dim(" 1. Verify codex repository access: gh repo view " + org + "/" + codexRepo));
|
|
1348
|
+
console.log(chalk7__default.default.dim(" 2. Configure AWS credentials for S3 access (if using file plugin)"));
|
|
1349
|
+
console.log(chalk7__default.default.dim(" 3. Edit .fractary/config.yaml to add external project dependencies"));
|
|
1350
|
+
console.log(chalk7__default.default.dim(" 4. Access current project files: codex://specs/SPEC-001.md"));
|
|
1351
|
+
console.log(chalk7__default.default.dim(" 5. Access external projects: codex://org/project/docs/README.md"));
|
|
1395
1352
|
} catch (error) {
|
|
1396
|
-
|
|
1397
|
-
console.log(JSON.stringify({
|
|
1398
|
-
status: "error",
|
|
1399
|
-
message: error.message
|
|
1400
|
-
}));
|
|
1401
|
-
} else {
|
|
1402
|
-
console.error(chalk8__default.default.red("Error:"), error.message);
|
|
1403
|
-
}
|
|
1353
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
1404
1354
|
process.exit(1);
|
|
1405
1355
|
}
|
|
1406
1356
|
});
|
|
@@ -1412,7 +1362,6 @@ function configCommand() {
|
|
|
1412
1362
|
const cmd = new commander.Command("config");
|
|
1413
1363
|
cmd.description("Manage configuration");
|
|
1414
1364
|
cmd.addCommand(initCommand());
|
|
1415
|
-
cmd.addCommand(migrateCommand());
|
|
1416
1365
|
return cmd;
|
|
1417
1366
|
}
|
|
1418
1367
|
|
|
@@ -1436,8 +1385,8 @@ function cacheListCommand() {
|
|
|
1436
1385
|
if (options.json) {
|
|
1437
1386
|
console.log(JSON.stringify({ entries: 0, message: "Cache is empty" }));
|
|
1438
1387
|
} else {
|
|
1439
|
-
console.log(
|
|
1440
|
-
console.log(
|
|
1388
|
+
console.log(chalk7__default.default.yellow("Cache is empty."));
|
|
1389
|
+
console.log(chalk7__default.default.dim("Fetch some documents to populate the cache."));
|
|
1441
1390
|
}
|
|
1442
1391
|
return;
|
|
1443
1392
|
}
|
|
@@ -1451,25 +1400,25 @@ function cacheListCommand() {
|
|
|
1451
1400
|
}, null, 2));
|
|
1452
1401
|
return;
|
|
1453
1402
|
}
|
|
1454
|
-
console.log(
|
|
1455
|
-
console.log(
|
|
1456
|
-
console.log(` Total: ${
|
|
1457
|
-
console.log(` Fresh: ${
|
|
1458
|
-
console.log(` Stale: ${stats.staleCount > 0 ?
|
|
1459
|
-
console.log(` Expired: ${stats.expiredCount > 0 ?
|
|
1403
|
+
console.log(chalk7__default.default.bold("Cache Overview\n"));
|
|
1404
|
+
console.log(chalk7__default.default.bold("Entries:"));
|
|
1405
|
+
console.log(` Total: ${chalk7__default.default.cyan(stats.entryCount.toString())} entries`);
|
|
1406
|
+
console.log(` Fresh: ${chalk7__default.default.green(stats.freshCount.toString())} entries`);
|
|
1407
|
+
console.log(` Stale: ${stats.staleCount > 0 ? chalk7__default.default.yellow(stats.staleCount.toString()) : chalk7__default.default.dim("0")} entries`);
|
|
1408
|
+
console.log(` Expired: ${stats.expiredCount > 0 ? chalk7__default.default.red(stats.expiredCount.toString()) : chalk7__default.default.dim("0")} entries`);
|
|
1460
1409
|
console.log("");
|
|
1461
|
-
console.log(
|
|
1462
|
-
console.log(` Total size: ${
|
|
1410
|
+
console.log(chalk7__default.default.bold("Storage:"));
|
|
1411
|
+
console.log(` Total size: ${chalk7__default.default.cyan(formatSize(stats.totalSize))}`);
|
|
1463
1412
|
console.log("");
|
|
1464
1413
|
const healthPercent = stats.entryCount > 0 ? stats.freshCount / stats.entryCount * 100 : 100;
|
|
1465
|
-
const healthColor = healthPercent > 80 ?
|
|
1414
|
+
const healthColor = healthPercent > 80 ? chalk7__default.default.green : healthPercent > 50 ? chalk7__default.default.yellow : chalk7__default.default.red;
|
|
1466
1415
|
console.log(`Cache health: ${healthColor(`${healthPercent.toFixed(0)}% fresh`)}`);
|
|
1467
1416
|
console.log("");
|
|
1468
|
-
console.log(
|
|
1469
|
-
console.log(
|
|
1470
|
-
console.log(
|
|
1417
|
+
console.log(chalk7__default.default.dim("Note: Individual cache entries are managed by the SDK."));
|
|
1418
|
+
console.log(chalk7__default.default.dim('Use "fractary codex cache stats" for detailed statistics.'));
|
|
1419
|
+
console.log(chalk7__default.default.dim('Use "fractary codex cache clear" to clear cache entries.'));
|
|
1471
1420
|
} catch (error) {
|
|
1472
|
-
console.error(
|
|
1421
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
1473
1422
|
process.exit(1);
|
|
1474
1423
|
}
|
|
1475
1424
|
});
|
|
@@ -1485,7 +1434,7 @@ function cacheClearCommand() {
|
|
|
1485
1434
|
const client = await getClient();
|
|
1486
1435
|
const statsBefore = await client.getCacheStats();
|
|
1487
1436
|
if (statsBefore.entryCount === 0) {
|
|
1488
|
-
console.log(
|
|
1437
|
+
console.log(chalk7__default.default.yellow("Cache is already empty. Nothing to clear."));
|
|
1489
1438
|
return;
|
|
1490
1439
|
}
|
|
1491
1440
|
let pattern;
|
|
@@ -1494,45 +1443,45 @@ function cacheClearCommand() {
|
|
|
1494
1443
|
} else if (options.pattern) {
|
|
1495
1444
|
pattern = options.pattern;
|
|
1496
1445
|
} else {
|
|
1497
|
-
console.log(
|
|
1498
|
-
console.log(
|
|
1499
|
-
console.log(
|
|
1446
|
+
console.log(chalk7__default.default.yellow("Please specify what to clear:"));
|
|
1447
|
+
console.log(chalk7__default.default.dim(" --all Clear entire cache"));
|
|
1448
|
+
console.log(chalk7__default.default.dim(' --pattern Clear entries matching pattern (e.g., "codex://fractary/*")'));
|
|
1500
1449
|
console.log("");
|
|
1501
|
-
console.log(
|
|
1502
|
-
console.log(
|
|
1503
|
-
console.log(
|
|
1450
|
+
console.log(chalk7__default.default.dim("Examples:"));
|
|
1451
|
+
console.log(chalk7__default.default.dim(" fractary codex cache clear --all"));
|
|
1452
|
+
console.log(chalk7__default.default.dim(' fractary codex cache clear --pattern "codex://fractary/cli/*"'));
|
|
1504
1453
|
return;
|
|
1505
1454
|
}
|
|
1506
1455
|
if (options.dryRun) {
|
|
1507
|
-
console.log(
|
|
1456
|
+
console.log(chalk7__default.default.blue("Dry run - would clear:\n"));
|
|
1508
1457
|
if (pattern) {
|
|
1509
|
-
console.log(
|
|
1510
|
-
console.log(
|
|
1458
|
+
console.log(chalk7__default.default.dim(` Pattern: ${pattern}`));
|
|
1459
|
+
console.log(chalk7__default.default.dim(` This would invalidate matching cache entries`));
|
|
1511
1460
|
} else {
|
|
1512
|
-
console.log(
|
|
1461
|
+
console.log(chalk7__default.default.dim(` All cache entries (${statsBefore.entryCount} entries)`));
|
|
1513
1462
|
}
|
|
1514
|
-
console.log(
|
|
1463
|
+
console.log(chalk7__default.default.dim(`
|
|
1515
1464
|
Total size: ${formatSize2(statsBefore.totalSize)}`));
|
|
1516
1465
|
return;
|
|
1517
1466
|
}
|
|
1518
1467
|
if (pattern) {
|
|
1519
|
-
console.log(
|
|
1468
|
+
console.log(chalk7__default.default.blue(`Clearing cache entries matching pattern: ${pattern}
|
|
1520
1469
|
`));
|
|
1521
1470
|
await client.invalidateCache(pattern);
|
|
1522
1471
|
} else {
|
|
1523
|
-
console.log(
|
|
1472
|
+
console.log(chalk7__default.default.blue(`Clearing entire cache (${statsBefore.entryCount} entries)...
|
|
1524
1473
|
`));
|
|
1525
1474
|
await client.invalidateCache();
|
|
1526
1475
|
}
|
|
1527
1476
|
const statsAfter = await client.getCacheStats();
|
|
1528
1477
|
const entriesCleared = statsBefore.entryCount - statsAfter.entryCount;
|
|
1529
1478
|
const sizeFreed = statsBefore.totalSize - statsAfter.totalSize;
|
|
1530
|
-
console.log(
|
|
1479
|
+
console.log(chalk7__default.default.green(`\u2713 Cleared ${entriesCleared} entries (${formatSize2(sizeFreed)} freed)`));
|
|
1531
1480
|
if (statsAfter.entryCount > 0) {
|
|
1532
|
-
console.log(
|
|
1481
|
+
console.log(chalk7__default.default.dim(` Remaining: ${statsAfter.entryCount} entries (${formatSize2(statsAfter.totalSize)})`));
|
|
1533
1482
|
}
|
|
1534
1483
|
} catch (error) {
|
|
1535
|
-
console.error(
|
|
1484
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
1536
1485
|
process.exit(1);
|
|
1537
1486
|
}
|
|
1538
1487
|
});
|
|
@@ -1561,25 +1510,25 @@ function cacheStatsCommand() {
|
|
|
1561
1510
|
console.log(JSON.stringify(stats, null, 2));
|
|
1562
1511
|
return;
|
|
1563
1512
|
}
|
|
1564
|
-
console.log(
|
|
1565
|
-
console.log(
|
|
1566
|
-
console.log(` Total entries: ${
|
|
1567
|
-
console.log(` Total size: ${
|
|
1568
|
-
console.log(` Fresh entries: ${
|
|
1569
|
-
console.log(` Stale entries: ${stats.staleCount > 0 ?
|
|
1570
|
-
console.log(` Expired entries: ${stats.expiredCount > 0 ?
|
|
1513
|
+
console.log(chalk7__default.default.bold("Cache Statistics\n"));
|
|
1514
|
+
console.log(chalk7__default.default.bold("Overview"));
|
|
1515
|
+
console.log(` Total entries: ${chalk7__default.default.cyan(stats.entryCount.toString())}`);
|
|
1516
|
+
console.log(` Total size: ${chalk7__default.default.cyan(formatSize3(stats.totalSize))}`);
|
|
1517
|
+
console.log(` Fresh entries: ${chalk7__default.default.green(stats.freshCount.toString())}`);
|
|
1518
|
+
console.log(` Stale entries: ${stats.staleCount > 0 ? chalk7__default.default.yellow(stats.staleCount.toString()) : chalk7__default.default.dim("0")}`);
|
|
1519
|
+
console.log(` Expired entries: ${stats.expiredCount > 0 ? chalk7__default.default.red(stats.expiredCount.toString()) : chalk7__default.default.dim("0")}`);
|
|
1571
1520
|
console.log("");
|
|
1572
1521
|
const healthPercent = stats.entryCount > 0 ? stats.freshCount / stats.entryCount * 100 : 100;
|
|
1573
|
-
const healthColor = healthPercent > 80 ?
|
|
1522
|
+
const healthColor = healthPercent > 80 ? chalk7__default.default.green : healthPercent > 50 ? chalk7__default.default.yellow : chalk7__default.default.red;
|
|
1574
1523
|
console.log(`Cache health: ${healthColor(`${healthPercent.toFixed(0)}% fresh`)}`);
|
|
1575
1524
|
if (stats.expiredCount > 0) {
|
|
1576
|
-
console.log(
|
|
1525
|
+
console.log(chalk7__default.default.dim('\nRun "fractary codex cache clear --pattern <pattern>" to clean up entries.'));
|
|
1577
1526
|
}
|
|
1578
1527
|
if (stats.entryCount === 0) {
|
|
1579
|
-
console.log(
|
|
1528
|
+
console.log(chalk7__default.default.dim("\nNo cached entries. Fetch some documents to populate the cache."));
|
|
1580
1529
|
}
|
|
1581
1530
|
} catch (error) {
|
|
1582
|
-
console.error(
|
|
1531
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
1583
1532
|
process.exit(1);
|
|
1584
1533
|
}
|
|
1585
1534
|
});
|
|
@@ -1589,7 +1538,7 @@ function cacheStatsCommand() {
|
|
|
1589
1538
|
// src/commands/cache/health.ts
|
|
1590
1539
|
init_cjs_shims();
|
|
1591
1540
|
init_migrate_config();
|
|
1592
|
-
async function
|
|
1541
|
+
async function fileExists2(filePath) {
|
|
1593
1542
|
try {
|
|
1594
1543
|
await fs__namespace.access(filePath);
|
|
1595
1544
|
return true;
|
|
@@ -1598,11 +1547,11 @@ async function fileExists3(filePath) {
|
|
|
1598
1547
|
}
|
|
1599
1548
|
}
|
|
1600
1549
|
async function checkConfiguration() {
|
|
1601
|
-
const configPath = path4__namespace.join(process.cwd(), ".fractary", "
|
|
1550
|
+
const configPath = path4__namespace.join(process.cwd(), ".fractary", "config.yaml");
|
|
1602
1551
|
const legacyConfigPath = path4__namespace.join(process.cwd(), ".fractary", "plugins", "codex", "config.json");
|
|
1603
1552
|
try {
|
|
1604
|
-
if (!await
|
|
1605
|
-
if (await
|
|
1553
|
+
if (!await fileExists2(configPath)) {
|
|
1554
|
+
if (await fileExists2(legacyConfigPath)) {
|
|
1606
1555
|
return {
|
|
1607
1556
|
name: "Configuration",
|
|
1608
1557
|
status: "warn",
|
|
@@ -1706,7 +1655,7 @@ async function checkCache() {
|
|
|
1706
1655
|
}
|
|
1707
1656
|
}
|
|
1708
1657
|
async function checkStorage() {
|
|
1709
|
-
const configPath = path4__namespace.join(process.cwd(), ".fractary", "
|
|
1658
|
+
const configPath = path4__namespace.join(process.cwd(), ".fractary", "config.yaml");
|
|
1710
1659
|
try {
|
|
1711
1660
|
const config = await readYamlConfig(configPath);
|
|
1712
1661
|
const providers = config.storage || [];
|
|
@@ -1715,7 +1664,7 @@ async function checkStorage() {
|
|
|
1715
1664
|
name: "Storage",
|
|
1716
1665
|
status: "warn",
|
|
1717
1666
|
message: "No storage providers configured",
|
|
1718
|
-
details: "Configure at least one provider in .fractary/
|
|
1667
|
+
details: "Configure at least one provider in .fractary/config.yaml"
|
|
1719
1668
|
};
|
|
1720
1669
|
}
|
|
1721
1670
|
const providerTypes = providers.map((p) => p.type).join(", ");
|
|
@@ -1796,32 +1745,32 @@ function healthCommand() {
|
|
|
1796
1745
|
}, null, 2));
|
|
1797
1746
|
return;
|
|
1798
1747
|
}
|
|
1799
|
-
console.log(
|
|
1748
|
+
console.log(chalk7__default.default.bold("Codex Health Check\n"));
|
|
1800
1749
|
for (const check of checks) {
|
|
1801
|
-
const icon = check.status === "pass" ?
|
|
1802
|
-
const statusColor = check.status === "pass" ?
|
|
1803
|
-
console.log(`${icon} ${
|
|
1750
|
+
const icon = check.status === "pass" ? chalk7__default.default.green("\u2713") : check.status === "warn" ? chalk7__default.default.yellow("\u26A0") : chalk7__default.default.red("\u2717");
|
|
1751
|
+
const statusColor = check.status === "pass" ? chalk7__default.default.green : check.status === "warn" ? chalk7__default.default.yellow : chalk7__default.default.red;
|
|
1752
|
+
console.log(`${icon} ${chalk7__default.default.bold(check.name)}`);
|
|
1804
1753
|
console.log(` ${statusColor(check.message)}`);
|
|
1805
1754
|
if (check.details) {
|
|
1806
|
-
console.log(` ${
|
|
1755
|
+
console.log(` ${chalk7__default.default.dim(check.details)}`);
|
|
1807
1756
|
}
|
|
1808
1757
|
console.log("");
|
|
1809
1758
|
}
|
|
1810
|
-
console.log(
|
|
1811
|
-
const overallStatus = failed > 0 ?
|
|
1759
|
+
console.log(chalk7__default.default.dim("\u2500".repeat(60)));
|
|
1760
|
+
const overallStatus = failed > 0 ? chalk7__default.default.red("UNHEALTHY") : warned > 0 ? chalk7__default.default.yellow("DEGRADED") : chalk7__default.default.green("HEALTHY");
|
|
1812
1761
|
console.log(`Status: ${overallStatus}`);
|
|
1813
|
-
console.log(
|
|
1762
|
+
console.log(chalk7__default.default.dim(`${passed} passed, ${warned} warnings, ${failed} failed`));
|
|
1814
1763
|
if (failed > 0 || warned > 0) {
|
|
1815
1764
|
console.log("");
|
|
1816
|
-
console.log(
|
|
1817
|
-
console.log(
|
|
1818
|
-
console.log(
|
|
1765
|
+
console.log(chalk7__default.default.dim("Run checks individually for more details:"));
|
|
1766
|
+
console.log(chalk7__default.default.dim(" fractary codex cache stats"));
|
|
1767
|
+
console.log(chalk7__default.default.dim(" fractary codex types list"));
|
|
1819
1768
|
}
|
|
1820
1769
|
if (failed > 0) {
|
|
1821
1770
|
process.exit(1);
|
|
1822
1771
|
}
|
|
1823
1772
|
} catch (error) {
|
|
1824
|
-
console.error(
|
|
1773
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
1825
1774
|
process.exit(1);
|
|
1826
1775
|
}
|
|
1827
1776
|
});
|
|
@@ -1869,8 +1818,8 @@ function syncCommand() {
|
|
|
1869
1818
|
try {
|
|
1870
1819
|
config = await readYamlConfig(configPath);
|
|
1871
1820
|
} catch (error) {
|
|
1872
|
-
console.error(
|
|
1873
|
-
console.log(
|
|
1821
|
+
console.error(chalk7__default.default.red("Error:"), "Codex not initialized.");
|
|
1822
|
+
console.log(chalk7__default.default.dim('Run "fractary codex init" first.'));
|
|
1874
1823
|
process.exit(1);
|
|
1875
1824
|
}
|
|
1876
1825
|
const { createSyncManager, createLocalStorage, detectCurrentProject } = await import('@fractary/codex');
|
|
@@ -1880,14 +1829,14 @@ function syncCommand() {
|
|
|
1880
1829
|
projectName = detected.project || void 0;
|
|
1881
1830
|
}
|
|
1882
1831
|
if (!projectName) {
|
|
1883
|
-
console.error(
|
|
1884
|
-
console.log(
|
|
1832
|
+
console.error(chalk7__default.default.red("Error:"), "Could not determine project name.");
|
|
1833
|
+
console.log(chalk7__default.default.dim("Provide project name as argument or run from a git repository."));
|
|
1885
1834
|
process.exit(1);
|
|
1886
1835
|
}
|
|
1887
1836
|
const validDirections = ["to-codex", "from-codex", "bidirectional"];
|
|
1888
1837
|
if (!validDirections.includes(options.direction)) {
|
|
1889
|
-
console.error(
|
|
1890
|
-
console.log(
|
|
1838
|
+
console.error(chalk7__default.default.red("Error:"), `Invalid direction: ${options.direction}`);
|
|
1839
|
+
console.log(chalk7__default.default.dim("Valid options: to-codex, from-codex, bidirectional"));
|
|
1891
1840
|
process.exit(1);
|
|
1892
1841
|
}
|
|
1893
1842
|
const direction = options.direction;
|
|
@@ -1944,13 +1893,13 @@ function syncCommand() {
|
|
|
1944
1893
|
});
|
|
1945
1894
|
matches.forEach((match) => matchedFilePaths.add(match));
|
|
1946
1895
|
} catch (error) {
|
|
1947
|
-
console.error(
|
|
1896
|
+
console.error(chalk7__default.default.yellow(`Warning: Invalid pattern "${pattern}": ${error.message}`));
|
|
1948
1897
|
}
|
|
1949
1898
|
}
|
|
1950
1899
|
const targetFiles = await Promise.all(
|
|
1951
1900
|
Array.from(matchedFilePaths).map(async (filePath) => {
|
|
1952
1901
|
const fullPath = path4__namespace.join(sourceDir, filePath);
|
|
1953
|
-
const stats = await import('fs/promises').then((
|
|
1902
|
+
const stats = await import('fs/promises').then((fs8) => fs8.stat(fullPath));
|
|
1954
1903
|
return {
|
|
1955
1904
|
path: filePath,
|
|
1956
1905
|
size: stats.size,
|
|
@@ -1972,14 +1921,14 @@ function syncCommand() {
|
|
|
1972
1921
|
try {
|
|
1973
1922
|
const { ensureCodexCloned: ensureCodexCloned2 } = await Promise.resolve().then(() => (init_codex_repository(), codex_repository_exports));
|
|
1974
1923
|
if (!options.json) {
|
|
1975
|
-
console.log(
|
|
1924
|
+
console.log(chalk7__default.default.blue("\u2139 Cloning/updating codex repository..."));
|
|
1976
1925
|
}
|
|
1977
1926
|
codexRepoPath = await ensureCodexCloned2(config, {
|
|
1978
1927
|
branch: targetBranch
|
|
1979
1928
|
});
|
|
1980
1929
|
if (!options.json) {
|
|
1981
|
-
console.log(
|
|
1982
|
-
console.log(
|
|
1930
|
+
console.log(chalk7__default.default.dim(` Codex cloned to: ${codexRepoPath}`));
|
|
1931
|
+
console.log(chalk7__default.default.dim(" Scanning for files routing to this project...\n"));
|
|
1983
1932
|
} else {
|
|
1984
1933
|
console.log(JSON.stringify({
|
|
1985
1934
|
info: "Routing-aware sync: cloned codex repository and scanning for files targeting this project",
|
|
@@ -1987,29 +1936,29 @@ function syncCommand() {
|
|
|
1987
1936
|
}, null, 2));
|
|
1988
1937
|
}
|
|
1989
1938
|
} catch (error) {
|
|
1990
|
-
console.error(
|
|
1991
|
-
console.error(
|
|
1992
|
-
console.log(
|
|
1939
|
+
console.error(chalk7__default.default.red("Error:"), "Failed to clone codex repository");
|
|
1940
|
+
console.error(chalk7__default.default.dim(` ${error.message}`));
|
|
1941
|
+
console.log(chalk7__default.default.yellow("\nTroubleshooting:"));
|
|
1993
1942
|
if (error.message.includes("Git command not found")) {
|
|
1994
|
-
console.log(
|
|
1995
|
-
console.log(
|
|
1943
|
+
console.log(chalk7__default.default.dim(" Git is not installed or not in PATH."));
|
|
1944
|
+
console.log(chalk7__default.default.dim(" Install git: https://git-scm.com/downloads"));
|
|
1996
1945
|
} else if (error.message.includes("authentication failed") || error.message.includes("Authentication failed")) {
|
|
1997
|
-
console.log(
|
|
1998
|
-
console.log(
|
|
1999
|
-
console.log(
|
|
2000
|
-
console.log(
|
|
1946
|
+
console.log(chalk7__default.default.dim(" GitHub authentication is required for private repositories."));
|
|
1947
|
+
console.log(chalk7__default.default.dim(" 1. Check auth status: gh auth status"));
|
|
1948
|
+
console.log(chalk7__default.default.dim(" 2. Login if needed: gh auth login"));
|
|
1949
|
+
console.log(chalk7__default.default.dim(" 3. Or set GITHUB_TOKEN environment variable"));
|
|
2001
1950
|
} else if (error.message.includes("Permission denied")) {
|
|
2002
|
-
console.log(
|
|
2003
|
-
console.log(
|
|
2004
|
-
console.log(
|
|
1951
|
+
console.log(chalk7__default.default.dim(" Permission denied accessing repository files."));
|
|
1952
|
+
console.log(chalk7__default.default.dim(" 1. Check file/directory permissions"));
|
|
1953
|
+
console.log(chalk7__default.default.dim(" 2. Ensure you have access to the repository"));
|
|
2005
1954
|
} else if (error.message.includes("not found") || error.message.includes("does not exist")) {
|
|
2006
|
-
console.log(
|
|
2007
|
-
console.log(
|
|
2008
|
-
console.log(
|
|
1955
|
+
console.log(chalk7__default.default.dim(` Repository not found: ${config.organization}/${config.codex_repository || "codex"}`));
|
|
1956
|
+
console.log(chalk7__default.default.dim(" 1. Verify the repository exists on GitHub"));
|
|
1957
|
+
console.log(chalk7__default.default.dim(" 2. Check organization and repository names in config"));
|
|
2009
1958
|
} else {
|
|
2010
|
-
console.log(
|
|
2011
|
-
console.log(
|
|
2012
|
-
console.log(
|
|
1959
|
+
console.log(chalk7__default.default.dim(" 1. Ensure git is installed: git --version"));
|
|
1960
|
+
console.log(chalk7__default.default.dim(" 2. Check GitHub auth: gh auth status"));
|
|
1961
|
+
console.log(chalk7__default.default.dim(` 3. Verify repo exists: ${config.organization}/${config.codex_repository || "codex"}`));
|
|
2013
1962
|
}
|
|
2014
1963
|
process.exit(1);
|
|
2015
1964
|
}
|
|
@@ -2039,7 +1988,7 @@ function syncCommand() {
|
|
|
2039
1988
|
synced: 0
|
|
2040
1989
|
}, null, 2));
|
|
2041
1990
|
} else {
|
|
2042
|
-
console.log(
|
|
1991
|
+
console.log(chalk7__default.default.yellow("No files to sync."));
|
|
2043
1992
|
}
|
|
2044
1993
|
return;
|
|
2045
1994
|
}
|
|
@@ -2082,98 +2031,98 @@ function syncCommand() {
|
|
|
2082
2031
|
}, null, 2));
|
|
2083
2032
|
return;
|
|
2084
2033
|
}
|
|
2085
|
-
console.log(
|
|
2086
|
-
console.log(` Project: ${
|
|
2087
|
-
console.log(` Organization: ${
|
|
2088
|
-
console.log(` Environment: ${
|
|
2089
|
-
console.log(` Direction: ${
|
|
2090
|
-
console.log(` Files: ${
|
|
2091
|
-
console.log(` Total size: ${
|
|
2034
|
+
console.log(chalk7__default.default.bold("Sync Plan\n"));
|
|
2035
|
+
console.log(` Project: ${chalk7__default.default.cyan(projectName)}`);
|
|
2036
|
+
console.log(` Organization: ${chalk7__default.default.cyan(config.organization)}`);
|
|
2037
|
+
console.log(` Environment: ${chalk7__default.default.cyan(options.env)} (${targetBranch})`);
|
|
2038
|
+
console.log(` Direction: ${chalk7__default.default.cyan(direction)}`);
|
|
2039
|
+
console.log(` Files: ${chalk7__default.default.cyan(plan.totalFiles.toString())}`);
|
|
2040
|
+
console.log(` Total size: ${chalk7__default.default.cyan(formatBytes(plan.totalBytes))}`);
|
|
2092
2041
|
if (plan.estimatedTime) {
|
|
2093
|
-
console.log(` Est. time: ${
|
|
2042
|
+
console.log(` Est. time: ${chalk7__default.default.dim(formatDuration(plan.estimatedTime))}`);
|
|
2094
2043
|
}
|
|
2095
2044
|
if (routingScan) {
|
|
2096
2045
|
console.log("");
|
|
2097
|
-
console.log(
|
|
2098
|
-
console.log(` Scanned: ${
|
|
2099
|
-
console.log(` Matched: ${
|
|
2100
|
-
console.log(` Source projects: ${
|
|
2046
|
+
console.log(chalk7__default.default.bold("Routing Statistics\n"));
|
|
2047
|
+
console.log(` Scanned: ${chalk7__default.default.cyan(routingScan.stats.totalScanned.toString())} files`);
|
|
2048
|
+
console.log(` Matched: ${chalk7__default.default.cyan(routingScan.stats.totalMatched.toString())} files`);
|
|
2049
|
+
console.log(` Source projects: ${chalk7__default.default.cyan(routingScan.stats.sourceProjects.length.toString())}`);
|
|
2101
2050
|
if (routingScan.stats.sourceProjects.length > 0) {
|
|
2102
|
-
console.log(
|
|
2051
|
+
console.log(chalk7__default.default.dim(` ${routingScan.stats.sourceProjects.slice(0, 5).join(", ")}`));
|
|
2103
2052
|
if (routingScan.stats.sourceProjects.length > 5) {
|
|
2104
|
-
console.log(
|
|
2053
|
+
console.log(chalk7__default.default.dim(` ... and ${routingScan.stats.sourceProjects.length - 5} more`));
|
|
2105
2054
|
}
|
|
2106
2055
|
}
|
|
2107
|
-
console.log(` Scan time: ${
|
|
2056
|
+
console.log(` Scan time: ${chalk7__default.default.dim(formatDuration(routingScan.stats.durationMs))}`);
|
|
2108
2057
|
}
|
|
2109
2058
|
console.log("");
|
|
2110
2059
|
if (plan.conflicts.length > 0) {
|
|
2111
|
-
console.log(
|
|
2060
|
+
console.log(chalk7__default.default.yellow(`\u26A0 ${plan.conflicts.length} conflicts detected:`));
|
|
2112
2061
|
for (const conflict of plan.conflicts.slice(0, 5)) {
|
|
2113
|
-
console.log(
|
|
2062
|
+
console.log(chalk7__default.default.yellow(` \u2022 ${conflict.path}`));
|
|
2114
2063
|
}
|
|
2115
2064
|
if (plan.conflicts.length > 5) {
|
|
2116
|
-
console.log(
|
|
2065
|
+
console.log(chalk7__default.default.dim(` ... and ${plan.conflicts.length - 5} more`));
|
|
2117
2066
|
}
|
|
2118
2067
|
console.log("");
|
|
2119
2068
|
}
|
|
2120
2069
|
if (plan.skipped.length > 0) {
|
|
2121
|
-
console.log(
|
|
2070
|
+
console.log(chalk7__default.default.dim(`${plan.skipped.length} files skipped (no changes)`));
|
|
2122
2071
|
console.log("");
|
|
2123
2072
|
}
|
|
2124
2073
|
if (options.dryRun) {
|
|
2125
|
-
console.log(
|
|
2074
|
+
console.log(chalk7__default.default.blue("Dry run - would sync:\n"));
|
|
2126
2075
|
const filesToShow = plan.files.slice(0, 10);
|
|
2127
2076
|
for (const file of filesToShow) {
|
|
2128
2077
|
const arrow = direction === "to-codex" ? "\u2192" : direction === "from-codex" ? "\u2190" : "\u2194";
|
|
2129
|
-
const opColor = file.operation === "create" ?
|
|
2078
|
+
const opColor = file.operation === "create" ? chalk7__default.default.green : file.operation === "update" ? chalk7__default.default.yellow : chalk7__default.default.dim;
|
|
2130
2079
|
console.log(
|
|
2131
|
-
|
|
2080
|
+
chalk7__default.default.dim(` ${arrow}`),
|
|
2132
2081
|
opColor(file.operation.padEnd(7)),
|
|
2133
2082
|
file.path,
|
|
2134
|
-
|
|
2083
|
+
chalk7__default.default.dim(`(${formatBytes(file.size || 0)})`)
|
|
2135
2084
|
);
|
|
2136
2085
|
}
|
|
2137
2086
|
if (plan.files.length > 10) {
|
|
2138
|
-
console.log(
|
|
2087
|
+
console.log(chalk7__default.default.dim(` ... and ${plan.files.length - 10} more files`));
|
|
2139
2088
|
}
|
|
2140
|
-
console.log(
|
|
2089
|
+
console.log(chalk7__default.default.dim(`
|
|
2141
2090
|
Total: ${plan.totalFiles} files (${formatBytes(plan.totalBytes)})`));
|
|
2142
|
-
console.log(
|
|
2091
|
+
console.log(chalk7__default.default.dim("Run without --dry-run to execute sync."));
|
|
2143
2092
|
return;
|
|
2144
2093
|
}
|
|
2145
|
-
console.log(
|
|
2094
|
+
console.log(chalk7__default.default.blue("Syncing...\n"));
|
|
2146
2095
|
const startTime = Date.now();
|
|
2147
2096
|
const result = await syncManager.executePlan(plan, syncOptions);
|
|
2148
2097
|
const duration = Date.now() - startTime;
|
|
2149
2098
|
console.log("");
|
|
2150
2099
|
if (result.success) {
|
|
2151
|
-
console.log(
|
|
2152
|
-
console.log(
|
|
2100
|
+
console.log(chalk7__default.default.green(`\u2713 Sync completed successfully`));
|
|
2101
|
+
console.log(chalk7__default.default.dim(` Synced: ${result.synced} files`));
|
|
2153
2102
|
if (result.skipped > 0) {
|
|
2154
|
-
console.log(
|
|
2103
|
+
console.log(chalk7__default.default.dim(` Skipped: ${result.skipped} files`));
|
|
2155
2104
|
}
|
|
2156
|
-
console.log(
|
|
2105
|
+
console.log(chalk7__default.default.dim(` Duration: ${formatDuration(duration)}`));
|
|
2157
2106
|
} else {
|
|
2158
|
-
console.log(
|
|
2159
|
-
console.log(
|
|
2160
|
-
console.log(
|
|
2107
|
+
console.log(chalk7__default.default.yellow(`\u26A0 Sync completed with errors`));
|
|
2108
|
+
console.log(chalk7__default.default.green(` Synced: ${result.synced} files`));
|
|
2109
|
+
console.log(chalk7__default.default.red(` Failed: ${result.failed} files`));
|
|
2161
2110
|
if (result.skipped > 0) {
|
|
2162
|
-
console.log(
|
|
2111
|
+
console.log(chalk7__default.default.dim(` Skipped: ${result.skipped} files`));
|
|
2163
2112
|
}
|
|
2164
2113
|
if (result.errors.length > 0) {
|
|
2165
2114
|
console.log("");
|
|
2166
|
-
console.log(
|
|
2115
|
+
console.log(chalk7__default.default.red("Errors:"));
|
|
2167
2116
|
for (const error of result.errors.slice(0, 5)) {
|
|
2168
|
-
console.log(
|
|
2117
|
+
console.log(chalk7__default.default.red(` \u2022 ${error.path}: ${error.error}`));
|
|
2169
2118
|
}
|
|
2170
2119
|
if (result.errors.length > 5) {
|
|
2171
|
-
console.log(
|
|
2120
|
+
console.log(chalk7__default.default.dim(` ... and ${result.errors.length - 5} more errors`));
|
|
2172
2121
|
}
|
|
2173
2122
|
}
|
|
2174
2123
|
}
|
|
2175
2124
|
} catch (error) {
|
|
2176
|
-
console.error(
|
|
2125
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
2177
2126
|
process.exit(1);
|
|
2178
2127
|
}
|
|
2179
2128
|
});
|
|
@@ -2225,35 +2174,35 @@ function typesListCommand() {
|
|
|
2225
2174
|
return;
|
|
2226
2175
|
}
|
|
2227
2176
|
if (types.length === 0) {
|
|
2228
|
-
console.log(
|
|
2177
|
+
console.log(chalk7__default.default.yellow("No types found."));
|
|
2229
2178
|
return;
|
|
2230
2179
|
}
|
|
2231
|
-
console.log(
|
|
2180
|
+
console.log(chalk7__default.default.bold("Artifact Types\n"));
|
|
2232
2181
|
const builtinTypes = types.filter((t) => registry.isBuiltIn(t.name));
|
|
2233
2182
|
const customTypes = types.filter((t) => !registry.isBuiltIn(t.name));
|
|
2234
2183
|
if (builtinTypes.length > 0 && !options.customOnly) {
|
|
2235
|
-
console.log(
|
|
2236
|
-
console.log(
|
|
2184
|
+
console.log(chalk7__default.default.bold("Built-in Types"));
|
|
2185
|
+
console.log(chalk7__default.default.dim("\u2500".repeat(70)));
|
|
2237
2186
|
for (const type of builtinTypes) {
|
|
2238
2187
|
const patternStr = type.patterns[0] || "";
|
|
2239
|
-
console.log(` ${
|
|
2240
|
-
console.log(` ${
|
|
2188
|
+
console.log(` ${chalk7__default.default.cyan(type.name.padEnd(12))} ${patternStr.padEnd(30)} ${chalk7__default.default.dim(`TTL: ${formatTtl(type.defaultTtl)}`)}`);
|
|
2189
|
+
console.log(` ${chalk7__default.default.dim(" ".repeat(12) + type.description)}`);
|
|
2241
2190
|
}
|
|
2242
2191
|
console.log("");
|
|
2243
2192
|
}
|
|
2244
2193
|
if (customTypes.length > 0 && !options.builtinOnly) {
|
|
2245
|
-
console.log(
|
|
2246
|
-
console.log(
|
|
2194
|
+
console.log(chalk7__default.default.bold("Custom Types"));
|
|
2195
|
+
console.log(chalk7__default.default.dim("\u2500".repeat(70)));
|
|
2247
2196
|
for (const type of customTypes) {
|
|
2248
2197
|
const patternStr = type.patterns[0] || "";
|
|
2249
|
-
console.log(` ${
|
|
2250
|
-
console.log(` ${
|
|
2198
|
+
console.log(` ${chalk7__default.default.green(type.name.padEnd(12))} ${patternStr.padEnd(30)} ${chalk7__default.default.dim(`TTL: ${formatTtl(type.defaultTtl)}`)}`);
|
|
2199
|
+
console.log(` ${chalk7__default.default.dim(" ".repeat(12) + type.description)}`);
|
|
2251
2200
|
}
|
|
2252
2201
|
console.log("");
|
|
2253
2202
|
}
|
|
2254
|
-
console.log(
|
|
2203
|
+
console.log(chalk7__default.default.dim(`Total: ${types.length} types (${builtinTypes.length} built-in, ${customTypes.length} custom)`));
|
|
2255
2204
|
} catch (error) {
|
|
2256
|
-
console.error(
|
|
2205
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
2257
2206
|
process.exit(1);
|
|
2258
2207
|
}
|
|
2259
2208
|
});
|
|
@@ -2276,8 +2225,8 @@ function typesShowCommand() {
|
|
|
2276
2225
|
const registry = client.getTypeRegistry();
|
|
2277
2226
|
const type = registry.get(name);
|
|
2278
2227
|
if (!type) {
|
|
2279
|
-
console.error(
|
|
2280
|
-
console.log(
|
|
2228
|
+
console.error(chalk7__default.default.red("Error:"), `Type "${name}" not found.`);
|
|
2229
|
+
console.log(chalk7__default.default.dim('Run "fractary codex types list" to see available types.'));
|
|
2281
2230
|
process.exit(1);
|
|
2282
2231
|
}
|
|
2283
2232
|
const isBuiltin = registry.isBuiltIn(name);
|
|
@@ -2296,39 +2245,39 @@ function typesShowCommand() {
|
|
|
2296
2245
|
}, null, 2));
|
|
2297
2246
|
return;
|
|
2298
2247
|
}
|
|
2299
|
-
const nameColor = isBuiltin ?
|
|
2300
|
-
console.log(
|
|
2248
|
+
const nameColor = isBuiltin ? chalk7__default.default.cyan : chalk7__default.default.green;
|
|
2249
|
+
console.log(chalk7__default.default.bold(`Type: ${nameColor(name)}
|
|
2301
2250
|
`));
|
|
2302
|
-
console.log(` ${
|
|
2303
|
-
console.log(` ${
|
|
2304
|
-
console.log(` ${
|
|
2251
|
+
console.log(` ${chalk7__default.default.dim("Source:")} ${isBuiltin ? "Built-in" : "Custom"}`);
|
|
2252
|
+
console.log(` ${chalk7__default.default.dim("Description:")} ${type.description}`);
|
|
2253
|
+
console.log(` ${chalk7__default.default.dim("TTL:")} ${formatTtl2(type.defaultTtl)} (${type.defaultTtl} seconds)`);
|
|
2305
2254
|
console.log("");
|
|
2306
|
-
console.log(
|
|
2255
|
+
console.log(chalk7__default.default.bold("Patterns"));
|
|
2307
2256
|
for (const pattern of type.patterns) {
|
|
2308
|
-
console.log(` ${
|
|
2257
|
+
console.log(` ${chalk7__default.default.dim("\u2022")} ${pattern}`);
|
|
2309
2258
|
}
|
|
2310
2259
|
if (type.archiveAfterDays !== null) {
|
|
2311
2260
|
console.log("");
|
|
2312
|
-
console.log(
|
|
2313
|
-
console.log(` ${
|
|
2314
|
-
console.log(` ${
|
|
2261
|
+
console.log(chalk7__default.default.bold("Archive Settings"));
|
|
2262
|
+
console.log(` ${chalk7__default.default.dim("After:")} ${type.archiveAfterDays} days`);
|
|
2263
|
+
console.log(` ${chalk7__default.default.dim("Storage:")} ${type.archiveStorage || "not set"}`);
|
|
2315
2264
|
}
|
|
2316
2265
|
if (type.syncPatterns && type.syncPatterns.length > 0) {
|
|
2317
2266
|
console.log("");
|
|
2318
|
-
console.log(
|
|
2267
|
+
console.log(chalk7__default.default.bold("Sync Patterns"));
|
|
2319
2268
|
for (const pattern of type.syncPatterns) {
|
|
2320
|
-
console.log(` ${
|
|
2269
|
+
console.log(` ${chalk7__default.default.dim("\u2022")} ${pattern}`);
|
|
2321
2270
|
}
|
|
2322
2271
|
}
|
|
2323
2272
|
if (type.excludePatterns && type.excludePatterns.length > 0) {
|
|
2324
2273
|
console.log("");
|
|
2325
|
-
console.log(
|
|
2274
|
+
console.log(chalk7__default.default.bold("Exclude Patterns"));
|
|
2326
2275
|
for (const pattern of type.excludePatterns) {
|
|
2327
|
-
console.log(` ${
|
|
2276
|
+
console.log(` ${chalk7__default.default.dim("\u2022")} ${pattern}`);
|
|
2328
2277
|
}
|
|
2329
2278
|
}
|
|
2330
2279
|
} catch (error) {
|
|
2331
|
-
console.error(
|
|
2280
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
2332
2281
|
process.exit(1);
|
|
2333
2282
|
}
|
|
2334
2283
|
});
|
|
@@ -2372,30 +2321,30 @@ function typesAddCommand() {
|
|
|
2372
2321
|
cmd.description("Add a custom artifact type").argument("<name>", "Type name (lowercase, alphanumeric with hyphens)").requiredOption("--pattern <glob>", "File pattern (glob syntax)").option("--ttl <duration>", 'Cache TTL (e.g., "24h", "7d")', "24h").option("--description <text>", "Type description").option("--json", "Output as JSON").action(async (name, options) => {
|
|
2373
2322
|
try {
|
|
2374
2323
|
if (!isValidTypeName(name)) {
|
|
2375
|
-
console.error(
|
|
2376
|
-
console.log(
|
|
2324
|
+
console.error(chalk7__default.default.red("Error:"), "Invalid type name.");
|
|
2325
|
+
console.log(chalk7__default.default.dim("Type name must be lowercase, start with a letter, and contain only letters, numbers, and hyphens."));
|
|
2377
2326
|
process.exit(1);
|
|
2378
2327
|
}
|
|
2379
2328
|
const client = await getClient();
|
|
2380
2329
|
const registry = client.getTypeRegistry();
|
|
2381
2330
|
if (registry.isBuiltIn(name)) {
|
|
2382
|
-
console.error(
|
|
2331
|
+
console.error(chalk7__default.default.red("Error:"), `Cannot override built-in type "${name}".`);
|
|
2383
2332
|
const builtinNames = registry.list().filter((t) => registry.isBuiltIn(t.name)).map((t) => t.name);
|
|
2384
|
-
console.log(
|
|
2333
|
+
console.log(chalk7__default.default.dim("Built-in types: " + builtinNames.join(", ")));
|
|
2385
2334
|
process.exit(1);
|
|
2386
2335
|
}
|
|
2387
2336
|
if (registry.has(name)) {
|
|
2388
|
-
console.error(
|
|
2389
|
-
console.log(
|
|
2337
|
+
console.error(chalk7__default.default.red("Error:"), `Custom type "${name}" already exists.`);
|
|
2338
|
+
console.log(chalk7__default.default.dim('Use "fractary codex types remove" first to remove it.'));
|
|
2390
2339
|
process.exit(1);
|
|
2391
2340
|
}
|
|
2392
2341
|
let ttlSeconds;
|
|
2393
2342
|
try {
|
|
2394
2343
|
ttlSeconds = parseTtl(options.ttl);
|
|
2395
2344
|
} catch {
|
|
2396
|
-
console.error(
|
|
2397
|
-
console.log(
|
|
2398
|
-
console.log(
|
|
2345
|
+
console.error(chalk7__default.default.red("Error:"), "Invalid TTL format.");
|
|
2346
|
+
console.log(chalk7__default.default.dim("Expected format: <number><unit> where unit is s (seconds), m (minutes), h (hours), or d (days)"));
|
|
2347
|
+
console.log(chalk7__default.default.dim("Examples: 30m, 24h, 7d"));
|
|
2399
2348
|
process.exit(1);
|
|
2400
2349
|
}
|
|
2401
2350
|
const configPath = path4__namespace.join(process.cwd(), ".fractary", "codex", "config.yaml");
|
|
@@ -2427,19 +2376,19 @@ function typesAddCommand() {
|
|
|
2427
2376
|
}, null, 2));
|
|
2428
2377
|
return;
|
|
2429
2378
|
}
|
|
2430
|
-
console.log(
|
|
2379
|
+
console.log(chalk7__default.default.green("\u2713"), `Added custom type "${chalk7__default.default.cyan(name)}"`);
|
|
2431
2380
|
console.log("");
|
|
2432
|
-
console.log(` ${
|
|
2433
|
-
console.log(` ${
|
|
2381
|
+
console.log(` ${chalk7__default.default.dim("Pattern:")} ${options.pattern}`);
|
|
2382
|
+
console.log(` ${chalk7__default.default.dim("TTL:")} ${formatTtl3(ttlSeconds)} (${ttlSeconds} seconds)`);
|
|
2434
2383
|
if (options.description) {
|
|
2435
|
-
console.log(` ${
|
|
2384
|
+
console.log(` ${chalk7__default.default.dim("Description:")} ${options.description}`);
|
|
2436
2385
|
}
|
|
2437
2386
|
console.log("");
|
|
2438
|
-
console.log(
|
|
2387
|
+
console.log(chalk7__default.default.dim("Note: Custom type will be available on next CLI invocation."));
|
|
2439
2388
|
} catch (error) {
|
|
2440
|
-
console.error(
|
|
2389
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
2441
2390
|
if (error.message.includes("Failed to load configuration")) {
|
|
2442
|
-
console.log(
|
|
2391
|
+
console.log(chalk7__default.default.dim('\nRun "fractary codex init" to create a configuration.'));
|
|
2443
2392
|
}
|
|
2444
2393
|
process.exit(1);
|
|
2445
2394
|
}
|
|
@@ -2457,20 +2406,20 @@ function typesRemoveCommand() {
|
|
|
2457
2406
|
const client = await getClient();
|
|
2458
2407
|
const registry = client.getTypeRegistry();
|
|
2459
2408
|
if (registry.isBuiltIn(name)) {
|
|
2460
|
-
console.error(
|
|
2461
|
-
console.log(
|
|
2409
|
+
console.error(chalk7__default.default.red("Error:"), `Cannot remove built-in type "${name}".`);
|
|
2410
|
+
console.log(chalk7__default.default.dim("Built-in types are permanent and cannot be removed."));
|
|
2462
2411
|
process.exit(1);
|
|
2463
2412
|
}
|
|
2464
2413
|
if (!registry.has(name)) {
|
|
2465
|
-
console.error(
|
|
2466
|
-
console.log(
|
|
2414
|
+
console.error(chalk7__default.default.red("Error:"), `Custom type "${name}" not found.`);
|
|
2415
|
+
console.log(chalk7__default.default.dim('Run "fractary codex types list --custom-only" to see custom types.'));
|
|
2467
2416
|
process.exit(1);
|
|
2468
2417
|
}
|
|
2469
2418
|
const typeInfo = registry.get(name);
|
|
2470
2419
|
const configPath = path4__namespace.join(process.cwd(), ".fractary", "codex", "config.yaml");
|
|
2471
2420
|
const config = await readYamlConfig(configPath);
|
|
2472
2421
|
if (!config.types?.custom?.[name]) {
|
|
2473
|
-
console.error(
|
|
2422
|
+
console.error(chalk7__default.default.red("Error:"), `Custom type "${name}" not found in configuration.`);
|
|
2474
2423
|
process.exit(1);
|
|
2475
2424
|
}
|
|
2476
2425
|
delete config.types.custom[name];
|
|
@@ -2494,17 +2443,17 @@ function typesRemoveCommand() {
|
|
|
2494
2443
|
}, null, 2));
|
|
2495
2444
|
return;
|
|
2496
2445
|
}
|
|
2497
|
-
console.log(
|
|
2446
|
+
console.log(chalk7__default.default.green("\u2713"), `Removed custom type "${chalk7__default.default.cyan(name)}"`);
|
|
2498
2447
|
console.log("");
|
|
2499
|
-
console.log(
|
|
2500
|
-
console.log(` ${
|
|
2501
|
-
console.log(` ${
|
|
2448
|
+
console.log(chalk7__default.default.dim("Removed configuration:"));
|
|
2449
|
+
console.log(` ${chalk7__default.default.dim("Pattern:")} ${typeInfo.patterns.join(", ")}`);
|
|
2450
|
+
console.log(` ${chalk7__default.default.dim("Description:")} ${typeInfo.description}`);
|
|
2502
2451
|
console.log("");
|
|
2503
|
-
console.log(
|
|
2452
|
+
console.log(chalk7__default.default.dim("Note: Custom type will be removed on next CLI invocation."));
|
|
2504
2453
|
} catch (error) {
|
|
2505
|
-
console.error(
|
|
2454
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
2506
2455
|
if (error.message.includes("Failed to load configuration")) {
|
|
2507
|
-
console.log(
|
|
2456
|
+
console.log(chalk7__default.default.dim('\nRun "fractary codex init" to create a configuration.'));
|
|
2508
2457
|
}
|
|
2509
2458
|
process.exit(1);
|
|
2510
2459
|
}
|