dsh-harness-kit 0.1.6 → 0.2.0

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 (31) hide show
  1. package/README.md +27 -13
  2. package/README.zh-CN.md +26 -16
  3. package/client.js +108 -11
  4. package/docs/DETAIL.en.md +29 -9
  5. package/docs/DETAIL.md +14 -4
  6. package/kernel/advance.js +3 -3
  7. package/kernel/bindings.js +11 -6
  8. package/kernel/commands.js +150 -23
  9. package/kernel/local-files.js +5 -5
  10. package/kernel/metrics.js +280 -0
  11. package/kernel/panel.js +140 -6
  12. package/kernel/paths.js +62 -1
  13. package/kernel/setup.js +5 -4
  14. package/kernel/te.js +4 -4
  15. package/kernel/worktree.js +162 -20
  16. package/package.json +1 -1
  17. package/packs/ai-coding/assets/scripts/codebase_guide_init.py +1 -1
  18. package/packs/ai-coding/assets/scripts/harness_init.py +15 -6
  19. package/packs/ai-coding/assets/scripts/te_lease.py +6 -1
  20. package/packs/ai-coding/assets/scripts/update_board.py +30 -0
  21. package/packs/ai-coding/flows/init.yml +2 -2
  22. /package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/{app-CLAUDE.tmpl → app-AGENTS.tmpl} +0 -0
  23. /package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/{module-CLAUDE.tmpl → module-AGENTS.tmpl} +0 -0
  24. /package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +0 -0
  25. /package/packs/ai-coding/assets/templates/java/maven/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +0 -0
  26. /package/packs/ai-coding/assets/templates/java/maven-multimodule/{module-CLAUDE.tmpl → module-AGENTS.tmpl} +0 -0
  27. /package/packs/ai-coding/assets/templates/java/maven-multimodule/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +0 -0
  28. /package/packs/ai-coding/assets/templates/javascript/mobile-app/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +0 -0
  29. /package/packs/ai-coding/assets/templates/javascript/uniapp/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +0 -0
  30. /package/packs/ai-coding/assets/templates/javascript/vue-multimodule/{app-CLAUDE.tmpl → app-AGENTS.tmpl} +0 -0
  31. /package/packs/ai-coding/assets/templates/javascript/vue-multimodule/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +0 -0
@@ -35,6 +35,15 @@ def get_template_dir(sp_type: str) -> str:
35
35
  }.get(sp_type, "")
36
36
 
37
37
 
38
+ def instruction_template(tdir: str, stem: str) -> str:
39
+ """入口文件模板:优先 *-AGENTS.tmpl;存量工作区回退旧 *-CLAUDE.tmpl。"""
40
+ for name in (f"{stem}-AGENTS.tmpl", f"{stem}-CLAUDE.tmpl"):
41
+ rel = f"{tdir}/{name}"
42
+ if (TEMPLATES_DIR / rel).is_file():
43
+ return rel
44
+ return f"{tdir}/{stem}-AGENTS.tmpl"
45
+
46
+
38
47
  def list_frontend_apps(path: Path):
39
48
  apps_dir = path / "apps"
40
49
  if not apps_dir.is_dir():
@@ -122,7 +131,7 @@ def generate_plan(root: Path) -> dict:
122
131
  "missing_keys": build_json_missing_keys(root, rel, f"{tdir}/build.tmpl"),
123
132
  },
124
133
  "docs/CODE_STANDARDS.md": {"status": check_file(root, f"{rel}/docs/CODE_STANDARDS.md"), "template": f"{tdir}/CODE_STANDARDS.tmpl"},
125
- "AGENTS.md": {"status": "EXISTS" if instruction_file(path) else "MISSING", "template": f"{tdir}/root-CLAUDE.tmpl"},
134
+ "AGENTS.md": {"status": "EXISTS" if instruction_file(path) else "MISSING", "template": instruction_template(tdir, "root")},
126
135
  },
127
136
  "codegraph": "EXISTS" if (path / ".codegraph").is_dir() else "MISSING",
128
137
  "modules": [],
@@ -131,25 +140,25 @@ def generate_plan(root: Path) -> dict:
131
140
  # 只生成根级 L1/L1.5/L2,modules 保持为空 —— 故此处不设分支。
132
141
  if stype == "vue-multimodule":
133
142
  sp["modules"] = [{"name": m["name"], "path": f"services/{name}/apps/{m['name']}",
134
- "template": f"{tdir}/app-CLAUDE.tmpl",
143
+ "template": instruction_template(tdir, "app"),
135
144
  "status": "EXISTS" if instruction_file(Path(m["path"])) else "MISSING"}
136
145
  for m in list_frontend_apps(path)]
137
146
  elif stype == "maven-multimodule":
138
147
  sp["modules"] = [{"name": m["name"],
139
148
  "path": f"services/{name}/{Path(m['parent']).relative_to(path) / m['name']}",
140
- "template": f"{tdir}/module-CLAUDE.tmpl",
149
+ "template": instruction_template(tdir, "module"),
141
150
  "status": "EXISTS" if instruction_file(Path(m["path"])) else "MISSING"}
142
151
  for m in list_maven_modules(path)]
143
152
  elif stype in ("dotnet", "dotnet-multimodule"):
144
- # 后端项目 → module-CLAUDE.tmpl;前端子项目(SPA/Blazor WASM)→ app-CLAUDE.tmpl
153
+ # 后端项目 → module-AGENTS.tmpl;前端子项目(SPA/Blazor WASM)→ app-AGENTS.tmpl
145
154
  sp["modules"] = [
146
155
  {"name": m["name"], "path": f"services/{name}/{m['name']}",
147
- "template": f"{tdir}/module-CLAUDE.tmpl",
156
+ "template": instruction_template(tdir, "module"),
148
157
  "status": "EXISTS" if instruction_file(Path(m["path"])) else "MISSING"}
149
158
  for m in lib.list_dotnet_projects(path)
150
159
  ] + [
151
160
  {"name": m["name"], "path": f"services/{name}/{m['name']}",
152
- "template": f"{tdir}/app-CLAUDE.tmpl",
161
+ "template": instruction_template(tdir, "app"),
153
162
  "status": "EXISTS" if instruction_file(Path(m["path"])) else "MISSING"}
154
163
  for m in lib.list_frontend_projects(path)
155
164
  ]
@@ -18,12 +18,17 @@ from pathlib import Path
18
18
 
19
19
 
20
20
  def env_path() -> Path:
21
+ return Path.cwd() / ".harness" / "local" / "test-env.json"
22
+
23
+
24
+ def legacy_env_path() -> Path:
21
25
  return Path.cwd() / ".harness" / "tasks" / "test-env.json"
22
26
 
23
27
 
24
28
  def read_env():
25
29
  try:
26
- data = json.loads(env_path().read_text(encoding="utf-8"))
30
+ path = env_path() if env_path().exists() or not legacy_env_path().exists() else legacy_env_path()
31
+ data = json.loads(path.read_text(encoding="utf-8"))
27
32
  except (OSError, json.JSONDecodeError):
28
33
  data = {}
29
34
  return {
@@ -400,6 +400,36 @@ def cmd_repair(root: Path, write: bool) -> int:
400
400
  return 0
401
401
  lines, rows = read_rows(board.read_text(encoding="utf-8"))
402
402
  changed = 0
403
+ # 旧 4 列看板迁移(任务|状态|负责|更新):先换成 7 列表头,再把旧列映射到新列。
404
+ # 负责人没有对应列,保留到「续接提示」里,避免修复时丢信息。
405
+ CANON_HEADER = "| 任务名 | 状态 | Profile | Apply进度 | 分支 | 上次活动 | 续接提示 |"
406
+ CANON_SEP = "|--------|------|---------|-----------|------|---------|----------|"
407
+ legacy = False
408
+ for i, line in enumerate(lines):
409
+ if not line.startswith("|"):
410
+ legacy = False
411
+ continue
412
+ cells = [c.strip() for c in line.strip().strip("|").split("|")]
413
+ if not cells:
414
+ continue
415
+ if not legacy and cells[0] in ("任务", "任务名") and len(cells) == 4:
416
+ legacy = True
417
+ lines[i] = CANON_HEADER
418
+ changed += 1
419
+ continue
420
+ if legacy:
421
+ if cells and not cells[0].strip("-: "):
422
+ lines[i] = CANON_SEP
423
+ changed += 1
424
+ continue
425
+ if len(cells) >= 4:
426
+ task, status, owner, updated = cells[0], cells[1], cells[2], cells[3]
427
+ hint = f"旧负责人:{owner}" if owner and owner != "—" else "—"
428
+ lines[i] = render_row([task, status, "—", "—", "—", updated, hint])
429
+ changed += 1
430
+ if changed:
431
+ # 让后续 repair 读取迁移后的行
432
+ lines, rows = read_rows("\n".join(lines))
403
433
  # 表头/分隔线规范化(曾有 Agent 用空格把单元格撑到 3.8 万字符)
404
434
  CANON = {
405
435
  "header": "| 任务名 | 状态 | Profile | Apply进度 | 分支 | 上次活动 | 续接提示 |",
@@ -56,12 +56,12 @@ stages:
56
56
  - name: L1 根 AGENTS.md
57
57
  actor: PM
58
58
  do:
59
- - 对每个确认生成的子工程派发一个 subagent:模板 root-CLAUDE.tmpl 全文 + 目标代码目录 + 输出 <子工程>/AGENTS.md;仅当 AGENTS.md 和 CLAUDE.md 都不存在时生成,已有任一则跳过
59
+ - 对每个确认生成的子工程派发一个 subagent:模板 root-AGENTS.tmpl(存量工作区若只有 root-CLAUDE.tmpl 则兼容) 全文 + 目标代码目录 + 输出 <子工程>/AGENTS.md;仅当 AGENTS.md 和 CLAUDE.md 都不存在时生成,已有任一则跳过
60
60
  - 「参考文档」段必须列 docs/CODE_STANDARDS.md —— 模板已写死该引用,不得按当前盘面自行判断"无参考文档"
61
61
  - name: 模块级 AGENTS.md
62
62
  actor: PM
63
63
  do:
64
- - 按 plan 中缺失的模块清单派发 subagent(后端 module-CLAUDE.tmpl / 前端 app-CLAUDE.tmpl),输出 <模块>/AGENTS.md;模块已有 AGENTS.md 或 CLAUDE.md 任一则跳过,每批最多 5 个并行,避免上下文爆炸
64
+ - 按 plan 中缺失的模块清单派发 subagent(后端 module-AGENTS.tmpl(旧 module-CLAUDE.tmpl 兼容) / 前端 app-AGENTS.tmpl(旧 app-CLAUDE.tmpl 兼容)),输出 <模块>/AGENTS.md;模块已有 AGENTS.md 或 CLAUDE.md 任一则跳过,每批最多 5 个并行,避免上下文爆炸
65
65
  - 每个 prompt 自包含:模板全文 + 模块路径 + 输出路径
66
66
  - name: CodeGraph 索引
67
67
  actor: PM