@amaster.ai/cli 1.1.47 → 1.1.49
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 +7 -3
- package/dist/cli.cjs +79 -11
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +79 -11
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,6 +36,7 @@ amaster logout
|
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
38
|
amaster addon search crm
|
|
39
|
+
amaster addon search crm --target /path/to/app
|
|
39
40
|
amaster addon view crm-pages
|
|
40
41
|
amaster addon view crm-pages@1.0.0
|
|
41
42
|
amaster addon versions crm-pages
|
|
@@ -72,9 +73,9 @@ marketplace/screenshots/preview.png
|
|
|
72
73
|
}
|
|
73
74
|
```
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
这些 `marketplace/` 文件只用于发布到 Addon Marketplace,不会被 `addon install` 安装到应用工程。需要随 Addon 安装到应用工程并被代码引用的运行素材,应声明为 `assets` member。
|
|
76
77
|
|
|
77
|
-
`addon search` 在未显式传 `--application-type`
|
|
78
|
+
`addon search` 在未显式传 `--application-type` 时,会从 `--target` 指定目录或当前目录向上查找最近的 `package.json`,读取同级 `app.settings.yml` 的 `type`,并自动按 `web` 或 `mini` 过滤。`addon search --target` 只用于推断应用类型,不会修改目标应用。
|
|
78
79
|
`addon search --json` 返回面向 MCP/AI 的轻量结果,只包含 `name`、`version`、`installSpecifier`、标题、描述、类目、适用类型、阶段、成员类型和主图地址。
|
|
79
80
|
|
|
80
81
|
常用参数:
|
|
@@ -97,6 +98,7 @@ marketplace/screenshots/preview.png
|
|
|
97
98
|
- `bpmn`
|
|
98
99
|
- `entity`
|
|
99
100
|
- `datasource`
|
|
101
|
+
- `assets`
|
|
100
102
|
- `settings`
|
|
101
103
|
|
|
102
104
|
`skill` member 可以发布到 Marketplace,供 Agent 通过 Server API 下载并安装到自己的 skill cache;普通设计态 `addon install` 不会把 `skill` 写入应用工程。Skill member 的 `source.path` 必须指向一个目录,目录内必须包含带 `name` 和 `description` frontmatter 的 `SKILL.md`,可选包含 `references/`、`assets/` 和 `scripts/`。如果存在 `scripts/`,必须提供 `scripts/scripts.json` 声明可执行入口的名称、路径、用途和确认策略;脚本依赖的辅助文件可放在 `scripts/` 下,不需要逐个声明为入口。
|
|
@@ -105,6 +107,7 @@ marketplace/screenshots/preview.png
|
|
|
105
107
|
|
|
106
108
|
- `src/addons/<addon-name>/meta.json`
|
|
107
109
|
- `settings` 成员会深合并到应用根目录 `app.settings.yml`
|
|
110
|
+
- `assets` 成员会复制到 `src/assets/<addon-name>`;组件或页面可用 `@/assets/<addon-name>/...` 静态导入这些图片、JSON、字体或其他前端运行素材
|
|
108
111
|
|
|
109
112
|
Addon 可在 `addon.json` 中声明安装后的运行配置要求:
|
|
110
113
|
|
|
@@ -154,7 +157,8 @@ Addon 可在 `addon.json` 中声明安装后的运行配置要求:
|
|
|
154
157
|
显式接入指导:
|
|
155
158
|
|
|
156
159
|
- Addon 包根目录可以放 `PROMPT.md`
|
|
157
|
-
- `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`
|
|
158
162
|
- 如果 Addon 本身就是一个 skill 资源,应在 `addon.json.members` 中显式声明 `type: "skill"`;普通 Addon 的根 `PROMPT.md` 只作为模型指导
|
|
159
163
|
|
|
160
164
|
升级策略:
|
package/dist/cli.cjs
CHANGED
|
@@ -612,7 +612,7 @@ function validateAddonManifest(manifest) {
|
|
|
612
612
|
validateInstallNpm(manifest);
|
|
613
613
|
}
|
|
614
614
|
function validateMembers(manifest) {
|
|
615
|
-
const allowedTypes = /* @__PURE__ */ new Set(["component", "page", "function", "skill", "theme", "settings", "workflow", "bpmn", "entity", "datasource"]);
|
|
615
|
+
const allowedTypes = /* @__PURE__ */ new Set(["component", "page", "function", "skill", "theme", "settings", "workflow", "bpmn", "entity", "datasource", "assets"]);
|
|
616
616
|
for (const member of manifest.members) {
|
|
617
617
|
if (!member.name || typeof member.name !== "string") {
|
|
618
618
|
throw new Error("addon.json member missing name");
|
|
@@ -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)`);
|
|
@@ -1190,6 +1191,9 @@ function toImportSpecifier(targetPath) {
|
|
|
1190
1191
|
const normalized = targetPath.replace(/\\/g, "/").replace(/^src\//, "@/");
|
|
1191
1192
|
return removePathExtension(normalized).replace(/\/index$/, "");
|
|
1192
1193
|
}
|
|
1194
|
+
function toAssetImportSpecifier(targetPath) {
|
|
1195
|
+
return targetPath.replace(/\\/g, "/").replace(/^src\//, "@/");
|
|
1196
|
+
}
|
|
1193
1197
|
function resolveInstalledAddonDisplay(meta) {
|
|
1194
1198
|
const legacyMeta = meta;
|
|
1195
1199
|
return {
|
|
@@ -1201,6 +1205,7 @@ function buildAddonLlmGuidance(input) {
|
|
|
1201
1205
|
const pageMembers = input.meta.members.filter((member) => member.type === "page");
|
|
1202
1206
|
const componentMembers = input.meta.members.filter((member) => member.type === "component");
|
|
1203
1207
|
const functionMembers = input.meta.members.filter((member) => member.type === "function");
|
|
1208
|
+
const assetMembers = input.meta.members.filter((member) => member.type === "assets");
|
|
1204
1209
|
const settingsMembers = input.meta.members.filter((member) => member.type === "settings");
|
|
1205
1210
|
const webRoutes = input.meta.members.filter((member) => member.type === "page" && member.page?.web).map((member) => ({
|
|
1206
1211
|
route: member.page.web.route,
|
|
@@ -1222,11 +1227,17 @@ function buildAddonLlmGuidance(input) {
|
|
|
1222
1227
|
name: member.name,
|
|
1223
1228
|
targetPaths: member.targetPaths
|
|
1224
1229
|
}));
|
|
1230
|
+
const assets = assetMembers.map((member) => ({
|
|
1231
|
+
name: member.name,
|
|
1232
|
+
targetPaths: member.targetPaths,
|
|
1233
|
+
importFrom: member.targetPaths[0] ? toAssetImportSpecifier(member.targetPaths[0]) : void 0
|
|
1234
|
+
}));
|
|
1225
1235
|
const settings = settingsMembers.map((member) => ({
|
|
1226
1236
|
targetPath: member.settings?.targetPath || member.targetPaths[0] || "",
|
|
1227
1237
|
paths: member.settings?.paths.map((item) => item.path) || []
|
|
1228
1238
|
}));
|
|
1229
1239
|
const display = resolveInstalledAddonDisplay(input.meta);
|
|
1240
|
+
const promptContent = input.meta.guidance?.prompt?.content ?? input.promptContent;
|
|
1230
1241
|
const instructions = [
|
|
1231
1242
|
"Use the installed Addon files in the host application's existing pages, components, routes, dialogs, or preview areas.",
|
|
1232
1243
|
"Do not reinstall to complete integration; edit application source files directly."
|
|
@@ -1240,6 +1251,9 @@ function buildAddonLlmGuidance(input) {
|
|
|
1240
1251
|
if (functionMembers.length > 0) {
|
|
1241
1252
|
instructions.push("Use installed function members by invoking their function names from the host application.");
|
|
1242
1253
|
}
|
|
1254
|
+
if (assetMembers.length > 0) {
|
|
1255
|
+
instructions.push("Import installed asset members from their @/assets paths instead of hardcoding external URLs.");
|
|
1256
|
+
}
|
|
1243
1257
|
if (hasInstallRequirements(input.requirements)) {
|
|
1244
1258
|
instructions.push(
|
|
1245
1259
|
"Configure the declared env/secret requirements before running or deploying the application. Use the app_secret_env tool instead of writing secret values into source files or .env examples."
|
|
@@ -1251,11 +1265,12 @@ function buildAddonLlmGuidance(input) {
|
|
|
1251
1265
|
return {
|
|
1252
1266
|
summary: display.description || display.title || `Installed addon ${input.meta.name}@${input.meta.version}.`,
|
|
1253
1267
|
instructions,
|
|
1254
|
-
prompt:
|
|
1268
|
+
prompt: promptContent ? { path: getAddonPromptTargetPath(input.meta.name), content: promptContent } : void 0,
|
|
1255
1269
|
webRoutes: webRoutes.length ? webRoutes : void 0,
|
|
1256
1270
|
miniPages: miniPages.length ? miniPages : void 0,
|
|
1257
1271
|
components: components.length ? components : void 0,
|
|
1258
1272
|
functions: functions.length ? functions : void 0,
|
|
1273
|
+
assets: assets.length ? assets : void 0,
|
|
1259
1274
|
settings: settings.length ? settings : void 0,
|
|
1260
1275
|
requirements: hasInstallRequirements(input.requirements) ? input.requirements : void 0,
|
|
1261
1276
|
npm: hasNpmDependencies(input.npm) ? input.npm : void 0
|
|
@@ -1264,11 +1279,35 @@ function buildAddonLlmGuidance(input) {
|
|
|
1264
1279
|
function getAddonMetaPath(targetDir, addonName) {
|
|
1265
1280
|
return path.join(targetDir, "src", "addons", addonName, "meta.json");
|
|
1266
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
|
+
}
|
|
1267
1305
|
async function readInstalledAddonMeta(metaPath) {
|
|
1268
1306
|
if (!fs.existsSync(metaPath)) {
|
|
1269
1307
|
return null;
|
|
1270
1308
|
}
|
|
1271
|
-
|
|
1309
|
+
const meta = JSON.parse(await promises$1.readFile(metaPath, "utf8"));
|
|
1310
|
+
return await hydrateInstalledAddonPrompt(metaPath, meta);
|
|
1272
1311
|
}
|
|
1273
1312
|
async function listAddonMetaPaths(targetDir) {
|
|
1274
1313
|
const addonsDir = path.join(targetDir, "src", "addons");
|
|
@@ -1372,12 +1411,12 @@ async function collectDirectoryFiles(sourceDir) {
|
|
|
1372
1411
|
}
|
|
1373
1412
|
return files.sort();
|
|
1374
1413
|
}
|
|
1375
|
-
async function planCopyMember(sourceRoot, sourceRelativePath, targetBaseRelativeDir, member, targetRelativePath) {
|
|
1414
|
+
async function planCopyMember(sourceRoot, sourceRelativePath, targetBaseRelativeDir, member, targetRelativePath, defaultTargetRelativePath) {
|
|
1376
1415
|
const sourceAbsolutePath = path.join(sourceRoot, sourceRelativePath);
|
|
1377
1416
|
const sourceStat = await promises$1.stat(sourceAbsolutePath);
|
|
1378
1417
|
const plannedFiles = [];
|
|
1379
1418
|
const targetPaths = [];
|
|
1380
|
-
const defaultTargetPath = path.join(targetBaseRelativeDir, path.basename(sourceRelativePath)).replace(/\\/g, "/");
|
|
1419
|
+
const defaultTargetPath = defaultTargetRelativePath ?? path.join(targetBaseRelativeDir, path.basename(sourceRelativePath)).replace(/\\/g, "/");
|
|
1381
1420
|
const memberTargetPath = targetRelativePath ?? defaultTargetPath;
|
|
1382
1421
|
if (sourceStat.isDirectory()) {
|
|
1383
1422
|
const sourceFiles = await collectDirectoryFiles(sourceAbsolutePath);
|
|
@@ -1461,6 +1500,9 @@ async function buildInstallPlan(options) {
|
|
|
1461
1500
|
case "theme":
|
|
1462
1501
|
targetBaseRelativeDir = path.join("src", "assets", manifest.name);
|
|
1463
1502
|
break;
|
|
1503
|
+
case "assets":
|
|
1504
|
+
targetBaseRelativeDir = path.join("src", "assets", manifest.name);
|
|
1505
|
+
break;
|
|
1464
1506
|
case "workflow":
|
|
1465
1507
|
targetBaseRelativeDir = path.join("src", "workflow");
|
|
1466
1508
|
break;
|
|
@@ -1480,6 +1522,9 @@ async function buildInstallPlan(options) {
|
|
|
1480
1522
|
throw new Error(`Unsupported addon member type: ${member.type}`);
|
|
1481
1523
|
}
|
|
1482
1524
|
const targetRelativePath = resolveMemberTargetPath(member);
|
|
1525
|
+
const sourceAbsolutePath = path.join(options.extractedDir, sourceRelativePath);
|
|
1526
|
+
const sourceStat = await promises$1.stat(sourceAbsolutePath);
|
|
1527
|
+
const defaultTargetPath = member.type === "assets" && sourceStat.isDirectory() ? targetBaseRelativeDir.replace(/\\/g, "/") : path.join(targetBaseRelativeDir, path.basename(sourceRelativePath)).replace(/\\/g, "/");
|
|
1483
1528
|
if (targetRelativePath && !isSameOrInsidePath(targetRelativePath, targetBaseRelativeDir)) {
|
|
1484
1529
|
throw new Error(
|
|
1485
1530
|
`Member ${member.name} target.path must stay inside ${targetBaseRelativeDir}: ${targetRelativePath}`
|
|
@@ -1490,7 +1535,8 @@ async function buildInstallPlan(options) {
|
|
|
1490
1535
|
sourceRelativePath,
|
|
1491
1536
|
targetBaseRelativeDir,
|
|
1492
1537
|
member,
|
|
1493
|
-
targetRelativePath
|
|
1538
|
+
targetRelativePath,
|
|
1539
|
+
defaultTargetPath
|
|
1494
1540
|
);
|
|
1495
1541
|
files.push(...planned.files);
|
|
1496
1542
|
const installedMember = {
|
|
@@ -1585,6 +1631,12 @@ function buildInstalledAddonMeta(options) {
|
|
|
1585
1631
|
installParameters: options.installParameters,
|
|
1586
1632
|
requirements: resolveInstallRequirements(options.manifest),
|
|
1587
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,
|
|
1588
1640
|
members: options.members,
|
|
1589
1641
|
files: options.files
|
|
1590
1642
|
};
|
|
@@ -1599,6 +1651,20 @@ async function writePlannedFiles(targetDir, planFiles) {
|
|
|
1599
1651
|
await promises$1.copyFile(file.sourcePath, absoluteTargetPath);
|
|
1600
1652
|
}
|
|
1601
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
|
+
}
|
|
1602
1668
|
function isPlainObject(value) {
|
|
1603
1669
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1604
1670
|
}
|
|
@@ -2102,6 +2168,8 @@ async function materializeAddon(options) {
|
|
|
2102
2168
|
const packageJsonFiles = await applyNpmDependencies(targetDir, npm);
|
|
2103
2169
|
await writePlannedFiles(targetDir, plan.files);
|
|
2104
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);
|
|
2105
2173
|
const installedFiles = [];
|
|
2106
2174
|
for (const plannedFile of plan.files) {
|
|
2107
2175
|
installedFiles.push(
|
|
@@ -2116,6 +2184,7 @@ async function materializeAddon(options) {
|
|
|
2116
2184
|
installParameters: plan.installParameters,
|
|
2117
2185
|
members: attachAppliedSettings(plan.members, settingsResult.appliedSettings),
|
|
2118
2186
|
files: installedFiles,
|
|
2187
|
+
promptContent,
|
|
2119
2188
|
installedAt: previousMeta?.installedAt
|
|
2120
2189
|
});
|
|
2121
2190
|
await ensureParentDirectory(plan.metaPath);
|
|
@@ -2125,7 +2194,6 @@ async function materializeAddon(options) {
|
|
|
2125
2194
|
await installPackageDependencies(targetDir);
|
|
2126
2195
|
}
|
|
2127
2196
|
const requirements = resolveInstallRequirements(plan.manifest);
|
|
2128
|
-
const promptContent = options.promptContent?.trim() || void 0;
|
|
2129
2197
|
const llmGuidance = buildAddonLlmGuidance({
|
|
2130
2198
|
operation: options.mode,
|
|
2131
2199
|
meta,
|
|
@@ -2135,8 +2203,8 @@ async function materializeAddon(options) {
|
|
|
2135
2203
|
});
|
|
2136
2204
|
return {
|
|
2137
2205
|
meta,
|
|
2138
|
-
writtenFiles: installedFiles.map((file) => file.path).concat(packageJsonFiles, restoredSettingsFiles, settingsResult.writtenFiles),
|
|
2139
|
-
removedFiles,
|
|
2206
|
+
writtenFiles: installedFiles.map((file) => file.path).concat(promptFiles.writtenFiles, packageJsonFiles, restoredSettingsFiles, settingsResult.writtenFiles),
|
|
2207
|
+
removedFiles: removedFiles.concat(promptFiles.removedFiles),
|
|
2140
2208
|
requirements,
|
|
2141
2209
|
missingRequirements: buildMissingRequirements(requirements),
|
|
2142
2210
|
npm,
|
|
@@ -3924,9 +3992,9 @@ addJsonOption(addRegistryOption(program.command("whoami").description("Show the
|
|
|
3924
3992
|
}
|
|
3925
3993
|
);
|
|
3926
3994
|
var addon = program.command("addon").description("Addon marketplace commands");
|
|
3927
|
-
addJsonOption(addOrganizationOption(addRegistryOption(addon.command("search [query]").description("Search addons")))).option("--application-type <type>", "Application type").option("--phase <phase>", "Phase filter").option("--member-type <type>", "Member type filter").option("--scope <scope>", "Scope filter").option("--page <page>", "Page number", (value) => Number.parseInt(value, 10)).option("--page-size <pageSize>", "Page size", (value) => Number.parseInt(value, 10)).action(async (query, options) => {
|
|
3995
|
+
addJsonOption(addOrganizationOption(addRegistryOption(addon.command("search [query]").description("Search addons")))).option("--target <path>", "Application root directory used to detect application type").option("--application-type <type>", "Application type").option("--phase <phase>", "Phase filter").option("--member-type <type>", "Member type filter").option("--scope <scope>", "Scope filter").option("--page <page>", "Page number", (value) => Number.parseInt(value, 10)).option("--page-size <pageSize>", "Page size", (value) => Number.parseInt(value, 10)).action(async (query, options) => {
|
|
3928
3996
|
const registry = resolveRegistryFromOptions(options);
|
|
3929
|
-
const applicationType = options.applicationType ?? await tryDetectNearestApplicationType();
|
|
3997
|
+
const applicationType = options.applicationType ?? await tryDetectNearestApplicationType(options.target);
|
|
3930
3998
|
const result = await searchAddons(registry, {
|
|
3931
3999
|
query,
|
|
3932
4000
|
applicationType,
|