Skip to content

Commit 0795203

Browse files
committed
docs: update documentation for dual-mode generation system
- Add 'Using This Scaffold' section to README.md - Document template mode (--in-place) and generator mode - Update GENERATE-PLUGIN.md with comprehensive mode explanations - Add workflow comparisons and use cases for each mode - Update file paths (parts/ → template-parts/) - Fix agent reference (scaffold-generator → generate-plugin) Completes tasks 6-7 of release preparation
1 parent 6b3fdcf commit 0795203

File tree

2 files changed

+231
-57
lines changed

2 files changed

+231
-57
lines changed

README.md

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,86 @@ A multi-block WordPress plugin scaffold with support for:
3030
- Node.js 18+
3131
- [Secure Custom Fields](https://wordpress.org/plugins/secure-custom-fields/) plugin
3232

33-
## Installation
33+
## Using This Scaffold
3434

35-
1. Clone this repository to your WordPress plugins directory:
35+
This scaffold can be used in two ways:
36+
37+
### Option 1: Template Mode (Modify Scaffold Directly)
38+
39+
Use the scaffold as a template repository and process it in-place:
40+
41+
1. **Create from template** on GitHub or clone the repository
42+
2. **Process the scaffold** with your plugin details:
43+
44+
```bash
45+
node scripts/generate-plugin.js --in-place
46+
```
47+
48+
This will:
49+
- Prompt for confirmation (to prevent accidental overwrites)
50+
- Replace all `{{mustache}}` variables in files
51+
- Update file and directory names with your slug
52+
- Process the scaffold directory directly (no separate output)
53+
54+
3. **Install dependencies and build**:
55+
56+
```bash
57+
npm install
58+
composer install
59+
npm run build
60+
```
61+
62+
4. **Commit your customized plugin** to your repository
63+
64+
**⚠️ Important**: Template mode modifies files in-place. Always use on a fresh clone or when you're certain you want to replace the scaffold content.
65+
66+
### Option 2: Generator Mode (Create New Plugin)
67+
68+
Generate a new plugin in a separate output directory:
69+
70+
1. **Clone or download** this scaffold repository
71+
2. **Run the generator** to create a new plugin:
72+
73+
```bash
74+
node scripts/generate-plugin.js
75+
```
76+
77+
Or with a configuration file:
78+
79+
```bash
80+
node scripts/generate-plugin.js --config my-plugin-config.json
81+
```
82+
83+
3. **Find your generated plugin** in:
84+
- `generated-plugins/<your-slug>/` - Complete plugin ready to use
85+
86+
4. **Move to WordPress plugins directory**:
87+
88+
```bash
89+
mv generated-plugins/my-plugin/ /path/to/wordpress/wp-content/plugins/
90+
cd /path/to/wordpress/wp-content/plugins/my-plugin/
91+
npm install
92+
composer install
93+
npm run build
94+
```
95+
96+
**Benefits**: Keeps the scaffold repository clean and can generate multiple plugins.
97+
98+
See [docs/GENERATE-PLUGIN.md](docs/GENERATE-PLUGIN.md) for detailed usage instructions, configuration options, and examples.
99+
100+
## Installation (For Already-Generated Plugins)
101+
102+
If you've already processed the scaffold or received a generated plugin:
103+
104+
1. Ensure you're in your WordPress plugins directory:
36105

37106
```bash
38-
cd wp-content/plugins/
39-
git clone https://github.com/{{author}}/{{slug}}.git
107+
cd wp-content/plugins/your-plugin-name
40108
```
41109

42110
2. Install dependencies:
43111

44112
```bash
45-
cd {{slug}}
46113
npm install
47114
composer install
48115
```

docs/GENERATE-PLUGIN.md

Lines changed: 159 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,147 @@ JSON configuration files (`package.json`, `composer.json`, `block.json`) use pla
162162
}
163163
```
164164

165+
## Operational Modes
166+
167+
### Template Mode vs Generator Mode
168+
169+
The scaffold supports two operational modes:
170+
171+
#### Template Mode (`--in-place`)
172+
173+
**Use when**: You want to use the scaffold as a starting point for your plugin.
174+
175+
- Processes files directly in the scaffold directory
176+
- Replaces all mustache variables in-place
177+
- Renames files and directories to match your slug
178+
- **⚠️ Destructive**: Modifies the scaffold permanently
179+
- Includes confirmation prompt to prevent accidents
180+
- Best for GitHub template repositories
181+
182+
**Command:**
183+
184+
```bash
185+
node scripts/generate-plugin.js --in-place
186+
```
187+
188+
**Workflow:**
189+
190+
1. Clone/fork the scaffold repository
191+
2. Run generator with `--in-place` flag
192+
3. Confirm the operation (y/N prompt)
193+
4. Scaffold is processed in-place
194+
5. Install dependencies and build
195+
6. Commit your customized plugin
196+
197+
#### Generator Mode (Default)
198+
199+
**Use when**: You want to create multiple plugins or keep the scaffold clean.
200+
201+
- Creates new plugin in `generated-plugins/<slug>/`
202+
- Leaves scaffold directory unchanged
203+
- Can generate multiple plugins
204+
- Safe for repeated use
205+
- Best for maintaining the scaffold as a tool
206+
207+
**Command:**
208+
209+
```bash
210+
node scripts/generate-plugin.js
211+
```
212+
213+
**Workflow:**
214+
215+
1. Clone the scaffold repository once
216+
2. Run generator (no `--in-place` flag)
217+
3. Generated plugin appears in `generated-plugins/<slug>/`
218+
4. Move to WordPress plugins directory
219+
5. Install dependencies and build
220+
6. Generate another plugin anytime
221+
165222
## Generation Methods
166223

167-
### Method 1: AI-Assisted Generation (Recommended)
224+
### Method 1: Template Mode (In-Place Processing)
225+
226+
Use the scaffold as a GitHub template and process it directly:
227+
228+
```bash
229+
# Interactive mode with confirmation
230+
node scripts/generate-plugin.js --in-place
231+
232+
# With configuration file
233+
node scripts/generate-plugin.js --in-place --config plugin-config.json
234+
235+
# Skip confirmation (automation only - use with caution)
236+
node scripts/generate-plugin.js --in-place --yes
237+
```
238+
239+
**Process:**
240+
241+
1. Prompts for plugin configuration (or reads from config file)
242+
2. **Displays confirmation warning** about in-place modification
243+
3. Waits for user confirmation (y/N)
244+
4. Processes all files in the scaffold directory
245+
5. Replaces mustache variables throughout
246+
6. Renames files/directories to match your slug
247+
7. Reports completion with next steps
248+
249+
**⚠️ Important Notes:**
250+
251+
- Always use on a fresh clone or template repository
252+
- Cannot be undone without version control
253+
- Confirmation prompt defaults to "No" for safety
254+
- Use `--yes` flag only in automated workflows you trust
255+
256+
### Method 2: Generator Mode (Default)
257+
258+
Create a new plugin in a separate output directory:
259+
260+
```bash
261+
# Interactive mode - prompts for all configuration
262+
node scripts/generate-plugin.js
263+
264+
# With configuration file
265+
node scripts/generate-plugin.js --config plugin-config.json
266+
267+
# With inline arguments
268+
node scripts/generate-plugin.js \
269+
--slug tour-operator \
270+
--name "Tour Operator" \
271+
--description "Tour booking and display plugin" \
272+
--author "LightSpeed" \
273+
--author-uri "https://developer.lsdev.biz"
274+
```
275+
276+
**Process:**
277+
278+
1. Reads configuration from prompts, file, or arguments
279+
2. Validates configuration against schema
280+
3. Creates `generated-plugins/<slug>/` directory
281+
4. Copies and processes all scaffold files
282+
5. Replaces mustache variables
283+
6. Renames files/directories
284+
7. Leaves scaffold directory unchanged
285+
286+
**Output Location:**
287+
288+
```bash
289+
generated-plugins/
290+
└── tour-operator/ # Your generated plugin
291+
├── tour-operator.php
292+
├── package.json
293+
├── composer.json
294+
└── ... (complete plugin structure)
295+
```
296+
297+
**Best for:**
298+
299+
- Creating multiple plugins from the same scaffold
300+
- Keeping scaffold repository clean
301+
- Testing different configurations
302+
- CI/CD pipelines
303+
- Advanced users comfortable with CLI tools
304+
305+
### Method 3: AI-Assisted Generation (Recommended)
168306

169307
Use the workspace prompt for an interactive, guided experience:
170308

@@ -179,7 +317,7 @@ Use the workspace prompt for an interactive, guided experience:
179317
3. Collects all required information interactively
180318
4. Validates input at each stage
181319
5. Confirms configuration before generation
182-
6. Generates the complete plugin structure
320+
6. Generates the complete plugin structure (uses generator mode by default)
183321
7. Provides post-generation setup instructions
184322

185323
**Benefits:**
@@ -189,6 +327,7 @@ Use the workspace prompt for an interactive, guided experience:
189327
- Validation at each step
190328
- Smart defaults for common configurations
191329
- Best for first-time users
330+
- Can use either template or generator mode
192331

193332
**Stages:**
194333

@@ -200,7 +339,7 @@ Use the workspace prompt for an interactive, guided experience:
200339
6. **Templates & Patterns** - Template and pattern selection
201340
7. **Version & Compatibility** - WordPress/PHP requirements
202341

203-
### Method 2: Agent-Based Generation
342+
### Method 4: Agent-Based Generation
204343

205344
Request the scaffold generator agent directly:
206345

@@ -214,60 +353,28 @@ Or be more specific:
214353
Create a tour operator plugin with tours CPT, destination taxonomy, and booking fields
215354
```
216355

217-
**Features:**
218-
219-
- Conversational interface
220-
- Can infer requirements from description
221-
- Validates configuration automatically
222-
- Follows agent specification in `.github/agents/scaffold-generator.agent.md`
223-
- Best for experienced users who know their requirements
224-
225-
### Method 3: CLI Script
226-
227-
Run the generator script directly from the command line:
228-
229-
```bash
230-
node bin/generate-plugin.js
231-
```
232-
233-
**Interactive Mode:**
234-
235-
```bash
236-
# Prompts for all required information
237-
node bin/generate-plugin.js
238-
```
356+
### Method 4: Agent-Based Generation
239357

240-
**Direct Mode:**
358+
Request the scaffold generator agent directly:
241359

242-
```bash
243-
# Provide all values via arguments
244-
node bin/generate-plugin.js \
245-
--slug tour-operator \
246-
--name "Tour Operator" \
247-
--description "Tour booking and display plugin" \
248-
--author "LightSpeed" \
249-
--author-uri "https://developer.lsdev.biz"
360+
```text
361+
Generate a new multi-block plugin from scaffold
250362
```
251363

252-
**Configuration File Mode:**
364+
Or be more specific:
253365

254-
```bash
255-
# Use a JSON configuration file
256-
echo '{
257-
"slug": "tour-operator",
258-
"name": "Tour Operator",
259-
"description": "Tour booking plugin",
260-
"author": "LightSpeed"
261-
}' > plugin-config.json
262-
263-
node bin/generate-plugin.js --config plugin-config.json
366+
```text
367+
Create a tour operator plugin with tours CPT, destination taxonomy, and booking fields
264368
```
265369

266-
**Best for:**
370+
**Features:**
267371

268-
- Automation and CI/CD pipelines
269-
- Batch plugin generation
270-
- Advanced users comfortable with CLI tools
372+
- Conversational interface
373+
- Can infer requirements from description
374+
- Validates configuration automatically
375+
- Follows agent specification in `.github/agents/generate-plugin.agent.md`
376+
- Best for experienced users who know their requirements
377+
- Can use either template or generator mode
271378

272379
## Post-Generation Workflow
273380

@@ -280,7 +387,7 @@ tree -L 2
280387

281388
Expected structure:
282389

283-
```
390+
```text
284391
tour-operator/
285392
├── tour-operator.php # Main plugin file (slug-based name)
286393
├── package.json # Node dependencies
@@ -293,7 +400,7 @@ tour-operator/
293400
│ └── scss/ # Stylesheets
294401
├── templates/ # Block templates
295402
├── patterns/ # Block patterns
296-
├── parts/ # Template parts
403+
├── template-parts/ # Template parts
297404
└── scf-json/ # SCF field groups
298405
```
299406

@@ -485,7 +592,7 @@ Updates: `package.json`, `composer.json`, main plugin file, all `block.json` fil
485592
## Related Documentation
486593

487594
- [Generator Instructions](.github/instructions/generate-plugin.instructions.md) - Rules for using mustache values
488-
- [Scaffold Generator Agent](.github/agents/scaffold-generator.agent.md) - Agent specification
595+
- [Plugin Generator Agent](.github/agents/generate-plugin.agent.md) - Agent specification
489596
- [Generation Prompt](.github/prompts/generate-plugin.prompt.md) - Interactive prompt template
490597
- [SCF Fields Reference](.github/instructions/scf-fields.instructions.md) - Field types and usage
491598
- [Build Process](BUILD-PROCESS.md) - Detailed build documentation

0 commit comments

Comments
 (0)