@amaster.ai/cli 1.1.48 → 1.1.50
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/README.md +2 -1
- package/dist/cli.cjs +53 -5
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +53 -5
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -965,6 +965,7 @@ async function tryDetectNearestApplicationType(startDir = process.cwd()) {
|
|
|
965
965
|
|
|
966
966
|
// src/marketplace/install.ts
|
|
967
967
|
var execFileAsync = promisify(execFile);
|
|
968
|
+
var ADDON_PROMPT_FILE_NAME = "PROMPT.md";
|
|
968
969
|
var AddonInstallConflictError = class extends Error {
|
|
969
970
|
constructor(input) {
|
|
970
971
|
super(`Addon ${input.operation} has ${input.conflicts.length} conflict(s)`);
|
|
@@ -1209,6 +1210,7 @@ function buildAddonLlmGuidance(input) {
|
|
|
1209
1210
|
paths: member.settings?.paths.map((item) => item.path) || []
|
|
1210
1211
|
}));
|
|
1211
1212
|
const display = resolveInstalledAddonDisplay(input.meta);
|
|
1213
|
+
const promptContent = input.meta.guidance?.prompt?.content ?? input.promptContent;
|
|
1212
1214
|
const instructions = [
|
|
1213
1215
|
"Use the installed Addon files in the host application's existing pages, components, routes, dialogs, or preview areas.",
|
|
1214
1216
|
"Do not reinstall to complete integration; edit application source files directly."
|
|
@@ -1236,7 +1238,7 @@ function buildAddonLlmGuidance(input) {
|
|
|
1236
1238
|
return {
|
|
1237
1239
|
summary: display.description || display.title || `Installed addon ${input.meta.name}@${input.meta.version}.`,
|
|
1238
1240
|
instructions,
|
|
1239
|
-
prompt:
|
|
1241
|
+
prompt: promptContent ? { path: getAddonPromptTargetPath(input.meta.name), content: promptContent } : void 0,
|
|
1240
1242
|
webRoutes: webRoutes.length ? webRoutes : void 0,
|
|
1241
1243
|
miniPages: miniPages.length ? miniPages : void 0,
|
|
1242
1244
|
components: components.length ? components : void 0,
|
|
@@ -1250,11 +1252,35 @@ function buildAddonLlmGuidance(input) {
|
|
|
1250
1252
|
function getAddonMetaPath(targetDir, addonName) {
|
|
1251
1253
|
return join(targetDir, "src", "addons", addonName, "meta.json");
|
|
1252
1254
|
}
|
|
1255
|
+
function getAddonPromptTargetPath(addonName) {
|
|
1256
|
+
return `src/addons/${addonName}/${ADDON_PROMPT_FILE_NAME}`;
|
|
1257
|
+
}
|
|
1258
|
+
async function hydrateInstalledAddonPrompt(metaPath, meta) {
|
|
1259
|
+
const prompt = meta.guidance?.prompt;
|
|
1260
|
+
if (!prompt?.path || prompt.content) {
|
|
1261
|
+
return meta;
|
|
1262
|
+
}
|
|
1263
|
+
const promptPath = ensurePathInsideTarget(dirname(metaPath), prompt.path);
|
|
1264
|
+
if (!existsSync(promptPath)) {
|
|
1265
|
+
return meta;
|
|
1266
|
+
}
|
|
1267
|
+
return {
|
|
1268
|
+
...meta,
|
|
1269
|
+
guidance: {
|
|
1270
|
+
...meta.guidance,
|
|
1271
|
+
prompt: {
|
|
1272
|
+
...prompt,
|
|
1273
|
+
content: (await readFile(promptPath, "utf8")).trim()
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1253
1278
|
async function readInstalledAddonMeta(metaPath) {
|
|
1254
1279
|
if (!existsSync(metaPath)) {
|
|
1255
1280
|
return null;
|
|
1256
1281
|
}
|
|
1257
|
-
|
|
1282
|
+
const meta = JSON.parse(await readFile(metaPath, "utf8"));
|
|
1283
|
+
return await hydrateInstalledAddonPrompt(metaPath, meta);
|
|
1258
1284
|
}
|
|
1259
1285
|
async function listAddonMetaPaths(targetDir) {
|
|
1260
1286
|
const addonsDir = join(targetDir, "src", "addons");
|
|
@@ -1578,6 +1604,12 @@ function buildInstalledAddonMeta(options) {
|
|
|
1578
1604
|
installParameters: options.installParameters,
|
|
1579
1605
|
requirements: resolveInstallRequirements(options.manifest),
|
|
1580
1606
|
npm: resolveInstallNpm(options.manifest),
|
|
1607
|
+
guidance: options.promptContent ? {
|
|
1608
|
+
prompt: {
|
|
1609
|
+
path: ADDON_PROMPT_FILE_NAME,
|
|
1610
|
+
contentHash: sha256Buffer(Buffer.from(options.promptContent))
|
|
1611
|
+
}
|
|
1612
|
+
} : void 0,
|
|
1581
1613
|
members: options.members,
|
|
1582
1614
|
files: options.files
|
|
1583
1615
|
};
|
|
@@ -1592,6 +1624,20 @@ async function writePlannedFiles(targetDir, planFiles) {
|
|
|
1592
1624
|
await copyFile(file.sourcePath, absoluteTargetPath);
|
|
1593
1625
|
}
|
|
1594
1626
|
}
|
|
1627
|
+
async function writeAddonPromptFile(targetDir, addonName, promptContent) {
|
|
1628
|
+
const promptTargetPath = getAddonPromptTargetPath(addonName);
|
|
1629
|
+
const absolutePromptPath = ensurePathInsideTarget(targetDir, promptTargetPath);
|
|
1630
|
+
if (promptContent) {
|
|
1631
|
+
await ensureParentDirectory(absolutePromptPath);
|
|
1632
|
+
await writeFile(absolutePromptPath, promptContent);
|
|
1633
|
+
return { writtenFiles: [promptTargetPath], removedFiles: [] };
|
|
1634
|
+
}
|
|
1635
|
+
if (existsSync(absolutePromptPath)) {
|
|
1636
|
+
await unlink(absolutePromptPath);
|
|
1637
|
+
return { writtenFiles: [], removedFiles: [promptTargetPath] };
|
|
1638
|
+
}
|
|
1639
|
+
return { writtenFiles: [], removedFiles: [] };
|
|
1640
|
+
}
|
|
1595
1641
|
function isPlainObject(value) {
|
|
1596
1642
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1597
1643
|
}
|
|
@@ -2095,6 +2141,8 @@ async function materializeAddon(options) {
|
|
|
2095
2141
|
const packageJsonFiles = await applyNpmDependencies(targetDir, npm);
|
|
2096
2142
|
await writePlannedFiles(targetDir, plan.files);
|
|
2097
2143
|
const settingsResult = await applyPlannedSettings(targetDir, plan.settings);
|
|
2144
|
+
const promptContent = options.promptContent?.trim() || void 0;
|
|
2145
|
+
const promptFiles = await writeAddonPromptFile(targetDir, plan.manifest.name, promptContent);
|
|
2098
2146
|
const installedFiles = [];
|
|
2099
2147
|
for (const plannedFile of plan.files) {
|
|
2100
2148
|
installedFiles.push(
|
|
@@ -2109,6 +2157,7 @@ async function materializeAddon(options) {
|
|
|
2109
2157
|
installParameters: plan.installParameters,
|
|
2110
2158
|
members: attachAppliedSettings(plan.members, settingsResult.appliedSettings),
|
|
2111
2159
|
files: installedFiles,
|
|
2160
|
+
promptContent,
|
|
2112
2161
|
installedAt: previousMeta?.installedAt
|
|
2113
2162
|
});
|
|
2114
2163
|
await ensureParentDirectory(plan.metaPath);
|
|
@@ -2118,7 +2167,6 @@ async function materializeAddon(options) {
|
|
|
2118
2167
|
await installPackageDependencies(targetDir);
|
|
2119
2168
|
}
|
|
2120
2169
|
const requirements = resolveInstallRequirements(plan.manifest);
|
|
2121
|
-
const promptContent = options.promptContent?.trim() || void 0;
|
|
2122
2170
|
const llmGuidance = buildAddonLlmGuidance({
|
|
2123
2171
|
operation: options.mode,
|
|
2124
2172
|
meta,
|
|
@@ -2128,8 +2176,8 @@ async function materializeAddon(options) {
|
|
|
2128
2176
|
});
|
|
2129
2177
|
return {
|
|
2130
2178
|
meta,
|
|
2131
|
-
writtenFiles: installedFiles.map((file) => file.path).concat(packageJsonFiles, restoredSettingsFiles, settingsResult.writtenFiles),
|
|
2132
|
-
removedFiles,
|
|
2179
|
+
writtenFiles: installedFiles.map((file) => file.path).concat(promptFiles.writtenFiles, packageJsonFiles, restoredSettingsFiles, settingsResult.writtenFiles),
|
|
2180
|
+
removedFiles: removedFiles.concat(promptFiles.removedFiles),
|
|
2133
2181
|
requirements,
|
|
2134
2182
|
missingRequirements: buildMissingRequirements(requirements),
|
|
2135
2183
|
npm,
|