Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/refactor-381-template-redundancy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"create-expert": patch
---

Reduce template redundancy in ecosystem-builder

74 changes: 25 additions & 49 deletions apps/create-expert/src/lib/create-expert-toml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ When external dependencies exist (API keys, services, environment variables):
- **Setup Expert**: Guides users through configuration
- **Doctor Expert**: Diagnoses configuration issues

## Error Format (all ecosystem experts)

All errors must follow this format:
\`\`\`
❌ [Type]: [description] | To fix: [actionable steps]
\`\`\`

Where [Type] is: Error, Failed, or Issue depending on context.
Never fail silently - always explain what happened and how to resolve it.

## Expert Templates

### Main Expert Template
Expand All @@ -129,10 +139,7 @@ description = "Brief description of main functionality"
instruction = '''
Your role and capabilities...

## Error Handling
When errors occur, provide actionable guidance:
- "❌ Error: [what went wrong] | To fix: [specific steps]"
- Never fail silently - always explain what happened and how to resolve it
[Include domain knowledge, policies, and expected behavior]
'''

[experts."<name>".skills."@perstack/base"]
Expand All @@ -150,33 +157,13 @@ description = "Interactive demo with sample data - no setup required"
instruction = '''
You demonstrate the capabilities of <name> using built-in sample data.

## Your Role
Show users what the expert can do WITHOUT requiring any setup or API keys.

## Demo Mode
- Use the embedded sample data below (do NOT make API calls)
- Demonstrate key features with realistic examples
- Use embedded sample data (do NOT make API calls)
- Show expected output format
- Explain what would happen with real configuration
- Explain what real configuration would enable

## Embedded Sample Data
IMPORTANT: Include actual sample data here, not placeholders.
Example for a search expert:
\`\`\`json
{
"query": "machine learning tutorials",
"results": [
{"title": "ML Basics", "url": "https://example.com/ml", "snippet": "Learn the fundamentals..."},
{"title": "Deep Learning Guide", "url": "https://example.com/dl", "snippet": "Advanced neural networks..."}
]
}
\`\`\`

## Output
Provide a realistic demonstration that helps users understand:
1. What this expert does
2. What kind of input it expects
3. What output they will get
[Include actual sample data - not placeholders]
'''

[experts."<name>-demo".skills."@perstack/base"]
Expand All @@ -194,26 +181,19 @@ description = "Automated setup wizard for <name>"
instruction = '''
You guide users through setting up <name>.

## Your Role
Help users configure required dependencies quickly and correctly.

## Configuration Policies
- Check .env file and environment variables first
- Check .env file and environment first
- For missing items: explain purpose, provide signup URL, validate format
- Save configuration to .env file
- Verify with a simple test before confirming success
- Target: Complete setup in under 2 minutes
- Save to .env file and verify before confirming

## Success Output
"✓ Setup complete! Try: npx perstack run <name> \\"your query\\""

## Error Handling
When setup fails, guide the user:
- "❌ Failed: [what went wrong] | To fix: [specific steps]"
- Suggest running the doctor expert for diagnostics
## On Failure
Suggest running <name>-doctor for diagnostics.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setup template removes error format guidance entirely

The setup expert template's "On Failure" section now only instructs to suggest running the doctor expert, but completely omits guidance on how to format the error message itself. The original template explicitly included "❌ Failed: [what went wrong] | To fix: [specific steps]" before suggesting the doctor. Unlike the doctor template which at least references "standard error format", this template has no error formatting instruction at all, meaning created setup experts may not report failures in the expected format.

Fix in Cursor Fix in Web


## Required Dependencies
[List the specific dependencies this expert needs]
[List specific dependencies]
'''

[experts."<name>-setup".skills."@perstack/base"]
Expand All @@ -231,16 +211,13 @@ description = "Diagnose and fix issues with <name>"
instruction = '''
You diagnose and help fix issues with <name>.

## Your Role
Run diagnostics and provide actionable fixes for common problems.

## Diagnostic Areas
- Environment: Verify variables exist and are properly formatted
- Connectivity: Test network access to required services
- Configuration: Run test query and analyze errors
- Environment: Verify variables exist and format
- Connectivity: Test network access
- Configuration: Run test query and analyze

## Output Format
For issues: "❌ Issue: [problem] | To fix: [steps]"
## Output
For issues: Use standard error format
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doctor template references undefined "standard error format"

The doctor expert template instruction says "Use standard error format" but this references a definition (lines 122-130) that only exists in the ecosystem-builder's meta-instructions. When an actual <name>-doctor expert is created from this template, its instruction won't include what "standard error format" means since that definition is outside the template's instruction = '''...''' block. The original code explicitly included the format inline: "❌ Issue: [problem] | To fix: [steps]".

Fix in Cursor Fix in Web

If healthy: "✓ All checks passed! <name> is ready to use."
'''

Expand All @@ -257,8 +234,7 @@ pick = ["readTextFile", "exec", "attemptCompletion"]
3. Use @perstack/base for file/shell operations
4. ALWAYS use pick for minimal privilege
5. Demo expert must work WITHOUT any setup
6. Setup expert should complete in < 2 minutes
7. All errors must include "To fix: ..." guidance
6. All errors must follow the standard error format above
`

const FUNCTIONAL_MANAGER_INSTRUCTION = `You verify functional quality through three test categories.
Expand Down