forge-cw 0.1.37 → 0.1.39
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/console/assets/index-BiJ7yYR0.css +1 -0
- package/console/assets/index-CHaA4O7s.js +31 -0
- package/console/index.html +2 -2
- package/console/shared/forge-dev-ui.js +9 -9
- package/dist/index.js +259 -91
- package/package.json +3 -3
- package/console/assets/index-CL35efIa.css +0 -1
- package/console/assets/index-Cgg7OkPv.js +0 -31
package/dist/index.js
CHANGED
|
@@ -7493,6 +7493,166 @@ var init_kioku_routes = __esm({
|
|
|
7493
7493
|
}
|
|
7494
7494
|
});
|
|
7495
7495
|
|
|
7496
|
+
// ../core/dist/voice.js
|
|
7497
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
7498
|
+
import { createWriteStream, existsSync as existsSync15 } from "node:fs";
|
|
7499
|
+
import { mkdir as mkdir2, rename, rm as rm2, writeFile } from "node:fs/promises";
|
|
7500
|
+
import { tmpdir } from "node:os";
|
|
7501
|
+
import { dirname as dirname7, join as join16 } from "node:path";
|
|
7502
|
+
function resolveWhisperBin(pathVar = process.env.PATH) {
|
|
7503
|
+
return findOnPath("whisper-cli", pathVar) ?? findOnPath("whisper-cpp", pathVar);
|
|
7504
|
+
}
|
|
7505
|
+
function validLanguage(language) {
|
|
7506
|
+
const value = (language ?? "auto").trim().toLowerCase() || "auto";
|
|
7507
|
+
if (!/^(auto|[a-z]{2,3})$/.test(value))
|
|
7508
|
+
throw new VoiceError(`unknown language: ${value}`);
|
|
7509
|
+
return value;
|
|
7510
|
+
}
|
|
7511
|
+
function cleanTranscript(stdout) {
|
|
7512
|
+
return stdout.replace(/\[[^\]]*\]/g, "").replace(/\s+/g, " ").trim();
|
|
7513
|
+
}
|
|
7514
|
+
var VOICE_MODEL, MODEL_URL, INSTALL_COMMAND, MAX_AUDIO_BYTES, VoiceError, tooLong, Voice;
|
|
7515
|
+
var init_voice = __esm({
|
|
7516
|
+
"../core/dist/voice.js"() {
|
|
7517
|
+
"use strict";
|
|
7518
|
+
init_cw_install();
|
|
7519
|
+
init_task_review();
|
|
7520
|
+
VOICE_MODEL = "small";
|
|
7521
|
+
MODEL_URL = `https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-${VOICE_MODEL}.bin`;
|
|
7522
|
+
INSTALL_COMMAND = "brew install whisper-cpp";
|
|
7523
|
+
MAX_AUDIO_BYTES = 10 * 1024 * 1024;
|
|
7524
|
+
VoiceError = class extends Error {
|
|
7525
|
+
status;
|
|
7526
|
+
constructor(message2, status = 400) {
|
|
7527
|
+
super(message2);
|
|
7528
|
+
this.status = status;
|
|
7529
|
+
}
|
|
7530
|
+
};
|
|
7531
|
+
tooLong = () => new VoiceError("the recording is too long");
|
|
7532
|
+
Voice = class {
|
|
7533
|
+
download = null;
|
|
7534
|
+
downloadError = null;
|
|
7535
|
+
// found once, then kept: the binary does not move while Forge runs
|
|
7536
|
+
binary = null;
|
|
7537
|
+
modelPath;
|
|
7538
|
+
pathVar;
|
|
7539
|
+
fetchImpl;
|
|
7540
|
+
run;
|
|
7541
|
+
constructor(options) {
|
|
7542
|
+
this.modelPath = options.modelPath;
|
|
7543
|
+
this.pathVar = options.pathVar;
|
|
7544
|
+
this.fetchImpl = options.fetch ?? fetch;
|
|
7545
|
+
this.run = options.run ?? createRunner(void 0, 12e4);
|
|
7546
|
+
}
|
|
7547
|
+
whisper() {
|
|
7548
|
+
this.binary ??= resolveWhisperBin(this.pathVar);
|
|
7549
|
+
return this.binary;
|
|
7550
|
+
}
|
|
7551
|
+
status() {
|
|
7552
|
+
const binary = this.whisper();
|
|
7553
|
+
const present = existsSync15(this.modelPath);
|
|
7554
|
+
return {
|
|
7555
|
+
ready: binary !== null && present,
|
|
7556
|
+
binary,
|
|
7557
|
+
install: INSTALL_COMMAND,
|
|
7558
|
+
model: { name: VOICE_MODEL, path: this.modelPath, present },
|
|
7559
|
+
download: this.download,
|
|
7560
|
+
downloadError: this.downloadError
|
|
7561
|
+
};
|
|
7562
|
+
}
|
|
7563
|
+
// starts the download in the background; status() reports its progress
|
|
7564
|
+
downloadModel() {
|
|
7565
|
+
if (!this.download && !existsSync15(this.modelPath)) {
|
|
7566
|
+
const progress = { received: 0, total: null };
|
|
7567
|
+
this.download = progress;
|
|
7568
|
+
this.downloadError = null;
|
|
7569
|
+
this.fetchModel(progress).catch((err) => {
|
|
7570
|
+
this.downloadError = err instanceof Error ? err.message : String(err);
|
|
7571
|
+
}).finally(() => {
|
|
7572
|
+
this.download = null;
|
|
7573
|
+
});
|
|
7574
|
+
}
|
|
7575
|
+
return this.status();
|
|
7576
|
+
}
|
|
7577
|
+
async fetchModel(progress) {
|
|
7578
|
+
const part = `${this.modelPath}.part`;
|
|
7579
|
+
await mkdir2(dirname7(this.modelPath), { recursive: true });
|
|
7580
|
+
const res = await this.fetchImpl(MODEL_URL);
|
|
7581
|
+
if (!res.ok || !res.body)
|
|
7582
|
+
throw new Error(`the model download answered ${res.status}`);
|
|
7583
|
+
const length = Number(res.headers.get("content-length"));
|
|
7584
|
+
progress.total = length > 0 ? length : null;
|
|
7585
|
+
const out = createWriteStream(part);
|
|
7586
|
+
try {
|
|
7587
|
+
const reader = res.body.getReader();
|
|
7588
|
+
for (; ; ) {
|
|
7589
|
+
const { done, value } = await reader.read();
|
|
7590
|
+
if (done)
|
|
7591
|
+
break;
|
|
7592
|
+
if (!out.write(value))
|
|
7593
|
+
await new Promise((resolve11) => out.once("drain", () => resolve11()));
|
|
7594
|
+
progress.received += value.byteLength;
|
|
7595
|
+
}
|
|
7596
|
+
await new Promise((resolve11, reject) => out.end((err) => err ? reject(err) : resolve11()));
|
|
7597
|
+
await rename(part, this.modelPath);
|
|
7598
|
+
} catch (err) {
|
|
7599
|
+
out.destroy();
|
|
7600
|
+
await rm2(part, { force: true });
|
|
7601
|
+
throw err;
|
|
7602
|
+
}
|
|
7603
|
+
}
|
|
7604
|
+
async transcribe(wav, language) {
|
|
7605
|
+
const lang = validLanguage(language);
|
|
7606
|
+
if (wav.byteLength === 0)
|
|
7607
|
+
throw new VoiceError("the recording is empty");
|
|
7608
|
+
if (wav.byteLength > MAX_AUDIO_BYTES)
|
|
7609
|
+
throw tooLong();
|
|
7610
|
+
const binary = this.whisper();
|
|
7611
|
+
if (!binary)
|
|
7612
|
+
throw new VoiceError(`whisper-cli is not installed: ${INSTALL_COMMAND}`, 409);
|
|
7613
|
+
if (!existsSync15(this.modelPath))
|
|
7614
|
+
throw new VoiceError(`the ${VOICE_MODEL} model is not downloaded`, 409);
|
|
7615
|
+
const file = join16(tmpdir(), `forge-voice-${randomUUID2()}.wav`);
|
|
7616
|
+
try {
|
|
7617
|
+
await writeFile(file, wav);
|
|
7618
|
+
const { code, stdout, stderr } = await this.run(binary, ["-m", this.modelPath, "-f", file, "-l", lang, "-nt", "-np"], tmpdir());
|
|
7619
|
+
if (code !== 0)
|
|
7620
|
+
throw new VoiceError(stderr.trim().split("\n").pop() || "whisper failed", 500);
|
|
7621
|
+
return cleanTranscript(stdout);
|
|
7622
|
+
} finally {
|
|
7623
|
+
await rm2(file, { force: true });
|
|
7624
|
+
}
|
|
7625
|
+
}
|
|
7626
|
+
};
|
|
7627
|
+
}
|
|
7628
|
+
});
|
|
7629
|
+
|
|
7630
|
+
// ../core/dist/voice-routes.js
|
|
7631
|
+
import { Hono as Hono5 } from "hono";
|
|
7632
|
+
function voiceRoutes(voice) {
|
|
7633
|
+
const app = new Hono5();
|
|
7634
|
+
app.onError((err, c) => {
|
|
7635
|
+
if (err instanceof VoiceError)
|
|
7636
|
+
return c.json({ error: err.message }, err.status);
|
|
7637
|
+
throw err;
|
|
7638
|
+
});
|
|
7639
|
+
app.get("/status", (c) => c.json(voice.status()));
|
|
7640
|
+
app.post("/model", (c) => c.json(voice.downloadModel()));
|
|
7641
|
+
app.post("/transcribe", async (c) => {
|
|
7642
|
+
if (Number(c.req.header("content-length")) > MAX_AUDIO_BYTES)
|
|
7643
|
+
throw tooLong();
|
|
7644
|
+
const wav = new Uint8Array(await c.req.arrayBuffer());
|
|
7645
|
+
return c.json({ text: await voice.transcribe(wav, c.req.query("language")) });
|
|
7646
|
+
});
|
|
7647
|
+
return app;
|
|
7648
|
+
}
|
|
7649
|
+
var init_voice_routes = __esm({
|
|
7650
|
+
"../core/dist/voice-routes.js"() {
|
|
7651
|
+
"use strict";
|
|
7652
|
+
init_voice();
|
|
7653
|
+
}
|
|
7654
|
+
});
|
|
7655
|
+
|
|
7496
7656
|
// ../sdk/dist/define.js
|
|
7497
7657
|
function isShellExecutor(run2) {
|
|
7498
7658
|
return typeof run2 === "object" && run2 !== null && run2.kind === "shell";
|
|
@@ -7543,7 +7703,7 @@ var init_dist = __esm({
|
|
|
7543
7703
|
|
|
7544
7704
|
// ../core/dist/module-permissions.js
|
|
7545
7705
|
import { realpathSync } from "node:fs";
|
|
7546
|
-
import { basename as basename3, dirname as
|
|
7706
|
+
import { basename as basename3, dirname as dirname8, join as join17, resolve as resolve5, sep as sep3 } from "node:path";
|
|
7547
7707
|
function expandGrants(permissions, settings) {
|
|
7548
7708
|
const p = permissions ?? {};
|
|
7549
7709
|
return {
|
|
@@ -7624,8 +7784,8 @@ function realOrParent(path) {
|
|
|
7624
7784
|
try {
|
|
7625
7785
|
return realpathSync(path);
|
|
7626
7786
|
} catch {
|
|
7627
|
-
const parent =
|
|
7628
|
-
return parent === path ? path :
|
|
7787
|
+
const parent = dirname8(path);
|
|
7788
|
+
return parent === path ? path : join17(realOrParent(parent), basename3(path));
|
|
7629
7789
|
}
|
|
7630
7790
|
}
|
|
7631
7791
|
var TEMPLATE_RE;
|
|
@@ -7639,7 +7799,7 @@ var init_module_permissions = __esm({
|
|
|
7639
7799
|
|
|
7640
7800
|
// ../core/dist/module-manifest.js
|
|
7641
7801
|
import { readFileSync as readFileSync11 } from "node:fs";
|
|
7642
|
-
import { join as
|
|
7802
|
+
import { join as join18, resolve as resolve6, sep as sep4 } from "node:path";
|
|
7643
7803
|
function checkSdk(range, version = SDK_VERSION) {
|
|
7644
7804
|
if (!import_semver2.default.validRange(range))
|
|
7645
7805
|
return `sdk range "${range}" is not valid semver`;
|
|
@@ -7754,11 +7914,11 @@ function insideFolder(dir, relative) {
|
|
|
7754
7914
|
}
|
|
7755
7915
|
function manifestFileFor(dir) {
|
|
7756
7916
|
try {
|
|
7757
|
-
const pkg = JSON.parse(readFileSync11(
|
|
7917
|
+
const pkg = JSON.parse(readFileSync11(join18(dir, "package.json"), "utf-8"));
|
|
7758
7918
|
const manifest = typeof pkg.forge?.manifest === "string" ? pkg.forge.manifest : "forge-module.json";
|
|
7759
|
-
return { file:
|
|
7919
|
+
return { file: join18(dir, manifest), hasForgeField: pkg.forge !== void 0 };
|
|
7760
7920
|
} catch {
|
|
7761
|
-
return { file:
|
|
7921
|
+
return { file: join18(dir, "forge-module.json"), hasForgeField: false };
|
|
7762
7922
|
}
|
|
7763
7923
|
}
|
|
7764
7924
|
function validateSettings(schema, values) {
|
|
@@ -7843,7 +8003,7 @@ var init_module_manifest = __esm({
|
|
|
7843
8003
|
});
|
|
7844
8004
|
|
|
7845
8005
|
// ../core/dist/module-context.js
|
|
7846
|
-
import { readFile, readdir, writeFile } from "node:fs/promises";
|
|
8006
|
+
import { readFile, readdir, writeFile as writeFile2 } from "node:fs/promises";
|
|
7847
8007
|
import { homedir as homedir6 } from "node:os";
|
|
7848
8008
|
function createForgeContext(deps, mod, getSettings, getGrants, onDenial) {
|
|
7849
8009
|
const doFetch = deps.fetch ?? globalThis.fetch;
|
|
@@ -7943,7 +8103,7 @@ function createForgeContext(deps, mod, getSettings, getGrants, onDenial) {
|
|
|
7943
8103
|
},
|
|
7944
8104
|
write: async (path, data) => {
|
|
7945
8105
|
await checkPath("fs:write", path);
|
|
7946
|
-
await
|
|
8106
|
+
await writeFile2(expandHome(path), data);
|
|
7947
8107
|
}
|
|
7948
8108
|
},
|
|
7949
8109
|
shell: {
|
|
@@ -8012,15 +8172,15 @@ var init_module_context = __esm({
|
|
|
8012
8172
|
});
|
|
8013
8173
|
|
|
8014
8174
|
// ../core/dist/module-host.js
|
|
8015
|
-
import { existsSync as
|
|
8016
|
-
import { basename as basename4, dirname as
|
|
8175
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync6, readdirSync as readdirSync7, readFileSync as readFileSync12, statSync as statSync4, writeFileSync as writeFileSync7 } from "node:fs";
|
|
8176
|
+
import { basename as basename4, dirname as dirname9, join as join19, resolve as resolve7, sep as sep5 } from "node:path";
|
|
8017
8177
|
import { pathToFileURL } from "node:url";
|
|
8018
8178
|
function disabled(id, c, reason, m) {
|
|
8019
8179
|
const text2 = (v, fallback) => typeof v === "string" && v ? v : fallback;
|
|
8020
8180
|
return { id, name: text2(m?.name, id), version: text2(m?.version, ""), displayName: text2(m?.displayName, id), source: c.source, state: "disabled", reason };
|
|
8021
8181
|
}
|
|
8022
8182
|
function packages(root, source, packaged) {
|
|
8023
|
-
if (!
|
|
8183
|
+
if (!existsSync16(root))
|
|
8024
8184
|
return [];
|
|
8025
8185
|
const out = [];
|
|
8026
8186
|
const consider = (dir, name) => {
|
|
@@ -8033,27 +8193,27 @@ function packages(root, source, packaged) {
|
|
|
8033
8193
|
if (!isDir(root, entry) || entry.name.startsWith("."))
|
|
8034
8194
|
continue;
|
|
8035
8195
|
if (entry.name.startsWith("@")) {
|
|
8036
|
-
for (const sub of readdirSync7(
|
|
8037
|
-
if (isDir(
|
|
8038
|
-
consider(
|
|
8196
|
+
for (const sub of readdirSync7(join19(root, entry.name), { withFileTypes: true })) {
|
|
8197
|
+
if (isDir(join19(root, entry.name), sub))
|
|
8198
|
+
consider(join19(root, entry.name, sub.name), `${entry.name}/${sub.name}`);
|
|
8039
8199
|
}
|
|
8040
8200
|
} else {
|
|
8041
|
-
consider(
|
|
8201
|
+
consider(join19(root, entry.name), entry.name);
|
|
8042
8202
|
}
|
|
8043
8203
|
}
|
|
8044
8204
|
return out;
|
|
8045
8205
|
}
|
|
8046
8206
|
function nearestPackage(dir) {
|
|
8047
|
-
for (let d = dir; ; d =
|
|
8048
|
-
const path =
|
|
8049
|
-
if (
|
|
8207
|
+
for (let d = dir; ; d = dirname9(d)) {
|
|
8208
|
+
const path = join19(d, "package.json");
|
|
8209
|
+
if (existsSync16(path)) {
|
|
8050
8210
|
try {
|
|
8051
8211
|
return { path, type: JSON.parse(readFileSync12(path, "utf-8")).type };
|
|
8052
8212
|
} catch {
|
|
8053
8213
|
return { path };
|
|
8054
8214
|
}
|
|
8055
8215
|
}
|
|
8056
|
-
if (
|
|
8216
|
+
if (dirname9(d) === d)
|
|
8057
8217
|
return null;
|
|
8058
8218
|
}
|
|
8059
8219
|
}
|
|
@@ -8063,7 +8223,7 @@ function isDir(parent, entry) {
|
|
|
8063
8223
|
if (!entry.isSymbolicLink())
|
|
8064
8224
|
return false;
|
|
8065
8225
|
try {
|
|
8066
|
-
return statSync4(
|
|
8226
|
+
return statSync4(join19(parent, entry.name)).isDirectory();
|
|
8067
8227
|
} catch {
|
|
8068
8228
|
return false;
|
|
8069
8229
|
}
|
|
@@ -8112,7 +8272,7 @@ var init_module_host = __esm({
|
|
|
8112
8272
|
bannersFile;
|
|
8113
8273
|
constructor(opts) {
|
|
8114
8274
|
this.opts = opts;
|
|
8115
|
-
this.bannersFile =
|
|
8275
|
+
this.bannersFile = join19(dirname9(opts.devFile), "module-banners.json");
|
|
8116
8276
|
}
|
|
8117
8277
|
list() {
|
|
8118
8278
|
return this.statuses;
|
|
@@ -8128,7 +8288,7 @@ var init_module_host = __esm({
|
|
|
8128
8288
|
// only what was installed into the modules folder; bundled, dev and Forge's own packages stay
|
|
8129
8289
|
removable(c) {
|
|
8130
8290
|
const { modulesDir } = this.opts;
|
|
8131
|
-
return c.source === "installed" &&
|
|
8291
|
+
return c.source === "installed" && dirname9(c.dir) === modulesDir || c.dir.startsWith(join19(modulesDir, "node_modules") + sep5);
|
|
8132
8292
|
}
|
|
8133
8293
|
// scans, reloads and dev changes run one at a time: each one awaits imports midway
|
|
8134
8294
|
queue = Promise.resolve();
|
|
@@ -8239,7 +8399,7 @@ var init_module_host = __esm({
|
|
|
8239
8399
|
const banner = this.loaded.get(id)?.status.banner;
|
|
8240
8400
|
if (!banner)
|
|
8241
8401
|
return;
|
|
8242
|
-
mkdirSync6(
|
|
8402
|
+
mkdirSync6(dirname9(this.bannersFile), { recursive: true });
|
|
8243
8403
|
writeFileSync7(this.bannersFile, JSON.stringify({ ...this.readBanners(), [id]: enabled }, null, 2));
|
|
8244
8404
|
banner.enabled = enabled;
|
|
8245
8405
|
}
|
|
@@ -8253,18 +8413,18 @@ var init_module_host = __esm({
|
|
|
8253
8413
|
}
|
|
8254
8414
|
candidates() {
|
|
8255
8415
|
const out = [];
|
|
8256
|
-
const folder = (dir, source) => out.push({ dir, source, manifestFile:
|
|
8416
|
+
const folder = (dir, source) => out.push({ dir, source, manifestFile: join19(dir, "forge-module.json"), packaged: false });
|
|
8257
8417
|
if (this.opts.bundledDir)
|
|
8258
8418
|
for (const name of [...BUNDLED_MODULES, ...BUNDLED_V1_MODULES])
|
|
8259
|
-
folder(
|
|
8419
|
+
folder(join19(this.opts.bundledDir, name), "bundled");
|
|
8260
8420
|
for (const dir of this.devDirs())
|
|
8261
8421
|
folder(dir, "dev");
|
|
8262
|
-
if (
|
|
8422
|
+
if (existsSync16(this.opts.modulesDir)) {
|
|
8263
8423
|
for (const entry of readdirSync7(this.opts.modulesDir, { withFileTypes: true })) {
|
|
8264
8424
|
if (entry.isDirectory() && entry.name !== "node_modules" && !entry.name.startsWith("."))
|
|
8265
|
-
folder(
|
|
8425
|
+
folder(join19(this.opts.modulesDir, entry.name), "installed");
|
|
8266
8426
|
}
|
|
8267
|
-
out.push(...packages(
|
|
8427
|
+
out.push(...packages(join19(this.opts.modulesDir, "node_modules"), "node_modules", true));
|
|
8268
8428
|
}
|
|
8269
8429
|
if (this.opts.forgeNodeModules)
|
|
8270
8430
|
out.push(...packages(this.opts.forgeNodeModules, "node_modules", false));
|
|
@@ -8278,7 +8438,7 @@ var init_module_host = __esm({
|
|
|
8278
8438
|
}
|
|
8279
8439
|
async loadCandidate(c, seen) {
|
|
8280
8440
|
const fallbackId = basename4(c.dir);
|
|
8281
|
-
if (!
|
|
8441
|
+
if (!existsSync16(c.manifestFile)) {
|
|
8282
8442
|
return c.packaged ? disabled(fallbackId, c, `no manifest at ${c.manifestFile}`) : void 0;
|
|
8283
8443
|
}
|
|
8284
8444
|
let raw;
|
|
@@ -8305,7 +8465,7 @@ var init_module_host = __esm({
|
|
|
8305
8465
|
let server;
|
|
8306
8466
|
if (m.server) {
|
|
8307
8467
|
const file = resolve7(c.dir, m.server);
|
|
8308
|
-
const owner = file.endsWith(".js") ? nearestPackage(
|
|
8468
|
+
const owner = file.endsWith(".js") ? nearestPackage(dirname9(file)) : null;
|
|
8309
8469
|
if (owner?.type === "commonjs")
|
|
8310
8470
|
return disabled(m.id, c, `${m.server} is an ES module but ${owner.path} says "type": "commonjs"; add "type": "module" to the module's package.json`, m);
|
|
8311
8471
|
try {
|
|
@@ -8333,12 +8493,12 @@ var init_module_host = __esm({
|
|
|
8333
8493
|
};
|
|
8334
8494
|
if (m.view) {
|
|
8335
8495
|
const entry = resolve7(c.dir, m.view.entry);
|
|
8336
|
-
const mtime =
|
|
8496
|
+
const mtime = existsSync16(entry) ? Math.floor(statSync4(entry).mtimeMs) : 0;
|
|
8337
8497
|
status.view = { url: `/api/modules/${m.id}/view.js`, title: m.view.title ?? m.displayName, version: `${m.version}-${mtime}` };
|
|
8338
8498
|
}
|
|
8339
8499
|
if (m.view?.banner) {
|
|
8340
8500
|
const file = resolve7(c.dir, m.view.banner);
|
|
8341
|
-
const mtime =
|
|
8501
|
+
const mtime = existsSync16(file) ? Math.floor(statSync4(file).mtimeMs) : 0;
|
|
8342
8502
|
status.banner = { url: `/api/modules/${m.id}/banner.js`, version: mtime, enabled: this.readBanners()[m.id] ?? c.source === "bundled" };
|
|
8343
8503
|
}
|
|
8344
8504
|
const settings = this.readSettings(m);
|
|
@@ -8423,13 +8583,13 @@ var init_module_confirmations = __esm({
|
|
|
8423
8583
|
|
|
8424
8584
|
// ../core/dist/module-install.js
|
|
8425
8585
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
8426
|
-
import { existsSync as
|
|
8427
|
-
import { homedir as homedir7, tmpdir } from "node:os";
|
|
8428
|
-
import { isAbsolute as isAbsolute2, join as
|
|
8586
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync7, mkdtempSync, readFileSync as readFileSync13, rmSync as rmSync4 } from "node:fs";
|
|
8587
|
+
import { homedir as homedir7, tmpdir as tmpdir2 } from "node:os";
|
|
8588
|
+
import { isAbsolute as isAbsolute2, join as join20, resolve as resolve8, sep as sep6 } from "node:path";
|
|
8429
8589
|
async function previewManifest(spec, opts) {
|
|
8430
8590
|
if (isPathSpec(spec, opts.cwd))
|
|
8431
8591
|
return readFolder(expand(spec, opts.cwd));
|
|
8432
|
-
const tmp = mkdtempSync(
|
|
8592
|
+
const tmp = mkdtempSync(join20(tmpdir2(), "forge-module-pack-"));
|
|
8433
8593
|
try {
|
|
8434
8594
|
const packed = await opts.run("npm", ["pack", spec, "--pack-destination", tmp, "--ignore-scripts", "--json"], opts.cwd);
|
|
8435
8595
|
if (packed.code !== 0)
|
|
@@ -8438,10 +8598,10 @@ async function previewManifest(spec, opts) {
|
|
|
8438
8598
|
const filename = info?.filename;
|
|
8439
8599
|
if (!filename)
|
|
8440
8600
|
throw new Error(`npm pack ${spec} produced no tarball`);
|
|
8441
|
-
const untar = await opts.run("tar", ["-xzf",
|
|
8601
|
+
const untar = await opts.run("tar", ["-xzf", join20(tmp, filename), "-C", tmp], opts.cwd);
|
|
8442
8602
|
if (untar.code !== 0)
|
|
8443
8603
|
throw new Error(`could not unpack ${filename}: ${untar.stderr.trim()}`);
|
|
8444
|
-
const preview = readFolder(
|
|
8604
|
+
const preview = readFolder(join20(tmp, "package"));
|
|
8445
8605
|
return info.name && info.version ? { ...preview, packed: { name: info.name, version: info.version } } : preview;
|
|
8446
8606
|
} finally {
|
|
8447
8607
|
rmSync4(tmp, { recursive: true, force: true });
|
|
@@ -8455,7 +8615,7 @@ function npmPackError(spec, output) {
|
|
|
8455
8615
|
}
|
|
8456
8616
|
function readFolder(dir) {
|
|
8457
8617
|
const manifestFile = manifestFileFor(dir).file;
|
|
8458
|
-
if (!
|
|
8618
|
+
if (!existsSync17(manifestFile))
|
|
8459
8619
|
throw new Error(`${dir} has no forge-module.json`);
|
|
8460
8620
|
const raw = JSON.parse(readFileSync13(manifestFile, "utf-8"));
|
|
8461
8621
|
const check = checkManifest(raw, dir);
|
|
@@ -8490,7 +8650,7 @@ function installArgs(spec, prefix) {
|
|
|
8490
8650
|
}
|
|
8491
8651
|
function packageName(dir) {
|
|
8492
8652
|
try {
|
|
8493
|
-
const name = JSON.parse(readFileSync13(
|
|
8653
|
+
const name = JSON.parse(readFileSync13(join20(dir, "package.json"), "utf-8")).name;
|
|
8494
8654
|
return typeof name === "string" ? name : void 0;
|
|
8495
8655
|
} catch {
|
|
8496
8656
|
return void 0;
|
|
@@ -8504,7 +8664,7 @@ var init_module_install = __esm({
|
|
|
8504
8664
|
init_output();
|
|
8505
8665
|
init_state_log();
|
|
8506
8666
|
TRUST_NOTE = "Modules run inside Forge with your access. Forge checks every call against these permissions, but it is not a sandbox: install only modules you trust.";
|
|
8507
|
-
isPathSpec = (spec, cwd) => spec.startsWith(".") || spec.startsWith("~") || isAbsolute2(spec) ||
|
|
8667
|
+
isPathSpec = (spec, cwd) => spec.startsWith(".") || spec.startsWith("~") || isAbsolute2(spec) || existsSync17(resolve8(cwd, spec)) && !spec.startsWith("@");
|
|
8508
8668
|
expand = (spec, cwd) => resolve8(cwd, expandHome(spec));
|
|
8509
8669
|
InstallError = class extends Error {
|
|
8510
8670
|
code;
|
|
@@ -8577,7 +8737,7 @@ var init_module_install = __esm({
|
|
|
8577
8737
|
throw new InstallError("not_found", `No module ${id}`);
|
|
8578
8738
|
if (!found.removable)
|
|
8579
8739
|
throw new InstallError("bad_request", `${id} was not installed into Forge's modules folder; a dev folder unloads when forge module dev stops`);
|
|
8580
|
-
const packages2 =
|
|
8740
|
+
const packages2 = join20(this.opts.modulesDir, "node_modules") + sep6;
|
|
8581
8741
|
if (found.dir.startsWith(packages2)) {
|
|
8582
8742
|
const name = packageName(found.dir) ?? found.dir.slice(packages2.length);
|
|
8583
8743
|
const res = await this.opts.run("npm", ["uninstall", "--prefix", this.opts.modulesDir, name], this.opts.modulesDir);
|
|
@@ -8606,11 +8766,11 @@ var init_module_install = __esm({
|
|
|
8606
8766
|
// ../core/dist/module-routes.js
|
|
8607
8767
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
8608
8768
|
import { resolve as resolve9 } from "node:path";
|
|
8609
|
-
import { Hono as
|
|
8769
|
+
import { Hono as Hono6 } from "hono";
|
|
8610
8770
|
function moduleRoutes(host, opts) {
|
|
8611
8771
|
const { db } = opts;
|
|
8612
8772
|
const confirmations = opts.confirmations ?? new Confirmations();
|
|
8613
|
-
const app = new
|
|
8773
|
+
const app = new Hono6();
|
|
8614
8774
|
app.use("*", async (_c, next) => {
|
|
8615
8775
|
await opts.ready;
|
|
8616
8776
|
await next();
|
|
@@ -9015,14 +9175,14 @@ var init_module_cw = __esm({
|
|
|
9015
9175
|
|
|
9016
9176
|
// ../core/dist/agent-runner.js
|
|
9017
9177
|
import { spawn as nodeSpawn } from "node:child_process";
|
|
9018
|
-
import { existsSync as
|
|
9019
|
-
import { tmpdir as
|
|
9020
|
-
import { join as
|
|
9178
|
+
import { existsSync as existsSync18, mkdtempSync as mkdtempSync2, rmSync as rmSync5 } from "node:fs";
|
|
9179
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
9180
|
+
import { join as join21 } from "node:path";
|
|
9021
9181
|
function runAgent(input, o) {
|
|
9022
9182
|
if (!ACCOUNT_NAME_RE.test(input.account))
|
|
9023
9183
|
return Promise.reject(new ModuleError("bad_request", "Invalid account"));
|
|
9024
|
-
const configDir =
|
|
9025
|
-
if (!
|
|
9184
|
+
const configDir = join21(o.cwHome, "accounts", input.account);
|
|
9185
|
+
if (!existsSync18(configDir))
|
|
9026
9186
|
return Promise.reject(new ModuleError("not_found", `Unknown account ${input.account}`));
|
|
9027
9187
|
const bad = input.allowedTools.find((tool) => !tool.startsWith("mcp__"));
|
|
9028
9188
|
if (bad !== void 0)
|
|
@@ -9034,7 +9194,7 @@ function runAgent(input, o) {
|
|
|
9034
9194
|
args.push("--allowedTools", input.allowedTools.join(","), "--output-format", "json");
|
|
9035
9195
|
const spawn9 = o.spawn ?? nodeSpawn;
|
|
9036
9196
|
const timeoutMs = input.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
9037
|
-
const cwd = mkdtempSync2(
|
|
9197
|
+
const cwd = mkdtempSync2(join21(tmpdir3(), "forge-agent-"));
|
|
9038
9198
|
const cleanup = () => rmSync5(cwd, { recursive: true, force: true });
|
|
9039
9199
|
return new Promise((resolve11, reject) => {
|
|
9040
9200
|
const child = spawn9("claude", args, { cwd, env: { ...envForAgent(), CLAUDE_CONFIG_DIR: configDir, ...CONNECTOR_ENV }, stdio: ["pipe", "pipe", "pipe"] });
|
|
@@ -9222,10 +9382,10 @@ var init_module_events = __esm({
|
|
|
9222
9382
|
});
|
|
9223
9383
|
|
|
9224
9384
|
// ../core/dist/server.js
|
|
9225
|
-
import { Hono as
|
|
9385
|
+
import { Hono as Hono7 } from "hono";
|
|
9226
9386
|
import { cors } from "hono/cors";
|
|
9227
|
-
import { join as
|
|
9228
|
-
import { readdirSync as readdirSync8, existsSync as
|
|
9387
|
+
import { join as join22, basename as basename5, resolve as resolve10 } from "node:path";
|
|
9388
|
+
import { readdirSync as readdirSync8, existsSync as existsSync19 } from "node:fs";
|
|
9229
9389
|
function parseHookEvent(raw) {
|
|
9230
9390
|
let body2 = {};
|
|
9231
9391
|
if (raw.length <= HOOK_BODY_MAX) {
|
|
@@ -9256,13 +9416,13 @@ function createForgeServer(options) {
|
|
|
9256
9416
|
const authProblem = remoteAuthProblem(localOnly, authToken);
|
|
9257
9417
|
if (authProblem)
|
|
9258
9418
|
throw new Error(authProblem);
|
|
9259
|
-
const dbPath =
|
|
9260
|
-
const modulesDir =
|
|
9419
|
+
const dbPath = join22(dataDir, "forge.db");
|
|
9420
|
+
const modulesDir = join22(dataDir, "modules");
|
|
9261
9421
|
const db = externalDb ?? new ForgeDB(dbPath);
|
|
9262
9422
|
const loader = new ModuleLoader(modulesDir, options.bundledModulesDir);
|
|
9263
9423
|
const runner = new ActionRunner();
|
|
9264
9424
|
loader.discover();
|
|
9265
|
-
const app = new
|
|
9425
|
+
const app = new Hono7();
|
|
9266
9426
|
app.use("*", localOnly ? localOriginGuard() : cors());
|
|
9267
9427
|
app.use("*", async (c, next) => {
|
|
9268
9428
|
await next();
|
|
@@ -9274,10 +9434,10 @@ function createForgeServer(options) {
|
|
|
9274
9434
|
mountAuthRoute(app, authToken);
|
|
9275
9435
|
}
|
|
9276
9436
|
const cwReader = new CWReader(options.cwDir);
|
|
9277
|
-
const generalSessions = new GeneralSessions(
|
|
9437
|
+
const generalSessions = new GeneralSessions(join22(dataDir, "general-sessions.json"));
|
|
9278
9438
|
const loginManager = new LoginManager(resolveCwBin(cwReader.cwHome));
|
|
9279
9439
|
app.route("/api/cw", cwRoutes(cwReader, { loginManager, localOnly, general: generalSessions, killSession: (key) => ptyManager.kill(key), events: { emit: (name, payload) => moduleEvents.emit(name, payload) } }));
|
|
9280
|
-
app.route("/api/skills", skillRoutes(cwReader, { backupDir:
|
|
9440
|
+
app.route("/api/skills", skillRoutes(cwReader, { backupDir: join22(dataDir, "skill-backups") }));
|
|
9281
9441
|
const { remote, shadow, warning } = remoteClassifierFromEnv();
|
|
9282
9442
|
if (warning)
|
|
9283
9443
|
console.warn(`[state] ${warning}`);
|
|
@@ -9296,10 +9456,11 @@ function createForgeServer(options) {
|
|
|
9296
9456
|
lastStateError = err.message;
|
|
9297
9457
|
}
|
|
9298
9458
|
});
|
|
9299
|
-
const hooks = new ClaudeHooks({ dir:
|
|
9459
|
+
const hooks = new ClaudeHooks({ dir: join22(dataDir, "hooks"), cwHome: cwReader.cwHome, warn: (message2) => console.warn(message2) });
|
|
9300
9460
|
const ptyManager = new PTYManager(states, hooks);
|
|
9301
9461
|
const terminalWss = createTerminalWss(ptyManager, cwReader, { localOnly, authToken, general: generalSessions });
|
|
9302
9462
|
app.route("/api/liveframe", liveframeRoutes());
|
|
9463
|
+
app.route("/api/voice", voiceRoutes(new Voice({ modelPath: process.env.FORGE_WHISPER_MODEL || join22(dataDir, "models", "ggml-small.bin") })));
|
|
9303
9464
|
const kioku = new Kioku({ projects: () => cwReader.getProjects(), pluginInstalls: () => installsOf(cwReader, "kioku") });
|
|
9304
9465
|
app.route("/api/kioku", kiokuRoutes(kioku, {
|
|
9305
9466
|
type: (project, sessionDir, text2) => ptyManager.typeLine(project, sessionDir, text2),
|
|
@@ -9331,7 +9492,7 @@ function createForgeServer(options) {
|
|
|
9331
9492
|
modulesDir,
|
|
9332
9493
|
bundledDir: options.bundledModulesDir,
|
|
9333
9494
|
forgeNodeModules: options.forgeNodeModules,
|
|
9334
|
-
devFile:
|
|
9495
|
+
devFile: join22(dataDir, "dev-modules.json"),
|
|
9335
9496
|
localOnly,
|
|
9336
9497
|
deps: {
|
|
9337
9498
|
db,
|
|
@@ -9531,21 +9692,21 @@ data: ${JSON.stringify(data)}
|
|
|
9531
9692
|
if (!dir.startsWith(home)) {
|
|
9532
9693
|
return c.json({ error: "Access denied: path must be within home directory" }, 403);
|
|
9533
9694
|
}
|
|
9534
|
-
if (!
|
|
9695
|
+
if (!existsSync19(dir)) {
|
|
9535
9696
|
return c.json({ error: "Directory not found" }, 404);
|
|
9536
9697
|
}
|
|
9537
9698
|
try {
|
|
9538
9699
|
const entries = readdirSync8(dir, { withFileTypes: true });
|
|
9539
9700
|
const dirs = entries.filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => ({
|
|
9540
9701
|
name: e.name,
|
|
9541
|
-
path:
|
|
9542
|
-
hasPackageJson:
|
|
9543
|
-
hasGit:
|
|
9702
|
+
path: join22(dir, e.name),
|
|
9703
|
+
hasPackageJson: existsSync19(join22(dir, e.name, "package.json")),
|
|
9704
|
+
hasGit: existsSync19(join22(dir, e.name, ".git"))
|
|
9544
9705
|
})).sort((a, b) => a.name.localeCompare(b.name));
|
|
9545
9706
|
return c.json({
|
|
9546
9707
|
current: dir,
|
|
9547
9708
|
name: basename5(dir),
|
|
9548
|
-
parent:
|
|
9709
|
+
parent: join22(dir, ".."),
|
|
9549
9710
|
directories: dirs
|
|
9550
9711
|
});
|
|
9551
9712
|
} catch {
|
|
@@ -9595,6 +9756,8 @@ var init_server = __esm({
|
|
|
9595
9756
|
init_general_sessions();
|
|
9596
9757
|
init_liveframe_routes();
|
|
9597
9758
|
init_kioku_routes();
|
|
9759
|
+
init_voice_routes();
|
|
9760
|
+
init_voice();
|
|
9598
9761
|
init_module_host();
|
|
9599
9762
|
init_module_routes();
|
|
9600
9763
|
init_module_install();
|
|
@@ -9616,7 +9779,7 @@ __export(db_postgres_exports, {
|
|
|
9616
9779
|
PostgresDB: () => PostgresDB
|
|
9617
9780
|
});
|
|
9618
9781
|
import postgres from "postgres";
|
|
9619
|
-
import { randomUUID as
|
|
9782
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
9620
9783
|
function teamModeOnly() {
|
|
9621
9784
|
throw new Error("not available in team mode");
|
|
9622
9785
|
}
|
|
@@ -9673,7 +9836,7 @@ var init_db_postgres = __esm({
|
|
|
9673
9836
|
return ["projects", "modules", "action_logs", "module_settings"];
|
|
9674
9837
|
}
|
|
9675
9838
|
addProject(input) {
|
|
9676
|
-
const id =
|
|
9839
|
+
const id = randomUUID3();
|
|
9677
9840
|
this.sql`INSERT INTO projects (id, name, path) VALUES (${id}, ${input.name}, ${input.path})`.execute();
|
|
9678
9841
|
return id;
|
|
9679
9842
|
}
|
|
@@ -9687,7 +9850,7 @@ var init_db_postgres = __esm({
|
|
|
9687
9850
|
this.sql`DELETE FROM projects WHERE id = ${id}`.execute();
|
|
9688
9851
|
}
|
|
9689
9852
|
addModule(input) {
|
|
9690
|
-
const id =
|
|
9853
|
+
const id = randomUUID3();
|
|
9691
9854
|
this.sql`INSERT INTO modules (id, name, version) VALUES (${id}, ${input.name}, ${input.version})`.execute();
|
|
9692
9855
|
return id;
|
|
9693
9856
|
}
|
|
@@ -9698,7 +9861,7 @@ var init_db_postgres = __esm({
|
|
|
9698
9861
|
this.sql`DELETE FROM modules WHERE name = ${name}`.execute();
|
|
9699
9862
|
}
|
|
9700
9863
|
logAction(input) {
|
|
9701
|
-
const id =
|
|
9864
|
+
const id = randomUUID3();
|
|
9702
9865
|
this.sql`INSERT INTO action_logs (id, project_id, module_id, action_id, command) VALUES (${id}, ${input.projectId}, ${input.moduleId}, ${input.actionId}, ${input.command})`.execute();
|
|
9703
9866
|
return id;
|
|
9704
9867
|
}
|
|
@@ -9759,8 +9922,8 @@ async function createDatabase(opts) {
|
|
|
9759
9922
|
await db.migrate();
|
|
9760
9923
|
return db;
|
|
9761
9924
|
}
|
|
9762
|
-
const { join:
|
|
9763
|
-
return new ForgeDB(
|
|
9925
|
+
const { join: join26 } = await import("node:path");
|
|
9926
|
+
return new ForgeDB(join26(opts.dataDir, "forge.db"));
|
|
9764
9927
|
}
|
|
9765
9928
|
var init_db_factory = __esm({
|
|
9766
9929
|
"../core/dist/db-factory.js"() {
|
|
@@ -9770,22 +9933,22 @@ var init_db_factory = __esm({
|
|
|
9770
9933
|
});
|
|
9771
9934
|
|
|
9772
9935
|
// ../core/dist/init.js
|
|
9773
|
-
import { existsSync as
|
|
9774
|
-
import { join as
|
|
9936
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
|
|
9937
|
+
import { join as join23 } from "node:path";
|
|
9775
9938
|
import { homedir as homedir8 } from "node:os";
|
|
9776
9939
|
function getForgeDir() {
|
|
9777
|
-
return
|
|
9940
|
+
return join23(homedir8(), ".forge");
|
|
9778
9941
|
}
|
|
9779
9942
|
function ensureForgeDir() {
|
|
9780
9943
|
const forgeDir = getForgeDir();
|
|
9781
|
-
if (
|
|
9944
|
+
if (existsSync20(forgeDir)) {
|
|
9782
9945
|
return { forgeDir, created: false };
|
|
9783
9946
|
}
|
|
9784
9947
|
mkdirSync8(forgeDir, { recursive: true });
|
|
9785
9948
|
for (const d of FORGE_SUBDIRS) {
|
|
9786
|
-
mkdirSync8(
|
|
9949
|
+
mkdirSync8(join23(forgeDir, d), { recursive: true });
|
|
9787
9950
|
}
|
|
9788
|
-
writeFileSync8(
|
|
9951
|
+
writeFileSync8(join23(forgeDir, "config.json"), JSON.stringify({
|
|
9789
9952
|
port: 3e3,
|
|
9790
9953
|
theme: "dark",
|
|
9791
9954
|
openBrowser: true,
|
|
@@ -9848,8 +10011,8 @@ var init_port_in_use = __esm({
|
|
|
9848
10011
|
});
|
|
9849
10012
|
|
|
9850
10013
|
// ../core/dist/start.js
|
|
9851
|
-
import { existsSync as
|
|
9852
|
-
import { join as
|
|
10014
|
+
import { existsSync as existsSync21, readFileSync as readFileSync14 } from "node:fs";
|
|
10015
|
+
import { join as join24 } from "node:path";
|
|
9853
10016
|
async function startForge(options) {
|
|
9854
10017
|
const { port, version, consoleDist: consoleDist2, bundledModulesDir: bundledModulesDir2, databaseUrl, authToken, fallbackToFreePort = false } = options;
|
|
9855
10018
|
const { forgeDir } = ensureForgeDir();
|
|
@@ -9869,10 +10032,10 @@ async function startForge(options) {
|
|
|
9869
10032
|
bundledModulesDir: bundledModulesDir2,
|
|
9870
10033
|
version
|
|
9871
10034
|
});
|
|
9872
|
-
if (consoleDist2 &&
|
|
10035
|
+
if (consoleDist2 && existsSync21(join24(consoleDist2, "index.html"))) {
|
|
9873
10036
|
const { serveStatic } = await import("@hono/node-server/serve-static");
|
|
9874
10037
|
server.app.use("/*", serveStatic({ root: consoleDist2 }));
|
|
9875
|
-
const indexHtml = readFileSync14(
|
|
10038
|
+
const indexHtml = readFileSync14(join24(consoleDist2, "index.html"), "utf-8");
|
|
9876
10039
|
server.app.get("*", (c) => c.html(indexHtml));
|
|
9877
10040
|
}
|
|
9878
10041
|
const { serve } = await import("@hono/node-server");
|
|
@@ -9943,6 +10106,8 @@ __export(dist_exports, {
|
|
|
9943
10106
|
PROVIDER_NAME_RE: () => PROVIDER_NAME_RE,
|
|
9944
10107
|
PTYManager: () => PTYManager,
|
|
9945
10108
|
TRUST_NOTE: () => TRUST_NOTE,
|
|
10109
|
+
Voice: () => Voice,
|
|
10110
|
+
VoiceError: () => VoiceError,
|
|
9946
10111
|
bearerAuth: () => bearerAuth,
|
|
9947
10112
|
createDatabase: () => createDatabase,
|
|
9948
10113
|
createForgeServer: () => createForgeServer,
|
|
@@ -9970,6 +10135,7 @@ __export(dist_exports, {
|
|
|
9970
10135
|
startForge: () => startForge,
|
|
9971
10136
|
supports: () => supports,
|
|
9972
10137
|
validateParams: () => validateParams,
|
|
10138
|
+
voiceRoutes: () => voiceRoutes,
|
|
9973
10139
|
waitForListening: () => waitForListening
|
|
9974
10140
|
});
|
|
9975
10141
|
var init_dist2 = __esm({
|
|
@@ -9995,6 +10161,8 @@ var init_dist2 = __esm({
|
|
|
9995
10161
|
init_liveframe_routes();
|
|
9996
10162
|
init_liveframe();
|
|
9997
10163
|
init_kioku_routes();
|
|
10164
|
+
init_voice_routes();
|
|
10165
|
+
init_voice();
|
|
9998
10166
|
init_kioku();
|
|
9999
10167
|
init_port_in_use();
|
|
10000
10168
|
init_start();
|
|
@@ -10004,9 +10172,9 @@ var init_dist2 = __esm({
|
|
|
10004
10172
|
});
|
|
10005
10173
|
|
|
10006
10174
|
// src/index.ts
|
|
10007
|
-
import { existsSync as
|
|
10175
|
+
import { existsSync as existsSync22, readFileSync as readFileSync15 } from "node:fs";
|
|
10008
10176
|
import { homedir as homedir9 } from "node:os";
|
|
10009
|
-
import { join as
|
|
10177
|
+
import { join as join25 } from "node:path";
|
|
10010
10178
|
function parseArgs(argv) {
|
|
10011
10179
|
const out = { open: true };
|
|
10012
10180
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -10017,11 +10185,11 @@ function parseArgs(argv) {
|
|
|
10017
10185
|
}
|
|
10018
10186
|
return out;
|
|
10019
10187
|
}
|
|
10020
|
-
var packageRoot =
|
|
10021
|
-
var isCheckout =
|
|
10022
|
-
var consoleDist = isCheckout ?
|
|
10023
|
-
var forgeVersion = JSON.parse(readFileSync15(
|
|
10024
|
-
var bundledModulesDir = isCheckout ?
|
|
10188
|
+
var packageRoot = join25(import.meta.dirname, "..");
|
|
10189
|
+
var isCheckout = existsSync22(join25(packageRoot, "src"));
|
|
10190
|
+
var consoleDist = isCheckout ? join25(packageRoot, "../console/dist") : join25(packageRoot, "console");
|
|
10191
|
+
var forgeVersion = JSON.parse(readFileSync15(join25(packageRoot, "package.json"), "utf-8")).version;
|
|
10192
|
+
var bundledModulesDir = isCheckout ? join25(packageRoot, "../../modules") : join25(packageRoot, "modules");
|
|
10025
10193
|
async function main() {
|
|
10026
10194
|
const { ensureForgeDir: ensureForgeDir2, startForge: startForge2, ensureCw: ensureCw2, pathWithCw: pathWithCw2, quietSqliteWarning: quietSqliteWarning2, portInUseMessage: portInUseMessage2 } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
10027
10195
|
quietSqliteWarning2();
|
|
@@ -10030,8 +10198,8 @@ async function main() {
|
|
|
10030
10198
|
if (created) {
|
|
10031
10199
|
console.log("First run \u2014 initialized Forge.");
|
|
10032
10200
|
}
|
|
10033
|
-
const cwHome =
|
|
10034
|
-
const cw = isCheckout ? { action: "skipped", message: "a checkout does not install CW" } : await ensureCw2({ cwHome, bundleDir:
|
|
10201
|
+
const cwHome = join25(process.env.HOME ?? homedir9(), ".cw");
|
|
10202
|
+
const cw = isCheckout ? { action: "skipped", message: "a checkout does not install CW" } : await ensureCw2({ cwHome, bundleDir: join25(packageRoot, "cw") });
|
|
10035
10203
|
if (cw.action === "installed") console.log(` Installed CW ${cw.version} in ${cwHome}`);
|
|
10036
10204
|
else if (cw.action === "updated") console.log(` Updated ${cw.message}`);
|
|
10037
10205
|
else if (cw.action === "failed") console.log(` Could not install CW: ${cw.message}`);
|