diff --git a/src/commands/_blindspot_guards.ts b/src/commands/_blindspot_guards.ts
index 5a9aa33..5f172c1 100644
--- a/src/commands/_blindspot_guards.ts
+++ b/src/commands/_blindspot_guards.ts
@@ -1,27 +1,16 @@
/**
- * ⚠️ v0.10 LEGACY FILE — 保留以兼容手动 --fields 路径
+ * commands/_blindspot_guards.ts — 高频盲点代码 guard (22 条, v0.11+ 运行时自动检查)
*
- * v0.11+ 推荐用 buildFormData 路径 (web 端原版) — 见 ./_buildformdata.ts
- * - AI 建表 (--ai): 走 _ai.ts + buildFormData (Task 7 已切换)
- * - AI JSON 直入 (--ai-json, Task 10 新增): 走 buildFormData
- * - 手动 --fields 路径: 仍依赖本文件 (用户已习惯简化格式)
- *
- * 删除时机: 手动 --fields 路径弃用后 (用户都走 AI/JSON)
- *
- */
-/**
- * commands/_blindspot_guards.ts — 高频盲点代码 guard (P2.1, doc/ai-optimization-plan.md §4.1)
- *
- * 设计: 从 ~52 条盲点中取高频 22 条, 从文档 → 代码, 运行时自动检查
- * 调用方: form create, dm create, menu create, form release, dict typeCreate 等
+ * 设计: 从 ~52 条盲点中取高频 22 条, 从文档 → 代码.
+ * 调用方: form/dm/menu create, form release, dict typeCreate 等所有 create 命令.
*
* 与 form/_blindspots.ts 的区别:
- * - _blindspots.ts: 5 条 (BS-23/31/32/15/V2), 校验已发布 form 的 columnData/formData 内部结构
+ * - _blindspots.ts: 6 条 (BS-23/31/32/15/V2/52), 校验已发布 form 的 columnData/formData 内部结构
* - _blindspot_guards.ts: 22 条 (BS-1/4/5/7/8/14/15b/28/37/38/39/40/41/42/43/44/45/46/47/48/49/50/51),
* 校验命令执行前/后的依赖条件、状态一致性、参数组合、外部约束
*
- * Why: AI 不需要"记住 52 条盲点", dacli 自己在执行时检查
- * 每个 guard 包含 id/trigger/check/fix 字段, 失败时输出 [ERROR]/[WARN] + 修复建议
+ * Why: AI 不需要"记住 52 条盲点", dacli 自己在执行时检查.
+ * 每个 guard 包含 id/trigger/check/fix 字段, 失败时输出 [ERROR]/[WARN] + 修复建议.
*
* 数据源 (按重要性):
* - .claude/CLAUDE.md "dacli 常见问题恢复" 段 (BS-8/47/48/49/50/51)
diff --git a/src/commands/_precheck.ts b/src/commands/_precheck.ts
index 60642f6..591e62a 100644
--- a/src/commands/_precheck.ts
+++ b/src/commands/_precheck.ts
@@ -1,18 +1,8 @@
/**
- * ⚠️ v0.10 LEGACY FILE — 保留以兼容 form/dm/menu create 的 pre-check
+ * commands/_precheck.ts — form/dm/menu create 执行前的依赖检查
*
- * v0.11+ 推荐用 buildFormData 路径 (web 端原版) — 见 ./form/_buildformdata.ts
- * pre-check 仍有价值: dbLinkId 检查 / enCode 重复 / 必填项验证
- * 但 form schema 完整性检查 (BS-51/52/54) 不再需要, buildFormData 自动保证
- *
- * 删除时机: 仅当 form create 完全迁移到 buildFormData 路径
- *
- */
-/**
- * commands/_precheck.ts — form/dm create 执行前的依赖检查
- *
- * 解决 D 类根因 (详见 doc/ai-error-analysis.md §D): 隐式依赖链只在文档里, 没有工具强制
- * 设计: 执行前自动验证依赖, 失败时明确报错 + 提示下一步, 不进入 API 调用
+ * v0.11+: form schema 完整性检查 (BS-51/52/54) 由 buildFormData 自动保证, 但 dbLinkId / enCode 重复
+ * / 必填项验证仍有价值. 调用方: form/dm/menu create.
*
* 与 P0.1 (AppContext) 衔接:
* - 直接 import { loadAppContext } 复用 context.ts 的采集逻辑
diff --git a/src/commands/form/_blindspots.ts b/src/commands/form/_blindspots.ts
index 718b908..4dcb2db 100644
--- a/src/commands/form/_blindspots.ts
+++ b/src/commands/form/_blindspots.ts
@@ -1,18 +1,9 @@
-/**
- * ⚠️ v0.10 LEGACY FILE — 保留以兼容手动 --fields 路径
- *
- * v0.11+ 推荐用 buildFormData 路径 (web 端原版) — 见 ./_buildformdata.ts
- * - AI 建表 (--ai): 走 _ai.ts + buildFormData (Task 7 已切换)
- * - AI JSON 直入 (--ai-json, Task 10 新增): 走 buildFormData
- * - 手动 --fields 路径: 仍依赖本文件 (用户已习惯简化格式)
- *
- * 删除时机: 手动 --fields 路径弃用后 (用户都走 AI/JSON)
- *
- */
/**
* commands/form/_blindspots.ts — 6 类盲点规则 (设计期 lint + 运行时 validate 共享)
*
- * 单一事实源: BS-23 / BS-31 / BS-32 / BS-15 / BS-V2 / BS-52
+ * v0.11+: 仍为单一事实源 (BS-23 / BS-31 / BS-32 / BS-15 / BS-V2 / BS-52).
+ * webapi 镜像消除了 BS-51/52/54 (字段 schema 自动完整), 但设计期 lint 仍依赖本文件.
+ * 调用方: form/lint.ts (设计期), form/validate.ts (运行时).
* 调用方: validate.ts (运行时, 需 form id)
* lint.ts (设计期, 不需 JNPF server)
*
diff --git a/src/commands/form/_browser_construct.ts b/src/commands/form/_browser_construct.ts
deleted file mode 100644
index 79fe0eb..0000000
--- a/src/commands/form/_browser_construct.ts
+++ /dev/null
@@ -1,384 +0,0 @@
-/**
- * _browser_construct — 智能构造表单 sample data
- *
- * 升级自 v0.7 sampleValueForJnpfKey() (v12 decimal 修复盲点 32)
- * 新增: dict 字典 / relationForm 数据接口 / 系统选择器
- *
- * Spec: docs/superpowers/specs/2026-06-16-dacli-form-browser-verify-design.md §4.2
- */
-import { JnpfClient } from '../../core/client.ts'
-
-/** 必填字段无 sample → buildSamples 抛出 */
-export class MissingSampleError extends Error {
- constructor(public fieldKey: string, public reason: string) {
- super(`必填字段 ${fieldKey} 无 sample: ${reason}`)
- this.name = 'MissingSampleError'
- }
-}
-
-export interface FieldSample {
- fieldKey: string
- label: string
- value: unknown
- skip?: boolean
- reason?: string
- /**
- * 可选 ID/value 列表 (Phase 2 修复, fill-form 走 popup click 用)
- * 适用 jnpfKey: select / radio / checkbox / dict / cascader / treeSelect /
- * userSelect / depSelect / organizeSelect
- * 字段结构: [{ id, value }] — id 是实际入库值, value 是显示文本
- */
- options?: Array<{ id: string; value: string }>
-}
-
-/**
- * 字段配置 (从 formSchema.fields 抽出, 简化版)
- * 与 workSystem 真实字段对齐, 缺字段走 undefined → sampleValueForJnpfKey 兜底
- */
-export interface FieldConfig {
- /** JNPF 组件类型, e.g. 'input' / 'select' / 'cascader' */
- jnpfKey: string
- /** 中文标签 (用于错误提示) */
- label: string
- required: boolean
- /** 字段名, e.g. 'f_name' (用于 decimal 关键词匹配) */
- fieldKey: string
- /** select/radio/checkbox 的静态 enum 选项 */
- options?: unknown[]
- /** select 关联的字典类型编码, e.g. 'user_status' */
- dictionaryType?: string
- /** cascader/treeSelect 关联的数据接口 ID */
- propsUrl?: string
- /** 表单默认值 (Phase 1 仅引用) */
- defaultValue?: unknown
- /** 子表递归标记 (Phase 2.5 单独处理) */
- isSubTable?: boolean
- subFields?: FieldConfig[]
-}
-
-export interface BuildSamplesOptions {
- /** JNPF 客户端, 不传则自动 fromToken() */
- client?: JnpfClient
- /** 跳过网络拉取 (测试用, 只用 options 静态字段) */
- skipNetwork?: boolean
-}
-
-export interface FormSchemaLike {
- fields: FieldConfig[]
-}
-
-/**
- * 静态字段 sample 值
- * v12 修复: 含 amount/money/price/total/sum/cost 关键词的 inputNumber 走 decimal
- */
-export function sampleValueForJnpfKey(
- fieldKey: string,
- jnpfKey: string
-): unknown {
- const ts = Date.now().toString(36)
- // decimal 金额字段 (v12 盲点 32 修复)
- if (jnpfKey === 'inputNumber') {
- if (/amount|money|price|total|sum|cost|fee/i.test(fieldKey)) {
- return 99.99
- }
- return 18
- }
- // 日期类
- if (
- jnpfKey === 'datePicker' ||
- jnpfKey === 'timePicker' ||
- jnpfKey === 'timeRange' ||
- jnpfKey === 'dateRange'
- ) {
- const d = new Date()
- return d.toISOString().slice(0, 10) // YYYY-MM-DD
- }
- // 富文本
- if (jnpfKey === 'editor') {
- return `
test-${ts}
`
- }
- // 开关/评分/滑块/颜色
- if (jnpfKey === 'switch') return true
- if (jnpfKey === 'rate') return 5
- if (jnpfKey === 'slider') return 50
- if (jnpfKey === 'colorPicker') return '#1890ff'
- // 文本 (input / textarea 及其它 fallback)
- return `test-${ts}`
-}
-
-/**
- * 跳过判断: 13 种 jnpfKey 直接 skip
- * Phase 2.5: 子表 'table' 单独处理, 现在 skip
- */
-const SKIP_KEYS = new Set([
- 'billRule',
- 'createUser', 'createTime', 'modifyUser', 'modifyTime',
- 'calculate',
- 'uploadFile',
- 'qrcode',
- 'groupTitle', 'divider', 'row', 'carousel',
- 'popupSelect', 'popupTableSelect', 'popupAttr', 'autoComplete',
- 'tableGrid',
- 'table', // 子表递归 (Phase 2.5 单独处理)
-])
-
-function shouldSkip(jnpfKey: string): boolean {
- return SKIP_KEYS.has(jnpfKey)
-}
-
-/**
- * 主入口: 从 form fields 构造 sample data
- * 必填字段无 sample → 抛 MissingSampleError
- *
- * 网络拉取失败 → 字段标记 skip=true, reason 提示
- * 非必填字段无 sample → 返 null + reason, 不抛错
- */
-export async function buildSamples(
- formSchema: FormSchemaLike,
- opts: BuildSamplesOptions = {}
-): Promise {
- // client 不传 → 自动 fromToken() 走真实 JNPF
- // 显式传 skipNetwork 优先
- const client = opts.client ?? (opts.skipNetwork ? undefined : await JnpfClient.fromToken())
- const skipNetwork = opts.skipNetwork ?? !client
-
- const samples: FieldSample[] = []
- for (const f of formSchema.fields) {
- if (shouldSkip(f.jnpfKey)) {
- samples.push({
- fieldKey: f.fieldKey,
- label: f.label,
- value: null,
- skip: true,
- reason: f.jnpfKey,
- })
- continue
- }
-
- let value: unknown
- let reason: string | undefined
- let skip = false
-
- // select/radio/checkbox 静态 enum + dict
- if (f.jnpfKey === 'select' || f.jnpfKey === 'radio' || f.jnpfKey === 'checkbox') {
- let opts: Array<{ id: string; value: string }> = []
- if (f.options && f.options.length > 0) {
- opts = (f.options as Array<{ value?: unknown; id?: unknown; fullName?: unknown; label?: unknown }>).map((o) => ({
- id: String(o.id ?? o.value ?? ''),
- value: String(o.fullName ?? o.label ?? o.value ?? ''),
- }))
- const first = f.options[0] as { value?: unknown; id?: unknown }
- const firstVal = first.value ?? first.id
- value = f.jnpfKey === 'checkbox' ? [firstVal] : firstVal
- } else if (f.dictionaryType && !skipNetwork && client) {
- const dict = await fetchDictionaryData(client, f.dictionaryType)
- opts = dict
- if (dict.length > 0) {
- value = f.jnpfKey === 'checkbox' ? [dict[0].id] : dict[0].id
- } else if (f.required) {
- throw new MissingSampleError(f.fieldKey, '字典为空')
- } else {
- value = null
- reason = '字典为空'
- skip = true
- }
- } else if (f.required) {
- throw new MissingSampleError(f.fieldKey, 'select 缺 options/dictionaryType')
- } else {
- value = null
- reason = 'select 无 options'
- skip = true
- }
- samples.push({ fieldKey: f.fieldKey, label: f.label, value, skip, reason, options: opts })
- continue
- }
-
- // cascader / treeSelect (propsUrl 数据接口)
- if (f.jnpfKey === 'cascader' || f.jnpfKey === 'treeSelect') {
- let data: Array<{ id: string; value: string }> = []
- if (f.propsUrl && !skipNetwork && client) {
- data = await fetchDataInterface(client, f.propsUrl)
- if (data.length > 0) {
- value = f.jnpfKey === 'cascader' ? [data[0].id] : data[0].id
- } else if (f.required) {
- throw new MissingSampleError(f.fieldKey, '数据接口为空')
- } else {
- value = null
- reason = '数据接口为空'
- skip = true
- }
- } else if (f.required) {
- throw new MissingSampleError(f.fieldKey, 'cascader/treeSelect 缺 propsUrl')
- } else {
- value = null
- reason = '无 propsUrl'
- skip = true
- }
- samples.push({ fieldKey: f.fieldKey, label: f.label, value, skip, reason, options: data })
- continue
- }
-
- // 系统选择器 (userSelect / depSelect / organizeSelect)
- if (f.jnpfKey === 'userSelect' || f.jnpfKey === 'depSelect' || f.jnpfKey === 'organizeSelect') {
- let fetchedList: Array<{ id: string; value: string }> = []
- if (skipNetwork || !client) {
- value = null
- reason = '跳过网络拉取'
- skip = true
- } else {
- fetchedList =
- f.jnpfKey === 'userSelect'
- ? await fetchUserList(client)
- : await fetchOrgList(client)
- if (fetchedList.length > 0) {
- value = fetchedList[0].id
- } else if (f.required) {
- throw new MissingSampleError(f.fieldKey, `${f.jnpfKey} 无默认数据`)
- } else {
- value = null
- reason = `${f.jnpfKey} 无默认数据`
- skip = true
- }
- }
- samples.push({ fieldKey: f.fieldKey, label: f.label, value, skip, reason, options: fetchedList })
- continue
- }
-
- // 静态字段 fallback
- value = sampleValueForJnpfKey(f.fieldKey, f.jnpfKey)
- if (value === undefined && f.required) {
- throw new MissingSampleError(f.fieldKey, `${f.jnpfKey} 无 sample`)
- }
- samples.push({ fieldKey: f.fieldKey, label: f.label, value, skip: false })
- }
- return samples
-}
-
-// ----- JNPF API 拉取辅助 -----
-
-/**
- * 字典数据拉取: GET /api/system/DictionaryData/{type}
- * 响应: { code, data: [{ id, enCode, fullName, ... }] } 或裸数组
- */
-async function fetchDictionaryData(
- client: JnpfClient,
- type: string
-): Promise> {
- try {
- const r = await client.get(`/system/DictionaryData/${type}`)
- const list = Array.isArray(r.data)
- ? r.data
- : (r.data && typeof r.data === 'object' && 'list' in r.data
- ? (r.data as { list?: unknown[] }).list
- : null) || []
- return (list as Array>).map((d) => ({
- id: String(d.id ?? d.enCode ?? ''),
- value: String(d.fullName ?? d.value ?? ''),
- }))
- } catch {
- return []
- }
-}
-
-/**
- * 数据接口拉取: GET /api/visualdev/DataInterface/{id}
- * 响应: { code, data: [...] } 或裸数组
- */
-async function fetchDataInterface(
- client: JnpfClient,
- id: string
-): Promise> {
- try {
- const r = await client.get(`/visualdev/DataInterface/${id}`)
- const list = Array.isArray(r.data)
- ? r.data
- : (r.data && typeof r.data === 'object' && 'list' in r.data
- ? (r.data as { list?: unknown[] }).list
- : null) || []
- return (list as Array>).map((d) => {
- const firstKey = Object.keys(d)[0]
- return {
- id: String(d.id ?? d.value ?? ''),
- value: String(d.fullName ?? (firstKey ? d[firstKey] : '') ?? ''),
- }
- })
- } catch {
- return []
- }
-}
-
-/**
- * 默认用户: GET /api/permission/Users/Selector
- */
-async function fetchDefaultUser(client: JnpfClient): Promise {
- try {
- const r = await client.get('/permission/Users/Selector')
- const list = unwrapList(r.data)
- const first = list[0] as Record | undefined
- return first ? String(first.id ?? '') : null
- } catch {
- return null
- }
-}
-
-/**
- * 默认组织: GET /api/permission/Organize/Selector
- */
-async function fetchDefaultOrg(client: JnpfClient): Promise {
- try {
- const r = await client.get('/permission/Organize/Selector')
- const list = unwrapList(r.data)
- const first = list[0] as Record | undefined
- return first ? String(first.id ?? '') : null
- } catch {
- return null
- }
-}
-
-/**
- * 用户列表 (Phase 2 修复, fill-form 走 popup click 用)
- * 返回 [{id, value}] — value 优先 fullName/realName, 兜底 account
- */
-async function fetchUserList(
- client: JnpfClient,
-): Promise> {
- try {
- const r = await client.get('/permission/Users/Selector')
- const list = unwrapList(r.data)
- return (list as Array>).map((u) => ({
- id: String(u.id ?? ''),
- value: String(u.fullName ?? u.realName ?? u.account ?? u.name ?? ''),
- }))
- } catch {
- return []
- }
-}
-
-/**
- * 组织/部门列表 (Phase 2 修复, fill-form 走 popup click 用)
- * 返回 [{id, value}] — value 优先 fullName, 兜底 name/enCode
- */
-async function fetchOrgList(
- client: JnpfClient,
-): Promise> {
- try {
- const r = await client.get('/permission/Organize/Selector')
- const list = unwrapList(r.data)
- return (list as Array>).map((o) => ({
- id: String(o.id ?? ''),
- value: String(o.fullName ?? o.name ?? o.enCode ?? ''),
- }))
- } catch {
- return []
- }
-}
-
-function unwrapList(data: unknown): unknown[] {
- if (Array.isArray(data)) return data
- if (data && typeof data === 'object') {
- const obj = data as Record
- if (Array.isArray(obj.list)) return obj.list
- if (Array.isArray(obj.data)) return obj.data
- }
- return []
-}
diff --git a/src/commands/form/_simplify.ts b/src/commands/form/_simplify.ts
index f5d5a6d..80551e2 100644
--- a/src/commands/form/_simplify.ts
+++ b/src/commands/form/_simplify.ts
@@ -1,18 +1,8 @@
-/**
- * ⚠️ v0.10 LEGACY FILE — 保留以兼容手动 --fields 路径
- *
- * v0.11+ 推荐用 buildFormData 路径 (web 端原版) — 见 ./_buildformdata.ts
- * - AI 建表 (--ai): 走 _ai.ts + buildFormData (Task 7 已切换)
- * - AI JSON 直入 (--ai-json, Task 10 新增): 走 buildFormData
- * - 手动 --fields 路径: 仍依赖本文件 (用户已习惯简化格式)
- *
- * 删除时机: 手动 --fields 路径弃用后 (用户都走 AI/JSON)
- *
- */
/**
* commands/form/_simplify.ts — 简化字段格式自动包 __config__ (D-3 盲点 42 + D-13 修复)
*
- * 用户友好的简化格式:
+ * v0.11+: --ai / --ai-json 路径走 _buildformdata.ts (webapi 镜像), 仍为 manual --fields 路径的核心.
+ * 调用方: form/create.ts (--fields 用户友好简化格式).
* [
* {"vmodel":"f_name","label":"名称","jnpfKey":"input","required":true,
* "dataType":"varchar","dataLength":"100"},
diff --git a/src/commands/form/fixcolumndata.ts b/src/commands/form/fixcolumndata.ts
index 85bc7e8..7294e9c 100644
--- a/src/commands/form/fixcolumndata.ts
+++ b/src/commands/form/fixcolumndata.ts
@@ -1,18 +1,8 @@
-/**
- * ⚠️ v0.10 LEGACY FILE — 保留以兼容手动 --fields 路径
- *
- * v0.11+ 推荐用 buildFormData 路径 (web 端原版) — 见 ./_buildformdata.ts
- * - AI 建表 (--ai): 走 _ai.ts + buildFormData (Task 7 已切换)
- * - AI JSON 直入 (--ai-json, Task 10 新增): 走 buildFormData
- * - 手动 --fields 路径: 仍依赖本文件 (用户已习惯简化格式)
- *
- * 删除时机: 手动 --fields 路径弃用后 (用户都走 AI/JSON)
- *
- */
/**
* commands/form/fixcolumndata.ts — 修复 form columnData 缺 4 个 use*Permission 字段
*
- * v0.7.1 闭环 (盲点 23): 早于 v0.7.1 的 form 用 `dacli form create` 创建时 columnData
+ * v0.11+: webapi 镜像化 (loadVisualDev), 修复 BS-23 (NPE from missing use*Permission).
+ * 仍为 dacli 命令, 用于老 form 修复.
* 缺 `useBtnPermission/useColumnPermission/useFormPermission/useDataPermission` 字段,
* Jackson 反序列化为 null → Actions/Module 报 "System abnormality" (NPE 在
* VisualUtil.setPcPermission line 139, .booleanValue() 解开 null)
diff --git a/src/commands/form/validate.ts b/src/commands/form/validate.ts
index abfe212..e334803 100644
--- a/src/commands/form/validate.ts
+++ b/src/commands/form/validate.ts
@@ -1,18 +1,8 @@
-/**
- * ⚠️ v0.10 LEGACY FILE — 保留以兼容手动 --fields 路径
- *
- * v0.11+ 推荐用 buildFormData 路径 (web 端原版) — 见 ./_buildformdata.ts
- * - AI 建表 (--ai): 走 _ai.ts + buildFormData (Task 7 已切换)
- * - AI JSON 直入 (--ai-json, Task 10 新增): 走 buildFormData
- * - 手动 --fields 路径: 仍依赖本文件 (用户已习惯简化格式)
- *
- * 删除时机: 手动 --fields 路径弃用后 (用户都走 AI/JSON)
- *
- */
/**
* commands/form/validate.ts — 校验表单结构 (columnData __config__ 完整性)
*
- * 镜像 Java 版 `dacli form validate ` 能力
+ * v0.11+: webapi 镜像化 (loadVisualDev), 调用 form/_blindspots.ts 6 类检查.
+ * 仍为 dacli 命令, 用于发布前快速排查.
* 共享 _blindspots.ts 的 6 类检查 (BS-23/31/32/15/V2/52)
* - formData.fields 每项有 __config__ (新 form: {fields:[]}; 老 form 流程表单: 直接是 array)
* - columnData.fields 每项有 __config__ (新版 JNPF 缺会白屏)