dsh-harness-kit 0.1.5 → 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.
- package/README.md +30 -15
- package/README.zh-CN.md +29 -18
- package/client.js +108 -11
- package/docs/DETAIL.en.md +30 -10
- package/docs/DETAIL.md +15 -5
- package/kernel/advance.js +3 -3
- package/kernel/bindings.js +11 -6
- package/kernel/commands.js +257 -20
- package/kernel/local-files.js +175 -0
- package/kernel/metrics.js +280 -0
- package/kernel/panel.js +141 -7
- package/kernel/paths.js +62 -1
- package/kernel/setup.js +20 -19
- package/kernel/te.js +4 -4
- package/kernel/worktree.js +164 -20
- package/package.json +1 -1
- package/packs/ai-coding/agents/business-analyst.md +4 -4
- package/packs/ai-coding/agents/code-reviewer.md +6 -6
- package/packs/ai-coding/agents/developer.md +5 -5
- package/packs/ai-coding/agents/solution-architect.md +2 -2
- package/packs/ai-coding/assets/scripts/codebase_guide_init.py +70 -48
- package/packs/ai-coding/assets/scripts/harness_init.py +30 -11
- package/packs/ai-coding/assets/scripts/te_lease.py +106 -0
- package/packs/ai-coding/assets/scripts/update_board.py +30 -0
- package/packs/ai-coding/assets/scripts/verify.py +3 -3
- package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/{app-CLAUDE.tmpl → app-AGENTS.tmpl} +5 -5
- package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/{module-CLAUDE.tmpl → module-AGENTS.tmpl} +5 -5
- package/packs/ai-coding/assets/templates/dotnet/dotnet-multimodule/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +3 -3
- package/packs/ai-coding/assets/templates/java/maven/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +3 -3
- package/packs/ai-coding/assets/templates/java/maven-multimodule/{module-CLAUDE.tmpl → module-AGENTS.tmpl} +5 -5
- package/packs/ai-coding/assets/templates/java/maven-multimodule/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +3 -3
- package/packs/ai-coding/assets/templates/javascript/mobile-app/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +3 -3
- package/packs/ai-coding/assets/templates/javascript/uniapp/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +3 -3
- package/packs/ai-coding/assets/templates/javascript/vue-multimodule/{app-CLAUDE.tmpl → app-AGENTS.tmpl} +4 -4
- package/packs/ai-coding/assets/templates/javascript/vue-multimodule/{root-CLAUDE.tmpl → root-AGENTS.tmpl} +3 -3
- package/packs/ai-coding/flows/init.yml +7 -7
|
@@ -5,8 +5,24 @@ import sys
|
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
import lib
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
INSTRUCTION_NAMES = ("AGENTS.md", "CLAUDE.md")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def existing_instruction(path: Path):
|
|
12
|
+
"""已有入口文件:AGENTS.md 优先,兼容旧 CLAUDE.md;没有返回 None。"""
|
|
13
|
+
for name in INSTRUCTION_NAMES:
|
|
14
|
+
candidate = path / name
|
|
15
|
+
if candidate.is_file():
|
|
16
|
+
return candidate
|
|
17
|
+
return None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def instruction_target(path: Path) -> Path:
|
|
21
|
+
"""新生成时只写 AGENTS.md(不生成 CLAUDE.md)。"""
|
|
22
|
+
return path / "AGENTS.md"
|
|
23
|
+
|
|
24
|
+
# 模块 / App 级 AGENTS.md 的**机器可读元信息行**:行内加粗键值 `- **键**:值`,**不是** `### 标题`。
|
|
25
|
+
# 这是 `.harness/templates/*/{module,app}-AGENTS.tmpl`(内容按 AGENTS.md 生成)与本检查器之间的**唯一契约**:
|
|
10
26
|
# 检查器按这些键做子串匹配,模板必须原样产出对应行 —— 模板若教标题形态,
|
|
11
27
|
# 「严格照模板生成」的文档必然报 WARN(历史上前端 41 个 App 全中)。
|
|
12
28
|
# `tests/harness/test_codebase_guide_init.py` 把两边钉死,改这里必须同步改模板。
|
|
@@ -14,7 +30,7 @@ META_KEYS_BACKEND_MODULE = ("路径", "domain") # 后端模块
|
|
|
14
30
|
META_KEYS_FRONTEND = ("职责", "domain") # 前端 App / fullstack 前端子项目
|
|
15
31
|
META_KEYS_DOMAIN_ONLY = ("domain",) # .NET 项目 / fullstack 后端项目
|
|
16
32
|
|
|
17
|
-
FRONTEND_SKELETON = """#
|
|
33
|
+
FRONTEND_SKELETON = """# AGENTS.md — 前端项目入口
|
|
18
34
|
|
|
19
35
|
## Build
|
|
20
36
|
|
|
@@ -75,7 +91,7 @@ COMPONENT_SKELETON = """# component — 共享组件库
|
|
|
75
91
|
<!-- TODO: 人工补充 -->
|
|
76
92
|
"""
|
|
77
93
|
|
|
78
|
-
FULLSTACK_SKELETON = """#
|
|
94
|
+
FULLSTACK_SKELETON = """# AGENTS.md — 前后端一体工程入口
|
|
79
95
|
|
|
80
96
|
## Build
|
|
81
97
|
|
|
@@ -145,9 +161,9 @@ def backend_module_dirs(backend_path: Path) -> list:
|
|
|
145
161
|
|
|
146
162
|
|
|
147
163
|
def check_backend(backend: Path, passed: int, failed: int, warned: int):
|
|
148
|
-
"""后端根 +
|
|
149
|
-
bref = backend
|
|
150
|
-
if bref
|
|
164
|
+
"""后端根 + 模块入口检查(AGENTS.md 优先,兼容 CLAUDE.md)。返回 (passed, failed, warned)。"""
|
|
165
|
+
bref = existing_instruction(backend)
|
|
166
|
+
if bref is not None:
|
|
151
167
|
t = bref.read_text(encoding="utf-8", errors="ignore")
|
|
152
168
|
for s in ("Build", "项目概述", "关键框架模式", "关键约定", "模块发现", "参考文档"):
|
|
153
169
|
if f"## {s}" in t:
|
|
@@ -155,15 +171,15 @@ def check_backend(backend: Path, passed: int, failed: int, warned: int):
|
|
|
155
171
|
else:
|
|
156
172
|
print(f" ⚠️ 段 [{s}] 缺失"); warned += 1
|
|
157
173
|
else:
|
|
158
|
-
print(f" ❌ {
|
|
174
|
+
print(f" ❌ {backend/'AGENTS.md'} 或 CLAUDE.md 都不存在!"); failed += 1
|
|
159
175
|
|
|
160
176
|
stype = lib.detect_service_type(backend)
|
|
161
177
|
if stype in ("dotnet", "dotnet-multimodule"):
|
|
162
|
-
# .NET 后端:模块 = 项目级
|
|
178
|
+
# .NET 后端:模块 = 项目级 AGENTS.md(module-AGENTS.tmpl 要求 domain 标签)
|
|
163
179
|
for m in lib.list_dotnet_projects(backend):
|
|
164
|
-
cf = Path(m["path"])
|
|
165
|
-
if
|
|
166
|
-
print(f" ❌ [{m['name']}] CLAUDE.md
|
|
180
|
+
cf = existing_instruction(Path(m["path"]))
|
|
181
|
+
if cf is None:
|
|
182
|
+
print(f" ❌ [{m['name']}] AGENTS.md / CLAUDE.md 都不存在!"); failed += 1
|
|
167
183
|
continue
|
|
168
184
|
t = cf.read_text(encoding="utf-8", errors="ignore")
|
|
169
185
|
ok = all(f"**{k}**" in t for k in META_KEYS_DOMAIN_ONLY)
|
|
@@ -176,9 +192,9 @@ def check_backend(backend: Path, passed: int, failed: int, warned: int):
|
|
|
176
192
|
for d in sorted(mod_dir.iterdir()):
|
|
177
193
|
if not d.is_dir():
|
|
178
194
|
continue
|
|
179
|
-
cf = d
|
|
180
|
-
if
|
|
181
|
-
print(f" ❌ [{d.name}] CLAUDE.md
|
|
195
|
+
cf = existing_instruction(d)
|
|
196
|
+
if cf is None:
|
|
197
|
+
print(f" ❌ [{d.name}] AGENTS.md / CLAUDE.md 都不存在!"); failed += 1
|
|
182
198
|
continue
|
|
183
199
|
t = cf.read_text(encoding="utf-8", errors="ignore")
|
|
184
200
|
ok = all(f"**{k}**" in t for k in META_KEYS_BACKEND_MODULE)
|
|
@@ -189,13 +205,13 @@ def check_backend(backend: Path, passed: int, failed: int, warned: int):
|
|
|
189
205
|
|
|
190
206
|
|
|
191
207
|
def check_frontend(frontend: Path, check_only: bool, passed: int, failed: int, warned: int, generated: int):
|
|
192
|
-
"""前端根 + apps + component CLAUDE.md
|
|
208
|
+
"""前端根 + apps + component 入口检查(AGENTS.md 优先,兼容 CLAUDE.md)(无 apps/ 布局则不要求 component)。返回 4 元组。
|
|
193
209
|
|
|
194
210
|
微前端多 App(role=frontend)与单应用形态(role=mobile:移动端 H5 / uni-app / 桌面 SPA)
|
|
195
|
-
同用此检查:apps/ 存在才检查 App 级与 component 骨架,不存在则只查根
|
|
211
|
+
同用此检查:apps/ 存在才检查 App 级与 component 骨架,不存在则只查根 AGENTS.md。
|
|
196
212
|
"""
|
|
197
|
-
fref = frontend
|
|
198
|
-
if fref
|
|
213
|
+
fref = existing_instruction(frontend)
|
|
214
|
+
if fref is not None:
|
|
199
215
|
t = fref.read_text(encoding="utf-8", errors="ignore")
|
|
200
216
|
for s in ("Build", "项目概述", "目录结构", "关键框架模式", "关键约定", "参考文档"):
|
|
201
217
|
if f"## {s}" in t:
|
|
@@ -203,10 +219,11 @@ def check_frontend(frontend: Path, check_only: bool, passed: int, failed: int, w
|
|
|
203
219
|
else:
|
|
204
220
|
print(f" ⚠️ 段 [{s}] 缺失"); warned += 1
|
|
205
221
|
else:
|
|
206
|
-
print(f" ❌ {
|
|
222
|
+
print(f" ❌ {frontend/'AGENTS.md'} 或 CLAUDE.md 都不存在!"); failed += 1
|
|
207
223
|
if not check_only:
|
|
208
|
-
|
|
209
|
-
|
|
224
|
+
target = instruction_target(frontend)
|
|
225
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
226
|
+
target.write_text(FRONTEND_SKELETON, encoding="utf-8")
|
|
210
227
|
print(" 🔧 已生成骨架"); generated += 1
|
|
211
228
|
|
|
212
229
|
# 前端 apps(无 apps/ 布局 → 不要求 app/component 骨架)
|
|
@@ -215,11 +232,12 @@ def check_frontend(frontend: Path, check_only: bool, passed: int, failed: int, w
|
|
|
215
232
|
for d in sorted(apps_dir.iterdir()):
|
|
216
233
|
if not d.is_dir() or d.name == "component":
|
|
217
234
|
continue
|
|
218
|
-
cf = d
|
|
219
|
-
if
|
|
220
|
-
print(f" ❌ [{d.name}] CLAUDE.md
|
|
235
|
+
cf = existing_instruction(d)
|
|
236
|
+
if cf is None:
|
|
237
|
+
print(f" ❌ [{d.name}] AGENTS.md / CLAUDE.md 都不存在!"); failed += 1
|
|
221
238
|
if not check_only:
|
|
222
|
-
|
|
239
|
+
target = instruction_target(d)
|
|
240
|
+
target.write_text(APP_SKELETON.format(name=d.name), encoding="utf-8")
|
|
223
241
|
print(" 🔧 已生成骨架"); generated += 1
|
|
224
242
|
else:
|
|
225
243
|
t = cf.read_text(encoding="utf-8", errors="ignore")
|
|
@@ -227,14 +245,15 @@ def check_frontend(frontend: Path, check_only: bool, passed: int, failed: int, w
|
|
|
227
245
|
passed += ok; warned += (not ok)
|
|
228
246
|
|
|
229
247
|
# component(共享组件库,仅 apps/ 布局下要求)
|
|
230
|
-
comp = apps_dir / "component"
|
|
231
|
-
if comp
|
|
248
|
+
comp = existing_instruction(apps_dir / "component")
|
|
249
|
+
if comp is not None:
|
|
232
250
|
passed += 1
|
|
233
251
|
else:
|
|
234
252
|
failed += 1
|
|
235
253
|
if not check_only:
|
|
236
|
-
|
|
237
|
-
|
|
254
|
+
target = instruction_target(apps_dir / "component")
|
|
255
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
256
|
+
target.write_text(COMPONENT_SKELETON, encoding="utf-8")
|
|
238
257
|
print(" 🔧 已生成 component 骨架"); generated += 1
|
|
239
258
|
return passed, failed, warned, generated
|
|
240
259
|
|
|
@@ -243,9 +262,9 @@ FULLSTACK_SECTIONS = ("Build", "项目概述", "目录结构", "关键框架模
|
|
|
243
262
|
|
|
244
263
|
|
|
245
264
|
def check_fullstack(fs: Path, check_only: bool, passed: int, failed: int, warned: int, generated: int):
|
|
246
|
-
"""fullstack 服务检查:根 CLAUDE.md 覆盖并集章节(后端+前端),后端项目 + 前端子项目文档齐全。返回 4 元组。"""
|
|
247
|
-
ref = fs
|
|
248
|
-
if ref
|
|
265
|
+
"""fullstack 服务检查:根 AGENTS.md/CLAUDE.md 覆盖并集章节(后端+前端),后端项目 + 前端子项目文档齐全。返回 4 元组。"""
|
|
266
|
+
ref = existing_instruction(fs)
|
|
267
|
+
if ref is not None:
|
|
249
268
|
t = ref.read_text(encoding="utf-8", errors="ignore")
|
|
250
269
|
for s in FULLSTACK_SECTIONS:
|
|
251
270
|
if f"## {s}" in t:
|
|
@@ -253,20 +272,22 @@ def check_fullstack(fs: Path, check_only: bool, passed: int, failed: int, warned
|
|
|
253
272
|
else:
|
|
254
273
|
print(f" ⚠️ 段 [{s}] 缺失"); warned += 1
|
|
255
274
|
else:
|
|
256
|
-
print(f" ❌ {
|
|
275
|
+
print(f" ❌ {fs/'AGENTS.md'} 或 CLAUDE.md 都不存在!"); failed += 1
|
|
257
276
|
if not check_only:
|
|
258
|
-
|
|
259
|
-
|
|
277
|
+
target = instruction_target(fs)
|
|
278
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
279
|
+
target.write_text(FULLSTACK_SKELETON, encoding="utf-8")
|
|
260
280
|
print(" 🔧 已生成骨架"); generated += 1
|
|
261
281
|
|
|
262
|
-
# 后端项目(.NET 后端项目 → 项目级
|
|
282
|
+
# 后端项目(.NET 后端项目 → 项目级 AGENTS.md)
|
|
263
283
|
for m in lib.list_dotnet_projects(fs):
|
|
264
|
-
cf = Path(m["path"])
|
|
265
|
-
if
|
|
266
|
-
print(f" ❌ [{m['name']}] CLAUDE.md
|
|
284
|
+
cf = existing_instruction(Path(m["path"]))
|
|
285
|
+
if cf is None:
|
|
286
|
+
print(f" ❌ [{m['name']}] AGENTS.md / CLAUDE.md 都不存在!"); failed += 1
|
|
267
287
|
if not check_only:
|
|
268
|
-
|
|
269
|
-
|
|
288
|
+
target = instruction_target(Path(m["path"]))
|
|
289
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
290
|
+
target.write_text(MODULE_SKELETON.format(name=m["name"]), encoding="utf-8")
|
|
270
291
|
print(" 🔧 已生成骨架"); generated += 1
|
|
271
292
|
continue
|
|
272
293
|
t = cf.read_text(encoding="utf-8", errors="ignore")
|
|
@@ -275,14 +296,15 @@ def check_fullstack(fs: Path, check_only: bool, passed: int, failed: int, warned
|
|
|
275
296
|
if not ok:
|
|
276
297
|
print(f" ⚠️ [{m['name']}] 缺必需段")
|
|
277
298
|
|
|
278
|
-
# 前端子项目(SPA / Blazor WASM → app 级
|
|
299
|
+
# 前端子项目(SPA / Blazor WASM → app 级 AGENTS.md)
|
|
279
300
|
for m in lib.list_frontend_projects(fs):
|
|
280
|
-
cf = Path(m["path"])
|
|
281
|
-
if
|
|
282
|
-
print(f" ❌ [{m['name']}] CLAUDE.md
|
|
301
|
+
cf = existing_instruction(Path(m["path"]))
|
|
302
|
+
if cf is None:
|
|
303
|
+
print(f" ❌ [{m['name']}] AGENTS.md / CLAUDE.md 都不存在!"); failed += 1
|
|
283
304
|
if not check_only:
|
|
284
|
-
|
|
285
|
-
|
|
305
|
+
target = instruction_target(Path(m["path"]))
|
|
306
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
307
|
+
target.write_text(APP_SKELETON.format(name=m["name"]), encoding="utf-8")
|
|
286
308
|
print(" 🔧 已生成骨架"); generated += 1
|
|
287
309
|
continue
|
|
288
310
|
t = cf.read_text(encoding="utf-8", errors="ignore")
|
|
@@ -11,6 +11,16 @@ import lib
|
|
|
11
11
|
|
|
12
12
|
TEMPLATES_DIR = lib.repo_root() / ".harness" / "templates"
|
|
13
13
|
PLAN_PATH = Path(".harness") / ".logs" / "workflow" / "harness-init-plan.json"
|
|
14
|
+
INSTRUCTION_NAMES = ("AGENTS.md", "CLAUDE.md")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def instruction_file(path: Path):
|
|
18
|
+
"""返回子工程/模块已有的入口文件(AGENTS 优先),没有则 None。"""
|
|
19
|
+
for name in INSTRUCTION_NAMES:
|
|
20
|
+
candidate = path / name
|
|
21
|
+
if candidate.is_file():
|
|
22
|
+
return candidate
|
|
23
|
+
return None
|
|
14
24
|
|
|
15
25
|
|
|
16
26
|
def get_template_dir(sp_type: str) -> str:
|
|
@@ -25,6 +35,15 @@ def get_template_dir(sp_type: str) -> str:
|
|
|
25
35
|
}.get(sp_type, "")
|
|
26
36
|
|
|
27
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
|
+
|
|
28
47
|
def list_frontend_apps(path: Path):
|
|
29
48
|
apps_dir = path / "apps"
|
|
30
49
|
if not apps_dir.is_dir():
|
|
@@ -102,7 +121,7 @@ def generate_plan(root: Path) -> dict:
|
|
|
102
121
|
"role": lib.detect_service_role(path),
|
|
103
122
|
"template_dir": tdir,
|
|
104
123
|
# 键序 = 生成顺序(有依赖,勿打乱):先落盘 build.json 与 docs/CODE_STANDARDS.md,
|
|
105
|
-
# 最后才生成
|
|
124
|
+
# 最后才生成 AGENTS.md —— 它是唯一要引用同批产物的文件(「参考文档」段列 CODE_STANDARDS.md),
|
|
106
125
|
# 先落盘会让子 Agent 读盘时看不到 docs/,据实写出「工程没有 docs 目录」。
|
|
107
126
|
"root_files": {
|
|
108
127
|
# missing_keys 让存量工程能被「补齐」而非只判 EXISTS 跳过(模板加字段的唯一传播路径)
|
|
@@ -112,7 +131,7 @@ def generate_plan(root: Path) -> dict:
|
|
|
112
131
|
"missing_keys": build_json_missing_keys(root, rel, f"{tdir}/build.tmpl"),
|
|
113
132
|
},
|
|
114
133
|
"docs/CODE_STANDARDS.md": {"status": check_file(root, f"{rel}/docs/CODE_STANDARDS.md"), "template": f"{tdir}/CODE_STANDARDS.tmpl"},
|
|
115
|
-
"
|
|
134
|
+
"AGENTS.md": {"status": "EXISTS" if instruction_file(path) else "MISSING", "template": instruction_template(tdir, "root")},
|
|
116
135
|
},
|
|
117
136
|
"codegraph": "EXISTS" if (path / ".codegraph").is_dir() else "MISSING",
|
|
118
137
|
"modules": [],
|
|
@@ -121,26 +140,26 @@ def generate_plan(root: Path) -> dict:
|
|
|
121
140
|
# 只生成根级 L1/L1.5/L2,modules 保持为空 —— 故此处不设分支。
|
|
122
141
|
if stype == "vue-multimodule":
|
|
123
142
|
sp["modules"] = [{"name": m["name"], "path": f"services/{name}/apps/{m['name']}",
|
|
124
|
-
"template":
|
|
125
|
-
"status": "EXISTS" if (Path(m["path"])
|
|
143
|
+
"template": instruction_template(tdir, "app"),
|
|
144
|
+
"status": "EXISTS" if instruction_file(Path(m["path"])) else "MISSING"}
|
|
126
145
|
for m in list_frontend_apps(path)]
|
|
127
146
|
elif stype == "maven-multimodule":
|
|
128
147
|
sp["modules"] = [{"name": m["name"],
|
|
129
148
|
"path": f"services/{name}/{Path(m['parent']).relative_to(path) / m['name']}",
|
|
130
|
-
"template":
|
|
131
|
-
"status": "EXISTS" if (Path(m["path"])
|
|
149
|
+
"template": instruction_template(tdir, "module"),
|
|
150
|
+
"status": "EXISTS" if instruction_file(Path(m["path"])) else "MISSING"}
|
|
132
151
|
for m in list_maven_modules(path)]
|
|
133
152
|
elif stype in ("dotnet", "dotnet-multimodule"):
|
|
134
|
-
# 后端项目 → module-
|
|
153
|
+
# 后端项目 → module-AGENTS.tmpl;前端子项目(SPA/Blazor WASM)→ app-AGENTS.tmpl
|
|
135
154
|
sp["modules"] = [
|
|
136
155
|
{"name": m["name"], "path": f"services/{name}/{m['name']}",
|
|
137
|
-
"template":
|
|
138
|
-
"status": "EXISTS" if (Path(m["path"])
|
|
156
|
+
"template": instruction_template(tdir, "module"),
|
|
157
|
+
"status": "EXISTS" if instruction_file(Path(m["path"])) else "MISSING"}
|
|
139
158
|
for m in lib.list_dotnet_projects(path)
|
|
140
159
|
] + [
|
|
141
160
|
{"name": m["name"], "path": f"services/{name}/{m['name']}",
|
|
142
|
-
"template":
|
|
143
|
-
"status": "EXISTS" if (Path(m["path"])
|
|
161
|
+
"template": instruction_template(tdir, "app"),
|
|
162
|
+
"status": "EXISTS" if instruction_file(Path(m["path"])) else "MISSING"}
|
|
144
163
|
for m in lib.list_frontend_projects(path)
|
|
145
164
|
]
|
|
146
165
|
subprojects.append(sp)
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""TE environment lease helper for PM/scripts.
|
|
3
|
+
|
|
4
|
+
The slash command `/hk-te` is user-only. This script exposes the same serial
|
|
5
|
+
lease to a PM running bash, so a TE gate does not require a human just to take
|
|
6
|
+
the lock. It is a resource lock, not an approval.
|
|
7
|
+
|
|
8
|
+
Usage:
|
|
9
|
+
te_lease.py acquire <task>
|
|
10
|
+
te_lease.py release <task>
|
|
11
|
+
te_lease.py status
|
|
12
|
+
"""
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import json
|
|
16
|
+
import sys
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def env_path() -> Path:
|
|
21
|
+
return Path.cwd() / ".harness" / "local" / "test-env.json"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def legacy_env_path() -> Path:
|
|
25
|
+
return Path.cwd() / ".harness" / "tasks" / "test-env.json"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def read_env():
|
|
29
|
+
try:
|
|
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"))
|
|
32
|
+
except (OSError, json.JSONDecodeError):
|
|
33
|
+
data = {}
|
|
34
|
+
return {
|
|
35
|
+
"holder": data.get("holder") if isinstance(data.get("holder"), str) else None,
|
|
36
|
+
"since": data.get("since"),
|
|
37
|
+
"queue": data.get("queue") if isinstance(data.get("queue"), list) else [],
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def write_env(env):
|
|
42
|
+
path = env_path()
|
|
43
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
44
|
+
path.write_text(json.dumps(env, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def acquire(task: str):
|
|
48
|
+
env = read_env()
|
|
49
|
+
if env["holder"] == task:
|
|
50
|
+
return f"TE 环境已由本任务持有({task}),继续 TE 阶段"
|
|
51
|
+
if env["holder"]:
|
|
52
|
+
if task not in env["queue"]:
|
|
53
|
+
env["queue"].append(task)
|
|
54
|
+
write_env(env)
|
|
55
|
+
return f"TE 环境被 **{env['holder']}** 占用:本任务已排队(第 {env['queue'].index(task) + 1} 位)。暂停 TE 阶段、不要派发 TE Worker、不要起服务/连测试库"
|
|
56
|
+
env["holder"] = task
|
|
57
|
+
env["since"] = __import__("datetime").datetime.now().astimezone().isoformat(timespec="seconds")
|
|
58
|
+
write_env(env)
|
|
59
|
+
return f"TE 环境已授权给 **{task}**(TE 标 ✅ 后自动释放)"
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def release(task: str):
|
|
63
|
+
env = read_env()
|
|
64
|
+
if env["holder"] == task:
|
|
65
|
+
env["holder"] = None
|
|
66
|
+
env["since"] = None
|
|
67
|
+
write_env(env)
|
|
68
|
+
return "TE 环境已释放" + (f"(排队:{'、'.join(env['queue'])},轮询器将自动晋升队首)" if env["queue"] else "")
|
|
69
|
+
before = len(env["queue"])
|
|
70
|
+
env["queue"] = [t for t in env["queue"] if t != task]
|
|
71
|
+
write_env(env)
|
|
72
|
+
return "已退出 TE 排队" if len(env["queue"]) < before else "本任务未持有 TE 环境也不在排队中"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def status():
|
|
76
|
+
env = read_env()
|
|
77
|
+
if not env["holder"] and not env["queue"]:
|
|
78
|
+
return "TE 环境空闲"
|
|
79
|
+
text = f"TE 环境持有:{env['holder'] or '(无)'}"
|
|
80
|
+
if env["since"]:
|
|
81
|
+
text += f"({env['since'][:19].replace('T', ' ')} 起)"
|
|
82
|
+
if env["queue"]:
|
|
83
|
+
text += f";排队:{' → '.join(env['queue'])}"
|
|
84
|
+
return text
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def main(argv):
|
|
88
|
+
if len(argv) < 2:
|
|
89
|
+
print(__doc__.strip())
|
|
90
|
+
return 2
|
|
91
|
+
action = argv[1]
|
|
92
|
+
if action == "status":
|
|
93
|
+
print(status())
|
|
94
|
+
return 0
|
|
95
|
+
if action in ("acquire", "release"):
|
|
96
|
+
if len(argv) < 3:
|
|
97
|
+
print(f"usage: te_lease.py {action} <task>", file=sys.stderr)
|
|
98
|
+
return 2
|
|
99
|
+
print(acquire(argv[2]) if action == "acquire" else release(argv[2]))
|
|
100
|
+
return 0
|
|
101
|
+
print(f"unknown action: {action}", file=sys.stderr)
|
|
102
|
+
return 2
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
if __name__ == "__main__":
|
|
106
|
+
raise SystemExit(main(sys.argv))
|
|
@@ -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进度 | 分支 | 上次活动 | 续接提示 |",
|
|
@@ -60,9 +60,9 @@ def run_build(service_path, name: str):
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
def check_claude_lines(path: Path):
|
|
63
|
-
f = path / "CLAUDE.md"
|
|
64
|
-
if
|
|
65
|
-
print(f" ⚠️ 未找到 {
|
|
63
|
+
f = next((p for p in (path / "AGENTS.md", path / "CLAUDE.md") if p.is_file()), None)
|
|
64
|
+
if f is None:
|
|
65
|
+
print(f" ⚠️ 未找到 {path}/AGENTS.md 或 CLAUDE.md,建议各子工程维护自己的技术规范。")
|
|
66
66
|
return
|
|
67
67
|
lines = len(f.read_text(encoding="utf-8", errors="ignore").splitlines())
|
|
68
68
|
v = claude_lines_verdict(lines)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: .NET 前端子项目
|
|
3
|
-
target: services/{{SUB_PROJECT}}/{{PROJECT_NAME}}/
|
|
2
|
+
description: .NET 前端子项目 AGENTS.md 生成指令(SPA / Blazor WASM;支持 UI/<子前端>/ 聚合目录嵌套)
|
|
3
|
+
target: services/{{SUB_PROJECT}}/{{PROJECT_NAME}}/AGENTS.md
|
|
4
4
|
variables:
|
|
5
5
|
PROJECT_PATH: "前端子项目完整路径(含 UI 等聚合目录段)"
|
|
6
6
|
PROJECT_NAME: "前端子项目相对服务根的路径段(如 UI/login、ClientApp)"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
请分析 `{{PROJECT_PATH}}/` 下的代码,生成前端子项目级
|
|
9
|
+
请分析 `{{PROJECT_PATH}}/` 下的代码,生成前端子项目级 AGENTS.md。
|
|
10
10
|
|
|
11
11
|
## 必须包含的章节
|
|
12
12
|
|
|
@@ -25,10 +25,10 @@ variables:
|
|
|
25
25
|
<!-- 从 package.json 或 .csproj PackageReference 中提取关键依赖:UI 库、状态管理、API 客户端 -->
|
|
26
26
|
|
|
27
27
|
### 关键约定/易错点
|
|
28
|
-
<!-- 只写本项目实际存在且与根
|
|
28
|
+
<!-- 只写本项目实际存在且与根 AGENTS.md 不重复的内容:组件命名、状态管理模式、API 调用封装 -->
|
|
29
29
|
|
|
30
30
|
## 约束
|
|
31
31
|
- 每个章节必须有实际内容,不得输出 TODO、待补充、留空
|
|
32
32
|
- 只生成以上章节,不添加额外章节
|
|
33
33
|
- 元信息块置于文件开头,键名逐字照抄(`职责` / `domain`,区分大小写),供机器检索
|
|
34
|
-
- 不要添加整体
|
|
34
|
+
- 不要添加整体 AGENTS.md 文件头
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: .NET 项目级
|
|
3
|
-
target: services/{{SUB_PROJECT}}/{{PROJECT_NAME}}/
|
|
2
|
+
description: .NET 项目级 AGENTS.md 生成指令
|
|
3
|
+
target: services/{{SUB_PROJECT}}/{{PROJECT_NAME}}/AGENTS.md
|
|
4
4
|
variables:
|
|
5
5
|
PROJECT_PATH: "项目绝对路径"
|
|
6
6
|
PROJECT_NAME: "项目目录名"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
请分析 `{{PROJECT_PATH}}/` 下的代码,生成项目级
|
|
9
|
+
请分析 `{{PROJECT_PATH}}/` 下的代码,生成项目级 AGENTS.md。
|
|
10
10
|
|
|
11
11
|
## 必须包含的章节
|
|
12
12
|
|
|
@@ -33,10 +33,10 @@ variables:
|
|
|
33
33
|
从基类/接口和命名推断类型(Controller/Service/Repository/DbContext/Middleware/Model) -->
|
|
34
34
|
|
|
35
35
|
### 关键约定/易错点
|
|
36
|
-
<!-- 从本项目代码中归纳项目特有的约定和易错点:DI 注册方式、中间件顺序、DbContext 生命周期、异步方法命名、异常处理惯例等。只写本项目实际存在且与根
|
|
36
|
+
<!-- 从本项目代码中归纳项目特有的约定和易错点:DI 注册方式、中间件顺序、DbContext 生命周期、异步方法命名、异常处理惯例等。只写本项目实际存在且与根 AGENTS.md 不重复的内容 -->
|
|
37
37
|
|
|
38
38
|
## 约束
|
|
39
39
|
- 每个章节必须有实际内容,不得输出 TODO、待补充、留空
|
|
40
40
|
- 只生成以上章节,不添加额外章节
|
|
41
41
|
- 元信息块置于文件开头,键名逐字照抄(`domain`,区分大小写),供机器检索
|
|
42
|
-
- 不要添加整体
|
|
42
|
+
- 不要添加整体 AGENTS.md 文件头
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: .NET 多项目根
|
|
3
|
-
target: services/{{SUB_PROJECT}}/
|
|
2
|
+
description: .NET 多项目根 AGENTS.md 生成指令(含前后端同仓库场景)
|
|
3
|
+
target: services/{{SUB_PROJECT}}/AGENTS.md
|
|
4
4
|
variables:
|
|
5
5
|
SUB_PROJECT: "子工程目录名"
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
请分析 `services/{{SUB_PROJECT}}/` 下的工程结构(.sln 解决方案文件、项目目录布局、NuGet 配置),生成根级
|
|
8
|
+
请分析 `services/{{SUB_PROJECT}}/` 下的工程结构(.sln 解决方案文件、项目目录布局、NuGet 配置),生成根级 AGENTS.md。若工程同时包含前端子项目(SPA / Blazor WebAssembly),根文档需一并概述前后端结构。
|
|
9
9
|
|
|
10
10
|
## 必须包含的章节
|
|
11
11
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: 通用 Java Maven 单模块根
|
|
3
|
-
target: services/{{SUB_PROJECT}}/
|
|
2
|
+
description: 通用 Java Maven 单模块根 AGENTS.md 生成指令
|
|
3
|
+
target: services/{{SUB_PROJECT}}/AGENTS.md
|
|
4
4
|
variables:
|
|
5
5
|
SUB_PROJECT: "子工程目录名"
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
请分析 `services/{{SUB_PROJECT}}/` 下的工程结构(pom.xml、目录布局、构建配置),生成根级
|
|
8
|
+
请分析 `services/{{SUB_PROJECT}}/` 下的工程结构(pom.xml、目录布局、构建配置),生成根级 AGENTS.md。
|
|
9
9
|
|
|
10
10
|
## 必须包含的章节
|
|
11
11
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: 通用 Java Maven 多模块模块级
|
|
3
|
-
target: services/{{SUB_PROJECT}}/{{MODULE_NAME}}/
|
|
2
|
+
description: 通用 Java Maven 多模块模块级 AGENTS.md 生成指令
|
|
3
|
+
target: services/{{SUB_PROJECT}}/{{MODULE_NAME}}/AGENTS.md
|
|
4
4
|
variables:
|
|
5
5
|
MODULE_PATH: "模块绝对路径"
|
|
6
6
|
MODULE_NAME: "模块目录名"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
请分析 `{{MODULE_PATH}}/src/` 下的 Java 代码,生成模块级
|
|
9
|
+
请分析 `{{MODULE_PATH}}/src/` 下的 Java 代码,生成模块级 AGENTS.md。
|
|
10
10
|
|
|
11
11
|
## 必须包含的章节
|
|
12
12
|
|
|
@@ -31,10 +31,10 @@ variables:
|
|
|
31
31
|
从注解和类名推断类型(Controller/Service/Repository/Config/Model/Util) -->
|
|
32
32
|
|
|
33
33
|
### 关键约定/易错点
|
|
34
|
-
<!-- 从本模块代码中归纳模块特有的约定和易错点:依赖注入的特殊规则、事务边界、连接管理、异常处理惯例、参数校验模式等。只写本模块实际存在且与根
|
|
34
|
+
<!-- 从本模块代码中归纳模块特有的约定和易错点:依赖注入的特殊规则、事务边界、连接管理、异常处理惯例、参数校验模式等。只写本模块实际存在且与根 AGENTS.md 不重复的内容 -->
|
|
35
35
|
|
|
36
36
|
## 约束
|
|
37
37
|
- 每个章节必须有实际内容,不得输出 TODO、待补充、留空
|
|
38
38
|
- 只生成以上章节,不添加额外章节
|
|
39
39
|
- 元信息块置于文件开头,键名逐字照抄(`路径` / `domain`,区分大小写),供机器检索
|
|
40
|
-
- 不要添加整体
|
|
40
|
+
- 不要添加整体 AGENTS.md 文件头
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: 通用 Java Maven 多模块根
|
|
3
|
-
target: services/{{SUB_PROJECT}}/
|
|
2
|
+
description: 通用 Java Maven 多模块根 AGENTS.md 生成指令
|
|
3
|
+
target: services/{{SUB_PROJECT}}/AGENTS.md
|
|
4
4
|
variables:
|
|
5
5
|
SUB_PROJECT: "子工程目录名"
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
请分析 `services/{{SUB_PROJECT}}/` 下的工程结构(pom.xml、目录布局、构建配置),生成根级
|
|
8
|
+
请分析 `services/{{SUB_PROJECT}}/` 下的工程结构(pom.xml、目录布局、构建配置),生成根级 AGENTS.md。
|
|
9
9
|
|
|
10
10
|
## 必须包含的章节
|
|
11
11
|
|
package/packs/ai-coding/assets/templates/javascript/mobile-app/{root-CLAUDE.tmpl → root-AGENTS.tmpl}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: 通用单应用前端(移动端 H5 / 独立 SPA)根
|
|
3
|
-
target: services/{{SUB_PROJECT}}/
|
|
2
|
+
description: 通用单应用前端(移动端 H5 / 独立 SPA)根 AGENTS.md 生成指令
|
|
3
|
+
target: services/{{SUB_PROJECT}}/AGENTS.md
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
请分析 `services/{{SUB_PROJECT}}/` 下的工程结构(package.json、构建配置、目录布局),生成根级
|
|
6
|
+
请分析 `services/{{SUB_PROJECT}}/` 下的工程结构(package.json、构建配置、目录布局),生成根级 AGENTS.md。
|
|
7
7
|
|
|
8
8
|
> 本工程是**单应用 SPA**(无 `apps/` 子应用容器),不要按微前端/多 App 架构描述。
|
|
9
9
|
|
package/packs/ai-coding/assets/templates/javascript/uniapp/{root-CLAUDE.tmpl → root-AGENTS.tmpl}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: uni-app 多端工程根
|
|
3
|
-
target: services/{{SUB_PROJECT}}/
|
|
2
|
+
description: uni-app 多端工程根 AGENTS.md 生成指令
|
|
3
|
+
target: services/{{SUB_PROJECT}}/AGENTS.md
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
请分析 `services/{{SUB_PROJECT}}/` 下的工程结构,生成根级
|
|
6
|
+
请分析 `services/{{SUB_PROJECT}}/` 下的工程结构,生成根级 AGENTS.md。
|
|
7
7
|
|
|
8
8
|
> 本工程是 **uni-app 多端工程**(一套代码编译到 H5 / 小程序 / App),不是普通 Web H5 SPA,
|
|
9
9
|
> 不要按 `src/views` + `vue-router` + `rem/postcss-pxtorem` 的 Web 套路描述。先判定形态再动笔:
|