@synchronized-studio/cmsassets-agent 0.1.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 ADDED
@@ -0,0 +1,152 @@
1
+ import {
2
+ AiFileResult,
3
+ AiReviewReport,
4
+ ApplyReport,
5
+ CmsInfo,
6
+ CmsType,
7
+ Confidence,
8
+ FilePatch,
9
+ FrameworkInfo,
10
+ FrameworkName,
11
+ InjectionCandidate,
12
+ InjectionType,
13
+ PackageManager,
14
+ PatchPlan,
15
+ PatchedFileReport,
16
+ ScanResult,
17
+ VerifyProfile,
18
+ VerifyReport,
19
+ applyPlan,
20
+ createPlan,
21
+ createReport,
22
+ gitOps,
23
+ loadPlanFile,
24
+ savePlanFile,
25
+ saveReport,
26
+ scan,
27
+ verify
28
+ } from "./chunk-J6E3CMX6.js";
29
+ import {
30
+ aiReviewAll
31
+ } from "./chunk-R6XRR66U.js";
32
+ import "./chunk-645ASJ55.js";
33
+ import "./chunk-QGM4M3NI.js";
34
+
35
+ // src/engine.ts
36
+ async function runFullPipeline(opts) {
37
+ const root = opts.projectRoot;
38
+ const scanResult = scan(root);
39
+ if (opts.cmsOverride) {
40
+ scanResult.cms.type = opts.cmsOverride;
41
+ }
42
+ if (opts.paramsOverride) {
43
+ Object.assign(scanResult.cms.params, opts.paramsOverride);
44
+ }
45
+ const plan = createPlan(scanResult);
46
+ if (opts.slug) {
47
+ plan.env.placeholder = `https://${opts.slug}.cmsassets.com`;
48
+ }
49
+ if (opts.allowLlmFallback) {
50
+ plan.policies.allowLlmFallback = true;
51
+ }
52
+ if (opts.verifyProfile) {
53
+ plan.policies.verifyProfile = opts.verifyProfile;
54
+ }
55
+ let planFilePath;
56
+ if (opts.savePlan) {
57
+ planFilePath = savePlanFile(root, plan);
58
+ }
59
+ let previousCommit = null;
60
+ if (opts.gitBranch && gitOps.isGitRepo(root)) {
61
+ previousCommit = gitOps.getHeadCommit(root);
62
+ gitOps.createBranch(root, `cmsassets-agent/integrate-${Date.now()}`);
63
+ }
64
+ const applyReport = await applyPlan(plan, {
65
+ dryRun: opts.dryRun ?? false,
66
+ includeTests: opts.includeTests ?? false,
67
+ maxFiles: opts.maxFiles
68
+ });
69
+ if (opts.gitCommit && gitOps.isGitRepo(root) && !opts.dryRun) {
70
+ gitOps.stageAll(root);
71
+ const applied = applyReport.files.filter((f) => f.applied).length;
72
+ const hash = gitOps.commit(
73
+ root,
74
+ `chore(cmsassets-agent): integrate response transformer (${applied} files)`
75
+ );
76
+ if (hash) {
77
+ applyReport.gitBranch = gitOps.getCurrentBranch(root);
78
+ applyReport.gitCommit = hash;
79
+ }
80
+ }
81
+ let aiReview;
82
+ if (opts.aiVerify && !opts.dryRun) {
83
+ const appliedFiles = applyReport.files.filter((f) => f.applied).map((f) => f.filePath);
84
+ if (appliedFiles.length > 0) {
85
+ aiReview = await aiReviewAll(root, appliedFiles, plan, {
86
+ maxIterations: opts.aiMaxIterations ?? 3,
87
+ model: opts.aiModel ?? "gpt-4o"
88
+ });
89
+ if (aiReview.filesFixed > 0 && opts.gitCommit && gitOps.isGitRepo(root)) {
90
+ gitOps.stageAll(root);
91
+ gitOps.commit(root, "chore(cmsassets-agent): AI-verified fixes for missed transforms");
92
+ }
93
+ }
94
+ }
95
+ let verifyReport;
96
+ if (!opts.dryRun) {
97
+ verifyReport = verify(root, {
98
+ profile: plan.policies.verifyProfile,
99
+ framework: scanResult.framework.name,
100
+ patchedFiles: applyReport.files.filter((f) => f.applied).map((f) => f.filePath)
101
+ });
102
+ }
103
+ const report = createReport({
104
+ scan: scanResult,
105
+ plan,
106
+ apply: applyReport,
107
+ verify: verifyReport,
108
+ aiReview
109
+ });
110
+ let reportFilePath;
111
+ if (opts.saveReport && !opts.dryRun) {
112
+ reportFilePath = saveReport(root, report);
113
+ }
114
+ return {
115
+ scan: scanResult,
116
+ plan,
117
+ report,
118
+ aiReview,
119
+ planFilePath,
120
+ reportFilePath
121
+ };
122
+ }
123
+ export {
124
+ AiFileResult,
125
+ AiReviewReport,
126
+ ApplyReport,
127
+ CmsInfo,
128
+ CmsType,
129
+ Confidence,
130
+ FilePatch,
131
+ FrameworkInfo,
132
+ FrameworkName,
133
+ InjectionCandidate,
134
+ InjectionType,
135
+ PackageManager,
136
+ PatchPlan,
137
+ PatchedFileReport,
138
+ ScanResult,
139
+ VerifyProfile,
140
+ VerifyReport,
141
+ aiReviewAll,
142
+ applyPlan,
143
+ createPlan,
144
+ createReport,
145
+ gitOps,
146
+ loadPlanFile,
147
+ runFullPipeline,
148
+ savePlanFile,
149
+ saveReport,
150
+ scan,
151
+ verify
152
+ };