@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/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
  }
@@ -883,6 +883,13 @@ function hasInstallRequirements(requirements) {
883
883
  function hasNpmDependencies(npm) {
884
884
  return Boolean(Object.keys(npm.dependencies ?? {}).length);
885
885
  }
886
+ function removePathExtension(path) {
887
+ return path.replace(/\.[^/.]+$/, "");
888
+ }
889
+ function toImportSpecifier(targetPath) {
890
+ const normalized = targetPath.replace(/\\/g, "/").replace(/^src\//, "@/");
891
+ return removePathExtension(normalized).replace(/\/index$/, "");
892
+ }
886
893
  function buildAddonLlmGuidance(input) {
887
894
  const pageMembers = input.meta.members.filter((member) => member.type === "page");
888
895
  const componentMembers = input.meta.members.filter((member) => member.type === "component");
@@ -901,16 +908,15 @@ function buildAddonLlmGuidance(input) {
901
908
  }));
902
909
  const components = componentMembers.map((member) => ({
903
910
  name: member.name,
904
- importFrom: member.targetPaths[0] || "",
905
- targetPaths: member.targetPaths
911
+ importFrom: member.targetPaths[0] ? toImportSpecifier(member.targetPaths[0]) : ""
906
912
  }));
907
913
  const settings = settingsMembers.map((member) => ({
908
914
  targetPath: member.settings?.targetPath || member.targetPaths[0] || "",
909
915
  paths: member.settings?.paths.map((item) => item.path) || []
910
916
  }));
911
917
  const instructions = [
912
- `Addon ${input.meta.name}@${input.meta.version} has been ${input.operation === "install" ? "installed" : "upgraded"} into the application files.`,
913
- "Do not run the install command again to apply integration steps; edit the application source files directly."
918
+ "Use the installed Addon files in the host application's existing pages, components, routes, dialogs, or preview areas.",
919
+ "Do not reinstall to complete integration; edit application source files directly."
914
920
  ];
915
921
  if (pageMembers.length > 0) {
916
922
  instructions.push("Wire the installed page members into the application's existing routing/configuration style.");
@@ -927,7 +933,7 @@ function buildAddonLlmGuidance(input) {
927
933
  return {
928
934
  summary: input.meta.manifest.description || input.meta.manifest.title || `Installed addon ${input.meta.name}@${input.meta.version}.`,
929
935
  instructions,
930
- skill: input.skillContent ? { path: "SKILL.md", content: input.skillContent } : void 0,
936
+ prompt: input.promptContent ? { path: "PROMPT.md", content: input.promptContent } : void 0,
931
937
  webRoutes: webRoutes.length ? webRoutes : void 0,
932
938
  miniPages: miniPages.length ? miniPages : void 0,
933
939
  components: components.length ? components : void 0,
@@ -936,24 +942,6 @@ function buildAddonLlmGuidance(input) {
936
942
  npm: hasNpmDependencies(input.npm) ? input.npm : void 0
937
943
  };
938
944
  }
939
- async function readAddonSkillGuidance(extractedDir, manifest) {
940
- const hasSkillMemberAtRoot = manifest.members.some((member) => {
941
- if (member.type !== "skill") {
942
- return false;
943
- }
944
- const sourcePath = resolveMemberSourcePath(member);
945
- return sourcePath === "SKILL.md";
946
- });
947
- if (hasSkillMemberAtRoot) {
948
- return void 0;
949
- }
950
- const skillPath = join(extractedDir, "SKILL.md");
951
- if (!existsSync(skillPath)) {
952
- return void 0;
953
- }
954
- const content = (await readFile(skillPath, "utf8")).trim();
955
- return content || void 0;
956
- }
957
945
  function getAddonMetaPath(targetDir, addonName) {
958
946
  return join(targetDir, "src", "addons", addonName, "meta.json");
959
947
  }
@@ -1759,13 +1747,13 @@ async function materializeAddon(options) {
1759
1747
  await installPackageDependencies(targetDir);
1760
1748
  }
1761
1749
  const requirements = resolveInstallRequirements(plan.manifest);
1762
- const skillContent = await readAddonSkillGuidance(options.extractedDir, plan.manifest);
1750
+ const promptContent = options.promptContent?.trim() || void 0;
1763
1751
  const llmGuidance = buildAddonLlmGuidance({
1764
1752
  operation: options.mode,
1765
1753
  meta,
1766
1754
  requirements,
1767
1755
  npm,
1768
- skillContent
1756
+ promptContent
1769
1757
  });
1770
1758
  return {
1771
1759
  meta,
@@ -1799,6 +1787,41 @@ function createOrganizationHeaders(organizationCode) {
1799
1787
  "x-organization-code": organizationCode
1800
1788
  };
1801
1789
  }
1790
+ function toAddonSearchResponse(response) {
1791
+ return {
1792
+ items: response.items.flatMap((addon2) => {
1793
+ const version = addon2.latestVersion;
1794
+ if (!version) {
1795
+ return [];
1796
+ }
1797
+ return [
1798
+ {
1799
+ name: addon2.name,
1800
+ version: version.version,
1801
+ installSpecifier: `${addon2.name}@${version.version}`,
1802
+ title: version.title,
1803
+ description: version.description,
1804
+ category: version.category,
1805
+ applicationTypes: version.applicationTypes,
1806
+ phases: version.phases,
1807
+ memberTypes: version.memberTypes,
1808
+ ...addon2.imageUrl ? { imageUrl: addon2.imageUrl } : {}
1809
+ }
1810
+ ];
1811
+ }),
1812
+ page: response.page,
1813
+ pageSize: response.pageSize,
1814
+ total: response.total
1815
+ };
1816
+ }
1817
+ async function readAddonPromptContent(sourceDir) {
1818
+ const promptPath = resolve(sourceDir, "PROMPT.md");
1819
+ if (!existsSync(promptPath)) {
1820
+ return void 0;
1821
+ }
1822
+ const content = (await readFile(promptPath, "utf8")).trim();
1823
+ return content || void 0;
1824
+ }
1802
1825
  function parseAddonSpecifier(specifier) {
1803
1826
  const trimmed = specifier.trim();
1804
1827
  if (!trimmed) {
@@ -1824,11 +1847,12 @@ async function searchAddons(registry, options) {
1824
1847
  if (options.scope) query.set("scope", options.scope);
1825
1848
  if (options.page) query.set("page", String(options.page));
1826
1849
  if (options.pageSize) query.set("pageSize", String(options.pageSize));
1827
- return await requestJson(registry, `/api/addons?${query.toString()}`, {
1850
+ const response = await requestJson(registry, `/api/addons?${query.toString()}`, {
1828
1851
  method: "GET",
1829
1852
  headers: createOrganizationHeaders(options.organizationCode),
1830
1853
  unwrapData: true
1831
1854
  });
1855
+ return toAddonSearchResponse(response);
1832
1856
  }
1833
1857
  async function getAddon(registry, name, organizationCode) {
1834
1858
  return await requestJson(registry, `/api/addons/${encodeURIComponent(name)}`, {
@@ -1919,6 +1943,7 @@ async function publishAddon(options) {
1919
1943
  tempArchiveDir = dirname(packaged.archivePath);
1920
1944
  }
1921
1945
  const manifest = await loadAddonManifestFromDirectory(manifestDir);
1946
+ const promptContent = isArchive ? void 0 : await readAddonPromptContent(sourcePath);
1922
1947
  const digest = sha256(archiveBuffer);
1923
1948
  return await withAccessToken(options.registry, async (accessToken) => {
1924
1949
  const headers = {
@@ -1957,7 +1982,8 @@ async function publishAddon(options) {
1957
1982
  headers,
1958
1983
  body: {
1959
1984
  sessionId: session.sessionId,
1960
- ...options.scope ? { scope: options.scope } : {}
1985
+ ...options.scope ? { scope: options.scope } : {},
1986
+ ...promptContent ? { promptContent } : {}
1961
1987
  },
1962
1988
  unwrapData: true
1963
1989
  }
@@ -2021,6 +2047,7 @@ async function resolveInstallVersion(registry, name, requestedVersion, organizat
2021
2047
  async function installAddonFromRegistry(options) {
2022
2048
  const { name, version: requestedVersion } = parseAddonSpecifier(options.specifier);
2023
2049
  const version = await resolveInstallVersion(options.registry, name, requestedVersion, options.organizationCode);
2050
+ const versionDetail = await getAddonVersion(options.registry, name, version, options.organizationCode);
2024
2051
  const archiveBuffer = await downloadAddonArchiveBuffer(options.registry, name, version, options.organizationCode);
2025
2052
  const extractedDir = await extractAddonArchiveBuffer(archiveBuffer);
2026
2053
  try {
@@ -2031,7 +2058,8 @@ async function installAddonFromRegistry(options) {
2031
2058
  applicationType: options.applicationType,
2032
2059
  organizationCode: options.organizationCode,
2033
2060
  installParameters: options.installParameters,
2034
- installPackageDependencies: true
2061
+ installPackageDependencies: true,
2062
+ promptContent: versionDetail.promptContent ?? void 0
2035
2063
  });
2036
2064
  } finally {
2037
2065
  await removeTempDirectory(extractedDir).catch(() => void 0);
@@ -2040,6 +2068,7 @@ async function installAddonFromRegistry(options) {
2040
2068
  async function upgradeAddonFromRegistry(options) {
2041
2069
  const { name, version: requestedVersion } = parseAddonSpecifier(options.specifier);
2042
2070
  const version = await resolveInstallVersion(options.registry, name, requestedVersion, options.organizationCode);
2071
+ const versionDetail = await getAddonVersion(options.registry, name, version, options.organizationCode);
2043
2072
  const archiveBuffer = await downloadAddonArchiveBuffer(options.registry, name, version, options.organizationCode);
2044
2073
  const extractedDir = await extractAddonArchiveBuffer(archiveBuffer);
2045
2074
  try {
@@ -2050,7 +2079,8 @@ async function upgradeAddonFromRegistry(options) {
2050
2079
  applicationType: options.applicationType,
2051
2080
  organizationCode: options.organizationCode,
2052
2081
  installParameters: options.installParameters,
2053
- installPackageDependencies: true
2082
+ installPackageDependencies: true,
2083
+ promptContent: versionDetail.promptContent ?? void 0
2054
2084
  });
2055
2085
  } finally {
2056
2086
  await removeTempDirectory(extractedDir).catch(() => void 0);
@@ -3417,12 +3447,6 @@ function renderAddonInstallResult(result, operation, options) {
3417
3447
  version: result.meta.version,
3418
3448
  applicationType: result.meta.applicationType
3419
3449
  },
3420
- files: {
3421
- written: result.writtenFiles,
3422
- removed: result.removedFiles
3423
- },
3424
- npm: Object.keys(result.npm.dependencies ?? {}).length ? result.npm : void 0,
3425
- missingRequirements: result.missingRequirements.envs?.length || result.missingRequirements.secrets?.length ? result.missingRequirements : void 0,
3426
3450
  llmGuidance: result.llmGuidance
3427
3451
  };
3428
3452
  if (options.json) {
@@ -3443,7 +3467,7 @@ function renderAddonInstallResult(result, operation, options) {
3443
3467
  if (result.llmGuidance.miniPages?.length) {
3444
3468
  lines.push("Next: wire mini pages from llmGuidance.miniPages.");
3445
3469
  }
3446
- if (output.missingRequirements) {
3470
+ if (result.missingRequirements.envs?.length || result.missingRequirements.secrets?.length) {
3447
3471
  lines.push("Next: configure missing env/secrets from llmGuidance.requirements.");
3448
3472
  }
3449
3473
  lines.push("Use --json for LLM-readable integration guidance.");