wordpress-agent-kit 0.2.1 → 0.2.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/.github/workflows/ci.yml +44 -0
- package/.husky/pre-commit +7 -0
- package/CLI_REVIEW.md +250 -0
- package/README.md +124 -51
- package/biome.json +39 -0
- package/dist/cli.js +75 -4
- package/dist/commands/install.js +43 -10
- package/dist/commands/run-playground.js +59 -14
- package/dist/commands/setup.js +222 -163
- package/dist/commands/sync-skills.js +33 -60
- package/dist/commands/upgrade.js +182 -0
- package/dist/lib/api.js +456 -0
- package/dist/lib/triage-mapper.js +18 -20
- package/dist/utils/exit-codes.js +60 -0
- package/dist/utils/output.js +96 -0
- package/dist/utils/paths.js +1 -1
- package/dist/utils/run.js +1 -1
- package/kit-learnings.md +192 -0
- package/package.json +7 -2
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main, master]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint-and-test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- name: Checkout repository
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Setup pnpm
|
|
17
|
+
uses: pnpm/action-setup@v4
|
|
18
|
+
with:
|
|
19
|
+
version: 9
|
|
20
|
+
run_install: false
|
|
21
|
+
|
|
22
|
+
- name: Setup Node.js
|
|
23
|
+
uses: actions/setup-node@v4
|
|
24
|
+
with:
|
|
25
|
+
node-version: '22'
|
|
26
|
+
cache: 'pnpm'
|
|
27
|
+
|
|
28
|
+
- name: Install dependencies
|
|
29
|
+
run: pnpm install --frozen-lockfile
|
|
30
|
+
|
|
31
|
+
- name: Check formatting
|
|
32
|
+
run: pnpm run format:check
|
|
33
|
+
|
|
34
|
+
- name: Run lint
|
|
35
|
+
run: pnpm run lint:check
|
|
36
|
+
|
|
37
|
+
- name: Type check
|
|
38
|
+
run: pnpm run check
|
|
39
|
+
|
|
40
|
+
- name: Run tests
|
|
41
|
+
run: pnpm run test:run
|
|
42
|
+
|
|
43
|
+
- name: Build
|
|
44
|
+
run: pnpm run build
|
package/CLI_REVIEW.md
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# WordPress Agent Kit CLI - Accessibility & Agent-Friendly Review
|
|
2
|
+
|
|
3
|
+
**Date**: 2026-06-08
|
|
4
|
+
**Version**: 0.2.1
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Executive Summary
|
|
9
|
+
|
|
10
|
+
The current CLI is functional for **human developers** using interactive prompts (`@clack/prompts`), but lacks features for **programmatic/agent usage**:
|
|
11
|
+
|
|
12
|
+
- ❌ No JSON output mode
|
|
13
|
+
- ❌ No machine-readable result objects
|
|
14
|
+
- ❌ No programmatic API (only CLI entrypoint)
|
|
15
|
+
- ❌ No non-interactive "headless" mode for all commands
|
|
16
|
+
- ❌ No structured logging/event streaming
|
|
17
|
+
- ❌ Exit codes not consistently semantic
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Current Architecture
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
src/
|
|
25
|
+
├── cli.ts # Entry point, Commander setup
|
|
26
|
+
├── commands/
|
|
27
|
+
│ ├── install.ts # Non-interactive (args + flags only) ✓
|
|
28
|
+
│ ├── setup.ts # Interactive (prompts only) ✗
|
|
29
|
+
│ ├── sync-skills.ts # Non-interactive (args + flags only) ✓
|
|
30
|
+
│ └── run-playground.ts # Non-interactive ✓
|
|
31
|
+
├── lib/
|
|
32
|
+
│ ├── installer.ts # Core logic (pure functions) ✓
|
|
33
|
+
│ └── triage-mapper.ts # Pure mappers ✓
|
|
34
|
+
└── utils/
|
|
35
|
+
├── paths.ts # Path resolution
|
|
36
|
+
└── run.ts # Command runner
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Good**: Core logic (`installKit`, mappers) is pure and testable.
|
|
40
|
+
**Gap**: `setup.ts` couples interactive prompts with business logic.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Recommendations
|
|
45
|
+
|
|
46
|
+
### 1. Add JSON Output Mode (--json)
|
|
47
|
+
|
|
48
|
+
**Goal**: Every command outputs structured JSON to stdout when requested.
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Success
|
|
52
|
+
wp-agent-kit install /path/to/project --platform github --json
|
|
53
|
+
# {"success":true,"targetDir":"/path/to/project","platform":"github","filesCopied":["AGENTS.md",".github/..."],"durationMs":142}
|
|
54
|
+
|
|
55
|
+
# Failure
|
|
56
|
+
wp-agent-kit install /nonexistent --json
|
|
57
|
+
# {"success":false,"error":"E_NOT_FOUND","message":"Target directory does not exist","code":"ENOENT"}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Implementation**:
|
|
61
|
+
- Add `--json` / `--output json` global flag in `cli.ts`
|
|
62
|
+
- Create `OutputFormatter` utility: `json`, `human`, `quiet`
|
|
63
|
+
- Return structured result objects from all command actions
|
|
64
|
+
- Separate stdout (JSON) from stderr (human diagnostics)
|
|
65
|
+
|
|
66
|
+
### 2. Add Machine-Readable Exit Codes
|
|
67
|
+
|
|
68
|
+
| Code | Meaning |
|
|
69
|
+
|------|---------|
|
|
70
|
+
| 0 | Success |
|
|
71
|
+
| 1 | General error |
|
|
72
|
+
| 2 | Invalid arguments / usage |
|
|
73
|
+
| 3 | Target not found / ENOENT |
|
|
74
|
+
| 4 | Permission denied / EACCES |
|
|
75
|
+
| 5 | Already exists (without --force) |
|
|
76
|
+
| 6 | Git/submodule error |
|
|
77
|
+
| 7 | Network/fetch error |
|
|
78
|
+
| 8 | Validation failed |
|
|
79
|
+
| 130 | Cancelled (SIGINT) |
|
|
80
|
+
|
|
81
|
+
### 3. Extract Programmatic API
|
|
82
|
+
|
|
83
|
+
Expose core functions for direct import by agents/scripts:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
// src/api.ts (new)
|
|
87
|
+
export interface InstallOptions {
|
|
88
|
+
targetDir: string;
|
|
89
|
+
platform: Platform;
|
|
90
|
+
force?: boolean;
|
|
91
|
+
dryRun?: boolean;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface InstallResult {
|
|
95
|
+
success: boolean;
|
|
96
|
+
targetDir: string;
|
|
97
|
+
platform: Platform;
|
|
98
|
+
filesCreated: string[];
|
|
99
|
+
filesSkipped: string[];
|
|
100
|
+
errors: string[];
|
|
101
|
+
durationMs: number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export async function installKit(options: InstallOptions): Promise<InstallResult>;
|
|
105
|
+
export async function syncSkills(options: SyncOptions): Promise<SyncResult>;
|
|
106
|
+
export async function runTriage(targetDir: string): Promise<TriageResult>;
|
|
107
|
+
export async function configureAgentsMd(options: ConfigureOptions): Promise<ConfigureResult>;
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Benefits**:
|
|
111
|
+
- Agents can import and call directly: `import { installKit } from 'wordpress-agent-kit'`
|
|
112
|
+
- No subprocess overhead
|
|
113
|
+
- Full TypeScript types
|
|
114
|
+
- Testable in isolation
|
|
115
|
+
|
|
116
|
+
### 4. Make `setup` Command Headless-Capable
|
|
117
|
+
|
|
118
|
+
Current `setup.ts` is prompt-driven. Add non-interactive mode:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Full non-interactive (requires all flags)
|
|
122
|
+
wp-agent-kit setup /path/to/project \
|
|
123
|
+
--project-type plugin \
|
|
124
|
+
--tech-stack gutenberg,rest-api,composer \
|
|
125
|
+
--platform github \
|
|
126
|
+
--yes \
|
|
127
|
+
--json
|
|
128
|
+
|
|
129
|
+
# Hybrid: run triage, apply detected values, no prompts
|
|
130
|
+
wp-agent-kit setup /path/to/project --auto --json
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Flag Matrix for `setup`**:
|
|
134
|
+
| Flag | Description |
|
|
135
|
+
|------|-------------|
|
|
136
|
+
| `--project-type <type>` | plugin \| theme \| block-theme \| site \| blocks \| other |
|
|
137
|
+
| `--tech-stack <list>` | Comma-separated: gutenberg,interactivity,rest-api,wpcli,composer,phpstan,npm,playground |
|
|
138
|
+
| `--platform <platform>` | github \| cursor \| claude \| agent \| pi |
|
|
139
|
+
| `--package-manager <pm>` | npm \| pnpm \| yarn |
|
|
140
|
+
| `--auto` | Run triage, apply detected values, skip prompts |
|
|
141
|
+
| `--yes` / `-y` | Accept all confirmations (requires other flags) |
|
|
142
|
+
| `--reset` | Overwrite existing |
|
|
143
|
+
| `--dry-run` | Show what would be done |
|
|
144
|
+
|
|
145
|
+
### 5. Add Structured Logging / Event Stream
|
|
146
|
+
|
|
147
|
+
For long-running operations (sync-skills, playground), emit NDJSON events:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
wp-agent-kit sync-skills --json-stream
|
|
151
|
+
# {"event":"start","phase":"clone","timestamp":"..."}
|
|
152
|
+
# {"event":"progress","phase":"fetch","message":"Fetching tags...","timestamp":"..."}
|
|
153
|
+
# {"event":"complete","phase":"install","result":{"skillsSynced":42,"timestamp":"..."}}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Events**: `start`, `progress`, `phase-change`, `warning`, `complete`, `error`
|
|
157
|
+
|
|
158
|
+
### 6. Add Dry-Run / Preview Mode
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
wp-agent-kit install /path --dry-run --json
|
|
162
|
+
# {"wouldCopy":[{"src":"AGENTS.template.md","dest":"/path/AGENTS.md"},{"src":".github/...","dest":"/path/.github/..."}],"wouldCreateDirs":[]}
|
|
163
|
+
|
|
164
|
+
wp-agent-kit setup /path --dry-run --auto --json
|
|
165
|
+
# {"wouldInstall":true,"detectedType":"plugin","detectedTech":["gutenberg","npm"],"wouldModify":["AGENTS.md"]}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 7. Add Shell Completion (Modern CLI Standard)
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Generate completion scripts
|
|
172
|
+
wp-agent-kit completion bash > /etc/bash_completion.d/wp-agent-kit
|
|
173
|
+
wp-agent-kit completion zsh > ~/.zsh/completions/_wp-agent-kit
|
|
174
|
+
wp-agent-kit completion fish > ~/.config/fish/completions/wp-agent-kit.fish
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Commander.js supports this natively: `program.enablePositionalOptions().addHelpCommand().configureOutput({ writeOut: ... })`
|
|
178
|
+
|
|
179
|
+
### 8. Add `--version` JSON Output
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
wp-agent-kit --version --json
|
|
183
|
+
# {"name":"wp-agent-kit","version":"0.2.1","node":"20.18.0","platform":"linux"}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Priority Matrix
|
|
189
|
+
|
|
190
|
+
| Priority | Feature | Effort | Impact |
|
|
191
|
+
|----------|---------|--------|--------|
|
|
192
|
+
| **P0** | JSON output (`--json`) | Low | High |
|
|
193
|
+
| **P0** | Semantic exit codes | Low | High |
|
|
194
|
+
| **P0** | Programmatic API export | Medium | High |
|
|
195
|
+
| **P1** | Headless `setup` mode | Medium | High |
|
|
196
|
+
| **P1** | Dry-run/preview | Low | Medium |
|
|
197
|
+
| **P2** | NDJSON event streaming | Medium | Medium |
|
|
198
|
+
| **P2** | Shell completions | Low | Medium |
|
|
199
|
+
| **P3** | Man page generation | Low | Low |
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Example: Agent-Friendly Workflow
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
# 1. Agent detects WordPress project
|
|
207
|
+
wp-agent-kit setup /workspace/my-plugin --auto --json
|
|
208
|
+
# {"success":true,"applied":{"projectType":"plugin","techStack":["gutenberg","npm"]},"filesModified":["AGENTS.md"]}
|
|
209
|
+
|
|
210
|
+
# 2. Agent syncs latest skills
|
|
211
|
+
wp-agent-kit sync-skills --json
|
|
212
|
+
# {"success":true,"skillsSynced":47,"source":"WordPress/agent-skills@trunk"}
|
|
213
|
+
|
|
214
|
+
# 3. Agent installs for specific platform (e.g., Cursor)
|
|
215
|
+
wp-agent-kit install /workspace/my-plugin --platform cursor --json
|
|
216
|
+
# {"success":true,"platform":"cursor","targetDir":"/workspace/my-plugin","filesCreated":[".cursor/...","AGENTS.md"]}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## Implementation Notes
|
|
222
|
+
|
|
223
|
+
### Minimal Changes for P0
|
|
224
|
+
|
|
225
|
+
1. **cli.ts**: Add global `--json` flag, result formatter
|
|
226
|
+
2. **commands/*.ts**: Return structured results instead of `process.exit()`
|
|
227
|
+
3. **lib/installer.ts**: Return `InstallResult` object (already close)
|
|
228
|
+
4. **package.json**: Add `"exports": { ".": "./dist/cli.js", "./api": "./dist/api.js" }`
|
|
229
|
+
|
|
230
|
+
### Testing Strategy
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
// tests/api/install.api.test.ts
|
|
234
|
+
import { installKit } from '../../src/api.js';
|
|
235
|
+
|
|
236
|
+
it('returns structured result on success', async () => {
|
|
237
|
+
const result = await installKit({ targetDir: '/tmp/test', platform: 'github' });
|
|
238
|
+
expect(result.success).toBe(true);
|
|
239
|
+
expect(result.filesCreated).toContain('AGENTS.md');
|
|
240
|
+
});
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## References
|
|
246
|
+
|
|
247
|
+
- [Commander.js JSON output patterns](https://github.com/tj/commander.js/blob/master/Examples/options-json.ts)
|
|
248
|
+
- [CLI Guidelines - Output](https://clig.dev/#output)
|
|
249
|
+
- [12-factor CLI apps](https://medium.com/@jdxcode/12-factor-cli-apps-dd3c227a0e46)
|
|
250
|
+
- [GitHub CLI `gh` JSON patterns](https://cli.github.com/manual/gh_help_formatting)
|
package/README.md
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
[](LICENSE)
|
|
4
4
|
[](https://www.typescriptlang.org/)
|
|
5
5
|
[](https://github.com/prettier/prettier)
|
|
6
|
-
[](package.json)
|
|
7
|
+
[](package.json)
|
|
7
8
|
|
|
8
|
-
**WordPress-focused AI agent starter kit** for GitHub Copilot, Claude, and other LLM coding agents. Includes instructions, specialized WordPress skills, and workflow automation aligned with industry standards.
|
|
9
|
+
**WordPress-focused AI agent starter kit** for GitHub Copilot, Cursor, Claude, and other LLM coding agents. Includes instructions, specialized WordPress skills, and workflow automation aligned with industry standards.
|
|
9
10
|
|
|
10
11
|
Maintained by [Kyle Brodeur](https://brodeur.me).
|
|
11
12
|
|
|
@@ -13,106 +14,178 @@ Maintained by [Kyle Brodeur](https://brodeur.me).
|
|
|
13
14
|
|
|
14
15
|
### Option 1: CLI (Recommended)
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
#### Interactive Setup Wizard
|
|
18
18
|
```bash
|
|
19
19
|
npx wp-agent-kit setup
|
|
20
20
|
# or
|
|
21
21
|
pnpm dlx wp-agent-kit setup
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
|
|
24
|
+
#### Non-Interactive (CI/Agent-Friendly)
|
|
25
|
+
```bash
|
|
26
|
+
# Auto-detect project type and tech stack
|
|
27
|
+
pnpm dlx wp-agent-kit setup --auto --json
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
# Or specify explicitly (for full automation)
|
|
30
|
+
pnpm dlx wp-agent-kit setup --project-type plugin --tech-stack gutenberg,rest-api,composer --platform github --yes --json
|
|
31
|
+
```
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
#### Install Only (No Configuration)
|
|
34
|
+
```bash
|
|
35
|
+
# For GitHub Copilot / VS Code
|
|
36
|
+
pnpm dlx wp-agent-kit@latest install --platform github
|
|
37
|
+
|
|
38
|
+
# For Cursor IDE
|
|
39
|
+
pnpm dlx wp-agent-kit@latest install --platform cursor
|
|
40
|
+
|
|
41
|
+
# For Pi Coding Agent (recommended)
|
|
42
|
+
pnpm dlx wp-agent-kit@latest install --platform pi
|
|
43
|
+
|
|
44
|
+
# For generic .agent workflows
|
|
45
|
+
pnpm dlx wp-agent-kit@latest install --platform agent
|
|
46
|
+
```
|
|
32
47
|
|
|
33
|
-
|
|
34
|
-
- **`wordpress-agent-kit-claude.tar.gz`** - For Claude
|
|
35
|
-
- **`wordpress-agent-kit-agent.tar.gz`** - For generic `.agent` workflows
|
|
36
|
-
- **`wordpress-agent-kit-cursor.tar.gz`** - For Cursor IDE
|
|
48
|
+
### Option 2: Pre-built Bundles
|
|
37
49
|
|
|
38
|
-
|
|
50
|
+
Download from the [latest release](https://github.com/kylebrodeur/wordpress-agent-kit/releases):
|
|
51
|
+
- `wordpress-agent-kit-github.tar.gz` — GitHub Copilot
|
|
52
|
+
- `wordpress-agent-kit-cursor.tar.gz` — Cursor IDE
|
|
53
|
+
- `wordpress-agent-kit-claude.tar.gz` — Claude
|
|
54
|
+
- `wordpress-agent-kit-agent.tar.gz` — Generic `.agent`
|
|
39
55
|
|
|
40
56
|
```bash
|
|
41
57
|
cd /path/to/your-wordpress-project
|
|
42
58
|
tar -xzf wordpress-agent-kit-github.tar.gz
|
|
43
59
|
```
|
|
44
60
|
|
|
45
|
-
|
|
46
|
-
- **Automatically detect** your project type and technologies.
|
|
47
|
-
- Customize `AGENTS.md` for your tech stack.
|
|
48
|
-
- Configure workflow instructions.
|
|
49
|
-
- Set up prompt templates.
|
|
61
|
+
## Agent-Friendly Features (v0.2.2+)
|
|
50
62
|
|
|
51
|
-
|
|
63
|
+
### Structured JSON Output (`--json`)
|
|
64
|
+
All commands output machine-readable JSON for programmatic use:
|
|
65
|
+
```bash
|
|
66
|
+
wp-agent-kit install --platform github --json
|
|
67
|
+
# {"success":true,"data":{"targetDir":"/path","platform":"github","filesCreated":[...],"durationMs":35}}
|
|
68
|
+
```
|
|
52
69
|
|
|
70
|
+
### Headless/Non-Interactive Mode
|
|
53
71
|
```bash
|
|
54
|
-
|
|
72
|
+
# Auto-detection
|
|
73
|
+
wp-agent-kit setup --auto --json
|
|
74
|
+
|
|
75
|
+
# Explicit config (CI/CD ready)
|
|
76
|
+
wp-agent-kit setup --project-type plugin --tech-stack gutenberg,rest-api --platform github --yes --json
|
|
55
77
|
```
|
|
56
78
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
79
|
+
### Dry-Run Preview (`--dry-run`)
|
|
80
|
+
```bash
|
|
81
|
+
wp-agent-kit install --platform github --dry-run --json
|
|
82
|
+
wp-agent-kit setup --project-type plugin --dry-run --json
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Upgrade Existing Installations
|
|
86
|
+
```bash
|
|
87
|
+
# Check for updates
|
|
88
|
+
wp-agent-kit upgrade --check-only --json
|
|
61
89
|
|
|
62
|
-
|
|
90
|
+
# Apply upgrade
|
|
91
|
+
wp-agent-kit upgrade --force --json
|
|
92
|
+
```
|
|
63
93
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
94
|
+
### Programmatic API
|
|
95
|
+
```typescript
|
|
96
|
+
import { installKitApi, syncSkillsApi, runTriageApi, configureAgentsMdApi } from 'wordpress-agent-kit/api';
|
|
67
97
|
|
|
68
|
-
|
|
98
|
+
await installKitApi({ targetDir: '/path', platform: 'github', force: true });
|
|
99
|
+
await syncSkillsApi({ ref: 'trunk' });
|
|
100
|
+
const triage = await runTriageApi({ targetDir: '/path' });
|
|
101
|
+
await configureAgentsMdApi({ targetDir: '/path', platform: 'github', config: { projectType: 'plugin', techStack: ['gutenberg'] }});
|
|
102
|
+
```
|
|
69
103
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
104
|
+
### Semantic Exit Codes
|
|
105
|
+
| Code | Meaning |
|
|
106
|
+
|------|---------|
|
|
107
|
+
| 0 | Success |
|
|
108
|
+
| 1 | General error |
|
|
109
|
+
| 2 | Invalid arguments |
|
|
110
|
+
| 3 | Not found (ENOENT) |
|
|
111
|
+
| 4 | Permission denied |
|
|
112
|
+
| 5 | Already exists (use --force) |
|
|
113
|
+
| 6 | Git error |
|
|
114
|
+
| 7 | Network error |
|
|
115
|
+
| 8 | Validation failed |
|
|
116
|
+
| 130 | Cancelled (SIGINT) |
|
|
117
|
+
|
|
118
|
+
## Platform Comparison
|
|
119
|
+
|
|
120
|
+
| Platform | Target Dir | Interactive? | Best For |
|
|
121
|
+
|----------|------------|--------------|----------|
|
|
122
|
+
| `pi` | `.pi/agent/skills/` | ❌ | **Pi Coding Agent** |
|
|
123
|
+
| `github` | `.github/skills/` | ❌ | GitHub Copilot, VS Code |
|
|
124
|
+
| `cursor` | `.cursor/skills/` | ❌ | Cursor IDE |
|
|
125
|
+
| `agent` | `.agent/skills/` | ❌ | Generic `.agent` workflows |
|
|
126
|
+
| `claude` | `.claude/skills/` | ✅ | Claude Code (interactive) |
|
|
127
|
+
|
|
128
|
+
## Commands Reference
|
|
129
|
+
|
|
130
|
+
| Command | Description |
|
|
131
|
+
|---------|-------------|
|
|
132
|
+
| `install [dir] --platform <p> [--force] [--dry-run] [--json]` | Install kit to target directory |
|
|
133
|
+
| `setup [dir] [--auto] [--project-type] [--tech-stack] [--yes] [--json]` | Interactive or headless setup |
|
|
134
|
+
| `sync-skills [ref] [--dry-run] [--json]` | Sync skills from WordPress/agent-skills |
|
|
135
|
+
| `playground [--port] [--no-auto-mount] [--json]` | Run local WordPress Playground |
|
|
136
|
+
| `upgrade [dir] [--platform] [--force] [--check-only] [--json]` | Upgrade existing installation |
|
|
74
137
|
|
|
75
138
|
## Development
|
|
76
139
|
|
|
77
|
-
This project uses a TypeScript-based CLI for all operations.
|
|
78
|
-
|
|
79
140
|
### Build CLI
|
|
80
|
-
|
|
81
141
|
```bash
|
|
82
142
|
pnpm build
|
|
83
143
|
```
|
|
84
144
|
|
|
85
|
-
###
|
|
86
|
-
|
|
145
|
+
### Run Tests
|
|
87
146
|
```bash
|
|
88
|
-
pnpm
|
|
89
|
-
pnpm build:bundles
|
|
147
|
+
pnpm test:run
|
|
90
148
|
```
|
|
91
149
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
150
|
+
### Lint & Format
|
|
151
|
+
```bash
|
|
152
|
+
pnpm run lint:check # Check only
|
|
153
|
+
pnpm run lint # Auto-fix
|
|
154
|
+
pnpm run format:check # Check formatting
|
|
155
|
+
pnpm run format # Auto-format
|
|
156
|
+
```
|
|
97
157
|
|
|
98
|
-
###
|
|
158
|
+
### Build Release Bundles
|
|
159
|
+
```bash
|
|
160
|
+
pnpm sync:skills
|
|
161
|
+
pnpm build:bundles
|
|
162
|
+
```
|
|
99
163
|
|
|
164
|
+
### Pre-Publish (Runs All Checks)
|
|
100
165
|
```bash
|
|
101
|
-
pnpm
|
|
166
|
+
pnpm run prepublishOnly
|
|
102
167
|
```
|
|
103
168
|
|
|
104
169
|
## Customization
|
|
105
170
|
|
|
106
|
-
**Quick method:** Run the interactive setup.
|
|
171
|
+
**Quick method:** Run the interactive or headless setup.
|
|
107
172
|
|
|
108
173
|
**Manual method:** Edit files directly:
|
|
109
|
-
|
|
110
174
|
1. Edit `AGENTS.md` to match your project's tech stack and conventions.
|
|
111
175
|
2. Run WordPress project triage (via `wp-project-triage` skill) to generate tailored instructions.
|
|
112
176
|
3. Update `.github/instructions/wordpress-workflow.instructions.md` with your workflow.
|
|
113
177
|
4. Keep prompts in `.github/prompts/` accurate for your plugin/theme.
|
|
114
178
|
|
|
179
|
+
## CI/CD Integration
|
|
180
|
+
|
|
181
|
+
```yaml
|
|
182
|
+
# GitHub Actions example
|
|
183
|
+
- name: Install WordPress Agent Kit
|
|
184
|
+
run: pnpm dlx wordpress-agent-kit@latest install --platform github --json
|
|
185
|
+
```
|
|
186
|
+
|
|
115
187
|
## Credits
|
|
116
188
|
|
|
117
189
|
- **[AGENTS.md](https://agentskills.io)** - The agent configuration standard.
|
|
118
190
|
- **[AgentSkills.io](https://agentskills.io)** - The open directory of agent skills.
|
|
191
|
+
- **[WordPress/agent-skills](https://github.com/WordPress/agent-skills)** - Upstream skills repository.
|
package/biome.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
|
3
|
+
"vcs": {
|
|
4
|
+
"enabled": true,
|
|
5
|
+
"clientKind": "git",
|
|
6
|
+
"useIgnoreFile": true
|
|
7
|
+
},
|
|
8
|
+
"files": {
|
|
9
|
+
"include": ["src/**/*.ts", "tests/**/*.ts", "scripts/**/*.ts"],
|
|
10
|
+
"ignoreUnknown": true
|
|
11
|
+
},
|
|
12
|
+
"organizeImports": {
|
|
13
|
+
"enabled": true
|
|
14
|
+
},
|
|
15
|
+
"linter": {
|
|
16
|
+
"enabled": true,
|
|
17
|
+
"rules": {
|
|
18
|
+
"recommended": true,
|
|
19
|
+
"suspicious": {
|
|
20
|
+
"noExplicitAny": "warn"
|
|
21
|
+
},
|
|
22
|
+
"correctness": {
|
|
23
|
+
"noUnusedVariables": "error"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"formatter": {
|
|
28
|
+
"enabled": true,
|
|
29
|
+
"indentStyle": "tab",
|
|
30
|
+
"lineWidth": 100
|
|
31
|
+
},
|
|
32
|
+
"javascript": {
|
|
33
|
+
"formatter": {
|
|
34
|
+
"quoteStyle": "single",
|
|
35
|
+
"trailingCommas": "es5",
|
|
36
|
+
"semicolons": "always"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -1,19 +1,90 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
2
3
|
import { Command } from 'commander';
|
|
3
|
-
import { createRequire } from 'module';
|
|
4
4
|
import { installCommand } from './commands/install.js';
|
|
5
|
+
import { runPlaygroundCommand } from './commands/run-playground.js';
|
|
5
6
|
import { setupCommand } from './commands/setup.js';
|
|
6
7
|
import { syncSkillsCommand } from './commands/sync-skills.js';
|
|
7
|
-
import {
|
|
8
|
+
import { upgradeCommand } from './commands/upgrade.js';
|
|
9
|
+
import { ExitCode } from './utils/exit-codes.js';
|
|
10
|
+
import { createFormatter } from './utils/output.js';
|
|
11
|
+
import { OutputFormatter } from './utils/output.js';
|
|
8
12
|
const require = createRequire(import.meta.url);
|
|
9
13
|
const { version } = require('../package.json');
|
|
10
14
|
const program = new Command();
|
|
15
|
+
// Global options for all commands
|
|
11
16
|
program
|
|
12
17
|
.name('wp-agent-kit')
|
|
13
18
|
.description('Utilities for WordPress Agent Kit')
|
|
14
|
-
.version(version)
|
|
19
|
+
.version(version)
|
|
20
|
+
.option('--json', 'Output JSON result to stdout', false)
|
|
21
|
+
.option('--quiet', 'Suppress all output except errors', false)
|
|
22
|
+
.option('--ndjson', 'Output NDJSON progress events (for long operations)', false)
|
|
23
|
+
.option('--dry-run', 'Preview actions without executing', false)
|
|
24
|
+
.configureHelp({
|
|
25
|
+
sortSubcommands: true,
|
|
26
|
+
});
|
|
27
|
+
// Add commands
|
|
15
28
|
program.addCommand(installCommand);
|
|
16
29
|
program.addCommand(setupCommand);
|
|
17
30
|
program.addCommand(syncSkillsCommand);
|
|
18
31
|
program.addCommand(runPlaygroundCommand);
|
|
19
|
-
program.
|
|
32
|
+
program.addCommand(upgradeCommand);
|
|
33
|
+
// Global error handler
|
|
34
|
+
program.exitOverride((err) => {
|
|
35
|
+
if (err.code === 'commander.helpDisplayed' || err.code === 'commander.versionDisplayed') {
|
|
36
|
+
process.exit(ExitCode.OK);
|
|
37
|
+
}
|
|
38
|
+
if (err.code === 'commander.unknownOption' || err.code === 'commander.invalidArgument') {
|
|
39
|
+
const formatter = createFormatter({ json: true }, 'wp-agent-kit', version);
|
|
40
|
+
const result = formatter.fail({
|
|
41
|
+
code: 'INVALID_ARGS',
|
|
42
|
+
message: err.message,
|
|
43
|
+
exitCode: ExitCode.INVALID_ARGS,
|
|
44
|
+
});
|
|
45
|
+
process.exit(OutputFormatter.getExitCode(result));
|
|
46
|
+
}
|
|
47
|
+
throw err;
|
|
48
|
+
});
|
|
49
|
+
// Custom help with examples
|
|
50
|
+
program.addHelpText('after', `
|
|
51
|
+
Examples:
|
|
52
|
+
$ wp-agent-kit install --platform github
|
|
53
|
+
$ wp-agent-kit setup --auto --json
|
|
54
|
+
$ wp-agent-kit sync-skills --ref trunk --ndjson
|
|
55
|
+
$ wp-agent-kit install --platform pi --dry-run --json
|
|
56
|
+
$ wp-agent-kit upgrade --check-only --json
|
|
57
|
+
|
|
58
|
+
Programmatic API:
|
|
59
|
+
import { installKit, syncSkills, runTriage } from 'wordpress-agent-kit/api';
|
|
60
|
+
|
|
61
|
+
For more info: https://github.com/kylebrodeur/wordpress-agent-kit
|
|
62
|
+
`);
|
|
63
|
+
try {
|
|
64
|
+
program.parse(process.argv);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
// Handle errors from commands that use process.exit
|
|
68
|
+
const err = error;
|
|
69
|
+
if (err.exitCode !== undefined) {
|
|
70
|
+
process.exit(err.exitCode);
|
|
71
|
+
}
|
|
72
|
+
// Fallback for unexpected errors
|
|
73
|
+
const formatter = createFormatter({ json: true }, 'wp-agent-kit', version);
|
|
74
|
+
const result = formatter.fail({
|
|
75
|
+
code: 'UNEXPECTED_ERROR',
|
|
76
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
77
|
+
exitCode: ExitCode.ERROR,
|
|
78
|
+
});
|
|
79
|
+
process.exit(OutputFormatter.getExitCode(result));
|
|
80
|
+
}
|
|
81
|
+
// Handle unhandled rejections
|
|
82
|
+
process.on('unhandledRejection', (reason) => {
|
|
83
|
+
const formatter = createFormatter({ json: true }, 'wp-agent-kit', version);
|
|
84
|
+
const result = formatter.fail({
|
|
85
|
+
code: 'UNHANDLED_REJECTION',
|
|
86
|
+
message: reason instanceof Error ? reason.message : String(reason),
|
|
87
|
+
exitCode: ExitCode.ERROR,
|
|
88
|
+
});
|
|
89
|
+
process.exit(OutputFormatter.getExitCode(result));
|
|
90
|
+
});
|