svharness 0.11.0 → 0.13.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/README.md +37 -44
- package/dist/commands/apply.js +447 -107
- package/dist/commands/convert.js +17 -15
- package/dist/commands/init.js +33 -5
- package/dist/commands/wizard.js +5 -4
- package/dist/core/apply-project-entry.js +37 -63
- package/dist/core/project-ignore.js +53 -0
- package/dist/index.js +23 -27
- package/dist/utils/harness-name.js +41 -0
- package/dist/utils/validate-args.js +72 -31
- package/package.json +1 -1
- package/templates/_shared/apply-skills/harness-apply-skills-main.md +19 -109
- package/templates/_shared/build-rules/harness-build-rule-convert-check.md +6 -4
- package/templates/_shared/build-skills/harness-build-skill-orchestrator.md +6 -6
- package/templates/svharness.config.example.yaml +2 -1
package/README.md
CHANGED
|
@@ -316,35 +316,39 @@ svharness build \
|
|
|
316
316
|
|
|
317
317
|
### `apply` —— 把已构建好的 harness 绑定到目标项目
|
|
318
318
|
|
|
319
|
-
把 `<name>-harness/`(通过 `build`
|
|
319
|
+
把 `<name>-harness/`(通过 `build` 完成的知识层)应用到目标项目时,`apply` 现采用**默认复制模式**:始终把 harness 拷贝到 `<target>/<name>-harness/`,然后注入 runtime skills/rules,并生成项目根 AI 入口。
|
|
320
320
|
|
|
321
321
|
```bash
|
|
322
|
-
#
|
|
322
|
+
# 默认复制模式(无需 --clone)
|
|
323
323
|
svharness apply --harness ../my-app-harness --target ./to-apply-project
|
|
324
324
|
|
|
325
|
-
# clone
|
|
325
|
+
# --clone 仍可传入,但仅兼容:行为与默认一致(都会拷贝)
|
|
326
326
|
svharness apply --harness ../my-app-harness --target ./to-apply-project --clone --yes
|
|
327
327
|
```
|
|
328
328
|
|
|
329
|
-
**在 Agent IDE 中触发**:对话框输入 `应用 harness-apply-skills-main 完成 xxx
|
|
329
|
+
**在 Agent IDE 中触发**:对话框输入 `应用 harness-apply-skills-main 完成 xxx 功能开发`,薄入口会提示并优先使用已注入的 `harness-apply-skills-*` 子 skill。
|
|
330
330
|
|
|
331
|
-
同时,CLI 会在**目标项目根**写入 `CLAUDE.md`(`--agent codechat` 或 `claude-code`)或 `AGENTS.md`(`qoder` / `cursor` / `opencode` / `generic
|
|
331
|
+
同时,CLI 会在**目标项目根**写入 `CLAUDE.md`(`--agent codechat` 或 `claude-code`)或 `AGENTS.md`(`qoder` / `cursor` / `opencode` / `generic`)。该入口由 `<harness>/AGENTS_APPLY.md` 拷贝并重命名生成(与 `build` 写入项目根入口的规则一致,不再单独落地 `AGENTS_APPLY.md`)。
|
|
332
|
+
|
|
333
|
+
此外,`apply` 会同步注入运行期资产:
|
|
334
|
+
|
|
335
|
+
- `<harness>/agent-env/rules/` → `<target>/<adapter.rulesDir>/`(若该 agent 声明了 `rulesDir`)
|
|
336
|
+
- `<harness>/agent-env/skills/` → `<target>/<adapter.skillsDir>/`(全量注入;`harness-apply-skills-main` 由模板写入为薄入口)
|
|
337
|
+
- 目标 `.gitignore` 会追加注入路径(幂等去重)
|
|
332
338
|
|
|
333
339
|
#### references 内容引用 → apply_skill_registry(S60,由 Agent 写入)
|
|
334
340
|
|
|
335
|
-
S60(`harness-build-skill-references-intake
|
|
341
|
+
S60(`harness-build-skill-references-intake`)属于 **build 阶段**。若某份 references 属于**内容引用**(apply 时要按 `references/md/` 原文指导开发),Agent 应:
|
|
336
342
|
|
|
337
343
|
1. 登记 `references/apply-skills-registry.yaml`(`skill_name`、`reference_md`、`description`,可选 `entry` / `source_id`)
|
|
338
|
-
2. 执行 `svharness apply`
|
|
344
|
+
2. 执行 `svharness apply` 时,运行期 skill 将按引用原文执行,且相关路径会改写到 `<target>/<name>-harness/` 下可达位置
|
|
339
345
|
|
|
340
346
|
无单独 CLI;规制约束、纯手册类 references **不**登记 registry。
|
|
341
347
|
|
|
342
|
-
####
|
|
348
|
+
#### build / apply 分工
|
|
343
349
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
| **bind-only** | 默认 | 保持在 `--harness` 原路径 | `bind-only` | harness 与多个目标项目共享、单一知识源 |
|
|
347
|
-
| **clone** | `--clone` | 拷贝到 `<target>/<name>-harness/` | `clone` | 需要自包含交付、离线使用、锁定版本 |
|
|
350
|
+
- **build 阶段**:生成 harness 本体资产(`AGENTS_APPLY.md`、`agent-env/skills`、`agent-env/rules`、`specs`、`baseline` 等)
|
|
351
|
+
- **apply 阶段**:复制 harness 到目标项目、注入 skills/rules、生成入口文件、写 `.gitignore`、校验注入文件引用关系
|
|
348
352
|
|
|
349
353
|
#### 全部参数
|
|
350
354
|
|
|
@@ -353,8 +357,8 @@ S60(`harness-build-skill-references-intake`)中,若某份 references 属
|
|
|
353
357
|
| `--harness <path>` | ✅ 必填 | 已构建好的 harness 目录(形如 `./my-app-harness`) | — |
|
|
354
358
|
| `--target <path>` | 可选 | 目标项目根目录 | **当前工作目录(cwd)** |
|
|
355
359
|
| `--agent <agent>` | 可选 | 目标 Agent:`codechat` / `qoder` / `cursor` / `claude-code` / `opencode` / `generic` | **从 `<harness>/.harness-build-state.yaml` 读取**;缺失则报错 |
|
|
356
|
-
| `--clone` | 可选 flag |
|
|
357
|
-
| `--force` | 可选 flag |
|
|
360
|
+
| `--clone` | 可选 flag | 兼容参数;当前实现下行为与默认一致(都会拷贝 harness) | `false` |
|
|
361
|
+
| `--force` | 可选 flag | 覆盖已存在注入目录与入口文件;同时允许重拷贝 harness | `false` |
|
|
358
362
|
| `-y, --yes` | 可选 flag | 跳过交互确认 | `false` |
|
|
359
363
|
| `--verbose` | 可选 flag | 显示详细日志 | `false` |
|
|
360
364
|
|
|
@@ -362,32 +366,15 @@ S60(`harness-build-skill-references-intake`)中,若某份 references 属
|
|
|
362
366
|
|
|
363
367
|
```
|
|
364
368
|
<target>/
|
|
365
|
-
├── CLAUDE.md | AGENTS.md # apply
|
|
366
|
-
├──
|
|
369
|
+
├── CLAUDE.md | AGENTS.md # apply 工作流入口(由 harness/AGENTS_APPLY.md 重命名)
|
|
370
|
+
├── <adapter.rulesDir>/... # 运行期 rules 注入(若 adapter 声明 rulesDir)
|
|
371
|
+
├── <adapter.skillsDir>/<runtime-skill>/SKILL.{md|mdc} # 运行期 skills 注入
|
|
367
372
|
├── <adapter.skillsDir>/harness-apply-skills-main/
|
|
368
|
-
│
|
|
369
|
-
|
|
370
|
-
│ └── references/binding.yaml # 冗余副本(权威源在 SKILL.md 内),供工具链解析
|
|
371
|
-
└── <name>-harness/ # 仅 --clone 模式
|
|
373
|
+
│ └── SKILL.{md|mdc} # 薄入口 skill(仅提示/索引,不做二级调度)
|
|
374
|
+
└── <name>-harness/ # apply 默认复制后的 harness
|
|
372
375
|
```
|
|
373
376
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
```yaml
|
|
377
|
-
harness_name: my-app
|
|
378
|
-
harness_root: D:\abs\path\to\my-app-harness # 运行时定位 harness 的绝对路径
|
|
379
|
-
harness_root_rel: ../my-app-harness # 相对 target 的路径(可读)
|
|
380
|
-
harness_version: 0.1.0
|
|
381
|
-
target_project: D:\abs\path\to\to-apply-project
|
|
382
|
-
agent: codechat
|
|
383
|
-
mode: bind-only # 或 clone
|
|
384
|
-
applied_at: '2026-05-12T13:34:54.184Z'
|
|
385
|
-
applied_by: svharness@0.8.0
|
|
386
|
-
```
|
|
387
|
-
|
|
388
|
-
> - clone 模式下 `harness_root` 指向克隆后的本地副本,而非 `--harness` 原路径。
|
|
389
|
-
> - 同路径自拷贝会被自动跳过(防御性校验)。
|
|
390
|
-
> - `--agent` 省略时从 harness 构建状态文件读取,确保与原 IDE 一致;若状态文件缺失则报错。
|
|
377
|
+
> 注入完成后,CLI 会校验入口文件、薄入口 skill、注入 skills/rules 内的路径引用是否可达;失败会报错中止。
|
|
391
378
|
|
|
392
379
|
### `convert` —— 文档 → Markdown 预处理(对接 S20_collect_inputs)
|
|
393
380
|
|
|
@@ -399,8 +386,11 @@ applied_by: svharness@0.8.0
|
|
|
399
386
|
# 最简 —— 所有参数均可省略,默认扫描当前目录
|
|
400
387
|
svharness convert
|
|
401
388
|
|
|
402
|
-
#
|
|
403
|
-
svharness convert --input ./docs/*.pdf
|
|
389
|
+
# 独立模式:md 直接写入 ./docs/md
|
|
390
|
+
svharness convert --input ./docs/*.pdf --output ./docs/md --yes
|
|
391
|
+
|
|
392
|
+
# harness 模式:md 写入 ./my-app-harness/requirements/md/
|
|
393
|
+
svharness convert --input ./my-app-harness/requirements/raw --output ./my-app-harness --yes
|
|
404
394
|
|
|
405
395
|
# 显示处理日志
|
|
406
396
|
svharness convert --verbose
|
|
@@ -411,8 +401,8 @@ svharness convert --verbose
|
|
|
411
401
|
| 参数 | 说明 | 默认值 |
|
|
412
402
|
|------|------|--------|
|
|
413
403
|
| `--input <path...>` | 一个或多个源文件 / 目录 / glob,支持 `./a/*.pdf`、`./docs/**/*.docx`、`./{a,b}/*.md` | `.`(当前目录) |
|
|
414
|
-
| `--harness <path>` |
|
|
415
|
-
| `--output <path>` |
|
|
404
|
+
| `--harness <path>` | harness 根目录(需 `harness.yaml`);单独使用时写入 `<harness>/<type>/md/`;与 `--output` 同用时 `--output` 为最终 md 目录 | — |
|
|
405
|
+
| `--output <path>` | **独立模式**:最终 md 输出目录;**harness 模式**:`path` 含 `harness.yaml` 时写入 `<path>/<type>/md/` | `.`(当前目录) |
|
|
416
406
|
| `--endpoint <url>` | 云端 `markitdown_serve` 基址,省略时读环境变量 `SVHARNESS_MARKITDOWN_ENDPOINT` | `http://markitdown.desaysz.site` |
|
|
417
407
|
| `--concurrency <n>` | 并发上传数 | `3` |
|
|
418
408
|
| `--max-file-mb <n>` | 单文件大小上限(MB),本地 + 服务端双重限流 | `50` |
|
|
@@ -427,8 +417,11 @@ svharness convert --verbose
|
|
|
427
417
|
- **健康探针前置**:上传前先 `GET /healthz`,不通直接退出并打印清晰定位指引(endpoint / 环境变量 / 服务端目录三条线索)。
|
|
428
418
|
- **单文件失败不中断**:失败单文件计入汇总,其它文件照常完成。结束时打印 `ok / skipped / failed` 计数。
|
|
429
419
|
- **本地白名单预过滤**:客户端与服务端的扩展名白名单保持一致,非白名单文件本地直接跳过,避免无意义往返。
|
|
430
|
-
-
|
|
431
|
-
-
|
|
420
|
+
- **两种输出模式**:
|
|
421
|
+
- **独立**:`--output` 即最终 md 目录(路径下无 `harness.yaml`),例如 `--output ./docs/md`。
|
|
422
|
+
- **harness**:`--output` 或 `--harness` 指向含 `harness.yaml` 的目录时,写入 `<harness>/<type>/md/`(build / Agent 模板沿用此约定)。
|
|
423
|
+
- **harness 模式收尾**:扫描 `raw/` 时跳过 `converted_md/`、`md/` 等;结束后将误落在 `raw/**/converted_md/` 下的 `.md` 迁回 `<type>/md/`。
|
|
424
|
+
- **源文件不改动**:只生成 md,不移动或删除原始文档。
|
|
432
425
|
|
|
433
426
|
#### 产物
|
|
434
427
|
|
|
@@ -750,7 +743,7 @@ svharness build --harness-name demo-unknown --arch python --agent codechat `
|
|
|
750
743
|
- [x] 多架构模板(`android-compose` / `android-xml` / `cpp` / `web-react` / `python`)
|
|
751
744
|
- [x] `_shared/` + `<arch>/` 两层叠拷合并
|
|
752
745
|
- [x] 每个架构自带 3-5 条规则文件(`.mdc` 格式,`always_on` 加载)
|
|
753
|
-
- [x] `apply` —— 把已构建好的 harness
|
|
746
|
+
- [x] `apply` —— 把已构建好的 harness 绑定到目标项目(默认复制模式,`--clone` 兼容保留)
|
|
754
747
|
- [x] 构建辅助资源统一命名(`build-skills/harness-build-skill-*`、`build-rules/harness-build-rule-*`)
|
|
755
748
|
- [ ] `detach` —— 从目标项目解绑并清理 dispatcher skill
|
|
756
749
|
- [ ] `doctor` —— 检查既有 harness 的健康度
|