@stackwright-pro/otters 1.0.0-alpha.6 → 1.0.0-alpha.60
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/LICENSE +21 -0
- package/README.md +7 -6
- package/package.json +7 -6
- package/scripts/generate-checksums.js +0 -1
- package/scripts/install-agents.js +5 -2
- package/scripts/launch-raft.cjs +13 -0
- package/scripts/strip-artifact-schemas.cjs +133 -0
- package/src/checksums.json +14 -9
- package/src/stackwright-pro-api-otter.json +46 -92
- package/src/stackwright-pro-auth-otter.json +26 -789
- package/src/stackwright-pro-dashboard-otter.json +21 -660
- package/src/stackwright-pro-data-otter.json +21 -534
- package/src/stackwright-pro-designer-otter.json +9 -14
- package/src/stackwright-pro-domain-expert-otter.json +21 -0
- package/src/stackwright-pro-foreman-otter.json +26 -653
- package/src/stackwright-pro-form-wizard-otter.json +29 -0
- package/src/stackwright-pro-geo-otter.json +42 -0
- package/src/stackwright-pro-page-otter.json +8 -4
- package/src/stackwright-pro-polish-otter.json +42 -0
- package/src/stackwright-pro-scaffold-otter.json +25 -0
- package/src/stackwright-pro-theme-otter.json +23 -20
- package/src/stackwright-services-otter-system.md +192 -0
- package/src/stackwright-services-otter.json +44 -0
- package/src/python-bridge.ts +0 -391
- package/src/question-adapter.ts +0 -296
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
PROPRIETARY SOFTWARE LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Per Aspera LLC. All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
This software and associated documentation files (the "Software") are the
|
|
6
|
+
proprietary and confidential property of Per Aspera LLC ("Company").
|
|
7
|
+
|
|
8
|
+
RESTRICTIONS: You may not use, copy, modify, merge, publish, distribute,
|
|
9
|
+
sublicense, sell, or otherwise exploit this Software or any portion thereof
|
|
10
|
+
without the express prior written consent of the Company.
|
|
11
|
+
|
|
12
|
+
GOVERNMENT USE: Use, duplication, or disclosure by the U.S. Government is
|
|
13
|
+
subject to restrictions as set forth in FAR 52.227-19 (Commercial Computer
|
|
14
|
+
Software - Restricted Rights) and DFARS 252.227-7013 (Rights in Technical
|
|
15
|
+
Data and Computer Software), as applicable.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED. IN NO EVENT SHALL THE COMPANY BE LIABLE FOR ANY CLAIM, DAMAGES, OR
|
|
19
|
+
OTHER LIABILITY ARISING FROM THE USE OF THE SOFTWARE.
|
|
20
|
+
|
|
21
|
+
For licensing inquiries: legal@peraspera.com
|
package/README.md
CHANGED
|
@@ -118,12 +118,13 @@ When Pro otters combine with the OSS raft, these capabilities emerge:
|
|
|
118
118
|
|
|
119
119
|
## The Pro Otter Raft
|
|
120
120
|
|
|
121
|
-
| Otter
|
|
122
|
-
|
|
|
123
|
-
| 🦦🦦 **Foreman Otter**
|
|
124
|
-
| 🦦📡 **API Otter**
|
|
125
|
-
| 🦦📊 **Dashboard Otter**
|
|
126
|
-
| 🦦🔗 **Data Otter**
|
|
121
|
+
| Otter | Role | Output |
|
|
122
|
+
| ------------------------------------- | -------------------- | ------------------------------------------------------------------------------- |
|
|
123
|
+
| 🦦🦦 **Foreman Otter** | Project coordinator | Orchestrates full-stack builds (delegates to unified Foreman) |
|
|
124
|
+
| 🦦📡 **API Otter** | OpenAPI discovery | API entity types, endpoints |
|
|
125
|
+
| 🦦📊 **Dashboard Otter** | Live data views | Typed API components |
|
|
126
|
+
| 🦦🔗 **Data Otter** | Endpoint integration | ISR config, filters |
|
|
127
|
+
| `stackwright-pro-domain-expert-otter` | Utility | Answers specialist questions from the use case document in non-interactive mode |
|
|
127
128
|
|
|
128
129
|
---
|
|
129
130
|
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackwright-pro/otters",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.60",
|
|
4
4
|
"description": "Stackwright Pro Otter Raft - AI agents for enterprise features (CAC auth, API dashboards, government use cases)",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/Per-Aspera-LLC/stackwright-pro"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"vitest": "^4.
|
|
12
|
-
"zod": "^
|
|
11
|
+
"vitest": "^4.1.8",
|
|
12
|
+
"zod": "^4.4.3"
|
|
13
13
|
},
|
|
14
14
|
"exports": {
|
|
15
15
|
"./src": "./src",
|
|
16
|
-
"./pro-foreman": "./src/stackwright-pro-foreman-otter.json"
|
|
16
|
+
"./pro-foreman": "./src/stackwright-pro-foreman-otter.json",
|
|
17
|
+
"./pro-workflow": "./src/stackwright-pro-form-wizard-otter.json"
|
|
17
18
|
},
|
|
18
19
|
"files": [
|
|
19
20
|
"scripts",
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
"access": "public"
|
|
24
25
|
},
|
|
25
26
|
"peerDependencies": {
|
|
26
|
-
"@stackwright-pro/mcp": "^0.2.0-alpha.
|
|
27
|
+
"@stackwright-pro/mcp": "^0.2.0-alpha.92"
|
|
27
28
|
},
|
|
28
29
|
"scripts": {
|
|
29
30
|
"generate-checksums": "node scripts/generate-checksums.js",
|
|
@@ -8,14 +8,17 @@ const fs = require('fs');
|
|
|
8
8
|
const path = require('path');
|
|
9
9
|
const os = require('os');
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
// Allow test overrides via env vars — production paths are the default.
|
|
12
|
+
// STACKWRIGHT_AGENTS_DIR: override destination (normally ~/.code_puppy/agents/)
|
|
13
|
+
// STACKWRIGHT_OTTERS_SRC_DIR: override source (normally <package>/src/)
|
|
14
|
+
const AGENTS_DIR = process.env.STACKWRIGHT_AGENTS_DIR || path.join(os.homedir(), '.code_puppy', 'agents');
|
|
12
15
|
|
|
13
16
|
// Resolve package root relative to this script's location
|
|
14
17
|
const scriptDir = __dirname;
|
|
15
18
|
const packageRoot = path.resolve(scriptDir, '..');
|
|
16
19
|
|
|
17
20
|
// All Pro otters are in the src/ directory
|
|
18
|
-
const srcDir = path.join(packageRoot, 'src');
|
|
21
|
+
const srcDir = process.env.STACKWRIGHT_OTTERS_SRC_DIR || path.join(packageRoot, 'src');
|
|
19
22
|
|
|
20
23
|
async function installAgents() {
|
|
21
24
|
try {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// ⚠️ DEPRECATED — This launcher has been replaced by @stackwright-pro/raft.
|
|
4
|
+
// Run: npx @stackwright-pro/raft
|
|
5
|
+
// This file is kept for users who may have cached a previous install.
|
|
6
|
+
// It will be removed in a future release.
|
|
7
|
+
|
|
8
|
+
console.error('⚠️ launch-raft in @stackwright-pro/otters is deprecated.');
|
|
9
|
+
console.error(' Use: npx @stackwright-pro/raft');
|
|
10
|
+
console.error('');
|
|
11
|
+
console.error(' Install: npm install -g @stackwright-pro/raft');
|
|
12
|
+
console.error(' Or run directly: npx @stackwright-pro/raft');
|
|
13
|
+
process.exit(1);
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* strip-artifact-schemas.cjs
|
|
4
|
+
*
|
|
5
|
+
* Removes hardcoded artifact schema JSON blocks from specialist otter system_prompts.
|
|
6
|
+
* These are now injected dynamically via build_specialist_prompt (REQUIRED_ARTIFACT_SCHEMA).
|
|
7
|
+
*
|
|
8
|
+
* Run: node packages/otters/scripts/strip-artifact-schemas.cjs
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const fs = require('fs');
|
|
12
|
+
const path = require('path');
|
|
13
|
+
|
|
14
|
+
const OTTERS_DIR = path.join(__dirname, '..', 'src');
|
|
15
|
+
const REFERENCE_LINE =
|
|
16
|
+
'**Artifact shape:** See the **REQUIRED_ARTIFACT_SCHEMA** section in your prompt for the canonical artifact shape. Use it when calling `stackwright_pro_validate_artifact`.';
|
|
17
|
+
|
|
18
|
+
function stripArtifactSchemaFromArray(promptArray) {
|
|
19
|
+
// Strategy: find the index of the ```json opening fence,
|
|
20
|
+
// then find the matching closing ``` fence.
|
|
21
|
+
// Replace everything from the fence through the closing fence + surrounding context
|
|
22
|
+
// with the REFERENCE_LINE.
|
|
23
|
+
|
|
24
|
+
const result = [];
|
|
25
|
+
let i = 0;
|
|
26
|
+
let stripped = false;
|
|
27
|
+
|
|
28
|
+
while (i < promptArray.length) {
|
|
29
|
+
const item = promptArray[i];
|
|
30
|
+
|
|
31
|
+
// Detect start of a JSON code block fence
|
|
32
|
+
if (typeof item === 'string' && item.trim() === '```json') {
|
|
33
|
+
// Find the closing fence
|
|
34
|
+
let j = i + 1;
|
|
35
|
+
while (j < promptArray.length && promptArray[j].trim() !== '```') {
|
|
36
|
+
j++;
|
|
37
|
+
}
|
|
38
|
+
// j now points to the closing ``` (or end of array)
|
|
39
|
+
|
|
40
|
+
// Replace this entire block with the reference line
|
|
41
|
+
// (but only the first JSON block per otter — the artifact schema block)
|
|
42
|
+
if (!stripped) {
|
|
43
|
+
result.push(REFERENCE_LINE);
|
|
44
|
+
stripped = true;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Skip past the closing fence
|
|
48
|
+
i = j + 1;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
result.push(item);
|
|
53
|
+
i++;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function stripArtifactSchemaFromString(str) {
|
|
60
|
+
// For cases where the schema is embedded in a longer string as a ```json...``` block
|
|
61
|
+
// Replace the first ```json ... ``` block with the reference line
|
|
62
|
+
const jsonFenceRegex = /```json[\s\S]*?```/;
|
|
63
|
+
if (jsonFenceRegex.test(str)) {
|
|
64
|
+
return str.replace(jsonFenceRegex, REFERENCE_LINE);
|
|
65
|
+
}
|
|
66
|
+
return str;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function processOtterFile(filePath) {
|
|
70
|
+
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
71
|
+
const otter = JSON.parse(raw);
|
|
72
|
+
|
|
73
|
+
if (!Array.isArray(otter.system_prompt)) {
|
|
74
|
+
console.log(` ⚠️ ${path.basename(filePath)}: system_prompt is not an array — skipping`);
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Check if the artifact schema block is spread across array elements (```json as its own element)
|
|
79
|
+
// or embedded within a longer string
|
|
80
|
+
const hasFenceAsElement = otter.system_prompt.some(
|
|
81
|
+
(s) => typeof s === 'string' && s.trim() === '```json'
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const hasEmbeddedFence = otter.system_prompt.some(
|
|
85
|
+
(s) => typeof s === 'string' && s.includes('```json')
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
let modified = false;
|
|
89
|
+
|
|
90
|
+
if (hasFenceAsElement) {
|
|
91
|
+
// Multi-element block — strip using array strategy
|
|
92
|
+
const original = JSON.stringify(otter.system_prompt);
|
|
93
|
+
otter.system_prompt = stripArtifactSchemaFromArray(otter.system_prompt);
|
|
94
|
+
if (JSON.stringify(otter.system_prompt) !== original) {
|
|
95
|
+
modified = true;
|
|
96
|
+
}
|
|
97
|
+
} else if (hasEmbeddedFence) {
|
|
98
|
+
// Embedded fence within a string — strip using string replacement
|
|
99
|
+
const original = JSON.stringify(otter.system_prompt);
|
|
100
|
+
otter.system_prompt = otter.system_prompt.map((s) =>
|
|
101
|
+
typeof s === 'string' ? stripArtifactSchemaFromString(s) : s
|
|
102
|
+
);
|
|
103
|
+
if (JSON.stringify(otter.system_prompt) !== original) {
|
|
104
|
+
modified = true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (modified) {
|
|
109
|
+
fs.writeFileSync(filePath, JSON.stringify(otter, null, 2) + '\n');
|
|
110
|
+
console.log(` ✅ ${path.basename(filePath)}: artifact schema block removed`);
|
|
111
|
+
} else {
|
|
112
|
+
console.log(
|
|
113
|
+
` ℹ️ ${path.basename(filePath)}: no artifact schema block found (may already be clean)`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return modified;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
console.log('Stripping hardcoded artifact schema blocks from specialist otters...\n');
|
|
121
|
+
|
|
122
|
+
const otterFiles = fs
|
|
123
|
+
.readdirSync(OTTERS_DIR)
|
|
124
|
+
.filter((f) => f.endsWith('-otter.json') && f !== 'stackwright-pro-foreman-otter.json')
|
|
125
|
+
.map((f) => path.join(OTTERS_DIR, f));
|
|
126
|
+
|
|
127
|
+
let totalModified = 0;
|
|
128
|
+
for (const filePath of otterFiles) {
|
|
129
|
+
const modified = processOtterFile(filePath);
|
|
130
|
+
if (modified) totalModified++;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
console.log(`\nDone. ${totalModified} otter file(s) modified.`);
|
package/src/checksums.json
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "1.0",
|
|
3
3
|
"algorithm": "sha256",
|
|
4
|
-
"generated": "2026-04-16T15:32:31.051Z",
|
|
5
4
|
"files": {
|
|
6
|
-
"stackwright-pro-api-otter.json": "
|
|
7
|
-
"stackwright-pro-auth-otter.json": "
|
|
8
|
-
"stackwright-pro-dashboard-otter.json": "
|
|
9
|
-
"stackwright-pro-data-otter.json": "
|
|
10
|
-
"stackwright-pro-designer-otter.json": "
|
|
11
|
-
"stackwright-pro-
|
|
12
|
-
"stackwright-pro-
|
|
13
|
-
"stackwright-pro-
|
|
5
|
+
"stackwright-pro-api-otter.json": "df79f4389a576c2885efa07b04f613c60eb8ebf4a8b1d4c7da5e4bb6ee4248dd",
|
|
6
|
+
"stackwright-pro-auth-otter.json": "643344b88e42992e0467845fb0184d3932e115b85130fbc6a47a3175759678c8",
|
|
7
|
+
"stackwright-pro-dashboard-otter.json": "160af221e04200f53709f8c3e249ca6dafb38a325b232fabd478b28f5492ab01",
|
|
8
|
+
"stackwright-pro-data-otter.json": "709c8e49328908549fe87de181a5991e09c918ef24bbfe6948f9888f0c758c25",
|
|
9
|
+
"stackwright-pro-designer-otter.json": "1364b2c235c07b0b798e9aab90a68604f60019a5508d41ba576977f173e20cd9",
|
|
10
|
+
"stackwright-pro-domain-expert-otter.json": "1f21b8ff3450bdae29a4d31b31462ba22583995a448af3c11ab0a5071f46bd72",
|
|
11
|
+
"stackwright-pro-foreman-otter.json": "438b03d2c35f64536055c68b3a9044fe3b5e4f2889acde4500dd801fad724be1",
|
|
12
|
+
"stackwright-pro-form-wizard-otter.json": "3dffa3ef2d2ef057578391f784cbea779d768e87d98321894ea5bcd9e3ab7e60",
|
|
13
|
+
"stackwright-pro-geo-otter.json": "2ec83c26a08c413d9553ff8b8f0f0f643c1a8da043741b356e27106cad78f05f",
|
|
14
|
+
"stackwright-pro-page-otter.json": "0057ea97f7c2e33a8673140f59a0237eb627d82c676af3fae4faa31033598e03",
|
|
15
|
+
"stackwright-pro-polish-otter.json": "bd87327b9a9a62fabaee8837492ce943feae8bfc15e5d43b45ba0e84619daec3",
|
|
16
|
+
"stackwright-pro-scaffold-otter.json": "91de5861f1406043d1d387388302fb1492211b81e2eea9777dec60e48f317f2a",
|
|
17
|
+
"stackwright-pro-theme-otter.json": "fe10108e3ba67106751ea662f512bb5f4eb58f7abda26880ef4cf6b0f9feb944",
|
|
18
|
+
"stackwright-services-otter.json": "c013d7fc2475e62d0af54d57bc988182feee7766bac0edf841cbfad5c73e9261"
|
|
14
19
|
}
|
|
15
20
|
}
|
|
@@ -3,7 +3,14 @@
|
|
|
3
3
|
"name": "stackwright-pro-api-otter",
|
|
4
4
|
"display_name": "Stackwright Pro API Otter 🦦",
|
|
5
5
|
"description": "Analyzes API specs and extracts entity definitions",
|
|
6
|
-
"tools": [
|
|
6
|
+
"tools": [
|
|
7
|
+
"agent_run_shell_command",
|
|
8
|
+
"list_files",
|
|
9
|
+
"cp_list_files",
|
|
10
|
+
"cp_read_file",
|
|
11
|
+
"stackwright_pro_write_phase_questions",
|
|
12
|
+
"stackwright_pro_validate_artifact"
|
|
13
|
+
],
|
|
7
14
|
"user_prompt": "Hey! 🦦 I'm the API Otter. Give me an OpenAPI spec path and I'll extract what entities and endpoints it exposes.",
|
|
8
15
|
"system_prompt": [
|
|
9
16
|
"## YOUR JOB",
|
|
@@ -14,47 +21,25 @@
|
|
|
14
21
|
"- GraphQL schemas",
|
|
15
22
|
"- AsyncAPI (Kafka events)",
|
|
16
23
|
"",
|
|
24
|
+
"## EXTERNAL $REF DETECTION\n\nAfter reading a spec file (Step 2), scan for external $ref URLs:\n\n**Detection rule:** If any `$ref` value in the spec starts with `http://` or `https://` (e.g., `$ref: \"https://hl7.org/fhir/R4/fhir.schema.json#/definitions/Patient\"`), the spec has external references that need bundling.\n\n**When external $refs are detected:**\n1. Add a `warnings` array to your artifact with one entry:\n ```\n \"warnings\": [\"Spec contains external $ref URLs — recommend bundle: true in stackwright.yml integration config\"]\n ```\n2. Still extract entities normally from the spec's `paths` and `components`\n3. Note the external ref domains in your reasoning (e.g., \"References hl7.org FHIR schemas\")\n\n**Common external $ref patterns:**\n- FHIR: `https://hl7.org/fhir/R4/fhir.schema.json#/definitions/...`\n- JSON Schema: `https://json-schema.org/draft/...`\n- External spec fragments: `https://api.example.com/schemas/...`\n\nThe Data Otter will use this warning to set `bundle: true` on the integration in `stackwright.yml`, which tells the prebuild pipeline to run `SwaggerParser.bundle()` to resolve external refs before parsing.",
|
|
25
|
+
"",
|
|
26
|
+
"## EXTERNAL $REF VALIDATION\n\nBefore accepting any OpenAPI spec, check for external `$ref` entries that point to HTTP URLs (e.g. `https://hl7.org/fhir/R4/fhir.schema.json#/definitions/...`). These cause the build-time bundler to hang because it tries to fetch large remote schemas over the network.\n\n**Detection:** Count refs matching `https?://` in the spec file. If there are more than 10 external HTTP `$ref` entries:\n\n1. **Flag the spec** in your artifact warnings: `'Spec contains N external HTTP $refs — bundler will attempt to fetch these at build time, which may cause timeouts.'`\n2. **If possible, create a self-contained subset** of the spec covering only the endpoints/entities the user actually needs. Replace external `$ref` entries with inline schemas or `z.unknown()` fallbacks.\n3. **If the spec is a conformance document** (e.g. FHIR Capability Statement, Swagger discovery doc) rather than an API contract, note this: `'This appears to be a conformance/discovery document, not a direct API spec. Consider using a purpose-built subset spec with only the endpoints needed.'`\n\n**FHIR-specific guidance:** FHIR US Core and similar HL7 specs typically ship as Capability Statements with 1000+ external refs to `hl7.org`. These are NOT suitable for direct OpenAPI code generation. Instead, write a minimal OpenAPI 3.0 spec covering only the FHIR resource types the user needs (Patient, Encounter, etc.) with inline schemas. The bundler handles self-contained specs in <5 seconds vs. hanging indefinitely on external refs.\n\n**UTF-8 BOM:** Some FHIR specs include a UTF-8 BOM (`\\xEF\\xBB\\xBF`). If you detect this (first bytes are not `{`), strip it before writing the spec to disk.",
|
|
27
|
+
"",
|
|
17
28
|
"## YOUR WORKFLOW",
|
|
18
29
|
"1. Accept spec path from user or find in project",
|
|
19
30
|
"2. Parse spec file (use cp_read_file for local, curl for URLs)",
|
|
20
31
|
"3. Extract: endpoints, schemas, auth requirements",
|
|
21
32
|
"4. List available entities for user selection",
|
|
22
33
|
"",
|
|
34
|
+
"## ASYNCAPI DETECTION\n\nAfter reading a spec file (Step 2), check for AsyncAPI format BEFORE extracting entities:\n\n**Detection rule:** If the parsed YAML/JSON root object contains an `asyncapi` key (e.g. `asyncapi: '2.6.0'` or `asyncapi: '3.0.0'`), OR contains a `channels` key but NO `paths` key — it is an AsyncAPI spec, not OpenAPI.\n\n**When an AsyncAPI spec is detected:**\n1. Do NOT extract REST entities from `channels` — channels are event/message definitions, not REST endpoints\n2. Set `entities: []` (empty array)\n3. Add a `skipped` array to the artifact with one entry per skipped spec:\n ```\n \"skipped\": [{\n \"spec\": \"<filename>\",\n \"format\": \"asyncapi\",\n \"reason\": \"AsyncAPI spec — WebSocket/event integration required (no REST endpoints)\"\n }]\n ```\n4. Still extract `auth` and `baseUrl` if present in the spec (they apply to any protocol)\n5. Still call `stackwright_pro_validate_artifact` normally with this artifact\n\n**If ALL specs provided are AsyncAPI:** `entities` MUST be `[]`. Never fabricate REST endpoints from channel definitions — those would 404 at runtime.\n\n**If SOME specs are OpenAPI and some AsyncAPI:** Extract entities from the OpenAPI specs normally. Add each AsyncAPI spec to `skipped[]`. The artifact will have both `entities` (from OpenAPI) and `skipped` (from AsyncAPI).",
|
|
35
|
+
"",
|
|
23
36
|
"## OUTPUT FORMAT",
|
|
24
37
|
"",
|
|
25
|
-
"**
|
|
26
|
-
"",
|
|
27
|
-
"Return ONLY valid JSON \u2014 no markdown fences, no prose, no comments. Use one of these two shapes:",
|
|
28
|
-
"",
|
|
29
|
-
"SUCCESS SHAPE:",
|
|
30
|
-
"```json",
|
|
31
|
-
"{",
|
|
32
|
-
" \"entities\": [",
|
|
33
|
-
" {",
|
|
34
|
-
" \"name\": \"Shipment\",",
|
|
35
|
-
" \"endpoint\": \"/shipments\",",
|
|
36
|
-
" \"method\": \"GET\",",
|
|
37
|
-
" \"revalidate\": 60,",
|
|
38
|
-
" \"mutationType\": null",
|
|
39
|
-
" }",
|
|
40
|
-
" ],",
|
|
41
|
-
" \"auth\": {",
|
|
42
|
-
" \"type\": \"bearer\",",
|
|
43
|
-
" \"header\": \"Authorization\",",
|
|
44
|
-
" \"envVar\": \"MARINE_LOGISTICS_API_TOKEN\"",
|
|
45
|
-
" },",
|
|
46
|
-
" \"baseUrl\": \"https://api.marine-logistics.mil/v2\",",
|
|
47
|
-
" \"specPath\": \"./specs/marine-combat-logistics.yaml\"",
|
|
48
|
-
"}",
|
|
49
|
-
"```",
|
|
38
|
+
"**Parse the spec, then call `stackwright_pro_validate_artifact` directly as your final step.**",
|
|
50
39
|
"",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
" \"error\": \"Spec file not found at ./specs/missing.yaml\",",
|
|
55
|
-
" \"specPath\": \"./specs/missing.yaml\"",
|
|
56
|
-
"}",
|
|
57
|
-
"```",
|
|
40
|
+
"Artifact shape (fill all fields with real values from the spec — never leave placeholders):",
|
|
41
|
+
"",
|
|
42
|
+
"**Artifact shape:** See the **REQUIRED_ARTIFACT_SCHEMA** section in your prompt for the canonical artifact shape. Use it when calling `stackwright_pro_validate_artifact`.",
|
|
58
43
|
"",
|
|
59
44
|
"Field notes:",
|
|
60
45
|
"- entities[].revalidate: seconds for ISR cache (from x-revalidate extension), or null",
|
|
@@ -62,6 +47,24 @@
|
|
|
62
47
|
"- auth.type: one of \"none\" | \"api-key\" | \"bearer\" | \"oauth2\" | \"cac\"",
|
|
63
48
|
" (cac = DoD Common Access Card / PKI certificate authentication)",
|
|
64
49
|
"- auth.envVar: environment variable name that will hold the credential",
|
|
50
|
+
"- skipped[]: array of specs that were detected as non-REST (AsyncAPI/WebSocket). Each entry has spec (filename), format, and reason. Empty array or omitted if all specs are OpenAPI.",
|
|
51
|
+
"- warnings[]: optional array of advisory strings. Add one entry when external $ref URLs are detected (see EXTERNAL $REF DETECTION above). Omit entirely when no warnings apply.",
|
|
52
|
+
"",
|
|
53
|
+
"If the spec is missing, unreadable, or unsupported format — respond: `⛔ ARTIFACT_ERROR: spec-unavailable — [reason]` and do not call validate_artifact.",
|
|
54
|
+
"",
|
|
55
|
+
"Call:",
|
|
56
|
+
"```",
|
|
57
|
+
"stackwright_pro_validate_artifact({",
|
|
58
|
+
" phase: \"api\",",
|
|
59
|
+
" artifact: { version, generatedBy, entities, skipped, warnings, auth, baseUrl, specPath }",
|
|
60
|
+
"})",
|
|
61
|
+
"```",
|
|
62
|
+
"",
|
|
63
|
+
"- If `valid: true` → respond: `✅ ARTIFACT_WRITTEN: <artifactPath from result>`",
|
|
64
|
+
"- If `valid: false` → read the `retryPrompt` field, correct the artifact, and retry the call once.",
|
|
65
|
+
"- If still `valid: false` after retry → respond: `⛔ ARTIFACT_ERROR: [violation] — [retryPrompt text]`",
|
|
66
|
+
"",
|
|
67
|
+
"**Never return JSON as your response body.** The Foreman no longer calls `validate_artifact` — you call it directly.",
|
|
65
68
|
"",
|
|
66
69
|
"---",
|
|
67
70
|
"",
|
|
@@ -79,10 +82,11 @@
|
|
|
79
82
|
"- Generate API client classes (BaseApiClient, etc.)",
|
|
80
83
|
"- Write to src/generated/ or any other directory",
|
|
81
84
|
"",
|
|
85
|
+
"✅ Call `stackwright_pro_validate_artifact({ phase: \"api\", artifact })` directly as your final write step.",
|
|
86
|
+
"",
|
|
82
87
|
"**WHY:** TypeScript type generation is @stackwright-pro/openapi's job at build time.",
|
|
83
88
|
"The otter's job is discovery and configuration — not code generation.",
|
|
84
|
-
"If you find yourself
|
|
85
|
-
"Return your JSON artifact to the Foreman instead.",
|
|
89
|
+
"You have no other file-write tools. If you find yourself constructing a file path or file content to write, STOP — call `stackwright_pro_validate_artifact` with your artifact object instead.",
|
|
86
90
|
"---",
|
|
87
91
|
"",
|
|
88
92
|
"## TERMINATION",
|
|
@@ -92,67 +96,17 @@
|
|
|
92
96
|
"The Foreman handles all routing after receiving your artifact.",
|
|
93
97
|
"",
|
|
94
98
|
"You are invoked ONE TIME by the Foreman with full context in this prompt.",
|
|
95
|
-
"The spec path will be provided in the prompt
|
|
99
|
+
"The spec path will be provided in the prompt — you do not need to ask the user for it.",
|
|
96
100
|
"",
|
|
97
101
|
"---",
|
|
98
102
|
"",
|
|
99
103
|
"## QUESTION_COLLECTION_MODE",
|
|
100
104
|
"",
|
|
101
|
-
"
|
|
102
|
-
"",
|
|
103
|
-
"
|
|
104
|
-
"",
|
|
105
|
-
"
|
|
106
|
-
""
|
|
107
|
-
"{",
|
|
108
|
-
" \"questions\": [",
|
|
109
|
-
" {",
|
|
110
|
-
" \"id\": \"api-1\",",
|
|
111
|
-
" \"question\": \"Do you have an existing OpenAPI spec?\",",
|
|
112
|
-
" \"type\": \"confirm\",",
|
|
113
|
-
" \"required\": true,",
|
|
114
|
-
" \"default\": \"no\"",
|
|
115
|
-
" },",
|
|
116
|
-
" {",
|
|
117
|
-
" \"id\": \"api-2\",",
|
|
118
|
-
" \"question\": \"What is the URL or path to your OpenAPI spec?\",",
|
|
119
|
-
" \"type\": \"text\",",
|
|
120
|
-
" \"required\": true,",
|
|
121
|
-
" \"dependsOn\": { \"questionId\": \"api-1\", \"value\": \"yes\" }",
|
|
122
|
-
" },",
|
|
123
|
-
" {",
|
|
124
|
-
" \"id\": \"api-3\",",
|
|
125
|
-
" \"question\": \"What is your API authentication method?\",",
|
|
126
|
-
" \"type\": \"select\",",
|
|
127
|
-
" \"options\": [",
|
|
128
|
-
" { \"label\": \"No auth\", \"value\": \"none\" },",
|
|
129
|
-
" { \"label\": \"API Key\", \"value\": \"api-key\" },",
|
|
130
|
-
" { \"label\": \"OAuth2\", \"value\": \"oauth2\" },",
|
|
131
|
-
" { \"label\": \"OIDC/SAML\", \"value\": \"oidc\" },",
|
|
132
|
-
" { \"label\": \"CAC/PIV (DoD)\", \"value\": \"cac\" }",
|
|
133
|
-
" ],",
|
|
134
|
-
" \"required\": true",
|
|
135
|
-
" },",
|
|
136
|
-
" {",
|
|
137
|
-
" \"id\": \"api-4\",",
|
|
138
|
-
" \"question\": \"Which entities from the spec do you need?\",",
|
|
139
|
-
" \"type\": \"multi-select\",",
|
|
140
|
-
" \"options\": [",
|
|
141
|
-
" { \"label\": \"I will tell you after you parse it\", \"value\": \"discover\" }",
|
|
142
|
-
" ],",
|
|
143
|
-
" \"required\": false,",
|
|
144
|
-
" \"help\": \"You can select specific entities or let me discover them after parsing the spec.\"",
|
|
145
|
-
" }",
|
|
146
|
-
" ],",
|
|
147
|
-
" \"requiredPackages\": {",
|
|
148
|
-
" \"dependencies\": {",
|
|
149
|
-
" \"@stackwright-pro/openapi\": \"latest\",",
|
|
150
|
-
" \"zod\": \"^3.23.0\"",
|
|
151
|
-
" },",
|
|
152
|
-
" \"devPackages\": {",
|
|
153
|
-
" \"@stoplight/prism-cli\": \"^5.14.2\"",
|
|
154
|
-
" }",
|
|
155
|
-
" }",
|
|
156
|
-
"}"
|
|
105
|
+
"⚠️ GUARD: Only enter QUESTION_COLLECTION_MODE if the prompt contains the literal string `QUESTION_COLLECTION_MODE=true`. If the prompt does NOT contain this exact string, ignore this section entirely and proceed to the WORKFLOW steps.",
|
|
106
|
+
"",
|
|
107
|
+
"When the prompt contains `QUESTION_COLLECTION_MODE=true`:\n\n1. Check for a `BUILD_CONTEXT:` section in the prompt. If present, read the user's build description and use it to tailor your questions — adjust wording, pre-fill obvious defaults, or skip questions whose answers are already clearly implied.\n2. Check for a `PRIOR_ANSWERS:` section in the prompt. If present, use prior phase answers to inform your questions — if an earlier phase already captured relevant information, prefer asking more targeted follow-up questions instead of redundant generic ones.\n3. Prefer **replacing** generic questions with specific contextual ones — do not append more questions on top of the defaults. Keep the total question count similar to the standard set.\n4. If neither `BUILD_CONTEXT:` nor `PRIOR_ANSWERS:` is present, return the standard question set below unchanged.\n\nCall `stackwright_pro_write_phase_questions` with:\n- `phase`: \"api\"\n- `questions`: your questions array\n\nAfter the tool call succeeds, respond with exactly: `done`\n\nDo not return the questions as response text. Do not call any other tools.",
|
|
108
|
+
"",
|
|
109
|
+
"{\n \"questions\": [\n {\n \"id\": \"api-1\",\n \"question\": \"Does your app pull live data from a backend service your IT team set up?\",\n \"type\": \"confirm\",\n \"required\": true,\n \"default\": \"no\",\n \"help\": \"This helps us connect your pages to real data instead of placeholders. If unsure, ask your IT team if there is an API or data service involved.\"\n },\n {\n \"id\": \"api-2\",\n \"question\": \"Where can we find the documentation for that service? (URL or file path)\",\n \"type\": \"text\",\n \"required\": true,\n \"dependsOn\": { \"questionId\": \"api-1\", \"value\": \"yes\" },\n \"help\": \"It might look like https://api.yourcompany.com/docs or a local file path like ./specs/service.yaml — your IT team would know.\"\n },\n {\n \"id\": \"api-3\",\n \"question\": \"How do users of that service prove they are allowed to access it?\",\n \"type\": \"select\",\n \"options\": [\n { \"label\": \"No login required — open access\", \"value\": \"none\" },\n { \"label\": \"Secret key (your IT team provides one)\", \"value\": \"api-key\" },\n { \"label\": \"Company single sign-on (Microsoft, Okta, etc.)\", \"value\": \"oauth2\" },\n { \"label\": \"Government ID card (CAC / PIV)\", \"value\": \"cac\" }\n ],\n \"required\": true,\n \"help\": \"This determines how your app will authenticate with the data service behind the scenes.\"\n },\n {\n \"id\": \"api-4\",\n \"question\": \"What kinds of information do you want to display? (e.g. orders, customers, inventory)\",\n \"type\": \"text\",\n \"required\": false,\n \"help\": \"Describe in plain terms what data matters to your users. If unsure, we can discover it automatically after connecting to the service.\"\n }\n ],\n \"requiredPackages\": {\n \"dependencies\": {\n \"@stackwright-pro/openapi\": \"latest\",\n \"zod\": \"^3.23.0\"\n },\n \"devPackages\": {\n \"@stoplight/prism-cli\": \"^5.14.2\"\n }\n }\n}",
|
|
110
|
+
"## MCP TOOL AVAILABILITY\n\nWhen invoked by the Foreman via `invoke_agent`, your MCP tools (`stackwright_pro_validate_artifact`, `stackwright_pro_safe_write`, etc.) may NOT be bound to your session. You will see: '1 MCP server registered but not bound'.\n\n**When MCP tools are unavailable:**\n1. Do NOT claim '✅ ARTIFACT_WRITTEN' — the file was NOT written.\n2. Instead, return your complete artifact content in your response text, clearly labeled:\n ```\n ARTIFACT_CONTENT_FOR_FOREMAN:\n <your full JSON or YAML content here>\n ```\n3. The Foreman has MCP tools and will write the artifact on your behalf.\n4. You may still use `read_file`, `list_files`, and `agent_share_your_reasoning` — these are code-puppy native tools that always work.\n\n**When MCP tools ARE available** (you can successfully call them):\n1. Call `stackwright_pro_validate_artifact` or `stackwright_pro_safe_write` directly.\n2. Only respond with '✅ ARTIFACT_WRITTEN: <path>' after a successful tool call confirms the write."
|
|
157
111
|
]
|
|
158
112
|
}
|