@codeharbor/agent-playbook 0.1.0 → 0.1.2
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 +4 -2
- package/package.json +5 -2
- package/skills/api-designer/README.md +36 -0
- package/skills/api-designer/SKILL.md +232 -0
- package/skills/api-designer/references/graphql-patterns.md +12 -0
- package/skills/api-designer/references/rest-patterns.md +17 -0
- package/skills/api-designer/scripts/generate_api.py +87 -0
- package/skills/api-designer/scripts/validate_api.py +48 -0
- package/skills/api-documenter/README.md +41 -0
- package/skills/api-documenter/SKILL.md +209 -0
- package/skills/api-documenter/references/examples/README.md +3 -0
- package/skills/api-documenter/references/examples/openapi-example.yaml +10 -0
- package/skills/api-documenter/references/openapi-template.yaml +5 -0
- package/skills/api-documenter/scripts/generate_openapi.py +84 -0
- package/skills/api-documenter/scripts/validate_openapi.py +45 -0
- package/skills/architecting-solutions/README.md +22 -0
- package/skills/architecting-solutions/SKILL.md +459 -0
- package/skills/auto-trigger/README.md +23 -0
- package/skills/auto-trigger/SKILL.md +183 -0
- package/skills/code-reviewer/README.md +59 -0
- package/skills/code-reviewer/SKILL.md +220 -0
- package/skills/code-reviewer/references/checklist.md +80 -0
- package/skills/code-reviewer/references/patterns.md +226 -0
- package/skills/code-reviewer/references/security.md +88 -0
- package/skills/code-reviewer/scripts/review_checklist.py +191 -0
- package/skills/commit-helper/README.md +58 -0
- package/skills/commit-helper/SKILL.md +159 -0
- package/skills/commit-helper/references/conventional-commits.md +68 -0
- package/skills/commit-helper/references/examples.md +125 -0
- package/skills/commit-helper/references/scopes.md +49 -0
- package/skills/commit-helper/scripts/validate_commit.py +70 -0
- package/skills/create-pr/README.md +182 -0
- package/skills/create-pr/SKILL.md +340 -0
- package/skills/debugger/README.md +53 -0
- package/skills/debugger/SKILL.md +239 -0
- package/skills/debugger/references/checklist.md +7 -0
- package/skills/debugger/references/errors.md +6 -0
- package/skills/debugger/references/patterns.md +5 -0
- package/skills/debugger/scripts/debug_report.py +77 -0
- package/skills/deployment-engineer/README.md +40 -0
- package/skills/deployment-engineer/SKILL.md +242 -0
- package/skills/deployment-engineer/references/kubernetes.md +23 -0
- package/skills/deployment-engineer/references/monitoring.md +14 -0
- package/skills/deployment-engineer/references/pipelines.md +12 -0
- package/skills/deployment-engineer/scripts/generate_deploy.py +72 -0
- package/skills/deployment-engineer/scripts/validate_deploy.py +46 -0
- package/skills/documentation-engineer/README.md +41 -0
- package/skills/documentation-engineer/SKILL.md +164 -0
- package/skills/documentation-engineer/references/api-template.md +22 -0
- package/skills/documentation-engineer/references/readme-template.md +25 -0
- package/skills/documentation-engineer/references/style-guide.md +13 -0
- package/skills/documentation-engineer/scripts/generate_docs.py +68 -0
- package/skills/documentation-engineer/scripts/validate_docs.py +46 -0
- package/skills/figma-designer/README.md +222 -0
- package/skills/figma-designer/SKILL.md +407 -0
- package/skills/figma-designer/references/example-output.md +86 -0
- package/skills/performance-engineer/README.md +42 -0
- package/skills/performance-engineer/SKILL.md +236 -0
- package/skills/performance-engineer/references/checklist.md +6 -0
- package/skills/performance-engineer/references/monitoring.md +5 -0
- package/skills/performance-engineer/references/optimization.md +7 -0
- package/skills/performance-engineer/scripts/perf_report.py +64 -0
- package/skills/performance-engineer/scripts/profile.py +63 -0
- package/skills/planning-with-files/README.md +27 -0
- package/skills/planning-with-files/SKILL.md +103 -0
- package/skills/prd-implementation-precheck/README.md +97 -0
- package/skills/prd-implementation-precheck/SKILL.md +112 -0
- package/skills/prd-planner/README.md +102 -0
- package/skills/prd-planner/SKILL.md +449 -0
- package/skills/prd-planner/references/edge-case-analysis.md +111 -0
- package/skills/qa-expert/README.md +37 -0
- package/skills/qa-expert/SKILL.md +225 -0
- package/skills/qa-expert/references/gates.md +11 -0
- package/skills/qa-expert/references/metrics.md +6 -0
- package/skills/qa-expert/references/strategy.md +11 -0
- package/skills/qa-expert/scripts/coverage_analysis.py +61 -0
- package/skills/qa-expert/scripts/generate_test_plan.py +68 -0
- package/skills/refactoring-specialist/README.md +37 -0
- package/skills/refactoring-specialist/SKILL.md +283 -0
- package/skills/refactoring-specialist/references/checklist.md +6 -0
- package/skills/refactoring-specialist/references/smells.md +6 -0
- package/skills/refactoring-specialist/references/techniques.md +6 -0
- package/skills/security-auditor/README.md +48 -0
- package/skills/security-auditor/SKILL.md +256 -0
- package/skills/security-auditor/references/checklist.md +7 -0
- package/skills/security-auditor/references/owasp.md +12 -0
- package/skills/security-auditor/references/remediation.md +7 -0
- package/skills/security-auditor/scripts/find_secrets.py +58 -0
- package/skills/security-auditor/scripts/security_audit.py +64 -0
- package/skills/self-improving-agent/README.md +136 -0
- package/skills/self-improving-agent/SKILL.md +407 -0
- package/skills/self-improving-agent/hooks/post-bash.sh +10 -0
- package/skills/self-improving-agent/hooks/pre-tool.sh +10 -0
- package/skills/self-improving-agent/hooks/session-end.sh +4 -0
- package/skills/self-improving-agent/memory/semantic-patterns.json +288 -0
- package/skills/self-improving-agent/references/appendix.md +131 -0
- package/skills/self-improving-agent/templates/correction-template.md +11 -0
- package/skills/self-improving-agent/templates/pattern-template.md +15 -0
- package/skills/self-improving-agent/templates/validation-template.md +14 -0
- package/skills/session-logger/README.md +50 -0
- package/skills/session-logger/SKILL.md +156 -0
- package/skills/skill-router/README.md +155 -0
- package/skills/skill-router/SKILL.md +215 -0
- package/skills/test-automator/README.md +41 -0
- package/skills/test-automator/SKILL.md +202 -0
- package/skills/test-automator/references/best-practices.md +6 -0
- package/skills/test-automator/references/examples/README.md +3 -0
- package/skills/test-automator/references/examples/unit-test-example.md +8 -0
- package/skills/test-automator/references/mocking.md +5 -0
- package/skills/test-automator/scripts/coverage_report.py +59 -0
- package/skills/test-automator/scripts/generate_test.py +66 -0
- package/skills/workflow-orchestrator/README.md +20 -0
- package/skills/workflow-orchestrator/SKILL.md +342 -0
- package/src/cli.js +107 -20
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Template generator for deployment plan.
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import argparse
|
|
6
|
+
import textwrap
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def write_output(path: Path, content: str, force: bool) -> bool:
|
|
10
|
+
if path.exists() and not force:
|
|
11
|
+
print(f"{path} already exists (use --force to overwrite)")
|
|
12
|
+
return False
|
|
13
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
14
|
+
path.write_text(content, encoding="utf-8")
|
|
15
|
+
return True
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def main() -> int:
|
|
19
|
+
parser = argparse.ArgumentParser(description="Generate a deployment plan.")
|
|
20
|
+
parser.add_argument("--output", default="deploy-plan.md", help="Output file path")
|
|
21
|
+
parser.add_argument("--name", default="example", help="Service or app name")
|
|
22
|
+
parser.add_argument("--env", default="production", help="Target environment")
|
|
23
|
+
parser.add_argument("--owner", default="team", help="Owning team")
|
|
24
|
+
parser.add_argument("--force", action="store_true", help="Overwrite existing file")
|
|
25
|
+
args = parser.parse_args()
|
|
26
|
+
|
|
27
|
+
content = textwrap.dedent(
|
|
28
|
+
f"""\
|
|
29
|
+
# Deployment Plan
|
|
30
|
+
|
|
31
|
+
## Overview
|
|
32
|
+
- Service: {args.name}
|
|
33
|
+
- Environment: {args.env}
|
|
34
|
+
- Owner: {args.owner}
|
|
35
|
+
|
|
36
|
+
## Preconditions
|
|
37
|
+
- Release approved
|
|
38
|
+
- Change window confirmed
|
|
39
|
+
- Backups verified
|
|
40
|
+
|
|
41
|
+
## Steps
|
|
42
|
+
1. Build and publish artifacts
|
|
43
|
+
2. Deploy to staging and run smoke tests
|
|
44
|
+
3. Run migrations (if needed)
|
|
45
|
+
4. Deploy to {args.env}
|
|
46
|
+
5. Verify health checks and dashboards
|
|
47
|
+
|
|
48
|
+
## Verification
|
|
49
|
+
- Health endpoint returns 200
|
|
50
|
+
- Key metrics within baseline
|
|
51
|
+
- Error budget stable
|
|
52
|
+
|
|
53
|
+
## Rollback
|
|
54
|
+
- Revert to last known good release
|
|
55
|
+
- Disable feature flags
|
|
56
|
+
- Communicate rollback status
|
|
57
|
+
|
|
58
|
+
## Observability
|
|
59
|
+
- Dashboard links
|
|
60
|
+
- Alert channels
|
|
61
|
+
"""
|
|
62
|
+
).strip() + "\n"
|
|
63
|
+
|
|
64
|
+
output = Path(args.output)
|
|
65
|
+
if not write_output(output, content, args.force):
|
|
66
|
+
return 1
|
|
67
|
+
print(f"Wrote {output}")
|
|
68
|
+
return 0
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
if __name__ == "__main__":
|
|
72
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Template validator for deployment plan.
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import argparse
|
|
6
|
+
|
|
7
|
+
DEFAULT_REQUIRED = [
|
|
8
|
+
"## Overview",
|
|
9
|
+
"## Preconditions",
|
|
10
|
+
"## Steps",
|
|
11
|
+
"## Verification",
|
|
12
|
+
"## Rollback",
|
|
13
|
+
"## Observability",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def main() -> int:
|
|
18
|
+
parser = argparse.ArgumentParser(description="Validate a generated artifact.")
|
|
19
|
+
parser.add_argument("--input", default="deploy-plan.md", help="Input file path")
|
|
20
|
+
parser.add_argument(
|
|
21
|
+
"--require",
|
|
22
|
+
action="append",
|
|
23
|
+
default=[],
|
|
24
|
+
help="Additional required section heading",
|
|
25
|
+
)
|
|
26
|
+
args = parser.parse_args()
|
|
27
|
+
|
|
28
|
+
path = Path(args.input)
|
|
29
|
+
if not path.exists():
|
|
30
|
+
print(f"Missing file: {path}")
|
|
31
|
+
return 1
|
|
32
|
+
|
|
33
|
+
text = path.read_text(encoding="utf-8", errors="ignore")
|
|
34
|
+
text_lower = text.lower()
|
|
35
|
+
required = DEFAULT_REQUIRED + args.require
|
|
36
|
+
missing = [section for section in required if section.lower() not in text_lower]
|
|
37
|
+
if missing:
|
|
38
|
+
print("Missing required sections: " + ", ".join(missing))
|
|
39
|
+
return 1
|
|
40
|
+
|
|
41
|
+
print(f"Validated {path}")
|
|
42
|
+
return 0
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if __name__ == "__main__":
|
|
46
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Documentation Engineer
|
|
2
|
+
|
|
3
|
+
> A Claude Code skill for creating clear, comprehensive documentation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
This skill is part of the [agent-playbook](https://github.com/Charon-Fan/agent-playbook) collection.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
You: Write documentation for this API
|
|
13
|
+
You: Create a README
|
|
14
|
+
You: Document this code
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Documentation Types
|
|
18
|
+
|
|
19
|
+
| Type | Description |
|
|
20
|
+
|------|-------------|
|
|
21
|
+
| **README** | Project overview and quick start |
|
|
22
|
+
| **API Docs** | Endpoint/function documentation |
|
|
23
|
+
| **Code Comments** | Inline explanations |
|
|
24
|
+
| **Architecture** | System design documentation |
|
|
25
|
+
|
|
26
|
+
## Scripts
|
|
27
|
+
|
|
28
|
+
Generate documentation structure:
|
|
29
|
+
```bash
|
|
30
|
+
python scripts/generate_docs.py
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Validate documentation:
|
|
34
|
+
```bash
|
|
35
|
+
python scripts/validate_docs.py
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Resources
|
|
39
|
+
|
|
40
|
+
- [Google Developer Documentation Style Guide](https://developers.google.com/tech-writing/one)
|
|
41
|
+
- [Diátaxis Framework](https://diataxis.fr/)
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: documentation-engineer
|
|
3
|
+
description: Technical documentation expert for creating clear, comprehensive documentation. Use when user asks to write docs, create README, or document code.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Grep, Glob, WebFetch, WebSearch
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Documentation Engineer
|
|
8
|
+
|
|
9
|
+
Expert in creating clear, comprehensive, and maintainable technical documentation.
|
|
10
|
+
|
|
11
|
+
## When This Skill Activates
|
|
12
|
+
|
|
13
|
+
Activates when you:
|
|
14
|
+
- Ask to write documentation
|
|
15
|
+
- Request README creation
|
|
16
|
+
- Mention "docs" or "document this"
|
|
17
|
+
- Need API documentation
|
|
18
|
+
|
|
19
|
+
## Documentation Types
|
|
20
|
+
|
|
21
|
+
### 1. README
|
|
22
|
+
Every project should have a README with:
|
|
23
|
+
|
|
24
|
+
```markdown
|
|
25
|
+
# Project Name
|
|
26
|
+
|
|
27
|
+
Brief description (what it does, why it exists)
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
Installation and usage in 3 steps or less.
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
Detailed installation instructions.
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
Examples of common usage patterns.
|
|
40
|
+
|
|
41
|
+
## Configuration
|
|
42
|
+
|
|
43
|
+
Environment variables and configuration options.
|
|
44
|
+
|
|
45
|
+
## Development
|
|
46
|
+
|
|
47
|
+
How to run tests, build, and develop locally.
|
|
48
|
+
|
|
49
|
+
## Contributing
|
|
50
|
+
|
|
51
|
+
Guidelines for contributors.
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
License information.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 2. API Documentation
|
|
59
|
+
|
|
60
|
+
For each endpoint/function:
|
|
61
|
+
|
|
62
|
+
- **Description**: What it does
|
|
63
|
+
- **Parameters**: Name, type, required/optional, description
|
|
64
|
+
- **Return value**: Type and structure
|
|
65
|
+
- **Errors**: Possible errors and conditions
|
|
66
|
+
- **Examples**: Usage examples
|
|
67
|
+
|
|
68
|
+
### 3. Code Comments
|
|
69
|
+
|
|
70
|
+
Comment **why**, not **what**:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
// Bad: Sets the count to zero
|
|
74
|
+
count = 0;
|
|
75
|
+
|
|
76
|
+
// Good: Reset count for new measurement cycle
|
|
77
|
+
count = 0;
|
|
78
|
+
|
|
79
|
+
// Bad: Check if user is admin
|
|
80
|
+
if (user.role === 'admin') {
|
|
81
|
+
|
|
82
|
+
// Good: Only admins can bypass approval workflow
|
|
83
|
+
if (user.role === 'admin') {
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 4. Architecture Documentation
|
|
87
|
+
|
|
88
|
+
- System overview
|
|
89
|
+
- Component relationships
|
|
90
|
+
- Data flow
|
|
91
|
+
- Design decisions
|
|
92
|
+
- Trade-offs considered
|
|
93
|
+
|
|
94
|
+
## Documentation Principles
|
|
95
|
+
|
|
96
|
+
1. **Be Clear**: Use simple, direct language
|
|
97
|
+
2. **Be Concise**: Respect the reader's time
|
|
98
|
+
3. **Be Accurate**: Keep docs in sync with code
|
|
99
|
+
4. **Be Complete**: Cover all public interfaces
|
|
100
|
+
5. **Be Current**: Update docs when code changes
|
|
101
|
+
|
|
102
|
+
## Writing Guidelines
|
|
103
|
+
|
|
104
|
+
### Headings
|
|
105
|
+
- Use sentence case for headings
|
|
106
|
+
- Start with a verb or noun
|
|
107
|
+
- Be descriptive
|
|
108
|
+
|
|
109
|
+
### Code Examples
|
|
110
|
+
- Show before/after when appropriate
|
|
111
|
+
- Include import statements
|
|
112
|
+
- Show expected output
|
|
113
|
+
- Handle edge cases
|
|
114
|
+
|
|
115
|
+
### Links
|
|
116
|
+
- Use relative links for internal docs
|
|
117
|
+
- Include anchors for sections
|
|
118
|
+
- Test that links work
|
|
119
|
+
|
|
120
|
+
### Diagrams
|
|
121
|
+
- Use Mermaid for flowcharts and sequences
|
|
122
|
+
- Keep diagrams simple
|
|
123
|
+
- Add a title and legend
|
|
124
|
+
|
|
125
|
+
## Documentation Checklist
|
|
126
|
+
|
|
127
|
+
### README
|
|
128
|
+
- [ ] Project description
|
|
129
|
+
- [ ] Quick start guide
|
|
130
|
+
- [ ] Installation instructions
|
|
131
|
+
- [ ] Usage examples
|
|
132
|
+
- [ ] Configuration guide
|
|
133
|
+
- [ ] Contributing guidelines
|
|
134
|
+
|
|
135
|
+
### Code Docs
|
|
136
|
+
- [ ] All public functions documented
|
|
137
|
+
- [ ] Parameters and returns documented
|
|
138
|
+
- [ ] Examples provided for complex functions
|
|
139
|
+
- [ ] Edge cases documented
|
|
140
|
+
|
|
141
|
+
### API Docs
|
|
142
|
+
- [ ] All endpoints documented
|
|
143
|
+
- [ ] Request/response schemas
|
|
144
|
+
- [ ] Authentication requirements
|
|
145
|
+
- [ ] Error responses documented
|
|
146
|
+
- [ ] Rate limits documented
|
|
147
|
+
|
|
148
|
+
## Scripts
|
|
149
|
+
|
|
150
|
+
Generate documentation structure:
|
|
151
|
+
```bash
|
|
152
|
+
python scripts/generate_docs.py
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Validate documentation:
|
|
156
|
+
```bash
|
|
157
|
+
python scripts/validate_docs.py
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## References
|
|
161
|
+
|
|
162
|
+
- `references/readme-template.md` - README template
|
|
163
|
+
- `references/api-template.md` - API documentation template
|
|
164
|
+
- `references/style-guide.md` - Documentation style guide
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# API Documentation Template
|
|
2
|
+
|
|
3
|
+
## Endpoint: /resource
|
|
4
|
+
|
|
5
|
+
**Method:** GET | POST | PUT | DELETE
|
|
6
|
+
|
|
7
|
+
**Description:** What the endpoint does.
|
|
8
|
+
|
|
9
|
+
### Parameters
|
|
10
|
+
- `id` (string, required) - Resource identifier
|
|
11
|
+
|
|
12
|
+
### Response
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"data": {}
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Errors
|
|
20
|
+
- `400` Bad Request
|
|
21
|
+
- `401` Unauthorized
|
|
22
|
+
- `404` Not Found
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# README Template
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
Describe what the project does and why it exists.
|
|
5
|
+
|
|
6
|
+
## Quick Start
|
|
7
|
+
1. Install dependencies
|
|
8
|
+
2. Configure environment
|
|
9
|
+
3. Run the main command
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
- Requirements
|
|
13
|
+
- Setup steps
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
Provide common usage examples.
|
|
17
|
+
|
|
18
|
+
## Configuration
|
|
19
|
+
List environment variables and configuration options.
|
|
20
|
+
|
|
21
|
+
## Development
|
|
22
|
+
How to lint, test, and build locally.
|
|
23
|
+
|
|
24
|
+
## Contributing
|
|
25
|
+
Explain how to propose changes.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Documentation Style Guide
|
|
2
|
+
|
|
3
|
+
## Headings
|
|
4
|
+
- Use sentence case
|
|
5
|
+
- Keep headings short and specific
|
|
6
|
+
|
|
7
|
+
## Code Blocks
|
|
8
|
+
- Always specify a language
|
|
9
|
+
- Keep examples minimal and runnable
|
|
10
|
+
|
|
11
|
+
## Links
|
|
12
|
+
- Use relative links for internal docs
|
|
13
|
+
- Prefer stable URLs for external references
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Template generator for documentation scaffold.
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import argparse
|
|
6
|
+
import textwrap
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def write_output(path: Path, content: str, force: bool) -> bool:
|
|
10
|
+
if path.exists() and not force:
|
|
11
|
+
print(f"{path} already exists (use --force to overwrite)")
|
|
12
|
+
return False
|
|
13
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
14
|
+
path.write_text(content, encoding="utf-8")
|
|
15
|
+
return True
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def main() -> int:
|
|
19
|
+
parser = argparse.ArgumentParser(description="Generate documentation scaffold.")
|
|
20
|
+
parser.add_argument("--output", default="docs/README.md", help="Output file path")
|
|
21
|
+
parser.add_argument("--name", default="example", help="Product or service name")
|
|
22
|
+
parser.add_argument("--owner", default="team", help="Owning team")
|
|
23
|
+
parser.add_argument("--force", action="store_true", help="Overwrite existing file")
|
|
24
|
+
args = parser.parse_args()
|
|
25
|
+
|
|
26
|
+
content = textwrap.dedent(
|
|
27
|
+
f"""\
|
|
28
|
+
# Documentation
|
|
29
|
+
|
|
30
|
+
## Overview
|
|
31
|
+
Describe {args.name} and its purpose.
|
|
32
|
+
|
|
33
|
+
## Ownership
|
|
34
|
+
- Owner: {args.owner}
|
|
35
|
+
- Support channel: TBD
|
|
36
|
+
|
|
37
|
+
## Quickstart
|
|
38
|
+
1. Install dependencies
|
|
39
|
+
2. Configure environment
|
|
40
|
+
3. Run the service
|
|
41
|
+
|
|
42
|
+
## Configuration
|
|
43
|
+
- Required environment variables
|
|
44
|
+
- Feature flags
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
Examples for {args.name}.
|
|
48
|
+
|
|
49
|
+
## API Reference
|
|
50
|
+
- Endpoints or SDK methods
|
|
51
|
+
|
|
52
|
+
## Troubleshooting
|
|
53
|
+
- Common errors and fixes
|
|
54
|
+
|
|
55
|
+
## Changelog
|
|
56
|
+
- Recent updates
|
|
57
|
+
"""
|
|
58
|
+
).strip() + "\n"
|
|
59
|
+
|
|
60
|
+
output = Path(args.output)
|
|
61
|
+
if not write_output(output, content, args.force):
|
|
62
|
+
return 1
|
|
63
|
+
print(f"Wrote {output}")
|
|
64
|
+
return 0
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if __name__ == "__main__":
|
|
68
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Template validator for documentation scaffold.
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import argparse
|
|
6
|
+
|
|
7
|
+
DEFAULT_REQUIRED = [
|
|
8
|
+
"## Overview",
|
|
9
|
+
"## Ownership",
|
|
10
|
+
"## Quickstart",
|
|
11
|
+
"## Configuration",
|
|
12
|
+
"## Usage",
|
|
13
|
+
"## Troubleshooting",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def main() -> int:
|
|
18
|
+
parser = argparse.ArgumentParser(description="Validate a generated artifact.")
|
|
19
|
+
parser.add_argument("--input", default="docs/README.md", help="Input file path")
|
|
20
|
+
parser.add_argument(
|
|
21
|
+
"--require",
|
|
22
|
+
action="append",
|
|
23
|
+
default=[],
|
|
24
|
+
help="Additional required section heading",
|
|
25
|
+
)
|
|
26
|
+
args = parser.parse_args()
|
|
27
|
+
|
|
28
|
+
path = Path(args.input)
|
|
29
|
+
if not path.exists():
|
|
30
|
+
print(f"Missing file: {path}")
|
|
31
|
+
return 1
|
|
32
|
+
|
|
33
|
+
text = path.read_text(encoding="utf-8", errors="ignore")
|
|
34
|
+
text_lower = text.lower()
|
|
35
|
+
required = DEFAULT_REQUIRED + args.require
|
|
36
|
+
missing = [section for section in required if section.lower() not in text_lower]
|
|
37
|
+
if missing:
|
|
38
|
+
print("Missing required sections: " + ", ".join(missing))
|
|
39
|
+
return 1
|
|
40
|
+
|
|
41
|
+
print(f"Validated {path}")
|
|
42
|
+
return 0
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if __name__ == "__main__":
|
|
46
|
+
raise SystemExit(main())
|