learnhouse 1.4.4 → 1.4.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.
Files changed (2) hide show
  1. package/dist/bin/learnhouse.js +379 -249
  2. package/package.json +1 -1
@@ -3613,10 +3613,10 @@ var {
3613
3613
  } = import_index.default;
3614
3614
 
3615
3615
  // bin/learnhouse.ts
3616
- var import_picocolors23 = __toESM(require_picocolors(), 1);
3616
+ var import_picocolors24 = __toESM(require_picocolors(), 1);
3617
3617
 
3618
3618
  // src/constants.ts
3619
- var VERSION = "1.4.4";
3619
+ var VERSION = "1.4.5";
3620
3620
  var APP_IMAGE = "ghcr.io/learnhouse/app:latest";
3621
3621
  var DEV_IMAGE = "ghcr.io/learnhouse/app:dev";
3622
3622
  var POSTGRES_IMAGE = "pgvector/pgvector:pg16";
@@ -4831,7 +4831,7 @@ ${barEnd}
4831
4831
  }
4832
4832
 
4833
4833
  // src/commands/setup.ts
4834
- var import_picocolors8 = __toESM(require_picocolors(), 1);
4834
+ var import_picocolors9 = __toESM(require_picocolors(), 1);
4835
4835
 
4836
4836
  // src/prompts/prerequisites.ts
4837
4837
  var import_picocolors6 = __toESM(require_picocolors(), 1);
@@ -5047,11 +5047,26 @@ async function checkPrerequisites() {
5047
5047
  s.stop("All prerequisites met");
5048
5048
  }
5049
5049
 
5050
+ // src/prompts/domain.ts
5051
+ var import_picocolors7 = __toESM(require_picocolors(), 1);
5052
+
5050
5053
  // src/utils/validators.ts
5054
+ var RESERVED_TLDS = /* @__PURE__ */ new Set([
5055
+ "local",
5056
+ "localhost",
5057
+ "test",
5058
+ "invalid",
5059
+ "example"
5060
+ ]);
5051
5061
  function validateEmail(value) {
5052
5062
  if (!value) return "Email is required";
5053
5063
  const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
5054
5064
  if (!re.test(value)) return "Please enter a valid email address";
5065
+ const domain = value.slice(value.lastIndexOf("@") + 1).toLowerCase();
5066
+ const tld = domain.includes(".") ? domain.slice(domain.lastIndexOf(".") + 1) : domain;
5067
+ if (RESERVED_TLDS.has(tld)) {
5068
+ return `Reserved TLD ".${tld}" is not accepted. Use a real domain (e.g. admin@yourdomain.com).`;
5069
+ }
5055
5070
  return void 0;
5056
5071
  }
5057
5072
  function validatePassword(value) {
@@ -5076,6 +5091,61 @@ function validateRequired(value) {
5076
5091
  return void 0;
5077
5092
  }
5078
5093
 
5094
+ // src/utils/network.ts
5095
+ import net from "net";
5096
+ function checkPort(port) {
5097
+ return new Promise((resolve) => {
5098
+ const server = net.createServer();
5099
+ server.once("error", () => resolve(false));
5100
+ server.once("listening", () => {
5101
+ server.close(() => resolve(true));
5102
+ });
5103
+ server.listen(port);
5104
+ });
5105
+ }
5106
+ async function findAvailablePort(preferred, candidates = [8080, 8e3, 9090, 3030, 5050]) {
5107
+ if (await checkPort(preferred)) return preferred;
5108
+ for (const port of candidates) {
5109
+ if (port === preferred) continue;
5110
+ if (await checkPort(port)) return port;
5111
+ }
5112
+ return null;
5113
+ }
5114
+ function checkTcpConnection(host, port, timeoutMs = 5e3) {
5115
+ return new Promise((resolve) => {
5116
+ const socket = net.createConnection({ host, port });
5117
+ const timer = setTimeout(() => {
5118
+ socket.destroy();
5119
+ resolve(false);
5120
+ }, timeoutMs);
5121
+ socket.once("connect", () => {
5122
+ clearTimeout(timer);
5123
+ socket.destroy();
5124
+ resolve(true);
5125
+ });
5126
+ socket.once("error", () => {
5127
+ clearTimeout(timer);
5128
+ resolve(false);
5129
+ });
5130
+ });
5131
+ }
5132
+ function parsePostgresUrl(connString) {
5133
+ try {
5134
+ const url = new URL(connString);
5135
+ return { host: url.hostname, port: url.port ? parseInt(url.port, 10) : 5432 };
5136
+ } catch {
5137
+ return null;
5138
+ }
5139
+ }
5140
+ function parseRedisUrl(connString) {
5141
+ try {
5142
+ const url = new URL(connString);
5143
+ return { host: url.hostname, port: url.port ? parseInt(url.port, 10) : 6379 };
5144
+ } catch {
5145
+ return null;
5146
+ }
5147
+ }
5148
+
5079
5149
  // src/prompts/domain.ts
5080
5150
  async function promptDomain() {
5081
5151
  const domain = await text({
@@ -5121,22 +5191,41 @@ async function promptDomain() {
5121
5191
  useHttps = true;
5122
5192
  }
5123
5193
  }
5124
- const defaultPort = autoSsl ? 443 : 80;
5194
+ const canonicalDefault = autoSsl ? 443 : 80;
5195
+ let defaultPort = canonicalDefault;
5196
+ if (!autoSsl) {
5197
+ const available = await findAvailablePort(canonicalDefault);
5198
+ if (available && available !== canonicalDefault) {
5199
+ R2.warn(`Port ${canonicalDefault} is already in use. Suggesting ${import_picocolors7.default.cyan(String(available))} instead.`);
5200
+ defaultPort = available;
5201
+ } else if (!available) {
5202
+ R2.warn("Could not find a free common port. You will need to enter one manually.");
5203
+ }
5204
+ }
5125
5205
  const portMessage = autoSsl ? "HTTPS port? (Caddy needs 443 for auto SSL, and will also listen on 80 for redirect)" : "HTTP port for the web server?";
5126
- const port = await text({
5127
- message: portMessage,
5128
- placeholder: String(defaultPort),
5129
- defaultValue: String(defaultPort),
5130
- validate: validatePort
5131
- });
5132
- if (Ct(port)) {
5133
- Ne();
5134
- process.exit(0);
5206
+ let httpPort = 0;
5207
+ while (httpPort === 0) {
5208
+ const port = await text({
5209
+ message: portMessage,
5210
+ placeholder: String(defaultPort),
5211
+ defaultValue: String(defaultPort),
5212
+ validate: validatePort
5213
+ });
5214
+ if (Ct(port)) {
5215
+ Ne();
5216
+ process.exit(0);
5217
+ }
5218
+ const parsed = parseInt(port, 10);
5219
+ if (parsed > 1024 && !await checkPort(parsed)) {
5220
+ R2.warn(`Port ${parsed} is already in use. Pick another.`);
5221
+ continue;
5222
+ }
5223
+ httpPort = parsed;
5135
5224
  }
5136
5225
  return {
5137
5226
  domain,
5138
5227
  useHttps,
5139
- httpPort: parseInt(port, 10),
5228
+ httpPort,
5140
5229
  autoSsl,
5141
5230
  sslEmail
5142
5231
  };
@@ -5144,56 +5233,7 @@ async function promptDomain() {
5144
5233
 
5145
5234
  // src/prompts/database.ts
5146
5235
  import crypto from "crypto";
5147
- var import_picocolors7 = __toESM(require_picocolors(), 1);
5148
-
5149
- // src/utils/network.ts
5150
- import net from "net";
5151
- function checkPort(port) {
5152
- return new Promise((resolve) => {
5153
- const server = net.createServer();
5154
- server.once("error", () => resolve(false));
5155
- server.once("listening", () => {
5156
- server.close(() => resolve(true));
5157
- });
5158
- server.listen(port);
5159
- });
5160
- }
5161
- function checkTcpConnection(host, port, timeoutMs = 5e3) {
5162
- return new Promise((resolve) => {
5163
- const socket = net.createConnection({ host, port });
5164
- const timer = setTimeout(() => {
5165
- socket.destroy();
5166
- resolve(false);
5167
- }, timeoutMs);
5168
- socket.once("connect", () => {
5169
- clearTimeout(timer);
5170
- socket.destroy();
5171
- resolve(true);
5172
- });
5173
- socket.once("error", () => {
5174
- clearTimeout(timer);
5175
- resolve(false);
5176
- });
5177
- });
5178
- }
5179
- function parsePostgresUrl(connString) {
5180
- try {
5181
- const url = new URL(connString);
5182
- return { host: url.hostname, port: url.port ? parseInt(url.port, 10) : 5432 };
5183
- } catch {
5184
- return null;
5185
- }
5186
- }
5187
- function parseRedisUrl(connString) {
5188
- try {
5189
- const url = new URL(connString);
5190
- return { host: url.hostname, port: url.port ? parseInt(url.port, 10) : 6379 };
5191
- } catch {
5192
- return null;
5193
- }
5194
- }
5195
-
5196
- // src/prompts/database.ts
5236
+ var import_picocolors8 = __toESM(require_picocolors(), 1);
5197
5237
  async function promptAndVerifyPostgres() {
5198
5238
  while (true) {
5199
5239
  const connString = await text({
@@ -5221,10 +5261,10 @@ async function promptAndVerifyPostgres() {
5221
5261
  s.start(`Checking connection to ${parsed.host}:${parsed.port}`);
5222
5262
  const reachable = await checkTcpConnection(parsed.host, parsed.port);
5223
5263
  if (reachable) {
5224
- s.stop(`${import_picocolors7.default.green("Connected")} to ${parsed.host}:${parsed.port}`);
5264
+ s.stop(`${import_picocolors8.default.green("Connected")} to ${parsed.host}:${parsed.port}`);
5225
5265
  return connString;
5226
5266
  }
5227
- s.stop(`${import_picocolors7.default.red("Connection failed")} to ${parsed.host}:${parsed.port}`);
5267
+ s.stop(`${import_picocolors8.default.red("Connection failed")} to ${parsed.host}:${parsed.port}`);
5228
5268
  const retry = await Re({
5229
5269
  message: "Could not reach the database. Try a different connection string?",
5230
5270
  initialValue: true
@@ -5262,10 +5302,10 @@ async function promptAndVerifyRedis() {
5262
5302
  s.start(`Checking connection to ${parsed.host}:${parsed.port}`);
5263
5303
  const reachable = await checkTcpConnection(parsed.host, parsed.port);
5264
5304
  if (reachable) {
5265
- s.stop(`${import_picocolors7.default.green("Connected")} to ${parsed.host}:${parsed.port}`);
5305
+ s.stop(`${import_picocolors8.default.green("Connected")} to ${parsed.host}:${parsed.port}`);
5266
5306
  return connString;
5267
5307
  }
5268
- s.stop(`${import_picocolors7.default.red("Connection failed")} to ${parsed.host}:${parsed.port}`);
5308
+ s.stop(`${import_picocolors8.default.red("Connection failed")} to ${parsed.host}:${parsed.port}`);
5269
5309
  const retry = await Re({
5270
5310
  message: "Could not reach Redis. Try a different connection string?",
5271
5311
  initialValue: true
@@ -5310,15 +5350,15 @@ async function promptDatabase() {
5310
5350
  useAiDatabase = dbImageChoice === "ai";
5311
5351
  dbPassword = crypto.randomBytes(24).toString("base64url");
5312
5352
  R2.message("");
5313
- R2.info(import_picocolors7.default.bold("Database credentials generated:"));
5353
+ R2.info(import_picocolors8.default.bold("Database credentials generated:"));
5314
5354
  R2.message([
5315
5355
  "",
5316
- ` ${import_picocolors7.default.dim("User:")} learnhouse`,
5317
- ` ${import_picocolors7.default.dim("Password:")} ${import_picocolors7.default.cyan(dbPassword)}`,
5318
- ` ${import_picocolors7.default.dim("Database:")} learnhouse`,
5319
- ` ${import_picocolors7.default.dim("Host:")} db:5432 (internal)`,
5356
+ ` ${import_picocolors8.default.dim("User:")} learnhouse`,
5357
+ ` ${import_picocolors8.default.dim("Password:")} ${import_picocolors8.default.cyan(dbPassword)}`,
5358
+ ` ${import_picocolors8.default.dim("Database:")} learnhouse`,
5359
+ ` ${import_picocolors8.default.dim("Host:")} db:5432 (internal)`,
5320
5360
  "",
5321
- ` ${import_picocolors7.default.yellow("Copy the password now if needed \u2014 it will be saved in .env")}`,
5361
+ ` ${import_picocolors8.default.yellow("Copy the password now if needed \u2014 it will be saved in .env")}`,
5322
5362
  ""
5323
5363
  ].join("\n"));
5324
5364
  const ack = await Re({ message: "Continue?", initialValue: true });
@@ -5366,8 +5406,25 @@ async function promptOrganization() {
5366
5406
  Ne();
5367
5407
  process.exit(0);
5368
5408
  }
5409
+ const orgSlug = await text({
5410
+ message: 'Organization slug? (used in URLs like /orgs/<slug> \u2014 keep "default" unless you know you need to change it)',
5411
+ placeholder: "default",
5412
+ defaultValue: "default",
5413
+ validate: (value) => {
5414
+ if (!value) return "Slug is required";
5415
+ if (!/^[a-z0-9][a-z0-9-]*[a-z0-9]?$/.test(value)) {
5416
+ return "Lowercase letters, numbers and hyphens only";
5417
+ }
5418
+ return void 0;
5419
+ }
5420
+ });
5421
+ if (Ct(orgSlug)) {
5422
+ Ne();
5423
+ process.exit(0);
5424
+ }
5369
5425
  return {
5370
- orgName
5426
+ orgName,
5427
+ orgSlug: orgSlug.toLowerCase()
5371
5428
  };
5372
5429
  }
5373
5430
 
@@ -5606,7 +5663,8 @@ ${deps.join("\n")}` : "";
5606
5663
  networks:
5607
5664
  - learnhouse-network-${id}
5608
5665
  healthcheck:
5609
- test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://localhost:80/ || exit 1"]
5666
+ # Use 127.0.0.1 \u2014 alpine's wget tries IPv6 first and Caddy only binds v4 by default
5667
+ test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://127.0.0.1:80/ || exit 1"]
5610
5668
  interval: 30s
5611
5669
  timeout: 10s
5612
5670
  retries: 3
@@ -5625,7 +5683,8 @@ ${deps.join("\n")}` : "";
5625
5683
  networks:
5626
5684
  - learnhouse-network-${id}
5627
5685
  healthcheck:
5628
- test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://localhost/ || exit 1"]
5686
+ # Use 127.0.0.1 \u2014 alpine's wget resolves localhost to IPv6 first, but nginx only listens on v4 by default
5687
+ test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://127.0.0.1/ || exit 1"]
5629
5688
  interval: 30s
5630
5689
  timeout: 10s
5631
5690
  retries: 3
@@ -5761,7 +5820,7 @@ function generateEnvFile(config) {
5761
5820
  `NEXT_PUBLIC_LEARNHOUSE_DOMAIN=${domainWithPort}`,
5762
5821
  `NEXT_PUBLIC_LEARNHOUSE_TOP_DOMAIN=${topDomain}`,
5763
5822
  "NEXT_PUBLIC_LEARNHOUSE_MULTI_ORG=False",
5764
- "NEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORG=default",
5823
+ `NEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORG=${config.orgSlug || "default"}`,
5765
5824
  `NEXT_PUBLIC_LEARNHOUSE_HTTPS=${config.useHttps ? "True" : "False"}`
5766
5825
  ];
5767
5826
  if (config.unsplashEnabled && config.unsplashAccessKey) {
@@ -5800,6 +5859,8 @@ function generateEnvFile(config) {
5800
5859
  `LEARNHOUSE_AUTH_JWT_SECRET_KEY=${jwtSecret}`,
5801
5860
  `LEARNHOUSE_INITIAL_ADMIN_EMAIL=${quoteEnvValue(config.adminEmail)}`,
5802
5861
  `LEARNHOUSE_INITIAL_ADMIN_PASSWORD=${quoteEnvValue(config.adminPassword)}`,
5862
+ `LEARNHOUSE_INITIAL_ORG_NAME=${quoteEnvValue(config.orgName || "Default Organization")}`,
5863
+ `LEARNHOUSE_INITIAL_ORG_SLUG=${quoteEnvValue(config.orgSlug || "default")}`,
5803
5864
  "",
5804
5865
  "# =============================================================================",
5805
5866
  "# Collaboration Server",
@@ -5904,6 +5965,7 @@ function generateNginxConf() {
5904
5965
  return `
5905
5966
  server {
5906
5967
  listen 80;
5968
+ listen [::]:80;
5907
5969
  server_name _;
5908
5970
  client_max_body_size 500M;
5909
5971
 
@@ -5970,7 +6032,7 @@ function writeConfig(config) {
5970
6032
  useHttps: config.useHttps,
5971
6033
  autoSsl: config.autoSsl,
5972
6034
  useExternalDb: config.useExternalDb,
5973
- orgSlug: "default"
6035
+ orgSlug: config.orgSlug || "default"
5974
6036
  };
5975
6037
  fs.writeFileSync(
5976
6038
  path.join(config.installDir, CONFIG_FILENAME),
@@ -6022,8 +6084,7 @@ function findInstallDir() {
6022
6084
  const running = installations.find(
6023
6085
  (i) => isContainerRunning(`learnhouse-app-${i.config.deploymentId}`)
6024
6086
  );
6025
- if (running) return running.dir;
6026
- return installations[0].dir;
6087
+ return (running ?? installations[0]).dir;
6027
6088
  }
6028
6089
  const cwd = process.cwd();
6029
6090
  if (isCompleteInstall(cwd)) return cwd;
@@ -6044,6 +6105,19 @@ async function waitForHealth(baseUrl) {
6044
6105
  }
6045
6106
  return false;
6046
6107
  }
6108
+ async function waitForOrgSeed(baseUrl, orgSlug) {
6109
+ const url = `${baseUrl}/api/v1/orgs/slug/${encodeURIComponent(orgSlug)}`;
6110
+ const deadline = Date.now() + 3e4;
6111
+ while (Date.now() < deadline) {
6112
+ try {
6113
+ const res = await fetch(url, { signal: AbortSignal.timeout(5e3) });
6114
+ if (res.ok) return true;
6115
+ } catch {
6116
+ }
6117
+ await new Promise((r) => setTimeout(r, HEALTH_CHECK_INTERVAL_MS));
6118
+ }
6119
+ return false;
6120
+ }
6047
6121
 
6048
6122
  // src/commands/setup.ts
6049
6123
  var STEP_NAMES = [
@@ -6061,7 +6135,7 @@ async function confirmOrBack(message) {
6061
6135
  message,
6062
6136
  options: [
6063
6137
  { value: "continue", label: "Continue" },
6064
- { value: "back", label: import_picocolors8.default.dim("Go back to previous step") }
6138
+ { value: "back", label: import_picocolors9.default.dim("Go back to previous step") }
6065
6139
  ]
6066
6140
  });
6067
6141
  if (Ct(result)) {
@@ -6072,7 +6146,7 @@ async function confirmOrBack(message) {
6072
6146
  }
6073
6147
  async function stepInstallDir() {
6074
6148
  const baseDir = path2.join(os2.homedir(), ".learnhouse");
6075
- R2.info(`All installations are stored in ${import_picocolors8.default.cyan("~/.learnhouse/<name>")}`);
6149
+ R2.info(`All installations are stored in ${import_picocolors9.default.cyan("~/.learnhouse/<name>")}`);
6076
6150
  const name = await text({
6077
6151
  message: "Name for this installation:",
6078
6152
  placeholder: "default",
@@ -6103,28 +6177,23 @@ async function stepInstallDir() {
6103
6177
  return resolved;
6104
6178
  }
6105
6179
  async function stepDomain() {
6106
- R2.step(import_picocolors8.default.cyan(`Step 2/6`) + " Domain Configuration");
6107
- const config = await promptDomain();
6108
- const portAvailable = await checkPort(config.httpPort);
6109
- if (!portAvailable) {
6110
- R2.warn(`Port ${config.httpPort} is already in use. You may need to free it before starting.`);
6111
- }
6112
- return config;
6180
+ R2.step(import_picocolors9.default.cyan(`Step 2/6`) + " Domain Configuration");
6181
+ return await promptDomain();
6113
6182
  }
6114
6183
  async function stepDatabase() {
6115
- R2.step(import_picocolors8.default.cyan(`Step 3/6`) + " Database & Redis");
6184
+ R2.step(import_picocolors9.default.cyan(`Step 3/6`) + " Database & Redis");
6116
6185
  return await promptDatabase();
6117
6186
  }
6118
6187
  async function stepOrganization() {
6119
- R2.step(import_picocolors8.default.cyan(`Step 4/6`) + " Organization Setup");
6188
+ R2.step(import_picocolors9.default.cyan(`Step 4/6`) + " Organization Setup");
6120
6189
  return await promptOrganization();
6121
6190
  }
6122
6191
  async function stepAdmin() {
6123
- R2.step(import_picocolors8.default.cyan(`Step 5/6`) + " Admin Account");
6192
+ R2.step(import_picocolors9.default.cyan(`Step 5/6`) + " Admin Account");
6124
6193
  return await promptAdmin();
6125
6194
  }
6126
6195
  async function stepFeatures() {
6127
- R2.step(import_picocolors8.default.cyan(`Step 6/6`) + " Optional Features");
6196
+ R2.step(import_picocolors9.default.cyan(`Step 6/6`) + " Optional Features");
6128
6197
  return await promptFeatures();
6129
6198
  }
6130
6199
  async function setupCommand(options) {
@@ -6133,6 +6202,13 @@ async function setupCommand(options) {
6133
6202
  console.error("Error: --admin-password is required in --ci mode");
6134
6203
  process.exit(1);
6135
6204
  }
6205
+ if (options.adminEmail) {
6206
+ const emailErr = validateEmail(options.adminEmail);
6207
+ if (emailErr) {
6208
+ console.error(`Error: --admin-email "${options.adminEmail}" \u2014 ${emailErr}`);
6209
+ process.exit(1);
6210
+ }
6211
+ }
6136
6212
  await checkPrerequisites();
6137
6213
  const installName = options.name || "default";
6138
6214
  const baseDir = path2.join(os2.homedir(), ".learnhouse");
@@ -6141,19 +6217,34 @@ async function setupCommand(options) {
6141
6217
  const deploymentId2 = crypto3.randomBytes(4).toString("hex");
6142
6218
  const channel2 = options.channel === "dev" ? "dev" : "stable";
6143
6219
  const dbPassword = crypto3.randomBytes(24).toString("base64url");
6220
+ let httpPort = options.port || 80;
6221
+ if (!options.port) {
6222
+ const available = await findAvailablePort(httpPort);
6223
+ if (available && available !== httpPort) {
6224
+ console.log(`Port ${httpPort} is in use \u2014 falling back to ${available}.`);
6225
+ httpPort = available;
6226
+ } else if (!available) {
6227
+ console.error("No common port is available. Pass --port=<port> explicitly.");
6228
+ process.exit(1);
6229
+ }
6230
+ } else if (!await checkPort(httpPort)) {
6231
+ console.error(`Port ${httpPort} is already in use. Free it or pass a different --port.`);
6232
+ process.exit(1);
6233
+ }
6144
6234
  const config2 = {
6145
6235
  deploymentId: deploymentId2,
6146
6236
  installDir: resolvedDir2,
6147
6237
  channel: channel2,
6148
6238
  domain: options.domain || "localhost",
6149
6239
  useHttps: false,
6150
- httpPort: options.port || 80,
6240
+ httpPort,
6151
6241
  autoSsl: false,
6152
6242
  useExternalDb: false,
6153
6243
  dbPassword,
6154
6244
  useAiDatabase: false,
6155
6245
  useExternalRedis: false,
6156
- orgName: "Default",
6246
+ orgName: options.orgName || "Default Organization",
6247
+ orgSlug: (options.orgSlug || "default").toLowerCase(),
6157
6248
  adminEmail: options.adminEmail || "admin@school.dev",
6158
6249
  adminPassword: options.adminPassword,
6159
6250
  aiEnabled: false,
@@ -6178,12 +6269,27 @@ async function setupCommand(options) {
6178
6269
  dockerComposeUp(resolvedDir2);
6179
6270
  const healthy = await waitForHealth(`http://localhost:${config2.httpPort}`);
6180
6271
  if (healthy) {
6181
- console.log("LearnHouse is ready!");
6272
+ const seeded = await waitForOrgSeed(`http://localhost:${config2.httpPort}`, "default");
6273
+ if (seeded) {
6274
+ console.log("LearnHouse is ready!");
6275
+ } else {
6276
+ console.error("");
6277
+ console.error("API is healthy but the default organization was not seeded.");
6278
+ console.error("Run `npx learnhouse logs` to inspect; pin a different image tag and re-run.");
6279
+ console.error("");
6280
+ process.exit(1);
6281
+ }
6182
6282
  } else {
6183
6283
  console.log("Health check timed out \u2014 services may still be starting");
6184
6284
  }
6185
- } catch {
6186
- console.error("Failed to start services");
6285
+ } catch (err) {
6286
+ const stderr = err?.stderr?.toString?.() ?? "";
6287
+ const message = err?.message ?? "";
6288
+ if (/port is already allocated/i.test(stderr) || /address already in use/i.test(stderr) || /port is already allocated/i.test(message)) {
6289
+ console.error(`Port ${config2.httpPort} is already bound \u2014 pass --port=<other> and re-run.`);
6290
+ } else {
6291
+ console.error("Failed to start services");
6292
+ }
6187
6293
  process.exit(1);
6188
6294
  }
6189
6295
  }
@@ -6194,7 +6300,7 @@ async function setupCommand(options) {
6194
6300
  return;
6195
6301
  }
6196
6302
  await printBanner();
6197
- We(import_picocolors8.default.cyan("LearnHouse Setup Wizard"));
6303
+ We(import_picocolors9.default.cyan("LearnHouse Setup Wizard"));
6198
6304
  await checkPrerequisites();
6199
6305
  const channelChoice = await Je({
6200
6306
  message: "Which release channel do you want to use?",
@@ -6227,7 +6333,7 @@ async function setupCommand(options) {
6227
6333
  while (step < totalSteps) {
6228
6334
  switch (step) {
6229
6335
  case 0: {
6230
- R2.step(import_picocolors8.default.cyan(`Step 1/${totalSteps}`) + " Install Directory");
6336
+ R2.step(import_picocolors9.default.cyan(`Step 1/${totalSteps}`) + " Install Directory");
6231
6337
  const result = await stepInstallDir();
6232
6338
  if (result === BACK) {
6233
6339
  step = Math.max(0, step - 1);
@@ -6300,19 +6406,19 @@ async function setupCommand(options) {
6300
6406
  const url = `${protocol}://${config.domain}${portSuffix}`;
6301
6407
  R2.step("Configuration Summary");
6302
6408
  R2.message([
6303
- ` ${import_picocolors8.default.dim("Directory:")} ${resolvedDir}`,
6304
- ` ${import_picocolors8.default.dim("Channel:")} ${config.channel === "dev" ? import_picocolors8.default.yellow("Dev (:dev)") : import_picocolors8.default.green("Stable")}`,
6305
- ` ${import_picocolors8.default.dim("URL:")} ${url}`,
6306
- ` ${import_picocolors8.default.dim("HTTPS:")} ${config.autoSsl ? "Auto SSL (Caddy)" : config.useHttps ? "Manual" : "Disabled"}`,
6307
- ` ${import_picocolors8.default.dim("Database:")} ${config.useExternalDb ? "External" : config.useAiDatabase ? "Local (Docker, AI-enabled)" : "Local (Docker)"}`,
6308
- ` ${import_picocolors8.default.dim("Redis:")} ${config.useExternalRedis ? "External" : "Local (Docker)"}`,
6309
- ` ${import_picocolors8.default.dim("Organization:")} ${config.orgName}`,
6310
- ` ${import_picocolors8.default.dim("Admin:")} ${config.adminEmail}`,
6311
- ` ${import_picocolors8.default.dim("AI:")} ${config.aiEnabled ? "Enabled" : "Disabled"}`,
6312
- ` ${import_picocolors8.default.dim("Email:")} ${config.emailEnabled ? "Enabled" : "Disabled"}`,
6313
- ` ${import_picocolors8.default.dim("S3 Storage:")} ${config.s3Enabled ? "Enabled" : "Disabled"}`,
6314
- ` ${import_picocolors8.default.dim("Google OAuth:")} ${config.googleOAuthEnabled ? "Enabled" : "Disabled"}`,
6315
- ` ${import_picocolors8.default.dim("Unsplash:")} ${config.unsplashEnabled ? "Enabled" : "Disabled"}`
6409
+ ` ${import_picocolors9.default.dim("Directory:")} ${resolvedDir}`,
6410
+ ` ${import_picocolors9.default.dim("Channel:")} ${config.channel === "dev" ? import_picocolors9.default.yellow("Dev (:dev)") : import_picocolors9.default.green("Stable")}`,
6411
+ ` ${import_picocolors9.default.dim("URL:")} ${url}`,
6412
+ ` ${import_picocolors9.default.dim("HTTPS:")} ${config.autoSsl ? "Auto SSL (Caddy)" : config.useHttps ? "Manual" : "Disabled"}`,
6413
+ ` ${import_picocolors9.default.dim("Database:")} ${config.useExternalDb ? "External" : config.useAiDatabase ? "Local (Docker, AI-enabled)" : "Local (Docker)"}`,
6414
+ ` ${import_picocolors9.default.dim("Redis:")} ${config.useExternalRedis ? "External" : "Local (Docker)"}`,
6415
+ ` ${import_picocolors9.default.dim("Organization:")} ${config.orgName}`,
6416
+ ` ${import_picocolors9.default.dim("Admin:")} ${config.adminEmail}`,
6417
+ ` ${import_picocolors9.default.dim("AI:")} ${config.aiEnabled ? "Enabled" : "Disabled"}`,
6418
+ ` ${import_picocolors9.default.dim("Email:")} ${config.emailEnabled ? "Enabled" : "Disabled"}`,
6419
+ ` ${import_picocolors9.default.dim("S3 Storage:")} ${config.s3Enabled ? "Enabled" : "Disabled"}`,
6420
+ ` ${import_picocolors9.default.dim("Google OAuth:")} ${config.googleOAuthEnabled ? "Enabled" : "Disabled"}`,
6421
+ ` ${import_picocolors9.default.dim("Unsplash:")} ${config.unsplashEnabled ? "Enabled" : "Disabled"}`
6316
6422
  ].join("\n"));
6317
6423
  let confirmed = false;
6318
6424
  while (!confirmed) {
@@ -6320,8 +6426,8 @@ async function setupCommand(options) {
6320
6426
  message: "What would you like to do?",
6321
6427
  options: [
6322
6428
  { value: "confirm", label: "Proceed with this configuration" },
6323
- { value: "edit", label: import_picocolors8.default.dim("Go back and edit a step") },
6324
- { value: "cancel", label: import_picocolors8.default.dim("Cancel setup") }
6429
+ { value: "edit", label: import_picocolors9.default.dim("Go back and edit a step") },
6430
+ { value: "cancel", label: import_picocolors9.default.dim("Cancel setup") }
6325
6431
  ]
6326
6432
  });
6327
6433
  if (Ct(action) || action === "cancel") {
@@ -6337,7 +6443,7 @@ async function setupCommand(options) {
6337
6443
  const idx = stepChoice;
6338
6444
  switch (idx) {
6339
6445
  case 0: {
6340
- R2.step(import_picocolors8.default.cyan(`Step 1/${totalSteps}`) + " Install Directory");
6446
+ R2.step(import_picocolors9.default.cyan(`Step 1/${totalSteps}`) + " Install Directory");
6341
6447
  const result = await stepInstallDir();
6342
6448
  if (result !== BACK) {
6343
6449
  resolvedDir = result;
@@ -6376,19 +6482,19 @@ async function setupCommand(options) {
6376
6482
  const url2 = `${p2}://${config.domain}${ps2}`;
6377
6483
  R2.step("Updated Configuration Summary");
6378
6484
  R2.message([
6379
- ` ${import_picocolors8.default.dim("Directory:")} ${config.installDir}`,
6380
- ` ${import_picocolors8.default.dim("Channel:")} ${config.channel === "dev" ? import_picocolors8.default.yellow("Dev (:dev)") : import_picocolors8.default.green("Stable")}`,
6381
- ` ${import_picocolors8.default.dim("URL:")} ${url2}`,
6382
- ` ${import_picocolors8.default.dim("HTTPS:")} ${config.autoSsl ? "Auto SSL (Caddy)" : config.useHttps ? "Manual" : "Disabled"}`,
6383
- ` ${import_picocolors8.default.dim("Database:")} ${config.useExternalDb ? "External" : config.useAiDatabase ? "Local (Docker, AI-enabled)" : "Local (Docker)"}`,
6384
- ` ${import_picocolors8.default.dim("Redis:")} ${config.useExternalRedis ? "External" : "Local (Docker)"}`,
6385
- ` ${import_picocolors8.default.dim("Organization:")} ${config.orgName}`,
6386
- ` ${import_picocolors8.default.dim("Admin:")} ${config.adminEmail}`,
6387
- ` ${import_picocolors8.default.dim("AI:")} ${config.aiEnabled ? "Enabled" : "Disabled"}`,
6388
- ` ${import_picocolors8.default.dim("Email:")} ${config.emailEnabled ? "Enabled" : "Disabled"}`,
6389
- ` ${import_picocolors8.default.dim("S3 Storage:")} ${config.s3Enabled ? "Enabled" : "Disabled"}`,
6390
- ` ${import_picocolors8.default.dim("Google OAuth:")} ${config.googleOAuthEnabled ? "Enabled" : "Disabled"}`,
6391
- ` ${import_picocolors8.default.dim("Unsplash:")} ${config.unsplashEnabled ? "Enabled" : "Disabled"}`
6485
+ ` ${import_picocolors9.default.dim("Directory:")} ${config.installDir}`,
6486
+ ` ${import_picocolors9.default.dim("Channel:")} ${config.channel === "dev" ? import_picocolors9.default.yellow("Dev (:dev)") : import_picocolors9.default.green("Stable")}`,
6487
+ ` ${import_picocolors9.default.dim("URL:")} ${url2}`,
6488
+ ` ${import_picocolors9.default.dim("HTTPS:")} ${config.autoSsl ? "Auto SSL (Caddy)" : config.useHttps ? "Manual" : "Disabled"}`,
6489
+ ` ${import_picocolors9.default.dim("Database:")} ${config.useExternalDb ? "External" : config.useAiDatabase ? "Local (Docker, AI-enabled)" : "Local (Docker)"}`,
6490
+ ` ${import_picocolors9.default.dim("Redis:")} ${config.useExternalRedis ? "External" : "Local (Docker)"}`,
6491
+ ` ${import_picocolors9.default.dim("Organization:")} ${config.orgName}`,
6492
+ ` ${import_picocolors9.default.dim("Admin:")} ${config.adminEmail}`,
6493
+ ` ${import_picocolors9.default.dim("AI:")} ${config.aiEnabled ? "Enabled" : "Disabled"}`,
6494
+ ` ${import_picocolors9.default.dim("Email:")} ${config.emailEnabled ? "Enabled" : "Disabled"}`,
6495
+ ` ${import_picocolors9.default.dim("S3 Storage:")} ${config.s3Enabled ? "Enabled" : "Disabled"}`,
6496
+ ` ${import_picocolors9.default.dim("Google OAuth:")} ${config.googleOAuthEnabled ? "Enabled" : "Disabled"}`,
6497
+ ` ${import_picocolors9.default.dim("Unsplash:")} ${config.unsplashEnabled ? "Enabled" : "Disabled"}`
6392
6498
  ].join("\n"));
6393
6499
  } else {
6394
6500
  confirmed = true;
@@ -6441,47 +6547,71 @@ async function setupCommand(options) {
6441
6547
  s2.stop("Services started");
6442
6548
  } catch (err) {
6443
6549
  s2.stop("Failed to start services");
6444
- R2.error("Docker Compose failed. Check the output above for details.");
6445
- R2.info(`You can manually start with: cd ${finalDir} && docker compose up -d`);
6550
+ const stderr = err?.stderr?.toString?.() ?? "";
6551
+ const message = err?.message ?? "";
6552
+ const portAllocated = /port is already allocated/i.test(stderr) || /port is already allocated/i.test(message) || /bind:.*address already in use/i.test(stderr);
6553
+ if (portAllocated) {
6554
+ R2.error(
6555
+ `Port ${config.httpPort} is already bound by another process or container \u2014 Docker couldn't publish to it.`
6556
+ );
6557
+ R2.info(
6558
+ `Fix one of these and re-run \`learnhouse start\` (your config is already saved):
6559
+ \u2022 Stop whatever is using port ${config.httpPort}, or
6560
+ \u2022 Re-run \`learnhouse setup\` and pick a different port, or
6561
+ \u2022 Edit HTTP_PORT in ${finalDir}/.env and run \`docker compose up -d\` from there.`
6562
+ );
6563
+ } else {
6564
+ R2.error("Docker Compose failed. Check the output above for details.");
6565
+ R2.info(`You can manually start with: cd ${finalDir} && docker compose up -d`);
6566
+ }
6446
6567
  process.exit(1);
6447
6568
  }
6448
6569
  const s3 = bt2();
6449
6570
  s3.start("Waiting for LearnHouse to be ready (up to 3 minutes)");
6450
6571
  const healthy = await waitForHealth(`http://localhost:${config.httpPort}`);
6451
6572
  if (healthy) {
6452
- s3.stop("LearnHouse is ready!");
6573
+ const seeded = await waitForOrgSeed(`http://localhost:${config.httpPort}`, "default");
6574
+ if (seeded) {
6575
+ s3.stop("LearnHouse is ready!");
6576
+ } else {
6577
+ s3.stop("API is healthy but the default organization was not seeded");
6578
+ R2.error(
6579
+ "`/api/v1/orgs/slug/default` returns no org. Run `learnhouse logs` to inspect, pin a different image tag, and re-run setup."
6580
+ );
6581
+ process.exit(1);
6582
+ }
6453
6583
  } else {
6454
6584
  s3.stop("Health check timed out");
6455
6585
  R2.warn("LearnHouse may still be starting. Check status with:");
6456
6586
  R2.message(` cd ${finalDir} && docker compose ps`);
6457
6587
  }
6458
- R2.success(import_picocolors8.default.green(import_picocolors8.default.bold("LearnHouse is installed!")));
6588
+ R2.success(import_picocolors9.default.green(import_picocolors9.default.bold("LearnHouse is installed!")));
6459
6589
  R2.message([
6460
6590
  "",
6461
- ` ${import_picocolors8.default.cyan("URL:")} ${finalUrl}`,
6462
- ` ${import_picocolors8.default.cyan("Admin:")} ${config.adminEmail}`,
6463
- ` ${import_picocolors8.default.cyan("Password:")} ${config.adminPassword}`,
6591
+ ` ${import_picocolors9.default.cyan("URL:")} ${finalUrl}`,
6592
+ ` ${import_picocolors9.default.cyan("Admin:")} ${config.adminEmail}`,
6593
+ ` ${import_picocolors9.default.cyan("Password:")} ${config.adminPassword}`,
6464
6594
  "",
6465
- ` ${import_picocolors8.default.dim("Management commands:")}`,
6466
- ` ${import_picocolors8.default.dim("$")} npx learnhouse start ${import_picocolors8.default.dim("Start services")}`,
6467
- ` ${import_picocolors8.default.dim("$")} npx learnhouse stop ${import_picocolors8.default.dim("Stop services")}`,
6468
- ` ${import_picocolors8.default.dim("$")} npx learnhouse logs ${import_picocolors8.default.dim("View logs")}`,
6469
- ` ${import_picocolors8.default.dim("$")} npx learnhouse config ${import_picocolors8.default.dim("Show configuration")}`,
6470
- ` ${import_picocolors8.default.dim("$")} npx learnhouse backup ${import_picocolors8.default.dim("Backup & restore")}`,
6471
- ` ${import_picocolors8.default.dim("$")} npx learnhouse deployments ${import_picocolors8.default.dim("Manage deployments")}`,
6472
- ` ${import_picocolors8.default.dim("$")} npx learnhouse doctor ${import_picocolors8.default.dim("Diagnose issues")}`,
6473
- ` ${import_picocolors8.default.dim("$")} npx learnhouse shell ${import_picocolors8.default.dim("Container shell")}`,
6595
+ ` ${import_picocolors9.default.dim("Management commands:")}`,
6596
+ ` ${import_picocolors9.default.dim("$")} npx learnhouse start ${import_picocolors9.default.dim("Start services")}`,
6597
+ ` ${import_picocolors9.default.dim("$")} npx learnhouse stop ${import_picocolors9.default.dim("Stop services")}`,
6598
+ ` ${import_picocolors9.default.dim("$")} npx learnhouse logs ${import_picocolors9.default.dim("View logs")}`,
6599
+ ` ${import_picocolors9.default.dim("$")} npx learnhouse config ${import_picocolors9.default.dim("Show configuration")}`,
6600
+ ` ${import_picocolors9.default.dim("$")} npx learnhouse backup ${import_picocolors9.default.dim("Backup & restore")}`,
6601
+ ` ${import_picocolors9.default.dim("$")} npx learnhouse deployments ${import_picocolors9.default.dim("Manage deployments")}`,
6602
+ ` ${import_picocolors9.default.dim("$")} npx learnhouse doctor ${import_picocolors9.default.dim("Diagnose issues")}`,
6603
+ ` ${import_picocolors9.default.dim("$")} npx learnhouse shell ${import_picocolors9.default.dim("Container shell")}`,
6474
6604
  ""
6475
6605
  ].join("\n"));
6476
6606
  } else {
6477
6607
  R2.info(`Files have been generated in ${finalDir}`);
6478
6608
  R2.message(` Start later with: cd ${finalDir} && docker compose up -d`);
6479
6609
  }
6480
- Le(import_picocolors8.default.dim("Happy teaching!"));
6610
+ Le(import_picocolors9.default.dim("Happy teaching!"));
6481
6611
  }
6482
6612
 
6483
6613
  // src/commands/start.ts
6484
- var import_picocolors9 = __toESM(require_picocolors(), 1);
6614
+ var import_picocolors10 = __toESM(require_picocolors(), 1);
6485
6615
  async function startCommand() {
6486
6616
  const dir = findInstallDir();
6487
6617
  const config = readConfig(dir);
@@ -6489,7 +6619,7 @@ async function startCommand() {
6489
6619
  R2.error("No LearnHouse installation found. Run `npx learnhouse setup` first.");
6490
6620
  process.exit(1);
6491
6621
  }
6492
- We(import_picocolors9.default.cyan("Starting LearnHouse"));
6622
+ We(import_picocolors10.default.cyan("Starting LearnHouse"));
6493
6623
  try {
6494
6624
  dockerComposeUp(config.installDir);
6495
6625
  R2.success("LearnHouse is running!");
@@ -6500,7 +6630,7 @@ async function startCommand() {
6500
6630
  }
6501
6631
 
6502
6632
  // src/commands/stop.ts
6503
- var import_picocolors10 = __toESM(require_picocolors(), 1);
6633
+ var import_picocolors11 = __toESM(require_picocolors(), 1);
6504
6634
  async function stopCommand() {
6505
6635
  const dir = findInstallDir();
6506
6636
  const config = readConfig(dir);
@@ -6508,7 +6638,7 @@ async function stopCommand() {
6508
6638
  R2.error("No LearnHouse installation found. Run `npx learnhouse setup` first.");
6509
6639
  process.exit(1);
6510
6640
  }
6511
- We(import_picocolors10.default.cyan("Stopping LearnHouse"));
6641
+ We(import_picocolors11.default.cyan("Stopping LearnHouse"));
6512
6642
  try {
6513
6643
  dockerComposeDown(config.installDir);
6514
6644
  R2.success("LearnHouse stopped.");
@@ -6548,7 +6678,7 @@ async function logsCommand() {
6548
6678
  }
6549
6679
 
6550
6680
  // src/commands/config.ts
6551
- var import_picocolors11 = __toESM(require_picocolors(), 1);
6681
+ var import_picocolors12 = __toESM(require_picocolors(), 1);
6552
6682
  async function configCommand() {
6553
6683
  const dir = findInstallDir();
6554
6684
  const config = readConfig(dir);
@@ -6556,25 +6686,25 @@ async function configCommand() {
6556
6686
  R2.error("No LearnHouse installation found. Run `npx learnhouse setup` first.");
6557
6687
  process.exit(1);
6558
6688
  }
6559
- We(import_picocolors11.default.cyan("LearnHouse Configuration"));
6689
+ We(import_picocolors12.default.cyan("LearnHouse Configuration"));
6560
6690
  const protocol = config.useHttps ? "https" : "http";
6561
6691
  const portSuffix = config.useHttps && config.httpPort === 443 || !config.useHttps && config.httpPort === 80 ? "" : `:${config.httpPort}`;
6562
6692
  R2.message([
6563
- ` ${import_picocolors11.default.dim("Version:")} ${config.version}`,
6564
- ` ${import_picocolors11.default.dim("Created:")} ${config.createdAt}`,
6565
- ` ${import_picocolors11.default.dim("Directory:")} ${config.installDir}`,
6566
- ` ${import_picocolors11.default.dim("URL:")} ${protocol}://${config.domain}${portSuffix}`,
6567
- ` ${import_picocolors11.default.dim("Org slug:")} ${config.orgSlug}`
6693
+ ` ${import_picocolors12.default.dim("Version:")} ${config.version}`,
6694
+ ` ${import_picocolors12.default.dim("Created:")} ${config.createdAt}`,
6695
+ ` ${import_picocolors12.default.dim("Directory:")} ${config.installDir}`,
6696
+ ` ${import_picocolors12.default.dim("URL:")} ${protocol}://${config.domain}${portSuffix}`,
6697
+ ` ${import_picocolors12.default.dim("Org slug:")} ${config.orgSlug}`
6568
6698
  ].join("\n"));
6569
- R2.info(import_picocolors11.default.dim(`Full config: ${dir}/learnhouse.config.json`));
6570
- R2.info(import_picocolors11.default.dim(`Environment: ${config.installDir}/.env (contains secrets)`));
6699
+ R2.info(import_picocolors12.default.dim(`Full config: ${dir}/learnhouse.config.json`));
6700
+ R2.info(import_picocolors12.default.dim(`Environment: ${config.installDir}/.env (contains secrets)`));
6571
6701
  }
6572
6702
 
6573
6703
  // src/commands/backup.ts
6574
6704
  import fs3 from "fs";
6575
6705
  import path3 from "path";
6576
6706
  import { execSync as execSync2 } from "child_process";
6577
- var import_picocolors12 = __toESM(require_picocolors(), 1);
6707
+ var import_picocolors13 = __toESM(require_picocolors(), 1);
6578
6708
  function resolveDbContainer(config) {
6579
6709
  const id = config.deploymentId || autoDetectDeploymentId();
6580
6710
  if (!id) return null;
@@ -6638,13 +6768,13 @@ async function createBackup() {
6638
6768
  fs3.rmSync(tmpDir, { recursive: true, force: true });
6639
6769
  const stats = fs3.statSync(archivePath);
6640
6770
  const sizeMb = (stats.size / (1024 * 1024)).toFixed(1);
6641
- R2.success(import_picocolors12.default.green(import_picocolors12.default.bold("Backup complete!")));
6771
+ R2.success(import_picocolors13.default.green(import_picocolors13.default.bold("Backup complete!")));
6642
6772
  R2.message([
6643
6773
  "",
6644
- ` ${import_picocolors12.default.dim("File:")} ${archivePath}`,
6645
- ` ${import_picocolors12.default.dim("Size:")} ${sizeMb} MB`,
6774
+ ` ${import_picocolors13.default.dim("File:")} ${archivePath}`,
6775
+ ` ${import_picocolors13.default.dim("Size:")} ${sizeMb} MB`,
6646
6776
  "",
6647
- ` ${import_picocolors12.default.dim("Restore with:")} npx learnhouse backup --restore ${archivePath}`,
6777
+ ` ${import_picocolors13.default.dim("Restore with:")} npx learnhouse backup --restore ${archivePath}`,
6648
6778
  ""
6649
6779
  ].join("\n"));
6650
6780
  }
@@ -6669,7 +6799,7 @@ async function restoreBackup(archivePath) {
6669
6799
  R2.error("Database container is not running. Start services first.");
6670
6800
  process.exit(1);
6671
6801
  }
6672
- R2.warn(import_picocolors12.default.yellow("This will overwrite the current database with the backup data."));
6802
+ R2.warn(import_picocolors13.default.yellow("This will overwrite the current database with the backup data."));
6673
6803
  const confirm = await Re({
6674
6804
  message: "Are you sure you want to restore from this backup?",
6675
6805
  initialValue: false
@@ -6728,16 +6858,16 @@ async function restoreBackup(archivePath) {
6728
6858
  }
6729
6859
  }
6730
6860
  fs3.rmSync(tmpDir, { recursive: true, force: true });
6731
- R2.success(import_picocolors12.default.green(import_picocolors12.default.bold("Restore complete!")));
6861
+ R2.success(import_picocolors13.default.green(import_picocolors13.default.bold("Restore complete!")));
6732
6862
  R2.info("You may want to restart services: npx learnhouse stop && npx learnhouse start");
6733
6863
  }
6734
6864
  async function backupCommand(archivePath, options) {
6735
6865
  if (options?.restore && archivePath) {
6736
- We(import_picocolors12.default.cyan("LearnHouse Restore"));
6866
+ We(import_picocolors13.default.cyan("LearnHouse Restore"));
6737
6867
  await restoreBackup(archivePath);
6738
6868
  return;
6739
6869
  }
6740
- We(import_picocolors12.default.cyan("LearnHouse Backup"));
6870
+ We(import_picocolors13.default.cyan("LearnHouse Backup"));
6741
6871
  const action = await Je({
6742
6872
  message: "What would you like to do?",
6743
6873
  options: [
@@ -6768,7 +6898,7 @@ async function backupCommand(archivePath, options) {
6768
6898
  import fs4 from "fs";
6769
6899
  import path4 from "path";
6770
6900
  import { execSync as execSync3 } from "child_process";
6771
- var import_picocolors13 = __toESM(require_picocolors(), 1);
6901
+ var import_picocolors14 = __toESM(require_picocolors(), 1);
6772
6902
  var SERVICES = ["learnhouse-app", "db", "redis"];
6773
6903
  function showDeployments() {
6774
6904
  let psOutput;
@@ -6783,7 +6913,7 @@ function showDeployments() {
6783
6913
  }
6784
6914
  if (!psOutput) {
6785
6915
  R2.info("No LearnHouse deployments found.");
6786
- R2.message(import_picocolors13.default.dim(" Run npx learnhouse setup to create one."));
6916
+ R2.message(import_picocolors14.default.dim(" Run npx learnhouse setup to create one."));
6787
6917
  return;
6788
6918
  }
6789
6919
  const deployments = /* @__PURE__ */ new Map();
@@ -6807,20 +6937,20 @@ function showDeployments() {
6807
6937
  }
6808
6938
  deployments.get(id).containers.push({ name, status, image });
6809
6939
  }
6810
- R2.info(`Found ${import_picocolors13.default.bold(String(deployments.size))} deployment${deployments.size === 1 ? "" : "s"}`);
6940
+ R2.info(`Found ${import_picocolors14.default.bold(String(deployments.size))} deployment${deployments.size === 1 ? "" : "s"}`);
6811
6941
  console.log();
6812
6942
  for (const [id, dep] of deployments) {
6813
6943
  const running = dep.containers.filter((c) => c.status.toLowerCase().startsWith("up")).length;
6814
6944
  const total = dep.containers.length;
6815
- const statusColor = running === total ? import_picocolors13.default.green : running > 0 ? import_picocolors13.default.yellow : import_picocolors13.default.red;
6945
+ const statusColor = running === total ? import_picocolors14.default.green : running > 0 ? import_picocolors14.default.yellow : import_picocolors14.default.red;
6816
6946
  const statusText = statusColor(`${running}/${total} running`);
6817
- console.log(` ${import_picocolors13.default.bold(import_picocolors13.default.white(`Deployment ${id}`))} ${statusText}`);
6947
+ console.log(` ${import_picocolors14.default.bold(import_picocolors14.default.white(`Deployment ${id}`))} ${statusText}`);
6818
6948
  console.log();
6819
6949
  for (const c of dep.containers) {
6820
6950
  const isUp = c.status.toLowerCase().startsWith("up");
6821
- const icon = isUp ? import_picocolors13.default.green("\u25CF") : import_picocolors13.default.red("\u25CF");
6951
+ const icon = isUp ? import_picocolors14.default.green("\u25CF") : import_picocolors14.default.red("\u25CF");
6822
6952
  const svcName = c.name.replace(`-${id}`, "");
6823
- console.log(` ${icon} ${import_picocolors13.default.white(svcName.padEnd(24))} ${import_picocolors13.default.dim(c.status)}`);
6953
+ console.log(` ${icon} ${import_picocolors14.default.white(svcName.padEnd(24))} ${import_picocolors14.default.dim(c.status)}`);
6824
6954
  }
6825
6955
  console.log();
6826
6956
  }
@@ -6893,14 +7023,14 @@ async function scaleResources() {
6893
7023
  R2.step("Current Resource Usage");
6894
7024
  try {
6895
7025
  const stats = dockerStats(config.installDir);
6896
- R2.message(import_picocolors13.default.dim(stats.trim()));
7026
+ R2.message(import_picocolors14.default.dim(stats.trim()));
6897
7027
  } catch {
6898
7028
  try {
6899
7029
  const id = config.deploymentId || autoDetectDeploymentId();
6900
7030
  const running = listDeploymentContainers(id || void 0).filter((c) => c.status.toLowerCase().startsWith("up")).map((c) => c.name);
6901
7031
  if (running.length > 0) {
6902
7032
  const stats = dockerStatsForContainers(running);
6903
- R2.message(import_picocolors13.default.dim(stats.trim()));
7033
+ R2.message(import_picocolors14.default.dim(stats.trim()));
6904
7034
  } else {
6905
7035
  R2.warn("No running containers found.");
6906
7036
  }
@@ -6916,11 +7046,11 @@ async function scaleResources() {
6916
7046
  let composeContent = fs4.readFileSync(composePath, "utf-8");
6917
7047
  const currentLimits = parseMemLimit(composePath);
6918
7048
  R2.step("Set Memory Limits");
6919
- R2.info(import_picocolors13.default.dim("Examples: 256m, 512m, 1g, 2g (leave empty to skip)"));
7049
+ R2.info(import_picocolors14.default.dim("Examples: 256m, 512m, 1g, 2g (leave empty to skip)"));
6920
7050
  let changed = false;
6921
7051
  for (const service of SERVICES) {
6922
7052
  const current = currentLimits.get(service);
6923
- const label = current ? `Memory limit for ${import_picocolors13.default.bold(service)} (current: ${current})` : `Memory limit for ${import_picocolors13.default.bold(service)} (not set)`;
7053
+ const label = current ? `Memory limit for ${import_picocolors14.default.bold(service)} (current: ${current})` : `Memory limit for ${import_picocolors14.default.bold(service)} (not set)`;
6924
7054
  const value = await text({
6925
7055
  message: label,
6926
7056
  placeholder: current ? void 0 : "e.g. 512m",
@@ -6963,7 +7093,7 @@ async function scaleResources() {
6963
7093
  }
6964
7094
  }
6965
7095
  async function deploymentsCommand() {
6966
- We(import_picocolors13.default.cyan("LearnHouse Deployments"));
7096
+ We(import_picocolors14.default.cyan("LearnHouse Deployments"));
6967
7097
  const action = await Je({
6968
7098
  message: "What would you like to do?",
6969
7099
  options: [
@@ -6980,24 +7110,24 @@ async function deploymentsCommand() {
6980
7110
  } else {
6981
7111
  await scaleResources();
6982
7112
  }
6983
- Le(import_picocolors13.default.dim("Done"));
7113
+ Le(import_picocolors14.default.dim("Done"));
6984
7114
  }
6985
7115
 
6986
7116
  // src/commands/doctor.ts
6987
7117
  import fs5 from "fs";
6988
7118
  import path5 from "path";
6989
7119
  import { execSync as execSync4 } from "child_process";
6990
- var import_picocolors14 = __toESM(require_picocolors(), 1);
7120
+ var import_picocolors15 = __toESM(require_picocolors(), 1);
6991
7121
  function pass(msg) {
6992
- console.log(` ${import_picocolors14.default.green("\u2713")} ${msg}`);
7122
+ console.log(` ${import_picocolors15.default.green("\u2713")} ${msg}`);
6993
7123
  }
6994
7124
  function warn(msg, fix) {
6995
- console.log(` ${import_picocolors14.default.yellow("!")} ${msg}`);
6996
- if (fix) console.log(` ${import_picocolors14.default.dim(`Fix: ${fix}`)}`);
7125
+ console.log(` ${import_picocolors15.default.yellow("!")} ${msg}`);
7126
+ if (fix) console.log(` ${import_picocolors15.default.dim(`Fix: ${fix}`)}`);
6997
7127
  }
6998
7128
  function fail(msg, fix) {
6999
- console.log(` ${import_picocolors14.default.red("\u2717")} ${msg}`);
7000
- if (fix) console.log(` ${import_picocolors14.default.dim(`Fix: ${fix}`)}`);
7129
+ console.log(` ${import_picocolors15.default.red("\u2717")} ${msg}`);
7130
+ if (fix) console.log(` ${import_picocolors15.default.dim(`Fix: ${fix}`)}`);
7001
7131
  }
7002
7132
  var REQUIRED_ENV_VARS = [
7003
7133
  "LEARNHOUSE_DOMAIN",
@@ -7015,30 +7145,30 @@ var SECRET_ENV_VARS = [
7015
7145
  async function doctorCommand() {
7016
7146
  const dir = findInstallDir();
7017
7147
  const config = readConfig(dir);
7018
- We(import_picocolors14.default.cyan("LearnHouse Doctor"));
7148
+ We(import_picocolors15.default.cyan("LearnHouse Doctor"));
7019
7149
  R2.step("Docker Environment");
7020
7150
  if (!isDockerInstalled()) {
7021
7151
  fail("Docker not installed", "Install Docker: https://docs.docker.com/get-docker/");
7022
- Le(import_picocolors14.default.red("Cannot continue without Docker"));
7152
+ Le(import_picocolors15.default.red("Cannot continue without Docker"));
7023
7153
  process.exit(1);
7024
7154
  }
7025
7155
  pass("Docker installed");
7026
7156
  if (!isDockerRunning()) {
7027
7157
  fail("Docker daemon not running", "Start Docker Desktop or run: sudo systemctl start docker");
7028
- Le(import_picocolors14.default.red("Cannot continue without Docker running"));
7158
+ Le(import_picocolors15.default.red("Cannot continue without Docker running"));
7029
7159
  process.exit(1);
7030
7160
  }
7031
7161
  pass("Docker daemon running");
7032
7162
  if (!config) {
7033
7163
  R2.warn("No LearnHouse installation found. Skipping deployment checks.");
7034
- Le(import_picocolors14.default.dim("Done"));
7164
+ Le(import_picocolors15.default.dim("Done"));
7035
7165
  return;
7036
7166
  }
7037
7167
  const id = config.deploymentId || autoDetectDeploymentId();
7038
7168
  const installDir = dir;
7039
7169
  if (!id) {
7040
7170
  R2.warn("No deployment ID found. Skipping container checks.");
7041
- Le(import_picocolors14.default.dim("Done"));
7171
+ Le(import_picocolors15.default.dim("Done"));
7042
7172
  return;
7043
7173
  }
7044
7174
  R2.step("Containers");
@@ -7109,7 +7239,7 @@ async function doctorCommand() {
7109
7239
  }
7110
7240
  try {
7111
7241
  const diskUsage = getDockerDiskUsage();
7112
- R2.message(import_picocolors14.default.dim(diskUsage.trim()));
7242
+ R2.message(import_picocolors15.default.dim(diskUsage.trim()));
7113
7243
  } catch {
7114
7244
  }
7115
7245
  R2.step("Log Analysis");
@@ -7123,7 +7253,7 @@ async function doctorCommand() {
7123
7253
  if (errorLines.length > 0) {
7124
7254
  warn(`${svcName} \u2014 ${errorLines.length} error(s) in last 50 log lines`);
7125
7255
  for (const line of errorLines.slice(0, 3)) {
7126
- console.log(` ${import_picocolors14.default.dim(line.trim().slice(0, 120))}`);
7256
+ console.log(` ${import_picocolors15.default.dim(line.trim().slice(0, 120))}`);
7127
7257
  }
7128
7258
  } else {
7129
7259
  pass(`${svcName} \u2014 no errors in recent logs`);
@@ -7177,11 +7307,11 @@ async function doctorCommand() {
7177
7307
  }
7178
7308
  }
7179
7309
  console.log();
7180
- Le(import_picocolors14.default.dim("Diagnosis complete"));
7310
+ Le(import_picocolors15.default.dim("Diagnosis complete"));
7181
7311
  }
7182
7312
 
7183
7313
  // src/commands/shell.ts
7184
- var import_picocolors15 = __toESM(require_picocolors(), 1);
7314
+ var import_picocolors16 = __toESM(require_picocolors(), 1);
7185
7315
  async function shellCommand() {
7186
7316
  const dir = findInstallDir();
7187
7317
  const config = readConfig(dir);
@@ -7203,7 +7333,7 @@ async function shellCommand() {
7203
7333
  message: "Select a container",
7204
7334
  options: containers.map((c) => ({
7205
7335
  value: c.name,
7206
- label: `${c.name.replace(`-${id}`, "")} ${import_picocolors15.default.dim(`(${c.name})`)}`
7336
+ label: `${c.name.replace(`-${id}`, "")} ${import_picocolors16.default.dim(`(${c.name})`)}`
7207
7337
  }))
7208
7338
  });
7209
7339
  if (Ct(selected)) {
@@ -7216,7 +7346,7 @@ async function shellCommand() {
7216
7346
 
7217
7347
  // src/commands/dev.ts
7218
7348
  import { spawn as spawn2, spawnSync as spawnSync2, execSync as execSync5 } from "child_process";
7219
- var import_picocolors17 = __toESM(require_picocolors(), 1);
7349
+ var import_picocolors18 = __toESM(require_picocolors(), 1);
7220
7350
  import * as path7 from "path";
7221
7351
  import * as fs7 from "fs";
7222
7352
 
@@ -7224,7 +7354,7 @@ import * as fs7 from "fs";
7224
7354
  import * as fs6 from "fs";
7225
7355
  import * as path6 from "path";
7226
7356
  import * as crypto4 from "crypto";
7227
- var import_picocolors16 = __toESM(require_picocolors(), 1);
7357
+ var import_picocolors17 = __toESM(require_picocolors(), 1);
7228
7358
  function generateJwtSecret() {
7229
7359
  return crypto4.randomBytes(32).toString("base64url");
7230
7360
  }
@@ -7351,9 +7481,9 @@ async function checkDevEnv(root) {
7351
7481
  byApp.set(m.app.label, list);
7352
7482
  }
7353
7483
  for (const [label, vars] of byApp) {
7354
- console.log(` ${import_picocolors16.default.bold(label)} ${import_picocolors16.default.dim(`(${vars[0].app.envFile})`)}`);
7484
+ console.log(` ${import_picocolors17.default.bold(label)} ${import_picocolors17.default.dim(`(${vars[0].app.envFile})`)}`);
7355
7485
  for (const m of vars) {
7356
- console.log(` ${import_picocolors16.default.red("\u2717")} ${import_picocolors16.default.cyan(m.envVar.name)} \u2014 ${import_picocolors16.default.dim(m.envVar.description)}`);
7486
+ console.log(` ${import_picocolors17.default.red("\u2717")} ${import_picocolors17.default.cyan(m.envVar.name)} \u2014 ${import_picocolors17.default.dim(m.envVar.description)}`);
7357
7487
  }
7358
7488
  console.log();
7359
7489
  }
@@ -7389,8 +7519,8 @@ async function checkDevEnv(root) {
7389
7519
  }
7390
7520
  if (toWrite.size > 0) {
7391
7521
  appendToEnvFile(filePath, toWrite);
7392
- const names = [...toWrite.keys()].map((k2) => import_picocolors16.default.cyan(k2)).join(", ");
7393
- R2.success(`${import_picocolors16.default.bold(app.label)}: wrote ${names} \u2192 ${import_picocolors16.default.dim(app.envFile)}`);
7522
+ const names = [...toWrite.keys()].map((k2) => import_picocolors17.default.cyan(k2)).join(", ");
7523
+ R2.success(`${import_picocolors17.default.bold(app.label)}: wrote ${names} \u2192 ${import_picocolors17.default.dim(app.envFile)}`);
7394
7524
  }
7395
7525
  }
7396
7526
  console.log();
@@ -7471,7 +7601,7 @@ async function waitForHealth2(label, command, args, maxAttempts = 30) {
7471
7601
  }
7472
7602
  return false;
7473
7603
  }
7474
- var CONTROLS_BAR = import_picocolors17.default.dim("\u2500".repeat(60)) + "\n" + import_picocolors17.default.dim(" ") + import_picocolors17.default.bold("ra") + import_picocolors17.default.dim(" restart api ") + import_picocolors17.default.bold("rw") + import_picocolors17.default.dim(" restart web ") + import_picocolors17.default.bold("rc") + import_picocolors17.default.dim(" restart collab ") + import_picocolors17.default.bold("rb") + import_picocolors17.default.dim(" restart all ") + import_picocolors17.default.bold("q") + import_picocolors17.default.dim(" quit") + "\n" + import_picocolors17.default.dim("\u2500".repeat(60));
7604
+ var CONTROLS_BAR = import_picocolors18.default.dim("\u2500".repeat(60)) + "\n" + import_picocolors18.default.dim(" ") + import_picocolors18.default.bold("ra") + import_picocolors18.default.dim(" restart api ") + import_picocolors18.default.bold("rw") + import_picocolors18.default.dim(" restart web ") + import_picocolors18.default.bold("rc") + import_picocolors18.default.dim(" restart collab ") + import_picocolors18.default.bold("rb") + import_picocolors18.default.dim(" restart all ") + import_picocolors18.default.bold("q") + import_picocolors18.default.dim(" quit") + "\n" + import_picocolors18.default.dim("\u2500".repeat(60));
7475
7605
  var lineCount = 0;
7476
7606
  var CONTROLS_INTERVAL = 50;
7477
7607
  function printControls() {
@@ -7553,7 +7683,7 @@ async function devCommand(opts) {
7553
7683
  R2.info("Run this command from within the learnhouse monorepo (must contain dev/docker-compose.yml, apps/api/, and apps/web/).");
7554
7684
  process.exit(1);
7555
7685
  }
7556
- We(import_picocolors17.default.cyan("LearnHouse Dev Mode"));
7686
+ We(import_picocolors18.default.cyan("LearnHouse Dev Mode"));
7557
7687
  const envOk = await checkDevEnv(root);
7558
7688
  if (!envOk) process.exit(1);
7559
7689
  const eePath = path7.join(root, "apps", "api", "ee");
@@ -7573,7 +7703,7 @@ async function devCommand(opts) {
7573
7703
  }
7574
7704
  }
7575
7705
  if (fs7.existsSync(eePath)) {
7576
- R2.info(`Running in ${import_picocolors17.default.bold("EE")} mode`);
7706
+ R2.info(`Running in ${import_picocolors18.default.bold("EE")} mode`);
7577
7707
  }
7578
7708
  }
7579
7709
  if (!isDockerInstalled()) {
@@ -7678,35 +7808,35 @@ async function devCommand(opts) {
7678
7808
  let webProc = null;
7679
7809
  let collabProc = null;
7680
7810
  const startApi = () => {
7681
- return spawnService("uv", ["run", "python", "app.py"], path7.join(root, "apps", "api"), "api", import_picocolors17.default.magenta);
7811
+ return spawnService("uv", ["run", "python", "app.py"], path7.join(root, "apps", "api"), "api", import_picocolors18.default.magenta);
7682
7812
  };
7683
7813
  const startWeb = () => {
7684
- return spawnService("next", ["dev", "--turbopack"], path7.join(root, "apps", "web"), "web", import_picocolors17.default.cyan);
7814
+ return spawnService("next", ["dev", "--turbopack"], path7.join(root, "apps", "web"), "web", import_picocolors18.default.cyan);
7685
7815
  };
7686
7816
  const startCollab = () => {
7687
- return spawnService("tsx", ["watch", "src/index.ts"], path7.join(root, "apps", "collab"), "collab", import_picocolors17.default.yellow);
7817
+ return spawnService("tsx", ["watch", "src/index.ts"], path7.join(root, "apps", "collab"), "collab", import_picocolors18.default.yellow);
7688
7818
  };
7689
7819
  apiProc = startApi();
7690
7820
  webProc = startWeb();
7691
7821
  collabProc = startCollab();
7692
7822
  R2.success("API, Web, and Collab servers started");
7693
7823
  console.log();
7694
- console.log(import_picocolors17.default.dim(" Thank you for contributing to LearnHouse!"));
7824
+ console.log(import_picocolors18.default.dim(" Thank you for contributing to LearnHouse!"));
7695
7825
  console.log();
7696
7826
  printControls();
7697
7827
  let shuttingDown = false;
7698
7828
  const shutdown = async () => {
7699
7829
  if (shuttingDown) return;
7700
7830
  shuttingDown = true;
7701
- console.log("\n" + import_picocolors17.default.dim("Shutting down dev servers..."));
7831
+ console.log("\n" + import_picocolors18.default.dim("Shutting down dev servers..."));
7702
7832
  if (process.stdin.isTTY && process.stdin.isRaw) {
7703
7833
  process.stdin.setRawMode(false);
7704
7834
  }
7705
7835
  process.stdin.pause();
7706
7836
  await Promise.all([killProcess(apiProc), killProcess(webProc), killProcess(collabProc)]);
7707
- console.log(import_picocolors17.default.dim("DB and Redis containers are still running for next session."));
7708
- console.log(import_picocolors17.default.dim("To stop them: docker compose -f .learnhouse/docker-compose.dev.yml -p learnhouse-dev down"));
7709
- console.log(import_picocolors17.default.dim("Thanks for building with LearnHouse!"));
7837
+ console.log(import_picocolors18.default.dim("DB and Redis containers are still running for next session."));
7838
+ console.log(import_picocolors18.default.dim("To stop them: docker compose -f .learnhouse/docker-compose.dev.yml -p learnhouse-dev down"));
7839
+ console.log(import_picocolors18.default.dim("Thanks for building with LearnHouse!"));
7710
7840
  process.exit(0);
7711
7841
  };
7712
7842
  process.on("SIGINT", shutdown);
@@ -7735,22 +7865,22 @@ async function devCommand(opts) {
7735
7865
  if (pendingR) {
7736
7866
  pendingR = false;
7737
7867
  if (key === "a") {
7738
- console.log(import_picocolors17.default.magenta("\n Restarting API...\n"));
7868
+ console.log(import_picocolors18.default.magenta("\n Restarting API...\n"));
7739
7869
  await killProcess(apiProc);
7740
7870
  apiProc = startApi();
7741
7871
  printControls();
7742
7872
  } else if (key === "w") {
7743
- console.log(import_picocolors17.default.cyan("\n Restarting Web...\n"));
7873
+ console.log(import_picocolors18.default.cyan("\n Restarting Web...\n"));
7744
7874
  await killProcess(webProc);
7745
7875
  webProc = startWeb();
7746
7876
  printControls();
7747
7877
  } else if (key === "c") {
7748
- console.log(import_picocolors17.default.yellow("\n Restarting Collab...\n"));
7878
+ console.log(import_picocolors18.default.yellow("\n Restarting Collab...\n"));
7749
7879
  await killProcess(collabProc);
7750
7880
  collabProc = startCollab();
7751
7881
  printControls();
7752
7882
  } else if (key === "b") {
7753
- console.log(import_picocolors17.default.yellow("\n Restarting all...\n"));
7883
+ console.log(import_picocolors18.default.yellow("\n Restarting all...\n"));
7754
7884
  await Promise.all([killProcess(apiProc), killProcess(webProc), killProcess(collabProc)]);
7755
7885
  apiProc = startApi();
7756
7886
  webProc = startWeb();
@@ -7768,7 +7898,7 @@ async function devCommand(opts) {
7768
7898
  import { execSync as execSync6 } from "child_process";
7769
7899
  import { readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "fs";
7770
7900
  import { join as join3 } from "path";
7771
- var import_picocolors18 = __toESM(require_picocolors(), 1);
7901
+ var import_picocolors19 = __toESM(require_picocolors(), 1);
7772
7902
  var GHCR_BASE2 = "ghcr.io/learnhouse/app";
7773
7903
  async function resolveTag(version) {
7774
7904
  try {
@@ -7802,9 +7932,9 @@ async function updateCommand(options) {
7802
7932
  }
7803
7933
  const targetVersion = options.version?.replace(/^v/, "");
7804
7934
  if (targetVersion) {
7805
- We(import_picocolors18.default.cyan(`Updating LearnHouse to v${targetVersion}`));
7935
+ We(import_picocolors19.default.cyan(`Updating LearnHouse to v${targetVersion}`));
7806
7936
  } else {
7807
- We(import_picocolors18.default.cyan("Updating LearnHouse to latest"));
7937
+ We(import_picocolors19.default.cyan("Updating LearnHouse to latest"));
7808
7938
  }
7809
7939
  const s = bt2();
7810
7940
  try {
@@ -7850,10 +7980,10 @@ async function updateCommand(options) {
7850
7980
  } else {
7851
7981
  R2.info("");
7852
7982
  R2.warn(
7853
- import_picocolors18.default.bold("This update may include database migrations.")
7983
+ import_picocolors19.default.bold("This update may include database migrations.")
7854
7984
  );
7855
7985
  R2.info(
7856
- `Before proceeding, check the release notes at ${import_picocolors18.default.cyan("https://docs.learnhouse.app")} for migration guides and breaking changes.`
7986
+ `Before proceeding, check the release notes at ${import_picocolors19.default.cyan("https://docs.learnhouse.app")} for migration guides and breaking changes.`
7857
7987
  );
7858
7988
  R2.info("");
7859
7989
  const runMigrations = await Re({
@@ -7943,7 +8073,7 @@ function waitForContainer(containerName, timeoutMs = 6e4) {
7943
8073
  }
7944
8074
 
7945
8075
  // src/commands/status.ts
7946
- var import_picocolors19 = __toESM(require_picocolors(), 1);
8076
+ var import_picocolors20 = __toESM(require_picocolors(), 1);
7947
8077
  async function statusCommand() {
7948
8078
  const dir = findInstallDir();
7949
8079
  const config = readConfig(dir);
@@ -7951,7 +8081,7 @@ async function statusCommand() {
7951
8081
  R2.error("No LearnHouse installation found. Run `npx learnhouse setup` first.");
7952
8082
  process.exit(1);
7953
8083
  }
7954
- We(import_picocolors19.default.cyan("LearnHouse Status"));
8084
+ We(import_picocolors20.default.cyan("LearnHouse Status"));
7955
8085
  const protocol = config.useHttps ? "https" : "http";
7956
8086
  const portSuffix = config.useHttps && config.httpPort === 443 || !config.useHttps && config.httpPort === 80 ? "" : `:${config.httpPort}`;
7957
8087
  R2.info(`URL: ${protocol}://${config.domain}${portSuffix}`);
@@ -7965,12 +8095,12 @@ async function statusCommand() {
7965
8095
  }
7966
8096
 
7967
8097
  // src/commands/health.ts
7968
- var import_picocolors20 = __toESM(require_picocolors(), 1);
8098
+ var import_picocolors21 = __toESM(require_picocolors(), 1);
7969
8099
  function pass2(msg) {
7970
- return `${import_picocolors20.default.green("\u25CF")} ${msg}`;
8100
+ return `${import_picocolors21.default.green("\u25CF")} ${msg}`;
7971
8101
  }
7972
8102
  function fail2(msg) {
7973
- return `${import_picocolors20.default.red("\u25CF")} ${msg}`;
8103
+ return `${import_picocolors21.default.red("\u25CF")} ${msg}`;
7974
8104
  }
7975
8105
  async function healthCommand() {
7976
8106
  const dir = findInstallDir();
@@ -7979,7 +8109,7 @@ async function healthCommand() {
7979
8109
  R2.error("No LearnHouse installation found. Run setup first.");
7980
8110
  process.exit(1);
7981
8111
  }
7982
- We(import_picocolors20.default.cyan("LearnHouse Health Check"));
8112
+ We(import_picocolors21.default.cyan("LearnHouse Health Check"));
7983
8113
  const id = config.deploymentId || autoDetectDeploymentId();
7984
8114
  if (!id) {
7985
8115
  R2.error("No deployment found. Start services first.");
@@ -8039,20 +8169,20 @@ async function healthCommand() {
8039
8169
  R2.step("Disk Usage");
8040
8170
  try {
8041
8171
  const diskOutput = getDockerDiskUsage();
8042
- R2.message(import_picocolors20.default.dim(diskOutput.trim()));
8172
+ R2.message(import_picocolors21.default.dim(diskOutput.trim()));
8043
8173
  } catch {
8044
8174
  R2.message(fail2("Could not retrieve disk usage"));
8045
8175
  }
8046
8176
  R2.step("Resource Usage");
8047
8177
  try {
8048
8178
  const stats = dockerStats(config.installDir);
8049
- R2.message(import_picocolors20.default.dim(stats.trim()));
8179
+ R2.message(import_picocolors21.default.dim(stats.trim()));
8050
8180
  } catch {
8051
8181
  try {
8052
8182
  const names = containers.filter((c) => c.status.toLowerCase().startsWith("up")).map((c) => c.name);
8053
8183
  if (names.length > 0) {
8054
8184
  const stats = dockerStatsForContainers(names);
8055
- R2.message(import_picocolors20.default.dim(stats.trim()));
8185
+ R2.message(import_picocolors21.default.dim(stats.trim()));
8056
8186
  } else {
8057
8187
  R2.message(fail2("No running containers to get stats from"));
8058
8188
  }
@@ -8060,13 +8190,13 @@ async function healthCommand() {
8060
8190
  R2.message(fail2("Could not retrieve resource stats"));
8061
8191
  }
8062
8192
  }
8063
- Le(import_picocolors20.default.dim("Health check complete"));
8193
+ Le(import_picocolors21.default.dim("Health check complete"));
8064
8194
  }
8065
8195
 
8066
8196
  // src/commands/env.ts
8067
8197
  import fs8 from "fs";
8068
8198
  import path8 from "path";
8069
- var import_picocolors21 = __toESM(require_picocolors(), 1);
8199
+ var import_picocolors22 = __toESM(require_picocolors(), 1);
8070
8200
  var SECRET_PATTERNS = ["PASSWORD", "SECRET", "API_KEY", "CLIENT_SECRET"];
8071
8201
  var CATEGORIES = {
8072
8202
  domain: {
@@ -8192,7 +8322,7 @@ async function envCommand() {
8192
8322
  R2.error(`No .env file found at ${envPath}`);
8193
8323
  process.exit(1);
8194
8324
  }
8195
- We(import_picocolors21.default.cyan("LearnHouse Environment Editor"));
8325
+ We(import_picocolors22.default.cyan("LearnHouse Environment Editor"));
8196
8326
  const originalContent = fs8.readFileSync(envPath, "utf-8");
8197
8327
  const envMap = parseEnv(originalContent);
8198
8328
  let editing = true;
@@ -8201,7 +8331,7 @@ async function envCommand() {
8201
8331
  message: "Select a category to edit",
8202
8332
  options: [
8203
8333
  ...Object.entries(CATEGORIES).map(([value, { label }]) => ({ value, label })),
8204
- { value: "_done", label: import_picocolors21.default.dim("Done editing") }
8334
+ { value: "_done", label: import_picocolors22.default.dim("Done editing") }
8205
8335
  ]
8206
8336
  });
8207
8337
  if (Ct(category) || category === "_done") {
@@ -8217,14 +8347,14 @@ async function envCommand() {
8217
8347
  }
8218
8348
  R2.step(`${cat.label} \u2014 Current Values`);
8219
8349
  for (const key2 of presentKeys) {
8220
- R2.message(` ${import_picocolors21.default.dim(key2)} = ${maskValue(key2, envMap.get(key2))}`);
8350
+ R2.message(` ${import_picocolors22.default.dim(key2)} = ${maskValue(key2, envMap.get(key2))}`);
8221
8351
  }
8222
8352
  const keyToEdit = await Je({
8223
8353
  message: "Select a variable to edit",
8224
8354
  options: [
8225
8355
  ...presentKeys.map((k2) => ({ value: k2, label: `${k2} = ${maskValue(k2, envMap.get(k2))}` })),
8226
- ...missingKeys.map((k2) => ({ value: k2, label: `${k2} ${import_picocolors21.default.dim("(not set)")}` })),
8227
- { value: "_back", label: import_picocolors21.default.dim("Back") }
8356
+ ...missingKeys.map((k2) => ({ value: k2, label: `${k2} ${import_picocolors22.default.dim("(not set)")}` })),
8357
+ { value: "_back", label: import_picocolors22.default.dim("Back") }
8228
8358
  ]
8229
8359
  });
8230
8360
  if (Ct(keyToEdit) || keyToEdit === "_back") continue;
@@ -8262,14 +8392,14 @@ async function envCommand() {
8262
8392
  } else {
8263
8393
  R2.info("No changes made.");
8264
8394
  }
8265
- Le(import_picocolors21.default.dim("Done"));
8395
+ Le(import_picocolors22.default.dim("Done"));
8266
8396
  }
8267
8397
 
8268
8398
  // src/commands/restore.ts
8269
8399
  import fs9 from "fs";
8270
8400
  import path9 from "path";
8271
8401
  import { execSync as execSync7 } from "child_process";
8272
- var import_picocolors22 = __toESM(require_picocolors(), 1);
8402
+ var import_picocolors23 = __toESM(require_picocolors(), 1);
8273
8403
  async function restoreCommand(archivePath) {
8274
8404
  if (!archivePath) {
8275
8405
  R2.error("Please provide the path to a backup archive.");
@@ -8301,7 +8431,7 @@ async function restoreCommand(archivePath) {
8301
8431
  R2.error("Database container is not running. Start services first.");
8302
8432
  process.exit(1);
8303
8433
  }
8304
- R2.warn(import_picocolors22.default.yellow("This will overwrite the current database with the backup data."));
8434
+ R2.warn(import_picocolors23.default.yellow("This will overwrite the current database with the backup data."));
8305
8435
  const confirm = await Re({
8306
8436
  message: "Are you sure you want to restore from this backup?",
8307
8437
  initialValue: false
@@ -8360,7 +8490,7 @@ async function restoreCommand(archivePath) {
8360
8490
  }
8361
8491
  }
8362
8492
  fs9.rmSync(tmpDir, { recursive: true, force: true });
8363
- R2.success(import_picocolors22.default.green(import_picocolors22.default.bold("Restore complete!")));
8493
+ R2.success(import_picocolors23.default.green(import_picocolors23.default.bold("Restore complete!")));
8364
8494
  R2.info("You may want to restart services: npx learnhouse stop && npx learnhouse start");
8365
8495
  }
8366
8496
 
@@ -8384,18 +8514,18 @@ var COMMANDS = [
8384
8514
  ];
8385
8515
  async function showWelcome() {
8386
8516
  await printBanner();
8387
- console.log(import_picocolors23.default.bold(import_picocolors23.default.white(" Available commands:\n")));
8517
+ console.log(import_picocolors24.default.bold(import_picocolors24.default.white(" Available commands:\n")));
8388
8518
  for (const cmd of COMMANDS) {
8389
- console.log(` ${import_picocolors23.default.cyan(cmd.name.padEnd(14))} ${import_picocolors23.default.dim(cmd.desc)}`);
8519
+ console.log(` ${import_picocolors24.default.cyan(cmd.name.padEnd(14))} ${import_picocolors24.default.dim(cmd.desc)}`);
8390
8520
  }
8391
8521
  console.log();
8392
- console.log(import_picocolors23.default.dim(" Run a command with: npx learnhouse <command>"));
8393
- console.log(import_picocolors23.default.dim(" Get started with: npx learnhouse setup"));
8522
+ console.log(import_picocolors24.default.dim(" Run a command with: npx learnhouse <command>"));
8523
+ console.log(import_picocolors24.default.dim(" Get started with: npx learnhouse setup"));
8394
8524
  console.log();
8395
8525
  }
8396
8526
  var program2 = new Command();
8397
8527
  program2.name("learnhouse").description("The official LearnHouse CLI \u2014 deploy, manage, and operate your LearnHouse instance").version(VERSION).action(showWelcome);
8398
- program2.command("setup").description("Interactive setup wizard for LearnHouse").option("--ci", "Non-interactive mode with defaults (for CI/automation)").option("--name <name>", 'Installation name (default: "default")').option("--domain <domain>", 'Domain name (default: "localhost")').option("--port <port>", "HTTP port (default: 80)", parseInt).option("--admin-email <email>", 'Admin email (default: "admin@school.dev")').option("--admin-password <password>", "Admin password (required in --ci mode)").option("--channel <channel>", 'Release channel: stable or dev (default: "stable")').option("--no-start", "Skip starting services after setup").action(setupCommand);
8528
+ program2.command("setup").description("Interactive setup wizard for LearnHouse").option("--ci", "Non-interactive mode with defaults (for CI/automation)").option("--name <name>", 'Installation name (default: "default")').option("--domain <domain>", 'Domain name (default: "localhost")').option("--port <port>", "HTTP port (default: 80)", parseInt).option("--admin-email <email>", 'Admin email (default: "admin@school.dev")').option("--admin-password <password>", "Admin password (required in --ci mode)").option("--org-name <name>", 'Organization display name (default: "Default Organization")').option("--org-slug <slug>", 'Organization slug used in URLs (default: "default")').option("--channel <channel>", 'Release channel: stable or dev (default: "stable")').option("--no-start", "Skip starting services after setup").action(setupCommand);
8399
8529
  program2.command("start").description("Start LearnHouse services").action(startCommand);
8400
8530
  program2.command("stop").description("Stop LearnHouse services").action(stopCommand);
8401
8531
  program2.command("logs").description("Stream logs from LearnHouse services").action(logsCommand);