viagen 0.0.11 → 0.0.12

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
@@ -74,8 +74,17 @@ help build and modify the app. Files you edit will trigger Vite HMR
74
74
  automatically. You can read .viagen/server.log to check recent Vite dev server
75
75
  output (compile errors, HMR updates, warnings). When running in a sandbox with
76
76
  git, the gh CLI is available and authenticated — you can create pull requests,
77
- comment on issues, and manage releases. If Vercel credentials are set, you can
78
- run "vercel deploy" to publish a preview and share the URL. Be concise.
77
+ comment on issues, and manage releases.
78
+
79
+ Publishing workflow:
80
+ - If you are on a feature branch (not main/master): commit your changes, push
81
+ to the remote, and create a pull request using "gh pr create". Share the PR URL.
82
+ - If you are on main/master and Vercel credentials are set ($VERCEL_TOKEN):
83
+ commit, push, and run "vercel deploy" to publish a preview. Share the preview URL.
84
+ - Check your current branch with "git branch --show-current" before deciding
85
+ which workflow to use.
86
+
87
+ Be concise.
79
88
  ```
80
89
 
81
90
  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:
package/dist/cli.js CHANGED
@@ -140,6 +140,7 @@ async function deploySandbox(opts) {
140
140
  }
141
141
  if (opts.git) {
142
142
  envMap["GITHUB_TOKEN"] = opts.git.token;
143
+ envMap["VIAGEN_BRANCH"] = opts.git.branch;
143
144
  }
144
145
  if (opts.vercel) {
145
146
  envMap["VERCEL_TOKEN"] = opts.vercel.token;
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. If Vercel credentials are set, you can run \"vercel deploy\" to publish a preview and share the URL. 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.\n\nPublishing workflow:\n- If you are on a feature branch (not main/master): commit your changes, push to the remote, and create a pull request using \"gh pr create\". Share the PR URL.\n- If you are on main/master and Vercel credentials are set ($VERCEL_TOKEN): commit, push, and run \"vercel deploy\" to publish a preview. Share the preview URL.\n- Check your current branch with \"git branch --show-current\" before deciding which workflow to use.\n\nBe concise.";
4
4
 
5
5
  interface GitInfo {
6
6
  /** HTTPS remote URL (transformed from SSH if needed). */
package/dist/index.js CHANGED
@@ -63,6 +63,7 @@ function registerHealthRoutes(server, env, errorRef) {
63
63
  server.middlewares.use("/via/health", (_req, res) => {
64
64
  const configured = !!env["ANTHROPIC_API_KEY"] || !!env["CLAUDE_ACCESS_TOKEN"];
65
65
  const git = !!env["GITHUB_TOKEN"];
66
+ const branch = env["VIAGEN_BRANCH"] || null;
66
67
  const sessionStart = env["VIAGEN_SESSION_START"] ? parseInt(env["VIAGEN_SESSION_START"], 10) : null;
67
68
  const sessionTimeout = env["VIAGEN_SESSION_TIMEOUT"] ? parseInt(env["VIAGEN_SESSION_TIMEOUT"], 10) : null;
68
69
  const session = sessionStart && sessionTimeout ? {
@@ -72,10 +73,10 @@ function registerHealthRoutes(server, env, errorRef) {
72
73
  } : null;
73
74
  res.setHeader("Content-Type", "application/json");
74
75
  if (configured) {
75
- res.end(JSON.stringify({ status: "ok", configured: true, git, session }));
76
+ res.end(JSON.stringify({ status: "ok", configured: true, git, branch, session }));
76
77
  } else {
77
78
  res.end(
78
- JSON.stringify({ status: "error", configured: false, git, session })
79
+ JSON.stringify({ status: "error", configured: false, git, branch, session })
79
80
  );
80
81
  }
81
82
  });
@@ -119,7 +120,14 @@ function readBody(req) {
119
120
  req.on("error", reject);
120
121
  });
121
122
  }
122
- var 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.`;
123
+ var 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.
124
+
125
+ Publishing workflow:
126
+ - If you are on a feature branch (not main/master): commit your changes, push to the remote, and create a pull request using "gh pr create". Share the PR URL.
127
+ - If you are on main/master and Vercel credentials are set ($VERCEL_TOKEN): commit, push, and run "vercel deploy" to publish a preview. Share the preview URL.
128
+ - Check your current branch with "git branch --show-current" before deciding which workflow to use.
129
+
130
+ Be concise.`;
123
131
  function findClaudeBin() {
124
132
  const _require = createRequire(import.meta.url);
125
133
  const pkgPath = _require.resolve("@anthropic-ai/claude-code/package.json");
@@ -1132,7 +1140,11 @@ function buildUiHtml() {
1132
1140
  });
1133
1141
  publishBtn.addEventListener('click', function () {
1134
1142
  if (isStreaming) return;
1135
- inputEl.value = 'Commit all changes, push to the remote repository, and run vercel deploy to get a preview URL';
1143
+ if (publishBtn.dataset.branch && publishBtn.dataset.branch !== 'main' && publishBtn.dataset.branch !== 'master') {
1144
+ inputEl.value = 'Commit all changes, push to the remote branch, and create a pull request using gh pr create. Share the PR URL.';
1145
+ } else {
1146
+ inputEl.value = 'Commit all changes, push to the remote repository, and run vercel deploy to get a preview URL';
1147
+ }
1136
1148
  send();
1137
1149
  });
1138
1150
 
@@ -1182,7 +1194,10 @@ function buildUiHtml() {
1182
1194
  var banner = document.getElementById('setup-banner');
1183
1195
  if (data.configured) {
1184
1196
  dot.className = 'status-dot ok';
1185
- if (data.git) publishBtn.style.display = '';
1197
+ if (data.git) {
1198
+ publishBtn.style.display = '';
1199
+ if (data.branch) publishBtn.dataset.branch = data.branch;
1200
+ }
1186
1201
  } else {
1187
1202
  dot.className = 'status-dot error';
1188
1203
  inputEl.disabled = true;
@@ -1272,7 +1287,7 @@ function createAuthMiddleware(token) {
1272
1287
  const cleanUrl = url.pathname + (url.search || "");
1273
1288
  res.setHeader(
1274
1289
  "Set-Cookie",
1275
- `viagen_session=${token}; HttpOnly; SameSite=Strict; Path=/`
1290
+ `viagen_session=${token}; HttpOnly; SameSite=Lax; Path=/; Secure`
1276
1291
  );
1277
1292
  res.writeHead(302, { Location: cleanUrl });
1278
1293
  res.end();
@@ -1417,6 +1432,7 @@ async function deploySandbox(opts) {
1417
1432
  }
1418
1433
  if (opts.git) {
1419
1434
  envMap["GITHUB_TOKEN"] = opts.git.token;
1435
+ envMap["VIAGEN_BRANCH"] = opts.git.branch;
1420
1436
  }
1421
1437
  if (opts.vercel) {
1422
1438
  envMap["VERCEL_TOKEN"] = opts.vercel.token;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viagen",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "Vite dev server plugin that exposes endpoints for chatting with Claude Code SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/site/index.html CHANGED
@@ -458,8 +458,15 @@ will trigger Vite HMR automatically. You can read
458
458
  (compile errors, HMR updates, warnings). When running in a
459
459
  sandbox with git, the gh CLI is available and authenticated —
460
460
  you can create pull requests, comment on issues, and manage
461
- releases. If Vercel credentials are set, you can run
462
- "vercel deploy" to publish a preview and share the URL.
461
+ releases.
462
+
463
+ Publishing workflow:
464
+ - On a feature branch: commit, push, and create a pull
465
+ request using "gh pr create". Share the PR URL.
466
+ - On main/master with Vercel credentials: commit, push,
467
+ and run "vercel deploy" to publish a preview.
468
+ - Check your branch with "git branch --show-current" first.
469
+
463
470
  Be concise.</code></pre>
464
471
  <p
465
472
  style="