viagen 0.0.4 → 0.0.8
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 +37 -3
- package/dist/cli.js +28 -2
- package/dist/index.d.ts +7 -1
- package/dist/index.js +465 -31
- package/dist/webpack.cjs +1443 -0
- package/dist/webpack.d.cts +62 -0
- package/dist/webpack.d.ts +62 -0
- package/dist/webpack.js +1415 -0
- package/package.json +23 -4
- package/site/.viagen/server.log +7 -7
- package/site/icon.png +0 -0
- package/site/icon.svg +2 -0
- package/site/index.html +196 -50
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# viagen
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A dev server plugin (Vite + webpack) and CLI tool that enables you to use Claude Code in a sandbox — instantly.
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
@@ -11,9 +11,11 @@ A Vite plugin and CLI tool that enables you to use Claude Code in a sandbox —
|
|
|
11
11
|
## Step 1 — Add viagen to your app
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
npm install viagen
|
|
14
|
+
npm install --save-dev viagen
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
### Vite
|
|
18
|
+
|
|
17
19
|
```ts
|
|
18
20
|
// vite.config.ts
|
|
19
21
|
import { defineConfig } from 'vite'
|
|
@@ -24,6 +26,22 @@ export default defineConfig({
|
|
|
24
26
|
})
|
|
25
27
|
```
|
|
26
28
|
|
|
29
|
+
### webpack
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
// webpack.config.js
|
|
33
|
+
const { setupViagen } = require('viagen/webpack')
|
|
34
|
+
|
|
35
|
+
module.exports = {
|
|
36
|
+
devServer: {
|
|
37
|
+
setupMiddlewares: (middlewares, devServer) => {
|
|
38
|
+
setupViagen(devServer)
|
|
39
|
+
return middlewares
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
27
45
|
## Step 2 — Setup
|
|
28
46
|
|
|
29
47
|
```bash
|
|
@@ -72,7 +90,10 @@ The default system prompt:
|
|
|
72
90
|
You are embedded in a Vite dev server as the "viagen" plugin. Your job is to
|
|
73
91
|
help build and modify the app. Files you edit will trigger Vite HMR
|
|
74
92
|
automatically. You can read .viagen/server.log to check recent Vite dev server
|
|
75
|
-
output (compile errors, HMR updates, warnings).
|
|
93
|
+
output (compile errors, HMR updates, warnings). When running in a sandbox with
|
|
94
|
+
git, the gh CLI is available and authenticated — you can create pull requests,
|
|
95
|
+
comment on issues, and manage releases. If Vercel credentials are set, you can
|
|
96
|
+
run "vercel deploy" to publish a preview and share the URL. Be concise.
|
|
76
97
|
```
|
|
77
98
|
|
|
78
99
|
Recent build errors are automatically appended to give Claude context about what went wrong. To customize the prompt, you can replace it entirely or extend the default:
|
|
@@ -89,6 +110,18 @@ viagen({
|
|
|
89
110
|
})
|
|
90
111
|
```
|
|
91
112
|
|
|
113
|
+
## webpack Options
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
setupViagen(devServer, {
|
|
117
|
+
position: 'bottom-right', // toggle button position
|
|
118
|
+
model: 'sonnet', // claude model
|
|
119
|
+
panelWidth: 420, // chat panel width in px
|
|
120
|
+
ui: true, // inject chat panel into pages
|
|
121
|
+
systemPrompt: '...', // custom system prompt
|
|
122
|
+
})
|
|
123
|
+
```
|
|
124
|
+
|
|
92
125
|
## API
|
|
93
126
|
|
|
94
127
|
Every viagen endpoint is available as an API. Build your own UI, integrate with CI, or script Claude from the command line.
|
|
@@ -99,6 +132,7 @@ POST /via/chat/reset — clear conversation history
|
|
|
99
132
|
GET /via/health — check API key status
|
|
100
133
|
GET /via/error — latest build error (if any)
|
|
101
134
|
GET /via/ui — standalone chat interface
|
|
135
|
+
GET /via/iframe — split view (app + chat side by side)
|
|
102
136
|
```
|
|
103
137
|
|
|
104
138
|
When `VIAGEN_AUTH_TOKEN` is set (always on in sandboxes), pass the token as a `Bearer` header or `?token=` query param.
|
package/dist/cli.js
CHANGED
|
@@ -76,7 +76,7 @@ async function deploySandbox(opts) {
|
|
|
76
76
|
"user.email",
|
|
77
77
|
opts.git.userEmail
|
|
78
78
|
]);
|
|
79
|
-
await sandbox2.runCommand("git", ["checkout", opts.git.branch]);
|
|
79
|
+
await sandbox2.runCommand("git", ["checkout", "-B", opts.git.branch]);
|
|
80
80
|
await sandbox2.runCommand("bash", [
|
|
81
81
|
"-c",
|
|
82
82
|
`echo 'https://x-access-token:${opts.git.token}@${extractHost(opts.git.remoteUrl)}' > ~/.git-credentials`
|
|
@@ -87,6 +87,18 @@ async function deploySandbox(opts) {
|
|
|
87
87
|
"credential.helper",
|
|
88
88
|
"store"
|
|
89
89
|
]);
|
|
90
|
+
await sandbox2.runCommand("bash", [
|
|
91
|
+
"-c",
|
|
92
|
+
"apt-get update -qq && apt-get install -y -qq gh > /dev/null 2>&1 || true"
|
|
93
|
+
]);
|
|
94
|
+
if (opts.vercel) {
|
|
95
|
+
await sandbox2.runCommand("npm", [
|
|
96
|
+
"install",
|
|
97
|
+
"-g",
|
|
98
|
+
"vercel",
|
|
99
|
+
"--silent"
|
|
100
|
+
]);
|
|
101
|
+
}
|
|
90
102
|
if (opts.overlayFiles && opts.overlayFiles.length > 0) {
|
|
91
103
|
await sandbox2.writeFiles(opts.overlayFiles);
|
|
92
104
|
}
|
|
@@ -96,7 +108,11 @@ async function deploySandbox(opts) {
|
|
|
96
108
|
await sandbox2.writeFiles(files);
|
|
97
109
|
}
|
|
98
110
|
}
|
|
99
|
-
const envLines = [
|
|
111
|
+
const envLines = [
|
|
112
|
+
`VIAGEN_AUTH_TOKEN=${token}`,
|
|
113
|
+
`VIAGEN_SESSION_START=${Math.floor(Date.now() / 1e3)}`,
|
|
114
|
+
`VIAGEN_SESSION_TIMEOUT=${(opts.timeoutMinutes ?? 30) * 60}`
|
|
115
|
+
];
|
|
100
116
|
if (opts.apiKey) {
|
|
101
117
|
envLines.push(`ANTHROPIC_API_KEY=${opts.apiKey}`);
|
|
102
118
|
} else if (opts.oauth) {
|
|
@@ -107,6 +123,11 @@ async function deploySandbox(opts) {
|
|
|
107
123
|
if (opts.git) {
|
|
108
124
|
envLines.push(`GITHUB_TOKEN=${opts.git.token}`);
|
|
109
125
|
}
|
|
126
|
+
if (opts.vercel) {
|
|
127
|
+
envLines.push(`VERCEL_TOKEN=${opts.vercel.token}`);
|
|
128
|
+
envLines.push(`VERCEL_ORG_ID=${opts.vercel.teamId}`);
|
|
129
|
+
envLines.push(`VERCEL_PROJECT_ID=${opts.vercel.projectId}`);
|
|
130
|
+
}
|
|
110
131
|
await sandbox2.writeFiles([
|
|
111
132
|
{
|
|
112
133
|
path: ".env",
|
|
@@ -697,6 +718,11 @@ async function sandbox(args) {
|
|
|
697
718
|
} : void 0,
|
|
698
719
|
git: deployGit,
|
|
699
720
|
overlayFiles,
|
|
721
|
+
vercel: env["VERCEL_TOKEN"] && env["VERCEL_TEAM_ID"] && env["VERCEL_PROJECT_ID"] ? {
|
|
722
|
+
token: env["VERCEL_TOKEN"],
|
|
723
|
+
teamId: env["VERCEL_TEAM_ID"],
|
|
724
|
+
projectId: env["VERCEL_PROJECT_ID"]
|
|
725
|
+
} : void 0,
|
|
700
726
|
timeoutMinutes
|
|
701
727
|
});
|
|
702
728
|
console.log("");
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
|
-
declare const DEFAULT_SYSTEM_PROMPT = "You are embedded in a Vite dev server as the \"viagen\" plugin. Your job is to help build and modify the app. Files you edit will trigger Vite HMR automatically. You can read .viagen/server.log to check recent Vite dev server output (compile errors, HMR updates, warnings). Be concise.";
|
|
3
|
+
declare const DEFAULT_SYSTEM_PROMPT = "You are embedded in a Vite dev server as the \"viagen\" plugin. Your job is to help build and modify the app. Files you edit will trigger Vite HMR automatically. You can read .viagen/server.log to check recent Vite dev server output (compile errors, HMR updates, warnings). When running in a sandbox with git, the gh CLI is available and authenticated \u2014 you can create pull requests, comment on issues, and manage releases. If Vercel credentials are set, you can run \"vercel deploy\" to publish a preview and share the URL. Be concise.";
|
|
4
4
|
|
|
5
5
|
interface GitInfo {
|
|
6
6
|
/** HTTPS remote URL (transformed from SSH if needed). */
|
|
@@ -32,6 +32,12 @@ interface DeploySandboxOptions {
|
|
|
32
32
|
path: string;
|
|
33
33
|
content: Buffer;
|
|
34
34
|
}[];
|
|
35
|
+
/** Vercel credentials for preview deploys from the sandbox. */
|
|
36
|
+
vercel?: {
|
|
37
|
+
token: string;
|
|
38
|
+
teamId: string;
|
|
39
|
+
projectId: string;
|
|
40
|
+
};
|
|
35
41
|
/** Sandbox timeout in minutes (default: 30, max depends on Vercel plan). */
|
|
36
42
|
timeoutMinutes?: number;
|
|
37
43
|
}
|