@botlearn/doc-gen 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/LICENSE +21 -0
- package/README.md +35 -0
- package/knowledge/anti-patterns.md +70 -0
- package/knowledge/best-practices.md +154 -0
- package/knowledge/domain.md +354 -0
- package/manifest.json +28 -0
- package/package.json +38 -0
- package/skill.md +48 -0
- package/strategies/main.md +147 -0
- package/tests/benchmark.json +506 -0
- package/tests/smoke.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 BotLearn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @botlearn/doc-gen
|
|
2
|
+
|
|
3
|
+
> Automated documentation generation for APIs, READMEs, changelogs, and code-level docs — raising doc completeness from 30% to 90% for OpenClaw Agent
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# via npm
|
|
9
|
+
npm install @botlearn/doc-gen
|
|
10
|
+
|
|
11
|
+
# via clawhub
|
|
12
|
+
clawhub install @botlearn/doc-gen
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Category
|
|
16
|
+
|
|
17
|
+
programming-assistance
|
|
18
|
+
|
|
19
|
+
## Dependencies
|
|
20
|
+
|
|
21
|
+
`@botlearn/code-gen`
|
|
22
|
+
|
|
23
|
+
## Files
|
|
24
|
+
|
|
25
|
+
| File | Description |
|
|
26
|
+
|------|-------------|
|
|
27
|
+
| `manifest.json` | Skill metadata and configuration |
|
|
28
|
+
| `skill.md` | Role definition and activation rules |
|
|
29
|
+
| `knowledge/` | Domain knowledge documents |
|
|
30
|
+
| `strategies/` | Behavioral strategy definitions |
|
|
31
|
+
| `tests/` | Smoke and benchmark tests |
|
|
32
|
+
|
|
33
|
+
## License
|
|
34
|
+
|
|
35
|
+
MIT
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
domain: doc-gen
|
|
3
|
+
topic: anti-patterns
|
|
4
|
+
priority: medium
|
|
5
|
+
ttl: 30d
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Documentation Generation — Anti-Patterns
|
|
9
|
+
|
|
10
|
+
## Content Anti-Patterns
|
|
11
|
+
|
|
12
|
+
### 1. Auto-Generated Gibberish
|
|
13
|
+
- **Problem**: Generating documentation that simply restates the function name in sentence form — `getUser` becomes "Gets the user" with no additional context about parameters, return values, edge cases, or usage
|
|
14
|
+
- **Fix**: Every doc entry must add information beyond what the signature already tells the reader. Describe *behavior*, *constraints*, *side effects*, and *failure modes*. If `getUser(id)` hits a database, state that. If it caches, state the TTL. If it throws on invalid IDs, document the error
|
|
15
|
+
|
|
16
|
+
### 2. Missing Examples
|
|
17
|
+
- **Problem**: API documentation that describes what a function does but provides no example of how to call it or what output to expect. Users must read source code to understand usage patterns
|
|
18
|
+
- **Fix**: Include at least one runnable example per public function. Show input, invocation, and expected output. For complex APIs, provide a basic example and an advanced example
|
|
19
|
+
|
|
20
|
+
### 3. Stale Documentation
|
|
21
|
+
- **Problem**: Documentation that describes behavior from a previous version of the code. Parameters that no longer exist, return types that have changed, or features that have been removed are still documented
|
|
22
|
+
- **Fix**: Compare documentation against the current code before finalizing. Check that every documented parameter exists in the function signature. Verify return types match. Flag any documentation that references removed or renamed identifiers
|
|
23
|
+
|
|
24
|
+
### 4. Copy-Paste Descriptions
|
|
25
|
+
- **Problem**: Using identical descriptions across similar functions without adapting to the specific behavior of each — e.g., `createUser`, `updateUser`, `deleteUser` all described as "Manages user data"
|
|
26
|
+
- **Fix**: Each function must have a description unique to its behavior. `createUser` inserts a new record, `updateUser` modifies an existing record (partial or full), `deleteUser` removes a record (soft or hard delete). State the specific action and its implications
|
|
27
|
+
|
|
28
|
+
### 5. Undocumented Error Cases
|
|
29
|
+
- **Problem**: Documentation only covers the happy path. Users discover thrown exceptions, rejection reasons, or error codes by encountering them at runtime
|
|
30
|
+
- **Fix**: Document every error/exception the function can throw or return. Include the condition that triggers each error and the error type/code. For async functions, document both rejection reasons and possible error response shapes
|
|
31
|
+
|
|
32
|
+
## Structural Anti-Patterns
|
|
33
|
+
|
|
34
|
+
### 6. Wall of Text README
|
|
35
|
+
- **Problem**: A README that is one continuous block of prose without headings, code blocks, or visual hierarchy. Users cannot scan for the information they need
|
|
36
|
+
- **Fix**: Use the standard README structure with clear sections: Title, Install, Quick Start, API, Configuration, Contributing, License. Use headers, code blocks, tables, and bullet lists to create scannable content
|
|
37
|
+
|
|
38
|
+
### 7. Missing Installation Instructions
|
|
39
|
+
- **Problem**: Documentation assumes the reader already knows how to install and configure the project. No package manager commands, no peer dependencies listed, no environment requirements stated
|
|
40
|
+
- **Fix**: Include explicit install commands for npm/yarn/pnpm. List all peer dependencies. State the minimum Node.js/Python/runtime version. Provide a verification step
|
|
41
|
+
|
|
42
|
+
### 8. Orphaned API References
|
|
43
|
+
- **Problem**: API documentation that exists in isolation without context — a list of functions with no guidance on which to use first, how they relate, or what workflow they support
|
|
44
|
+
- **Fix**: Start API documentation with an overview section that explains the main use cases and which functions to call. Group related functions. Provide a "Getting Started" flow that walks through the primary workflow
|
|
45
|
+
|
|
46
|
+
### 9. Inconsistent Formatting
|
|
47
|
+
- **Problem**: Documentation mixes different styles: some functions use JSDoc, others use plain comments; some parameters are in tables, others in bullet lists; some examples use TypeScript, others plain JavaScript
|
|
48
|
+
- **Fix**: Establish and follow a single documentation style guide. All functions use the same tag format. All parameters use the same presentation (table or list). All examples use the same language and style. Run a linter if available
|
|
49
|
+
|
|
50
|
+
### 10. Changelog as Commit Log
|
|
51
|
+
- **Problem**: The changelog is a raw dump of git commit messages — cryptic, inconsistent, and full of noise like "fix typo", "wip", "merge branch"
|
|
52
|
+
- **Fix**: Curate changelog entries to describe user-facing changes only. Group by category (Added, Changed, Fixed, etc.). Write entries in imperative mood. Exclude internal refactors, typo fixes, and CI changes unless they affect users. Reference issue numbers
|
|
53
|
+
|
|
54
|
+
## Quality Anti-Patterns
|
|
55
|
+
|
|
56
|
+
### 11. Type Information Without Context
|
|
57
|
+
- **Problem**: Documenting that a parameter is `string` without explaining what string values are valid — e.g., "id: string" tells the reader nothing about format (UUID? slug? numeric string?), length constraints, or validation rules
|
|
58
|
+
- **Fix**: Always include semantic context with types: "id: string — A UUID v4 identifying the user (e.g., `550e8400-e29b-41d4-a716-446655440000`)" or "status: string — One of `active`, `suspended`, `deleted`"
|
|
59
|
+
|
|
60
|
+
### 12. Documenting Private Internals as Public API
|
|
61
|
+
- **Problem**: Documentation includes internal helper functions, private methods, or implementation details that users should not depend on, creating an implied contract on unstable APIs
|
|
62
|
+
- **Fix**: Clearly separate public and internal documentation. Mark private/internal functions with `@internal` or `@private`. Exclude them from generated API docs by default. If internal details are documented for contributors, place them in a separate section or file (e.g., `ARCHITECTURE.md`)
|
|
63
|
+
|
|
64
|
+
### 13. No Deprecation Migration Path
|
|
65
|
+
- **Problem**: Marking a function as deprecated without explaining what to use instead or how to migrate existing code
|
|
66
|
+
- **Fix**: Every deprecation notice must include: (1) what to use instead, (2) a code example showing the migration from old to new, (3) the version when the deprecated API will be removed. Example: `@deprecated Since v2.0. Use fetchUser() instead. Will be removed in v3.0.`
|
|
67
|
+
|
|
68
|
+
### 14. Version-Blind Documentation
|
|
69
|
+
- **Problem**: Documentation does not indicate which version of the software it applies to. Users on older versions follow instructions that fail, or miss features available in their version
|
|
70
|
+
- **Fix**: Use `@since` tags to mark when APIs were introduced. Include version badges on READMEs. In changelogs, ensure version numbers and dates are accurate. For multi-version projects, provide version-specific documentation or clearly mark version requirements
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
---
|
|
2
|
+
domain: doc-gen
|
|
3
|
+
topic: documentation-quality-and-coverage
|
|
4
|
+
priority: high
|
|
5
|
+
ttl: 30d
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Documentation Generation — Best Practices
|
|
9
|
+
|
|
10
|
+
## API Documentation Coverage
|
|
11
|
+
|
|
12
|
+
### 1. Completeness Checklist
|
|
13
|
+
Every public API entry point must have:
|
|
14
|
+
- **Summary** — One-sentence description of what the function/method does
|
|
15
|
+
- **Description** — Detailed explanation of behavior, including edge cases
|
|
16
|
+
- **Parameters** — Every parameter with name, type, default value, constraints, and description
|
|
17
|
+
- **Return value** — Type and description of what is returned, including null/undefined cases
|
|
18
|
+
- **Errors/Exceptions** — All throwable errors with conditions that trigger them
|
|
19
|
+
- **Examples** — At least one usage example with realistic input and expected output
|
|
20
|
+
- **Since/Version** — When the API was introduced or last changed
|
|
21
|
+
|
|
22
|
+
### 2. Coverage Metrics
|
|
23
|
+
Target documentation coverage levels:
|
|
24
|
+
|
|
25
|
+
| Level | Coverage | Description |
|
|
26
|
+
|-------|----------|-------------|
|
|
27
|
+
| Minimal | 30% | Only function names and parameter names |
|
|
28
|
+
| Basic | 50% | Summaries + parameter types |
|
|
29
|
+
| Good | 70% | Full descriptions + return values + errors |
|
|
30
|
+
| Excellent | 85% | All of above + examples + cross-references |
|
|
31
|
+
| Complete | 90%+ | Full coverage including edge cases, deprecation notices, and migration guides |
|
|
32
|
+
|
|
33
|
+
### 3. Measuring Coverage
|
|
34
|
+
- Count **public exports** (functions, classes, types, constants) as the denominator
|
|
35
|
+
- Count **fully documented** exports (meeting "Good" level) as the numerator
|
|
36
|
+
- Report per-module coverage alongside aggregate project coverage
|
|
37
|
+
|
|
38
|
+
## Example Quality Standards
|
|
39
|
+
|
|
40
|
+
### Write Examples That Teach
|
|
41
|
+
- Start with the **simplest possible usage** — demonstrate the happy path first
|
|
42
|
+
- Follow with **common variations** — optional parameters, configuration options
|
|
43
|
+
- End with **edge cases** — error handling, boundary conditions
|
|
44
|
+
- Use **realistic data** — avoid `foo`, `bar`, `test123`; use domain-appropriate values
|
|
45
|
+
|
|
46
|
+
### Example Structure Template
|
|
47
|
+
```javascript
|
|
48
|
+
// 1. Basic usage — what most users need
|
|
49
|
+
const client = new ApiClient({ baseUrl: 'https://api.example.com' });
|
|
50
|
+
const user = await client.getUser('usr_abc123');
|
|
51
|
+
// => { id: 'usr_abc123', name: 'Alice', email: 'alice@example.com' }
|
|
52
|
+
|
|
53
|
+
// 2. With options — common customization
|
|
54
|
+
const users = await client.listUsers({ limit: 10, role: 'admin' });
|
|
55
|
+
// => [{ id: 'usr_abc123', ... }, ...]
|
|
56
|
+
|
|
57
|
+
// 3. Error handling — what can go wrong
|
|
58
|
+
try {
|
|
59
|
+
await client.getUser('nonexistent');
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (error instanceof NotFoundError) {
|
|
62
|
+
console.log(error.message); // => "User not found: nonexistent"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Example Anti-Patterns to Avoid
|
|
68
|
+
- Trivial examples that don't demonstrate real value: `add(1, 2) // => 3`
|
|
69
|
+
- Examples that depend on external state without setup context
|
|
70
|
+
- Examples with fictional imports or unavailable dependencies
|
|
71
|
+
- Missing expected output — always show the return value
|
|
72
|
+
|
|
73
|
+
## Consistent Style Guide
|
|
74
|
+
|
|
75
|
+
### Tone and Voice
|
|
76
|
+
- Use **second person** ("you") for guides and tutorials
|
|
77
|
+
- Use **third person** for API references ("Returns the user object")
|
|
78
|
+
- Write in **active voice**: "The function returns..." not "The value is returned by..."
|
|
79
|
+
- Be **concise but complete** — avoid filler phrases like "It should be noted that..."
|
|
80
|
+
|
|
81
|
+
### Formatting Conventions
|
|
82
|
+
- **Function names** in backticks: `getUserById()`
|
|
83
|
+
- **Parameter names** in backticks: `userId`
|
|
84
|
+
- **Type names** in backticks: `Promise<User>`
|
|
85
|
+
- **File paths** in backticks: `src/models/user.ts`
|
|
86
|
+
- **Code blocks** with language identifier: ` ```typescript `
|
|
87
|
+
- **Tables** for structured data (parameters, configuration, comparison)
|
|
88
|
+
- **Admonitions** for warnings, notes, and tips
|
|
89
|
+
|
|
90
|
+
### Description Patterns
|
|
91
|
+
| Element | Pattern | Example |
|
|
92
|
+
|---------|---------|---------|
|
|
93
|
+
| Function | "Verb + object + context" | "Retrieve a user by their unique identifier" |
|
|
94
|
+
| Parameter | "The + noun + constraint" | "The user's email address (must be valid RFC 5322)" |
|
|
95
|
+
| Return | "The + result + condition" | "The matching user, or undefined if not found" |
|
|
96
|
+
| Error | "Thrown when + condition" | "Thrown when the user ID does not exist" |
|
|
97
|
+
| Class | "A + noun + purpose" | "A thread-safe cache for storing session data" |
|
|
98
|
+
|
|
99
|
+
### Cross-Referencing
|
|
100
|
+
- Link related functions: "See also: `updateUser()`, `deleteUser()`"
|
|
101
|
+
- Reference parent class/module: "Part of the `UserRepository` class"
|
|
102
|
+
- Link to external specs: "Implements [RFC 7519](https://tools.ietf.org/html/rfc7519)"
|
|
103
|
+
|
|
104
|
+
## README Quality Criteria
|
|
105
|
+
|
|
106
|
+
### Quick Start Must Work
|
|
107
|
+
- The quick-start code block must be **copy-pasteable** and runnable
|
|
108
|
+
- Include all necessary imports and setup
|
|
109
|
+
- Show the minimum viable usage in under 10 lines
|
|
110
|
+
- Verify the quick start works by mentally or actually running it
|
|
111
|
+
|
|
112
|
+
### Installation Completeness
|
|
113
|
+
- Include **all package managers**: npm, yarn, pnpm
|
|
114
|
+
- Note **peer dependencies** that must be installed separately
|
|
115
|
+
- Include **environment requirements**: Node.js version, OS compatibility
|
|
116
|
+
- Show **verification**: a quick command to verify successful installation
|
|
117
|
+
|
|
118
|
+
### API Reference Organization
|
|
119
|
+
- Group by **module or feature area**, not alphabetically
|
|
120
|
+
- Show most commonly used APIs first
|
|
121
|
+
- Clearly mark **optional** vs **required** parameters
|
|
122
|
+
- Include return type in the function signature header
|
|
123
|
+
|
|
124
|
+
## Changelog Quality Criteria
|
|
125
|
+
|
|
126
|
+
### Entry Guidelines
|
|
127
|
+
- Each entry must be **understandable without reading code** — describe the user impact
|
|
128
|
+
- Use **imperative mood**: "Add batch user creation" not "Added batch user creation"
|
|
129
|
+
- Include **issue/PR references** when applicable: `(#234)`
|
|
130
|
+
- Mark **breaking changes** prominently with migration instructions
|
|
131
|
+
- Group related changes under the same category
|
|
132
|
+
- Order entries by impact within each category (most impactful first)
|
|
133
|
+
|
|
134
|
+
### Version Semantics
|
|
135
|
+
| Change Type | Version Bump | Example |
|
|
136
|
+
|------------|-------------|---------|
|
|
137
|
+
| Breaking API change | Major (X.0.0) | Renamed `getUser` to `fetchUser` |
|
|
138
|
+
| New feature (backward-compatible) | Minor (0.X.0) | Added `batchCreate` endpoint |
|
|
139
|
+
| Bug fix | Patch (0.0.X) | Fixed null pointer in `deleteUser` |
|
|
140
|
+
| Deprecation notice | Minor (0.X.0) | Deprecated `searchUsers` |
|
|
141
|
+
| Security fix | Patch (0.0.X) | Patched SQL injection |
|
|
142
|
+
|
|
143
|
+
## Documentation Maintenance
|
|
144
|
+
|
|
145
|
+
### Freshness Checks
|
|
146
|
+
- Verify documentation accuracy when the underlying code changes
|
|
147
|
+
- Flag documentation older than the most recent code change as potentially stale
|
|
148
|
+
- Include "Last updated" dates on long-form documents
|
|
149
|
+
- Run doc-coverage reports as part of CI to detect regressions
|
|
150
|
+
|
|
151
|
+
### Documentation-Code Sync
|
|
152
|
+
- Document during development, not after — prevents drift
|
|
153
|
+
- Use automated tools (typedoc, swagger-jsdoc) to generate from annotations where possible
|
|
154
|
+
- Treat documentation changes as part of the same PR as code changes
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
---
|
|
2
|
+
domain: doc-gen
|
|
3
|
+
topic: documentation-formats-and-syntax
|
|
4
|
+
priority: high
|
|
5
|
+
ttl: 30d
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Documentation Generation — Formats, Syntax & Conventions
|
|
9
|
+
|
|
10
|
+
## JSDoc / TSDoc Syntax
|
|
11
|
+
|
|
12
|
+
### Basic Function Documentation
|
|
13
|
+
```javascript
|
|
14
|
+
/**
|
|
15
|
+
* Calculate the total price including tax and optional discount.
|
|
16
|
+
*
|
|
17
|
+
* @param {number} basePrice - The pre-tax price in cents
|
|
18
|
+
* @param {number} taxRate - Tax rate as a decimal (e.g., 0.08 for 8%)
|
|
19
|
+
* @param {number} [discount=0] - Optional discount amount in cents
|
|
20
|
+
* @returns {number} The final price in cents, rounded to the nearest integer
|
|
21
|
+
* @throws {RangeError} If basePrice or taxRate is negative
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Basic usage
|
|
25
|
+
* calculateTotal(1000, 0.08);
|
|
26
|
+
* // => 1080
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // With discount
|
|
30
|
+
* calculateTotal(1000, 0.08, 100);
|
|
31
|
+
* // => 980
|
|
32
|
+
*/
|
|
33
|
+
function calculateTotal(basePrice, taxRate, discount = 0) { ... }
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Common JSDoc Tags
|
|
37
|
+
| Tag | Purpose | Example |
|
|
38
|
+
|-----|---------|---------|
|
|
39
|
+
| `@param` | Document a parameter | `@param {string} name - The user's name` |
|
|
40
|
+
| `@returns` | Document the return value | `@returns {Promise<User>} The resolved user` |
|
|
41
|
+
| `@throws` | Document thrown errors | `@throws {NotFoundError} If user does not exist` |
|
|
42
|
+
| `@example` | Provide usage example | Code block with input/output |
|
|
43
|
+
| `@deprecated` | Mark as deprecated | `@deprecated Use newMethod() instead` |
|
|
44
|
+
| `@since` | Version introduced | `@since 2.1.0` |
|
|
45
|
+
| `@see` | Cross-reference | `@see {@link OtherClass}` |
|
|
46
|
+
| `@typedef` | Define a custom type | `@typedef {Object} Config` |
|
|
47
|
+
| `@property` | Document object property | `@property {string} name - Display name` |
|
|
48
|
+
| `@async` | Mark as async | For async functions |
|
|
49
|
+
| `@private` | Mark as private | Excluded from public docs |
|
|
50
|
+
| `@public` | Mark as public | Included in public docs |
|
|
51
|
+
|
|
52
|
+
### TypeScript-Specific TSDoc
|
|
53
|
+
```typescript
|
|
54
|
+
/**
|
|
55
|
+
* Repository for managing user entities.
|
|
56
|
+
*
|
|
57
|
+
* @typeParam T - The entity type extending BaseUser
|
|
58
|
+
* @remarks
|
|
59
|
+
* This class implements the Repository pattern for user management.
|
|
60
|
+
* All methods are transaction-safe.
|
|
61
|
+
*/
|
|
62
|
+
class UserRepository<T extends BaseUser> {
|
|
63
|
+
/**
|
|
64
|
+
* Find a user by their unique identifier.
|
|
65
|
+
*
|
|
66
|
+
* @param id - The user's UUID
|
|
67
|
+
* @returns The user entity or undefined if not found
|
|
68
|
+
*/
|
|
69
|
+
async findById(id: string): Promise<T | undefined> { ... }
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Python Docstrings (Google Style)
|
|
74
|
+
```python
|
|
75
|
+
def fetch_data(url: str, timeout: int = 30, retries: int = 3) -> dict:
|
|
76
|
+
"""Fetch JSON data from a remote endpoint with retry logic.
|
|
77
|
+
|
|
78
|
+
Sends an HTTP GET request to the specified URL and returns the
|
|
79
|
+
parsed JSON response. Implements exponential backoff on failure.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
url: The fully-qualified URL to fetch from.
|
|
83
|
+
timeout: Request timeout in seconds. Defaults to 30.
|
|
84
|
+
retries: Maximum number of retry attempts. Defaults to 3.
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
A dictionary containing the parsed JSON response body.
|
|
88
|
+
|
|
89
|
+
Raises:
|
|
90
|
+
ConnectionError: If all retry attempts are exhausted.
|
|
91
|
+
ValueError: If the response is not valid JSON.
|
|
92
|
+
|
|
93
|
+
Example:
|
|
94
|
+
>>> data = fetch_data("https://api.example.com/users")
|
|
95
|
+
>>> print(data["count"])
|
|
96
|
+
42
|
|
97
|
+
"""
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## OpenAPI 3.x Specification
|
|
101
|
+
|
|
102
|
+
### Minimal Endpoint Definition
|
|
103
|
+
```yaml
|
|
104
|
+
openapi: 3.0.3
|
|
105
|
+
info:
|
|
106
|
+
title: User Management API
|
|
107
|
+
version: 1.0.0
|
|
108
|
+
description: RESTful API for managing user accounts and profiles.
|
|
109
|
+
|
|
110
|
+
paths:
|
|
111
|
+
/users/{userId}:
|
|
112
|
+
get:
|
|
113
|
+
operationId: getUserById
|
|
114
|
+
summary: Retrieve a user by ID
|
|
115
|
+
description: |
|
|
116
|
+
Returns the full user profile for the given user ID.
|
|
117
|
+
Requires authentication via Bearer token.
|
|
118
|
+
tags:
|
|
119
|
+
- Users
|
|
120
|
+
parameters:
|
|
121
|
+
- name: userId
|
|
122
|
+
in: path
|
|
123
|
+
required: true
|
|
124
|
+
description: The unique identifier of the user (UUID v4)
|
|
125
|
+
schema:
|
|
126
|
+
type: string
|
|
127
|
+
format: uuid
|
|
128
|
+
example: "550e8400-e29b-41d4-a716-446655440000"
|
|
129
|
+
responses:
|
|
130
|
+
"200":
|
|
131
|
+
description: User found and returned successfully
|
|
132
|
+
content:
|
|
133
|
+
application/json:
|
|
134
|
+
schema:
|
|
135
|
+
$ref: "#/components/schemas/User"
|
|
136
|
+
example:
|
|
137
|
+
id: "550e8400-e29b-41d4-a716-446655440000"
|
|
138
|
+
name: "Alice Johnson"
|
|
139
|
+
email: "alice@example.com"
|
|
140
|
+
createdAt: "2024-01-15T08:30:00Z"
|
|
141
|
+
"404":
|
|
142
|
+
description: User not found
|
|
143
|
+
content:
|
|
144
|
+
application/json:
|
|
145
|
+
schema:
|
|
146
|
+
$ref: "#/components/schemas/Error"
|
|
147
|
+
example:
|
|
148
|
+
code: "USER_NOT_FOUND"
|
|
149
|
+
message: "No user exists with the given ID"
|
|
150
|
+
"401":
|
|
151
|
+
description: Authentication required
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Component Schemas
|
|
155
|
+
```yaml
|
|
156
|
+
components:
|
|
157
|
+
schemas:
|
|
158
|
+
User:
|
|
159
|
+
type: object
|
|
160
|
+
required: [id, name, email, createdAt]
|
|
161
|
+
properties:
|
|
162
|
+
id:
|
|
163
|
+
type: string
|
|
164
|
+
format: uuid
|
|
165
|
+
description: Unique user identifier
|
|
166
|
+
name:
|
|
167
|
+
type: string
|
|
168
|
+
minLength: 1
|
|
169
|
+
maxLength: 100
|
|
170
|
+
description: Full display name
|
|
171
|
+
email:
|
|
172
|
+
type: string
|
|
173
|
+
format: email
|
|
174
|
+
description: Primary email address
|
|
175
|
+
createdAt:
|
|
176
|
+
type: string
|
|
177
|
+
format: date-time
|
|
178
|
+
description: Account creation timestamp (ISO 8601)
|
|
179
|
+
Error:
|
|
180
|
+
type: object
|
|
181
|
+
required: [code, message]
|
|
182
|
+
properties:
|
|
183
|
+
code:
|
|
184
|
+
type: string
|
|
185
|
+
description: Machine-readable error code
|
|
186
|
+
message:
|
|
187
|
+
type: string
|
|
188
|
+
description: Human-readable error description
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Key OpenAPI Elements
|
|
192
|
+
| Element | Purpose | Required |
|
|
193
|
+
|---------|---------|----------|
|
|
194
|
+
| `operationId` | Unique identifier for the operation | Recommended |
|
|
195
|
+
| `summary` | Short one-line description | Yes |
|
|
196
|
+
| `description` | Detailed multi-line description | Recommended |
|
|
197
|
+
| `tags` | Group related endpoints | Recommended |
|
|
198
|
+
| `parameters` | Path, query, header params | As needed |
|
|
199
|
+
| `requestBody` | POST/PUT/PATCH payload | As needed |
|
|
200
|
+
| `responses` | All possible responses | Yes |
|
|
201
|
+
| `security` | Auth requirements | As needed |
|
|
202
|
+
| `examples` | Request/response examples | Recommended |
|
|
203
|
+
|
|
204
|
+
## README Conventions
|
|
205
|
+
|
|
206
|
+
### Standard README Structure
|
|
207
|
+
```markdown
|
|
208
|
+
# Project Name
|
|
209
|
+
|
|
210
|
+
> One-line description of what the project does.
|
|
211
|
+
|
|
212
|
+
[](...)
|
|
213
|
+
[](...)
|
|
214
|
+
[](...)
|
|
215
|
+
|
|
216
|
+
## Features
|
|
217
|
+
|
|
218
|
+
- Feature 1 — brief description
|
|
219
|
+
- Feature 2 — brief description
|
|
220
|
+
- Feature 3 — brief description
|
|
221
|
+
|
|
222
|
+
## Installation
|
|
223
|
+
|
|
224
|
+
\`\`\`bash
|
|
225
|
+
npm install package-name
|
|
226
|
+
\`\`\`
|
|
227
|
+
|
|
228
|
+
## Quick Start
|
|
229
|
+
|
|
230
|
+
\`\`\`javascript
|
|
231
|
+
import { Something } from 'package-name';
|
|
232
|
+
|
|
233
|
+
const result = Something.doWork({ input: 'example' });
|
|
234
|
+
console.log(result);
|
|
235
|
+
\`\`\`
|
|
236
|
+
|
|
237
|
+
## API Reference
|
|
238
|
+
|
|
239
|
+
### `functionName(param1, param2)`
|
|
240
|
+
|
|
241
|
+
Description of the function.
|
|
242
|
+
|
|
243
|
+
**Parameters:**
|
|
244
|
+
| Name | Type | Default | Description |
|
|
245
|
+
|------|------|---------|-------------|
|
|
246
|
+
| `param1` | `string` | — | Description |
|
|
247
|
+
| `param2` | `number` | `10` | Description |
|
|
248
|
+
|
|
249
|
+
**Returns:** `Promise<Result>` — Description of return value.
|
|
250
|
+
|
|
251
|
+
**Example:**
|
|
252
|
+
\`\`\`javascript
|
|
253
|
+
const result = await functionName('hello', 42);
|
|
254
|
+
\`\`\`
|
|
255
|
+
|
|
256
|
+
## Configuration
|
|
257
|
+
|
|
258
|
+
| Option | Type | Default | Description |
|
|
259
|
+
|--------|------|---------|-------------|
|
|
260
|
+
| `debug` | `boolean` | `false` | Enable debug logging |
|
|
261
|
+
| `timeout` | `number` | `5000` | Request timeout in ms |
|
|
262
|
+
|
|
263
|
+
## Contributing
|
|
264
|
+
|
|
265
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup and guidelines.
|
|
266
|
+
|
|
267
|
+
## License
|
|
268
|
+
|
|
269
|
+
[MIT](./LICENSE) © Author Name
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### README Section Priority
|
|
273
|
+
| Section | Priority | When to Include |
|
|
274
|
+
|---------|----------|----------------|
|
|
275
|
+
| Title + description | Required | Always |
|
|
276
|
+
| Installation | Required | Always |
|
|
277
|
+
| Quick Start / Usage | Required | Always |
|
|
278
|
+
| API Reference | Required | For libraries |
|
|
279
|
+
| Configuration | Required | If configurable |
|
|
280
|
+
| Features | Recommended | When non-obvious |
|
|
281
|
+
| Badges | Recommended | For published packages |
|
|
282
|
+
| Contributing | Recommended | For open-source |
|
|
283
|
+
| License | Required | Always |
|
|
284
|
+
| Changelog link | Recommended | For versioned projects |
|
|
285
|
+
|
|
286
|
+
## Changelog Format (Keep a Changelog)
|
|
287
|
+
|
|
288
|
+
### Standard Structure
|
|
289
|
+
```markdown
|
|
290
|
+
# Changelog
|
|
291
|
+
|
|
292
|
+
All notable changes to this project will be documented in this file.
|
|
293
|
+
|
|
294
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
295
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
296
|
+
|
|
297
|
+
## [Unreleased]
|
|
298
|
+
|
|
299
|
+
### Added
|
|
300
|
+
- New user profile endpoint (`GET /users/:id/profile`)
|
|
301
|
+
|
|
302
|
+
### Changed
|
|
303
|
+
- Improved error messages for validation failures
|
|
304
|
+
|
|
305
|
+
## [1.2.0] - 2024-08-15
|
|
306
|
+
|
|
307
|
+
### Added
|
|
308
|
+
- Batch user creation endpoint (`POST /users/batch`)
|
|
309
|
+
- Rate limiting middleware with configurable thresholds
|
|
310
|
+
|
|
311
|
+
### Fixed
|
|
312
|
+
- Race condition in concurrent session updates (#234)
|
|
313
|
+
- Memory leak in WebSocket connection handler (#228)
|
|
314
|
+
|
|
315
|
+
### Deprecated
|
|
316
|
+
- `GET /users/search` — use `GET /users?q=` instead (removal in 2.0.0)
|
|
317
|
+
|
|
318
|
+
## [1.1.0] - 2024-07-01
|
|
319
|
+
|
|
320
|
+
### Added
|
|
321
|
+
- OAuth 2.0 PKCE authentication flow
|
|
322
|
+
- Refresh token rotation
|
|
323
|
+
|
|
324
|
+
### Changed
|
|
325
|
+
- Upgraded bcrypt to v5.1.0 for improved performance
|
|
326
|
+
|
|
327
|
+
### Security
|
|
328
|
+
- Patched XSS vulnerability in user input sanitization (CVE-2024-XXXXX)
|
|
329
|
+
|
|
330
|
+
[Unreleased]: https://github.com/org/repo/compare/v1.2.0...HEAD
|
|
331
|
+
[1.2.0]: https://github.com/org/repo/compare/v1.1.0...v1.2.0
|
|
332
|
+
[1.1.0]: https://github.com/org/repo/releases/tag/v1.1.0
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### Changelog Categories
|
|
336
|
+
| Category | Use For |
|
|
337
|
+
|----------|---------|
|
|
338
|
+
| `Added` | New features |
|
|
339
|
+
| `Changed` | Changes to existing functionality |
|
|
340
|
+
| `Deprecated` | Features that will be removed |
|
|
341
|
+
| `Removed` | Features that have been removed |
|
|
342
|
+
| `Fixed` | Bug fixes |
|
|
343
|
+
| `Security` | Vulnerability patches |
|
|
344
|
+
|
|
345
|
+
### Commit-to-Changelog Mapping
|
|
346
|
+
| Commit Prefix | Changelog Category |
|
|
347
|
+
|--------------|-------------------|
|
|
348
|
+
| `feat:` | Added |
|
|
349
|
+
| `fix:` | Fixed |
|
|
350
|
+
| `refactor:` | Changed |
|
|
351
|
+
| `deprecate:` | Deprecated |
|
|
352
|
+
| `perf:` | Changed |
|
|
353
|
+
| `security:` | Security |
|
|
354
|
+
| `BREAKING CHANGE:` | Changed (major version) |
|
package/manifest.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@botlearn/doc-gen",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Automated documentation generation for APIs, READMEs, changelogs, and code-level docs — raising doc completeness from 30% to 90% for OpenClaw Agent",
|
|
5
|
+
"category": "programming-assistance",
|
|
6
|
+
"author": "BotLearn",
|
|
7
|
+
"benchmarkDimension": "code-generation",
|
|
8
|
+
"expectedImprovement": 30,
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@botlearn/code-gen": "^1.0.0"
|
|
11
|
+
},
|
|
12
|
+
"compatibility": {
|
|
13
|
+
"openclaw": ">=0.5.0"
|
|
14
|
+
},
|
|
15
|
+
"files": {
|
|
16
|
+
"skill": "skill.md",
|
|
17
|
+
"knowledge": [
|
|
18
|
+
"knowledge/domain.md",
|
|
19
|
+
"knowledge/best-practices.md",
|
|
20
|
+
"knowledge/anti-patterns.md"
|
|
21
|
+
],
|
|
22
|
+
"strategies": [
|
|
23
|
+
"strategies/main.md"
|
|
24
|
+
],
|
|
25
|
+
"smokeTest": "tests/smoke.json",
|
|
26
|
+
"benchmark": "tests/benchmark.json"
|
|
27
|
+
}
|
|
28
|
+
}
|