@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/README.md
CHANGED
|
@@ -157,7 +157,8 @@ Addon 可在 `addon.json` 中声明安装后的运行配置要求:
|
|
|
157
157
|
显式接入指导:
|
|
158
158
|
|
|
159
159
|
- Addon 包根目录可以放 `PROMPT.md`
|
|
160
|
-
- `PROMPT.md`
|
|
160
|
+
- `PROMPT.md` 不会进入发布安装包;发布时会作为版本提示词元数据保存。安装/升级后会写入 `src/addons/<addon-name>/PROMPT.md`,并在 `src/addons/<addon-name>/meta.json` 中记录 `guidance.prompt.path` 和 `contentHash`
|
|
161
|
+
- 安装/升级结果的 `llmGuidance.prompt` 会返回提示词内容;后续 `addon list --json` 也会读取已安装 Addon 目录中的 `PROMPT.md` 并返回 `guidance.prompt.content`
|
|
161
162
|
- 如果 Addon 本身就是一个 skill 资源,应在 `addon.json.members` 中显式声明 `type: "skill"`;普通 Addon 的根 `PROMPT.md` 只作为模型指导
|
|
162
163
|
|
|
163
164
|
升级策略:
|
package/dist/cli.cjs
CHANGED
|
@@ -992,6 +992,7 @@ async function tryDetectNearestApplicationType(startDir = process.cwd()) {
|
|
|
992
992
|
|
|
993
993
|
// src/marketplace/install.ts
|
|
994
994
|
var execFileAsync = util.promisify(child_process.execFile);
|
|
995
|
+
var ADDON_PROMPT_FILE_NAME = "PROMPT.md";
|
|
995
996
|
var AddonInstallConflictError = class extends Error {
|
|
996
997
|
constructor(input) {
|
|
997
998
|
super(`Addon ${input.operation} has ${input.conflicts.length} conflict(s)`);
|
|
@@ -1236,6 +1237,7 @@ function buildAddonLlmGuidance(input) {
|
|
|
1236
1237
|
paths: member.settings?.paths.map((item) => item.path) || []
|
|
1237
1238
|
}));
|
|
1238
1239
|
const display = resolveInstalledAddonDisplay(input.meta);
|
|
1240
|
+
const promptContent = input.meta.guidance?.prompt?.content ?? input.promptContent;
|
|
1239
1241
|
const instructions = [
|
|
1240
1242
|
"Use the installed Addon files in the host application's existing pages, components, routes, dialogs, or preview areas.",
|
|
1241
1243
|
"Do not reinstall to complete integration; edit application source files directly."
|
|
@@ -1263,7 +1265,7 @@ function buildAddonLlmGuidance(input) {
|
|
|
1263
1265
|
return {
|
|
1264
1266
|
summary: display.description || display.title || `Installed addon ${input.meta.name}@${input.meta.version}.`,
|
|
1265
1267
|
instructions,
|
|
1266
|
-
prompt:
|
|
1268
|
+
prompt: promptContent ? { path: getAddonPromptTargetPath(input.meta.name), content: promptContent } : void 0,
|
|
1267
1269
|
webRoutes: webRoutes.length ? webRoutes : void 0,
|
|
1268
1270
|
miniPages: miniPages.length ? miniPages : void 0,
|
|
1269
1271
|
components: components.length ? components : void 0,
|
|
@@ -1277,11 +1279,35 @@ function buildAddonLlmGuidance(input) {
|
|
|
1277
1279
|
function getAddonMetaPath(targetDir, addonName) {
|
|
1278
1280
|
return path.join(targetDir, "src", "addons", addonName, "meta.json");
|
|
1279
1281
|
}
|
|
1282
|
+
function getAddonPromptTargetPath(addonName) {
|
|
1283
|
+
return `src/addons/${addonName}/${ADDON_PROMPT_FILE_NAME}`;
|
|
1284
|
+
}
|
|
1285
|
+
async function hydrateInstalledAddonPrompt(metaPath, meta) {
|
|
1286
|
+
const prompt = meta.guidance?.prompt;
|
|
1287
|
+
if (!prompt?.path || prompt.content) {
|
|
1288
|
+
return meta;
|
|
1289
|
+
}
|
|
1290
|
+
const promptPath = ensurePathInsideTarget(path.dirname(metaPath), prompt.path);
|
|
1291
|
+
if (!fs.existsSync(promptPath)) {
|
|
1292
|
+
return meta;
|
|
1293
|
+
}
|
|
1294
|
+
return {
|
|
1295
|
+
...meta,
|
|
1296
|
+
guidance: {
|
|
1297
|
+
...meta.guidance,
|
|
1298
|
+
prompt: {
|
|
1299
|
+
...prompt,
|
|
1300
|
+
content: (await promises$1.readFile(promptPath, "utf8")).trim()
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1280
1305
|
async function readInstalledAddonMeta(metaPath) {
|
|
1281
1306
|
if (!fs.existsSync(metaPath)) {
|
|
1282
1307
|
return null;
|
|
1283
1308
|
}
|
|
1284
|
-
|
|
1309
|
+
const meta = JSON.parse(await promises$1.readFile(metaPath, "utf8"));
|
|
1310
|
+
return await hydrateInstalledAddonPrompt(metaPath, meta);
|
|
1285
1311
|
}
|
|
1286
1312
|
async function listAddonMetaPaths(targetDir) {
|
|
1287
1313
|
const addonsDir = path.join(targetDir, "src", "addons");
|
|
@@ -1605,6 +1631,12 @@ function buildInstalledAddonMeta(options) {
|
|
|
1605
1631
|
installParameters: options.installParameters,
|
|
1606
1632
|
requirements: resolveInstallRequirements(options.manifest),
|
|
1607
1633
|
npm: resolveInstallNpm(options.manifest),
|
|
1634
|
+
guidance: options.promptContent ? {
|
|
1635
|
+
prompt: {
|
|
1636
|
+
path: ADDON_PROMPT_FILE_NAME,
|
|
1637
|
+
contentHash: sha256Buffer(Buffer.from(options.promptContent))
|
|
1638
|
+
}
|
|
1639
|
+
} : void 0,
|
|
1608
1640
|
members: options.members,
|
|
1609
1641
|
files: options.files
|
|
1610
1642
|
};
|
|
@@ -1619,6 +1651,20 @@ async function writePlannedFiles(targetDir, planFiles) {
|
|
|
1619
1651
|
await promises$1.copyFile(file.sourcePath, absoluteTargetPath);
|
|
1620
1652
|
}
|
|
1621
1653
|
}
|
|
1654
|
+
async function writeAddonPromptFile(targetDir, addonName, promptContent) {
|
|
1655
|
+
const promptTargetPath = getAddonPromptTargetPath(addonName);
|
|
1656
|
+
const absolutePromptPath = ensurePathInsideTarget(targetDir, promptTargetPath);
|
|
1657
|
+
if (promptContent) {
|
|
1658
|
+
await ensureParentDirectory(absolutePromptPath);
|
|
1659
|
+
await promises$1.writeFile(absolutePromptPath, promptContent);
|
|
1660
|
+
return { writtenFiles: [promptTargetPath], removedFiles: [] };
|
|
1661
|
+
}
|
|
1662
|
+
if (fs.existsSync(absolutePromptPath)) {
|
|
1663
|
+
await promises$1.unlink(absolutePromptPath);
|
|
1664
|
+
return { writtenFiles: [], removedFiles: [promptTargetPath] };
|
|
1665
|
+
}
|
|
1666
|
+
return { writtenFiles: [], removedFiles: [] };
|
|
1667
|
+
}
|
|
1622
1668
|
function isPlainObject(value) {
|
|
1623
1669
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1624
1670
|
}
|
|
@@ -2122,6 +2168,8 @@ async function materializeAddon(options) {
|
|
|
2122
2168
|
const packageJsonFiles = await applyNpmDependencies(targetDir, npm);
|
|
2123
2169
|
await writePlannedFiles(targetDir, plan.files);
|
|
2124
2170
|
const settingsResult = await applyPlannedSettings(targetDir, plan.settings);
|
|
2171
|
+
const promptContent = options.promptContent?.trim() || void 0;
|
|
2172
|
+
const promptFiles = await writeAddonPromptFile(targetDir, plan.manifest.name, promptContent);
|
|
2125
2173
|
const installedFiles = [];
|
|
2126
2174
|
for (const plannedFile of plan.files) {
|
|
2127
2175
|
installedFiles.push(
|
|
@@ -2136,6 +2184,7 @@ async function materializeAddon(options) {
|
|
|
2136
2184
|
installParameters: plan.installParameters,
|
|
2137
2185
|
members: attachAppliedSettings(plan.members, settingsResult.appliedSettings),
|
|
2138
2186
|
files: installedFiles,
|
|
2187
|
+
promptContent,
|
|
2139
2188
|
installedAt: previousMeta?.installedAt
|
|
2140
2189
|
});
|
|
2141
2190
|
await ensureParentDirectory(plan.metaPath);
|
|
@@ -2145,7 +2194,6 @@ async function materializeAddon(options) {
|
|
|
2145
2194
|
await installPackageDependencies(targetDir);
|
|
2146
2195
|
}
|
|
2147
2196
|
const requirements = resolveInstallRequirements(plan.manifest);
|
|
2148
|
-
const promptContent = options.promptContent?.trim() || void 0;
|
|
2149
2197
|
const llmGuidance = buildAddonLlmGuidance({
|
|
2150
2198
|
operation: options.mode,
|
|
2151
2199
|
meta,
|
|
@@ -2155,8 +2203,8 @@ async function materializeAddon(options) {
|
|
|
2155
2203
|
});
|
|
2156
2204
|
return {
|
|
2157
2205
|
meta,
|
|
2158
|
-
writtenFiles: installedFiles.map((file) => file.path).concat(packageJsonFiles, restoredSettingsFiles, settingsResult.writtenFiles),
|
|
2159
|
-
removedFiles,
|
|
2206
|
+
writtenFiles: installedFiles.map((file) => file.path).concat(promptFiles.writtenFiles, packageJsonFiles, restoredSettingsFiles, settingsResult.writtenFiles),
|
|
2207
|
+
removedFiles: removedFiles.concat(promptFiles.removedFiles),
|
|
2160
2208
|
requirements,
|
|
2161
2209
|
missingRequirements: buildMissingRequirements(requirements),
|
|
2162
2210
|
npm,
|