@wundam/orchex 1.0.0-rc.1 → 1.0.0-rc.2

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 CHANGED
@@ -11,19 +11,16 @@ Your AI assistant does tasks one at a time. Orchex makes it do 10 at once — sa
11
11
  - **Parallel Execution** — Multiple streams run simultaneously in dependency-aware waves. 5-10x faster than serial prompting.
12
12
  - **Ownership Enforcement** — Each stream can only modify files in its `owns` array. No two agents touch the same file. Zero conflicts.
13
13
  - **`orchex learn`** — The magic command. Paste a markdown plan, get executable parallel streams with dependency inference and anti-pattern detection. No other tool does this.
14
- - **Self-Healing** — 10 error categories with targeted fix streams. Not blind retry — categorized analysis with augmented instructions.
15
- - **Multi-LLM** — OpenAI, Gemini, Claude, DeepSeek, Ollama. Route different orchestrations to different providers — use DeepSeek ($0.001/1K) for docs, Claude ($0.015/1K) for core logic.
14
+ - **Self-Healing** — Categorized error analysis with targeted fix streams. Not blind retry.
15
+ - **Multi-LLM** — OpenAI, Gemini, Claude, DeepSeek, Ollama. Route different orchestrations to different providers.
16
16
  - **BYOK** — Bring your own API key from any supported provider. You control costs.
17
- - **Context Budget Intelligence** — Provider-aware limits with soft/hard enforcement and adaptive learning per stream category.
18
- - **Team Collaboration** — Organization members see each other's orchestration runs. Shared dashboard with org switcher and access controls.
19
- - **Observability** — Real-time stats: speedup multiplier, success rate, self-heal recoveries, time saved. Per-user dashboard with 30-day rolling metrics.
20
17
 
21
18
  ## Prerequisites
22
19
 
23
20
  - [Node.js](https://nodejs.org/) >= 18
24
21
  - LLM API key (one of the following):
25
22
  - `ANTHROPIC_API_KEY` for Anthropic Claude
26
- - `OPENAI_API_KEY` for OpenAI (GPT-4, GPT-4.1)
23
+ - `OPENAI_API_KEY` for OpenAI (GPT-4.1, GPT-4.5)
27
24
  - `GEMINI_API_KEY` for Google Gemini
28
25
  - `DEEPSEEK_API_KEY` for DeepSeek (V3, Coder, Reasoner)
29
26
  - Or configure Ollama for local models
@@ -40,6 +37,24 @@ Or use directly:
40
37
  npx @wundam/orchex
41
38
  ```
42
39
 
40
+ ## Cloud Setup (Optional)
41
+
42
+ Connect to orchex cloud for managed execution:
43
+
44
+ ```bash
45
+ orchex login
46
+ ```
47
+
48
+ Your browser opens — log in or create a free account, click **Allow**. Token saved automatically.
49
+
50
+ ```bash
51
+ orchex status # Check tier and trial runs
52
+ orchex logout # Clear credentials
53
+ orchex --help # All commands
54
+ ```
55
+
56
+ See the [cloud setup guide](docs/user-guide/cloud-setup.md) for full details.
57
+
43
58
  ## MCP Configuration
44
59
 
45
60
  Add to your MCP config (e.g. project `.mcp.json`):
@@ -94,13 +109,7 @@ orchex.init({
94
109
  orchex.execute({ mode: "auto" })
95
110
  ```
96
111
 
97
- Calculates waves from dependencies (topological sort), then for each wave:
98
- 1. Runs **setup** commands for each stream
99
- 2. Builds a **4-layer context prompt** (project, stream files, dependency artifacts, instructions)
100
- 3. Calls the **LLM API** in parallel (one call per stream in the wave)
101
- 4. Parses and **validates artifacts** from responses
102
- 5. **Applies** file operations to the codebase
103
- 6. Runs **verify** commands
112
+ Calculates waves from dependencies (topological sort), then executes each wave in parallel — running setup commands, calling the LLM API, applying file operations with ownership enforcement, and running verification commands.
104
113
 
105
114
  Wave plan for the example above:
106
115
  - **Wave 1:** `types` (no deps)
@@ -138,28 +147,6 @@ orchex.complete({ archive: true })
138
147
  | `recover` | Detect and recover stuck streams from mid-execution failures |
139
148
  | `reload` | Restart the MCP server process (picks up config/code changes) |
140
149
 
141
- ## Architecture
142
-
143
- ```
144
- orchex.execute()
145
-
146
- For each wave (parallel streams within wave):
147
-
148
- ├── 1. Resolve — load manifest, calculate waves, find target
149
- ├── 2. Setup — run pre-execution commands
150
- ├── 3. Context — build 4-layer prompt
151
- │ ├── Project context (file tree, deps, config)
152
- │ ├── Stream context (owned + read-only file contents)
153
- │ ├── Dependency context (completed artifact summaries)
154
- │ └── Instructions (artifact format, ownership rules)
155
- ├── 4. Execute — call LLM API in parallel (Claude/OpenAI/Gemini/DeepSeek/Ollama)
156
- ├── 5. Validate — parse orchex-artifact from response
157
- ├── 6. Apply — write files to codebase (with ownership enforcement)
158
- └── 7. Verify — run post-execution commands
159
- ```
160
-
161
- Streams can only modify files listed in their `owns` array. A file-based lock prevents concurrent `execute` calls.
162
-
163
150
  ## Stream Definition
164
151
 
165
152
  | Field | Type | Description |
@@ -177,120 +164,12 @@ Streams can only modify files listed in their `owns` array. A file-based lock pr
177
164
 
178
165
  **One stream = one atomic deliverable.** If your stream description uses "and" between distinct concepts, split it.
179
166
 
180
- | Pattern | Success | Why |
181
- |---------|---------|-----|
182
- | `docs-installation` (one installation guide) | ✅ | Single focused topic |
183
- | `integration-claude-code` (one integration guide) | ✅ | Predictable structure |
184
- | `unified-layout` (implementation + tests) | ✅ | Code + tests are one unit |
185
- | `docs-structure` (5 different docs) | ❌ | Multiple distinct outputs |
186
- | `tutorials-first` (setup + walkthrough + summary) | ❌ | Multiple conceptual sections |
187
-
188
167
  **Slicing heuristics:**
189
- - **`owns` > 4 distinct files** → Split (each file requiring different content should be separate)
190
- - **`reads` > 4 files** → Split (high synthesis complexity = timeout risk)
168
+ - **`owns` > 4 distinct files** → Split
169
+ - **`reads` > 4 files** → Split (high synthesis complexity)
191
170
  - **Expected output > 6,000 tokens** → Split
171
+ - **Code implementation + its tests** → Keep together
192
172
  - **Tutorials** → Section into intro/walkthrough/conclusion streams
193
- - **Code implementation + its tests** → Keep together (they must match)
194
- - **Templated repetition** → Can bundle (structurally identical outputs)
195
-
196
- ## Context Budget Intelligence
197
-
198
- Orchex Learn tracks context budget usage and adapts thresholds based on execution history.
199
-
200
- ### Provider-Aware Limits
201
-
202
- | Provider | Context Limit | Default Soft | Default Hard |
203
- |----------|---------------|--------------|--------------|
204
- | Anthropic | 200,000 | 140,000 | 180,000 |
205
- | OpenAI | 128,000 | 89,600 | 115,200 |
206
- | Gemini | 1,000,000 | 700,000 | 900,000 |
207
- | DeepSeek | 128,000 | 89,600 | 115,200 |
208
- | Ollama | 128,000 | 89,600 | 115,200 |
209
-
210
- ### Budget Warnings
211
-
212
- When a stream's estimated context exceeds limits, warnings appear in execution output:
213
-
214
- ```json
215
- {
216
- "event": "budget_warning",
217
- "streamId": "large-docs",
218
- "violationType": "soft",
219
- "estimatedTokens": 156000,
220
- "budgetLimit": 140000
221
- }
222
- ```
223
-
224
- ### Adaptive Learning
225
-
226
- Thresholds improve as execution history accumulates:
227
- - **Per-category limits** — Code streams vs. documentation vs. tutorials
228
- - **Confidence levels** — Low (0-49 samples) → Medium (50-99) → High (100+)
229
- - **Persisted learning** — Saved in `.orchex/learn/thresholds.json`
230
-
231
- ### Stream Category Recommendations
232
-
233
- | Category | Max Owns | Max Reads | Notes |
234
- |----------|----------|-----------|-------|
235
- | code | 4 | 4 | Implementation files |
236
- | docs | 6 | 3 | Documentation pages |
237
- | tutorial | 3 | 4 | Sectioned tutorials |
238
- | test | 4 | 5 | Test files with fixtures |
239
- | migration | 3 | 4 | Schema migrations |
240
-
241
- ## Stream Validation
242
-
243
- Orchex validates stream definitions during `init` and `add_stream`, detecting anti-patterns and suggesting improvements.
244
-
245
- ### Quality Analysis
246
-
247
- ```json
248
- {
249
- "qualityAnalysis": {
250
- "overallScore": 85,
251
- "issues": { "errors": 0, "warnings": 2, "info": 1 },
252
- "problematicStreams": ["large-docs"],
253
- "splitSuggestions": [{
254
- "streamId": "large-docs",
255
- "templateName": "Documentation Set",
256
- "suggestedStreams": ["docs-overview", "docs-installation", "docs-quickstart"]
257
- }]
258
- }
259
- }
260
- ```
261
-
262
- ### Anti-Patterns Detected
263
-
264
- | Pattern | Severity | Description |
265
- |---------|----------|-------------|
266
- | High owns count | warning | Stream owns >4 files across multiple directories |
267
- | High reads count | warning | Stream reads >4 files (synthesis complexity) |
268
- | Compound plan | warning | Plan contains multiple "and" conjunctions |
269
- | Empty plan | error | Stream has no plan description |
270
- | No verification | info | Stream has no verify commands |
271
-
272
- ### Template-Based Split Suggestions
273
-
274
- When anti-patterns are detected, Orchex suggests splits based on known templates:
275
- - **Documentation Set** — Split into overview, installation, quickstart, etc.
276
- - **Code Feature** — Split into types, core, tests, docs
277
- - **Migration** — Split into new implementation, migrate components, deprecate old
278
- - **Tutorial** — Split into intro, steps, conclusion
279
- - **API Reference** — Split by module
280
-
281
- ### Automatic Splitting in `learn`
282
-
283
- When `orchex learn` parses a markdown plan, it automatically splits deliverables with mixed concerns into focused sub-streams following `types → migrations → core → tests → docs` ordering. Each sub-stream gets relevant plan content and files for its concern. Dependencies chain sequentially: the first sub-stream inherits the parent's deps, and each subsequent sub-stream depends on the previous one. Cross-deliverable dependencies resolve to the `-core` sibling (the implementation stream) rather than scaffolding streams like `-types` or `-migrations`. Plan authors can use `- Read:` / `- Import:` markers alongside `- Create:` / `- Modify:` to declare read-only file dependencies.
284
-
285
- ### Learn Pipeline Intelligence
286
-
287
- The `learn` pipeline includes several quality improvements:
288
-
289
- - **Import-based reads inference** — Parses `import`/`require()` from code blocks in plan documents and auto-adds referenced files to `reads`. Resolves relative imports when filename context is available.
290
- - **Path validation** — Validates `owns`/`reads` paths against the filesystem when `projectDir` is available. Auto-corrects unambiguous mismatches (e.g., `tools.ts` → `src/tools.ts`) with visible warnings.
291
- - **Cycle auto-resolution** — When two streams mutually read each other's owned files (context reads, not sequencing requirements), the false dependency cycle is automatically resolved. N-node file-ownership-only cycles are broken by removing the weakest edge. Cycles involving explicit or content-pattern dependencies are preserved and reported as errors.
292
- - **Structured description extraction** — Complex sections (>3000 chars, >=3 children) get numbered task lists instead of truncated prose, ensuring all sub-sections are visible to the LLM.
293
- - **Complexity warnings** — Flags deliverables with many sub-sections, suggesting YAML definitions or `deliverable_level: 3` for manual decomposition.
294
173
 
295
174
  ## Development
296
175
 
@@ -317,15 +196,7 @@ For local development, point `.mcp.json` to your local build:
317
196
 
318
197
  ## Pricing
319
198
 
320
- | Tier | Price | What you get |
321
- |---|---|---|
322
- | **Local** | Free | Core MCP tools: 5 streams, 2 waves, single provider, BYOK. |
323
- | **Cloud Trial** | $0 ($5 credit) | Full cloud features. 30-day credit, no credit card required. |
324
- | **Pro** | $19/mo | 100 cloud runs/mo, 15 agents, 10 waves, 2 providers, `orchex learn`, full self-healing. |
325
- | **Team** | $49/user/mo | 500 cloud runs/mo, 25 agents, 25 waves, 3 providers, shared orchestrations, team management. |
326
- | **Enterprise** | Custom | Unlimited runs + waves, 50+ agents, all providers, self-hosted, SLA + dedicated support. |
327
-
328
- 1 run = 1 orchestration. BYOK on all plans — you pay your own LLM API costs.
199
+ See [orchex.dev/pricing](https://orchex.dev/pricing) for current plans and limits. Free local tier included.
329
200
 
330
201
  ## License
331
202
 
@@ -68,6 +68,24 @@ export declare function checkOwnership(operations: FileOperation[], owns: string
68
68
  * Returns violations, warnings, and allowed files separately.
69
69
  */
70
70
  export declare function checkOwnershipDetailed(operations: FileOperation[], owns: string[], options?: OwnershipCheckOptions): OwnershipCheckResult;
71
+ /**
72
+ * Validate syntax of files modified by artifact operations.
73
+ *
74
+ * Strategy:
75
+ * - JSON: in-process JSON.parse (fast, no child process)
76
+ * - JS/MJS/CJS: node --check (per-file syntax check)
77
+ * - TS/TSX inside tsconfig include: project-wide `tsc --noEmit --project tsconfig.json`,
78
+ * filtered to only report errors from stream-owned files. This respects skipLibCheck,
79
+ * global type augmentations (declare global), and include/exclude paths.
80
+ * - TS/TSX outside tsconfig include (e.g. tests/): per-file `tsc --noEmit
81
+ * --isolatedModules --skipLibCheck`, filtered to exclude node_modules errors.
82
+ *
83
+ * Returns valid:true if all files pass or have unsupported extensions.
84
+ */
85
+ export declare function validateSyntax(projectDir: string, operations: FileOperation[]): Promise<{
86
+ valid: boolean;
87
+ errors: string[];
88
+ }>;
71
89
  /**
72
90
  * Apply a stream's artifact to the project codebase.
73
91
  * Creates a backup before applying. Rolls back on error.
@@ -109,6 +127,50 @@ export interface StreamBackup {
109
127
  * Public API — used by orchestrator for verify isolation.
110
128
  */
111
129
  export declare function createStreamBackup(projectDir: string, streamId: string, operations: FileOperation[]): Promise<StreamBackup>;
130
+ /**
131
+ * Persist a stream backup to disk as JSON.
132
+ * Stored in .orchex/active/backups/<streamId>.json
133
+ */
134
+ export declare function writeBackup(projectDir: string, backup: StreamBackup): Promise<void>;
135
+ /**
136
+ * Read a single backup from disk. Returns null if not found.
137
+ */
138
+ export declare function readBackup(projectDir: string, streamId: string): Promise<StreamBackup | null>;
139
+ /**
140
+ * Read all persisted backups from disk.
141
+ */
142
+ export declare function readAllBackups(projectDir: string): Promise<StreamBackup[]>;
143
+ /**
144
+ * Delete a single backup file.
145
+ */
146
+ export declare function deleteBackup(projectDir: string, streamId: string): Promise<void>;
147
+ interface IsolationState {
148
+ streamId: string;
149
+ phase: 'reverting' | 'testing' | 'restoring';
150
+ timestamp: string;
151
+ }
152
+ /**
153
+ * Write isolation state to disk before each dangerous phase.
154
+ * If the process crashes, recovery can read this to know which
155
+ * stream was being tested and restore from its disk backup.
156
+ */
157
+ export declare function writeIsolationState(projectDir: string, streamId: string, phase: IsolationState['phase']): Promise<void>;
158
+ /**
159
+ * Read isolation state. Returns null if no state file exists.
160
+ */
161
+ export declare function readIsolationState(projectDir: string): Promise<IsolationState | null>;
162
+ /**
163
+ * Clear isolation state after successful completion or recovery.
164
+ */
165
+ export declare function clearIsolationState(projectDir: string): Promise<void>;
166
+ /**
167
+ * Recover from a crash that happened during verify isolation.
168
+ * Reads .isolation-state to determine which stream was being tested,
169
+ * then restores it from its disk backup.
170
+ *
171
+ * Returns true if recovery was performed, false if no recovery needed.
172
+ */
173
+ export declare function recoverFromIsolationCrash(projectDir: string): Promise<boolean>;
112
174
  /**
113
175
  * Revert a stream's changes using its backup.
114
176
  * Restores modified files and removes created files.
@@ -119,14 +181,33 @@ export declare function revertStreamBackup(projectDir: string, backup: StreamBac
119
181
  * Used to re-apply changes after a temporary revert during verify isolation.
120
182
  */
121
183
  export declare function restoreStreamBackup(projectDir: string, backup: StreamBackup): Promise<void>;
184
+ /**
185
+ * Execute a function with only the specified stream's changes on disk.
186
+ * Temporarily reverts all other streams' backups, runs fn, then restores them.
187
+ * Uses crash-recovery state machine (.isolation-state) for safety.
188
+ *
189
+ * If otherBackups is empty, fn is called directly without isolation.
190
+ */
191
+ export declare function withStreamIsolation<T>(projectDir: string, streamId: string, otherBackups: StreamBackup[], fn: () => Promise<T>): Promise<T>;
192
+ export interface IsolationOptions {
193
+ /** Total timeout for the entire isolation process in ms. Default: 120_000 (2 min). */
194
+ timeoutMs?: number;
195
+ }
196
+ export interface FileOverlap {
197
+ path: string;
198
+ streams: string[];
199
+ }
200
+ export interface IsolationResult {
201
+ verdicts: Map<string, 'guilty' | 'innocent' | 'unknown'>;
202
+ fileOverlaps: FileOverlap[];
203
+ }
122
204
  /**
123
205
  * Isolate which stream(s) caused a verify failure by temporarily
124
206
  * reverting each stream's changes and re-running its verify commands.
125
207
  *
126
- * Returns a map of streamId → verdict:
127
- * - 'guilty': reverting this stream made verify pass
128
- * - 'innocent': reverting this stream didn't fix verify
129
- * - 'unknown': couldn't determine (interaction between streams)
208
+ * Returns an IsolationResult with:
209
+ * - verdicts: streamId → 'guilty' | 'innocent' | 'unknown'
210
+ * - fileOverlaps: files modified by multiple streams (diagnostic hint)
130
211
  */
131
- export declare function isolateVerifyFailure(projectDir: string, backups: StreamBackup[], failedVerifyMap: Map<string, string[]>): Promise<Map<string, 'guilty' | 'innocent' | 'unknown'>>;
212
+ export declare function isolateVerifyFailure(projectDir: string, backups: StreamBackup[], failedVerifyMap: Map<string, string[]>, options?: IsolationOptions): Promise<IsolationResult>;
132
213
  export {};