@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.cjs +17 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var path3 = require('path');
|
|
4
4
|
var child_process = require('child_process');
|
|
5
|
-
var
|
|
5
|
+
var micromatch3 = require('micromatch');
|
|
6
6
|
var zod = require('zod');
|
|
7
7
|
var yaml = require('js-yaml');
|
|
8
8
|
var fs2 = require('fs/promises');
|
|
@@ -10,7 +10,7 @@ var fs2 = require('fs/promises');
|
|
|
10
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
|
|
12
12
|
var path3__default = /*#__PURE__*/_interopDefault(path3);
|
|
13
|
-
var
|
|
13
|
+
var micromatch3__default = /*#__PURE__*/_interopDefault(micromatch3);
|
|
14
14
|
var yaml__default = /*#__PURE__*/_interopDefault(yaml);
|
|
15
15
|
var fs2__default = /*#__PURE__*/_interopDefault(fs2);
|
|
16
16
|
|
|
@@ -499,7 +499,7 @@ var TypeRegistry = class {
|
|
|
499
499
|
for (const type of sortedTypes) {
|
|
500
500
|
if (type.name === "default") continue;
|
|
501
501
|
for (const pattern of type.patterns) {
|
|
502
|
-
if (
|
|
502
|
+
if (micromatch3__default.default.isMatch(normalizedPath, pattern)) {
|
|
503
503
|
this.patternCache.set(filePath, type.name);
|
|
504
504
|
return type.name;
|
|
505
505
|
}
|
|
@@ -554,7 +554,7 @@ var TypeRegistry = class {
|
|
|
554
554
|
}
|
|
555
555
|
return files.filter((file) => {
|
|
556
556
|
const normalized = file.replace(/\\/g, "/");
|
|
557
|
-
return type.patterns.some((pattern) =>
|
|
557
|
+
return type.patterns.some((pattern) => micromatch3__default.default.isMatch(normalized, pattern));
|
|
558
558
|
});
|
|
559
559
|
}
|
|
560
560
|
/**
|
|
@@ -785,6 +785,12 @@ function normalizeLegacyMetadata(parsed) {
|
|
|
785
785
|
if (parsed.codex?.excludes && !parsed.codex_sync_exclude) {
|
|
786
786
|
normalized.codex_sync_exclude = parsed.codex.excludes;
|
|
787
787
|
}
|
|
788
|
+
if (parsed.codex_sync_includes && !normalized.codex_sync_include) {
|
|
789
|
+
normalized.codex_sync_include = parsed.codex_sync_includes;
|
|
790
|
+
}
|
|
791
|
+
if (parsed.codex_sync_excludes && !normalized.codex_sync_exclude) {
|
|
792
|
+
normalized.codex_sync_exclude = parsed.codex_sync_excludes;
|
|
793
|
+
}
|
|
788
794
|
return normalized;
|
|
789
795
|
}
|
|
790
796
|
function hasFrontmatter(content) {
|
|
@@ -808,7 +814,7 @@ function extractRawFrontmatter(content) {
|
|
|
808
814
|
}
|
|
809
815
|
function matchPattern(pattern, value) {
|
|
810
816
|
if (pattern === value) return true;
|
|
811
|
-
return
|
|
817
|
+
return micromatch3__default.default.isMatch(value, pattern);
|
|
812
818
|
}
|
|
813
819
|
function matchAnyPattern(patterns, value) {
|
|
814
820
|
if (patterns.length === 1 && patterns[0] === "*") {
|
|
@@ -2439,7 +2445,7 @@ var DEFAULT_SYNC_CONFIG = {
|
|
|
2439
2445
|
};
|
|
2440
2446
|
function evaluatePath(path6, rules, direction, defaultExcludes = []) {
|
|
2441
2447
|
for (const pattern of defaultExcludes) {
|
|
2442
|
-
if (
|
|
2448
|
+
if (micromatch3__default.default.isMatch(path6, pattern)) {
|
|
2443
2449
|
return {
|
|
2444
2450
|
path: path6,
|
|
2445
2451
|
shouldSync: false,
|
|
@@ -2452,7 +2458,7 @@ function evaluatePath(path6, rules, direction, defaultExcludes = []) {
|
|
|
2452
2458
|
if (rule.direction && rule.direction !== direction) {
|
|
2453
2459
|
continue;
|
|
2454
2460
|
}
|
|
2455
|
-
if (
|
|
2461
|
+
if (micromatch3__default.default.isMatch(path6, rule.pattern)) {
|
|
2456
2462
|
return {
|
|
2457
2463
|
path: path6,
|
|
2458
2464
|
shouldSync: rule.include,
|
|
@@ -2527,7 +2533,7 @@ function validateRules(rules) {
|
|
|
2527
2533
|
continue;
|
|
2528
2534
|
}
|
|
2529
2535
|
try {
|
|
2530
|
-
|
|
2536
|
+
micromatch3__default.default.isMatch("test", rule.pattern);
|
|
2531
2537
|
} catch {
|
|
2532
2538
|
errors.push(`Rule ${i}: invalid pattern "${rule.pattern}"`);
|
|
2533
2539
|
}
|
|
@@ -2720,7 +2726,7 @@ async function scanCodexWithRouting(options) {
|
|
|
2720
2726
|
org,
|
|
2721
2727
|
rules,
|
|
2722
2728
|
storage,
|
|
2723
|
-
skipNoFrontmatter =
|
|
2729
|
+
skipNoFrontmatter = false,
|
|
2724
2730
|
maxFileSize = 10 * 1024 * 1024
|
|
2725
2731
|
// 10MB default
|
|
2726
2732
|
} = options;
|
|
@@ -2734,10 +2740,6 @@ async function scanCodexWithRouting(options) {
|
|
|
2734
2740
|
for (const filePath of allFiles) {
|
|
2735
2741
|
totalScanned++;
|
|
2736
2742
|
try {
|
|
2737
|
-
if (!filePath.endsWith(".md")) {
|
|
2738
|
-
totalSkipped++;
|
|
2739
|
-
continue;
|
|
2740
|
-
}
|
|
2741
2743
|
const fullPath = path3__default.default.join(codexDir, filePath);
|
|
2742
2744
|
const stats = await fs2__default.default.stat(fullPath);
|
|
2743
2745
|
if (stats.size > maxFileSize) {
|
|
@@ -3140,7 +3142,7 @@ function ruleMatchesContext(rule, context) {
|
|
|
3140
3142
|
return true;
|
|
3141
3143
|
}
|
|
3142
3144
|
function ruleMatchesPath(rule, path6) {
|
|
3143
|
-
return
|
|
3145
|
+
return micromatch3__default.default.isMatch(path6, rule.pattern);
|
|
3144
3146
|
}
|
|
3145
3147
|
function ruleMatchesAction(rule, action) {
|
|
3146
3148
|
return rule.actions.includes(action);
|
|
@@ -3201,7 +3203,7 @@ function validateRules2(rules) {
|
|
|
3201
3203
|
continue;
|
|
3202
3204
|
}
|
|
3203
3205
|
try {
|
|
3204
|
-
|
|
3206
|
+
micromatch3__default.default.isMatch("test", rule.pattern);
|
|
3205
3207
|
} catch {
|
|
3206
3208
|
errors.push(`Rule ${i}: invalid pattern "${rule.pattern}"`);
|
|
3207
3209
|
}
|