@agentprismform/agent-plugin 1.3.1 → 1.4.0
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/bin/form-agent-mcp.cjs +233 -37
- package/bin/form-agent.cjs +245 -54
- package/package.json +2 -2
- package/preview/modern-preview.css +1 -1
- package/preview/modern-preview.iife.js +6 -6
- package/skills/form-schema-author/SKILL.md +12 -0
package/bin/form-agent-mcp.cjs
CHANGED
|
@@ -16281,6 +16281,7 @@ var require_v2Core = __commonJS({
|
|
|
16281
16281
|
"packages/form-agent/src/v2Core.cjs"(exports2, module2) {
|
|
16282
16282
|
"use strict";
|
|
16283
16283
|
var fs = require("node:fs");
|
|
16284
|
+
var os2 = require("node:os");
|
|
16284
16285
|
var path2 = require("node:path");
|
|
16285
16286
|
var crypto = require("node:crypto");
|
|
16286
16287
|
var { FormCore } = require_dist();
|
|
@@ -16677,7 +16678,18 @@ var require_v2Core = __commonJS({
|
|
|
16677
16678
|
function escapeInlineScript(text) {
|
|
16678
16679
|
return String(text).replace(/<\/(script)/gi, "<\\/$1");
|
|
16679
16680
|
}
|
|
16680
|
-
function
|
|
16681
|
+
function normalizeSubmitUrl(raw) {
|
|
16682
|
+
if (raw === void 0 || raw === null) return "";
|
|
16683
|
+
const trimmed = String(raw).trim();
|
|
16684
|
+
if (!trimmed) return "";
|
|
16685
|
+
if (!/^https?:\/\//i.test(trimmed)) {
|
|
16686
|
+
throw Object.assign(new Error(`\u65E0\u6548\u7684 submitUrl\uFF1A${trimmed}\uFF08\u4EC5\u652F\u6301 http:// \u6216 https:// \u5730\u5740\uFF09`), {
|
|
16687
|
+
code: "INVALID_ARGUMENT"
|
|
16688
|
+
});
|
|
16689
|
+
}
|
|
16690
|
+
return trimmed;
|
|
16691
|
+
}
|
|
16692
|
+
function renderStandaloneHtml({ schema, themeConfig, mode, locale, submitUrl, assetsDir }) {
|
|
16681
16693
|
const normalizedTheme = themeConfig ? { ...themeConfig } : { version: "1.0.0", skin: "fin-minimal", override: {}, formMode: "flat", showProgressBar: true };
|
|
16682
16694
|
const effectiveMode = mode === "final" || normalizedTheme.mode === "final" ? "final" : "preview";
|
|
16683
16695
|
if (effectiveMode === "final") {
|
|
@@ -16687,6 +16699,7 @@ var require_v2Core = __commonJS({
|
|
|
16687
16699
|
if (locale !== void 0 || normalizedTheme.locale) {
|
|
16688
16700
|
normalizedTheme.locale = effectiveLocale;
|
|
16689
16701
|
}
|
|
16702
|
+
const effectiveSubmitUrl = normalizeSubmitUrl(submitUrl);
|
|
16690
16703
|
const jsPath = path2.join(assetsDir, "modern-preview.iife.js");
|
|
16691
16704
|
const cssPath = path2.join(assetsDir, "modern-preview.css");
|
|
16692
16705
|
if (!fs.existsSync(jsPath) || !fs.existsSync(cssPath)) {
|
|
@@ -16698,6 +16711,8 @@ var require_v2Core = __commonJS({
|
|
|
16698
16711
|
const cssCode = fs.readFileSync(cssPath, "utf8");
|
|
16699
16712
|
const safeTitle = String(schema.title || (effectiveLocale === "en-US" ? "FormSchema Live Preview" : "FormSchema \u5B9E\u65F6\u9884\u89C8")).replace(/[<>&"]/g, "");
|
|
16700
16713
|
const pageTitle = effectiveMode === "final" ? safeTitle : `${safeTitle} \xB7 FormSchema Preview`;
|
|
16714
|
+
const submitUrlScriptLine = effectiveSubmitUrl ? `
|
|
16715
|
+
window.__AGENT_SUBMIT_URL__ = ${escapeInlineScript(JSON.stringify(effectiveSubmitUrl))};` : "";
|
|
16701
16716
|
const html = `<!DOCTYPE html>
|
|
16702
16717
|
<html lang="${effectiveLocale}">
|
|
16703
16718
|
<head>
|
|
@@ -16709,7 +16724,7 @@ var require_v2Core = __commonJS({
|
|
|
16709
16724
|
<body>
|
|
16710
16725
|
<div id="app"></div>
|
|
16711
16726
|
<script>
|
|
16712
|
-
window.__AGENT_PREVIEW_MODE__ = ${JSON.stringify(effectiveMode)}
|
|
16727
|
+
window.__AGENT_PREVIEW_MODE__ = ${JSON.stringify(effectiveMode)};${submitUrlScriptLine}
|
|
16713
16728
|
window.__AGENT_FORM_SCHEMA__ = ${escapeInlineScript(JSON.stringify(schema))};
|
|
16714
16729
|
window.__AGENT_THEME_CONFIG__ = ${escapeInlineScript(JSON.stringify(normalizedTheme))};
|
|
16715
16730
|
</script>
|
|
@@ -16717,16 +16732,22 @@ var require_v2Core = __commonJS({
|
|
|
16717
16732
|
</body>
|
|
16718
16733
|
</html>
|
|
16719
16734
|
`;
|
|
16720
|
-
return { html, mode: effectiveMode, locale: effectiveLocale };
|
|
16735
|
+
return { html, mode: effectiveMode, locale: effectiveLocale, submitUrl: effectiveSubmitUrl || null };
|
|
16721
16736
|
}
|
|
16722
|
-
function previewExportHtml({ schemaPath, themePath, out, mode, locale, assetsDir }) {
|
|
16737
|
+
function previewExportHtml({ schemaPath, themePath, out, mode, locale, submitUrl, assetsDir }) {
|
|
16723
16738
|
const schema = normalizeSchemaEnvelope(readJsonFile(schemaPath, "FormSchema \u6587\u4EF6"));
|
|
16724
16739
|
const themeConfig = themePath ? readJsonFile(themePath, "ThemeConfigJson \u6587\u4EF6") : { version: "1.0.0", skin: "fin-minimal", override: {}, formMode: "flat", showProgressBar: true };
|
|
16725
|
-
const {
|
|
16740
|
+
const {
|
|
16741
|
+
html,
|
|
16742
|
+
mode: effectiveMode,
|
|
16743
|
+
locale: effectiveLocale,
|
|
16744
|
+
submitUrl: effectiveSubmitUrl
|
|
16745
|
+
} = renderStandaloneHtml({
|
|
16726
16746
|
schema,
|
|
16727
16747
|
themeConfig,
|
|
16728
16748
|
mode,
|
|
16729
16749
|
locale,
|
|
16750
|
+
submitUrl,
|
|
16730
16751
|
assetsDir
|
|
16731
16752
|
});
|
|
16732
16753
|
const absOut = path2.resolve(out);
|
|
@@ -16737,6 +16758,7 @@ var require_v2Core = __commonJS({
|
|
|
16737
16758
|
status: "exported",
|
|
16738
16759
|
mode: effectiveMode,
|
|
16739
16760
|
locale: effectiveLocale,
|
|
16761
|
+
submitUrl: effectiveSubmitUrl,
|
|
16740
16762
|
path: absOut,
|
|
16741
16763
|
sizeKb,
|
|
16742
16764
|
fileUrl: `file://${absOut}`
|
|
@@ -16802,8 +16824,10 @@ module.exports = ${JSON.stringify(payload, null, 2)}
|
|
|
16802
16824
|
outDir,
|
|
16803
16825
|
keyStyle = "snake_case",
|
|
16804
16826
|
includeHtml = true,
|
|
16827
|
+
submitUrl,
|
|
16805
16828
|
assetsDir
|
|
16806
16829
|
}) {
|
|
16830
|
+
const effectiveSubmitUrl = normalizeSubmitUrl(submitUrl);
|
|
16807
16831
|
const schema = normalizeSchemaEnvelope(readJsonFile(schemaPath, "FormSchema \u6587\u4EF6"));
|
|
16808
16832
|
const governance = validateFormSchemaGovernance(schema);
|
|
16809
16833
|
if (!governance.valid) {
|
|
@@ -16841,7 +16865,7 @@ module.exports = ${JSON.stringify(payload, null, 2)}
|
|
|
16841
16865
|
let finalHtmlOut = null;
|
|
16842
16866
|
let finalHtmlSizeKb = null;
|
|
16843
16867
|
if (includeHtml !== false && assetsDir) {
|
|
16844
|
-
const { html } = renderStandaloneHtml({ schema, themeConfig, mode: "final", assetsDir });
|
|
16868
|
+
const { html } = renderStandaloneHtml({ schema, themeConfig, mode: "final", submitUrl: effectiveSubmitUrl, assetsDir });
|
|
16845
16869
|
finalHtmlOut = path2.join(absDir, "final.html");
|
|
16846
16870
|
fs.writeFileSync(finalHtmlOut, html, "utf8");
|
|
16847
16871
|
finalHtmlSizeKb = Math.round(fs.statSync(finalHtmlOut).size / 1024);
|
|
@@ -16858,6 +16882,7 @@ module.exports = ${JSON.stringify(payload, null, 2)}
|
|
|
16858
16882
|
piiFields: contract.piiSummary.map((p) => p.key),
|
|
16859
16883
|
governanceValid: governance.valid,
|
|
16860
16884
|
presetAuditCount: auditFieldPresetCoverage(schema).length,
|
|
16885
|
+
...effectiveSubmitUrl ? { submitUrl: effectiveSubmitUrl } : {},
|
|
16861
16886
|
artifacts: {
|
|
16862
16887
|
schema: { file: "form.schema.json", sha256: sha256(schemaOut) },
|
|
16863
16888
|
theme: { file: "theme.config.json", sha256: sha256(themeOut) },
|
|
@@ -16929,22 +16954,148 @@ module.exports = ${JSON.stringify(payload, null, 2)}
|
|
|
16929
16954
|
if (!name.endsWith("Form")) name += "Form";
|
|
16930
16955
|
return name;
|
|
16931
16956
|
}
|
|
16957
|
+
function tryReadJsonSafe(filePath) {
|
|
16958
|
+
try {
|
|
16959
|
+
if (!fs.existsSync(filePath) || !fs.statSync(filePath).isFile()) return null;
|
|
16960
|
+
return JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
16961
|
+
} catch (_) {
|
|
16962
|
+
return null;
|
|
16963
|
+
}
|
|
16964
|
+
}
|
|
16965
|
+
function findNearestExistingDir(targetPath) {
|
|
16966
|
+
let cur = path2.resolve(targetPath || process.cwd());
|
|
16967
|
+
for (let i = 0; i < 12; i++) {
|
|
16968
|
+
try {
|
|
16969
|
+
if (fs.existsSync(cur)) {
|
|
16970
|
+
return fs.statSync(cur).isDirectory() ? cur : path2.dirname(cur);
|
|
16971
|
+
}
|
|
16972
|
+
} catch (_) {
|
|
16973
|
+
}
|
|
16974
|
+
const parent = path2.dirname(cur);
|
|
16975
|
+
if (parent === cur) break;
|
|
16976
|
+
cur = parent;
|
|
16977
|
+
}
|
|
16978
|
+
return process.cwd();
|
|
16979
|
+
}
|
|
16980
|
+
function detectHostEnvironment({ projectDir, outDir } = {}) {
|
|
16981
|
+
const startDir = findNearestExistingDir(projectDir || outDir || process.cwd());
|
|
16982
|
+
const homeDir = path2.resolve(os2.homedir());
|
|
16983
|
+
const tmpDirs = /* @__PURE__ */ new Set([path2.resolve(os2.tmpdir())]);
|
|
16984
|
+
try {
|
|
16985
|
+
tmpDirs.add(fs.realpathSync(os2.tmpdir()));
|
|
16986
|
+
} catch (_) {
|
|
16987
|
+
}
|
|
16988
|
+
let cur = startDir;
|
|
16989
|
+
for (let depth = 0; depth < 6; depth++) {
|
|
16990
|
+
if (depth > 0 && (cur === homeDir || tmpDirs.has(cur))) break;
|
|
16991
|
+
const wxProj = tryReadJsonSafe(path2.join(cur, "project.config.json"));
|
|
16992
|
+
if (wxProj && (wxProj.appid !== void 0 || wxProj.miniprogramRoot !== void 0 || wxProj.compileType === "miniprogram")) {
|
|
16993
|
+
return {
|
|
16994
|
+
resolvedPlatform: "miniapp",
|
|
16995
|
+
confidence: "high",
|
|
16996
|
+
projectRoot: cur,
|
|
16997
|
+
signals: ["project.config.json"],
|
|
16998
|
+
summary: "Detected WeChat Miniapp project via project.config.json"
|
|
16999
|
+
};
|
|
17000
|
+
}
|
|
17001
|
+
const wxApp = tryReadJsonSafe(path2.join(cur, "app.json"));
|
|
17002
|
+
if (wxApp && Array.isArray(wxApp.pages)) {
|
|
17003
|
+
return {
|
|
17004
|
+
resolvedPlatform: "miniapp",
|
|
17005
|
+
confidence: "high",
|
|
17006
|
+
projectRoot: cur,
|
|
17007
|
+
signals: ["app.json(pages)"],
|
|
17008
|
+
summary: "Detected WeChat Miniapp project via app.json"
|
|
17009
|
+
};
|
|
17010
|
+
}
|
|
17011
|
+
const pkg = tryReadJsonSafe(path2.join(cur, "package.json"));
|
|
17012
|
+
if (pkg && typeof pkg === "object") {
|
|
17013
|
+
const deps = { ...pkg.dependencies || {}, ...pkg.devDependencies || {} };
|
|
17014
|
+
const hasVue = Boolean(deps.vue || deps.nuxt || deps["@vitejs/plugin-vue"]);
|
|
17015
|
+
const hasReact = Boolean(deps.react || deps["react-dom"] || deps.next || deps["@vitejs/plugin-react"]);
|
|
17016
|
+
if (hasVue && !hasReact) {
|
|
17017
|
+
const signals = ["package.json", deps.nuxt ? "dep:nuxt" : "dep:vue"];
|
|
17018
|
+
return {
|
|
17019
|
+
resolvedPlatform: "vue3",
|
|
17020
|
+
confidence: "high",
|
|
17021
|
+
projectRoot: cur,
|
|
17022
|
+
signals,
|
|
17023
|
+
summary: `Detected Vue 3 host project (${signals.join(", ")})`
|
|
17024
|
+
};
|
|
17025
|
+
}
|
|
17026
|
+
if (hasReact && !hasVue) {
|
|
17027
|
+
const signals = ["package.json", deps.next ? "dep:next" : "dep:react"];
|
|
17028
|
+
return {
|
|
17029
|
+
resolvedPlatform: "react18",
|
|
17030
|
+
confidence: "high",
|
|
17031
|
+
projectRoot: cur,
|
|
17032
|
+
signals,
|
|
17033
|
+
summary: `Detected React 18 host project (${signals.join(", ")})`
|
|
17034
|
+
};
|
|
17035
|
+
}
|
|
17036
|
+
if (hasVue && hasReact) {
|
|
17037
|
+
if (fs.existsSync(path2.join(cur, "src/App.vue"))) {
|
|
17038
|
+
return {
|
|
17039
|
+
resolvedPlatform: "vue3",
|
|
17040
|
+
confidence: "high",
|
|
17041
|
+
projectRoot: cur,
|
|
17042
|
+
signals: ["package.json", "src/App.vue"],
|
|
17043
|
+
summary: "Detected Vue 3 host project via src/App.vue"
|
|
17044
|
+
};
|
|
17045
|
+
}
|
|
17046
|
+
if (fs.existsSync(path2.join(cur, "src/App.tsx")) || fs.existsSync(path2.join(cur, "src/App.jsx"))) {
|
|
17047
|
+
return {
|
|
17048
|
+
resolvedPlatform: "react18",
|
|
17049
|
+
confidence: "high",
|
|
17050
|
+
projectRoot: cur,
|
|
17051
|
+
signals: ["package.json", "src/App.tsx"],
|
|
17052
|
+
summary: "Detected React 18 host project via src/App.tsx"
|
|
17053
|
+
};
|
|
17054
|
+
}
|
|
17055
|
+
}
|
|
17056
|
+
}
|
|
17057
|
+
const parent = path2.dirname(cur);
|
|
17058
|
+
if (parent === cur) break;
|
|
17059
|
+
cur = parent;
|
|
17060
|
+
}
|
|
17061
|
+
return {
|
|
17062
|
+
resolvedPlatform: "standalone",
|
|
17063
|
+
confidence: "fallback",
|
|
17064
|
+
projectRoot: startDir,
|
|
17065
|
+
signals: ["no-frontend-framework-detected"],
|
|
17066
|
+
summary: "No Vue/React/Miniapp host detected \u2014 delivering zero-dependency standalone HTML bundle"
|
|
17067
|
+
};
|
|
17068
|
+
}
|
|
16932
17069
|
function scaffoldHost({
|
|
16933
17070
|
schemaPath,
|
|
16934
17071
|
themePath,
|
|
16935
|
-
platform,
|
|
17072
|
+
platform = "auto",
|
|
16936
17073
|
outDir,
|
|
17074
|
+
projectDir,
|
|
16937
17075
|
componentName,
|
|
16938
17076
|
keyStyle = "snake_case",
|
|
16939
|
-
packageScope = "@agentprismform"
|
|
17077
|
+
packageScope = "@agentprismform",
|
|
17078
|
+
submitUrl,
|
|
17079
|
+
assetsDir
|
|
16940
17080
|
}) {
|
|
16941
|
-
const VALID_PLATFORMS = ["vue3", "react18", "miniapp", "headless"];
|
|
16942
|
-
|
|
17081
|
+
const VALID_PLATFORMS = ["auto", "vue3", "react18", "miniapp", "standalone", "headless"];
|
|
17082
|
+
const requestedPlatform = platform || "auto";
|
|
17083
|
+
if (!VALID_PLATFORMS.includes(requestedPlatform)) {
|
|
16943
17084
|
throw Object.assign(
|
|
16944
|
-
new Error(`\u4E0D\u652F\u6301\u7684\u76EE\u6807\u5E73\u53F0\uFF1A${
|
|
17085
|
+
new Error(`\u4E0D\u652F\u6301\u7684\u76EE\u6807\u5E73\u53F0\uFF1A${requestedPlatform}\uFF08\u53EF\u9009\uFF1A${VALID_PLATFORMS.join(", ")}\uFF09`),
|
|
16945
17086
|
{ code: "INVALID_ARGUMENT" }
|
|
16946
17087
|
);
|
|
16947
17088
|
}
|
|
17089
|
+
const effectiveSubmitUrl = normalizeSubmitUrl(submitUrl);
|
|
17090
|
+
const detection = requestedPlatform === "auto" ? { requestedPlatform: "auto", ...detectHostEnvironment({ projectDir, outDir }) } : {
|
|
17091
|
+
requestedPlatform,
|
|
17092
|
+
resolvedPlatform: requestedPlatform,
|
|
17093
|
+
confidence: "explicit",
|
|
17094
|
+
projectRoot: findNearestExistingDir(projectDir || outDir || process.cwd()),
|
|
17095
|
+
signals: ["explicit-platform"],
|
|
17096
|
+
summary: `Explicit platform requested: ${requestedPlatform}`
|
|
17097
|
+
};
|
|
17098
|
+
const resolvedPlatform = detection.resolvedPlatform;
|
|
16948
17099
|
const schema = normalizeSchemaEnvelope(readJsonFile(schemaPath, "FormSchema \u6587\u4EF6"));
|
|
16949
17100
|
const rawTheme = themePath ? readJsonFile(themePath, "ThemeConfigJson \u6587\u4EF6") : { version: "1.0.0", skin: "fin-minimal", override: {}, formMode: "flat", showProgressBar: true };
|
|
16950
17101
|
const themeConfig = { ...rawTheme, mode: "final" };
|
|
@@ -16958,7 +17109,8 @@ module.exports = ${JSON.stringify(payload, null, 2)}
|
|
|
16958
17109
|
format: "agentprismform-mobile-bundle/v1",
|
|
16959
17110
|
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
16960
17111
|
schema,
|
|
16961
|
-
themeConfig
|
|
17112
|
+
themeConfig,
|
|
17113
|
+
...effectiveSubmitUrl ? { submitUrl: effectiveSubmitUrl } : {}
|
|
16962
17114
|
};
|
|
16963
17115
|
const bundleOut = writeJsonAtomic(path2.join(absDir, "form.bundle.json"), bundle, { overwrite: true });
|
|
16964
17116
|
const typesOut = path2.join(absDir, "types.d.ts");
|
|
@@ -16967,7 +17119,7 @@ module.exports = ${JSON.stringify(payload, null, 2)}
|
|
|
16967
17119
|
let packages = [];
|
|
16968
17120
|
let entryFile = "";
|
|
16969
17121
|
let mountSnippet = "";
|
|
16970
|
-
if (
|
|
17122
|
+
if (resolvedPlatform === "vue3") {
|
|
16971
17123
|
packages = [`${scope}/render-vue`];
|
|
16972
17124
|
entryFile = path2.join(absDir, `${compName}.vue`);
|
|
16973
17125
|
const vueCode = `<script setup lang="ts">
|
|
@@ -17012,7 +17164,7 @@ const emit = defineEmits<{
|
|
|
17012
17164
|
fs.writeFileSync(entryFile, vueCode, "utf8");
|
|
17013
17165
|
files.component = entryFile;
|
|
17014
17166
|
mountSnippet = `<${compName} :host-handlers="hostHandlers" :custom-controls="{}" @submit="handleSubmit" />`;
|
|
17015
|
-
} else if (
|
|
17167
|
+
} else if (resolvedPlatform === "react18") {
|
|
17016
17168
|
packages = [`${scope}/render-web`];
|
|
17017
17169
|
entryFile = path2.join(absDir, `${compName}.tsx`);
|
|
17018
17170
|
const reactCode = `import React from 'react'
|
|
@@ -17058,7 +17210,7 @@ export function ${compName}({
|
|
|
17058
17210
|
fs.writeFileSync(entryFile, reactCode, "utf8");
|
|
17059
17211
|
files.component = entryFile;
|
|
17060
17212
|
mountSnippet = `<${compName} hostHandlers={hostHandlers} customControls={{}} onSubmit={handleSubmit} />`;
|
|
17061
|
-
} else if (
|
|
17213
|
+
} else if (resolvedPlatform === "headless") {
|
|
17062
17214
|
packages = [`${scope}/core`, `${scope}/render`];
|
|
17063
17215
|
entryFile = path2.join(absDir, `${compName}.tsx`);
|
|
17064
17216
|
const headlessCode = `import React, { useEffect, useRef, useState } from 'react'
|
|
@@ -17144,8 +17296,23 @@ export function ${compName}({ onSubmit }: ${compName}Props) {
|
|
|
17144
17296
|
fs.writeFileSync(entryFile, headlessCode, "utf8");
|
|
17145
17297
|
files.component = entryFile;
|
|
17146
17298
|
mountSnippet = `<${compName} onSubmit={handleSubmit} />`;
|
|
17299
|
+
} else if (resolvedPlatform === "standalone") {
|
|
17300
|
+
packages = [];
|
|
17301
|
+
const resolvedAssetsDir = assetsDir || path2.resolve(__dirname, "../preview");
|
|
17302
|
+
const { html } = renderStandaloneHtml({
|
|
17303
|
+
schema,
|
|
17304
|
+
themeConfig,
|
|
17305
|
+
mode: "final",
|
|
17306
|
+
submitUrl: effectiveSubmitUrl,
|
|
17307
|
+
assetsDir: resolvedAssetsDir
|
|
17308
|
+
});
|
|
17309
|
+
entryFile = path2.join(absDir, "index.html");
|
|
17310
|
+
fs.writeFileSync(entryFile, html, "utf8");
|
|
17311
|
+
files.html = entryFile;
|
|
17312
|
+
mountSnippet = effectiveSubmitUrl ? `# Deploy index.html to any static host (Cloudflare Pages / Vercel / Nginx / OSS)
|
|
17313
|
+
# Submissions POST JSON with Idempotency-Key -> ${effectiveSubmitUrl}` : `# Open index.html directly in any browser, or deploy to Cloudflare Pages / Vercel / Nginx / OSS (zero backend required)`;
|
|
17147
17314
|
} else {
|
|
17148
|
-
packages = [`${scope}/
|
|
17315
|
+
packages = [`${scope}/render-miniapp`];
|
|
17149
17316
|
const dataFile = path2.join(absDir, "preview-data.js");
|
|
17150
17317
|
const jsonFile = path2.join(absDir, "index.json");
|
|
17151
17318
|
const wxmlFile = path2.join(absDir, "index.wxml");
|
|
@@ -17175,6 +17342,7 @@ export function ${compName}({ onSubmit }: ${compName}Props) {
|
|
|
17175
17342
|
`,
|
|
17176
17343
|
"utf8"
|
|
17177
17344
|
);
|
|
17345
|
+
const defaultMiniappUrl = effectiveSubmitUrl || "https://api.example.com/forms/submit";
|
|
17178
17346
|
fs.writeFileSync(
|
|
17179
17347
|
jsFile,
|
|
17180
17348
|
`const bundle = require('./preview-data.js')
|
|
@@ -17187,7 +17355,7 @@ Page({
|
|
|
17187
17355
|
onFormSubmit(ev) {
|
|
17188
17356
|
this.setData({ submitting: true })
|
|
17189
17357
|
wx.request({
|
|
17190
|
-
url: (this.data.schema && this.data.schema.submitApi) ||
|
|
17358
|
+
url: bundle.submitUrl || (this.data.schema && this.data.schema.submitApi) || ${JSON.stringify(defaultMiniappUrl)},
|
|
17191
17359
|
method: 'POST',
|
|
17192
17360
|
header: { 'Idempotency-Key': 'wx_' + Date.now() },
|
|
17193
17361
|
data: ev.detail,
|
|
@@ -17205,14 +17373,19 @@ Page({
|
|
|
17205
17373
|
files.pageJs = jsFile;
|
|
17206
17374
|
mountSnippet = `// Register "${path2.basename(absDir)}/index" inside WeChat Miniapp app.json -> "pages"`;
|
|
17207
17375
|
}
|
|
17208
|
-
const localInstallCmd = "npm install --install-links " + packages.map((p) => `<path-to-AgentPrismForm>/packages/${p.split("/")[1]}`).join(" ");
|
|
17209
|
-
const npmInstallCmd = `npm install ${packages.join(" ")}
|
|
17210
|
-
const
|
|
17211
|
-
|
|
17212
|
-
integrationDoc,
|
|
17213
|
-
`# ${compName} Integration Guide / \u63A5\u5165\u6307\u5357
|
|
17376
|
+
const localInstallCmd = packages.length ? "npm install --install-links " + packages.map((p) => `<path-to-AgentPrismForm>/packages/${p.split("/")[1]}`).join(" ") : "";
|
|
17377
|
+
const npmInstallCmd = packages.length ? `npm install ${packages.join(" ")}` : "";
|
|
17378
|
+
const submitNote = effectiveSubmitUrl ? `
|
|
17379
|
+
## Submit Endpoint / \u63D0\u4EA4\u63A5\u53E3\u51FA\u53E3
|
|
17214
17380
|
|
|
17215
|
-
|
|
17381
|
+
Configured \`submitUrl\`: \`${effectiveSubmitUrl}\`
|
|
17382
|
+
|
|
17383
|
+
Payload envelope sent via \`POST\` (with \`Idempotency-Key\` header):
|
|
17384
|
+
\`\`\`json
|
|
17385
|
+
{ "submissionId": "sub_...", "schemaVersion": "1.0.0", "storageKey": "${schema.storageKey || ""}", "submittedAt": "...", "channel": "web-mobile", "data": { ... } }
|
|
17386
|
+
\`\`\`
|
|
17387
|
+
` : "";
|
|
17388
|
+
const installSection = packages.length ? `## 1. Install Required Packages / \u5B89\u88C5\u4F9D\u8D56\u5305
|
|
17216
17389
|
|
|
17217
17390
|
**Option A \u2014 From npm registry / \u4ECE npm \u5B98\u65B9\u6E90\u76F4\u63A5\u5B89\u88C5\uFF08\u63A8\u8350\uFF09:**
|
|
17218
17391
|
\`\`\`bash
|
|
@@ -17223,24 +17396,37 @@ ${npmInstallCmd}
|
|
|
17223
17396
|
\`\`\`bash
|
|
17224
17397
|
${localInstallCmd}
|
|
17225
17398
|
\`\`\`
|
|
17399
|
+
` : `## 1. Zero-Dependency Standalone Delivery / \u96F6\u4F9D\u8D56\u72EC\u7ACB\u4EA4\u4ED8
|
|
17400
|
+
|
|
17401
|
+
No npm packages or build step required. \`index.html\` is a self-contained zero-chrome deliverable ready for any static host (Cloudflare Pages, Vercel, GitHub Pages, Nginx, or OSS).
|
|
17402
|
+
`;
|
|
17403
|
+
const integrationDoc = path2.join(absDir, "INTEGRATION.md");
|
|
17404
|
+
fs.writeFileSync(
|
|
17405
|
+
integrationDoc,
|
|
17406
|
+
`# ${compName} Integration Guide / \u63A5\u5165\u6307\u5357
|
|
17226
17407
|
|
|
17227
|
-
|
|
17408
|
+
> **Resolved Delivery Target**: \`${resolvedPlatform}\` (${detection.summary})
|
|
17409
|
+
|
|
17410
|
+
${installSection}
|
|
17411
|
+
## 2. Mount or Deploy / \u6302\u8F7D\u6216\u90E8\u7F72
|
|
17228
17412
|
|
|
17229
17413
|
\`\`\`tsx
|
|
17230
17414
|
${mountSnippet}
|
|
17231
17415
|
\`\`\`
|
|
17232
|
-
|
|
17416
|
+
${submitNote}
|
|
17233
17417
|
## 3. Files Generated / \u751F\u6210\u6587\u4EF6\u6E05\u5355
|
|
17234
17418
|
- \`form.bundle.json\` \u2014 Finalized FormSchema + locked ThemeConfig
|
|
17235
17419
|
- \`types.d.ts\` \u2014 TypeScript DTO derived from FormSchema
|
|
17236
|
-
- \`${path2.basename(entryFile)}\` \u2014 Ready-to-run ${
|
|
17420
|
+
- \`${path2.basename(entryFile)}\` \u2014 Ready-to-run ${resolvedPlatform} deliverable
|
|
17237
17421
|
`,
|
|
17238
17422
|
"utf8"
|
|
17239
17423
|
);
|
|
17240
17424
|
files.integrationGuide = integrationDoc;
|
|
17241
17425
|
return {
|
|
17242
17426
|
status: "scaffolded",
|
|
17243
|
-
platform,
|
|
17427
|
+
platform: resolvedPlatform,
|
|
17428
|
+
detection,
|
|
17429
|
+
submitUrl: effectiveSubmitUrl || null,
|
|
17244
17430
|
componentName: compName,
|
|
17245
17431
|
outDir: absDir,
|
|
17246
17432
|
packages,
|
|
@@ -17251,6 +17437,7 @@ ${mountSnippet}
|
|
|
17251
17437
|
}
|
|
17252
17438
|
module2.exports = {
|
|
17253
17439
|
listSnippetsAndPresets,
|
|
17440
|
+
detectHostEnvironment,
|
|
17254
17441
|
schemaInit,
|
|
17255
17442
|
schemaSet,
|
|
17256
17443
|
schemaPatch,
|
|
@@ -17407,7 +17594,7 @@ var TOOLS = [
|
|
|
17407
17594
|
},
|
|
17408
17595
|
{
|
|
17409
17596
|
name: "form_preview_html",
|
|
17410
|
-
description: '1 \u79D2\u5BFC\u51FA\u96F6\u4F9D\u8D56\u3001\u65E0\u9700\u542F\u52A8\u670D\u52A1\u7684\u79BB\u7EBF\u5355\u6587\u4EF6 HTML\uFF1B\u652F\u6301 mode="preview"\uFF08\u5E26\u6837\u5F0F/\u952E\u76D8\u8C03\u8BD5\u5DE5\u5177\u680F\uFF09\u4E0E mode="final"\uFF08\u96F6\u8C03\u8BD5\u680F\u3001\u6837\u5F0F\u4E0E\u4EA4\u4E92\u5DF2\u6C89\u6DC0\u9501\u5B9A\u7684\u6700\u7EC8\u4EA4\u4ED8\u6210\u54C1\uFF09\uFF0C\u652F\u6301 locale="zh-CN"|"en-US"',
|
|
17597
|
+
description: '1 \u79D2\u5BFC\u51FA\u96F6\u4F9D\u8D56\u3001\u65E0\u9700\u542F\u52A8\u670D\u52A1\u7684\u79BB\u7EBF\u5355\u6587\u4EF6 HTML\uFF1B\u652F\u6301 mode="preview"\uFF08\u5E26\u6837\u5F0F/\u952E\u76D8\u8C03\u8BD5\u5DE5\u5177\u680F\uFF09\u4E0E mode="final"\uFF08\u96F6\u8C03\u8BD5\u680F\u3001\u6837\u5F0F\u4E0E\u4EA4\u4E92\u5DF2\u6C89\u6DC0\u9501\u5B9A\u7684\u6700\u7EC8\u4EA4\u4ED8\u6210\u54C1\uFF09\uFF0C\u652F\u6301 locale="zh-CN"|"en-US" \u4EE5\u53CA\u53EF\u9009 submitUrl \u63D0\u4EA4\u51FA\u53E3',
|
|
17411
17598
|
inputSchema: {
|
|
17412
17599
|
type: "object",
|
|
17413
17600
|
required: ["schemaPath", "out"],
|
|
@@ -17416,7 +17603,8 @@ var TOOLS = [
|
|
|
17416
17603
|
themePath: { type: "string" },
|
|
17417
17604
|
out: { type: "string" },
|
|
17418
17605
|
mode: { type: "string", enum: ["preview", "final"], default: "preview" },
|
|
17419
|
-
locale: { type: "string", enum: ["zh-CN", "en-US"], description: "\u53EF\u9009\u8986\u76D6\u5BFC\u51FA HTML \u7684 UI \u8BED\u8A00\uFF08\u9ED8\u8BA4\u8DDF\u968F theme.locale \u6216 zh-CN\uFF09" }
|
|
17606
|
+
locale: { type: "string", enum: ["zh-CN", "en-US"], description: "\u53EF\u9009\u8986\u76D6\u5BFC\u51FA HTML \u7684 UI \u8BED\u8A00\uFF08\u9ED8\u8BA4\u8DDF\u968F theme.locale \u6216 zh-CN\uFF09" },
|
|
17607
|
+
submitUrl: { type: "string", description: "\u53EF\u9009\uFF1A\u663E\u5F0F\u914D\u7F6E\u72EC\u7ACB\u5B9A\u7A3F HTML \u7684 POST JSON \u63D0\u4EA4\u63A5\u53E3\uFF08http/https\uFF09\uFF1B\u7559\u7A7A\u5219 100% \u79BB\u7EBF\u672C\u5730\u56DE\u6267\u3001\u4E0D\u5916\u53D1\u4EFB\u4F55\u6570\u636E" }
|
|
17420
17608
|
}
|
|
17421
17609
|
}
|
|
17422
17610
|
},
|
|
@@ -17445,7 +17633,8 @@ var TOOLS = [
|
|
|
17445
17633
|
mappingPath: { type: "string" },
|
|
17446
17634
|
outDir: { type: "string", description: "\u6700\u7EC8\u4EA4\u4ED8\u5305\u8F93\u51FA\u76EE\u5F55" },
|
|
17447
17635
|
keyStyle: { type: "string", enum: ["snake_case", "camelCase"], default: "snake_case" },
|
|
17448
|
-
includeHtml: { type: "boolean", default: true }
|
|
17636
|
+
includeHtml: { type: "boolean", default: true },
|
|
17637
|
+
submitUrl: { type: "string", description: "\u53EF\u9009\uFF1A\u4E3A\u5BFC\u51FA\u7684 final.html \u6CE8\u5165 POST JSON \u63D0\u4EA4\u51FA\u53E3\uFF08http/https\uFF09\uFF1B\u7559\u7A7A\u5219\u7EAF\u79BB\u7EBF" }
|
|
17449
17638
|
}
|
|
17450
17639
|
}
|
|
17451
17640
|
},
|
|
@@ -17559,18 +17748,25 @@ var TOOLS = [
|
|
|
17559
17748
|
},
|
|
17560
17749
|
{
|
|
17561
17750
|
name: "form_scaffold_host",
|
|
17562
|
-
description:
|
|
17751
|
+
description: 'Agent-First \u4E00\u952E\u81EA\u52A8\u51B3\u7B56\u5E76\u843D\u5730\u6700\u7EC8\u4EA4\u4ED8\u7269\uFF1A\u9ED8\u8BA4 platform="auto" \u81EA\u52A8\u626B\u63CF\u5BBF\u4E3B\u76EE\u5F55\uFF08Vue 3 / React 18 / \u5FAE\u4FE1\u5C0F\u7A0B\u5E8F / \u65E0\u5DE5\u7A0B\u65F6\u81EA\u52A8\u964D\u7EA7\u4E3A\u72EC\u7ACB\u96F6\u4F9D\u8D56 HTML\uFF09\uFF0C\u81EA\u52A8\u751F\u6210 form.bundle.json\u3001types.d.ts\u3001\u53EF\u76F4\u63A5\u6302\u8F7D\u9875\u9762\u6216\u72EC\u7ACB index.html \u53CA INTEGRATION.md',
|
|
17563
17752
|
inputSchema: {
|
|
17564
17753
|
type: "object",
|
|
17565
|
-
required: ["schemaPath", "
|
|
17754
|
+
required: ["schemaPath", "outDir"],
|
|
17566
17755
|
properties: {
|
|
17567
17756
|
schemaPath: { type: "string" },
|
|
17568
17757
|
themePath: { type: "string" },
|
|
17569
|
-
platform: {
|
|
17570
|
-
|
|
17758
|
+
platform: {
|
|
17759
|
+
type: "string",
|
|
17760
|
+
enum: ["auto", "vue3", "react18", "miniapp", "standalone", "headless"],
|
|
17761
|
+
default: "auto",
|
|
17762
|
+
description: "\u76EE\u6807\u4EA4\u4ED8\u5F62\u6001\uFF1B\u9ED8\u8BA4 auto \u81EA\u52A8\u63A2\u6D4B\u9879\u76EE\u6280\u672F\u6808\uFF08\u65E0\u524D\u7AEF\u4ED3\u5E93\u65F6\u81EA\u52A8\u4EA7\u51FA\u96F6\u4F9D\u8D56 standalone index.html\uFF09"
|
|
17763
|
+
},
|
|
17764
|
+
projectDir: { type: "string", description: "\u53EF\u9009\uFF1A\u7528\u4E8E auto \u63A2\u6D4B\u7684\u5BBF\u4E3B\u5DE5\u7A0B\u6839\u76EE\u5F55\uFF08\u9ED8\u8BA4\u4ECE outDir \u5411\u4E0A\u626B\u63CF\uFF09" },
|
|
17765
|
+
outDir: { type: "string", description: "\u76EE\u6807\u4EA4\u4ED8\u76EE\u5F55\u8DEF\u5F84\uFF0C\u5982 ./src/forms/event-reg \u6216 ./dist-form" },
|
|
17571
17766
|
componentName: { type: "string", description: "\u53EF\u9009\u7EC4\u4EF6\u540D\uFF08PascalCase\uFF09" },
|
|
17572
17767
|
keyStyle: { type: "string", enum: ["snake_case", "camelCase"], default: "snake_case" },
|
|
17573
|
-
packageScope: { type: "string", default: "@agentprismform" }
|
|
17768
|
+
packageScope: { type: "string", default: "@agentprismform" },
|
|
17769
|
+
submitUrl: { type: "string", description: "\u53EF\u9009\uFF1A\u663E\u5F0F\u914D\u7F6E\u63D0\u4EA4\u63A5\u6536\u7AEF\u70B9\uFF08http/https\uFF09\uFF0C\u7528\u4E8E\u72EC\u7ACB HTML \u6216\u5C0F\u7A0B\u5E8F\u9ED8\u8BA4\u63D0\u4EA4\u63A5\u53E3" }
|
|
17574
17770
|
}
|
|
17575
17771
|
}
|
|
17576
17772
|
}
|
|
@@ -17618,7 +17814,7 @@ async function callTool(name, args = {}) {
|
|
|
17618
17814
|
case "form_hub_webhook":
|
|
17619
17815
|
return await v2.hubWebhook(args);
|
|
17620
17816
|
case "form_scaffold_host":
|
|
17621
|
-
return v2.scaffoldHost(args);
|
|
17817
|
+
return v2.scaffoldHost({ ...args, assetsDir });
|
|
17622
17818
|
default:
|
|
17623
17819
|
throw Object.assign(new Error(`\u672A\u77E5 MCP \u5DE5\u5177\uFF1A${name}`), { code: "INVALID_ARGUMENT" });
|
|
17624
17820
|
}
|