viagen 0.0.8 → 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/dist/index.js +8 -1
- package/dist/webpack.cjs +18 -2
- package/dist/webpack.js +26 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
1
8
|
// src/index.ts
|
|
2
9
|
import { readFileSync as readFileSync2 } from "fs";
|
|
3
10
|
import { dirname, join as join3 } from "path";
|
|
@@ -121,7 +128,7 @@ function readBody(req) {
|
|
|
121
128
|
}
|
|
122
129
|
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
130
|
function findClaudeBin() {
|
|
124
|
-
const _require = createRequire(import.meta.url);
|
|
131
|
+
const _require = typeof __require !== "undefined" ? __require : createRequire(import.meta.url);
|
|
125
132
|
const pkgPath = _require.resolve("@anthropic-ai/claude-code/package.json");
|
|
126
133
|
return pkgPath.replace("package.json", "cli.js");
|
|
127
134
|
}
|
package/dist/webpack.cjs
CHANGED
|
@@ -129,7 +129,7 @@ function readBody(req) {
|
|
|
129
129
|
}
|
|
130
130
|
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.`;
|
|
131
131
|
function findClaudeBin() {
|
|
132
|
-
const _require = (0, import_node_module.createRequire)(import_meta.url);
|
|
132
|
+
const _require = typeof require !== "undefined" ? require : (0, import_node_module.createRequire)(import_meta.url);
|
|
133
133
|
const pkgPath = _require.resolve("@anthropic-ai/claude-code/package.json");
|
|
134
134
|
return pkgPath.replace("package.json", "cli.js");
|
|
135
135
|
}
|
|
@@ -1310,11 +1310,27 @@ function setupViagen(devServer, options) {
|
|
|
1310
1310
|
position: options?.position ?? "bottom-right",
|
|
1311
1311
|
ui: options?.ui ?? true
|
|
1312
1312
|
};
|
|
1313
|
+
const projectRoot = process.cwd();
|
|
1313
1314
|
const env = {};
|
|
1315
|
+
const dotenvPath = (0, import_node_path2.join)(projectRoot, ".env");
|
|
1316
|
+
if ((0, import_node_fs2.existsSync)(dotenvPath)) {
|
|
1317
|
+
const content = (0, import_node_fs2.readFileSync)(dotenvPath, "utf-8");
|
|
1318
|
+
for (const line of content.split("\n")) {
|
|
1319
|
+
const trimmed = line.trim();
|
|
1320
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
1321
|
+
const eqIdx = trimmed.indexOf("=");
|
|
1322
|
+
if (eqIdx === -1) continue;
|
|
1323
|
+
const key = trimmed.slice(0, eqIdx).trim();
|
|
1324
|
+
let val = trimmed.slice(eqIdx + 1).trim();
|
|
1325
|
+
if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
|
|
1326
|
+
val = val.slice(1, -1);
|
|
1327
|
+
}
|
|
1328
|
+
env[key] = val;
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1314
1331
|
for (const [k, v] of Object.entries(process.env)) {
|
|
1315
1332
|
if (v !== void 0) env[k] = v;
|
|
1316
1333
|
}
|
|
1317
|
-
const projectRoot = process.cwd();
|
|
1318
1334
|
const claudeBin = findClaudeBin();
|
|
1319
1335
|
const logBuffer = new LogBuffer();
|
|
1320
1336
|
logBuffer.init(projectRoot);
|
package/dist/webpack.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
1
8
|
// src/webpack.ts
|
|
2
|
-
import { readFileSync } from "fs";
|
|
9
|
+
import { existsSync, readFileSync } from "fs";
|
|
3
10
|
import { dirname, join as join2 } from "path";
|
|
4
11
|
import { fileURLToPath } from "url";
|
|
5
12
|
|
|
@@ -103,7 +110,7 @@ function readBody(req) {
|
|
|
103
110
|
}
|
|
104
111
|
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.`;
|
|
105
112
|
function findClaudeBin() {
|
|
106
|
-
const _require = createRequire(import.meta.url);
|
|
113
|
+
const _require = typeof __require !== "undefined" ? __require : createRequire(import.meta.url);
|
|
107
114
|
const pkgPath = _require.resolve("@anthropic-ai/claude-code/package.json");
|
|
108
115
|
return pkgPath.replace("package.json", "cli.js");
|
|
109
116
|
}
|
|
@@ -1283,11 +1290,27 @@ function setupViagen(devServer, options) {
|
|
|
1283
1290
|
position: options?.position ?? "bottom-right",
|
|
1284
1291
|
ui: options?.ui ?? true
|
|
1285
1292
|
};
|
|
1293
|
+
const projectRoot = process.cwd();
|
|
1286
1294
|
const env = {};
|
|
1295
|
+
const dotenvPath = join2(projectRoot, ".env");
|
|
1296
|
+
if (existsSync(dotenvPath)) {
|
|
1297
|
+
const content = readFileSync(dotenvPath, "utf-8");
|
|
1298
|
+
for (const line of content.split("\n")) {
|
|
1299
|
+
const trimmed = line.trim();
|
|
1300
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
1301
|
+
const eqIdx = trimmed.indexOf("=");
|
|
1302
|
+
if (eqIdx === -1) continue;
|
|
1303
|
+
const key = trimmed.slice(0, eqIdx).trim();
|
|
1304
|
+
let val = trimmed.slice(eqIdx + 1).trim();
|
|
1305
|
+
if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
|
|
1306
|
+
val = val.slice(1, -1);
|
|
1307
|
+
}
|
|
1308
|
+
env[key] = val;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1287
1311
|
for (const [k, v] of Object.entries(process.env)) {
|
|
1288
1312
|
if (v !== void 0) env[k] = v;
|
|
1289
1313
|
}
|
|
1290
|
-
const projectRoot = process.cwd();
|
|
1291
1314
|
const claudeBin = findClaudeBin();
|
|
1292
1315
|
const logBuffer = new LogBuffer();
|
|
1293
1316
|
logBuffer.init(projectRoot);
|