@fractary/codex-mcp 0.7.1 → 0.9.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/dist/index.cjs CHANGED
@@ -9482,6 +9482,7 @@ var safeLoadAll = renamed("safeLoadAll", "loadAll");
9482
9482
  var safeDump = renamed("safeDump", "dump");
9483
9483
 
9484
9484
  // ../../sdk/js/dist/index.js
9485
+ var import_util4 = require("util");
9485
9486
  var __defProp2 = Object.defineProperty;
9486
9487
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
9487
9488
  var __esm2 = (fn, res) => function __init() {
@@ -9731,9 +9732,45 @@ function resolveReference(uri, options = {}) {
9731
9732
  };
9732
9733
  if (isCurrentProject && parsed.path) {
9733
9734
  resolved.localPath = parsed.path;
9735
+ if (options.config) {
9736
+ const fileSource = detectFilePluginSource(parsed.path, options.config);
9737
+ if (fileSource) {
9738
+ resolved.sourceType = "file-plugin";
9739
+ resolved.filePluginSource = fileSource.name;
9740
+ resolved.localPath = fileSource.fullPath;
9741
+ }
9742
+ }
9734
9743
  }
9735
9744
  return resolved;
9736
9745
  }
9746
+ function detectFilePluginSource(filePath, config) {
9747
+ if (!config?.file?.sources) {
9748
+ return null;
9749
+ }
9750
+ for (const [sourceName, source] of Object.entries(config.file.sources)) {
9751
+ const basePath = source.local?.base_path;
9752
+ if (!basePath) {
9753
+ continue;
9754
+ }
9755
+ const normalizedPath = filePath.replace(/^\.\//, "").replace(/^\//, "");
9756
+ const normalizedBasePath = basePath.replace(/^\.\//, "").replace(/^\//, "").replace(/\/$/, "");
9757
+ if (normalizedPath.startsWith(normalizedBasePath)) {
9758
+ return {
9759
+ name: sourceName,
9760
+ fullPath: import_path.default.join(basePath, normalizedPath.substring(normalizedBasePath.length).replace(/^\//, ""))
9761
+ };
9762
+ }
9763
+ const sourceNameInPath = normalizedBasePath.split("/").pop();
9764
+ if (sourceNameInPath && normalizedPath.startsWith(sourceNameInPath + "/")) {
9765
+ const pathWithoutSource = normalizedPath.substring(sourceNameInPath.length + 1);
9766
+ return {
9767
+ name: sourceName,
9768
+ fullPath: import_path.default.join(basePath, pathWithoutSource)
9769
+ };
9770
+ }
9771
+ }
9772
+ return null;
9773
+ }
9737
9774
  var TTL = {
9738
9775
  ONE_HOUR: 3600,
9739
9776
  ONE_DAY: 86400,
@@ -9882,6 +9919,16 @@ var DirectionalSyncSchema = external_exports.object({
9882
9919
  default_to_codex: external_exports.array(external_exports.string()).optional(),
9883
9920
  default_from_codex: external_exports.array(external_exports.string()).optional()
9884
9921
  });
9922
+ var ArchiveProjectConfigSchema = external_exports.object({
9923
+ enabled: external_exports.boolean(),
9924
+ handler: external_exports.enum(["s3", "r2", "gcs", "local"]),
9925
+ bucket: external_exports.string().optional(),
9926
+ prefix: external_exports.string().optional(),
9927
+ patterns: external_exports.array(external_exports.string()).optional()
9928
+ });
9929
+ var ArchiveConfigSchema = external_exports.object({
9930
+ projects: external_exports.record(ArchiveProjectConfigSchema)
9931
+ });
9885
9932
  var CodexConfigSchema = external_exports.object({
9886
9933
  organizationSlug: external_exports.string(),
9887
9934
  directories: external_exports.object({
@@ -9891,8 +9938,45 @@ var CodexConfigSchema = external_exports.object({
9891
9938
  }).optional(),
9892
9939
  rules: SyncRulesSchema.optional(),
9893
9940
  // Directional sync configuration
9894
- sync: DirectionalSyncSchema.optional()
9941
+ sync: DirectionalSyncSchema.optional(),
9942
+ // Archive configuration
9943
+ archive: ArchiveConfigSchema.optional()
9895
9944
  }).strict();
9945
+ var FileSourceSchema = external_exports.object({
9946
+ type: external_exports.enum(["s3", "r2", "gcs", "local"]),
9947
+ bucket: external_exports.string().optional(),
9948
+ prefix: external_exports.string().optional(),
9949
+ region: external_exports.string().optional(),
9950
+ local: external_exports.object({
9951
+ base_path: external_exports.string()
9952
+ }),
9953
+ push: external_exports.object({
9954
+ compress: external_exports.boolean().optional(),
9955
+ keep_local: external_exports.boolean().optional()
9956
+ }).optional(),
9957
+ auth: external_exports.object({
9958
+ profile: external_exports.string().optional()
9959
+ }).optional()
9960
+ }).refine(
9961
+ (data) => {
9962
+ if (data.type !== "local" && !data.bucket) {
9963
+ return false;
9964
+ }
9965
+ return true;
9966
+ },
9967
+ {
9968
+ message: "Bucket is required for s3, r2, and gcs storage types",
9969
+ path: ["bucket"]
9970
+ }
9971
+ );
9972
+ var FileConfigSchema = external_exports.object({
9973
+ schema_version: external_exports.string(),
9974
+ sources: external_exports.record(FileSourceSchema)
9975
+ });
9976
+ external_exports.object({
9977
+ file: FileConfigSchema.optional(),
9978
+ codex: CodexConfigSchema.optional()
9979
+ });
9896
9980
  init_matcher();
9897
9981
  init_matcher();
9898
9982
  var DEFAULT_FETCH_OPTIONS = {
@@ -9905,6 +9989,7 @@ var DEFAULT_FETCH_OPTIONS = {
9905
9989
  maxSize: 10 * 1024 * 1024
9906
9990
  // 10MB
9907
9991
  };
9992
+ var execFileAsync = (0, import_util4.promisify)(import_child_process.execFile);
9908
9993
 
9909
9994
  // src/tools.ts
9910
9995
  init_cjs_shims();
@@ -9995,6 +10080,14 @@ var CODEX_TOOLS = [
9995
10080
  },
9996
10081
  required: ["pattern"]
9997
10082
  }
10083
+ },
10084
+ {
10085
+ name: "codex_file_sources_list",
10086
+ description: "List file plugin sources available in the current project.",
10087
+ inputSchema: {
10088
+ type: "object",
10089
+ properties: {}
10090
+ }
9998
10091
  }
9999
10092
  ];
10000
10093
  function textResult(text, isError = false) {
@@ -10031,9 +10124,12 @@ async function handleFetch(args, ctx) {
10031
10124
  }
10032
10125
  try {
10033
10126
  let result;
10127
+ const isFilePlugin = ref.isCurrentProject && ref.sourceType === "file-plugin";
10034
10128
  if (noCache) {
10035
10129
  result = await ctx.storage.fetch(ref, { branch });
10036
- await ctx.cache.set(uri, result);
10130
+ if (!isFilePlugin) {
10131
+ await ctx.cache.set(uri, result);
10132
+ }
10037
10133
  } else {
10038
10134
  result = await ctx.cache.get(ref, { branch });
10039
10135
  }
@@ -10041,6 +10137,10 @@ async function handleFetch(args, ctx) {
10041
10137
  return resourceResult(uri, content, result.contentType);
10042
10138
  } catch (error) {
10043
10139
  const message = error instanceof Error ? error.message : String(error);
10140
+ const errorName = error instanceof Error ? error.name : "Error";
10141
+ if (errorName === "FilePluginFileNotFoundError") {
10142
+ return textResult(message, true);
10143
+ }
10044
10144
  return textResult(`Failed to fetch ${uri}: ${message}`, true);
10045
10145
  }
10046
10146
  }
@@ -10139,6 +10239,33 @@ async function handleCacheClear(args, ctx) {
10139
10239
  return textResult(`Failed to clear cache: ${message}`, true);
10140
10240
  }
10141
10241
  }
10242
+ async function handleFileSourcesList(ctx) {
10243
+ try {
10244
+ const filePluginProvider = ctx.storage.getProvider("file-plugin");
10245
+ if (!filePluginProvider) {
10246
+ return textResult(`No file plugin sources configured.
10247
+
10248
+ To enable file plugin integration, the storage manager must be initialized with filePlugin configuration.
10249
+
10250
+ File plugin sources allow codex to access current project artifacts (specs, logs, etc.) directly from the local filesystem without caching.`);
10251
+ }
10252
+ return textResult(`File plugin provider is configured.
10253
+
10254
+ File plugin sources are available for current project artifact access.
10255
+ Sources are read directly from local filesystem without caching.
10256
+
10257
+ To see available sources, check the unified configuration at:
10258
+ .fractary/config.yaml
10259
+
10260
+ Look for the 'file.sources' section which defines:
10261
+ - specs: .fractary/specs
10262
+ - logs: .fractary/logs
10263
+ - etc.`);
10264
+ } catch (error) {
10265
+ const message = error instanceof Error ? error.message : String(error);
10266
+ return textResult(`Failed to list file sources: ${message}`, true);
10267
+ }
10268
+ }
10142
10269
  async function handleToolCall(name, args, ctx) {
10143
10270
  switch (name) {
10144
10271
  case "codex_document_fetch":
@@ -10149,6 +10276,8 @@ async function handleToolCall(name, args, ctx) {
10149
10276
  return handleList(args, ctx);
10150
10277
  case "codex_cache_clear":
10151
10278
  return handleCacheClear(args, ctx);
10279
+ case "codex_file_sources_list":
10280
+ return handleFileSourcesList(ctx);
10152
10281
  default:
10153
10282
  return textResult(`Unknown tool: ${name}`, true);
10154
10283
  }