dsh-git-push 2.8.4 → 2.9.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.
Files changed (46) hide show
  1. package/README.md +22 -3
  2. package/assets/minihost.sh +35 -0
  3. package/assets/preview.html +36703 -0
  4. package/assets/start.sh +396 -0
  5. package/assets/tree-sitter/LICENSE +21 -0
  6. package/assets/tree-sitter/README.md +69 -0
  7. package/assets/tree-sitter/VERSIONS.txt +1 -0
  8. package/assets/tree-sitter/tree-sitter-javascript.wasm +0 -0
  9. package/assets/tree-sitter/tree-sitter-python.wasm +0 -0
  10. package/assets/tree-sitter/tree-sitter-typescript.wasm +0 -0
  11. package/assets/tree-sitter/tree-sitter.js +3980 -0
  12. package/assets/tree-sitter/tree-sitter.wasm +0 -0
  13. package/lib/app/apply.js +15 -2
  14. package/lib/app/audit-api.js +1 -1
  15. package/lib/app/command-registry.js +6 -2
  16. package/lib/app/handlers/workspace-paths.js +107 -0
  17. package/lib/app/http-handlers.js +19 -2
  18. package/lib/app/inject-text.js +1 -0
  19. package/lib/app/tool-call.js +38 -4
  20. package/lib/app/tools.js +5 -11
  21. package/lib/ast/code-lines.js +52 -0
  22. package/lib/ast/index.js +1 -1
  23. package/lib/ast/tokenizer.js +7 -2
  24. package/lib/ast/treesitter.js +208 -0
  25. package/lib/audit/audit-file.js +3 -3
  26. package/lib/audit/orchestrate.js +38 -0
  27. package/lib/audit-rules/audit-rules-nodejs.yml +2 -2
  28. package/lib/audit-rules/audit-rules-paths.yml +1 -1
  29. package/lib/audit-rules/audit-rules-performance.yml +12 -0
  30. package/lib/checks/dispatch.js +3 -3
  31. package/lib/checks/filter.js +7 -1
  32. package/lib/checks/regex.js +19 -4
  33. package/lib/commit-push.js +8 -4
  34. package/lib/core/workspace-paths.js +100 -0
  35. package/lib/git/push.js +9 -3
  36. package/lib/npm/publish.js +6 -2
  37. package/lib/npm/registry.js +23 -2
  38. package/lib/rule/registry.js +7 -0
  39. package/lib/self/index.js +4 -1
  40. package/lib/user-requirements.json +2 -1
  41. package/package.json +2 -1
  42. package/scripts/cpu-sample.mjs +188 -0
  43. package/scripts/sync-plugin-install.mjs +84 -21
  44. package/scripts/sync-plugin.mjs +14 -9
  45. package/skills/guide/guide-cli-scripts.md +1 -1
  46. package/skills/guide/guide-commit-push.md +33 -0
package/README.md CHANGED
@@ -64,7 +64,7 @@ DSH(DeepSeek Harness)git 提交推送与代码审计插件——提交前自
64
64
 
65
65
  | 文档 | 讲什么 |
66
66
  |---|---|
67
- | [docs/SPEC.md](docs/SPEC.md) | **当前有效规格唯一入口**:身份 / 18 个工具 / 34 条 HTTP 接口 / 20 个设置键 / 4 个数据文件 / 审计规则体系 / 文档产物 / 版本纪律 / 测试基线 |
67
+ | [docs/SPEC.md](docs/SPEC.md) | **当前有效规格唯一入口**:身份 / 18 个工具 / 35 条 HTTP 接口 / 20 个设置键 / 4 个数据文件 / 审计规则体系 / 文档产物 / 版本纪律 / 测试基线 |
68
68
  | [docs/功能-审计规则体系.md](docs/功能-审计规则体系.md) | 22 个规则槽位 / 138 条规则的组织方式、作用域字段、三层结构、运行入口、结果怎么读、怎么豁免 |
69
69
  | [docs/功能-历史提交审计.md](docs/功能-历史提交审计.md) | 逐提交回放审计:解决什么、怎么跑、与普通审计的差异与成本 |
70
70
  | [docs/功能-文档与结构追踪.md](docs/功能-文档与结构追踪.md) | tree-doc / doc-func / doc-version 三份自动生成文档怎么更新、漂移怎么办 |
@@ -272,7 +272,7 @@ dsh-git-push/
272
272
  │ │ ├── slot-stats.js — 规则槽位命中统计(模块级状态)
273
273
  │ │ ├── tool-call.js — 工具调用分发(git_scan/commit_push/audit/status 等全部工具)
274
274
  │ │ ├── tools.js — 工具定义清单(名称/描述/参数 schema)
275
- │ │ └── …(9 个更深文件)
275
+ │ │ └── …(10 个更深文件)
276
276
  │ ├── ast/ — AST 实现层(token 级判定:括号/控制流/数据流/凭据/魔数/命名/规模/分词)
277
277
  │ │ ├── brace.js — 括号配对与区间包含工具
278
278
  │ │ ├── callgraph.js — 调用链追踪(单文件调用图 + isInRequestPath,io-risk 请求路径判定升级)
@@ -297,6 +297,7 @@ dsh-git-push/
297
297
  │ │ ├── size.js — 规模检查(函数长度/文件长度/重复字符串)
298
298
  │ │ ├── symbol-index.js — (待注释)
299
299
  │ │ ├── tokenizer.js — 分词器(token 流 + LRU 缓存)
300
+ │ │ ├── treesitter.js — (待注释)
300
301
  │ ├── audit/ — 审计编排层(文件收集/逐文件检查/槽位聚合/审计出口)
301
302
  │ │ ├── analysis-coverage.js — (待注释)
302
303
  │ │ ├── audit-file.js — 单文件审计执行(跑检查+豁免)
@@ -390,6 +391,7 @@ dsh-git-push/
390
391
  │ │ ├── credentials.js — (待注释)
391
392
  │ │ ├── endpoints.js — (待注释)
392
393
  │ │ ├── exec.js — (待注释)
394
+ │ │ ├── workspace-paths.js — (待注释)
393
395
  │ ├── exempt/ — 豁免机制(dsh-skip-* 注释标记解析与文件头/行内语义)
394
396
  │ │ ├── index.js — 豁免注册表(dsh-skip-* 全标记消费)
395
397
  │ ├── fs/ — (待注释)
@@ -468,6 +470,7 @@ dsh-git-push/
468
470
  │ ├── build-client.mjs — 客户端分片拼接(PART_ORDER + --check 门禁 + 形态铁律自检)
469
471
  │ ├── check.mjs — 语法检查脚本(npm run check)
470
472
  │ ├── clean-date-comments.py — (待注释)
473
+ │ ├── cpu-sample.mjs — (待注释)
471
474
  │ ├── doc-drift.mjs — (待注释)
472
475
  │ ├── doc-func.mjs — (待注释)
473
476
  │ ├── doc-tree.mjs — (待注释)
@@ -504,6 +507,15 @@ dsh-git-push/
504
507
  ├── assets/ — 预览页与配图(preview.html 交互模拟页 + 面板截图)
505
508
  │ ├── minihost.sh — (待注释)
506
509
  │ ├── start.sh — 预览服务器启停脚本(start/stop/restart/status + --port + PID/日志/健康检查 /preview-ping)
510
+ │ ├── tree-sitter/ — (待注释)
511
+ │ │ ├── LICENSE — (待注释)
512
+ │ │ ├── README.md — (待注释)
513
+ │ │ ├── VERSIONS.txt — (待注释)
514
+ │ │ ├── tree-sitter-javascript.wasm — (待注释)
515
+ │ │ ├── tree-sitter-python.wasm — (待注释)
516
+ │ │ ├── tree-sitter-typescript.wasm — (待注释)
517
+ │ │ ├── tree-sitter.js — (待注释)
518
+ │ │ ├── tree-sitter.wasm — (待注释)
507
519
  ├── test/ — node:test 全量单元测试(541+ 条,覆盖审计/推送/账号/HTTP/后台任务)
508
520
  │ ├── .test — 空文件豁免标记(目录级豁免 .test 目录)
509
521
  │ ├── e2e-npm-tab-render.mjs — (待注释)
@@ -512,6 +524,7 @@ dsh-git-push/
512
524
  │ ├── test-account-refresh-on-push.mjs — (待注释)
513
525
  │ ├── test-account-ssh.mjs — 账号检查 + SSH 密钥测试
514
526
  │ ├── test-analysis-coverage.mjs — (待注释)
527
+ │ ├── test-ast-confirm-span.mjs — (待注释)
515
528
  │ ├── test-audit-api-http.mjs — (待注释)
516
529
  │ ├── test-audit-api.mjs — (待注释)
517
530
  │ ├── test-audit-bad-file.mjs — 审计拦截门禁测试(硬编码密码/API key/.env 凭据文件)
@@ -522,6 +535,7 @@ dsh-git-push/
522
535
  │ ├── test-audit-npm-publish-rules.mjs — (待注释)
523
536
  │ ├── test-audit-push-boundary.mjs — (待注释)
524
537
  │ ├── test-audit-scope.mjs — 审计作用域/凭据占位符回归测试
538
+ │ ├── test-audit-slot-order.mjs — (待注释)
525
539
  │ ├── test-audit.mjs — 审计总入口测试(auditFull/changed/豁免/gitignore)
526
540
  │ ├── test-auditignore.mjs — (待注释)
527
541
  │ ├── test-auto-push.mjs — 任务完成自动推送测试(检测纯函数 + registerAutoPush 门控监听注册)
@@ -564,6 +578,7 @@ dsh-git-push/
564
578
  │ ├── test-ext-variable-min-length.mjs — (待注释)
565
579
  │ ├── test-false-positive-fixes.mjs — 误报修复回归测试
566
580
  │ ├── test-file-health.mjs — 文件健康度矩阵评分测试
581
+ │ ├── test-filter-ext.mjs — (待注释)
567
582
  │ ├── test-folder-scope.mjs — 目录级审计作用域回归测试
568
583
  │ ├── test-func-doc-drift.mjs — (待注释)
569
584
  │ ├── test-generated-html-artifact.mjs — (待注释)
@@ -590,6 +605,7 @@ dsh-git-push/
590
605
  │ ├── test-module-splitter-multiline.mjs — (待注释)
591
606
  │ ├── test-module-splitter.mjs — module_splitter 工具 + CLI 接入测试(契约 + 行为 + 脚本随插件发布)
592
607
  │ ├── test-name-length-scope.mjs — (待注释)
608
+ │ ├── test-npm-enobufs.mjs — (待注释)
593
609
  │ ├── test-npm-install.mjs — (待注释)
594
610
  │ ├── test-npm-publish.mjs — (待注释)
595
611
  │ ├── test-npm-registry.mjs — (待注释)
@@ -635,14 +651,17 @@ dsh-git-push/
635
651
  │ ├── test-tool-probes.mjs — (待注释)
636
652
  │ ├── test-tools-e2e.mjs — (待注释)
637
653
  │ ├── test-tree-doc.mjs — README 目录树脚本测试(gen/check/apply 闭环)
654
+ │ ├── test-treesitter.mjs — (待注释)
638
655
  │ ├── test-version-metrics.mjs — (待注释)
639
656
  │ ├── test-visibility-unified.mjs — (待注释)
657
+ │ ├── test-workspace-paths.mjs — (待注释)
640
658
  │ ├── fixtures/ — (待注释)
641
659
  │ │ ├── TimeZoneComboBox-CRnoCikG.js — Pawchive 混淆产物样本(hash 文件名——跳过判定 fixture)
642
660
  │ ├── helpers/ — (待注释)
643
661
  │ │ ├── test-cache.mjs — (待注释)
644
662
  │ │ ├── tmp-dir.mjs — (待注释)
645
663
  ├── docs/ — 开发文档
664
+ │ ├── 2.9.0-design.md — (待注释)
646
665
  │ ├── 2026-10-09-审计插件性能优化.MD — (待注释)
647
666
  │ ├── 2026-10-11-单一真源与文档漂移治理方案.MD — (待注释)
648
667
  │ ├── 2026-10-11-硬编码路径改造为审计引擎方案.MD — (待注释)
@@ -1418,7 +1437,7 @@ node scripts/audit-runtime-check.mjs --all <目录>
1418
1437
  - `scripts/audit-runtime-check.mjs`:三层审计的 L3 运行时检测(见「独立脚本:运行时检测」)
1419
1438
  - `scripts/scrub-user-wording.mjs`:清洗注释里的沟通残留措辞(见「独立脚本:清洗用户沟通措辞」)
1420
1439
  - `scripts/check.mjs`:全仓语法检查(`node --check` 批量)
1421
- - `scripts/sync-plugin.mjs`:源码仓库 → 安装副本的双副本同步(默认 dry-run,`--write` 才写)。2026-10-09 起同时做**部署形态与免重启热重载自检**:`--profile <名>` 指定 profile(多 profile 时必须显式给,否则报所有候选而不是默默取首个)、`--fix` 按目标形态修正安装位置(`local-plugins/` 真实目录 + `node_modules/` **相对**软链);每次都报告「该插件改代码能否免重启热重载」(读 profile 的 `cordis.patch.yml` 里 `id: hmr` 的 `base`/`root`)以及 profile 依赖声明是否该改回 `file:local-plugins/<插件>`
1440
+ - `scripts/sync-plugin.mjs`:源码仓库 → 安装副本的同步(默认 dry-run,`--write` 才写)。**安装位置 = `local-plugins/<插件>`(真源)**;`node_modules/<插件>` 只是解析入口,由 DSH/pnpm 安装流程按 profile 的 `file:local-plugins/<插件>` 声明生成——**本脚本不建链、不改链**(并会报警「node_modules 下的副本内容与真源不一致」这种会顶掉真源的形态,实测过旧副本顶掉新版;与真源同 inode 的硬链接副本属正常安装产物、不报警)。2026-10-09 起同时做**部署形态与免重启热重载自检**:`--profile <名>` 指定 profile(多 profile 时必须显式给,否则报所有候选而不是默默取首个)、`--fix` 只修 `local-plugins` 侧形态(解软链 / 建真实目录);每次都报告「该插件改代码能否免重启热重载」(读 profile 的 `cordis.patch.yml` 里 `id: hmr` 的 `base`/`root`)以及 profile 依赖声明是否该写 `file:local-plugins/<插件>`
1422
1441
  - `scripts/sync-plugin-install.mjs`:上一条里安装形态/HMR 自检的实现模块(被 `sync-plugin.mjs` 引用,非独立入口)
1423
1442
  - **测试**:`npm test` 一条命令复现全绿(2026-10-09 实测 1195 用例 / 1193 通过 / 0 失败,2 跳过)
1424
1443
 
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env bash
2
+ # dsh-plugin mini-host 一键启动 —— 本地跑本插件服务端代码,**改完代码刷新页面即生效**,
3
+ # 既不用重启 DSH 宿主、也不用重启本服务(每个请求 fork 一次性子进程,插件模块天然新鲜)。
4
+ #
5
+ # 依赖通用工具:dsh-plugin-minihost.mjs(+ dsh-plugin-minihost-child.mjs)
6
+ # 位置:技能仓库 ai-work-archive/skills/,或运行时目录 <DSH_HOME>/skills/
7
+ # 用法:
8
+ # bash assets/minihost.sh # 默认端口 31100
9
+ # bash assets/minihost.sh --port 31200 # 换端口(其余参数透传给 mini-host)
10
+ # 环境变量:
11
+ # DSH_SKILLS_DIR 指定含通用工具的 skills 目录(默认 $DSH_HOME/skills 或 ~/.dsh/skills)
12
+ # PORT 默认端口(默认 31100)
13
+ # NODE_BIN 指定 node(默认 PATH 里的 node)
14
+ set -uo pipefail
15
+ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
16
+ SKILLS_DIR="${DSH_SKILLS_DIR:-${DSH_HOME:-$HOME/.dsh}/skills}"
17
+ TOOL="$SKILLS_DIR/dsh-plugin-minihost.mjs"
18
+ if [ ! -f "$TOOL" ]; then
19
+ echo "找不到通用工具:$TOOL"
20
+ echo "请设置 DSH_SKILLS_DIR 指向含 dsh-plugin-minihost.mjs 的 skills 目录"
21
+ exit 2
22
+ fi
23
+ ARGS=(--plugin "$ROOT" --port "${PORT:-31100}")
24
+ # 预览页是**生成产物**(.gitignore 已忽略,不入库):缺失时先自动生成一次,
25
+ # 否则 --preview 分支会**静默跳过**(页面打开是 404/无预览页,且没有任何报错)。
26
+ PREVIEW_HTML="$ROOT/assets/preview.html"
27
+ PREVIEW_GEN="$ROOT/scripts/preview-gen.mjs"
28
+ if [ ! -f "$PREVIEW_HTML" ] && [ -f "$PREVIEW_GEN" ]; then
29
+ echo "[minihost] 预览页缺失,先生成一次:node scripts/preview-gen.mjs"
30
+ "${NODE_BIN:-node}" "$PREVIEW_GEN" >/dev/null 2>&1 \
31
+ || echo "[minihost] 预览页生成失败(继续启动,但不带预览页)"
32
+ fi
33
+ [ -f "$PREVIEW_HTML" ] && ARGS+=(--preview "$PREVIEW_HTML")
34
+ [ -d "$ROOT/lib" ] && ARGS+=(--static "$ROOT/lib")
35
+ exec "${NODE_BIN:-node}" "$TOOL" "${ARGS[@]}" "$@"