@fractary/codex 0.3.0 → 0.4.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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import path3 from 'path';
2
2
  import { execSync } from 'child_process';
3
- import micromatch2, { isMatch } from 'micromatch';
3
+ import micromatch3 from 'micromatch';
4
4
  import { z } from 'zod';
5
5
  import yaml from 'js-yaml';
6
6
  import fs2 from 'fs/promises';
@@ -490,7 +490,7 @@ var TypeRegistry = class {
490
490
  for (const type of sortedTypes) {
491
491
  if (type.name === "default") continue;
492
492
  for (const pattern of type.patterns) {
493
- if (micromatch2.isMatch(normalizedPath, pattern)) {
493
+ if (micromatch3.isMatch(normalizedPath, pattern)) {
494
494
  this.patternCache.set(filePath, type.name);
495
495
  return type.name;
496
496
  }
@@ -545,7 +545,7 @@ var TypeRegistry = class {
545
545
  }
546
546
  return files.filter((file) => {
547
547
  const normalized = file.replace(/\\/g, "/");
548
- return type.patterns.some((pattern) => micromatch2.isMatch(normalized, pattern));
548
+ return type.patterns.some((pattern) => micromatch3.isMatch(normalized, pattern));
549
549
  });
550
550
  }
551
551
  /**
@@ -776,6 +776,12 @@ function normalizeLegacyMetadata(parsed) {
776
776
  if (parsed.codex?.excludes && !parsed.codex_sync_exclude) {
777
777
  normalized.codex_sync_exclude = parsed.codex.excludes;
778
778
  }
779
+ if (parsed.codex_sync_includes && !normalized.codex_sync_include) {
780
+ normalized.codex_sync_include = parsed.codex_sync_includes;
781
+ }
782
+ if (parsed.codex_sync_excludes && !normalized.codex_sync_exclude) {
783
+ normalized.codex_sync_exclude = parsed.codex_sync_excludes;
784
+ }
779
785
  return normalized;
780
786
  }
781
787
  function hasFrontmatter(content) {
@@ -799,7 +805,7 @@ function extractRawFrontmatter(content) {
799
805
  }
800
806
  function matchPattern(pattern, value) {
801
807
  if (pattern === value) return true;
802
- return isMatch(value, pattern);
808
+ return micromatch3.isMatch(value, pattern);
803
809
  }
804
810
  function matchAnyPattern(patterns, value) {
805
811
  if (patterns.length === 1 && patterns[0] === "*") {
@@ -2430,7 +2436,7 @@ var DEFAULT_SYNC_CONFIG = {
2430
2436
  };
2431
2437
  function evaluatePath(path6, rules, direction, defaultExcludes = []) {
2432
2438
  for (const pattern of defaultExcludes) {
2433
- if (micromatch2.isMatch(path6, pattern)) {
2439
+ if (micromatch3.isMatch(path6, pattern)) {
2434
2440
  return {
2435
2441
  path: path6,
2436
2442
  shouldSync: false,
@@ -2443,7 +2449,7 @@ function evaluatePath(path6, rules, direction, defaultExcludes = []) {
2443
2449
  if (rule.direction && rule.direction !== direction) {
2444
2450
  continue;
2445
2451
  }
2446
- if (micromatch2.isMatch(path6, rule.pattern)) {
2452
+ if (micromatch3.isMatch(path6, rule.pattern)) {
2447
2453
  return {
2448
2454
  path: path6,
2449
2455
  shouldSync: rule.include,
@@ -2518,7 +2524,7 @@ function validateRules(rules) {
2518
2524
  continue;
2519
2525
  }
2520
2526
  try {
2521
- micromatch2.isMatch("test", rule.pattern);
2527
+ micromatch3.isMatch("test", rule.pattern);
2522
2528
  } catch {
2523
2529
  errors.push(`Rule ${i}: invalid pattern "${rule.pattern}"`);
2524
2530
  }
@@ -2711,7 +2717,7 @@ async function scanCodexWithRouting(options) {
2711
2717
  org,
2712
2718
  rules,
2713
2719
  storage,
2714
- skipNoFrontmatter = true,
2720
+ skipNoFrontmatter = false,
2715
2721
  maxFileSize = 10 * 1024 * 1024
2716
2722
  // 10MB default
2717
2723
  } = options;
@@ -2725,10 +2731,6 @@ async function scanCodexWithRouting(options) {
2725
2731
  for (const filePath of allFiles) {
2726
2732
  totalScanned++;
2727
2733
  try {
2728
- if (!filePath.endsWith(".md")) {
2729
- totalSkipped++;
2730
- continue;
2731
- }
2732
2734
  const fullPath = path3.join(codexDir, filePath);
2733
2735
  const stats = await fs2.stat(fullPath);
2734
2736
  if (stats.size > maxFileSize) {
@@ -3131,7 +3133,7 @@ function ruleMatchesContext(rule, context) {
3131
3133
  return true;
3132
3134
  }
3133
3135
  function ruleMatchesPath(rule, path6) {
3134
- return micromatch2.isMatch(path6, rule.pattern);
3136
+ return micromatch3.isMatch(path6, rule.pattern);
3135
3137
  }
3136
3138
  function ruleMatchesAction(rule, action) {
3137
3139
  return rule.actions.includes(action);
@@ -3192,7 +3194,7 @@ function validateRules2(rules) {
3192
3194
  continue;
3193
3195
  }
3194
3196
  try {
3195
- micromatch2.isMatch("test", rule.pattern);
3197
+ micromatch3.isMatch("test", rule.pattern);
3196
3198
  } catch {
3197
3199
  errors.push(`Rule ${i}: invalid pattern "${rule.pattern}"`);
3198
3200
  }