Merge main into proxy branch (formatting and docs)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Gregory Schier
2026-03-13 12:09:59 -07:00
parent 3c4035097a
commit 7314aedc71
712 changed files with 13408 additions and 13322 deletions

View File

@@ -1,7 +1,7 @@
const fs = require('fs');
const path = require('path');
const readline = require('readline');
const slugify = require('slugify');
const fs = require("fs");
const path = require("path");
const readline = require("readline");
const slugify = require("slugify");
const rl = readline.createInterface({
input: process.stdin,
@@ -11,33 +11,33 @@ const rl = readline.createInterface({
function generateTimestamp() {
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, '0');
const day = String(now.getDate()).padStart(2, '0');
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
const month = String(now.getMonth() + 1).padStart(2, "0");
const day = String(now.getDate()).padStart(2, "0");
const hours = String(now.getHours()).padStart(2, "0");
const minutes = String(now.getMinutes()).padStart(2, "0");
const seconds = String(now.getSeconds()).padStart(2, "0");
return `${year}${month}${day}${hours}${minutes}${seconds}`;
}
async function createMigration() {
try {
const migrationName = await new Promise((resolve) => {
rl.question('Enter migration name: ', resolve);
rl.question("Enter migration name: ", resolve);
});
const timestamp = generateTimestamp();
const fileName = `${timestamp}_${slugify(String(migrationName), { lower: true })}.sql`;
const migrationsDir = path.join(__dirname, '../crates/yaak-models/migrations');
const migrationsDir = path.join(__dirname, "../crates/yaak-models/migrations");
const filePath = path.join(migrationsDir, fileName);
if (!fs.existsSync(migrationsDir)) {
fs.mkdirSync(migrationsDir, { recursive: true });
}
fs.writeFileSync(filePath, '-- Add migration SQL here\n');
fs.writeFileSync(filePath, "-- Add migration SQL here\n");
console.log(`Created migration file: ${fileName}`);
} catch (error) {
console.error('Error creating migration:', error);
console.error("Error creating migration:", error);
} finally {
rl.close();
}

View File

@@ -74,9 +74,7 @@ try {
}
}
const clientDevMatch = content.match(
/^(?:YAAK_CLIENT_DEV_PORT|YAAK_DEV_PORT)=(\d+)/m,
);
const clientDevMatch = content.match(/^(?:YAAK_CLIENT_DEV_PORT|YAAK_DEV_PORT)=(\d+)/m);
if (clientDevMatch) {
const port = parseInt(clientDevMatch[1], 10);
const index = port - CLIENT_PORT_BASE;
@@ -99,10 +97,7 @@ try {
// Increment MCP to get the next available port
maxMcpPort++;
} catch (err) {
console.error(
"Warning: Could not check other worktrees for port conflicts:",
err.message,
);
console.error("Warning: Could not check other worktrees for port conflicts:", err.message);
// Continue with default ports
}
@@ -214,13 +209,8 @@ try {
}
}
} catch (err) {
console.warn(
"Warning: Could not copy files from main worktree:",
err.message,
);
console.warn("Warning: Could not copy files from main worktree:", err.message);
// Continue anyway
}
console.log(
"\n✓ Worktree setup complete! Run `npm run init` to install dependencies.",
);
console.log("\n✓ Worktree setup complete! Run `npm run init` to install dependencies.");

View File

@@ -1,18 +1,18 @@
const { execSync } = require('node:child_process');
const { execSync } = require("node:child_process");
const version = tryExecSync('wasm-pack --version');
if (version.startsWith('wasm-pack ')) {
console.log('wasm-pack already installed');
const version = tryExecSync("wasm-pack --version");
if (version.startsWith("wasm-pack ")) {
console.log("wasm-pack already installed");
return;
}
console.log('Installing wasm-pack via cargo...');
execSync('cargo install wasm-pack --locked', { stdio: 'inherit' });
console.log("Installing wasm-pack via cargo...");
execSync("cargo install wasm-pack --locked", { stdio: "inherit" });
function tryExecSync(cmd) {
try {
return execSync(cmd, { stdio: 'pipe' }).toString('utf-8');
} catch (_) {
return '';
return execSync(cmd, { stdio: "pipe" }).toString("utf-8");
} catch {
return "";
}
}

View File

@@ -1,15 +1,19 @@
const { readdirSync } = require('node:fs');
const path = require('node:path');
const { execSync } = require('node:child_process');
const { readdirSync } = require("node:fs");
const path = require("node:path");
const { execSync } = require("node:child_process");
const pluginsDir = path.join(__dirname, '..', 'plugins');
const pluginsDir = path.join(__dirname, "..", "plugins");
console.log('Publishing core Yaak plugins');
console.log("Publishing core Yaak plugins");
for (const name of readdirSync(pluginsDir)) {
const dir = path.join(pluginsDir, name);
if (name.startsWith('.')) continue;
console.log('Building plugin', dir);
execSync('npm run build', { stdio: 'inherit', cwd: dir });
execSync('yaakcli publish', { stdio: 'inherit', cwd: dir, env: { ...process.env, ENVIRONMENT: 'development' } });
if (name.startsWith(".")) continue;
console.log("Building plugin", dir);
execSync("npm run build", { stdio: "inherit", cwd: dir });
execSync("yaakcli publish", {
stdio: "inherit",
cwd: dir,
env: { ...process.env, ENVIRONMENT: "development" },
});
}

View File

@@ -6,10 +6,7 @@ if (!version) {
throw new Error("YAAK_VERSION environment variable not set");
}
const tauriConfigPath = path.join(
__dirname,
"../crates-tauri/yaak-app-client/tauri.conf.json",
);
const tauriConfigPath = path.join(__dirname, "../crates-tauri/yaak-app-client/tauri.conf.json");
const tauriConfig = JSON.parse(fs.readFileSync(tauriConfigPath, "utf8"));
tauriConfig.version = version;

View File

@@ -58,9 +58,7 @@ if (appConfig == null) {
const port =
process.env[appConfig.devPortEnv] ||
(appConfig.fallbackDevPortEnv
? process.env[appConfig.fallbackDevPortEnv]
: undefined) ||
(appConfig.fallbackDevPortEnv ? process.env[appConfig.fallbackDevPortEnv] : undefined) ||
appConfig.defaultPort;
const config = JSON.stringify({
build: { devUrl: `http://localhost:${port}` },
@@ -76,9 +74,7 @@ for (let i = 0; i < additionalArgs.length; i++) {
const isInlineJson = value.trimStart().startsWith("{");
normalizedAdditionalArgs.push("--config");
normalizedAdditionalArgs.push(
!isInlineJson && !path.isAbsolute(value)
? path.join(rootDir, value)
: value,
!isInlineJson && !path.isAbsolute(value) ? path.join(rootDir, value) : value,
);
i++;
continue;
@@ -99,13 +95,7 @@ const args = [
];
// Invoke the tauri CLI JS entry point directly via node to avoid shell escaping issues on Windows
const tauriJs = path.join(
rootDir,
"node_modules",
"@tauri-apps",
"cli",
"tauri.js",
);
const tauriJs = path.join(rootDir, "node_modules", "@tauri-apps", "cli", "tauri.js");
const result = spawnSync(process.execPath, [tauriJs, ...args], {
cwd: path.join(rootDir, appConfig.appDir),

View File

@@ -15,14 +15,11 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
const rootDir = path.join(__dirname, "..");
// Read root package.json to get workspaces
const rootPkg = JSON.parse(
fs.readFileSync(path.join(rootDir, "package.json"), "utf8"),
);
const rootPkg = JSON.parse(fs.readFileSync(path.join(rootDir, "package.json"), "utf8"));
const workspaces = rootPkg.workspaces || [];
const requestedWorkspaces = process.argv.slice(2);
const workspaceCandidates =
requestedWorkspaces.length > 0 ? requestedWorkspaces : workspaces;
const workspaceCandidates = requestedWorkspaces.length > 0 ? requestedWorkspaces : workspaces;
// Find all candidate workspaces with a dev script
const workspacesWithDev = workspaceCandidates.filter((ws) => {

View File

@@ -1,20 +1,20 @@
const path = require('node:path');
const crypto = require('node:crypto');
const fs = require('node:fs');
const decompress = require('decompress');
const Downloader = require('nodejs-file-downloader');
const { rmSync, cpSync, mkdirSync, existsSync } = require('node:fs');
const { execSync } = require('node:child_process');
const path = require("node:path");
const crypto = require("node:crypto");
const fs = require("node:fs");
const decompress = require("decompress");
const Downloader = require("nodejs-file-downloader");
const { rmSync, cpSync, mkdirSync, existsSync } = require("node:fs");
const { execSync } = require("node:child_process");
const NODE_VERSION = 'v24.11.1';
const NODE_VERSION = "v24.11.1";
// `${process.platform}_${process.arch}`
const MAC_ARM = 'darwin_arm64';
const MAC_X64 = 'darwin_x64';
const LNX_ARM = 'linux_arm64';
const LNX_X64 = 'linux_x64';
const WIN_X64 = 'win32_x64';
const WIN_ARM = 'win32_arm64';
const MAC_ARM = "darwin_arm64";
const MAC_X64 = "darwin_x64";
const LNX_ARM = "linux_arm64";
const LNX_X64 = "linux_x64";
const WIN_X64 = "win32_x64";
const WIN_ARM = "win32_arm64";
const URL_MAP = {
[MAC_ARM]: `https://nodejs.org/download/release/${NODE_VERSION}/node-${NODE_VERSION}-darwin-arm64.tar.gz`,
@@ -35,31 +35,31 @@ const SRC_BIN_MAP = {
};
const DST_BIN_MAP = {
[MAC_ARM]: 'yaaknode',
[MAC_X64]: 'yaaknode',
[LNX_ARM]: 'yaaknode',
[LNX_X64]: 'yaaknode',
[WIN_X64]: 'yaaknode.exe',
[WIN_ARM]: 'yaaknode.exe',
[MAC_ARM]: "yaaknode",
[MAC_X64]: "yaaknode",
[LNX_ARM]: "yaaknode",
[LNX_X64]: "yaaknode",
[WIN_X64]: "yaaknode.exe",
[WIN_ARM]: "yaaknode.exe",
};
const SHA256_MAP = {
[MAC_ARM]: 'b05aa3a66efe680023f930bd5af3fdbbd542794da5644ca2ad711d68cbd4dc35',
[MAC_X64]: '096081b6d6fcdd3f5ba0f5f1d44a47e83037ad2e78eada26671c252fe64dd111',
[LNX_ARM]: '0dc93ec5c798b0d347f068db6d205d03dea9a71765e6a53922b682b91265d71f',
[LNX_X64]: '58a5ff5cc8f2200e458bea22e329d5c1994aa1b111d499ca46ec2411d58239ca',
[WIN_X64]: '5355ae6d7c49eddcfde7d34ac3486820600a831bf81dc3bdca5c8db6a9bb0e76',
[WIN_ARM]: 'ce9ee4e547ebdff355beb48e309b166c24df6be0291c9eaf103ce15f3de9e5b4',
[MAC_ARM]: "b05aa3a66efe680023f930bd5af3fdbbd542794da5644ca2ad711d68cbd4dc35",
[MAC_X64]: "096081b6d6fcdd3f5ba0f5f1d44a47e83037ad2e78eada26671c252fe64dd111",
[LNX_ARM]: "0dc93ec5c798b0d347f068db6d205d03dea9a71765e6a53922b682b91265d71f",
[LNX_X64]: "58a5ff5cc8f2200e458bea22e329d5c1994aa1b111d499ca46ec2411d58239ca",
[WIN_X64]: "5355ae6d7c49eddcfde7d34ac3486820600a831bf81dc3bdca5c8db6a9bb0e76",
[WIN_ARM]: "ce9ee4e547ebdff355beb48e309b166c24df6be0291c9eaf103ce15f3de9e5b4",
};
const key = `${process.platform}_${process.env.YAAK_TARGET_ARCH ?? process.arch}`;
const destDir = path.join(__dirname, `..`, 'crates-tauri', 'yaak-app-client', 'vendored', 'node');
const destDir = path.join(__dirname, `..`, "crates-tauri", "yaak-app-client", "vendored", "node");
const binDest = path.join(destDir, DST_BIN_MAP[key]);
console.log(`Vendoring NodeJS ${NODE_VERSION} for ${key}`);
if (existsSync(binDest) && tryExecSync(`${binDest} --version`).trim() === NODE_VERSION) {
console.log('NodeJS already vendored');
console.log("NodeJS already vendored");
return;
}
@@ -67,12 +67,12 @@ rmSync(destDir, { recursive: true, force: true });
mkdirSync(destDir, { recursive: true });
const url = URL_MAP[key];
const tmpDir = path.join(__dirname, 'tmp-node');
const tmpDir = path.join(__dirname, "tmp-node");
rmSync(tmpDir, { recursive: true, force: true });
(async function () {
// Download GitHub release artifact
console.log('Downloading NodeJS at', url);
console.log("Downloading NodeJS at", url);
const { filePath } = await new Downloader({
url,
directory: tmpDir,
@@ -82,11 +82,13 @@ rmSync(tmpDir, { recursive: true, force: true });
// Verify SHA256
const expectedHash = SHA256_MAP[key];
const fileBuffer = fs.readFileSync(filePath);
const actualHash = crypto.createHash('sha256').update(fileBuffer).digest('hex');
const actualHash = crypto.createHash("sha256").update(fileBuffer).digest("hex");
if (actualHash !== expectedHash) {
throw new Error(`SHA256 mismatch for ${path.basename(filePath)}\n expected: ${expectedHash}\n actual: ${actualHash}`);
throw new Error(
`SHA256 mismatch for ${path.basename(filePath)}\n expected: ${expectedHash}\n actual: ${actualHash}`,
);
}
console.log('SHA256 verified:', actualHash);
console.log("SHA256 verified:", actualHash);
// Decompress to the same directory
await decompress(filePath, tmpDir, {});
@@ -96,16 +98,16 @@ rmSync(tmpDir, { recursive: true, force: true });
cpSync(binSrc, binDest);
rmSync(tmpDir, { recursive: true, force: true });
console.log('Downloaded NodeJS to', binDest);
console.log("Downloaded NodeJS to", binDest);
})().catch((err) => {
console.log('Script failed:', err);
console.log("Script failed:", err);
process.exit(1);
});
function tryExecSync(cmd) {
try {
return execSync(cmd, { stdio: 'pipe' }).toString('utf-8');
return execSync(cmd, { stdio: "pipe" }).toString("utf-8");
} catch (_) {
return '';
return "";
}
}

View File

@@ -23,7 +23,15 @@ for (const name of readdirSync(pluginsDir)) {
console.log(`Skipping ${name} (external plugin)`);
continue;
}
const destDir = path.join( __dirname, "..", 'crates-tauri','yaak-app-client','vendored','plugins', name);
const destDir = path.join(
__dirname,
"..",
"crates-tauri",
"yaak-app-client",
"vendored",
"plugins",
name,
);
mkdirSync(destDir, { recursive: true });
console.log(`Copying ${name} to ${destDir}`);
cpSync(path.join(dir, "package.json"), path.join(destDir, "package.json"));

View File

@@ -1,20 +1,20 @@
const crypto = require('node:crypto');
const fs = require('node:fs');
const decompress = require('decompress');
const Downloader = require('nodejs-file-downloader');
const path = require('node:path');
const { rmSync, mkdirSync, cpSync, existsSync, statSync, chmodSync } = require('node:fs');
const { execSync } = require('node:child_process');
const crypto = require("node:crypto");
const fs = require("node:fs");
const decompress = require("decompress");
const Downloader = require("nodejs-file-downloader");
const path = require("node:path");
const { rmSync, mkdirSync, cpSync, existsSync, statSync, chmodSync } = require("node:fs");
const { execSync } = require("node:child_process");
const VERSION = '33.1';
const VERSION = "33.1";
// `${process.platform}_${process.arch}`
const MAC_ARM = 'darwin_arm64';
const MAC_X64 = 'darwin_x64';
const LNX_ARM = 'linux_arm64';
const LNX_X64 = 'linux_x64';
const WIN_X64 = 'win32_x64';
const WIN_ARM = 'win32_arm64';
const MAC_ARM = "darwin_arm64";
const MAC_X64 = "darwin_x64";
const LNX_ARM = "linux_arm64";
const LNX_X64 = "linux_x64";
const WIN_X64 = "win32_x64";
const WIN_ARM = "win32_arm64";
const URL_MAP = {
[MAC_ARM]: `https://github.com/protocolbuffers/protobuf/releases/download/v${VERSION}/protoc-${VERSION}-osx-aarch_64.zip`,
@@ -26,43 +26,43 @@ const URL_MAP = {
};
const SRC_BIN_MAP = {
[MAC_ARM]: 'bin/protoc',
[MAC_X64]: 'bin/protoc',
[LNX_ARM]: 'bin/protoc',
[LNX_X64]: 'bin/protoc',
[WIN_X64]: 'bin/protoc.exe',
[WIN_ARM]: 'bin/protoc.exe',
[MAC_ARM]: "bin/protoc",
[MAC_X64]: "bin/protoc",
[LNX_ARM]: "bin/protoc",
[LNX_X64]: "bin/protoc",
[WIN_X64]: "bin/protoc.exe",
[WIN_ARM]: "bin/protoc.exe",
};
const DST_BIN_MAP = {
[MAC_ARM]: 'yaakprotoc',
[MAC_X64]: 'yaakprotoc',
[LNX_ARM]: 'yaakprotoc',
[LNX_X64]: 'yaakprotoc',
[WIN_X64]: 'yaakprotoc.exe',
[WIN_ARM]: 'yaakprotoc.exe',
[MAC_ARM]: "yaakprotoc",
[MAC_X64]: "yaakprotoc",
[LNX_ARM]: "yaakprotoc",
[LNX_X64]: "yaakprotoc",
[WIN_X64]: "yaakprotoc.exe",
[WIN_ARM]: "yaakprotoc.exe",
};
const SHA256_MAP = {
[MAC_ARM]: 'db7e66ff7f9080614d0f5505a6b0ac488cf89a15621b6a361672d1332ec2e14e',
[MAC_X64]: 'e20b5f930e886da85e7402776a4959efb1ed60c57e72794bcade765e67abaa82',
[LNX_ARM]: '6018147740548e0e0f764408c87f4cd040e6e1c1203e13aeacaf811892b604f3',
[LNX_X64]: 'f3340e28a83d1c637d8bafdeed92b9f7db6a384c26bca880a6e5217b40a4328b',
[WIN_X64]: 'd7a207fb6eec0e4b1b6613be3b7d11905375b6fd1147a071116eb8e9f24ac53b',
[WIN_ARM]: 'd7a207fb6eec0e4b1b6613be3b7d11905375b6fd1147a071116eb8e9f24ac53b',
[MAC_ARM]: "db7e66ff7f9080614d0f5505a6b0ac488cf89a15621b6a361672d1332ec2e14e",
[MAC_X64]: "e20b5f930e886da85e7402776a4959efb1ed60c57e72794bcade765e67abaa82",
[LNX_ARM]: "6018147740548e0e0f764408c87f4cd040e6e1c1203e13aeacaf811892b604f3",
[LNX_X64]: "f3340e28a83d1c637d8bafdeed92b9f7db6a384c26bca880a6e5217b40a4328b",
[WIN_X64]: "d7a207fb6eec0e4b1b6613be3b7d11905375b6fd1147a071116eb8e9f24ac53b",
[WIN_ARM]: "d7a207fb6eec0e4b1b6613be3b7d11905375b6fd1147a071116eb8e9f24ac53b",
};
const dstDir = path.join(__dirname, `..`, 'crates-tauri', 'yaak-app-client', 'vendored', 'protoc');
const dstDir = path.join(__dirname, `..`, "crates-tauri", "yaak-app-client", "vendored", "protoc");
const key = `${process.platform}_${process.env.YAAK_TARGET_ARCH ?? process.arch}`;
console.log(`Vendoring protoc ${VERSION} for ${key}`);
const url = URL_MAP[key];
const tmpDir = path.join(__dirname, 'tmp-protoc');
const tmpDir = path.join(__dirname, "tmp-protoc");
const binSrc = path.join(tmpDir, SRC_BIN_MAP[key]);
const binDst = path.join(dstDir, DST_BIN_MAP[key]);
if (existsSync(binDst) && tryExecSync(`${binDst} --version`).trim().includes(VERSION)) {
console.log('Protoc already vendored');
console.log("Protoc already vendored");
return;
}
@@ -77,11 +77,13 @@ mkdirSync(dstDir, { recursive: true });
// Verify SHA256
const expectedHash = SHA256_MAP[key];
const fileBuffer = fs.readFileSync(filePath);
const actualHash = crypto.createHash('sha256').update(fileBuffer).digest('hex');
const actualHash = crypto.createHash("sha256").update(fileBuffer).digest("hex");
if (actualHash !== expectedHash) {
throw new Error(`SHA256 mismatch for ${path.basename(filePath)}\n expected: ${expectedHash}\n actual: ${actualHash}`);
throw new Error(
`SHA256 mismatch for ${path.basename(filePath)}\n expected: ${expectedHash}\n actual: ${actualHash}`,
);
}
console.log('SHA256 verified:', actualHash);
console.log("SHA256 verified:", actualHash);
// Decompress to the same directory
await decompress(filePath, tmpDir, {});
@@ -90,8 +92,8 @@ mkdirSync(dstDir, { recursive: true });
cpSync(binSrc, binDst);
// Copy other files
const includeSrc = path.join(tmpDir, 'include');
const includeDst = path.join(dstDir, 'include');
const includeSrc = path.join(tmpDir, "include");
const includeDst = path.join(dstDir, "include");
cpSync(includeSrc, includeDst, { recursive: true });
rmSync(tmpDir, { recursive: true, force: true });
@@ -100,13 +102,13 @@ mkdirSync(dstDir, { recursive: true });
const newMode = stat.mode | 0o200;
chmodSync(binDst, newMode);
console.log('Downloaded protoc to', binDst);
})().catch((err) => console.log('Script failed:', err));
console.log("Downloaded protoc to", binDst);
})().catch((err) => console.log("Script failed:", err));
function tryExecSync(cmd) {
try {
return execSync(cmd, { stdio: 'pipe' }).toString('utf-8');
return execSync(cmd, { stdio: "pipe" }).toString("utf-8");
} catch (_) {
return '';
return "";
}
}