@amaster.ai/cli 1.1.33 → 1.1.35
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 +1 -1
- package/dist/cli.cjs +44 -32
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +44 -32
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -150,7 +150,7 @@ Addon 可在 `addon.json` 中声明安装后的运行配置要求:
|
|
|
150
150
|
显式接入指导:
|
|
151
151
|
|
|
152
152
|
- Addon 包根目录可以放 `PROMPT.md`
|
|
153
|
-
- `PROMPT.md`
|
|
153
|
+
- `PROMPT.md` 不会进入安装包,也不会安装到应用工程;发布时会作为版本提示词元数据保存,并在安装/升级结果的 `llmGuidance.prompt` 中返回给大模型
|
|
154
154
|
- 如果 Addon 本身就是一个 skill 资源,应在 `addon.json.members` 中显式声明 `type: "skill"`;普通 Addon 的根 `PROMPT.md` 只作为模型指导
|
|
155
155
|
|
|
156
156
|
升级策略:
|
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
|
}
|
|
@@ -917,9 +917,17 @@ function toImportSpecifier(targetPath) {
|
|
|
917
917
|
const normalized = targetPath.replace(/\\/g, "/").replace(/^src\//, "@/");
|
|
918
918
|
return removePathExtension(normalized).replace(/\/index$/, "");
|
|
919
919
|
}
|
|
920
|
+
function resolveInstalledAddonDisplay(meta) {
|
|
921
|
+
const legacyMeta = meta;
|
|
922
|
+
return {
|
|
923
|
+
title: meta.display?.title ?? legacyMeta.manifest?.title,
|
|
924
|
+
description: legacyMeta.manifest?.description
|
|
925
|
+
};
|
|
926
|
+
}
|
|
920
927
|
function buildAddonLlmGuidance(input) {
|
|
921
928
|
const pageMembers = input.meta.members.filter((member) => member.type === "page");
|
|
922
929
|
const componentMembers = input.meta.members.filter((member) => member.type === "component");
|
|
930
|
+
const functionMembers = input.meta.members.filter((member) => member.type === "function");
|
|
923
931
|
const settingsMembers = input.meta.members.filter((member) => member.type === "settings");
|
|
924
932
|
const webRoutes = input.meta.members.filter((member) => member.type === "page" && member.page?.web).map((member) => ({
|
|
925
933
|
route: member.page.web.route,
|
|
@@ -937,10 +945,15 @@ function buildAddonLlmGuidance(input) {
|
|
|
937
945
|
name: member.name,
|
|
938
946
|
importFrom: member.targetPaths[0] ? toImportSpecifier(member.targetPaths[0]) : ""
|
|
939
947
|
}));
|
|
948
|
+
const functions = functionMembers.map((member) => ({
|
|
949
|
+
name: member.name,
|
|
950
|
+
targetPaths: member.targetPaths
|
|
951
|
+
}));
|
|
940
952
|
const settings = settingsMembers.map((member) => ({
|
|
941
953
|
targetPath: member.settings?.targetPath || member.targetPaths[0] || "",
|
|
942
954
|
paths: member.settings?.paths.map((item) => item.path) || []
|
|
943
955
|
}));
|
|
956
|
+
const display = resolveInstalledAddonDisplay(input.meta);
|
|
944
957
|
const instructions = [
|
|
945
958
|
"Use the installed Addon files in the host application's existing pages, components, routes, dialogs, or preview areas.",
|
|
946
959
|
"Do not reinstall to complete integration; edit application source files directly."
|
|
@@ -951,6 +964,9 @@ function buildAddonLlmGuidance(input) {
|
|
|
951
964
|
if (componentMembers.length > 0) {
|
|
952
965
|
instructions.push("Use installed component members from their target paths where the application needs them.");
|
|
953
966
|
}
|
|
967
|
+
if (functionMembers.length > 0) {
|
|
968
|
+
instructions.push("Use installed function members by invoking their function names from the host application.");
|
|
969
|
+
}
|
|
954
970
|
if (hasInstallRequirements(input.requirements)) {
|
|
955
971
|
instructions.push("Configure the declared env/secret requirements before running or deploying the application.");
|
|
956
972
|
}
|
|
@@ -958,35 +974,18 @@ function buildAddonLlmGuidance(input) {
|
|
|
958
974
|
instructions.push("NPM dependencies have been written to package.json; avoid adding duplicate dependency entries.");
|
|
959
975
|
}
|
|
960
976
|
return {
|
|
961
|
-
summary:
|
|
977
|
+
summary: display.description || display.title || `Installed addon ${input.meta.name}@${input.meta.version}.`,
|
|
962
978
|
instructions,
|
|
963
979
|
prompt: input.promptContent ? { path: "PROMPT.md", content: input.promptContent } : void 0,
|
|
964
980
|
webRoutes: webRoutes.length ? webRoutes : void 0,
|
|
965
981
|
miniPages: miniPages.length ? miniPages : void 0,
|
|
966
982
|
components: components.length ? components : void 0,
|
|
983
|
+
functions: functions.length ? functions : void 0,
|
|
967
984
|
settings: settings.length ? settings : void 0,
|
|
968
985
|
requirements: hasInstallRequirements(input.requirements) ? input.requirements : void 0,
|
|
969
986
|
npm: hasNpmDependencies(input.npm) ? input.npm : void 0
|
|
970
987
|
};
|
|
971
988
|
}
|
|
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
|
-
}
|
|
990
989
|
function getAddonMetaPath(targetDir, addonName) {
|
|
991
990
|
return path.join(targetDir, "src", "addons", addonName, "meta.json");
|
|
992
991
|
}
|
|
@@ -1173,6 +1172,9 @@ async function buildInstallPlan(options) {
|
|
|
1173
1172
|
case "datasource":
|
|
1174
1173
|
targetBaseRelativeDir = path.join("src", "db", "datasource");
|
|
1175
1174
|
break;
|
|
1175
|
+
case "function":
|
|
1176
|
+
targetBaseRelativeDir = path.join("src", "functions");
|
|
1177
|
+
break;
|
|
1176
1178
|
default:
|
|
1177
1179
|
throw new Error(`Unsupported addon member type: ${member.type}`);
|
|
1178
1180
|
}
|
|
@@ -1246,13 +1248,8 @@ function buildInstalledAddonMeta(options) {
|
|
|
1246
1248
|
organizationCode: options.organizationCode,
|
|
1247
1249
|
installedAt,
|
|
1248
1250
|
updatedAt: now,
|
|
1249
|
-
|
|
1250
|
-
title: options.manifest.display.title
|
|
1251
|
-
description: options.manifest.display.description,
|
|
1252
|
-
category: options.manifest.display.category,
|
|
1253
|
-
applicationTypes: options.manifest.compatibility.applicationTypes,
|
|
1254
|
-
phases: options.manifest.compatibility.phases,
|
|
1255
|
-
memberTypes: [...new Set(options.manifest.members.map((member) => member.type))]
|
|
1251
|
+
display: {
|
|
1252
|
+
title: options.manifest.display.title
|
|
1256
1253
|
},
|
|
1257
1254
|
installParameters: options.installParameters,
|
|
1258
1255
|
requirements: resolveInstallRequirements(options.manifest),
|
|
@@ -1787,12 +1784,13 @@ async function materializeAddon(options) {
|
|
|
1787
1784
|
installedAt: previousMeta?.installedAt
|
|
1788
1785
|
});
|
|
1789
1786
|
await ensureParentDirectory(plan.metaPath);
|
|
1790
|
-
await promises$1.writeFile(plan.metaPath, JSON.stringify(meta, null, 2)
|
|
1787
|
+
await promises$1.writeFile(plan.metaPath, `${JSON.stringify(meta, null, 2)}
|
|
1788
|
+
`);
|
|
1791
1789
|
if (options.installPackageDependencies && packageJsonFiles.length) {
|
|
1792
1790
|
await installPackageDependencies(targetDir);
|
|
1793
1791
|
}
|
|
1794
1792
|
const requirements = resolveInstallRequirements(plan.manifest);
|
|
1795
|
-
const promptContent =
|
|
1793
|
+
const promptContent = options.promptContent?.trim() || void 0;
|
|
1796
1794
|
const llmGuidance = buildAddonLlmGuidance({
|
|
1797
1795
|
operation: options.mode,
|
|
1798
1796
|
meta,
|
|
@@ -1859,6 +1857,14 @@ function toAddonSearchResponse(response) {
|
|
|
1859
1857
|
total: response.total
|
|
1860
1858
|
};
|
|
1861
1859
|
}
|
|
1860
|
+
async function readAddonPromptContent(sourceDir) {
|
|
1861
|
+
const promptPath = path.resolve(sourceDir, "PROMPT.md");
|
|
1862
|
+
if (!fs.existsSync(promptPath)) {
|
|
1863
|
+
return void 0;
|
|
1864
|
+
}
|
|
1865
|
+
const content = (await promises$1.readFile(promptPath, "utf8")).trim();
|
|
1866
|
+
return content || void 0;
|
|
1867
|
+
}
|
|
1862
1868
|
function parseAddonSpecifier(specifier) {
|
|
1863
1869
|
const trimmed = specifier.trim();
|
|
1864
1870
|
if (!trimmed) {
|
|
@@ -1980,6 +1986,7 @@ async function publishAddon(options) {
|
|
|
1980
1986
|
tempArchiveDir = path.dirname(packaged.archivePath);
|
|
1981
1987
|
}
|
|
1982
1988
|
const manifest = await loadAddonManifestFromDirectory(manifestDir);
|
|
1989
|
+
const promptContent = isArchive ? void 0 : await readAddonPromptContent(sourcePath);
|
|
1983
1990
|
const digest = sha256(archiveBuffer);
|
|
1984
1991
|
return await withAccessToken(options.registry, async (accessToken) => {
|
|
1985
1992
|
const headers = {
|
|
@@ -2018,7 +2025,8 @@ async function publishAddon(options) {
|
|
|
2018
2025
|
headers,
|
|
2019
2026
|
body: {
|
|
2020
2027
|
sessionId: session.sessionId,
|
|
2021
|
-
...options.scope ? { scope: options.scope } : {}
|
|
2028
|
+
...options.scope ? { scope: options.scope } : {},
|
|
2029
|
+
...promptContent ? { promptContent } : {}
|
|
2022
2030
|
},
|
|
2023
2031
|
unwrapData: true
|
|
2024
2032
|
}
|
|
@@ -2082,6 +2090,7 @@ async function resolveInstallVersion(registry, name, requestedVersion, organizat
|
|
|
2082
2090
|
async function installAddonFromRegistry(options) {
|
|
2083
2091
|
const { name, version: requestedVersion } = parseAddonSpecifier(options.specifier);
|
|
2084
2092
|
const version = await resolveInstallVersion(options.registry, name, requestedVersion, options.organizationCode);
|
|
2093
|
+
const versionDetail = await getAddonVersion(options.registry, name, version, options.organizationCode);
|
|
2085
2094
|
const archiveBuffer = await downloadAddonArchiveBuffer(options.registry, name, version, options.organizationCode);
|
|
2086
2095
|
const extractedDir = await extractAddonArchiveBuffer(archiveBuffer);
|
|
2087
2096
|
try {
|
|
@@ -2092,7 +2101,8 @@ async function installAddonFromRegistry(options) {
|
|
|
2092
2101
|
applicationType: options.applicationType,
|
|
2093
2102
|
organizationCode: options.organizationCode,
|
|
2094
2103
|
installParameters: options.installParameters,
|
|
2095
|
-
installPackageDependencies: true
|
|
2104
|
+
installPackageDependencies: true,
|
|
2105
|
+
promptContent: versionDetail.promptContent ?? void 0
|
|
2096
2106
|
});
|
|
2097
2107
|
} finally {
|
|
2098
2108
|
await removeTempDirectory(extractedDir).catch(() => void 0);
|
|
@@ -2101,6 +2111,7 @@ async function installAddonFromRegistry(options) {
|
|
|
2101
2111
|
async function upgradeAddonFromRegistry(options) {
|
|
2102
2112
|
const { name, version: requestedVersion } = parseAddonSpecifier(options.specifier);
|
|
2103
2113
|
const version = await resolveInstallVersion(options.registry, name, requestedVersion, options.organizationCode);
|
|
2114
|
+
const versionDetail = await getAddonVersion(options.registry, name, version, options.organizationCode);
|
|
2104
2115
|
const archiveBuffer = await downloadAddonArchiveBuffer(options.registry, name, version, options.organizationCode);
|
|
2105
2116
|
const extractedDir = await extractAddonArchiveBuffer(archiveBuffer);
|
|
2106
2117
|
try {
|
|
@@ -2111,7 +2122,8 @@ async function upgradeAddonFromRegistry(options) {
|
|
|
2111
2122
|
applicationType: options.applicationType,
|
|
2112
2123
|
organizationCode: options.organizationCode,
|
|
2113
2124
|
installParameters: options.installParameters,
|
|
2114
|
-
installPackageDependencies: true
|
|
2125
|
+
installPackageDependencies: true,
|
|
2126
|
+
promptContent: versionDetail.promptContent ?? void 0
|
|
2115
2127
|
});
|
|
2116
2128
|
} finally {
|
|
2117
2129
|
await removeTempDirectory(extractedDir).catch(() => void 0);
|