@amaster.ai/cli 1.1.31 → 1.1.33
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 +13 -4
- package/dist/cli.cjs +159 -151
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +159 -151
- 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
|
|
|
@@ -139,10 +140,18 @@ Addon 可在 `addon.json` 中声明安装后的运行配置要求:
|
|
|
139
140
|
|
|
140
141
|
`install.requirements` 会写入 `meta.json`,并在安装/升级结果中返回 `requirements` 和 `missingRequirements`。`secrets` 只保存键名和说明,不保存密钥值。
|
|
141
142
|
|
|
142
|
-
|
|
143
|
+
页面接入方式:
|
|
143
144
|
|
|
144
|
-
-
|
|
145
|
-
-
|
|
145
|
+
- CLI 只复制页面文件并写入 `src/addons/{addonName}/meta.json`
|
|
146
|
+
- CLI 不自动修改 `src/routes.tsx` 或 `src/app.config.ts`
|
|
147
|
+
- 安装/升级结果会返回 `llmGuidance`,由大模型按当前应用结构接入 web routes、mini pages 和 tabBar
|
|
148
|
+
- `addon install/upgrade --json` 只返回精简消费视图,不返回完整安装元数据、文件 hash、发布物料或数据库 id
|
|
149
|
+
|
|
150
|
+
显式接入指导:
|
|
151
|
+
|
|
152
|
+
- Addon 包根目录可以放 `PROMPT.md`
|
|
153
|
+
- `PROMPT.md` 不会安装到应用工程,只会在安装/升级结果的 `llmGuidance.prompt` 中返回给大模型
|
|
154
|
+
- 如果 Addon 本身就是一个 skill 资源,应在 `addon.json.members` 中显式声明 `type: "skill"`;普通 Addon 的根 `PROMPT.md` 只作为模型指导
|
|
146
155
|
|
|
147
156
|
升级策略:
|
|
148
157
|
|
|
@@ -178,7 +187,7 @@ Addon 可在 `addon.json` 中声明安装后的运行配置要求:
|
|
|
178
187
|
}
|
|
179
188
|
```
|
|
180
189
|
|
|
181
|
-
MCP 接入时可按 `conflicts[].path` 读取应用里的当前文件,并按 `memberName` / `sourcePath` 获取 Addon 原始内容,再交给 AI
|
|
190
|
+
MCP 接入时可按 `conflicts[].path` 读取应用里的当前文件,并按 `memberName` / `sourcePath` 获取 Addon 原始内容,再交给 AI 或人工合并处理。
|
|
182
191
|
|
|
183
192
|
## 模板检查
|
|
184
193
|
|
package/dist/cli.cjs
CHANGED
|
@@ -765,14 +765,6 @@ async function tryDetectNearestApplicationType(startDir = process.cwd()) {
|
|
|
765
765
|
|
|
766
766
|
// src/marketplace/install.ts
|
|
767
767
|
var execFileAsync = util.promisify(child_process.execFile);
|
|
768
|
-
var ADDON_ROUTES_FILE = "src/routes-addon.ts";
|
|
769
|
-
var ADDON_ROUTES_IMPORT = 'import { addonRoutes } from "./routes-addon";';
|
|
770
|
-
var LEGACY_ADDON_ROUTES_IMPORT = 'import { addonRoutes } from "./amaster/registry/addon-routes.generated";';
|
|
771
|
-
var LEGACY_ADDON_ROUTES_FILE = "src/amaster/registry/addon-routes.generated.ts";
|
|
772
|
-
var ADDON_PAGES_FILE = "src/app-addon.config.ts";
|
|
773
|
-
var ADDON_PAGES_IMPORT = 'import { addonPages, addonTabBarItems } from "./app-addon.config";';
|
|
774
|
-
var LEGACY_ADDON_PAGES_IMPORT = 'import { addonPages, addonTabBarItems } from "./amaster/registry/addon-pages.generated";';
|
|
775
|
-
var LEGACY_ADDON_PAGES_FILE = "src/amaster/registry/addon-pages.generated.ts";
|
|
776
768
|
var AddonInstallConflictError = class extends Error {
|
|
777
769
|
constructor(input) {
|
|
778
770
|
super(`Addon ${input.operation} has ${input.conflicts.length} conflict(s)`);
|
|
@@ -821,13 +813,6 @@ function ensurePathInsideTarget(targetDir, relativePath) {
|
|
|
821
813
|
}
|
|
822
814
|
return absolute;
|
|
823
815
|
}
|
|
824
|
-
function removeFileExtension(input) {
|
|
825
|
-
const extension = path.extname(input);
|
|
826
|
-
return extension ? input.slice(0, -extension.length) : input;
|
|
827
|
-
}
|
|
828
|
-
function toPascalCase(input) {
|
|
829
|
-
return input.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((part) => part[0].toUpperCase() + part.slice(1)).join("");
|
|
830
|
-
}
|
|
831
816
|
function parseScalarValue(rawValue, expectedType, enumValues) {
|
|
832
817
|
const primaryType = Array.isArray(expectedType) ? expectedType[0] : expectedType;
|
|
833
818
|
if (enumValues?.length) {
|
|
@@ -919,6 +904,89 @@ function buildMissingRequirements(requirements) {
|
|
|
919
904
|
secrets: requirements.secrets?.filter((item) => item.required !== false).map((item) => ({ ...item }))
|
|
920
905
|
};
|
|
921
906
|
}
|
|
907
|
+
function hasInstallRequirements(requirements) {
|
|
908
|
+
return Boolean(requirements.envs?.length || requirements.secrets?.length);
|
|
909
|
+
}
|
|
910
|
+
function hasNpmDependencies(npm) {
|
|
911
|
+
return Boolean(Object.keys(npm.dependencies ?? {}).length);
|
|
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
|
+
}
|
|
920
|
+
function buildAddonLlmGuidance(input) {
|
|
921
|
+
const pageMembers = input.meta.members.filter((member) => member.type === "page");
|
|
922
|
+
const componentMembers = input.meta.members.filter((member) => member.type === "component");
|
|
923
|
+
const settingsMembers = input.meta.members.filter((member) => member.type === "settings");
|
|
924
|
+
const webRoutes = input.meta.members.filter((member) => member.type === "page" && member.page?.web).map((member) => ({
|
|
925
|
+
route: member.page.web.route,
|
|
926
|
+
entry: member.page.web.entry.startsWith("src/") ? member.page.web.entry : `src/${member.page.web.entry}`,
|
|
927
|
+
title: member.page.web.title,
|
|
928
|
+
visible: member.page.web.visible,
|
|
929
|
+
suggestedFile: "src/routes.tsx"
|
|
930
|
+
}));
|
|
931
|
+
const miniPages = input.meta.members.filter((member) => member.type === "page" && member.page?.mini).map((member) => ({
|
|
932
|
+
pagePath: member.page.mini.pagePath,
|
|
933
|
+
suggestedFile: "src/app.config.ts",
|
|
934
|
+
tabBar: member.page.mini.tabBar
|
|
935
|
+
}));
|
|
936
|
+
const components = componentMembers.map((member) => ({
|
|
937
|
+
name: member.name,
|
|
938
|
+
importFrom: member.targetPaths[0] ? toImportSpecifier(member.targetPaths[0]) : ""
|
|
939
|
+
}));
|
|
940
|
+
const settings = settingsMembers.map((member) => ({
|
|
941
|
+
targetPath: member.settings?.targetPath || member.targetPaths[0] || "",
|
|
942
|
+
paths: member.settings?.paths.map((item) => item.path) || []
|
|
943
|
+
}));
|
|
944
|
+
const instructions = [
|
|
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."
|
|
947
|
+
];
|
|
948
|
+
if (pageMembers.length > 0) {
|
|
949
|
+
instructions.push("Wire the installed page members into the application's existing routing/configuration style.");
|
|
950
|
+
}
|
|
951
|
+
if (componentMembers.length > 0) {
|
|
952
|
+
instructions.push("Use installed component members from their target paths where the application needs them.");
|
|
953
|
+
}
|
|
954
|
+
if (hasInstallRequirements(input.requirements)) {
|
|
955
|
+
instructions.push("Configure the declared env/secret requirements before running or deploying the application.");
|
|
956
|
+
}
|
|
957
|
+
if (hasNpmDependencies(input.npm)) {
|
|
958
|
+
instructions.push("NPM dependencies have been written to package.json; avoid adding duplicate dependency entries.");
|
|
959
|
+
}
|
|
960
|
+
return {
|
|
961
|
+
summary: input.meta.manifest.description || input.meta.manifest.title || `Installed addon ${input.meta.name}@${input.meta.version}.`,
|
|
962
|
+
instructions,
|
|
963
|
+
prompt: input.promptContent ? { path: "PROMPT.md", content: input.promptContent } : void 0,
|
|
964
|
+
webRoutes: webRoutes.length ? webRoutes : void 0,
|
|
965
|
+
miniPages: miniPages.length ? miniPages : void 0,
|
|
966
|
+
components: components.length ? components : void 0,
|
|
967
|
+
settings: settings.length ? settings : void 0,
|
|
968
|
+
requirements: hasInstallRequirements(input.requirements) ? input.requirements : void 0,
|
|
969
|
+
npm: hasNpmDependencies(input.npm) ? input.npm : void 0
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
async function readAddonPrompt(extractedDir, manifest) {
|
|
973
|
+
const hasPromptMemberAtRoot = manifest.members.some((member) => {
|
|
974
|
+
if (member.type !== "skill") {
|
|
975
|
+
return false;
|
|
976
|
+
}
|
|
977
|
+
const sourcePath = resolveMemberSourcePath(member);
|
|
978
|
+
return sourcePath === "PROMPT.md";
|
|
979
|
+
});
|
|
980
|
+
if (hasPromptMemberAtRoot) {
|
|
981
|
+
return void 0;
|
|
982
|
+
}
|
|
983
|
+
const promptPath = path.join(extractedDir, "PROMPT.md");
|
|
984
|
+
if (!fs.existsSync(promptPath)) {
|
|
985
|
+
return void 0;
|
|
986
|
+
}
|
|
987
|
+
const content = (await promises$1.readFile(promptPath, "utf8")).trim();
|
|
988
|
+
return content || void 0;
|
|
989
|
+
}
|
|
922
990
|
function getAddonMetaPath(targetDir, addonName) {
|
|
923
991
|
return path.join(targetDir, "src", "addons", addonName, "meta.json");
|
|
924
992
|
}
|
|
@@ -1677,136 +1745,6 @@ async function validateUpgradeConflicts(targetDir, plan, existingMetas, previous
|
|
|
1677
1745
|
});
|
|
1678
1746
|
}
|
|
1679
1747
|
}
|
|
1680
|
-
async function ensureWebRoutesPatched(targetDir) {
|
|
1681
|
-
const routesFile = path.join(targetDir, "src", "routes.tsx");
|
|
1682
|
-
const original = await promises$1.readFile(routesFile, "utf8");
|
|
1683
|
-
let next = original;
|
|
1684
|
-
if (next.includes(LEGACY_ADDON_ROUTES_IMPORT)) {
|
|
1685
|
-
next = next.replace(LEGACY_ADDON_ROUTES_IMPORT, ADDON_ROUTES_IMPORT);
|
|
1686
|
-
}
|
|
1687
|
-
if (!next.includes(ADDON_ROUTES_IMPORT)) {
|
|
1688
|
-
next = next.replace(
|
|
1689
|
-
'import type { ComponentType } from "react";',
|
|
1690
|
-
`import type { ComponentType } from "react";
|
|
1691
|
-
${ADDON_ROUTES_IMPORT}`
|
|
1692
|
-
);
|
|
1693
|
-
}
|
|
1694
|
-
if (!next.includes("...addonRoutes")) {
|
|
1695
|
-
const routeArrayPattern = /const routes:\s*RouteConfig\[\]\s*=\s*\[([\s\S]*?)\];/;
|
|
1696
|
-
const match = next.match(routeArrayPattern);
|
|
1697
|
-
if (!match) {
|
|
1698
|
-
throw new Error("Unable to patch src/routes.tsx for addon route registration");
|
|
1699
|
-
}
|
|
1700
|
-
const inner = match[1]?.trim() ?? "";
|
|
1701
|
-
const replacement = inner ? `const routes: RouteConfig[] = [
|
|
1702
|
-
...addonRoutes,
|
|
1703
|
-
${match[1]}
|
|
1704
|
-
];` : "const routes: RouteConfig[] = [\n ...addonRoutes,\n];";
|
|
1705
|
-
next = next.replace(routeArrayPattern, replacement);
|
|
1706
|
-
}
|
|
1707
|
-
if (next !== original) {
|
|
1708
|
-
await promises$1.writeFile(routesFile, next);
|
|
1709
|
-
}
|
|
1710
|
-
}
|
|
1711
|
-
async function ensureMiniAppConfigPatched(targetDir, needsTabBarItems) {
|
|
1712
|
-
const configFile = path.join(targetDir, "src", "app.config.ts");
|
|
1713
|
-
const original = await promises$1.readFile(configFile, "utf8");
|
|
1714
|
-
let next = original;
|
|
1715
|
-
if (next.includes(LEGACY_ADDON_PAGES_IMPORT)) {
|
|
1716
|
-
next = next.replace(LEGACY_ADDON_PAGES_IMPORT, ADDON_PAGES_IMPORT);
|
|
1717
|
-
}
|
|
1718
|
-
if (!next.includes(ADDON_PAGES_IMPORT)) {
|
|
1719
|
-
next = `${ADDON_PAGES_IMPORT}
|
|
1720
|
-
${next}`;
|
|
1721
|
-
}
|
|
1722
|
-
if (!next.includes("...addonPages")) {
|
|
1723
|
-
next = next.replace(/const pages\s*=\s*\[([\s\S]*?)\]/, (_full, inner) => {
|
|
1724
|
-
const trimmed = inner.trim();
|
|
1725
|
-
if (!trimmed) {
|
|
1726
|
-
return "const pages = [...addonPages]";
|
|
1727
|
-
}
|
|
1728
|
-
return `const pages = [${inner}, ...addonPages]`;
|
|
1729
|
-
});
|
|
1730
|
-
}
|
|
1731
|
-
if (needsTabBarItems && !next.includes("...addonTabBarItems")) {
|
|
1732
|
-
const listPattern = /list:\s*\[([\s\S]*?)\]/;
|
|
1733
|
-
const match = next.match(listPattern);
|
|
1734
|
-
if (!match) {
|
|
1735
|
-
throw new Error("Unable to patch src/app.config.ts for addon tabBar registration");
|
|
1736
|
-
}
|
|
1737
|
-
next = next.replace(listPattern, (_full, inner) => `list: [${inner}, ...addonTabBarItems]`);
|
|
1738
|
-
}
|
|
1739
|
-
if (next !== original) {
|
|
1740
|
-
await promises$1.writeFile(configFile, next);
|
|
1741
|
-
}
|
|
1742
|
-
}
|
|
1743
|
-
async function rebuildRegistryFiles(targetDir, applicationType, metas) {
|
|
1744
|
-
if (applicationType === "web") {
|
|
1745
|
-
const pageMembers2 = metas.flatMap(
|
|
1746
|
-
(meta) => meta.members.filter((member) => member.type === "page" && member.page?.web).map((member) => ({ addonName: meta.name, member }))
|
|
1747
|
-
).sort((left, right) => `${left.addonName}:${left.member.name}`.localeCompare(`${right.addonName}:${right.member.name}`));
|
|
1748
|
-
const imports = pageMembers2.map(({ addonName, member }) => {
|
|
1749
|
-
const identifier = toPascalCase(`${addonName}-${member.name}-page`);
|
|
1750
|
-
const entry = member.page.web.entry;
|
|
1751
|
-
return {
|
|
1752
|
-
identifier,
|
|
1753
|
-
importPath: `./${removeFileExtension(entry).replace(/\\/g, "/")}`,
|
|
1754
|
-
route: member.page.web.route,
|
|
1755
|
-
visible: member.page.web.visible,
|
|
1756
|
-
name: member.name
|
|
1757
|
-
};
|
|
1758
|
-
});
|
|
1759
|
-
const routesFile = path.join(targetDir, "src", "routes.tsx");
|
|
1760
|
-
const routesContent = fs.existsSync(routesFile) ? await promises$1.readFile(routesFile, "utf8") : "";
|
|
1761
|
-
const alreadyPatched2 = routesContent.includes(ADDON_ROUTES_IMPORT) || routesContent.includes(LEGACY_ADDON_ROUTES_IMPORT) || routesContent.includes("...addonRoutes");
|
|
1762
|
-
await promises$1.unlink(path.join(targetDir, LEGACY_ADDON_ROUTES_FILE)).catch(() => void 0);
|
|
1763
|
-
if (imports.length > 0 || alreadyPatched2) {
|
|
1764
|
-
const fileContent = [
|
|
1765
|
-
'import type { ComponentType } from "react";',
|
|
1766
|
-
...imports.map((item) => `import ${item.identifier} from "${item.importPath}";`),
|
|
1767
|
-
"",
|
|
1768
|
-
"type AddonRouteConfig = {",
|
|
1769
|
-
" name: string;",
|
|
1770
|
-
" path: string;",
|
|
1771
|
-
" Component: ComponentType<Record<string, unknown>>;",
|
|
1772
|
-
" visible?: boolean;",
|
|
1773
|
-
"};",
|
|
1774
|
-
"",
|
|
1775
|
-
"export const addonRoutes: AddonRouteConfig[] = [",
|
|
1776
|
-
...imports.map(
|
|
1777
|
-
(item) => ` { name: ${JSON.stringify(item.name)}, path: ${JSON.stringify(item.route)}, Component: ${item.identifier},${item.visible === void 0 ? "" : ` visible: ${item.visible},`} },`
|
|
1778
|
-
),
|
|
1779
|
-
"];",
|
|
1780
|
-
""
|
|
1781
|
-
].join("\n");
|
|
1782
|
-
await promises$1.writeFile(path.join(targetDir, ADDON_ROUTES_FILE), fileContent);
|
|
1783
|
-
await ensureWebRoutesPatched(targetDir);
|
|
1784
|
-
}
|
|
1785
|
-
return;
|
|
1786
|
-
}
|
|
1787
|
-
const pageMembers = metas.flatMap(
|
|
1788
|
-
(meta) => meta.members.filter((member) => member.type === "page" && member.page?.mini).map((member) => member.page.mini)
|
|
1789
|
-
).sort((left, right) => left.pagePath.localeCompare(right.pagePath));
|
|
1790
|
-
const addonPages = pageMembers.map((page) => page.pagePath);
|
|
1791
|
-
const addonTabBarItems = pageMembers.filter((page) => page.tabBar).map((page) => ({
|
|
1792
|
-
pagePath: page.pagePath,
|
|
1793
|
-
...page.tabBar
|
|
1794
|
-
}));
|
|
1795
|
-
const appConfigFile = path.join(targetDir, "src", "app.config.ts");
|
|
1796
|
-
const appConfigContent = fs.existsSync(appConfigFile) ? await promises$1.readFile(appConfigFile, "utf8") : "";
|
|
1797
|
-
const alreadyPatched = appConfigContent.includes(ADDON_PAGES_IMPORT) || appConfigContent.includes(LEGACY_ADDON_PAGES_IMPORT) || appConfigContent.includes("...addonPages") || appConfigContent.includes("...addonTabBarItems");
|
|
1798
|
-
await promises$1.unlink(path.join(targetDir, LEGACY_ADDON_PAGES_FILE)).catch(() => void 0);
|
|
1799
|
-
if (addonPages.length > 0 || alreadyPatched) {
|
|
1800
|
-
const fileContent = [
|
|
1801
|
-
`export const addonPages = ${JSON.stringify(addonPages, null, 2)};`,
|
|
1802
|
-
"",
|
|
1803
|
-
`export const addonTabBarItems = ${JSON.stringify(addonTabBarItems, null, 2)};`,
|
|
1804
|
-
""
|
|
1805
|
-
].join("\n");
|
|
1806
|
-
await promises$1.writeFile(path.join(targetDir, ADDON_PAGES_FILE), fileContent);
|
|
1807
|
-
await ensureMiniAppConfigPatched(targetDir, addonTabBarItems.length > 0);
|
|
1808
|
-
}
|
|
1809
|
-
}
|
|
1810
1748
|
async function materializeAddon(options) {
|
|
1811
1749
|
const targetDir = path.resolve(options.targetDir);
|
|
1812
1750
|
const existingMetas = await listInstalledAddons(targetDir);
|
|
@@ -1850,19 +1788,26 @@ async function materializeAddon(options) {
|
|
|
1850
1788
|
});
|
|
1851
1789
|
await ensureParentDirectory(plan.metaPath);
|
|
1852
1790
|
await promises$1.writeFile(plan.metaPath, JSON.stringify(meta, null, 2));
|
|
1853
|
-
const nextMetas = existingMetas.filter((item) => item.name !== meta.name).concat(meta);
|
|
1854
|
-
await rebuildRegistryFiles(targetDir, plan.applicationType, nextMetas.filter((item) => item.applicationType === plan.applicationType));
|
|
1855
1791
|
if (options.installPackageDependencies && packageJsonFiles.length) {
|
|
1856
1792
|
await installPackageDependencies(targetDir);
|
|
1857
1793
|
}
|
|
1858
1794
|
const requirements = resolveInstallRequirements(plan.manifest);
|
|
1795
|
+
const promptContent = await readAddonPrompt(options.extractedDir, plan.manifest);
|
|
1796
|
+
const llmGuidance = buildAddonLlmGuidance({
|
|
1797
|
+
operation: options.mode,
|
|
1798
|
+
meta,
|
|
1799
|
+
requirements,
|
|
1800
|
+
npm,
|
|
1801
|
+
promptContent
|
|
1802
|
+
});
|
|
1859
1803
|
return {
|
|
1860
1804
|
meta,
|
|
1861
1805
|
writtenFiles: installedFiles.map((file) => file.path).concat(packageJsonFiles, restoredSettingsFiles, settingsResult.writtenFiles),
|
|
1862
1806
|
removedFiles,
|
|
1863
1807
|
requirements,
|
|
1864
1808
|
missingRequirements: buildMissingRequirements(requirements),
|
|
1865
|
-
npm
|
|
1809
|
+
npm,
|
|
1810
|
+
llmGuidance
|
|
1866
1811
|
};
|
|
1867
1812
|
}
|
|
1868
1813
|
async function installAddonFromExtractedDirectory(options) {
|
|
@@ -1887,6 +1832,33 @@ function createOrganizationHeaders(organizationCode) {
|
|
|
1887
1832
|
"x-organization-code": organizationCode
|
|
1888
1833
|
};
|
|
1889
1834
|
}
|
|
1835
|
+
function toAddonSearchResponse(response) {
|
|
1836
|
+
return {
|
|
1837
|
+
items: response.items.flatMap((addon2) => {
|
|
1838
|
+
const version = addon2.latestVersion;
|
|
1839
|
+
if (!version) {
|
|
1840
|
+
return [];
|
|
1841
|
+
}
|
|
1842
|
+
return [
|
|
1843
|
+
{
|
|
1844
|
+
name: addon2.name,
|
|
1845
|
+
version: version.version,
|
|
1846
|
+
installSpecifier: `${addon2.name}@${version.version}`,
|
|
1847
|
+
title: version.title,
|
|
1848
|
+
description: version.description,
|
|
1849
|
+
category: version.category,
|
|
1850
|
+
applicationTypes: version.applicationTypes,
|
|
1851
|
+
phases: version.phases,
|
|
1852
|
+
memberTypes: version.memberTypes,
|
|
1853
|
+
...addon2.imageUrl ? { imageUrl: addon2.imageUrl } : {}
|
|
1854
|
+
}
|
|
1855
|
+
];
|
|
1856
|
+
}),
|
|
1857
|
+
page: response.page,
|
|
1858
|
+
pageSize: response.pageSize,
|
|
1859
|
+
total: response.total
|
|
1860
|
+
};
|
|
1861
|
+
}
|
|
1890
1862
|
function parseAddonSpecifier(specifier) {
|
|
1891
1863
|
const trimmed = specifier.trim();
|
|
1892
1864
|
if (!trimmed) {
|
|
@@ -1912,11 +1884,12 @@ async function searchAddons(registry, options) {
|
|
|
1912
1884
|
if (options.scope) query.set("scope", options.scope);
|
|
1913
1885
|
if (options.page) query.set("page", String(options.page));
|
|
1914
1886
|
if (options.pageSize) query.set("pageSize", String(options.pageSize));
|
|
1915
|
-
|
|
1887
|
+
const response = await requestJson(registry, `/api/addons?${query.toString()}`, {
|
|
1916
1888
|
method: "GET",
|
|
1917
1889
|
headers: createOrganizationHeaders(options.organizationCode),
|
|
1918
1890
|
unwrapData: true
|
|
1919
1891
|
});
|
|
1892
|
+
return toAddonSearchResponse(response);
|
|
1920
1893
|
}
|
|
1921
1894
|
async function getAddon(registry, name, organizationCode) {
|
|
1922
1895
|
return await requestJson(registry, `/api/addons/${encodeURIComponent(name)}`, {
|
|
@@ -3496,6 +3469,41 @@ function formatLoginIdentity(user) {
|
|
|
3496
3469
|
function resolveAddonTargetDir(target) {
|
|
3497
3470
|
return target ? target : resolveNearestPackageRoot();
|
|
3498
3471
|
}
|
|
3472
|
+
function renderAddonInstallResult(result, operation, options) {
|
|
3473
|
+
const output = {
|
|
3474
|
+
success: true,
|
|
3475
|
+
operation,
|
|
3476
|
+
addon: {
|
|
3477
|
+
name: result.meta.name,
|
|
3478
|
+
version: result.meta.version,
|
|
3479
|
+
applicationType: result.meta.applicationType
|
|
3480
|
+
},
|
|
3481
|
+
llmGuidance: result.llmGuidance
|
|
3482
|
+
};
|
|
3483
|
+
if (options.json) {
|
|
3484
|
+
renderOutput(output, options);
|
|
3485
|
+
return;
|
|
3486
|
+
}
|
|
3487
|
+
const lines = [
|
|
3488
|
+
`Addon ${operation === "install" ? "installed" : "upgraded"}: ${result.meta.name}@${result.meta.version}`,
|
|
3489
|
+
`Application type: ${result.meta.applicationType}`,
|
|
3490
|
+
`Written files: ${result.writtenFiles.length}`
|
|
3491
|
+
];
|
|
3492
|
+
if (result.removedFiles.length) {
|
|
3493
|
+
lines.push(`Removed files: ${result.removedFiles.length}`);
|
|
3494
|
+
}
|
|
3495
|
+
if (result.llmGuidance.webRoutes?.length) {
|
|
3496
|
+
lines.push("Next: wire web routes from llmGuidance.webRoutes.");
|
|
3497
|
+
}
|
|
3498
|
+
if (result.llmGuidance.miniPages?.length) {
|
|
3499
|
+
lines.push("Next: wire mini pages from llmGuidance.miniPages.");
|
|
3500
|
+
}
|
|
3501
|
+
if (result.missingRequirements.envs?.length || result.missingRequirements.secrets?.length) {
|
|
3502
|
+
lines.push("Next: configure missing env/secrets from llmGuidance.requirements.");
|
|
3503
|
+
}
|
|
3504
|
+
lines.push("Use --json for LLM-readable integration guidance.");
|
|
3505
|
+
renderOutput(lines.join("\n"), options);
|
|
3506
|
+
}
|
|
3499
3507
|
function requireStack(value) {
|
|
3500
3508
|
if (value === "react-vite" || value === "taro") {
|
|
3501
3509
|
return value;
|
|
@@ -3658,7 +3666,7 @@ addJsonOption(addOrganizationOption(addRegistryOption(addon.command("install <sp
|
|
|
3658
3666
|
organizationCode: options.organizationCode,
|
|
3659
3667
|
installParameters: parseKeyValuePairs(options.set)
|
|
3660
3668
|
});
|
|
3661
|
-
|
|
3669
|
+
renderAddonInstallResult(result, "install", options);
|
|
3662
3670
|
});
|
|
3663
3671
|
addJsonOption(addOrganizationOption(addRegistryOption(addon.command("upgrade <specifier>").description("Upgrade an installed addon")))).option("--target <path>", "Application root directory, defaults to nearest package.json directory").addOption(new commander.Option("--application-type <type>", "Application type").choices(["web", "mini"])).option("--set <key=value>", "Install parameter", (value, previous = []) => previous.concat(value), []).action(async (specifier, options) => {
|
|
3664
3672
|
const registry = resolveRegistryFromOptions(options);
|
|
@@ -3670,7 +3678,7 @@ addJsonOption(addOrganizationOption(addRegistryOption(addon.command("upgrade <sp
|
|
|
3670
3678
|
organizationCode: options.organizationCode,
|
|
3671
3679
|
installParameters: parseKeyValuePairs(options.set)
|
|
3672
3680
|
});
|
|
3673
|
-
|
|
3681
|
+
renderAddonInstallResult(result, "upgrade", options);
|
|
3674
3682
|
});
|
|
3675
3683
|
addJsonOption(addon.command("list").description("List installed addons in an application")).option("--target <path>", "Application root directory, defaults to nearest package.json directory").action(async (options) => {
|
|
3676
3684
|
const installed = await listInstalledAddons(resolveAddonTargetDir(options.target));
|