Commit Graph
638 Commits
Author SHA1 Message Date
ssw 7a69fe2f33 auto(bfc0cfa2c3a4): session end @ 2026-07-20T13:01:24 (+1f) 2026-07-20 13:01:25 +08:00
sswandClaude 3d45ac8f3b fix(dacli): default log._quiet=false — only form create opts in
Other commands (app/dict/menu/dm/etc) were silently broken because
log._quiet defaulted to true, swallowing all output. Now defaults
to false; only form/create.ts calls log.setQuiet(true).

Co-Authored-By: Claude <[email protected]>
2026-07-20 11:55:27 +08:00
sswandClaude 7b0ef40f38 fix(dacli): remove process.on('exit') flush — error output now clean
Error path: only log.error() messages shown (stderr, always visible).
Buffer discarded on process.exit(), no noise from process logs.
--verbose still shows full 26-line output for debugging.

Verified 3 scenarios:
  Default success:   2 lines (v2 summary)
  --verbose success: 26 lines (full process logs)
  Default error:     6 lines (only errors, no buffer dump)

Co-Authored-By: Claude <[email protected]>
2026-07-20 11:01:39 +08:00
sswandClaude 4e5e271019 feat(dacli): default quiet output + --verbose for full logs
- log.ts: add setQuiet/flush/discard buffer mode
- form/create.ts: default quiet (2-line summary), --verbose for full output
- Error messages always go to stderr regardless of mode
- process.on('exit') fallback: flush buffer on crash to preserve context

Output comparison:
  Default:  ✓ quiettest  (id=...)  修正 1 处  [5.3s]
             详情: dacli log last
  --verbose: 26 lines (v1 behavior preserved)

Co-Authored-By: Claude <[email protected]>
2026-07-20 10:56:32 +08:00
sswandClaude 741a175766 feat(dacli): v2.0 auto-fix pipeline + structured logging
Core changes:
- _auto_fix.ts: 3-tier fix pipeline (Silent/Assertive/Suggest)
  - Silent: jnpfKey whitelist, child table component restrictions, _fk suffix removal
  - Assertive: datetime→datePicker, timePicker→datePicker, int+dict→select, FK→relationForm
  - Suggest: FK找不到匹配表单, int+select缺dictType
- logfile.ts: structured JSON logs under ~/.dacli/logs/{appCode}/
- log/last.ts: dacli log last command for querying
- form/create.ts: integrated auto_fix pipeline + AI token pre-check auto-re-login

Verified:
- NCPF AI token expired → auto re-login before AI call
- f_signup_time (timePicker) → auto-fixed to datePicker ✅
- f_user_id (inputNumber) → suggestion (no matching 'user' form in testspace)
- Output ends with v2 one-line summary + 'dacli log last' hint

Co-Authored-By: Claude <[email protected]>
2026-07-20 10:35:12 +08:00
sswandClaude 61405e128d fix(dacli): resolve merge conflicts + add v2 architecture spec
- resolve 10 merge conflicts across 4 files (app/init, dict/typecreate, form/create, webapi/_defhttp)
- fix syntax errors in typecreate.ts (commented-out if block)
- add ADR-0010: dacli v2 self-correcting CLI architecture design
- add simulation test comparing v1 vs v2 behavior

Co-Authored-By: Claude <[email protected]>
2026-07-20 10:11:41 +08:00
ssw ec10f7ddfc auto(bfc0cfa2c3a4): session end @ 2026-07-20T08:58:21 (+1f) 2026-07-20 08:58:21 +08:00
ssw 5a8cbca732 chore(.claude): archive dacli-ts + jnpf-browser-automation skills, clean CLAUDE.md references 2026-07-17 13:26:49 +08:00
ssw a650cf6b04 test(dacli): final dogfood regression test — all 9 success criteria PASS 2026-07-17 12:51:50 +08:00
sswandClaude 761405a8b7 chore(dacli): clean comment violations batch 5 (5 files)
Files: test/run.ts, form/import.ts, form/audit.ts, dm/_validate.ts, workflow/_validate.ts

Co-Authored-By: Claude <[email protected]>
2026-07-17 12:46:53 +08:00
sswandClaude 5a8bc1d1f5 chore(dacli): clean comment violations batch 4 (5 files)
Files: report/index.ts, form/update.ts, form/_smart_props.ts, di/_lookup.ts, dict/typecreate.ts

Co-Authored-By: Claude <[email protected]>
2026-07-17 12:43:23 +08:00
sswandClaude da43d93af3 chore(dacli): clean comment violations batch 3 (5 files)
Files: app/context.ts, _encode_validator.ts, form/release.ts, di/update.ts, test/browser.ts

Co-Authored-By: Claude <[email protected]>
2026-07-17 12:40:30 +08:00
sswandClaude cbeb429a6d chore(dacli): clean comment violations batch 2 (5 files)
Files: form/_validate.ts, di/create.ts, form/_ai.ts, workflow/create.ts, dict/_validate.ts

Co-Authored-By: Claude <[email protected]>
2026-07-17 12:34:30 +08:00
sswandClaude 42e596aecc chore(dacli): clean comment violations in top 5 files (batch 1)
Files cleaned: form/create.ts, _blindspot_guards.ts, form/codegen.ts,
test/render.ts, menu/create.ts

- Removed BS-*/R\d+/v0.x+/date markers from comments
- Cleaned app name references (jxcj/workSystem/developSystem/tds) in comments
- Updated check_clean_comments.sh to only flag comment lines
- Added scripts/clean_comments.py for automated comment cleaning
- Vitest: 22 tests pass, 0 errors

Co-Authored-By: Claude <[email protected]>
2026-07-17 12:28:52 +08:00
ssw 3f87c226c2 auto(bfc0cfa2c3a4): session end @ 2026-07-17T12:25:27 (+1f) 2026-07-17 12:25:27 +08:00
sswandClaude b37564171b ci(dacli): add check_no_dacli_ts_refs.sh CI gate
Co-Authored-By: Claude <[email protected]>
2026-07-17 12:24:56 +08:00
ssw c22695b5ca auto(bfc0cfa2c3a4): session end @ 2026-07-17T12:23:13 (+2f) 2026-07-17 12:23:13 +08:00
sswandClaude fc2282f259 chore: remove all dacli-ts references, rename to dacli
Co-Authored-By: Claude <[email protected]>
2026-07-17 12:20:48 +08:00
ssw 08787a6f94 feat(dacli): add check_clean_comments.sh script
- Detects violation comments in dacli/src/** (BS-*/R\d+/jxcj/v0.x+ patterns)
- Whitelists _anti_patterns.ts (must retain source references)
- Run: ./scripts/check_clean_comments.sh
- Finds 1709 current violations (to be cleaned in Task 3.5)
2026-07-17 12:05:37 +08:00
ssw 60432caef2 feat(dacli): add gen-anti-patterns-md.sh + first auto-generated anti-patterns markdown
- scripts/extract_anti_patterns.ts: extracts ANTI_PATTERNS from _anti_patterns.ts to stdout
- scripts/gen-anti-patterns-md.sh: bash wrapper with --check mode for CI
- docs/anti-patterns.md: auto-generated from 25 entries across 11 commands
2026-07-17 12:03:07 +08:00
ssw 79447386ad docs(dacli): create decisions/ directory + 9 ADR documents (0001-0009) 2026-07-17 11:59:47 +08:00
sswandClaude ad1c65b975 feat(dacli): migrate 11 commands to installHelpHookWithPatterns
Migrate form/create, form/update, form/info, form/delete, menu/create,
dict/typeCreate, workflow/create, dm/create, di/create, test/run,
app/context from installHelpHook to installHelpHookWithPatterns.

Each command now passes its ANTI_PATTERNS key so --help auto-injects
relevant pitfalls (踩过的坑) content.

Co-Authored-By: Claude <[email protected]>
2026-07-17 11:55:49 +08:00
ssw d659fa2a80 feat(dacli): integrate enrichHelp into installHelpHook via installHelpHookWithPatterns 2026-07-17 11:49:25 +08:00
ssw 394b8ce867 feat(dacli): implement enrichHelp() to merge ANTI_PATTERNS into DacliHelp 2026-07-17 11:46:07 +08:00
ssw 4c114229a8 feat(dacli): populate ANTI_PATTERNS for 11 commands (25 total entries) 2026-07-17 11:43:54 +08:00
ssw a45145e5b9 feat(dacli): populate ANTI_PATTERNS['form create'] with 8 patterns 2026-07-17 11:40:40 +08:00
ssw 5d7efca370 feat(dacli): define AntiPattern interface + ANTI_PATTERNS skeleton 2026-07-17 11:36:19 +08:00
ssw 04c758d15a chore(dacli): remove installAiHelpHook alias + dead code (AI_FLAGS/getMeta/maybeInterceptAiHelp/renderAiHelp) 2026-07-17 08:59:51 +08:00
ssw 4a5cae861a refactor(dacli): migrate remaining 167 installAiHelpHook call sites to installHelpHook 260716 2026-07-16 22:13:15 +08:00
ssw 9e82b1657a refactor(dacli): migrate form/create.ts to installHelpHook (proof for Task 1.5) 2026-07-16 22:05:56 +08:00
ssw 96fbbdf1c0 fix(dacli): restore dual-path installHelpHook + preserve _aiMeta + update docs 2026-07-16 21:39:34 +08:00
ssw 38c6fe6ae2 fix(dacli): preserve _aiMeta for behavioral compat + update module docs 2026-07-16 21:37:39 +08:00
ssw cc64e13d86 test(dacli): strengthen installHelpHook test with outputHelp capture 2026-07-16 21:27:25 +08:00
ssw 3f7498b496 auto(bfc0cfa2c3a4): session end @ 2026-07-16T21:07:10 (+3f) 2026-07-16 21:07:11 +08:00
ssw da8c1db076 feat(dacli): add installHelpHook with backward-compat alias 2026-07-16 20:44:44 +08:00
ssw cfa3135986 feat(dacli): render pitfalls rationale + clarify purpose JSDoc 2026-07-16 17:07:46 +08:00
ssw 319221148b feat(dacli): implement renderDacliHelp with 4 new sections 2026-07-16 16:58:31 +08:00
ssw cb12ca08ca ci(dacli): enable vitest typecheck + narrow tests/scripts glob 2026-07-16 16:51:01 +08:00
ssw c16bd298a7 feat(dacli): extend DacliHelp with 4 fields + add tests/core to vitest include 2026-07-16 16:26:29 +08:00
ssw f95fe29e85 auto(bfc0cfa2c3a4): session end @ 2026-07-16T16:24:47 (+1f) 2026-07-16 16:24:47 +08:00
sswandClaude 27d508ac11 BS-18 BUG 修 + BS-新62 失败兜底 + form/update 物理表同步 log (2026-07-16 实战)
## 改动

### src/commands/form/_relationForm_auto.ts (修 BS-18 BUG)
- v0.22+: modelId 用 matched.id (formId 数字) 而非 targetEnc (enCode 字符串)
- JNPF 后端期望 formId, enCode 是给人看的
- 历史: log 写 'BS-18: 自动注入 1 个 relationForm' 但实际存为 select with empty options

### src/commands/form/_smart_props.ts (加 applyHeuristicRelationForm 失败兜底)
- v0.22+: smartProps AI Login expired → BS-新62 失败兜底
- 强匹配: 字段名含 ctx.forms enCode (case-insensitive) → modelId
- 弱匹配: label 含 ctx.forms fullName
- 0 候选 → 跳过 (user 后续手工补)
- 跟 applyHeuristicRequired 并列, 不依赖 AI

### src/commands/form/create.ts
- v0.22+: form create 成功后追加 dm list 查物理表状态 log
- '✓ 物理表已建: <enCode> (N 列) — form create 走 web 端建表流程'
- 缺物理表时 warn 'autoTable 未触发或 web 端跳过'
- 集成 applyHeuristicRelationForm 到 smartProps 失败兜底分支

### src/commands/form/update.ts
- v0.22+: form update 成功后对比 --fields 新增 vModel vs 物理表实际字段
- 缺物理表列时 warn + 给修复路径 (form import --autoTable / dm drop + form create 重建 / 手工 ALTER)
- 避免 user 不知道 form update 不同步物理表

来源: jxcj M1 阶段 7 重建 2026-07-16 实战教训 + 干净子代理 testspace 验证
详见 .claude/skills/dacli-ts/references/anti-patterns §15 / form-physical-table-sync.md

Co-Authored-By: Claude <[email protected]>
2026-07-16 12:14:42 +08:00
ssw 18bcfda3e8 P1-8: test browser 自动 login (session 失效兜底)
问题: ~/.dacli-snapshots/<app>.json 缓存 localStorage/sessionStorage 含 token,
       token 过期后 SPA 跳 /login → 7 检查跑在登录页 → 误报 (3 FAIL + 4 FALSE PASS).

复现 (testspace): testspace.json (Jul 14) + 跑 form newtestform01 → 4/7 PASS
       inputIds=[form_item_account, form_item_password] 是登录页, 不是 form.

修复: 新增 autoLoginAndRefreshStorage helper + isLoginRedirect 检测:
  - launch browser → goto realUrl → 检测 URL 含 /login → 调 helper:
    - fresh context → goto /login → fill admin/123456 → click 登 录
    - waitForURL 不含 /login (SPA 真实跳转)
    - 抓 storage → 写回 ~/.dacli-snapshots/<app>.json
  - 把新 storage 注入原 context + 重试 navigation
  - form + workflow 两条 path 接入
  - 按钮文案兼容 (登 录 / 登录 / login), Enter 兜底
  -5s click 超时 + 8s URL 等待超时容错

验证 (testspace):
  - form 846788008962163205 (newtestform01): 4/7 → 7/7 (16.88s)
  - form 846788180106543621 (newtestform05): 7/7 (8.72s, snapshot 已刷有效)
  - workflow (flowTodo): 7/7 (10.93s)

设计权衡: 复用现 chromium browser 实例避免再 launch, addInitScript + re-goto
  模式最小化修改, 不影响 TC-A/TC-C 路径 (那些不调 browser.ts). dr memo §13
  cross-project 沉淀待 anti-patterns.md 后续入库.
2026-07-16 06:57:03 +08:00
Claude a767d2bea8 P1-7: form create AI Login expired 自动 fallback web buildFormData 默认空 schema
## bug (jxcj M1 复盘, 2026-07-16)
NCPF 后端 AI (POST /visualdev/ai/form) Login expired 全局阻塞, 报
  code=400 msg=组件属性推理异常: OpenAI 响应无 choices: {"msg":"Login expired, please log in again","code":600}
SSW /ssw/ai/repair 也用同 token 必 fail (5s/10s/20s 浪费).
后果: jxcj M1 11 form 全部受影响, --ai 路径 exit 2, user 必须手动 --enCode + --fullName 重跑建空表单.

## 修复 (3 文件 + 1 单测, +75/-3)
1. _ssw_retry.ts: 加 isLoginExpired() helper (与 isTokenPlanExhausted 同模式)
2. form/_ai.ts:
   - AiFormResponse 加 loginExpired?: boolean 标记
   - callAiForm: NCPF Login expired 跳过 SSW fallback, 返 loginExpired=true
   - callSswAiRepair: SSW Login expired 跳过剩余重试, 同上
3. form/create.ts: --ai 段检测 loginExpired=true → user 传了 --enCode/--fullName 走 web buildFormData 默认空 schema (0 字段, state=1 可用), 未传 exit 2 提示
4. tests/unit/p1-7-ai-login-fallback.test.ts: 12 单测覆盖 isLoginExpired + callAiForm Login expired fallback (mock JnpfClient.postJson)

## 试通命令 (testspace)
- 12 单测 PASS (含 5s 退避)
- testspace 实跑 P17v3 form 创建+发布 PASS (正常 AI 路径不破坏)
- 回归: form-drift 21 + field-builder 18 + blindspot 16 + round12/13/15/17 = 121 tests PASS, 0 regression
- TS 编译: 46 errors baseline = 46 errors after (无新增)

## 关键决策
- 跳过 SSW fallback: SSW 同 token 必 fail, retry 浪费
- fallback 走 web buildFormData 默认空 schema: Login expired 不阻断 form 创建, user 后续用 form update --fields 加字段
- user 未传 --enCode/--fullName → exit 2: AI 不可用无法自动生成 enCode, 比 silent fallback 安全
- 用 (r as any).code 局部 cast: 不修 pre-existing 'let r: AiFormResponse' 类型 bug (留给后续 cleanup PR)
- 不动 BS-新113 5s/10s/20s retry 策略: 仍适用于 429 token plan (临时限流可恢复)
2026-07-16 06:43:32 +08:00
ssw 2106b8dcdd P1-5: form create enCode 转换 warning (BS-新56 强化)
jxcj M1 复盘: 11 form 实战发现 NCPF backend 静默 strip snake_case → camelCase,
旧 warning (BS-新38 '下次别用 - 或 _') 太轻量, 用户/AI 没注意 enCode 已被转换,
导致设计文档 enCode (snake_case) 与 JNPF 实际 enCode (camelCase) 不一致.

修复 (1 文件 create.ts, +18/-1):
1. 增强 autoStripEnCode warning: 3 行含 NCPF camelCase 根因 + 表名同步 + 后续命令参考
2. 保存 originalUserEnCode (BEFORE strip), AI 路径 mismatch 检测:
   user enCode != AI suggested enCode → 提示用户 + 说明最终用 user input

验证 (testspace):
- snake_case enCode: 5 行 warning (3 行 strip + 2 行 mismatch), form 创建成功
- 不传 enCode: 无 warning, AI 建议一次性通过
- vitest 3 套 55 tests PASS, 0 regression

Refs: docs/jxcj/dacli-fix-plan.md §11 + P1-5 完成段
2026-07-16 02:21:22 +08:00
ssw 1e054dff8d P1-3: codegen 默认输出 controller 到 biz 模块 (简化 cp 步骤)
合并 commit 9d06370 (核心 fix) + 本次 polish (3 处遗漏):
- shortToFull mapping: --module-only=controller 跟随默认行为 (默认→biz, --separate-controller→独立)
- hint message: 默认模式显示 P1-3 提示 (entity→entity-module, biz→biz-module 含 controller), --separate-controller 模式保留旧版提示
- AI help hook notes: 加 P1-3 说明条目

镜像: jxcj M1 实测 11 form codegen 后 9 controller 需手动 cp 到 ssw-{app}-biz/controller/, 对齐 ssw-dos 模块结构 (只有 entity + biz, controller 在 biz 里)

回执: docs/jxcj/dacli-fix-plan.md §P1-3 完成
JSON: /tmp/p1-3-complete.json
2026-07-16 02:11:33 +08:00
ssw 9d06370fc6 auto(bfc0cfa2c3a4): session end @ 2026-07-16T02:01:53 (+1f) 2026-07-16 02:01:54 +08:00
ssw 3731657fa0 P1-2: form create BS-新117 4 限制防护 (jnpfKey 推断)
修复 AI Login expired 时 NCPF 后端 AI 兜底 schema jnpfKey 选错问题。
仅改 dacli/src/commands/form/_form_repair.ts 一文件 (双向防御):

1. LABEL_PATTERNS 收紧 (去歧义源头):
   - depSelect 规则: /单位|公司/ 去掉, 保留 /部门|组织|机构|分公司/
     (主办/承办/协办方是 varchar 字符串, 不是部门实体)
   - timePicker 规则: /时间/ 去掉, 保留 /时刻|^at |at$|hour$/i
     (报名/创建/更新时间都含日期, 应走 datePicker)

2. VM_RULES 新增 3 条防御性 Rule:
   - Rule 7 (BS-新117 #1): depSelect + label 无'组织|部门|机构|分公司'
     → input (varchar 主办/承办/协办方)
   - Rule 8 (BS-新117 #2): timePicker + (label 含 报名/创建/.../日期
     或 vmodel 是 *_time 不含 _hour/_min/_sec) → datePicker
     (label-based 兜底, 覆盖 fieldDbType=undefined 场景)
   - Rule 9 (BS-新117 #3): f_*_id (非系统字段) + input → relationForm
     (CLAUDE.md §6 强制, jnpfKey 层面, modelId 由 --relation-form-auto 注入)

验证 (testspace):
- BEFORE 复现: 主办单位→depSelect, 报名时间→timePicker (BUG)
- AFTER 修复 (form v8): 主办单位→input, 报名时间→datePicker (tag=JnpfDatePicker) ✓
- FK rule 9 测试: f_organizer_id/f_competition_id → relationForm, f_user_id → userSelect, f_id → input (SKIP)
- 回归: vitest 6 套 111 tests PASS (form-drift, field-builder, round13/15/17, blindspot_guards)

关键决策:
- 双向防御 (LABEL_PATTERNS 收紧 + VM_RULES 加规则), 不依赖单层
- 仅改 _form_repair.ts, create.ts 调用链不变
- 仅设 jnpfKey 不补 modelId (auto-injection 路径基于 aiModelList)

限制:
- testspace 残留 8 个 testjxcjp12* form (auto-classifier 拒绝 delete)
- Rule 9 FK modelId/propsValue/relationField 需用户手动提供
2026-07-16 01:53:56 +08:00
ssw 1aab1d537e P1-1: codegen 自动写 Lombok annotationProcessorPaths (entity/biz/controller 三模块 pom.xml)
- 抽 lombokVersion='1.18.42' + lombokCompilerPlugin 模板 (含 source/target=1.8 + annotationProcessorPaths)
- entity/biz/controller 三 pom.xml 均加 lombok 依赖 (scope=provided) + maven-compiler-plugin annotationProcessorPaths
- 修 jxcj M1 复盘 BUG: 11 form codegen 后 mvn compile 报 'cannot find symbol log/getter' (Lombok 注解不生效)
- testspace P11 测试 form (id=847250969413551045) 已验证通过 (已清理删除)
2026-07-16 01:35:10 +08:00
ssw 353e7e9104 P0-4: 修 menu create Actions/Module 失败自动 fallback 低级模式 2026-07-16 00:27:07 +08:00
ssw a529c4e0fa P0-5: 修 form create trigger 默认值 (CodePreview 失败兜底) 2026-07-16 00:12:14 +08:00