@hap-labs/human-agent-paradigm 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/CHANGELOG.md +21 -0
- package/LICENSE +21 -0
- package/README.md +60 -0
- package/README.zh-CN.md +52 -0
- package/assets/EN/CONFORMANCE_CHECKLIST.md +211 -0
- package/assets/EN/CONTRACT_TEMPLATE.md +241 -0
- package/assets/EN/DECISION_REQUEST_TEMPLATE.md +157 -0
- package/assets/EN/DELIVERY_REPORT_TEMPLATE.md +188 -0
- package/assets/EN/DERIVED_SPECIFICATION.md +607 -0
- package/assets/EN/HUMAN_AGENT_PARADIGM.md +390 -0
- package/assets/ZH_CN/CONFORMANCE_CHECKLIST.md +192 -0
- package/assets/ZH_CN/CONTRACT_TEMPLATE.md +216 -0
- package/assets/ZH_CN/DECISION_REQUEST_TEMPLATE.md +140 -0
- package/assets/ZH_CN/DELIVERY_REPORT_TEMPLATE.md +199 -0
- package/assets/ZH_CN/DERIVED_SPECIFICATION.md +497 -0
- package/assets/ZH_CN/HUMAN_AGENT_PARADIGM.md +285 -0
- package/package.json +38 -0
- package/scripts/python/repo_governance_check/__init__.py +3 -0
- package/scripts/python/repo_governance_check/__main__.py +6 -0
- package/scripts/python/repo_governance_check/checks.py +359 -0
- package/scripts/python/repo_governance_check/cli.py +115 -0
- package/scripts/python/repo_governance_check/config.py +33 -0
- package/scripts/python/repo_governance_check/governance_check_config.json +166 -0
- package/scripts/python/repo_governance_check/report.py +79 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""Render check results as JSON, Markdown, and console summaries."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from collections import Counter
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def summarize(findings):
|
|
8
|
+
by_rule = Counter(finding.rule_id for finding in findings)
|
|
9
|
+
return {
|
|
10
|
+
"total_findings": len(findings),
|
|
11
|
+
"findings_by_rule": dict(sorted(by_rule.items())),
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def result_payload(run_id, root, config_path, docs_dir, elapsed_seconds, findings):
|
|
16
|
+
return {
|
|
17
|
+
"run_id": run_id,
|
|
18
|
+
"root": str(root),
|
|
19
|
+
"docs_dir": str(docs_dir),
|
|
20
|
+
"config_path": str(config_path),
|
|
21
|
+
"elapsed_seconds": round(elapsed_seconds, 4),
|
|
22
|
+
"summary": summarize(findings),
|
|
23
|
+
"findings": [finding.to_dict() for finding in findings],
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def render_json(payload):
|
|
28
|
+
return json.dumps(payload, ensure_ascii=False, indent=2) + "\n"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def render_markdown(payload):
|
|
32
|
+
summary = payload["summary"]
|
|
33
|
+
lines = [
|
|
34
|
+
"# repo_governance_check 结构检查报告",
|
|
35
|
+
"",
|
|
36
|
+
"> 本报告仅表示结构检查结果,不构成对文档内容实质符合性的证明。",
|
|
37
|
+
"",
|
|
38
|
+
f"- Run ID: `{payload['run_id']}`",
|
|
39
|
+
f"- Root: `{payload['root']}`",
|
|
40
|
+
f"- Docs dir: `{payload['docs_dir']}`",
|
|
41
|
+
f"- Config: `{payload['config_path']}`",
|
|
42
|
+
f"- Elapsed: {payload['elapsed_seconds']} s",
|
|
43
|
+
f"- Total findings: {summary['total_findings']}",
|
|
44
|
+
"",
|
|
45
|
+
"## 规则汇总",
|
|
46
|
+
"",
|
|
47
|
+
"| 规则 | 发现数 |",
|
|
48
|
+
"| :--- | :--- |",
|
|
49
|
+
]
|
|
50
|
+
for rule_id, count in summary["findings_by_rule"].items():
|
|
51
|
+
lines.append(f"| {rule_id} | {count} |")
|
|
52
|
+
lines.extend(["", "## 发现清单", ""])
|
|
53
|
+
if not payload["findings"]:
|
|
54
|
+
lines.append("无发现。")
|
|
55
|
+
else:
|
|
56
|
+
lines.extend(
|
|
57
|
+
[
|
|
58
|
+
"| 规则 | 严重度 | 文件 | 行号 | 消息 | 证据 |",
|
|
59
|
+
"| :--- | :--- | :--- | :--- | :--- | :--- |",
|
|
60
|
+
]
|
|
61
|
+
)
|
|
62
|
+
for finding in payload["findings"]:
|
|
63
|
+
lines.append(
|
|
64
|
+
"| {rule_id} | {severity} | `{file}` | {line} | {message} | {evidence} |".format(
|
|
65
|
+
**finding
|
|
66
|
+
)
|
|
67
|
+
)
|
|
68
|
+
lines.append("")
|
|
69
|
+
return "\n".join(lines)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def render_console(payload):
|
|
73
|
+
summary = payload["summary"]
|
|
74
|
+
status = "STRUCTURAL FAIL" if summary["total_findings"] else "STRUCTURAL PASS"
|
|
75
|
+
return (
|
|
76
|
+
f"{status}: {summary['total_findings']} structural finding(s) "
|
|
77
|
+
f"in {payload['root']} (docs: {payload['docs_dir']}, "
|
|
78
|
+
f"{payload['elapsed_seconds']} s)"
|
|
79
|
+
)
|