@stackwright-pro/otters 0.1.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.
@@ -0,0 +1,11 @@
1
+ {
2
+ "mcpServers": [
3
+ {
4
+ "name": "stackwright-pro-mcp",
5
+ "command": "pnpm",
6
+ "args": ["exec", "stackwright-pro-mcp"],
7
+ "autoStart": true,
8
+ "workingDirectory": "${PROJECT_ROOT}"
9
+ }
10
+ ]
11
+ }
package/MCP_TOOLS.md ADDED
@@ -0,0 +1,264 @@
1
+ # Stackwright Pro MCP Tools Reference
2
+
3
+ This document defines the MCP tools available for Pro Otters.
4
+
5
+ ## Tool Naming Convention
6
+
7
+ All Pro tools use the `stackwright_pro_` prefix to distinguish from OSS tools:
8
+ - `stackwright_pro_*` — Pro-specific tools
9
+ - `stackwright_*` — OSS Stackwright tools
10
+
11
+ ## Available Tools
12
+
13
+ ### API Discovery Tools
14
+
15
+ #### `stackwright_pro_list_entities`
16
+
17
+ Lists available entities from an OpenAPI spec or Zod schemas.
18
+
19
+ **Arguments:**
20
+ ```typescript
21
+ {
22
+ specPath?: string; // Path to OpenAPI spec (YAML/JSON)
23
+ schemaPath?: string; // Path to compiled Zod schemas
24
+ projectRoot?: string; // Project root (auto-detected if omitted)
25
+ }
26
+ ```
27
+
28
+ **Returns:**
29
+ ```typescript
30
+ {
31
+ success: boolean;
32
+ entities: {
33
+ name: string; // "Equipment", "Supplies"
34
+ slug: string; // "equipment", "supplies"
35
+ endpoint: string; // "/equipment", "/supplies/{id}"
36
+ fieldCount: number; // Number of fields
37
+ fields: {
38
+ name: string;
39
+ type: string;
40
+ required: boolean;
41
+ description?: string;
42
+ }[];
43
+ sourceFile: string;
44
+ }[];
45
+ errors?: string[];
46
+ }
47
+ ```
48
+
49
+ **Example:**
50
+ ```
51
+ stackwright_pro_list_entities --specPath ./api.yaml
52
+ ```
53
+
54
+ ---
55
+
56
+ #### `stackwright_pro_generate_filter`
57
+
58
+ Generates endpoint filter configuration from selected entities.
59
+
60
+ **Arguments:**
61
+ ```typescript
62
+ {
63
+ selectedEntities: string[]; // Entity slugs to include
64
+ projectRoot?: string; // Project root
65
+ outputFormat?: 'yaml' | 'json';
66
+ }
67
+ ```
68
+
69
+ **Returns:**
70
+ ```typescript
71
+ {
72
+ success: boolean;
73
+ filter: {
74
+ include?: string[]; // Endpoint patterns to include
75
+ exclude?: string[]; // Endpoint patterns to exclude
76
+ };
77
+ yaml?: string; // YAML snippet for stackwright.yml
78
+ errors?: string[];
79
+ }
80
+ ```
81
+
82
+ **Example:**
83
+ ```
84
+ stackwright_pro_generate_filter --selectedEntities equipment,supplies
85
+ ```
86
+
87
+ ---
88
+
89
+ #### `stackwright_pro_validate_spec`
90
+
91
+ Validates an OpenAPI spec against approved-specs configuration.
92
+
93
+ **Arguments:**
94
+ ```typescript
95
+ {
96
+ specPath: string;
97
+ configPath?: string; // Path to stackwright.yml with prebuild.security config
98
+ }
99
+ ```
100
+
101
+ **Returns:**
102
+ ```typescript
103
+ {
104
+ valid: boolean;
105
+ specUrl: string;
106
+ errorCode?: 'SPEC_NOT_ON_ALLOWLIST' | 'SPEC_MODIFIED' | 'DOWNLOAD_FAILED';
107
+ error?: string;
108
+ }
109
+ ```
110
+
111
+ ---
112
+
113
+ #### `stackwright_pro_discover_and_filter`
114
+
115
+ Convenience wrapper: list entities, let user select, generate filter.
116
+
117
+ **Arguments:**
118
+ ```typescript
119
+ {
120
+ specPath: string;
121
+ projectRoot?: string;
122
+ }
123
+ ```
124
+
125
+ **Returns:**
126
+ ```typescript
127
+ {
128
+ success: boolean;
129
+ entities: Entity[]; // All discovered entities
130
+ selectedEntities: string[]; // User-selected slugs
131
+ filter: FilterConfig; // Generated filter
132
+ yaml: string; // Ready-to-use YAML snippet
133
+ }
134
+ ```
135
+
136
+ ---
137
+
138
+ ### ISR Configuration Tools
139
+
140
+ #### `stackwright_pro_configure_isr`
141
+
142
+ Configures ISR (Incremental Static Regeneration) for API-backed collections.
143
+
144
+ **Arguments:**
145
+ ```typescript
146
+ {
147
+ collection: string; // Collection name
148
+ revalidateSeconds?: number; // Revalidation interval (default: 60)
149
+ fallback?: 'blocking' | 'true' | 'false';
150
+ projectRoot?: string;
151
+ }
152
+ ```
153
+
154
+ **Returns:**
155
+ ```typescript
156
+ {
157
+ success: boolean;
158
+ collection: string;
159
+ config: {
160
+ revalidate: number;
161
+ fallback: 'blocking' | 'true' | 'false';
162
+ };
163
+ yaml: string; // YAML snippet to add to stackwright.yml
164
+ }
165
+ ```
166
+
167
+ ---
168
+
169
+ ### Dashboard Generation Tools
170
+
171
+ #### `stackwright_pro_generate_dashboard`
172
+
173
+ Generates a dashboard page configuration from API entities.
174
+
175
+ **Arguments:**
176
+ ```typescript
177
+ {
178
+ entities: string[]; // Entity slugs to include
179
+ layout: 'grid' | 'table' | 'mixed';
180
+ projectRoot?: string;
181
+ }
182
+ ```
183
+
184
+ **Returns:**
185
+ ```typescript
186
+ {
187
+ success: boolean;
188
+ pageConfig: {
189
+ slug: string;
190
+ content: YAMLContent;
191
+ };
192
+ validationResult: ValidationResult;
193
+ }
194
+ ```
195
+
196
+ ---
197
+
198
+ ### Enterprise Security Tools
199
+
200
+ #### `stackwright_pro_add_approved_spec`
201
+
202
+ Adds a spec to the approved-specs allowlist.
203
+
204
+ **Arguments:**
205
+ ```typescript
206
+ {
207
+ name: string;
208
+ url: string;
209
+ sha256: string;
210
+ configPath?: string; // Path to stackwright.yml
211
+ }
212
+ ```
213
+
214
+ **Returns:**
215
+ ```typescript
216
+ {
217
+ success: boolean;
218
+ message: string;
219
+ config: PrebuildSecurityConfig;
220
+ }
221
+ ```
222
+
223
+ ---
224
+
225
+ #### `stackwright_pro_list_approved_specs`
226
+
227
+ Lists all approved specs in the configuration.
228
+
229
+ **Arguments:**
230
+ ```typescript
231
+ {
232
+ configPath?: string; // Path to stackwright.yml
233
+ }
234
+ ```
235
+
236
+ **Returns:**
237
+ ```typescript
238
+ {
239
+ specs: {
240
+ name: string;
241
+ url: string;
242
+ sha256: string;
243
+ }[];
244
+ securityEnabled: boolean;
245
+ }
246
+ ```
247
+
248
+ ---
249
+
250
+ ## Usage by Otter
251
+
252
+ | Otter | Tools Used |
253
+ |-------|------------|
254
+ | API Otter | `stackwright_pro_list_entities`, `stackwright_pro_validate_spec` |
255
+ | Data Otter | `stackwright_pro_generate_filter`, `stackwright_pro_configure_isr` |
256
+ | Dashboard Otter | `stackwright_pro_generate_dashboard`, `stackwright_render_page` |
257
+ | Foreman Pro Otter | All of the above + `stackwright_scaffold_project` |
258
+
259
+ ## Future Tools (Phase 2)
260
+
261
+ - `stackwright_pro_test_api_connection` — Test API connectivity
262
+ - `stackwright_pro_generate_types` — Generate TypeScript types from spec
263
+ - `stackwright_pro_generate_zod_schemas` — Generate Zod schemas
264
+ - `stackwright_pro_export_collection` — Export API data to file
@@ -0,0 +1,179 @@
1
+ # Pro Otter Architecture
2
+
3
+ ## Overview
4
+
5
+ The Pro Otter Raft builds on the OSS Stackwright Otter Raft to add live API integration. While OSS otters build static content pages, Pro otters connect pages to real-time API data.
6
+
7
+ ## The Pro Raft
8
+
9
+ ```
10
+ ┌────────────────────────────────────────────────────────────────────┐
11
+ │ PRO OTTER RAFT │
12
+ ├────────────────────────────────────────────────────────────────────┤
13
+ │ │
14
+ │ 🦦🔧 Foreman Pro Otter │
15
+ │ ├── Entry point for Pro projects │
16
+ │ ├── Orchestrates: API → Data → Dashboard pipeline │
17
+ │ └── Invokes child otters via agent_share_your_reasoning │
18
+ │ │
19
+ │ 🦦🔍 API Otter │
20
+ │ ├── Discovers entities from OpenAPI specs │
21
+ │ ├── Validates specs against approved-specs (enterprise) │
22
+ │ └── Outputs: Entity list + spec validation │
23
+ │ │
24
+ │ 🦦📊 Data Otter │
25
+ │ ├── Generates endpoint filters from selected entities │
26
+ │ ├── Configures ISR revalidation intervals │
27
+ │ └── Outputs: stackwright.yml API configuration │
28
+ │ │
29
+ │ 🦦📈 Dashboard Otter │
30
+ │ ├── Builds pages displaying live API data │
31
+ │ ├── Uses collection_listing, data_table, stats_grid content types │
32
+ │ └── Outputs: Validated pages/*.yml files │
33
+ │ │
34
+ └────────────────────────────────────────────────────────────────────┘
35
+ ```
36
+
37
+ ## Data Flow
38
+
39
+ ```
40
+ 1. FOREMAN PRO OTTER
41
+
42
+ ├─► "What API should we connect to?"
43
+
44
+
45
+ 2. API OTTER
46
+
47
+ ├─► stackwright_pro_list_entities --specPath <url>
48
+
49
+ ├─► "Found 47 entities: Equipment, Supplies, Personnel..."
50
+
51
+ ├─► User selects: equipment, supplies
52
+
53
+
54
+ 3. DATA OTTER
55
+
56
+ ├─► stackwright_pro_generate_filter --selectedEntities equipment,supplies
57
+
58
+ ├─► Generates: endpoints.include: ["/equipment/**", "/supplies/**"]
59
+
60
+ ├─► stackwright_pro_configure_isr --collection equipment --revalidateSeconds 60
61
+
62
+ ├─► stackwright_pro_configure_isr --collection supplies --revalidateSeconds 120
63
+
64
+
65
+ 4. DASHBOARD OTTER
66
+
67
+ ├─► Reads: stackwright.yml (API config)
68
+
69
+ ├─► Designs: Equipment listing + detail views
70
+
71
+ ├─► Writes: pages/equipment/content.yml
72
+
73
+ ├─► Validates: stackwright_validate_pages
74
+
75
+ └─► Renders: stackwright_render_page --slug /equipment
76
+ ```
77
+
78
+ ## MCP Tool Categories
79
+
80
+ ### Discovery Tools
81
+ - `stackwright_pro_list_entities` — Find entities in OpenAPI spec
82
+ - `stackwright_pro_validate_spec` — Check against approved specs
83
+
84
+ ### Configuration Tools
85
+ - `stackwright_pro_generate_filter` — Create endpoint filters
86
+ - `stackwright_pro_configure_isr` — Set revalidation intervals
87
+
88
+ ### Generation Tools
89
+ - `stackwright_pro_generate_dashboard` — Create dashboard pages
90
+ - `stackwright_pro_add_approved_spec` — Add to allowlist
91
+
92
+ ## Enterprise Mode
93
+
94
+ When `prebuild.security.enabled: true` in stackwright.yml:
95
+
96
+ ```
97
+ ┌────────────────────────────────────────────────────────────────────┐
98
+ │ ENTERPRISE MODE │
99
+ ├────────────────────────────────────────────────────────────────────┤
100
+ │ │
101
+ │ User provides: https://api.gov.mil/logistics/v1/openapi.yaml │
102
+ │ │
103
+ │ API OTTER: │
104
+ │ ├─► stackwright_pro_validate_spec --specPath <url> │
105
+ │ │ │
106
+ │ │ Validates: │
107
+ │ │ ├─► URL is on approved-specs allowlist │
108
+ │ │ ├─► SHA-256 hash matches approved version │
109
+ │ │ └─► No SSRF risk (redirects blocked) │
110
+ │ │ │
111
+ │ └─► ✓ Spec approved OR ✗ Security rejection │
112
+ │ │
113
+ └────────────────────────────────────────────────────────────────────┘
114
+ ```
115
+
116
+ ## Dashboard Page Types
117
+
118
+ | Content Type | Use Case | API Binding |
119
+ |--------------|----------|-------------|
120
+ | `collection_listing` | Paginated list of items | `collection: equipment` |
121
+ | `data_table` | Sortable/filterable table | `collection: equipment` + `params: {sort, filter}` |
122
+ | `stats_grid` | KPI cards | `collection: equipment` + `aggregate: count` |
123
+ | `detail_view` | Single item detail | `collection: equipment` + `slug_field: id` |
124
+
125
+ ## File Outputs
126
+
127
+ After a full Pro build:
128
+
129
+ ```
130
+ project/
131
+ ├── stackwright.yml # API integrations + ISR config
132
+ ├── src/
133
+ │ └── generated/
134
+ │ └── equipment/
135
+ │ ├── client.ts # Typed API client
136
+ │ ├── types.ts # TypeScript types
137
+ │ └── schemas.ts # Zod validation schemas
138
+ └── pages/
139
+ └── equipment/
140
+ └── content.yml # Dashboard page definition
141
+ ```
142
+
143
+ ## Dependencies
144
+
145
+ ### OSS MCP Server
146
+ Pro otters depend on the OSS Stackwright MCP server for:
147
+ - `stackwright_scaffold_project`
148
+ - `stackwright_render_page`
149
+ - `stackwright_validate_pages`
150
+
151
+ ### Pro MCP Server (packages/mcp/)
152
+ Pro otters use the Pro MCP server for:
153
+ - `stackwright_pro_list_entities`
154
+ - `stackwright_pro_generate_filter`
155
+ - `stackwright_pro_configure_isr`
156
+ - etc.
157
+
158
+ ## Security Model
159
+
160
+ ```
161
+ ┌────────────────────────────────────────────────────────────────────┐
162
+ │ SECURITY MODEL │
163
+ ├────────────────────────────────────────────────────────────────────┤
164
+ │ │
165
+ │ 1. ENDPOINT FILTERING │
166
+ │ ├─► SME selects entities → only those endpoints generated │
167
+ │ └─► Prevents unauthorized API access │
168
+ │ │
169
+ │ 2. APPROVED-SPECS (Enterprise) │
170
+ │ ├─► SHA-256 hash verification │
171
+ │ ├─► URL allowlist │
172
+ │ └─► Fails build if spec modified │
173
+ │ │
174
+ │ 3. ISR REVALIDATION │
175
+ │ ├─► Stale-while-revalidate pattern │
176
+ │ └─► Fails gracefully, never serves broken data │
177
+ │ │
178
+ └────────────────────────────────────────────────────────────────────┘
179
+ ```
package/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # Stackwright Pro Otter Raft 🦦
2
+
3
+ AI agents for building Stackwright Pro projects with live API integration.
4
+
5
+ ## The Pro Raft
6
+
7
+ | Otter | Role | What it does |
8
+ |-------|------|--------------|
9
+ | **Foreman Pro Otter** | Coordinator | Orchestrates API → Data → Dashboard pipeline |
10
+ | **API Otter** | API Explorer | Discovers entities from OpenAPI specs |
11
+ | **Data Otter** | Configuration | Generates endpoint filters, configures ISR |
12
+ | **Dashboard Otter** | Page Builder | Builds pages displaying live API data |
13
+
14
+ ## Quick Start
15
+
16
+ ```bash
17
+ # Start with Foreman Pro Otter
18
+ code-puppy invoke stackwright-pro-foreman-otter
19
+
20
+ # Or individual otters
21
+ code-puppy invoke stackwright-pro-api-otter
22
+ code-puppy invoke stackwright-pro-data-otter
23
+ code-puppy invoke stackwright-pro-dashboard-otter
24
+ ```
25
+
26
+ ## What Pro Adds
27
+
28
+ | Feature | OSS Stackwright | Pro Stackwright |
29
+ |---------|-----------------|-----------------|
30
+ | Content source | YAML files | Live API data |
31
+ | Data freshness | Build-time | Real-time (ISR) |
32
+ | API integration | None | OpenAPI → typed client |
33
+ | Enterprise security | None | Approved-specs validation |
34
+
35
+ ## Prerequisites
36
+
37
+ 1. **Stackwright Pro packages installed:**
38
+ ```bash
39
+ pnpm add @stackwright-pro/openapi
40
+ ```
41
+
42
+ 2. **Pro MCP server running:**
43
+ ```bash
44
+ # The .code-puppy.json auto-starts the Pro MCP server
45
+ code-puppy invoke stackwright-pro-foreman-otter
46
+ ```
47
+
48
+ 3. **OpenAPI spec** (URL or local file):
49
+ - Government: `https://api.gov.mil/logistics/v1/openapi.yaml`
50
+ - Enterprise: `https://api.internal.com/openapi.json`
51
+ - Local: `./specs/my-api.yaml`
52
+
53
+ ## Example Workflow
54
+
55
+ ```
56
+ > "Build me a logistics dashboard from our government API"
57
+
58
+ FOREMAN PRO OTTER:
59
+ ├─► API OTTER: What spec should I use?
60
+
61
+ │ "Here's the approved government API: https://api.gov.mil/logistics/v1/openapi.yaml"
62
+
63
+ ├─► API OTTER: *discovers 47 entities*
64
+ │ └─► Found: Equipment, Supplies, Personnel, Vehicles, Facilities...
65
+
66
+ │ "Which entities do you want to display?"
67
+
68
+ │ "Equipment, Supplies, and Vehicles"
69
+
70
+ ├─► DATA OTTER: *generates endpoint filters*
71
+ │ └─► Configured: /equipment/**, /supplies/**, /vehicles/**
72
+
73
+ │ *configures ISR*
74
+ │ └─► Equipment: revalidate=60s, Supplies: revalidate=120s
75
+
76
+ ├─► DASHBOARD OTTER: *builds pages*
77
+ │ └─► Created: /equipment, /supplies, /vehicles
78
+
79
+ └─► "Done! Your logistics dashboard is ready."
80
+ ```
81
+
82
+ ## Enterprise Mode
83
+
84
+ For government/defense environments, enable approved-specs validation:
85
+
86
+ ```yaml
87
+ # stackwright.yml
88
+ prebuild:
89
+ security:
90
+ enabled: true
91
+ allowlist:
92
+ - name: Logistics API
93
+ url: https://api.gov.mil/logistics/v1/openapi.yaml
94
+ sha256: a1b2c3d4e5f6...
95
+ ```
96
+
97
+ This ensures:
98
+ - Only pre-approved API specs are used
99
+ - Spec integrity verified via SHA-256
100
+ - SSRF attacks blocked
101
+
102
+ ## MCP Tools
103
+
104
+ See [MCP_TOOLS.md](./MCP_TOOLS.md) for full reference.
105
+
106
+ ## Architecture
107
+
108
+ See [PRO_OTTER_ARCHITECTURE.md](./PRO_OTTER_ARCHITECTURE.md) for detailed architecture.
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@stackwright-pro/otters",
3
+ "version": "0.1.0",
4
+ "description": "Pro Otter Raft - AI agents for building full-stack Stackwright Pro projects with live API integration",
5
+ "license": "PROPRIETARY",
6
+ "files": [
7
+ "*.json",
8
+ "*.md"
9
+ ],
10
+ "peerDependencies": {
11
+ "@stackwright-pro/mcp": "0.1.0"
12
+ }
13
+ }