forge-workflow 1.4.9 → 1.5.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/docs/SETUP.md CHANGED
@@ -27,6 +27,12 @@ npm install forge-workflow
27
27
  npx forge setup
28
28
  ```
29
29
 
30
+ **Interactive prompts**:
31
+ 1. Which agents do you use?
32
+ 2. Install Beads? (y/n) - Git-backed issue tracking
33
+ 3. Install OpenSpec? (y/n) - Spec-driven development
34
+ 4. Configure external services? (optional)
35
+
30
36
  **What gets created**:
31
37
  - `AGENTS.md` - Universal instructions (always)
32
38
  - Agent-specific files based on your selection
package/docs/TOOLCHAIN.md CHANGED
@@ -47,11 +47,24 @@ Complete reference for all tools integrated with the Forge workflow.
47
47
 
48
48
  ### Installation
49
49
 
50
+ **Auto-installation** (Recommended):
50
51
  ```bash
51
- # npm (recommended)
52
+ npx forge setup
53
+ # Prompts: "Install Beads? (y/n)"
54
+ # Automatically installs and initializes
55
+ ```
56
+
57
+ **Manual installation**:
58
+ ```bash
59
+ # npm (global)
52
60
  npm install -g @beads/bd
61
+ bd init
62
+
63
+ # npm (local)
64
+ npm install -D @beads/bd
65
+ npx bd init
53
66
 
54
- # Or with bunx (no global install)
67
+ # Or with bunx (no install needed)
55
68
  bunx @beads/bd init
56
69
  ```
57
70
 
@@ -216,11 +229,24 @@ bd sync # Always sync at end!
216
229
 
217
230
  ### Installation
218
231
 
232
+ **Auto-installation** (Recommended):
219
233
  ```bash
220
- # npm (requires Node.js 20.19+)
234
+ npx forge setup
235
+ # Prompts: "Install OpenSpec? (y/n)"
236
+ # Automatically installs and initializes (if selected)
237
+ ```
238
+
239
+ **Manual installation**:
240
+ ```bash
241
+ # npm (global - requires Node.js 20.19+)
221
242
  npm install -g @fission-ai/openspec
243
+ openspec init
244
+
245
+ # npm (local)
246
+ npm install -D @fission-ai/openspec
247
+ npx openspec init
222
248
 
223
- # Or with bunx
249
+ # Or with bunx (no install needed)
224
250
  bunx @fission-ai/openspec init
225
251
  ```
226
252
 
@@ -0,0 +1,363 @@
1
+ # Validation & Enforcement
2
+
3
+ Forge includes built-in validation and TDD enforcement to ensure quality and consistency.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Git Hooks](#git-hooks)
8
+ - [Validation CLI](#validation-cli)
9
+ - [Validators by Stage](#validators-by-stage)
10
+ - [Override Mechanisms](#override-mechanisms)
11
+ - [Configuration](#configuration)
12
+
13
+ ---
14
+
15
+ ## Git Hooks
16
+
17
+ Forge uses [Lefthook](https://github.com/evilmartians/lefthook) for fast, language-agnostic git hooks.
18
+
19
+ ### Pre-Commit Hook
20
+
21
+ **Purpose**: Enforce TDD by blocking commits of source code without tests.
22
+
23
+ **Trigger**: Before every commit
24
+
25
+ **Checks**:
26
+ - Detects staged source files (`.js`, `.ts`, `.py`, `.go`, `.java`, `.rb`, etc.)
27
+ - Verifies corresponding test files exist (`.test.js`, `.spec.ts`, etc.)
28
+ - Excludes config files, test files, and documentation
29
+
30
+ **Behavior**:
31
+ When source code lacks tests, offers guided recovery:
32
+
33
+ ```
34
+ ⚠️ Looks like you're committing source code without tests:
35
+
36
+ - src/user-service.js
37
+
38
+ 📋 TDD Reminder:
39
+ Write tests BEFORE implementation (RED-GREEN-REFACTOR)
40
+
41
+ What would you like to do?
42
+ 1. Unstage source files (keep tests staged)
43
+ 2. Continue anyway (I have a good reason)
44
+ 3. Abort commit (let me add tests)
45
+
46
+ Your choice (1-3):
47
+ ```
48
+
49
+ **Override**:
50
+ ```bash
51
+ git commit --no-verify # Skip in emergencies
52
+ ```
53
+
54
+ ### Pre-Push Hook
55
+
56
+ **Purpose**: Ensure all tests pass before pushing to remote.
57
+
58
+ **Trigger**: Before every push
59
+
60
+ **Checks**:
61
+ - Runs `npm test`
62
+ - Verifies all tests pass
63
+
64
+ **Override**:
65
+ ```bash
66
+ LEFTHOOK=0 git push # Skip all hooks
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Validation CLI
72
+
73
+ The `forge-validate` CLI checks prerequisites for each workflow stage.
74
+
75
+ ### Usage
76
+
77
+ ```bash
78
+ forge-validate <command>
79
+ ```
80
+
81
+ ### Commands
82
+
83
+ | Command | Purpose | When to Use |
84
+ |---------|---------|-------------|
85
+ | `status` | Check project prerequisites | Setup, onboarding |
86
+ | `dev` | Validate before `/dev` | Before implementation |
87
+ | `ship` | Validate before `/ship` | Before creating PR |
88
+
89
+ ---
90
+
91
+ ## Validators by Stage
92
+
93
+ ### `forge-validate status`
94
+
95
+ **Purpose**: Check basic project setup
96
+
97
+ **Checks**:
98
+ - ✓ Git repository initialized
99
+ - ✓ `package.json` exists
100
+ - ✓ Test framework configured (`npm test` script)
101
+ - ✓ Node.js installed
102
+
103
+ **Example**:
104
+ ```bash
105
+ $ forge-validate status
106
+
107
+ Checking project prerequisites...
108
+
109
+ Validation Results:
110
+
111
+ ✓ Git repository
112
+ ✓ package.json exists
113
+ ✓ Test framework configured
114
+ ✓ Node.js installed
115
+
116
+ ✅ All checks passed!
117
+ ```
118
+
119
+ ---
120
+
121
+ ### `forge-validate dev`
122
+
123
+ **Purpose**: Validate before starting implementation (`/dev`)
124
+
125
+ **Checks**:
126
+ - ✓ On feature branch (`feat/*`, `fix/*`, `docs/*`)
127
+ - ✓ Plan file exists (`.claude/plans/*.md`)
128
+ - ✓ Research file exists (`docs/research/*.md`)
129
+ - ✓ Test directory exists
130
+
131
+ **Example**:
132
+ ```bash
133
+ $ forge-validate dev
134
+
135
+ Validating prerequisites for /dev stage...
136
+
137
+ Validation Results:
138
+
139
+ ✓ On feature branch
140
+ ✓ Plan file exists
141
+ ✓ Research file exists
142
+ ✓ Test directory exists
143
+
144
+ ✅ All checks passed!
145
+ ```
146
+
147
+ **Failed Example**:
148
+ ```bash
149
+ $ forge-validate dev
150
+
151
+ Validating prerequisites for /dev stage...
152
+
153
+ Validation Results:
154
+
155
+ ✗ On feature branch
156
+ Not on a feature branch. Create one: git checkout -b feat/your-feature
157
+ ✓ Plan file exists
158
+ ✗ Research file exists
159
+ No research file found in docs/research/. Run: /research
160
+
161
+ ❌ Some checks failed. Please fix the issues above.
162
+ ```
163
+
164
+ ---
165
+
166
+ ### `forge-validate ship`
167
+
168
+ **Purpose**: Validate before creating PR (`/ship`)
169
+
170
+ **Checks**:
171
+ - ✓ Tests exist (`.test.js`, `.spec.ts` files)
172
+ - ✓ Tests pass (`npm test` succeeds)
173
+ - ✓ Documentation updated (`README.md` or `docs/`)
174
+ - ✓ No uncommitted changes
175
+
176
+ **Example**:
177
+ ```bash
178
+ $ forge-validate ship
179
+
180
+ Validating prerequisites for /ship stage...
181
+
182
+ Validation Results:
183
+
184
+ ✓ Tests exist
185
+ ✓ Tests pass
186
+ ✓ Documentation updated
187
+ ✓ No uncommitted changes
188
+
189
+ ✅ All checks passed!
190
+ ```
191
+
192
+ ---
193
+
194
+ ## Override Mechanisms
195
+
196
+ ### Git Hooks
197
+
198
+ **Emergency Override** (use sparingly):
199
+
200
+ ```bash
201
+ # Skip pre-commit hook
202
+ git commit --no-verify -m "Emergency hotfix"
203
+
204
+ # Skip pre-push hook
205
+ LEFTHOOK=0 git push
206
+ ```
207
+
208
+ **When to use**:
209
+ - Emergency hotfixes
210
+ - Work-in-progress commits (before pushing)
211
+ - Non-code commits (docs, config)
212
+
213
+ **When NOT to use**:
214
+ - Regular development
215
+ - Public repositories
216
+ - Production deployments
217
+
218
+ ### Validation CLI
219
+
220
+ The CLI provides guidance but doesn't block actions. You can proceed manually if checks fail.
221
+
222
+ ---
223
+
224
+ ## Configuration
225
+
226
+ ### Lefthook Configuration
227
+
228
+ Edit `lefthook.yml` to customize hooks:
229
+
230
+ ```yaml
231
+ pre-commit:
232
+ commands:
233
+ tdd-check:
234
+ run: node .forge/hooks/check-tdd.js
235
+ stage_fixed: false
236
+ tags: tdd
237
+ glob: "*.{js,ts,jsx,tsx,py,go,java,rb}"
238
+
239
+ pre-push:
240
+ commands:
241
+ tests:
242
+ run: npm test
243
+ tags: tests
244
+ ```
245
+
246
+ **Options**:
247
+ - `run`: Command to execute
248
+ - `stage_fixed`: Auto-stage modified files (false = safer)
249
+ - `tags`: Categorize hooks
250
+ - `glob`: File patterns to trigger hook
251
+
252
+ ### Custom Test Patterns
253
+
254
+ Edit `.forge/hooks/check-tdd.js` to add custom test patterns:
255
+
256
+ ```javascript
257
+ // Around line 72
258
+ const testPatterns = [
259
+ `${basename}.test${ext}`,
260
+ `${basename}.spec${ext}`,
261
+ `test/${basename}.test${ext}`,
262
+ `tests/${basename}.test${ext}`,
263
+ `__tests__/${basename}.test${ext}`,
264
+ // Add custom patterns here
265
+ `${dir}/__tests__/${basename}${ext}`,
266
+ `spec/${basename}_spec${ext}`, // RSpec style
267
+ ];
268
+ ```
269
+
270
+ ### Validation CLI Customization
271
+
272
+ Edit `bin/forge-validate.js` to add custom validators:
273
+
274
+ ```javascript
275
+ function validateCustomStage() {
276
+ console.log('Validating custom stage...\n');
277
+
278
+ check('Custom check', () => {
279
+ // Your validation logic
280
+ return true;
281
+ }, 'Custom error message');
282
+
283
+ return printResults();
284
+ }
285
+ ```
286
+
287
+ ---
288
+
289
+ ## Installation
290
+
291
+ Hooks are automatically installed when you run:
292
+
293
+ ```bash
294
+ # Install lefthook (one-time)
295
+ npm install -D lefthook
296
+
297
+ # Set up Forge
298
+ npx forge setup
299
+ ```
300
+
301
+ The hooks will be automatically installed in your project's `.git/hooks/` directory.
302
+
303
+ **Manual installation** (if needed):
304
+
305
+ ```bash
306
+ # If you prefer global installation
307
+ npm install -g lefthook
308
+
309
+ # Install hooks
310
+ lefthook install
311
+ ```
312
+
313
+ ---
314
+
315
+ ## Troubleshooting
316
+
317
+ ### Hooks not running
318
+
319
+ ```bash
320
+ # Check lefthook installation
321
+ lefthook version
322
+
323
+ # Reinstall hooks
324
+ lefthook install
325
+
326
+ # Check git hooks directory
327
+ ls -la .git/hooks/
328
+ ```
329
+
330
+ ### False positives
331
+
332
+ If the hook incorrectly flags a file:
333
+
334
+ 1. **Short-term**: Use `--no-verify` to skip
335
+ 2. **Long-term**: Update exclusion patterns in `.forge/hooks/check-tdd.js`
336
+
337
+ ### Tests failing on push
338
+
339
+ ```bash
340
+ # Run tests locally
341
+ npm test
342
+
343
+ # Fix failures, then
344
+ git push
345
+ ```
346
+
347
+ ---
348
+
349
+ ## Best Practices
350
+
351
+ 1. **Write tests first**: Let the hooks guide you to TDD
352
+ 2. **Don't abuse overrides**: Only use `--no-verify` in emergencies
353
+ 3. **Keep tests fast**: Pre-push hooks run on every push
354
+ 4. **Document exceptions**: If you override, explain why in commit message
355
+ 5. **Update validators**: Customize for your project's needs
356
+
357
+ ---
358
+
359
+ ## See Also
360
+
361
+ - [Workflow Guide](WORKFLOW.md) - Complete 9-stage workflow
362
+ - [TDD Guide](../CLAUDE.md) - TDD principles and practices
363
+ - [Lefthook Docs](https://github.com/evilmartians/lefthook) - Full hook configuration
package/lefthook.yml ADDED
@@ -0,0 +1,30 @@
1
+ # Lefthook Git Hooks Configuration
2
+ # TDD Enforcement for Forge Workflow
3
+ #
4
+ # To skip hooks in emergencies:
5
+ # git commit --no-verify (skip pre-commit)
6
+ # LEFTHOOK=0 git push (skip pre-push)
7
+
8
+ pre-commit:
9
+ commands:
10
+ tdd-check:
11
+ run: node .forge/hooks/check-tdd.js
12
+ stage_fixed: false
13
+ tags: tdd
14
+ glob: "*.{js,ts,jsx,tsx,py,go,java,rb}"
15
+
16
+ pre-push:
17
+ commands:
18
+ tests:
19
+ # Detect package manager: bun > pnpm > yarn > npm
20
+ run: |
21
+ if command -v bun >/dev/null 2>&1 && [ -f "bun.lockb" ]; then
22
+ bun test
23
+ elif command -v pnpm >/dev/null 2>&1 && [ -f "pnpm-lock.yaml" ]; then
24
+ pnpm test
25
+ elif command -v yarn >/dev/null 2>&1 && [ -f "yarn.lock" ]; then
26
+ yarn test
27
+ else
28
+ npm test
29
+ fi
30
+ tags: tests
@@ -0,0 +1,202 @@
1
+ # Agent Plugins
2
+
3
+ This directory contains plugin definitions for all supported AI coding agents.
4
+
5
+ ## Plugin Architecture
6
+
7
+ Each agent is defined by a JSON file following the plugin schema. This allows:
8
+ - **Discoverability**: New agents can be added without modifying core code
9
+ - **Community contributions**: Anyone can add support for new agents
10
+ - **Backwards compatibility**: Existing functionality remains unchanged
11
+ - **Maintainability**: Agent configurations are separated from business logic
12
+
13
+ ## Plugin Schema
14
+
15
+ Each plugin file must follow this structure:
16
+
17
+ ```json
18
+ {
19
+ "id": "agent-id", // REQUIRED: Unique identifier (lowercase, alphanumeric, hyphens)
20
+ "name": "Agent Name", // REQUIRED: Human-readable name
21
+ "version": "1.0.0", // REQUIRED: Semantic version (x.y.z)
22
+ "description": "...", // OPTIONAL: Brief description
23
+ "homepage": "https://...", // OPTIONAL: Agent's homepage URL
24
+ "capabilities": { // OPTIONAL: Agent capabilities
25
+ "commands": true, // Supports commands
26
+ "skills": true, // Supports skills
27
+ "hooks": false // Supports git hooks
28
+ },
29
+ "directories": { // REQUIRED: Directory structure (at least one)
30
+ "commands": ".agent/commands",
31
+ "rules": ".agent/rules",
32
+ "skills": ".agent/skills/forge-workflow",
33
+ "scripts": ".agent/scripts"
34
+ },
35
+ "files": { // OPTIONAL: Important file paths
36
+ "rootConfig": "AGENT.md",
37
+ "skillDefinition": ".agent/skills/forge-workflow/SKILL.md"
38
+ },
39
+ "setup": { // OPTIONAL: Setup instructions
40
+ "copyCommands": true,
41
+ "copyRules": true,
42
+ "createSkill": true,
43
+ "customSetup": "agent-name",
44
+ "needsConversion": false
45
+ }
46
+ }
47
+ ```
48
+
49
+ ### Required Fields
50
+
51
+ - **id**: Unique identifier for the agent (must match filename without `.plugin.json`)
52
+ - **name**: Display name shown to users
53
+ - **version**: Semantic version number (major.minor.patch)
54
+ - **directories**: Object with at least one directory path
55
+
56
+ ### Optional Fields
57
+
58
+ - **description**: Short description of the agent
59
+ - **homepage**: URL to agent's official website
60
+ - **capabilities**: Object defining what the agent supports
61
+ - **files**: Important configuration file paths
62
+ - **setup**: Installation and setup instructions
63
+
64
+ ## Supported Agents
65
+
66
+ Currently supported AI coding agents:
67
+
68
+ | Agent | ID | Description |
69
+ |-------|----|-----------|
70
+ | Claude Code | `claude` | Anthropic's CLI agent |
71
+ | Cursor | `cursor` | AI-first code editor |
72
+ | Windsurf | `windsurf` | Codeium's agentic IDE |
73
+ | Kilo Code | `kilocode` | VS Code extension |
74
+ | Google Antigravity | `antigravity` | Google's agent IDE |
75
+ | GitHub Copilot | `copilot` | GitHub's AI assistant |
76
+ | Continue | `continue` | Open-source AI assistant |
77
+ | OpenCode | `opencode` | Open-source agent |
78
+ | Cline | `cline` | VS Code agent extension |
79
+ | Roo Code | `roo` | Cline fork with modes |
80
+ | Aider | `aider` | Terminal-based agent |
81
+
82
+ ## Adding a New Agent
83
+
84
+ To add support for a new AI coding agent:
85
+
86
+ 1. **Create plugin file**: `lib/agents/your-agent.plugin.json`
87
+ 2. **Follow schema**: Use the template below or copy an existing plugin
88
+ 3. **Validate**: Run tests to ensure your plugin is valid
89
+ 4. **Test**: Run `npx forge setup --agents your-agent` to verify
90
+ 5. **Submit PR**: Contribute back to the community!
91
+
92
+ ### Plugin Template
93
+
94
+ See `.github/PLUGIN_TEMPLATE.json` for a ready-to-use template.
95
+
96
+ ```json
97
+ {
98
+ "id": "your-agent",
99
+ "name": "Your Agent Name",
100
+ "version": "1.0.0",
101
+ "description": "Brief description of your agent",
102
+ "homepage": "https://your-agent.example.com",
103
+ "capabilities": {
104
+ "commands": true,
105
+ "skills": true,
106
+ "hooks": false
107
+ },
108
+ "directories": {
109
+ "rules": ".your-agent/rules",
110
+ "skills": ".your-agent/skills/forge-workflow"
111
+ },
112
+ "files": {
113
+ "rootConfig": ".your-agent-rules"
114
+ },
115
+ "setup": {
116
+ "createSkill": true
117
+ }
118
+ }
119
+ ```
120
+
121
+ ## Validation
122
+
123
+ The PluginManager automatically validates all plugins on load:
124
+
125
+ - **Schema validation**: Required fields must be present
126
+ - **Type checking**: Fields must have correct types
127
+ - **Unique IDs**: No duplicate plugin IDs allowed
128
+ - **JSON syntax**: Files must be valid JSON
129
+
130
+ Run tests to validate your plugin:
131
+
132
+ ```bash
133
+ npm test test/plugins/
134
+ ```
135
+
136
+ ## Community Contributions
137
+
138
+ We welcome community contributions for new AI coding agents!
139
+
140
+ **Before submitting:**
141
+ 1. Ensure your plugin passes all validation tests
142
+ 2. Test the agent setup with `npx forge setup --agents your-agent`
143
+ 3. Document any special setup requirements
144
+ 4. Follow the existing plugin structure
145
+
146
+ **PR Guidelines:**
147
+ - One plugin per PR
148
+ - Include plugin JSON file only (no code changes needed)
149
+ - Update this README with agent information
150
+ - Test that all existing tests still pass
151
+
152
+ ## Technical Details
153
+
154
+ ### Plugin Loading
155
+
156
+ The `PluginManager` class (`lib/plugin-manager.js`) handles:
157
+ - Auto-discovery of `.plugin.json` files in this directory
158
+ - Schema validation for each plugin
159
+ - Conversion to internal AGENTS format (backwards compatibility)
160
+ - Error handling for invalid plugins
161
+
162
+ ### Backwards Compatibility
163
+
164
+ Plugins are automatically converted to the legacy AGENTS object structure:
165
+
166
+ ```javascript
167
+ {
168
+ name: plugin.name,
169
+ description: plugin.description,
170
+ dirs: Object.values(plugin.directories),
171
+ hasCommands: plugin.capabilities?.commands,
172
+ hasSkill: plugin.capabilities?.skills,
173
+ // ... other fields
174
+ }
175
+ ```
176
+
177
+ This ensures existing code continues to work without modifications.
178
+
179
+ ## Troubleshooting
180
+
181
+ ### Plugin Not Loading
182
+
183
+ If your plugin isn't appearing in `npx forge setup`:
184
+
185
+ 1. **Check filename**: Must end with `.plugin.json`
186
+ 2. **Validate JSON**: Ensure file is valid JSON (no trailing commas, quotes correct)
187
+ 3. **Check required fields**: id, name, version, directories must be present
188
+ 4. **Run tests**: `npm test test/plugins/` will show specific errors
189
+ 5. **Check logs**: Any loading errors will be displayed
190
+
191
+ ### Schema Validation Errors
192
+
193
+ Common validation errors:
194
+
195
+ - `missing required field "id"`: Add the id field
196
+ - `"directories" must be an object`: Ensure directories is an object, not array
197
+ - `"version" must be a string`: Version must be in "x.y.z" format
198
+ - `Plugin with ID "x" already exists`: Choose a unique ID
199
+
200
+ ## License
201
+
202
+ All plugin definitions in this directory are MIT licensed, same as the Forge project.
@@ -0,0 +1,16 @@
1
+ {
2
+ "id": "aider",
3
+ "name": "Aider",
4
+ "version": "1.0.0",
5
+ "description": "Terminal-based agent",
6
+ "homepage": "https://aider.chat",
7
+ "capabilities": {
8
+ "commands": false,
9
+ "skills": false,
10
+ "hooks": false
11
+ },
12
+ "directories": {},
13
+ "setup": {
14
+ "customSetup": "aider"
15
+ }
16
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "id": "antigravity",
3
+ "name": "Google Antigravity",
4
+ "version": "1.0.0",
5
+ "description": "Google's agent IDE",
6
+ "homepage": "https://developers.google.com/ai",
7
+ "capabilities": {
8
+ "commands": false,
9
+ "skills": true,
10
+ "hooks": false
11
+ },
12
+ "directories": {
13
+ "workflows": ".agent/workflows",
14
+ "rules": ".agent/rules",
15
+ "skills": ".agent/skills/forge-workflow"
16
+ },
17
+ "files": {
18
+ "rootConfig": "GEMINI.md"
19
+ },
20
+ "setup": {
21
+ "copyRules": true,
22
+ "createSkill": true,
23
+ "needsConversion": true
24
+ }
25
+ }