@qelos/plugins-cli 0.0.21 → 0.0.22
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/package.json +1 -1
- package/services/file-refs.mjs +22 -15
- package/services/integrations.mjs +24 -1
- package/services/plugins.mjs +46 -1
package/package.json
CHANGED
package/services/file-refs.mjs
CHANGED
|
@@ -134,26 +134,33 @@ export function extractIntegrationContent(integration, integrationPath, fileName
|
|
|
134
134
|
|
|
135
135
|
// Extract the first pre_message content
|
|
136
136
|
const preMessage = updatedIntegration.target.details.pre_messages[0];
|
|
137
|
-
if (preMessage && preMessage.content
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
// Skip if content is empty or just whitespace
|
|
141
|
-
if (!content.trim()) {
|
|
137
|
+
if (preMessage && preMessage.content) {
|
|
138
|
+
// Check if content is already a $ref
|
|
139
|
+
if (typeof preMessage.content === 'object' && preMessage.content.$ref) {
|
|
142
140
|
return updatedIntegration;
|
|
143
141
|
}
|
|
142
|
+
|
|
143
|
+
// Only extract if content is a string
|
|
144
|
+
if (typeof preMessage.content === 'string') {
|
|
145
|
+
const content = preMessage.content;
|
|
146
|
+
|
|
147
|
+
// Skip if content is empty or just whitespace
|
|
148
|
+
if (!content.trim()) {
|
|
149
|
+
return updatedIntegration;
|
|
150
|
+
}
|
|
144
151
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
152
|
+
// Generate filename
|
|
153
|
+
const baseName = path.basename(fileName, '.integration.json');
|
|
154
|
+
const mdFileName = `${baseName}.md`;
|
|
155
|
+
const mdFilePath = path.join(extractDir, mdFileName);
|
|
156
|
+
const relativeRef = `./prompts/${mdFileName}`;
|
|
150
157
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
logger.debug(`Extracted pre_message content to: ${relativeRef}`);
|
|
158
|
+
// Write content to file
|
|
159
|
+
fs.writeFileSync(mdFilePath, content, 'utf-8');
|
|
154
160
|
|
|
155
|
-
|
|
156
|
-
|
|
161
|
+
// Replace with $ref
|
|
162
|
+
updatedIntegration.target.details.pre_messages[0].content = { $ref: relativeRef };
|
|
163
|
+
}
|
|
157
164
|
}
|
|
158
165
|
|
|
159
166
|
return updatedIntegration;
|
|
@@ -76,6 +76,24 @@ function sanitizeIntegrationForFile(integration) {
|
|
|
76
76
|
delete sanitized[field];
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
|
+
|
|
80
|
+
// Remove _id from internal objects
|
|
81
|
+
if (sanitized.trigger && sanitized.trigger._id) {
|
|
82
|
+
delete sanitized.trigger._id;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (sanitized.target && sanitized.target._id) {
|
|
86
|
+
delete sanitized.target._id;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (Array.isArray(sanitized.dataManipulation)) {
|
|
90
|
+
sanitized.dataManipulation.forEach(item => {
|
|
91
|
+
if (item._id) {
|
|
92
|
+
delete item._id;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
79
97
|
return sanitized;
|
|
80
98
|
}
|
|
81
99
|
|
|
@@ -177,8 +195,13 @@ export async function pushIntegrations(sdk, path, options = {}) {
|
|
|
177
195
|
logger.success(`Created: ${displayName}`);
|
|
178
196
|
}
|
|
179
197
|
|
|
198
|
+
// Re-extract content to files to maintain $ref structure
|
|
199
|
+
// This ensures pre_messages are stored as prompt md files after pushing
|
|
200
|
+
const processedResponse = extractIntegrationContent(response, path, file);
|
|
201
|
+
|
|
180
202
|
// Persist returned integration (with _id) back to disk
|
|
181
|
-
writeIntegrationFile(filePath, sanitizeIntegrationForFile(
|
|
203
|
+
writeIntegrationFile(filePath, sanitizeIntegrationForFile(processedResponse));
|
|
204
|
+
|
|
182
205
|
results.push({ status: 'fulfilled' });
|
|
183
206
|
} catch (error) {
|
|
184
207
|
logger.error(`Failed to push integration file ${file}`, error);
|
package/services/plugins.mjs
CHANGED
|
@@ -4,6 +4,48 @@ import { join } from 'node:path';
|
|
|
4
4
|
import { logger } from './logger.mjs';
|
|
5
5
|
import { extractMicroFrontendStructures, resolveMicroFrontendStructures } from './micro-frontends.mjs';
|
|
6
6
|
|
|
7
|
+
function sanitizePluginForFile(plugin) {
|
|
8
|
+
const sanitized = JSON.parse(JSON.stringify(plugin));
|
|
9
|
+
|
|
10
|
+
// Remove _id from internal objects in arrays
|
|
11
|
+
if (Array.isArray(sanitized.subscribedEvents)) {
|
|
12
|
+
sanitized.subscribedEvents.forEach(item => {
|
|
13
|
+
if (item._id) delete item._id;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (Array.isArray(sanitized.microFrontends)) {
|
|
18
|
+
sanitized.microFrontends.forEach(mfe => {
|
|
19
|
+
if (mfe._id) delete mfe._id;
|
|
20
|
+
if (Array.isArray(mfe.requires)) {
|
|
21
|
+
mfe.requires.forEach(item => {
|
|
22
|
+
if (item._id) delete item._id;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (Array.isArray(sanitized.injectables)) {
|
|
29
|
+
sanitized.injectables.forEach(item => {
|
|
30
|
+
if (item._id) delete item._id;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (Array.isArray(sanitized.navBarGroups)) {
|
|
35
|
+
sanitized.navBarGroups.forEach(item => {
|
|
36
|
+
if (item._id) delete item._id;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (Array.isArray(sanitized.cruds)) {
|
|
41
|
+
sanitized.cruds.forEach(item => {
|
|
42
|
+
if (item._id) delete item._id;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return sanitized;
|
|
47
|
+
}
|
|
48
|
+
|
|
7
49
|
/**
|
|
8
50
|
* Push plugins from local directory to remote
|
|
9
51
|
* @param {Object} sdk - Initialized SDK instance
|
|
@@ -179,7 +221,10 @@ export async function pullPlugins(sdk, targetPath) {
|
|
|
179
221
|
cruds: (fullPlugin.cruds || []).map(removeIdFromObject),
|
|
180
222
|
}
|
|
181
223
|
|
|
182
|
-
|
|
224
|
+
// Sanitize the plugin to remove any remaining _id fields from internal objects
|
|
225
|
+
const sanitizedPlugin = sanitizePluginForFile(relevantFields);
|
|
226
|
+
|
|
227
|
+
fs.writeFileSync(filePath, JSON.stringify(sanitizedPlugin, null, 2), 'utf-8');
|
|
183
228
|
logger.step(`Pulled: ${plugin.apiPath}`);
|
|
184
229
|
}));
|
|
185
230
|
|