@agentprismform/agent-plugin 1.2.0 → 1.3.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/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/bin/form-agent-mcp.cjs +37 -225
- package/bin/form-agent.cjs +43 -226
- package/bin/install-host.cjs +34 -4
- package/package.json +2 -1
- package/preview/assets/index-DqinfX8n.js +62 -0
- package/preview/assets/skill-preview-DLn0brqE.js +153 -0
- package/preview/modern-preview.css +1 -1
- package/preview/skill-preview.html +1 -1
- package/preview/assets/index-I07pgrbZ.js +0 -62
- package/preview/assets/skill-preview-DMg9HJ6e.js +0 -153
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
Zero-dependency AI Agent plugin (CLI + 20-tool stdio MCP Server + Skill) for authoring, validating, self-testing, scaffolding host pages (`scaffold-host`), and live-previewing `FormSchema` forms across Vue 3, React 18, WeChat Miniapp, and standalone offline HTML (with full `en-US` / `zh-CN` UI switching).
|
|
6
6
|
|
|
7
|
-
## Quick Install (
|
|
7
|
+
## Quick Install (One Command via `npx` — Zero Global Install Needed)
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
|
|
10
|
+
npx @agentprismform/agent-plugin install --host antigravity --scope user --write-mcp
|
|
11
11
|
# or --host deepseek-harness | claude | cursor | all
|
|
12
12
|
```
|
package/README.zh-CN.md
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
零外部依赖的 AI Agent 表单插件(CLI + 20 工具 stdio MCP Server + Skill),支持 `FormSchema` 确定性创作、无头自测、一键脚手架注入宿主工程(`scaffold-host`)、SSE 1 秒热刷新预览与定稿单文件 HTML 导出(原生支持 `zh-CN` / `en-US` 双语切换)。
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## 一条命令免全局安装接入 AI 宿主(Antigravity / DeepSeek-Harness / Claude Code / Cursor)
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
|
|
10
|
+
npx @agentprismform/agent-plugin install --host antigravity --scope user --write-mcp
|
|
11
11
|
# 也支持 --host deepseek-harness | claude | cursor | all
|
|
12
12
|
```
|
package/bin/form-agent-mcp.cjs
CHANGED
|
@@ -16949,154 +16949,59 @@ module.exports = ${JSON.stringify(payload, null, 2)}
|
|
|
16949
16949
|
let entryFile = "";
|
|
16950
16950
|
let mountSnippet = "";
|
|
16951
16951
|
if (platform === "vue3") {
|
|
16952
|
-
packages = [`${scope}/
|
|
16952
|
+
packages = [`${scope}/render-vue`];
|
|
16953
16953
|
entryFile = path2.join(absDir, `${compName}.vue`);
|
|
16954
16954
|
const vueCode = `<script setup lang="ts">
|
|
16955
|
-
import {
|
|
16956
|
-
import { FormCore, type FormSchema } from '${scope}/core'
|
|
16957
|
-
import { createFormRenderState, type ResolvedFormGroup } from '${scope}/render'
|
|
16958
|
-
import { FormRender } from '${scope}/render-vue'
|
|
16959
|
-
import {
|
|
16960
|
-
FORM_UI_HOST_HANDLERS_KEY,
|
|
16961
|
-
MODERN_COLLAPSIBLE_KEY,
|
|
16962
|
-
MODERN_CUSTOM_CONTROLS_KEY,
|
|
16963
|
-
MODERN_KEYBOARD_POLICY_KEY,
|
|
16964
|
-
MODERN_LOCALE_KEY,
|
|
16965
|
-
MODERN_SHELL_SKIN_KEY,
|
|
16966
|
-
MODERN_THEME_OVERRIDE_KEY,
|
|
16967
|
-
getModernShellComponents,
|
|
16968
|
-
resolveModernThemeVars,
|
|
16969
|
-
type FormUiHostHandlers,
|
|
16970
|
-
type ModernCustomControlsMap,
|
|
16971
|
-
type ModernKeyboardPolicy,
|
|
16972
|
-
type ModernLocale,
|
|
16973
|
-
type ModernShellSkin,
|
|
16974
|
-
} from '${scope}/render-ui'
|
|
16975
|
-
import '${scope}/render-ui/style.css'
|
|
16955
|
+
import { PrismForm, type UniversalHostHandlers } from '${scope}/render-vue'
|
|
16976
16956
|
import '${scope}/render-vue/style.css'
|
|
16977
16957
|
import bundle from './form.bundle.json'
|
|
16978
16958
|
|
|
16979
|
-
|
|
16959
|
+
withDefaults(
|
|
16980
16960
|
defineProps<{
|
|
16981
|
-
hostHandlers?:
|
|
16982
|
-
customControls?:
|
|
16983
|
-
locale?:
|
|
16961
|
+
hostHandlers?: UniversalHostHandlers | null
|
|
16962
|
+
customControls?: Record<string, any>
|
|
16963
|
+
locale?: 'zh-CN' | 'en-US'
|
|
16984
16964
|
submitText?: string
|
|
16965
|
+
submitting?: boolean
|
|
16985
16966
|
}>(),
|
|
16986
16967
|
{
|
|
16987
16968
|
hostHandlers: null,
|
|
16988
16969
|
customControls: () => ({}),
|
|
16989
|
-
locale: ((bundle.themeConfig as any)?.locale || 'zh-CN') as
|
|
16970
|
+
locale: ((bundle.themeConfig as any)?.locale || 'zh-CN') as 'zh-CN' | 'en-US',
|
|
16990
16971
|
submitText: ((bundle.themeConfig as any)?.submitText || '') as string,
|
|
16972
|
+
submitting: false,
|
|
16991
16973
|
},
|
|
16992
16974
|
)
|
|
16993
16975
|
|
|
16994
16976
|
const emit = defineEmits<{
|
|
16995
16977
|
(e: 'submit', payload: Record<string, unknown>): void
|
|
16996
16978
|
}>()
|
|
16997
|
-
|
|
16998
|
-
const schema = bundle.schema as unknown as FormSchema
|
|
16999
|
-
const themeCfg = (bundle.themeConfig || {}) as Record<string, any>
|
|
17000
|
-
const skin = ref<ModernShellSkin>((themeCfg.skin || 'fin-minimal') as ModernShellSkin)
|
|
17001
|
-
const localeRef = ref<ModernLocale>(props.locale)
|
|
17002
|
-
watch(() => props.locale, (v) => { localeRef.value = v })
|
|
17003
|
-
|
|
17004
|
-
const themeVars = resolveModernThemeVars(skin.value, themeCfg.override || null)
|
|
17005
|
-
const modernShell = getModernShellComponents()
|
|
17006
|
-
|
|
17007
|
-
const fields = reactive<Record<string, any>>({})
|
|
17008
|
-
const groups = ref<ResolvedFormGroup[]>([])
|
|
17009
|
-
const submitting = ref(false)
|
|
17010
|
-
let core: FormCore | null = null
|
|
17011
|
-
|
|
17012
|
-
provide(FORM_UI_HOST_HANDLERS_KEY, props.hostHandlers)
|
|
17013
|
-
provide(MODERN_SHELL_SKIN_KEY, skin)
|
|
17014
|
-
provide(MODERN_THEME_OVERRIDE_KEY, themeCfg.override || null)
|
|
17015
|
-
provide(MODERN_COLLAPSIBLE_KEY, themeCfg.formMode === 'collapsible')
|
|
17016
|
-
provide(MODERN_KEYBOARD_POLICY_KEY, (themeCfg.keyboardPolicy || 'auto') as ModernKeyboardPolicy)
|
|
17017
|
-
provide(MODERN_LOCALE_KEY, localeRef)
|
|
17018
|
-
provide(MODERN_CUSTOM_CONTROLS_KEY, props.customControls)
|
|
17019
|
-
|
|
17020
|
-
function syncState() {
|
|
17021
|
-
if (!core) return
|
|
17022
|
-
for (const k of Object.keys(fields)) delete fields[k]
|
|
17023
|
-
for (const k of Object.keys(core.fields)) fields[k] = { ...core.fields[k] }
|
|
17024
|
-
groups.value = createFormRenderState(schema, { ...fields }, { excludeTaskAndAgreement: false }).groups
|
|
17025
|
-
}
|
|
17026
|
-
|
|
17027
|
-
async function onSubmit() {
|
|
17028
|
-
if (!core || submitting.value) return
|
|
17029
|
-
if (!core.validateAll()) {
|
|
17030
|
-
syncState()
|
|
17031
|
-
const firstErr = document.querySelector('[data-has-error="1"]') as HTMLElement | null
|
|
17032
|
-
firstErr?.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
|
17033
|
-
const input = firstErr?.querySelector('input, textarea, select') as HTMLElement | null
|
|
17034
|
-
input?.focus?.({ preventScroll: true })
|
|
17035
|
-
return
|
|
17036
|
-
}
|
|
17037
|
-
submitting.value = true
|
|
17038
|
-
try {
|
|
17039
|
-
const payload = core.collectFormData({ skipVerify: true })
|
|
17040
|
-
emit('submit', payload)
|
|
17041
|
-
} finally {
|
|
17042
|
-
submitting.value = false
|
|
17043
|
-
}
|
|
17044
|
-
}
|
|
17045
|
-
|
|
17046
|
-
onMounted(async () => {
|
|
17047
|
-
const mem = new Map<string, any>()
|
|
17048
|
-
core = new FormCore(JSON.parse(JSON.stringify(schema)), {
|
|
17049
|
-
get: (k) => mem.get(k),
|
|
17050
|
-
set: (k, v) => mem.set(k, v),
|
|
17051
|
-
remove: (k) => mem.delete(k),
|
|
17052
|
-
})
|
|
17053
|
-
await core.init({})
|
|
17054
|
-
core.on('afterChange', syncState)
|
|
17055
|
-
syncState()
|
|
17056
|
-
})
|
|
17057
|
-
|
|
17058
|
-
onUnmounted(() => {
|
|
17059
|
-
core?.off('afterChange', syncState)
|
|
17060
|
-
})
|
|
17061
16979
|
</script>
|
|
17062
16980
|
|
|
17063
16981
|
<template>
|
|
17064
|
-
<
|
|
17065
|
-
|
|
17066
|
-
|
|
17067
|
-
|
|
17068
|
-
|
|
17069
|
-
|
|
17070
|
-
|
|
17071
|
-
|
|
17072
|
-
|
|
17073
|
-
/>
|
|
17074
|
-
<div style="padding: 12px 16px;">
|
|
17075
|
-
<button
|
|
17076
|
-
type="button"
|
|
17077
|
-
:disabled="submitting"
|
|
17078
|
-
style="width: 100%; height: 44px; border: 0; border-radius: 10px; background: var(--fs-brand, #0F52BA); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;"
|
|
17079
|
-
@click="onSubmit"
|
|
17080
|
-
>
|
|
17081
|
-
{{ submitText || (localeRef === 'en-US' ? 'Submit Form' : '\u63D0\u4EA4\u8868\u5355') }}
|
|
17082
|
-
</button>
|
|
17083
|
-
</div>
|
|
17084
|
-
</div>
|
|
16982
|
+
<PrismForm
|
|
16983
|
+
:bundle="bundle as any"
|
|
16984
|
+
:host-handlers="hostHandlers"
|
|
16985
|
+
:custom-controls="customControls"
|
|
16986
|
+
:locale="locale"
|
|
16987
|
+
:submit-text="submitText || undefined"
|
|
16988
|
+
:submitting="submitting"
|
|
16989
|
+
@submit="(payload) => emit('submit', payload)"
|
|
16990
|
+
/>
|
|
17085
16991
|
</template>
|
|
17086
16992
|
`;
|
|
17087
16993
|
fs.writeFileSync(entryFile, vueCode, "utf8");
|
|
17088
16994
|
files.component = entryFile;
|
|
17089
16995
|
mountSnippet = `<${compName} :host-handlers="hostHandlers" :custom-controls="{}" @submit="handleSubmit" />`;
|
|
17090
16996
|
} else if (platform === "react18") {
|
|
17091
|
-
packages = [`${scope}/
|
|
16997
|
+
packages = [`${scope}/render-web`];
|
|
17092
16998
|
entryFile = path2.join(absDir, `${compName}.tsx`);
|
|
17093
|
-
const reactCode = `import React
|
|
17094
|
-
import { FormCore, type FormSchema } from '${scope}/core'
|
|
16999
|
+
const reactCode = `import React from 'react'
|
|
17095
17000
|
import {
|
|
17096
|
-
|
|
17001
|
+
PrismForm,
|
|
17097
17002
|
type FormWebHostHandlers,
|
|
17098
17003
|
type WebCustomControlsMap,
|
|
17099
|
-
type
|
|
17004
|
+
type WebLocale,
|
|
17100
17005
|
type WebRenderControlFn,
|
|
17101
17006
|
} from '${scope}/render-web'
|
|
17102
17007
|
import bundle from './form.bundle.json'
|
|
@@ -17105,6 +17010,7 @@ export interface ${compName}Props {
|
|
|
17105
17010
|
hostHandlers?: FormWebHostHandlers | null
|
|
17106
17011
|
customControls?: WebCustomControlsMap
|
|
17107
17012
|
renderControl?: WebRenderControlFn
|
|
17013
|
+
locale?: WebLocale
|
|
17108
17014
|
submitText?: string
|
|
17109
17015
|
onSubmit: (payload: Record<string, unknown>) => void | Promise<void>
|
|
17110
17016
|
}
|
|
@@ -17113,114 +17019,20 @@ export function ${compName}({
|
|
|
17113
17019
|
hostHandlers = null,
|
|
17114
17020
|
customControls,
|
|
17115
17021
|
renderControl,
|
|
17022
|
+
locale,
|
|
17116
17023
|
submitText,
|
|
17117
17024
|
onSubmit,
|
|
17118
17025
|
}: ${compName}Props) {
|
|
17119
|
-
const schema = bundle.schema as unknown as FormSchema
|
|
17120
|
-
const themeCfg = (bundle.themeConfig || {}) as Record<string, any>
|
|
17121
|
-
const coreRef = useRef<FormCore | null>(null)
|
|
17122
|
-
const [fields, setFields] = useState<Record<string, any>>({})
|
|
17123
|
-
const [submitting, setSubmitting] = useState(false)
|
|
17124
|
-
|
|
17125
|
-
const syncState = useCallback(() => {
|
|
17126
|
-
const c = coreRef.current
|
|
17127
|
-
if (!c) return
|
|
17128
|
-
const next: Record<string, any> = {}
|
|
17129
|
-
for (const k of Object.keys(c.fields)) next[k] = { ...c.fields[k] }
|
|
17130
|
-
setFields(next)
|
|
17131
|
-
}, [])
|
|
17132
|
-
|
|
17133
|
-
useEffect(() => {
|
|
17134
|
-
const mem = new Map<string, any>()
|
|
17135
|
-
const c = new FormCore(JSON.parse(JSON.stringify(schema)), {
|
|
17136
|
-
get: (k) => mem.get(k),
|
|
17137
|
-
set: (k, v) => mem.set(k, v),
|
|
17138
|
-
remove: (k) => mem.delete(k),
|
|
17139
|
-
})
|
|
17140
|
-
coreRef.current = c
|
|
17141
|
-
c.init({}).then(() => {
|
|
17142
|
-
c.on('afterChange', syncState)
|
|
17143
|
-
syncState()
|
|
17144
|
-
})
|
|
17145
|
-
return () => { c.off('afterChange', syncState) }
|
|
17146
|
-
}, [schema, syncState])
|
|
17147
|
-
|
|
17148
|
-
const handleFieldChange = useCallback(
|
|
17149
|
-
({ key, value, eventType }: { key: string; value: any; eventType?: string }) => {
|
|
17150
|
-
const c = coreRef.current
|
|
17151
|
-
if (!c) return
|
|
17152
|
-
const hadError = Boolean(c.fields[key]?.errMsg)
|
|
17153
|
-
c.setControlData(key, value, {
|
|
17154
|
-
eventType: eventType === 'inputChange' ? undefined : eventType,
|
|
17155
|
-
...(eventType === 'inputChange' && !hadError ? { skipVerify: true } : {}),
|
|
17156
|
-
})
|
|
17157
|
-
},
|
|
17158
|
-
[],
|
|
17159
|
-
)
|
|
17160
|
-
|
|
17161
|
-
const handleSubmit = async () => {
|
|
17162
|
-
const c = coreRef.current
|
|
17163
|
-
if (!c || submitting) return
|
|
17164
|
-
if (!c.validateAll()) {
|
|
17165
|
-
syncState()
|
|
17166
|
-
const firstErr = document.querySelector('[data-has-error="1"]') as HTMLElement | null
|
|
17167
|
-
firstErr?.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
|
17168
|
-
const input = firstErr?.querySelector('input, textarea, select') as HTMLElement | null
|
|
17169
|
-
input?.focus?.({ preventScroll: true })
|
|
17170
|
-
return
|
|
17171
|
-
}
|
|
17172
|
-
setSubmitting(true)
|
|
17173
|
-
try {
|
|
17174
|
-
const payload = c.collectFormData({ skipVerify: true })
|
|
17175
|
-
await onSubmit(payload)
|
|
17176
|
-
} finally {
|
|
17177
|
-
setSubmitting(false)
|
|
17178
|
-
}
|
|
17179
|
-
}
|
|
17180
|
-
|
|
17181
|
-
const label =
|
|
17182
|
-
submitText ||
|
|
17183
|
-
themeCfg.submitText ||
|
|
17184
|
-
(String(themeCfg.locale || '').startsWith('en') ? 'Submit Form' : '\u63D0\u4EA4\u8868\u5355')
|
|
17185
|
-
|
|
17186
17026
|
return (
|
|
17187
|
-
<
|
|
17188
|
-
|
|
17189
|
-
|
|
17190
|
-
|
|
17191
|
-
|
|
17192
|
-
|
|
17193
|
-
|
|
17194
|
-
|
|
17195
|
-
|
|
17196
|
-
hostHandlers={hostHandlers}
|
|
17197
|
-
customControls={customControls}
|
|
17198
|
-
renderControl={renderControl}
|
|
17199
|
-
onFieldChange={handleFieldChange}
|
|
17200
|
-
footer={
|
|
17201
|
-
<div style={{ padding: '12px 16px' }}>
|
|
17202
|
-
<button
|
|
17203
|
-
type="button"
|
|
17204
|
-
disabled={submitting}
|
|
17205
|
-
onClick={handleSubmit}
|
|
17206
|
-
style={{
|
|
17207
|
-
width: '100%',
|
|
17208
|
-
height: 44,
|
|
17209
|
-
border: 0,
|
|
17210
|
-
borderRadius: 10,
|
|
17211
|
-
background: themeCfg.override?.brandColor || '#0F52BA',
|
|
17212
|
-
color: '#fff',
|
|
17213
|
-
fontSize: 15,
|
|
17214
|
-
fontWeight: 600,
|
|
17215
|
-
cursor: 'pointer',
|
|
17216
|
-
}}
|
|
17217
|
-
>
|
|
17218
|
-
{label}
|
|
17219
|
-
</button>
|
|
17220
|
-
</div>
|
|
17221
|
-
}
|
|
17222
|
-
/>
|
|
17223
|
-
</div>
|
|
17027
|
+
<PrismForm
|
|
17028
|
+
bundle={bundle as any}
|
|
17029
|
+
hostHandlers={hostHandlers}
|
|
17030
|
+
customControls={customControls}
|
|
17031
|
+
renderControl={renderControl}
|
|
17032
|
+
locale={locale}
|
|
17033
|
+
submitText={submitText}
|
|
17034
|
+
onSubmit={onSubmit}
|
|
17035
|
+
/>
|
|
17224
17036
|
)
|
|
17225
17037
|
}
|
|
17226
17038
|
`;
|
|
@@ -17383,14 +17195,14 @@ Page({
|
|
|
17383
17195
|
|
|
17384
17196
|
## 1. Install Required Packages / \u5B89\u88C5\u4F9D\u8D56\u5305
|
|
17385
17197
|
|
|
17386
|
-
**Option A \u2014 From
|
|
17198
|
+
**Option A \u2014 From npm registry / \u4ECE npm \u5B98\u65B9\u6E90\u76F4\u63A5\u5B89\u88C5\uFF08\u63A8\u8350\uFF09:**
|
|
17387
17199
|
\`\`\`bash
|
|
17388
|
-
${
|
|
17200
|
+
${npmInstallCmd}
|
|
17389
17201
|
\`\`\`
|
|
17390
17202
|
|
|
17391
|
-
**Option B \u2014 From
|
|
17203
|
+
**Option B \u2014 From local AgentPrismForm clone / \u79BB\u7EBF\u6216\u672C\u5730\u4ED3\u5E93\u8C03\u8BD5:**
|
|
17392
17204
|
\`\`\`bash
|
|
17393
|
-
${
|
|
17205
|
+
${localInstallCmd}
|
|
17394
17206
|
\`\`\`
|
|
17395
17207
|
|
|
17396
17208
|
## 2. Mount in Your App / \u5728\u4E1A\u52A1\u9875\u9762\u6302\u8F7D
|