@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/dist/cli.js
CHANGED
|
@@ -14,7 +14,7 @@ import { promisify } from 'util';
|
|
|
14
14
|
import YAML2 from 'yaml';
|
|
15
15
|
import ts from 'typescript';
|
|
16
16
|
|
|
17
|
-
var EXCLUDED_NAMES = /* @__PURE__ */ new Set([".git", "node_modules", ".DS_Store"]);
|
|
17
|
+
var EXCLUDED_NAMES = /* @__PURE__ */ new Set([".git", "node_modules", ".DS_Store", "PROMPT.md"]);
|
|
18
18
|
function sha256(buffer) {
|
|
19
19
|
return `sha256:${createHash("sha256").update(buffer).digest("hex")}`;
|
|
20
20
|
}
|
|
@@ -890,9 +890,17 @@ function toImportSpecifier(targetPath) {
|
|
|
890
890
|
const normalized = targetPath.replace(/\\/g, "/").replace(/^src\//, "@/");
|
|
891
891
|
return removePathExtension(normalized).replace(/\/index$/, "");
|
|
892
892
|
}
|
|
893
|
+
function resolveInstalledAddonDisplay(meta) {
|
|
894
|
+
const legacyMeta = meta;
|
|
895
|
+
return {
|
|
896
|
+
title: meta.display?.title ?? legacyMeta.manifest?.title,
|
|
897
|
+
description: legacyMeta.manifest?.description
|
|
898
|
+
};
|
|
899
|
+
}
|
|
893
900
|
function buildAddonLlmGuidance(input) {
|
|
894
901
|
const pageMembers = input.meta.members.filter((member) => member.type === "page");
|
|
895
902
|
const componentMembers = input.meta.members.filter((member) => member.type === "component");
|
|
903
|
+
const functionMembers = input.meta.members.filter((member) => member.type === "function");
|
|
896
904
|
const settingsMembers = input.meta.members.filter((member) => member.type === "settings");
|
|
897
905
|
const webRoutes = input.meta.members.filter((member) => member.type === "page" && member.page?.web).map((member) => ({
|
|
898
906
|
route: member.page.web.route,
|
|
@@ -910,10 +918,15 @@ function buildAddonLlmGuidance(input) {
|
|
|
910
918
|
name: member.name,
|
|
911
919
|
importFrom: member.targetPaths[0] ? toImportSpecifier(member.targetPaths[0]) : ""
|
|
912
920
|
}));
|
|
921
|
+
const functions = functionMembers.map((member) => ({
|
|
922
|
+
name: member.name,
|
|
923
|
+
targetPaths: member.targetPaths
|
|
924
|
+
}));
|
|
913
925
|
const settings = settingsMembers.map((member) => ({
|
|
914
926
|
targetPath: member.settings?.targetPath || member.targetPaths[0] || "",
|
|
915
927
|
paths: member.settings?.paths.map((item) => item.path) || []
|
|
916
928
|
}));
|
|
929
|
+
const display = resolveInstalledAddonDisplay(input.meta);
|
|
917
930
|
const instructions = [
|
|
918
931
|
"Use the installed Addon files in the host application's existing pages, components, routes, dialogs, or preview areas.",
|
|
919
932
|
"Do not reinstall to complete integration; edit application source files directly."
|
|
@@ -924,6 +937,9 @@ function buildAddonLlmGuidance(input) {
|
|
|
924
937
|
if (componentMembers.length > 0) {
|
|
925
938
|
instructions.push("Use installed component members from their target paths where the application needs them.");
|
|
926
939
|
}
|
|
940
|
+
if (functionMembers.length > 0) {
|
|
941
|
+
instructions.push("Use installed function members by invoking their function names from the host application.");
|
|
942
|
+
}
|
|
927
943
|
if (hasInstallRequirements(input.requirements)) {
|
|
928
944
|
instructions.push("Configure the declared env/secret requirements before running or deploying the application.");
|
|
929
945
|
}
|
|
@@ -931,35 +947,18 @@ function buildAddonLlmGuidance(input) {
|
|
|
931
947
|
instructions.push("NPM dependencies have been written to package.json; avoid adding duplicate dependency entries.");
|
|
932
948
|
}
|
|
933
949
|
return {
|
|
934
|
-
summary:
|
|
950
|
+
summary: display.description || display.title || `Installed addon ${input.meta.name}@${input.meta.version}.`,
|
|
935
951
|
instructions,
|
|
936
952
|
prompt: input.promptContent ? { path: "PROMPT.md", content: input.promptContent } : void 0,
|
|
937
953
|
webRoutes: webRoutes.length ? webRoutes : void 0,
|
|
938
954
|
miniPages: miniPages.length ? miniPages : void 0,
|
|
939
955
|
components: components.length ? components : void 0,
|
|
956
|
+
functions: functions.length ? functions : void 0,
|
|
940
957
|
settings: settings.length ? settings : void 0,
|
|
941
958
|
requirements: hasInstallRequirements(input.requirements) ? input.requirements : void 0,
|
|
942
959
|
npm: hasNpmDependencies(input.npm) ? input.npm : void 0
|
|
943
960
|
};
|
|
944
961
|
}
|
|
945
|
-
async function readAddonPrompt(extractedDir, manifest) {
|
|
946
|
-
const hasPromptMemberAtRoot = manifest.members.some((member) => {
|
|
947
|
-
if (member.type !== "skill") {
|
|
948
|
-
return false;
|
|
949
|
-
}
|
|
950
|
-
const sourcePath = resolveMemberSourcePath(member);
|
|
951
|
-
return sourcePath === "PROMPT.md";
|
|
952
|
-
});
|
|
953
|
-
if (hasPromptMemberAtRoot) {
|
|
954
|
-
return void 0;
|
|
955
|
-
}
|
|
956
|
-
const promptPath = join(extractedDir, "PROMPT.md");
|
|
957
|
-
if (!existsSync(promptPath)) {
|
|
958
|
-
return void 0;
|
|
959
|
-
}
|
|
960
|
-
const content = (await readFile(promptPath, "utf8")).trim();
|
|
961
|
-
return content || void 0;
|
|
962
|
-
}
|
|
963
962
|
function getAddonMetaPath(targetDir, addonName) {
|
|
964
963
|
return join(targetDir, "src", "addons", addonName, "meta.json");
|
|
965
964
|
}
|
|
@@ -1146,6 +1145,9 @@ async function buildInstallPlan(options) {
|
|
|
1146
1145
|
case "datasource":
|
|
1147
1146
|
targetBaseRelativeDir = join("src", "db", "datasource");
|
|
1148
1147
|
break;
|
|
1148
|
+
case "function":
|
|
1149
|
+
targetBaseRelativeDir = join("src", "functions");
|
|
1150
|
+
break;
|
|
1149
1151
|
default:
|
|
1150
1152
|
throw new Error(`Unsupported addon member type: ${member.type}`);
|
|
1151
1153
|
}
|
|
@@ -1219,13 +1221,8 @@ function buildInstalledAddonMeta(options) {
|
|
|
1219
1221
|
organizationCode: options.organizationCode,
|
|
1220
1222
|
installedAt,
|
|
1221
1223
|
updatedAt: now,
|
|
1222
|
-
|
|
1223
|
-
title: options.manifest.display.title
|
|
1224
|
-
description: options.manifest.display.description,
|
|
1225
|
-
category: options.manifest.display.category,
|
|
1226
|
-
applicationTypes: options.manifest.compatibility.applicationTypes,
|
|
1227
|
-
phases: options.manifest.compatibility.phases,
|
|
1228
|
-
memberTypes: [...new Set(options.manifest.members.map((member) => member.type))]
|
|
1224
|
+
display: {
|
|
1225
|
+
title: options.manifest.display.title
|
|
1229
1226
|
},
|
|
1230
1227
|
installParameters: options.installParameters,
|
|
1231
1228
|
requirements: resolveInstallRequirements(options.manifest),
|
|
@@ -1760,12 +1757,13 @@ async function materializeAddon(options) {
|
|
|
1760
1757
|
installedAt: previousMeta?.installedAt
|
|
1761
1758
|
});
|
|
1762
1759
|
await ensureParentDirectory(plan.metaPath);
|
|
1763
|
-
await writeFile(plan.metaPath, JSON.stringify(meta, null, 2)
|
|
1760
|
+
await writeFile(plan.metaPath, `${JSON.stringify(meta, null, 2)}
|
|
1761
|
+
`);
|
|
1764
1762
|
if (options.installPackageDependencies && packageJsonFiles.length) {
|
|
1765
1763
|
await installPackageDependencies(targetDir);
|
|
1766
1764
|
}
|
|
1767
1765
|
const requirements = resolveInstallRequirements(plan.manifest);
|
|
1768
|
-
const promptContent =
|
|
1766
|
+
const promptContent = options.promptContent?.trim() || void 0;
|
|
1769
1767
|
const llmGuidance = buildAddonLlmGuidance({
|
|
1770
1768
|
operation: options.mode,
|
|
1771
1769
|
meta,
|
|
@@ -1832,6 +1830,14 @@ function toAddonSearchResponse(response) {
|
|
|
1832
1830
|
total: response.total
|
|
1833
1831
|
};
|
|
1834
1832
|
}
|
|
1833
|
+
async function readAddonPromptContent(sourceDir) {
|
|
1834
|
+
const promptPath = resolve(sourceDir, "PROMPT.md");
|
|
1835
|
+
if (!existsSync(promptPath)) {
|
|
1836
|
+
return void 0;
|
|
1837
|
+
}
|
|
1838
|
+
const content = (await readFile(promptPath, "utf8")).trim();
|
|
1839
|
+
return content || void 0;
|
|
1840
|
+
}
|
|
1835
1841
|
function parseAddonSpecifier(specifier) {
|
|
1836
1842
|
const trimmed = specifier.trim();
|
|
1837
1843
|
if (!trimmed) {
|
|
@@ -1953,6 +1959,7 @@ async function publishAddon(options) {
|
|
|
1953
1959
|
tempArchiveDir = dirname(packaged.archivePath);
|
|
1954
1960
|
}
|
|
1955
1961
|
const manifest = await loadAddonManifestFromDirectory(manifestDir);
|
|
1962
|
+
const promptContent = isArchive ? void 0 : await readAddonPromptContent(sourcePath);
|
|
1956
1963
|
const digest = sha256(archiveBuffer);
|
|
1957
1964
|
return await withAccessToken(options.registry, async (accessToken) => {
|
|
1958
1965
|
const headers = {
|
|
@@ -1991,7 +1998,8 @@ async function publishAddon(options) {
|
|
|
1991
1998
|
headers,
|
|
1992
1999
|
body: {
|
|
1993
2000
|
sessionId: session.sessionId,
|
|
1994
|
-
...options.scope ? { scope: options.scope } : {}
|
|
2001
|
+
...options.scope ? { scope: options.scope } : {},
|
|
2002
|
+
...promptContent ? { promptContent } : {}
|
|
1995
2003
|
},
|
|
1996
2004
|
unwrapData: true
|
|
1997
2005
|
}
|
|
@@ -2055,6 +2063,7 @@ async function resolveInstallVersion(registry, name, requestedVersion, organizat
|
|
|
2055
2063
|
async function installAddonFromRegistry(options) {
|
|
2056
2064
|
const { name, version: requestedVersion } = parseAddonSpecifier(options.specifier);
|
|
2057
2065
|
const version = await resolveInstallVersion(options.registry, name, requestedVersion, options.organizationCode);
|
|
2066
|
+
const versionDetail = await getAddonVersion(options.registry, name, version, options.organizationCode);
|
|
2058
2067
|
const archiveBuffer = await downloadAddonArchiveBuffer(options.registry, name, version, options.organizationCode);
|
|
2059
2068
|
const extractedDir = await extractAddonArchiveBuffer(archiveBuffer);
|
|
2060
2069
|
try {
|
|
@@ -2065,7 +2074,8 @@ async function installAddonFromRegistry(options) {
|
|
|
2065
2074
|
applicationType: options.applicationType,
|
|
2066
2075
|
organizationCode: options.organizationCode,
|
|
2067
2076
|
installParameters: options.installParameters,
|
|
2068
|
-
installPackageDependencies: true
|
|
2077
|
+
installPackageDependencies: true,
|
|
2078
|
+
promptContent: versionDetail.promptContent ?? void 0
|
|
2069
2079
|
});
|
|
2070
2080
|
} finally {
|
|
2071
2081
|
await removeTempDirectory(extractedDir).catch(() => void 0);
|
|
@@ -2074,6 +2084,7 @@ async function installAddonFromRegistry(options) {
|
|
|
2074
2084
|
async function upgradeAddonFromRegistry(options) {
|
|
2075
2085
|
const { name, version: requestedVersion } = parseAddonSpecifier(options.specifier);
|
|
2076
2086
|
const version = await resolveInstallVersion(options.registry, name, requestedVersion, options.organizationCode);
|
|
2087
|
+
const versionDetail = await getAddonVersion(options.registry, name, version, options.organizationCode);
|
|
2077
2088
|
const archiveBuffer = await downloadAddonArchiveBuffer(options.registry, name, version, options.organizationCode);
|
|
2078
2089
|
const extractedDir = await extractAddonArchiveBuffer(archiveBuffer);
|
|
2079
2090
|
try {
|
|
@@ -2084,7 +2095,8 @@ async function upgradeAddonFromRegistry(options) {
|
|
|
2084
2095
|
applicationType: options.applicationType,
|
|
2085
2096
|
organizationCode: options.organizationCode,
|
|
2086
2097
|
installParameters: options.installParameters,
|
|
2087
|
-
installPackageDependencies: true
|
|
2098
|
+
installPackageDependencies: true,
|
|
2099
|
+
promptContent: versionDetail.promptContent ?? void 0
|
|
2088
2100
|
});
|
|
2089
2101
|
} finally {
|
|
2090
2102
|
await removeTempDirectory(extractedDir).catch(() => void 0);
|