@amaster.ai/cli 1.1.32 → 1.1.34
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 +5 -3
- package/dist/cli.cjs +61 -37
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +61 -37
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,6 +75,7 @@ marketplace/screenshots/preview.png
|
|
|
75
75
|
这些文件只用于发布到 Addon Marketplace,不会被 `addon install` 安装到应用工程。
|
|
76
76
|
|
|
77
77
|
`addon search` 在未显式传 `--application-type` 时,会从当前目录向上查找最近的 `package.json`,读取同级 `app.settings.yml` 的 `type`,并自动按 `web` 或 `mini` 过滤。
|
|
78
|
+
`addon search --json` 返回面向 MCP/AI 的轻量结果,只包含 `name`、`version`、`installSpecifier`、标题、描述、类目、适用类型、阶段、成员类型和主图地址。
|
|
78
79
|
|
|
79
80
|
常用参数:
|
|
80
81
|
|
|
@@ -144,12 +145,13 @@ Addon 可在 `addon.json` 中声明安装后的运行配置要求:
|
|
|
144
145
|
- CLI 只复制页面文件并写入 `src/addons/{addonName}/meta.json`
|
|
145
146
|
- CLI 不自动修改 `src/routes.tsx` 或 `src/app.config.ts`
|
|
146
147
|
- 安装/升级结果会返回 `llmGuidance`,由大模型按当前应用结构接入 web routes、mini pages 和 tabBar
|
|
148
|
+
- `addon install/upgrade --json` 只返回精简消费视图,不返回完整安装元数据、文件 hash、发布物料或数据库 id
|
|
147
149
|
|
|
148
150
|
显式接入指导:
|
|
149
151
|
|
|
150
|
-
- Addon 包根目录可以放 `
|
|
151
|
-
- `
|
|
152
|
-
- 如果 Addon 本身就是一个 skill 资源,应在 `addon.json.members` 中显式声明 `type: "skill"`;普通 Addon 的根 `
|
|
152
|
+
- Addon 包根目录可以放 `PROMPT.md`
|
|
153
|
+
- `PROMPT.md` 不会进入安装包,也不会安装到应用工程;发布时会作为版本提示词元数据保存,并在安装/升级结果的 `llmGuidance.prompt` 中返回给大模型
|
|
154
|
+
- 如果 Addon 本身就是一个 skill 资源,应在 `addon.json.members` 中显式声明 `type: "skill"`;普通 Addon 的根 `PROMPT.md` 只作为模型指导
|
|
153
155
|
|
|
154
156
|
升级策略:
|
|
155
157
|
|
package/dist/cli.cjs
CHANGED
|
@@ -41,7 +41,7 @@ var tar__namespace = /*#__PURE__*/_interopNamespace(tar);
|
|
|
41
41
|
var YAML2__default = /*#__PURE__*/_interopDefault(YAML2);
|
|
42
42
|
var ts__default = /*#__PURE__*/_interopDefault(ts);
|
|
43
43
|
|
|
44
|
-
var EXCLUDED_NAMES = /* @__PURE__ */ new Set([".git", "node_modules", ".DS_Store"]);
|
|
44
|
+
var EXCLUDED_NAMES = /* @__PURE__ */ new Set([".git", "node_modules", ".DS_Store", "PROMPT.md"]);
|
|
45
45
|
function sha256(buffer) {
|
|
46
46
|
return `sha256:${crypto.createHash("sha256").update(buffer).digest("hex")}`;
|
|
47
47
|
}
|
|
@@ -910,6 +910,13 @@ function hasInstallRequirements(requirements) {
|
|
|
910
910
|
function hasNpmDependencies(npm) {
|
|
911
911
|
return Boolean(Object.keys(npm.dependencies ?? {}).length);
|
|
912
912
|
}
|
|
913
|
+
function removePathExtension(path) {
|
|
914
|
+
return path.replace(/\.[^/.]+$/, "");
|
|
915
|
+
}
|
|
916
|
+
function toImportSpecifier(targetPath) {
|
|
917
|
+
const normalized = targetPath.replace(/\\/g, "/").replace(/^src\//, "@/");
|
|
918
|
+
return removePathExtension(normalized).replace(/\/index$/, "");
|
|
919
|
+
}
|
|
913
920
|
function buildAddonLlmGuidance(input) {
|
|
914
921
|
const pageMembers = input.meta.members.filter((member) => member.type === "page");
|
|
915
922
|
const componentMembers = input.meta.members.filter((member) => member.type === "component");
|
|
@@ -928,16 +935,15 @@ function buildAddonLlmGuidance(input) {
|
|
|
928
935
|
}));
|
|
929
936
|
const components = componentMembers.map((member) => ({
|
|
930
937
|
name: member.name,
|
|
931
|
-
importFrom: member.targetPaths[0]
|
|
932
|
-
targetPaths: member.targetPaths
|
|
938
|
+
importFrom: member.targetPaths[0] ? toImportSpecifier(member.targetPaths[0]) : ""
|
|
933
939
|
}));
|
|
934
940
|
const settings = settingsMembers.map((member) => ({
|
|
935
941
|
targetPath: member.settings?.targetPath || member.targetPaths[0] || "",
|
|
936
942
|
paths: member.settings?.paths.map((item) => item.path) || []
|
|
937
943
|
}));
|
|
938
944
|
const instructions = [
|
|
939
|
-
|
|
940
|
-
"Do not
|
|
945
|
+
"Use the installed Addon files in the host application's existing pages, components, routes, dialogs, or preview areas.",
|
|
946
|
+
"Do not reinstall to complete integration; edit application source files directly."
|
|
941
947
|
];
|
|
942
948
|
if (pageMembers.length > 0) {
|
|
943
949
|
instructions.push("Wire the installed page members into the application's existing routing/configuration style.");
|
|
@@ -954,7 +960,7 @@ function buildAddonLlmGuidance(input) {
|
|
|
954
960
|
return {
|
|
955
961
|
summary: input.meta.manifest.description || input.meta.manifest.title || `Installed addon ${input.meta.name}@${input.meta.version}.`,
|
|
956
962
|
instructions,
|
|
957
|
-
|
|
963
|
+
prompt: input.promptContent ? { path: "PROMPT.md", content: input.promptContent } : void 0,
|
|
958
964
|
webRoutes: webRoutes.length ? webRoutes : void 0,
|
|
959
965
|
miniPages: miniPages.length ? miniPages : void 0,
|
|
960
966
|
components: components.length ? components : void 0,
|
|
@@ -963,24 +969,6 @@ function buildAddonLlmGuidance(input) {
|
|
|
963
969
|
npm: hasNpmDependencies(input.npm) ? input.npm : void 0
|
|
964
970
|
};
|
|
965
971
|
}
|
|
966
|
-
async function readAddonSkillGuidance(extractedDir, manifest) {
|
|
967
|
-
const hasSkillMemberAtRoot = manifest.members.some((member) => {
|
|
968
|
-
if (member.type !== "skill") {
|
|
969
|
-
return false;
|
|
970
|
-
}
|
|
971
|
-
const sourcePath = resolveMemberSourcePath(member);
|
|
972
|
-
return sourcePath === "SKILL.md";
|
|
973
|
-
});
|
|
974
|
-
if (hasSkillMemberAtRoot) {
|
|
975
|
-
return void 0;
|
|
976
|
-
}
|
|
977
|
-
const skillPath = path.join(extractedDir, "SKILL.md");
|
|
978
|
-
if (!fs.existsSync(skillPath)) {
|
|
979
|
-
return void 0;
|
|
980
|
-
}
|
|
981
|
-
const content = (await promises$1.readFile(skillPath, "utf8")).trim();
|
|
982
|
-
return content || void 0;
|
|
983
|
-
}
|
|
984
972
|
function getAddonMetaPath(targetDir, addonName) {
|
|
985
973
|
return path.join(targetDir, "src", "addons", addonName, "meta.json");
|
|
986
974
|
}
|
|
@@ -1786,13 +1774,13 @@ async function materializeAddon(options) {
|
|
|
1786
1774
|
await installPackageDependencies(targetDir);
|
|
1787
1775
|
}
|
|
1788
1776
|
const requirements = resolveInstallRequirements(plan.manifest);
|
|
1789
|
-
const
|
|
1777
|
+
const promptContent = options.promptContent?.trim() || void 0;
|
|
1790
1778
|
const llmGuidance = buildAddonLlmGuidance({
|
|
1791
1779
|
operation: options.mode,
|
|
1792
1780
|
meta,
|
|
1793
1781
|
requirements,
|
|
1794
1782
|
npm,
|
|
1795
|
-
|
|
1783
|
+
promptContent
|
|
1796
1784
|
});
|
|
1797
1785
|
return {
|
|
1798
1786
|
meta,
|
|
@@ -1826,6 +1814,41 @@ function createOrganizationHeaders(organizationCode) {
|
|
|
1826
1814
|
"x-organization-code": organizationCode
|
|
1827
1815
|
};
|
|
1828
1816
|
}
|
|
1817
|
+
function toAddonSearchResponse(response) {
|
|
1818
|
+
return {
|
|
1819
|
+
items: response.items.flatMap((addon2) => {
|
|
1820
|
+
const version = addon2.latestVersion;
|
|
1821
|
+
if (!version) {
|
|
1822
|
+
return [];
|
|
1823
|
+
}
|
|
1824
|
+
return [
|
|
1825
|
+
{
|
|
1826
|
+
name: addon2.name,
|
|
1827
|
+
version: version.version,
|
|
1828
|
+
installSpecifier: `${addon2.name}@${version.version}`,
|
|
1829
|
+
title: version.title,
|
|
1830
|
+
description: version.description,
|
|
1831
|
+
category: version.category,
|
|
1832
|
+
applicationTypes: version.applicationTypes,
|
|
1833
|
+
phases: version.phases,
|
|
1834
|
+
memberTypes: version.memberTypes,
|
|
1835
|
+
...addon2.imageUrl ? { imageUrl: addon2.imageUrl } : {}
|
|
1836
|
+
}
|
|
1837
|
+
];
|
|
1838
|
+
}),
|
|
1839
|
+
page: response.page,
|
|
1840
|
+
pageSize: response.pageSize,
|
|
1841
|
+
total: response.total
|
|
1842
|
+
};
|
|
1843
|
+
}
|
|
1844
|
+
async function readAddonPromptContent(sourceDir) {
|
|
1845
|
+
const promptPath = path.resolve(sourceDir, "PROMPT.md");
|
|
1846
|
+
if (!fs.existsSync(promptPath)) {
|
|
1847
|
+
return void 0;
|
|
1848
|
+
}
|
|
1849
|
+
const content = (await promises$1.readFile(promptPath, "utf8")).trim();
|
|
1850
|
+
return content || void 0;
|
|
1851
|
+
}
|
|
1829
1852
|
function parseAddonSpecifier(specifier) {
|
|
1830
1853
|
const trimmed = specifier.trim();
|
|
1831
1854
|
if (!trimmed) {
|
|
@@ -1851,11 +1874,12 @@ async function searchAddons(registry, options) {
|
|
|
1851
1874
|
if (options.scope) query.set("scope", options.scope);
|
|
1852
1875
|
if (options.page) query.set("page", String(options.page));
|
|
1853
1876
|
if (options.pageSize) query.set("pageSize", String(options.pageSize));
|
|
1854
|
-
|
|
1877
|
+
const response = await requestJson(registry, `/api/addons?${query.toString()}`, {
|
|
1855
1878
|
method: "GET",
|
|
1856
1879
|
headers: createOrganizationHeaders(options.organizationCode),
|
|
1857
1880
|
unwrapData: true
|
|
1858
1881
|
});
|
|
1882
|
+
return toAddonSearchResponse(response);
|
|
1859
1883
|
}
|
|
1860
1884
|
async function getAddon(registry, name, organizationCode) {
|
|
1861
1885
|
return await requestJson(registry, `/api/addons/${encodeURIComponent(name)}`, {
|
|
@@ -1946,6 +1970,7 @@ async function publishAddon(options) {
|
|
|
1946
1970
|
tempArchiveDir = path.dirname(packaged.archivePath);
|
|
1947
1971
|
}
|
|
1948
1972
|
const manifest = await loadAddonManifestFromDirectory(manifestDir);
|
|
1973
|
+
const promptContent = isArchive ? void 0 : await readAddonPromptContent(sourcePath);
|
|
1949
1974
|
const digest = sha256(archiveBuffer);
|
|
1950
1975
|
return await withAccessToken(options.registry, async (accessToken) => {
|
|
1951
1976
|
const headers = {
|
|
@@ -1984,7 +2009,8 @@ async function publishAddon(options) {
|
|
|
1984
2009
|
headers,
|
|
1985
2010
|
body: {
|
|
1986
2011
|
sessionId: session.sessionId,
|
|
1987
|
-
...options.scope ? { scope: options.scope } : {}
|
|
2012
|
+
...options.scope ? { scope: options.scope } : {},
|
|
2013
|
+
...promptContent ? { promptContent } : {}
|
|
1988
2014
|
},
|
|
1989
2015
|
unwrapData: true
|
|
1990
2016
|
}
|
|
@@ -2048,6 +2074,7 @@ async function resolveInstallVersion(registry, name, requestedVersion, organizat
|
|
|
2048
2074
|
async function installAddonFromRegistry(options) {
|
|
2049
2075
|
const { name, version: requestedVersion } = parseAddonSpecifier(options.specifier);
|
|
2050
2076
|
const version = await resolveInstallVersion(options.registry, name, requestedVersion, options.organizationCode);
|
|
2077
|
+
const versionDetail = await getAddonVersion(options.registry, name, version, options.organizationCode);
|
|
2051
2078
|
const archiveBuffer = await downloadAddonArchiveBuffer(options.registry, name, version, options.organizationCode);
|
|
2052
2079
|
const extractedDir = await extractAddonArchiveBuffer(archiveBuffer);
|
|
2053
2080
|
try {
|
|
@@ -2058,7 +2085,8 @@ async function installAddonFromRegistry(options) {
|
|
|
2058
2085
|
applicationType: options.applicationType,
|
|
2059
2086
|
organizationCode: options.organizationCode,
|
|
2060
2087
|
installParameters: options.installParameters,
|
|
2061
|
-
installPackageDependencies: true
|
|
2088
|
+
installPackageDependencies: true,
|
|
2089
|
+
promptContent: versionDetail.promptContent ?? void 0
|
|
2062
2090
|
});
|
|
2063
2091
|
} finally {
|
|
2064
2092
|
await removeTempDirectory(extractedDir).catch(() => void 0);
|
|
@@ -2067,6 +2095,7 @@ async function installAddonFromRegistry(options) {
|
|
|
2067
2095
|
async function upgradeAddonFromRegistry(options) {
|
|
2068
2096
|
const { name, version: requestedVersion } = parseAddonSpecifier(options.specifier);
|
|
2069
2097
|
const version = await resolveInstallVersion(options.registry, name, requestedVersion, options.organizationCode);
|
|
2098
|
+
const versionDetail = await getAddonVersion(options.registry, name, version, options.organizationCode);
|
|
2070
2099
|
const archiveBuffer = await downloadAddonArchiveBuffer(options.registry, name, version, options.organizationCode);
|
|
2071
2100
|
const extractedDir = await extractAddonArchiveBuffer(archiveBuffer);
|
|
2072
2101
|
try {
|
|
@@ -2077,7 +2106,8 @@ async function upgradeAddonFromRegistry(options) {
|
|
|
2077
2106
|
applicationType: options.applicationType,
|
|
2078
2107
|
organizationCode: options.organizationCode,
|
|
2079
2108
|
installParameters: options.installParameters,
|
|
2080
|
-
installPackageDependencies: true
|
|
2109
|
+
installPackageDependencies: true,
|
|
2110
|
+
promptContent: versionDetail.promptContent ?? void 0
|
|
2081
2111
|
});
|
|
2082
2112
|
} finally {
|
|
2083
2113
|
await removeTempDirectory(extractedDir).catch(() => void 0);
|
|
@@ -3444,12 +3474,6 @@ function renderAddonInstallResult(result, operation, options) {
|
|
|
3444
3474
|
version: result.meta.version,
|
|
3445
3475
|
applicationType: result.meta.applicationType
|
|
3446
3476
|
},
|
|
3447
|
-
files: {
|
|
3448
|
-
written: result.writtenFiles,
|
|
3449
|
-
removed: result.removedFiles
|
|
3450
|
-
},
|
|
3451
|
-
npm: Object.keys(result.npm.dependencies ?? {}).length ? result.npm : void 0,
|
|
3452
|
-
missingRequirements: result.missingRequirements.envs?.length || result.missingRequirements.secrets?.length ? result.missingRequirements : void 0,
|
|
3453
3477
|
llmGuidance: result.llmGuidance
|
|
3454
3478
|
};
|
|
3455
3479
|
if (options.json) {
|
|
@@ -3470,7 +3494,7 @@ function renderAddonInstallResult(result, operation, options) {
|
|
|
3470
3494
|
if (result.llmGuidance.miniPages?.length) {
|
|
3471
3495
|
lines.push("Next: wire mini pages from llmGuidance.miniPages.");
|
|
3472
3496
|
}
|
|
3473
|
-
if (
|
|
3497
|
+
if (result.missingRequirements.envs?.length || result.missingRequirements.secrets?.length) {
|
|
3474
3498
|
lines.push("Next: configure missing env/secrets from llmGuidance.requirements.");
|
|
3475
3499
|
}
|
|
3476
3500
|
lines.push("Use --json for LLM-readable integration guidance.");
|