supbuddy 3.1.3 → 3.1.5
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/bin.js +470 -210
- package/dist/daemon/worker.cjs +249 -20
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -9255,11 +9255,11 @@ var require_mime_types = __commonJS({
|
|
|
9255
9255
|
}
|
|
9256
9256
|
return exts[0];
|
|
9257
9257
|
}
|
|
9258
|
-
function lookup(
|
|
9259
|
-
if (!
|
|
9258
|
+
function lookup(path38) {
|
|
9259
|
+
if (!path38 || typeof path38 !== "string") {
|
|
9260
9260
|
return false;
|
|
9261
9261
|
}
|
|
9262
|
-
var extension2 = extname("x." +
|
|
9262
|
+
var extension2 = extname("x." + path38).toLowerCase().substr(1);
|
|
9263
9263
|
if (!extension2) {
|
|
9264
9264
|
return false;
|
|
9265
9265
|
}
|
|
@@ -9375,7 +9375,7 @@ var require_accepts = __commonJS({
|
|
|
9375
9375
|
var require_base64id = __commonJS({
|
|
9376
9376
|
"../../node_modules/.pnpm/base64id@2.0.0/node_modules/base64id/lib/base64id.js"(exports, module) {
|
|
9377
9377
|
"use strict";
|
|
9378
|
-
var
|
|
9378
|
+
var crypto7 = __require("crypto");
|
|
9379
9379
|
var Base64Id = function() {
|
|
9380
9380
|
};
|
|
9381
9381
|
Base64Id.prototype.getRandomBytes = function(bytes) {
|
|
@@ -9383,12 +9383,12 @@ var require_base64id = __commonJS({
|
|
|
9383
9383
|
var self = this;
|
|
9384
9384
|
bytes = bytes || 12;
|
|
9385
9385
|
if (bytes > BUFFER_SIZE) {
|
|
9386
|
-
return
|
|
9386
|
+
return crypto7.randomBytes(bytes);
|
|
9387
9387
|
}
|
|
9388
9388
|
var bytesInBuffer = parseInt(BUFFER_SIZE / bytes);
|
|
9389
9389
|
var threshold = parseInt(bytesInBuffer * 0.85);
|
|
9390
9390
|
if (!threshold) {
|
|
9391
|
-
return
|
|
9391
|
+
return crypto7.randomBytes(bytes);
|
|
9392
9392
|
}
|
|
9393
9393
|
if (this.bytesBufferIndex == null) {
|
|
9394
9394
|
this.bytesBufferIndex = -1;
|
|
@@ -9400,14 +9400,14 @@ var require_base64id = __commonJS({
|
|
|
9400
9400
|
if (this.bytesBufferIndex == -1 || this.bytesBufferIndex > threshold) {
|
|
9401
9401
|
if (!this.isGeneratingBytes) {
|
|
9402
9402
|
this.isGeneratingBytes = true;
|
|
9403
|
-
|
|
9403
|
+
crypto7.randomBytes(BUFFER_SIZE, function(err, bytes2) {
|
|
9404
9404
|
self.bytesBuffer = bytes2;
|
|
9405
9405
|
self.bytesBufferIndex = 0;
|
|
9406
9406
|
self.isGeneratingBytes = false;
|
|
9407
9407
|
});
|
|
9408
9408
|
}
|
|
9409
9409
|
if (this.bytesBufferIndex == -1) {
|
|
9410
|
-
return
|
|
9410
|
+
return crypto7.randomBytes(bytes);
|
|
9411
9411
|
}
|
|
9412
9412
|
}
|
|
9413
9413
|
var result = this.bytesBuffer.slice(bytes * this.bytesBufferIndex, bytes * (this.bytesBufferIndex + 1));
|
|
@@ -9421,7 +9421,7 @@ var require_base64id = __commonJS({
|
|
|
9421
9421
|
}
|
|
9422
9422
|
this.sequenceNumber = this.sequenceNumber + 1 | 0;
|
|
9423
9423
|
rand.writeInt32BE(this.sequenceNumber, 11);
|
|
9424
|
-
if (
|
|
9424
|
+
if (crypto7.randomBytes) {
|
|
9425
9425
|
this.getRandomBytes(12).copy(rand);
|
|
9426
9426
|
} else {
|
|
9427
9427
|
[0, 4, 8].forEach(function(i) {
|
|
@@ -12660,11 +12660,11 @@ var require_server = __commonJS({
|
|
|
12660
12660
|
* @protected
|
|
12661
12661
|
*/
|
|
12662
12662
|
_computePath(options) {
|
|
12663
|
-
let
|
|
12663
|
+
let path38 = (options.path || "/engine.io").replace(/\/$/, "");
|
|
12664
12664
|
if (options.addTrailingSlash !== false) {
|
|
12665
|
-
|
|
12665
|
+
path38 += "/";
|
|
12666
12666
|
}
|
|
12667
|
-
return
|
|
12667
|
+
return path38;
|
|
12668
12668
|
}
|
|
12669
12669
|
/**
|
|
12670
12670
|
* Returns a list of available transports for upgrade given a certain transport.
|
|
@@ -13180,10 +13180,10 @@ var require_server = __commonJS({
|
|
|
13180
13180
|
* @param {Object} options
|
|
13181
13181
|
*/
|
|
13182
13182
|
attach(server, options = {}) {
|
|
13183
|
-
const
|
|
13183
|
+
const path38 = this._computePath(options);
|
|
13184
13184
|
const destroyUpgradeTimeout = options.destroyUpgradeTimeout || 1e3;
|
|
13185
13185
|
function check(req) {
|
|
13186
|
-
return
|
|
13186
|
+
return path38 === req.url.slice(0, path38.length);
|
|
13187
13187
|
}
|
|
13188
13188
|
const listeners = server.listeners("request").slice(0);
|
|
13189
13189
|
server.removeAllListeners("request");
|
|
@@ -13191,7 +13191,7 @@ var require_server = __commonJS({
|
|
|
13191
13191
|
server.on("listening", this.init.bind(this));
|
|
13192
13192
|
server.on("request", (req, res) => {
|
|
13193
13193
|
if (check(req)) {
|
|
13194
|
-
debug('intercepting request for path "%s"',
|
|
13194
|
+
debug('intercepting request for path "%s"', path38);
|
|
13195
13195
|
this.handleRequest(req, res);
|
|
13196
13196
|
} else {
|
|
13197
13197
|
let i = 0;
|
|
@@ -14031,8 +14031,8 @@ var require_userver = __commonJS({
|
|
|
14031
14031
|
* @param options
|
|
14032
14032
|
*/
|
|
14033
14033
|
attach(app, options = {}) {
|
|
14034
|
-
const
|
|
14035
|
-
app.any(
|
|
14034
|
+
const path38 = this._computePath(options);
|
|
14035
|
+
app.any(path38, this.handleRequest.bind(this)).ws(path38, {
|
|
14036
14036
|
compression: options.compression,
|
|
14037
14037
|
idleTimeout: options.idleTimeout,
|
|
14038
14038
|
maxBackpressure: options.maxBackpressure,
|
|
@@ -18461,7 +18461,7 @@ var require_dist2 = __commonJS({
|
|
|
18461
18461
|
var zlib_1 = __require("zlib");
|
|
18462
18462
|
var accepts = require_accepts();
|
|
18463
18463
|
var stream_1 = __require("stream");
|
|
18464
|
-
var
|
|
18464
|
+
var path38 = __require("path");
|
|
18465
18465
|
var engine_io_1 = require_engine_io();
|
|
18466
18466
|
var client_1 = require_client();
|
|
18467
18467
|
var events_1 = __require("events");
|
|
@@ -18656,7 +18656,7 @@ var require_dist2 = __commonJS({
|
|
|
18656
18656
|
res.writeHeader("cache-control", "public, max-age=0");
|
|
18657
18657
|
res.writeHeader("content-type", "application/" + (isMap ? "json" : "javascript") + "; charset=utf-8");
|
|
18658
18658
|
res.writeHeader("etag", expectedEtag);
|
|
18659
|
-
const filepath =
|
|
18659
|
+
const filepath = path38.join(__dirname, "../client-dist/", filename);
|
|
18660
18660
|
(0, uws_1.serveFile)(res, filepath);
|
|
18661
18661
|
});
|
|
18662
18662
|
}
|
|
@@ -18738,7 +18738,7 @@ var require_dist2 = __commonJS({
|
|
|
18738
18738
|
* @private
|
|
18739
18739
|
*/
|
|
18740
18740
|
static sendFile(filename, req, res) {
|
|
18741
|
-
const readStream = (0, fs_1.createReadStream)(
|
|
18741
|
+
const readStream = (0, fs_1.createReadStream)(path38.join(__dirname, "../client-dist/", filename));
|
|
18742
18742
|
const encoding = accepts(req).encodings(["br", "gzip", "deflate"]);
|
|
18743
18743
|
const onError = (err) => {
|
|
18744
18744
|
if (err) {
|
|
@@ -20536,8 +20536,8 @@ var init_parseUtil = __esm({
|
|
|
20536
20536
|
init_errors();
|
|
20537
20537
|
init_en();
|
|
20538
20538
|
makeIssue = (params) => {
|
|
20539
|
-
const { data, path:
|
|
20540
|
-
const fullPath = [...
|
|
20539
|
+
const { data, path: path38, errorMaps, issueData } = params;
|
|
20540
|
+
const fullPath = [...path38, ...issueData.path || []];
|
|
20541
20541
|
const fullIssue = {
|
|
20542
20542
|
...issueData,
|
|
20543
20543
|
path: fullPath
|
|
@@ -20848,11 +20848,11 @@ var init_types2 = __esm({
|
|
|
20848
20848
|
init_parseUtil();
|
|
20849
20849
|
init_util();
|
|
20850
20850
|
ParseInputLazyPath = class {
|
|
20851
|
-
constructor(parent, value,
|
|
20851
|
+
constructor(parent, value, path38, key) {
|
|
20852
20852
|
this._cachedPath = [];
|
|
20853
20853
|
this.parent = parent;
|
|
20854
20854
|
this.data = value;
|
|
20855
|
-
this._path =
|
|
20855
|
+
this._path = path38;
|
|
20856
20856
|
this._key = key;
|
|
20857
20857
|
}
|
|
20858
20858
|
get path() {
|
|
@@ -31687,6 +31687,43 @@ var init_compose_scanner = __esm({
|
|
|
31687
31687
|
|
|
31688
31688
|
// ../../packages/core/caddy-ca-manager.ts
|
|
31689
31689
|
import fs9 from "fs/promises";
|
|
31690
|
+
import path11 from "path";
|
|
31691
|
+
import os7 from "os";
|
|
31692
|
+
async function getCaddyDataDir() {
|
|
31693
|
+
const platform = process.platform;
|
|
31694
|
+
let userDataPath;
|
|
31695
|
+
if (platform === "darwin") {
|
|
31696
|
+
userDataPath = path11.join(os7.homedir(), "Library", "Application Support", "Supbuddy");
|
|
31697
|
+
} else if (platform === "win32") {
|
|
31698
|
+
userDataPath = path11.join(
|
|
31699
|
+
process.env.APPDATA || path11.join(os7.homedir(), "AppData", "Roaming"),
|
|
31700
|
+
"Supbuddy"
|
|
31701
|
+
);
|
|
31702
|
+
} else {
|
|
31703
|
+
userDataPath = path11.join(
|
|
31704
|
+
process.env.XDG_CONFIG_HOME || path11.join(os7.homedir(), ".config"),
|
|
31705
|
+
"Supbuddy"
|
|
31706
|
+
);
|
|
31707
|
+
}
|
|
31708
|
+
const dataDir = path11.join(userDataPath, "caddy-data");
|
|
31709
|
+
await fs9.mkdir(dataDir, { recursive: true });
|
|
31710
|
+
return dataDir;
|
|
31711
|
+
}
|
|
31712
|
+
async function getCaddyCAPath() {
|
|
31713
|
+
try {
|
|
31714
|
+
const dataDir = await getCaddyDataDir();
|
|
31715
|
+
const caPath = path11.join(dataDir, "caddy", "pki", "authorities", "local", "root.crt");
|
|
31716
|
+
try {
|
|
31717
|
+
await fs9.access(caPath);
|
|
31718
|
+
return caPath;
|
|
31719
|
+
} catch {
|
|
31720
|
+
return null;
|
|
31721
|
+
}
|
|
31722
|
+
} catch (error) {
|
|
31723
|
+
console.error("[Caddy CA] Error getting CA path:", error);
|
|
31724
|
+
return null;
|
|
31725
|
+
}
|
|
31726
|
+
}
|
|
31690
31727
|
async function readSystemKeychainCaddyFingerprints() {
|
|
31691
31728
|
const { execSync: execSync3 } = await import("child_process");
|
|
31692
31729
|
try {
|
|
@@ -31783,38 +31820,211 @@ var init_caddy_ca_manager = __esm({
|
|
|
31783
31820
|
// ../../packages/core/bundled-runtime-trust.ts
|
|
31784
31821
|
import fs10 from "fs/promises";
|
|
31785
31822
|
import fsSync from "fs";
|
|
31786
|
-
import
|
|
31787
|
-
import
|
|
31823
|
+
import path12 from "path";
|
|
31824
|
+
import os8 from "os";
|
|
31825
|
+
import crypto2 from "crypto";
|
|
31788
31826
|
import { execFile as execFile4, execFileSync as execFileSync2 } from "child_process";
|
|
31789
31827
|
import { promisify as promisify5 } from "util";
|
|
31790
31828
|
function getSupbuddyDataDir() {
|
|
31791
31829
|
const platform = process.platform;
|
|
31792
31830
|
if (platform === "darwin") {
|
|
31793
|
-
return
|
|
31831
|
+
return path12.join(os8.homedir(), "Library", "Application Support", "Supbuddy");
|
|
31794
31832
|
}
|
|
31795
31833
|
if (platform === "win32") {
|
|
31796
|
-
return
|
|
31797
|
-
process.env.APPDATA ||
|
|
31834
|
+
return path12.join(
|
|
31835
|
+
process.env.APPDATA || path12.join(os8.homedir(), "AppData", "Roaming"),
|
|
31798
31836
|
"Supbuddy"
|
|
31799
31837
|
);
|
|
31800
31838
|
}
|
|
31801
|
-
return
|
|
31802
|
-
process.env.XDG_CONFIG_HOME ||
|
|
31839
|
+
return path12.join(
|
|
31840
|
+
process.env.XDG_CONFIG_HOME || path12.join(os8.homedir(), ".config"),
|
|
31803
31841
|
"Supbuddy"
|
|
31804
31842
|
);
|
|
31805
31843
|
}
|
|
31806
31844
|
function getBundleDir() {
|
|
31807
|
-
return
|
|
31845
|
+
return path12.join(getSupbuddyDataDir(), "ca-bundle");
|
|
31808
31846
|
}
|
|
31809
31847
|
function getBundlePath() {
|
|
31810
|
-
return
|
|
31848
|
+
return path12.join(getBundleDir(), "current.crt");
|
|
31849
|
+
}
|
|
31850
|
+
function isSupbuddyOwnedCaPath(p) {
|
|
31851
|
+
if (!p) return false;
|
|
31852
|
+
const resolved = path12.resolve(p);
|
|
31853
|
+
const root = path12.resolve(getSupbuddyDataDir());
|
|
31854
|
+
if (resolved === root || resolved.startsWith(root + path12.sep)) return true;
|
|
31855
|
+
return /[/\\]supbuddy[/\\].*(ca-bundle|caddy[/\\].*pki|authorities[/\\]local|current(-merged)?\.crt)/i.test(
|
|
31856
|
+
resolved
|
|
31857
|
+
);
|
|
31858
|
+
}
|
|
31859
|
+
function samePath(a, b, caseInsensitive) {
|
|
31860
|
+
const na = path12.resolve(a);
|
|
31861
|
+
const nb = path12.resolve(b);
|
|
31862
|
+
return caseInsensitive ? na.toLowerCase() === nb.toLowerCase() : na === nb;
|
|
31863
|
+
}
|
|
31864
|
+
function looksAbsolutePath(v) {
|
|
31865
|
+
return v.startsWith("/") || /^[A-Za-z]:[\\/]/.test(v);
|
|
31866
|
+
}
|
|
31867
|
+
function parseProcessEnvScan(psOutput, varName) {
|
|
31868
|
+
const valueRe = new RegExp(`(?:^|\\s)${varName}=(.*?)(?=\\s[A-Za-z_][A-Za-z0-9_]*=|$)`);
|
|
31869
|
+
const out = [];
|
|
31870
|
+
for (const line of psOutput.split("\n")) {
|
|
31871
|
+
const head = line.match(/^\s*(\d+)\s+(\d+)\s+(.*)$/);
|
|
31872
|
+
if (!head) continue;
|
|
31873
|
+
const rest = head[3];
|
|
31874
|
+
const m = rest.match(valueRe);
|
|
31875
|
+
if (!m) continue;
|
|
31876
|
+
const value = m[1].trim();
|
|
31877
|
+
if (value === "" || !looksAbsolutePath(value)) continue;
|
|
31878
|
+
const envStart = rest.search(ENV_TOKEN_RE);
|
|
31879
|
+
const command = (envStart === -1 ? rest : rest.slice(0, envStart)).trim();
|
|
31880
|
+
out.push({ pid: parseInt(head[1], 10), ppid: parseInt(head[2], 10), command, value });
|
|
31881
|
+
}
|
|
31882
|
+
return out;
|
|
31883
|
+
}
|
|
31884
|
+
function friendlyProcessName(command) {
|
|
31885
|
+
const app = command.match(/^(.*?)\.app\//);
|
|
31886
|
+
if (app) return path12.basename(app[1]);
|
|
31887
|
+
const exe = command.split(/\s+/)[0] ?? command;
|
|
31888
|
+
return path12.basename(exe) || command;
|
|
31889
|
+
}
|
|
31890
|
+
function pickRepresentativeHolder(holders) {
|
|
31891
|
+
if (holders.length === 0) return void 0;
|
|
31892
|
+
const pids = new Set(holders.map((h) => h.pid));
|
|
31893
|
+
const topmost = holders.filter((h) => h.ppid == null || !pids.has(h.ppid));
|
|
31894
|
+
const pool = topmost.length > 0 ? topmost : holders;
|
|
31895
|
+
const score = (h) => /\.app\//.test(h.command) ? 0 : 1;
|
|
31896
|
+
return [...pool].sort((a, b) => score(a) - score(b) || a.pid - b.pid)[0];
|
|
31897
|
+
}
|
|
31898
|
+
function classifyNodeExtraCaCerts(observations, canonicalPath, opts = {}) {
|
|
31899
|
+
const ci = opts.caseInsensitive ?? process.platform !== "linux";
|
|
31900
|
+
const byValue = /* @__PURE__ */ new Map();
|
|
31901
|
+
for (const o of observations) {
|
|
31902
|
+
if (!o.value) continue;
|
|
31903
|
+
const key = ci ? path12.resolve(o.value).toLowerCase() : path12.resolve(o.value);
|
|
31904
|
+
const prev = byValue.get(key);
|
|
31905
|
+
if (prev) {
|
|
31906
|
+
prev.holderCount = (prev.holderCount ?? 1) + (o.holderCount ?? 1);
|
|
31907
|
+
continue;
|
|
31908
|
+
}
|
|
31909
|
+
byValue.set(key, { ...o, holderCount: o.holderCount ?? 1 });
|
|
31910
|
+
}
|
|
31911
|
+
const divergent = [];
|
|
31912
|
+
const foreign = [];
|
|
31913
|
+
for (const o of byValue.values()) {
|
|
31914
|
+
if (samePath(o.value, canonicalPath, ci)) continue;
|
|
31915
|
+
if (isSupbuddyOwnedCaPath(o.value)) divergent.push(o);
|
|
31916
|
+
else foreign.push(o);
|
|
31917
|
+
}
|
|
31918
|
+
return { divergent, foreign, conflicting: foreign[0]?.value ?? divergent[0]?.value ?? null };
|
|
31919
|
+
}
|
|
31920
|
+
async function scanProcessesForNodeExtra() {
|
|
31921
|
+
const rows = [];
|
|
31922
|
+
try {
|
|
31923
|
+
if (process.platform === "darwin") {
|
|
31924
|
+
const uid = process.getuid?.() ?? 0;
|
|
31925
|
+
const { stdout } = await execFileP(
|
|
31926
|
+
"/bin/ps",
|
|
31927
|
+
["-Eww", "-o", "pid=,ppid=,command=", "-U", String(uid)],
|
|
31928
|
+
{ encoding: "utf-8", maxBuffer: 64 * 1024 * 1024, timeout: 1e4 }
|
|
31929
|
+
);
|
|
31930
|
+
rows.push(...parseProcessEnvScan(stdout, "NODE_EXTRA_CA_CERTS"));
|
|
31931
|
+
} else if (process.platform === "linux") {
|
|
31932
|
+
const uid = process.getuid?.() ?? 0;
|
|
31933
|
+
for (const name of await fs10.readdir("/proc")) {
|
|
31934
|
+
if (!/^\d+$/.test(name)) continue;
|
|
31935
|
+
try {
|
|
31936
|
+
const st = await fs10.stat(`/proc/${name}`);
|
|
31937
|
+
if (st.uid !== uid) continue;
|
|
31938
|
+
const envRaw = await fs10.readFile(`/proc/${name}/environ`, "utf-8");
|
|
31939
|
+
const hit = envRaw.split("\0").find((e) => e.startsWith("NODE_EXTRA_CA_CERTS="));
|
|
31940
|
+
if (!hit) continue;
|
|
31941
|
+
const value = hit.slice("NODE_EXTRA_CA_CERTS=".length).trim();
|
|
31942
|
+
if (!value || !looksAbsolutePath(value)) continue;
|
|
31943
|
+
const cmd = (await fs10.readFile(`/proc/${name}/cmdline`, "utf-8")).split("\0").join(" ").trim();
|
|
31944
|
+
let ppid;
|
|
31945
|
+
try {
|
|
31946
|
+
const stat2 = await fs10.readFile(`/proc/${name}/stat`, "utf-8");
|
|
31947
|
+
ppid = parseInt(stat2.slice(stat2.lastIndexOf(")") + 2).split(" ")[1], 10);
|
|
31948
|
+
} catch {
|
|
31949
|
+
ppid = void 0;
|
|
31950
|
+
}
|
|
31951
|
+
rows.push({ pid: parseInt(name, 10), ppid, command: cmd, value });
|
|
31952
|
+
} catch {
|
|
31953
|
+
}
|
|
31954
|
+
}
|
|
31955
|
+
}
|
|
31956
|
+
} catch {
|
|
31957
|
+
return [];
|
|
31958
|
+
}
|
|
31959
|
+
const byValue = /* @__PURE__ */ new Map();
|
|
31960
|
+
for (const r of rows) {
|
|
31961
|
+
const list = byValue.get(r.value);
|
|
31962
|
+
if (list) list.push(r);
|
|
31963
|
+
else byValue.set(r.value, [r]);
|
|
31964
|
+
}
|
|
31965
|
+
return [...byValue.entries()].map(([value, holders]) => {
|
|
31966
|
+
const rep = pickRepresentativeHolder(holders);
|
|
31967
|
+
return {
|
|
31968
|
+
origin: "process",
|
|
31969
|
+
value,
|
|
31970
|
+
detail: rep ? `${friendlyProcessName(rep.command)} (pid ${rep.pid})` : void 0,
|
|
31971
|
+
holderCount: holders.length,
|
|
31972
|
+
// A path that no longer exists is silently ignored by Node — the local
|
|
31973
|
+
// CA just vanishes, which presents as UNABLE_TO_GET_ISSUER_CERT_LOCALLY
|
|
31974
|
+
// with nothing in the status to explain it.
|
|
31975
|
+
exists: fsSync.existsSync(value)
|
|
31976
|
+
};
|
|
31977
|
+
}).sort((a, b) => b.holderCount - a.holderCount || a.value.localeCompare(b.value));
|
|
31978
|
+
}
|
|
31979
|
+
async function probeLoginShellNodeExtra() {
|
|
31980
|
+
if (process.platform === "win32") return null;
|
|
31981
|
+
const shell = process.env.SHELL || "/bin/sh";
|
|
31982
|
+
if (!PROBEABLE_SHELLS.has(path12.basename(shell))) return null;
|
|
31983
|
+
try {
|
|
31984
|
+
const { stdout } = await execFileP(
|
|
31985
|
+
shell,
|
|
31986
|
+
["-l", "-c", 'printf %s "$NODE_EXTRA_CA_CERTS"'],
|
|
31987
|
+
{
|
|
31988
|
+
// A clean slate — HOME/USER only, so the profile chain is the ONLY source.
|
|
31989
|
+
env: {
|
|
31990
|
+
HOME: os8.homedir(),
|
|
31991
|
+
USER: process.env.USER ?? "",
|
|
31992
|
+
LOGNAME: process.env.LOGNAME ?? process.env.USER ?? "",
|
|
31993
|
+
PATH: "/usr/bin:/bin:/usr/sbin:/sbin",
|
|
31994
|
+
TERM: "dumb"
|
|
31995
|
+
},
|
|
31996
|
+
encoding: "utf-8",
|
|
31997
|
+
timeout: 8e3,
|
|
31998
|
+
maxBuffer: 1024 * 1024
|
|
31999
|
+
}
|
|
32000
|
+
);
|
|
32001
|
+
const v = stdout.trim();
|
|
32002
|
+
return v === "" ? null : v;
|
|
32003
|
+
} catch {
|
|
32004
|
+
return null;
|
|
32005
|
+
}
|
|
32006
|
+
}
|
|
32007
|
+
async function getEffectiveEnvObservations(force = false) {
|
|
32008
|
+
const now = Date.now();
|
|
32009
|
+
if (!force && effectiveEnvCache && now - effectiveEnvCache.at < EFFECTIVE_ENV_TTL_MS) {
|
|
32010
|
+
return { loginShell: effectiveEnvCache.loginShell, processes: effectiveEnvCache.processes };
|
|
32011
|
+
}
|
|
32012
|
+
const [loginShell, processes] = await Promise.all([
|
|
32013
|
+
probeLoginShellNodeExtra(),
|
|
32014
|
+
scanProcessesForNodeExtra()
|
|
32015
|
+
]);
|
|
32016
|
+
effectiveEnvCache = { at: now, loginShell, processes };
|
|
32017
|
+
return { loginShell, processes };
|
|
32018
|
+
}
|
|
32019
|
+
function invalidateEffectiveEnvCache() {
|
|
32020
|
+
effectiveEnvCache = null;
|
|
31811
32021
|
}
|
|
31812
32022
|
function getPlistPath() {
|
|
31813
|
-
return
|
|
32023
|
+
return path12.join(os8.homedir(), "Library", "LaunchAgents", `${PLIST_LABEL}.plist`);
|
|
31814
32024
|
}
|
|
31815
32025
|
function getEnvironmentDPath() {
|
|
31816
|
-
return
|
|
31817
|
-
process.env.XDG_CONFIG_HOME ||
|
|
32026
|
+
return path12.join(
|
|
32027
|
+
process.env.XDG_CONFIG_HOME || path12.join(os8.homedir(), ".config"),
|
|
31818
32028
|
"environment.d",
|
|
31819
32029
|
"supbuddy-ca.conf"
|
|
31820
32030
|
);
|
|
@@ -31829,6 +32039,10 @@ function parsePemBlocks(pem) {
|
|
|
31829
32039
|
const re = /-----BEGIN CERTIFICATE-----[\s\S]*?-----END CERTIFICATE-----/g;
|
|
31830
32040
|
return pem.match(re) ?? [];
|
|
31831
32041
|
}
|
|
32042
|
+
function hashPemBlock(block) {
|
|
32043
|
+
const normalized = block.replace(/\s+/g, "");
|
|
32044
|
+
return crypto2.createHash("sha256").update(normalized).digest("hex").slice(0, 16);
|
|
32045
|
+
}
|
|
31832
32046
|
async function countPemRoots() {
|
|
31833
32047
|
try {
|
|
31834
32048
|
const pem = await fs10.readFile(getBundlePath(), "utf-8");
|
|
@@ -31858,7 +32072,7 @@ async function scanLegacyTrustAgents() {
|
|
|
31858
32072
|
if (process.platform !== "darwin") return [];
|
|
31859
32073
|
const managed = getPlistPath();
|
|
31860
32074
|
const dirs = [
|
|
31861
|
-
|
|
32075
|
+
path12.join(os8.homedir(), "Library", "LaunchAgents"),
|
|
31862
32076
|
"/Library/LaunchAgents",
|
|
31863
32077
|
"/Library/LaunchDaemons"
|
|
31864
32078
|
];
|
|
@@ -31872,7 +32086,7 @@ async function scanLegacyTrustAgents() {
|
|
|
31872
32086
|
}
|
|
31873
32087
|
for (const name of names) {
|
|
31874
32088
|
if (!name.endsWith(".plist")) continue;
|
|
31875
|
-
const full =
|
|
32089
|
+
const full = path12.join(dir, name);
|
|
31876
32090
|
if (full === managed) continue;
|
|
31877
32091
|
let content;
|
|
31878
32092
|
try {
|
|
@@ -31893,7 +32107,7 @@ async function cleanupLegacyTrustAgents() {
|
|
|
31893
32107
|
try {
|
|
31894
32108
|
await fs10.copyFile(plistPath, `${plistPath}.supbuddy-backup`).catch(() => {
|
|
31895
32109
|
});
|
|
31896
|
-
const label =
|
|
32110
|
+
const label = path12.basename(plistPath, ".plist");
|
|
31897
32111
|
const uid = process.getuid?.() ?? 501;
|
|
31898
32112
|
await execFileP("/bin/launchctl", ["bootout", `gui/${uid}/${label}`]).catch(() => {
|
|
31899
32113
|
});
|
|
@@ -31988,13 +32202,37 @@ function getArtifactPath() {
|
|
|
31988
32202
|
if (process.platform === "win32") return "HKCU\\Environment";
|
|
31989
32203
|
return null;
|
|
31990
32204
|
}
|
|
31991
|
-
async function
|
|
32205
|
+
async function bundleHasActiveCaddyRoot() {
|
|
32206
|
+
try {
|
|
32207
|
+
const caddyCaPath = await getCaddyCAPath();
|
|
32208
|
+
if (!caddyCaPath) return true;
|
|
32209
|
+
const caddyBlocks = parsePemBlocks(await fs10.readFile(caddyCaPath, "utf-8"));
|
|
32210
|
+
if (caddyBlocks.length === 0) return true;
|
|
32211
|
+
const bundleHashes = new Set(
|
|
32212
|
+
parsePemBlocks(await fs10.readFile(getBundlePath(), "utf-8")).map(hashPemBlock)
|
|
32213
|
+
);
|
|
32214
|
+
return caddyBlocks.every((b) => bundleHashes.has(hashPemBlock(b)));
|
|
32215
|
+
} catch {
|
|
32216
|
+
return true;
|
|
32217
|
+
}
|
|
32218
|
+
}
|
|
32219
|
+
async function getStatus(lastRefreshedAt, opts = {}) {
|
|
31992
32220
|
const installed = await isInstalled();
|
|
31993
32221
|
const env3 = await readCurrentEnv();
|
|
31994
32222
|
const bundlePath = getBundlePath();
|
|
31995
32223
|
const rootCount = await countPemRoots();
|
|
31996
|
-
const
|
|
31997
|
-
const
|
|
32224
|
+
const hasActiveRoot = await bundleHasActiveCaddyRoot();
|
|
32225
|
+
const probe3 = opts.probeEffectiveEnv ?? true;
|
|
32226
|
+
const effective = probe3 ? await getEffectiveEnvObservations(opts.force) : { loginShell: null, processes: [] };
|
|
32227
|
+
const observations = [];
|
|
32228
|
+
if (env3.NODE_EXTRA_CA_CERTS) {
|
|
32229
|
+
observations.push({ origin: "managed", value: env3.NODE_EXTRA_CA_CERTS, detail: getMethod() });
|
|
32230
|
+
}
|
|
32231
|
+
if (effective.loginShell) {
|
|
32232
|
+
observations.push({ origin: "login-shell", value: effective.loginShell, detail: process.env.SHELL ?? "login shell" });
|
|
32233
|
+
}
|
|
32234
|
+
observations.push(...effective.processes);
|
|
32235
|
+
const classified = classifyNodeExtraCaCerts(observations, bundlePath);
|
|
31998
32236
|
return {
|
|
31999
32237
|
installed,
|
|
32000
32238
|
method: getMethod(),
|
|
@@ -32002,7 +32240,13 @@ async function getStatus(lastRefreshedAt) {
|
|
|
32002
32240
|
bundleRootCount: rootCount,
|
|
32003
32241
|
lastRefreshedAt,
|
|
32004
32242
|
currentEnv: env3,
|
|
32005
|
-
|
|
32243
|
+
// What a NEW terminal resolves. Falls back to the managed value only when we
|
|
32244
|
+
// couldn't probe (Windows / exotic shell), never silently.
|
|
32245
|
+
effectiveNodeExtraCaCerts: probe3 ? effective.loginShell : null,
|
|
32246
|
+
nodeExtraCaCertsObservations: observations,
|
|
32247
|
+
divergentNodeExtraCaCerts: classified.divergent,
|
|
32248
|
+
conflictingNodeExtraCaCerts: classified.conflicting,
|
|
32249
|
+
bundleContainsActiveCaddyRoot: hasActiveRoot,
|
|
32006
32250
|
artifactPath: installed ? getArtifactPath() : null
|
|
32007
32251
|
};
|
|
32008
32252
|
}
|
|
@@ -32027,6 +32271,7 @@ async function remove(lastRefreshedAt) {
|
|
|
32027
32271
|
}
|
|
32028
32272
|
await fs10.rm(getBundleDir(), { recursive: true, force: true }).catch(() => {
|
|
32029
32273
|
});
|
|
32274
|
+
invalidateEffectiveEnvCache();
|
|
32030
32275
|
} catch (e) {
|
|
32031
32276
|
return { success: false, error: `Remove failed: ${e.message ?? String(e)}` };
|
|
32032
32277
|
}
|
|
@@ -32035,7 +32280,7 @@ async function remove(lastRefreshedAt) {
|
|
|
32035
32280
|
status: await getStatus(lastRefreshedAt)
|
|
32036
32281
|
};
|
|
32037
32282
|
}
|
|
32038
|
-
var execFileP, PLIST_LABEL, MANAGED_ENV_VARS, LEGACY_REPLACE_VARS, ALL_ENV_VARS;
|
|
32283
|
+
var execFileP, PLIST_LABEL, MANAGED_ENV_VARS, LEGACY_REPLACE_VARS, ALL_ENV_VARS, ENV_TOKEN_RE, PROBEABLE_SHELLS, EFFECTIVE_ENV_TTL_MS, effectiveEnvCache;
|
|
32039
32284
|
var init_bundled_runtime_trust2 = __esm({
|
|
32040
32285
|
"../../packages/core/bundled-runtime-trust.ts"() {
|
|
32041
32286
|
"use strict";
|
|
@@ -32045,6 +32290,10 @@ var init_bundled_runtime_trust2 = __esm({
|
|
|
32045
32290
|
MANAGED_ENV_VARS = ["NODE_EXTRA_CA_CERTS"];
|
|
32046
32291
|
LEGACY_REPLACE_VARS = ["SSL_CERT_FILE", "REQUESTS_CA_BUNDLE"];
|
|
32047
32292
|
ALL_ENV_VARS = [...MANAGED_ENV_VARS, ...LEGACY_REPLACE_VARS];
|
|
32293
|
+
ENV_TOKEN_RE = /\s[A-Za-z_][A-Za-z0-9_]*=/;
|
|
32294
|
+
PROBEABLE_SHELLS = /* @__PURE__ */ new Set(["sh", "bash", "zsh", "ksh", "dash", "fish"]);
|
|
32295
|
+
EFFECTIVE_ENV_TTL_MS = 3e4;
|
|
32296
|
+
effectiveEnvCache = null;
|
|
32048
32297
|
}
|
|
32049
32298
|
});
|
|
32050
32299
|
|
|
@@ -32089,11 +32338,11 @@ var init_docker_watcher = __esm({
|
|
|
32089
32338
|
import { exec as exec3 } from "child_process";
|
|
32090
32339
|
import { promisify as promisify6 } from "util";
|
|
32091
32340
|
import fs11 from "fs/promises";
|
|
32092
|
-
import
|
|
32341
|
+
import path13 from "path";
|
|
32093
32342
|
async function tailscaleKeyPath() {
|
|
32094
|
-
const dir =
|
|
32343
|
+
const dir = path13.join(await getAppSupportDir(), "secrets");
|
|
32095
32344
|
await fs11.mkdir(dir, { recursive: true, mode: 448 });
|
|
32096
|
-
return
|
|
32345
|
+
return path13.join(dir, "tailscale-api-key.secret");
|
|
32097
32346
|
}
|
|
32098
32347
|
async function persistTailscaleKey(key) {
|
|
32099
32348
|
try {
|
|
@@ -34327,7 +34576,7 @@ var require_multicast_dns = __commonJS({
|
|
|
34327
34576
|
var dgram = __require("dgram");
|
|
34328
34577
|
var thunky = require_thunky();
|
|
34329
34578
|
var events = __require("events");
|
|
34330
|
-
var
|
|
34579
|
+
var os14 = __require("os");
|
|
34331
34580
|
var noop = function() {
|
|
34332
34581
|
};
|
|
34333
34582
|
module.exports = function(opts) {
|
|
@@ -34457,14 +34706,14 @@ var require_multicast_dns = __commonJS({
|
|
|
34457
34706
|
return that;
|
|
34458
34707
|
};
|
|
34459
34708
|
function defaultInterface() {
|
|
34460
|
-
var networks =
|
|
34709
|
+
var networks = os14.networkInterfaces();
|
|
34461
34710
|
var names = Object.keys(networks);
|
|
34462
34711
|
for (var i = 0; i < names.length; i++) {
|
|
34463
34712
|
var net2 = networks[names[i]];
|
|
34464
34713
|
for (var j = 0; j < net2.length; j++) {
|
|
34465
34714
|
var iface = net2[j];
|
|
34466
34715
|
if (isIPv4(iface.family) && !iface.internal) {
|
|
34467
|
-
if (
|
|
34716
|
+
if (os14.platform() === "darwin" && names[i] === "en0") return iface.address;
|
|
34468
34717
|
return "0.0.0.0";
|
|
34469
34718
|
}
|
|
34470
34719
|
}
|
|
@@ -34472,7 +34721,7 @@ var require_multicast_dns = __commonJS({
|
|
|
34472
34721
|
return "127.0.0.1";
|
|
34473
34722
|
}
|
|
34474
34723
|
function allInterfaces() {
|
|
34475
|
-
var networks =
|
|
34724
|
+
var networks = os14.networkInterfaces();
|
|
34476
34725
|
var names = Object.keys(networks);
|
|
34477
34726
|
var res = [];
|
|
34478
34727
|
for (var i = 0; i < names.length; i++) {
|
|
@@ -34526,7 +34775,7 @@ var init_mapping_scope = __esm({
|
|
|
34526
34775
|
|
|
34527
34776
|
// ../../packages/core/dns-platform.ts
|
|
34528
34777
|
import fs12 from "fs/promises";
|
|
34529
|
-
import
|
|
34778
|
+
import path14 from "path";
|
|
34530
34779
|
function getManagedDomainSuffixes() {
|
|
34531
34780
|
const store = useStore2.getState();
|
|
34532
34781
|
const suffixes = /* @__PURE__ */ new Set();
|
|
@@ -34545,7 +34794,7 @@ async function buildMacOsCleanupCommand() {
|
|
|
34545
34794
|
const files = await fs12.readdir(resolverDir);
|
|
34546
34795
|
const toRemove = [];
|
|
34547
34796
|
for (const file of files) {
|
|
34548
|
-
const filePath =
|
|
34797
|
+
const filePath = path14.join(resolverDir, file);
|
|
34549
34798
|
try {
|
|
34550
34799
|
const content = await fs12.readFile(filePath, "utf-8");
|
|
34551
34800
|
if (content.includes(SUPBUDDY_MARKER)) {
|
|
@@ -34619,7 +34868,7 @@ async function auditMacOsResolver(expected) {
|
|
|
34619
34868
|
const present = [];
|
|
34620
34869
|
for (const file of entries) {
|
|
34621
34870
|
try {
|
|
34622
|
-
const content = await fs12.readFile(
|
|
34871
|
+
const content = await fs12.readFile(path14.join(resolverDir, file), "utf-8");
|
|
34623
34872
|
if (content.includes(SUPBUDDY_MARKER)) present.push(file);
|
|
34624
34873
|
} catch {
|
|
34625
34874
|
}
|
|
@@ -36595,7 +36844,7 @@ var require_udp2 = __commonJS({
|
|
|
36595
36844
|
"use strict";
|
|
36596
36845
|
var udp = __require("dgram");
|
|
36597
36846
|
var net2 = __require("net");
|
|
36598
|
-
var
|
|
36847
|
+
var crypto7 = __require("crypto");
|
|
36599
36848
|
var Packet3 = require_packet();
|
|
36600
36849
|
var { debuglog } = __require("util");
|
|
36601
36850
|
var debug = debuglog("dns2");
|
|
@@ -36609,7 +36858,7 @@ var require_udp2 = __commonJS({
|
|
|
36609
36858
|
return (name, type2 = "A", cls = Packet3.CLASS.IN, options = {}) => {
|
|
36610
36859
|
const { clientIp, recursive = true } = options;
|
|
36611
36860
|
const query = new Packet3();
|
|
36612
|
-
query.header.id =
|
|
36861
|
+
query.header.id = crypto7.randomInt(65536);
|
|
36613
36862
|
if (recursive) {
|
|
36614
36863
|
query.header.rd = 1;
|
|
36615
36864
|
}
|
|
@@ -36881,21 +37130,21 @@ var init_dns_server = __esm({
|
|
|
36881
37130
|
|
|
36882
37131
|
// ../../packages/core/caddyfile-generator.ts
|
|
36883
37132
|
import fs13 from "fs/promises";
|
|
36884
|
-
import
|
|
36885
|
-
import
|
|
37133
|
+
import path15 from "path";
|
|
37134
|
+
import os9 from "os";
|
|
36886
37135
|
async function getCaddyfileDir() {
|
|
36887
37136
|
const platform = process.platform;
|
|
36888
37137
|
let userDataPath;
|
|
36889
37138
|
if (platform === "darwin") {
|
|
36890
|
-
userDataPath =
|
|
37139
|
+
userDataPath = path15.join(os9.homedir(), "Library", "Application Support", "Supbuddy");
|
|
36891
37140
|
} else if (platform === "win32") {
|
|
36892
|
-
userDataPath =
|
|
36893
|
-
process.env.APPDATA ||
|
|
37141
|
+
userDataPath = path15.join(
|
|
37142
|
+
process.env.APPDATA || path15.join(os9.homedir(), "AppData", "Roaming"),
|
|
36894
37143
|
"Supbuddy"
|
|
36895
37144
|
);
|
|
36896
37145
|
} else {
|
|
36897
|
-
userDataPath =
|
|
36898
|
-
process.env.XDG_CONFIG_HOME ||
|
|
37146
|
+
userDataPath = path15.join(
|
|
37147
|
+
process.env.XDG_CONFIG_HOME || path15.join(os9.homedir(), ".config"),
|
|
36899
37148
|
"Supbuddy"
|
|
36900
37149
|
);
|
|
36901
37150
|
}
|
|
@@ -36915,7 +37164,7 @@ async function writeFileAtomic(filePath, content) {
|
|
|
36915
37164
|
}
|
|
36916
37165
|
async function generateCaddyfile(mappings, settings, options = {}, validate) {
|
|
36917
37166
|
const caddyfileDir = await getCaddyfileDir();
|
|
36918
|
-
const caddyfilePath =
|
|
37167
|
+
const caddyfilePath = path15.join(caddyfileDir, "Caddyfile");
|
|
36919
37168
|
const caddyfileContent = buildCaddyfileContent(mappings, settings, options);
|
|
36920
37169
|
if (validate) {
|
|
36921
37170
|
const res = await validate(caddyfileContent);
|
|
@@ -37048,7 +37297,7 @@ function buildCaddyfileContent(mappings, settings, options = {}) {
|
|
|
37048
37297
|
}
|
|
37049
37298
|
async function getCaddyDataDir2() {
|
|
37050
37299
|
const caddyfileDir = await getCaddyfileDir();
|
|
37051
|
-
const dataDir =
|
|
37300
|
+
const dataDir = path15.join(caddyfileDir, "caddy-data");
|
|
37052
37301
|
await fs13.mkdir(dataDir, { recursive: true });
|
|
37053
37302
|
return dataDir;
|
|
37054
37303
|
}
|
|
@@ -37105,9 +37354,9 @@ var init_env_utils = __esm({
|
|
|
37105
37354
|
});
|
|
37106
37355
|
|
|
37107
37356
|
// ../../packages/core/project-env.ts
|
|
37108
|
-
import
|
|
37357
|
+
import path16 from "path";
|
|
37109
37358
|
async function resolveProjectEnv(projectPath) {
|
|
37110
|
-
const all = await readEnvFileAsDict(
|
|
37359
|
+
const all = await readEnvFileAsDict(path16.join(projectPath, ".env.local"));
|
|
37111
37360
|
const out = {};
|
|
37112
37361
|
for (const [k, v] of Object.entries(all)) {
|
|
37113
37362
|
if (k.startsWith("SUPABASE_")) out[k] = v;
|
|
@@ -37377,8 +37626,8 @@ async function isSupabaseInitialized(projectPath) {
|
|
|
37377
37626
|
const { promisify: promisify15 } = await import("util");
|
|
37378
37627
|
const execAsync9 = promisify15(exec9);
|
|
37379
37628
|
const fs33 = await import("fs/promises");
|
|
37380
|
-
const
|
|
37381
|
-
const supabasePath =
|
|
37629
|
+
const path38 = await import("path");
|
|
37630
|
+
const supabasePath = path38.join(projectPath, "supabase");
|
|
37382
37631
|
await fs33.access(supabasePath);
|
|
37383
37632
|
return true;
|
|
37384
37633
|
} catch {
|
|
@@ -37402,8 +37651,8 @@ function parseFieldFromBlock(block, field, fallback) {
|
|
|
37402
37651
|
async function parseConfigPort(projectPath, section, fallback, field = "port") {
|
|
37403
37652
|
try {
|
|
37404
37653
|
const fs33 = await import("fs/promises");
|
|
37405
|
-
const
|
|
37406
|
-
const content = await fs33.readFile(
|
|
37654
|
+
const path38 = await import("path");
|
|
37655
|
+
const content = await fs33.readFile(path38.join(projectPath, "supabase", "config.toml"), "utf-8");
|
|
37407
37656
|
const block = extractSectionBlock(content, section);
|
|
37408
37657
|
if (!block) return fallback;
|
|
37409
37658
|
return parseFieldFromBlock(block, field, fallback);
|
|
@@ -37413,10 +37662,10 @@ async function parseConfigPort(projectPath, section, fallback, field = "port") {
|
|
|
37413
37662
|
}
|
|
37414
37663
|
async function readSupabasePorts(projectPath) {
|
|
37415
37664
|
const fs33 = await import("fs/promises");
|
|
37416
|
-
const
|
|
37665
|
+
const path38 = await import("path");
|
|
37417
37666
|
let content = "";
|
|
37418
37667
|
try {
|
|
37419
|
-
content = await fs33.readFile(
|
|
37668
|
+
content = await fs33.readFile(path38.join(projectPath, "supabase", "config.toml"), "utf-8");
|
|
37420
37669
|
} catch {
|
|
37421
37670
|
return { db: 54322, api: 54321, studio: 54323, inbucket: 54324, shadow: 54320, pooler: 54329, smtp: 54325, pop3: 54326, analytics: 54327 };
|
|
37422
37671
|
}
|
|
@@ -37758,10 +38007,10 @@ function takenSupabaseProjectIds(projects, excludeId) {
|
|
|
37758
38007
|
}
|
|
37759
38008
|
async function resolveSupaDir(project) {
|
|
37760
38009
|
if (!project.path) return null;
|
|
37761
|
-
const
|
|
38010
|
+
const path38 = await import("path");
|
|
37762
38011
|
const fs33 = await import("fs/promises");
|
|
37763
|
-
const supaDir = project.supabasePath ?
|
|
37764
|
-
const configPath =
|
|
38012
|
+
const supaDir = project.supabasePath ? path38.join(project.path, project.supabasePath) : project.path;
|
|
38013
|
+
const configPath = path38.join(supaDir, "supabase", "config.toml");
|
|
37765
38014
|
try {
|
|
37766
38015
|
await fs33.access(configPath);
|
|
37767
38016
|
} catch {
|
|
@@ -37928,14 +38177,14 @@ function buildL4AppConfig() {
|
|
|
37928
38177
|
}
|
|
37929
38178
|
return { servers };
|
|
37930
38179
|
}
|
|
37931
|
-
function adminRequest(method,
|
|
38180
|
+
function adminRequest(method, path38, body) {
|
|
37932
38181
|
return new Promise((resolve, reject) => {
|
|
37933
38182
|
const payload = body === void 0 ? void 0 : JSON.stringify(body);
|
|
37934
38183
|
const req = http.request(
|
|
37935
38184
|
{
|
|
37936
38185
|
host: ADMIN_HOST,
|
|
37937
38186
|
port: ADMIN_PORT,
|
|
37938
|
-
path:
|
|
38187
|
+
path: path38,
|
|
37939
38188
|
method,
|
|
37940
38189
|
headers: payload ? { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(payload) } : {},
|
|
37941
38190
|
timeout: 5e3
|
|
@@ -38144,7 +38393,7 @@ var init_caddy_supervisor = __esm({
|
|
|
38144
38393
|
import { spawn as spawn6, execFile as execFile5 } from "child_process";
|
|
38145
38394
|
import { promisify as promisify8 } from "util";
|
|
38146
38395
|
import { randomUUID } from "crypto";
|
|
38147
|
-
import
|
|
38396
|
+
import path17 from "path";
|
|
38148
38397
|
import fs15 from "fs/promises";
|
|
38149
38398
|
import nodeProcess2 from "process";
|
|
38150
38399
|
function getCaddyBinaryPath() {
|
|
@@ -38160,18 +38409,18 @@ function getCaddyBinaryPath() {
|
|
|
38160
38409
|
}
|
|
38161
38410
|
const bundledBinDir = nodeProcess2.env.SUPBUDDY_BIN_DIR;
|
|
38162
38411
|
if (bundledBinDir) {
|
|
38163
|
-
return
|
|
38412
|
+
return path17.join(bundledBinDir, binaryName);
|
|
38164
38413
|
}
|
|
38165
38414
|
const isDev = process.env.NODE_ENV !== "production";
|
|
38166
38415
|
if (isDev) {
|
|
38167
|
-
return
|
|
38416
|
+
return path17.join(process.cwd(), "resources", "bin", binaryName);
|
|
38168
38417
|
} else {
|
|
38169
|
-
return
|
|
38418
|
+
return path17.join(process.resourcesPath, "bin", binaryName);
|
|
38170
38419
|
}
|
|
38171
38420
|
}
|
|
38172
38421
|
async function reapStaleCaddyProcesses() {
|
|
38173
38422
|
if (process.platform === "win32") return;
|
|
38174
|
-
const binaryName =
|
|
38423
|
+
const binaryName = path17.basename(getCaddyBinaryPath());
|
|
38175
38424
|
let survivors = await listCaddyPids(binaryName);
|
|
38176
38425
|
for (const pid of survivors) {
|
|
38177
38426
|
sendSignalIgnoringMissing(pid, "SIGTERM");
|
|
@@ -38264,7 +38513,7 @@ async function doStartCaddyServer() {
|
|
|
38264
38513
|
...process.env,
|
|
38265
38514
|
HOME: homeDir,
|
|
38266
38515
|
XDG_DATA_HOME: dataDir,
|
|
38267
|
-
XDG_CONFIG_HOME:
|
|
38516
|
+
XDG_CONFIG_HOME: path17.dirname(caddyfilePath)
|
|
38268
38517
|
};
|
|
38269
38518
|
caddyProcess = spawn6(binaryPath, ["run", "--config", caddyfilePath, "--adapter", "caddyfile"], {
|
|
38270
38519
|
env: caddyEnv,
|
|
@@ -38354,6 +38603,7 @@ async function stopCaddyServer() {
|
|
|
38354
38603
|
await caddySupervisor.quiesce();
|
|
38355
38604
|
caddySupervisor.reset();
|
|
38356
38605
|
if (!caddyProcess) {
|
|
38606
|
+
await reapStaleCaddyProcesses();
|
|
38357
38607
|
return;
|
|
38358
38608
|
}
|
|
38359
38609
|
store.setProxyStatus("stopping");
|
|
@@ -38379,6 +38629,7 @@ async function stopCaddyServer() {
|
|
|
38379
38629
|
}
|
|
38380
38630
|
});
|
|
38381
38631
|
caddyProcess = null;
|
|
38632
|
+
await reapStaleCaddyProcesses();
|
|
38382
38633
|
store.setProxyStatus("idle");
|
|
38383
38634
|
console.log("[Caddy] Server stopped");
|
|
38384
38635
|
} catch (error) {
|
|
@@ -38438,7 +38689,7 @@ function isCaddyErrorLine(line) {
|
|
|
38438
38689
|
async function validateCaddyfileContent(content) {
|
|
38439
38690
|
const binaryPath = getCaddyBinaryPath();
|
|
38440
38691
|
const dir = await getCaddyfileDir();
|
|
38441
|
-
const tmpPath =
|
|
38692
|
+
const tmpPath = path17.join(dir, `Caddyfile.validate.${process.pid}.${caddyValidateCounter++}.tmp`);
|
|
38442
38693
|
const execFileAsync6 = promisify8(execFile5);
|
|
38443
38694
|
try {
|
|
38444
38695
|
await fs15.writeFile(tmpPath, content, "utf-8");
|
|
@@ -38531,13 +38782,7 @@ async function stopAllServices(deps = realDeps()) {
|
|
|
38531
38782
|
});
|
|
38532
38783
|
});
|
|
38533
38784
|
await step("stopDnsServer", () => deps.stopDnsServer());
|
|
38534
|
-
|
|
38535
|
-
await step("isCaddyRunning", () => {
|
|
38536
|
-
caddyRunning = deps.isCaddyRunning();
|
|
38537
|
-
});
|
|
38538
|
-
if (caddyRunning) {
|
|
38539
|
-
await step("stopCaddyServer", () => deps.stopCaddyServer());
|
|
38540
|
-
}
|
|
38785
|
+
await step("stopCaddyServer", () => deps.stopCaddyServer());
|
|
38541
38786
|
}
|
|
38542
38787
|
var realDeps;
|
|
38543
38788
|
var init_stop_all_services = __esm({
|
|
@@ -39020,7 +39265,7 @@ var init_ca_and_trust = __esm({
|
|
|
39020
39265
|
});
|
|
39021
39266
|
|
|
39022
39267
|
// ../../packages/core/system-doctor/checks/orphan-mcp-secrets.ts
|
|
39023
|
-
import
|
|
39268
|
+
import path18 from "path";
|
|
39024
39269
|
function secretKey(clientId) {
|
|
39025
39270
|
return clientId.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
39026
39271
|
}
|
|
@@ -39032,8 +39277,8 @@ function liveSecretKeys() {
|
|
|
39032
39277
|
return new Set(clients.filter((c) => !c.revoked).map((c) => secretKey(c.id)));
|
|
39033
39278
|
}
|
|
39034
39279
|
function isRemovableSecret(p, dir, live) {
|
|
39035
|
-
if (
|
|
39036
|
-
const m = SECRET_RE.exec(
|
|
39280
|
+
if (path18.dirname(p) !== dir) return false;
|
|
39281
|
+
const m = SECRET_RE.exec(path18.basename(p));
|
|
39037
39282
|
return m !== null && !live.has(m[1]);
|
|
39038
39283
|
}
|
|
39039
39284
|
var SECRET_RE;
|
|
@@ -39047,7 +39292,7 @@ var init_orphan_mcp_secrets = __esm({
|
|
|
39047
39292
|
|
|
39048
39293
|
// ../../packages/core/system-doctor/wipe/steps/revoked-mcp-secrets.ts
|
|
39049
39294
|
import fs19 from "fs/promises";
|
|
39050
|
-
import
|
|
39295
|
+
import path19 from "path";
|
|
39051
39296
|
var revokedMcpSecrets;
|
|
39052
39297
|
var init_revoked_mcp_secrets = __esm({
|
|
39053
39298
|
"../../packages/core/system-doctor/wipe/steps/revoked-mcp-secrets.ts"() {
|
|
@@ -39058,7 +39303,7 @@ var init_revoked_mcp_secrets = __esm({
|
|
|
39058
39303
|
tiers: ["deep", "full"],
|
|
39059
39304
|
destroysUserData: false,
|
|
39060
39305
|
async build(ctx) {
|
|
39061
|
-
const dir =
|
|
39306
|
+
const dir = path19.join(ctx.appSupportDir, "secrets");
|
|
39062
39307
|
let live;
|
|
39063
39308
|
try {
|
|
39064
39309
|
live = liveSecretKeys();
|
|
@@ -39071,11 +39316,11 @@ var init_revoked_mcp_secrets = __esm({
|
|
|
39071
39316
|
} catch {
|
|
39072
39317
|
return [];
|
|
39073
39318
|
}
|
|
39074
|
-
const targets = entries.filter((e) => e.isFile()).map((e) =>
|
|
39319
|
+
const targets = entries.filter((e) => e.isFile()).map((e) => path19.join(dir, e.name)).filter((p) => isRemovableSecret(p, dir, live));
|
|
39075
39320
|
if (targets.length === 0) return [];
|
|
39076
39321
|
return [
|
|
39077
39322
|
{
|
|
39078
|
-
label: `Delete ${targets.length} dead MCP token secret(s) from ${dir}: ${targets.map((p) =>
|
|
39323
|
+
label: `Delete ${targets.length} dead MCP token secret(s) from ${dir}: ${targets.map((p) => path19.basename(p)).join(", ")}`,
|
|
39079
39324
|
destructive: true,
|
|
39080
39325
|
run: async () => {
|
|
39081
39326
|
const failures = [];
|
|
@@ -39209,7 +39454,7 @@ var init_orphan_dind = __esm({
|
|
|
39209
39454
|
});
|
|
39210
39455
|
|
|
39211
39456
|
// ../../packages/core/system-doctor/wipe/steps/tier3-targets.ts
|
|
39212
|
-
import
|
|
39457
|
+
import path20 from "path";
|
|
39213
39458
|
function projectSnapshot() {
|
|
39214
39459
|
return [...useStore2.getState().projects];
|
|
39215
39460
|
}
|
|
@@ -39281,7 +39526,7 @@ async function dindTargets(ctx) {
|
|
|
39281
39526
|
return targets;
|
|
39282
39527
|
}
|
|
39283
39528
|
async function requireArchive(ctx, vol) {
|
|
39284
|
-
const archive =
|
|
39529
|
+
const archive = path20.join(backupDirFor(ctx.appSupportDir, ctx.stamp), `${vol}.tar.gz`);
|
|
39285
39530
|
let size = -1;
|
|
39286
39531
|
try {
|
|
39287
39532
|
size = (await ctx.fs.stat(archive)).size;
|
|
@@ -39310,9 +39555,9 @@ var init_tier3_targets = __esm({
|
|
|
39310
39555
|
|
|
39311
39556
|
// ../../packages/core/system-doctor/wipe/steps/backup-project-data.ts
|
|
39312
39557
|
import fs20 from "fs/promises";
|
|
39313
|
-
import
|
|
39558
|
+
import path21 from "path";
|
|
39314
39559
|
function dumpAction(p, container, dir, ctx) {
|
|
39315
|
-
const dest =
|
|
39560
|
+
const dest = path21.join(dir, `supabase-${p.id}.pgc`);
|
|
39316
39561
|
return {
|
|
39317
39562
|
label: `Back up the Supabase database of "${p.name ?? p.id}" (pg_dump of ${container}) to ${dest}`,
|
|
39318
39563
|
destructive: false,
|
|
@@ -39328,7 +39573,7 @@ function dumpAction(p, container, dir, ctx) {
|
|
|
39328
39573
|
`Backup of "${p.name ?? p.id}" is truncated: copied ${size} of ${dump2.bytes} bytes to ${dest}`
|
|
39329
39574
|
);
|
|
39330
39575
|
}
|
|
39331
|
-
await ctx.fs.writeFile(`${dest}.sha256`, `${dump2.sha256} ${
|
|
39576
|
+
await ctx.fs.writeFile(`${dest}.sha256`, `${dump2.sha256} ${path21.basename(dest)}
|
|
39332
39577
|
`);
|
|
39333
39578
|
} finally {
|
|
39334
39579
|
await fs20.rm(dump2.dir, { recursive: true, force: true }).catch(() => {
|
|
@@ -39369,7 +39614,7 @@ var init_backup_project_data = __esm({
|
|
|
39369
39614
|
}
|
|
39370
39615
|
for (const vol of [...new Set(volumes)]) {
|
|
39371
39616
|
actions.push({
|
|
39372
|
-
label: `Archive docker volume '${vol}' to ${
|
|
39617
|
+
label: `Archive docker volume '${vol}' to ${path21.join(dir, `${vol}.tar.gz`)} (may take several minutes)`,
|
|
39373
39618
|
destructive: false,
|
|
39374
39619
|
// Never hand-rolled: backupDockerVolume prechecks the volume, archives on
|
|
39375
39620
|
// the long-timeout THROWING seam and proves the result with `gzip -t`.
|
|
@@ -39386,7 +39631,7 @@ var init_backup_project_data = __esm({
|
|
|
39386
39631
|
|
|
39387
39632
|
// ../../packages/core/project-context/detect.ts
|
|
39388
39633
|
import fs21 from "fs/promises";
|
|
39389
|
-
import
|
|
39634
|
+
import path22 from "path";
|
|
39390
39635
|
async function isDir(p) {
|
|
39391
39636
|
try {
|
|
39392
39637
|
const st = await fs21.stat(p);
|
|
@@ -39399,12 +39644,12 @@ async function detectTargets(projectPath) {
|
|
|
39399
39644
|
return {
|
|
39400
39645
|
agents_md: true,
|
|
39401
39646
|
claude_md: true,
|
|
39402
|
-
cursor: await isDir(
|
|
39403
|
-
claude_skills: await isDir(
|
|
39404
|
-
windsurf: await isDir(
|
|
39405
|
-
continue: await isDir(
|
|
39406
|
-
copilot: await isDir(
|
|
39407
|
-
jetbrains: await isDir(
|
|
39647
|
+
cursor: await isDir(path22.join(projectPath, ".cursor")),
|
|
39648
|
+
claude_skills: await isDir(path22.join(projectPath, ".claude")),
|
|
39649
|
+
windsurf: await isDir(path22.join(projectPath, ".codeium", "windsurf")),
|
|
39650
|
+
continue: await isDir(path22.join(projectPath, ".continue")),
|
|
39651
|
+
copilot: await isDir(path22.join(projectPath, ".github")),
|
|
39652
|
+
jetbrains: await isDir(path22.join(projectPath, ".idea"))
|
|
39408
39653
|
};
|
|
39409
39654
|
}
|
|
39410
39655
|
var init_detect = __esm({
|
|
@@ -39418,7 +39663,7 @@ var DOCS_MARKDOWN;
|
|
|
39418
39663
|
var init_docs_generated = __esm({
|
|
39419
39664
|
"../../packages/core/project-context/docs.generated.ts"() {
|
|
39420
39665
|
"use strict";
|
|
39421
|
-
DOCS_MARKDOWN = "# Supbuddy docs\n\n> Run multiple Supabase projects at once on one Mac, each with its own custom local domain.\n\n## Getting started\n\nThere are two ways to run Supbuddy. Use the **macOS desktop app** (steps below), or the **command-line interface**, which runs on macOS and Linux. For the CLI, install it with `npx supbuddy@latest` and jump to [Command-line interface](#command-line-interface-cli). The app and the CLI share the same state, so you can use either or both.\n\n### 1. Install\n\nDownload the latest `.dmg` from the [download page](/api/download). Drag **Supbuddy.app** into `/Applications` and launch it. Supbuddy is signed and notarized; macOS will not show a Gatekeeper warning. Requires an Apple Silicon Mac (M1/M2/M3/M4, arm64). The desktop app is macOS-only in v2, but the headless CLI runs on Linux too. See [Command-line interface](#command-line-interface-cli).\n\n### 2. Trust the local Certificate Authority\n\nCaddy mints its local CA the first time it actually serves a site, so the cert only exists once you have **at least one enabled mapping and the proxy running** \u2014 an empty proxy never generates it. With that in place, open the app and click **Install** (the first-launch prompt, or **Settings \u2192 Network** later). Supbuddy adds the CA (Caddy's internal PKI at `~/Library/Application Support/Supbuddy/caddy-data/caddy/pki/authorities/local/root.crt`) to your **System keychain** via `sudo security add-trusted-cert`; macOS asks for your password once. Caddy does **not** self-install trust (the generated Caddyfile sets `skip_install_trust`), so this button is what makes the padlock green \u2014 fully quit and reopen your browser afterward to pick it up. Every Supbuddy domain then gets HTTPS with no per-domain prompts or warnings. (On Windows the install is manual: Supbuddy shows the PowerShell `Import-Certificate \u2026 -CertStoreLocation Cert:\\LocalMachine\\Root` command to run as Administrator.)\n\nCaddy names its root by year, so each yearly rotation (or a data wipe) leaves a same-name root behind with a different key. On every Install, Supbuddy first removes any stale `Caddy Local Authority` roots whose fingerprint doesn't match the current one, then adds the current root \u2014 leftover mismatched roots otherwise make Firefox-family browsers fail with `SEC_ERROR_BAD_SIGNATURE`.\n\n**Firefox, Zen, and Brave keep their own certificate store** that Supbuddy can't reach (they don't consult the System keychain). After a CA change, either delete any stale `Caddy Local Authority` entries from the browser's own certificate manager and re-import the new root, or \u2014 on Firefox/Zen \u2014 set `security.enterprise_roots.enabled` to `true` in `about:config` so the browser reads the System keychain.\n\nIf Supbuddy detects an AI tool that ships its own JavaScript runtime (Claude Code, Cursor, Windsurf, Continue, Codex CLI, OpenCode, etc.) it will also offer to enable **Bundled-runtime trust** in the same first-run prompt. Those tools don't read the system Keychain (they carry their own Mozilla CA bundle), so without this setup the first OAuth/MCP connection to a `*.test` URL fails with `unable to get local issuer certificate`. Enable it once and Supbuddy keeps it in sync (including across yearly Caddy CA rotation). See the **Bundled-runtime trust** section under Settings \u2192 General for details.\n\nIf you skip the prompt, you can re-trigger it any time from the **Settings \u2192 Network** tab.\n\n### 3. Add your first project\n\nClick **Add project** in the Configure tab and pick a project root folder (the one with `package.json` and/or `supabase/config.toml`). Supbuddy scans it and creates auto-mapped subdomains based on what it finds:\n\n- Supabase Kong \u2192 `api.<project>.test`\n- Supabase Studio \u2192 `studio.<project>.test`\n- Supabase Inbucket / Mailpit \u2192 `mail.<project>.test`\n- Each detected app (Next.js, Vite, etc.) \u2192 `<app-name>.<project>.test`\n\nThe default TLD is `.test`. You can change it project-wide in **Settings \u2192 General \u2192 Default TLD**.\n\n### 4. Start the proxy\n\nToggle the project on. Supbuddy starts Caddy on port 8443 (HTTPS) and starts its built-in DNS server on port 5353. If you want real ports 80/443 instead of 8080/8443, enable **port forwarding** in **Settings \u2192 Network**. Supbuddy inserts a `pfctl` redirect rule into `/etc/pf.conf` (asks for sudo once) and reports whether the redirect is actually being enforced via a live 443 probe \u2014 not merely that the rule is on disk. If port forwarding is on but 443 won't connect, see [Port forwarding is on but 443 won't connect](#port-forwarding-is-on-but-443-wont-connect).\n\n> If the one-time sudo prompt is cancelled or fails, Supbuddy no longer aborts the start: Caddy still comes up and HTTPS keeps working on the high port (8443), and the proxy shows a degraded **error** state with a **Retry** so you can re-run the privileged setup. The CA is still generated in this state.\n\n## Core concepts\n\nFour things to understand:\n\n- **Project**: a folder you registered. Holds detected *apps* (Next.js, Vite, etc.), detected *services* (Supabase stack, Docker Compose services), and a list of *mappings*.\n- **Mapping**: a domain \u2192 port pair (e.g. `api.acme.test \u2192 54321`). Auto-generated mappings are tied to a detected service or app; you can also create manual ones.\n- **Isolation mode**: per-project. One of:\n - `thin` (lightweight, **the default for newly registered projects**): still your host Docker (no nested containers, no DinD), but Supbuddy gives each project its own **port block** and a unique Compose `project_id`, written into that project's `supabase/config.toml`. That's what lets several Supabase projects run **at once on the shared daemon**, each reached by name (`api.<project>.test`, `studio.<project>.test`). Apps bind a **per-project loopback IP** (127.0.0.2, 127.0.0.3, \u2026) so every project's dev servers keep their canonical ports \u2014 each project gets its *own* `:3000`. Start dev servers with `supbuddy run -- <dev command>` so they bind that IP. Supbuddy owns those config.toml keys while the project is `thin` and restores them the moment you switch back to `host`.\n - `host`: everything shares `127.0.0.1` and the stock ports. Dev-server ports collide across projects, and only one host-mode Supabase project can run at a time (the standard `supabase start` constraint). Use `host` **only when the project's Supabase stack is already running on the host independently of Supbuddy** (you run `supabase start` yourself and don't want Supbuddy re-porting `config.toml`). MCP registration (`register_project`) detects that case and keeps such projects on `host` automatically; in the app's Add-project dialog, pick **Host** in the Environment section yourself.\n- **Active vs inactive**: any project can be \"active\" (proxied + reachable) or inactive. Inactive projects keep their state, so flipping them on is a few seconds. Run as many active projects as you want.\n\n## Project cards (Configure tab)\n\nEach registered project appears as a card in the Configure tab. Cards have a single-row header that's always visible and a tab-based body that expands on click.\n\n### Header\n\nReading left to right:\n\n- **Expand chevron** + **project name**: click to expand/collapse the card.\n- **Status indicator**: a single colored dot next to the project name aggregating the realtime state of every subsystem (Supabase services, Compose, scripts, AI sync, port conflicts, next.config warnings). Red = error, amber = warning, green = at least one service running, muted gray = idle, animated cyan spinner = transitioning. Hover for a tooltip that lists each subsystem's state.\n- **Tech badges**: e.g. `TurboRepo`, `Supabase` (shown when detected).\n\n**Supabase connection warning.** When a project's app `.env` is missing the\nSupabase connection vars, or they've gone stale relative to the live target\n(e.g. after switching isolation, which republishes ports), the card shows a\n`supabase env: not connected` / `supabase env: out of date` pill. Click it to\nopen Connect and push fresh values, or choose **Ignore for this project**.\n- **Env mode chip**: read-only `Host` or `Thin` label (matching the project's isolation mode). To switch modes, open the **Supabase** tab and use the **Environment** section at the top.\n- **Issues counter**: red for errors, amber for warnings. Click to open the **issues popover** (see below). Hidden when there are no issues.\n- **Warnings chip**: all project-level warnings (isolation drift, missing env vars, config issues, etc.) are consolidated into a single amber chip next to the enable toggle. Click it to see each warning item-by-item; it shows a spinner while Supbuddy re-checks the project.\n- **Enable toggle** (right edge): turn the project's proxy on/off without deleting it.\n- **\u22EF actions menu** (right edge): every project-level action: **Edit project**, **Rescan**, **Re-check configs** (re-runs the connection/env drift check for this project), **Select folder**, **Export bundle**, and **Delete project**.\n\n### Issues popover\n\nClicking the issues counter opens a popover listing all current errors and warnings. Each issue shows a severity icon, title, optional detail, and a **\u2192 open {tab}** link. Clicking the link jumps to the relevant tab and closes the popover.\n\n### Body tabs (when expanded)\n\nThe body renders a flat tab strip with 6 conditional tabs. Below ~480 px, the strip collapses to a dropdown selector. (Project-level actions, like edit, rescan, re-check configs, select folder, export, and delete, are in the header's **\u22EF menu**, not a tab.)\n\n#### Apps (default tab)\n\nPer-app rows are domain-first: `domain \u2192 :port` (with hover-revealed copy/open URL buttons), then app name + tech badge, then a flex spacer pushes hover-revealed **edit** / **delete** / **access** (LAN / Tailscale state) actions and the per-mapping **toggle** to the right edge. A **Map** CTA appears on hover for unmapped apps. Manual mappings scoped to this project (not auto-generated) are listed below under their own subheader.\n\n#### Supabase (shown when Supabase is detected)\n\n**Environment section (top):** host/thin switcher. A legacy project still on the old Isolated (VM) mode shows the migration wizard here instead (see [Migrating a legacy Isolated (VM) project to Thin](#migrating-a-legacy-isolated-vm-project-to-thin)).\n\n**Action bar:** Start, Stop, Restart buttons; a first-class **Connect** button (cyan, opens the connection panel for `.env` generation / merge); and a **More** menu with **Config editor** and **Details**.\n\n**Config editor: secret extraction.** When you save a `supabase/config.toml` that contains a secret-bearing value inline (e.g. an SMTP password under `[auth.email.smtp]`, an OAuth `secret`, or any `*_key`/`auth_token`), Supbuddy prompts before writing: it lists the detected secrets and lets you pick which gitignored env file to move them to (defaulting to the project-root `.env.local`). The value is written there and replaced in `config.toml` with an `env(SUPABASE_\u2026)` reference, so secrets never land in git. Supbuddy injects those `SUPABASE_`-prefixed values back into the `supabase start` environment so the references resolve. (Saving a config with no inline secrets writes directly, with no prompt.)\n\n**Service rows** (read-only): status dot, service name, URL. No inline actions; lifecycle is driven by the action bar.\n\n#### Compose (shown when Compose services are detected)\n\n**Action bar:** Start, Stop, Restart. **Service rows** are read-only (status dot, name, URL). Add-on services declared in `supbuddy.addons.yml` (see **Add-on Compose services**) appear here alongside the base stack and in `get_compose_status` over MCP.\n\n#### Other (shown when non-Supabase, non-Compose services are detected)\n\nRead-only service rows: status dot, name, URL.\n\n#### Scripts (shown when scripts are detected)\n\nBookmarked scripts appear in a **Quick Access** group at the top; remaining scripts appear under **Other Scripts**. Per-script row: status dot, name, uptime, bookmark star, Start/Stop/Restart buttons. A search input appears when there are more than 5 scripts.\n\n#### AI Tools\n\nWraps the project-context-sync panel: sync mode selector (Auto / Manual / Off), detected targets list with per-target **scope** (global / local), advanced options, and recent activity. See [Per-project AI context sync](#per-project-ai-context-sync) for what global vs. local means.\n\n> Project-level actions (**Edit**, **Rescan**, **Re-check configs**, **Select folder**, **Export bundle**, **Delete**) are no longer a tab. They live in the header's **\u22EF actions menu**.\n\n---\n\n## Multiple Supabase projects (the main use case)\n\nThe reason Supbuddy exists. Stock Supabase CLI binds to fixed ports (54321 Kong, 54322 Postgres, 54323 Studio, 54324 Inbucket). Two projects on the same machine collide; you must `supabase stop` one before `supabase start`-ing the other.\n\nTwo ways to break that constraint, picked per project in the **Supabase** tab \u2192 **Environment** section:\n\n### Thin (lightweight, recommended)\n\nSwitch a project to **Thin**. Supbuddy assigns it a free port block (in the `55000+` range), writes those ports plus a unique Compose `project_id` into its `supabase/config.toml`, and runs `supabase start` on your **normal host Docker**, with no nested containers and nothing to pull. Several projects boot side by side this way; each is reached by name (`api.acme.test`, `studio.acme.test`, `mail.acme.test`). Switch back to **Host** and Supbuddy restores the original `config.toml` and stops just that project's stack.\n\nThis is the lightest, fastest option and the right default for most setups \u2014 which is why **newly registered projects default to Thin**. One caveat: if your `config.toml` omits a port key (e.g. `[inbucket] smtp_port`), Supbuddy can't relocate a port that isn't declared, so that one service falls back to its stock port. That is fine for a single project, but spell those keys out if two Thin projects need the same service.\n\n### Dev servers on Thin: every project keeps its own `:3000`\n\nA Thin project also gets its own **loopback IP** (127.0.0.2, 127.0.0.3, \u2026, persisted per project). Its app dev servers bind that IP instead of `127.0.0.1`, so canonical ports never collide across projects \u2014 five Next.js apps in five projects can all run on `:3000` at once, and Supbuddy's proxy routes each `web.<project>.test` to its project's IP.\n\nStart dev servers through the launcher:\n\n```bash\nsupbuddy run -- next dev # binds -H <project loopback IP>, stays on :3000\nsupbuddy run -- vite # injects --host <ip> --strictPort\nsupbuddy run --print -- next dev # show what would run, without running it\n```\n\n`supbuddy run` reads the project's IP from the nearest `.supbuddy/meta.json` (`loopbackIp`, written when Thin is enabled), ensures the loopback alias exists, injects the right bind flag for the detected framework, and execs your command. It prints one concise line with the project's Caddy-proxied URL (e.g. `[supbuddy] \u2192 https://web.<project>.test`) \u2014 the address you should actually open. For **Next and Vite** it also hides the dev server's own `- Local:/- Network:` banner (which only echoes the raw loopback IP `127.0.0.N:<port>`, bypassing Supbuddy's HTTPS proxy): those two lines are filtered out of the piped output, every other line passes through untouched, and colours are preserved via `FORCE_COLOR` (stdin stays interactive). Other frameworks pass through with no filtering. When a project has several app mappings, it matches the one whose port equals the dev server's port (from `--port`/`-p` or the framework default), else lists them all. Make it the project's `dev` script (`\"dev\": \"supbuddy run -- next dev\"`) so nobody \u2014 humans or agents \u2014 has to remember it. **Never move an app to a nonstandard port because `127.0.0.1:3000` is busy**; that port belongs to another project's IP space.\n\n### When to stay on Host\n\nKeep a project on **Host** only when its Supabase stack runs on the host *independently of Supbuddy* \u2014 you run `supabase start` yourself on the stock ports and don't want Supbuddy rewriting `config.toml`. MCP registration (`register_project`) detects a stack like that (running containers for the project's `config.toml` `project_id`) and keeps the project on Host automatically; in the app's Add-project dialog, pick **Host** in the Environment section for such projects. Stop the stack (`supabase stop`) and switch to Thin whenever you're ready.\n\n### Running them all at once\n\nRegister as many projects as you want, and all of them can be \"active\" (proxied) at the same time. There's no limit. A Thin project's stack restarts in seconds; a Host project needs the standard `supabase start` cycle.\n\n### Migrating a legacy Isolated (VM) project to Thin\n\nIf you created a project in an older version of Supbuddy that used the now-retired **Isolated (VM)** mode, Supbuddy detects it on launch and offers a one-way, guided migration to **Thin**. The migration wizard appears in the **Supabase** tab's Environment section for any project still flagged as VM.\n\nThe migration is data-safe: Supbuddy dumps your Postgres data, starts a fresh Thin stack, restores the dump into it, and row-count-verifies the restore before tearing down the old VM container. No data loss. After migrating, the VM is gone and there's no way to switch back (but your data is intact in the Thin stack).\n\nOver MCP, three tools handle the migration bridge:\n\n- `list_pending_vm_migrations` (read): lists all projects still on the legacy VM mode awaiting migration.\n- `migrate_vm_to_thin` ( `{ project_id }` ) (write): starts the guided data-safe migration (dump, restore, verify).\n- `finish_vm_migration` ( `{ project_id }` ) (write): tears down the old VM container after migration is verified. Returns an error if called before verification passes.\n\n## Custom domains & TLDs\n\nEvery mapping resolves through Supbuddy's built-in DNS server on port 5353. By default the TLD is `.test` (an IETF-reserved TLD safe for local use). You can change the default in **Settings \u2192 General \u2192 Default TLD** to `local`, `dev`, or anything else; existing mappings are migrated to the new TLD on save.\n\nFor host resolution, Supbuddy *does not* use `/etc/hosts` for wildcards; it runs a DNS resolver. macOS's default resolver only queries port 53; Supbuddy installs a per-project resolver file under `/etc/resolver/<project-domain>` (e.g. `/etc/resolver/myapp.local`) pointing at `127.0.0.1:5353`. macOS picks the longest-suffix-matching file, so per-project entries route reliably without colliding with reserved namespaces like `.local` (which Bonjour/mDNS owns). You'll be prompted for sudo the first time this changes.\n\nResolver files exist only for domains the proxy actually serves \u2014 the same set that gets a Caddy site block: enabled mappings that are either standalone or under an **enabled** project. Disable or delete a project and its resolver file is removed with its routes (one sudo prompt, and only when something really changed), so its domains go back to failing as \"server not found\" instead of resolving into a TLS handshake error from a proxy that has nothing to serve. Enabling it again writes the file back; so does restarting the proxy.\n\n### Per-project TLD\n\nBy default every project's domain uses the global TLD (Settings \u2192 Default TLD, e.g. `.test`). A single project can opt into its **own** TLD \u2014 set the suffix in the project dialog, pass `tld` to the `register_project` / `update_project` MCP tools, or use the CLI: `supbuddy project add <path> --tld=portal` when registering, or `supbuddy project set <project> --tld=portal` on an existing one (`--tld=` with an empty value clears the override). That project's base domain and all its subdomains then live on the override TLD (e.g. `cueplusplus.portal`, `web.cueplusplus.portal`) while every other project stays on the global default. The override is durable across restarts and is unaffected when you change the global TLD. Prefer `.test` or a vanity label like `.portal`; avoid `.local` (it collides with macOS mDNS/Bonjour).\n\n### LAN sharing\n\nWhen LAN sharing is enabled (Settings \u2192 Network), Supbuddy binds Caddy to `0.0.0.0` instead of `127.0.0.1` and runs an mDNS responder so other machines on your local network can reach your dev servers via `<hostname>.local`. Useful for testing on your phone or another laptop without setting up Tailscale.\n\n**`.local` TLD + LAN sharing:** macOS reserves the `.local` namespace for Bonjour/mDNS (RFC 6762), and macOS's TCP stack short-circuits self-connections to your own LAN IP via the loopback path *without consulting `pf`*, so the obvious \"redirect lo0 \u2192 my LAN IP\" trick can't fix it. Supbuddy's mDNS responder works around this by **ignoring queries that originate from this machine**, letting the OS resolver fall through to `/etc/resolver/<project-domain>` (which routes to `127.0.0.1` where Caddy listens). Other LAN devices still get answered with the LAN IP and reach you normally. The net result: `.local` works correctly both on this machine and on other LAN devices, with no manual configuration. If you previously worked around this by switching to `.test`, you can switch back.\n\nIf `studio.<project>.local` (or similar) doesn't load: open the Configure tab. A red banner will tell you whether it's a DNS, port-forwarding, or mDNS-race issue, with the specific recovery action.\n\n### Tailscale\n\nIf you have Tailscale installed and a Tailscale API key configured in Settings, Supbuddy can push split-DNS routes to your tailnet so any device on your tailnet resolves your Supbuddy domains. Optional, off by default.\n\n## Monorepo support\n\nSupbuddy auto-detects these monorepo layouts when scanning a project root:\n\n- Turborepo (presence of `turbo.json`)\n- pnpm workspaces (`pnpm-workspace.yaml`)\n- npm/yarn workspaces (`workspaces` field in root `package.json`)\n- Common folder layouts: `apps/*`, `packages/*`, `services/*`, `sites/*`\n\nEach detected app gets its own subdomain. Supabase is searched for in the project root and these subdirectories: `apps/*`, `packages/*`, `services/*`, `sites/*`, `db/`, `db/*`, `database/`, `database/*`, `packages/backend`, `packages/db`, `packages/database`.\n\n### Detected app frameworks\n\nPort detection looks for the framework dependency in `package.json` and combines that with: explicit `-p`/`--port` in the dev script, `PORT=` env in the dev script, or a config file read. If none of those resolve, the framework default is used:\n\n| Framework dependency | Default port |\n| --- | --- |\n| `next` | 3000 |\n| `vite` | 5173 |\n| `@remix-run/dev`, `@remix-run/serve` | 3000 |\n| `astro` | 4321 |\n| `nuxt`, `nuxt3` | 3000 |\n| `@sveltejs/kit` | 5173 |\n| `@angular/core` | 4200 |\n| `@nestjs/core` | 3000 |\n| `express`, `fastify`, `koa`, `hono`, `@hono/node-server`, `elysia`, `polka`, `tinyhttp` | none (must be explicit in dev script) |\n\n### Server Actions allowedOrigins audit\n\nFor Next.js apps, Supbuddy reads your `next.config.{ts,mts,js,mjs,cjs}` and extracts the hosts in `experimental.serverActions.allowedOrigins`. If a mapped subdomain is missing from that list, the project's **warnings chip** flags `next.config: N origins missing`; Server Action POSTs through Supbuddy mappings would 403 otherwise. Open the **Apps** tab (the chip's \"open apps\" jump) where the affected app shows the warning with a **Fix** button.\n\nThe Fix button opens a dialog with a paste-ready snippet and an **Apply\u2026** button: click it to see a unified diff of the change Supbuddy will make to your `next.config`, then **Confirm & write** to apply it. Supbuddy handles the four common config shapes (existing `allowedOrigins` array, existing `serverActions` block without it, existing `experimental` block without `serverActions`, or no `experimental` at all). The edit is strictly additive: existing array entries are kept verbatim, including spreads (`...devHosts`), identifiers and comments, and only the missing origins are appended.\n\nIf `allowedOrigins` (or `serverActions`, or `experimental`) is set to something other than a plain array/object literal \u2014 an identifier, a function call, a ternary, `[...] as string[]` \u2014 Supbuddy **refuses to patch** rather than guess, and the dialog says so along with the exact origins to add. This is deliberate: a wrong rewrite would produce a duplicate key (TypeScript `TS1117`) that breaks your build long after the fact, so the fallback is the copyable snippet. Use it and edit by hand.\n\nAfter write, Supbuddy rescans the project so the warning disappears immediately. Restart your dev server for the change to take effect; Next.js does not hot-reload `next.config`. Over MCP the same audit is exposed as `preview_next_origins` / `apply_next_origins`; both return `ok: false` with an explanation in the refusal case, and `apply_next_origins` never writes a file it cannot verify.\n\n### Next.js cross-origin dev requests (allowedDevOrigins)\n\nSupbuddy proxies your dev server but **passes the browser's real `Origin` header through** (it no longer rewrites `Origin` to the upstream address). That's required so Server Actions and other origin checks see the actual page origin \u2014 but it means **Next.js 15.3+ and 16** dev servers, which validate cross-origin dev requests against `allowedDevOrigins` (defaulting to `localhost`), now treat a request arriving on a Supbuddy domain (or a Thin project's `127.0.0.N` loopback IP) as cross-origin and can reject it. Add your Supbuddy domain to `allowedDevOrigins` in `next.config`:\n\n```js\n// next.config.js\nmodule.exports = {\n allowedDevOrigins: ['web.myproject.test'],\n}\n```\n\nRestart the dev server afterward; Next.js does not hot-reload `next.config`. This is separate from `experimental.serverActions.allowedOrigins` (the Server Actions CSRF list above) \u2014 15.3+/16 may need both.\n\n### Vite allowedHosts audit\n\nFor Vite apps, Supbuddy reads your `vite.config.{ts,mts,cts,js,mjs,cjs}` and extracts `server.allowedHosts`. If a mapped host isn't covered, the **warnings chip** flags `vite: N hosts blocked`; Vite's dev server otherwise rejects proxied requests for unknown hosts with `Blocked request. This host (\"\u2026\") is not allowed.` (403). A `.your-project.local` entry counts as covering every subdomain, so an existing wildcard suffix doesn't trigger a false warning.\n\nLike the Next.js audit, the affected app's **Fix** button on the **Apps** tab opens a dialog with a paste-ready snippet and an **Apply\u2026** button that previews a unified diff and writes `server.allowedHosts` into your `vite.config` (handling an existing `allowedHosts` array, an existing `server` block without it, or no `server` block at all; `allowedHosts: true` is left untouched). The edit is strictly additive \u2014 existing entries, spreads and comments are kept verbatim and only missing hosts are appended \u2014 and, exactly as with the Next.js audit, Supbuddy **refuses to patch** when `allowedHosts` or `server` is set to anything other than a plain array/object literal, pointing you at the snippet instead of risking a duplicate-key build break. After write, Supbuddy rescans so the warning clears. Restart your dev server for the change to take effect; Vite does not hot-reload `vite.config`.\n\n## MCP setup (AI agents)\n\nSupbuddy ships a built-in MCP server on `http://127.0.0.1:9877/mcp` with static Bearer-token auth. Five clients have one-click install; any other MCP-compatible tool can be configured manually with the same URL + token.\n\nOpen **Settings \u2192 MCP \u2192 Add client**, pick the client kind, and Supbuddy generates a token, edits the client's config file, and backs up the original (`<file>.supbuddy-backup` next to it). If the install can't complete it surfaces an error toast rather than stalling. The same client-management surface (**Settings \u2192 MCP \u2192 Clients**: install, edit scopes, set-primary, rotate token, revoke) drives each client from the app.\n\n### Auto-install paths\n\n| Client | Config file | Transport |\n| --- | --- | --- |\n| Claude Code | `~/.claude.json` (user) or `<project>/.mcp.json` (project) | HTTP |\n| Claude Desktop | `~/Library/Application Support/Claude/claude_desktop_config.json` | stdio shim via `npx -y @supbuddy/mcp@latest` |\n| Cursor | `~/.cursor/mcp.json` (user) or `<project>/.cursor/mcp.json` (project) | HTTP |\n| Codex CLI | `~/.codex/config.toml` (adds an `[mcp_servers.supbuddy]` block) | HTTP |\n| Windsurf | `~/.codeium/windsurf/mcp_config.json` | HTTP |\n\n### MCP tool surface\n\nThe MCP server has full read and write access:\n\n- Read tools (`list_mappings`, `list_projects`, `get_health`, `get_compose_status`, `list_pending_vm_migrations`, etc.), with env values and request bodies included.\n- `get_client_capabilities` and `request_scope_elevation` (scope discovery + user-approved grant).\n- `read_env_file`, `tail_request_logs`, `watch_audit_log`.\n- Write tools: `create_mapping`, `delete_mapping` (soft-delete), `register_project`, `update_project`, `set_supabase_config_path`, `start_proxy`, `start_supabase`, `stop_supabase`, `restart_supabase`, `switch_isolation`, `migrate_vm_to_thin`, `finish_vm_migration`, `start_compose`, `stop_compose`, `restart_compose`, `scaffold_addons`, `seed_addons`, `write_env_file`, `copy_env_var`, `write_supabase_config`.\n- Scripts tools (`list_scripts`, `start_script`, `stop_script`, `restart_script`, `bookmark_script`, `tail_script_logs`); see *Scripts MCP tools* below.\n- Extended Supabase tools: `init_supabase`, `validate_supabase_config`, `list_supabase_backups`, `restore_supabase_backup`, `cancel_supabase_start`, `force_recreate_supabase`, `restart_supabase_container`, `get_supabase_analytics`, `set_supabase_analytics`.\n- Bundle (export/import a project's full config): `export_bundle`, `import_bundle`, `validate_bundle`.\n- Supbuddy Cloud (opt-in, per-project): `cloud_sign_in`, `push_to_cloud`, `get_cloud_status`, `cloud_teardown` \u2014 push a project (with its Supabase schema + data) to a hosted cloud stack and control it. The `cloud` link (`{ projectId, stackId, pushedAt, url }`) also appears on `get_project` / `list_projects`, so any client sees which projects are in the cloud.\n- Connection / env-target workflow: `preview_connection`, `get_env_targets`, `diff_env`, `apply_env`, `write_connection`, `test_connection`, `dismiss_connection_drift`.\n- Host & network tools: bundled-runtime trust (`get_trust_status`, `install_trust`, `remove_trust`, `detect_trust_tools`, `test_trust`), Tailscale (`get_tailscale_status`, `set_tailscale_key`, `remove_tailscale_key`, `test_tailscale`), DNS (`get_dns_status`), CA (`uninstall_ca`), and port-forwarding (`get_port_forwarding_status`, `set_port_forwarding`, `reload_port_forwarding`).\n- `tail_service_logs`: streams a Compose/add-on service's container logs over SSE (like `tail_request_logs` but for container stdout/stderr).\n- `watch_supabase`: streams a project's live Supabase start/stop/restart progress over SSE: operation status, image-pull/service snapshots, and (for VM projects) raw log lines. Backs `supbuddy supabase start --follow`.\n- System doctor: `doctor` (scope `read`) runs the read-only health & drift scan and returns a report of findings (each with a `checkId`, severity, evidence, and whether it's `fixable`) \u2014 it mutates nothing. `doctor_fix` ( `{ check_ids: [...] }` ) applies the opt-in repairs for those checks; it's **system-scoped and confirm-gated** (a modal, exactly like `uninstall_ca`), so a read-scoped client can't trigger a fix and an agent can't silently run a destructive repair. Backs `supbuddy doctor` / `doctor --fix` (see *System doctor*).\n- System reset: `system_wipe` ( `{ tier: \"soft\" | \"deep\" }` , scope `system`) runs the tiered reset described under *System reset*. It is gated **twice**: it always returns a plan first \u2014 even for `auto_apply` clients \u2014 whose `side_effects` are the literal manifest the wipe will execute, and the subsequent `apply` still blocks on a user confirmation modal. `tier: \"full\"` is **rejected**: it deletes the credentials the caller is authenticating with, and its final steps (uninstalling the service, removing the app-data directory) can't run inside the daemon \u2014 run `supbuddy reset --tier=full` in a terminal instead.\n- Multiple MCP clients can connect simultaneously. The same MCP-HTTP surface backs the headless **CLI** (see *Command-line interface* below).\n\n### Scopes: discovery & self-service elevation\n\nEach MCP client holds a set of **scopes** (`read`, `log_tail`, `mappings`, `projects`, `services`, `config`, `system`, `apply`) chosen when it's added. A tool call that needs a scope the client lacks fails with `scope_denied`, whose payload now carries a `user_message` and `details.remediation` pointing at the fix.\n\n- `get_client_capabilities` ( `{ tool? }` ) returns the calling client's `granted_scopes` and `available_scopes`. Pass a `tool` name to get `{ required_scope, required_feature, can_call, reason? }` so an agent can pre-flight a call instead of probing by hitting `scope_denied`.\n- `request_scope_elevation` ( `{ scopes: [...] }` ) asks the **user** to grant the named scopes. Supbuddy shows a blocking approval dialog; on approval the scopes are added to the client. Already-granted scopes short-circuit without a prompt.\n\nYou can also review and edit any client's scopes from the GUI: **Settings \u2192 MCP \u2192 Clients** lists each client's granted scopes inline and exposes a **Scopes** button that opens the same scope editor used when adding a client.\n\n### Registering a project via MCP\n\n`register_project` takes a `root_path` (required), an optional `label`, `auto_scan` (default `true`), and an optional `isolation` (`'thin'` or `'host'`). It registers the project the same way the GUI's \"Add project\" flow does:\n\n- Derives a base domain as `<slug>.<defaultTld>` from the label (or the folder name), e.g. `staffhub.test`.\n- Records both the project `path` and `rootPath` so the project is visible to the proxy, scans, and file tools alike.\n- Scans the folder (unless `auto_scan: false`) for apps, services, scripts, and package manager.\n- Creates per-app subdomain mappings from the discovered apps (e.g. `site.staffhub.test \u2192 :3400`), derives the host service subdomains (`api.`, `studio.`, \u2026), and reloads Caddy.\n- **Defaults to `thin` isolation**: the project gets its own loopback IP so its dev servers keep canonical ports (`:3000`) with no cross-project collisions \u2014 run them with `supbuddy run -- <dev command>`. The one exception: if the project's Supabase stack is **already running on the host outside Supbuddy**, registration keeps it on `host` (switching would rewrite its `config.toml` ports and orphan the running stack). Pass `isolation: 'host'` to opt out explicitly, or `isolation: 'thin'` to skip the detection and force thin.\n\nThe response includes an `isolation_note` explaining which mode was chosen and why \u2014 agents should read it instead of assuming.\n\n### Switching isolation over MCP\n\n`switch_isolation` ( `{ project_id, target_mode: 'host' | 'thin', auto_start? }` ) moves an existing project between **host** and **thin** mode. To-thin writes the per-project port block and `project_id` into `supabase/config.toml` and (unless `auto_start: false`) starts Supabase; to-host restores the original `config.toml` and stops that project's stack. It runs in the background and returns `{ started: true }`; poll `get_project` (`isolation`) for the current mode.\n\nA project can also be patched with `update_project`: its `patch` accepts `name`, `enabled`, `domain`, and `isolation` (it intentionally does **not** accept `path`/`rootPath`). Note that patching `isolation` only flips the flag; use `switch_isolation` to actually provision/tear down the port assignment.\n\n### Legacy VM migration over MCP\n\nFor projects still on the retired Isolated (VM) mode, three tools handle the one-way migration to Thin:\n\n- `list_pending_vm_migrations` (read): lists all projects still on the legacy VM mode, with their current `vmState` and migration readiness.\n- `migrate_vm_to_thin` ( `{ project_id }` ) (write): starts the guided data-safe migration. It dumps Postgres data from the VM, starts a fresh Thin stack, restores the dump, and row-count-verifies before signalling completion. Returns `{ started: true }`; poll `get_project` (`migrationState`) for progress.\n- `finish_vm_migration` ( `{ project_id }` ) (write): tears down the old VM container after verification passes. Errors if called before the verify step completes.\n\n### Repointing a project's Supabase config\n\n`set_supabase_config_path` ( `{ project_id, supabase_path }` ) switches which `supabase/config.toml` a project uses, for monorepos that carry more than one (e.g. a repo-root config and an app-level one). `supabase_path` is the project-relative directory **containing** the `supabase/` folder (`\".\"` for the repo root, e.g. `\"apps/getnightowls\"`). It persists the path, re-derives `supabaseProjectId` from the new config, and re-scans services. The previous stack's Docker volume is **left intact** (not deleted), so the switch is reversible; the response reports it under `orphaned_previous_stack`.\n\n### Moving a secret between env files\n\n`copy_env_var` ( `{ source_path, source_key, target_path, target_key? }` ) relocates a single variable from one env file to another (e.g. a value put in an app's `.env.local` that the stack actually injects from the repo-root `.env.local`). The value is read and written entirely inside the worker (it **never crosses the MCP boundary** and never appears in the audit log), so an agent can move a secret without it being printed. `target_key` defaults to `source_key`.\n\n### Plan / apply for destructive tools\n\nTools that delete or mutate state (`delete_mapping`, `delete_project`, `write_env_file`, etc.) return a *plan* with a preview. The MCP client (or you, in the Activity panel) explicitly calls `apply` with the `plan_id` to execute. Plans expire after 5 minutes if not applied. Soft-deletes go to the Trash and are recoverable for 7 days.\n\n## Add-on Compose services\n\nA project can declare **extra** Docker Compose services that Supbuddy discovers, merges, runs, health-checks, and tails alongside the managed stack: a Redis cache, a worker queue, a search engine, etc. Add-on services run on the host's shared Docker daemon in both `host` and `thin` isolation, with no extra setup needed.\n\n### Declaration files & merge precedence\n\nSupbuddy looks for up to three Compose fragments in the project and merges them, later wins:\n\n1. `docker-compose.yml`: your base Compose file.\n2. `docker-compose.override.yml`: your own override, honored if present (standard Compose convention).\n3. `supbuddy.addons.yml`: Supbuddy-owned add-on fragment.\n\nAll present fragments are passed explicitly, e.g. `docker compose -f docker-compose.yml -f docker-compose.override.yml -f supbuddy.addons.yml --project-name <pinned> \u2026`. The project name is pinned so the same set of containers is addressed every time. Add-on services join the Compose project's default network automatically; no extra network setup is needed for them to reach (or be reached by) the rest of the stack.\n\n### `supbuddy.addons.yml` format\n\nA valid Compose fragment (a standard `services:` map) plus an optional Supbuddy-only `x-supbuddy:` extension block. A plain `docker compose up` ignores `x-supbuddy:`, so the file stays usable without Supbuddy. Today `x-supbuddy` supports a one-shot **seed** step:\n\n```yaml\nservices:\n redis:\n image: redis:7-alpine\n ports: [\"6379:6379\"]\nx-supbuddy:\n seed:\n service: redis\n command: [\"redis-cli\", \"ping\"] # explicit argv, runs once after services are healthy\n runOnce: true\n```\n\nThe seed step runs **once** after the add-on services are up and healthy. It's idempotent, keyed by a signature of the seed spec, so it only re-runs if the spec changes (or you force it). It fires automatically on project start, and on demand via the `seed_addons` MCP tool.\n\n### MCP tools\n\n- `scaffold_addons` ( `{ project_id }` ): scope `config`. Creates a starter `supbuddy.addons.yml` if the project doesn't have one. Never clobbers an existing file.\n- `seed_addons` ( `{ project_id, force? }` ): scope `services`. Runs the declared `x-supbuddy.seed` step. Idempotent unless `force: true`.\n- `tail_service_logs` ( `{ project_id, service }` ): scope `log_tail`. Streams a Compose/add-on service's container logs over SSE (like `tail_request_logs`, but for container stdout/stderr).\n- `watch_supabase` ( `{ project_id }` ): scope `log_tail`. Streams a project's live Supabase start/stop/restart progress over SSE: `operation` (status + message), `progress` (image-pull/service snapshots), and `log` (raw lines, VM projects). The stream ends on a terminal status. Backs `supbuddy supabase start --follow`.\n\n### Scripts MCP tools\n\nScripts detected in a project (e.g. `dev`, `build`, `test`) are controllable over MCP:\n\n- `list_scripts` ( `{ project_id }` ): scope `read`. Returns all detected scripts with their current status and bookmark state.\n- `start_script` ( `{ project_id, script }` ): scope `services`. Starts the named script process.\n- `stop_script` ( `{ project_id, script }` ): scope `services`. Stops the named script process.\n- `restart_script` ( `{ project_id, script }` ): scope `services`. Stops then starts the named script process.\n- `bookmark_script` ( `{ project_id, script, bookmarked }` ): scope `services`. Pins (`bookmarked: true`) or unpins a script in the Quick Access group.\n- `tail_script_logs` ( `{ project_id, script }` ): scope `log_tail`. Streams the named script's stdout/stderr over SSE.\n\n### `get_compose_status` shape\n\n`get_compose_status` ( `{ project_id }` ) returns live per-service status, not just whether Compose is installed:\n\n```json\n{\n \"project_id\": \"\u2026\",\n \"compose_installed\": true,\n \"running\": true,\n \"services\": [\n { \"name\": \"redis\", \"status\": \"running\", \"health\": \"healthy\", \"ports\": [\"6379:6379\"], \"image\": \"redis:7-alpine\", \"container_id\": \"\u2026\", \"source\": \"addons\" }\n ]\n}\n```\n\nEach service's `source` is one of `base` | `override` | `addons`, telling you which fragment declared it.\n\n## Per-project AI context sync\n\nEach project has a **Context sync: AI tools** panel, accessible via the **AI Tools** tab in the project card, that writes a project-scoped briefing to disk so AI agents working in that repo see your live mappings, services, and isolation state without having to ask. Files written:\n\n- `.supbuddy/`: `README.md`, `mappings.md`, `services.md`, `project.md`, `mcp.md`, `do-not.md`, `docs.md`. The full live snapshot, regenerated on each sync.\n- `AGENTS.md` and `CLAUDE.md`: a small managed block prepended (or updated in place) telling the agent which project this is and pointing it at `.supbuddy/`.\n- Editor skill files when detected: `.cursor/rules/supbuddy.mdc`, `.claude/skills/supbuddy/SKILL.md`, `.codeium/windsurf/rules/supbuddy.md`, `.continue/rules/supbuddy.md`, `.github/copilot-instructions.md`, `.idea/supbuddy.md`.\n- `.gitignore` managed block, ignoring: `.supbuddy/meta.json` (volatile sync state), `*.supbuddy-backup-*` (rollback snapshots), and the per-editor skill files that are written **locally** (see scope below). The rest of `.supbuddy/` is intended to be committed; `AGENTS.md`, `CLAUDE.md`, and `.github/copilot-instructions.md` are also kept committable since you may have hand-written content there alongside Supbuddy's managed block.\n\n### Global vs. local scope\n\nThe per-editor skill files are generic Supbuddy-owned pointers (\"this is a Supbuddy project: read `.supbuddy/`, prefer the MCP tools\"). For editors that expose a **Supbuddy-owned global location**, Supbuddy writes that pointer **once, machine-wide** instead of copying it into every project, so it isn't duplicated across all your repos. Project-specific data always stays local in `.supbuddy/`.\n\n- **Claude Code** \u2192 one global skill at `~/.claude/skills/supbuddy/SKILL.md`. **Cursor** \u2192 `~/.cursor/skills/supbuddy/SKILL.md`. The global skill self-scopes: it only acts when the working directory has a `.supbuddy/` folder, and resolves the active project from that folder's `meta.json`.\n- All other targets (`windsurf`, `continue`, the `AGENTS.md`/`CLAUDE.md`/Copilot managed blocks, JetBrains) stay **local**: their \"global\" files are shared user files, so Supbuddy won't overwrite them.\n- Each target has a **scope** setting: `auto` (default: global for the Claude/Cursor skills, local for everything else), `global`, `local` (force per-project, useful if you commit the file for teammates), or `off`. A machine-global file is reference-counted across projects and removed automatically once no project uses it (on disabling sync, deleting a project, or switching that target back to local). Note: uninstalling Supbuddy (e.g. dragging it to the Trash on macOS) does **not** auto-remove these global files; delete them manually from `~/.claude/skills/supbuddy/` and `~/.cursor/skills/supbuddy/` if needed.\n- The always-loaded `CLAUDE.md`/`AGENTS.md` managed block stays local as a safety net so agents stay aware even if the on-demand global skill doesn't auto-activate.\n\nSync modes per project:\n\n- **Auto**: Supbuddy regenerates the files whenever mappings, services, or project state change.\n- **Manual only**: files are only written when you click **Sync now** (or use the tray's *Sync AI context for all projects*).\n- **Off**: nothing is written.\n\nThe collapsed header shows an at-a-glance status pill: mode (`auto` / `manual` / `off`), a colored dot for the last sync result, and a relative timestamp. Disabled targets (e.g. an editor whose folder isn't present) appear greyed out in the **Detected targets** list inside the panel.\n\n## Supbuddy Cloud\n\nPush a project \u2014 its Supabase schema **and data** \u2014 to a hosted cloud dev-stack (its own full self-hosted Supabase \u2014 Postgres, Auth, REST, Storage, Realtime, Studio behind a gateway \u2014 as an isolated graph of machines on a per-tenant private network) and control it from the app, the CLI, or MCP. **Opt-in and per-project:** nothing cloud-related appears in a project until you've signed in.\n\n- **Get started** \u2014 the top bar shows a **Get started with Supbuddy Cloud** strip; sign in (email/password) there. Once signed in it becomes **Open cloud** (opens [cloud.supbuddy.app](https://cloud.supbuddy.app) in your browser). Sign-in state + the Claude connection also live under **Settings \u2192 Cloud**.\n- **Push a project** \u2014 after signing in, each project's \u22EF menu gains **Push to cloud\u2026**. The push ships the project's stack descriptor + a `pg_dump` of its Supabase data (fail-closed: uploaded to a private bucket via a single-use key, sha-verified, restored *inside* the stack's private network, then deleted). Your **local project stays intact** \u2014 a **\u2601** badge appears on its row; click it (or \u22EF \u2192 **Open in cloud**) to open the stack in the web app.\n- **CLI / MCP** \u2014 the same flow headless: `supbuddy cloud login|push|status|teardown` (password via arg or `SUPBUDDY_CLOUD_PASSWORD`), or the `push_to_cloud` / `get_cloud_status` / `cloud_teardown` / `cloud_sign_in` MCP tools. `project ls` marks pushed projects with \u2601, and `get_project` / `list_projects` carry the `cloud` link. `cloud_teardown` (and the \u22EF teardown) destroy the remote stack and unlink it locally \u2014 routed through the same plan/apply gate as other destructive tools.\n- **Service breadth** \u2014 a self-hosted push provisions the **full** Supabase stack by default. Pass `push_to_cloud`'s `supabase_services: \"minimal\"` (MCP) to opt down to a lean db/auth/REST stack instead.\n- **Idle auto-stop** \u2014 a running cloud stack that reports no activity for ~30 minutes is automatically **stopped** to save cost (its data + config persist; start it again from the web app). A background reaper also reconciles any stack whose machines went missing.\n- **Web console** \u2014 [cloud.supbuddy.app](https://cloud.supbuddy.app) lists your org's stacks; open one for its per-service health, live status, and **start / stop / restart / tear down** controls, plus a **Recent activity** feed of control-plane events. **Push to cloud** in the console provisions a stack from a GitHub `owner/repo` (self-hosted or bring-your-own Supabase; full or minimal service set) \u2014 the code-only path; pushing a local project *with its data* still goes through the desktop app / CLI.\n\n## Command-line interface (CLI)\n\nEverything the desktop app can do is also driveable headlessly from a terminal, with no GUI window. The CLI runs a **daemon** (the same worker process the GUI uses: Caddy proxy, DNS, Supabase/Compose lifecycle, MCP-HTTP) and a set of commands that attach to it over the local MCP-HTTP port. This is for SSH sessions, CI, `tmux`/server boxes, and scripting.\n\nThe binary is `supbuddy`, with a short alias `sup`. Run `supbuddy help` for the full usage list.\n\nYou can install the CLI on its own, without the desktop app:\n\n```bash\nnpx supbuddy@latest # asks to install the CLI globally (supbuddy + sup)\n```\n\nThat command does nothing on its own except offer to put `supbuddy` and `sup` on your PATH. The CLI runs independently of the desktop app, so you can add the app later (or never). On a Mac the app installs the same two commands for you.\n\n### The daemon\n\n```bash\nsupbuddy daemon --detach # start the worker in the background\nsupbuddy status # daemon + proxy health, plus which worker the daemon is running\nsupbuddy stop # graceful shutdown\n```\n\n`--detach` backgrounds the daemon and prints its pid + ports. Foreground `supbuddy daemon` runs it attached (Ctrl-C shuts it down cleanly). On start the daemon writes a discovery file, `daemon.json` (mode `0600`), into the shared state dir holding its pid, the Socket.IO port, the MCP-HTTP port, and a control token; every other command reads it to find and authenticate to the daemon, so you never pass ports or tokens by hand. Only one daemon may run per state dir; a second `daemon` start is refused.\n\nThe CLI and the desktop app **share one state dir** (`~/Library/Application Support/Supbuddy/`), so they manage the same projects, mappings, and settings. They must not run two workers against it at once: if you launch the desktop app while a CLI daemon is running, the app detects it and offers to **stop the daemon and continue** or **quit**. It never forks a competing worker (which would corrupt `state.json`).\n\n### Run on login (service)\n\n```bash\nsupbuddy service install # start-on-login (launchd on macOS, systemd-user on Linux)\nsupbuddy service status\nsupbuddy service uninstall\n```\n\n### Commands\n\nAll app surfaces have a command. Names follow `supbuddy <module> <action> [args] [--flags]`. The main groups:\n\n| Group | Examples |\n| --- | --- |\n| Dev launcher | `run [--print] -- <dev command>` \u2014 on a Thin project, binds the dev server to the project's loopback IP (from `.supbuddy/meta.json`) so it keeps its canonical port (e.g. `supbuddy run -- next dev` stays on `:3000`) |\n| Health / proxy | `status`, `doctor [--fix]` (health & drift scan \u2014 see *System doctor*), `reset [--tier=soft\\|deep\\|full]` (tiered system reset \u2014 see *System reset*), `proxy status\\|start\\|stop\\|restart` |\n| Mappings | `map ls\\|add\\|get\\|set\\|enable\\|disable\\|rm\\|restore` |\n| Projects | `project ls\\|add\\|get\\|scan\\|set\\|enable\\|disable\\|rm\\|restore\\|env\\|refresh-context` |\n| Supabase | `supabase start\\|stop\\|restart\\|status <proj>` (add `--follow` to stream live progress), `supabase config apply <proj> <file>` |\n| Cloud | `cloud login <email> [<pw>]` (or `SUPBUDDY_CLOUD_PASSWORD`), `cloud push <proj> [--repo=owner/repo] [--force]`, `cloud status [<proj>]`, `cloud teardown <proj>` \u2014 push a project (with its Supabase data) to a hosted cloud stack; `project ls` marks pushed projects with \u2601 |\n| Compose | `compose up\\|down\\|restart\\|status\\|logs <proj> [svcs]` |\n| Scripts | `scripts ls\\|start\\|stop\\|restart\\|logs\\|bookmark <proj> [script]` |\n| Isolation | `isolation switch <proj> <host\\|thin>`, `isolation pending-migrations`, `migrate start\\|finish <uuid>` |\n| Certificates | `ca status\\|install\\|uninstall` |\n| Env files | `env copy <src> <key> <target>`, `env write <path> <K=V>\u2026` |\n| Settings | `settings get`, `settings set --json <patch>` |\n| MCP | `mcp add [<agent>]` (register Supbuddy into a coding agent: interactive, or `--write`/`--print`/`--prompt`), `mcp ls`, `mcp revoke <id>`, `mcp approvals apply\\|cancel <id>` |\n| Host / network | `connect`, `trust`, `tailscale`, `dns`, `pf` (port-forwarding) |\n| Logs | `logs requests [-f]`, `logs audit [-f]`, `logs get <id>` |\n| Account | `account`, `caps`, `addons scaffold\\|seed <proj>` |\n| Dashboard | `tui` (alias `dash`) |\n\nGlobal flags: `--json` (machine-readable output), `--yes` (skip confirmations), `--quiet`, `--url`/`--token` (attach to a specific/remote daemon instead of auto-discovery), `--state-dir` (override the shared dir), `--timeout`, and `-f`/`--follow` for streaming log commands and live `supabase start|stop|restart` progress.\n\nDestructive operations go through the same **plan \u2192 apply** gate as MCP (see *Plan / apply for destructive tools*); the CLI's control token is granted auto-apply, so they execute directly.\n\n### Live dashboard (TUI)\n\n```bash\nsupbuddy tui # or: sup dash\n```\n\n`supbuddy tui` opens a full-screen terminal dashboard that attaches to the running daemon and shows live connection/proxy status, the project list (with each project's isolation, Supabase, and Compose state), the mapping count, and a tail of recent requests. Press `r` to refresh, `q` to quit. It needs a running daemon (`supbuddy daemon --detach`); if none is found it tells you so.\n\n### System doctor\n\n```bash\nsupbuddy doctor # read-only scan; prints findings by severity\nsupbuddy doctor --fix # scan, show the repair manifest, confirm (y/N), then apply\nsupbuddy doctor --fix --only=ca-not-trusted # restrict repairs to specific check ids (comma-separated)\nsupbuddy doctor --fix --yes # skip the interactive confirm (scripting / CI)\n```\n\n`supbuddy doctor` runs a **read-only** health and drift scan and prints its findings grouped by severity \u2014 **critical**, **warning**, **info** \u2014 each with a title, a one-line detail, and concrete evidence (paths, container names, certificate fingerprints). The scan mutates nothing and exits non-zero when any finding is **critical**, so you can gate a script or CI on it.\n\n`--fix` re-scans, prints a **manifest** \u2014 one line per fixable finding, taken from the scan you just saw \u2014 and, unless you pass `--yes`, asks `Apply these fixes? [y/N]` (default **No**) before touching anything. (The desktop app's doctor panel shows the finer-grained repair *actions* themselves; the CLI lists the findings those actions belong to.) `--only=<comma,ids>` restricts the repair to specific check ids; `--yes` skips the prompt for non-interactive use. This is the **confirm-before-harm** contract: the scan is read-only, and every repair is opt-in and gated. Fixes that need elevated access prompt for your password when they run.\n\nA repair that ends up doing nothing is reported as such, never as success: if a requested check's finding is already gone, is advisory, can't be re-checked, or names an unknown id, it's listed under **NOT APPLIED** and the command exits non-zero.\n\nThe doctor ships **18 checks**. Rows marked **Advisory** have **no auto-fix at all**: `--fix` will never touch them, and the finding's detail tells you what to do by hand. Checks marked *macOS* return nothing on other platforms.\n\n| Check id | Severity | What it flags | Auto-fix |\n| --- | --- | --- | --- |\n| `state-corrupt` | critical | `state.json` can't be parsed (or isn't an object), so the daemon boots with **empty** state \u2014 no projects, mappings, settings or MCP clients | Copies the file aside as `state.json.corrupt-<timestamp>` so you can hand-recover it. Nothing is deleted or rewritten |\n| `caddy-stuck` | critical | Caddy is alive but its admin API is wedged, so config reloads can't land | Restarts Caddy (stop \u2192 start) |\n| `caddy-ipv4-unreachable` | critical | Caddy's loaded config declares an HTTPS listener but `127.0.0.1:<port>` **refuses** connections \u2014 every IPv4 client is cut off (browsers, curl, and the pf 443\u21928443 redirect) while the process is up and its admin API answers | **Advisory \u2014 no auto-fix.** Run `supbuddy proxy restart` to rebind. Only a connection **refused** counts: a *timeout* on a pf redirect target is normal (the reply is reverse-NAT'd back to :443 and never matches your socket), so it is never reported as a fault |\n| `ca-not-trusted` | warning | The local CA exists but the **current** root isn't trusted in the System keychain (the padlock stays broken). Detection is by fingerprint, so a stale same-name root from an earlier CA no longer counts as installed | Installs it into the System keychain (`security add-trusted-cert`; asks for your password). Where trust **cannot be read at all** (Windows) this drops to **advisory, info, no auto-fix** \u2014 it reports what to import by hand rather than offering a repair that can't run |\n| `pf-not-enforcing` | warning | Port forwarding is configured but 443 isn't redirecting | **Advisory \u2014 no auto-fix.** Run `supbuddy proxy restart`: only that path re-runs the privileged pf setup, so the doctor won't claim a success it can't deliver |\n| `duplicate-caddy-ca` | warning | *macOS.* Stale same-name `Caddy Local Authority` roots with a different key \u2014 the cause of Firefox-family `SEC_ERROR_BAD_SIGNATURE` | Deletes the stale roots **and installs the current one** in a single elevated batch (asks for your password). Delete-only could leave a machine with no trusted Caddy root at all when the current one wasn't in the keychain yet |\n| `orphan-caddy-container` | warning | A leftover pre-binary-era `supbuddy-caddy` Docker container | Removes the container, its `supbuddy-net` network and its data/config volumes (the `caddy:latest` image is kept) |\n| `orphan-lo0-aliases` | warning | *macOS.* `127.0.0.N` aliases on `lo0` owned by no Thin project \u2014 deleting a Thin project never tore its alias down | Removes only those aliases (asks for your password); `127.0.0.1` and any non-Supbuddy alias are left alone |\n| `orphan-dind` | warning | Docker-in-Docker containers from the retired Isolated (VM) mode belonging to no registered project \u2014 each one confirmed to actually be a DinD first | Force-removes those containers and their `<name>-docker` data volumes. **This is project data**: if you deleted a project and chose to keep its data, this is that data. The Caddy container and non-Supbuddy containers are never touched |\n| `orphan-supabase-volumes` | warning | Docker volumes of Supbuddy-managed (`sb-`-prefixed) Supabase stacks owned by no registered project | Removes those volumes. **This is database data.** Host-mode stacks, stacks you started yourself, and projects still in the MCP trash (restorable for 7 days) are never touched |\n| `orphan-launchagents` | warning | *macOS.* Legacy CA-trust LaunchAgents from older builds that re-export `SSL_CERT_FILE` / `REQUESTS_CA_BUNDLE` / `NODE_EXTRA_CA_CERTS` at every login and break **public** TLS | Boots each agent out and removes it, leaving a `.supbuddy-backup` copy alongside. Root-owned agents under `/Library` may resist; the fix reports those as a failure instead of claiming success |\n| `orphan-electron-token-files` | warning | Leftover `~/.config/Supbuddy/mcp/<clientId>.bin` token files from the retired Electron app, for clients that no longer exist | Deletes those files (no elevation). They can't be decrypted any more anyway; clients that are merely revoked keep their record and are left alone |\n| `orphan-mcp-secrets` | warning | `secrets/mcp-<clientId>.secret` files whose token can no longer authenticate (client revoked, or no record at all) | Deletes those files (no elevation) \u2014 it can't log a working agent out. Secrets for current clients, and the non-MCP secrets stored alongside them (license, cloud session, Tailscale key), are left untouched |\n| `unmanaged-supabase` | info | A Supabase stack on the host daemon that maps to no registered project (e.g. a plain `supabase start`) | **Advisory \u2014 no auto-fix.** Supbuddy never tears down a stack you started yourself; run `supabase stop` in its project if you don't need it |\n| `stale-resolver-files` | info | *macOS.* Supbuddy-marked `/etc/resolver/<suffix>` files for suffixes no **enabled** project or mapping claims any more (deleted projects, a disabled one, an older per-project TLD) | Removes only those files (asks for your password); suffixes still in use are left alone. Reversible \u2014 enabling the project or restarting the proxy writes the file back |\n| `pf-conf-backups` | info | *macOS.* `/etc/pf.conf.backup.<timestamp>` copies piled up in `/etc` by older versions (which wrote a new one on every port-forwarding disable) | Removes the redundant copies, **keeping the newest one** and the stable `/etc/pf.conf.supbuddy-backup` (asks for your password) |\n| `stale-mcp-config-tokens` | info | An agent config (`~/.claude.json`, Claude Desktop, Cursor, Codex, Windsurf, or a registered project's `.mcp.json` / `.cursor/mcp.json`) holds a `mcpServers.supbuddy` token Supbuddy no longer accepts \u2014 the 401 \"Token not recognized\" state | **Advisory \u2014 no auto-fix.** Supbuddy won't rewrite config files you own and edit. Delete the `mcpServers.supbuddy` entry from the file named in the finding, or run `supbuddy mcp add <agent>` to mint a fresh token. The finding names the file, never the token |\n| `stale-browser-nss-roots` | info | *macOS.* A Firefox / Zen / LibreWolf / Waterfox profile whose own NSS store (`cert9.db`) holds a `Caddy Local Authority` root Supbuddy can't reach | **Advisory \u2014 no auto-fix.** Nothing is wrong unless that browser shows certificate errors. Fix it there: Settings \u2192 Privacy & Security \u2192 Certificates \u2192 View Certificates\u2026 \u2192 Authorities, delete every `Caddy Local Authority` entry, then re-import Supbuddy's CA |\n\nThe same scan and repairs are available over MCP as the `doctor` and `doctor_fix` tools (see *MCP tool surface*), and in the app under **Settings \u2192 General \u2192 System health \u2192 Scan** \u2014 the panel scans on open, groups the findings by severity, and gates every repair behind the same manifest + confirm step (see *Settings reference \u2192 General*). The panel has no reset button: a wipe stays a CLI operation.\n\n### System reset\n\n```bash\nsupbuddy reset # soft (the default): app state + caches\nsupbuddy reset --tier=deep # + services, Caddy containers, system integrations, CA trust\nsupbuddy reset --tier=full # + project data, repo artifacts, secrets, service, app data\nsupbuddy reset --tier=deep --yes # skip the y/N confirm (scripting / CI)\nsupbuddy reset --tier=full --yes --i-understand # the ONLY scripted path for a full reset\n```\n\n`supbuddy reset` removes Supbuddy's footprint from your machine in **tiers**, and each tier is a superset of the one before it:\n\n| Tier | What it removes |\n| --- | --- |\n| `soft` (default) | App state \u2014 projects, mappings, settings, MCP clients, project-context sync and user-skill records \u2014 plus the Docker image cache (`<app-data>/image-cache`, images are re-pulled on demand) and the buffered request log. It touches **no** Docker container or volume, **nothing** under `/etc`, and **no** file in your repos, so it never asks for your password |\n| `deep` | \u2026plus: stops every service; removes the leftover Caddy container/network/volumes, the `/etc/hosts` entries, the `/etc/resolver` files, the pf `:80`/`:443` redirect, the `127.0.0.N` loopback aliases, the bundled-runtime CA trust and the `Caddy Local Authority` roots in your keychain, and the token files of already-revoked MCP clients. **Your data is preserved**: no Supabase volume, no DinD container, no repo file and no *live* MCP token is touched \u2014 `deep` unwinds what Supbuddy installed on the machine, it is not a data wipe |\n| `full` | \u2026plus **your project data, backed up first**: every Supbuddy-**managed** (`sb-`-prefixed) Supabase stack's data volumes and every DinD container with its data volume, the `.supbuddy/` directories, managed blocks and `.env.supbuddy` files in your registered repos, and **every** credential (license, live MCP tokens, cloud session, Tailscale key) \u2014 then it uninstalls the start-on-login service and empties the app-data directory. A **host-mode** project's Supabase stack is only *stopped*: those containers and volumes are yours, and they are kept |\n\nMost steps enumerate what's actually on your machine first, so anything that isn't there drops out of the manifest instead of being advertised and skipped. `soft` needs no elevated access at all. `deep` batches the pf redirect, the resolver configuration and the loopback aliases into **one** password prompt; the legacy `/etc/hosts` block and the keychain CA removal ask separately, so expect up to three. `full` may prompt more than once as it tears projects down.\n\n**Reset is a CLI operation, on purpose \u2014 there is no reset button in the app.** The gates that make a wipe safe don't survive the trip into a GUI: a typed `RESET`, a refusal on non-interactive input, and a daemon confirmation the app itself would be answering. On top of that, `--tier=full` refuses outright while the desktop app is running (its watchdog respawns the daemon ~20s after it stops), so a button for it would be a trap. The app's **Settings \u2192 General \u2192 System health** panel points here instead.\n\n**Backup before harm.** Anything you can't regenerate \u2014 `state.json`, every managed Supabase database that is running (`pg_dump`, custom format, with a `.sha256` alongside), every managed data volume (`tar.gz`, verified with `gzip -t`) \u2014 is written to `<app-data>/backups/reset-<timestamp>/` **before** a single destructive step runs, and if any backup fails the whole reset **aborts before destroying anything**. The directory is printed prominently before you confirm, and again when the reset finishes; `manifest.json` inside it records exactly what was planned and what ran. On top of that coarse guarantee, each volume is gated individually: **no archive, no removal** \u2014 a volume with no non-empty `.tar.gz` next to it is left alone and the run records why.\n\n**A backup that can't be written stops the reset \u2014 safely.** Archiving a volume is given ten minutes; a genuinely large one (tens of GB of Postgres data plus a DinD image cache) can exceed that, and when it does the reset **aborts with nothing destroyed**. Stop the stack and prune what you don't need (`docker system prune`, drop old branches/schemas), or archive that volume yourself, then run the reset again. The same applies to any other backup failure: a full disk, an unreadable volume, a Docker daemon that stops answering.\n\n**The backups survive a full reset.** They live inside the app-data directory, so the last step of `--tier=full` empties that directory *content-wise and skips `backups/`* rather than deleting it wholesale. Move that directory somewhere safe afterwards \u2014 it's the only copy.\n\n**Confirmation.** Every tier prints the **manifest** first \u2014 the literal list of actions that will run, derived from the same actions the engine executes. `soft` and `deep` then ask `Apply this \"<tier>\" reset? [y/N]` (default **No**); `--yes` skips that prompt. `--tier=full` requires you to **type the word `RESET`** \u2014 `--yes` alone does **not** bypass it. The one scripted path for a full reset is `--yes --i-understand`, both flags together. Every prompt refuses on a non-interactive (piped) stdin rather than proceeding.\n\n**The daemon confirms too.** `soft` and `deep` run inside the daemon, which asks for its own approval before it starts \u2014 the same gate as `doctor --fix` and `ca uninstall`. With the Supbuddy app open you get a native **Allow / Deny** dialog. A daemon with neither a dialog nor a terminal \u2014 the start-on-login service, or an app-spawned daemon while the app is closed \u2014 has nobody to ask and **denies**; run a foreground `supbuddy daemon` in one terminal and the reset from a second, and it will prompt there. Don't reach for `supbuddy daemon --yes` to get past it: that auto-approves *every* confirmation for that daemon's whole lifetime.\n\n**Quit the app before a full reset.** The desktop app supervises the daemon and restarts it about 20 seconds after it stops, which would put a live daemon back into the directory the last step clears. `--tier=full` refuses up front while the app is running \u2014 before it asks you to type `RESET`, and before it changes anything. Quit the app (menu bar icon \u2192 Quit) and run it again; the quit dialog's default **Leave running** is fine, since the reset stops the daemon itself. The check looks for the *app* process only, so nothing else has to change. `--tier=full` also runs with no daemon at all, so if you quit with **Stop service** you can go straight ahead.\n\n**The order of a full reset**, once you've confirmed: the start-on-login service is uninstalled, the daemon is stopped and waited for (the reset refuses to run against a live daemon, which would rewrite `state.json` underneath it), the backup and teardown steps above run, and only then is the app-data directory emptied \u2014 keeping `backups/`. If the reset aborted, or if a daemon came back while it was running, the app-data directory is left in place and the CLI tells you so rather than clearing it under a live process.\n\n`soft` and `deep` are also available over MCP as the plan-gated `system_wipe` tool (see *MCP tool surface*). `--tier=full` is **CLI-only**: it deletes the credentials any agent would be calling with, and a daemon cannot uninstall the service it runs under or delete the directory it runs from.\n\n**What a full reset does not remove.** It only ever touches paths of **registered** projects \u2014 there is no disk scan for stray `.supbuddy` directories \u2014 and it won't delete or rewrite files whose ownership is ambiguous. So after `--tier=full` these are still on disk, and you can remove them by hand:\n\n- Per-editor rule files Supbuddy wrote in your repos: `.cursor/rules/supbuddy.mdc`, `.claude/skills/supbuddy/SKILL.md`, `.codeium/windsurf/rules/supbuddy.md`, `.continue/rules/supbuddy.md`, `.idea/supbuddy.md`. Shared files (`CLAUDE.md`, `AGENTS.md`, `.gitignore`, \u2026) keep their content and only lose Supbuddy's sentinel-delimited block.\n- Values `apply_env` merged into your **own** `.env*` files. The fully-owned `.env.supbuddy` files *are* deleted.\n- The bare `.env.supbuddy` line in `.gitignore` \u2014 it sits outside the managed block.\n- `vite.config.*` `allowedHosts` and `next.config.*` dev-origin patches.\n- `supabase/config.toml` port / `project_id` patches, when restoring the original file failed during the Thin teardown.\n- MCP client config entries written by `mcp add` / `install_mcp_config` (`~/.claude.json`, Claude Desktop, Cursor, Codex, Windsurf, a project `.mcp.json` / `.cursor/mcp.json`). The token they hold is dead the moment the secrets are deleted; `supbuddy doctor`'s `stale-mcp-config-tokens` check will name each file.\n- The `caddy:latest` Docker image (shared and re-pullable) and anything a host-mode project owns.\n- The Supbuddy app itself \u2014 drag `Supbuddy.app` to the Trash \u2014 and the backups directory, which is the whole point of keeping it.\n\n## Settings reference\n\nOpen Settings via the gear icon top-right or by clicking the tray icon \u2192 Open Dashboard \u2192 gear. Five tabs.\n\n### General\n\n- **Theme**: dark or light.\n- **Auto-start at login**: registers Supbuddy as a macOS login item. Default: on.\n- **Default TLD**: applied to new auto-generated mappings. Existing mappings are renamed to the new TLD on save. Default: `test`.\n- **Default isolation**: `host` or `thin` for newly added projects. Default: `thin` (per-project loopback IP; apps keep canonical ports like `:3000`). MCP registration additionally keeps a project on `host` when its Supabase stack is already running on the host outside Supbuddy.\n- **Auto-subdomain mapping**: when on, services and apps detected during a project scan get mappings created automatically. Default: on.\n- **Bundled-runtime trust**: installs Supbuddy's local root CA into a place that apps with bundled JavaScript runtimes (Claude Code, Cursor, Windsurf, Continue, Codex CLI, OpenCode, \u2026) actually read. These apps don't consult the system Keychain (they ship their own Mozilla bundle), so without this they fail OAuth/MCP/HTTPS calls to `*.test` with `unable to get local issuer certificate`. Default: prompted on first launch when one of those tools is detected.\n - **macOS**: writes `~/Library/LaunchAgents/com.cueplusplus.supbuddy.bundled-runtime-ca-trust.plist` and calls `launchctl setenv NODE_EXTRA_CA_CERTS / SSL_CERT_FILE / REQUESTS_CA_BUNDLE` so GUI-launched apps inherit the right vars at process-start time.\n - **Linux**: writes `~/.config/environment.d/supbuddy-ca.conf` (read by systemd-aware user sessions on GNOME/KDE/Sway/etc.).\n - **Windows**: per-user `setx NODE_EXTRA_CA_CERTS / SSL_CERT_FILE / REQUESTS_CA_BUNDLE` to `HKCU\\Environment`.\n - All three env vars point at `~/Library/Application Support/Supbuddy/ca-bundle/current.crt` (or the platform-equivalent), a *cumulative* concatenated PEM Supbuddy maintains. When Caddy rotates its root (yearly today, sometimes more), Supbuddy appends the new root automatically; long-running TLS contexts holding the old root keep working until the process restarts.\n - **Test trust**: runs an in-process HTTPS request against the first available `*.test` mapping with the same env vars set, to verify end-to-end without relaunching anything. It probes the **real access path** (port 443 when port forwarding is on, otherwise the high port), matching what real clients hit, so it doesn't false-negative against a port nothing is forwarding.\n - **Conflict refusal**: if `NODE_EXTRA_CA_CERTS` is already set to something else (corporate proxy, Zscaler), Supbuddy refuses to overwrite and surfaces the conflicting path. You can override with the explicit prompt that pops up on Install.\n - **Quit and relaunch your AI tools** after install: the env var only takes effect for *newly-launched* processes.\n- **System health** (**Scan**): opens the **System Doctor** panel \u2014 the same read-only, 17-check health & drift scan as `supbuddy doctor` (see *System doctor*), in the app. Opening the panel only scans; it changes nothing.\n - Findings are grouped **critical \u2192 warning \u2192 info**, each with its title, one-line detail, concrete evidence (paths, container names, fingerprints), check id and category. **Rescan** re-runs the scan; the header shows the counts. A scan that times out says so and points at `supbuddy doctor` \u2014 the daemon is installed and updated separately from the app, and one older than this panel doesn't answer its channels.\n - **Fix\u2026** on a fixable finding \u2014 or **Fix all (n)** in the header \u2014 never repairs anything by itself. It opens the **manifest**: the literal list of actions that would run, each marked *destructive* or *safe*, built from the same actions the engine executes. **Apply** stays disabled until that manifest has loaded and contains at least one action, so an empty or failed plan can't be rubber-stamped. Same confirm-before-harm contract as `doctor --fix`.\n - Repairs that need elevated access ask for your password when they run. One that outlives the app's 15-second reply window (a password prompt sitting open) is reported as *may still be running \u2014 rescan in a moment*, not as a failure.\n - Findings with no auto-fix show **advisory** instead of a Fix button; the detail says what to do by hand. Checks that couldn't run at all are listed at the bottom as *Checks that could not run*, rather than being silently dropped.\n - **There is no reset button here, on purpose** \u2014 the footer points at `supbuddy reset` instead. See *System reset*.\n\n### Network\n\n- **HTTP port**: default 8080.\n- **HTTPS port**: default 8443.\n- **DNS port**: default 5353.\n- **Port forwarding**: when on, inserts a `pfctl` rule mapping 80\u2192HTTP port and 443\u2192HTTPS port into `/etc/pf.conf` (correct translation-section placement; self-heals a file corrupted by older versions). Asks for sudo once. Status reflects a live 443 enforcement probe, not just file presence.\n- **LAN sharing**: binds Caddy to `0.0.0.0` + starts mDNS responder.\n- **Tailscale**: paste a tailnet API key to enable split-DNS push.\n- **Install / Uninstall CA**: **Install** adds Caddy's root cert to your System keychain (removing any stale same-name roots first); **Uninstall** removes every `Caddy Local Authority` root it added. macOS asks for your password each time.\n\n### Storage\n\nTrash retention (per-kind), volume sizes, image-cache controls.\n\n### MCP\n\n- **Clients**: list of connected clients. Each row has a **\u22EF** actions menu: install, edit scopes, set-primary, rotate token, revoke.\n- **Activity**: audit log with Apply/Cancel/Undo on plan rows.\n- **Trash**: soft-deleted mappings and projects, restorable for 7 days.\n- Settings: server `enabled`, `port` (default 9877), `audit_cap` (default 5000), `trash_ttl_days` (default 7).\n\n### AI Skills\n\nInstall Supbuddy's agent **skill at the user level** (machine-wide) so the agent sees Supbuddy in every repo without per-project setup. Each global-capable agent has a **master on/off** plus an **autosync** toggle (keeps the installed skill refreshed when Supbuddy updates it) and shows its install path + version.\n\n- **Who can install at user level**: only agents whose global file Supbuddy fully **owns** and that **self-scope** (act only when the working directory has a `.supbuddy/`): **Claude Code** (`~/.claude/skills/supbuddy/SKILL.md`) and **Cursor** (`~/.cursor/skills/supbuddy/SKILL.md`). The install is reference-counted under a synthetic `__user__` ref so it persists independent of any project and is never pruned by the boot reconcile.\n- **Master \u2194 project**: the AI Skills tab is the **master** (user-level). To commit a skill into a specific repo, use that project's **AI Tools** tab and set the target to **Project** (the old `local` scope, which writes into the repo for teammates); **User** there means the master install covers it.\n- Agents whose global file holds *your own* content (Claude `CLAUDE.md`, Codex `AGENTS.md`, Copilot, Windsurf, Continue, JetBrains) are **project-level only**: a machine-wide write there could clobber your config, so they're injected per-project instead.\n\n## Tray menu\n\nThe macOS menu bar tray icon opens a menu with:\n\n- **Status: \u2026**: current proxy state (running / idle).\n- **DNS Active (:5353)**: shown when proxy is running.\n- **LAN Sharing (\\<ip\\>)**: shown when LAN sharing is on.\n- **Tailscale (\\<ip\\>)**: shown when Tailscale is connected.\n- **Start Proxy / Stop Proxy**: opens the dashboard.\n- **Projects**: each project opens a submenu with **Apps** (click to open the mapped URL), **Supabase** services (status dot + open), and **Scripts** (your bookmarked scripts as a one-click **Start <name>** / **Stop <name>** toggle), plus **Restart Supabase**/**Restart services** and **Show in Supbuddy**.\n- **Open Dashboard**.\n- **Sync AI context for all projects**: runs the project-context sync engine for every registered project (writes `.supbuddy/`, `CLAUDE.md`, `AGENTS.md`, etc.).\n- **Show Logs**: reveals `main.log` in Finder.\n- **Check for Updates...**: manual update check (only enabled in packaged builds).\n- **Quit**.\n\n## File locations\n\nAll under `~/Library/Application Support/Supbuddy/` on macOS:\n\n- `main.log` + `main.log.1`: app logs (rotates at 2 MB).\n- `state.json`: persistent state (projects, mappings, settings, MCP clients, license).\n- `caddy-data/`: Caddy's data dir (PKI, autosaves, certs).\n- `caddy-data/caddy/pki/authorities/local/root.crt`: the local CA cert installed in your Keychain.\n- `ca-bundle/current.crt`: cumulative PEM containing every Caddy root that has ever been emitted. Used by **Bundled-runtime trust** as the target for `NODE_EXTRA_CA_CERTS` / `SSL_CERT_FILE` / `REQUESTS_CA_BUNDLE`. Real file (not a symlink) so Bun-bundled CLIs read it correctly.\n- `ca-bundle/versioned/<sha>.crt`: per-root snapshots for forensics.\n- `Caddyfile`: generated reverse-proxy config.\n- `daemon.json`: written while a headless CLI daemon is running (pid, Socket.IO + MCP-HTTP ports, control token); `0600`, removed on shutdown. Used by `supbuddy` CLI commands to discover and authenticate to the daemon, and by the desktop app to detect a running CLI daemon at launch.\n- `certs/`: legacy CA from the pre-Caddy era (unused in current builds).\n\nMCP-specific:\n\n- MCP client tokens (file-backed secret, mode `0600`): `~/Library/Application Support/Supbuddy/secrets/mcp-<client-id>.secret`\n- MCP audit log: under `~/Library/Application Support/Supbuddy/`, capped at `audit_cap` entries (default 5000).\n\n## Troubleshooting\n\n### Run a health & drift scan first (`supbuddy doctor`)\n\nWhen something's off, `supbuddy doctor` is the quickest triage. It runs a **read-only** scan of 18 checks and prints findings by severity, and many of the issues below have a matching check \u2014 an unreadable `state.json`, an untrusted CA, a wedged Caddy, port 443 not redirecting, stale duplicate CA roots, legacy CA-trust LaunchAgents poisoning public TLS, an agent config still holding a revoked MCP token, a Firefox profile pinning an old Caddy root, and leftovers from deleted projects (Docker containers/volumes, `127.0.0.N` loopback aliases, `/etc/resolver` files, MCP token files). Add `--fix` to apply the opt-in repairs after a confirmation prompt \u2014 some checks are advisory and have no auto-fix. See [System doctor](#system-doctor) for the full check list and flags.\n\n### Browser shows \"Not secure\" or certificate warning\n\nThe Caddy CA is not trusted. Open **Settings \u2192 Network \u2192 Install Certificate**. macOS will prompt for your password. After install, fully restart your browser (Cmd+Q, not just close window). Verify: *Keychain Access* \u2192 System keychain \u2192 search for \"Caddy Local Authority\".\n\n### \"unable to get local issuer certificate\" / \"self signed certificate in certificate chain\" from Claude Code, Cursor, MCP servers, or other AI tools\n\nThese tools ship their own bundled JavaScript runtime (Bun, Electron, pkg-bundled Node) and ignore the system Keychain. Open **Settings \u2192 General \u2192 Bundled-runtime trust** and click **Install**. Then *fully quit and relaunch* the AI tool; the env vars only take effect for newly-launched processes. Verify with `launchctl getenv NODE_EXTRA_CA_CERTS` (macOS); it should print `~/Library/Application Support/Supbuddy/ca-bundle/current.crt`. If install is refused with a conflict warning, you already have `NODE_EXTRA_CA_CERTS` set (often a corporate proxy / Zscaler), so Supbuddy won't silently overwrite; use the override prompt or manually concatenate the two PEMs.\n\n### \"Docker is not running. Please start Docker Desktop.\"\n\nCompose and Supabase features need Docker. Open Docker Desktop and wait until the whale icon stops animating.\n\n### \"Docker Compose is not installed\"\n\nCompose v2 ships inside Docker Desktop. If you removed Docker Desktop and are using a standalone Docker daemon (e.g. Colima, Rancher), install compose: `brew install docker-compose`.\n\n### \"Leftover host containers\" / \"isolation drift\" warning on a project\n\nSupbuddy flags **isolation drift** when a project's running containers don't match its configured isolation mode, for example a **Host** project with a stale `thin`-mode stack still running, or a **Thin** project with leftover host-mode containers. Switching isolation modes doesn't tear down the old layer, so those containers linger, waste resources, and can shadow the project's real stack. The warning appears in the **warnings chip** next to the enable toggle (click it to see each item; it shows a spinner while Supbuddy re-checks), as an entry in the issues counter, and as a notice on the **Supabase** tab listing the exact containers and any data volumes.\n\n**Guided cleanup.** Open the Supabase tab \u2192 **Clean up leftovers\u2026** to stop and remove the leftover containers. Data volumes are kept by default; deleting them is opt-in, and when the leftover copy looks newer than the active one, it requires an explicit choice and a backup (tarred to `\u2026/Supbuddy/backups/<project>-<timestamp>/`). If you recently migrated a VM project, any leftover VM container from before migration can also be cleaned up from this flow.\n\nIf the leftover copy's data looks **newer** than the active one, the warning turns red; don't delete its volumes without first deciding which copy to keep. The Configure tab also shows a dismissible note when Supabase stacks are running on your host that Supbuddy doesn't manage at all (e.g. a plain `supabase start`).\n\n### MCP client says \"Invalid OAuth error\" or \"JSON Parse error: Unexpected EOF\"\n\nThe MCP client is trying OAuth discovery and getting an empty 404. Either the token was lost (regenerate it in **Settings \u2192 MCP \u2192 the client's \u22EF menu \u2192 Rotate token**) or you're on a build older than the OAuth-probe fix. Update to the latest version; the server now answers OAuth discovery paths with a structured 404 instead of an empty body, and 401 responses include `WWW-Authenticate: Bearer` so the client doesn't fall back to OAuth.\n\n### MCP token disappeared after app restart\n\nFixed in recent builds. If you're on an older version, regenerate the token. Root cause was that `addMcpClient` didn't trigger state persistence; the client was held in memory only.\n\n### Server Actions return 403 in a Next.js app behind Supbuddy\n\nNext.js's CSRF guard rejects POSTs whose Origin isn't in `experimental.serverActions.allowedOrigins`. Supbuddy detects this and flags it in the warnings chip: open the **Apps** tab and hit **Fix** on the affected app for a paste-ready snippet, or **Apply\u2026** to preview a unified diff and write the change to `next.config` directly. After applying, restart your dev server.\n\nOn **Next.js 15.3+/16**, a proxied dev request can also be blocked (e.g. a \"Cross origin request detected\" warning) because Supbuddy now passes the real browser `Origin` through rather than rewriting it, and Next validates it against `allowedDevOrigins` (which defaults to `localhost`). Add your Supbuddy domain to `allowedDevOrigins` in `next.config` \u2014 see [Next.js cross-origin dev requests](#nextjs-cross-origin-dev-requests-alloweddevorigins). This is a separate key from the Server Actions list; 15.3+/16 may need both.\n\n### Vite dev server returns \"Blocked request. This host is not allowed.\" (403)\n\nVite (v5+) rejects requests whose `Host` header isn't in `server.allowedHosts`, so a Vite app reached through a Supbuddy domain 403s until the host is allowed. Supbuddy detects this and flags `vite: N hosts blocked` in the warnings chip: open the **Apps** tab and hit **Fix** on the affected app for a paste-ready snippet, or **Apply\u2026** to preview a diff and write `server.allowedHosts` into your `vite.config` directly. **Restart the Vite dev server afterward**; Vite does not hot-reload its config. A single `.your-project.local` entry covers every subdomain.\n\n### Supabase Realtime: channel reaches `SUBSCRIBED` but no `postgres_changes` events arrive\n\nIf a channel subscribes fine (and writes succeed) but change events never fire, this is almost always **realtime warmup timing right after the stack starts** \u2014 not the Supbuddy proxy. Local Realtime can accept a channel join and report `SUBSCRIBED` before its logical-replication binding for the tenant is ready, so `INSERT`/`UPDATE`s in that brief window are silently missed. Give the stack a few seconds after the Supabase tab goes green, then re-subscribe (or reconnect the channel). This is **unrelated to the `.local` domain**: Kong routes `/realtime/v1/*` by path and rewrites the upstream `Host` to its internal realtime tenant, so reaching realtime through `https://api.<project>.local` behaves identically to the raw `localhost:54321` port \u2014 forwarding the `.local` host upstream does not change tenant resolution. The new `sb_publishable_*` / `sb_secret_*` API keys also work for local realtime (Kong maps them to the legacy JWT), so you don't need to switch key formats.\n\n### Project shows a red \"PROXY ERROR\" banner: domain resolves but won't load\n\nAfter the proxy starts, Supbuddy runs an end-to-end reachability check: it resolves a project domain through the OS resolver and tries to connect to Caddy on the HTTPS port. If the name resolves but the connection fails, the project shows a red **PROXY ERROR** banner naming the likely cause (DNS, port-forwarding, or mDNS race) plus a recovery action.\n\nThe most common case: the domain resolves to `127.0.0.1` but port 443 won't connect because the elevated `pfctl` 443\u21928443 redirect drifted away (typically after a restart, so Caddy is up on 8443 with nothing forwarding 443). Click **Retry**; as of v2.3.6 it re-applies the port-forwarding rule (approve the sudo prompt). On older builds, toggle the proxy off\u2192on instead. If LAN sharing is **off**, disregard any \"LAN sharing / Bonjour\" wording in the banner; the cause is the missing forward, not mDNS.\n\n### Port forwarding is on but 443 won't connect\n\nSupbuddy reports port forwarding as **active** only when a live probe confirms 443 actually reaches Caddy \u2014 the rule being on disk isn't enough. If the rule is present but not being enforced (typically right after a reboot, or when an older Supbuddy version left `/etc/pf.conf` in a broken state), the status carries a `pf_not_enforcing` diagnostic instead of a false \"enabled\", and the banner tells you to **restart the proxy** to re-apply the redirect.\n\nOlder versions appended their `rdr-anchor` to the **end** of `/etc/pf.conf`, after Apple's filter anchor \u2014 which pf rejects, because translation rules must come before filtering rules. That silently invalidated the whole ruleset, so every later `pfctl -f` failed and 443 was dead. Current builds insert the anchor in the correct translation section and **self-heal** a file corrupted by the old version on the next proxy start. Supbuddy keeps a single stable backup at `/etc/pf.conf.supbuddy-backup` (older builds accumulated unbounded timestamped backups). If a restart doesn't fix it, inspect `/etc/pf.conf` and confirm the `rdr-anchor \"virtual.localhost\"` line sits before `anchor \"com.apple/*\"`.\n\n### Proxy came up but shows a degraded \"error\" state\n\nIf the one-time sudo prompt for port forwarding / DNS is cancelled or fails, Supbuddy no longer aborts the whole start. Caddy still starts and HTTPS keeps working on the high port (8443), and the CA is still generated; the proxy just shows an actionable **error** (degraded) state with a **Retry**. Click **Retry** and approve the sudo prompt to restore real-port (80/443) access and DNS. Until then, reach your apps on `https://<domain>:8443`.\n\n### Port already in use (8080, 8443, 5353, 9877)\n\nDefault ports: HTTP 8080, HTTPS 8443, DNS 5353, MCP 9877. Change them in **Settings \u2192 Network** / **Settings \u2192 MCP**. Find what's holding a port: `lsof -i :<port>`.\n\n### Wipe everything and start over\n\nUse `supbuddy reset` (see *System reset*) \u2014 it backs up anything you can't regenerate first, and it removes the things a plain `rm -rf` leaves behind (the pf redirect, the resolver files, the loopback aliases, the trusted CA):\n\n```bash\nsupbuddy reset --tier=soft # just the app state and caches\nsupbuddy reset --tier=deep # + services, Caddy leftovers, /etc integrations, CA trust\nsupbuddy reset --tier=full # + project data, repo artifacts, secrets, service, app data\n```\n\nThe manual equivalent, if the CLI isn't available \u2014 quit Supbuddy first, and note that this deletes `secrets/` and any backups under it with no copy anywhere:\n\n```bash\n# Wipe app data (state, certs, Caddyfile, logs, MCP tokens under secrets/)\nrm -rf ~/Library/Application\\ Support/Supbuddy\n\n# Optional: remove the trusted CA\nsudo security delete-certificate -c \"Caddy Local Authority\" /Library/Keychains/System.keychain\n```\n\n## FAQ\n\n### Is Supbuddy free?\n\nYes. Supbuddy is free. Register as many projects and mappings as you want, with full HTTPS, full DNS, full Supabase isolation, and full read and write MCP access. There are no caps and no tiers.\n\n### Does Supbuddy send my data anywhere?\n\nNo. Caddy, the DNS server, and the MCP server all run locally on your Mac. The only outbound traffic is: Tailscale split-DNS push (only if you enabled it), auto-update checks (GitHub Releases), and Google Analytics on the marketing site (not the desktop app). The desktop app does not send telemetry.\n\n### Can I work offline?\n\nYes. The app works fully offline once the CA is trusted and projects are registered.\n\n### Linux / Windows support?\n\nThe desktop app is macOS-only in v2. The headless CLI and daemon also run on Linux, where `supbuddy service install` registers a `systemd-user` start-on-login unit (macOS uses `launchd`). Windows is not supported. A few desktop code paths (certutil, update-ca-certificates) anticipate other platforms but are not tested there.\n\n### Can I use my own TLD?\n\nYes. Set any TLD in **Settings \u2192 General \u2192 Default TLD**. Supbuddy installs `/etc/resolver/<project-domain>` files that tell macOS to query our DNS server for that project's domain. Avoid TLDs that actually resolve on the public internet (.com, .net, etc.); your browser will hit the real site for cached entries.\n\n### What happens if I delete a project?\n\nThe project moves to the Trash (visible in **Settings \u2192 MCP \u2192 Trash**) for 7 days, then is permanently deleted by the sweep timer. Restoring brings back the project record and all its mappings.\n\n### How do I uninstall Supbuddy?\n\n1. Quit the app (the full reset refuses to run while it's open, because its watchdog restarts the daemon).\n2. Run `supbuddy reset --tier=full` and type `RESET` when it asks. This backs up your project data, then removes the containers, volumes, `/etc` integrations, CA trust, repo artifacts, credentials, the start-on-login service and the app-data directory \u2014 keeping `<app-data>/backups/reset-<timestamp>/`. See *System reset*, including the short list of things it deliberately leaves behind.\n3. Drag **Supbuddy.app** from `/Applications` to the Trash, and move the backups directory somewhere safe (or delete it).\n4. If you'd rather not use the CLI: see \"Wipe everything and start over\" above for the manual equivalent, plus `sudo security delete-certificate -c \"Caddy Local Authority\" /Library/Keychains/System.keychain` to remove the trusted CA.\n\n### Where do I report a bug?\n\nEmail support with your version (visible at the bottom of the Settings popover) and the relevant lines from `~/Library/Application Support/Supbuddy/main.log`.\n";
|
|
39666
|
+
DOCS_MARKDOWN = "# Supbuddy docs\n\n> Run multiple Supabase projects at once on one Mac, each with its own custom local domain.\n\n## Getting started\n\nThere are two ways to run Supbuddy. Use the **macOS desktop app** (steps below), or the **command-line interface**, which runs on macOS and Linux. For the CLI, install it with `npx supbuddy@latest` and jump to [Command-line interface](#command-line-interface-cli). The app and the CLI share the same state, so you can use either or both.\n\n### 1. Install\n\nDownload the latest `.dmg` from the [download page](/api/download). Drag **Supbuddy.app** into `/Applications` and launch it. Supbuddy is signed and notarized; macOS will not show a Gatekeeper warning. Requires an Apple Silicon Mac (M1/M2/M3/M4, arm64). The desktop app is macOS-only in v2, but the headless CLI runs on Linux too. See [Command-line interface](#command-line-interface-cli).\n\n### 2. Trust the local Certificate Authority\n\nCaddy mints its local CA the first time it actually serves a site, so the cert only exists once you have **at least one enabled mapping and the proxy running** \u2014 an empty proxy never generates it. With that in place, open the app and click **Install** (the first-launch prompt, or **Settings \u2192 Network** later). Supbuddy adds the CA (Caddy's internal PKI at `~/Library/Application Support/Supbuddy/caddy-data/caddy/pki/authorities/local/root.crt`) to your **System keychain** via `sudo security add-trusted-cert`; macOS asks for your password once. Caddy does **not** self-install trust (the generated Caddyfile sets `skip_install_trust`), so this button is what makes the padlock green \u2014 fully quit and reopen your browser afterward to pick it up. Every Supbuddy domain then gets HTTPS with no per-domain prompts or warnings. (On Windows the install is manual: Supbuddy shows the PowerShell `Import-Certificate \u2026 -CertStoreLocation Cert:\\LocalMachine\\Root` command to run as Administrator.)\n\nCaddy names its root by year, so each yearly rotation (or a data wipe) leaves a same-name root behind with a different key. On every Install, Supbuddy first removes any stale `Caddy Local Authority` roots whose fingerprint doesn't match the current one, then adds the current root \u2014 leftover mismatched roots otherwise make Firefox-family browsers fail with `SEC_ERROR_BAD_SIGNATURE`.\n\n**Firefox, Zen, and Brave keep their own certificate store** that Supbuddy can't reach (they don't consult the System keychain). After a CA change, either delete any stale `Caddy Local Authority` entries from the browser's own certificate manager and re-import the new root, or \u2014 on Firefox/Zen \u2014 set `security.enterprise_roots.enabled` to `true` in `about:config` so the browser reads the System keychain.\n\nIf Supbuddy detects an AI tool that ships its own JavaScript runtime (Claude Code, Cursor, Windsurf, Continue, Codex CLI, OpenCode, etc.) it will also offer to enable **Bundled-runtime trust** in the same first-run prompt. Those tools don't read the system Keychain (they carry their own Mozilla CA bundle), so without this setup the first OAuth/MCP connection to a `*.test` URL fails with `unable to get local issuer certificate`. Enable it once and Supbuddy keeps it in sync (including across yearly Caddy CA rotation). See the **Bundled-runtime trust** section under Settings \u2192 General for details.\n\nIf you skip the prompt, you can re-trigger it any time from the **Settings \u2192 Network** tab.\n\n### 3. Add your first project\n\nClick **Add project** in the Configure tab and pick a project root folder (the one with `package.json` and/or `supabase/config.toml`). Supbuddy scans it and creates auto-mapped subdomains based on what it finds:\n\n- Supabase Kong \u2192 `api.<project>.test`\n- Supabase Studio \u2192 `studio.<project>.test`\n- Supabase Inbucket / Mailpit \u2192 `mail.<project>.test`\n- Each detected app (Next.js, Vite, etc.) \u2192 `<app-name>.<project>.test`\n\nThe default TLD is `.test`. You can change it project-wide in **Settings \u2192 General \u2192 Default TLD**.\n\n### 4. Start the proxy\n\nToggle the project on. Supbuddy starts Caddy on port 8443 (HTTPS) and starts its built-in DNS server on port 5353. If you want real ports 80/443 instead of 8080/8443, enable **port forwarding** in **Settings \u2192 Network**. Supbuddy inserts a `pfctl` redirect rule into `/etc/pf.conf` (asks for sudo once) and reports whether the redirect is actually being enforced via a live 443 probe \u2014 not merely that the rule is on disk. If port forwarding is on but 443 won't connect, see [Port forwarding is on but 443 won't connect](#port-forwarding-is-on-but-443-wont-connect).\n\n> If the one-time sudo prompt is cancelled or fails, Supbuddy no longer aborts the start: Caddy still comes up and HTTPS keeps working on the high port (8443), and the proxy shows a degraded **error** state with a **Retry** so you can re-run the privileged setup. The CA is still generated in this state.\n\n## Core concepts\n\nFour things to understand:\n\n- **Project**: a folder you registered. Holds detected *apps* (Next.js, Vite, etc.), detected *services* (Supabase stack, Docker Compose services), and a list of *mappings*.\n- **Mapping**: a domain \u2192 port pair (e.g. `api.acme.test \u2192 54321`). Auto-generated mappings are tied to a detected service or app; you can also create manual ones.\n- **Isolation mode**: per-project. One of:\n - `thin` (lightweight, **the default for newly registered projects**): still your host Docker (no nested containers, no DinD), but Supbuddy gives each project its own **port block** and a unique Compose `project_id`, written into that project's `supabase/config.toml`. That's what lets several Supabase projects run **at once on the shared daemon**, each reached by name (`api.<project>.test`, `studio.<project>.test`). Apps bind a **per-project loopback IP** (127.0.0.2, 127.0.0.3, \u2026) so every project's dev servers keep their canonical ports \u2014 each project gets its *own* `:3000`. Start dev servers with `supbuddy run -- <dev command>` so they bind that IP. Supbuddy owns those config.toml keys while the project is `thin` and restores them the moment you switch back to `host`.\n - `host`: everything shares `127.0.0.1` and the stock ports. Dev-server ports collide across projects, and only one host-mode Supabase project can run at a time (the standard `supabase start` constraint). Use `host` **only when the project's Supabase stack is already running on the host independently of Supbuddy** (you run `supabase start` yourself and don't want Supbuddy re-porting `config.toml`). MCP registration (`register_project`) detects that case and keeps such projects on `host` automatically; in the app's Add-project dialog, pick **Host** in the Environment section yourself.\n- **Active vs inactive**: any project can be \"active\" (proxied + reachable) or inactive. Inactive projects keep their state, so flipping them on is a few seconds. Run as many active projects as you want.\n\n## Project cards (Configure tab)\n\nEach registered project appears as a card in the Configure tab. Cards have a single-row header that's always visible and a tab-based body that expands on click.\n\n### Header\n\nReading left to right:\n\n- **Expand chevron** + **project name**: click to expand/collapse the card.\n- **Status indicator**: a single colored dot next to the project name aggregating the realtime state of every subsystem (Supabase services, Compose, scripts, AI sync, port conflicts, next.config warnings). Red = error, amber = warning, green = at least one service running, muted gray = idle, animated cyan spinner = transitioning. Hover for a tooltip that lists each subsystem's state.\n- **Tech badges**: e.g. `TurboRepo`, `Supabase` (shown when detected).\n\n**Supabase connection warning.** When a project's app `.env` is missing the\nSupabase connection vars, or they've gone stale relative to the live target\n(e.g. after switching isolation, which republishes ports), the card shows a\n`supabase env: not connected` / `supabase env: out of date` pill. Click it to\nopen Connect and push fresh values, or choose **Ignore for this project**.\n- **Env mode chip**: read-only `Host` or `Thin` label (matching the project's isolation mode). To switch modes, open the **Supabase** tab and use the **Environment** section at the top.\n- **Issues counter**: red for errors, amber for warnings. Click to open the **issues popover** (see below). Hidden when there are no issues.\n- **Warnings chip**: all project-level warnings (isolation drift, missing env vars, config issues, etc.) are consolidated into a single amber chip next to the enable toggle. Click it to see each warning item-by-item; it shows a spinner while Supbuddy re-checks the project.\n- **Enable toggle** (right edge): turn the project's proxy on/off without deleting it.\n- **\u22EF actions menu** (right edge): every project-level action: **Edit project**, **Rescan**, **Re-check configs** (re-runs the connection/env drift check for this project), **Select folder**, **Export bundle**, and **Delete project**.\n\n### Issues popover\n\nClicking the issues counter opens a popover listing all current errors and warnings. Each issue shows a severity icon, title, optional detail, and a **\u2192 open {tab}** link. Clicking the link jumps to the relevant tab and closes the popover.\n\n### Body tabs (when expanded)\n\nThe body renders a flat tab strip with 6 conditional tabs. Below ~480 px, the strip collapses to a dropdown selector. (Project-level actions, like edit, rescan, re-check configs, select folder, export, and delete, are in the header's **\u22EF menu**, not a tab.)\n\n#### Apps (default tab)\n\nPer-app rows are domain-first: `domain \u2192 :port` (with hover-revealed copy/open URL buttons), then app name + tech badge, then a flex spacer pushes hover-revealed **edit** / **delete** / **access** (LAN / Tailscale state) actions and the per-mapping **toggle** to the right edge. A **Map** CTA appears on hover for unmapped apps. Manual mappings scoped to this project (not auto-generated) are listed below under their own subheader.\n\n#### Supabase (shown when Supabase is detected)\n\n**Environment section (top):** host/thin switcher. A legacy project still on the old Isolated (VM) mode shows the migration wizard here instead (see [Migrating a legacy Isolated (VM) project to Thin](#migrating-a-legacy-isolated-vm-project-to-thin)).\n\n**Action bar:** Start, Stop, Restart buttons; a first-class **Connect** button (cyan, opens the connection panel for `.env` generation / merge); and a **More** menu with **Config editor** and **Details**.\n\n**Config editor: secret extraction.** When you save a `supabase/config.toml` that contains a secret-bearing value inline (e.g. an SMTP password under `[auth.email.smtp]`, an OAuth `secret`, or any `*_key`/`auth_token`), Supbuddy prompts before writing: it lists the detected secrets and lets you pick which gitignored env file to move them to (defaulting to the project-root `.env.local`). The value is written there and replaced in `config.toml` with an `env(SUPABASE_\u2026)` reference, so secrets never land in git. Supbuddy injects those `SUPABASE_`-prefixed values back into the `supabase start` environment so the references resolve. (Saving a config with no inline secrets writes directly, with no prompt.)\n\n**Service rows** (read-only): status dot, service name, URL. No inline actions; lifecycle is driven by the action bar.\n\n#### Compose (shown when Compose services are detected)\n\n**Action bar:** Start, Stop, Restart. **Service rows** are read-only (status dot, name, URL). Add-on services declared in `supbuddy.addons.yml` (see **Add-on Compose services**) appear here alongside the base stack and in `get_compose_status` over MCP.\n\n#### Other (shown when non-Supabase, non-Compose services are detected)\n\nRead-only service rows: status dot, name, URL.\n\n#### Scripts (shown when scripts are detected)\n\nBookmarked scripts appear in a **Quick Access** group at the top; remaining scripts appear under **Other Scripts**. Per-script row: status dot, name, uptime, bookmark star, Start/Stop/Restart buttons. A search input appears when there are more than 5 scripts.\n\n#### AI Tools\n\nWraps the project-context-sync panel: sync mode selector (Auto / Manual / Off), detected targets list with per-target **scope** (global / local), advanced options, and recent activity. See [Per-project AI context sync](#per-project-ai-context-sync) for what global vs. local means.\n\n> Project-level actions (**Edit**, **Rescan**, **Re-check configs**, **Select folder**, **Export bundle**, **Delete**) are no longer a tab. They live in the header's **\u22EF actions menu**.\n\n---\n\n## Multiple Supabase projects (the main use case)\n\nThe reason Supbuddy exists. Stock Supabase CLI binds to fixed ports (54321 Kong, 54322 Postgres, 54323 Studio, 54324 Inbucket). Two projects on the same machine collide; you must `supabase stop` one before `supabase start`-ing the other.\n\nTwo ways to break that constraint, picked per project in the **Supabase** tab \u2192 **Environment** section:\n\n### Thin (lightweight, recommended)\n\nSwitch a project to **Thin**. Supbuddy assigns it a free port block (in the `55000+` range), writes those ports plus a unique Compose `project_id` into its `supabase/config.toml`, and runs `supabase start` on your **normal host Docker**, with no nested containers and nothing to pull. Several projects boot side by side this way; each is reached by name (`api.acme.test`, `studio.acme.test`, `mail.acme.test`). Switch back to **Host** and Supbuddy restores the original `config.toml` and stops just that project's stack.\n\nThis is the lightest, fastest option and the right default for most setups \u2014 which is why **newly registered projects default to Thin**. One caveat: if your `config.toml` omits a port key (e.g. `[inbucket] smtp_port`), Supbuddy can't relocate a port that isn't declared, so that one service falls back to its stock port. That is fine for a single project, but spell those keys out if two Thin projects need the same service.\n\n### Dev servers on Thin: every project keeps its own `:3000`\n\nA Thin project also gets its own **loopback IP** (127.0.0.2, 127.0.0.3, \u2026, persisted per project). Its app dev servers bind that IP instead of `127.0.0.1`, so canonical ports never collide across projects \u2014 five Next.js apps in five projects can all run on `:3000` at once, and Supbuddy's proxy routes each `web.<project>.test` to its project's IP.\n\nStart dev servers through the launcher:\n\n```bash\nsupbuddy run -- next dev # binds -H <project loopback IP>, stays on :3000\nsupbuddy run -- vite # injects --host <ip> --strictPort\nsupbuddy run --print -- next dev # show what would run, without running it\n```\n\n`supbuddy run` reads the project's IP from the nearest `.supbuddy/meta.json` (`loopbackIp`, written when Thin is enabled), ensures the loopback alias exists, injects the right bind flag for the detected framework, and execs your command. It prints one concise line with the project's Caddy-proxied URL (e.g. `[supbuddy] \u2192 https://web.<project>.test`) \u2014 the address you should actually open. For **Next and Vite** it also hides the dev server's own `- Local:/- Network:` banner (which only echoes the raw loopback IP `127.0.0.N:<port>`, bypassing Supbuddy's HTTPS proxy): those two lines are filtered out of the piped output, every other line passes through untouched, and colours are preserved via `FORCE_COLOR` (stdin stays interactive). Other frameworks pass through with no filtering. When a project has several app mappings, it matches the one whose port equals the dev server's port (from `--port`/`-p` or the framework default), else lists them all. Make it the project's `dev` script (`\"dev\": \"supbuddy run -- next dev\"`) so nobody \u2014 humans or agents \u2014 has to remember it. **Never move an app to a nonstandard port because `127.0.0.1:3000` is busy**; that port belongs to another project's IP space.\n\n### When to stay on Host\n\nKeep a project on **Host** only when its Supabase stack runs on the host *independently of Supbuddy* \u2014 you run `supabase start` yourself on the stock ports and don't want Supbuddy rewriting `config.toml`. MCP registration (`register_project`) detects a stack like that (running containers for the project's `config.toml` `project_id`) and keeps the project on Host automatically; in the app's Add-project dialog, pick **Host** in the Environment section for such projects. Stop the stack (`supabase stop`) and switch to Thin whenever you're ready.\n\n### Running them all at once\n\nRegister as many projects as you want, and all of them can be \"active\" (proxied) at the same time. There's no limit. A Thin project's stack restarts in seconds; a Host project needs the standard `supabase start` cycle.\n\n### Migrating a legacy Isolated (VM) project to Thin\n\nIf you created a project in an older version of Supbuddy that used the now-retired **Isolated (VM)** mode, Supbuddy detects it on launch and offers a one-way, guided migration to **Thin**. The migration wizard appears in the **Supabase** tab's Environment section for any project still flagged as VM.\n\nThe migration is data-safe: Supbuddy dumps your Postgres data, starts a fresh Thin stack, restores the dump into it, and row-count-verifies the restore before tearing down the old VM container. No data loss. After migrating, the VM is gone and there's no way to switch back (but your data is intact in the Thin stack).\n\nOver MCP, three tools handle the migration bridge:\n\n- `list_pending_vm_migrations` (read): lists all projects still on the legacy VM mode awaiting migration.\n- `migrate_vm_to_thin` ( `{ project_id }` ) (write): starts the guided data-safe migration (dump, restore, verify).\n- `finish_vm_migration` ( `{ project_id }` ) (write): tears down the old VM container after migration is verified. Returns an error if called before verification passes.\n\n## Custom domains & TLDs\n\nEvery mapping resolves through Supbuddy's built-in DNS server on port 5353. By default the TLD is `.test` (an IETF-reserved TLD safe for local use). You can change the default in **Settings \u2192 General \u2192 Default TLD** to `local`, `dev`, or anything else; existing mappings are migrated to the new TLD on save.\n\nFor host resolution, Supbuddy *does not* use `/etc/hosts` for wildcards; it runs a DNS resolver. macOS's default resolver only queries port 53; Supbuddy installs a per-project resolver file under `/etc/resolver/<project-domain>` (e.g. `/etc/resolver/myapp.local`) pointing at `127.0.0.1:5353`. macOS picks the longest-suffix-matching file, so per-project entries route reliably without colliding with reserved namespaces like `.local` (which Bonjour/mDNS owns). You'll be prompted for sudo the first time this changes.\n\nResolver files exist only for domains the proxy actually serves \u2014 the same set that gets a Caddy site block: enabled mappings that are either standalone or under an **enabled** project. Disable or delete a project and its resolver file is removed with its routes (one sudo prompt, and only when something really changed), so its domains go back to failing as \"server not found\" instead of resolving into a TLS handshake error from a proxy that has nothing to serve. Enabling it again writes the file back; so does restarting the proxy.\n\n### Per-project TLD\n\nBy default every project's domain uses the global TLD (Settings \u2192 Default TLD, e.g. `.test`). A single project can opt into its **own** TLD \u2014 set the suffix in the project dialog, pass `tld` to the `register_project` / `update_project` MCP tools, or use the CLI: `supbuddy project add <path> --tld=portal` when registering, or `supbuddy project set <project> --tld=portal` on an existing one (`--tld=` with an empty value clears the override). That project's base domain and all its subdomains then live on the override TLD (e.g. `cueplusplus.portal`, `web.cueplusplus.portal`) while every other project stays on the global default. The override is durable across restarts and is unaffected when you change the global TLD. Prefer `.test` or a vanity label like `.portal`; avoid `.local` (it collides with macOS mDNS/Bonjour).\n\n### LAN sharing\n\nWhen LAN sharing is enabled (Settings \u2192 Network), Supbuddy binds Caddy to `0.0.0.0` instead of `127.0.0.1` and runs an mDNS responder so other machines on your local network can reach your dev servers via `<hostname>.local`. Useful for testing on your phone or another laptop without setting up Tailscale.\n\n**`.local` TLD + LAN sharing:** macOS reserves the `.local` namespace for Bonjour/mDNS (RFC 6762), and macOS's TCP stack short-circuits self-connections to your own LAN IP via the loopback path *without consulting `pf`*, so the obvious \"redirect lo0 \u2192 my LAN IP\" trick can't fix it. Supbuddy's mDNS responder works around this by **ignoring queries that originate from this machine**, letting the OS resolver fall through to `/etc/resolver/<project-domain>` (which routes to `127.0.0.1` where Caddy listens). Other LAN devices still get answered with the LAN IP and reach you normally. The net result: `.local` works correctly both on this machine and on other LAN devices, with no manual configuration. If you previously worked around this by switching to `.test`, you can switch back.\n\nIf `studio.<project>.local` (or similar) doesn't load: open the Configure tab. A red banner will tell you whether it's a DNS, port-forwarding, or mDNS-race issue, with the specific recovery action.\n\n### Tailscale\n\nIf you have Tailscale installed and a Tailscale API key configured in Settings, Supbuddy can push split-DNS routes to your tailnet so any device on your tailnet resolves your Supbuddy domains. Optional, off by default.\n\n## Monorepo support\n\nSupbuddy auto-detects these monorepo layouts when scanning a project root:\n\n- Turborepo (presence of `turbo.json`)\n- pnpm workspaces (`pnpm-workspace.yaml`)\n- npm/yarn workspaces (`workspaces` field in root `package.json`)\n- Common folder layouts: `apps/*`, `packages/*`, `services/*`, `sites/*`\n\nEach detected app gets its own subdomain. Supabase is searched for in the project root and these subdirectories: `apps/*`, `packages/*`, `services/*`, `sites/*`, `db/`, `db/*`, `database/`, `database/*`, `packages/backend`, `packages/db`, `packages/database`.\n\n### Detected app frameworks\n\nPort detection looks for the framework dependency in `package.json` and combines that with: explicit `-p`/`--port` in the dev script, `PORT=` env in the dev script, or a config file read. If none of those resolve, the framework default is used:\n\n| Framework dependency | Default port |\n| --- | --- |\n| `next` | 3000 |\n| `vite` | 5173 |\n| `@remix-run/dev`, `@remix-run/serve` | 3000 |\n| `astro` | 4321 |\n| `nuxt`, `nuxt3` | 3000 |\n| `@sveltejs/kit` | 5173 |\n| `@angular/core` | 4200 |\n| `@nestjs/core` | 3000 |\n| `express`, `fastify`, `koa`, `hono`, `@hono/node-server`, `elysia`, `polka`, `tinyhttp` | none (must be explicit in dev script) |\n\n### Server Actions allowedOrigins audit\n\nFor Next.js apps, Supbuddy reads your `next.config.{ts,mts,js,mjs,cjs}` and extracts the hosts in `experimental.serverActions.allowedOrigins`. If a mapped subdomain is missing from that list, the project's **warnings chip** flags `next.config: N origins missing`; Server Action POSTs through Supbuddy mappings would 403 otherwise. Open the **Apps** tab (the chip's \"open apps\" jump) where the affected app shows the warning with a **Fix** button.\n\nThe Fix button opens a dialog with a paste-ready snippet and an **Apply\u2026** button: click it to see a unified diff of the change Supbuddy will make to your `next.config`, then **Confirm & write** to apply it. Supbuddy handles the four common config shapes (existing `allowedOrigins` array, existing `serverActions` block without it, existing `experimental` block without `serverActions`, or no `experimental` at all). The edit is strictly additive: existing array entries are kept verbatim, including spreads (`...devHosts`), identifiers and comments, and only the missing origins are appended.\n\nIf `allowedOrigins` (or `serverActions`, or `experimental`) is set to something other than a plain array/object literal \u2014 an identifier, a function call, a ternary, `[...] as string[]` \u2014 Supbuddy **refuses to patch** rather than guess, and the dialog says so along with the exact origins to add. This is deliberate: a wrong rewrite would produce a duplicate key (TypeScript `TS1117`) that breaks your build long after the fact, so the fallback is the copyable snippet. Use it and edit by hand.\n\nAfter write, Supbuddy rescans the project so the warning disappears immediately. Restart your dev server for the change to take effect; Next.js does not hot-reload `next.config`. Over MCP the same audit is exposed as `preview_next_origins` / `apply_next_origins`; both return `ok: false` with an explanation in the refusal case, and `apply_next_origins` never writes a file it cannot verify.\n\n### Next.js cross-origin dev requests (allowedDevOrigins)\n\nSupbuddy proxies your dev server but **passes the browser's real `Origin` header through** (it no longer rewrites `Origin` to the upstream address). That's required so Server Actions and other origin checks see the actual page origin \u2014 but it means **Next.js 15.3+ and 16** dev servers, which validate cross-origin dev requests against `allowedDevOrigins` (defaulting to `localhost`), now treat a request arriving on a Supbuddy domain (or a Thin project's `127.0.0.N` loopback IP) as cross-origin and can reject it. Add your Supbuddy domain to `allowedDevOrigins` in `next.config`:\n\n```js\n// next.config.js\nmodule.exports = {\n allowedDevOrigins: ['web.myproject.test'],\n}\n```\n\nRestart the dev server afterward; Next.js does not hot-reload `next.config`. This is separate from `experimental.serverActions.allowedOrigins` (the Server Actions CSRF list above) \u2014 15.3+/16 may need both.\n\n### Vite allowedHosts audit\n\nFor Vite apps, Supbuddy reads your `vite.config.{ts,mts,cts,js,mjs,cjs}` and extracts `server.allowedHosts`. If a mapped host isn't covered, the **warnings chip** flags `vite: N hosts blocked`; Vite's dev server otherwise rejects proxied requests for unknown hosts with `Blocked request. This host (\"\u2026\") is not allowed.` (403). A `.your-project.local` entry counts as covering every subdomain, so an existing wildcard suffix doesn't trigger a false warning.\n\nLike the Next.js audit, the affected app's **Fix** button on the **Apps** tab opens a dialog with a paste-ready snippet and an **Apply\u2026** button that previews a unified diff and writes `server.allowedHosts` into your `vite.config` (handling an existing `allowedHosts` array, an existing `server` block without it, or no `server` block at all; `allowedHosts: true` is left untouched). The edit is strictly additive \u2014 existing entries, spreads and comments are kept verbatim and only missing hosts are appended \u2014 and, exactly as with the Next.js audit, Supbuddy **refuses to patch** when `allowedHosts` or `server` is set to anything other than a plain array/object literal, pointing you at the snippet instead of risking a duplicate-key build break. After write, Supbuddy rescans so the warning clears. Restart your dev server for the change to take effect; Vite does not hot-reload `vite.config`.\n\n## MCP setup (AI agents)\n\nSupbuddy ships a built-in MCP server on `http://127.0.0.1:9877/mcp` with static Bearer-token auth. Five clients have one-click install; any other MCP-compatible tool can be configured manually with the same URL + token.\n\nOpen **Settings \u2192 MCP \u2192 Add client**, pick the client kind, and Supbuddy generates a token, edits the client's config file, and backs up the original (`<file>.supbuddy-backup` next to it). If the install can't complete it surfaces an error toast rather than stalling. The same client-management surface (**Settings \u2192 MCP \u2192 Clients**: install, edit scopes, set-primary, rotate token, revoke) drives each client from the app.\n\n### Auto-install paths\n\n| Client | Config file | Transport |\n| --- | --- | --- |\n| Claude Code | `~/.claude.json` (user) or `<project>/.mcp.json` (project) | HTTP |\n| Claude Desktop | `~/Library/Application Support/Claude/claude_desktop_config.json` | stdio shim via `npx -y @supbuddy/mcp@latest` |\n| Cursor | `~/.cursor/mcp.json` (user) or `<project>/.cursor/mcp.json` (project) | HTTP |\n| Codex CLI | `~/.codex/config.toml` (adds an `[mcp_servers.supbuddy]` block) | HTTP |\n| Windsurf | `~/.codeium/windsurf/mcp_config.json` | HTTP |\n\n### MCP tool surface\n\nThe MCP server has full read and write access:\n\n- Read tools (`list_mappings`, `list_projects`, `get_health`, `get_compose_status`, `list_pending_vm_migrations`, etc.), with env values and request bodies included.\n- `get_client_capabilities` and `request_scope_elevation` (scope discovery + user-approved grant).\n- `read_env_file`, `tail_request_logs`, `watch_audit_log`.\n- Write tools: `create_mapping`, `delete_mapping` (soft-delete), `register_project`, `update_project`, `set_supabase_config_path`, `start_proxy`, `start_supabase`, `stop_supabase`, `restart_supabase`, `switch_isolation`, `migrate_vm_to_thin`, `finish_vm_migration`, `start_compose`, `stop_compose`, `restart_compose`, `scaffold_addons`, `seed_addons`, `write_env_file`, `copy_env_var`, `write_supabase_config`.\n- Scripts tools (`list_scripts`, `start_script`, `stop_script`, `restart_script`, `bookmark_script`, `tail_script_logs`); see *Scripts MCP tools* below.\n- Extended Supabase tools: `init_supabase`, `validate_supabase_config`, `list_supabase_backups`, `restore_supabase_backup`, `cancel_supabase_start`, `force_recreate_supabase`, `restart_supabase_container`, `get_supabase_analytics`, `set_supabase_analytics`.\n- Bundle (export/import a project's full config): `export_bundle`, `import_bundle`, `validate_bundle`.\n- Supbuddy Cloud (opt-in, per-project): `cloud_sign_in`, `push_to_cloud`, `get_cloud_status`, `cloud_teardown` \u2014 push a project (with its Supabase schema + data) to a hosted cloud stack and control it. The `cloud` link (`{ projectId, stackId, pushedAt, url }`) also appears on `get_project` / `list_projects`, so any client sees which projects are in the cloud.\n- Connection / env-target workflow: `preview_connection`, `get_env_targets`, `diff_env`, `apply_env`, `write_connection`, `test_connection`, `dismiss_connection_drift`.\n- Host & network tools: bundled-runtime trust (`get_trust_status`, `install_trust`, `remove_trust`, `detect_trust_tools`, `test_trust`), Tailscale (`get_tailscale_status`, `set_tailscale_key`, `remove_tailscale_key`, `test_tailscale`), DNS (`get_dns_status`), CA (`uninstall_ca`), and port-forwarding (`get_port_forwarding_status`, `set_port_forwarding`, `reload_port_forwarding`).\n- `tail_service_logs`: streams a Compose/add-on service's container logs over SSE (like `tail_request_logs` but for container stdout/stderr).\n- `watch_supabase`: streams a project's live Supabase start/stop/restart progress over SSE: operation status, image-pull/service snapshots, and (for VM projects) raw log lines. Backs `supbuddy supabase start --follow`.\n- System doctor: `doctor` (scope `read`) runs the read-only health & drift scan and returns a report of findings (each with a `checkId`, severity, evidence, and whether it's `fixable`) \u2014 it mutates nothing. `doctor_fix` ( `{ check_ids: [...] }` ) applies the opt-in repairs for those checks; it's **system-scoped and confirm-gated** (a modal, exactly like `uninstall_ca`), so a read-scoped client can't trigger a fix and an agent can't silently run a destructive repair. Backs `supbuddy doctor` / `doctor --fix` (see *System doctor*).\n- System reset: `system_wipe` ( `{ tier: \"soft\" | \"deep\" }` , scope `system`) runs the tiered reset described under *System reset*. It is gated **twice**: it always returns a plan first \u2014 even for `auto_apply` clients \u2014 whose `side_effects` are the literal manifest the wipe will execute, and the subsequent `apply` still blocks on a user confirmation modal. `tier: \"full\"` is **rejected**: it deletes the credentials the caller is authenticating with, and its final steps (uninstalling the service, removing the app-data directory) can't run inside the daemon \u2014 run `supbuddy reset --tier=full` in a terminal instead.\n- Multiple MCP clients can connect simultaneously. The same MCP-HTTP surface backs the headless **CLI** (see *Command-line interface* below).\n\n### Scopes: discovery & self-service elevation\n\nEach MCP client holds a set of **scopes** (`read`, `log_tail`, `mappings`, `projects`, `services`, `config`, `system`, `apply`) chosen when it's added. A tool call that needs a scope the client lacks fails with `scope_denied`, whose payload now carries a `user_message` and `details.remediation` pointing at the fix.\n\n- `get_client_capabilities` ( `{ tool? }` ) returns the calling client's `granted_scopes` and `available_scopes`. Pass a `tool` name to get `{ required_scope, required_feature, can_call, reason? }` so an agent can pre-flight a call instead of probing by hitting `scope_denied`.\n- `request_scope_elevation` ( `{ scopes: [...] }` ) asks the **user** to grant the named scopes. Supbuddy shows a blocking approval dialog; on approval the scopes are added to the client. Already-granted scopes short-circuit without a prompt.\n\nYou can also review and edit any client's scopes from the GUI: **Settings \u2192 MCP \u2192 Clients** lists each client's granted scopes inline and exposes a **Scopes** button that opens the same scope editor used when adding a client.\n\n### Registering a project via MCP\n\n`register_project` takes a `root_path` (required), an optional `label`, `auto_scan` (default `true`), and an optional `isolation` (`'thin'` or `'host'`). It registers the project the same way the GUI's \"Add project\" flow does:\n\n- Derives a base domain as `<slug>.<defaultTld>` from the label (or the folder name), e.g. `staffhub.test`.\n- Records both the project `path` and `rootPath` so the project is visible to the proxy, scans, and file tools alike.\n- Scans the folder (unless `auto_scan: false`) for apps, services, scripts, and package manager.\n- Creates per-app subdomain mappings from the discovered apps (e.g. `site.staffhub.test \u2192 :3400`), derives the host service subdomains (`api.`, `studio.`, \u2026), and reloads Caddy.\n- **Defaults to `thin` isolation**: the project gets its own loopback IP so its dev servers keep canonical ports (`:3000`) with no cross-project collisions \u2014 run them with `supbuddy run -- <dev command>`. The one exception: if the project's Supabase stack is **already running on the host outside Supbuddy**, registration keeps it on `host` (switching would rewrite its `config.toml` ports and orphan the running stack). Pass `isolation: 'host'` to opt out explicitly, or `isolation: 'thin'` to skip the detection and force thin.\n\nThe response includes an `isolation_note` explaining which mode was chosen and why \u2014 agents should read it instead of assuming.\n\n### Switching isolation over MCP\n\n`switch_isolation` ( `{ project_id, target_mode: 'host' | 'thin', auto_start? }` ) moves an existing project between **host** and **thin** mode. To-thin writes the per-project port block and `project_id` into `supabase/config.toml` and (unless `auto_start: false`) starts Supabase; to-host restores the original `config.toml` and stops that project's stack. It runs in the background and returns `{ started: true }`; poll `get_project` (`isolation`) for the current mode.\n\nA project can also be patched with `update_project`: its `patch` accepts `name`, `enabled`, `domain`, and `isolation` (it intentionally does **not** accept `path`/`rootPath`). Note that patching `isolation` only flips the flag; use `switch_isolation` to actually provision/tear down the port assignment.\n\n### Legacy VM migration over MCP\n\nFor projects still on the retired Isolated (VM) mode, three tools handle the one-way migration to Thin:\n\n- `list_pending_vm_migrations` (read): lists all projects still on the legacy VM mode, with their current `vmState` and migration readiness.\n- `migrate_vm_to_thin` ( `{ project_id }` ) (write): starts the guided data-safe migration. It dumps Postgres data from the VM, starts a fresh Thin stack, restores the dump, and row-count-verifies before signalling completion. Returns `{ started: true }`; poll `get_project` (`migrationState`) for progress.\n- `finish_vm_migration` ( `{ project_id }` ) (write): tears down the old VM container after verification passes. Errors if called before the verify step completes.\n\n### Repointing a project's Supabase config\n\n`set_supabase_config_path` ( `{ project_id, supabase_path }` ) switches which `supabase/config.toml` a project uses, for monorepos that carry more than one (e.g. a repo-root config and an app-level one). `supabase_path` is the project-relative directory **containing** the `supabase/` folder (`\".\"` for the repo root, e.g. `\"apps/getnightowls\"`). It persists the path, re-derives `supabaseProjectId` from the new config, and re-scans services. The previous stack's Docker volume is **left intact** (not deleted), so the switch is reversible; the response reports it under `orphaned_previous_stack`.\n\n### Moving a secret between env files\n\n`copy_env_var` ( `{ source_path, source_key, target_path, target_key? }` ) relocates a single variable from one env file to another (e.g. a value put in an app's `.env.local` that the stack actually injects from the repo-root `.env.local`). The value is read and written entirely inside the worker (it **never crosses the MCP boundary** and never appears in the audit log), so an agent can move a secret without it being printed. `target_key` defaults to `source_key`.\n\n### Plan / apply for destructive tools\n\nTools that delete or mutate state (`delete_mapping`, `delete_project`, `write_env_file`, etc.) return a *plan* with a preview. The MCP client (or you, in the Activity panel) explicitly calls `apply` with the `plan_id` to execute. Plans expire after 5 minutes if not applied. Soft-deletes go to the Trash and are recoverable for 7 days.\n\n## Add-on Compose services\n\nA project can declare **extra** Docker Compose services that Supbuddy discovers, merges, runs, health-checks, and tails alongside the managed stack: a Redis cache, a worker queue, a search engine, etc. Add-on services run on the host's shared Docker daemon in both `host` and `thin` isolation, with no extra setup needed.\n\n### Declaration files & merge precedence\n\nSupbuddy looks for up to three Compose fragments in the project and merges them, later wins:\n\n1. `docker-compose.yml`: your base Compose file.\n2. `docker-compose.override.yml`: your own override, honored if present (standard Compose convention).\n3. `supbuddy.addons.yml`: Supbuddy-owned add-on fragment.\n\nAll present fragments are passed explicitly, e.g. `docker compose -f docker-compose.yml -f docker-compose.override.yml -f supbuddy.addons.yml --project-name <pinned> \u2026`. The project name is pinned so the same set of containers is addressed every time. Add-on services join the Compose project's default network automatically; no extra network setup is needed for them to reach (or be reached by) the rest of the stack.\n\n### `supbuddy.addons.yml` format\n\nA valid Compose fragment (a standard `services:` map) plus an optional Supbuddy-only `x-supbuddy:` extension block. A plain `docker compose up` ignores `x-supbuddy:`, so the file stays usable without Supbuddy. Today `x-supbuddy` supports a one-shot **seed** step:\n\n```yaml\nservices:\n redis:\n image: redis:7-alpine\n ports: [\"6379:6379\"]\nx-supbuddy:\n seed:\n service: redis\n command: [\"redis-cli\", \"ping\"] # explicit argv, runs once after services are healthy\n runOnce: true\n```\n\nThe seed step runs **once** after the add-on services are up and healthy. It's idempotent, keyed by a signature of the seed spec, so it only re-runs if the spec changes (or you force it). It fires automatically on project start, and on demand via the `seed_addons` MCP tool.\n\n### MCP tools\n\n- `scaffold_addons` ( `{ project_id }` ): scope `config`. Creates a starter `supbuddy.addons.yml` if the project doesn't have one. Never clobbers an existing file.\n- `seed_addons` ( `{ project_id, force? }` ): scope `services`. Runs the declared `x-supbuddy.seed` step. Idempotent unless `force: true`.\n- `tail_service_logs` ( `{ project_id, service }` ): scope `log_tail`. Streams a Compose/add-on service's container logs over SSE (like `tail_request_logs`, but for container stdout/stderr).\n- `watch_supabase` ( `{ project_id }` ): scope `log_tail`. Streams a project's live Supabase start/stop/restart progress over SSE: `operation` (status + message), `progress` (image-pull/service snapshots), and `log` (raw lines, VM projects). The stream ends on a terminal status. Backs `supbuddy supabase start --follow`.\n\n### Scripts MCP tools\n\nScripts detected in a project (e.g. `dev`, `build`, `test`) are controllable over MCP:\n\n- `list_scripts` ( `{ project_id }` ): scope `read`. Returns all detected scripts with their current status and bookmark state.\n- `start_script` ( `{ project_id, script }` ): scope `services`. Starts the named script process.\n- `stop_script` ( `{ project_id, script }` ): scope `services`. Stops the named script process.\n- `restart_script` ( `{ project_id, script }` ): scope `services`. Stops then starts the named script process.\n- `bookmark_script` ( `{ project_id, script, bookmarked }` ): scope `services`. Pins (`bookmarked: true`) or unpins a script in the Quick Access group.\n- `tail_script_logs` ( `{ project_id, script }` ): scope `log_tail`. Streams the named script's stdout/stderr over SSE.\n\n### `get_compose_status` shape\n\n`get_compose_status` ( `{ project_id }` ) returns live per-service status, not just whether Compose is installed:\n\n```json\n{\n \"project_id\": \"\u2026\",\n \"compose_installed\": true,\n \"running\": true,\n \"services\": [\n { \"name\": \"redis\", \"status\": \"running\", \"health\": \"healthy\", \"ports\": [\"6379:6379\"], \"image\": \"redis:7-alpine\", \"container_id\": \"\u2026\", \"source\": \"addons\" }\n ]\n}\n```\n\nEach service's `source` is one of `base` | `override` | `addons`, telling you which fragment declared it.\n\n## Per-project AI context sync\n\nEach project has a **Context sync: AI tools** panel, accessible via the **AI Tools** tab in the project card, that writes a project-scoped briefing to disk so AI agents working in that repo see your live mappings, services, and isolation state without having to ask. Files written:\n\n- `.supbuddy/`: `README.md`, `mappings.md`, `services.md`, `project.md`, `mcp.md`, `do-not.md`, `docs.md`. The full live snapshot, regenerated on each sync.\n- `AGENTS.md` and `CLAUDE.md`: a small managed block prepended (or updated in place) telling the agent which project this is and pointing it at `.supbuddy/`.\n- Editor skill files when detected: `.cursor/rules/supbuddy.mdc`, `.claude/skills/supbuddy/SKILL.md`, `.codeium/windsurf/rules/supbuddy.md`, `.continue/rules/supbuddy.md`, `.github/copilot-instructions.md`, `.idea/supbuddy.md`.\n- `.gitignore` managed block, ignoring: `.supbuddy/meta.json` (volatile sync state), `*.supbuddy-backup-*` (rollback snapshots), and the per-editor skill files that are written **locally** (see scope below). The rest of `.supbuddy/` is intended to be committed; `AGENTS.md`, `CLAUDE.md`, and `.github/copilot-instructions.md` are also kept committable since you may have hand-written content there alongside Supbuddy's managed block.\n\n### Global vs. local scope\n\nThe per-editor skill files are generic Supbuddy-owned pointers (\"this is a Supbuddy project: read `.supbuddy/`, prefer the MCP tools\"). For editors that expose a **Supbuddy-owned global location**, Supbuddy writes that pointer **once, machine-wide** instead of copying it into every project, so it isn't duplicated across all your repos. Project-specific data always stays local in `.supbuddy/`.\n\n- **Claude Code** \u2192 one global skill at `~/.claude/skills/supbuddy/SKILL.md`. **Cursor** \u2192 `~/.cursor/skills/supbuddy/SKILL.md`. The global skill self-scopes: it only acts when the working directory has a `.supbuddy/` folder, and resolves the active project from that folder's `meta.json`.\n- All other targets (`windsurf`, `continue`, the `AGENTS.md`/`CLAUDE.md`/Copilot managed blocks, JetBrains) stay **local**: their \"global\" files are shared user files, so Supbuddy won't overwrite them.\n- Each target has a **scope** setting: `auto` (default: global for the Claude/Cursor skills, local for everything else), `global`, `local` (force per-project, useful if you commit the file for teammates), or `off`. A machine-global file is reference-counted across projects and removed automatically once no project uses it (on disabling sync, deleting a project, or switching that target back to local). Note: uninstalling Supbuddy (e.g. dragging it to the Trash on macOS) does **not** auto-remove these global files; delete them manually from `~/.claude/skills/supbuddy/` and `~/.cursor/skills/supbuddy/` if needed.\n- The always-loaded `CLAUDE.md`/`AGENTS.md` managed block stays local as a safety net so agents stay aware even if the on-demand global skill doesn't auto-activate.\n\nSync modes per project:\n\n- **Auto**: Supbuddy regenerates the files whenever mappings, services, or project state change.\n- **Manual only**: files are only written when you click **Sync now** (or use the tray's *Sync AI context for all projects*).\n- **Off**: nothing is written.\n\nThe collapsed header shows an at-a-glance status pill: mode (`auto` / `manual` / `off`), a colored dot for the last sync result, and a relative timestamp. Disabled targets (e.g. an editor whose folder isn't present) appear greyed out in the **Detected targets** list inside the panel.\n\n## Supbuddy Cloud\n\nPush a project \u2014 its Supabase schema **and data** \u2014 to a hosted cloud dev-stack (its own full self-hosted Supabase \u2014 Postgres, Auth, REST, Storage, Realtime, Studio behind a gateway \u2014 as an isolated graph of machines on a per-tenant private network) and control it from the app, the CLI, or MCP. **Opt-in and per-project:** nothing cloud-related appears in a project until you've signed in.\n\n- **Get started** \u2014 the top bar shows a **Get started with Supbuddy Cloud** strip; sign in (email/password) there. Once signed in it becomes **Open cloud** (opens [cloud.supbuddy.app](https://cloud.supbuddy.app) in your browser). Sign-in state + the Claude connection also live under **Settings \u2192 Cloud**.\n- **Push a project** \u2014 after signing in, each project's \u22EF menu gains **Push to cloud\u2026**. The push ships the project's stack descriptor + a `pg_dump` of its Supabase data (fail-closed: uploaded to a private bucket via a single-use key, sha-verified, restored *inside* the stack's private network, then deleted). Your **local project stays intact** \u2014 a **\u2601** badge appears on its row; click it (or \u22EF \u2192 **Open in cloud**) to open the stack in the web app.\n- **CLI / MCP** \u2014 the same flow headless: `supbuddy cloud login|push|status|teardown` (password via arg or `SUPBUDDY_CLOUD_PASSWORD`), or the `push_to_cloud` / `get_cloud_status` / `cloud_teardown` / `cloud_sign_in` MCP tools. `project ls` marks pushed projects with \u2601, and `get_project` / `list_projects` carry the `cloud` link. `cloud_teardown` (and the \u22EF teardown) destroy the remote stack and unlink it locally \u2014 routed through the same plan/apply gate as other destructive tools.\n- **Service breadth** \u2014 a self-hosted push provisions the **full** Supabase stack by default. Pass `push_to_cloud`'s `supabase_services: \"minimal\"` (MCP) to opt down to a lean db/auth/REST stack instead.\n- **Idle auto-stop** \u2014 a running cloud stack that reports no activity for ~30 minutes is automatically **stopped** to save cost (its data + config persist; start it again from the web app). A background reaper also reconciles any stack whose machines went missing.\n- **Web console** \u2014 [cloud.supbuddy.app](https://cloud.supbuddy.app) lists your org's stacks; open one for its per-service health, live status, and **start / stop / restart / tear down** controls, plus a **Recent activity** feed of control-plane events. **Push to cloud** in the console provisions a stack from a GitHub `owner/repo` (self-hosted or bring-your-own Supabase; full or minimal service set) \u2014 the code-only path; pushing a local project *with its data* still goes through the desktop app / CLI.\n\n## Command-line interface (CLI)\n\nEverything the desktop app can do is also driveable headlessly from a terminal, with no GUI window. The CLI runs a **daemon** (the same worker process the GUI uses: Caddy proxy, DNS, Supabase/Compose lifecycle, MCP-HTTP) and a set of commands that attach to it over the local MCP-HTTP port. This is for SSH sessions, CI, `tmux`/server boxes, and scripting.\n\nThe binary is `supbuddy`, with a short alias `sup`. Run `supbuddy help` for the full usage list.\n\nYou can install the CLI on its own, without the desktop app:\n\n```bash\nnpx supbuddy@latest # asks to install the CLI globally (supbuddy + sup)\n```\n\nThat command does nothing on its own except offer to put `supbuddy` and `sup` on your PATH. The CLI runs independently of the desktop app, so you can add the app later (or never). On a Mac the app installs the same two commands for you.\n\n### The daemon\n\n```bash\nsupbuddy daemon --detach # start the worker in the background\nsupbuddy status # daemon + proxy health, plus which worker the daemon is running\nsupbuddy stop # graceful shutdown\n```\n\n`--detach` backgrounds the daemon and prints its pid + ports. Foreground `supbuddy daemon` runs it attached (Ctrl-C shuts it down cleanly). On start the daemon writes a discovery file, `daemon.json` (mode `0600`), into the shared state dir holding its pid, the Socket.IO port, the MCP-HTTP port, and a control token; every other command reads it to find and authenticate to the daemon, so you never pass ports or tokens by hand. Only one daemon may run per state dir; a second `daemon` start is refused.\n\nThe CLI and the desktop app **share one state dir** (`~/Library/Application Support/Supbuddy/`), so they manage the same projects, mappings, and settings. They must not run two workers against it at once: if you launch the desktop app while a CLI daemon is running, the app detects it and offers to **stop the daemon and continue** or **quit**. It never forks a competing worker (which would corrupt `state.json`).\n\n### Run on login (service)\n\n```bash\nsupbuddy service install # start-on-login (launchd on macOS, systemd-user on Linux)\nsupbuddy service status\nsupbuddy service uninstall\n```\n\n### Commands\n\nAll app surfaces have a command. Names follow `supbuddy <module> <action> [args] [--flags]`. The main groups:\n\n| Group | Examples |\n| --- | --- |\n| Dev launcher | `run [--print] -- <dev command>` \u2014 on a Thin project, binds the dev server to the project's loopback IP (from `.supbuddy/meta.json`) so it keeps its canonical port (e.g. `supbuddy run -- next dev` stays on `:3000`) |\n| Health / proxy | `status`, `doctor [--fix]` (health & drift scan \u2014 see *System doctor*), `reset [--tier=soft\\|deep\\|full]` (tiered system reset \u2014 see *System reset*), `proxy status\\|start\\|stop\\|restart` |\n| Mappings | `map ls\\|add\\|get\\|set\\|enable\\|disable\\|rm\\|restore` |\n| Projects | `project ls\\|add\\|get\\|scan\\|set\\|enable\\|disable\\|rm\\|restore\\|env\\|refresh-context` |\n| Supabase | `supabase start\\|stop\\|restart\\|status <proj>` (add `--follow` to stream live progress), `supabase config apply <proj> <file>` |\n| Cloud | `cloud login <email> [<pw>]` (or `SUPBUDDY_CLOUD_PASSWORD`), `cloud push <proj> [--repo=owner/repo] [--force]`, `cloud status [<proj>]`, `cloud teardown <proj>` \u2014 push a project (with its Supabase data) to a hosted cloud stack; `project ls` marks pushed projects with \u2601 |\n| Compose | `compose up\\|down\\|restart\\|status\\|logs <proj> [svcs]` |\n| Scripts | `scripts ls\\|start\\|stop\\|restart\\|logs\\|bookmark <proj> [script]` |\n| Isolation | `isolation switch <proj> <host\\|thin>`, `isolation pending-migrations`, `migrate start\\|finish <uuid>` |\n| Certificates | `ca status\\|install\\|uninstall` |\n| Env files | `env copy <src> <key> <target>`, `env write <path> <K=V>\u2026` |\n| Settings | `settings get`, `settings set --json <patch>` |\n| MCP | `mcp add [<agent>]` (register Supbuddy into a coding agent: interactive, or `--write`/`--print`/`--prompt`), `mcp ls`, `mcp revoke <id>`, `mcp approvals apply\\|cancel <id>` |\n| Host / network | `connect`, `trust`, `tailscale`, `dns`, `pf` (port-forwarding) |\n| Logs | `logs requests [-f]`, `logs audit [-f]`, `logs get <id>` |\n| Account | `account`, `caps`, `addons scaffold\\|seed <proj>` |\n| Dashboard | `tui` (alias `dash`) |\n\nGlobal flags: `--json` (machine-readable output), `--yes` (skip confirmations), `--quiet`, `--url`/`--token` (attach to a specific/remote daemon instead of auto-discovery), `--state-dir` (override the shared dir), `--timeout`, and `-f`/`--follow` for streaming log commands and live `supabase start|stop|restart` progress.\n\nDestructive operations go through the same **plan \u2192 apply** gate as MCP (see *Plan / apply for destructive tools*); the CLI's control token is granted auto-apply, so they execute directly.\n\n### Live dashboard (TUI)\n\n```bash\nsupbuddy tui # or: sup dash\n```\n\n`supbuddy tui` opens a full-screen terminal dashboard that attaches to the running daemon and shows live connection/proxy status, the project list (with each project's isolation, Supabase, and Compose state), the mapping count, and a tail of recent requests. Press `r` to refresh, `q` to quit. It needs a running daemon (`supbuddy daemon --detach`); if none is found it tells you so.\n\n### System doctor\n\n```bash\nsupbuddy doctor # read-only scan; prints findings by severity\nsupbuddy doctor --fix # scan, show the repair manifest, confirm (y/N), then apply\nsupbuddy doctor --fix --only=ca-not-trusted # restrict repairs to specific check ids (comma-separated)\nsupbuddy doctor --fix --yes # skip the interactive confirm (scripting / CI)\n```\n\n`supbuddy doctor` runs a **read-only** health and drift scan and prints its findings grouped by severity \u2014 **critical**, **warning**, **info** \u2014 each with a title, a one-line detail, and concrete evidence (paths, container names, certificate fingerprints). The scan mutates nothing and exits non-zero when any finding is **critical**, so you can gate a script or CI on it.\n\n`--fix` re-scans, prints a **manifest** \u2014 one line per fixable finding, taken from the scan you just saw \u2014 and, unless you pass `--yes`, asks `Apply these fixes? [y/N]` (default **No**) before touching anything. (The desktop app's doctor panel shows the finer-grained repair *actions* themselves; the CLI lists the findings those actions belong to.) `--only=<comma,ids>` restricts the repair to specific check ids; `--yes` skips the prompt for non-interactive use. This is the **confirm-before-harm** contract: the scan is read-only, and every repair is opt-in and gated. Fixes that need elevated access prompt for your password when they run.\n\nA repair that ends up doing nothing is reported as such, never as success: if a requested check's finding is already gone, is advisory, can't be re-checked, or names an unknown id, it's listed under **NOT APPLIED** and the command exits non-zero.\n\nThe doctor ships **18 checks**. Rows marked **Advisory** have **no auto-fix at all**: `--fix` will never touch them, and the finding's detail tells you what to do by hand. Checks marked *macOS* return nothing on other platforms.\n\n| Check id | Severity | What it flags | Auto-fix |\n| --- | --- | --- | --- |\n| `state-corrupt` | critical | `state.json` can't be parsed (or isn't an object), so the daemon boots with **empty** state \u2014 no projects, mappings, settings or MCP clients | Copies the file aside as `state.json.corrupt-<timestamp>` so you can hand-recover it. Nothing is deleted or rewritten |\n| `caddy-stuck` | critical | Caddy is alive but its admin API is wedged, so config reloads can't land | Restarts Caddy (stop \u2192 start) |\n| `caddy-ipv4-unreachable` | critical | Caddy's loaded config declares an HTTPS listener but `127.0.0.1:<port>` **refuses** connections \u2014 every IPv4 client is cut off (browsers, curl, and the pf 443\u21928443 redirect) while the process is up and its admin API answers | **Advisory \u2014 no auto-fix.** Run `supbuddy proxy restart` to rebind. Only a connection **refused** counts: a *timeout* on a pf redirect target is normal (the reply is reverse-NAT'd back to :443 and never matches your socket), so it is never reported as a fault |\n| `ca-not-trusted` | warning | The local CA exists but the **current** root isn't trusted in the System keychain (the padlock stays broken). Detection is by fingerprint, so a stale same-name root from an earlier CA no longer counts as installed | Installs it into the System keychain (`security add-trusted-cert`; asks for your password). Where trust **cannot be read at all** (Windows) this drops to **advisory, info, no auto-fix** \u2014 it reports what to import by hand rather than offering a repair that can't run |\n| `pf-not-enforcing` | warning | Port forwarding is configured but 443 isn't redirecting | **Advisory \u2014 no auto-fix.** Run `supbuddy proxy restart`: only that path re-runs the privileged pf setup, so the doctor won't claim a success it can't deliver |\n| `duplicate-caddy-ca` | warning | *macOS.* Stale same-name `Caddy Local Authority` roots with a different key \u2014 the cause of Firefox-family `SEC_ERROR_BAD_SIGNATURE` | Deletes the stale roots **and installs the current one** in a single elevated batch (asks for your password). Delete-only could leave a machine with no trusted Caddy root at all when the current one wasn't in the keychain yet |\n| `orphan-caddy-container` | warning | A leftover pre-binary-era `supbuddy-caddy` Docker container | Removes the container, its `supbuddy-net` network and its data/config volumes (the `caddy:latest` image is kept) |\n| `orphan-lo0-aliases` | warning | *macOS.* `127.0.0.N` aliases on `lo0` owned by no Thin project \u2014 deleting a Thin project never tore its alias down | Removes only those aliases (asks for your password); `127.0.0.1` and any non-Supbuddy alias are left alone |\n| `orphan-dind` | warning | Docker-in-Docker containers from the retired Isolated (VM) mode belonging to no registered project \u2014 each one confirmed to actually be a DinD first | Force-removes those containers and their `<name>-docker` data volumes. **This is project data**: if you deleted a project and chose to keep its data, this is that data. The Caddy container and non-Supbuddy containers are never touched |\n| `orphan-supabase-volumes` | warning | Docker volumes of Supbuddy-managed (`sb-`-prefixed) Supabase stacks owned by no registered project | Removes those volumes. **This is database data.** Host-mode stacks, stacks you started yourself, and projects still in the MCP trash (restorable for 7 days) are never touched |\n| `orphan-launchagents` | warning | *macOS.* Legacy CA-trust LaunchAgents from older builds that re-export `SSL_CERT_FILE` / `REQUESTS_CA_BUNDLE` / `NODE_EXTRA_CA_CERTS` at every login and break **public** TLS | Boots each agent out and removes it, leaving a `.supbuddy-backup` copy alongside. Root-owned agents under `/Library` may resist; the fix reports those as a failure instead of claiming success |\n| `orphan-electron-token-files` | warning | Leftover `~/.config/Supbuddy/mcp/<clientId>.bin` token files from the retired Electron app, for clients that no longer exist | Deletes those files (no elevation). They can't be decrypted any more anyway; clients that are merely revoked keep their record and are left alone |\n| `orphan-mcp-secrets` | warning | `secrets/mcp-<clientId>.secret` files whose token can no longer authenticate (client revoked, or no record at all) | Deletes those files (no elevation) \u2014 it can't log a working agent out. Secrets for current clients, and the non-MCP secrets stored alongside them (license, cloud session, Tailscale key), are left untouched |\n| `unmanaged-supabase` | info | A Supabase stack on the host daemon that maps to no registered project (e.g. a plain `supabase start`) | **Advisory \u2014 no auto-fix.** Supbuddy never tears down a stack you started yourself; run `supabase stop` in its project if you don't need it |\n| `stale-resolver-files` | info | *macOS.* Supbuddy-marked `/etc/resolver/<suffix>` files for suffixes no **enabled** project or mapping claims any more (deleted projects, a disabled one, an older per-project TLD) | Removes only those files (asks for your password); suffixes still in use are left alone. Reversible \u2014 enabling the project or restarting the proxy writes the file back |\n| `pf-conf-backups` | info | *macOS.* `/etc/pf.conf.backup.<timestamp>` copies piled up in `/etc` by older versions (which wrote a new one on every port-forwarding disable) | Removes the redundant copies, **keeping the newest one** and the stable `/etc/pf.conf.supbuddy-backup` (asks for your password) |\n| `stale-mcp-config-tokens` | info | An agent config (`~/.claude.json`, Claude Desktop, Cursor, Codex, Windsurf, or a registered project's `.mcp.json` / `.cursor/mcp.json`) holds a `mcpServers.supbuddy` token Supbuddy no longer accepts \u2014 the 401 \"Token not recognized\" state | **Advisory \u2014 no auto-fix.** Supbuddy won't rewrite config files you own and edit. Delete the `mcpServers.supbuddy` entry from the file named in the finding, or run `supbuddy mcp add <agent>` to mint a fresh token. The finding names the file, never the token |\n| `stale-browser-nss-roots` | info | *macOS.* A Firefox / Zen / LibreWolf / Waterfox profile whose own NSS store (`cert9.db`) holds a `Caddy Local Authority` root Supbuddy can't reach | **Advisory \u2014 no auto-fix.** Nothing is wrong unless that browser shows certificate errors. Fix it there: Settings \u2192 Privacy & Security \u2192 Certificates \u2192 View Certificates\u2026 \u2192 Authorities, delete every `Caddy Local Authority` entry, then re-import Supbuddy's CA |\n\nThe same scan and repairs are available over MCP as the `doctor` and `doctor_fix` tools (see *MCP tool surface*), and in the app under **Settings \u2192 General \u2192 System health \u2192 Scan** \u2014 the panel scans on open, groups the findings by severity, and gates every repair behind the same manifest + confirm step (see *Settings reference \u2192 General*). The panel has no reset button: a wipe stays a CLI operation.\n\n### System reset\n\n```bash\nsupbuddy reset # soft (the default): app state + caches\nsupbuddy reset --tier=deep # + services, Caddy containers, system integrations, CA trust\nsupbuddy reset --tier=full # + project data, repo artifacts, secrets, service, app data\nsupbuddy reset --tier=deep --yes # skip the y/N confirm (scripting / CI)\nsupbuddy reset --tier=full --yes --i-understand # the ONLY scripted path for a full reset\n```\n\n`supbuddy reset` removes Supbuddy's footprint from your machine in **tiers**, and each tier is a superset of the one before it:\n\n| Tier | What it removes |\n| --- | --- |\n| `soft` (default) | App state \u2014 projects, mappings, settings, MCP clients, project-context sync and user-skill records \u2014 plus the Docker image cache (`<app-data>/image-cache`, images are re-pulled on demand) and the buffered request log. It touches **no** Docker container or volume, **nothing** under `/etc`, and **no** file in your repos, so it never asks for your password |\n| `deep` | \u2026plus: stops every service; removes the leftover Caddy container/network/volumes, the `/etc/hosts` entries, the `/etc/resolver` files, the pf `:80`/`:443` redirect, the `127.0.0.N` loopback aliases, the bundled-runtime CA trust and the `Caddy Local Authority` roots in your keychain, and the token files of already-revoked MCP clients. **Your data is preserved**: no Supabase volume, no DinD container, no repo file and no *live* MCP token is touched \u2014 `deep` unwinds what Supbuddy installed on the machine, it is not a data wipe |\n| `full` | \u2026plus **your project data, backed up first**: every Supbuddy-**managed** (`sb-`-prefixed) Supabase stack's data volumes and every DinD container with its data volume, the `.supbuddy/` directories, managed blocks and `.env.supbuddy` files in your registered repos, and **every** credential (license, live MCP tokens, cloud session, Tailscale key) \u2014 then it uninstalls the start-on-login service and empties the app-data directory. A **host-mode** project's Supabase stack is only *stopped*: those containers and volumes are yours, and they are kept |\n\nMost steps enumerate what's actually on your machine first, so anything that isn't there drops out of the manifest instead of being advertised and skipped. `soft` needs no elevated access at all. `deep` batches the pf redirect, the resolver configuration and the loopback aliases into **one** password prompt; the legacy `/etc/hosts` block and the keychain CA removal ask separately, so expect up to three. `full` may prompt more than once as it tears projects down.\n\n**Reset is a CLI operation, on purpose \u2014 there is no reset button in the app.** The gates that make a wipe safe don't survive the trip into a GUI: a typed `RESET`, a refusal on non-interactive input, and a daemon confirmation the app itself would be answering. On top of that, `--tier=full` refuses outright while the desktop app is running (its watchdog respawns the daemon ~20s after it stops), so a button for it would be a trap. The app's **Settings \u2192 General \u2192 System health** panel points here instead.\n\n**Backup before harm.** Anything you can't regenerate \u2014 `state.json`, every managed Supabase database that is running (`pg_dump`, custom format, with a `.sha256` alongside), every managed data volume (`tar.gz`, verified with `gzip -t`) \u2014 is written to `<app-data>/backups/reset-<timestamp>/` **before** a single destructive step runs, and if any backup fails the whole reset **aborts before destroying anything**. The directory is printed prominently before you confirm, and again when the reset finishes; `manifest.json` inside it records exactly what was planned and what ran. On top of that coarse guarantee, each volume is gated individually: **no archive, no removal** \u2014 a volume with no non-empty `.tar.gz` next to it is left alone and the run records why.\n\n**A backup that can't be written stops the reset \u2014 safely.** Archiving a volume is given ten minutes; a genuinely large one (tens of GB of Postgres data plus a DinD image cache) can exceed that, and when it does the reset **aborts with nothing destroyed**. Stop the stack and prune what you don't need (`docker system prune`, drop old branches/schemas), or archive that volume yourself, then run the reset again. The same applies to any other backup failure: a full disk, an unreadable volume, a Docker daemon that stops answering.\n\n**The backups survive a full reset.** They live inside the app-data directory, so the last step of `--tier=full` empties that directory *content-wise and skips `backups/`* rather than deleting it wholesale. Move that directory somewhere safe afterwards \u2014 it's the only copy.\n\n**Confirmation.** Every tier prints the **manifest** first \u2014 the literal list of actions that will run, derived from the same actions the engine executes. `soft` and `deep` then ask `Apply this \"<tier>\" reset? [y/N]` (default **No**); `--yes` skips that prompt. `--tier=full` requires you to **type the word `RESET`** \u2014 `--yes` alone does **not** bypass it. The one scripted path for a full reset is `--yes --i-understand`, both flags together. Every prompt refuses on a non-interactive (piped) stdin rather than proceeding.\n\n**The daemon confirms too.** `soft` and `deep` run inside the daemon, which asks for its own approval before it starts \u2014 the same gate as `doctor --fix` and `ca uninstall`. With the Supbuddy app open you get a native **Allow / Deny** dialog. A daemon with neither a dialog nor a terminal \u2014 the start-on-login service, or an app-spawned daemon while the app is closed \u2014 has nobody to ask and **denies**; run a foreground `supbuddy daemon` in one terminal and the reset from a second, and it will prompt there. Don't reach for `supbuddy daemon --yes` to get past it: that auto-approves *every* confirmation for that daemon's whole lifetime.\n\n**Quit the app before a full reset.** The desktop app supervises the daemon and restarts it about 20 seconds after it stops, which would put a live daemon back into the directory the last step clears. `--tier=full` refuses up front while the app is running \u2014 before it asks you to type `RESET`, and before it changes anything. Quit the app (menu bar icon \u2192 Quit) and run it again; the quit dialog's default **Leave running** is fine, since the reset stops the daemon itself. The check looks for the *app* process only, so nothing else has to change. `--tier=full` also runs with no daemon at all, so if you quit with **Stop service** you can go straight ahead.\n\n**The order of a full reset**, once you've confirmed: the start-on-login service is uninstalled, the daemon is stopped and waited for (the reset refuses to run against a live daemon, which would rewrite `state.json` underneath it), the backup and teardown steps above run, and only then is the app-data directory emptied \u2014 keeping `backups/`. If the reset aborted, or if a daemon came back while it was running, the app-data directory is left in place and the CLI tells you so rather than clearing it under a live process.\n\n`soft` and `deep` are also available over MCP as the plan-gated `system_wipe` tool (see *MCP tool surface*). `--tier=full` is **CLI-only**: it deletes the credentials any agent would be calling with, and a daemon cannot uninstall the service it runs under or delete the directory it runs from.\n\n**What a full reset does not remove.** It only ever touches paths of **registered** projects \u2014 there is no disk scan for stray `.supbuddy` directories \u2014 and it won't delete or rewrite files whose ownership is ambiguous. So after `--tier=full` these are still on disk, and you can remove them by hand:\n\n- Per-editor rule files Supbuddy wrote in your repos: `.cursor/rules/supbuddy.mdc`, `.claude/skills/supbuddy/SKILL.md`, `.codeium/windsurf/rules/supbuddy.md`, `.continue/rules/supbuddy.md`, `.idea/supbuddy.md`. Shared files (`CLAUDE.md`, `AGENTS.md`, `.gitignore`, \u2026) keep their content and only lose Supbuddy's sentinel-delimited block.\n- Values `apply_env` merged into your **own** `.env*` files. The fully-owned `.env.supbuddy` files *are* deleted.\n- The bare `.env.supbuddy` line in `.gitignore` \u2014 it sits outside the managed block.\n- `vite.config.*` `allowedHosts` and `next.config.*` dev-origin patches.\n- `supabase/config.toml` port / `project_id` patches, when restoring the original file failed during the Thin teardown.\n- MCP client config entries written by `mcp add` / `install_mcp_config` (`~/.claude.json`, Claude Desktop, Cursor, Codex, Windsurf, a project `.mcp.json` / `.cursor/mcp.json`). The token they hold is dead the moment the secrets are deleted; `supbuddy doctor`'s `stale-mcp-config-tokens` check will name each file.\n- The `caddy:latest` Docker image (shared and re-pullable) and anything a host-mode project owns.\n- The Supbuddy app itself \u2014 drag `Supbuddy.app` to the Trash \u2014 and the backups directory, which is the whole point of keeping it.\n\n## Settings reference\n\nOpen Settings via the gear icon top-right or by clicking the tray icon \u2192 Open Dashboard \u2192 gear. Five tabs.\n\n### General\n\n- **Theme**: dark or light.\n- **Auto-start at login**: registers Supbuddy as a macOS login item. Default: on.\n- **Default TLD**: applied to new auto-generated mappings. Existing mappings are renamed to the new TLD on save. Default: `test`.\n- **Default isolation**: `host` or `thin` for newly added projects. Default: `thin` (per-project loopback IP; apps keep canonical ports like `:3000`). MCP registration additionally keeps a project on `host` when its Supabase stack is already running on the host outside Supbuddy.\n- **Auto-subdomain mapping**: when on, services and apps detected during a project scan get mappings created automatically. Default: on.\n- **Bundled-runtime trust**: installs Supbuddy's local root CA into a place that apps with bundled JavaScript runtimes (Claude Code, Cursor, Windsurf, Continue, Codex CLI, OpenCode, \u2026) actually read. These apps don't consult the system Keychain (they ship their own Mozilla bundle), so without this they fail OAuth/MCP/HTTPS calls to `*.test` with `unable to get local issuer certificate`. Default: prompted on first launch when one of those tools is detected.\n - **macOS**: writes `~/Library/LaunchAgents/com.cueplusplus.supbuddy.bundled-runtime-ca-trust.plist` and calls `launchctl setenv NODE_EXTRA_CA_CERTS` so GUI-launched apps inherit it at process-start time.\n - **Linux**: writes `~/.config/environment.d/supbuddy-ca.conf` (read by systemd-aware user sessions on GNOME/KDE/Sway/etc.).\n - **Windows**: per-user `setx NODE_EXTRA_CA_CERTS` to `HKCU\\Environment`.\n - **Only `NODE_EXTRA_CA_CERTS` is set session-globally**, because it is *additive* \u2014 Node appends the file to its built-in public roots, so a stale or wrong value can never strip public trust. `SSL_CERT_FILE` / `REQUESTS_CA_BUNDLE` are deliberately **not** set globally: they *replace* the entire trust store, and pointing them at a local-only bundle breaks every public TLS handshake in the login session. Older builds did set them; install and every boot reconcile now actively unset them. OpenSSL/Python tools that need local trust get it per-project, from the merged public+local bundle.\n - It points at `~/Library/Application Support/Supbuddy/ca-bundle/current.crt` (or the platform equivalent), a *cumulative* concatenated PEM Supbuddy maintains \u2014 **not** Caddy's own `caddy-data/\u2026/pki/authorities/local/root.crt`, which rotates independently. When Caddy rotates its root (yearly today, sometimes more), Supbuddy appends the new root automatically; long-running TLS contexts holding the old root keep working until the process restarts. Reading trust status also verifies Caddy's *active* root is actually in the bundle and re-appends it if not, so a rotation can't be missed just because the file watcher wasn't running.\n - **Test trust**: runs an in-process HTTPS request against the first available `*.test` mapping with the same env vars set, to verify end-to-end without relaunching anything. It probes the **real access path** (port 443 when port forwarding is on, otherwise the high port), matching what real clients hit, so it doesn't false-negative against a port nothing is forwarding.\n - **Effective-value detection**: status reports the value *in effect*, not just the one Supbuddy set. `launchctl setenv` cannot retro-patch an already-running process, so an app launched before an install keeps whatever it captured and hands that to every shell and dev server it spawns \u2014 a terminal can be using a completely different CA path from the one `launchctl getenv` prints. Supbuddy samples three places: what it set, what a fresh login shell resolves, and what live processes actually hold. Divergent values are listed with the app to relaunch (and flagged when the file no longer exists \u2014 Node ignores a missing `NODE_EXTRA_CA_CERTS` silently, which presents as `unable to get local issuer certificate` with nothing to explain it).\n - **Conflict refusal**: if `NODE_EXTRA_CA_CERTS` is already set to a bundle Supbuddy doesn't own (corporate proxy, Zscaler, another vendor's CA), install refuses and surfaces the conflicting path. You can override with the explicit prompt that pops up on Install. A path Supbuddy *does* own but that isn't the current bundle \u2014 an older build's value, or Caddy's `root.crt` from a hand-rolled setup \u2014 is not a conflict: install corrects it.\n - **Quit and relaunch your AI tools** after install: the env var only takes effect for *newly-launched* processes. Install names any app still holding an older path.\n- **System health** (**Scan**): opens the **System Doctor** panel \u2014 the same read-only, 17-check health & drift scan as `supbuddy doctor` (see *System doctor*), in the app. Opening the panel only scans; it changes nothing.\n - Findings are grouped **critical \u2192 warning \u2192 info**, each with its title, one-line detail, concrete evidence (paths, container names, fingerprints), check id and category. **Rescan** re-runs the scan; the header shows the counts. A scan that times out says so and points at `supbuddy doctor` \u2014 the daemon is installed and updated separately from the app, and one older than this panel doesn't answer its channels.\n - **Fix\u2026** on a fixable finding \u2014 or **Fix all (n)** in the header \u2014 never repairs anything by itself. It opens the **manifest**: the literal list of actions that would run, each marked *destructive* or *safe*, built from the same actions the engine executes. **Apply** stays disabled until that manifest has loaded and contains at least one action, so an empty or failed plan can't be rubber-stamped. Same confirm-before-harm contract as `doctor --fix`.\n - Repairs that need elevated access ask for your password when they run. One that outlives the app's 15-second reply window (a password prompt sitting open) is reported as *may still be running \u2014 rescan in a moment*, not as a failure.\n - Findings with no auto-fix show **advisory** instead of a Fix button; the detail says what to do by hand. Checks that couldn't run at all are listed at the bottom as *Checks that could not run*, rather than being silently dropped.\n - **There is no reset button here, on purpose** \u2014 the footer points at `supbuddy reset` instead. See *System reset*.\n\n### Network\n\n- **HTTP port**: default 8080.\n- **HTTPS port**: default 8443.\n- **DNS port**: default 5353.\n- **Port forwarding**: when on, inserts a `pfctl` rule mapping 80\u2192HTTP port and 443\u2192HTTPS port into `/etc/pf.conf` (correct translation-section placement; self-heals a file corrupted by older versions). Asks for sudo once. Status reflects a live 443 enforcement probe, not just file presence.\n- **LAN sharing**: binds Caddy to `0.0.0.0` + starts mDNS responder.\n- **Tailscale**: paste a tailnet API key to enable split-DNS push.\n- **Install / Uninstall CA**: **Install** adds Caddy's root cert to your System keychain (removing any stale same-name roots first); **Uninstall** removes every `Caddy Local Authority` root it added. macOS asks for your password each time.\n\n### Storage\n\nTrash retention (per-kind), volume sizes, image-cache controls.\n\n### MCP\n\n- **Clients**: list of connected clients. Each row has a **\u22EF** actions menu: install, edit scopes, set-primary, rotate token, revoke.\n- **Activity**: audit log with Apply/Cancel/Undo on plan rows.\n- **Trash**: soft-deleted mappings and projects, restorable for 7 days.\n- Settings: server `enabled`, `port` (default 9877), `audit_cap` (default 5000), `trash_ttl_days` (default 7).\n\n### AI Skills\n\nInstall Supbuddy's agent **skill at the user level** (machine-wide) so the agent sees Supbuddy in every repo without per-project setup. Each global-capable agent has a **master on/off** plus an **autosync** toggle (keeps the installed skill refreshed when Supbuddy updates it) and shows its install path + version.\n\n- **Who can install at user level**: only agents whose global file Supbuddy fully **owns** and that **self-scope** (act only when the working directory has a `.supbuddy/`): **Claude Code** (`~/.claude/skills/supbuddy/SKILL.md`) and **Cursor** (`~/.cursor/skills/supbuddy/SKILL.md`). The install is reference-counted under a synthetic `__user__` ref so it persists independent of any project and is never pruned by the boot reconcile.\n- **Master \u2194 project**: the AI Skills tab is the **master** (user-level). To commit a skill into a specific repo, use that project's **AI Tools** tab and set the target to **Project** (the old `local` scope, which writes into the repo for teammates); **User** there means the master install covers it.\n- Agents whose global file holds *your own* content (Claude `CLAUDE.md`, Codex `AGENTS.md`, Copilot, Windsurf, Continue, JetBrains) are **project-level only**: a machine-wide write there could clobber your config, so they're injected per-project instead.\n\n## Tray menu\n\nThe macOS menu bar tray icon opens a menu with:\n\n- **Status: \u2026**: current proxy state (running / idle).\n- **DNS Active (:5353)**: shown when proxy is running.\n- **LAN Sharing (\\<ip\\>)**: shown when LAN sharing is on.\n- **Tailscale (\\<ip\\>)**: shown when Tailscale is connected.\n- **Start Proxy / Stop Proxy**: opens the dashboard.\n- **Projects**: each project opens a submenu with **Apps** (click to open the mapped URL), **Supabase** services (status dot + open), and **Scripts** (your bookmarked scripts as a one-click **Start <name>** / **Stop <name>** toggle), plus **Restart Supabase**/**Restart services** and **Show in Supbuddy**.\n- **Open Dashboard**.\n- **Sync AI context for all projects**: runs the project-context sync engine for every registered project (writes `.supbuddy/`, `CLAUDE.md`, `AGENTS.md`, etc.).\n- **Show Logs**: reveals `main.log` in Finder.\n- **Check for Updates...**: manual update check (only enabled in packaged builds).\n- **Quit**.\n\n## File locations\n\nAll under `~/Library/Application Support/Supbuddy/` on macOS:\n\n- `main.log` + `main.log.1`: app logs (rotates at 2 MB).\n- `state.json`: persistent state (projects, mappings, settings, MCP clients, license).\n- `caddy-data/`: Caddy's data dir (PKI, autosaves, certs).\n- `caddy-data/caddy/pki/authorities/local/root.crt`: the local CA cert installed in your Keychain.\n- `ca-bundle/current.crt`: cumulative PEM containing every Caddy root that has ever been emitted. Used by **Bundled-runtime trust** as the target for `NODE_EXTRA_CA_CERTS` / `SSL_CERT_FILE` / `REQUESTS_CA_BUNDLE`. Real file (not a symlink) so Bun-bundled CLIs read it correctly.\n- `ca-bundle/versioned/<sha>.crt`: per-root snapshots for forensics.\n- `Caddyfile`: generated reverse-proxy config.\n- `daemon.json`: written while a headless CLI daemon is running (pid, Socket.IO + MCP-HTTP ports, control token); `0600`, removed on shutdown. Used by `supbuddy` CLI commands to discover and authenticate to the daemon, and by the desktop app to detect a running CLI daemon at launch.\n- `certs/`: legacy CA from the pre-Caddy era (unused in current builds).\n\nMCP-specific:\n\n- MCP client tokens (file-backed secret, mode `0600`): `~/Library/Application Support/Supbuddy/secrets/mcp-<client-id>.secret`\n- MCP audit log: under `~/Library/Application Support/Supbuddy/`, capped at `audit_cap` entries (default 5000).\n\n## Troubleshooting\n\n### Run a health & drift scan first (`supbuddy doctor`)\n\nWhen something's off, `supbuddy doctor` is the quickest triage. It runs a **read-only** scan of 18 checks and prints findings by severity, and many of the issues below have a matching check \u2014 an unreadable `state.json`, an untrusted CA, a wedged Caddy, port 443 not redirecting, stale duplicate CA roots, legacy CA-trust LaunchAgents poisoning public TLS, an agent config still holding a revoked MCP token, a Firefox profile pinning an old Caddy root, and leftovers from deleted projects (Docker containers/volumes, `127.0.0.N` loopback aliases, `/etc/resolver` files, MCP token files). Add `--fix` to apply the opt-in repairs after a confirmation prompt \u2014 some checks are advisory and have no auto-fix. See [System doctor](#system-doctor) for the full check list and flags.\n\n### Browser shows \"Not secure\" or certificate warning\n\nThe Caddy CA is not trusted. Open **Settings \u2192 Network \u2192 Install Certificate**. macOS will prompt for your password. After install, fully restart your browser (Cmd+Q, not just close window). Verify: *Keychain Access* \u2192 System keychain \u2192 search for \"Caddy Local Authority\".\n\n### \"unable to get local issuer certificate\" / \"self signed certificate in certificate chain\" from Claude Code, Cursor, MCP servers, or other AI tools\n\nThese tools ship their own bundled JavaScript runtime (Bun, Electron, pkg-bundled Node) and ignore the system Keychain. Open **Settings \u2192 General \u2192 Bundled-runtime trust** and click **Install**. Then *fully quit and relaunch* the AI tool; the env var only takes effect for newly-launched processes. Verify with `launchctl getenv NODE_EXTRA_CA_CERTS` (macOS); it should print `~/Library/Application Support/Supbuddy/ca-bundle/current.crt`. If install is refused with a conflict warning, you already have `NODE_EXTRA_CA_CERTS` pointing at a bundle Supbuddy doesn't own (often a corporate proxy / Zscaler), so Supbuddy won't silently overwrite; use the override prompt or manually concatenate the two PEMs.\n\nIf it *still* fails after a relaunch, the process is probably not using the value `launchctl getenv` prints. Compare them:\n\n```bash\nlaunchctl getenv NODE_EXTRA_CA_CERTS # what Supbuddy set\nnode -e \"console.log(process.env.NODE_EXTRA_CA_CERTS)\" # what your shell actually has\n```\n\nIf they differ, an app launched *before* the install captured the old value and is handing it to every shell and dev server it spawns \u2014 `launchctl setenv` cannot change an already-running process. The trust panel lists the divergent value and names the app to relaunch; quitting and reopening that app (not just the terminal tab) fixes it. A value pointing at Caddy's own `caddy-data/\u2026/pki/authorities/local/root.crt` is the classic case: that file rotates independently of Supbuddy's bundle, so the two agree until they suddenly don't.\n\n### \"Docker is not running. Please start Docker Desktop.\"\n\nCompose and Supabase features need Docker. Open Docker Desktop and wait until the whale icon stops animating.\n\n### \"Docker Compose is not installed\"\n\nCompose v2 ships inside Docker Desktop. If you removed Docker Desktop and are using a standalone Docker daemon (e.g. Colima, Rancher), install compose: `brew install docker-compose`.\n\n### \"Leftover host containers\" / \"isolation drift\" warning on a project\n\nSupbuddy flags **isolation drift** when a project's running containers don't match its configured isolation mode, for example a **Host** project with a stale `thin`-mode stack still running, or a **Thin** project with leftover host-mode containers. Switching isolation modes doesn't tear down the old layer, so those containers linger, waste resources, and can shadow the project's real stack. The warning appears in the **warnings chip** next to the enable toggle (click it to see each item; it shows a spinner while Supbuddy re-checks), as an entry in the issues counter, and as a notice on the **Supabase** tab listing the exact containers and any data volumes.\n\n**Guided cleanup.** Open the Supabase tab \u2192 **Clean up leftovers\u2026** to stop and remove the leftover containers. Data volumes are kept by default; deleting them is opt-in, and when the leftover copy looks newer than the active one, it requires an explicit choice and a backup (tarred to `\u2026/Supbuddy/backups/<project>-<timestamp>/`). If you recently migrated a VM project, any leftover VM container from before migration can also be cleaned up from this flow.\n\nIf the leftover copy's data looks **newer** than the active one, the warning turns red; don't delete its volumes without first deciding which copy to keep. The Configure tab also shows a dismissible note when Supabase stacks are running on your host that Supbuddy doesn't manage at all (e.g. a plain `supabase start`).\n\n### MCP client says \"Invalid OAuth error\" or \"JSON Parse error: Unexpected EOF\"\n\nThe MCP client is trying OAuth discovery and getting an empty 404. Either the token was lost (regenerate it in **Settings \u2192 MCP \u2192 the client's \u22EF menu \u2192 Rotate token**) or you're on a build older than the OAuth-probe fix. Update to the latest version; the server now answers OAuth discovery paths with a structured 404 instead of an empty body, and 401 responses include `WWW-Authenticate: Bearer` so the client doesn't fall back to OAuth.\n\n### MCP token disappeared after app restart\n\nFixed in recent builds. If you're on an older version, regenerate the token. Root cause was that `addMcpClient` didn't trigger state persistence; the client was held in memory only.\n\n### Server Actions return 403 in a Next.js app behind Supbuddy\n\nNext.js's CSRF guard rejects POSTs whose Origin isn't in `experimental.serverActions.allowedOrigins`. Supbuddy detects this and flags it in the warnings chip: open the **Apps** tab and hit **Fix** on the affected app for a paste-ready snippet, or **Apply\u2026** to preview a unified diff and write the change to `next.config` directly. After applying, restart your dev server.\n\nOn **Next.js 15.3+/16**, a proxied dev request can also be blocked (e.g. a \"Cross origin request detected\" warning) because Supbuddy now passes the real browser `Origin` through rather than rewriting it, and Next validates it against `allowedDevOrigins` (which defaults to `localhost`). Add your Supbuddy domain to `allowedDevOrigins` in `next.config` \u2014 see [Next.js cross-origin dev requests](#nextjs-cross-origin-dev-requests-alloweddevorigins). This is a separate key from the Server Actions list; 15.3+/16 may need both.\n\n### Vite dev server returns \"Blocked request. This host is not allowed.\" (403)\n\nVite (v5+) rejects requests whose `Host` header isn't in `server.allowedHosts`, so a Vite app reached through a Supbuddy domain 403s until the host is allowed. Supbuddy detects this and flags `vite: N hosts blocked` in the warnings chip: open the **Apps** tab and hit **Fix** on the affected app for a paste-ready snippet, or **Apply\u2026** to preview a diff and write `server.allowedHosts` into your `vite.config` directly. **Restart the Vite dev server afterward**; Vite does not hot-reload its config. A single `.your-project.local` entry covers every subdomain.\n\n### Supabase Realtime: channel reaches `SUBSCRIBED` but no `postgres_changes` events arrive\n\nIf a channel subscribes fine (and writes succeed) but change events never fire, this is almost always **realtime warmup timing right after the stack starts** \u2014 not the Supbuddy proxy. Local Realtime can accept a channel join and report `SUBSCRIBED` before its logical-replication binding for the tenant is ready, so `INSERT`/`UPDATE`s in that brief window are silently missed. Give the stack a few seconds after the Supabase tab goes green, then re-subscribe (or reconnect the channel). This is **unrelated to the `.local` domain**: Kong routes `/realtime/v1/*` by path and rewrites the upstream `Host` to its internal realtime tenant, so reaching realtime through `https://api.<project>.local` behaves identically to the raw `localhost:54321` port \u2014 forwarding the `.local` host upstream does not change tenant resolution. The new `sb_publishable_*` / `sb_secret_*` API keys also work for local realtime (Kong maps them to the legacy JWT), so you don't need to switch key formats.\n\n### Project shows a red \"PROXY ERROR\" banner: domain resolves but won't load\n\nAfter the proxy starts, Supbuddy runs an end-to-end reachability check: it resolves a project domain through the OS resolver and tries to connect to Caddy on the HTTPS port. If the name resolves but the connection fails, the project shows a red **PROXY ERROR** banner naming the likely cause (DNS, port-forwarding, or mDNS race) plus a recovery action.\n\nThe most common case: the domain resolves to `127.0.0.1` but port 443 won't connect because the elevated `pfctl` 443\u21928443 redirect drifted away (typically after a restart, so Caddy is up on 8443 with nothing forwarding 443). Click **Retry**; as of v2.3.6 it re-applies the port-forwarding rule (approve the sudo prompt). On older builds, toggle the proxy off\u2192on instead. If LAN sharing is **off**, disregard any \"LAN sharing / Bonjour\" wording in the banner; the cause is the missing forward, not mDNS.\n\n### Port forwarding is on but 443 won't connect\n\nSupbuddy reports port forwarding as **active** only when a live probe confirms 443 actually reaches Caddy \u2014 the rule being on disk isn't enough. If the rule is present but not being enforced (typically right after a reboot, or when an older Supbuddy version left `/etc/pf.conf` in a broken state), the status carries a `pf_not_enforcing` diagnostic instead of a false \"enabled\", and the banner tells you to **restart the proxy** to re-apply the redirect.\n\nOlder versions appended their `rdr-anchor` to the **end** of `/etc/pf.conf`, after Apple's filter anchor \u2014 which pf rejects, because translation rules must come before filtering rules. That silently invalidated the whole ruleset, so every later `pfctl -f` failed and 443 was dead. Current builds insert the anchor in the correct translation section and **self-heal** a file corrupted by the old version on the next proxy start. Supbuddy keeps a single stable backup at `/etc/pf.conf.supbuddy-backup` (older builds accumulated unbounded timestamped backups). If a restart doesn't fix it, inspect `/etc/pf.conf` and confirm the `rdr-anchor \"virtual.localhost\"` line sits before `anchor \"com.apple/*\"`.\n\n### Proxy came up but shows a degraded \"error\" state\n\nIf the one-time sudo prompt for port forwarding / DNS is cancelled or fails, Supbuddy no longer aborts the whole start. Caddy still starts and HTTPS keeps working on the high port (8443), and the CA is still generated; the proxy just shows an actionable **error** (degraded) state with a **Retry**. Click **Retry** and approve the sudo prompt to restore real-port (80/443) access and DNS. Until then, reach your apps on `https://<domain>:8443`.\n\n### Port already in use (8080, 8443, 5353, 9877)\n\nDefault ports: HTTP 8080, HTTPS 8443, DNS 5353, MCP 9877. Change them in **Settings \u2192 Network** / **Settings \u2192 MCP**. Find what's holding a port: `lsof -i :<port>`.\n\n### Wipe everything and start over\n\nUse `supbuddy reset` (see *System reset*) \u2014 it backs up anything you can't regenerate first, and it removes the things a plain `rm -rf` leaves behind (the pf redirect, the resolver files, the loopback aliases, the trusted CA):\n\n```bash\nsupbuddy reset --tier=soft # just the app state and caches\nsupbuddy reset --tier=deep # + services, Caddy leftovers, /etc integrations, CA trust\nsupbuddy reset --tier=full # + project data, repo artifacts, secrets, service, app data\n```\n\nThe manual equivalent, if the CLI isn't available \u2014 quit Supbuddy first, and note that this deletes `secrets/` and any backups under it with no copy anywhere:\n\n```bash\n# Wipe app data (state, certs, Caddyfile, logs, MCP tokens under secrets/)\nrm -rf ~/Library/Application\\ Support/Supbuddy\n\n# Optional: remove the trusted CA\nsudo security delete-certificate -c \"Caddy Local Authority\" /Library/Keychains/System.keychain\n```\n\n## FAQ\n\n### Is Supbuddy free?\n\nYes. Supbuddy is free. Register as many projects and mappings as you want, with full HTTPS, full DNS, full Supabase isolation, and full read and write MCP access. There are no caps and no tiers.\n\n### Does Supbuddy send my data anywhere?\n\nNo. Caddy, the DNS server, and the MCP server all run locally on your Mac. The only outbound traffic is: Tailscale split-DNS push (only if you enabled it), auto-update checks (GitHub Releases), and Google Analytics on the marketing site (not the desktop app). The desktop app does not send telemetry.\n\n### Can I work offline?\n\nYes. The app works fully offline once the CA is trusted and projects are registered.\n\n### Linux / Windows support?\n\nThe desktop app is macOS-only in v2. The headless CLI and daemon also run on Linux, where `supbuddy service install` registers a `systemd-user` start-on-login unit (macOS uses `launchd`). Windows is not supported. A few desktop code paths (certutil, update-ca-certificates) anticipate other platforms but are not tested there.\n\n### Can I use my own TLD?\n\nYes. Set any TLD in **Settings \u2192 General \u2192 Default TLD**. Supbuddy installs `/etc/resolver/<project-domain>` files that tell macOS to query our DNS server for that project's domain. Avoid TLDs that actually resolve on the public internet (.com, .net, etc.); your browser will hit the real site for cached entries.\n\n### What happens if I delete a project?\n\nThe project moves to the Trash (visible in **Settings \u2192 MCP \u2192 Trash**) for 7 days, then is permanently deleted by the sweep timer. Restoring brings back the project record and all its mappings.\n\n### How do I uninstall Supbuddy?\n\n1. Quit the app (the full reset refuses to run while it's open, because its watchdog restarts the daemon).\n2. Run `supbuddy reset --tier=full` and type `RESET` when it asks. This backs up your project data, then removes the containers, volumes, `/etc` integrations, CA trust, repo artifacts, credentials, the start-on-login service and the app-data directory \u2014 keeping `<app-data>/backups/reset-<timestamp>/`. See *System reset*, including the short list of things it deliberately leaves behind.\n3. Drag **Supbuddy.app** from `/Applications` to the Trash, and move the backups directory somewhere safe (or delete it).\n4. If you'd rather not use the CLI: see \"Wipe everything and start over\" above for the manual equivalent, plus `sudo security delete-certificate -c \"Caddy Local Authority\" /Library/Keychains/System.keychain` to remove the trusted CA.\n\n### Where do I report a bug?\n\nEmail support with your version (visible at the bottom of the Settings popover) and the relevant lines from `~/Library/Application Support/Supbuddy/main.log`.\n";
|
|
39422
39667
|
}
|
|
39423
39668
|
});
|
|
39424
39669
|
|
|
@@ -39808,9 +40053,9 @@ When a \`.supbuddy/\` directory IS present (use the NEAREST one at or above the
|
|
|
39808
40053
|
});
|
|
39809
40054
|
|
|
39810
40055
|
// ../../packages/core/project-context/managed-block.ts
|
|
39811
|
-
import
|
|
40056
|
+
import crypto3 from "crypto";
|
|
39812
40057
|
function blockChecksum(body) {
|
|
39813
|
-
return
|
|
40058
|
+
return crypto3.createHash("sha256").update(body, "utf-8").digest("hex");
|
|
39814
40059
|
}
|
|
39815
40060
|
function extractBlock(text) {
|
|
39816
40061
|
const beginMatch = BEGIN_RE.exec(text);
|
|
@@ -39854,11 +40099,11 @@ var init_managed_block = __esm({
|
|
|
39854
40099
|
|
|
39855
40100
|
// ../../packages/core/project-context/write-engine.ts
|
|
39856
40101
|
import fs22 from "fs/promises";
|
|
39857
|
-
import
|
|
39858
|
-
import
|
|
40102
|
+
import path23 from "path";
|
|
40103
|
+
import crypto4 from "crypto";
|
|
39859
40104
|
async function atomicWrite(absolutePath, content) {
|
|
39860
|
-
await fs22.mkdir(
|
|
39861
|
-
const tmp = absolutePath + ".tmp." + process.pid + "." + Date.now() + "." +
|
|
40105
|
+
await fs22.mkdir(path23.dirname(absolutePath), { recursive: true });
|
|
40106
|
+
const tmp = absolutePath + ".tmp." + process.pid + "." + Date.now() + "." + crypto4.randomBytes(3).toString("hex");
|
|
39862
40107
|
await fs22.writeFile(tmp, content, "utf-8");
|
|
39863
40108
|
await fs22.rename(tmp, absolutePath);
|
|
39864
40109
|
}
|
|
@@ -39927,13 +40172,13 @@ var init_write_engine = __esm({
|
|
|
39927
40172
|
|
|
39928
40173
|
// ../../packages/core/project-context/gitignore.ts
|
|
39929
40174
|
import fs23 from "fs/promises";
|
|
39930
|
-
import
|
|
40175
|
+
import path24 from "path";
|
|
39931
40176
|
function buildGitignoreBody(localOwnedRels = []) {
|
|
39932
40177
|
const editorEntries = [...new Set(localOwnedRels)].sort();
|
|
39933
40178
|
return ["# Supbuddy-managed (do not commit)", ...ALWAYS_IGNORED, ...editorEntries].join("\n");
|
|
39934
40179
|
}
|
|
39935
40180
|
async function ensureGitignoreEntries(projectPath, localOwnedRels = []) {
|
|
39936
|
-
const p =
|
|
40181
|
+
const p = path24.join(projectPath, ".gitignore");
|
|
39937
40182
|
let existing = "";
|
|
39938
40183
|
try {
|
|
39939
40184
|
existing = await fs23.readFile(p, "utf-8");
|
|
@@ -39945,7 +40190,7 @@ async function ensureGitignoreEntries(projectPath, localOwnedRels = []) {
|
|
|
39945
40190
|
await fs23.writeFile(p, updated, "utf-8");
|
|
39946
40191
|
}
|
|
39947
40192
|
async function removeGitignoreEntries(projectPath) {
|
|
39948
|
-
const p =
|
|
40193
|
+
const p = path24.join(projectPath, ".gitignore");
|
|
39949
40194
|
let existing = "";
|
|
39950
40195
|
try {
|
|
39951
40196
|
existing = await fs23.readFile(p, "utf-8");
|
|
@@ -39968,10 +40213,10 @@ var init_gitignore = __esm({
|
|
|
39968
40213
|
});
|
|
39969
40214
|
|
|
39970
40215
|
// ../../packages/core/project-context/capabilities.ts
|
|
39971
|
-
import
|
|
39972
|
-
import
|
|
40216
|
+
import path25 from "path";
|
|
40217
|
+
import os10 from "os";
|
|
39973
40218
|
function globalHomeDir() {
|
|
39974
|
-
return process.env.SUPBUDDY_HOME_DIR ||
|
|
40219
|
+
return process.env.SUPBUDDY_HOME_DIR || os10.homedir();
|
|
39975
40220
|
}
|
|
39976
40221
|
function resolveTargetScope(scope, cap) {
|
|
39977
40222
|
const s = scope ?? "auto";
|
|
@@ -39983,7 +40228,7 @@ function resolveTargetScope(scope, cap) {
|
|
|
39983
40228
|
}
|
|
39984
40229
|
function resolveGlobalPath(cap, homeDir) {
|
|
39985
40230
|
if (!cap.globalPathParts) return null;
|
|
39986
|
-
return
|
|
40231
|
+
return path25.join(homeDir, ...cap.globalPathParts);
|
|
39987
40232
|
}
|
|
39988
40233
|
var TARGET_CAPABILITIES;
|
|
39989
40234
|
var init_capabilities = __esm({
|
|
@@ -40008,10 +40253,10 @@ var init_capabilities = __esm({
|
|
|
40008
40253
|
|
|
40009
40254
|
// ../../packages/core/project-context/global-registry.ts
|
|
40010
40255
|
import fs24 from "fs/promises";
|
|
40011
|
-
import
|
|
40012
|
-
import
|
|
40256
|
+
import path26 from "path";
|
|
40257
|
+
import crypto5 from "crypto";
|
|
40013
40258
|
async function registryPath() {
|
|
40014
|
-
return
|
|
40259
|
+
return path26.join(await getAppSupportDir(), "global-context.json");
|
|
40015
40260
|
}
|
|
40016
40261
|
async function loadRegistry() {
|
|
40017
40262
|
const p = await registryPath();
|
|
@@ -40027,7 +40272,7 @@ async function saveRegistry(reg) {
|
|
|
40027
40272
|
}
|
|
40028
40273
|
async function rmdirLeaf(filePath) {
|
|
40029
40274
|
try {
|
|
40030
|
-
await fs24.rmdir(
|
|
40275
|
+
await fs24.rmdir(path26.dirname(filePath));
|
|
40031
40276
|
} catch {
|
|
40032
40277
|
}
|
|
40033
40278
|
}
|
|
@@ -40087,7 +40332,7 @@ var init_global_registry = __esm({
|
|
|
40087
40332
|
init_store();
|
|
40088
40333
|
init_write_engine();
|
|
40089
40334
|
init_capabilities();
|
|
40090
|
-
sha = (s) =>
|
|
40335
|
+
sha = (s) => crypto5.createHash("sha256").update(s).digest("hex");
|
|
40091
40336
|
registryLock = Promise.resolve();
|
|
40092
40337
|
}
|
|
40093
40338
|
});
|
|
@@ -40103,7 +40348,7 @@ __export(sync_manager_exports, {
|
|
|
40103
40348
|
stopContextSync: () => stopContextSync,
|
|
40104
40349
|
syncProjectNow: () => syncProjectNow
|
|
40105
40350
|
});
|
|
40106
|
-
import
|
|
40351
|
+
import path27 from "path";
|
|
40107
40352
|
import fs25 from "fs/promises";
|
|
40108
40353
|
import { createRequire as createRequire2 } from "module";
|
|
40109
40354
|
function effectiveScope(slot, settings) {
|
|
@@ -40236,7 +40481,7 @@ async function syncProjectNow(projectId, opts = {}) {
|
|
|
40236
40481
|
try {
|
|
40237
40482
|
const r = await ensureGlobalFile(gp, content, SUPBUDDY_VERSION, projectId);
|
|
40238
40483
|
files.push({ path: gp, rel_path: gp, target: t.slot, status: r.status });
|
|
40239
|
-
await fs25.rm(
|
|
40484
|
+
await fs25.rm(path27.join(project.path, t.rel), { force: true }).catch(() => {
|
|
40240
40485
|
});
|
|
40241
40486
|
delete checksums[t.rel];
|
|
40242
40487
|
} catch (err) {
|
|
@@ -40251,7 +40496,7 @@ async function syncProjectNow(projectId, opts = {}) {
|
|
|
40251
40496
|
continue;
|
|
40252
40497
|
}
|
|
40253
40498
|
}
|
|
40254
|
-
const abs =
|
|
40499
|
+
const abs = path27.join(project.path, t.rel);
|
|
40255
40500
|
try {
|
|
40256
40501
|
let res;
|
|
40257
40502
|
if (t.ownership === "managed-block") {
|
|
@@ -40307,7 +40552,7 @@ async function syncProjectNow(projectId, opts = {}) {
|
|
|
40307
40552
|
}
|
|
40308
40553
|
}
|
|
40309
40554
|
if (settings.manage_gitignore) {
|
|
40310
|
-
const gitignorePath =
|
|
40555
|
+
const gitignorePath = path27.join(project.path, ".gitignore");
|
|
40311
40556
|
try {
|
|
40312
40557
|
let before = null;
|
|
40313
40558
|
try {
|
|
@@ -40334,7 +40579,7 @@ async function syncProjectNow(projectId, opts = {}) {
|
|
|
40334
40579
|
});
|
|
40335
40580
|
}
|
|
40336
40581
|
}
|
|
40337
|
-
const metaAbs =
|
|
40582
|
+
const metaAbs = path27.join(project.path, ".supbuddy", "meta.json");
|
|
40338
40583
|
const metaRel = ".supbuddy/meta.json";
|
|
40339
40584
|
try {
|
|
40340
40585
|
const checksumsForMeta = { ...checksums };
|
|
@@ -40720,18 +40965,18 @@ var init_dind = __esm({
|
|
|
40720
40965
|
|
|
40721
40966
|
// ../../packages/core/system-doctor/wipe/steps/repo-artifacts.ts
|
|
40722
40967
|
import fs26 from "fs/promises";
|
|
40723
|
-
import
|
|
40968
|
+
import path28 from "path";
|
|
40724
40969
|
async function ownedEnvFiles(p, repo) {
|
|
40725
|
-
const root =
|
|
40970
|
+
const root = path28.resolve(repo);
|
|
40726
40971
|
const dirs = /* @__PURE__ */ new Set([root]);
|
|
40727
40972
|
for (const app of p.apps ?? []) {
|
|
40728
|
-
if (!app?.path || !
|
|
40729
|
-
const abs =
|
|
40730
|
-
if (abs === root || abs.startsWith(`${root}${
|
|
40973
|
+
if (!app?.path || !path28.isAbsolute(app.path)) continue;
|
|
40974
|
+
const abs = path28.resolve(app.path);
|
|
40975
|
+
if (abs === root || abs.startsWith(`${root}${path28.sep}`)) dirs.add(abs);
|
|
40731
40976
|
}
|
|
40732
40977
|
const files = [];
|
|
40733
40978
|
for (const d of dirs) {
|
|
40734
|
-
const f =
|
|
40979
|
+
const f = path28.join(d, ".env.supbuddy");
|
|
40735
40980
|
try {
|
|
40736
40981
|
if ((await fs26.lstat(f)).isFile()) files.push(f);
|
|
40737
40982
|
} catch {
|
|
@@ -40740,9 +40985,9 @@ async function ownedEnvFiles(p, repo) {
|
|
|
40740
40985
|
return files;
|
|
40741
40986
|
}
|
|
40742
40987
|
function isSafeProjectPath(p) {
|
|
40743
|
-
if (!
|
|
40744
|
-
const resolved =
|
|
40745
|
-
return resolved !==
|
|
40988
|
+
if (!path28.isAbsolute(p)) return false;
|
|
40989
|
+
const resolved = path28.resolve(p);
|
|
40990
|
+
return resolved !== path28.parse(resolved).root;
|
|
40746
40991
|
}
|
|
40747
40992
|
async function isRealDirectory(p) {
|
|
40748
40993
|
try {
|
|
@@ -40762,7 +41007,7 @@ async function pathExists(p) {
|
|
|
40762
41007
|
async function recordedBlockFiles(repo, dir) {
|
|
40763
41008
|
let checksums;
|
|
40764
41009
|
try {
|
|
40765
|
-
const raw = JSON.parse(await fs26.readFile(
|
|
41010
|
+
const raw = JSON.parse(await fs26.readFile(path28.join(dir, "meta.json"), "utf-8"));
|
|
40766
41011
|
checksums = raw?.checksums ?? {};
|
|
40767
41012
|
} catch {
|
|
40768
41013
|
return [];
|
|
@@ -40770,8 +41015,8 @@ async function recordedBlockFiles(repo, dir) {
|
|
|
40770
41015
|
const files = [];
|
|
40771
41016
|
for (const rel of Object.keys(checksums)) {
|
|
40772
41017
|
if (typeof rel !== "string" || rel.startsWith(".supbuddy/")) continue;
|
|
40773
|
-
const abs =
|
|
40774
|
-
if (!abs.startsWith(`${
|
|
41018
|
+
const abs = path28.resolve(repo, rel);
|
|
41019
|
+
if (!abs.startsWith(`${path28.resolve(repo)}${path28.sep}`)) continue;
|
|
40775
41020
|
try {
|
|
40776
41021
|
if (extractBlock(await fs26.readFile(abs, "utf-8"))) files.push(abs);
|
|
40777
41022
|
} catch {
|
|
@@ -40817,16 +41062,16 @@ var init_repo_artifacts = __esm({
|
|
|
40817
41062
|
for (const p of projectSnapshot()) {
|
|
40818
41063
|
const repo = p.path;
|
|
40819
41064
|
if (!repo || !isSafeProjectPath(repo)) continue;
|
|
40820
|
-
const dir =
|
|
41065
|
+
const dir = path28.join(repo, ".supbuddy");
|
|
40821
41066
|
const hasDir = await isRealDirectory(dir);
|
|
40822
41067
|
const blocks = hasDir ? await recordedBlockFiles(repo, dir) : [];
|
|
40823
41068
|
const envFiles = await ownedEnvFiles(p, repo);
|
|
40824
41069
|
if (!hasDir && blocks.length === 0 && envFiles.length === 0) continue;
|
|
40825
41070
|
const bits = [
|
|
40826
41071
|
hasDir && `remove ${dir}/`,
|
|
40827
|
-
envFiles.length > 0 && `delete ${envFiles.map((f) =>
|
|
41072
|
+
envFiles.length > 0 && `delete ${envFiles.map((f) => path28.relative(repo, f)).join(", ")}`,
|
|
40828
41073
|
"release the machine-global skill refs and the .gitignore block",
|
|
40829
|
-
blocks.length > 0 && `strip the managed Supbuddy block from ${blocks.map((b) =>
|
|
41074
|
+
blocks.length > 0 && `strip the managed Supbuddy block from ${blocks.map((b) => path28.relative(repo, b)).join(", ")}`
|
|
40830
41075
|
].filter(Boolean);
|
|
40831
41076
|
actions.push({
|
|
40832
41077
|
label: `Clean Supbuddy artifacts from "${p.name ?? p.id}" (${repo}): ${bits.join(", ")}`,
|
|
@@ -40868,13 +41113,13 @@ var init_bundle_exporter = __esm({
|
|
|
40868
41113
|
|
|
40869
41114
|
// ../../packages/core/cloud.ts
|
|
40870
41115
|
import fs27 from "fs/promises";
|
|
40871
|
-
import
|
|
41116
|
+
import path29 from "path";
|
|
40872
41117
|
import { execFile as execFile8 } from "child_process";
|
|
40873
41118
|
import { promisify as promisify13 } from "util";
|
|
40874
41119
|
async function sessionPath(dir) {
|
|
40875
|
-
const d = dir ??
|
|
41120
|
+
const d = dir ?? path29.join(await getAppSupportDir(), "secrets");
|
|
40876
41121
|
await fs27.mkdir(d, { recursive: true, mode: 448 });
|
|
40877
|
-
return
|
|
41122
|
+
return path29.join(d, "cloud-session.secret");
|
|
40878
41123
|
}
|
|
40879
41124
|
async function clearCloudSession(dir) {
|
|
40880
41125
|
await fs27.rm(await sessionPath(dir), { force: true }).catch(() => {
|
|
@@ -40894,7 +41139,7 @@ var init_cloud = __esm({
|
|
|
40894
41139
|
|
|
40895
41140
|
// ../../packages/core/system-doctor/wipe/steps/all-secrets.ts
|
|
40896
41141
|
import fs28 from "fs/promises";
|
|
40897
|
-
import
|
|
41142
|
+
import path30 from "path";
|
|
40898
41143
|
var allSecrets;
|
|
40899
41144
|
var init_all_secrets = __esm({
|
|
40900
41145
|
"../../packages/core/system-doctor/wipe/steps/all-secrets.ts"() {
|
|
@@ -40906,7 +41151,7 @@ var init_all_secrets = __esm({
|
|
|
40906
41151
|
tiers: ["full"],
|
|
40907
41152
|
destroysUserData: false,
|
|
40908
41153
|
async build(ctx) {
|
|
40909
|
-
const dir =
|
|
41154
|
+
const dir = path30.join(ctx.appSupportDir, "secrets");
|
|
40910
41155
|
let count;
|
|
40911
41156
|
try {
|
|
40912
41157
|
count = (await fs28.readdir(dir)).length;
|
|
@@ -41253,8 +41498,8 @@ __export(service_exports, {
|
|
|
41253
41498
|
uninstallService: () => uninstallService
|
|
41254
41499
|
});
|
|
41255
41500
|
import fs29 from "fs/promises";
|
|
41256
|
-
import
|
|
41257
|
-
import
|
|
41501
|
+
import os11 from "os";
|
|
41502
|
+
import path31 from "path";
|
|
41258
41503
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
41259
41504
|
import { spawnSync } from "child_process";
|
|
41260
41505
|
function launchdPlist(o) {
|
|
@@ -41277,9 +41522,9 @@ function launchdPlist(o) {
|
|
|
41277
41522
|
<key>KeepAlive</key>
|
|
41278
41523
|
<true/>
|
|
41279
41524
|
<key>StandardOutPath</key>
|
|
41280
|
-
<string>${
|
|
41525
|
+
<string>${path31.join(o.logDir, "daemon.log")}</string>
|
|
41281
41526
|
<key>StandardErrorPath</key>
|
|
41282
|
-
<string>${
|
|
41527
|
+
<string>${path31.join(o.logDir, "daemon-error.log")}</string>
|
|
41283
41528
|
</dict>
|
|
41284
41529
|
</plist>
|
|
41285
41530
|
`;
|
|
@@ -41299,16 +41544,16 @@ WantedBy=default.target
|
|
|
41299
41544
|
`;
|
|
41300
41545
|
}
|
|
41301
41546
|
function launchdPlistPath() {
|
|
41302
|
-
return
|
|
41547
|
+
return path31.join(os11.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
|
|
41303
41548
|
}
|
|
41304
41549
|
function systemdUnitPath() {
|
|
41305
|
-
const configHome = process.env.XDG_CONFIG_HOME ??
|
|
41306
|
-
return
|
|
41550
|
+
const configHome = process.env.XDG_CONFIG_HOME ?? path31.join(os11.homedir(), ".config");
|
|
41551
|
+
return path31.join(configHome, "systemd", "user", SYSTEMD_SERVICE);
|
|
41307
41552
|
}
|
|
41308
41553
|
function resolveBinPath() {
|
|
41309
|
-
const __dirname3 =
|
|
41310
|
-
const repoRoot =
|
|
41311
|
-
return
|
|
41554
|
+
const __dirname3 = path31.dirname(fileURLToPath2(import.meta.url));
|
|
41555
|
+
const repoRoot = path31.resolve(__dirname3, "..", "..", "..");
|
|
41556
|
+
return path31.join(repoRoot, "apps", "cli", "dist", "bin.js");
|
|
41312
41557
|
}
|
|
41313
41558
|
async function installService(opts = {}, run = defaultRunner2) {
|
|
41314
41559
|
const platform = process.platform;
|
|
@@ -41328,11 +41573,11 @@ Run \`yarn workspace supbuddy build\` first.`
|
|
|
41328
41573
|
return 1;
|
|
41329
41574
|
}
|
|
41330
41575
|
const stateDir = opts.stateDir ?? defaultStateDir();
|
|
41331
|
-
const logDir =
|
|
41576
|
+
const logDir = path31.join(stateDir, "logs");
|
|
41332
41577
|
await fs29.mkdir(logDir, { recursive: true });
|
|
41333
41578
|
if (platform === "darwin") {
|
|
41334
41579
|
const plistPath = launchdPlistPath();
|
|
41335
|
-
await fs29.mkdir(
|
|
41580
|
+
await fs29.mkdir(path31.dirname(plistPath), { recursive: true });
|
|
41336
41581
|
const content2 = launchdPlist({ label: LAUNCHD_LABEL, nodePath, binPath, stateDir, logDir });
|
|
41337
41582
|
await fs29.writeFile(plistPath, content2, { encoding: "utf8", mode: 420 });
|
|
41338
41583
|
run("launchctl", ["unload", plistPath]);
|
|
@@ -41345,7 +41590,7 @@ Run \`yarn workspace supbuddy build\` first.`
|
|
|
41345
41590
|
return 0;
|
|
41346
41591
|
}
|
|
41347
41592
|
const unitPath = systemdUnitPath();
|
|
41348
|
-
await fs29.mkdir(
|
|
41593
|
+
await fs29.mkdir(path31.dirname(unitPath), { recursive: true });
|
|
41349
41594
|
const content = systemdUnit({ label: LAUNCHD_LABEL, nodePath, binPath, stateDir, logDir });
|
|
41350
41595
|
await fs29.writeFile(unitPath, content, { encoding: "utf8", mode: 420 });
|
|
41351
41596
|
const reload = run("systemctl", ["--user", "daemon-reload"]);
|
|
@@ -41465,10 +41710,10 @@ __export(reset_full_exports, {
|
|
|
41465
41710
|
removeAppDataPreservingBackups: () => removeAppDataPreservingBackups
|
|
41466
41711
|
});
|
|
41467
41712
|
import fsp from "fs/promises";
|
|
41468
|
-
import
|
|
41713
|
+
import path32 from "path";
|
|
41469
41714
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
41470
41715
|
async function removeAppDataPreservingBackups(appSupportDir, io2 = defaultRemoveIo) {
|
|
41471
|
-
if (!appSupportDir || !
|
|
41716
|
+
if (!appSupportDir || !path32.isAbsolute(appSupportDir)) {
|
|
41472
41717
|
throw new Error(`refusing to empty "${appSupportDir}": not an absolute app-data directory path`);
|
|
41473
41718
|
}
|
|
41474
41719
|
const entries = await io2.readdir(appSupportDir);
|
|
@@ -41484,7 +41729,7 @@ async function removeAppDataPreservingBackups(appSupportDir, io2 = defaultRemove
|
|
|
41484
41729
|
preserved.push(name);
|
|
41485
41730
|
continue;
|
|
41486
41731
|
}
|
|
41487
|
-
await io2.rm(
|
|
41732
|
+
await io2.rm(path32.join(appSupportDir, name), { recursive: true, force: true });
|
|
41488
41733
|
removed.push(name);
|
|
41489
41734
|
}
|
|
41490
41735
|
const left = (await io2.readdir(appSupportDir)).filter((n) => n !== BACKUPS_DIRNAME);
|
|
@@ -41495,7 +41740,7 @@ async function removeAppDataPreservingBackups(appSupportDir, io2 = defaultRemove
|
|
|
41495
41740
|
}
|
|
41496
41741
|
return {
|
|
41497
41742
|
appSupportDir,
|
|
41498
|
-
backupsDir:
|
|
41743
|
+
backupsDir: path32.join(appSupportDir, BACKUPS_DIRNAME),
|
|
41499
41744
|
removed,
|
|
41500
41745
|
preserved
|
|
41501
41746
|
};
|
|
@@ -41513,7 +41758,7 @@ function defaultProcessProbe(cmd, args) {
|
|
|
41513
41758
|
}
|
|
41514
41759
|
}
|
|
41515
41760
|
async function hydrateStoreFromDisk(appSupportDir, useStore3) {
|
|
41516
|
-
const raw = await fsp.readFile(
|
|
41761
|
+
const raw = await fsp.readFile(path32.join(appSupportDir, "state.json"), "utf8").catch(() => null);
|
|
41517
41762
|
if (!raw) return null;
|
|
41518
41763
|
let data;
|
|
41519
41764
|
try {
|
|
@@ -42552,10 +42797,10 @@ __export(install_exports, {
|
|
|
42552
42797
|
});
|
|
42553
42798
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
42554
42799
|
import readline2 from "readline";
|
|
42555
|
-
import
|
|
42800
|
+
import path33 from "path";
|
|
42556
42801
|
function isEphemeralNpx() {
|
|
42557
42802
|
const argv1 = process.argv[1] || "";
|
|
42558
|
-
if (argv1.includes(`${
|
|
42803
|
+
if (argv1.includes(`${path33.sep}_npx${path33.sep}`) || argv1.includes("/_npx/")) return true;
|
|
42559
42804
|
if (process.env.npm_command === "exec") return true;
|
|
42560
42805
|
return false;
|
|
42561
42806
|
}
|
|
@@ -42629,8 +42874,8 @@ var selftest_exports = {};
|
|
|
42629
42874
|
import net from "net";
|
|
42630
42875
|
import http2 from "http";
|
|
42631
42876
|
import fs30 from "fs/promises";
|
|
42632
|
-
import
|
|
42633
|
-
import
|
|
42877
|
+
import os12 from "os";
|
|
42878
|
+
import path34 from "path";
|
|
42634
42879
|
function getFreePort() {
|
|
42635
42880
|
return new Promise((resolve, reject) => {
|
|
42636
42881
|
const srv = net.createServer();
|
|
@@ -42714,7 +42959,7 @@ async function main() {
|
|
|
42714
42959
|
const workerPort = await getFreePort();
|
|
42715
42960
|
let mcpPort = await getFreePort();
|
|
42716
42961
|
if (mcpPort === workerPort) mcpPort = await getFreePort();
|
|
42717
|
-
const stateDir = await fs30.mkdtemp(
|
|
42962
|
+
const stateDir = await fs30.mkdtemp(path34.join(os12.tmpdir(), "supbuddy-selftest-"));
|
|
42718
42963
|
const seed = {
|
|
42719
42964
|
projects: [],
|
|
42720
42965
|
mappings: [],
|
|
@@ -42724,7 +42969,7 @@ async function main() {
|
|
|
42724
42969
|
mcp: { enabled: true, port: mcpPort, audit_cap: 5e3, trash_ttl_days: 7 }
|
|
42725
42970
|
}
|
|
42726
42971
|
};
|
|
42727
|
-
await fs30.writeFile(
|
|
42972
|
+
await fs30.writeFile(path34.join(stateDir, "state.json"), JSON.stringify(seed, null, 2));
|
|
42728
42973
|
console.log(`isolated state dir: ${stateDir}`);
|
|
42729
42974
|
console.log(`worker (Socket.IO) port: ${workerPort} MCP port: ${mcpPort}
|
|
42730
42975
|
`);
|
|
@@ -42775,9 +43020,9 @@ __export(update_exports, {
|
|
|
42775
43020
|
import https from "https";
|
|
42776
43021
|
import fs31 from "fs/promises";
|
|
42777
43022
|
import { createWriteStream as createWriteStream2 } from "fs";
|
|
42778
|
-
import
|
|
42779
|
-
import
|
|
42780
|
-
import
|
|
43023
|
+
import os13 from "os";
|
|
43024
|
+
import path35 from "path";
|
|
43025
|
+
import crypto6 from "crypto";
|
|
42781
43026
|
import readline3 from "readline";
|
|
42782
43027
|
import { execFile as execFile9, execFileSync as execFileSync3, spawn as spawn8 } from "child_process";
|
|
42783
43028
|
function semver(tag) {
|
|
@@ -42879,7 +43124,7 @@ function installedVersion() {
|
|
|
42879
43124
|
}
|
|
42880
43125
|
async function sha256(file) {
|
|
42881
43126
|
const buf = await fs31.readFile(file);
|
|
42882
|
-
return
|
|
43127
|
+
return crypto6.createHash("sha256").update(buf).digest("hex");
|
|
42883
43128
|
}
|
|
42884
43129
|
function promptYesNo3(question) {
|
|
42885
43130
|
return new Promise((resolve) => {
|
|
@@ -42902,7 +43147,7 @@ function sq(p) {
|
|
|
42902
43147
|
return `'${p.replace(/'/g, "'\\''")}'`;
|
|
42903
43148
|
}
|
|
42904
43149
|
async function swapApp(newApp) {
|
|
42905
|
-
const dir =
|
|
43150
|
+
const dir = path35.dirname(INSTALLED_APP);
|
|
42906
43151
|
if (await canWrite(dir)) {
|
|
42907
43152
|
const bak = `${INSTALLED_APP}.bak-${process.pid}`;
|
|
42908
43153
|
if (await fs31.stat(INSTALLED_APP).then(() => true).catch(() => false)) {
|
|
@@ -42977,10 +43222,10 @@ supbuddy update: could not reach the release server \u2014 ${e.message}`);
|
|
|
42977
43222
|
return 0;
|
|
42978
43223
|
}
|
|
42979
43224
|
}
|
|
42980
|
-
const tmp = await fs31.mkdtemp(
|
|
42981
|
-
const tar =
|
|
42982
|
-
const shaFile =
|
|
42983
|
-
const extractDir =
|
|
43225
|
+
const tmp = await fs31.mkdtemp(path35.join(os13.tmpdir(), "supbuddy-update-"));
|
|
43226
|
+
const tar = path35.join(tmp, TAR_ASSET);
|
|
43227
|
+
const shaFile = path35.join(tmp, SHA_ASSET);
|
|
43228
|
+
const extractDir = path35.join(tmp, "extracted");
|
|
42984
43229
|
try {
|
|
42985
43230
|
console.log("Downloading\u2026");
|
|
42986
43231
|
await downloadAsset(pick.tarUrl, tar);
|
|
@@ -42994,7 +43239,7 @@ supbuddy update: could not reach the release server \u2014 ${e.message}`);
|
|
|
42994
43239
|
}
|
|
42995
43240
|
await fs31.mkdir(extractDir, { recursive: true });
|
|
42996
43241
|
execFileSync3("tar", ["-xzf", tar, "-C", extractDir]);
|
|
42997
|
-
const newApp =
|
|
43242
|
+
const newApp = path35.join(extractDir, "Supbuddy.app");
|
|
42998
43243
|
if (!await fs31.stat(newApp).then(() => true).catch(() => false)) {
|
|
42999
43244
|
console.error("supbuddy update: the archive did not contain Supbuddy.app.");
|
|
43000
43245
|
return 1;
|
|
@@ -43097,11 +43342,11 @@ __export(run_exports, {
|
|
|
43097
43342
|
});
|
|
43098
43343
|
import { spawn as spawn9, execSync as execSync2 } from "child_process";
|
|
43099
43344
|
import fs32 from "fs";
|
|
43100
|
-
import
|
|
43345
|
+
import path36 from "path";
|
|
43101
43346
|
function readMeta(startDir) {
|
|
43102
43347
|
let dir = startDir;
|
|
43103
43348
|
for (; ; ) {
|
|
43104
|
-
const metaPath =
|
|
43349
|
+
const metaPath = path36.join(dir, ".supbuddy", "meta.json");
|
|
43105
43350
|
if (fs32.existsSync(metaPath)) {
|
|
43106
43351
|
try {
|
|
43107
43352
|
return JSON.parse(fs32.readFileSync(metaPath, "utf-8"));
|
|
@@ -43109,7 +43354,7 @@ function readMeta(startDir) {
|
|
|
43109
43354
|
return {};
|
|
43110
43355
|
}
|
|
43111
43356
|
}
|
|
43112
|
-
const parent =
|
|
43357
|
+
const parent = path36.dirname(dir);
|
|
43113
43358
|
if (parent === dir) return {};
|
|
43114
43359
|
dir = parent;
|
|
43115
43360
|
}
|
|
@@ -43243,7 +43488,7 @@ init_state_dir();
|
|
|
43243
43488
|
import { realpathSync } from "fs";
|
|
43244
43489
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
43245
43490
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
43246
|
-
import
|
|
43491
|
+
import path37 from "path";
|
|
43247
43492
|
|
|
43248
43493
|
// src/commands.ts
|
|
43249
43494
|
init_client();
|
|
@@ -44326,12 +44571,12 @@ async function runCommand(argv, flags, clientFactory) {
|
|
|
44326
44571
|
return 0;
|
|
44327
44572
|
}
|
|
44328
44573
|
if (sub === "env-read") {
|
|
44329
|
-
const
|
|
44330
|
-
if (!
|
|
44574
|
+
const path38 = rest[0];
|
|
44575
|
+
if (!path38) {
|
|
44331
44576
|
console.error("usage: supbuddy project env-read <path> [--key K]");
|
|
44332
44577
|
return 1;
|
|
44333
44578
|
}
|
|
44334
|
-
const args = { path:
|
|
44579
|
+
const args = { path: path38 };
|
|
44335
44580
|
if (typeof flags.key === "string") args.key = flags.key;
|
|
44336
44581
|
print(await client.call("read_env_file", args), flags);
|
|
44337
44582
|
return 0;
|
|
@@ -44612,8 +44857,8 @@ async function runCommand(argv, flags, clientFactory) {
|
|
|
44612
44857
|
return 0;
|
|
44613
44858
|
}
|
|
44614
44859
|
if (sub === "write") {
|
|
44615
|
-
const [
|
|
44616
|
-
if (!
|
|
44860
|
+
const [path38, ...pairs2] = rest;
|
|
44861
|
+
if (!path38 || pairs2.length === 0) {
|
|
44617
44862
|
console.error("usage: supbuddy env write <path> <key=val>...");
|
|
44618
44863
|
return 1;
|
|
44619
44864
|
}
|
|
@@ -44628,7 +44873,7 @@ async function runCommand(argv, flags, clientFactory) {
|
|
|
44628
44873
|
const v = pair.slice(eqIdx + 1);
|
|
44629
44874
|
patch[k] = v === "" ? null : v;
|
|
44630
44875
|
}
|
|
44631
|
-
print(await client.call("write_env_file", { path:
|
|
44876
|
+
print(await client.call("write_env_file", { path: path38, patch }), flags);
|
|
44632
44877
|
return 0;
|
|
44633
44878
|
}
|
|
44634
44879
|
console.error("usage: supbuddy env copy|write ...");
|
|
@@ -44991,6 +45236,18 @@ var SHORT_FLAG_MAP = {
|
|
|
44991
45236
|
y: "yes",
|
|
44992
45237
|
q: "quiet"
|
|
44993
45238
|
};
|
|
45239
|
+
function resolveStopOutcome(pid, alive) {
|
|
45240
|
+
if (alive) {
|
|
45241
|
+
return {
|
|
45242
|
+
exitCode: 1,
|
|
45243
|
+
removeDaemonInfo: false,
|
|
45244
|
+
message: `supbuddy: daemon (pid ${pid}) did not exit within 8s \u2014 still running.
|
|
45245
|
+
daemon.json was left in place so the app can still find it.
|
|
45246
|
+
Force it if you must: kill -9 ${pid}`
|
|
45247
|
+
};
|
|
45248
|
+
}
|
|
45249
|
+
return { exitCode: 0, removeDaemonInfo: true, message: `supbuddy: stopped (pid ${pid})` };
|
|
45250
|
+
}
|
|
44994
45251
|
function parseFlags(argv) {
|
|
44995
45252
|
const flags = {};
|
|
44996
45253
|
const positionals = [];
|
|
@@ -45150,12 +45407,12 @@ Global flags:
|
|
|
45150
45407
|
|
|
45151
45408
|
See docs/MULTIMODE_DELIVERY_ASSESSMENT.md for the full roadmap.`;
|
|
45152
45409
|
async function runShell(opts, stateDir, module) {
|
|
45153
|
-
const
|
|
45410
|
+
const os14 = await import("os");
|
|
45154
45411
|
const fs33 = await import("fs");
|
|
45155
45412
|
const shellEntry = fileURLToPath3(new URL("../../tui/src/shell/bin.tsx", import.meta.url));
|
|
45156
|
-
const REPO_ROOT2 =
|
|
45157
|
-
const tsxBin =
|
|
45158
|
-
const resultFile =
|
|
45413
|
+
const REPO_ROOT2 = path37.resolve(fileURLToPath3(import.meta.url), "..", "..", "..", "..");
|
|
45414
|
+
const tsxBin = path37.join(REPO_ROOT2, "node_modules", ".bin", "tsx");
|
|
45415
|
+
const resultFile = path37.join(os14.tmpdir(), `supbuddy-shell-${process.pid}-${Date.now()}.json`);
|
|
45159
45416
|
const env3 = { ...process.env, SUPBUDDY_SHELL_RESULT: resultFile };
|
|
45160
45417
|
if (stateDir) env3.SUPBUDDY_STATE_DIR = stateDir;
|
|
45161
45418
|
if (module) env3.SUPBUDDY_SHELL_MODULE = module;
|
|
@@ -45252,8 +45509,8 @@ async function dispatch(argv, opts) {
|
|
|
45252
45509
|
case "tui":
|
|
45253
45510
|
case "dash": {
|
|
45254
45511
|
const tuiEntry = fileURLToPath3(new URL("../../tui/src/bin.tsx", import.meta.url));
|
|
45255
|
-
const REPO_ROOT2 =
|
|
45256
|
-
const tsxBin =
|
|
45512
|
+
const REPO_ROOT2 = path37.resolve(fileURLToPath3(import.meta.url), "..", "..", "..", "..");
|
|
45513
|
+
const tsxBin = path37.join(REPO_ROOT2, "node_modules", ".bin", "tsx");
|
|
45257
45514
|
const env3 = { ...process.env };
|
|
45258
45515
|
if (typeof flags["state-dir"] === "string") env3.SUPBUDDY_STATE_DIR = flags["state-dir"];
|
|
45259
45516
|
if (typeof flags["url"] === "string") env3.SUPBUDDY_DAEMON_URL = flags["url"];
|
|
@@ -45308,9 +45565,11 @@ async function dispatch(argv, opts) {
|
|
|
45308
45565
|
const still = await readDaemonInfo(dir);
|
|
45309
45566
|
if (!still || !isPidAlive(still.pid)) break;
|
|
45310
45567
|
}
|
|
45311
|
-
|
|
45312
|
-
|
|
45313
|
-
|
|
45568
|
+
const outcome = resolveStopOutcome(pid, isPidAlive(pid));
|
|
45569
|
+
if (outcome.removeDaemonInfo) await removeDaemonInfo(dir);
|
|
45570
|
+
if (outcome.exitCode === 0) console.log(outcome.message);
|
|
45571
|
+
else console.error(outcome.message);
|
|
45572
|
+
return outcome.exitCode;
|
|
45314
45573
|
}
|
|
45315
45574
|
case void 0:
|
|
45316
45575
|
case "": {
|
|
@@ -45386,7 +45645,8 @@ if (isMain) {
|
|
|
45386
45645
|
export {
|
|
45387
45646
|
dispatch,
|
|
45388
45647
|
flushStream,
|
|
45389
|
-
parseFlags
|
|
45648
|
+
parseFlags,
|
|
45649
|
+
resolveStopOutcome
|
|
45390
45650
|
};
|
|
45391
45651
|
/*! Bundled license information:
|
|
45392
45652
|
|