@fractary/codex-cli 0.9.0 → 0.10.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 +2 -2
- package/dist/cli.cjs +338 -386
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +337 -385
- 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
|
}
|
|
@@ -1023,6 +1023,105 @@ 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
|
+
async function readFractaryGitignore(projectRoot) {
|
|
1036
|
+
const gitignorePath = path4__namespace.join(projectRoot, ".fractary", ".gitignore");
|
|
1037
|
+
try {
|
|
1038
|
+
return await fs__namespace.readFile(gitignorePath, "utf-8");
|
|
1039
|
+
} catch (error) {
|
|
1040
|
+
if (error.code === "ENOENT") {
|
|
1041
|
+
return null;
|
|
1042
|
+
}
|
|
1043
|
+
throw error;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
async function writeFractaryGitignore(projectRoot, content) {
|
|
1047
|
+
const gitignorePath = path4__namespace.join(projectRoot, ".fractary", ".gitignore");
|
|
1048
|
+
await fs__namespace.mkdir(path4__namespace.join(projectRoot, ".fractary"), { recursive: true });
|
|
1049
|
+
await fs__namespace.writeFile(gitignorePath, content, "utf-8");
|
|
1050
|
+
}
|
|
1051
|
+
function normalizeCachePath(cachePath) {
|
|
1052
|
+
let normalized = cachePath.replace(/\\/g, "/");
|
|
1053
|
+
normalized = normalized.replace(/^\.fractary\//, "");
|
|
1054
|
+
if (!normalized.endsWith("/")) {
|
|
1055
|
+
normalized += "/";
|
|
1056
|
+
}
|
|
1057
|
+
return normalized;
|
|
1058
|
+
}
|
|
1059
|
+
function isCachePathIgnored(gitignoreContent, cachePath) {
|
|
1060
|
+
const normalized = normalizeCachePath(cachePath);
|
|
1061
|
+
const lines = gitignoreContent.split("\n").map((l) => l.trim());
|
|
1062
|
+
return lines.some((line) => {
|
|
1063
|
+
if (line.startsWith("#") || line === "") return false;
|
|
1064
|
+
let normalizedLine = line.replace(/\\/g, "/");
|
|
1065
|
+
if (!normalizedLine.endsWith("/")) {
|
|
1066
|
+
normalizedLine += "/";
|
|
1067
|
+
}
|
|
1068
|
+
return normalizedLine === normalized;
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
function addCachePathToGitignore(gitignoreContent, cachePath, comment) {
|
|
1072
|
+
const normalized = normalizeCachePath(cachePath);
|
|
1073
|
+
if (isCachePathIgnored(gitignoreContent, cachePath)) {
|
|
1074
|
+
return gitignoreContent;
|
|
1075
|
+
}
|
|
1076
|
+
let addition = "";
|
|
1077
|
+
{
|
|
1078
|
+
addition += `
|
|
1079
|
+
# ${comment}
|
|
1080
|
+
`;
|
|
1081
|
+
}
|
|
1082
|
+
addition += normalized + "\n";
|
|
1083
|
+
return gitignoreContent.trimEnd() + addition;
|
|
1084
|
+
}
|
|
1085
|
+
async function ensureCachePathIgnored(projectRoot, cachePath) {
|
|
1086
|
+
const gitignorePath = path4__namespace.join(projectRoot, ".fractary", ".gitignore");
|
|
1087
|
+
let relativeCachePath = cachePath;
|
|
1088
|
+
if (path4__namespace.isAbsolute(cachePath)) {
|
|
1089
|
+
relativeCachePath = path4__namespace.relative(path4__namespace.join(projectRoot, ".fractary"), cachePath);
|
|
1090
|
+
}
|
|
1091
|
+
relativeCachePath = normalizeCachePath(relativeCachePath);
|
|
1092
|
+
let content = await readFractaryGitignore(projectRoot);
|
|
1093
|
+
const gitignoreExists = content !== null;
|
|
1094
|
+
if (!gitignoreExists) {
|
|
1095
|
+
content = DEFAULT_FRACTARY_GITIGNORE;
|
|
1096
|
+
if (!isCachePathIgnored(content, relativeCachePath)) {
|
|
1097
|
+
content = addCachePathToGitignore(content, relativeCachePath, "Custom cache directory");
|
|
1098
|
+
}
|
|
1099
|
+
await writeFractaryGitignore(projectRoot, content);
|
|
1100
|
+
return {
|
|
1101
|
+
created: true,
|
|
1102
|
+
updated: false,
|
|
1103
|
+
alreadyIgnored: false,
|
|
1104
|
+
gitignorePath
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
if (isCachePathIgnored(content, relativeCachePath)) {
|
|
1108
|
+
return {
|
|
1109
|
+
created: false,
|
|
1110
|
+
updated: false,
|
|
1111
|
+
alreadyIgnored: true,
|
|
1112
|
+
gitignorePath
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
content = addCachePathToGitignore(content, relativeCachePath, "Custom cache directory");
|
|
1116
|
+
await writeFractaryGitignore(projectRoot, content);
|
|
1117
|
+
return {
|
|
1118
|
+
created: false,
|
|
1119
|
+
updated: true,
|
|
1120
|
+
alreadyIgnored: false,
|
|
1121
|
+
gitignorePath
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1026
1125
|
// src/commands/config/init.ts
|
|
1027
1126
|
async function getOrgFromGitRemote() {
|
|
1028
1127
|
try {
|
|
@@ -1047,7 +1146,7 @@ function initCommand() {
|
|
|
1047
1146
|
const cmd = new commander.Command("init");
|
|
1048
1147
|
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) => {
|
|
1049
1148
|
try {
|
|
1050
|
-
console.log(
|
|
1149
|
+
console.log(chalk7__default.default.blue("Initializing unified Fractary configuration...\n"));
|
|
1051
1150
|
let org = options.org;
|
|
1052
1151
|
if (!org) {
|
|
1053
1152
|
org = await getOrgFromGitRemote();
|
|
@@ -1063,23 +1162,23 @@ function initCommand() {
|
|
|
1063
1162
|
}
|
|
1064
1163
|
if (!org) {
|
|
1065
1164
|
org = path4__namespace.basename(process.cwd()).split("-")[0] || "default";
|
|
1066
|
-
console.log(
|
|
1067
|
-
console.log(
|
|
1165
|
+
console.log(chalk7__default.default.yellow(`\u26A0 Could not detect organization, using: ${org}`));
|
|
1166
|
+
console.log(chalk7__default.default.dim(" Use --org <slug> to specify explicitly\n"));
|
|
1068
1167
|
} else {
|
|
1069
|
-
console.log(
|
|
1168
|
+
console.log(chalk7__default.default.dim(`Organization: ${chalk7__default.default.cyan(org)}
|
|
1070
1169
|
`));
|
|
1071
1170
|
}
|
|
1072
1171
|
let project = options.project;
|
|
1073
1172
|
if (!project) {
|
|
1074
1173
|
project = path4__namespace.basename(process.cwd());
|
|
1075
|
-
console.log(
|
|
1174
|
+
console.log(chalk7__default.default.dim(`Project: ${chalk7__default.default.cyan(project)}
|
|
1076
1175
|
`));
|
|
1077
1176
|
}
|
|
1078
1177
|
const configPath = path4__namespace.join(process.cwd(), ".fractary", "config.yaml");
|
|
1079
1178
|
const configExists = await fileExists(configPath);
|
|
1080
1179
|
if (configExists && !options.force) {
|
|
1081
|
-
console.log(
|
|
1082
|
-
console.log(
|
|
1180
|
+
console.log(chalk7__default.default.yellow(`\u26A0 Configuration already exists at .fractary/config.yaml`));
|
|
1181
|
+
console.log(chalk7__default.default.dim("Merging with existing configuration...\n"));
|
|
1083
1182
|
}
|
|
1084
1183
|
console.log("Creating directory structure...");
|
|
1085
1184
|
const dirs = [
|
|
@@ -1091,7 +1190,15 @@ function initCommand() {
|
|
|
1091
1190
|
];
|
|
1092
1191
|
for (const dir of dirs) {
|
|
1093
1192
|
await fs__namespace.mkdir(path4__namespace.join(process.cwd(), dir), { recursive: true });
|
|
1094
|
-
console.log(
|
|
1193
|
+
console.log(chalk7__default.default.green("\u2713"), chalk7__default.default.dim(dir + "/"));
|
|
1194
|
+
}
|
|
1195
|
+
const gitignoreResult = await ensureCachePathIgnored(process.cwd(), ".fractary/codex/cache");
|
|
1196
|
+
if (gitignoreResult.created) {
|
|
1197
|
+
console.log(chalk7__default.default.green("\u2713"), chalk7__default.default.dim(".fractary/.gitignore (created)"));
|
|
1198
|
+
} else if (gitignoreResult.updated) {
|
|
1199
|
+
console.log(chalk7__default.default.green("\u2713"), chalk7__default.default.dim(".fractary/.gitignore (updated)"));
|
|
1200
|
+
} else {
|
|
1201
|
+
console.log(chalk7__default.default.green("\u2713"), chalk7__default.default.dim(".fractary/.gitignore (exists)"));
|
|
1095
1202
|
}
|
|
1096
1203
|
console.log("\nInitializing configuration...");
|
|
1097
1204
|
const result = await initializeUnifiedConfig(
|
|
@@ -1101,182 +1208,28 @@ function initCommand() {
|
|
|
1101
1208
|
{ force: options.force }
|
|
1102
1209
|
);
|
|
1103
1210
|
if (result.created) {
|
|
1104
|
-
console.log(
|
|
1211
|
+
console.log(chalk7__default.default.green("\u2713"), chalk7__default.default.dim(".fractary/config.yaml (created)"));
|
|
1105
1212
|
} else if (result.merged) {
|
|
1106
|
-
console.log(
|
|
1107
|
-
}
|
|
1108
|
-
console.log(
|
|
1109
|
-
console.log(
|
|
1110
|
-
console.log(
|
|
1111
|
-
console.log(
|
|
1112
|
-
console.log(
|
|
1113
|
-
console.log(
|
|
1114
|
-
console.log(
|
|
1115
|
-
console.log(
|
|
1116
|
-
console.log(
|
|
1117
|
-
console.log(
|
|
1118
|
-
console.log(
|
|
1119
|
-
console.log(
|
|
1120
|
-
console.log(
|
|
1121
|
-
console.log(
|
|
1122
|
-
console.log(
|
|
1123
|
-
console.log(
|
|
1213
|
+
console.log(chalk7__default.default.green("\u2713"), chalk7__default.default.dim(".fractary/config.yaml (merged with existing)"));
|
|
1214
|
+
}
|
|
1215
|
+
console.log(chalk7__default.default.green("\n\u2713 Unified configuration initialized successfully!\n"));
|
|
1216
|
+
console.log(chalk7__default.default.bold("Configuration:"));
|
|
1217
|
+
console.log(chalk7__default.default.dim(` Organization: ${org}`));
|
|
1218
|
+
console.log(chalk7__default.default.dim(` Project: ${project}`));
|
|
1219
|
+
console.log(chalk7__default.default.dim(` Config: .fractary/config.yaml`));
|
|
1220
|
+
console.log(chalk7__default.default.bold("\nFile plugin sources:"));
|
|
1221
|
+
console.log(chalk7__default.default.dim(" - specs: .fractary/specs/ \u2192 S3"));
|
|
1222
|
+
console.log(chalk7__default.default.dim(" - logs: .fractary/logs/ \u2192 S3"));
|
|
1223
|
+
console.log(chalk7__default.default.bold("\nCodex plugin:"));
|
|
1224
|
+
console.log(chalk7__default.default.dim(" - Cache: .fractary/codex/cache/"));
|
|
1225
|
+
console.log(chalk7__default.default.dim(" - Dependencies: (none configured)"));
|
|
1226
|
+
console.log(chalk7__default.default.bold("\nNext steps:"));
|
|
1227
|
+
console.log(chalk7__default.default.dim(" 1. Configure AWS credentials for S3 access"));
|
|
1228
|
+
console.log(chalk7__default.default.dim(" 2. Edit .fractary/config.yaml to add external project dependencies"));
|
|
1229
|
+
console.log(chalk7__default.default.dim(" 3. Access current project files: codex://specs/SPEC-001.md"));
|
|
1230
|
+
console.log(chalk7__default.default.dim(" 4. Access external projects: codex://org/project/docs/README.md"));
|
|
1124
1231
|
} catch (error) {
|
|
1125
|
-
console.error(
|
|
1126
|
-
process.exit(1);
|
|
1127
|
-
}
|
|
1128
|
-
});
|
|
1129
|
-
return cmd;
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
// src/commands/config/migrate.ts
|
|
1133
|
-
init_cjs_shims();
|
|
1134
|
-
init_migrate_config();
|
|
1135
|
-
async function fileExists2(filePath) {
|
|
1136
|
-
try {
|
|
1137
|
-
await fs__namespace.access(filePath);
|
|
1138
|
-
return true;
|
|
1139
|
-
} catch {
|
|
1140
|
-
return false;
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
async function readFileContent(filePath) {
|
|
1144
|
-
return fs__namespace.readFile(filePath, "utf-8");
|
|
1145
|
-
}
|
|
1146
|
-
function migrateCommand() {
|
|
1147
|
-
const cmd = new commander.Command("migrate");
|
|
1148
|
-
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) => {
|
|
1149
|
-
try {
|
|
1150
|
-
const legacyConfigPath = path4__namespace.join(process.cwd(), ".fractary", "plugins", "codex", "config.json");
|
|
1151
|
-
const newConfigPath = path4__namespace.join(process.cwd(), ".fractary", "codex", "config.yaml");
|
|
1152
|
-
if (!await fileExists2(legacyConfigPath)) {
|
|
1153
|
-
if (options.json) {
|
|
1154
|
-
console.log(JSON.stringify({
|
|
1155
|
-
status: "no_config",
|
|
1156
|
-
message: "No legacy configuration file found",
|
|
1157
|
-
path: legacyConfigPath
|
|
1158
|
-
}));
|
|
1159
|
-
} else {
|
|
1160
|
-
console.log(chalk8__default.default.yellow("\u26A0 No legacy configuration file found."));
|
|
1161
|
-
console.log(chalk8__default.default.dim(` Expected: ${legacyConfigPath}`));
|
|
1162
|
-
console.log(chalk8__default.default.dim('\nRun "fractary codex init" to create a new v3.0 YAML configuration.'));
|
|
1163
|
-
}
|
|
1164
|
-
return;
|
|
1165
|
-
}
|
|
1166
|
-
if (await fileExists2(newConfigPath) && !options.dryRun) {
|
|
1167
|
-
if (options.json) {
|
|
1168
|
-
console.log(JSON.stringify({
|
|
1169
|
-
status: "already_migrated",
|
|
1170
|
-
message: "YAML configuration already exists",
|
|
1171
|
-
path: newConfigPath
|
|
1172
|
-
}));
|
|
1173
|
-
} else {
|
|
1174
|
-
console.log(chalk8__default.default.yellow("\u26A0 YAML configuration already exists."));
|
|
1175
|
-
console.log(chalk8__default.default.dim(` Path: ${newConfigPath}`));
|
|
1176
|
-
console.log(chalk8__default.default.dim('\nUse "fractary codex init --force" to recreate.'));
|
|
1177
|
-
}
|
|
1178
|
-
return;
|
|
1179
|
-
}
|
|
1180
|
-
const legacyContent = await readFileContent(legacyConfigPath);
|
|
1181
|
-
let legacyConfig;
|
|
1182
|
-
try {
|
|
1183
|
-
legacyConfig = JSON.parse(legacyContent);
|
|
1184
|
-
} catch {
|
|
1185
|
-
console.error(chalk8__default.default.red("Error:"), "Invalid JSON in legacy config file.");
|
|
1186
|
-
process.exit(1);
|
|
1187
|
-
}
|
|
1188
|
-
if (!options.json && !options.dryRun) {
|
|
1189
|
-
console.log(chalk8__default.default.blue("Migrating Codex configuration to v3.0 YAML format...\n"));
|
|
1190
|
-
}
|
|
1191
|
-
const migrationResult = await migrateConfig(
|
|
1192
|
-
legacyConfigPath,
|
|
1193
|
-
{
|
|
1194
|
-
createBackup: options.backup !== false,
|
|
1195
|
-
backupSuffix: (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")
|
|
1196
|
-
}
|
|
1197
|
-
);
|
|
1198
|
-
if (!options.json) {
|
|
1199
|
-
console.log(chalk8__default.default.bold("Legacy Configuration:"));
|
|
1200
|
-
console.log(chalk8__default.default.dim(` Path: ${legacyConfigPath}`));
|
|
1201
|
-
console.log(chalk8__default.default.dim(` Organization: ${legacyConfig.organization || legacyConfig.organizationSlug || "unknown"}`));
|
|
1202
|
-
console.log("");
|
|
1203
|
-
console.log(chalk8__default.default.bold("Migration Changes:"));
|
|
1204
|
-
console.log(chalk8__default.default.green(" + Format: JSON \u2192 YAML"));
|
|
1205
|
-
console.log(chalk8__default.default.green(" + Location: .fractary/plugins/codex/ \u2192 .fractary/"));
|
|
1206
|
-
console.log(chalk8__default.default.green(" + File: config.json \u2192 codex.yaml"));
|
|
1207
|
-
console.log(chalk8__default.default.green(" + Storage: Multi-provider configuration"));
|
|
1208
|
-
console.log(chalk8__default.default.green(" + Cache: Modern cache management"));
|
|
1209
|
-
console.log(chalk8__default.default.green(" + Types: Custom type registry"));
|
|
1210
|
-
if (migrationResult.warnings.length > 0) {
|
|
1211
|
-
console.log("");
|
|
1212
|
-
console.log(chalk8__default.default.yellow("Warnings:"));
|
|
1213
|
-
for (const warning of migrationResult.warnings) {
|
|
1214
|
-
console.log(chalk8__default.default.yellow(" \u26A0"), chalk8__default.default.dim(warning));
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
console.log("");
|
|
1218
|
-
if (options.dryRun) {
|
|
1219
|
-
console.log(chalk8__default.default.blue("Dry run - no changes made."));
|
|
1220
|
-
console.log(chalk8__default.default.dim("Run without --dry-run to execute migration."));
|
|
1221
|
-
return;
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
if (options.json) {
|
|
1225
|
-
const output = {
|
|
1226
|
-
status: options.dryRun ? "migration_ready" : "migrated",
|
|
1227
|
-
dryRun: options.dryRun || false,
|
|
1228
|
-
legacyConfig: {
|
|
1229
|
-
path: legacyConfigPath,
|
|
1230
|
-
organization: legacyConfig.organization || legacyConfig.organizationSlug
|
|
1231
|
-
},
|
|
1232
|
-
newConfig: {
|
|
1233
|
-
path: newConfigPath,
|
|
1234
|
-
organization: migrationResult.yamlConfig.organization
|
|
1235
|
-
},
|
|
1236
|
-
warnings: migrationResult.warnings,
|
|
1237
|
-
backupPath: migrationResult.backupPath
|
|
1238
|
-
};
|
|
1239
|
-
console.log(JSON.stringify(output, null, 2));
|
|
1240
|
-
if (options.dryRun) {
|
|
1241
|
-
return;
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
if (!options.dryRun) {
|
|
1245
|
-
await writeYamlConfig(migrationResult.yamlConfig, newConfigPath);
|
|
1246
|
-
const cacheDir = path4__namespace.join(process.cwd(), ".codex-cache");
|
|
1247
|
-
await fs__namespace.mkdir(cacheDir, { recursive: true });
|
|
1248
|
-
if (!options.json) {
|
|
1249
|
-
console.log(chalk8__default.default.green("\u2713"), "YAML configuration created");
|
|
1250
|
-
console.log(chalk8__default.default.green("\u2713"), "Cache directory initialized");
|
|
1251
|
-
if (migrationResult.backupPath) {
|
|
1252
|
-
console.log(chalk8__default.default.green("\u2713"), "Legacy config backed up");
|
|
1253
|
-
}
|
|
1254
|
-
console.log("");
|
|
1255
|
-
console.log(chalk8__default.default.bold("New Configuration:"));
|
|
1256
|
-
console.log(chalk8__default.default.dim(` Path: ${newConfigPath}`));
|
|
1257
|
-
console.log(chalk8__default.default.dim(` Organization: ${migrationResult.yamlConfig.organization}`));
|
|
1258
|
-
console.log(chalk8__default.default.dim(` Cache: ${migrationResult.yamlConfig.cacheDir || ".codex-cache"}`));
|
|
1259
|
-
console.log(chalk8__default.default.dim(` Storage Providers: ${migrationResult.yamlConfig.storage?.length || 0}`));
|
|
1260
|
-
console.log("");
|
|
1261
|
-
console.log(chalk8__default.default.bold("Next Steps:"));
|
|
1262
|
-
console.log(chalk8__default.default.dim(" 1. Review the new configuration: .fractary/codex/config.yaml"));
|
|
1263
|
-
console.log(chalk8__default.default.dim(' 2. Set your GitHub token: export GITHUB_TOKEN="your_token"'));
|
|
1264
|
-
console.log(chalk8__default.default.dim(" 3. Test fetching: fractary codex fetch codex://org/project/path"));
|
|
1265
|
-
if (migrationResult.backupPath) {
|
|
1266
|
-
console.log("");
|
|
1267
|
-
console.log(chalk8__default.default.dim(`Backup saved: ${path4__namespace.basename(migrationResult.backupPath)}`));
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
} catch (error) {
|
|
1272
|
-
if (options.json) {
|
|
1273
|
-
console.log(JSON.stringify({
|
|
1274
|
-
status: "error",
|
|
1275
|
-
message: error.message
|
|
1276
|
-
}));
|
|
1277
|
-
} else {
|
|
1278
|
-
console.error(chalk8__default.default.red("Error:"), error.message);
|
|
1279
|
-
}
|
|
1232
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
1280
1233
|
process.exit(1);
|
|
1281
1234
|
}
|
|
1282
1235
|
});
|
|
@@ -1288,7 +1241,6 @@ function configCommand() {
|
|
|
1288
1241
|
const cmd = new commander.Command("config");
|
|
1289
1242
|
cmd.description("Manage configuration");
|
|
1290
1243
|
cmd.addCommand(initCommand());
|
|
1291
|
-
cmd.addCommand(migrateCommand());
|
|
1292
1244
|
return cmd;
|
|
1293
1245
|
}
|
|
1294
1246
|
|
|
@@ -1312,8 +1264,8 @@ function cacheListCommand() {
|
|
|
1312
1264
|
if (options.json) {
|
|
1313
1265
|
console.log(JSON.stringify({ entries: 0, message: "Cache is empty" }));
|
|
1314
1266
|
} else {
|
|
1315
|
-
console.log(
|
|
1316
|
-
console.log(
|
|
1267
|
+
console.log(chalk7__default.default.yellow("Cache is empty."));
|
|
1268
|
+
console.log(chalk7__default.default.dim("Fetch some documents to populate the cache."));
|
|
1317
1269
|
}
|
|
1318
1270
|
return;
|
|
1319
1271
|
}
|
|
@@ -1327,25 +1279,25 @@ function cacheListCommand() {
|
|
|
1327
1279
|
}, null, 2));
|
|
1328
1280
|
return;
|
|
1329
1281
|
}
|
|
1330
|
-
console.log(
|
|
1331
|
-
console.log(
|
|
1332
|
-
console.log(` Total: ${
|
|
1333
|
-
console.log(` Fresh: ${
|
|
1334
|
-
console.log(` Stale: ${stats.staleCount > 0 ?
|
|
1335
|
-
console.log(` Expired: ${stats.expiredCount > 0 ?
|
|
1282
|
+
console.log(chalk7__default.default.bold("Cache Overview\n"));
|
|
1283
|
+
console.log(chalk7__default.default.bold("Entries:"));
|
|
1284
|
+
console.log(` Total: ${chalk7__default.default.cyan(stats.entryCount.toString())} entries`);
|
|
1285
|
+
console.log(` Fresh: ${chalk7__default.default.green(stats.freshCount.toString())} entries`);
|
|
1286
|
+
console.log(` Stale: ${stats.staleCount > 0 ? chalk7__default.default.yellow(stats.staleCount.toString()) : chalk7__default.default.dim("0")} entries`);
|
|
1287
|
+
console.log(` Expired: ${stats.expiredCount > 0 ? chalk7__default.default.red(stats.expiredCount.toString()) : chalk7__default.default.dim("0")} entries`);
|
|
1336
1288
|
console.log("");
|
|
1337
|
-
console.log(
|
|
1338
|
-
console.log(` Total size: ${
|
|
1289
|
+
console.log(chalk7__default.default.bold("Storage:"));
|
|
1290
|
+
console.log(` Total size: ${chalk7__default.default.cyan(formatSize(stats.totalSize))}`);
|
|
1339
1291
|
console.log("");
|
|
1340
1292
|
const healthPercent = stats.entryCount > 0 ? stats.freshCount / stats.entryCount * 100 : 100;
|
|
1341
|
-
const healthColor = healthPercent > 80 ?
|
|
1293
|
+
const healthColor = healthPercent > 80 ? chalk7__default.default.green : healthPercent > 50 ? chalk7__default.default.yellow : chalk7__default.default.red;
|
|
1342
1294
|
console.log(`Cache health: ${healthColor(`${healthPercent.toFixed(0)}% fresh`)}`);
|
|
1343
1295
|
console.log("");
|
|
1344
|
-
console.log(
|
|
1345
|
-
console.log(
|
|
1346
|
-
console.log(
|
|
1296
|
+
console.log(chalk7__default.default.dim("Note: Individual cache entries are managed by the SDK."));
|
|
1297
|
+
console.log(chalk7__default.default.dim('Use "fractary codex cache stats" for detailed statistics.'));
|
|
1298
|
+
console.log(chalk7__default.default.dim('Use "fractary codex cache clear" to clear cache entries.'));
|
|
1347
1299
|
} catch (error) {
|
|
1348
|
-
console.error(
|
|
1300
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
1349
1301
|
process.exit(1);
|
|
1350
1302
|
}
|
|
1351
1303
|
});
|
|
@@ -1361,7 +1313,7 @@ function cacheClearCommand() {
|
|
|
1361
1313
|
const client = await getClient();
|
|
1362
1314
|
const statsBefore = await client.getCacheStats();
|
|
1363
1315
|
if (statsBefore.entryCount === 0) {
|
|
1364
|
-
console.log(
|
|
1316
|
+
console.log(chalk7__default.default.yellow("Cache is already empty. Nothing to clear."));
|
|
1365
1317
|
return;
|
|
1366
1318
|
}
|
|
1367
1319
|
let pattern;
|
|
@@ -1370,45 +1322,45 @@ function cacheClearCommand() {
|
|
|
1370
1322
|
} else if (options.pattern) {
|
|
1371
1323
|
pattern = options.pattern;
|
|
1372
1324
|
} else {
|
|
1373
|
-
console.log(
|
|
1374
|
-
console.log(
|
|
1375
|
-
console.log(
|
|
1325
|
+
console.log(chalk7__default.default.yellow("Please specify what to clear:"));
|
|
1326
|
+
console.log(chalk7__default.default.dim(" --all Clear entire cache"));
|
|
1327
|
+
console.log(chalk7__default.default.dim(' --pattern Clear entries matching pattern (e.g., "codex://fractary/*")'));
|
|
1376
1328
|
console.log("");
|
|
1377
|
-
console.log(
|
|
1378
|
-
console.log(
|
|
1379
|
-
console.log(
|
|
1329
|
+
console.log(chalk7__default.default.dim("Examples:"));
|
|
1330
|
+
console.log(chalk7__default.default.dim(" fractary codex cache clear --all"));
|
|
1331
|
+
console.log(chalk7__default.default.dim(' fractary codex cache clear --pattern "codex://fractary/cli/*"'));
|
|
1380
1332
|
return;
|
|
1381
1333
|
}
|
|
1382
1334
|
if (options.dryRun) {
|
|
1383
|
-
console.log(
|
|
1335
|
+
console.log(chalk7__default.default.blue("Dry run - would clear:\n"));
|
|
1384
1336
|
if (pattern) {
|
|
1385
|
-
console.log(
|
|
1386
|
-
console.log(
|
|
1337
|
+
console.log(chalk7__default.default.dim(` Pattern: ${pattern}`));
|
|
1338
|
+
console.log(chalk7__default.default.dim(` This would invalidate matching cache entries`));
|
|
1387
1339
|
} else {
|
|
1388
|
-
console.log(
|
|
1340
|
+
console.log(chalk7__default.default.dim(` All cache entries (${statsBefore.entryCount} entries)`));
|
|
1389
1341
|
}
|
|
1390
|
-
console.log(
|
|
1342
|
+
console.log(chalk7__default.default.dim(`
|
|
1391
1343
|
Total size: ${formatSize2(statsBefore.totalSize)}`));
|
|
1392
1344
|
return;
|
|
1393
1345
|
}
|
|
1394
1346
|
if (pattern) {
|
|
1395
|
-
console.log(
|
|
1347
|
+
console.log(chalk7__default.default.blue(`Clearing cache entries matching pattern: ${pattern}
|
|
1396
1348
|
`));
|
|
1397
1349
|
await client.invalidateCache(pattern);
|
|
1398
1350
|
} else {
|
|
1399
|
-
console.log(
|
|
1351
|
+
console.log(chalk7__default.default.blue(`Clearing entire cache (${statsBefore.entryCount} entries)...
|
|
1400
1352
|
`));
|
|
1401
1353
|
await client.invalidateCache();
|
|
1402
1354
|
}
|
|
1403
1355
|
const statsAfter = await client.getCacheStats();
|
|
1404
1356
|
const entriesCleared = statsBefore.entryCount - statsAfter.entryCount;
|
|
1405
1357
|
const sizeFreed = statsBefore.totalSize - statsAfter.totalSize;
|
|
1406
|
-
console.log(
|
|
1358
|
+
console.log(chalk7__default.default.green(`\u2713 Cleared ${entriesCleared} entries (${formatSize2(sizeFreed)} freed)`));
|
|
1407
1359
|
if (statsAfter.entryCount > 0) {
|
|
1408
|
-
console.log(
|
|
1360
|
+
console.log(chalk7__default.default.dim(` Remaining: ${statsAfter.entryCount} entries (${formatSize2(statsAfter.totalSize)})`));
|
|
1409
1361
|
}
|
|
1410
1362
|
} catch (error) {
|
|
1411
|
-
console.error(
|
|
1363
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
1412
1364
|
process.exit(1);
|
|
1413
1365
|
}
|
|
1414
1366
|
});
|
|
@@ -1437,25 +1389,25 @@ function cacheStatsCommand() {
|
|
|
1437
1389
|
console.log(JSON.stringify(stats, null, 2));
|
|
1438
1390
|
return;
|
|
1439
1391
|
}
|
|
1440
|
-
console.log(
|
|
1441
|
-
console.log(
|
|
1442
|
-
console.log(` Total entries: ${
|
|
1443
|
-
console.log(` Total size: ${
|
|
1444
|
-
console.log(` Fresh entries: ${
|
|
1445
|
-
console.log(` Stale entries: ${stats.staleCount > 0 ?
|
|
1446
|
-
console.log(` Expired entries: ${stats.expiredCount > 0 ?
|
|
1392
|
+
console.log(chalk7__default.default.bold("Cache Statistics\n"));
|
|
1393
|
+
console.log(chalk7__default.default.bold("Overview"));
|
|
1394
|
+
console.log(` Total entries: ${chalk7__default.default.cyan(stats.entryCount.toString())}`);
|
|
1395
|
+
console.log(` Total size: ${chalk7__default.default.cyan(formatSize3(stats.totalSize))}`);
|
|
1396
|
+
console.log(` Fresh entries: ${chalk7__default.default.green(stats.freshCount.toString())}`);
|
|
1397
|
+
console.log(` Stale entries: ${stats.staleCount > 0 ? chalk7__default.default.yellow(stats.staleCount.toString()) : chalk7__default.default.dim("0")}`);
|
|
1398
|
+
console.log(` Expired entries: ${stats.expiredCount > 0 ? chalk7__default.default.red(stats.expiredCount.toString()) : chalk7__default.default.dim("0")}`);
|
|
1447
1399
|
console.log("");
|
|
1448
1400
|
const healthPercent = stats.entryCount > 0 ? stats.freshCount / stats.entryCount * 100 : 100;
|
|
1449
|
-
const healthColor = healthPercent > 80 ?
|
|
1401
|
+
const healthColor = healthPercent > 80 ? chalk7__default.default.green : healthPercent > 50 ? chalk7__default.default.yellow : chalk7__default.default.red;
|
|
1450
1402
|
console.log(`Cache health: ${healthColor(`${healthPercent.toFixed(0)}% fresh`)}`);
|
|
1451
1403
|
if (stats.expiredCount > 0) {
|
|
1452
|
-
console.log(
|
|
1404
|
+
console.log(chalk7__default.default.dim('\nRun "fractary codex cache clear --pattern <pattern>" to clean up entries.'));
|
|
1453
1405
|
}
|
|
1454
1406
|
if (stats.entryCount === 0) {
|
|
1455
|
-
console.log(
|
|
1407
|
+
console.log(chalk7__default.default.dim("\nNo cached entries. Fetch some documents to populate the cache."));
|
|
1456
1408
|
}
|
|
1457
1409
|
} catch (error) {
|
|
1458
|
-
console.error(
|
|
1410
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
1459
1411
|
process.exit(1);
|
|
1460
1412
|
}
|
|
1461
1413
|
});
|
|
@@ -1465,7 +1417,7 @@ function cacheStatsCommand() {
|
|
|
1465
1417
|
// src/commands/cache/health.ts
|
|
1466
1418
|
init_cjs_shims();
|
|
1467
1419
|
init_migrate_config();
|
|
1468
|
-
async function
|
|
1420
|
+
async function fileExists2(filePath) {
|
|
1469
1421
|
try {
|
|
1470
1422
|
await fs__namespace.access(filePath);
|
|
1471
1423
|
return true;
|
|
@@ -1474,11 +1426,11 @@ async function fileExists3(filePath) {
|
|
|
1474
1426
|
}
|
|
1475
1427
|
}
|
|
1476
1428
|
async function checkConfiguration() {
|
|
1477
|
-
const configPath = path4__namespace.join(process.cwd(), ".fractary", "
|
|
1429
|
+
const configPath = path4__namespace.join(process.cwd(), ".fractary", "config.yaml");
|
|
1478
1430
|
const legacyConfigPath = path4__namespace.join(process.cwd(), ".fractary", "plugins", "codex", "config.json");
|
|
1479
1431
|
try {
|
|
1480
|
-
if (!await
|
|
1481
|
-
if (await
|
|
1432
|
+
if (!await fileExists2(configPath)) {
|
|
1433
|
+
if (await fileExists2(legacyConfigPath)) {
|
|
1482
1434
|
return {
|
|
1483
1435
|
name: "Configuration",
|
|
1484
1436
|
status: "warn",
|
|
@@ -1582,7 +1534,7 @@ async function checkCache() {
|
|
|
1582
1534
|
}
|
|
1583
1535
|
}
|
|
1584
1536
|
async function checkStorage() {
|
|
1585
|
-
const configPath = path4__namespace.join(process.cwd(), ".fractary", "
|
|
1537
|
+
const configPath = path4__namespace.join(process.cwd(), ".fractary", "config.yaml");
|
|
1586
1538
|
try {
|
|
1587
1539
|
const config = await readYamlConfig(configPath);
|
|
1588
1540
|
const providers = config.storage || [];
|
|
@@ -1591,7 +1543,7 @@ async function checkStorage() {
|
|
|
1591
1543
|
name: "Storage",
|
|
1592
1544
|
status: "warn",
|
|
1593
1545
|
message: "No storage providers configured",
|
|
1594
|
-
details: "Configure at least one provider in .fractary/
|
|
1546
|
+
details: "Configure at least one provider in .fractary/config.yaml"
|
|
1595
1547
|
};
|
|
1596
1548
|
}
|
|
1597
1549
|
const providerTypes = providers.map((p) => p.type).join(", ");
|
|
@@ -1672,32 +1624,32 @@ function healthCommand() {
|
|
|
1672
1624
|
}, null, 2));
|
|
1673
1625
|
return;
|
|
1674
1626
|
}
|
|
1675
|
-
console.log(
|
|
1627
|
+
console.log(chalk7__default.default.bold("Codex Health Check\n"));
|
|
1676
1628
|
for (const check of checks) {
|
|
1677
|
-
const icon = check.status === "pass" ?
|
|
1678
|
-
const statusColor = check.status === "pass" ?
|
|
1679
|
-
console.log(`${icon} ${
|
|
1629
|
+
const icon = check.status === "pass" ? chalk7__default.default.green("\u2713") : check.status === "warn" ? chalk7__default.default.yellow("\u26A0") : chalk7__default.default.red("\u2717");
|
|
1630
|
+
const statusColor = check.status === "pass" ? chalk7__default.default.green : check.status === "warn" ? chalk7__default.default.yellow : chalk7__default.default.red;
|
|
1631
|
+
console.log(`${icon} ${chalk7__default.default.bold(check.name)}`);
|
|
1680
1632
|
console.log(` ${statusColor(check.message)}`);
|
|
1681
1633
|
if (check.details) {
|
|
1682
|
-
console.log(` ${
|
|
1634
|
+
console.log(` ${chalk7__default.default.dim(check.details)}`);
|
|
1683
1635
|
}
|
|
1684
1636
|
console.log("");
|
|
1685
1637
|
}
|
|
1686
|
-
console.log(
|
|
1687
|
-
const overallStatus = failed > 0 ?
|
|
1638
|
+
console.log(chalk7__default.default.dim("\u2500".repeat(60)));
|
|
1639
|
+
const overallStatus = failed > 0 ? chalk7__default.default.red("UNHEALTHY") : warned > 0 ? chalk7__default.default.yellow("DEGRADED") : chalk7__default.default.green("HEALTHY");
|
|
1688
1640
|
console.log(`Status: ${overallStatus}`);
|
|
1689
|
-
console.log(
|
|
1641
|
+
console.log(chalk7__default.default.dim(`${passed} passed, ${warned} warnings, ${failed} failed`));
|
|
1690
1642
|
if (failed > 0 || warned > 0) {
|
|
1691
1643
|
console.log("");
|
|
1692
|
-
console.log(
|
|
1693
|
-
console.log(
|
|
1694
|
-
console.log(
|
|
1644
|
+
console.log(chalk7__default.default.dim("Run checks individually for more details:"));
|
|
1645
|
+
console.log(chalk7__default.default.dim(" fractary codex cache stats"));
|
|
1646
|
+
console.log(chalk7__default.default.dim(" fractary codex types list"));
|
|
1695
1647
|
}
|
|
1696
1648
|
if (failed > 0) {
|
|
1697
1649
|
process.exit(1);
|
|
1698
1650
|
}
|
|
1699
1651
|
} catch (error) {
|
|
1700
|
-
console.error(
|
|
1652
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
1701
1653
|
process.exit(1);
|
|
1702
1654
|
}
|
|
1703
1655
|
});
|
|
@@ -1745,8 +1697,8 @@ function syncCommand() {
|
|
|
1745
1697
|
try {
|
|
1746
1698
|
config = await readYamlConfig(configPath);
|
|
1747
1699
|
} catch (error) {
|
|
1748
|
-
console.error(
|
|
1749
|
-
console.log(
|
|
1700
|
+
console.error(chalk7__default.default.red("Error:"), "Codex not initialized.");
|
|
1701
|
+
console.log(chalk7__default.default.dim('Run "fractary codex init" first.'));
|
|
1750
1702
|
process.exit(1);
|
|
1751
1703
|
}
|
|
1752
1704
|
const { createSyncManager, createLocalStorage, detectCurrentProject } = await import('@fractary/codex');
|
|
@@ -1756,14 +1708,14 @@ function syncCommand() {
|
|
|
1756
1708
|
projectName = detected.project || void 0;
|
|
1757
1709
|
}
|
|
1758
1710
|
if (!projectName) {
|
|
1759
|
-
console.error(
|
|
1760
|
-
console.log(
|
|
1711
|
+
console.error(chalk7__default.default.red("Error:"), "Could not determine project name.");
|
|
1712
|
+
console.log(chalk7__default.default.dim("Provide project name as argument or run from a git repository."));
|
|
1761
1713
|
process.exit(1);
|
|
1762
1714
|
}
|
|
1763
1715
|
const validDirections = ["to-codex", "from-codex", "bidirectional"];
|
|
1764
1716
|
if (!validDirections.includes(options.direction)) {
|
|
1765
|
-
console.error(
|
|
1766
|
-
console.log(
|
|
1717
|
+
console.error(chalk7__default.default.red("Error:"), `Invalid direction: ${options.direction}`);
|
|
1718
|
+
console.log(chalk7__default.default.dim("Valid options: to-codex, from-codex, bidirectional"));
|
|
1767
1719
|
process.exit(1);
|
|
1768
1720
|
}
|
|
1769
1721
|
const direction = options.direction;
|
|
@@ -1820,7 +1772,7 @@ function syncCommand() {
|
|
|
1820
1772
|
});
|
|
1821
1773
|
matches.forEach((match) => matchedFilePaths.add(match));
|
|
1822
1774
|
} catch (error) {
|
|
1823
|
-
console.error(
|
|
1775
|
+
console.error(chalk7__default.default.yellow(`Warning: Invalid pattern "${pattern}": ${error.message}`));
|
|
1824
1776
|
}
|
|
1825
1777
|
}
|
|
1826
1778
|
const targetFiles = await Promise.all(
|
|
@@ -1848,14 +1800,14 @@ function syncCommand() {
|
|
|
1848
1800
|
try {
|
|
1849
1801
|
const { ensureCodexCloned: ensureCodexCloned2 } = await Promise.resolve().then(() => (init_codex_repository(), codex_repository_exports));
|
|
1850
1802
|
if (!options.json) {
|
|
1851
|
-
console.log(
|
|
1803
|
+
console.log(chalk7__default.default.blue("\u2139 Cloning/updating codex repository..."));
|
|
1852
1804
|
}
|
|
1853
1805
|
codexRepoPath = await ensureCodexCloned2(config, {
|
|
1854
1806
|
branch: targetBranch
|
|
1855
1807
|
});
|
|
1856
1808
|
if (!options.json) {
|
|
1857
|
-
console.log(
|
|
1858
|
-
console.log(
|
|
1809
|
+
console.log(chalk7__default.default.dim(` Codex cloned to: ${codexRepoPath}`));
|
|
1810
|
+
console.log(chalk7__default.default.dim(" Scanning for files routing to this project...\n"));
|
|
1859
1811
|
} else {
|
|
1860
1812
|
console.log(JSON.stringify({
|
|
1861
1813
|
info: "Routing-aware sync: cloned codex repository and scanning for files targeting this project",
|
|
@@ -1863,29 +1815,29 @@ function syncCommand() {
|
|
|
1863
1815
|
}, null, 2));
|
|
1864
1816
|
}
|
|
1865
1817
|
} catch (error) {
|
|
1866
|
-
console.error(
|
|
1867
|
-
console.error(
|
|
1868
|
-
console.log(
|
|
1818
|
+
console.error(chalk7__default.default.red("Error:"), "Failed to clone codex repository");
|
|
1819
|
+
console.error(chalk7__default.default.dim(` ${error.message}`));
|
|
1820
|
+
console.log(chalk7__default.default.yellow("\nTroubleshooting:"));
|
|
1869
1821
|
if (error.message.includes("Git command not found")) {
|
|
1870
|
-
console.log(
|
|
1871
|
-
console.log(
|
|
1822
|
+
console.log(chalk7__default.default.dim(" Git is not installed or not in PATH."));
|
|
1823
|
+
console.log(chalk7__default.default.dim(" Install git: https://git-scm.com/downloads"));
|
|
1872
1824
|
} else if (error.message.includes("authentication failed") || error.message.includes("Authentication failed")) {
|
|
1873
|
-
console.log(
|
|
1874
|
-
console.log(
|
|
1875
|
-
console.log(
|
|
1876
|
-
console.log(
|
|
1825
|
+
console.log(chalk7__default.default.dim(" GitHub authentication is required for private repositories."));
|
|
1826
|
+
console.log(chalk7__default.default.dim(" 1. Check auth status: gh auth status"));
|
|
1827
|
+
console.log(chalk7__default.default.dim(" 2. Login if needed: gh auth login"));
|
|
1828
|
+
console.log(chalk7__default.default.dim(" 3. Or set GITHUB_TOKEN environment variable"));
|
|
1877
1829
|
} else if (error.message.includes("Permission denied")) {
|
|
1878
|
-
console.log(
|
|
1879
|
-
console.log(
|
|
1880
|
-
console.log(
|
|
1830
|
+
console.log(chalk7__default.default.dim(" Permission denied accessing repository files."));
|
|
1831
|
+
console.log(chalk7__default.default.dim(" 1. Check file/directory permissions"));
|
|
1832
|
+
console.log(chalk7__default.default.dim(" 2. Ensure you have access to the repository"));
|
|
1881
1833
|
} else if (error.message.includes("not found") || error.message.includes("does not exist")) {
|
|
1882
|
-
console.log(
|
|
1883
|
-
console.log(
|
|
1884
|
-
console.log(
|
|
1834
|
+
console.log(chalk7__default.default.dim(` Repository not found: ${config.organization}/${config.codex_repository || "codex"}`));
|
|
1835
|
+
console.log(chalk7__default.default.dim(" 1. Verify the repository exists on GitHub"));
|
|
1836
|
+
console.log(chalk7__default.default.dim(" 2. Check organization and repository names in config"));
|
|
1885
1837
|
} else {
|
|
1886
|
-
console.log(
|
|
1887
|
-
console.log(
|
|
1888
|
-
console.log(
|
|
1838
|
+
console.log(chalk7__default.default.dim(" 1. Ensure git is installed: git --version"));
|
|
1839
|
+
console.log(chalk7__default.default.dim(" 2. Check GitHub auth: gh auth status"));
|
|
1840
|
+
console.log(chalk7__default.default.dim(` 3. Verify repo exists: ${config.organization}/${config.codex_repository || "codex"}`));
|
|
1889
1841
|
}
|
|
1890
1842
|
process.exit(1);
|
|
1891
1843
|
}
|
|
@@ -1915,7 +1867,7 @@ function syncCommand() {
|
|
|
1915
1867
|
synced: 0
|
|
1916
1868
|
}, null, 2));
|
|
1917
1869
|
} else {
|
|
1918
|
-
console.log(
|
|
1870
|
+
console.log(chalk7__default.default.yellow("No files to sync."));
|
|
1919
1871
|
}
|
|
1920
1872
|
return;
|
|
1921
1873
|
}
|
|
@@ -1958,98 +1910,98 @@ function syncCommand() {
|
|
|
1958
1910
|
}, null, 2));
|
|
1959
1911
|
return;
|
|
1960
1912
|
}
|
|
1961
|
-
console.log(
|
|
1962
|
-
console.log(` Project: ${
|
|
1963
|
-
console.log(` Organization: ${
|
|
1964
|
-
console.log(` Environment: ${
|
|
1965
|
-
console.log(` Direction: ${
|
|
1966
|
-
console.log(` Files: ${
|
|
1967
|
-
console.log(` Total size: ${
|
|
1913
|
+
console.log(chalk7__default.default.bold("Sync Plan\n"));
|
|
1914
|
+
console.log(` Project: ${chalk7__default.default.cyan(projectName)}`);
|
|
1915
|
+
console.log(` Organization: ${chalk7__default.default.cyan(config.organization)}`);
|
|
1916
|
+
console.log(` Environment: ${chalk7__default.default.cyan(options.env)} (${targetBranch})`);
|
|
1917
|
+
console.log(` Direction: ${chalk7__default.default.cyan(direction)}`);
|
|
1918
|
+
console.log(` Files: ${chalk7__default.default.cyan(plan.totalFiles.toString())}`);
|
|
1919
|
+
console.log(` Total size: ${chalk7__default.default.cyan(formatBytes(plan.totalBytes))}`);
|
|
1968
1920
|
if (plan.estimatedTime) {
|
|
1969
|
-
console.log(` Est. time: ${
|
|
1921
|
+
console.log(` Est. time: ${chalk7__default.default.dim(formatDuration(plan.estimatedTime))}`);
|
|
1970
1922
|
}
|
|
1971
1923
|
if (routingScan) {
|
|
1972
1924
|
console.log("");
|
|
1973
|
-
console.log(
|
|
1974
|
-
console.log(` Scanned: ${
|
|
1975
|
-
console.log(` Matched: ${
|
|
1976
|
-
console.log(` Source projects: ${
|
|
1925
|
+
console.log(chalk7__default.default.bold("Routing Statistics\n"));
|
|
1926
|
+
console.log(` Scanned: ${chalk7__default.default.cyan(routingScan.stats.totalScanned.toString())} files`);
|
|
1927
|
+
console.log(` Matched: ${chalk7__default.default.cyan(routingScan.stats.totalMatched.toString())} files`);
|
|
1928
|
+
console.log(` Source projects: ${chalk7__default.default.cyan(routingScan.stats.sourceProjects.length.toString())}`);
|
|
1977
1929
|
if (routingScan.stats.sourceProjects.length > 0) {
|
|
1978
|
-
console.log(
|
|
1930
|
+
console.log(chalk7__default.default.dim(` ${routingScan.stats.sourceProjects.slice(0, 5).join(", ")}`));
|
|
1979
1931
|
if (routingScan.stats.sourceProjects.length > 5) {
|
|
1980
|
-
console.log(
|
|
1932
|
+
console.log(chalk7__default.default.dim(` ... and ${routingScan.stats.sourceProjects.length - 5} more`));
|
|
1981
1933
|
}
|
|
1982
1934
|
}
|
|
1983
|
-
console.log(` Scan time: ${
|
|
1935
|
+
console.log(` Scan time: ${chalk7__default.default.dim(formatDuration(routingScan.stats.durationMs))}`);
|
|
1984
1936
|
}
|
|
1985
1937
|
console.log("");
|
|
1986
1938
|
if (plan.conflicts.length > 0) {
|
|
1987
|
-
console.log(
|
|
1939
|
+
console.log(chalk7__default.default.yellow(`\u26A0 ${plan.conflicts.length} conflicts detected:`));
|
|
1988
1940
|
for (const conflict of plan.conflicts.slice(0, 5)) {
|
|
1989
|
-
console.log(
|
|
1941
|
+
console.log(chalk7__default.default.yellow(` \u2022 ${conflict.path}`));
|
|
1990
1942
|
}
|
|
1991
1943
|
if (plan.conflicts.length > 5) {
|
|
1992
|
-
console.log(
|
|
1944
|
+
console.log(chalk7__default.default.dim(` ... and ${plan.conflicts.length - 5} more`));
|
|
1993
1945
|
}
|
|
1994
1946
|
console.log("");
|
|
1995
1947
|
}
|
|
1996
1948
|
if (plan.skipped.length > 0) {
|
|
1997
|
-
console.log(
|
|
1949
|
+
console.log(chalk7__default.default.dim(`${plan.skipped.length} files skipped (no changes)`));
|
|
1998
1950
|
console.log("");
|
|
1999
1951
|
}
|
|
2000
1952
|
if (options.dryRun) {
|
|
2001
|
-
console.log(
|
|
1953
|
+
console.log(chalk7__default.default.blue("Dry run - would sync:\n"));
|
|
2002
1954
|
const filesToShow = plan.files.slice(0, 10);
|
|
2003
1955
|
for (const file of filesToShow) {
|
|
2004
1956
|
const arrow = direction === "to-codex" ? "\u2192" : direction === "from-codex" ? "\u2190" : "\u2194";
|
|
2005
|
-
const opColor = file.operation === "create" ?
|
|
1957
|
+
const opColor = file.operation === "create" ? chalk7__default.default.green : file.operation === "update" ? chalk7__default.default.yellow : chalk7__default.default.dim;
|
|
2006
1958
|
console.log(
|
|
2007
|
-
|
|
1959
|
+
chalk7__default.default.dim(` ${arrow}`),
|
|
2008
1960
|
opColor(file.operation.padEnd(7)),
|
|
2009
1961
|
file.path,
|
|
2010
|
-
|
|
1962
|
+
chalk7__default.default.dim(`(${formatBytes(file.size || 0)})`)
|
|
2011
1963
|
);
|
|
2012
1964
|
}
|
|
2013
1965
|
if (plan.files.length > 10) {
|
|
2014
|
-
console.log(
|
|
1966
|
+
console.log(chalk7__default.default.dim(` ... and ${plan.files.length - 10} more files`));
|
|
2015
1967
|
}
|
|
2016
|
-
console.log(
|
|
1968
|
+
console.log(chalk7__default.default.dim(`
|
|
2017
1969
|
Total: ${plan.totalFiles} files (${formatBytes(plan.totalBytes)})`));
|
|
2018
|
-
console.log(
|
|
1970
|
+
console.log(chalk7__default.default.dim("Run without --dry-run to execute sync."));
|
|
2019
1971
|
return;
|
|
2020
1972
|
}
|
|
2021
|
-
console.log(
|
|
1973
|
+
console.log(chalk7__default.default.blue("Syncing...\n"));
|
|
2022
1974
|
const startTime = Date.now();
|
|
2023
1975
|
const result = await syncManager.executePlan(plan, syncOptions);
|
|
2024
1976
|
const duration = Date.now() - startTime;
|
|
2025
1977
|
console.log("");
|
|
2026
1978
|
if (result.success) {
|
|
2027
|
-
console.log(
|
|
2028
|
-
console.log(
|
|
1979
|
+
console.log(chalk7__default.default.green(`\u2713 Sync completed successfully`));
|
|
1980
|
+
console.log(chalk7__default.default.dim(` Synced: ${result.synced} files`));
|
|
2029
1981
|
if (result.skipped > 0) {
|
|
2030
|
-
console.log(
|
|
1982
|
+
console.log(chalk7__default.default.dim(` Skipped: ${result.skipped} files`));
|
|
2031
1983
|
}
|
|
2032
|
-
console.log(
|
|
1984
|
+
console.log(chalk7__default.default.dim(` Duration: ${formatDuration(duration)}`));
|
|
2033
1985
|
} else {
|
|
2034
|
-
console.log(
|
|
2035
|
-
console.log(
|
|
2036
|
-
console.log(
|
|
1986
|
+
console.log(chalk7__default.default.yellow(`\u26A0 Sync completed with errors`));
|
|
1987
|
+
console.log(chalk7__default.default.green(` Synced: ${result.synced} files`));
|
|
1988
|
+
console.log(chalk7__default.default.red(` Failed: ${result.failed} files`));
|
|
2037
1989
|
if (result.skipped > 0) {
|
|
2038
|
-
console.log(
|
|
1990
|
+
console.log(chalk7__default.default.dim(` Skipped: ${result.skipped} files`));
|
|
2039
1991
|
}
|
|
2040
1992
|
if (result.errors.length > 0) {
|
|
2041
1993
|
console.log("");
|
|
2042
|
-
console.log(
|
|
1994
|
+
console.log(chalk7__default.default.red("Errors:"));
|
|
2043
1995
|
for (const error of result.errors.slice(0, 5)) {
|
|
2044
|
-
console.log(
|
|
1996
|
+
console.log(chalk7__default.default.red(` \u2022 ${error.path}: ${error.error}`));
|
|
2045
1997
|
}
|
|
2046
1998
|
if (result.errors.length > 5) {
|
|
2047
|
-
console.log(
|
|
1999
|
+
console.log(chalk7__default.default.dim(` ... and ${result.errors.length - 5} more errors`));
|
|
2048
2000
|
}
|
|
2049
2001
|
}
|
|
2050
2002
|
}
|
|
2051
2003
|
} catch (error) {
|
|
2052
|
-
console.error(
|
|
2004
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
2053
2005
|
process.exit(1);
|
|
2054
2006
|
}
|
|
2055
2007
|
});
|
|
@@ -2101,35 +2053,35 @@ function typesListCommand() {
|
|
|
2101
2053
|
return;
|
|
2102
2054
|
}
|
|
2103
2055
|
if (types.length === 0) {
|
|
2104
|
-
console.log(
|
|
2056
|
+
console.log(chalk7__default.default.yellow("No types found."));
|
|
2105
2057
|
return;
|
|
2106
2058
|
}
|
|
2107
|
-
console.log(
|
|
2059
|
+
console.log(chalk7__default.default.bold("Artifact Types\n"));
|
|
2108
2060
|
const builtinTypes = types.filter((t) => registry.isBuiltIn(t.name));
|
|
2109
2061
|
const customTypes = types.filter((t) => !registry.isBuiltIn(t.name));
|
|
2110
2062
|
if (builtinTypes.length > 0 && !options.customOnly) {
|
|
2111
|
-
console.log(
|
|
2112
|
-
console.log(
|
|
2063
|
+
console.log(chalk7__default.default.bold("Built-in Types"));
|
|
2064
|
+
console.log(chalk7__default.default.dim("\u2500".repeat(70)));
|
|
2113
2065
|
for (const type of builtinTypes) {
|
|
2114
2066
|
const patternStr = type.patterns[0] || "";
|
|
2115
|
-
console.log(` ${
|
|
2116
|
-
console.log(` ${
|
|
2067
|
+
console.log(` ${chalk7__default.default.cyan(type.name.padEnd(12))} ${patternStr.padEnd(30)} ${chalk7__default.default.dim(`TTL: ${formatTtl(type.defaultTtl)}`)}`);
|
|
2068
|
+
console.log(` ${chalk7__default.default.dim(" ".repeat(12) + type.description)}`);
|
|
2117
2069
|
}
|
|
2118
2070
|
console.log("");
|
|
2119
2071
|
}
|
|
2120
2072
|
if (customTypes.length > 0 && !options.builtinOnly) {
|
|
2121
|
-
console.log(
|
|
2122
|
-
console.log(
|
|
2073
|
+
console.log(chalk7__default.default.bold("Custom Types"));
|
|
2074
|
+
console.log(chalk7__default.default.dim("\u2500".repeat(70)));
|
|
2123
2075
|
for (const type of customTypes) {
|
|
2124
2076
|
const patternStr = type.patterns[0] || "";
|
|
2125
|
-
console.log(` ${
|
|
2126
|
-
console.log(` ${
|
|
2077
|
+
console.log(` ${chalk7__default.default.green(type.name.padEnd(12))} ${patternStr.padEnd(30)} ${chalk7__default.default.dim(`TTL: ${formatTtl(type.defaultTtl)}`)}`);
|
|
2078
|
+
console.log(` ${chalk7__default.default.dim(" ".repeat(12) + type.description)}`);
|
|
2127
2079
|
}
|
|
2128
2080
|
console.log("");
|
|
2129
2081
|
}
|
|
2130
|
-
console.log(
|
|
2082
|
+
console.log(chalk7__default.default.dim(`Total: ${types.length} types (${builtinTypes.length} built-in, ${customTypes.length} custom)`));
|
|
2131
2083
|
} catch (error) {
|
|
2132
|
-
console.error(
|
|
2084
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
2133
2085
|
process.exit(1);
|
|
2134
2086
|
}
|
|
2135
2087
|
});
|
|
@@ -2152,8 +2104,8 @@ function typesShowCommand() {
|
|
|
2152
2104
|
const registry = client.getTypeRegistry();
|
|
2153
2105
|
const type = registry.get(name);
|
|
2154
2106
|
if (!type) {
|
|
2155
|
-
console.error(
|
|
2156
|
-
console.log(
|
|
2107
|
+
console.error(chalk7__default.default.red("Error:"), `Type "${name}" not found.`);
|
|
2108
|
+
console.log(chalk7__default.default.dim('Run "fractary codex types list" to see available types.'));
|
|
2157
2109
|
process.exit(1);
|
|
2158
2110
|
}
|
|
2159
2111
|
const isBuiltin = registry.isBuiltIn(name);
|
|
@@ -2172,39 +2124,39 @@ function typesShowCommand() {
|
|
|
2172
2124
|
}, null, 2));
|
|
2173
2125
|
return;
|
|
2174
2126
|
}
|
|
2175
|
-
const nameColor = isBuiltin ?
|
|
2176
|
-
console.log(
|
|
2127
|
+
const nameColor = isBuiltin ? chalk7__default.default.cyan : chalk7__default.default.green;
|
|
2128
|
+
console.log(chalk7__default.default.bold(`Type: ${nameColor(name)}
|
|
2177
2129
|
`));
|
|
2178
|
-
console.log(` ${
|
|
2179
|
-
console.log(` ${
|
|
2180
|
-
console.log(` ${
|
|
2130
|
+
console.log(` ${chalk7__default.default.dim("Source:")} ${isBuiltin ? "Built-in" : "Custom"}`);
|
|
2131
|
+
console.log(` ${chalk7__default.default.dim("Description:")} ${type.description}`);
|
|
2132
|
+
console.log(` ${chalk7__default.default.dim("TTL:")} ${formatTtl2(type.defaultTtl)} (${type.defaultTtl} seconds)`);
|
|
2181
2133
|
console.log("");
|
|
2182
|
-
console.log(
|
|
2134
|
+
console.log(chalk7__default.default.bold("Patterns"));
|
|
2183
2135
|
for (const pattern of type.patterns) {
|
|
2184
|
-
console.log(` ${
|
|
2136
|
+
console.log(` ${chalk7__default.default.dim("\u2022")} ${pattern}`);
|
|
2185
2137
|
}
|
|
2186
2138
|
if (type.archiveAfterDays !== null) {
|
|
2187
2139
|
console.log("");
|
|
2188
|
-
console.log(
|
|
2189
|
-
console.log(` ${
|
|
2190
|
-
console.log(` ${
|
|
2140
|
+
console.log(chalk7__default.default.bold("Archive Settings"));
|
|
2141
|
+
console.log(` ${chalk7__default.default.dim("After:")} ${type.archiveAfterDays} days`);
|
|
2142
|
+
console.log(` ${chalk7__default.default.dim("Storage:")} ${type.archiveStorage || "not set"}`);
|
|
2191
2143
|
}
|
|
2192
2144
|
if (type.syncPatterns && type.syncPatterns.length > 0) {
|
|
2193
2145
|
console.log("");
|
|
2194
|
-
console.log(
|
|
2146
|
+
console.log(chalk7__default.default.bold("Sync Patterns"));
|
|
2195
2147
|
for (const pattern of type.syncPatterns) {
|
|
2196
|
-
console.log(` ${
|
|
2148
|
+
console.log(` ${chalk7__default.default.dim("\u2022")} ${pattern}`);
|
|
2197
2149
|
}
|
|
2198
2150
|
}
|
|
2199
2151
|
if (type.excludePatterns && type.excludePatterns.length > 0) {
|
|
2200
2152
|
console.log("");
|
|
2201
|
-
console.log(
|
|
2153
|
+
console.log(chalk7__default.default.bold("Exclude Patterns"));
|
|
2202
2154
|
for (const pattern of type.excludePatterns) {
|
|
2203
|
-
console.log(` ${
|
|
2155
|
+
console.log(` ${chalk7__default.default.dim("\u2022")} ${pattern}`);
|
|
2204
2156
|
}
|
|
2205
2157
|
}
|
|
2206
2158
|
} catch (error) {
|
|
2207
|
-
console.error(
|
|
2159
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
2208
2160
|
process.exit(1);
|
|
2209
2161
|
}
|
|
2210
2162
|
});
|
|
@@ -2248,30 +2200,30 @@ function typesAddCommand() {
|
|
|
2248
2200
|
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) => {
|
|
2249
2201
|
try {
|
|
2250
2202
|
if (!isValidTypeName(name)) {
|
|
2251
|
-
console.error(
|
|
2252
|
-
console.log(
|
|
2203
|
+
console.error(chalk7__default.default.red("Error:"), "Invalid type name.");
|
|
2204
|
+
console.log(chalk7__default.default.dim("Type name must be lowercase, start with a letter, and contain only letters, numbers, and hyphens."));
|
|
2253
2205
|
process.exit(1);
|
|
2254
2206
|
}
|
|
2255
2207
|
const client = await getClient();
|
|
2256
2208
|
const registry = client.getTypeRegistry();
|
|
2257
2209
|
if (registry.isBuiltIn(name)) {
|
|
2258
|
-
console.error(
|
|
2210
|
+
console.error(chalk7__default.default.red("Error:"), `Cannot override built-in type "${name}".`);
|
|
2259
2211
|
const builtinNames = registry.list().filter((t) => registry.isBuiltIn(t.name)).map((t) => t.name);
|
|
2260
|
-
console.log(
|
|
2212
|
+
console.log(chalk7__default.default.dim("Built-in types: " + builtinNames.join(", ")));
|
|
2261
2213
|
process.exit(1);
|
|
2262
2214
|
}
|
|
2263
2215
|
if (registry.has(name)) {
|
|
2264
|
-
console.error(
|
|
2265
|
-
console.log(
|
|
2216
|
+
console.error(chalk7__default.default.red("Error:"), `Custom type "${name}" already exists.`);
|
|
2217
|
+
console.log(chalk7__default.default.dim('Use "fractary codex types remove" first to remove it.'));
|
|
2266
2218
|
process.exit(1);
|
|
2267
2219
|
}
|
|
2268
2220
|
let ttlSeconds;
|
|
2269
2221
|
try {
|
|
2270
2222
|
ttlSeconds = parseTtl(options.ttl);
|
|
2271
2223
|
} catch {
|
|
2272
|
-
console.error(
|
|
2273
|
-
console.log(
|
|
2274
|
-
console.log(
|
|
2224
|
+
console.error(chalk7__default.default.red("Error:"), "Invalid TTL format.");
|
|
2225
|
+
console.log(chalk7__default.default.dim("Expected format: <number><unit> where unit is s (seconds), m (minutes), h (hours), or d (days)"));
|
|
2226
|
+
console.log(chalk7__default.default.dim("Examples: 30m, 24h, 7d"));
|
|
2275
2227
|
process.exit(1);
|
|
2276
2228
|
}
|
|
2277
2229
|
const configPath = path4__namespace.join(process.cwd(), ".fractary", "codex", "config.yaml");
|
|
@@ -2303,19 +2255,19 @@ function typesAddCommand() {
|
|
|
2303
2255
|
}, null, 2));
|
|
2304
2256
|
return;
|
|
2305
2257
|
}
|
|
2306
|
-
console.log(
|
|
2258
|
+
console.log(chalk7__default.default.green("\u2713"), `Added custom type "${chalk7__default.default.cyan(name)}"`);
|
|
2307
2259
|
console.log("");
|
|
2308
|
-
console.log(` ${
|
|
2309
|
-
console.log(` ${
|
|
2260
|
+
console.log(` ${chalk7__default.default.dim("Pattern:")} ${options.pattern}`);
|
|
2261
|
+
console.log(` ${chalk7__default.default.dim("TTL:")} ${formatTtl3(ttlSeconds)} (${ttlSeconds} seconds)`);
|
|
2310
2262
|
if (options.description) {
|
|
2311
|
-
console.log(` ${
|
|
2263
|
+
console.log(` ${chalk7__default.default.dim("Description:")} ${options.description}`);
|
|
2312
2264
|
}
|
|
2313
2265
|
console.log("");
|
|
2314
|
-
console.log(
|
|
2266
|
+
console.log(chalk7__default.default.dim("Note: Custom type will be available on next CLI invocation."));
|
|
2315
2267
|
} catch (error) {
|
|
2316
|
-
console.error(
|
|
2268
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
2317
2269
|
if (error.message.includes("Failed to load configuration")) {
|
|
2318
|
-
console.log(
|
|
2270
|
+
console.log(chalk7__default.default.dim('\nRun "fractary codex init" to create a configuration.'));
|
|
2319
2271
|
}
|
|
2320
2272
|
process.exit(1);
|
|
2321
2273
|
}
|
|
@@ -2333,20 +2285,20 @@ function typesRemoveCommand() {
|
|
|
2333
2285
|
const client = await getClient();
|
|
2334
2286
|
const registry = client.getTypeRegistry();
|
|
2335
2287
|
if (registry.isBuiltIn(name)) {
|
|
2336
|
-
console.error(
|
|
2337
|
-
console.log(
|
|
2288
|
+
console.error(chalk7__default.default.red("Error:"), `Cannot remove built-in type "${name}".`);
|
|
2289
|
+
console.log(chalk7__default.default.dim("Built-in types are permanent and cannot be removed."));
|
|
2338
2290
|
process.exit(1);
|
|
2339
2291
|
}
|
|
2340
2292
|
if (!registry.has(name)) {
|
|
2341
|
-
console.error(
|
|
2342
|
-
console.log(
|
|
2293
|
+
console.error(chalk7__default.default.red("Error:"), `Custom type "${name}" not found.`);
|
|
2294
|
+
console.log(chalk7__default.default.dim('Run "fractary codex types list --custom-only" to see custom types.'));
|
|
2343
2295
|
process.exit(1);
|
|
2344
2296
|
}
|
|
2345
2297
|
const typeInfo = registry.get(name);
|
|
2346
2298
|
const configPath = path4__namespace.join(process.cwd(), ".fractary", "codex", "config.yaml");
|
|
2347
2299
|
const config = await readYamlConfig(configPath);
|
|
2348
2300
|
if (!config.types?.custom?.[name]) {
|
|
2349
|
-
console.error(
|
|
2301
|
+
console.error(chalk7__default.default.red("Error:"), `Custom type "${name}" not found in configuration.`);
|
|
2350
2302
|
process.exit(1);
|
|
2351
2303
|
}
|
|
2352
2304
|
delete config.types.custom[name];
|
|
@@ -2370,17 +2322,17 @@ function typesRemoveCommand() {
|
|
|
2370
2322
|
}, null, 2));
|
|
2371
2323
|
return;
|
|
2372
2324
|
}
|
|
2373
|
-
console.log(
|
|
2325
|
+
console.log(chalk7__default.default.green("\u2713"), `Removed custom type "${chalk7__default.default.cyan(name)}"`);
|
|
2374
2326
|
console.log("");
|
|
2375
|
-
console.log(
|
|
2376
|
-
console.log(` ${
|
|
2377
|
-
console.log(` ${
|
|
2327
|
+
console.log(chalk7__default.default.dim("Removed configuration:"));
|
|
2328
|
+
console.log(` ${chalk7__default.default.dim("Pattern:")} ${typeInfo.patterns.join(", ")}`);
|
|
2329
|
+
console.log(` ${chalk7__default.default.dim("Description:")} ${typeInfo.description}`);
|
|
2378
2330
|
console.log("");
|
|
2379
|
-
console.log(
|
|
2331
|
+
console.log(chalk7__default.default.dim("Note: Custom type will be removed on next CLI invocation."));
|
|
2380
2332
|
} catch (error) {
|
|
2381
|
-
console.error(
|
|
2333
|
+
console.error(chalk7__default.default.red("Error:"), error.message);
|
|
2382
2334
|
if (error.message.includes("Failed to load configuration")) {
|
|
2383
|
-
console.log(
|
|
2335
|
+
console.log(chalk7__default.default.dim('\nRun "fractary codex init" to create a configuration.'));
|
|
2384
2336
|
}
|
|
2385
2337
|
process.exit(1);
|
|
2386
2338
|
}
|