Skip to content

Commit cf57f3c

Browse files
Antigravity Agentclaude
andcommitted
feat(spec-writer): Subagent Spec Writer Pipeline (#76)
- specs/tri/spec_writer.tri: VIBEE spec for spec generation pipeline - src/tri/tri_spec_writer.zig: extractModuleName, generateSpecContent, writeAndValidate - 4/4 tests pass, vibee gen + ast-check validated - Uses Zig 0.15.2 unmanaged ArrayList API (.empty, allocator per method) Closes #76 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ef0074a commit cf57f3c

2 files changed

Lines changed: 440 additions & 0 deletions

File tree

specs/tri/spec_writer.tri

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# ═══════════════════════════════════════════════════════════════════════════════
2+
# VIBEE Specification — Spec Writer Pipeline
3+
# ═══════════════════════════════════════════════════════════════════════════════
4+
# φ² + 1/φ² = 3 = TRINITY
5+
# 📝 Generates .tri specs from GitHub issue descriptions
6+
# Pipeline Link integration: spec_create (Link 6)
7+
# ═══════════════════════════════════════════════════════════════════════════════
8+
9+
name: spec_writer
10+
version: "1.0.0"
11+
language: zig
12+
module: spec_writer
13+
14+
description: |
15+
Spec Writer — generates well-formed .tri specifications from GitHub issues.
16+
17+
Input: issue number → fetches title, body, labels via gh CLI
18+
Output: specs/tri/{module_name}.tri → ready for vibee gen
19+
20+
Template-based generation:
21+
1. Parse issue → extract purpose, types, behaviors
22+
2. Fill .tri YAML template
23+
3. Write to specs/tri/
24+
4. Validate via vibee gen
25+
5. If compile fails → log to MU, retry with fixes
26+
27+
# ═══════════════════════════════════════════════════════════════════════════════
28+
# TYPE SYSTEM
29+
# ═══════════════════════════════════════════════════════════════════════════════
30+
31+
types:
32+
IssueData:
33+
fields:
34+
number: Int
35+
title: String
36+
body: String
37+
labels: List(String)
38+
39+
SpecField:
40+
fields:
41+
name: String
42+
field_type: String
43+
44+
SpecType:
45+
fields:
46+
name: String
47+
kind: String
48+
fields: List(SpecField)
49+
variants: List(String)
50+
51+
SpecBehavior:
52+
fields:
53+
name: String
54+
description: String
55+
inputs: List(SpecField)
56+
output: String
57+
steps: List(String)
58+
59+
GeneratedSpec:
60+
fields:
61+
module_name: String
62+
spec_path: String
63+
generated_path: String
64+
compile_ok: Bool
65+
66+
WriteResult:
67+
fields:
68+
spec: GeneratedSpec
69+
errors: List(String)
70+
71+
# ═══════════════════════════════════════════════════════════════════════════════
72+
# BEHAVIORS
73+
# ═══════════════════════════════════════════════════════════════════════════════
74+
75+
behaviors:
76+
fetch_issue:
77+
description: "Fetch GitHub issue data via gh CLI"
78+
inputs:
79+
- issue_number: Int
80+
output: IssueData
81+
steps:
82+
- Run gh issue view {number} --json title,body,labels
83+
- Parse JSON response
84+
- Return IssueData struct
85+
86+
analyze_issue:
87+
description: "Extract spec components from issue description"
88+
inputs:
89+
- issue: IssueData
90+
output: List(SpecType)
91+
steps:
92+
- Parse title for module name
93+
- Extract type definitions from body
94+
- Identify behavior signatures
95+
- Map labels to agent assignments
96+
97+
generate_spec:
98+
description: "Generate .tri spec file from analyzed issue"
99+
inputs:
100+
- issue: IssueData
101+
- types: List(SpecType)
102+
- behaviors: List(SpecBehavior)
103+
output: GeneratedSpec
104+
steps:
105+
- Build YAML header (name, version, language, module)
106+
- Render types section
107+
- Render behaviors section
108+
- Write to specs/tri/{module_name}.tri
109+
110+
validate_spec:
111+
description: "Run vibee gen + zig ast-check on generated spec"
112+
inputs:
113+
- spec: GeneratedSpec
114+
output: WriteResult
115+
steps:
116+
- Run vibee gen {spec_path}
117+
- Run zig ast-check {generated_path}
118+
- If fail, collect errors
119+
- Return WriteResult with compile status
120+
121+
write_from_issue:
122+
description: "Full pipeline: issue → spec → codegen → validate"
123+
inputs:
124+
- issue_number: Int
125+
output: WriteResult
126+
steps:
127+
- fetch_issue(issue_number)
128+
- analyze_issue(issue)
129+
- generate_spec(issue, types, behaviors)
130+
- validate_spec(spec)
131+
- If compile_ok, return success
132+
- If fail, log to MU and return errors
133+
134+
# ═══════════════════════════════════════════════════════════════════════════════
135+
# CONSTRAINTS
136+
# ═══════════════════════════════════════════════════════════════════════════════
137+
138+
constraints:
139+
- All generated specs MUST pass vibee gen without errors
140+
- Module names derived from issue title (snake_case)
141+
- Generated .zig MUST pass zig ast-check
142+
- Maximum 3 retry attempts on compile failure
143+
- Each retry logged to MU error patterns
144+
145+
# ═══════════════════════════════════════════════════════════════════════════════
146+
# TESTS
147+
# ═══════════════════════════════════════════════════════════════════════════════
148+
149+
tests:
150+
- name: "generate spec from mock issue"
151+
input: {number: 0, title: "test module", body: "A test", labels: []}
152+
expected: {compile_ok: true}
153+
154+
- name: "snake_case module naming"
155+
input: {title: "feat(mu): Agent MU Error Protocol"}
156+
expected: {module_name: "agent_mu_error_protocol"}

0 commit comments

Comments
 (0)