@fractary/codex 0.11.2 → 0.12.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 +43 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +43 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1865,7 +1865,9 @@ declare class SyncManager {
|
|
|
1865
1865
|
getOrCreateManifest(org: string, project: string): Promise<SyncManifest>;
|
|
1866
1866
|
listLocalFiles(directory: string): Promise<FileInfo[]>;
|
|
1867
1867
|
createPlan(_org: string, _project: string, sourceDir: string, targetFiles: FileInfo[], options?: SyncOptions): Promise<SyncPlan>;
|
|
1868
|
-
createRoutingAwarePlan(org: string, project: string, codexDir: string, options?: SyncOptions
|
|
1868
|
+
createRoutingAwarePlan(org: string, project: string, codexDir: string, options?: SyncOptions & {
|
|
1869
|
+
codexRepo?: string;
|
|
1870
|
+
}): Promise<SyncPlan & {
|
|
1869
1871
|
routingScan?: RoutingScanResult;
|
|
1870
1872
|
}>;
|
|
1871
1873
|
executePlan(plan: SyncPlan, options?: SyncOptions): Promise<SyncResult>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1865,7 +1865,9 @@ declare class SyncManager {
|
|
|
1865
1865
|
getOrCreateManifest(org: string, project: string): Promise<SyncManifest>;
|
|
1866
1866
|
listLocalFiles(directory: string): Promise<FileInfo[]>;
|
|
1867
1867
|
createPlan(_org: string, _project: string, sourceDir: string, targetFiles: FileInfo[], options?: SyncOptions): Promise<SyncPlan>;
|
|
1868
|
-
createRoutingAwarePlan(org: string, project: string, codexDir: string, options?: SyncOptions
|
|
1868
|
+
createRoutingAwarePlan(org: string, project: string, codexDir: string, options?: SyncOptions & {
|
|
1869
|
+
codexRepo?: string;
|
|
1870
|
+
}): Promise<SyncPlan & {
|
|
1869
1871
|
routingScan?: RoutingScanResult;
|
|
1870
1872
|
}>;
|
|
1871
1873
|
executePlan(plan: SyncPlan, options?: SyncOptions): Promise<SyncResult>;
|
package/dist/index.js
CHANGED
|
@@ -63,11 +63,14 @@ function matchToCodexPattern(filePath, patterns) {
|
|
|
63
63
|
}
|
|
64
64
|
return patterns.some((pattern) => matchPattern(pattern, filePath));
|
|
65
65
|
}
|
|
66
|
-
function matchFromCodexPattern(codexFilePath, patterns, targetProject) {
|
|
66
|
+
function matchFromCodexPattern(codexFilePath, patterns, targetProject, options) {
|
|
67
67
|
if (!patterns || patterns.length === 0) {
|
|
68
68
|
return false;
|
|
69
69
|
}
|
|
70
70
|
return patterns.some((pattern) => {
|
|
71
|
+
if (pattern.startsWith(CODEX_URI_PREFIX2)) {
|
|
72
|
+
return matchCodexUri(pattern, codexFilePath, targetProject, options);
|
|
73
|
+
}
|
|
71
74
|
if (pattern.startsWith("projects/")) {
|
|
72
75
|
return matchPattern(pattern, codexFilePath);
|
|
73
76
|
}
|
|
@@ -85,6 +88,21 @@ function matchFromCodexPattern(codexFilePath, patterns, targetProject) {
|
|
|
85
88
|
}
|
|
86
89
|
});
|
|
87
90
|
}
|
|
91
|
+
function matchCodexUri(uriPattern, codexFilePath, targetProject, options) {
|
|
92
|
+
let withoutPrefix = uriPattern.slice(CODEX_URI_PREFIX2.length);
|
|
93
|
+
withoutPrefix = withoutPrefix.replace(/{org}/g, options?.org || "").replace(/{project}/g, targetProject).replace(/{codex_repo}/g, options?.codexRepo || "");
|
|
94
|
+
const parts = withoutPrefix.split("/");
|
|
95
|
+
if (parts.length < 2) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
const project = parts[1];
|
|
99
|
+
const pathPattern = parts.slice(2).join("/");
|
|
100
|
+
if (!project) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
const fullPattern = pathPattern ? `projects/${project}/${pathPattern}` : `projects/${project}/**`;
|
|
104
|
+
return matchPattern(fullPattern, codexFilePath);
|
|
105
|
+
}
|
|
88
106
|
function extractProjectFromCodexPath(codexFilePath) {
|
|
89
107
|
const firstSlashIndex = codexFilePath.indexOf("/");
|
|
90
108
|
if (firstSlashIndex === -1) {
|
|
@@ -99,15 +117,26 @@ function getRelativePath(codexFilePath) {
|
|
|
99
117
|
}
|
|
100
118
|
return codexFilePath.substring(firstSlashIndex + 1);
|
|
101
119
|
}
|
|
102
|
-
function expandPlaceholders(patterns, targetProject) {
|
|
120
|
+
function expandPlaceholders(patterns, targetProject, options) {
|
|
103
121
|
if (!patterns) {
|
|
104
122
|
return patterns;
|
|
105
123
|
}
|
|
106
|
-
return patterns.map((pattern) =>
|
|
124
|
+
return patterns.map((pattern) => {
|
|
125
|
+
let expanded = pattern.replace(/{project}/g, targetProject);
|
|
126
|
+
if (options?.org) {
|
|
127
|
+
expanded = expanded.replace(/{org}/g, options.org);
|
|
128
|
+
}
|
|
129
|
+
if (options?.codexRepo) {
|
|
130
|
+
expanded = expanded.replace(/{codex_repo}/g, options.codexRepo);
|
|
131
|
+
}
|
|
132
|
+
return expanded;
|
|
133
|
+
});
|
|
107
134
|
}
|
|
135
|
+
var CODEX_URI_PREFIX2;
|
|
108
136
|
var init_directional_patterns = __esm({
|
|
109
137
|
"src/sync/directional-patterns.ts"() {
|
|
110
138
|
init_matcher();
|
|
139
|
+
CODEX_URI_PREFIX2 = "codex://";
|
|
111
140
|
}
|
|
112
141
|
});
|
|
113
142
|
|
|
@@ -3505,6 +3534,7 @@ async function scanCodexWithRouting(options) {
|
|
|
3505
3534
|
codexDir,
|
|
3506
3535
|
targetProject,
|
|
3507
3536
|
org,
|
|
3537
|
+
codexRepo,
|
|
3508
3538
|
rules,
|
|
3509
3539
|
storage,
|
|
3510
3540
|
skipNoFrontmatter = false,
|
|
@@ -3523,7 +3553,10 @@ async function scanCodexWithRouting(options) {
|
|
|
3523
3553
|
if (fromCodexPatterns && fromCodexPatterns.length > 0) {
|
|
3524
3554
|
const module = await Promise.resolve().then(() => (init_directional_patterns(), directional_patterns_exports));
|
|
3525
3555
|
matchFromCodexPattern2 = module.matchFromCodexPattern;
|
|
3526
|
-
expandedFromCodexPatterns = module.expandPlaceholders(fromCodexPatterns, targetProject
|
|
3556
|
+
expandedFromCodexPatterns = module.expandPlaceholders(fromCodexPatterns, targetProject, {
|
|
3557
|
+
org,
|
|
3558
|
+
codexRepo
|
|
3559
|
+
});
|
|
3527
3560
|
}
|
|
3528
3561
|
const allFiles = await listAllFilesRecursive(codexDir);
|
|
3529
3562
|
for (const filePath of allFiles) {
|
|
@@ -3545,7 +3578,10 @@ async function scanCodexWithRouting(options) {
|
|
|
3545
3578
|
let parseResult = null;
|
|
3546
3579
|
const useFrontmatter = options.routing?.use_frontmatter === true;
|
|
3547
3580
|
if (matchFromCodexPattern2 && expandedFromCodexPatterns && expandedFromCodexPatterns.length > 0) {
|
|
3548
|
-
shouldSync = matchFromCodexPattern2(filePath, expandedFromCodexPatterns, targetProject
|
|
3581
|
+
shouldSync = matchFromCodexPattern2(filePath, expandedFromCodexPatterns, targetProject, {
|
|
3582
|
+
org,
|
|
3583
|
+
codexRepo
|
|
3584
|
+
});
|
|
3549
3585
|
parseResult = parseMetadata(content, { strict: false });
|
|
3550
3586
|
} else if (useFrontmatter) {
|
|
3551
3587
|
parseResult = parseMetadata(content, { strict: false });
|
|
@@ -3826,6 +3862,8 @@ var SyncManager = class {
|
|
|
3826
3862
|
codexDir,
|
|
3827
3863
|
targetProject: project,
|
|
3828
3864
|
org,
|
|
3865
|
+
codexRepo: options?.codexRepo,
|
|
3866
|
+
// For codex:// URI {codex_repo} placeholder
|
|
3829
3867
|
rules: void 0,
|
|
3830
3868
|
// Use default routing rules (preventSelfSync, preventCodexSync, etc.)
|
|
3831
3869
|
storage: this.localStorage,
|