Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
03aa74a
refactor: cut the Project panel's live tools, the extra AI presets an…
Mikey-Ku Oct 22, 2026
9d5ce40
feat: a home for your plans in ~/.stackwise, with a profile, a librar…
Mikey-Ku Oct 22, 2026
f6d31b3
feat: a sidebar shell with Projects and Settings pages
Mikey-Ku Oct 22, 2026
ea8ea18
feat: a Mac app, and the canvas laid out in layers
Mikey-Ku Oct 22, 2026
db4a597
feat: a test plan for every build task, over MCP and in the project pack
Mikey-Ku Oct 22, 2026
e7387b8
docs: the README and MCP reference for the Mac app, the library, laye…
Mikey-Ku Oct 22, 2026
ccbd59a
fix: the Ask default answerer lives in the profile too
Mikey-Ku Oct 22, 2026
b916aea
fix: pack the Mac app from electron/ with the server's dependencies i…
Mikey-Ku Oct 22, 2026
73ba83b
ci: deny electron-winstaller's build script so pnpm 12 installs
Mikey-Ku Oct 22, 2026
0d4db2e
fix: the app opens on your projects, and a new window no longer adds …
Mikey-Ku Oct 22, 2026
df2aec1
fix: the app's window loads its page once the server answers
Mikey-Ku Oct 22, 2026
26c5af6
feat: a chat pane, settings in sections, and a model per built-in AI
Mikey-Ku Oct 22, 2026
5defb36
feat: a fixed chat pane, no AI gate, Projects and Settings from the c…
Mikey-Ku Oct 22, 2026
b16d8f8
fix: nothing goes to disk before the library has been pulled
Mikey-Ku Oct 22, 2026
80f2db5
docs: the save gate and the flush, in the gotchas
Mikey-Ku Oct 22, 2026
80fd4c7
feat: the chat pane resizes from its edge, and Learn lives in the shell
Mikey-Ku Oct 22, 2026
2e4874d
feat: the chat narrates every change to the plan, from the facts
Mikey-Ku Oct 22, 2026
75bb1e0
docs: restore CLAUDE.md, with the Learn shell page, the pane width an…
Mikey-Ku Oct 22, 2026
2498444
feat: a flat toolbar instead of floating pills, and the chat pane ope…
Mikey-Ku Oct 22, 2026
9e5b4b6
feat: the chat composer picks a provider and a model, and the pane co…
Mikey-Ku Oct 22, 2026
9ed826e
fix: a quiet focus on the chat composer, no blue ring
Mikey-Ku Oct 22, 2026
b3ad19a
feat: the model menu shows each model's name, context window and pric…
Mikey-Ku Oct 22, 2026
eab5513
feat: a model pick applies to Claude Code too
Mikey-Ku Oct 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ GEMINI_API_KEY=
# OPENAI_MODEL=gpt-6-luna
# GEMINI_MODEL=gemini-3.8-flash

# More models. Each turns on once its key (if it needs one) and its model are set.
# OPENROUTER_API_KEY= OPENROUTER_MODEL=
# GROQ_API_KEY= GROQ_MODEL=
# MISTRAL_API_KEY= MISTRAL_MODEL=
# A model running on this computer with Ollama. Turns on once its model is set.
# OLLAMA_MODEL= OLLAMA_BASE_URL=http://localhost:11434/v1
# Any other API that speaks OpenAI's chat format:
# CUSTOM_AI_BASE_URL= CUSTOM_AI_API_KEY= CUSTOM_AI_MODEL= CUSTOM_AI_LABEL=

# Optional overrides.
# STACKWISE_MODEL=claude-opus-5
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ CLAUDE.local.md
.claude/settings.local.json
.claude/worktrees/
.playwright-mcp/

# The desktop app build (electron-builder).
release/
33 changes: 21 additions & 12 deletions CLAUDE.md

Large diffs are not rendered by default.

244 changes: 133 additions & 111 deletions README.md

Large diffs are not rendered by default.

353 changes: 284 additions & 69 deletions docs/MCP.md

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions electron/after-pack.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// electron-builder hook: puts the standalone server into the app bundle. electron-builder's own
// extraResources copy leaves out node_modules, which the server needs, so this copies the folder
// pack.cjs made (symlinks kept, all relative) into Contents/Resources/standalone before the
// bundle is signed.
const path = require("node:path");
const fs = require("node:fs");
const { execFileSync } = require("node:child_process");

exports.default = async function afterPack(context) {
const from = path.join(__dirname, "..", ".next", "app-standalone");
if (!fs.existsSync(path.join(from, "server.js"))) throw new Error("No .next/app-standalone/server.js: run node electron/pack.cjs first.");
const app = `${context.packager.appInfo.productFilename}.app`;
const to = path.join(context.appOutDir, app, "Contents", "Resources", "standalone");
fs.rmSync(to, { recursive: true, force: true });
execFileSync("cp", ["-R", from, to]);
const next = path.join(to, "node_modules", "next", "package.json");
if (!fs.existsSync(next) || path.relative(to, fs.realpathSync(next)).startsWith("..")) throw new Error(`The copied standalone's node_modules/next doesn't resolve inside ${to}`);
console.log(` • standalone server copied into ${app}/Contents/Resources/standalone`);
};
13 changes: 13 additions & 0 deletions electron/build.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Runs electron-builder for the Mac app from inside electron/, so its package.json (no
// dependencies) is the project and only the four app files go into app.asar. Run under
// `pnpm app:build`, electron-builder sees pnpm in npm_config_user_agent and asks pnpm for the
// dependency tree, which answers with the repo's: 300 MB of node_modules in the bundle. Without
// those variables it falls back to the folder itself and packs nothing extra.
const path = require("node:path");
const { spawnSync } = require("node:child_process");

const root = path.join(__dirname, "..");
const env = Object.fromEntries(Object.entries(process.env).filter(([name]) => !name.startsWith("npm_") && !name.startsWith("PNPM_")));
const args = process.argv.slice(2);
const result = spawnSync(path.join(root, "node_modules", ".bin", "electron-builder"), ["--mac", "--arm64", "--publish", "never", ...args], { cwd: __dirname, env, stdio: "inherit" });
process.exit(result.status ?? 1);
Binary file added electron/build/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
206 changes: 206 additions & 0 deletions electron/main.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
// StackWise as a Mac app. It runs StackWise's server on this computer (127.0.0.1:4310, the same
// address the stackwise command and Claude Code use), shows it in a window, and stays in the menu
// bar when the window is closed so coding agents can still reach the MCP server. Quit stops the
// server. Only Electron's own modules are used here, so the app bundle carries no other code.
const { app, BrowserWindow, Menu, Tray, clipboard, nativeImage, shell } = require("electron");
const { spawn } = require("node:child_process");
const fs = require("node:fs");
const os = require("node:os");
const path = require("node:path");

const HOST = "127.0.0.1";
const PORT = 4310;
const URL = `http://${HOST}:${PORT}`;
const MCP_URL = `${URL}/api/mcp`;
const HOME = process.env.STACKWISE_HOME || path.join(os.homedir(), ".stackwise");

/** @type {import("node:child_process").ChildProcess | null} */
let server = null;
/** @type {BrowserWindow | null} */
let win = null;
/** @type {Tray | null} */
let tray = null;
let quitting = false;

async function up() {
try {
const response = await fetch(`${URL}/api/status`, { signal: AbortSignal.timeout(1500) });
return response.ok;
} catch {
return false;
}
}

/** AI keys saved from the app live in ~/.stackwise/.env.local; the server gets them at start. */
function savedEnv() {
const env = {};
try {
for (const line of fs.readFileSync(path.join(HOME, ".env.local"), "utf8").split("\n")) {
const match = /^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*?)\s*$/.exec(line);
if (match && !match[1].startsWith("#")) env[match[1]] = match[2].replace(/^(["'])(.*)\1$/, "$2");
}
} catch {
// No keys yet.
}
return env;
}

function startServer() {
fs.mkdirSync(HOME, { recursive: true });
const log = fs.openSync(path.join(HOME, "app.log"), "a");
const env = { ...process.env, ...savedEnv(), PORT: String(PORT), HOSTNAME: HOST, STACKWISE_HOME: HOME, STACKWISE_DESKTOP: "1" };
if (app.isPackaged) {
// The built site, with data/ and public/ beside server.js, run by the Node inside Electron.
const dir = path.join(process.resourcesPath, "standalone");
server = spawn(process.execPath, [path.join(dir, "server.js")], { cwd: dir, env: { ...env, ELECTRON_RUN_AS_NODE: "1" }, stdio: ["ignore", log, log] });
} else {
// Development: the repo's dev server, with hot reload.
server = spawn("pnpm", ["dev"], { cwd: path.join(__dirname, ".."), env, stdio: ["ignore", log, log], shell: true });
}
server.on("exit", () => {
server = null;
});
}

async function waitForServer() {
for (let i = 0; i < 240; i++) {
if (await up()) return true;
await new Promise((resolve) => setTimeout(resolve, 500));
}
return false;
}

function createWindow() {
win = new BrowserWindow({
width: 1360,
height: 880,
minWidth: 880,
minHeight: 600,
title: "StackWise",
titleBarStyle: "hiddenInset",
trafficLightPosition: { x: 18, y: 20 },
backgroundColor: "#f5f5f7",
webPreferences: { preload: path.join(__dirname, "preload.cjs"), contextIsolation: true, sandbox: true },
});
// The window is visible from the start. Created hidden and shown on ready-to-show, its page
// stayed in the hidden state on macOS 26: no layout, no paint, a blank gray window.
// Links to other sites open in the browser, never in this window.
win.webContents.setWindowOpenHandler(({ url }) => {
if (!url.startsWith(URL)) shell.openExternal(url);
return { action: "deny" };
});
win.webContents.on("will-navigate", (event, url) => {
if (!url.startsWith(URL)) {
event.preventDefault();
shell.openExternal(url);
}
});
// Closing the window keeps StackWise running for agents; Quit stops it.
win.on("close", (event) => {
if (quitting) return;
event.preventDefault();
win && win.hide();
});
win.on("closed", () => {
win = null;
});
win.loadURL(SPLASH);
// A load that fails because the server is still starting is tried again, up to ten times.
let retries = 0;
win.webContents.on("did-fail-load", (event, code, description, url, isMainFrame) => {
if (!isMainFrame || !url.startsWith(URL) || retries >= 10) return;
retries += 1;
setTimeout(() => win && win.loadURL(url), 500);
});
}

const MARK = `<svg width="72" height="72" viewBox="0 0 1254 1254" aria-hidden="true"><rect width="1254" height="1254" rx="270" fill="#0561ee"/><g fill="none" stroke="#fff" stroke-linecap="round" stroke-linejoin="round"><path d="M627 337 L933 520 L627 703 L322 520 Z" stroke-width="62"/><path d="M322 668 L627 848 L932 668" stroke-width="64"/><path d="M322 792 L627 967 L932 792" stroke-width="64"/><circle cx="607" cy="517" r="88" stroke-width="34"/><path d="M562 520 a46 46 0 0 1 40 -40" stroke-width="20"/><path d="M692 570 L735 604" stroke="#0561ee" stroke-width="92"/><path d="M692 570 L735 604" stroke-width="46"/></g></svg>`;
const PAGE_STYLE = `html,body{height:100%;margin:0}body{display:grid;place-items:center;background:#f5f5f7;color:#6e6e73;font:15px -apple-system,system-ui,sans-serif;-webkit-app-region:drag;-webkit-user-select:none}@media(prefers-color-scheme:dark){body{background:#1c1c1e;color:#98989d}}.m{display:grid;gap:16px;justify-items:center;text-align:center}.m strong{color:#1d1d1f;font-size:17px}@media(prefers-color-scheme:dark){.m strong{color:#f5f5f7}}@keyframes p{50%{opacity:.45}}.t{animation:p 1.6s ease-in-out infinite}code{font:13px ui-monospace,Menlo,monospace}`;
/** A page of the app's own, shown while the server starts and if it doesn't. */
const localPage = (body) => `data:text/html;charset=utf-8,${encodeURIComponent(`<!doctype html><meta charset="utf-8"><style>${PAGE_STYLE}</style><body><div class="m">${MARK}${body}</div></body>`)}`;
const SPLASH = localPage(`<div class="t">Starting StackWise</div>`);

/** The page the app opens on: your projects; the canvas is one click from there. */
function loadHome() {
win && win.loadURL(`${URL}/projects`);
}

function showWindow() {
if (!win) {
createWindow();
loadHome();
} else {
win.show();
win.focus();
}
}

function createTray() {
const icon = nativeImage.createFromPath(path.join(__dirname, "trayTemplate.png"));
icon.setTemplateImage(true);
tray = new Tray(icon);
tray.setToolTip("StackWise");
const refresh = async () => {
const running = await up();
tray &&
tray.setContextMenu(
Menu.buildFromTemplate([
{ label: "Open StackWise", click: showWindow },
{ type: "separator" },
{ label: running ? `MCP server: running at ${HOST}:${PORT}` : "MCP server: starting", enabled: false },
{ label: "Copy the MCP address", click: () => clipboard.writeText(MCP_URL) },
{ label: "Open the data folder", click: () => shell.openPath(HOME) },
{ type: "separator" },
{ label: "Quit StackWise", click: () => app.quit() },
]),
);
};
tray.on("click", showWindow);
void refresh();
setInterval(() => void refresh(), 15_000);
}

function appMenu() {
Menu.setApplicationMenu(
Menu.buildFromTemplate([
{ label: "StackWise", submenu: [{ role: "about" }, { type: "separator" }, { label: "Settings", accelerator: "Cmd+,", click: () => (showWindow(), win && win.loadURL(`${URL}/settings`)) }, { type: "separator" }, { role: "hide" }, { role: "hideOthers" }, { type: "separator" }, { role: "quit" }] },
{ label: "File", submenu: [{ label: "Projects", accelerator: "Cmd+O", click: () => (showWindow(), win && win.loadURL(`${URL}/projects`)) }, { label: "The canvas", accelerator: "Cmd+1", click: () => (showWindow(), win && win.loadURL(URL)) }, { type: "separator" }, { role: "close" }] },
{ role: "editMenu" },
{ role: "viewMenu" },
{ role: "windowMenu" },
{ label: "Help", submenu: [{ label: "Documentation", click: () => shell.openExternal("https://github.com/Mikey-Ku/StackWise#readme") }, { label: "Learn", click: () => (showWindow(), win && win.loadURL(`${URL}/learn`)) }] },
]),
);
}

// One copy at a time: a second launch opens the window of the first.
if (!app.requestSingleInstanceLock()) app.quit();
app.on("second-instance", showWindow);

app.whenReady().then(async () => {
appMenu();
// A StackWise already running (the stackwise command, or pnpm dev) is used as it is.
if (!(await up())) startServer();
createTray();
// The window comes up at once (gray), and loads the page only when the server answers: a load
// sent before that failed with ECONNREFUSED and left the window blank for good.
createWindow();
if (await waitForServer()) loadHome();
else {
win && win.loadURL(localPage(`<strong>StackWise didn't start</strong><div>Its log is in <code>${HOME}/app.log</code>.</div>`));
}
});

app.on("activate", showWindow);
app.on("before-quit", () => {
quitting = true;
if (server && server.pid) {
try {
process.kill(-server.pid, "SIGTERM");
} catch {
server.kill("SIGTERM");
}
}
});
// The app lives in the menu bar; closing every window doesn't quit it.
app.on("window-all-closed", () => undefined);
67 changes: 67 additions & 0 deletions electron/pack.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// After `next build` with STACKWISE_STANDALONE=1: the standalone server needs the static files,
// public/ and data/ beside it, which Next leaves out. Copied here, then after-pack.cjs ships the
// folder inside the app bundle.
const fs = require("node:fs");
const path = require("node:path");
const { execFileSync } = require("node:child_process");

const root = path.join(__dirname, "..");
const built = path.join(root, ".next", "standalone");
const out = path.join(root, ".next", "app-standalone");
if (!fs.existsSync(path.join(built, "server.js"))) {
console.error("No .next/standalone/server.js: run STACKWISE_STANDALONE=1 next build first.");
process.exit(1);
}
// pnpm lays node_modules out as symlinks into a store (.pnpm), and Node resolves a package's
// dependencies from where the link points, so the links have to stay links: copied as plain
// folders, next can't find @swc/helpers any more. cp -R keeps them; the loop below makes every
// absolute one relative, so the folder works wherever the bundle ends up.
fs.rmSync(out, { recursive: true, force: true });
fs.mkdirSync(out, { recursive: true });
execFileSync("cp", ["-R", `${built}/.`, out]);
for (const [from, to] of [
[".next/static", ".next/static"],
["public", "public"],
["data", "data"],
]) {
fs.rmSync(path.join(out, to), { recursive: true, force: true });
fs.cpSync(path.join(root, from), path.join(out, to), { recursive: true, dereference: true });
}
// Nothing of the person's goes into the bundle: no keys, no state.
for (const stray of [".env.local", ".env", ".stackwise"]) fs.rmSync(path.join(out, stray), { recursive: true, force: true });

let relinked = 0;
const bad = [];
const walk = (dir) => {
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
const file = path.join(dir, entry.name);
if (entry.isSymbolicLink()) {
let target = fs.readlinkSync(file);
if (path.isAbsolute(target)) {
const inside = path.relative(built, target);
if (inside.startsWith("..")) {
bad.push(`${file} -> ${target}`);
continue;
}
target = path.relative(path.dirname(file), path.join(out, inside));
fs.unlinkSync(file);
fs.symlinkSync(target, file);
relinked += 1;
}
let real;
try {
real = fs.realpathSync(file);
} catch {
bad.push(`${file} -> ${target} (dangling)`);
continue;
}
if (path.relative(out, real).startsWith("..")) bad.push(`${file} -> ${real} (outside)`);
} else if (entry.isDirectory()) walk(file);
}
};
walk(out);
if (bad.length) {
console.error(`Links that leave ${out}:\n${bad.slice(0, 8).join("\n")}`);
process.exit(1);
}
console.log(`Packed ${out}: server.js, .next/static, public, data; ${relinked} links made relative, none leave the folder.`);
47 changes: 47 additions & 0 deletions electron/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "stackwise",
"productName": "StackWise",
"version": "0.1.0",
"description": "Plan an app's stack you understand: a sourced rules engine checks every connection, then hands your coding agent the plan over MCP.",
"main": "main.cjs",
"author": "Michael Ku",
"license": "MIT",
"private": true,
"build": {
"appId": "me.michaelkujr.stackwise",
"productName": "StackWise",
"electronVersion": "44.9.3",
"directories": {
"output": "../release"
},
"files": [
"main.cjs",
"preload.cjs",
"trayTemplate.png",
"trayTemplate@2x.png"
],
"afterPack": "after-pack.cjs",
"npmRebuild": false,
"mac": {
"category": "public.app-category.developer-tools",
"target": [
{
"target": "dmg",
"arch": [
"arm64"
]
},
{
"target": "zip",
"arch": [
"arm64"
]
}
],
"icon": "build/icon.png",
"darkModeSupport": true,
"identity": null
},
"artifactName": "StackWise-${version}-arm64.${ext}"
}
}
6 changes: 6 additions & 0 deletions electron/preload.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Runs in the page before StackWise loads, with no access to Node. It marks the page as being
// inside the Mac app, so the top bars leave room for the window's traffic lights and can be
// dragged (globals.css and shell.css read data-desktop).
document.addEventListener("DOMContentLoaded", () => {
document.documentElement.dataset.desktop = "mac";
});
Binary file added electron/trayTemplate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added electron/trayTemplate@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import nextTs from "eslint-config-next/typescript";
export default defineConfig([
...nextVitals,
...nextTs,
globalIgnores([".next/**", "out/**", "build/**", "next-env.d.ts"]),
// electron/ is the Mac app's main process: CommonJS by design, run by Electron rather than built by Next.
globalIgnores([".next/**", "out/**", "build/**", "release/**", "electron/**", "next-env.d.ts"]),
]);
Loading
Loading