tribunal-kit 2.4.2 → 2.4.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/.agent/scripts/patch_skills_meta.py +177 -177
- package/.agent/scripts/patch_skills_output.py +285 -285
- package/.agent/scripts/strengthen_skills.py +220 -220
- package/.agent/skills/github-operations/SKILL.md +354 -354
- package/.agent/skills/readme-builder/SKILL.md +270 -270
- package/.agent/workflows/strengthen-skills.md +99 -99
- package/bin/tribunal-kit.js +547 -542
- package/package.json +53 -38
|
@@ -1,285 +1,285 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
patch_skills_output.py — Adds structured Output Format sections to SKILL.md files.
|
|
4
|
-
|
|
5
|
-
Inserts a domain-tailored '## Output Format' block before the Tribunal Integration
|
|
6
|
-
section (or appends to the end if no Tribunal section is present).
|
|
7
|
-
|
|
8
|
-
Skills already containing '## Output Format', '## Output', or '## Report Format'
|
|
9
|
-
are skipped automatically.
|
|
10
|
-
|
|
11
|
-
Usage:
|
|
12
|
-
python .agent/scripts/patch_skills_output.py .
|
|
13
|
-
python .agent/scripts/patch_skills_output.py . --dry-run
|
|
14
|
-
python .agent/scripts/patch_skills_output.py . --skill python-pro
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
import os
|
|
18
|
-
import sys
|
|
19
|
-
import re
|
|
20
|
-
import argparse
|
|
21
|
-
from pathlib import Path
|
|
22
|
-
|
|
23
|
-
RED = "\033[91m"
|
|
24
|
-
GREEN = "\033[92m"
|
|
25
|
-
YELLOW = "\033[93m"
|
|
26
|
-
BLUE = "\033[94m"
|
|
27
|
-
BOLD = "\033[1m"
|
|
28
|
-
RESET = "\033[0m"
|
|
29
|
-
|
|
30
|
-
# ─── Templates ───────────────────────────────────────────────────────────────
|
|
31
|
-
|
|
32
|
-
CODE_QUALITY_TEMPLATE = """\
|
|
33
|
-
## Output Format
|
|
34
|
-
|
|
35
|
-
When this skill produces or reviews code, structure your output as follows:
|
|
36
|
-
|
|
37
|
-
```
|
|
38
|
-
━━━ {skill_name} Report ━━━━━━━━━━━━━━━━━━━━━━━━
|
|
39
|
-
Skill: {skill_name}
|
|
40
|
-
Language: [detected language / framework]
|
|
41
|
-
Scope: [N files · N functions]
|
|
42
|
-
─────────────────────────────────────────────────
|
|
43
|
-
✅ Passed: [checks that passed, or "All clean"]
|
|
44
|
-
⚠️ Warnings: [non-blocking issues, or "None"]
|
|
45
|
-
❌ Blocked: [blocking issues requiring fix, or "None"]
|
|
46
|
-
─────────────────────────────────────────────────
|
|
47
|
-
VBC status: PENDING → VERIFIED
|
|
48
|
-
Evidence: [test output / lint pass / compile success]
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
**VBC (Verification-Before-Completion) is mandatory.**
|
|
52
|
-
Do not mark status as VERIFIED until concrete terminal evidence is provided.
|
|
53
|
-
|
|
54
|
-
"""
|
|
55
|
-
|
|
56
|
-
DECISION_CARD_TEMPLATE = """\
|
|
57
|
-
## Output Format
|
|
58
|
-
|
|
59
|
-
When this skill produces a recommendation or design decision, structure your output as:
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
━━━ {skill_name} Recommendation ━━━━━━━━━━━━━━━━
|
|
63
|
-
Decision: [what was chosen / proposed]
|
|
64
|
-
Rationale: [why — one concise line]
|
|
65
|
-
Trade-offs: [what is consciously accepted]
|
|
66
|
-
Next action: [concrete next step for the user]
|
|
67
|
-
─────────────────────────────────────────────────
|
|
68
|
-
Pre-Flight: ✅ All checks passed
|
|
69
|
-
or ❌ [blocking item that must be resolved first]
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
"""
|
|
73
|
-
|
|
74
|
-
GENERIC_TEMPLATE = """\
|
|
75
|
-
## Output Format
|
|
76
|
-
|
|
77
|
-
When this skill completes a task, structure your output as:
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
━━━ {skill_name} Output ━━━━━━━━━━━━━━━━━━━━━━━━
|
|
81
|
-
Task: [what was performed]
|
|
82
|
-
Result: [outcome summary — one line]
|
|
83
|
-
─────────────────────────────────────────────────
|
|
84
|
-
Checks: ✅ [N passed] · ⚠️ [N warnings] · ❌ [N blocked]
|
|
85
|
-
VBC status: PENDING → VERIFIED
|
|
86
|
-
Evidence: [link to terminal output, test result, or file diff]
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
"""
|
|
90
|
-
|
|
91
|
-
# ─── Skill → template routing ────────────────────────────────────────────────
|
|
92
|
-
|
|
93
|
-
CODE_GEN_SKILLS = {
|
|
94
|
-
"python-pro", "clean-code", "dotnet-core-expert", "rust-pro",
|
|
95
|
-
"nextjs-react-expert", "vue-expert", "react-specialist",
|
|
96
|
-
"csharp-developer", "nodejs-best-practices", "python-patterns",
|
|
97
|
-
"tailwind-patterns", "bash-linux", "powershell-windows",
|
|
98
|
-
"llm-engineering", "mcp-builder", "game-development",
|
|
99
|
-
"edge-computing", "local-first", "realtime-patterns",
|
|
100
|
-
"tdd-workflow", "testing-patterns", "lint-and-validate",
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
DECISION_SKILLS = {
|
|
104
|
-
"api-patterns", "database-design", "architecture", "observability",
|
|
105
|
-
"devops-engineer", "platform-engineer", "deployment-procedures",
|
|
106
|
-
"server-management", "security-auditor", "vulnerability-scanner",
|
|
107
|
-
"red-team-tactics", "performance-profiling", "i18n-localization",
|
|
108
|
-
"geo-fundamentals", "seo-fundamentals", "sql-pro",
|
|
109
|
-
"brainstorming", "plan-writing", "behavioral-modes",
|
|
110
|
-
"app-builder", "intelligent-routing", "mobile-design",
|
|
111
|
-
"frontend-design", "ui-ux-pro-max", "ui-ux-researcher",
|
|
112
|
-
"web-design-guidelines", "trend-researcher",
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
# Skills that already have output format sections — SKIP
|
|
116
|
-
ALREADY_HAVE_OUTPUT = {
|
|
117
|
-
"whimsy-injector", "workflow-optimizer",
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
# Markers indicating an existing output section
|
|
121
|
-
EXISTING_OUTPUT_MARKERS = [
|
|
122
|
-
"## Output Format",
|
|
123
|
-
"## Output\n",
|
|
124
|
-
"## Report Format",
|
|
125
|
-
"## Output Card",
|
|
126
|
-
"Whimsy Injection Report",
|
|
127
|
-
"Workflow Optimization Report",
|
|
128
|
-
]
|
|
129
|
-
|
|
130
|
-
# ─── Logic ───────────────────────────────────────────────────────────────────
|
|
131
|
-
|
|
132
|
-
def get_template(skill_name: str) -> str:
|
|
133
|
-
if skill_name in CODE_GEN_SKILLS:
|
|
134
|
-
return CODE_QUALITY_TEMPLATE
|
|
135
|
-
if skill_name in DECISION_SKILLS:
|
|
136
|
-
return DECISION_CARD_TEMPLATE
|
|
137
|
-
return GENERIC_TEMPLATE
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
def has_output_section(content: str) -> bool:
|
|
141
|
-
for marker in EXISTING_OUTPUT_MARKERS:
|
|
142
|
-
if marker in content:
|
|
143
|
-
return True
|
|
144
|
-
return False
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
def get_skill_name_from_frontmatter(content: str) -> str | None:
|
|
148
|
-
"""Extract the 'name:' field from YAML frontmatter."""
|
|
149
|
-
match = re.search(r"^name:\s*(.+)$", content, re.MULTILINE)
|
|
150
|
-
return match.group(1).strip() if match else None
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
def build_block(template: str, skill_name: str) -> str:
|
|
154
|
-
# Capitalise display name
|
|
155
|
-
display = skill_name.replace("-", " ").title()
|
|
156
|
-
return template.replace("{skill_name}", display)
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
def inject_output_block(content: str, block: str) -> str:
|
|
160
|
-
"""
|
|
161
|
-
Insert block before '## 🏛️ Tribunal Integration' if present,
|
|
162
|
-
otherwise append to end of file.
|
|
163
|
-
"""
|
|
164
|
-
tribunal_markers = [
|
|
165
|
-
"## 🏛️ Tribunal Integration",
|
|
166
|
-
"## Tribunal Integration",
|
|
167
|
-
]
|
|
168
|
-
for marker in tribunal_markers:
|
|
169
|
-
idx = content.find(marker)
|
|
170
|
-
if idx != -1:
|
|
171
|
-
return content[:idx] + block + "\n---\n\n" + content[idx:]
|
|
172
|
-
|
|
173
|
-
# Append to end with a separator
|
|
174
|
-
return content.rstrip() + "\n\n---\n\n" + block
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
def process_skill(skill_dir: Path, dry_run: bool) -> str:
|
|
178
|
-
"""Returns 'updated', 'skipped', or 'error'."""
|
|
179
|
-
skill_name = skill_dir.name
|
|
180
|
-
skill_md = skill_dir / "SKILL.md"
|
|
181
|
-
|
|
182
|
-
if not skill_md.exists():
|
|
183
|
-
return "skipped"
|
|
184
|
-
|
|
185
|
-
try:
|
|
186
|
-
content = skill_md.read_text(encoding="utf-8")
|
|
187
|
-
|
|
188
|
-
if skill_name in ALREADY_HAVE_OUTPUT or has_output_section(content):
|
|
189
|
-
skip(f"{skill_name} — output format already present")
|
|
190
|
-
return "skipped"
|
|
191
|
-
|
|
192
|
-
# Determine display name
|
|
193
|
-
display_name = get_skill_name_from_frontmatter(content) or skill_name
|
|
194
|
-
template = get_template(skill_name)
|
|
195
|
-
block = build_block(template, display_name)
|
|
196
|
-
patched = inject_output_block(content, block)
|
|
197
|
-
|
|
198
|
-
if dry_run:
|
|
199
|
-
template_type = (
|
|
200
|
-
"Code Quality" if skill_name in CODE_GEN_SKILLS
|
|
201
|
-
else "Decision Card" if skill_name in DECISION_SKILLS
|
|
202
|
-
else "Generic"
|
|
203
|
-
)
|
|
204
|
-
warn(f"[DRY RUN] {skill_name} — would add Output Format ({template_type})")
|
|
205
|
-
return "updated"
|
|
206
|
-
|
|
207
|
-
skill_md.write_text(patched, encoding="utf-8")
|
|
208
|
-
template_type = (
|
|
209
|
-
"Code Quality" if skill_name in CODE_GEN_SKILLS
|
|
210
|
-
else "Decision Card" if skill_name in DECISION_SKILLS
|
|
211
|
-
else "Generic"
|
|
212
|
-
)
|
|
213
|
-
ok(f"{skill_name} — added Output Format ({template_type})")
|
|
214
|
-
return "updated"
|
|
215
|
-
|
|
216
|
-
except Exception as e:
|
|
217
|
-
fail(f"{skill_name} — {e}")
|
|
218
|
-
return "error"
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
def header(title: str) -> None:
|
|
222
|
-
print(f"\n{BOLD}{BLUE}━━━ {title} ━━━{RESET}")
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
def ok(msg: str) -> None:
|
|
226
|
-
print(f" {GREEN}✅ {msg}{RESET}")
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
def skip(msg: str) -> None:
|
|
230
|
-
print(f" {YELLOW}⏭️ {msg}{RESET}")
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
def warn(msg: str) -> None:
|
|
234
|
-
print(f" {YELLOW}⚠️ {msg}{RESET}")
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
def fail(msg: str) -> None:
|
|
238
|
-
print(f" {RED}❌ {msg}{RESET}")
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
def main() -> None:
|
|
242
|
-
parser = argparse.ArgumentParser(
|
|
243
|
-
description="Adds Output Format sections to SKILL.md files that are missing them"
|
|
244
|
-
)
|
|
245
|
-
parser.add_argument("path", help="Project root directory")
|
|
246
|
-
parser.add_argument("--dry-run", action="store_true", help="Show changes without writing")
|
|
247
|
-
parser.add_argument("--skill", help="Only patch a specific skill by name")
|
|
248
|
-
args = parser.parse_args()
|
|
249
|
-
|
|
250
|
-
project_root = Path(args.path).resolve()
|
|
251
|
-
skills_dir = project_root / ".agent" / "skills"
|
|
252
|
-
|
|
253
|
-
if not skills_dir.is_dir():
|
|
254
|
-
fail(f"Skills directory not found: {skills_dir}")
|
|
255
|
-
sys.exit(1)
|
|
256
|
-
|
|
257
|
-
print(f"{BOLD}Tribunal — patch_skills_output.py{RESET}")
|
|
258
|
-
if args.dry_run:
|
|
259
|
-
print(f" {YELLOW}DRY RUN — no files will be written{RESET}")
|
|
260
|
-
print(f"Skills dir: {skills_dir}\n")
|
|
261
|
-
|
|
262
|
-
counts: dict[str, int] = {"updated": 0, "skipped": 0, "error": 0}
|
|
263
|
-
|
|
264
|
-
header("Patching Output Format Sections")
|
|
265
|
-
for skill_dir in sorted(skills_dir.iterdir()):
|
|
266
|
-
if not skill_dir.is_dir():
|
|
267
|
-
continue
|
|
268
|
-
if args.skill and skill_dir.name != args.skill:
|
|
269
|
-
continue
|
|
270
|
-
result = process_skill(skill_dir, args.dry_run)
|
|
271
|
-
counts[result] += 1
|
|
272
|
-
|
|
273
|
-
print(f"\n{BOLD}━━━ Summary ━━━{RESET}")
|
|
274
|
-
print(f" {GREEN}✅ Updated: {counts['updated']}{RESET}")
|
|
275
|
-
print(f" {YELLOW}⏭️ Skipped: {counts['skipped']}{RESET}")
|
|
276
|
-
if counts["error"]:
|
|
277
|
-
print(f" {RED}❌ Errors: {counts['error']}{RESET}")
|
|
278
|
-
if args.dry_run:
|
|
279
|
-
print(f" {YELLOW}(dry-run — nothing written){RESET}")
|
|
280
|
-
|
|
281
|
-
sys.exit(1 if counts["error"] > 0 else 0)
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
if __name__ == "__main__":
|
|
285
|
-
main()
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
patch_skills_output.py — Adds structured Output Format sections to SKILL.md files.
|
|
4
|
+
|
|
5
|
+
Inserts a domain-tailored '## Output Format' block before the Tribunal Integration
|
|
6
|
+
section (or appends to the end if no Tribunal section is present).
|
|
7
|
+
|
|
8
|
+
Skills already containing '## Output Format', '## Output', or '## Report Format'
|
|
9
|
+
are skipped automatically.
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
python .agent/scripts/patch_skills_output.py .
|
|
13
|
+
python .agent/scripts/patch_skills_output.py . --dry-run
|
|
14
|
+
python .agent/scripts/patch_skills_output.py . --skill python-pro
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import os
|
|
18
|
+
import sys
|
|
19
|
+
import re
|
|
20
|
+
import argparse
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
|
|
23
|
+
RED = "\033[91m"
|
|
24
|
+
GREEN = "\033[92m"
|
|
25
|
+
YELLOW = "\033[93m"
|
|
26
|
+
BLUE = "\033[94m"
|
|
27
|
+
BOLD = "\033[1m"
|
|
28
|
+
RESET = "\033[0m"
|
|
29
|
+
|
|
30
|
+
# ─── Templates ───────────────────────────────────────────────────────────────
|
|
31
|
+
|
|
32
|
+
CODE_QUALITY_TEMPLATE = """\
|
|
33
|
+
## Output Format
|
|
34
|
+
|
|
35
|
+
When this skill produces or reviews code, structure your output as follows:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
━━━ {skill_name} Report ━━━━━━━━━━━━━━━━━━━━━━━━
|
|
39
|
+
Skill: {skill_name}
|
|
40
|
+
Language: [detected language / framework]
|
|
41
|
+
Scope: [N files · N functions]
|
|
42
|
+
─────────────────────────────────────────────────
|
|
43
|
+
✅ Passed: [checks that passed, or "All clean"]
|
|
44
|
+
⚠️ Warnings: [non-blocking issues, or "None"]
|
|
45
|
+
❌ Blocked: [blocking issues requiring fix, or "None"]
|
|
46
|
+
─────────────────────────────────────────────────
|
|
47
|
+
VBC status: PENDING → VERIFIED
|
|
48
|
+
Evidence: [test output / lint pass / compile success]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**VBC (Verification-Before-Completion) is mandatory.**
|
|
52
|
+
Do not mark status as VERIFIED until concrete terminal evidence is provided.
|
|
53
|
+
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
DECISION_CARD_TEMPLATE = """\
|
|
57
|
+
## Output Format
|
|
58
|
+
|
|
59
|
+
When this skill produces a recommendation or design decision, structure your output as:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
━━━ {skill_name} Recommendation ━━━━━━━━━━━━━━━━
|
|
63
|
+
Decision: [what was chosen / proposed]
|
|
64
|
+
Rationale: [why — one concise line]
|
|
65
|
+
Trade-offs: [what is consciously accepted]
|
|
66
|
+
Next action: [concrete next step for the user]
|
|
67
|
+
─────────────────────────────────────────────────
|
|
68
|
+
Pre-Flight: ✅ All checks passed
|
|
69
|
+
or ❌ [blocking item that must be resolved first]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
GENERIC_TEMPLATE = """\
|
|
75
|
+
## Output Format
|
|
76
|
+
|
|
77
|
+
When this skill completes a task, structure your output as:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
━━━ {skill_name} Output ━━━━━━━━━━━━━━━━━━━━━━━━
|
|
81
|
+
Task: [what was performed]
|
|
82
|
+
Result: [outcome summary — one line]
|
|
83
|
+
─────────────────────────────────────────────────
|
|
84
|
+
Checks: ✅ [N passed] · ⚠️ [N warnings] · ❌ [N blocked]
|
|
85
|
+
VBC status: PENDING → VERIFIED
|
|
86
|
+
Evidence: [link to terminal output, test result, or file diff]
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
# ─── Skill → template routing ────────────────────────────────────────────────
|
|
92
|
+
|
|
93
|
+
CODE_GEN_SKILLS = {
|
|
94
|
+
"python-pro", "clean-code", "dotnet-core-expert", "rust-pro",
|
|
95
|
+
"nextjs-react-expert", "vue-expert", "react-specialist",
|
|
96
|
+
"csharp-developer", "nodejs-best-practices", "python-patterns",
|
|
97
|
+
"tailwind-patterns", "bash-linux", "powershell-windows",
|
|
98
|
+
"llm-engineering", "mcp-builder", "game-development",
|
|
99
|
+
"edge-computing", "local-first", "realtime-patterns",
|
|
100
|
+
"tdd-workflow", "testing-patterns", "lint-and-validate",
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
DECISION_SKILLS = {
|
|
104
|
+
"api-patterns", "database-design", "architecture", "observability",
|
|
105
|
+
"devops-engineer", "platform-engineer", "deployment-procedures",
|
|
106
|
+
"server-management", "security-auditor", "vulnerability-scanner",
|
|
107
|
+
"red-team-tactics", "performance-profiling", "i18n-localization",
|
|
108
|
+
"geo-fundamentals", "seo-fundamentals", "sql-pro",
|
|
109
|
+
"brainstorming", "plan-writing", "behavioral-modes",
|
|
110
|
+
"app-builder", "intelligent-routing", "mobile-design",
|
|
111
|
+
"frontend-design", "ui-ux-pro-max", "ui-ux-researcher",
|
|
112
|
+
"web-design-guidelines", "trend-researcher",
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
# Skills that already have output format sections — SKIP
|
|
116
|
+
ALREADY_HAVE_OUTPUT = {
|
|
117
|
+
"whimsy-injector", "workflow-optimizer",
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
# Markers indicating an existing output section
|
|
121
|
+
EXISTING_OUTPUT_MARKERS = [
|
|
122
|
+
"## Output Format",
|
|
123
|
+
"## Output\n",
|
|
124
|
+
"## Report Format",
|
|
125
|
+
"## Output Card",
|
|
126
|
+
"Whimsy Injection Report",
|
|
127
|
+
"Workflow Optimization Report",
|
|
128
|
+
]
|
|
129
|
+
|
|
130
|
+
# ─── Logic ───────────────────────────────────────────────────────────────────
|
|
131
|
+
|
|
132
|
+
def get_template(skill_name: str) -> str:
|
|
133
|
+
if skill_name in CODE_GEN_SKILLS:
|
|
134
|
+
return CODE_QUALITY_TEMPLATE
|
|
135
|
+
if skill_name in DECISION_SKILLS:
|
|
136
|
+
return DECISION_CARD_TEMPLATE
|
|
137
|
+
return GENERIC_TEMPLATE
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def has_output_section(content: str) -> bool:
|
|
141
|
+
for marker in EXISTING_OUTPUT_MARKERS:
|
|
142
|
+
if marker in content:
|
|
143
|
+
return True
|
|
144
|
+
return False
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def get_skill_name_from_frontmatter(content: str) -> str | None:
|
|
148
|
+
"""Extract the 'name:' field from YAML frontmatter."""
|
|
149
|
+
match = re.search(r"^name:\s*(.+)$", content, re.MULTILINE)
|
|
150
|
+
return match.group(1).strip() if match else None
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def build_block(template: str, skill_name: str) -> str:
|
|
154
|
+
# Capitalise display name
|
|
155
|
+
display = skill_name.replace("-", " ").title()
|
|
156
|
+
return template.replace("{skill_name}", display)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def inject_output_block(content: str, block: str) -> str:
|
|
160
|
+
"""
|
|
161
|
+
Insert block before '## 🏛️ Tribunal Integration' if present,
|
|
162
|
+
otherwise append to end of file.
|
|
163
|
+
"""
|
|
164
|
+
tribunal_markers = [
|
|
165
|
+
"## 🏛️ Tribunal Integration",
|
|
166
|
+
"## Tribunal Integration",
|
|
167
|
+
]
|
|
168
|
+
for marker in tribunal_markers:
|
|
169
|
+
idx = content.find(marker)
|
|
170
|
+
if idx != -1:
|
|
171
|
+
return content[:idx] + block + "\n---\n\n" + content[idx:]
|
|
172
|
+
|
|
173
|
+
# Append to end with a separator
|
|
174
|
+
return content.rstrip() + "\n\n---\n\n" + block
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def process_skill(skill_dir: Path, dry_run: bool) -> str:
|
|
178
|
+
"""Returns 'updated', 'skipped', or 'error'."""
|
|
179
|
+
skill_name = skill_dir.name
|
|
180
|
+
skill_md = skill_dir / "SKILL.md"
|
|
181
|
+
|
|
182
|
+
if not skill_md.exists():
|
|
183
|
+
return "skipped"
|
|
184
|
+
|
|
185
|
+
try:
|
|
186
|
+
content = skill_md.read_text(encoding="utf-8")
|
|
187
|
+
|
|
188
|
+
if skill_name in ALREADY_HAVE_OUTPUT or has_output_section(content):
|
|
189
|
+
skip(f"{skill_name} — output format already present")
|
|
190
|
+
return "skipped"
|
|
191
|
+
|
|
192
|
+
# Determine display name
|
|
193
|
+
display_name = get_skill_name_from_frontmatter(content) or skill_name
|
|
194
|
+
template = get_template(skill_name)
|
|
195
|
+
block = build_block(template, display_name)
|
|
196
|
+
patched = inject_output_block(content, block)
|
|
197
|
+
|
|
198
|
+
if dry_run:
|
|
199
|
+
template_type = (
|
|
200
|
+
"Code Quality" if skill_name in CODE_GEN_SKILLS
|
|
201
|
+
else "Decision Card" if skill_name in DECISION_SKILLS
|
|
202
|
+
else "Generic"
|
|
203
|
+
)
|
|
204
|
+
warn(f"[DRY RUN] {skill_name} — would add Output Format ({template_type})")
|
|
205
|
+
return "updated"
|
|
206
|
+
|
|
207
|
+
skill_md.write_text(patched, encoding="utf-8")
|
|
208
|
+
template_type = (
|
|
209
|
+
"Code Quality" if skill_name in CODE_GEN_SKILLS
|
|
210
|
+
else "Decision Card" if skill_name in DECISION_SKILLS
|
|
211
|
+
else "Generic"
|
|
212
|
+
)
|
|
213
|
+
ok(f"{skill_name} — added Output Format ({template_type})")
|
|
214
|
+
return "updated"
|
|
215
|
+
|
|
216
|
+
except Exception as e:
|
|
217
|
+
fail(f"{skill_name} — {e}")
|
|
218
|
+
return "error"
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def header(title: str) -> None:
|
|
222
|
+
print(f"\n{BOLD}{BLUE}━━━ {title} ━━━{RESET}")
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def ok(msg: str) -> None:
|
|
226
|
+
print(f" {GREEN}✅ {msg}{RESET}")
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def skip(msg: str) -> None:
|
|
230
|
+
print(f" {YELLOW}⏭️ {msg}{RESET}")
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def warn(msg: str) -> None:
|
|
234
|
+
print(f" {YELLOW}⚠️ {msg}{RESET}")
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def fail(msg: str) -> None:
|
|
238
|
+
print(f" {RED}❌ {msg}{RESET}")
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def main() -> None:
|
|
242
|
+
parser = argparse.ArgumentParser(
|
|
243
|
+
description="Adds Output Format sections to SKILL.md files that are missing them"
|
|
244
|
+
)
|
|
245
|
+
parser.add_argument("path", help="Project root directory")
|
|
246
|
+
parser.add_argument("--dry-run", action="store_true", help="Show changes without writing")
|
|
247
|
+
parser.add_argument("--skill", help="Only patch a specific skill by name")
|
|
248
|
+
args = parser.parse_args()
|
|
249
|
+
|
|
250
|
+
project_root = Path(args.path).resolve()
|
|
251
|
+
skills_dir = project_root / ".agent" / "skills"
|
|
252
|
+
|
|
253
|
+
if not skills_dir.is_dir():
|
|
254
|
+
fail(f"Skills directory not found: {skills_dir}")
|
|
255
|
+
sys.exit(1)
|
|
256
|
+
|
|
257
|
+
print(f"{BOLD}Tribunal — patch_skills_output.py{RESET}")
|
|
258
|
+
if args.dry_run:
|
|
259
|
+
print(f" {YELLOW}DRY RUN — no files will be written{RESET}")
|
|
260
|
+
print(f"Skills dir: {skills_dir}\n")
|
|
261
|
+
|
|
262
|
+
counts: dict[str, int] = {"updated": 0, "skipped": 0, "error": 0}
|
|
263
|
+
|
|
264
|
+
header("Patching Output Format Sections")
|
|
265
|
+
for skill_dir in sorted(skills_dir.iterdir()):
|
|
266
|
+
if not skill_dir.is_dir():
|
|
267
|
+
continue
|
|
268
|
+
if args.skill and skill_dir.name != args.skill:
|
|
269
|
+
continue
|
|
270
|
+
result = process_skill(skill_dir, args.dry_run)
|
|
271
|
+
counts[result] += 1
|
|
272
|
+
|
|
273
|
+
print(f"\n{BOLD}━━━ Summary ━━━{RESET}")
|
|
274
|
+
print(f" {GREEN}✅ Updated: {counts['updated']}{RESET}")
|
|
275
|
+
print(f" {YELLOW}⏭️ Skipped: {counts['skipped']}{RESET}")
|
|
276
|
+
if counts["error"]:
|
|
277
|
+
print(f" {RED}❌ Errors: {counts['error']}{RESET}")
|
|
278
|
+
if args.dry_run:
|
|
279
|
+
print(f" {YELLOW}(dry-run — nothing written){RESET}")
|
|
280
|
+
|
|
281
|
+
sys.exit(1 if counts["error"] > 0 else 0)
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
if __name__ == "__main__":
|
|
285
|
+
main()
|