viagen 0.0.5 → 0.0.9

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
@@ -1,6 +1,6 @@
1
1
  # viagen
2
2
 
3
- A Vite plugin and CLI tool that enables you to use Claude Code in a sandbox — instantly.
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
 
@@ -14,6 +14,8 @@ A Vite plugin and CLI tool that enables you to use Claude Code in a sandbox —
14
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
@@ -74,7 +92,8 @@ 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
93
  output (compile errors, HMR updates, warnings). When running in a sandbox with
76
94
  git, the gh CLI is available and authenticated — you can create pull requests,
77
- comment on issues, and manage releases. Be concise.
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.
78
97
  ```
79
98
 
80
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:
@@ -91,6 +110,18 @@ viagen({
91
110
  })
92
111
  ```
93
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
+
94
125
  ## API
95
126
 
96
127
  Every viagen endpoint is available as an API. Build your own UI, integrate with CI, or script Claude from the command line.
@@ -101,6 +132,7 @@ POST /via/chat/reset — clear conversation history
101
132
  GET /via/health — check API key status
102
133
  GET /via/error — latest build error (if any)
103
134
  GET /via/ui — standalone chat interface
135
+ GET /via/iframe — split view (app + chat side by side)
104
136
  ```
105
137
 
106
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
@@ -91,6 +91,14 @@ async function deploySandbox(opts) {
91
91
  "-c",
92
92
  "apt-get update -qq && apt-get install -y -qq gh > /dev/null 2>&1 || true"
93
93
  ]);
94
+ if (opts.vercel) {
95
+ await sandbox2.runCommand("npm", [
96
+ "install",
97
+ "-g",
98
+ "vercel",
99
+ "--silent"
100
+ ]);
101
+ }
94
102
  if (opts.overlayFiles && opts.overlayFiles.length > 0) {
95
103
  await sandbox2.writeFiles(opts.overlayFiles);
96
104
  }
@@ -100,7 +108,11 @@ async function deploySandbox(opts) {
100
108
  await sandbox2.writeFiles(files);
101
109
  }
102
110
  }
103
- const envLines = [`VIAGEN_AUTH_TOKEN=${token}`];
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
+ ];
104
116
  if (opts.apiKey) {
105
117
  envLines.push(`ANTHROPIC_API_KEY=${opts.apiKey}`);
106
118
  } else if (opts.oauth) {
@@ -111,6 +123,11 @@ async function deploySandbox(opts) {
111
123
  if (opts.git) {
112
124
  envLines.push(`GITHUB_TOKEN=${opts.git.token}`);
113
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
+ }
114
131
  await sandbox2.writeFiles([
115
132
  {
116
133
  path: ".env",
@@ -701,6 +718,11 @@ async function sandbox(args) {
701
718
  } : void 0,
702
719
  git: deployGit,
703
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,
704
726
  timeoutMinutes
705
727
  });
706
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). 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. 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
  }