@fractary/codex-mcp 0.10.0 → 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 +119 -47
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +51 -6
- 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 = [
|
|
@@ -12667,12 +12696,21 @@ var SyncRulesSchema = external_exports.object({
|
|
|
12667
12696
|
defaultInclude: external_exports.array(external_exports.string()).optional(),
|
|
12668
12697
|
defaultExclude: external_exports.array(external_exports.string()).optional()
|
|
12669
12698
|
});
|
|
12699
|
+
var DirectionalSyncConfigSchema = external_exports.object({
|
|
12700
|
+
/** Patterns to include (required) */
|
|
12701
|
+
include: external_exports.array(external_exports.string()),
|
|
12702
|
+
/** Patterns to exclude (optional) */
|
|
12703
|
+
exclude: external_exports.array(external_exports.string()).optional()
|
|
12704
|
+
});
|
|
12670
12705
|
var DirectionalSyncSchema = external_exports.object({
|
|
12706
|
+
// New format (v0.7.0+) - Recommended
|
|
12671
12707
|
// Patterns for files to push from this project to codex
|
|
12672
|
-
to_codex:
|
|
12708
|
+
to_codex: DirectionalSyncConfigSchema.optional(),
|
|
12673
12709
|
// Patterns for files to pull from codex to this project
|
|
12674
|
-
|
|
12675
|
-
|
|
12710
|
+
from_codex: DirectionalSyncConfigSchema.optional(),
|
|
12711
|
+
// Global exclude patterns (applied to both directions)
|
|
12712
|
+
exclude: external_exports.array(external_exports.string()).optional(),
|
|
12713
|
+
// Legacy format (deprecated, backward compatible)
|
|
12676
12714
|
// Org-level defaults (only in codex repository config)
|
|
12677
12715
|
default_to_codex: external_exports.array(external_exports.string()).optional(),
|
|
12678
12716
|
default_from_codex: external_exports.array(external_exports.string()).optional()
|
|
@@ -14571,9 +14609,57 @@ var CacheManager = class {
|
|
|
14571
14609
|
function createCacheManager(config) {
|
|
14572
14610
|
return new CacheManager(config);
|
|
14573
14611
|
}
|
|
14574
|
-
|
|
14575
|
-
|
|
14576
|
-
|
|
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
|
+
};
|
|
14577
14663
|
|
|
14578
14664
|
// src/server.ts
|
|
14579
14665
|
init_cjs_shims();
|
|
@@ -15051,58 +15137,44 @@ var McpServer = class {
|
|
|
15051
15137
|
};
|
|
15052
15138
|
|
|
15053
15139
|
// src/cli.ts
|
|
15054
|
-
function expandEnvVars(obj) {
|
|
15055
|
-
if (typeof obj === "string") {
|
|
15056
|
-
return obj.replace(/\$\{([^}]+)\}/g, (_, varName) => {
|
|
15057
|
-
return process.env[varName] || `\${${varName}}`;
|
|
15058
|
-
});
|
|
15059
|
-
}
|
|
15060
|
-
if (Array.isArray(obj)) {
|
|
15061
|
-
return obj.map((item) => expandEnvVars(item));
|
|
15062
|
-
}
|
|
15063
|
-
if (obj !== null && typeof obj === "object") {
|
|
15064
|
-
const result = {};
|
|
15065
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
15066
|
-
result[key] = expandEnvVars(value);
|
|
15067
|
-
}
|
|
15068
|
-
return result;
|
|
15069
|
-
}
|
|
15070
|
-
return obj;
|
|
15071
|
-
}
|
|
15072
15140
|
var program2 = new Command();
|
|
15073
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) => {
|
|
15074
|
-
let
|
|
15142
|
+
let codexConfig = void 0;
|
|
15143
|
+
let fileConfig = void 0;
|
|
15075
15144
|
try {
|
|
15076
|
-
const
|
|
15077
|
-
|
|
15078
|
-
|
|
15079
|
-
|
|
15080
|
-
|
|
15081
|
-
// Preserve file section if present (for file plugin integration)
|
|
15082
|
-
file: rawConfig.file
|
|
15083
|
-
};
|
|
15084
|
-
} else {
|
|
15085
|
-
config = rawConfig || {};
|
|
15086
|
-
}
|
|
15087
|
-
config = expandEnvVars(config);
|
|
15145
|
+
const unifiedConfig = await readUnifiedConfig(options.config, {
|
|
15146
|
+
expandEnv: true
|
|
15147
|
+
});
|
|
15148
|
+
codexConfig = unifiedConfig.codex;
|
|
15149
|
+
fileConfig = unifiedConfig.file;
|
|
15088
15150
|
} catch (error) {
|
|
15151
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
15089
15152
|
if (options.config !== ".fractary/config.yaml") {
|
|
15090
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
|
+
}
|
|
15091
15159
|
}
|
|
15092
15160
|
}
|
|
15093
|
-
const storageConfig = {
|
|
15094
|
-
|
|
15095
|
-
|
|
15096
|
-
|
|
15161
|
+
const storageConfig = {};
|
|
15162
|
+
if (codexConfig?.storage) {
|
|
15163
|
+
Object.assign(storageConfig, { providers: codexConfig.storage });
|
|
15164
|
+
}
|
|
15165
|
+
if (codexConfig?.archive) {
|
|
15097
15166
|
storageConfig.s3Archive = {
|
|
15098
|
-
projects:
|
|
15167
|
+
projects: codexConfig.archive.projects || {},
|
|
15099
15168
|
fractaryCli: process.env.FRACTARY_CLI || "fractary"
|
|
15100
15169
|
};
|
|
15101
15170
|
}
|
|
15171
|
+
if (fileConfig) {
|
|
15172
|
+
storageConfig.file = fileConfig;
|
|
15173
|
+
}
|
|
15102
15174
|
const storage = createStorageManager(storageConfig);
|
|
15103
15175
|
const cache = createCacheManager({
|
|
15104
|
-
cacheDir:
|
|
15105
|
-
...
|
|
15176
|
+
cacheDir: codexConfig?.cacheDir || codexConfig?.cache?.cacheDir || ".fractary/codex/cache",
|
|
15177
|
+
...codexConfig?.cache || {}
|
|
15106
15178
|
});
|
|
15107
15179
|
if (storage) {
|
|
15108
15180
|
cache.setStorageManager(storage);
|