Commit 138bab3
Fix plop template for non-interactive environments
Fixes issue where plop generator fails with readline errors when run from
non-TTY environments like AI agents, CI, or piped scripts.
## Changes
### plopfile.cjs
- Added comprehensive JSDoc comments explaining both interactive and non-interactive usage
- Documented command-line argument syntax: `npx plop create-tool "ToolName" "tool_name_tool"`
- Fixed tool registration to include `{ httpRequest }` parameter
### plop-templates/tool.hbs
- Fixed execute() method signature to include `accessToken: string` parameter
- Added proper `annotations` property (title, readOnlyHint, openWorldHint, etc.)
- Replaced invalid syntax with valid TypeScript (throw Error vs invalid ellipsis)
- Updated example to use correct API: `mapboxApiEndpoint` (not MAPBOX_API_ENDPOINT)
- Added comprehensive TODO comments with proper code structure
### plop-templates/tool.test.hbs
- Migrated from Jest to Vitest (describe, it, expect, vi)
- Updated imports to use current test utilities (setupHttpRequest, assertHeadersSent)
- Fixed import paths to match current structure
- Added copyright header
- Added MAPBOX_ACCESS_TOKEN env var setup
- Added three test cases: custom header, structured content, API errors
### CLAUDE.md
- Documented both interactive and non-interactive modes
- Added clear examples and usage notes
- Emphasized non-interactive mode for AI agents to avoid readline errors
## Testing
Verified generator works in non-interactive mode:
```bash
npx plop create-tool "Example" "example_tool"
```
Generated files:
- ExampleTool.ts with proper structure and annotations
- ExampleTool.input.schema.ts
- ExampleTool.output.schema.ts
- ExampleTool.test.ts with vitest tests
- Auto-updates toolRegistry.ts with correct registration
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>1 parent 79f11aa commit 138bab3
File tree
4 files changed
+112
-24
lines changed- plop-templates
4 files changed
+112
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
69 | 76 | | |
70 | 77 | | |
| 78 | + | |
| 79 | + | |
71 | 80 | | |
72 | 81 | | |
73 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
19 | 26 | | |
20 | 27 | | |
21 | 28 | | |
| |||
28 | 35 | | |
29 | 36 | | |
30 | 37 | | |
| 38 | + | |
31 | 39 | | |
32 | 40 | | |
33 | 41 | | |
34 | | - | |
| 42 | + | |
| 43 | + | |
35 | 44 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
42 | 62 | | |
43 | 63 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
3 | 18 | | |
4 | 19 | | |
5 | 20 | | |
6 | | - | |
| 21 | + | |
7 | 22 | | |
8 | 23 | | |
9 | 24 | | |
10 | | - | |
11 | | - | |
12 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
13 | 34 | | |
14 | 35 | | |
15 | | - | |
16 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
17 | 52 | | |
18 | | - | |
19 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
20 | 56 | | |
21 | 57 | | |
22 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
23 | 62 | | |
24 | 63 | | |
25 | 64 | | |
26 | 65 | | |
27 | | - | |
| 66 | + | |
28 | 67 | | |
29 | | - | |
30 | 68 | | |
31 | 69 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
1 | 22 | | |
2 | 23 | | |
3 | 24 | | |
| |||
6 | 27 | | |
7 | 28 | | |
8 | 29 | | |
9 | | - | |
| 30 | + | |
10 | 31 | | |
11 | 32 | | |
12 | 33 | | |
| |||
44 | 65 | | |
45 | 66 | | |
46 | 67 | | |
47 | | - | |
| 68 | + | |
48 | 69 | | |
49 | 70 | | |
50 | 71 | | |
| |||
0 commit comments