dsh-harness-kit 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +321 -2
- package/README.zh-CN.md +278 -0
- package/client.js +1272 -0
- package/cordis.patch.yml +4 -0
- package/docs/DETAIL.en.md +97 -0
- package/docs/DETAIL.md +73 -0
- package/docs/assets/ui-new-task.png +0 -0
- package/docs/assets/ui-onboarding.png +0 -0
- package/docs/assets/ui-war-room.png +0 -0
- package/icon.svg +7 -0
- package/index.js +49 -0
- package/kernel/advance.js +96 -0
- package/kernel/bindings.js +24 -0
- package/kernel/commands.js +927 -0
- package/kernel/env.js +64 -0
- package/kernel/exec.js +41 -0
- package/kernel/flows.js +89 -0
- package/kernel/guards.js +79 -0
- package/kernel/miniyaml.js +133 -0
- package/kernel/models.js +104 -0
- package/kernel/panel.js +1103 -0
- package/kernel/paths.js +53 -0
- package/kernel/roles.js +67 -0
- package/kernel/setup.js +644 -0
- package/kernel/state.js +59 -0
- package/kernel/steer.js +27 -0
- package/kernel/sync.js +140 -0
- package/kernel/te.js +122 -0
- package/kernel/worktree.js +868 -0
- package/locale/en.json +14 -0
- package/locale/zh.json +14 -0
- package/package.json +63 -4
- package/packs/ai-coding/agents/business-analyst.md +90 -0
- package/packs/ai-coding/agents/code-reviewer.md +156 -0
- package/packs/ai-coding/agents/developer.md +147 -0
- package/packs/ai-coding/agents/project-manager.md +190 -0
- package/packs/ai-coding/agents/readiness-reviewer.md +123 -0
- package/packs/ai-coding/agents/solution-architect.md +122 -0
- package/packs/ai-coding/agents/test-engineer.md +230 -0
- package/packs/ai-coding/assets/scripts/check_codegraph.py +215 -0
- package/packs/ai-coding/assets/scripts/codebase_guide_init.py +330 -0
- package/packs/ai-coding/assets/scripts/env_auto.py +612 -0
- package/packs/ai-coding/assets/scripts/harness.py +38 -0
- package/packs/ai-coding/assets/scripts/harness_init.py +193 -0
- package/packs/ai-coding/assets/scripts/lib.py +1011 -0
- package/packs/ai-coding/assets/scripts/run_field.py +295 -0
- package/packs/ai-coding/assets/scripts/spec_lint.py +247 -0
- package/packs/ai-coding/assets/scripts/update_board.py +524 -0
- package/packs/ai-coding/assets/scripts/verify.py +184 -0
- package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/CODE_STANDARDS.tmpl +44 -0
- package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/app-CLAUDE.tmpl +34 -0
- package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/build.tmpl +8 -0
- package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/module-CLAUDE.tmpl +42 -0
- package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/root-CLAUDE.tmpl +41 -0
- package/packs/ai-coding/assets/templates/java/maven/CODE_STANDARDS.tmpl +44 -0
- package/packs/ai-coding/assets/templates/java/maven/build.tmpl +9 -0
- package/packs/ai-coding/assets/templates/java/maven/root-CLAUDE.tmpl +38 -0
- package/packs/ai-coding/assets/templates/java/maven-multimodule/CODE_STANDARDS.tmpl +44 -0
- package/packs/ai-coding/assets/templates/java/maven-multimodule/build.tmpl +9 -0
- package/packs/ai-coding/assets/templates/java/maven-multimodule/module-CLAUDE.tmpl +40 -0
- package/packs/ai-coding/assets/templates/java/maven-multimodule/root-CLAUDE.tmpl +38 -0
- package/packs/ai-coding/assets/templates/javascript/mobile-app/CODE_STANDARDS.tmpl +51 -0
- package/packs/ai-coding/assets/templates/javascript/mobile-app/build.tmpl +8 -0
- package/packs/ai-coding/assets/templates/javascript/mobile-app/root-CLAUDE.tmpl +36 -0
- package/packs/ai-coding/assets/templates/javascript/uniapp/CODE_STANDARDS.tmpl +69 -0
- package/packs/ai-coding/assets/templates/javascript/uniapp/build.tmpl +8 -0
- package/packs/ai-coding/assets/templates/javascript/uniapp/root-CLAUDE.tmpl +56 -0
- package/packs/ai-coding/assets/templates/javascript/vue-multimodule/CODE_STANDARDS.tmpl +51 -0
- package/packs/ai-coding/assets/templates/javascript/vue-multimodule/app-CLAUDE.tmpl +36 -0
- package/packs/ai-coding/assets/templates/javascript/vue-multimodule/build.tmpl +8 -0
- package/packs/ai-coding/assets/templates/javascript/vue-multimodule/root-CLAUDE.tmpl +34 -0
- package/packs/ai-coding/flows/_router.yml +14 -0
- package/packs/ai-coding/flows/bugfix.yml +37 -0
- package/packs/ai-coding/flows/fix.yml +44 -0
- package/packs/ai-coding/flows/init.yml +83 -0
- package/packs/ai-coding/flows/new.yml +29 -0
- package/packs/ai-coding/flows/quick.yml +40 -0
- package/packs/ai-coding/flows/refactor.yml +50 -0
- package/packs/ai-coding/flows/standard.yml +49 -0
- package/packs/ai-coding/rules/code-standards.md +30 -0
- package/packs/ai-coding/rules/core.md +83 -0
- package/packs/ai-coding/templates/bugfix.md +29 -0
- package/packs/ai-coding/templates/memory-entry.md +46 -0
- package/packs/ai-coding/templates/proposal.md +47 -0
- package/packs/ai-coding/templates/spec-template.md +34 -0
- package/screenshots.json +5 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# .harness/scripts/harness_init.py
|
|
3
|
+
# Harness 脚手架:探测子工程结构,生成初始化计划 JSON。
|
|
4
|
+
# 用法:
|
|
5
|
+
# python3 harness_init.py --detect # 探测并把计划写入 .harness/.logs/workflow/harness-init-plan.json(AI 读文件)
|
|
6
|
+
# python3 harness_init.py --json # 计划打到 stdout,不落盘
|
|
7
|
+
# python3 harness_init.py # 交互展示
|
|
8
|
+
import json, sys
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
import lib
|
|
11
|
+
|
|
12
|
+
TEMPLATES_DIR = lib.repo_root() / ".harness" / "templates"
|
|
13
|
+
PLAN_PATH = Path(".harness") / ".logs" / "workflow" / "harness-init-plan.json"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def get_template_dir(sp_type: str) -> str:
|
|
17
|
+
return {
|
|
18
|
+
"maven-multimodule": "java/maven-multimodule",
|
|
19
|
+
"maven": "java/maven",
|
|
20
|
+
"vue-multimodule": "javascript/vue-multimodule",
|
|
21
|
+
"mobile-app": "javascript/mobile-app",
|
|
22
|
+
"uniapp": "javascript/uniapp",
|
|
23
|
+
"dotnet": "dotnet/dotnet-multimodule",
|
|
24
|
+
"dotnet-multimodule": "dotnet/dotnet-multimodule",
|
|
25
|
+
}.get(sp_type, "")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def list_frontend_apps(path: Path):
|
|
29
|
+
apps_dir = path / "apps"
|
|
30
|
+
if not apps_dir.is_dir():
|
|
31
|
+
return []
|
|
32
|
+
out = []
|
|
33
|
+
for d in sorted(apps_dir.iterdir()):
|
|
34
|
+
if not d.is_dir() or d.name.startswith(".") or d.name in ("node_modules", "target", "dist", "build"):
|
|
35
|
+
continue
|
|
36
|
+
if list(d.glob("*.vue")) or (d / "store").is_dir() or (d / "views").is_dir() or (d / "router").is_dir():
|
|
37
|
+
out.append({"name": d.name, "parent": str(apps_dir), "path": str(d)})
|
|
38
|
+
return out
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def list_maven_modules(path: Path):
|
|
42
|
+
"""枚举 Maven 模块:顶层 pom+src 目录 + 结构识别的扁平容器目录下的模块子目录(含去重)。
|
|
43
|
+
|
|
44
|
+
容器识别为结构探测(lib.is_maven_container):有聚合 pom.xml、自身无 src、存在带 src 的子目录。
|
|
45
|
+
顶层模块先枚举(同名优先),随后容器内的扁平子目录补入,path 保留嵌套段。
|
|
46
|
+
"""
|
|
47
|
+
out, seen = [], set()
|
|
48
|
+
containers = []
|
|
49
|
+
for d in sorted(path.iterdir()):
|
|
50
|
+
if not d.is_dir() or d.name.startswith("."):
|
|
51
|
+
continue
|
|
52
|
+
if (d / "pom.xml").is_file() and (d / "src").is_dir():
|
|
53
|
+
if d.name not in lib.MODULE_DIR_EXCLUDES:
|
|
54
|
+
out.append({"name": d.name, "parent": str(path), "path": str(d)})
|
|
55
|
+
seen.add(d.name)
|
|
56
|
+
elif lib.is_maven_container(d):
|
|
57
|
+
containers.append(d)
|
|
58
|
+
for child in containers:
|
|
59
|
+
for d in sorted(child.iterdir()):
|
|
60
|
+
if not (d.is_dir() and (d / "src").is_dir()):
|
|
61
|
+
continue
|
|
62
|
+
if d.name.startswith(".") or d.name in lib.MODULE_DIR_EXCLUDES or d.name in seen:
|
|
63
|
+
continue
|
|
64
|
+
out.append({"name": d.name, "parent": str(child), "path": str(d)})
|
|
65
|
+
return out
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def check_file(root: Path, rel: str) -> str:
|
|
69
|
+
return "EXISTS" if (root / rel).is_file() else "MISSING"
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def build_json_missing_keys(root: Path, rel: str, template: str) -> list:
|
|
73
|
+
"""已存在的 build.json 相对模板缺哪些键。
|
|
74
|
+
|
|
75
|
+
**只比键、不比 value**:值是工程事实(`start-ok` 要 Step 7b 靠真实运行补齐,
|
|
76
|
+
各工程的命令也各不相同),按值比对会把正常的差异报成「待修」。
|
|
77
|
+
|
|
78
|
+
没有这个函数时,已存在的 build.json 一律只判 EXISTS 就跳过——模板加了新字段
|
|
79
|
+
也传不到存量工程(build.json 是模板纯拷贝,没有 AI 分析环节可以「顺带想到」)。
|
|
80
|
+
"""
|
|
81
|
+
try:
|
|
82
|
+
tmpl = json.loads((root / ".harness" / "templates" / template).read_text(encoding="utf-8"))
|
|
83
|
+
cur = json.loads((root / rel / ".harness" / "build.json").read_text(encoding="utf-8"))
|
|
84
|
+
except (OSError, json.JSONDecodeError):
|
|
85
|
+
# 读不了 / 非法 JSON 不在这里报——交由 check_harness.py 的「存量 build.json 体检」响亮报错
|
|
86
|
+
return []
|
|
87
|
+
if not isinstance(tmpl, dict) or not isinstance(cur, dict):
|
|
88
|
+
return []
|
|
89
|
+
return [k for k in tmpl if k not in cur]
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def generate_plan(root: Path) -> dict:
|
|
93
|
+
subprojects = []
|
|
94
|
+
for name, path in lib.discover_service_dirs(root):
|
|
95
|
+
stype = lib.detect_service_type(path)
|
|
96
|
+
tdir = get_template_dir(stype)
|
|
97
|
+
if not tdir:
|
|
98
|
+
continue
|
|
99
|
+
rel = f"services/{name}"
|
|
100
|
+
sp = {
|
|
101
|
+
"name": name, "path": rel, "path_abs": str(path), "type": stype,
|
|
102
|
+
"role": lib.detect_service_role(path),
|
|
103
|
+
"template_dir": tdir,
|
|
104
|
+
# 键序 = 生成顺序(有依赖,勿打乱):先落盘 build.json 与 docs/CODE_STANDARDS.md,
|
|
105
|
+
# 最后才生成 CLAUDE.md —— 它是唯一要引用同批产物的文件(「参考文档」段列 CODE_STANDARDS.md),
|
|
106
|
+
# 先落盘会让子 Agent 读盘时看不到 docs/,据实写出「工程没有 docs 目录」。
|
|
107
|
+
"root_files": {
|
|
108
|
+
# missing_keys 让存量工程能被「补齐」而非只判 EXISTS 跳过(模板加字段的唯一传播路径)
|
|
109
|
+
".harness/build.json": {
|
|
110
|
+
"status": check_file(root, f"{rel}/.harness/build.json"),
|
|
111
|
+
"template": f"{tdir}/build.tmpl",
|
|
112
|
+
"missing_keys": build_json_missing_keys(root, rel, f"{tdir}/build.tmpl"),
|
|
113
|
+
},
|
|
114
|
+
"docs/CODE_STANDARDS.md": {"status": check_file(root, f"{rel}/docs/CODE_STANDARDS.md"), "template": f"{tdir}/CODE_STANDARDS.tmpl"},
|
|
115
|
+
"CLAUDE.md": {"status": check_file(root, f"{rel}/CLAUDE.md"), "template": f"{tdir}/root-CLAUDE.tmpl"},
|
|
116
|
+
},
|
|
117
|
+
"codegraph": "EXISTS" if (path / ".codegraph").is_dir() else "MISSING",
|
|
118
|
+
"modules": [],
|
|
119
|
+
}
|
|
120
|
+
# mobile-app(单应用 SPA)与 uniapp(uni-app 多端)都无 apps/ 子应用容器:
|
|
121
|
+
# 只生成根级 L1/L1.5/L2,modules 保持为空 —— 故此处不设分支。
|
|
122
|
+
if stype == "vue-multimodule":
|
|
123
|
+
sp["modules"] = [{"name": m["name"], "path": f"services/{name}/apps/{m['name']}",
|
|
124
|
+
"template": f"{tdir}/app-CLAUDE.tmpl",
|
|
125
|
+
"status": "EXISTS" if (Path(m["path"]) / "CLAUDE.md").is_file() else "MISSING"}
|
|
126
|
+
for m in list_frontend_apps(path)]
|
|
127
|
+
elif stype == "maven-multimodule":
|
|
128
|
+
sp["modules"] = [{"name": m["name"],
|
|
129
|
+
"path": f"services/{name}/{Path(m['parent']).relative_to(path) / m['name']}",
|
|
130
|
+
"template": f"{tdir}/module-CLAUDE.tmpl",
|
|
131
|
+
"status": "EXISTS" if (Path(m["path"]) / "CLAUDE.md").is_file() else "MISSING"}
|
|
132
|
+
for m in list_maven_modules(path)]
|
|
133
|
+
elif stype in ("dotnet", "dotnet-multimodule"):
|
|
134
|
+
# 后端项目 → module-CLAUDE.tmpl;前端子项目(SPA/Blazor WASM)→ app-CLAUDE.tmpl
|
|
135
|
+
sp["modules"] = [
|
|
136
|
+
{"name": m["name"], "path": f"services/{name}/{m['name']}",
|
|
137
|
+
"template": f"{tdir}/module-CLAUDE.tmpl",
|
|
138
|
+
"status": "EXISTS" if (Path(m["path"]) / "CLAUDE.md").is_file() else "MISSING"}
|
|
139
|
+
for m in lib.list_dotnet_projects(path)
|
|
140
|
+
] + [
|
|
141
|
+
{"name": m["name"], "path": f"services/{name}/{m['name']}",
|
|
142
|
+
"template": f"{tdir}/app-CLAUDE.tmpl",
|
|
143
|
+
"status": "EXISTS" if (Path(m["path"]) / "CLAUDE.md").is_file() else "MISSING"}
|
|
144
|
+
for m in lib.list_frontend_projects(path)
|
|
145
|
+
]
|
|
146
|
+
subprojects.append(sp)
|
|
147
|
+
return {"subprojects": subprojects}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def main():
|
|
151
|
+
mode = sys.argv[1] if len(sys.argv) > 1 else ""
|
|
152
|
+
root = lib.repo_root()
|
|
153
|
+
# 初始化即安装 pre-commit 门禁(幂等):任意分支拦子模块指针的改/删,集成分支另拦交付物
|
|
154
|
+
lib.git(["config", "core.hooksPath", str(root / ".harness" / "git-hooks")], cwd=root)
|
|
155
|
+
plan = generate_plan(root)
|
|
156
|
+
if mode in ("--detect", "--json"):
|
|
157
|
+
payload = json.dumps(plan, ensure_ascii=False, indent=2)
|
|
158
|
+
if mode == "--detect":
|
|
159
|
+
# 计划落盘供 AI 读取(大工程模块多,stdout 输出不便复核);stdout 只留一行摘要。
|
|
160
|
+
out = root / PLAN_PATH
|
|
161
|
+
out.parent.mkdir(parents=True, exist_ok=True)
|
|
162
|
+
out.write_text(payload + "\n", encoding="utf-8")
|
|
163
|
+
n_sp = len(plan["subprojects"])
|
|
164
|
+
n_mod = sum(len(sp["modules"]) for sp in plan["subprojects"])
|
|
165
|
+
print(f"探测完成:{n_sp} 个子工程 / {n_mod} 个模块 → {PLAN_PATH.as_posix()}")
|
|
166
|
+
else:
|
|
167
|
+
print(payload)
|
|
168
|
+
return 0
|
|
169
|
+
if not (root / "services").is_dir():
|
|
170
|
+
print("⚠ 未检测到 services/ 目录,工程可能还未接入子工程。")
|
|
171
|
+
return 1
|
|
172
|
+
stale = 0
|
|
173
|
+
for sp in plan["subprojects"]:
|
|
174
|
+
print(f"━━━ {sp['name']} ({sp['type']}) ━━━")
|
|
175
|
+
print(f" 模板: .harness/templates/{sp['template_dir']}/")
|
|
176
|
+
for fk, fi in sp["root_files"].items():
|
|
177
|
+
mk = fi.get("missing_keys") or []
|
|
178
|
+
if mk:
|
|
179
|
+
# 只印 EXISTS 会让人以为「没事可做」——真实情况是老字段没跟上模板
|
|
180
|
+
print(f" ♻️ {fk}: EXISTS → 补 {len(mk)} 个缺失字段 ({', '.join(mk)})")
|
|
181
|
+
stale += 1
|
|
182
|
+
else:
|
|
183
|
+
print(f" {'✅' if fi['status']=='EXISTS' else '⬜'} {fk}: {fi['status']}")
|
|
184
|
+
print(f" {'✅' if sp['codegraph']=='EXISTS' else '⬜'} codegraph: {sp['codegraph']}")
|
|
185
|
+
print(f" 📦 模块 ({len(sp['modules'])})")
|
|
186
|
+
if stale:
|
|
187
|
+
print(f"\n♻️ {stale} 个文件需**补齐**(只加缺失的键,不覆盖已有值)。")
|
|
188
|
+
print("请确认以上计划,确认后在 Claude Code 中执行 /harness-init 开始生成。")
|
|
189
|
+
return 0
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
if __name__ == "__main__":
|
|
193
|
+
sys.exit(main())
|