@wundam/orchex 1.0.0-rc.2 → 1.0.0-rc.21
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/README.md +59 -18
- package/dist/cloud-executor.d.ts +71 -0
- package/dist/cloud-executor.js +335 -0
- package/dist/cloud-sync.d.ts +8 -0
- package/dist/cloud-sync.js +52 -0
- package/dist/config.d.ts +30 -4
- package/dist/config.js +61 -2
- package/dist/context-builder.d.ts +2 -0
- package/dist/context-builder.js +11 -3
- package/dist/cost.js +1 -1
- package/dist/entitlements/jwt.d.ts +7 -0
- package/dist/entitlements/jwt.js +78 -0
- package/dist/entitlements/resolve.d.ts +17 -0
- package/dist/entitlements/resolve.js +49 -0
- package/dist/entitlements/types.d.ts +21 -0
- package/dist/entitlements/types.js +4 -0
- package/dist/executors/base.d.ts +1 -1
- package/dist/executors/bedrock-executor.d.ts +39 -0
- package/dist/executors/bedrock-executor.js +197 -0
- package/dist/executors/index.d.ts +1 -0
- package/dist/executors/index.js +24 -1
- package/dist/index.js +468 -23
- package/dist/intelligence/index.d.ts +44 -0
- package/dist/intelligence/index.js +160 -0
- package/dist/key-cache.d.ts +31 -0
- package/dist/key-cache.js +84 -0
- package/dist/login-helpers.d.ts +25 -0
- package/dist/login-helpers.js +54 -0
- package/dist/manifest.js +18 -1
- package/dist/mcp-instructions.d.ts +1 -0
- package/dist/mcp-instructions.js +84 -0
- package/dist/mcp-resources.d.ts +8 -0
- package/dist/mcp-resources.js +420 -0
- package/dist/model-cache.d.ts +18 -0
- package/dist/model-cache.js +62 -0
- package/dist/model-validator.d.ts +20 -0
- package/dist/model-validator.js +125 -0
- package/dist/orchestrator.d.ts +14 -0
- package/dist/orchestrator.js +191 -32
- package/dist/setup/ide-registry.d.ts +13 -0
- package/dist/setup/ide-registry.js +51 -0
- package/dist/setup/index.d.ts +1 -0
- package/dist/setup/index.js +111 -0
- package/dist/tier-gating.js +0 -16
- package/dist/tiers.d.ts +35 -5
- package/dist/tiers.js +39 -3
- package/dist/tools.d.ts +6 -1
- package/dist/tools.js +852 -95
- package/dist/types.d.ts +71 -60
- package/dist/types.js +3 -0
- package/dist/waves.d.ts +1 -1
- package/dist/waves.js +29 -2
- package/package.json +41 -5
- package/src/entitlements/public-key.pem +9 -0
- package/dist/intelligence/anti-pattern-detector.d.ts +0 -117
- package/dist/intelligence/anti-pattern-detector.js +0 -327
- package/dist/intelligence/budget-enforcer.d.ts +0 -119
- package/dist/intelligence/budget-enforcer.js +0 -226
- package/dist/intelligence/context-optimizer.d.ts +0 -111
- package/dist/intelligence/context-optimizer.js +0 -282
- package/dist/intelligence/cost-tracker.d.ts +0 -114
- package/dist/intelligence/cost-tracker.js +0 -183
- package/dist/intelligence/deliverable-extractor.d.ts +0 -134
- package/dist/intelligence/deliverable-extractor.js +0 -909
- package/dist/intelligence/dependency-inferrer.d.ts +0 -87
- package/dist/intelligence/dependency-inferrer.js +0 -403
- package/dist/intelligence/diagnostics.d.ts +0 -33
- package/dist/intelligence/diagnostics.js +0 -64
- package/dist/intelligence/error-analyzer.d.ts +0 -7
- package/dist/intelligence/error-analyzer.js +0 -76
- package/dist/intelligence/file-chunker.d.ts +0 -15
- package/dist/intelligence/file-chunker.js +0 -64
- package/dist/intelligence/fix-stream-manager.d.ts +0 -59
- package/dist/intelligence/fix-stream-manager.js +0 -212
- package/dist/intelligence/heuristics.d.ts +0 -23
- package/dist/intelligence/heuristics.js +0 -124
- package/dist/intelligence/learning-engine.d.ts +0 -157
- package/dist/intelligence/learning-engine.js +0 -433
- package/dist/intelligence/learning-feedback.d.ts +0 -96
- package/dist/intelligence/learning-feedback.js +0 -202
- package/dist/intelligence/pattern-analyzer.d.ts +0 -35
- package/dist/intelligence/pattern-analyzer.js +0 -189
- package/dist/intelligence/plan-parser.d.ts +0 -124
- package/dist/intelligence/plan-parser.js +0 -498
- package/dist/intelligence/planner.d.ts +0 -29
- package/dist/intelligence/planner.js +0 -86
- package/dist/intelligence/self-healer.d.ts +0 -16
- package/dist/intelligence/self-healer.js +0 -84
- package/dist/intelligence/slicing-metrics.d.ts +0 -62
- package/dist/intelligence/slicing-metrics.js +0 -202
- package/dist/intelligence/slicing-templates.d.ts +0 -81
- package/dist/intelligence/slicing-templates.js +0 -420
- package/dist/intelligence/split-suggester.d.ts +0 -69
- package/dist/intelligence/split-suggester.js +0 -176
- package/dist/intelligence/stream-generator.d.ts +0 -90
- package/dist/intelligence/stream-generator.js +0 -452
- package/dist/telemetry/telemetry-types.d.ts +0 -85
- package/dist/telemetry/telemetry-types.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ORCHEX_INSTRUCTIONS = "Orchex is a multi-LLM orchestration tool that coordinates parallel AI agents to implement features across multiple files with zero merge conflicts.\n\n## Core Concepts\n\n\u2022 **Streams**: File ownership units \u2014 each stream owns 1-3 files exclusively\n\u2022 **Waves**: Parallel execution groups \u2014 streams in same wave run simultaneously \n\u2022 **Ownership**: Strict isolation \u2014 no two streams can modify the same file\n\u2022 **Self-Healing**: Auto-recovery from failures (max 3 attempts per stream)\n\u2022 **Learning**: System improves with every run, adapting to your codebase\n\u2022 **Model Registry**: Dynamic model discovery \u2014 available models auto-updated from providers daily\n\n## How to Start\n\nAlways use `auto`. It handles everything:\n- Short intent: \"Add user auth with JWT\"\n- Full PRD or spec document: paste the content as the intent\n- Bug report: \"Fix the login timeout on mobile\"\n- Refactoring request: \"Extract payment logic into service layer\"\n\nDo NOT use `learn` directly \u2014 it expects a structured implementation plan with code deliverables, not a PRD or spec.\nDo NOT parse user documents into sections yourself \u2014 `auto` does this automatically.\n\n## Available Tools\n\n### Getting Started:\n\u2022 `auto` \u2014 **Start here.** Takes any input (intent, PRD, spec, bug report) \u2192 generates implementation plan \u2192 previews \u2192 executes.\n\u2022 `init-plan` \u2014 Generate plan template for manual editing (advanced \u2014 use `auto` for most cases)\n\u2022 `init` + `add_stream` \u2014 Manual stream-by-stream control (advanced)\n\n### During Execution:\n\u2022 `status` \u2014 Check current state and progress\n\u2022 `execute` \u2014 Run all pending streams\n\u2022 `recover` \u2014 Auto-heal failed streams\n\u2022 `rollback-stream` \u2014 Undo changes from a specific stream\n\u2022 `reload` \u2014 Refresh state from disk\n\n### After Execution:\n\u2022 `complete` \u2014 Mark orchestration as done and cleanup\n\u2022 `reset-learning` \u2014 Clear learned patterns\n\n### Internal (rarely called directly):\n\u2022 `learn` \u2014 Parse a structured implementation plan into stream definitions. Prefer `auto`.\n\n## Error Recovery\n\nIf execute fails, call status to check stream states, then recover to self-heal failed streams automatically.\n\n## Available Resources\n\n\u2022 orchex://quickstart \u2014 Getting started guide and setup\n\u2022 orchex://concepts/streams \u2014 Stream ownership model\n\u2022 orchex://concepts/waves \u2014 Parallel execution system\n\u2022 orchex://concepts/ownership \u2014 File isolation rules\n\u2022 orchex://concepts/self-healing \u2014 Auto-recovery mechanics\n\u2022 orchex://concepts/providers \u2014 LLM provider configuration\n\u2022 orchex://examples \u2014 Real-world orchestration examples\n\u2022 orchex://api-reference \u2014 Stream definition schema\n\n## API Keys\n\nANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, DEEPSEEK_API_KEY, AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY (for Bedrock)\n\n## Supported Providers\n\nClaude (Anthropic), OpenAI, Gemini, DeepSeek, Ollama (local), AWS Bedrock \u2014 models auto-discovered via registry\n\n**Note:** Cloud mode (`mode: \"cloud\"`) currently uses Anthropic as the execution provider. All 6 providers are available in local mode.\n\n## Cloud Trial\n\nGet 10 free cloud runs (no expiry, no credit card required) \u2014 run `npx @wundam/orchex login`\n\n## Tiers\n\n\u2022 **Free**: 5 streams, 2 waves, all 6 providers (BYOK)\n\u2022 **Pro** ($19/mo): 15 streams, 10 waves\n\u2022 **Team** ($49/user/mo): 25 streams, 25 waves";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export const ORCHEX_INSTRUCTIONS = `\
|
|
2
|
+
Orchex is a multi-LLM orchestration tool that coordinates parallel AI agents to \
|
|
3
|
+
implement features across multiple files with zero merge conflicts.
|
|
4
|
+
|
|
5
|
+
## Core Concepts
|
|
6
|
+
|
|
7
|
+
• **Streams**: File ownership units — each stream owns 1-3 files exclusively
|
|
8
|
+
• **Waves**: Parallel execution groups — streams in same wave run simultaneously
|
|
9
|
+
• **Ownership**: Strict isolation — no two streams can modify the same file
|
|
10
|
+
• **Self-Healing**: Auto-recovery from failures (max 3 attempts per stream)
|
|
11
|
+
• **Learning**: System improves with every run, adapting to your codebase
|
|
12
|
+
• **Model Registry**: Dynamic model discovery — available models auto-updated from providers daily
|
|
13
|
+
|
|
14
|
+
## How to Start
|
|
15
|
+
|
|
16
|
+
Always use \`auto\`. It handles everything:
|
|
17
|
+
- Short intent: "Add user auth with JWT"
|
|
18
|
+
- Full PRD or spec document: paste the content as the intent
|
|
19
|
+
- Bug report: "Fix the login timeout on mobile"
|
|
20
|
+
- Refactoring request: "Extract payment logic into service layer"
|
|
21
|
+
|
|
22
|
+
Do NOT use \`learn\` directly — it expects a structured implementation plan with code deliverables, not a PRD or spec.
|
|
23
|
+
Do NOT parse user documents into sections yourself — \`auto\` does this automatically.
|
|
24
|
+
|
|
25
|
+
## Available Tools
|
|
26
|
+
|
|
27
|
+
### Getting Started:
|
|
28
|
+
• \`auto\` — **Start here.** Takes any input (intent, PRD, spec, bug report) → generates implementation plan → previews → executes.
|
|
29
|
+
• \`init-plan\` — Generate plan template for manual editing (advanced — use \`auto\` for most cases)
|
|
30
|
+
• \`init\` + \`add_stream\` — Manual stream-by-stream control (advanced)
|
|
31
|
+
|
|
32
|
+
### During Execution:
|
|
33
|
+
• \`status\` — Check current state and progress
|
|
34
|
+
• \`execute\` — Run all pending streams
|
|
35
|
+
• \`recover\` — Auto-heal failed streams
|
|
36
|
+
• \`rollback-stream\` — Undo changes from a specific stream
|
|
37
|
+
• \`reload\` — Refresh state from disk
|
|
38
|
+
|
|
39
|
+
### After Execution:
|
|
40
|
+
• \`complete\` — Mark orchestration as done and cleanup
|
|
41
|
+
• \`reset-learning\` — Clear learned patterns
|
|
42
|
+
|
|
43
|
+
### Internal (rarely called directly):
|
|
44
|
+
• \`learn\` — Parse a structured implementation plan into stream definitions. Prefer \`auto\`.
|
|
45
|
+
|
|
46
|
+
## Error Recovery
|
|
47
|
+
|
|
48
|
+
If execute fails, call status to check stream states, then recover to self-heal \
|
|
49
|
+
failed streams automatically.
|
|
50
|
+
|
|
51
|
+
## Available Resources
|
|
52
|
+
|
|
53
|
+
• orchex://quickstart — Getting started guide and setup
|
|
54
|
+
• orchex://concepts/streams — Stream ownership model
|
|
55
|
+
• orchex://concepts/waves — Parallel execution system
|
|
56
|
+
• orchex://concepts/ownership — File isolation rules
|
|
57
|
+
• orchex://concepts/self-healing — Auto-recovery mechanics
|
|
58
|
+
• orchex://concepts/providers — LLM provider configuration
|
|
59
|
+
• orchex://examples — Real-world orchestration examples
|
|
60
|
+
• orchex://api-reference — Stream definition schema
|
|
61
|
+
|
|
62
|
+
## API Keys
|
|
63
|
+
|
|
64
|
+
ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, DEEPSEEK_API_KEY, \
|
|
65
|
+
AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY (for Bedrock)
|
|
66
|
+
|
|
67
|
+
## Supported Providers
|
|
68
|
+
|
|
69
|
+
Claude (Anthropic), OpenAI, Gemini, DeepSeek, Ollama (local), AWS Bedrock — models auto-discovered via registry
|
|
70
|
+
|
|
71
|
+
**Note:** Cloud mode (\`mode: "cloud"\`) currently uses Anthropic as the execution \
|
|
72
|
+
provider. All 6 providers are available in local mode.
|
|
73
|
+
|
|
74
|
+
## Cloud Trial
|
|
75
|
+
|
|
76
|
+
Get 10 free cloud runs (no expiry, no credit card required) — run \
|
|
77
|
+
\`npx @wundam/orchex login\`
|
|
78
|
+
|
|
79
|
+
## Tiers
|
|
80
|
+
|
|
81
|
+
• **Free**: 5 streams, 2 waves, all 6 providers (BYOK)
|
|
82
|
+
• **Pro** ($19/mo): 15 streams, 10 waves
|
|
83
|
+
• **Team** ($49/user/mo): 25 streams, 25 waves\
|
|
84
|
+
`;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
export interface ResourceEntry {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
content: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const RESOURCE_REGISTRY: Record<string, ResourceEntry>;
|
|
8
|
+
export declare function registerResources(server: McpServer): void;
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
export const RESOURCE_REGISTRY = {
|
|
2
|
+
'orchex://quickstart': {
|
|
3
|
+
name: 'Getting Started',
|
|
4
|
+
description: 'Quick setup guide for Orchex MCP server',
|
|
5
|
+
content: `# Getting Started with Orchex
|
|
6
|
+
|
|
7
|
+
## MCP Configuration
|
|
8
|
+
|
|
9
|
+
Add Orchex to your IDE's MCP config (e.g. \`.cursor/mcp.json\` or Claude Desktop config):
|
|
10
|
+
|
|
11
|
+
\`\`\`json
|
|
12
|
+
{
|
|
13
|
+
"mcpServers": {
|
|
14
|
+
"orchex": {
|
|
15
|
+
"command": "npx",
|
|
16
|
+
"args": ["-y", "@wundam/orchex@latest"]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
\`\`\`
|
|
21
|
+
|
|
22
|
+
Orchex inherits your shell environment automatically — no \`env\` block needed unless overriding specific values.
|
|
23
|
+
|
|
24
|
+
## API Key Setup
|
|
25
|
+
|
|
26
|
+
Set provider keys as environment variables in your shell profile (\`~/.zshrc\` or \`~/.bashrc\`):
|
|
27
|
+
|
|
28
|
+
- \`ANTHROPIC_API_KEY\` — Claude (recommended default)
|
|
29
|
+
- \`OPENAI_API_KEY\` — GPT-4o and variants
|
|
30
|
+
- \`GEMINI_API_KEY\` — Google Gemini
|
|
31
|
+
- \`DEEPSEEK_API_KEY\` — DeepSeek
|
|
32
|
+
- AWS credentials — Bedrock
|
|
33
|
+
|
|
34
|
+
Orchex auto-detects which providers are available from your environment.
|
|
35
|
+
|
|
36
|
+
## First Run
|
|
37
|
+
|
|
38
|
+
Use the \`auto\` tool to plan and execute in one shot:
|
|
39
|
+
|
|
40
|
+
\`\`\`
|
|
41
|
+
auto intent="Add a /health endpoint to the Express server" projectDir="/path/to/project"
|
|
42
|
+
\`\`\`
|
|
43
|
+
|
|
44
|
+
Orchex will generate a plan, show you a preview of proposed streams, and ask for confirmation before executing.
|
|
45
|
+
|
|
46
|
+
## Cloud Trial
|
|
47
|
+
|
|
48
|
+
Get 10 free cloud-managed runs with:
|
|
49
|
+
|
|
50
|
+
\`\`\`
|
|
51
|
+
orchex login
|
|
52
|
+
\`\`\`
|
|
53
|
+
|
|
54
|
+
This fetches an entitlement JWT that unlocks Pro-level limits (up to 10 streams, 10 waves, multiple providers) for your trial runs. No credit card required.
|
|
55
|
+
|
|
56
|
+
## Key Tools
|
|
57
|
+
|
|
58
|
+
- \`auto\` — full autopilot: intent → plan → execute
|
|
59
|
+
- \`init\` + \`add_stream\` + \`execute\` — manual workflow for fine-grained control
|
|
60
|
+
- \`status\` — check orchestration progress
|
|
61
|
+
- \`complete\` — finalize and archive after execution
|
|
62
|
+
`,
|
|
63
|
+
},
|
|
64
|
+
'orchex://concepts/streams': {
|
|
65
|
+
name: 'Streams',
|
|
66
|
+
description: 'Stream ownership model and file isolation',
|
|
67
|
+
content: `# Streams
|
|
68
|
+
|
|
69
|
+
Streams are the atomic unit of work in Orchex. Each stream represents a focused, bounded task executed by a single LLM call.
|
|
70
|
+
|
|
71
|
+
## Core Properties
|
|
72
|
+
|
|
73
|
+
Every stream definition includes:
|
|
74
|
+
|
|
75
|
+
- \`name\` — unique identifier (e.g. \`"auth-middleware"\`)
|
|
76
|
+
- \`deps\` — stream IDs this stream depends on (must complete first)
|
|
77
|
+
- \`owns\` — files this stream will create or modify (exclusive ownership)
|
|
78
|
+
- \`reads\` — files needed for context but not modified
|
|
79
|
+
- \`plan\` — YAML instructions passed directly to the executing LLM
|
|
80
|
+
- \`setup\` — shell commands to run before execution (e.g. \`npm install\`)
|
|
81
|
+
- \`verify\` — shell commands to validate output (e.g. \`npm test\`, \`tsc --noEmit\`)
|
|
82
|
+
|
|
83
|
+
## Ownership Model
|
|
84
|
+
|
|
85
|
+
Each file in \`owns\` belongs exclusively to one stream. No two streams may own the same file. This prevents merge conflicts when streams run in parallel. Ownership is validated at \`init\` time — conflicts cause an immediate error before any execution begins.
|
|
86
|
+
|
|
87
|
+
## Parallel Execution
|
|
88
|
+
|
|
89
|
+
Streams with no shared dependencies run simultaneously within a wave. Orchex automatically groups streams into waves based on the dependency graph. A stream in wave 2 can safely read files owned by wave 1 streams because wave 1 is complete before wave 2 starts.
|
|
90
|
+
|
|
91
|
+
## Fix Streams
|
|
92
|
+
|
|
93
|
+
When a stream fails, Orchex generates a fix stream automatically. The fix stream inherits the same \`owns\` list and receives the full error context — stderr, verification output, and file diffs — in its plan. Fix chains are capped at 3 attempts per stream.
|
|
94
|
+
|
|
95
|
+
## Plan Quality
|
|
96
|
+
|
|
97
|
+
The \`plan\` field is the LLM's entire instruction set. Markdown prose outside the YAML is not visible to the executing model. Be explicit: specify file paths, function signatures, import statements, and constraints like "do NOT use library X".
|
|
98
|
+
`,
|
|
99
|
+
},
|
|
100
|
+
'orchex://concepts/waves': {
|
|
101
|
+
name: 'Waves',
|
|
102
|
+
description: 'Parallel execution and dependency management',
|
|
103
|
+
content: `# Waves
|
|
104
|
+
|
|
105
|
+
Waves are groups of streams that execute simultaneously. Orchex automatically calculates wave assignments from the dependency graph — you declare dependencies, Orchex figures out parallelism.
|
|
106
|
+
|
|
107
|
+
## How Wave Assignment Works
|
|
108
|
+
|
|
109
|
+
1. Streams with no dependencies → wave 1
|
|
110
|
+
2. Streams whose all dependencies are in wave 1 → wave 2
|
|
111
|
+
3. Streams whose all dependencies are in waves 1–2 → wave 3
|
|
112
|
+
4. And so on...
|
|
113
|
+
|
|
114
|
+
A stream is placed in the earliest wave where all its dependencies have already been assigned.
|
|
115
|
+
|
|
116
|
+
## Dependency Rules
|
|
117
|
+
|
|
118
|
+
- \`deps\` references other stream IDs (names), not wave numbers
|
|
119
|
+
- A stream can only depend on streams in earlier waves (no circular deps)
|
|
120
|
+
- Orchex detects and rejects circular dependencies at \`init\` time
|
|
121
|
+
- Cross-wave file access is safe: earlier waves are fully complete before later waves start
|
|
122
|
+
|
|
123
|
+
## Execution Modes
|
|
124
|
+
|
|
125
|
+
- \`execute mode=auto\` — runs all waves sequentially, one wave at a time
|
|
126
|
+
- \`execute mode=wave\` — runs the next pending wave (useful for step-by-step control)
|
|
127
|
+
- Within a wave, all streams launch in parallel
|
|
128
|
+
|
|
129
|
+
## Wave-Level Circuit Breaker
|
|
130
|
+
|
|
131
|
+
If every stream in a wave fails, Orchex halts execution immediately rather than running dependent waves that are guaranteed to fail. The circuit breaker state is visible in \`status\` output.
|
|
132
|
+
|
|
133
|
+
## Practical Tips
|
|
134
|
+
|
|
135
|
+
- Keep waves shallow (3–5 streams per wave) for predictable parallelism
|
|
136
|
+
- Use \`reads\` on shared files rather than deps when you only need context
|
|
137
|
+
- Streams that touch unrelated parts of the codebase can safely be in the same wave even if logically sequential
|
|
138
|
+
`,
|
|
139
|
+
},
|
|
140
|
+
'orchex://concepts/ownership': {
|
|
141
|
+
name: 'Ownership',
|
|
142
|
+
description: 'File isolation rules preventing merge conflicts',
|
|
143
|
+
content: `# Ownership
|
|
144
|
+
|
|
145
|
+
Orchex enforces strict file ownership to prevent parallel streams from corrupting each other's work.
|
|
146
|
+
|
|
147
|
+
## owns vs reads
|
|
148
|
+
|
|
149
|
+
- \`owns\` — files this stream will create or modify. Exclusive: no other stream may list these files in its \`owns\`.
|
|
150
|
+
- \`reads\` — files needed for context. Non-exclusive: any number of streams can read the same file.
|
|
151
|
+
|
|
152
|
+
A stream may freely read files it does not own. It must not write to files it does not own.
|
|
153
|
+
|
|
154
|
+
## Ownership Validation
|
|
155
|
+
|
|
156
|
+
At \`init\` time, Orchex validates the full ownership graph before any stream executes:
|
|
157
|
+
|
|
158
|
+
- Duplicate \`owns\` entries across streams → init fails with a conflict error naming both streams
|
|
159
|
+
- Files in \`reads\` that are also in \`owns\` of the same stream → allowed (owns implies read access)
|
|
160
|
+
- Non-existent files in \`owns\` → allowed (stream may create them)
|
|
161
|
+
|
|
162
|
+
## Path Rules
|
|
163
|
+
|
|
164
|
+
- All paths in \`owns\` and \`reads\` must be relative to the project directory
|
|
165
|
+
- Absolute paths are rejected
|
|
166
|
+
- Paths must stay within the project directory — traversal (e.g. \`../../secrets\`) is blocked
|
|
167
|
+
|
|
168
|
+
## Fix Stream Inheritance
|
|
169
|
+
|
|
170
|
+
When a fix stream is auto-generated for a failed stream, it inherits the parent's \`owns\` list exactly. This ensures the fix can overwrite broken output without ownership conflicts.
|
|
171
|
+
|
|
172
|
+
## Common Patterns
|
|
173
|
+
|
|
174
|
+
- **New file creation**: list only in \`owns\`, no \`reads\` needed
|
|
175
|
+
- **Editing shared config** (e.g. \`tsconfig.json\`): only one stream may own it; others use \`reads\`
|
|
176
|
+
- **Barrel exports** (e.g. \`src/index.ts\`): assign ownership to a dedicated "exports" stream that runs last
|
|
177
|
+
- **Test files**: typically co-located ownership — stream that owns \`auth.ts\` also owns \`auth.test.ts\`
|
|
178
|
+
`,
|
|
179
|
+
},
|
|
180
|
+
'orchex://concepts/self-healing': {
|
|
181
|
+
name: 'Self-Healing',
|
|
182
|
+
description: 'Automatic error detection and recovery',
|
|
183
|
+
content: `# Self-Healing
|
|
184
|
+
|
|
185
|
+
When a stream fails, Orchex automatically analyzes the error, generates a targeted fix stream, and retries — up to 3 attempts per chain.
|
|
186
|
+
|
|
187
|
+
## Error Categories
|
|
188
|
+
|
|
189
|
+
Orchex classifies errors into 10+ categories to decide whether to retry:
|
|
190
|
+
|
|
191
|
+
**Retryable (code errors):**
|
|
192
|
+
- Test failures — unit/integration tests report failures
|
|
193
|
+
- Type errors — TypeScript compilation errors
|
|
194
|
+
- Lint errors — ESLint/style violations
|
|
195
|
+
- Syntax errors — unparseable output
|
|
196
|
+
- Missing imports — module not found at runtime
|
|
197
|
+
- Logic errors — incorrect behavior detected by verify commands
|
|
198
|
+
|
|
199
|
+
**Not retryable (infrastructure errors):**
|
|
200
|
+
- Model not found (404) — invalid model ID in config
|
|
201
|
+
- Authentication failure — invalid or missing API key
|
|
202
|
+
- Server errors (5xx) — provider outage
|
|
203
|
+
- Rate limit exceeded — quota hit (surfaces as user-facing error)
|
|
204
|
+
- Context length exceeded — plan too large for model
|
|
205
|
+
|
|
206
|
+
## Fix Stream Generation
|
|
207
|
+
|
|
208
|
+
On a retryable failure, Orchex:
|
|
209
|
+
|
|
210
|
+
1. Captures the full error context: stderr, verify output, file diffs, and the original plan
|
|
211
|
+
2. Generates a new stream with the error context injected into its plan
|
|
212
|
+
3. Assigns the same \`owns\` list as the failed stream
|
|
213
|
+
4. Queues it as the next stream to execute
|
|
214
|
+
|
|
215
|
+
## Chain Limits
|
|
216
|
+
|
|
217
|
+
Each fix stream is chained to its parent via \`parentStreamId\`. Orchex traverses the full chain to count attempts. At 3 attempts, the stream is marked permanently failed and execution continues with other streams (if possible).
|
|
218
|
+
|
|
219
|
+
## Circuit Breaker
|
|
220
|
+
|
|
221
|
+
If all streams in a wave fail with the same error type, the wave-level circuit breaker trips. Subsequent waves are skipped and the orchestration is marked failed. This prevents cascading failures when the root cause affects all streams (e.g. a broken dependency or missing env var).
|
|
222
|
+
|
|
223
|
+
## selfHealable Flag
|
|
224
|
+
|
|
225
|
+
Streams can opt out of self-healing by setting \`selfHealable: false\`. Infrastructure streams or one-shot migrations may use this to fail fast rather than retry.
|
|
226
|
+
`,
|
|
227
|
+
},
|
|
228
|
+
'orchex://concepts/providers': {
|
|
229
|
+
name: 'Providers',
|
|
230
|
+
description: 'LLM provider configuration and API keys',
|
|
231
|
+
content: `# Providers
|
|
232
|
+
|
|
233
|
+
Orchex supports 6 LLM providers. Keys are read from environment variables automatically.
|
|
234
|
+
|
|
235
|
+
## Supported Providers
|
|
236
|
+
|
|
237
|
+
| Provider | Env Var(s) | Fallback Model |
|
|
238
|
+
|----------|-----------|---------------|
|
|
239
|
+
| Anthropic (Claude) | \`ANTHROPIC_API_KEY\` | claude-sonnet-4-5-20250929 |
|
|
240
|
+
| OpenAI | \`OPENAI_API_KEY\` | gpt-4.1 |
|
|
241
|
+
| Google Gemini | \`GEMINI_API_KEY\` | gemini-2.0-flash |
|
|
242
|
+
| DeepSeek | \`DEEPSEEK_API_KEY\` | deepseek-coder |
|
|
243
|
+
| Ollama | (none — local) | llama3.3:70b |
|
|
244
|
+
| AWS Bedrock | \`AWS_ACCESS_KEY_ID\` + \`AWS_SECRET_ACCESS_KEY\` + \`AWS_REGION\` | claude-3.5-sonnet |
|
|
245
|
+
|
|
246
|
+
Models are auto-discovered from provider APIs daily. The fallback models above are only used when the registry is unavailable (offline mode). Use \`GET /api/v1/models\` to see all currently available models.
|
|
247
|
+
|
|
248
|
+
## Override via Env Vars
|
|
249
|
+
|
|
250
|
+
Set \`ORCHEX_PROVIDER\` and \`ORCHEX_MODEL\` to override the auto-detected default:
|
|
251
|
+
|
|
252
|
+
\`\`\`
|
|
253
|
+
ORCHEX_PROVIDER=openai ORCHEX_MODEL=gpt-4o-mini
|
|
254
|
+
\`\`\`
|
|
255
|
+
|
|
256
|
+
## Auto-Detection
|
|
257
|
+
|
|
258
|
+
Orchex scans available API keys at startup and selects a provider automatically. Priority order: Anthropic → OpenAI → Gemini → DeepSeek → Bedrock → Ollama.
|
|
259
|
+
|
|
260
|
+
## Cloud Mode
|
|
261
|
+
|
|
262
|
+
Cloud execution (\`mode: "cloud"\`) currently uses Anthropic as the backend provider. Provider and model settings in your config apply to **local mode only**. If you configure a non-Anthropic provider in cloud mode, Orchex will warn you before execution.
|
|
263
|
+
|
|
264
|
+
To use non-Anthropic providers, run in local mode with your own API key:
|
|
265
|
+
|
|
266
|
+
\`\`\`
|
|
267
|
+
orchex config --local --provider openai
|
|
268
|
+
export OPENAI_API_KEY=sk-...
|
|
269
|
+
\`\`\`
|
|
270
|
+
|
|
271
|
+
## Per-Stream Routing (Pro+)
|
|
272
|
+
|
|
273
|
+
On Pro and Team tiers, individual streams can specify a different provider or model. This allows using a fast/cheap model for simple streams and a powerful model for complex ones within the same orchestration.
|
|
274
|
+
|
|
275
|
+
## Model Registry
|
|
276
|
+
|
|
277
|
+
Orchex maintains a dynamic model registry updated daily from provider APIs. Models are validated before execution — if a model is unavailable, orchex falls back to the next best option and warns you. The registry is cached locally (\`~/.orchex/models.json\`, 24h TTL) and refreshed on \`orchex login\`.
|
|
278
|
+
|
|
279
|
+
## Providers
|
|
280
|
+
|
|
281
|
+
All tiers support all 6 providers (BYOK) — no provider restrictions.
|
|
282
|
+
|
|
283
|
+
## Ollama (Local)
|
|
284
|
+
|
|
285
|
+
Ollama runs locally — no API key needed. Set \`ORCHEX_PROVIDER=ollama\` and \`ORCHEX_MODEL=<your-model>\`. Requires Ollama running on \`localhost:11434\`. Useful for air-gapped environments or cost-sensitive workloads.
|
|
286
|
+
`,
|
|
287
|
+
},
|
|
288
|
+
'orchex://examples': {
|
|
289
|
+
name: 'Examples',
|
|
290
|
+
description: 'Real-world orchestration patterns',
|
|
291
|
+
content: `# Orchestration Examples
|
|
292
|
+
|
|
293
|
+
## Example 1: Feature Implementation
|
|
294
|
+
|
|
295
|
+
**Intent:** "Add user authentication with JWT to the Express API"
|
|
296
|
+
|
|
297
|
+
\`\`\`
|
|
298
|
+
auto intent="Add user authentication with JWT to the Express API" projectDir="/app"
|
|
299
|
+
\`\`\`
|
|
300
|
+
|
|
301
|
+
Typical output: 5 streams across 2 waves.
|
|
302
|
+
|
|
303
|
+
- Wave 1: \`jwt-utils\` (owns: \`src/auth/jwt.ts\`), \`user-model\` (owns: \`src/models/user.ts\`)
|
|
304
|
+
- Wave 2: \`auth-middleware\` (owns: \`src/middleware/auth.ts\`, reads: jwt-utils + user-model), \`auth-routes\` (owns: \`src/routes/auth.ts\`), \`auth-tests\` (owns: \`tests/auth.test.ts\`)
|
|
305
|
+
|
|
306
|
+
## Example 2: Bug Fix
|
|
307
|
+
|
|
308
|
+
**Intent:** "Fix the login timeout on mobile — users are logged out after 5 minutes"
|
|
309
|
+
|
|
310
|
+
\`\`\`
|
|
311
|
+
auto intent="Fix the login timeout on mobile — users are logged out after 5 minutes" projectDir="/app"
|
|
312
|
+
\`\`\`
|
|
313
|
+
|
|
314
|
+
Typical output: 2 streams, 1 wave (no dependencies between them).
|
|
315
|
+
|
|
316
|
+
- \`session-config\` (owns: \`src/config/session.ts\`) — extend TTL
|
|
317
|
+
- \`session-tests\` (owns: \`tests/session.test.ts\`) — add regression test
|
|
318
|
+
|
|
319
|
+
## Example 3: Refactoring
|
|
320
|
+
|
|
321
|
+
**Intent:** "Extract payment logic from the order controller into a dedicated PaymentService"
|
|
322
|
+
|
|
323
|
+
Typical output: 4 streams, 3 waves.
|
|
324
|
+
|
|
325
|
+
- Wave 1: \`payment-service\` (owns: \`src/services/payment.ts\`)
|
|
326
|
+
- Wave 2: \`payment-tests\` (owns: \`tests/payment.test.ts\`), \`order-controller-update\` (owns: \`src/controllers/order.ts\`, reads: payment-service)
|
|
327
|
+
- Wave 3: \`barrel-exports\` (owns: \`src/services/index.ts\`)
|
|
328
|
+
|
|
329
|
+
## Example 4: From a PRD or Spec Document
|
|
330
|
+
|
|
331
|
+
Orchex handles full documents — not just short intents:
|
|
332
|
+
|
|
333
|
+
\`\`\`
|
|
334
|
+
auto intent="<paste entire PRD or spec content here>" project_dir="/path/to/project"
|
|
335
|
+
\`\`\`
|
|
336
|
+
|
|
337
|
+
Orchex extracts implementation deliverables from the document, ignores non-code sections
|
|
338
|
+
(executive summary, problem statement, market analysis), and generates development streams
|
|
339
|
+
with proper file ownership.
|
|
340
|
+
|
|
341
|
+
## Tips for Better Results
|
|
342
|
+
|
|
343
|
+
- **Be specific**: "Add JWT auth to Express" beats "improve security"
|
|
344
|
+
- **Mention file paths**: "…in \`src/routes/users.ts\`" guides stream planning
|
|
345
|
+
- **Include constraints**: "do not modify the existing test suite", "use the existing \`db\` helper"
|
|
346
|
+
- **Scope tightly**: one feature per orchestration; break large refactors into phases
|
|
347
|
+
- **Verify commands**: Orchex uses \`npm test\` and \`tsc --noEmit\` by default — ensure they pass before starting
|
|
348
|
+
`,
|
|
349
|
+
},
|
|
350
|
+
'orchex://api-reference': {
|
|
351
|
+
name: 'API Reference',
|
|
352
|
+
description: 'Stream definition schema and tool parameters',
|
|
353
|
+
content: `# API Reference
|
|
354
|
+
|
|
355
|
+
## Stream Definition Schema
|
|
356
|
+
|
|
357
|
+
\`\`\`
|
|
358
|
+
StreamDefinition {
|
|
359
|
+
name: string // unique ID within orchestration
|
|
360
|
+
deps: string[] // names of streams that must complete first
|
|
361
|
+
owns: string[] // files this stream will create/modify (exclusive)
|
|
362
|
+
reads: string[] // files needed for context (non-exclusive)
|
|
363
|
+
plan: string // YAML instructions — the LLM's entire input
|
|
364
|
+
setup: string[] // shell commands before execution (e.g. "npm install")
|
|
365
|
+
verify: string[] // validation commands after execution (e.g. "npm test")
|
|
366
|
+
}
|
|
367
|
+
\`\`\`
|
|
368
|
+
|
|
369
|
+
## Key Rules
|
|
370
|
+
|
|
371
|
+
- \`owns\` paths must be relative to \`projectDir\` (no absolute paths, no \`../\` traversal)
|
|
372
|
+
- \`deps\` references stream \`name\` values, not indices
|
|
373
|
+
- \`plan\` is the LLM's entire instruction set — prose outside YAML blocks is not visible to the executing model
|
|
374
|
+
- \`verify\` commands that exit non-zero trigger self-healing (if the error is retryable)
|
|
375
|
+
|
|
376
|
+
## MCP Tools
|
|
377
|
+
|
|
378
|
+
| Tool | Purpose |
|
|
379
|
+
|------|---------|
|
|
380
|
+
| \`auto\` | Full autopilot: intent → plan → preview → execute |
|
|
381
|
+
| \`init\` | Create orchestration from stream definitions |
|
|
382
|
+
| \`add_stream\` | Add a stream to an existing orchestration |
|
|
383
|
+
| \`execute\` | Run pending streams (mode: auto \| wave) |
|
|
384
|
+
| \`status\` | Get current orchestration state |
|
|
385
|
+
| \`complete\` | Finalize and archive orchestration |
|
|
386
|
+
| \`recover\` | Resume a failed or interrupted orchestration |
|
|
387
|
+
| \`learn\` | Parse implementation plan into stream definitions (internal — prefer auto) |
|
|
388
|
+
| \`rollback-stream\` | Revert a specific stream's file changes |
|
|
389
|
+
| \`reload\` | Reload orchestration state from disk |
|
|
390
|
+
| \`reset-learning\` | Clear learned patterns |
|
|
391
|
+
| \`init-plan\` | Initialize from a pre-written plan document |
|
|
392
|
+
|
|
393
|
+
## auto Tool Parameters
|
|
394
|
+
|
|
395
|
+
- \`intent\` (required) — natural language description of what to build
|
|
396
|
+
- \`projectDir\` (required) — absolute path to project root
|
|
397
|
+
- \`provider\` — override default LLM provider
|
|
398
|
+
- \`model\` — override default model
|
|
399
|
+
- \`approve\` — skip confirmation prompt (\`true\` for non-interactive use)
|
|
400
|
+
|
|
401
|
+
## execute Tool Parameters
|
|
402
|
+
|
|
403
|
+
- \`orchestrationId\` — ID from \`init\` or \`auto\`
|
|
404
|
+
- \`mode\` — \`"auto"\` (all waves) or \`"wave"\` (next wave only)
|
|
405
|
+
`,
|
|
406
|
+
},
|
|
407
|
+
};
|
|
408
|
+
export function registerResources(server) {
|
|
409
|
+
for (const [uriPath, entry] of Object.entries(RESOURCE_REGISTRY)) {
|
|
410
|
+
server.resource(entry.name, uriPath, { description: entry.description, mimeType: 'text/markdown' }, async (uri) => ({
|
|
411
|
+
contents: [
|
|
412
|
+
{
|
|
413
|
+
uri: uri.href,
|
|
414
|
+
text: entry.content,
|
|
415
|
+
mimeType: 'text/markdown',
|
|
416
|
+
},
|
|
417
|
+
],
|
|
418
|
+
}));
|
|
419
|
+
}
|
|
420
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface CachedModelEntry {
|
|
2
|
+
modelId: string;
|
|
3
|
+
displayName: string | null;
|
|
4
|
+
pricingInputPerM: number | null;
|
|
5
|
+
pricingOutputPerM: number | null;
|
|
6
|
+
}
|
|
7
|
+
export interface CachedModels {
|
|
8
|
+
providers: Record<string, CachedModelEntry[]>;
|
|
9
|
+
fetchedAt: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function writeModelCache(data: CachedModels): Promise<void>;
|
|
12
|
+
export declare function readModelCache(): Promise<CachedModels | null>;
|
|
13
|
+
export declare function clearModelCache(): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Fetch models from Orchex server and cache locally.
|
|
16
|
+
* Returns null if server is unreachable (offline/local mode).
|
|
17
|
+
*/
|
|
18
|
+
export declare function fetchAndCacheModels(apiUrl: string): Promise<CachedModels | null>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as os from 'os';
|
|
4
|
+
/** TTL for cached models — 24 hours. */
|
|
5
|
+
const CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
6
|
+
const CACHE_FILENAME = 'models.json';
|
|
7
|
+
function cacheDir() {
|
|
8
|
+
return process.env.ORCHEX_CONFIG_DIR ?? path.join(os.homedir(), '.orchex');
|
|
9
|
+
}
|
|
10
|
+
function cachePath() {
|
|
11
|
+
return path.join(cacheDir(), CACHE_FILENAME);
|
|
12
|
+
}
|
|
13
|
+
export async function writeModelCache(data) {
|
|
14
|
+
const dir = cacheDir();
|
|
15
|
+
await fs.mkdir(dir, { recursive: true });
|
|
16
|
+
await fs.writeFile(cachePath(), JSON.stringify(data, null, 2), { encoding: 'utf-8', mode: 0o600 });
|
|
17
|
+
}
|
|
18
|
+
export async function readModelCache() {
|
|
19
|
+
try {
|
|
20
|
+
const raw = await fs.readFile(cachePath(), 'utf-8');
|
|
21
|
+
const data = JSON.parse(raw);
|
|
22
|
+
// TTL check
|
|
23
|
+
const age = Date.now() - new Date(data.fetchedAt).getTime();
|
|
24
|
+
if (age > CACHE_TTL_MS)
|
|
25
|
+
return null;
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export async function clearModelCache() {
|
|
33
|
+
try {
|
|
34
|
+
await fs.unlink(cachePath());
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// Ignore — file may not exist
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Fetch models from Orchex server and cache locally.
|
|
42
|
+
* Returns null if server is unreachable (offline/local mode).
|
|
43
|
+
*/
|
|
44
|
+
export async function fetchAndCacheModels(apiUrl) {
|
|
45
|
+
try {
|
|
46
|
+
const resp = await fetch(`${apiUrl}/api/v1/models`, {
|
|
47
|
+
signal: AbortSignal.timeout(5000), // 5s timeout
|
|
48
|
+
});
|
|
49
|
+
if (!resp.ok)
|
|
50
|
+
return null;
|
|
51
|
+
const data = await resp.json();
|
|
52
|
+
const cached = {
|
|
53
|
+
providers: data.providers,
|
|
54
|
+
fetchedAt: new Date().toISOString(),
|
|
55
|
+
};
|
|
56
|
+
await writeModelCache(cached);
|
|
57
|
+
return cached;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type LLMProvider } from './config.js';
|
|
2
|
+
export interface ModelValidationResult {
|
|
3
|
+
originalModel: string;
|
|
4
|
+
resolvedModel: string;
|
|
5
|
+
wasFallback: boolean;
|
|
6
|
+
reason?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Static fallback chains — used only when registry + cache are both unavailable.
|
|
10
|
+
*/
|
|
11
|
+
export declare const MODEL_FALLBACKS: Record<string, string[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a model to an available one using the registry/cache.
|
|
14
|
+
* Resolution chain: cache → server fetch → static fallback
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveModel(provider: LLMProvider, preferredModel: string, apiUrl?: string): Promise<ModelValidationResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Check if a provider has a valid API key configured.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isProviderAvailable(provider: LLMProvider): boolean;
|