@fractary/codex-mcp 0.10.1 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +107 -44
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +39 -3
- package/dist/index.cjs.map +1 -1
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -12272,11 +12272,14 @@ function matchToCodexPattern(filePath, patterns) {
|
|
|
12272
12272
|
}
|
|
12273
12273
|
return patterns.some((pattern) => matchPattern(pattern, filePath));
|
|
12274
12274
|
}
|
|
12275
|
-
function matchFromCodexPattern(codexFilePath, patterns, targetProject) {
|
|
12275
|
+
function matchFromCodexPattern(codexFilePath, patterns, targetProject, options) {
|
|
12276
12276
|
if (!patterns || patterns.length === 0) {
|
|
12277
12277
|
return false;
|
|
12278
12278
|
}
|
|
12279
12279
|
return patterns.some((pattern) => {
|
|
12280
|
+
if (pattern.startsWith(CODEX_URI_PREFIX2)) {
|
|
12281
|
+
return matchCodexUri(pattern, codexFilePath, targetProject, options);
|
|
12282
|
+
}
|
|
12280
12283
|
if (pattern.startsWith("projects/")) {
|
|
12281
12284
|
return matchPattern(pattern, codexFilePath);
|
|
12282
12285
|
}
|
|
@@ -12294,6 +12297,21 @@ function matchFromCodexPattern(codexFilePath, patterns, targetProject) {
|
|
|
12294
12297
|
}
|
|
12295
12298
|
});
|
|
12296
12299
|
}
|
|
12300
|
+
function matchCodexUri(uriPattern, codexFilePath, targetProject, options) {
|
|
12301
|
+
let withoutPrefix = uriPattern.slice(CODEX_URI_PREFIX2.length);
|
|
12302
|
+
withoutPrefix = withoutPrefix.replace(/{org}/g, options?.org || "").replace(/{project}/g, targetProject).replace(/{codex_repo}/g, options?.codexRepo || "");
|
|
12303
|
+
const parts = withoutPrefix.split("/");
|
|
12304
|
+
if (parts.length < 2) {
|
|
12305
|
+
return false;
|
|
12306
|
+
}
|
|
12307
|
+
const project = parts[1];
|
|
12308
|
+
const pathPattern = parts.slice(2).join("/");
|
|
12309
|
+
if (!project) {
|
|
12310
|
+
return false;
|
|
12311
|
+
}
|
|
12312
|
+
const fullPattern = pathPattern ? `projects/${project}/${pathPattern}` : `projects/${project}/**`;
|
|
12313
|
+
return matchPattern(fullPattern, codexFilePath);
|
|
12314
|
+
}
|
|
12297
12315
|
function extractProjectFromCodexPath(codexFilePath) {
|
|
12298
12316
|
const firstSlashIndex = codexFilePath.indexOf("/");
|
|
12299
12317
|
if (firstSlashIndex === -1) {
|
|
@@ -12308,15 +12326,26 @@ function getRelativePath(codexFilePath) {
|
|
|
12308
12326
|
}
|
|
12309
12327
|
return codexFilePath.substring(firstSlashIndex + 1);
|
|
12310
12328
|
}
|
|
12311
|
-
function expandPlaceholders(patterns, targetProject) {
|
|
12329
|
+
function expandPlaceholders(patterns, targetProject, options) {
|
|
12312
12330
|
if (!patterns) {
|
|
12313
12331
|
return patterns;
|
|
12314
12332
|
}
|
|
12315
|
-
return patterns.map((pattern) =>
|
|
12333
|
+
return patterns.map((pattern) => {
|
|
12334
|
+
let expanded = pattern.replace(/{project}/g, targetProject);
|
|
12335
|
+
if (options?.org) {
|
|
12336
|
+
expanded = expanded.replace(/{org}/g, options.org);
|
|
12337
|
+
}
|
|
12338
|
+
if (options?.codexRepo) {
|
|
12339
|
+
expanded = expanded.replace(/{codex_repo}/g, options.codexRepo);
|
|
12340
|
+
}
|
|
12341
|
+
return expanded;
|
|
12342
|
+
});
|
|
12316
12343
|
}
|
|
12344
|
+
var CODEX_URI_PREFIX2;
|
|
12317
12345
|
var init_directional_patterns = __esm2({
|
|
12318
12346
|
"src/sync/directional-patterns.ts"() {
|
|
12319
12347
|
init_matcher();
|
|
12348
|
+
CODEX_URI_PREFIX2 = "codex://";
|
|
12320
12349
|
}
|
|
12321
12350
|
});
|
|
12322
12351
|
var FORBIDDEN_PATTERNS = [
|
|
@@ -14580,9 +14609,57 @@ var CacheManager = class {
|
|
|
14580
14609
|
function createCacheManager(config) {
|
|
14581
14610
|
return new CacheManager(config);
|
|
14582
14611
|
}
|
|
14583
|
-
|
|
14584
|
-
|
|
14585
|
-
|
|
14612
|
+
function expandEnvVars(value, options = {}) {
|
|
14613
|
+
const env = options.env ?? process.env;
|
|
14614
|
+
return value.replace(/\$\{([^}]+)\}/g, (match, varName) => {
|
|
14615
|
+
const envValue = env[varName];
|
|
14616
|
+
if (envValue === void 0) {
|
|
14617
|
+
if (options.warnOnMissing) {
|
|
14618
|
+
console.warn(`Warning: Environment variable ${varName} is not set`);
|
|
14619
|
+
}
|
|
14620
|
+
if (options.onMissing) {
|
|
14621
|
+
options.onMissing(varName);
|
|
14622
|
+
}
|
|
14623
|
+
return match;
|
|
14624
|
+
}
|
|
14625
|
+
return envValue;
|
|
14626
|
+
});
|
|
14627
|
+
}
|
|
14628
|
+
function expandEnvVarsInConfig(config, options = {}) {
|
|
14629
|
+
if (typeof config === "string") {
|
|
14630
|
+
return expandEnvVars(config, options);
|
|
14631
|
+
}
|
|
14632
|
+
if (Array.isArray(config)) {
|
|
14633
|
+
return config.map((item) => expandEnvVarsInConfig(item, options));
|
|
14634
|
+
}
|
|
14635
|
+
if (config !== null && typeof config === "object") {
|
|
14636
|
+
const result = {};
|
|
14637
|
+
for (const [key, value] of Object.entries(config)) {
|
|
14638
|
+
result[key] = expandEnvVarsInConfig(value, options);
|
|
14639
|
+
}
|
|
14640
|
+
return result;
|
|
14641
|
+
}
|
|
14642
|
+
return config;
|
|
14643
|
+
}
|
|
14644
|
+
async function readUnifiedConfig(configPath, options = {}) {
|
|
14645
|
+
const content = await fs3.readFile(configPath, "utf-8");
|
|
14646
|
+
let config = load(content);
|
|
14647
|
+
if (options.expandEnv !== false) {
|
|
14648
|
+
const envOptions = {
|
|
14649
|
+
env: options.env,
|
|
14650
|
+
warnOnMissing: options.warnOnMissingEnv
|
|
14651
|
+
};
|
|
14652
|
+
config = expandEnvVarsInConfig(config, envOptions);
|
|
14653
|
+
}
|
|
14654
|
+
return config;
|
|
14655
|
+
}
|
|
14656
|
+
var SIZE_MULTIPLIERS = {
|
|
14657
|
+
B: 1,
|
|
14658
|
+
KB: 1024,
|
|
14659
|
+
MB: 1024 * 1024,
|
|
14660
|
+
GB: 1024 * 1024 * 1024,
|
|
14661
|
+
TB: 1024 * 1024 * 1024 * 1024
|
|
14662
|
+
};
|
|
14586
14663
|
|
|
14587
14664
|
// src/server.ts
|
|
14588
14665
|
init_cjs_shims();
|
|
@@ -15060,58 +15137,44 @@ var McpServer = class {
|
|
|
15060
15137
|
};
|
|
15061
15138
|
|
|
15062
15139
|
// src/cli.ts
|
|
15063
|
-
function expandEnvVars(obj) {
|
|
15064
|
-
if (typeof obj === "string") {
|
|
15065
|
-
return obj.replace(/\$\{([^}]+)\}/g, (_, varName) => {
|
|
15066
|
-
return process.env[varName] || `\${${varName}}`;
|
|
15067
|
-
});
|
|
15068
|
-
}
|
|
15069
|
-
if (Array.isArray(obj)) {
|
|
15070
|
-
return obj.map((item) => expandEnvVars(item));
|
|
15071
|
-
}
|
|
15072
|
-
if (obj !== null && typeof obj === "object") {
|
|
15073
|
-
const result = {};
|
|
15074
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
15075
|
-
result[key] = expandEnvVars(value);
|
|
15076
|
-
}
|
|
15077
|
-
return result;
|
|
15078
|
-
}
|
|
15079
|
-
return obj;
|
|
15080
|
-
}
|
|
15081
15140
|
var program2 = new Command();
|
|
15082
15141
|
program2.name("fractary-codex-mcp").description("MCP server for Fractary Codex knowledge management").version("0.8.0").option("--config <path>", "Path to config file", ".fractary/config.yaml").action(async (options) => {
|
|
15083
|
-
let
|
|
15142
|
+
let codexConfig = void 0;
|
|
15143
|
+
let fileConfig = void 0;
|
|
15084
15144
|
try {
|
|
15085
|
-
const
|
|
15086
|
-
|
|
15087
|
-
|
|
15088
|
-
|
|
15089
|
-
|
|
15090
|
-
// Preserve file section if present (for file plugin integration)
|
|
15091
|
-
file: rawConfig.file
|
|
15092
|
-
};
|
|
15093
|
-
} else {
|
|
15094
|
-
config = rawConfig || {};
|
|
15095
|
-
}
|
|
15096
|
-
config = expandEnvVars(config);
|
|
15145
|
+
const unifiedConfig = await readUnifiedConfig(options.config, {
|
|
15146
|
+
expandEnv: true
|
|
15147
|
+
});
|
|
15148
|
+
codexConfig = unifiedConfig.codex;
|
|
15149
|
+
fileConfig = unifiedConfig.file;
|
|
15097
15150
|
} catch (error) {
|
|
15151
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
15098
15152
|
if (options.config !== ".fractary/config.yaml") {
|
|
15099
15153
|
console.error(`Warning: Could not load config file: ${options.config}`);
|
|
15154
|
+
console.error(` Error: ${errorMessage}`);
|
|
15155
|
+
} else {
|
|
15156
|
+
if (!errorMessage.includes("ENOENT")) {
|
|
15157
|
+
console.error(`Warning: Config file exists but could not be parsed: ${errorMessage}`);
|
|
15158
|
+
}
|
|
15100
15159
|
}
|
|
15101
15160
|
}
|
|
15102
|
-
const storageConfig = {
|
|
15103
|
-
|
|
15104
|
-
|
|
15105
|
-
|
|
15161
|
+
const storageConfig = {};
|
|
15162
|
+
if (codexConfig?.storage) {
|
|
15163
|
+
Object.assign(storageConfig, { providers: codexConfig.storage });
|
|
15164
|
+
}
|
|
15165
|
+
if (codexConfig?.archive) {
|
|
15106
15166
|
storageConfig.s3Archive = {
|
|
15107
|
-
projects:
|
|
15167
|
+
projects: codexConfig.archive.projects || {},
|
|
15108
15168
|
fractaryCli: process.env.FRACTARY_CLI || "fractary"
|
|
15109
15169
|
};
|
|
15110
15170
|
}
|
|
15171
|
+
if (fileConfig) {
|
|
15172
|
+
storageConfig.file = fileConfig;
|
|
15173
|
+
}
|
|
15111
15174
|
const storage = createStorageManager(storageConfig);
|
|
15112
15175
|
const cache = createCacheManager({
|
|
15113
|
-
cacheDir:
|
|
15114
|
-
...
|
|
15176
|
+
cacheDir: codexConfig?.cacheDir || codexConfig?.cache?.cacheDir || ".fractary/codex/cache",
|
|
15177
|
+
...codexConfig?.cache || {}
|
|
15115
15178
|
});
|
|
15116
15179
|
if (storage) {
|
|
15117
15180
|
cache.setStorageManager(storage);
|