Skip to content

Commit 3f317a1

Browse files
committed
fix(cli): add local plugin dev steps to MCP instructions
1 parent 523a773 commit 3f317a1

File tree

1 file changed

+109
-1
lines changed

1 file changed

+109
-1
lines changed

cli/internal/mcp/instructions-plugin-library-development.md

Lines changed: 109 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This guide covers how to create and maintain Suga plugin libraries, which provide the building blocks that platforms compose together.
44

5+
**Note for AI Agents**: This is a technical reference for precise implementation details. For user-facing documentation with more conceptual explanations and getting started guides, refer users to the [Plugin Development Guide](/guides/plugin-development) in the Suga docs.
6+
57
## Overview
68

79
A **plugin library** is a collection of reusable Terraform modules that implement infrastructure components. Each plugin in the library is a self-contained unit that:
@@ -63,7 +65,7 @@ Plugins typically fall into these categories:
6365

6466
### What Is Runtime Code?
6567

66-
Runtime code is **Go code that gets embedded into your Suga application** to facilitate communication between your app and the deployed cloud infrastructure. This is NOT an SDK or library - it is **necessary runtime code** that your application requires to function.
68+
Runtime code (also called "runtime adapters" in user-facing documentation) is **Go code that gets embedded into your Suga application** to facilitate communication between your app and the deployed cloud infrastructure. This is NOT an SDK or library - it is **necessary runtime code** that your application requires to function.
6769

6870
**Currently, runtime code is ONLY written in Go.**
6971

@@ -453,6 +455,112 @@ terraform {
453455
}
454456
```
455457

458+
## Local Development Workflow
459+
460+
The `suga plugin serve` command and `suga build --replace-library` flag enable rapid plugin development without publishing changes to a registry.
461+
462+
### Why This Matters
463+
464+
Without these tools, every plugin change would require:
465+
1. Pushing changes to Git
466+
2. Tagging a new version
467+
3. Publishing to the Suga platform
468+
4. Updating platform definitions to use the new version
469+
5. Building applications to test changes
470+
471+
This cycle could take minutes for each iteration. The local development workflow reduces this to seconds.
472+
473+
### Step 1: Start the Plugin Development Server
474+
475+
From your plugin library root directory:
476+
477+
```bash
478+
cd my-plugins
479+
suga plugin serve
480+
```
481+
482+
You'll see output like:
483+
484+
```
485+
Suga Plugin Development Server
486+
Listening on: http://localhost:9000
487+
488+
Discovered Plugins:
489+
✓ lambda (service)
490+
✓ s3-bucket (bucket)
491+
492+
Configuration:
493+
Add to your platform.yaml:
494+
libraries:
495+
myorg/myplugins: http://localhost:9000
496+
497+
Press Ctrl+C to stop
498+
```
499+
500+
The server:
501+
- Discovers all plugins in subdirectories
502+
- Validates manifest files
503+
- Serves plugin manifests over HTTP
504+
- Implements the Go module proxy protocol for runtime code
505+
- Watches for file changes (restart to pick up new plugins)
506+
507+
### Step 2: Test Your Plugin in an Application
508+
509+
In a separate terminal, navigate to a Suga application that uses a platform with the plugin library you're developing.
510+
511+
Replace the library at build time:
512+
513+
```bash
514+
cd my-app
515+
suga build --replace-library suga/aws=http://localhost:9000
516+
```
517+
518+
This tells Suga to:
519+
1. Load your platform definition
520+
2. Replace the `suga/aws` library with your local version at `http://localhost:9000`
521+
3. Use your local plugin manifests and Terraform modules
522+
4. Download runtime code from your local Go module proxy
523+
5. Generate Terraform with your changes
524+
525+
**Multiple Replacements**: You can replace multiple libraries at once:
526+
```bash
527+
suga build -r suga/aws=http://localhost:9000 -r suga/gcp=http://localhost:9001
528+
```
529+
530+
### Step 3: Iterate and Refine
531+
532+
The development cycle becomes:
533+
534+
1. **Edit your plugin files** (manifest.yaml, Terraform, or Go code)
535+
2. **Rebuild your application**: `suga build -r suga/aws=http://localhost:9000`
536+
3. **Test the generated Terraform**: `cd terraform/stacks/my-app && terraform init --upgrade && terraform plan`
537+
4. **Repeat**: Make adjustments and rebuild
538+
539+
### Step 4: Using with Custom Platforms
540+
541+
If you're developing both a platform and plugins simultaneously:
542+
543+
**Option 1: Replace in platform definition**
544+
545+
Edit your `platform.yaml` to reference your local server:
546+
547+
```yaml
548+
name: my-platform
549+
libraries:
550+
myorg/myplugins: http://localhost:9000 # Local development
551+
# myorg/myplugins: v0.0.1 # Production version
552+
```
553+
554+
**Option 2: Replace at build time (recommended)**
555+
556+
Keep production URLs in your platform and override during development:
557+
558+
```bash
559+
suga build --replace-library myorg/myplugins=http://localhost:9000
560+
```
561+
562+
This keeps your platform definition production-ready while allowing local testing.
563+
456564
## Development Workflow
457565

458566
### 1. Planning a New Plugin

0 commit comments

Comments
 (0)