Commit Graph
787 Commits
Author SHA1 Message Date
sswandClaude 2d499fa19a feat(dacli): form update --ai schema-aware 增量加字段
v0.23+ 扩展 form update (无新命令, 避免 25→26 个命令的记忆负担), 复用既有 PUT
+ merge + dirty check + strict relationForm 校验 流程, 仅注入 LLM 推理环节:

- _ai.ts: 新增 inferAddFields() + FORM_COMPONENT_WHITELIST (23 项镜像 JNPF7
  AiConstants.GEN_MODEL_COMPNENT) + extractJsonArray() (JSON fence 容错)
- update.ts: --ai <desc> 拉现有 schema → LLM 仅生成新字段 (强相关上下文)
                  → 服务端 4 重安全网 (vmodel 命名/重名/jnpfKey 白名单/label 重名)
                  → 注入 opts.fields, 走既有 mergeFormFieldUpdates
- 链 P0-2 (--optimize) + P0-6 (--preview) + P0-7 (Login expired fallback) 复用
- 兜底设计修正 (用户反馈 2026-07-27): 短描述 (<10字符) 拒绝走 LLM
- 友好区分 0-字段错误: "全被剔除" vs "LLM 没生成" 两种语义

实测 (testspace): form p06s09 1→4 字段 (f_source/f_reporter_phone/f_urgency_level
LLM 生成 snake_case+select+必填); 重提相同描述 → LLM 识别重复返 0 → 友好报错。

新增 5 个 vitest 覆盖 JSON fence 容错; quality-gate: tsc 0 · vitest 488 · baseline L1-L5。

Co-Authored-By: Claude <[email protected]>
2026-07-27 16:55:39 +08:00
ssw 168e436a6f auto(14b5ea1b9bd9): session end @ 2026-07-27T16:49:20 (+2f) 2026-07-27 16:49:20 +08:00
sswandClaude 46a874839a feat(dacli): P0-2 描述优化 + P1-5 BPMN lint + P1-6 AI 健康检查 + 兜底设计修正
复用已部署 SSW /api/ssw/ai/openai-proxy (B方案零 boot 改动):

- P0-2: dacli form optimize "<模糊描述>" + form create --ai --optimize 一键链
  (改写成含字段+字典候选项的结构化描述, 跟 P0-6 --preview 组成完整闭环)
- P1-6: app status llmPing 改端到端 test prompt (旧 GET /visualdev/ai/health 恒 skip 形同虚设,
  改后能真验 LLM+token 有效, Login expired 显式标注)
- P1-5: workflow --ai 跑 validateFlowNodeStructure lint 失败不重试 LLM
  (本轮实证两次 LLM 产出几乎一样, 浪费 token, 走兜底补 DI 仍可用)

兜底设计修正 (用户反馈 2026-07-27): LLM 是主路径, 兜底仅在 LLM 不可用时启用
- form/workflow --ai 短输入 (<10字符) 拒绝走 LLM, 走 web buildFormData 默认 schema
  (form: webType=1 + f_basic_name 占位字段绕 JNPF step machine VS401;
   f_id 是系统关键字不能用)
- 严禁: ① 一上来就用 prompt 拼凑 ② lint 失败就重调 LLM

新增/改动:
- src/core/llm.ts (chatViaProxy 共享 LLM 包装)
- src/commands/form/optimize.ts (P0-2 命令 + OPTIMIZE_PROMPT)
- src/core/client.ts (postJsonRaw 供 OpenAI 兼容非 envelope 端点)
- src/commands/app/status.ts (P1-6 端到端 llmPing)
- src/commands/form/{create,index}.ts (--optimize 链 + 短输入守卫)
- src/commands/workflow/create.ts (P1-5 lint + 短输入守卫)
- tests/unit/form_create_json_stdout.test.ts (短输入不再走 LLM, 测试描述加长)
- docs/jnpf7-analysis §15

quality-gate: tsc 0 · vitest 483 · doc:check · baseline L1-L5 全绿

Co-Authored-By: Claude <[email protected]>
2026-07-27 16:35:29 +08:00
ssw 206f1fd86c auto(14b5ea1b9bd9): session end @ 2026-07-27T16:31:03 (+4f) 2026-07-27 16:31:03 +08:00
ssw 379ebe1f00 auto(14b5ea1b9bd9): session end @ 2026-07-27T16:09:18 (+5f) 2026-07-27 16:09:18 +08:00
sswandClaude 3f1cb3a03b feat(dacli): JNPF7 验证闭环 Stage 0 + P0-6 preview + workflow canvas 回归修复
Stage 0 (验证基础设施):
- 5 层验证工具链 (tools/) + JSON Schema + validate-baseline.sh CI gate
- P0-9: components-whitelist.yaml 单一来源 + parseFlowXml 消漂移 (create.ts tag 改消费 component-map.json)
- E-2: docs/components.md 文档化 6 个 pass-through 组件
- P1-16: validate-baseline 接入 quality-gate.sh
- L3 回归测试 (bs117 / bpmn-bs / antipattern-output) + mock LLM 库

P0-6 (user-in-the-loop):
- form create --ai --preview: 提交前渲染字段表格 (CJK 对齐) + TTY 交互确认 (_preview.ts)

workflow canvas 回归修复 (v0.22+ SSW 迁移引入):
- parseFlowXml 命名空间无关 (flowNodes 缺口)
- _autoLayout 无 DI 时合成完整 BPMNDiagram+Shape+Edge + bpmn2 归一化 (canvas 缺口)
- 真实后端 + 浏览器设计器验证画布渲染; 详见 jnpf7-analysis §14

quality-gate 全绿: tsc 0 · vitest 483 · doc:check · baseline L1-L5

Co-Authored-By: Claude <[email protected]>
2026-07-27 12:49:44 +08:00
ssw b015b2c0a3 auto(14b5ea1b9bd9): session end @ 2026-07-27T12:15:29 (+3f) 2026-07-27 12:15:30 +08:00
ssw 7a69cff8d3 auto(14b5ea1b9bd9): session end @ 2026-07-27T11:03:39 (+1f) 2026-07-27 11:03:39 +08:00
ssw f0a3179ace auto(14b5ea1b9bd9): session end @ 2026-07-27T10:43:30 (+2f) 2026-07-27 10:43:30 +08:00
ssw f648d11c94 auto(14b5ea1b9bd9): session end @ 2026-07-27T10:18:52 (+4f) 2026-07-27 10:18:53 +08:00
ssw 079c606acb auto(14b5ea1b9bd9): session end @ 2026-07-27T08:00:37 (+1f) 2026-07-27 08:00:38 +08:00
ssw 43646817ab auto(14b5ea1b9bd9): session end @ 2026-07-26T11:29:35 (+1f) 2026-07-26 11:29:36 +08:00
ssw e2a8369490 v0.22+ (2026-07-25) P1-5 + BS-新43 闭环 + NCPF 全面清理
[pre-existing vitest failures: 5 drift 检测 (BS-drift-F-5), 与本会话改动无关, 不阻塞提交]

形式:
- 9 个修复 (P0-1/2/3, P1-4/6/7/5, P2-8/9)
- 整合 NCPF 时代 band-aid: callNcpfBackendWithRetry / callSswAiRepair / callSswAiWorkflowRepair
- NCPF 引用 53 → 0 (仅 README 1 行历史叫法)
- form/workflow --ai 单一 SSW 路径 (callSswBuildForm + callSswBuildWorkflow)
- 删 dead code -226 行

新增 (10 untracked):
- tests/unit/ai_ssw_build_form.test.ts (4 测试)
- tests/unit/output_filter_stderr.test.ts
- tests/unit/relationform_auto_tdd3.test.ts
- tests/unit/role_assign_p0_1.test.ts
- tests/unit/role_list_null_data.test.ts
- tests/unit/test_browser_appcode_default.test.ts
- tests/unit/user_create_password.test.ts
- src/commands/form/_relationform_completeness.ts
- docs/decisions/0017-tdd2-end-to-end-findings.md
- docs/dacli-hardening-2026-07-25-tdd2.md

修改:
- src/commands/form/_ai.ts (-226 行 dead code, +180 行简化)
- src/commands/form/create.ts (12 处 NCPF 描述清理)
- src/commands/_post_reminders.ts / _ssw_retry.ts (1-2 处 NCPF 清理)
- src/commands/app/status.ts (3 处 NCPF 清理)
- src/commands/form/{_form_repair,_validate,_smart_props}.ts (各 1-2 处清理)
- README.md 5 大铁律 §2 + 架构核心 + 高频命令 + 命名规范 4 处描述更新
- docs/尚数网基本开发规范v3.0.md (1 处 NCPF 清理)
2026-07-26 10:04:16 +08:00
ssw d322fcca32 auto(14b5ea1b9bd9): session end @ 2026-07-25T20:49:24 (+1f) 2026-07-25 20:49:26 +08:00
ssw a5d0411fbd auto(14b5ea1b9bd9): session end @ 2026-07-25T20:33:29 (+10f) 2026-07-25 20:33:30 +08:00
ssw 19879e9adb auto(14b5ea1b9bd9): session end @ 2026-07-25T20:20:01 (+1f) 2026-07-25 20:20:02 +08:00
ssw cab3c35d35 auto(14b5ea1b9bd9): session end @ 2026-07-25T17:33:07 (+5f) 2026-07-25 17:33:08 +08:00
ssw c0e59a3e1d auto(14b5ea1b9bd9): session end @ 2026-07-25T17:18:06 (+2f) 2026-07-25 17:18:08 +08:00
ssw 84d7882118 auto(14b5ea1b9bd9): session end @ 2026-07-25T16:43:08 (+1f) 2026-07-25 16:43:08 +08:00
ssw 6fc262f8c0 auto(14b5ea1b9bd9): session end @ 2026-07-25T16:21:35 (+5f) 2026-07-25 16:21:35 +08:00
ssw 54989b9ef1 auto(14b5ea1b9bd9): session end @ 2026-07-25T11:08:36 (+8f) 2026-07-25 11:08:36 +08:00
ssw 53874e7617 auto(14b5ea1b9bd9): session end @ 2026-07-25T10:34:06 (+1f) 2026-07-25 10:34:07 +08:00
ssw c7f4c255ad fix(test-render): relationForm 配置完整性读 __config__ 而非顶层 (TD8 smoke test 第二轮)
TD8 设备借还管理 smoke test 第二轮 (含 workflow + DI):
- 发现 TC-C relationForm 配置完整性 读 `rf.modelId` 但实际数据在 `rf.__config__.modelId`
- 即使跑了 dacli form relation-form-complete 补全 4 字段, TC-C 仍报 FAIL (永远 undefined)
- 修复 render.ts:525-527 + :535: 读 `cfg = rf.__config__ || rf` 而非直接 `rf`

实测 (本轮):
- borrowrecord TC-C 10/11 → 11/11 (relationForm FAIL → PASS)
- 整套 20/20 (2 form 全过)

质量门:
  [1/4] tsc: 0 错误
  [2/4] vitest: 415 passed
  [3/4] doc:check: 0 drift
  [4/4] smoke: PASS
2026-07-24 22:48:49 +08:00
ssw 0b14466681 fix(dacli): 5 项 tdd8 smoke test 命中修复 — relationForm 4 字段闭环
#1 新增 dacli form relation-form-complete 命令
  - 自动补 relationForm 4 字段 (jnpfKey/modelId/propsValue/relationField)
  - propsValue 从 target 表 f_*_name 字段自动推
  - relationField 默认 = source FK 字段自身
  - --dry-run 模式只推导不写
  - 19 个单测覆盖 (isRelationFormComplete/pickDisplayField/deriveCompletion)

#2 form update --fields 加 --strict 校验 (默认 ON)
  - relationForm 4 字段缺任一 → ctx.fail + 提示用 relation-form-complete 自动补
  - --no-strict 兼容老用法
  - 7 个单测覆盖 (validateRelationFormFields)

#4 --json 模式 log.* 走 stderr
  - log.ts 加 setJsonMode()/isJsonMode()
  - info/ok/warn/dim/raw 在 jsonMode 时走 stderr
  - setupOutputFilter 自动联动
  - 修 menu/info.ts 启用 setupOutputFilter (之前直接 log.* 污染 stdout)
  - 修 4 个测试 mock 补 setJsonMode + isJsonMode

#6 menu info 加 formEnCode 反查
  - 从 propertyJson.moduleId → form list 反查
  - 输出 relatedForms[] 含 formEnCode/formId/fullName
  - 解决 form enCode 与 menu enCode hash 后缀不一致问题

#8 TC-A 报告 PASS 显式标 SKIP/FAIL 区分
  - '通过: 4/5 (4 PASS + 0 FAIL + 1 SKIP)' 而非仅 '4/5'

实测 tdd8 (本轮 smoke test) 43/46 → 应能提升 (TC-C relationForm FAIL 修复)

质量门 (scripts/quality-gate.sh):
  [1/4] tsc --noEmit: 0 错误
  [2/4] vitest run tests/unit: 415 passed (含 26 个新测)
  [3/4] doc:check: 0 drift (272 文件扫过)
  [4/4] backend smoke: dacli form list PASS
2026-07-24 22:29:54 +08:00
ssw cf4af60806 feat(dacli): Tier 1 跟进 4 项 — 容错/dbPing/menuIntegrity --fix/reuse wrapper
回应用户"都去完善" — 落地 4 项 tdd8 smoke test 暴露的痛点:

[1/4] non-JSON 容错 (src/core/client.ts)
  - 修 schedule list / monitor flow 等命令报"unexpected response shape"崩
  - parseJson(): HTTP 2xx + 空 body → 返 envelope-style {code:200, data:null} (JNPF 端点 bug 已知)
  - HTTP 2xx + 非 JSON body → graceful degrade 同上, 不 throw
  - 实战: schedule list 之前 100% 崩, 现在返 200 + 空 data (语义清晰)

[2/4] dbPing 真实实现 (src/commands/app/status.ts)
  - 替换 /system/DataSource/TestConnection (404) → /system/DataModel/{dbLinkId}/Tables
  - 端点真实, dm list 端点, 走通即 DB 连得上
  - 4xx/5xx 都报真错误, 不再 skip
  - 实战: dbPing 75ms 真检查 (之前永远 skip, 防不住 BS-E14)

[3/4] menuIntegrity --fix 跟进 (src/commands/app/status.ts)
  - 新选项: --fix-menu-url 自动重建空 urlAddress 菜单
  - 策略: 拉 form list → enCode 匹配 → PUT /system/Menu/{id} urlAddress=model/{enCode}
  - 非 form 菜单 (enCode 不在 formList) → skip + log "需手填"
  - tdd8 实测: 4 项空 urlAddress 可自动修 (需你确认执行)
  - DacliHelp 同步更新 notes

[4/4] --reuse-if-exists 通用化 (src/commands/_reusable_create.ts)
  - 新增通用 wrapper: reusableCreate({cmdName, enCode, findExisting, runCreate})
  - form/dict/menu create 全部接入 (各 ~20 行)
  - 6 个新单元测试 (复用场景, 异常容错, 空 enCode 等)
  - 4 个命令统一 shape: ctx.success({enCode, id, fullName, state, reused: true, mode: 'reuse-if-exists'})
  - dm/workflow 跳过 (enCode 概念不直接适用, tableName/flowId 走不同路径)

验证:
- typecheck 0 errors
- vitest 39 文件 / 389 tests pass (含 6 个新 reusable_create 测试)
- doc:check 0 drift (扫描 271 文件)
- quality gate 4/4 (tsc + vitest + doc:check + smoke)

意外: dict/typecreate.ts 文件在 case-insensitive fs 上 cp 时被误删, git restore 恢复 — 提醒后续 case-sensitivity 风险
2026-07-24 19:53:27 +08:00
ssw 0377ca73c7 fix(form-create): --reuse-if-exists 检查上移到 --ai 分支之前
tdd8 smoke test 发现的边界 bug (commit 87a246e 引入):
- 原始位置: line 760+, 在 --ai 分支 (line 423+) 之后
- 影响: 用户传 --ai 时, --ai 分支先跑 15s NCPF LLM, 然后才到 reuse 检查
- 结果: 即便 enCode 已存在 (reuse 应该秒级返回), AI 路径下也浪费 15s

修复:
- 把 reuse 检查移到 --aiField (line 421) 之后、--ai (line 455) 之前
- 加 fallback log: "enCode 不存在, 继续 --ai 创建" 让用户知道 reuse 未命中
- 复用 findExistingForm() 纯函数 (unit test 已覆盖)

验证 (tdd8 端到端):
- 不带 --ai: 0.3s 命中 (跟之前一致)
- 带 --ai: 0.3s 命中 (之前 80s+)
- enCode 不存在: 0.3s 继续创建 (之前 15s+)
- typecheck 0 errors, vitest 39/383 tests pass, quality gate 4/4

tdd8 全模块 smoke (Module 1-6) 完成, 见 docs/tdd8/learnings.md
2026-07-24 18:56:50 +08:00
ssw 87a246ed9e feat(dacli): Tier 1 固化 3 项 — hook + idempotent + health check
回应用户"还有哪些要 dacli 固化的" — 落地 Tier 1 全部 3 件:

[1/3] Pre-commit hook 加 doc:check (scripts/quality-gate.sh)
  - 质量门从 [1/3] tsc + [2/3] vitest + [3/3] smoke → [1/4]+[2/4]+[3/4]+[4/4]
  - 新 [3/4] doc:check (npx tsx scripts/check-doc-drift.ts) — 防回归
  - 任何 doc drift 立即阻断 commit (呼应 audit 2026-07-24 §6 治本建议)
  - DACLI_SKIP_GATE=1 紧急绕过 (与现有 tsc/vitest 一致)
  - 注释同步更新 pre-commit (scripts/githooks/pre-commit)

[2/3] form create --reuse-if-exists (src/commands/form/create.ts)
  - 防 BS-新131 AI agent 反复跑场景返工
  - 命中已存在 enCode → 跳过创建, 返回现有 id + state (state=0/1 都支持)
  - 抽 findExistingForm() 纯函数 + 6 个单元测试 (exact match, 不 fuzzy)
  - 新选项: --reuse-if-exists (默认 false, 向后兼容)

[3/3] app status 加 3 项深度健康检查 (src/commands/app/status.ts)
  - dbPing: GET /system/DataSource/{dbLinkId}/Actions/TestConnection (防 BS-E14)
    · 404/405 视为 skip (端点可能未暴露, 不阻断)
    · dbLinkId=0 视为 skip (主库, 不需测试)
  - llmPing: GET /visualdev/ai/health (防 --ai 路径 LLM 挂掉)
    · 404 视为 skip (端点可能未部署 health)
  - menuIntegrity: /oauth/CurrentUser menuList.urlAddress 不空 (防 BS-56 SPA 404)
    · 任意 fail → 退出码 1 (AI agent 应停下修复)
  - 人类可读模式 + --json 模式都展示 deepChecks 数组
  - 实战验证: tdd8 跑出 menuIntegrity 真问题 (4 项 menu urlAddress 空)

验证:
- typecheck 0 errors
- vitest 39 文件 / 393 tests pass (含 6 新 reuse-if-exists 测试)
- doc:check 0 drift
- 实战: dacli app status 跑出 3 项深度检查 + 1 个真 backend finding

测试未跑 (需要 live JNPF):
- form create --reuse-if-exists 端到端 (受 auto-classifier 误判限制)
2026-07-24 18:26:45 +08:00
ssw afc2a88105 fix(form-info): enCode 兜底加 keyword=0 fallback + toLowerCase 模糊匹配
df213fd 加的 enCode 兜底在 tdd8 smoke test 暴露 1 个边界 bug:
- web 端 getVisualDevList({ keyword }) 是 exact-match
- 输入 "tdd8customermanage" (lowercase) 但实际 enCode="tdd8CustomerManage" (PascalCase)
  → keyword 查询 0 条 → resolver 报"未匹配"

修复:
1. keyword 查询 0 条时 fallback 到无 keyword 全量 (pageSize=500, 单 app 表单数 < 500 安全)
2. toLowerCase 模糊匹配 (处理 PascalCase / camelCase 大小写不一致)
3. try/catch 兜底 (web 端偶发 5xx 不阻断 — 走 fallback)

验证 (tdd8 smoke test 2026-07-24):
- dacli form info tdd8customermanage --summary  → 0.2s (命中 fallback, 正确解析)
- dacli form info 850387545819711621 --summary  → 0.1s (literal id 路径, 性能无回归)
- typecheck 0 errors, anti_patterns tests 10/10, doc:check PASS (0 drift)

tdd8 app + 5 关卡验证文档已写 docs/tdd8/learnings.md (workdir 无 git, 不入 dacli repo)
2026-07-24 17:25:26 +08:00
ssw 955a3780a6 fix(docs): 删 2 条历史遗留 docs 路径引用 (audit.ts + storage/list.ts)
跟进 df213fd 归档的剩余 2 条 drift findings:
- form/audit.ts: docs/dos/debug.md + TC_C_SOURCE_IMPORT.md (dos app 不存在)
- storage/list.ts: docs/dacli/2/dacli-conf-usage.md (路径从未存在)

保留 web + api 段, 仅删 stale ref 行。

验证: npm run doc:check → ✅ 0 drift (270 文件 / 215 命令 / 25 反模式)
2026-07-24 16:38:58 +08:00
ssw df213fdfad fix(dacli-docs): 修审计报告 14 项 + 加 CI 校验防再漂 (P0/P1/P2 全清)
审计报告 docs/dacli-doc-audit-report.md 14 项全部采纳:

P0 (3 项事实错误, 直接误导 AI 执行):
- ANTI_PATTERN F_→f_ 前缀 (form update --fields 实际是小写)
- ANTI_PATTERN AP-fc-4 vs AP-fu-1 矛盾 (统一指向 form import --autoTable)
- ANTI_PATTERN form info <enCode> 误导 (改为 <id>, 加 enCode 自动解析 fallback)

P1 (3 项文档漂移):
- CLAUDE.md "含 FK 时必用 --fields" → 实际已废弃, 删除 + form/create.ts Commander 加 DEPRECATED
- doc/get.ts 引用 Java DocCommand.java → 改指 TS _parser.ts
- AP-fd-1 "--cascade 必带" 过度约束 → 改为可选

P2 (2 项衔接断裂):
- Source 路径 web/.../ → web/apps/jnpf-web-apps-main/src/ (73 文件)
- test/run TC-B 前置提示 (需 menu 挂载)

附加 (CI script 抓出的 8 条额外路径 drift, 已就近修正):
- di/create|export|copy: DataInterfaceController.java 路径补 jnpf-java-boot/ + jnpf/base/controller/
- print/delete|update: PrintDevController.java 同上
- org/create: OrganizeController.java 路径 jnpf/controller/ → jnpf/permission/controller/
- form/codegen|audit: FormGenerator/FormGenerator.vue 加 /components/ + /src/ 前缀
- workflow/create: flowEngine + FlowProcess 加 views/onlineDev/ + components/ 前缀
- workflow/syncForm: FlowableProcessDesigner.vue 不存在 → 改指 Form.vue
- msg/notice*: notice.ts 不存在 → 改指 msgMonitor.ts
- bigscreen/delete|update: 双前缀 web/.../src/jnpf-web-datascreen-vue3/ → jnpf/前端/
- app/login: api/auth.ts → api/core/auth.ts
- apis/refresh|status|info: Java ApiService 路径 → TS 化指向
- test/render: sysData/formDesign 加 views/ 前缀
- form/create: formDesign/Form.vue 加 views/onlineDev/ 前缀

Task 1.6 收尾: 删 core/help.ts legacy (~85 行 dead code):
- AI_FLAGS / getMeta / maybeInterceptAiHelp / renderAiHelp
- installAiHelpHook alias / _aiMeta 副作用 / AiHelp type alias

新增 docs/doc-drift-findings-2026-07-24.md (2 条无法自动修复的 docs 路径, 待人工)

新增 scripts/check-doc-drift.ts (scripts/check-doc-drift.ts, 218 行):
- 4 类检查: 命令引用 / arg-opt 一致性 / source 路径 / ANTI_PATTERNS 命令引用
- 接入 npm run doc:check
- 验证: 修复前 21 处 drift → 修复后 2 处 (已归档)

测试: typecheck 0 errors, 387/387 tests pass, doc:check 报告 2 known issues
2026-07-24 16:33:31 +08:00
ssw 4cc0df3ced auto(14b5ea1b9bd9): session end @ 2026-07-24T15:56:59 (+6f) 2026-07-24 15:57:01 +08:00
sswandClaude 891a600245 test(guards): P2.5 — verify guards effective, reconcile stale test, un-quarantine
Verified (evidence, not guess): the guards ARE effective — command-scoped by design,
wired into form/create, form/release, dm/create, menu/create; BS-47/BS-50 fire
correctly when called with their command (as all production callers + verify_option.test.ts do).
The 12 failures were a STALE test, not broken guards:
- 8 'should-trigger' used pre-command-scoping calls → added command args (BS-47 'dict typeCreate', BS-50 'menu create')
- BS-15b / BS-28 / BS-32b: guards removed from registry long ago → dropped stale assertions
- BS-5: real check is ctx===null (not 'empty existingEnCodes') → fixed test
- BS-51 WARN / BS-44 INFO / BS-60 ERROR: test asserted wrong levels → fixed
- BS-60 repurposed (invalid jnpfKey / placeholder columnOptions, not missing vmodel) → fixed trigger
Impl: fixed objective dup-id bug — renamed 2nd 'BS-14' (type=4 view-release WARN) → 'BS-14b'.
Un-quarantined: removed --exclude from scripts/quality-gate.sh.

Verified: full gate green WITH blindspot_guards (tsc 0 + all unit incl. 41/41 guards + smoke).

Co-Authored-By: Claude <[email protected]>
2026-07-24 13:45:48 +08:00
sswandClaude 2c38b4666d refactor(exit): P6c-2 — migrate 6 mutation commands to wrapCommand
Failures now route through ctx.fail → CommandLog (dacli log last) instead of bare
process.exit(1); success → ctx.success. Follows the form/delete exemplar.
- form/import (3 fails→ctx.fail), form/fix_entity (2 pre-flight guards kept, success→ctx.success),
  form/bindflow (persistence-verify fail→ctx.fail), app/logout, kb/deprecate, kb/entry
- pre-flight/interactive guards (未登录/未找到目录) stay as pre-flight process.exit (user abort, not loggable)

Scope note: app/use was NOT migrated (reverted) — it is a display command (like
app/status/context) whose value is its context output; wrapCommand's quiet-by-default
would suppress that. wrapCommand fits mutations, not display commands.

Verified: tsc 0; gate green (vitest 336); app use display intact; log lines net-zero
(only re-indented); form/delete exemplar already proved the ctx.fail runtime path.

Co-Authored-By: Claude <[email protected]>
2026-07-24 13:03:28 +08:00
sswandClaude 6009044fec refactor(exit): P6c-2 exemplar — migrate form delete to wrapCommand
First of the mutation-command wrapCommand migrations. Delete failure now routes
through ctx.fail → CommandLog (dacli log last) instead of bare process.exit(1).
The --yes interactive confirmation stays a pre-flight guard (user abort, not a
loggable failure). Establishes the transform pattern for the remaining mutation cmds.

Key scoping finding (recorded in PLAN P6c-2): wrapCommand adds printCommandEnd
side-effects meant for MUTATIONS — READ/utility commands (log/*, app/status·context,
kb/show·audit, test/generate, form/preview) should NOT be wrapped (output noise, no
failure worth logging). So P6c-2 targets mutation cmds only, not all 23.

Verified: tsc 0; form delete --help wires up; delete non-existent id → ctx.fail
path prints failure + 'dacli log last' (routes through CommandLog).

Co-Authored-By: Claude <[email protected]>
2026-07-24 12:11:34 +08:00
sswandClaude d4cc3d09db feat(ssw-loop): P7 — generate command reference from commander tree (kill drift)
Per DESIGN §6 / user catch: ssw-loop subagent templates hand-code dacli command
syntax and drift (typ. missing --category). Command tree is now the single source.
- src/program.ts: extract buildProgram() (assembles commander tree, no parse/side-effect)
- src/cli.ts: slimmed to import buildProgram() + parse + top-level error handling
- scripts/gen-command-reference.ts: walk tree → .claude/.../command-reference.generated.md
  (190 commands w/ all options + defaults, incl --category/--column-naming)

Verified: tsc 0; cli entry smoke (form list) intact after refactor; generator emits
190 commands. (.claude side: generated ref + drift-check committed separately.)

Co-Authored-By: Claude <[email protected]>
2026-07-24 11:45:30 +08:00
sswandClaude 7988ead926 chore(pkg): P6 — single package manager (npm) + pg pool allowExitOnIdle
- delete pnpm-lock.yaml + pnpm-workspace.yaml (6-week-stale invalid placeholder);
  package-lock.json is the live one (has @types/pg). set [email protected].
  gitignore pnpm-lock/workspace so they can't creep back (audit M1)
- kb/_client.ts pool: allowExitOnIdle:true — process exits when connections idle,
  fixes kb commands hanging the event loop (audit M3, pool.end never called)

Co-Authored-By: Claude <[email protected]>
2026-07-24 11:22:13 +08:00
sswandClaude 571ac27ab2 refactor(paths): P5 — getCcWorkDir() single source, drop 37 hardcoded /home/ubuntu
Per audit §7 / H1: ~37 src files hardcoded '/home/ubuntu/ccWorkDir', welding the
whole pipeline to one container (external CI / other machines crash).
- new src/core/paths.ts: getCcWorkDir() (env CCWORKDIR || default) + getWebSrc()
- swept 36 files: '/home/ubuntu/ccWorkDir<sub>' literals → `${getCcWorkDir()}<sub>`
  templates; collapsed 3 inline (process.env.CCWORKDIR || '...') dupes to getCcWorkDir()
- covers webapi mirror (_loader WEB_SRC/JNPF_UTILS_UUID + 24 module *_SRC), db/verify
  paths, drift/coverage/selfcheck, buildformdata, codegen, render, blindspot boot paths
- playwright .cache path + doc-comment refs left as-is (not ccWorkDir-rooted)

Verified: tsc 0 (validates every inserted import path); runtime menu webapi
initWebapi OK; smoke form list returns real data (WEB_SRC end-to-end via getCcWorkDir);
vitest unit 336 pass.

Co-Authored-By: Claude <[email protected]>
2026-07-24 10:48:55 +08:00
sswandClaude 2c6e92d3e9 fix(security): P4 — spawn over execSync, token 0600, env-only crypto key
Per audit §8 / H2 / H3 / M4:
- form/create.ts AI-relogin: execSync(`...--password=123456...`) → spawnSync
  array form (no shell → no command injection via cliEntry/appCode); creds from
  config DEFAULT_ACCOUNT/DEFAULT_PASSWORD (env-overridable), no inline literal
- config.ts saveToken: token.json 0600 + dir 0700 + chmod fallback for existing
  0644 files (token holds bearer, was world-readable)
- crypto.ts: drop hardcoded FALLBACK_KEY ('EY8...'); missing key → throw (refuse
  to encrypt with weak key under AES-ECB) instead of silent weak fallback
- @types/pg already installed in P1 (kb SQL client no longer any-typed)

Verified: tsc 0; crypto still loads key from web/.env (96-char hex, no throw →
login intact in container); vitest unit 336 pass (blindspot_guards quarantined).

Co-Authored-By: Claude <[email protected]>
2026-07-24 10:42:51 +08:00
sswandClaude 21eb5520c7 build(quality): P3 — real pre-commit gate (tsc+vitest+smoke); ceremony gate → advisory
Root-cause fix (audit §12.4.1): the only pre-commit gate was _gate_webapi,
which greps comment provenance / webapi ref-rate but NEVER runs tsc or vitest
→ 48 type errors + 20 failing tests could merge under an all-green gate (false green).

- scripts/quality-gate.sh: [1] tsc --noEmit (block) [2] vitest run tests/unit (block)
  [3] backend smoke (advisory local / mandatory CI). No ceremony (no magic-string grep).
  git rev-parse for root (no hardcoded /home/ubuntu).
- scripts/githooks/pre-commit (version-controlled): runs quality-gate (blocking),
  then _gate_webapi as advisory (never blocks).
- scripts/install-hooks.sh: git config core.hooksPath scripts/githooks
- README §232: gate now enforced, tsc rule 靠自觉 → 门强制

blindspot_guards.test.ts quarantined via --exclude (12 fails = registry drift,
PLAN §P2.5) — loudly documented, not silently hidden.

Verified: NEGATIVE test — injected a type error, gate BLOCKED the commit (exit 2);
removed → tsc 0, gate passes. Gate passes its own gate.

Co-Authored-By: Claude <[email protected]>
2026-07-24 09:58:07 +08:00
sswandClaude fc16d93114 test(fixtures): restore tests/fixtures/plan.md (deleted in d982753, tests still ref it)
doc-md-slice.test.ts reads this fixture; cleanup commit removed the file but
left 7 tests referencing it → they fell back to placeholder and failed.
Restored from d982753^. doc-md-slice now 14/14 green. Honest fix (test always
needed this asset), not fake-green.

Co-Authored-By: Claude <[email protected]>
2026-07-24 09:50:39 +08:00
sswandClaude 6210a273c6 fix(tests): P2 — test tsc errors 18→0 (tsc now fully 0/51)
- 4 AppContext fixtures (blindspot_guards/bs54_guard/dbLinkId/verify_option):
  add topLevelMenus:[] + currentSystemId:'' (fields added in BS-109, fixtures drifted)
- CreateOpts: add internal __aiBuildFormData?:{formData} hook (was (opts as any));
  fixes 3 form_create_smartprops_ai.test.ts errors
- e2e/_helpers/nav.ts: /// <reference lib=dom /> for page.evaluate browser context
  (resolves document/HTMLElement + item/e unknown)
- bs66-70 test: type formVm as Set<string>
- auto_fix.test: gX1!.candidates!  ; defhttp test: HeadersInit → Record<string,string>
- output_filter.test: cast stdout spy to declared MockInstance type

Verified: tsc 0 errors; vitest unit 361 pass / 19 fail == pre-existing
(blindspot_guards registry drift + doc-md-slice fixture, audit §12.2) — no regression.

Co-Authored-By: Claude <[email protected]>
2026-07-24 09:47:46 +08:00
sswandClaude e4b9ffa471 fix(types): P1 — src tsc errors 33→0
Root cause (24/33): JnpfResp<T> envelope treated as inner type.
- form/_ai.ts: callNcpfBackendWithRetry returns JnpfResp<AiFormResponse>
  (body already reads .code/.msg/.data); callAiForm r typed as envelope,
  unwrap data explicitly; drop as-unknown-as casts; fix stale workflow log fields
- form/create.ts: infer-category postJson generic was double-wrapped envelope
  → pass inner {id,fullName}; add columnNaming to CreateOpts (option existed)
- form/bindflow.ts: workflow Info get<> passed envelope shape → inner type,
  flowNodes typed string|Record instead of any-ized {data?:any}
Stragglers:
- _precheck.ts: await fromToken() before initWebapi
- verify-runner.ts: import currentBaseUrl (was undefined name, real bug); +warn? on VerifyResult
- codegen.ts: ctx.addFix → addSuggestion (only method on ctx)
- audit.ts: source.blindspot → ref (fits type)
- test/render.ts: componentOk widened to number|boolean (holds false|count)
- log.ts: raw writer param (s:string) → (...a) to match writer map contravariance
- kb/_client.ts: install @types/pg (also P4)

Verified: tsc src=0 (total 51→18, rest in tests/); vitest unit 361 pass /
19 fail (fail set == pre-existing blindspot_guards + doc-md-slice, audit §12.2;
no regression in touched files).

Co-Authored-By: Claude <[email protected]>
2026-07-24 09:36:58 +08:00
sswandClaude d52744d697 docs(decisions): add ADR 0016 app clear p1-2e scope ghost
Co-Authored-By: Claude <[email protected]>
2026-07-24 08:44:55 +08:00
ssw 4042bac60f auto(14b5ea1b9bd9): session end @ 2026-07-23T19:20:56 (+1f) 2026-07-23 19:20:57 +08:00
ssw 2357cb97be auto(14b5ea1b9bd9): session end @ 2026-07-23T18:49:07 (+1f) 2026-07-23 18:49:08 +08:00
sswandClaude cba74702f2 chore(docs): commit 上轮遗留文件 (归档指针 + 2 审计 + jxcj M2 字段修复脚本) (2026-07-23)
补提交上一轮 (commit 64fbb4a cmd-review/drift 归档 + 76c2937 broken ref reroute + b4dce30 auto-gen 撤回) 期间未落库的 4 个文件:

1. docs/cmd-review/README.md (30 行)
   - 上轮归档逻辑产出物, 指向 archive/cmd-review-2026-07/, 给新会话 AI 引路
   - 本应在 commit 64fbb4a (cmd-review 全归档) 一并提交, 但当时遗漏
   - 含归档原因 / 当前权威 (dacli <cmd> --help) / 历史快照定位指引

2. docs/audit-2026-07-22.md (192 → 196 行, 顶部加 deprecate 头)
   - macOS 上做的中立审计, 已知 3 条核心结论 (本机崩溃 / 硬编码路径 / B 关卡退化) 全部是环境错位误判
   - 顶部加 ⚠️ 头, 指向 audit-2026-07-23-deep §更正声明 + §12 容器内实跑复核
   - 仍成立部分: 硬编码 /home/ubuntu/...ccWorkDir (脆弱性), 双包管理器, wrapCommand 迁移不完整

3. docs/audit-2026-07-23-deep.md (292 行, 完整)
   - 深度审计 (架构层), 容器内 'docker exec jnpf-all-in-one' 复跑后更正前一版 3 条误判
   - 实测: tsc --noEmit 48 错 (src 内, 违反 README §232 铁律), vitest unit 20 失败 (集中在 blindspot_guards 漂移)
   - 主结论修订: ssw-loop 在 intended 环境里 '能驱动开发' (int 撤回初版 '仪式化' 措辞)
   - 但真正结构性盲点: 整套质量体系不跑 tsc/vitest → 48 类型错 + 20 失败与全绿关卡并存
   - 修订后 5 件优先事: (1) 补 tsc+vitest 进回路 (2) 修 48 src 类型错 (3) 修 blindspot 漂移 (4) 抽 getCcWorkDir() (5) 统一包管理器

4. docs/web-patches/jxcj-m2-field-fix.py (227 行)
   - jxcj M2 form schema 字段修正脚本 (webapi PUT fallback)
   - 背景: dacli form create --ai 重命名字段 + 丢失 dictType + 误判 userSelect, form update --fields 间歇报 'System abnormality'
   - 走 Python PUT 直接调 JNPF webapi 兜底修复 (跟 DACLI 数据建模路径平行)
   - 配套 web-patches/README.md 当前 Patches 状态表 (只列 .md, py 脚本独立)
   - 注: 该脚本不属于 jnpf/boot 基线改动, 是 dacli 之外的应用级修复脚本, 按 web-patches 规则不入归档

触发: 用户要求 '提交' untracked 3 文件, 顺手补 cmd-review/README.md 上轮遗漏.

Co-Authored-By: Claude <[email protected]>
2026-07-23 15:58:49 +08:00
sswandClaude b4dce306a0 revert: 删除 auto-gen anti-patterns.md 链路 (_anti_patterns.ts 保留给 --help Pitfalls) (2026-07-23)
撤回上一轮尝试 (commit 9e21fea 之前 '加 AP-* entry + 重生成 md' 意向未落 commit 但改了文件) 涉及的反模式 auto-gen 链路.

# 之前考虑
- _anti_patterns.ts 是 13 个命令 --help Pitfalls 段的 compile-time SSOT (installHelpHookWithPatterns → enrichHelp 自动注入)
- docs/anti-patterns.md 通过 gen-anti-patterns-md.sh 从 ts 生成, 用于人类/外部 AI 读

# 撤回原因
- 重生成时 4 个手动加的内容被覆盖丢失: AP-cross-business-info-leak + AP-cross-smartprops-missing-update + BS-新132 修订 + BS-新133 修订
- 根因: AntiPattern schema (1 行 wrong / 1-2 行 right / 1-2 句 rationale) 信息密度太低, 装不下 'mitigation 多步骤 + BS 修订 + jxcj M2 验证实验数据'
- 强行加进去违反 schema 精神, 不加进去就丢内容
- 两难说明: ts→md auto-gen 对反模式这种文档不合适 (schema 跟实际信息密度不匹配)

# 此 commit
1. 删除 docs/anti-patterns.md (304 行, 人类阅读目的)
2. 删除 scripts/gen-anti-patterns-md.sh (49 行, generator)
3. 删除 scripts/extract_anti_patterns.ts (20 行, extractor)
4. _anti_patterns.ts: 文件头注释 '由 TS 自动生成 md' → 'compile-time SSOT, 不再 auto-gen md'
5. ANTI_PATTERNS 撤回到 253 行纯净版 (撤上一轮加的 'form codegen' + 'cross' CommandKey + 3 个 entry)

# 保留
- _anti_patterns.ts 本身保留 (installHelpHookWithPatterns 仍依赖 enrichHelp 注入 AP-* 给 --help 输出)
- 实测: 'dacli form create --help' 仍输出 'Pitfalls (踩过的坑):' 段
- 13 个命令 (form create/info/update/delete, di create, app context, test run, workflow create, menu create, dm create, dict typeCreate) --help 仍自动含 AP-* 反模式

# 后续
- 4 个丢失内容 (AP-cross-business-info-leak + AP-cross-smartprops-missing-update + BS-新132/133 修订) 暂未沉淀, 后续如需可入 docs/{app}/jxcj/learnings.md (应用特定) 或 ssw-loop SKILL.md (通用元规则)
- 反模式新内容优先入 _anti_patterns.ts 走 --help 自动路径 (machine-readable 优势)

Co-Authored-By: Claude <[email protected]>
2026-07-23 15:37:40 +08:00
sswandClaude 76c2937020 fix(src): reroute 45 broken cmd-review/drift refs to archive paths (2026-07-23)
清理 src/ 注释 + DacliHelp ref 字段里指向 cmd-review/ + drift/Rxx 的 broken 引用, 全部改指到 archive/ 子目录 (随上一轮 cmd-review/drift 整体归档):

A. 8 处 DacliHelp 'ref:' 字段 (改 archive 路径, 保留 AI 溯源):
   - src/commands/bigscreen/{list,info,release}.ts → archive/review/v0.14-webapi-rollout-plan.md §2.1
   - src/commands/bigscreen/{construct,_validate}.ts → archive/review/v0.13-webapi-form-workflow-refactor.md §8.2.4
   - src/commands/msg/templatecreate.ts → archive/cmd-review-2026-07/msg.md
   - src/commands/integration/{smstest,webhooktest}.ts → archive/cmd-review-2026-07/integration.md

B. 16 处 anti-patterns.ts 'source: drift/Rxx' (改 archive 路径, 保持源唯一):
   - R5/R9/R12/R17/R12-fix-batch1/R12-fix-batch2 → archive/drift-rounds-2026-07/<对应文件>
   - BS-新38 / column_drift / F3 / BS-DI-1/2/3 子标签保留

C. 21 处注释里 broken 引用清理:
   - 具体路径 (app/{list,info}, datascreen, print/create, regression-2026-06-29) → 改 archive 路径
   - 通用引用 ('cmd-review/app.md 已识别' / 'cmd-review 已知 X') → 改 'v3.0+ 评审已识别/已知'
   - 孤儿引用 (config.ts v0.15-token-home.md 不存在) → 改 archive/review/regression-2026-06-29.md (实际决策文件)
   - 移除 '/cmd-review/xxx' path 引用, 保留描述信息

最终:
- src/ 只剩 3 处 'archive/cmd-review-2026-07/*' 引用 (正确指向 archive)
- tsc --noEmit 未引入新错误 (3 处现有 ts 错都在 tests/unit/, audit-2026-07-23-deep 已记录)
- 下一轮 anti-patterns.md 自动重生成会反映新的 archive 路径

Co-Authored-By: Claude <[email protected]>
2026-07-23 15:16:28 +08:00
ssw 0bb32d5ae2 auto(14b5ea1b9bd9): session end @ 2026-07-23T15:04:41 (+10f) 2026-07-23 15:04:41 +08:00
sswandClaude 64fbb4ac0a docs: archive cmd-review 25 + drift round 20 (2026-07-23)
清理 help 体系干扰/过期信息, 整体归档:

1. cmd-review/ 25 文件 → archive/cmd-review-2026-07/
   - 22 个 2026-06-30 一波生成的命令审计
   - 1 个 bigscreen-components (2026-07-01)
   - 1 个 bigscreen (2026-07-01)
   - 1 个 app (2026-07-01)
   - 含 form/dm/menu M2 实战更新版 (建议已落地, 整体降级归档)
   - cmd-review/ 留 README.md 指针

2. drift/ 20 个 round summary → archive/drift-rounds-2026-07/
   - round 3-4/5/6/7/7b/8/9/10/11/12/13/14/15/16/17 + day summary
   - drift/ 保留 README/USAGE/fetch-baseline.sh 基础设施
   - drift/README.md 加 ⚠️ 头

3. 改引用:
   - dacli/README.md §必读文档 改指 archive
   - 7 个 ADR (0001-0004/0011/0013/0015) 顶部加 ⚠️ 头说明引用路径已迁
   - archive/README.md 加 cmd-review-2026-07/ + drift-rounds-2026-07/ 段, 更新结构图, 更新 AI 误读防御清单

新权威源:
- 命令用法 → 'dacli <cmd> --help' (DacliHelp 注入 pitfalls/bestPractices/decisionTree)
- 决策理由 → docs/decisions/0001-0016 ADR (git-tracked, 权威)
- 反模式 → docs/anti-patterns.md (auto-gen, _anti_patterns.ts 为单一权威)

触发: 用户反馈 'dacli help 体系感觉很多干扰/过期信息, 看看怎么处理'
      + 'cmd-review 22 + drift 13 round 意义不大, 也可归档'

Co-Authored-By: Claude <[email protected]>
2026-07-23 15:04:18 +08:00