switchyard-ai 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +147 -0
- package/bin/switchyard-darwin-arm64 +0 -0
- package/bin/switchyard-linux-amd64 +0 -0
- package/bin/switchyard-windows-amd64.exe +0 -0
- package/bin/switchyard.js +63 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# switchyard-ai
|
|
2
|
+
|
|
3
|
+
> **Switchyard: The Routing, Cost & Safety Layer for AI Coding Agents**
|
|
4
|
+
|
|
5
|
+
Switchyard eliminates AI model routing inefficiencies, prevents destructive code modifications with pre-task Git Checkpoints, and enables Bring Your Own Key (BYOK) for zero server costs.
|
|
6
|
+
|
|
7
|
+
- Official Documentation: https://switchyard-docs--lukasdesouza.replit.app/
|
|
8
|
+
- GitHub Repository: https://github.com/LukasdeSouza/nexus-ai-gateway
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Installation & Quickstart
|
|
13
|
+
|
|
14
|
+
Run instantly with `npx` (no prerequisites, runs on Windows, macOS, and Linux):
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npx switchyard-ai
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or install globally to use the `switchyard` and `sy` commands from any terminal:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install -g switchyard-ai
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Verify installation:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
switchyard --help
|
|
30
|
+
# or use the fast alias:
|
|
31
|
+
sy --help
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Authentication & API Keys (BYOK)
|
|
37
|
+
|
|
38
|
+
### 1. Web Authentication (GitHub OAuth)
|
|
39
|
+
```bash
|
|
40
|
+
switchyard login
|
|
41
|
+
```
|
|
42
|
+
Opens your browser to authenticate and links your terminal session.
|
|
43
|
+
|
|
44
|
+
### 2. Bring Your Own Key (Zero Server Costs)
|
|
45
|
+
Configure your personal API keys so Switchyard routes directly through your quotas:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Configure Gemini
|
|
49
|
+
switchyard keys set gemini AIzaSyYourKeyHere
|
|
50
|
+
|
|
51
|
+
# Configure OpenAI
|
|
52
|
+
switchyard keys set openai sk-proj-YourKeyHere
|
|
53
|
+
|
|
54
|
+
# Configure Anthropic
|
|
55
|
+
switchyard keys set anthropic sk-ant-YourKeyHere
|
|
56
|
+
|
|
57
|
+
# Configure DeepSeek
|
|
58
|
+
switchyard keys set deepseek sk-YourKeyHere
|
|
59
|
+
|
|
60
|
+
# Inspect active keys status
|
|
61
|
+
switchyard keys
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Interactive Agent Chat (REPL)
|
|
67
|
+
|
|
68
|
+
Start an interactive coding session in any project repository:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
switchyard chat
|
|
72
|
+
# or simply:
|
|
73
|
+
sy
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Context Injection (@ Mentions)
|
|
77
|
+
Attach local codebase context into your prompt without manual copying:
|
|
78
|
+
- `@src/server.ts`: Injects the file with syntax-indexed line numbers.
|
|
79
|
+
- `@internal/storage/`: Injects directory structure and file sizes (skips `.git`, `node_modules`, `vendor`).
|
|
80
|
+
|
|
81
|
+
### Slash Commands
|
|
82
|
+
Control the agent live inside the chat prompt:
|
|
83
|
+
|
|
84
|
+
| Command | Short | Description |
|
|
85
|
+
|---|---|---|
|
|
86
|
+
| `/help` | | Show interactive command cheat sheet |
|
|
87
|
+
| `/policy <mode>` | `/pol` | Switch policy: `explain`, `plan`, `approve`, `safe-auto`, `autopilot` |
|
|
88
|
+
| `/preset <name>` | | Switch preset: `auto`, `explore`, `build`, `reason`, `review` |
|
|
89
|
+
| `/model <alias>` | | Pin to a specific model (e.g. `gpt-4o`, `claude-3-5-sonnet`) |
|
|
90
|
+
| `/budget <usd>` | | Set per-task hard spending limit in USD (e.g. `/budget 0.25`) |
|
|
91
|
+
| `/caveman on\|off` | | Toggle token-saver mode (reduces output tokens by 35-65%) |
|
|
92
|
+
| `/rollback` | | Instantly restore workspace to pre-task Git Checkpoint |
|
|
93
|
+
| `/stats` | | View session token spend, model calls, and savings vs baseline |
|
|
94
|
+
| `/whoami` | | Display current project ID and active API key |
|
|
95
|
+
| `/clear` | | Clear current conversation history |
|
|
96
|
+
| `/exit` | `/quit` | Exit the REPL |
|
|
97
|
+
|
|
98
|
+
### Keyboard Shortcuts
|
|
99
|
+
- `[Tab]` Key: Context-sensitive autocompletion for slash commands, policies, presets, and `@` file paths.
|
|
100
|
+
- `Up / Down Arrows`: Browse command history.
|
|
101
|
+
- `Ctrl + C`: Cancel current generation or prompt.
|
|
102
|
+
- `Ctrl + D`: Exit cleanly.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## One-Shot Task Runner
|
|
107
|
+
|
|
108
|
+
Execute tasks directly from your terminal or CI/CD scripts without entering the interactive shell:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Preview diffs before applying:
|
|
112
|
+
switchyard run --policy approve "Add input validation to @src/routes/auth.ts"
|
|
113
|
+
|
|
114
|
+
# Autonomous execution on feature branch:
|
|
115
|
+
switchyard run --policy autopilot "Generate unit tests for @pkg/calculator.go"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Remote Task Daemon (Cloud Dispatch)
|
|
121
|
+
|
|
122
|
+
Connect your local workspace to the Switchyard Web Dashboard. When you dispatch prompts from the web, your local daemon picks them up, edits code locally, and syncs diffs back:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
switchyard daemon
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Execution Policies
|
|
131
|
+
|
|
132
|
+
- **`explain`**: Read-only mode. Answers technical questions and generates snippets without modifying disk.
|
|
133
|
+
- **`plan`**: Dry-run mode. Generates architecture plans and preview diffs without writing files.
|
|
134
|
+
- **`approve`** *(Default)*: Displays unified diffs and prompts `[Y/n/s/a]` before writing to disk.
|
|
135
|
+
- **`safe-auto`**: Automatically applies edits, strictly blocking protected files (`.env*`, lockfiles, `.git/`).
|
|
136
|
+
- **`autopilot`**: Full multi-file autonomy with automatic Git Checkpoints for instant `/rollback`.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Links & Community
|
|
141
|
+
|
|
142
|
+
- Documentation: https://switchyard-docs--lukasdesouza.replit.app/
|
|
143
|
+
- GitHub: https://github.com/LukasdeSouza/nexus-ai-gateway
|
|
144
|
+
- Node.js SDK: `npm install switchyard-sdk`
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
License: MIT
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const os = require('os');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const { spawnSync } = require('child_process');
|
|
7
|
+
|
|
8
|
+
function getBinaryPath() {
|
|
9
|
+
const platform = os.platform();
|
|
10
|
+
const arch = os.arch();
|
|
11
|
+
|
|
12
|
+
let binaryName = '';
|
|
13
|
+
if (platform === 'win32') {
|
|
14
|
+
binaryName = 'switchyard-windows-amd64.exe';
|
|
15
|
+
} else if (platform === 'darwin') {
|
|
16
|
+
binaryName = arch === 'arm64' ? 'switchyard-darwin-arm64' : 'switchyard-darwin-amd64';
|
|
17
|
+
} else if (platform === 'linux') {
|
|
18
|
+
binaryName = 'switchyard-linux-amd64';
|
|
19
|
+
} else {
|
|
20
|
+
console.error(`[Switchyard] Unsupported platform: ${platform} (${arch})`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const binaryPath = path.join(__dirname, binaryName);
|
|
25
|
+
|
|
26
|
+
if (!fs.existsSync(binaryPath)) {
|
|
27
|
+
// Check fallback for local switchyard.exe or switchyard
|
|
28
|
+
const localFallback = path.join(__dirname, platform === 'win32' ? 'switchyard.exe' : 'switchyard');
|
|
29
|
+
if (fs.existsSync(localFallback)) {
|
|
30
|
+
return localFallback;
|
|
31
|
+
}
|
|
32
|
+
console.error(`[Switchyard] Error: Binary not found for ${platform}-${arch} at ${binaryPath}`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Ensure execution permissions on Unix
|
|
37
|
+
if (platform !== 'win32') {
|
|
38
|
+
try {
|
|
39
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
40
|
+
} catch (_) {}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return binaryPath;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function run() {
|
|
47
|
+
const binary = getBinaryPath();
|
|
48
|
+
const args = process.argv.slice(2);
|
|
49
|
+
|
|
50
|
+
const result = spawnSync(binary, args, {
|
|
51
|
+
stdio: 'inherit',
|
|
52
|
+
windowsHide: false,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (result.error) {
|
|
56
|
+
console.error(`[Switchyard] Failed to execute process: ${result.error.message}`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
process.exit(result.status ?? 0);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
run();
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "switchyard-ai",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Switchyard - The Routing, Cost & Safety Layer for AI Coding Agents",
|
|
5
|
+
"main": "./bin/switchyard.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"switchyard": "bin/switchyard.js",
|
|
8
|
+
"sy": "bin/switchyard.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"keywords": [
|
|
15
|
+
"switchyard",
|
|
16
|
+
"ai",
|
|
17
|
+
"coding-agent",
|
|
18
|
+
"router",
|
|
19
|
+
"gateway",
|
|
20
|
+
"llm",
|
|
21
|
+
"cli",
|
|
22
|
+
"anthropic",
|
|
23
|
+
"gemini",
|
|
24
|
+
"openai"
|
|
25
|
+
],
|
|
26
|
+
"author": "Lucas de Souza",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/LukasdeSouza/nexus-ai-gateway.git"
|
|
31
|
+
}
|
|
32
|
+
}
|