@agentprismform/agent-plugin 1.2.0 → 1.3.1
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 +81 -244
- package/bin/form-agent.cjs +77 -241
- package/bin/install-host.cjs +34 -4
- package/package.json +2 -1
- package/preview/assets/index-W20NBzZy.js +62 -0
- package/preview/assets/skill-preview-dOID4sJY.js +153 -0
- package/preview/modern-preview.css +1 -1
- package/preview/modern-preview.iife.js +9 -9
- package/preview/skill-preview.html +1 -1
- package/skills/form-schema-author/SKILL.md +50 -46
- package/preview/assets/index-I07pgrbZ.js +0 -62
- package/preview/assets/skill-preview-DMg9HJ6e.js +0 -153
package/bin/form-agent.cjs
CHANGED
|
@@ -3131,19 +3131,37 @@ var require_patch = __commonJS({
|
|
|
3131
3131
|
for (const op of operations) {
|
|
3132
3132
|
switch (op.type) {
|
|
3133
3133
|
case "SET_FORM_META": {
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3134
|
+
const meta = op.patch || op;
|
|
3135
|
+
if (!meta || typeof meta !== "object") {
|
|
3136
|
+
opErrors.push({
|
|
3137
|
+
code: "INVALID_FIELD_KEY",
|
|
3138
|
+
severity: "error",
|
|
3139
|
+
message: 'SET_FORM_META \u9700\u8981 patch \u5BF9\u8C61\uFF0C\u4F8B\u5982 { "type": "SET_FORM_META", "patch": { "title": "...", "storageKey": "..." } }'
|
|
3140
|
+
});
|
|
3141
|
+
break;
|
|
3142
|
+
}
|
|
3143
|
+
if (meta.title !== void 0)
|
|
3144
|
+
next.title = meta.title;
|
|
3145
|
+
if (meta.description !== void 0)
|
|
3146
|
+
next.description = meta.description;
|
|
3147
|
+
if (meta.submitApi !== void 0)
|
|
3148
|
+
next.submitApi = meta.submitApi;
|
|
3149
|
+
if (meta.storageKey !== void 0)
|
|
3150
|
+
next.storageKey = meta.storageKey;
|
|
3142
3151
|
break;
|
|
3143
3152
|
}
|
|
3144
3153
|
case "ADD_GROUP": {
|
|
3154
|
+
const grp = op.group || (op.key ? { key: op.key, title: op.title || "", items: op.items || [] } : null);
|
|
3155
|
+
if (!grp || typeof grp !== "object" || !grp.key) {
|
|
3156
|
+
opErrors.push({
|
|
3157
|
+
code: "GROUP_NOT_FOUND",
|
|
3158
|
+
severity: "error",
|
|
3159
|
+
message: 'ADD_GROUP \u9700\u8981 group \u5BF9\u8C61\u4E14\u542B key\uFF0C\u4F8B\u5982 { "type": "ADD_GROUP", "group": { "key": "group_info", "title": "\u57FA\u672C\u4FE1\u606F", "items": [] } }'
|
|
3160
|
+
});
|
|
3161
|
+
break;
|
|
3162
|
+
}
|
|
3145
3163
|
const idx = clampIndex(op.index, next.groups.length);
|
|
3146
|
-
next.groups.splice(idx, 0, JSON.parse(JSON.stringify(
|
|
3164
|
+
next.groups.splice(idx, 0, JSON.parse(JSON.stringify(grp)));
|
|
3147
3165
|
break;
|
|
3148
3166
|
}
|
|
3149
3167
|
case "UPDATE_GROUP": {
|
|
@@ -3157,12 +3175,13 @@ var require_patch = __commonJS({
|
|
|
3157
3175
|
});
|
|
3158
3176
|
break;
|
|
3159
3177
|
}
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3178
|
+
const gPatch = op.patch || {};
|
|
3179
|
+
if (gPatch.title !== void 0)
|
|
3180
|
+
g.title = gPatch.title;
|
|
3181
|
+
if (gPatch.description !== void 0)
|
|
3182
|
+
g.description = gPatch.description;
|
|
3183
|
+
if (gPatch.visible !== void 0)
|
|
3184
|
+
g.visible = gPatch.visible;
|
|
3166
3185
|
break;
|
|
3167
3186
|
}
|
|
3168
3187
|
case "REMOVE_GROUP": {
|
|
@@ -5297,154 +5316,59 @@ module.exports = ${JSON.stringify(payload, null, 2)}
|
|
|
5297
5316
|
let entryFile = "";
|
|
5298
5317
|
let mountSnippet = "";
|
|
5299
5318
|
if (platform === "vue3") {
|
|
5300
|
-
packages = [`${scope}/
|
|
5319
|
+
packages = [`${scope}/render-vue`];
|
|
5301
5320
|
entryFile = path2.join(absDir, `${compName}.vue`);
|
|
5302
5321
|
const vueCode = `<script setup lang="ts">
|
|
5303
|
-
import {
|
|
5304
|
-
import { FormCore, type FormSchema } from '${scope}/core'
|
|
5305
|
-
import { createFormRenderState, type ResolvedFormGroup } from '${scope}/render'
|
|
5306
|
-
import { FormRender } from '${scope}/render-vue'
|
|
5307
|
-
import {
|
|
5308
|
-
FORM_UI_HOST_HANDLERS_KEY,
|
|
5309
|
-
MODERN_COLLAPSIBLE_KEY,
|
|
5310
|
-
MODERN_CUSTOM_CONTROLS_KEY,
|
|
5311
|
-
MODERN_KEYBOARD_POLICY_KEY,
|
|
5312
|
-
MODERN_LOCALE_KEY,
|
|
5313
|
-
MODERN_SHELL_SKIN_KEY,
|
|
5314
|
-
MODERN_THEME_OVERRIDE_KEY,
|
|
5315
|
-
getModernShellComponents,
|
|
5316
|
-
resolveModernThemeVars,
|
|
5317
|
-
type FormUiHostHandlers,
|
|
5318
|
-
type ModernCustomControlsMap,
|
|
5319
|
-
type ModernKeyboardPolicy,
|
|
5320
|
-
type ModernLocale,
|
|
5321
|
-
type ModernShellSkin,
|
|
5322
|
-
} from '${scope}/render-ui'
|
|
5323
|
-
import '${scope}/render-ui/style.css'
|
|
5322
|
+
import { PrismForm, type UniversalHostHandlers } from '${scope}/render-vue'
|
|
5324
5323
|
import '${scope}/render-vue/style.css'
|
|
5325
5324
|
import bundle from './form.bundle.json'
|
|
5326
5325
|
|
|
5327
|
-
|
|
5326
|
+
withDefaults(
|
|
5328
5327
|
defineProps<{
|
|
5329
|
-
hostHandlers?:
|
|
5330
|
-
customControls?:
|
|
5331
|
-
locale?:
|
|
5328
|
+
hostHandlers?: UniversalHostHandlers | null
|
|
5329
|
+
customControls?: Record<string, any>
|
|
5330
|
+
locale?: 'zh-CN' | 'en-US'
|
|
5332
5331
|
submitText?: string
|
|
5332
|
+
submitting?: boolean
|
|
5333
5333
|
}>(),
|
|
5334
5334
|
{
|
|
5335
5335
|
hostHandlers: null,
|
|
5336
5336
|
customControls: () => ({}),
|
|
5337
|
-
locale: ((bundle.themeConfig as any)?.locale || 'zh-CN') as
|
|
5337
|
+
locale: ((bundle.themeConfig as any)?.locale || 'zh-CN') as 'zh-CN' | 'en-US',
|
|
5338
5338
|
submitText: ((bundle.themeConfig as any)?.submitText || '') as string,
|
|
5339
|
+
submitting: false,
|
|
5339
5340
|
},
|
|
5340
5341
|
)
|
|
5341
5342
|
|
|
5342
5343
|
const emit = defineEmits<{
|
|
5343
5344
|
(e: 'submit', payload: Record<string, unknown>): void
|
|
5344
5345
|
}>()
|
|
5345
|
-
|
|
5346
|
-
const schema = bundle.schema as unknown as FormSchema
|
|
5347
|
-
const themeCfg = (bundle.themeConfig || {}) as Record<string, any>
|
|
5348
|
-
const skin = ref<ModernShellSkin>((themeCfg.skin || 'fin-minimal') as ModernShellSkin)
|
|
5349
|
-
const localeRef = ref<ModernLocale>(props.locale)
|
|
5350
|
-
watch(() => props.locale, (v) => { localeRef.value = v })
|
|
5351
|
-
|
|
5352
|
-
const themeVars = resolveModernThemeVars(skin.value, themeCfg.override || null)
|
|
5353
|
-
const modernShell = getModernShellComponents()
|
|
5354
|
-
|
|
5355
|
-
const fields = reactive<Record<string, any>>({})
|
|
5356
|
-
const groups = ref<ResolvedFormGroup[]>([])
|
|
5357
|
-
const submitting = ref(false)
|
|
5358
|
-
let core: FormCore | null = null
|
|
5359
|
-
|
|
5360
|
-
provide(FORM_UI_HOST_HANDLERS_KEY, props.hostHandlers)
|
|
5361
|
-
provide(MODERN_SHELL_SKIN_KEY, skin)
|
|
5362
|
-
provide(MODERN_THEME_OVERRIDE_KEY, themeCfg.override || null)
|
|
5363
|
-
provide(MODERN_COLLAPSIBLE_KEY, themeCfg.formMode === 'collapsible')
|
|
5364
|
-
provide(MODERN_KEYBOARD_POLICY_KEY, (themeCfg.keyboardPolicy || 'auto') as ModernKeyboardPolicy)
|
|
5365
|
-
provide(MODERN_LOCALE_KEY, localeRef)
|
|
5366
|
-
provide(MODERN_CUSTOM_CONTROLS_KEY, props.customControls)
|
|
5367
|
-
|
|
5368
|
-
function syncState() {
|
|
5369
|
-
if (!core) return
|
|
5370
|
-
for (const k of Object.keys(fields)) delete fields[k]
|
|
5371
|
-
for (const k of Object.keys(core.fields)) fields[k] = { ...core.fields[k] }
|
|
5372
|
-
groups.value = createFormRenderState(schema, { ...fields }, { excludeTaskAndAgreement: false }).groups
|
|
5373
|
-
}
|
|
5374
|
-
|
|
5375
|
-
async function onSubmit() {
|
|
5376
|
-
if (!core || submitting.value) return
|
|
5377
|
-
if (!core.validateAll()) {
|
|
5378
|
-
syncState()
|
|
5379
|
-
const firstErr = document.querySelector('[data-has-error="1"]') as HTMLElement | null
|
|
5380
|
-
firstErr?.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
|
5381
|
-
const input = firstErr?.querySelector('input, textarea, select') as HTMLElement | null
|
|
5382
|
-
input?.focus?.({ preventScroll: true })
|
|
5383
|
-
return
|
|
5384
|
-
}
|
|
5385
|
-
submitting.value = true
|
|
5386
|
-
try {
|
|
5387
|
-
const payload = core.collectFormData({ skipVerify: true })
|
|
5388
|
-
emit('submit', payload)
|
|
5389
|
-
} finally {
|
|
5390
|
-
submitting.value = false
|
|
5391
|
-
}
|
|
5392
|
-
}
|
|
5393
|
-
|
|
5394
|
-
onMounted(async () => {
|
|
5395
|
-
const mem = new Map<string, any>()
|
|
5396
|
-
core = new FormCore(JSON.parse(JSON.stringify(schema)), {
|
|
5397
|
-
get: (k) => mem.get(k),
|
|
5398
|
-
set: (k, v) => mem.set(k, v),
|
|
5399
|
-
remove: (k) => mem.delete(k),
|
|
5400
|
-
})
|
|
5401
|
-
await core.init({})
|
|
5402
|
-
core.on('afterChange', syncState)
|
|
5403
|
-
syncState()
|
|
5404
|
-
})
|
|
5405
|
-
|
|
5406
|
-
onUnmounted(() => {
|
|
5407
|
-
core?.off('afterChange', syncState)
|
|
5408
|
-
})
|
|
5409
5346
|
</script>
|
|
5410
5347
|
|
|
5411
5348
|
<template>
|
|
5412
|
-
<
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
/>
|
|
5422
|
-
<div style="padding: 12px 16px;">
|
|
5423
|
-
<button
|
|
5424
|
-
type="button"
|
|
5425
|
-
:disabled="submitting"
|
|
5426
|
-
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;"
|
|
5427
|
-
@click="onSubmit"
|
|
5428
|
-
>
|
|
5429
|
-
{{ submitText || (localeRef === 'en-US' ? 'Submit Form' : '\u63D0\u4EA4\u8868\u5355') }}
|
|
5430
|
-
</button>
|
|
5431
|
-
</div>
|
|
5432
|
-
</div>
|
|
5349
|
+
<PrismForm
|
|
5350
|
+
:bundle="bundle as any"
|
|
5351
|
+
:host-handlers="hostHandlers"
|
|
5352
|
+
:custom-controls="customControls"
|
|
5353
|
+
:locale="locale"
|
|
5354
|
+
:submit-text="submitText || undefined"
|
|
5355
|
+
:submitting="submitting"
|
|
5356
|
+
@submit="(payload) => emit('submit', payload)"
|
|
5357
|
+
/>
|
|
5433
5358
|
</template>
|
|
5434
5359
|
`;
|
|
5435
5360
|
fs.writeFileSync(entryFile, vueCode, "utf8");
|
|
5436
5361
|
files.component = entryFile;
|
|
5437
5362
|
mountSnippet = `<${compName} :host-handlers="hostHandlers" :custom-controls="{}" @submit="handleSubmit" />`;
|
|
5438
5363
|
} else if (platform === "react18") {
|
|
5439
|
-
packages = [`${scope}/
|
|
5364
|
+
packages = [`${scope}/render-web`];
|
|
5440
5365
|
entryFile = path2.join(absDir, `${compName}.tsx`);
|
|
5441
|
-
const reactCode = `import React
|
|
5442
|
-
import { FormCore, type FormSchema } from '${scope}/core'
|
|
5366
|
+
const reactCode = `import React from 'react'
|
|
5443
5367
|
import {
|
|
5444
|
-
|
|
5368
|
+
PrismForm,
|
|
5445
5369
|
type FormWebHostHandlers,
|
|
5446
5370
|
type WebCustomControlsMap,
|
|
5447
|
-
type
|
|
5371
|
+
type WebLocale,
|
|
5448
5372
|
type WebRenderControlFn,
|
|
5449
5373
|
} from '${scope}/render-web'
|
|
5450
5374
|
import bundle from './form.bundle.json'
|
|
@@ -5453,6 +5377,7 @@ export interface ${compName}Props {
|
|
|
5453
5377
|
hostHandlers?: FormWebHostHandlers | null
|
|
5454
5378
|
customControls?: WebCustomControlsMap
|
|
5455
5379
|
renderControl?: WebRenderControlFn
|
|
5380
|
+
locale?: WebLocale
|
|
5456
5381
|
submitText?: string
|
|
5457
5382
|
onSubmit: (payload: Record<string, unknown>) => void | Promise<void>
|
|
5458
5383
|
}
|
|
@@ -5461,114 +5386,20 @@ export function ${compName}({
|
|
|
5461
5386
|
hostHandlers = null,
|
|
5462
5387
|
customControls,
|
|
5463
5388
|
renderControl,
|
|
5389
|
+
locale,
|
|
5464
5390
|
submitText,
|
|
5465
5391
|
onSubmit,
|
|
5466
5392
|
}: ${compName}Props) {
|
|
5467
|
-
const schema = bundle.schema as unknown as FormSchema
|
|
5468
|
-
const themeCfg = (bundle.themeConfig || {}) as Record<string, any>
|
|
5469
|
-
const coreRef = useRef<FormCore | null>(null)
|
|
5470
|
-
const [fields, setFields] = useState<Record<string, any>>({})
|
|
5471
|
-
const [submitting, setSubmitting] = useState(false)
|
|
5472
|
-
|
|
5473
|
-
const syncState = useCallback(() => {
|
|
5474
|
-
const c = coreRef.current
|
|
5475
|
-
if (!c) return
|
|
5476
|
-
const next: Record<string, any> = {}
|
|
5477
|
-
for (const k of Object.keys(c.fields)) next[k] = { ...c.fields[k] }
|
|
5478
|
-
setFields(next)
|
|
5479
|
-
}, [])
|
|
5480
|
-
|
|
5481
|
-
useEffect(() => {
|
|
5482
|
-
const mem = new Map<string, any>()
|
|
5483
|
-
const c = new FormCore(JSON.parse(JSON.stringify(schema)), {
|
|
5484
|
-
get: (k) => mem.get(k),
|
|
5485
|
-
set: (k, v) => mem.set(k, v),
|
|
5486
|
-
remove: (k) => mem.delete(k),
|
|
5487
|
-
})
|
|
5488
|
-
coreRef.current = c
|
|
5489
|
-
c.init({}).then(() => {
|
|
5490
|
-
c.on('afterChange', syncState)
|
|
5491
|
-
syncState()
|
|
5492
|
-
})
|
|
5493
|
-
return () => { c.off('afterChange', syncState) }
|
|
5494
|
-
}, [schema, syncState])
|
|
5495
|
-
|
|
5496
|
-
const handleFieldChange = useCallback(
|
|
5497
|
-
({ key, value, eventType }: { key: string; value: any; eventType?: string }) => {
|
|
5498
|
-
const c = coreRef.current
|
|
5499
|
-
if (!c) return
|
|
5500
|
-
const hadError = Boolean(c.fields[key]?.errMsg)
|
|
5501
|
-
c.setControlData(key, value, {
|
|
5502
|
-
eventType: eventType === 'inputChange' ? undefined : eventType,
|
|
5503
|
-
...(eventType === 'inputChange' && !hadError ? { skipVerify: true } : {}),
|
|
5504
|
-
})
|
|
5505
|
-
},
|
|
5506
|
-
[],
|
|
5507
|
-
)
|
|
5508
|
-
|
|
5509
|
-
const handleSubmit = async () => {
|
|
5510
|
-
const c = coreRef.current
|
|
5511
|
-
if (!c || submitting) return
|
|
5512
|
-
if (!c.validateAll()) {
|
|
5513
|
-
syncState()
|
|
5514
|
-
const firstErr = document.querySelector('[data-has-error="1"]') as HTMLElement | null
|
|
5515
|
-
firstErr?.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
|
5516
|
-
const input = firstErr?.querySelector('input, textarea, select') as HTMLElement | null
|
|
5517
|
-
input?.focus?.({ preventScroll: true })
|
|
5518
|
-
return
|
|
5519
|
-
}
|
|
5520
|
-
setSubmitting(true)
|
|
5521
|
-
try {
|
|
5522
|
-
const payload = c.collectFormData({ skipVerify: true })
|
|
5523
|
-
await onSubmit(payload)
|
|
5524
|
-
} finally {
|
|
5525
|
-
setSubmitting(false)
|
|
5526
|
-
}
|
|
5527
|
-
}
|
|
5528
|
-
|
|
5529
|
-
const label =
|
|
5530
|
-
submitText ||
|
|
5531
|
-
themeCfg.submitText ||
|
|
5532
|
-
(String(themeCfg.locale || '').startsWith('en') ? 'Submit Form' : '\u63D0\u4EA4\u8868\u5355')
|
|
5533
|
-
|
|
5534
5393
|
return (
|
|
5535
|
-
<
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
hostHandlers={hostHandlers}
|
|
5545
|
-
customControls={customControls}
|
|
5546
|
-
renderControl={renderControl}
|
|
5547
|
-
onFieldChange={handleFieldChange}
|
|
5548
|
-
footer={
|
|
5549
|
-
<div style={{ padding: '12px 16px' }}>
|
|
5550
|
-
<button
|
|
5551
|
-
type="button"
|
|
5552
|
-
disabled={submitting}
|
|
5553
|
-
onClick={handleSubmit}
|
|
5554
|
-
style={{
|
|
5555
|
-
width: '100%',
|
|
5556
|
-
height: 44,
|
|
5557
|
-
border: 0,
|
|
5558
|
-
borderRadius: 10,
|
|
5559
|
-
background: themeCfg.override?.brandColor || '#0F52BA',
|
|
5560
|
-
color: '#fff',
|
|
5561
|
-
fontSize: 15,
|
|
5562
|
-
fontWeight: 600,
|
|
5563
|
-
cursor: 'pointer',
|
|
5564
|
-
}}
|
|
5565
|
-
>
|
|
5566
|
-
{label}
|
|
5567
|
-
</button>
|
|
5568
|
-
</div>
|
|
5569
|
-
}
|
|
5570
|
-
/>
|
|
5571
|
-
</div>
|
|
5394
|
+
<PrismForm
|
|
5395
|
+
bundle={bundle as any}
|
|
5396
|
+
hostHandlers={hostHandlers}
|
|
5397
|
+
customControls={customControls}
|
|
5398
|
+
renderControl={renderControl}
|
|
5399
|
+
locale={locale}
|
|
5400
|
+
submitText={submitText}
|
|
5401
|
+
onSubmit={onSubmit}
|
|
5402
|
+
/>
|
|
5572
5403
|
)
|
|
5573
5404
|
}
|
|
5574
5405
|
`;
|
|
@@ -5731,14 +5562,14 @@ Page({
|
|
|
5731
5562
|
|
|
5732
5563
|
## 1. Install Required Packages / \u5B89\u88C5\u4F9D\u8D56\u5305
|
|
5733
5564
|
|
|
5734
|
-
**Option A \u2014 From
|
|
5565
|
+
**Option A \u2014 From npm registry / \u4ECE npm \u5B98\u65B9\u6E90\u76F4\u63A5\u5B89\u88C5\uFF08\u63A8\u8350\uFF09:**
|
|
5735
5566
|
\`\`\`bash
|
|
5736
|
-
${
|
|
5567
|
+
${npmInstallCmd}
|
|
5737
5568
|
\`\`\`
|
|
5738
5569
|
|
|
5739
|
-
**Option B \u2014 From
|
|
5570
|
+
**Option B \u2014 From local AgentPrismForm clone / \u79BB\u7EBF\u6216\u672C\u5730\u4ED3\u5E93\u8C03\u8BD5:**
|
|
5740
5571
|
\`\`\`bash
|
|
5741
|
-
${
|
|
5572
|
+
${localInstallCmd}
|
|
5742
5573
|
\`\`\`
|
|
5743
5574
|
|
|
5744
5575
|
## 2. Mount in Your App / \u5728\u4E1A\u52A1\u9875\u9762\u6302\u8F7D
|
|
@@ -6123,6 +5954,11 @@ data: ${JSON.stringify({
|
|
|
6123
5954
|
// output/oss-release/agentprismform-1.0.0-stage/packages/agent-plugin/.oss-cli-entry.cjs
|
|
6124
5955
|
var path = require("node:path");
|
|
6125
5956
|
var os = require("node:os");
|
|
5957
|
+
var { spawnSync } = require("node:child_process");
|
|
5958
|
+
if (process.argv[2] === "install") {
|
|
5959
|
+
const r = spawnSync(process.execPath, [path.join(__dirname, "install-host.cjs"), ...process.argv.slice(3)], { stdio: "inherit" });
|
|
5960
|
+
process.exit(r.status === null ? 1 : r.status);
|
|
5961
|
+
}
|
|
6126
5962
|
var v2 = require_v2Core();
|
|
6127
5963
|
var { startV2Server: startServer } = require_v2Server();
|
|
6128
5964
|
var protocolVersion = "1.0";
|
|
@@ -6169,7 +6005,7 @@ async function run() {
|
|
|
6169
6005
|
const assetsDir = path.resolve(flags["--assets-dir"] || path.join(__dirname, "../preview"));
|
|
6170
6006
|
let result;
|
|
6171
6007
|
if (command === "describe") {
|
|
6172
|
-
result = { name: "@agentprismform/agent-plugin", version: "1.
|
|
6008
|
+
result = { name: "@agentprismform/agent-plugin", version: "1.3.1", protocolVersion, v2Supported: true, v2Loop: Object.keys(commands) };
|
|
6173
6009
|
} else if (command === "snippets") {
|
|
6174
6010
|
result = v2.listSnippetsAndPresets();
|
|
6175
6011
|
} else if (command === "schema-init") {
|
package/bin/install-host.cjs
CHANGED
|
@@ -6,7 +6,7 @@ const path = require('node:path')
|
|
|
6
6
|
const VALID_HOSTS = ['antigravity', 'deepseek-harness', 'claude', 'cursor', 'all']
|
|
7
7
|
|
|
8
8
|
function parse(argv) {
|
|
9
|
-
const out = { host: 'antigravity', scope: 'user', package: path.resolve(__dirname, '..'), writeMcp: false, dryRun: false, home: os.homedir() }
|
|
9
|
+
const out = { host: 'antigravity', scope: 'user', package: path.resolve(__dirname, '..'), persistDir: '', writeMcp: false, dryRun: false, home: os.homedir() }
|
|
10
10
|
for (let i = 0; i < argv.length; i += 1) {
|
|
11
11
|
const k = argv[i]
|
|
12
12
|
if (k === '--write-mcp') { out.writeMcp = true; continue }
|
|
@@ -14,14 +14,44 @@ function parse(argv) {
|
|
|
14
14
|
const v = argv[++i]
|
|
15
15
|
if (k === '--host') out.host = v
|
|
16
16
|
else if (k === '--package') out.package = path.resolve(v)
|
|
17
|
+
else if (k === '--persist-dir') out.persistDir = path.resolve(v)
|
|
17
18
|
else if (k === '--scope') out.scope = v
|
|
18
19
|
else if (k === '--home') out.home = path.resolve(v)
|
|
19
|
-
else throw new Error('Usage: --host antigravity|deepseek-harness|claude|cursor|all [--scope user|project] [--write-mcp] [--dry-run]')
|
|
20
|
+
else throw new Error('Usage: --host antigravity|deepseek-harness|claude|cursor|all [--scope user|project] [--write-mcp] [--dry-run] [--persist-dir <dir>]')
|
|
20
21
|
}
|
|
21
22
|
if (!VALID_HOSTS.includes(out.host)) throw new Error('--host must be ' + VALID_HOSTS.join('|'))
|
|
22
23
|
return out
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
function copyTree(src, dest) {
|
|
27
|
+
const stat = fs.statSync(src)
|
|
28
|
+
if (stat.isDirectory()) {
|
|
29
|
+
fs.mkdirSync(dest, { recursive: true })
|
|
30
|
+
for (const e of fs.readdirSync(src)) copyTree(path.join(src, e), path.join(dest, e))
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true })
|
|
34
|
+
fs.copyFileSync(src, dest)
|
|
35
|
+
fs.chmodSync(dest, stat.mode)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function resolveInstallRoot(opts) {
|
|
39
|
+
const fromNpx = /[\\/]_npx[\\/]/i.test(opts.package)
|
|
40
|
+
const targetDir = opts.persistDir || (fromNpx ? path.join(opts.home, '.agentprismform/agent-plugin') : '')
|
|
41
|
+
if (!targetDir || path.resolve(targetDir) === path.resolve(opts.package)) {
|
|
42
|
+
return { pkg: opts.package, persisted: false }
|
|
43
|
+
}
|
|
44
|
+
if (!opts.dryRun) {
|
|
45
|
+
fs.rmSync(targetDir, { recursive: true, force: true })
|
|
46
|
+
fs.mkdirSync(targetDir, { recursive: true })
|
|
47
|
+
for (const entry of ['bin', 'preview', 'skills', 'package.json', 'README.md', 'README.zh-CN.md']) {
|
|
48
|
+
const src = path.join(opts.package, entry)
|
|
49
|
+
if (fs.existsSync(src)) copyTree(src, path.join(targetDir, entry))
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return { pkg: targetDir, persisted: true }
|
|
53
|
+
}
|
|
54
|
+
|
|
25
55
|
function expand(h) { return h === 'all' ? ['antigravity', 'deepseek-harness', 'claude', 'cursor'] : [h] }
|
|
26
56
|
function skillRoot(h, s, home) {
|
|
27
57
|
const base = s === 'user' ? home : process.cwd()
|
|
@@ -39,7 +69,7 @@ function mcpPath(h, s, home) {
|
|
|
39
69
|
|
|
40
70
|
function main() {
|
|
41
71
|
const opts = parse(process.argv.slice(2))
|
|
42
|
-
const pkg = opts
|
|
72
|
+
const { pkg, persisted } = resolveInstallRoot(opts)
|
|
43
73
|
const mcp = path.join(pkg, 'bin/form-agent-mcp.cjs')
|
|
44
74
|
const entry = { command: 'node', args: [mcp], env: { FORM_AGENT_HOME: pkg } }
|
|
45
75
|
const links = []
|
|
@@ -85,6 +115,6 @@ function main() {
|
|
|
85
115
|
}
|
|
86
116
|
mcpConfigs.push({ host: h, path: mp, written: Boolean(opts.writeMcp && !opts.dryRun) })
|
|
87
117
|
}
|
|
88
|
-
process.stdout.write(JSON.stringify({ ok: true, links, mcpConfigs, mcpSnippet: { mcpServers: { 'form-schema-agent': entry } } }, null, 2) + '\n')
|
|
118
|
+
process.stdout.write(JSON.stringify({ ok: true, installRoot: pkg, persisted, links, mcpConfigs, mcpSnippet: { mcpServers: { 'form-schema-agent': entry } } }, null, 2) + '\n')
|
|
89
119
|
}
|
|
90
120
|
main()
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentprismform/agent-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "AI Agent plugin for schema-driven forms: zero-dependency CLI, stdio MCP Server, Skill, SSE live-reload preview, and standalone offline HTML exporter",
|
|
5
5
|
"bin": {
|
|
6
|
+
"agent-plugin": "bin/form-agent.cjs",
|
|
6
7
|
"form-schema-agent": "bin/form-agent.cjs",
|
|
7
8
|
"form-schema-agent-mcp": "bin/form-agent-mcp.cjs",
|
|
8
9
|
"form-schema-install": "bin/install-host.cjs"
|