@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.cjs
CHANGED
|
@@ -5,17 +5,17 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
5
5
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
// output/oss-release/agentprismform-1.
|
|
8
|
+
// output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/types.js
|
|
9
9
|
var require_types = __commonJS({
|
|
10
|
-
"output/oss-release/agentprismform-1.
|
|
10
|
+
"output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/types.js"(exports2) {
|
|
11
11
|
"use strict";
|
|
12
12
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
// output/oss-release/agentprismform-1.
|
|
16
|
+
// output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/expression/types.js
|
|
17
17
|
var require_types2 = __commonJS({
|
|
18
|
-
"output/oss-release/agentprismform-1.
|
|
18
|
+
"output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/expression/types.js"(exports2) {
|
|
19
19
|
"use strict";
|
|
20
20
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
21
21
|
exports2.DEFAULT_MAX_DEPTH = exports2.DEFAULT_MAX_LENGTH = exports2.ExpressionError = void 0;
|
|
@@ -32,9 +32,9 @@ var require_types2 = __commonJS({
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
// output/oss-release/agentprismform-1.
|
|
35
|
+
// output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/expression/safeV1.js
|
|
36
36
|
var require_safeV1 = __commonJS({
|
|
37
|
-
"output/oss-release/agentprismform-1.
|
|
37
|
+
"output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/expression/safeV1.js"(exports2) {
|
|
38
38
|
"use strict";
|
|
39
39
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
40
40
|
exports2.tokenize = tokenize;
|
|
@@ -461,9 +461,9 @@ var require_safeV1 = __commonJS({
|
|
|
461
461
|
}
|
|
462
462
|
});
|
|
463
463
|
|
|
464
|
-
// output/oss-release/agentprismform-1.
|
|
464
|
+
// output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/expression/index.js
|
|
465
465
|
var require_expression = __commonJS({
|
|
466
|
-
"output/oss-release/agentprismform-1.
|
|
466
|
+
"output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/expression/index.js"(exports2) {
|
|
467
467
|
"use strict";
|
|
468
468
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
469
469
|
exports2.tokenize = exports2.parseSafeV1 = exports2.isSafeV1Expression = exports2.DEFAULT_MAX_LENGTH = exports2.DEFAULT_MAX_DEPTH = exports2.ExpressionError = void 0;
|
|
@@ -621,9 +621,9 @@ var require_expression = __commonJS({
|
|
|
621
621
|
}
|
|
622
622
|
});
|
|
623
623
|
|
|
624
|
-
// output/oss-release/agentprismform-1.
|
|
624
|
+
// output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/utils.js
|
|
625
625
|
var require_utils = __commonJS({
|
|
626
|
-
"output/oss-release/agentprismform-1.
|
|
626
|
+
"output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/utils.js"(exports2) {
|
|
627
627
|
"use strict";
|
|
628
628
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
629
629
|
exports2.evaluateExpression = void 0;
|
|
@@ -722,9 +722,9 @@ var require_utils = __commonJS({
|
|
|
722
722
|
}
|
|
723
723
|
});
|
|
724
724
|
|
|
725
|
-
// output/oss-release/agentprismform-1.
|
|
725
|
+
// output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/validate.js
|
|
726
726
|
var require_validate = __commonJS({
|
|
727
|
-
"output/oss-release/agentprismform-1.
|
|
727
|
+
"output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/validate.js"(exports2) {
|
|
728
728
|
"use strict";
|
|
729
729
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
730
730
|
exports2.isEmptyValue = isEmptyValue;
|
|
@@ -920,9 +920,9 @@ var require_validate = __commonJS({
|
|
|
920
920
|
}
|
|
921
921
|
});
|
|
922
922
|
|
|
923
|
-
// output/oss-release/agentprismform-1.
|
|
923
|
+
// output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/relations.js
|
|
924
924
|
var require_relations = __commonJS({
|
|
925
|
-
"output/oss-release/agentprismform-1.
|
|
925
|
+
"output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/relations.js"(exports2) {
|
|
926
926
|
"use strict";
|
|
927
927
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
928
928
|
exports2.resolveRelations = resolveRelations;
|
|
@@ -1021,9 +1021,9 @@ var require_relations = __commonJS({
|
|
|
1021
1021
|
}
|
|
1022
1022
|
});
|
|
1023
1023
|
|
|
1024
|
-
// output/oss-release/agentprismform-1.
|
|
1024
|
+
// output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/FormCore.js
|
|
1025
1025
|
var require_FormCore = __commonJS({
|
|
1026
|
-
"output/oss-release/agentprismform-1.
|
|
1026
|
+
"output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/FormCore.js"(exports2) {
|
|
1027
1027
|
"use strict";
|
|
1028
1028
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1029
1029
|
exports2.FormCore = void 0;
|
|
@@ -2227,9 +2227,9 @@ var require_FormCore = __commonJS({
|
|
|
2227
2227
|
}
|
|
2228
2228
|
});
|
|
2229
2229
|
|
|
2230
|
-
// output/oss-release/agentprismform-1.
|
|
2230
|
+
// output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/questionnaire.js
|
|
2231
2231
|
var require_questionnaire = __commonJS({
|
|
2232
|
-
"output/oss-release/agentprismform-1.
|
|
2232
|
+
"output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/questionnaire.js"(exports2) {
|
|
2233
2233
|
"use strict";
|
|
2234
2234
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
2235
2235
|
exports2.schemaToQuestionnaire = schemaToQuestionnaire;
|
|
@@ -2284,9 +2284,9 @@ var require_questionnaire = __commonJS({
|
|
|
2284
2284
|
}
|
|
2285
2285
|
});
|
|
2286
2286
|
|
|
2287
|
-
// output/oss-release/agentprismform-1.
|
|
2287
|
+
// output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/index.js
|
|
2288
2288
|
var require_dist = __commonJS({
|
|
2289
|
-
"output/oss-release/agentprismform-1.
|
|
2289
|
+
"output/oss-release/agentprismform-1.4.0-stage/packages/core/dist/index.js"(exports2) {
|
|
2290
2290
|
"use strict";
|
|
2291
2291
|
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
2292
2292
|
if (k2 === void 0) k2 = k;
|
|
@@ -4629,6 +4629,7 @@ var require_v2Core = __commonJS({
|
|
|
4629
4629
|
"packages/form-agent/src/v2Core.cjs"(exports2, module2) {
|
|
4630
4630
|
"use strict";
|
|
4631
4631
|
var fs = require("node:fs");
|
|
4632
|
+
var os2 = require("node:os");
|
|
4632
4633
|
var path2 = require("node:path");
|
|
4633
4634
|
var crypto = require("node:crypto");
|
|
4634
4635
|
var { FormCore } = require_dist();
|
|
@@ -5025,7 +5026,18 @@ var require_v2Core = __commonJS({
|
|
|
5025
5026
|
function escapeInlineScript(text) {
|
|
5026
5027
|
return String(text).replace(/<\/(script)/gi, "<\\/$1");
|
|
5027
5028
|
}
|
|
5028
|
-
function
|
|
5029
|
+
function normalizeSubmitUrl(raw) {
|
|
5030
|
+
if (raw === void 0 || raw === null) return "";
|
|
5031
|
+
const trimmed = String(raw).trim();
|
|
5032
|
+
if (!trimmed) return "";
|
|
5033
|
+
if (!/^https?:\/\//i.test(trimmed)) {
|
|
5034
|
+
throw Object.assign(new Error(`\u65E0\u6548\u7684 submitUrl\uFF1A${trimmed}\uFF08\u4EC5\u652F\u6301 http:// \u6216 https:// \u5730\u5740\uFF09`), {
|
|
5035
|
+
code: "INVALID_ARGUMENT"
|
|
5036
|
+
});
|
|
5037
|
+
}
|
|
5038
|
+
return trimmed;
|
|
5039
|
+
}
|
|
5040
|
+
function renderStandaloneHtml({ schema, themeConfig, mode, locale, submitUrl, assetsDir }) {
|
|
5029
5041
|
const normalizedTheme = themeConfig ? { ...themeConfig } : { version: "1.0.0", skin: "fin-minimal", override: {}, formMode: "flat", showProgressBar: true };
|
|
5030
5042
|
const effectiveMode = mode === "final" || normalizedTheme.mode === "final" ? "final" : "preview";
|
|
5031
5043
|
if (effectiveMode === "final") {
|
|
@@ -5035,6 +5047,7 @@ var require_v2Core = __commonJS({
|
|
|
5035
5047
|
if (locale !== void 0 || normalizedTheme.locale) {
|
|
5036
5048
|
normalizedTheme.locale = effectiveLocale;
|
|
5037
5049
|
}
|
|
5050
|
+
const effectiveSubmitUrl = normalizeSubmitUrl(submitUrl);
|
|
5038
5051
|
const jsPath = path2.join(assetsDir, "modern-preview.iife.js");
|
|
5039
5052
|
const cssPath = path2.join(assetsDir, "modern-preview.css");
|
|
5040
5053
|
if (!fs.existsSync(jsPath) || !fs.existsSync(cssPath)) {
|
|
@@ -5046,6 +5059,8 @@ var require_v2Core = __commonJS({
|
|
|
5046
5059
|
const cssCode = fs.readFileSync(cssPath, "utf8");
|
|
5047
5060
|
const safeTitle = String(schema.title || (effectiveLocale === "en-US" ? "FormSchema Live Preview" : "FormSchema \u5B9E\u65F6\u9884\u89C8")).replace(/[<>&"]/g, "");
|
|
5048
5061
|
const pageTitle = effectiveMode === "final" ? safeTitle : `${safeTitle} \xB7 FormSchema Preview`;
|
|
5062
|
+
const submitUrlScriptLine = effectiveSubmitUrl ? `
|
|
5063
|
+
window.__AGENT_SUBMIT_URL__ = ${escapeInlineScript(JSON.stringify(effectiveSubmitUrl))};` : "";
|
|
5049
5064
|
const html = `<!DOCTYPE html>
|
|
5050
5065
|
<html lang="${effectiveLocale}">
|
|
5051
5066
|
<head>
|
|
@@ -5057,7 +5072,7 @@ var require_v2Core = __commonJS({
|
|
|
5057
5072
|
<body>
|
|
5058
5073
|
<div id="app"></div>
|
|
5059
5074
|
<script>
|
|
5060
|
-
window.__AGENT_PREVIEW_MODE__ = ${JSON.stringify(effectiveMode)}
|
|
5075
|
+
window.__AGENT_PREVIEW_MODE__ = ${JSON.stringify(effectiveMode)};${submitUrlScriptLine}
|
|
5061
5076
|
window.__AGENT_FORM_SCHEMA__ = ${escapeInlineScript(JSON.stringify(schema))};
|
|
5062
5077
|
window.__AGENT_THEME_CONFIG__ = ${escapeInlineScript(JSON.stringify(normalizedTheme))};
|
|
5063
5078
|
</script>
|
|
@@ -5065,16 +5080,22 @@ var require_v2Core = __commonJS({
|
|
|
5065
5080
|
</body>
|
|
5066
5081
|
</html>
|
|
5067
5082
|
`;
|
|
5068
|
-
return { html, mode: effectiveMode, locale: effectiveLocale };
|
|
5083
|
+
return { html, mode: effectiveMode, locale: effectiveLocale, submitUrl: effectiveSubmitUrl || null };
|
|
5069
5084
|
}
|
|
5070
|
-
function previewExportHtml({ schemaPath, themePath, out, mode, locale, assetsDir }) {
|
|
5085
|
+
function previewExportHtml({ schemaPath, themePath, out, mode, locale, submitUrl, assetsDir }) {
|
|
5071
5086
|
const schema = normalizeSchemaEnvelope(readJsonFile(schemaPath, "FormSchema \u6587\u4EF6"));
|
|
5072
5087
|
const themeConfig = themePath ? readJsonFile(themePath, "ThemeConfigJson \u6587\u4EF6") : { version: "1.0.0", skin: "fin-minimal", override: {}, formMode: "flat", showProgressBar: true };
|
|
5073
|
-
const {
|
|
5088
|
+
const {
|
|
5089
|
+
html,
|
|
5090
|
+
mode: effectiveMode,
|
|
5091
|
+
locale: effectiveLocale,
|
|
5092
|
+
submitUrl: effectiveSubmitUrl
|
|
5093
|
+
} = renderStandaloneHtml({
|
|
5074
5094
|
schema,
|
|
5075
5095
|
themeConfig,
|
|
5076
5096
|
mode,
|
|
5077
5097
|
locale,
|
|
5098
|
+
submitUrl,
|
|
5078
5099
|
assetsDir
|
|
5079
5100
|
});
|
|
5080
5101
|
const absOut = path2.resolve(out);
|
|
@@ -5085,6 +5106,7 @@ var require_v2Core = __commonJS({
|
|
|
5085
5106
|
status: "exported",
|
|
5086
5107
|
mode: effectiveMode,
|
|
5087
5108
|
locale: effectiveLocale,
|
|
5109
|
+
submitUrl: effectiveSubmitUrl,
|
|
5088
5110
|
path: absOut,
|
|
5089
5111
|
sizeKb,
|
|
5090
5112
|
fileUrl: `file://${absOut}`
|
|
@@ -5150,8 +5172,10 @@ module.exports = ${JSON.stringify(payload, null, 2)}
|
|
|
5150
5172
|
outDir,
|
|
5151
5173
|
keyStyle = "snake_case",
|
|
5152
5174
|
includeHtml = true,
|
|
5175
|
+
submitUrl,
|
|
5153
5176
|
assetsDir
|
|
5154
5177
|
}) {
|
|
5178
|
+
const effectiveSubmitUrl = normalizeSubmitUrl(submitUrl);
|
|
5155
5179
|
const schema = normalizeSchemaEnvelope(readJsonFile(schemaPath, "FormSchema \u6587\u4EF6"));
|
|
5156
5180
|
const governance = validateFormSchemaGovernance(schema);
|
|
5157
5181
|
if (!governance.valid) {
|
|
@@ -5189,7 +5213,7 @@ module.exports = ${JSON.stringify(payload, null, 2)}
|
|
|
5189
5213
|
let finalHtmlOut = null;
|
|
5190
5214
|
let finalHtmlSizeKb = null;
|
|
5191
5215
|
if (includeHtml !== false && assetsDir) {
|
|
5192
|
-
const { html } = renderStandaloneHtml({ schema, themeConfig, mode: "final", assetsDir });
|
|
5216
|
+
const { html } = renderStandaloneHtml({ schema, themeConfig, mode: "final", submitUrl: effectiveSubmitUrl, assetsDir });
|
|
5193
5217
|
finalHtmlOut = path2.join(absDir, "final.html");
|
|
5194
5218
|
fs.writeFileSync(finalHtmlOut, html, "utf8");
|
|
5195
5219
|
finalHtmlSizeKb = Math.round(fs.statSync(finalHtmlOut).size / 1024);
|
|
@@ -5206,6 +5230,7 @@ module.exports = ${JSON.stringify(payload, null, 2)}
|
|
|
5206
5230
|
piiFields: contract.piiSummary.map((p) => p.key),
|
|
5207
5231
|
governanceValid: governance.valid,
|
|
5208
5232
|
presetAuditCount: auditFieldPresetCoverage(schema).length,
|
|
5233
|
+
...effectiveSubmitUrl ? { submitUrl: effectiveSubmitUrl } : {},
|
|
5209
5234
|
artifacts: {
|
|
5210
5235
|
schema: { file: "form.schema.json", sha256: sha256(schemaOut) },
|
|
5211
5236
|
theme: { file: "theme.config.json", sha256: sha256(themeOut) },
|
|
@@ -5277,22 +5302,148 @@ module.exports = ${JSON.stringify(payload, null, 2)}
|
|
|
5277
5302
|
if (!name.endsWith("Form")) name += "Form";
|
|
5278
5303
|
return name;
|
|
5279
5304
|
}
|
|
5305
|
+
function tryReadJsonSafe(filePath) {
|
|
5306
|
+
try {
|
|
5307
|
+
if (!fs.existsSync(filePath) || !fs.statSync(filePath).isFile()) return null;
|
|
5308
|
+
return JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
5309
|
+
} catch (_) {
|
|
5310
|
+
return null;
|
|
5311
|
+
}
|
|
5312
|
+
}
|
|
5313
|
+
function findNearestExistingDir(targetPath) {
|
|
5314
|
+
let cur = path2.resolve(targetPath || process.cwd());
|
|
5315
|
+
for (let i = 0; i < 12; i++) {
|
|
5316
|
+
try {
|
|
5317
|
+
if (fs.existsSync(cur)) {
|
|
5318
|
+
return fs.statSync(cur).isDirectory() ? cur : path2.dirname(cur);
|
|
5319
|
+
}
|
|
5320
|
+
} catch (_) {
|
|
5321
|
+
}
|
|
5322
|
+
const parent = path2.dirname(cur);
|
|
5323
|
+
if (parent === cur) break;
|
|
5324
|
+
cur = parent;
|
|
5325
|
+
}
|
|
5326
|
+
return process.cwd();
|
|
5327
|
+
}
|
|
5328
|
+
function detectHostEnvironment({ projectDir, outDir } = {}) {
|
|
5329
|
+
const startDir = findNearestExistingDir(projectDir || outDir || process.cwd());
|
|
5330
|
+
const homeDir = path2.resolve(os2.homedir());
|
|
5331
|
+
const tmpDirs = /* @__PURE__ */ new Set([path2.resolve(os2.tmpdir())]);
|
|
5332
|
+
try {
|
|
5333
|
+
tmpDirs.add(fs.realpathSync(os2.tmpdir()));
|
|
5334
|
+
} catch (_) {
|
|
5335
|
+
}
|
|
5336
|
+
let cur = startDir;
|
|
5337
|
+
for (let depth = 0; depth < 6; depth++) {
|
|
5338
|
+
if (depth > 0 && (cur === homeDir || tmpDirs.has(cur))) break;
|
|
5339
|
+
const wxProj = tryReadJsonSafe(path2.join(cur, "project.config.json"));
|
|
5340
|
+
if (wxProj && (wxProj.appid !== void 0 || wxProj.miniprogramRoot !== void 0 || wxProj.compileType === "miniprogram")) {
|
|
5341
|
+
return {
|
|
5342
|
+
resolvedPlatform: "miniapp",
|
|
5343
|
+
confidence: "high",
|
|
5344
|
+
projectRoot: cur,
|
|
5345
|
+
signals: ["project.config.json"],
|
|
5346
|
+
summary: "Detected WeChat Miniapp project via project.config.json"
|
|
5347
|
+
};
|
|
5348
|
+
}
|
|
5349
|
+
const wxApp = tryReadJsonSafe(path2.join(cur, "app.json"));
|
|
5350
|
+
if (wxApp && Array.isArray(wxApp.pages)) {
|
|
5351
|
+
return {
|
|
5352
|
+
resolvedPlatform: "miniapp",
|
|
5353
|
+
confidence: "high",
|
|
5354
|
+
projectRoot: cur,
|
|
5355
|
+
signals: ["app.json(pages)"],
|
|
5356
|
+
summary: "Detected WeChat Miniapp project via app.json"
|
|
5357
|
+
};
|
|
5358
|
+
}
|
|
5359
|
+
const pkg = tryReadJsonSafe(path2.join(cur, "package.json"));
|
|
5360
|
+
if (pkg && typeof pkg === "object") {
|
|
5361
|
+
const deps = { ...pkg.dependencies || {}, ...pkg.devDependencies || {} };
|
|
5362
|
+
const hasVue = Boolean(deps.vue || deps.nuxt || deps["@vitejs/plugin-vue"]);
|
|
5363
|
+
const hasReact = Boolean(deps.react || deps["react-dom"] || deps.next || deps["@vitejs/plugin-react"]);
|
|
5364
|
+
if (hasVue && !hasReact) {
|
|
5365
|
+
const signals = ["package.json", deps.nuxt ? "dep:nuxt" : "dep:vue"];
|
|
5366
|
+
return {
|
|
5367
|
+
resolvedPlatform: "vue3",
|
|
5368
|
+
confidence: "high",
|
|
5369
|
+
projectRoot: cur,
|
|
5370
|
+
signals,
|
|
5371
|
+
summary: `Detected Vue 3 host project (${signals.join(", ")})`
|
|
5372
|
+
};
|
|
5373
|
+
}
|
|
5374
|
+
if (hasReact && !hasVue) {
|
|
5375
|
+
const signals = ["package.json", deps.next ? "dep:next" : "dep:react"];
|
|
5376
|
+
return {
|
|
5377
|
+
resolvedPlatform: "react18",
|
|
5378
|
+
confidence: "high",
|
|
5379
|
+
projectRoot: cur,
|
|
5380
|
+
signals,
|
|
5381
|
+
summary: `Detected React 18 host project (${signals.join(", ")})`
|
|
5382
|
+
};
|
|
5383
|
+
}
|
|
5384
|
+
if (hasVue && hasReact) {
|
|
5385
|
+
if (fs.existsSync(path2.join(cur, "src/App.vue"))) {
|
|
5386
|
+
return {
|
|
5387
|
+
resolvedPlatform: "vue3",
|
|
5388
|
+
confidence: "high",
|
|
5389
|
+
projectRoot: cur,
|
|
5390
|
+
signals: ["package.json", "src/App.vue"],
|
|
5391
|
+
summary: "Detected Vue 3 host project via src/App.vue"
|
|
5392
|
+
};
|
|
5393
|
+
}
|
|
5394
|
+
if (fs.existsSync(path2.join(cur, "src/App.tsx")) || fs.existsSync(path2.join(cur, "src/App.jsx"))) {
|
|
5395
|
+
return {
|
|
5396
|
+
resolvedPlatform: "react18",
|
|
5397
|
+
confidence: "high",
|
|
5398
|
+
projectRoot: cur,
|
|
5399
|
+
signals: ["package.json", "src/App.tsx"],
|
|
5400
|
+
summary: "Detected React 18 host project via src/App.tsx"
|
|
5401
|
+
};
|
|
5402
|
+
}
|
|
5403
|
+
}
|
|
5404
|
+
}
|
|
5405
|
+
const parent = path2.dirname(cur);
|
|
5406
|
+
if (parent === cur) break;
|
|
5407
|
+
cur = parent;
|
|
5408
|
+
}
|
|
5409
|
+
return {
|
|
5410
|
+
resolvedPlatform: "standalone",
|
|
5411
|
+
confidence: "fallback",
|
|
5412
|
+
projectRoot: startDir,
|
|
5413
|
+
signals: ["no-frontend-framework-detected"],
|
|
5414
|
+
summary: "No Vue/React/Miniapp host detected \u2014 delivering zero-dependency standalone HTML bundle"
|
|
5415
|
+
};
|
|
5416
|
+
}
|
|
5280
5417
|
function scaffoldHost({
|
|
5281
5418
|
schemaPath,
|
|
5282
5419
|
themePath,
|
|
5283
|
-
platform,
|
|
5420
|
+
platform = "auto",
|
|
5284
5421
|
outDir,
|
|
5422
|
+
projectDir,
|
|
5285
5423
|
componentName,
|
|
5286
5424
|
keyStyle = "snake_case",
|
|
5287
|
-
packageScope = "@agentprismform"
|
|
5425
|
+
packageScope = "@agentprismform",
|
|
5426
|
+
submitUrl,
|
|
5427
|
+
assetsDir
|
|
5288
5428
|
}) {
|
|
5289
|
-
const VALID_PLATFORMS = ["vue3", "react18", "miniapp", "headless"];
|
|
5290
|
-
|
|
5429
|
+
const VALID_PLATFORMS = ["auto", "vue3", "react18", "miniapp", "standalone", "headless"];
|
|
5430
|
+
const requestedPlatform = platform || "auto";
|
|
5431
|
+
if (!VALID_PLATFORMS.includes(requestedPlatform)) {
|
|
5291
5432
|
throw Object.assign(
|
|
5292
|
-
new Error(`\u4E0D\u652F\u6301\u7684\u76EE\u6807\u5E73\u53F0\uFF1A${
|
|
5433
|
+
new Error(`\u4E0D\u652F\u6301\u7684\u76EE\u6807\u5E73\u53F0\uFF1A${requestedPlatform}\uFF08\u53EF\u9009\uFF1A${VALID_PLATFORMS.join(", ")}\uFF09`),
|
|
5293
5434
|
{ code: "INVALID_ARGUMENT" }
|
|
5294
5435
|
);
|
|
5295
5436
|
}
|
|
5437
|
+
const effectiveSubmitUrl = normalizeSubmitUrl(submitUrl);
|
|
5438
|
+
const detection = requestedPlatform === "auto" ? { requestedPlatform: "auto", ...detectHostEnvironment({ projectDir, outDir }) } : {
|
|
5439
|
+
requestedPlatform,
|
|
5440
|
+
resolvedPlatform: requestedPlatform,
|
|
5441
|
+
confidence: "explicit",
|
|
5442
|
+
projectRoot: findNearestExistingDir(projectDir || outDir || process.cwd()),
|
|
5443
|
+
signals: ["explicit-platform"],
|
|
5444
|
+
summary: `Explicit platform requested: ${requestedPlatform}`
|
|
5445
|
+
};
|
|
5446
|
+
const resolvedPlatform = detection.resolvedPlatform;
|
|
5296
5447
|
const schema = normalizeSchemaEnvelope(readJsonFile(schemaPath, "FormSchema \u6587\u4EF6"));
|
|
5297
5448
|
const rawTheme = themePath ? readJsonFile(themePath, "ThemeConfigJson \u6587\u4EF6") : { version: "1.0.0", skin: "fin-minimal", override: {}, formMode: "flat", showProgressBar: true };
|
|
5298
5449
|
const themeConfig = { ...rawTheme, mode: "final" };
|
|
@@ -5306,7 +5457,8 @@ module.exports = ${JSON.stringify(payload, null, 2)}
|
|
|
5306
5457
|
format: "agentprismform-mobile-bundle/v1",
|
|
5307
5458
|
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5308
5459
|
schema,
|
|
5309
|
-
themeConfig
|
|
5460
|
+
themeConfig,
|
|
5461
|
+
...effectiveSubmitUrl ? { submitUrl: effectiveSubmitUrl } : {}
|
|
5310
5462
|
};
|
|
5311
5463
|
const bundleOut = writeJsonAtomic(path2.join(absDir, "form.bundle.json"), bundle, { overwrite: true });
|
|
5312
5464
|
const typesOut = path2.join(absDir, "types.d.ts");
|
|
@@ -5315,7 +5467,7 @@ module.exports = ${JSON.stringify(payload, null, 2)}
|
|
|
5315
5467
|
let packages = [];
|
|
5316
5468
|
let entryFile = "";
|
|
5317
5469
|
let mountSnippet = "";
|
|
5318
|
-
if (
|
|
5470
|
+
if (resolvedPlatform === "vue3") {
|
|
5319
5471
|
packages = [`${scope}/render-vue`];
|
|
5320
5472
|
entryFile = path2.join(absDir, `${compName}.vue`);
|
|
5321
5473
|
const vueCode = `<script setup lang="ts">
|
|
@@ -5360,7 +5512,7 @@ const emit = defineEmits<{
|
|
|
5360
5512
|
fs.writeFileSync(entryFile, vueCode, "utf8");
|
|
5361
5513
|
files.component = entryFile;
|
|
5362
5514
|
mountSnippet = `<${compName} :host-handlers="hostHandlers" :custom-controls="{}" @submit="handleSubmit" />`;
|
|
5363
|
-
} else if (
|
|
5515
|
+
} else if (resolvedPlatform === "react18") {
|
|
5364
5516
|
packages = [`${scope}/render-web`];
|
|
5365
5517
|
entryFile = path2.join(absDir, `${compName}.tsx`);
|
|
5366
5518
|
const reactCode = `import React from 'react'
|
|
@@ -5406,7 +5558,7 @@ export function ${compName}({
|
|
|
5406
5558
|
fs.writeFileSync(entryFile, reactCode, "utf8");
|
|
5407
5559
|
files.component = entryFile;
|
|
5408
5560
|
mountSnippet = `<${compName} hostHandlers={hostHandlers} customControls={{}} onSubmit={handleSubmit} />`;
|
|
5409
|
-
} else if (
|
|
5561
|
+
} else if (resolvedPlatform === "headless") {
|
|
5410
5562
|
packages = [`${scope}/core`, `${scope}/render`];
|
|
5411
5563
|
entryFile = path2.join(absDir, `${compName}.tsx`);
|
|
5412
5564
|
const headlessCode = `import React, { useEffect, useRef, useState } from 'react'
|
|
@@ -5492,8 +5644,23 @@ export function ${compName}({ onSubmit }: ${compName}Props) {
|
|
|
5492
5644
|
fs.writeFileSync(entryFile, headlessCode, "utf8");
|
|
5493
5645
|
files.component = entryFile;
|
|
5494
5646
|
mountSnippet = `<${compName} onSubmit={handleSubmit} />`;
|
|
5647
|
+
} else if (resolvedPlatform === "standalone") {
|
|
5648
|
+
packages = [];
|
|
5649
|
+
const resolvedAssetsDir = assetsDir || path2.resolve(__dirname, "../preview");
|
|
5650
|
+
const { html } = renderStandaloneHtml({
|
|
5651
|
+
schema,
|
|
5652
|
+
themeConfig,
|
|
5653
|
+
mode: "final",
|
|
5654
|
+
submitUrl: effectiveSubmitUrl,
|
|
5655
|
+
assetsDir: resolvedAssetsDir
|
|
5656
|
+
});
|
|
5657
|
+
entryFile = path2.join(absDir, "index.html");
|
|
5658
|
+
fs.writeFileSync(entryFile, html, "utf8");
|
|
5659
|
+
files.html = entryFile;
|
|
5660
|
+
mountSnippet = effectiveSubmitUrl ? `# Deploy index.html to any static host (Cloudflare Pages / Vercel / Nginx / OSS)
|
|
5661
|
+
# 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)`;
|
|
5495
5662
|
} else {
|
|
5496
|
-
packages = [`${scope}/
|
|
5663
|
+
packages = [`${scope}/render-miniapp`];
|
|
5497
5664
|
const dataFile = path2.join(absDir, "preview-data.js");
|
|
5498
5665
|
const jsonFile = path2.join(absDir, "index.json");
|
|
5499
5666
|
const wxmlFile = path2.join(absDir, "index.wxml");
|
|
@@ -5523,6 +5690,7 @@ export function ${compName}({ onSubmit }: ${compName}Props) {
|
|
|
5523
5690
|
`,
|
|
5524
5691
|
"utf8"
|
|
5525
5692
|
);
|
|
5693
|
+
const defaultMiniappUrl = effectiveSubmitUrl || "https://api.example.com/forms/submit";
|
|
5526
5694
|
fs.writeFileSync(
|
|
5527
5695
|
jsFile,
|
|
5528
5696
|
`const bundle = require('./preview-data.js')
|
|
@@ -5535,7 +5703,7 @@ Page({
|
|
|
5535
5703
|
onFormSubmit(ev) {
|
|
5536
5704
|
this.setData({ submitting: true })
|
|
5537
5705
|
wx.request({
|
|
5538
|
-
url: (this.data.schema && this.data.schema.submitApi) ||
|
|
5706
|
+
url: bundle.submitUrl || (this.data.schema && this.data.schema.submitApi) || ${JSON.stringify(defaultMiniappUrl)},
|
|
5539
5707
|
method: 'POST',
|
|
5540
5708
|
header: { 'Idempotency-Key': 'wx_' + Date.now() },
|
|
5541
5709
|
data: ev.detail,
|
|
@@ -5553,14 +5721,19 @@ Page({
|
|
|
5553
5721
|
files.pageJs = jsFile;
|
|
5554
5722
|
mountSnippet = `// Register "${path2.basename(absDir)}/index" inside WeChat Miniapp app.json -> "pages"`;
|
|
5555
5723
|
}
|
|
5556
|
-
const localInstallCmd = "npm install --install-links " + packages.map((p) => `<path-to-AgentPrismForm>/packages/${p.split("/")[1]}`).join(" ");
|
|
5557
|
-
const npmInstallCmd = `npm install ${packages.join(" ")}
|
|
5558
|
-
const
|
|
5559
|
-
|
|
5560
|
-
integrationDoc,
|
|
5561
|
-
`# ${compName} Integration Guide / \u63A5\u5165\u6307\u5357
|
|
5724
|
+
const localInstallCmd = packages.length ? "npm install --install-links " + packages.map((p) => `<path-to-AgentPrismForm>/packages/${p.split("/")[1]}`).join(" ") : "";
|
|
5725
|
+
const npmInstallCmd = packages.length ? `npm install ${packages.join(" ")}` : "";
|
|
5726
|
+
const submitNote = effectiveSubmitUrl ? `
|
|
5727
|
+
## Submit Endpoint / \u63D0\u4EA4\u63A5\u53E3\u51FA\u53E3
|
|
5562
5728
|
|
|
5563
|
-
|
|
5729
|
+
Configured \`submitUrl\`: \`${effectiveSubmitUrl}\`
|
|
5730
|
+
|
|
5731
|
+
Payload envelope sent via \`POST\` (with \`Idempotency-Key\` header):
|
|
5732
|
+
\`\`\`json
|
|
5733
|
+
{ "submissionId": "sub_...", "schemaVersion": "1.0.0", "storageKey": "${schema.storageKey || ""}", "submittedAt": "...", "channel": "web-mobile", "data": { ... } }
|
|
5734
|
+
\`\`\`
|
|
5735
|
+
` : "";
|
|
5736
|
+
const installSection = packages.length ? `## 1. Install Required Packages / \u5B89\u88C5\u4F9D\u8D56\u5305
|
|
5564
5737
|
|
|
5565
5738
|
**Option A \u2014 From npm registry / \u4ECE npm \u5B98\u65B9\u6E90\u76F4\u63A5\u5B89\u88C5\uFF08\u63A8\u8350\uFF09:**
|
|
5566
5739
|
\`\`\`bash
|
|
@@ -5571,24 +5744,37 @@ ${npmInstallCmd}
|
|
|
5571
5744
|
\`\`\`bash
|
|
5572
5745
|
${localInstallCmd}
|
|
5573
5746
|
\`\`\`
|
|
5747
|
+
` : `## 1. Zero-Dependency Standalone Delivery / \u96F6\u4F9D\u8D56\u72EC\u7ACB\u4EA4\u4ED8
|
|
5748
|
+
|
|
5749
|
+
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).
|
|
5750
|
+
`;
|
|
5751
|
+
const integrationDoc = path2.join(absDir, "INTEGRATION.md");
|
|
5752
|
+
fs.writeFileSync(
|
|
5753
|
+
integrationDoc,
|
|
5754
|
+
`# ${compName} Integration Guide / \u63A5\u5165\u6307\u5357
|
|
5574
5755
|
|
|
5575
|
-
|
|
5756
|
+
> **Resolved Delivery Target**: \`${resolvedPlatform}\` (${detection.summary})
|
|
5757
|
+
|
|
5758
|
+
${installSection}
|
|
5759
|
+
## 2. Mount or Deploy / \u6302\u8F7D\u6216\u90E8\u7F72
|
|
5576
5760
|
|
|
5577
5761
|
\`\`\`tsx
|
|
5578
5762
|
${mountSnippet}
|
|
5579
5763
|
\`\`\`
|
|
5580
|
-
|
|
5764
|
+
${submitNote}
|
|
5581
5765
|
## 3. Files Generated / \u751F\u6210\u6587\u4EF6\u6E05\u5355
|
|
5582
5766
|
- \`form.bundle.json\` \u2014 Finalized FormSchema + locked ThemeConfig
|
|
5583
5767
|
- \`types.d.ts\` \u2014 TypeScript DTO derived from FormSchema
|
|
5584
|
-
- \`${path2.basename(entryFile)}\` \u2014 Ready-to-run ${
|
|
5768
|
+
- \`${path2.basename(entryFile)}\` \u2014 Ready-to-run ${resolvedPlatform} deliverable
|
|
5585
5769
|
`,
|
|
5586
5770
|
"utf8"
|
|
5587
5771
|
);
|
|
5588
5772
|
files.integrationGuide = integrationDoc;
|
|
5589
5773
|
return {
|
|
5590
5774
|
status: "scaffolded",
|
|
5591
|
-
platform,
|
|
5775
|
+
platform: resolvedPlatform,
|
|
5776
|
+
detection,
|
|
5777
|
+
submitUrl: effectiveSubmitUrl || null,
|
|
5592
5778
|
componentName: compName,
|
|
5593
5779
|
outDir: absDir,
|
|
5594
5780
|
packages,
|
|
@@ -5599,6 +5785,7 @@ ${mountSnippet}
|
|
|
5599
5785
|
}
|
|
5600
5786
|
module2.exports = {
|
|
5601
5787
|
listSnippetsAndPresets,
|
|
5788
|
+
detectHostEnvironment,
|
|
5602
5789
|
schemaInit,
|
|
5603
5790
|
schemaSet,
|
|
5604
5791
|
schemaPatch,
|
|
@@ -5951,7 +6138,7 @@ data: ${JSON.stringify({
|
|
|
5951
6138
|
}
|
|
5952
6139
|
});
|
|
5953
6140
|
|
|
5954
|
-
// output/oss-release/agentprismform-1.
|
|
6141
|
+
// output/oss-release/agentprismform-1.4.0-stage/packages/agent-plugin/.oss-cli-entry.cjs
|
|
5955
6142
|
var path = require("node:path");
|
|
5956
6143
|
var os = require("node:os");
|
|
5957
6144
|
var { spawnSync } = require("node:child_process");
|
|
@@ -5977,7 +6164,7 @@ var commands = {
|
|
|
5977
6164
|
"preview-miniapp": ["--schema", "--miniapp-project"],
|
|
5978
6165
|
"schema-export": ["--schema", "--out"],
|
|
5979
6166
|
"release-export": ["--schema", "--out-dir"],
|
|
5980
|
-
"scaffold-host": ["--schema", "--
|
|
6167
|
+
"scaffold-host": ["--schema", "--out-dir"],
|
|
5981
6168
|
"schema-contract": ["--schema"],
|
|
5982
6169
|
"contract-verify": ["--schema", "--target"],
|
|
5983
6170
|
"payload-map": ["--schema", "--data"],
|
|
@@ -6005,7 +6192,7 @@ async function run() {
|
|
|
6005
6192
|
const assetsDir = path.resolve(flags["--assets-dir"] || path.join(__dirname, "../preview"));
|
|
6006
6193
|
let result;
|
|
6007
6194
|
if (command === "describe") {
|
|
6008
|
-
result = { name: "@agentprismform/agent-plugin", version: "1.
|
|
6195
|
+
result = { name: "@agentprismform/agent-plugin", version: "1.4.0", protocolVersion, v2Supported: true, v2Loop: Object.keys(commands) };
|
|
6009
6196
|
} else if (command === "snippets") {
|
|
6010
6197
|
result = v2.listSnippetsAndPresets();
|
|
6011
6198
|
} else if (command === "schema-init") {
|
|
@@ -6039,7 +6226,7 @@ async function run() {
|
|
|
6039
6226
|
} else if (command === "preview-register") {
|
|
6040
6227
|
result = v2.registerV2Preview({ schemaPath: flags["--schema"], themePath: flags["--theme"], dataDir });
|
|
6041
6228
|
} else if (command === "preview-html") {
|
|
6042
|
-
result = v2.previewExportHtml({ schemaPath: flags["--schema"], themePath: flags["--theme"], out: flags["--out"], mode: flags["--mode"], locale: flags["--locale"], assetsDir });
|
|
6229
|
+
result = v2.previewExportHtml({ schemaPath: flags["--schema"], themePath: flags["--theme"], out: flags["--out"], mode: flags["--mode"], locale: flags["--locale"], submitUrl: flags["--submit-url"], assetsDir });
|
|
6043
6230
|
} else if (command === "preview-miniapp") {
|
|
6044
6231
|
result = v2.previewSyncMiniapp({ schemaPath: flags["--schema"], themePath: flags["--theme"], miniappProject: flags["--miniapp-project"] });
|
|
6045
6232
|
} else if (command === "schema-export") {
|
|
@@ -6052,17 +6239,21 @@ async function run() {
|
|
|
6052
6239
|
outDir: flags["--out-dir"],
|
|
6053
6240
|
keyStyle: flags["--key-style"] || "snake_case",
|
|
6054
6241
|
includeHtml: flags["--include-html"] === void 0 ? true : flags["--include-html"] !== "false",
|
|
6242
|
+
submitUrl: flags["--submit-url"],
|
|
6055
6243
|
assetsDir
|
|
6056
6244
|
});
|
|
6057
6245
|
} else if (command === "scaffold-host") {
|
|
6058
6246
|
result = v2.scaffoldHost({
|
|
6059
6247
|
schemaPath: flags["--schema"],
|
|
6060
6248
|
themePath: flags["--theme"],
|
|
6061
|
-
platform: flags["--platform"],
|
|
6249
|
+
platform: flags["--platform"] || "auto",
|
|
6062
6250
|
outDir: flags["--out-dir"],
|
|
6251
|
+
projectDir: flags["--project-dir"],
|
|
6063
6252
|
componentName: flags["--component-name"],
|
|
6064
6253
|
keyStyle: flags["--key-style"] || "snake_case",
|
|
6065
|
-
packageScope: flags["--scope"] || "@agentprismform"
|
|
6254
|
+
packageScope: flags["--scope"] || "@agentprismform",
|
|
6255
|
+
submitUrl: flags["--submit-url"],
|
|
6256
|
+
assetsDir
|
|
6066
6257
|
});
|
|
6067
6258
|
} else if (command === "schema-contract") {
|
|
6068
6259
|
result = v2.schemaContract({ schemaPath: flags["--schema"], keyStyle: flags["--key-style"], out: flags["--out"] });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentprismform/agent-plugin",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "[PRIMARY ENTRY] Agent-First form closed-loop plugin (20-tool MCP Server + CLI + Skill): author, self-test, preview, auto-detect target stack & deliver to Vue 3, React 18, Miniapp, or Standalone HTML",
|
|
5
5
|
"bin": {
|
|
6
6
|
"agent-plugin": "bin/form-agent.cjs",
|
|
7
7
|
"form-schema-agent": "bin/form-agent.cjs",
|