dsh-git-push 2.10.5 → 2.12.3
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/.auditignore +2 -4
- package/README.md +78 -1487
- package/lib/app/inject-text.js +0 -1
- package/lib/app/tool-call.js +2 -2
- package/lib/ast/io-risk-loop.js +1 -1
- package/lib/ast/tokenizer.js +76 -1
- package/lib/ast/treesitter.js +78 -14
- package/lib/audit/collector.js +9 -1
- package/lib/audit/finding.js +8 -1
- package/lib/audit/report-yaml.js +5 -1
- package/lib/audit-rules/audit-rules-comment.yml +0 -68
- package/lib/audit-rules/audit-rules-csharp.yml +82 -0
- package/lib/audit-rules/audit-rules-structure.yml +2 -3
- package/lib/git/push.js +1 -1
- package/lib/rule/loader.js +5 -1
- package/lib/self/index.js +1 -1
- package/lib/skip-dirs.js +6 -3
- package/package.json +6 -1
- package/scripts/doc-tree.mjs +4 -2
- package/scripts/doc-version.mjs +4 -4
- package/scripts/{readme-gen.mjs → version-source.mjs} +8 -153
- package/skills/dev/dsh-git-push.md +3 -11
- package/skills/guide/guide-cli-scripts.md +0 -2
- package/assets/tree-sitter/LICENSE +0 -21
- package/assets/tree-sitter/README.md +0 -69
- package/assets/tree-sitter/VERSIONS.txt +0 -1
- package/assets/tree-sitter/tree-sitter-javascript.wasm +0 -0
- package/assets/tree-sitter/tree-sitter-python.wasm +0 -0
- package/assets/tree-sitter/tree-sitter-typescript.wasm +0 -0
- package/assets/tree-sitter/tree-sitter.js +0 -3980
- package/assets/tree-sitter/tree-sitter.wasm +0 -0
- package/lib/readme-templates/readme.yml +0 -38
- package/lib/vendor/js-yaml/LICENSE +0 -21
- package/lib/vendor/js-yaml/js-yaml.mjs +0 -3073
- package/scripts/scrub-user-wording.mjs +0 -420
package/scripts/doc-version.mjs
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* 分体式文档三兄弟之一(doc-tree 文件树 / doc-func 函数列表 / doc-version 版本列表)。
|
|
7
7
|
* 版本表数据源 = `docs/releases.json`(每版一行说明)+ 版本真源文件(package.json 等)
|
|
8
8
|
* + `version-metrics.json`(可选量化记录);**不读 git log**(2026-10-16 改,原因见
|
|
9
|
-
*
|
|
9
|
+
* version-source.mjs 的 buildReadmeVersionTable 注释)。
|
|
10
10
|
* 写入宿主 md(README 有 dshgp-version 标记块用 README,否则 docs/ 带块 md)。
|
|
11
|
-
* 复用
|
|
11
|
+
* 复用 version-source.mjs 的 buildReadmeVersionTable(版本聚合逻辑单一事实源)。
|
|
12
12
|
*
|
|
13
13
|
* 用法:
|
|
14
14
|
* node scripts/doc-version.mjs gen [--root <项目根>] # 打印版本表文本
|
|
@@ -19,7 +19,7 @@ import { readFileSync, writeFileSync, existsSync } from 'node:fs';
|
|
|
19
19
|
import { join, resolve, relative, basename, dirname } from 'node:path';
|
|
20
20
|
import { fileURLToPath } from 'node:url';
|
|
21
21
|
import { findMarkedHostMd } from './doc-tree.mjs';
|
|
22
|
-
import { buildReadmeVersionTable, detectVersionSource, projectVersionOf, readReleases, VERSION_SOURCES } from './
|
|
22
|
+
import { buildReadmeVersionTable, detectVersionSource, projectVersionOf, readReleases, VERSION_SOURCES } from './version-source.mjs';
|
|
23
23
|
|
|
24
24
|
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
25
25
|
const MARKER = 'dshgp-version';
|
|
@@ -27,7 +27,7 @@ const MARK_START = `<!-- ${MARKER}:start -->`;
|
|
|
27
27
|
const MARK_END = `<!-- ${MARKER}:end -->`;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* 版本源探测与读取**在 scripts/version-source.mjs**(版本表生成与版本源同源,避免两处各写一份)。
|
|
31
31
|
* 这里只做再导出,保持旧调用方的 import 路径不变。
|
|
32
32
|
*
|
|
33
33
|
* ⚠️ 2026-10-16 起:版本表**不再读 git log**(`detectVersionSource` 不再回退 'git-log')——
|
|
@@ -1,65 +1,16 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* 版本源探测与版本表聚合(供 doc-version 门禁生成 CHANGELOG/README 版本表使用)。
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* 来历:原先与 README 模板渲染混在 scripts/readme-gen.mjs 里;README 生成能力已作废(README 改由
|
|
5
|
+
* readme-spec 手工维护、不再按模板渲染),故把**仍在关键路径上**的版本源逻辑单独拆出,
|
|
6
|
+
* 模板渲染/TOC/genReadme 一并删除,避免死代码继续挂在门禁脚本的依赖链上。
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* 缺省只打印生成内容(README 模板文本),--write 才落盘。
|
|
11
|
-
*
|
|
12
|
-
* 模板优先级:--template 指定 > <repo>/template/README.md > 本脚本附带的 readme.yml > 内置兜底。
|
|
8
|
+
* 纯读取:只读 package.json 等版本文件、docs/releases.json、version-metrics.json,
|
|
9
|
+
* 不写盘、不改仓库(写入由 doc-version.mjs 负责)。
|
|
13
10
|
*/
|
|
14
|
-
import { existsSync, readFileSync
|
|
15
|
-
import {
|
|
16
|
-
import { fileURLToPath } from 'node:url';
|
|
11
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
12
|
+
import { join } from 'node:path';
|
|
17
13
|
import { spawnSync } from 'node:child_process';
|
|
18
|
-
import { load as yamlLoad } from '../lib/vendor/js-yaml/js-yaml.mjs';
|
|
19
|
-
|
|
20
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
21
|
-
/** 插件根(scripts/readme-gen.mjs → ../../) */
|
|
22
|
-
const PLUGIN_ROOT = join(__dirname, '..');
|
|
23
|
-
/** yml 模板目录(复用插件 lib/readme-templates,脚本相对路径 = ../lib/readme-templates) */
|
|
24
|
-
const README_TEMPLATE_YML_DIR = join(__dirname, '..', 'lib', 'readme-templates');
|
|
25
|
-
|
|
26
|
-
/** 内置兜底模板 */
|
|
27
|
-
const DEFAULT_README_TEMPLATE = `# {{name}}
|
|
28
|
-
|
|
29
|
-
> {{description}}
|
|
30
|
-
|
|
31
|
-
## 目录
|
|
32
|
-
|
|
33
|
-
{{toc}}
|
|
34
|
-
|
|
35
|
-
## 架构设计
|
|
36
|
-
|
|
37
|
-
<!-- INSERT: 项目核心架构说明(分层/组件/模块/关键设计决策) -->
|
|
38
|
-
|
|
39
|
-
## 文件目录结构及作用
|
|
40
|
-
|
|
41
|
-
<!-- INSERT: 关键文件/目录清单 + 每项作用说明 -->
|
|
42
|
-
|
|
43
|
-
## 启动脚本
|
|
44
|
-
|
|
45
|
-
<!-- INSERT: start.sh 用法:start / stop / restart / status,含端口与环境要求 -->
|
|
46
|
-
|
|
47
|
-
## API 总览
|
|
48
|
-
|
|
49
|
-
<!-- INSERT: | 方法 | 路径 | 说明 | -->
|
|
50
|
-
|
|
51
|
-
## 版本列表
|
|
52
|
-
|
|
53
|
-
{{versionTable}}
|
|
54
|
-
|
|
55
|
-
## 注意事项
|
|
56
|
-
|
|
57
|
-
<!-- INSERT: 踩过的坑、边界条件、依赖环境要求、已知限制 -->
|
|
58
|
-
|
|
59
|
-
## 开发计划 / 疑难杂症
|
|
60
|
-
|
|
61
|
-
<!-- INSERT: 待办功能、已知问题、未解决的技术难题 -->
|
|
62
|
-
`;
|
|
63
14
|
|
|
64
15
|
/** runGit 精简单机版(git log 取提交标题,供版本表聚合)。 */
|
|
65
16
|
function runGit(args, { cwd = '' } = {}) {
|
|
@@ -72,61 +23,6 @@ function runGit(args, { cwd = '' } = {}) {
|
|
|
72
23
|
}
|
|
73
24
|
|
|
74
25
|
/** 渲染 yml 模板({ header, sections })→ markdown 模板文本(占位符原样保留)。 */
|
|
75
|
-
export function renderReadmeTemplateYml(data) {
|
|
76
|
-
const rawHeader = data?.header;
|
|
77
|
-
const header = (typeof rawHeader === 'string' ? rawHeader
|
|
78
|
-
: (rawHeader && typeof rawHeader === 'object') ? [rawHeader.title, rawHeader.intro].filter(Boolean).join('\n\n')
|
|
79
|
-
: '').trim();
|
|
80
|
-
const sections = Array.isArray(data?.sections) ? data.sections : [];
|
|
81
|
-
const parts = [];
|
|
82
|
-
if (header) parts.push(header);
|
|
83
|
-
for (const s of sections) {
|
|
84
|
-
const title = String(s?.title || '').trim();
|
|
85
|
-
if (!title) continue;
|
|
86
|
-
parts.push(`## ${title}\n\n${String(s?.body ?? '')}`);
|
|
87
|
-
}
|
|
88
|
-
return parts.join('\n\n') + '\n';
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** 装载 yml 模板(templates/*.yml 首个可用),失败返回 null。 */
|
|
92
|
-
export function loadReadmeTemplateYml(dir = README_TEMPLATE_YML_DIR) {
|
|
93
|
-
let names = [];
|
|
94
|
-
try { names = readdirSync(dir); } catch { return null; }
|
|
95
|
-
const file = names.filter((f) => /\.ya?ml$/i.test(f)).sort()[0];
|
|
96
|
-
if (!file) return null;
|
|
97
|
-
const full = join(dir, file);
|
|
98
|
-
try {
|
|
99
|
-
const parsedYml = yamlLoad(readFileSync(full, 'utf8'));
|
|
100
|
-
if (!parsedYml || typeof parsedYml !== 'object') return null;
|
|
101
|
-
return { file: full, data: parsedYml, template: renderReadmeTemplateYml(parsedYml) };
|
|
102
|
-
} catch { return null; }
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/** 解析 README 模板:显式模板 > <repo>/template/README.md > yml > 内置兜底。 */
|
|
106
|
-
export function resolveReadmeTemplate({ repoPath = '', explicit = '' } = {}) {
|
|
107
|
-
if (explicit) {
|
|
108
|
-
try { const t = readFileSync(explicit, 'utf8'); if (t.trim()) return { source: explicit, template: t }; } catch { /* 忽略 */ }
|
|
109
|
-
}
|
|
110
|
-
for (const cand of [join(repoPath, 'template', 'README.md')]) {
|
|
111
|
-
try { if (existsSync(cand)) { const t = readFileSync(cand, 'utf8'); if (t.trim()) return { source: cand, template: t }; } } catch { /* 忽略 */ }
|
|
112
|
-
}
|
|
113
|
-
const yml = loadReadmeTemplateYml();
|
|
114
|
-
if (yml) return { source: yml.file, template: yml.template, yml: yml.data };
|
|
115
|
-
return { source: 'builtin', template: DEFAULT_README_TEMPLATE };
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/** 从模板自动生成目录(## 标题 → 锚点,'目录' 不列)。 */
|
|
119
|
-
export function tocFromTemplate(template) {
|
|
120
|
-
const titles = [];
|
|
121
|
-
for (const line of String(template || '').split('\n')) {
|
|
122
|
-
const match = line.match(/^##\s+(.+?)\s*$/);
|
|
123
|
-
if (!match) continue;
|
|
124
|
-
const t = match[1].trim();
|
|
125
|
-
if (t === '目录') continue;
|
|
126
|
-
titles.push(t);
|
|
127
|
-
}
|
|
128
|
-
return titles.map((t) => `- [${t}](#${t})`).join('\n');
|
|
129
|
-
}
|
|
130
26
|
|
|
131
27
|
const VERSION_RE = /\bv?(\d+)\.(\d+)\.(\d+)\b/;
|
|
132
28
|
|
|
@@ -275,44 +171,3 @@ export function buildReadmeVersionTable(repoPath) {
|
|
|
275
171
|
}
|
|
276
172
|
|
|
277
173
|
/** 生成 README 文本(不落盘)。 */
|
|
278
|
-
export function genReadme({ repoPath, template = '' } = {}) {
|
|
279
|
-
let name = '项目名', description = '一句话简介', version = null;
|
|
280
|
-
try {
|
|
281
|
-
const pkg = JSON.parse(readFileSync(join(repoPath, 'package.json'), 'utf8'));
|
|
282
|
-
if (pkg.name) name = pkg.name;
|
|
283
|
-
if (pkg.description) description = pkg.description;
|
|
284
|
-
if (pkg.version) version = pkg.version;
|
|
285
|
-
} catch { /* 非 npm 用默认 */ }
|
|
286
|
-
const vtable = toString(buildReadmeVersionTable(repoPath));
|
|
287
|
-
const { source, template: tpl } = resolveReadmeTemplate({ repoPath, template });
|
|
288
|
-
const toc = tocFromTemplate(tpl);
|
|
289
|
-
const content = tpl
|
|
290
|
-
.replaceAll('{{name}}', name).replaceAll('{{description}}', description)
|
|
291
|
-
.replaceAll('{{version}}', version || '').replaceAll('{{toc}}', toc)
|
|
292
|
-
.replaceAll('{{versionTable}}', vtable);
|
|
293
|
-
return { ok: true, content, name, description, version, templateSource: source, versionTable: buildReadmeVersionTable(repoPath), toc };
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
function toString(arr) { return Array.isArray(arr) ? arr.join('\n') : String(arr || ''); }
|
|
297
|
-
|
|
298
|
-
function main(argv) {
|
|
299
|
-
const args = [...argv];
|
|
300
|
-
const repoPath = args.find((a) => !a.startsWith('--'));
|
|
301
|
-
const writeIdx = args.indexOf('--write');
|
|
302
|
-
const writePath = writeIdx >= 0 ? args[writeIdx + 1] : '';
|
|
303
|
-
const tplIdx = args.indexOf('--template');
|
|
304
|
-
const template = tplIdx >= 0 ? args[tplIdx + 1] : '';
|
|
305
|
-
if (!repoPath) { console.error('用法: node scripts/readme-gen.mjs <repoPath> [--write <path>] [--template <path>]'); process.exit(1); }
|
|
306
|
-
const r = genReadme({ repoPath, template });
|
|
307
|
-
if (!r.ok) { console.error(r.error); process.exit(1); }
|
|
308
|
-
if (writePath) { try { writeFileSync(writePath, r.content, 'utf8'); console.error(`已生成: ${writePath}(模板:${r.templateSource})`); } catch (e) { console.error('写入失败:', e?.message); process.exit(1); } }
|
|
309
|
-
else process.stdout.write(r.content);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// 仅作为 CLI 直接运行时执行 main;作为模块 import 供测试时不自动跑(用 import.meta 判断是否入口)
|
|
313
|
-
if (process.argv[1] && import.meta.url && String(import.meta.url).startsWith('file:')) {
|
|
314
|
-
try {
|
|
315
|
-
const entry = fileURLToPath(import.meta.url);
|
|
316
|
-
if (entry === String(process.argv[1])) main(process.argv.slice(2));
|
|
317
|
-
} catch { /* 非 file url 不做入口判断 */ }
|
|
318
|
-
}
|
|
@@ -227,17 +227,10 @@ pnpm add github:EIGHTfs/dsh-git-push#<commit>
|
|
|
227
227
|
|
|
228
228
|
**约定**:README 不直接内嵌长文档(版本表/文件树/函数列表),改为「## 分体式文档」节链接引用。三脚本命令统一 `gen`(打印)/ `apply`(写宿主,自动探测带标记块的 md)/ `check`(查漂移);宿主探测复用公共函数 `findMarkedHostMd(root, marker)`(优先 README,README 无标记块时扫描 .md 找含块文件)。
|
|
229
229
|
|
|
230
|
-
### 9.2 README
|
|
230
|
+
### 9.2 README 生成(能力已下线)
|
|
231
231
|
|
|
232
|
-
`git_gen_readme`
|
|
233
|
-
|
|
234
|
-
```bash
|
|
235
|
-
node scripts/readme-gen.mjs <repoPath> [--write <path>] [--template <path>]
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
- 只打印不写 → 不传 `--write`;`--write README.md` 才落盘
|
|
239
|
-
- `--template` 指定自定义模板(缺省 `lib/readme-templates/readme.yml`);占位符 `{{name}} {{description}} {{version}} {{toc}} {{versionTable}}`
|
|
240
|
-
- 插件不再内置生成能力,push.js 的「仓库无 README」提示引用此脚本
|
|
232
|
+
`git_gen_readme` 工具与模板渲染脚本均已移除:README 由使用手册规范手工维护,不再按模板生成。
|
|
233
|
+
「仓库无 README」之类的提示保留,但不再指向任何生成脚本。
|
|
241
234
|
|
|
242
235
|
### 9.3 doc-tree 自动探测 md(2026-09-29)
|
|
243
236
|
|
|
@@ -272,7 +265,6 @@ node scripts/readme-gen.mjs <repoPath> [--write <path>] [--template <path>]
|
|
|
272
265
|
| `git_remote_create` | **`repo`**、`visibility?`(默认 private)、`dryRun?` | 同名存在则复用,否则创建并把 origin 指向 API 地址;`ensureRemoteRepo` |
|
|
273
266
|
| `git_set_visibility` | **`repo`**、**`visibility`** | `PATCH /repos/{owner}/{repo}` 的 private 字段;改 public 前须确认无凭据暴露;`setVisibility` |
|
|
274
267
|
| `link_check` | `path?`(缺省 workspaceRoot) | 分级扣分(404/403 −3、DNS −2、超时/5xx −1,flaky 域名 ×0.2);**只 warning 永不 blocker**;并发 10;`checkLinks`/`probeLinks` |
|
|
275
|
-
| `git_gen_readme` | **`repo`**、`writePath?`(缺省只返回内容) | 模板优先级:插件 `template/README.md` > 内置 `readme.yml` > 代码兜底;版本表由 `git log --reverse` 聚合;`genReadme` |
|
|
276
268
|
|
|
277
269
|
**接线层**(`lib/plugin/index.js`,Host 侧四段真实 API):工具 `ctx.inject(['tools'])` → `register(defineTool(spec))`(`output.render` **必须返回块数组**);提示词注入 `inject(['systemPrompt'])` → `section({name, order, text})`;HTTP `inject(['webServer'])` → `register({kind:'prefix', path, handler})`;客户端**不在此注册**(由 package.json `dsh.client` + `exports["./client"]` 自动发现)。
|
|
278
270
|
|
|
@@ -57,7 +57,6 @@ git-sluice self-check
|
|
|
57
57
|
| 脚本 | 作用 | 用法要点 |
|
|
58
58
|
|------|------|----------|
|
|
59
59
|
| `scripts/rule-switch.mjs` | 手动启停安装版本的规则槽位(与侧边栏 UI 启停同一套实现) | `node scripts/rule-switch.mjs <status\|enable\|disable> <槽位>` |
|
|
60
|
-
| `scripts/scrub-user-wording.mjs` | 清洗代码注释里的沟通残留措辞(只警告不改、逐条确认、每文件 `.bak`) | `node scripts/scrub-user-wording.mjs <路径...> [--apply [--yes]]`;`--repo <仓库>` 只处理未提交 diff |
|
|
61
60
|
| `scripts/audit-runtime-check.mjs` | 三层审计的 L3 运行时检测:动态 import 后清空再访问,抓静态查不出的 bug | `node scripts/audit-runtime-check.mjs <js 文件> [--obj 名]`;`--all <目录>` |
|
|
62
61
|
| `scripts/scan-file-io.mjs` | 扫描脚本里的文件读写调用与路径,标四级风险(与审计 `robustness/io-risk` 同标准) | `node scripts/scan-file-io.mjs <路径> [--write]` |
|
|
63
62
|
| `scripts/scan-repos.mjs` | 扫描本地 git 仓库清单 | `node scripts/scan-repos.mjs --root <root> --owner <owner> [--depth 10] [--max 200]` |
|
|
@@ -70,7 +69,6 @@ git-sluice self-check
|
|
|
70
69
|
| `scripts/check.mjs` | 语法检查(递归查 lib 与 CLI 入口) |
|
|
71
70
|
| `scripts/scan-version.mjs` | 版本一致性校验(三处版本号是否同步) |
|
|
72
71
|
| `scripts/doc-func.mjs` / `doc-tree.mjs` / `doc-version.mjs` | 函数列表 / 目录树 / 版本记录 三份文档与代码同步(`check` 查漂移、`apply` 写回) |
|
|
73
|
-
| `scripts/readme-gen.mjs` | README 生成 |
|
|
74
72
|
| (已迁移)dsh-useful-tools 的 `preview` 工具(action=gen / 只更数据段 / check` 漂移门禁 / `--watch` 监听) / ``preview` 工具 action=serve(dsh-useful-tools)`(默认反代真后端 / `--direct` 直连插件 / `--local` 免重启) | 界面预览页生成与漂移门禁、本地真实后端测试服务 |
|
|
75
73
|
| `scripts/browser-page-probe.mjs` | 无头浏览器探针:读页面真实渲染文本 + 抓前端运行时错误(零硬编码路径,自动探测环境) |
|
|
76
74
|
| ``sync_plugin` 工具(dsh-useful-tools)` | 同步(工作区 → 安装副本;**安装位置 = local-plugins 真源**)+ 部署形态与免重启热重载自检:`--profile <名>` 指定 profile(多 profile 必给)、`--fix` 只修 local-plugins 侧形态(解软链 / 建真实目录)。node_modules 入口由 DSH 安装流程生成,本脚本不建链;若那里的副本**内容与真源不一致**会报警(实测会顶掉真源;同 inode 硬链接副本不报) |
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018-2024 Max Brunsfeld
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
# assets/tree-sitter —— 随包发布的 tree-sitter 运行时与语法(**第三方,MIT**)
|
|
2
|
-
|
|
3
|
-
本目录是**第三方产物**,不是本项目源码。用途:给审计的「列级/语法级精筛」提供真语法树,
|
|
4
|
-
与 `lib/ast/*` 的自研 token 级判定形成互补(自研层始终保留为**回退路径**)。
|
|
5
|
-
|
|
6
|
-
## 内容与来源(钉死版本,勿随手升级)
|
|
7
|
-
|
|
8
|
-
| 文件 | 来源 | 版本 | 大小 | sha256(前 16 位) |
|
|
9
|
-
|---|---|---|---|---|
|
|
10
|
-
| `tree-sitter.js` | npm `web-tree-sitter` | **0.25.10** | 150,999 B | 见 `sha256sum` 现场复核 |
|
|
11
|
-
| `tree-sitter.wasm` | npm `web-tree-sitter` | **0.25.10** | 205,488 B | 同上 |
|
|
12
|
-
| `tree-sitter-javascript.wasm` | npm `tree-sitter-wasms` | 0.1.13 | 647,334 B | `63812b9e275d2685` |
|
|
13
|
-
| `tree-sitter-typescript.wasm` | npm `tree-sitter-wasms` | 0.1.13 | 2,342,690 B | `8515404dceed38e1` |
|
|
14
|
-
| `tree-sitter-python.wasm` | npm `tree-sitter-wasms` | 0.1.13 | 476,105 B | `9056d0fb0c337810` |
|
|
15
|
-
| `LICENSE` | npm `web-tree-sitter` | 0.25.10 | 1,085 B | —— |
|
|
16
|
-
|
|
17
|
-
> ⚠️ **运行时版本不要随手升**:实测 `web-tree-sitter@0.27.1` 与 `tree-sitter-wasms@0.1.13` 的语法
|
|
18
|
-
> **不兼容** —— `Language.load` 会在 `getDylinkMetadata` 处抛出**空消息**的 Error(0.26.0 同样失败 ✗)。
|
|
19
|
-
> 0.25.10 实测可加载同一批语法(`LANGUAGE_VERSION=15`)✓;换版本必须重跑 `lib/ast/treesitter.js` 的冒烟测试。
|
|
20
|
-
|
|
21
|
-
下载方式(可复现;CDN 直取,不走 npm install):
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
WTS=0.25.10; TSW=0.1.13
|
|
25
|
-
# 注意:0.25.x 的文件名是 tree-sitter.js / tree-sitter.wasm(0.27.x 才是 web-tree-sitter.* ✗ 不兼容)
|
|
26
|
-
curl -sL -o tree-sitter.js "https://cdn.jsdelivr.net/npm/web-tree-sitter@$WTS/tree-sitter.js"
|
|
27
|
-
curl -sL -o tree-sitter.wasm "https://cdn.jsdelivr.net/npm/web-tree-sitter@$WTS/tree-sitter.wasm"
|
|
28
|
-
curl -sL -o LICENSE "https://cdn.jsdelivr.net/npm/web-tree-sitter@$WTS/LICENSE"
|
|
29
|
-
for L in javascript typescript python; do
|
|
30
|
-
curl -sL -o "tree-sitter-$L.wasm" "https://cdn.jsdelivr.net/npm/tree-sitter-wasms@$TSW/out/tree-sitter-$L.wasm"
|
|
31
|
-
done
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## 落库校验(每次改动本目录都要复核)
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
# ① 必须是真 wasm(魔数 \0asm)——曾把 CDN 的 404 错误页当 wasm 存进来过 ✗
|
|
38
|
-
for f in *.wasm; do printf '%s %s\n' "$(head -c4 "$f" | od -An -c | tr -d ' \n')" "$f"; done
|
|
39
|
-
# ② 与上表 sha256 对照
|
|
40
|
-
sha256sum *.wasm *.js
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## 许可与合规
|
|
44
|
-
|
|
45
|
-
- `web-tree-sitter`(含 `web-tree-sitter.js` / `web-tree-sitter.wasm`):**MIT**,许可证原文见同目录 `LICENSE`。
|
|
46
|
-
- 语法包 `tree-sitter-wasms` 内各语法由对应上游语法项目构建(各语法多为 MIT/Apache-2.0);
|
|
47
|
-
本目录只随包分发**预编译 wasm**,不改动其内容。
|
|
48
|
-
- 分发要求:保留 `LICENSE` 与来源说明(本文件即是)✓
|
|
49
|
-
|
|
50
|
-
## 语言集合口径(与审计规则包对齐)
|
|
51
|
-
|
|
52
|
-
**加载哪些语言 = `lib/audit-rules/` 里存在哪些「语言规则包」**(**空占位包也算** ✓):
|
|
53
|
-
|
|
54
|
-
```
|
|
55
|
-
有规则的:nodejs(js/ts) · frontend(js/ts/css/html) · java · python
|
|
56
|
-
空占位包:cpp · go · php · rust · swift
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
当前试点已落 **javascript / typescript / python** 三个;
|
|
60
|
-
其余(java/go/rust/cpp/php/swift)按同一口径后续补入(每个约 0.3~2.3MB,**体积是主要代价** ✗)。
|
|
61
|
-
|
|
62
|
-
## 与自研层的关系(重要)
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
优先:能加载到语法 wasm ⇒ 用语法树确认「命中的那一处是不是真的语法节点」(如 string_fragment / comment ⇒ 不是代码)
|
|
66
|
-
回退:加载失败 / 无对应语法 / 超预算 ⇒ 退回 lib/ast/code-lines.js 的 token 级(行级 + 列级)判定
|
|
67
|
-
铁律:**新增规则字段必须同时登记 lib/rule/registry.js 的 withRuleScope 补丁点** ✗
|
|
68
|
-
—— 否则会出现「单元测试通过、生产路径静默失效」(2026-10-15 实测踩到)
|
|
69
|
-
```
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
版本留档: web-tree-sitter@0.25.10 · tree-sitter-wasms@0.1.13
|
|
Binary file
|
|
Binary file
|
|
Binary file
|