@kombai/cli 0.1.1 → 0.1.2-beta.2

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/kombai.mjs CHANGED
@@ -613,9 +613,9 @@ var init_env = __esm({
613
613
  preprod: { api: "https://api.assistant.preprod.kombai.com", web: "https://agent.preprod.kombai.com" },
614
614
  prod: { api: "https://api.assistant.app.kombai.com", web: "https://agent.kombai.com" }
615
615
  });
616
- DEFAULT_ENV = Object.hasOwn(ENVIRONMENTS, "prod") ? (
616
+ DEFAULT_ENV = Object.hasOwn(ENVIRONMENTS, "dev") ? (
617
617
  /** @type {EnvName} */
618
- "prod"
618
+ "dev"
619
619
  ) : "prod";
620
620
  }
621
621
  });
@@ -818,11 +818,11 @@ var init_version = __esm({
818
818
  "src/lib/version.js"() {
819
819
  "use strict";
820
820
  init_define_KOMBAI_TELEMETRY();
821
- CLI_VERSION = true ? "0.1.1" : (
821
+ CLI_VERSION = true ? "0.1.2-beta.2" : (
822
822
  /** @type {{ version: string }} */
823
823
  JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8")).version
824
824
  );
825
- CLI_RUN = true ? "npx -y @kombai/cli@latest" : "npx -y @kombai/cli@latest";
825
+ CLI_RUN = true ? "npx -y @kombai/cli@next" : "npx -y @kombai/cli@latest";
826
826
  }
827
827
  });
828
828
 
@@ -849,7 +849,7 @@ function retryAfterMs(value) {
849
849
  const at = Date.parse(value ?? "");
850
850
  return Number.isFinite(at) ? Math.max(0, at - Date.now()) : 2e3;
851
851
  }
852
- function apiError(status, body, method, path22) {
852
+ function apiError(status, body, method, path23) {
853
853
  const {
854
854
  errorCode,
855
855
  apiMessage,
@@ -863,7 +863,7 @@ function apiError(status, body, method, path22) {
863
863
  ...extras
864
864
  };
865
865
  const code2 = typeof errorCode === "string" ? errorCode : `HTTP_${status}`;
866
- const message = code2 === "DESIGN_NOT_FOUND" && rest.what === "canvas" ? PRIVATE_CANVAS : typeof apiMessage === "string" && apiMessage ? apiMessage : `${method} ${path22} answered ${status}.`;
866
+ const message = code2 === "DESIGN_NOT_FOUND" && rest.what === "canvas" ? PRIVATE_CANVAS : typeof apiMessage === "string" && apiMessage ? apiMessage : `${method} ${path23} answered ${status}.`;
867
867
  const guestRow = GUEST_ERRORS[code2];
868
868
  const needsLogin = status === 401 || guestRow !== void 0;
869
869
  const text = guestRow?.message?.(rest, typeof apiMessage === "string" ? apiMessage : "") ?? message;
@@ -874,8 +874,8 @@ function apiError(status, body, method, path22) {
874
874
  details: Object.keys(rest).length ? rest : void 0
875
875
  });
876
876
  }
877
- function timedOut(method, path22) {
878
- return new CliError("CLI_TIMEOUT", `The command's deadline passed during ${method} ${path22}.`, {
877
+ function timedOut(method, path23) {
878
+ return new CliError("CLI_TIMEOUT", `The command's deadline passed during ${method} ${path23}.`, {
879
879
  exit: Exit.TIMED_OUT
880
880
  });
881
881
  }
@@ -910,10 +910,10 @@ var init_api = __esm({
910
910
  * @param {string} path
911
911
  * @param {number | undefined} status
912
912
  */
913
- constructor(method, path22, status) {
914
- super("CLI_NETWORK", `${method} ${path22} got no usable answer${status ? ` (${status})` : ""}.`, {
913
+ constructor(method, path23, status) {
914
+ super("CLI_NETWORK", `${method} ${path23} got no usable answer${status ? ` (${status})` : ""}.`, {
915
915
  status,
916
- details: { method, path: path22 }
916
+ details: { method, path: path23 }
917
917
  });
918
918
  this.lost = true;
919
919
  }
@@ -948,9 +948,9 @@ var init_api = __esm({
948
948
  * @returns {Promise<ApiResponse>}
949
949
  */
950
950
  async call(options) {
951
- const { method, path: path22, retry = "safe" } = options;
951
+ const { method, path: path23, retry = "safe" } = options;
952
952
  const deadline = options.deadline ?? this.deadline;
953
- const url2 = `${this.baseUrl}${path22}${queryString(options.query)}`;
953
+ const url2 = `${this.baseUrl}${path23}${queryString(options.query)}`;
954
954
  const headers = {
955
955
  "x-kombai-cli": this.ctx.version,
956
956
  "x-type": "agent",
@@ -964,7 +964,7 @@ var init_api = __esm({
964
964
  let lostTries = 0;
965
965
  for (; ; ) {
966
966
  const limit = deadline.clamp(CALL_LIMIT_MS);
967
- if (limit <= 0) throw timedOut(method, path22);
967
+ if (limit <= 0) throw timedOut(method, path23);
968
968
  let res;
969
969
  if (method !== "GET") this.ctx.changeSent = true;
970
970
  try {
@@ -978,12 +978,12 @@ var init_api = __esm({
978
978
  } catch (error3) {
979
979
  const blocked = blockedRequest(this.ctx.sandbox, error3);
980
980
  if (blocked) throw blocked;
981
- if (deadline.expired()) throw timedOut(method, path22);
981
+ if (deadline.expired()) throw timedOut(method, path23);
982
982
  if (retry === "safe" && lostTries < LOST_ANSWER_BACKOFF_MS.length) {
983
- await this.wait(LOST_ANSWER_BACKOFF_MS[lostTries++], deadline, method, path22);
983
+ await this.wait(LOST_ANSWER_BACKOFF_MS[lostTries++], deadline, method, path23);
984
984
  continue;
985
985
  }
986
- throw new LostAnswer(method, path22, void 0);
986
+ throw new LostAnswer(method, path23, void 0);
987
987
  }
988
988
  this.checkContractVersion(res.headers);
989
989
  const parsed = await readBody(res);
@@ -997,17 +997,17 @@ var init_api = __esm({
997
997
  }
998
998
  if (UNKNOWN_OUTCOME_STATUSES.has(res.status)) {
999
999
  if (retry === "safe" && lostTries < LOST_ANSWER_BACKOFF_MS.length) {
1000
- await this.wait(LOST_ANSWER_BACKOFF_MS[lostTries++], deadline, method, path22);
1000
+ await this.wait(LOST_ANSWER_BACKOFF_MS[lostTries++], deadline, method, path23);
1001
1001
  continue;
1002
1002
  }
1003
- if (retry === "once") throw new LostAnswer(method, path22, res.status);
1003
+ if (retry === "once") throw new LostAnswer(method, path23, res.status);
1004
1004
  }
1005
1005
  if (res.ok) {
1006
1006
  if (headers["x-kombai-guest"] && parsed?.guest === true && typeof parsed.guestExpiresAt === "string")
1007
1007
  await this.onGuestExpires?.(parsed.guestExpiresAt);
1008
1008
  return { status: res.status, body: parsed, headers: res.headers };
1009
1009
  }
1010
- const error2 = apiError(res.status, parsed, method, path22);
1010
+ const error2 = apiError(res.status, parsed, method, path23);
1011
1011
  if (res.status === 503 && res.headers.has("retry-after")) {
1012
1012
  error2.details = { ...error2.details, retryAfter: res.headers.get("retry-after") };
1013
1013
  }
@@ -1092,8 +1092,8 @@ var init_api = __esm({
1092
1092
  * @param {string} method
1093
1093
  * @param {string} path
1094
1094
  */
1095
- async wait(ms, deadline, method, path22) {
1096
- if (deadline.remaining() <= ms) throw timedOut(method, path22);
1095
+ async wait(ms, deadline, method, path23) {
1096
+ if (deadline.remaining() <= ms) throw timedOut(method, path23);
1097
1097
  await this.ctx.sleep(ms);
1098
1098
  }
1099
1099
  /** @param {Headers} headers */
@@ -1252,7 +1252,8 @@ function storePaths(home) {
1252
1252
  credentialsLock: path4.join(home, "credentials.lock"),
1253
1253
  browser: path4.join(home, "browser"),
1254
1254
  render: path4.join(home, "render"),
1255
- claims: path4.join(home, "claims")
1255
+ claims: path4.join(home, "claims"),
1256
+ appSkillsRemoved: path4.join(home, "app-skills-removed")
1256
1257
  };
1257
1258
  }
1258
1259
  async function readRecord(file2, after) {
@@ -2504,6 +2505,10 @@ var init_asset = __esm({
2504
2505
 
2505
2506
  // src/commands/auth.js
2506
2507
  import { constants, generateKeyPairSync, privateDecrypt, randomBytes as randomBytes4 } from "node:crypto";
2508
+ function loginBudgetMs(expiresAt, serverDate) {
2509
+ const budget = Date.parse(expiresAt) - Date.parse(serverDate ?? "");
2510
+ return Number.isFinite(budget) ? budget : LOGIN_WINDOW_MS;
2511
+ }
2507
2512
  async function claimGuest(ctx, env) {
2508
2513
  if (!await readGuest(ctx.home, env)) return {};
2509
2514
  const outcome = await settleClaim(ctx, await openSession(ctx, { claim: false }));
@@ -2571,7 +2576,7 @@ function loginExpired() {
2571
2576
  next: "kombai login"
2572
2577
  });
2573
2578
  }
2574
- var REUSE_KEY_MS, POLL_MS2, RSA_BITS, login, logout, whoami, guest, claim;
2579
+ var REUSE_KEY_MS, POLL_MS2, RSA_BITS, LOGIN_WINDOW_MS, login, logout, whoami, guest, claim;
2575
2580
  var init_auth = __esm({
2576
2581
  "src/commands/auth.js"() {
2577
2582
  "use strict";
@@ -2588,6 +2593,7 @@ var init_auth = __esm({
2588
2593
  REUSE_KEY_MS = 3 * 24 * 60 * 60 * 1e3;
2589
2594
  POLL_MS2 = 2e3;
2590
2595
  RSA_BITS = 3072;
2596
+ LOGIN_WINDOW_MS = 6e5;
2591
2597
  login = {
2592
2598
  name: "login",
2593
2599
  summary: "Sign in through the browser. Prints a waiting line with a match code at once, then the signed-in line. A key with more than 3 days left is reused. With a guest token here, it then claims the guest canvas into the account.",
@@ -2606,6 +2612,7 @@ var init_auth = __esm({
2606
2612
  const { publicKey, privateKey } = generateKeyPairSync("rsa", { modulusLength: RSA_BITS });
2607
2613
  const api = new ApiClient({ ctx, baseUrl: hosts.api, key: null, deadline: new Deadline(null, ctx.now) });
2608
2614
  let started;
2615
+ let serverDate;
2609
2616
  try {
2610
2617
  const res = await api.call({
2611
2618
  method: "POST",
@@ -2621,7 +2628,11 @@ var init_auth = __esm({
2621
2628
  cliVersion: ctx.version
2622
2629
  }
2623
2630
  });
2624
- started = res.body;
2631
+ const b = res.body;
2632
+ if (!b || typeof b.code !== "string" || typeof b.matchCode !== "string" || typeof b.approveUrl !== "string" || !b.approveUrl.startsWith(`${hosts.web}/`) || !Number.isFinite(Date.parse(b.expiresAt)))
2633
+ throw new CliError("CLI_BAD_ANSWER", "The sign-in answer was not a login code.", { next: "kombai login" });
2634
+ started = b;
2635
+ serverDate = res.headers.get("date");
2625
2636
  } catch (error2) {
2626
2637
  if (error2 instanceof LostAnswer) error2.next = "kombai login";
2627
2638
  throw error2;
@@ -2633,7 +2644,7 @@ var init_auth = __esm({
2633
2644
  expiresAt: started.expiresAt
2634
2645
  });
2635
2646
  if (!flags["no-browser"] && ctx.hasDisplay) await ctx.openUrl(started.approveUrl);
2636
- const deadline = new Deadline(Date.parse(started.expiresAt) - ctx.now(), ctx.now);
2647
+ const deadline = new Deadline(loginBudgetMs(started.expiresAt, serverDate), ctx.now);
2637
2648
  for (; ; ) {
2638
2649
  let answer2;
2639
2650
  try {
@@ -4044,15 +4055,15 @@ function toWSLPath(dir, fallback) {
4044
4055
  return fallback;
4045
4056
  }
4046
4057
  }
4047
- function getLocalAppDataPath(path22) {
4058
+ function getLocalAppDataPath(path23) {
4048
4059
  const userRegExp = /\/mnt\/([a-z])\/Users\/([^\/:]+)\/AppData\//;
4049
- const results = userRegExp.exec(path22) || [];
4060
+ const results = userRegExp.exec(path23) || [];
4050
4061
  return `/mnt/${results[1]}/Users/${results[2]}/AppData/Local`;
4051
4062
  }
4052
- function getWSLLocalAppDataPath(path22) {
4063
+ function getWSLLocalAppDataPath(path23) {
4053
4064
  const userRegExp = /\/([a-z])\/Users\/([^\/:]+)\/AppData\//;
4054
- const results = userRegExp.exec(path22) || [];
4055
- return toWSLPath(`${results[1]}:\\Users\\${results[2]}\\AppData\\Local`, getLocalAppDataPath(path22));
4065
+ const results = userRegExp.exec(path23) || [];
4066
+ return toWSLPath(`${results[1]}:\\Users\\${results[2]}\\AppData\\Local`, getLocalAppDataPath(path23));
4056
4067
  }
4057
4068
  function makeUnixTmpDir() {
4058
4069
  return childProcess.execSync("mktemp -d -t lighthouse.XXXXXXX").toString().trim();
@@ -4701,7 +4712,7 @@ var require_windows = __commonJS({
4701
4712
  module.exports = isexe;
4702
4713
  isexe.sync = sync;
4703
4714
  var fs19 = __require("fs");
4704
- function checkPathExt(path22, options) {
4715
+ function checkPathExt(path23, options) {
4705
4716
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
4706
4717
  if (!pathext) {
4707
4718
  return true;
@@ -4712,25 +4723,25 @@ var require_windows = __commonJS({
4712
4723
  }
4713
4724
  for (var i = 0; i < pathext.length; i++) {
4714
4725
  var p = pathext[i].toLowerCase();
4715
- if (p && path22.substr(-p.length).toLowerCase() === p) {
4726
+ if (p && path23.substr(-p.length).toLowerCase() === p) {
4716
4727
  return true;
4717
4728
  }
4718
4729
  }
4719
4730
  return false;
4720
4731
  }
4721
- function checkStat(stat, path22, options) {
4732
+ function checkStat(stat, path23, options) {
4722
4733
  if (!stat.isSymbolicLink() && !stat.isFile()) {
4723
4734
  return false;
4724
4735
  }
4725
- return checkPathExt(path22, options);
4736
+ return checkPathExt(path23, options);
4726
4737
  }
4727
- function isexe(path22, options, cb) {
4728
- fs19.stat(path22, function(er, stat) {
4729
- cb(er, er ? false : checkStat(stat, path22, options));
4738
+ function isexe(path23, options, cb) {
4739
+ fs19.stat(path23, function(er, stat) {
4740
+ cb(er, er ? false : checkStat(stat, path23, options));
4730
4741
  });
4731
4742
  }
4732
- function sync(path22, options) {
4733
- return checkStat(fs19.statSync(path22), path22, options);
4743
+ function sync(path23, options) {
4744
+ return checkStat(fs19.statSync(path23), path23, options);
4734
4745
  }
4735
4746
  }
4736
4747
  });
@@ -4742,13 +4753,13 @@ var require_mode = __commonJS({
4742
4753
  module.exports = isexe;
4743
4754
  isexe.sync = sync;
4744
4755
  var fs19 = __require("fs");
4745
- function isexe(path22, options, cb) {
4746
- fs19.stat(path22, function(er, stat) {
4756
+ function isexe(path23, options, cb) {
4757
+ fs19.stat(path23, function(er, stat) {
4747
4758
  cb(er, er ? false : checkStat(stat, options));
4748
4759
  });
4749
4760
  }
4750
- function sync(path22, options) {
4751
- return checkStat(fs19.statSync(path22), options);
4761
+ function sync(path23, options) {
4762
+ return checkStat(fs19.statSync(path23), options);
4752
4763
  }
4753
4764
  function checkStat(stat, options) {
4754
4765
  return stat.isFile() && checkMode(stat, options);
@@ -4782,7 +4793,7 @@ var require_isexe = __commonJS({
4782
4793
  }
4783
4794
  module.exports = isexe;
4784
4795
  isexe.sync = sync;
4785
- function isexe(path22, options, cb) {
4796
+ function isexe(path23, options, cb) {
4786
4797
  if (typeof options === "function") {
4787
4798
  cb = options;
4788
4799
  options = {};
@@ -4792,7 +4803,7 @@ var require_isexe = __commonJS({
4792
4803
  throw new TypeError("callback not provided");
4793
4804
  }
4794
4805
  return new Promise(function(resolve, reject) {
4795
- isexe(path22, options || {}, function(er, is) {
4806
+ isexe(path23, options || {}, function(er, is) {
4796
4807
  if (er) {
4797
4808
  reject(er);
4798
4809
  } else {
@@ -4801,7 +4812,7 @@ var require_isexe = __commonJS({
4801
4812
  });
4802
4813
  });
4803
4814
  }
4804
- core(path22, options || {}, function(er, is) {
4815
+ core(path23, options || {}, function(er, is) {
4805
4816
  if (er) {
4806
4817
  if (er.code === "EACCES" || options && options.ignoreErrors) {
4807
4818
  er = null;
@@ -4811,9 +4822,9 @@ var require_isexe = __commonJS({
4811
4822
  cb(er, is);
4812
4823
  });
4813
4824
  }
4814
- function sync(path22, options) {
4825
+ function sync(path23, options) {
4815
4826
  try {
4816
- return core.sync(path22, options || {});
4827
+ return core.sync(path23, options || {});
4817
4828
  } catch (er) {
4818
4829
  if (options && options.ignoreErrors || er.code === "EACCES") {
4819
4830
  return false;
@@ -4830,7 +4841,7 @@ var require_which = __commonJS({
4830
4841
  "../../node_modules/which/which.js"(exports, module) {
4831
4842
  init_define_KOMBAI_TELEMETRY();
4832
4843
  var isWindows3 = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
4833
- var path22 = __require("path");
4844
+ var path23 = __require("path");
4834
4845
  var COLON = isWindows3 ? ";" : ":";
4835
4846
  var isexe = require_isexe();
4836
4847
  var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
@@ -4868,7 +4879,7 @@ var require_which = __commonJS({
4868
4879
  return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
4869
4880
  const ppRaw = pathEnv[i];
4870
4881
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
4871
- const pCmd = path22.join(pathPart, cmd);
4882
+ const pCmd = path23.join(pathPart, cmd);
4872
4883
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
4873
4884
  resolve(subStep(p, i, 0));
4874
4885
  });
@@ -4895,7 +4906,7 @@ var require_which = __commonJS({
4895
4906
  for (let i = 0; i < pathEnv.length; i++) {
4896
4907
  const ppRaw = pathEnv[i];
4897
4908
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
4898
- const pCmd = path22.join(pathPart, cmd);
4909
+ const pCmd = path23.join(pathPart, cmd);
4899
4910
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
4900
4911
  for (let j = 0; j < pathExt.length; j++) {
4901
4912
  const cur = p + pathExt[j];
@@ -4927,8 +4938,8 @@ import { existsSync } from "fs";
4927
4938
  import path10 from "path";
4928
4939
  function getEdgeLinux(name) {
4929
4940
  try {
4930
- let path22 = import_which.default.sync(name);
4931
- return path22;
4941
+ let path23 = import_which.default.sync(name);
4942
+ return path23;
4932
4943
  } catch (e) {
4933
4944
  }
4934
4945
  return null;
@@ -5194,7 +5205,7 @@ var init_browser = __esm({
5194
5205
  });
5195
5206
 
5196
5207
  // ../design-mode/packages/shared/src/tailwind-script.ts
5197
- var TAILWIND_BROWSER_PATH, TAILWIND_BROWSER_VERSION, TAILWIND_BROWSER_ROUTE, TAILWIND_SCRIPT_TAG, TAILWIND_CDN_SRI, TAILWIND_CDN_SCRIPT_TAG, TAILWIND_PROBE_ATTR, TAILWIND_PROBE_HTML;
5208
+ var TAILWIND_BROWSER_PATH, TAILWIND_BROWSER_VERSION, TAILWIND_BROWSER_ROUTE, TAILWIND_SCRIPT_TAG, TAILWIND_PROBE_ATTR, TAILWIND_PROBE_HTML;
5198
5209
  var init_tailwind_script = __esm({
5199
5210
  "../design-mode/packages/shared/src/tailwind-script.ts"() {
5200
5211
  "use strict";
@@ -5203,24 +5214,113 @@ var init_tailwind_script = __esm({
5203
5214
  TAILWIND_BROWSER_VERSION = "4.3.3";
5204
5215
  TAILWIND_BROWSER_ROUTE = `${TAILWIND_BROWSER_PATH}?v=${TAILWIND_BROWSER_VERSION}`;
5205
5216
  TAILWIND_SCRIPT_TAG = `<script src="${TAILWIND_BROWSER_ROUTE}"></script>`;
5206
- TAILWIND_CDN_SRI = "sha384-2ql948lIdLcGEE0/qxNiudyTjgauA3RDJERu5xW75kFCvSl5a9odyQYCb6tEjnmB";
5207
- TAILWIND_CDN_SCRIPT_TAG = `<script src="https://unpkg.com/@tailwindcss/browser@${TAILWIND_BROWSER_VERSION}/dist/index.global.js" integrity="${TAILWIND_CDN_SRI}" crossorigin="anonymous"></script>`;
5208
5217
  TAILWIND_PROBE_ATTR = "data-kombai-tw-probe";
5209
5218
  TAILWIND_PROBE_HTML = `<div ${TAILWIND_PROBE_ATTR} class="flex" style="position:absolute;top:0;left:0;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none"></div>`;
5210
5219
  }
5211
5220
  });
5212
5221
 
5222
+ // ../design-mode/packages/shared/src/tailwind-detection.ts
5223
+ function withoutScripts(html) {
5224
+ return html.replace(
5225
+ RAW_ELEMENTS,
5226
+ (element, name) => name.toLowerCase() === "script" ? "" : element
5227
+ );
5228
+ }
5229
+ function attribute(attrs, name) {
5230
+ const match = new RegExp(`(?:^|\\s)${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i").exec(attrs);
5231
+ return match?.[1] ?? match?.[2] ?? match?.[3] ?? "";
5232
+ }
5233
+ function hasTailwindRuntime(html) {
5234
+ const clean = html.replace(/<!--[\s\S]*?(?:-->|$)/g, "").replace(RAW_ELEMENTS, (element, name) => name.toLowerCase() === "style" ? "" : element);
5235
+ for (const match of clean.matchAll(/<script\b((?:"[^"]*"|'[^']*'|[^'">])*)>([\s\S]*?)(?:<\/script\s*>|$)/gi)) {
5236
+ if (attribute(match[1] ?? "", TAILWIND_RELAY_ATTR) === "true") return true;
5237
+ if (RUNTIME_URL.test(attribute(match[1] ?? "", "src")) || RUNTIME_URL.test(match[2] ?? "")) return true;
5238
+ }
5239
+ return false;
5240
+ }
5241
+ function hasCompiledTailwind(html) {
5242
+ const clean = withoutScripts(html.replace(/<!--[\s\S]*?(?:-->|$)/g, ""));
5243
+ const markup = clean.replace(RAW_ELEMENTS, "");
5244
+ for (const match of markup.matchAll(/<link\b((?:"[^"]*"|'[^']*'|[^'">])*)>/gi)) {
5245
+ if (COMPILED_URL.test(attribute(match[1] ?? "", "href"))) return true;
5246
+ }
5247
+ for (const match of clean.matchAll(/<style\b((?:"[^"]*"|'[^']*'|[^'">])*)>([\s\S]*?)<\/style\s*>/gi)) {
5248
+ const css = match[2] ?? "";
5249
+ const uncommentedCss = css.replace(/\/\*[\s\S]*?\*\//g, "");
5250
+ for (const imported of uncommentedCss.matchAll(/@import\s+(?:url\(\s*)?(?:"([^"]+)"|'([^']+)'|([^\s);]+))/gi)) {
5251
+ if (COMPILED_URL.test(imported[1] ?? imported[2] ?? imported[3] ?? "")) return true;
5252
+ }
5253
+ if (attribute(match[1] ?? "", "id") === "__tw-css" && css.trim().length > 0 || /tailwindcss\s+v\d/i.test(css) || css.includes("@layer utilities") && /--tw-[\w-]+\s*:/.test(css))
5254
+ return true;
5255
+ }
5256
+ return false;
5257
+ }
5258
+ function needsTailwindRuntime(html) {
5259
+ if (hasTailwindRuntime(html) || hasCompiledTailwind(html)) return false;
5260
+ const clean = withoutScripts(html.replace(/<!--[\s\S]*?(?:-->|$)/g, ""));
5261
+ for (const style of clean.matchAll(RAW_ELEMENTS)) {
5262
+ if (attribute(style[2] ?? "", "type").toLowerCase() === "text/tailwindcss") return true;
5263
+ }
5264
+ const markup = clean.replace(
5265
+ RAW_ELEMENTS,
5266
+ (_match, name) => name.toLowerCase() === "style" ? "<style>" : ""
5267
+ );
5268
+ const utilities = /* @__PURE__ */ new Set();
5269
+ let hasClasses = false;
5270
+ let hasStylesheet = false;
5271
+ for (const tag of markup.matchAll(/<([a-z][\w:-]*)\b((?:"[^"]*"|'[^']*'|[^'">])*)(?:>|$)/gi)) {
5272
+ const name = tag[1].toLowerCase();
5273
+ const attrs = tag[2] ?? "";
5274
+ if (name === "style" || name === "link" && attribute(attrs, "rel").toLowerCase().split(/\s+/).includes("stylesheet"))
5275
+ hasStylesheet = true;
5276
+ for (const candidate of attribute(attrs, "class").split(/\s+/).filter(Boolean)) {
5277
+ hasClasses = true;
5278
+ const token = candidate.replace(/^!|!$/g, "");
5279
+ const variant = VARIANT.exec(token);
5280
+ const base = variant?.[1] ?? token;
5281
+ if (ARBITRARY.test(base) || variant !== null && UTILITY.test(base) || /^(?:min-|max-)?[wh]-(?:screen|[sdl]v[wh])$/.test(base))
5282
+ return true;
5283
+ if (UTILITY.test(base)) utilities.add(base);
5284
+ }
5285
+ }
5286
+ return utilities.size >= 3 && [...utilities].some((name) => name.includes("-")) || hasClasses && !hasStylesheet;
5287
+ }
5288
+ function tailwindScanInput(html, overrides) {
5289
+ return `${overrides?.head ?? ""}<html ${overrides?.htmlAttrs ?? ""}><body ${overrides?.bodyAttrs ?? ""}>${html}`;
5290
+ }
5291
+ var OPTIONAL_TAILWIND_CDN_URL, OPTIONAL_TAILWIND_SCRIPT_TAG, TAILWIND_CDN_SCRIPT_TAG, TAILWIND_RELAY_ATTR, TAILWIND_RUNTIME_SELECTOR, TAILWIND_DOCUMENT_SELECTOR, RUNTIME_URL, COMPILED_URL, UTILITY, ARBITRARY, VARIANT, RAW_ELEMENTS;
5292
+ var init_tailwind_detection = __esm({
5293
+ "../design-mode/packages/shared/src/tailwind-detection.ts"() {
5294
+ "use strict";
5295
+ init_define_KOMBAI_TELEMETRY();
5296
+ init_tailwind_script();
5297
+ OPTIONAL_TAILWIND_CDN_URL = "https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4";
5298
+ OPTIONAL_TAILWIND_SCRIPT_TAG = `<script src="${OPTIONAL_TAILWIND_CDN_URL}"></script>`;
5299
+ TAILWIND_CDN_SCRIPT_TAG = OPTIONAL_TAILWIND_SCRIPT_TAG;
5300
+ TAILWIND_RELAY_ATTR = "data-kombai-tailwind-runtime";
5301
+ TAILWIND_RUNTIME_SELECTOR = 'script[src*="@tailwindcss/browser"],script[src*="cdn.tailwindcss.com"],script[src*="/api/tailwind/browser.js"]';
5302
+ TAILWIND_DOCUMENT_SELECTOR = `${TAILWIND_RUNTIME_SELECTOR},meta[name="kombai-tailwind-runtime"]`;
5303
+ RUNTIME_URL = /@tailwindcss\/browser(?:@|[/?#]|$)|cdn\.tailwindcss\.com(?:[/?#]|$)|\/api\/tailwind\/browser\.js(?:[?#]|$)/i;
5304
+ COMPILED_URL = /tailwind(?:css)?(?:[.-][\w-]+)*\.css(?:[?#]|$)/i;
5305
+ UTILITY = /^-?(?:(?:[mp][trblxyse]?|gap(?:-[xy])?|space-[xy]|w|h|min-[wh]|max-[wh]|size|inset|top|right|bottom|left|z|opacity|order|grow|shrink)-(?:\d+(?:\.\d+)?(?:\/\d+)?|px|auto|full|screen|fit|min|max|none)|(?:bg|text|border|ring|fill|stroke|from|via|to)-(?:[a-z]+-\d{2,3}|white|black|transparent|current)|(?:grid-cols|col-span|row-span)-\d+|(?:items|justify|self|content)-(?:start|end|center|between|around|stretch)|(?:flex|inline-flex|grid|inline-grid|block|hidden|relative|absolute|fixed|sticky)|rounded(?:-(?:none|sm|md|lg|xl|2xl|3xl|full))?|shadow(?:-(?:none|sm|md|lg|xl|2xl))?|font-(?:sans|serif|mono|thin|light|normal|medium|semibold|bold|extrabold|black)|text-(?:xs|sm|base|lg|xl|[2-9]xl|left|center|right|justify|start|end)|tracking-(?:tighter|tight|normal|wide|wider|widest)|leading-(?:none|tight|snug|normal|relaxed|loose|\d+(?:\.\d+)?)|uppercase|lowercase|capitalize|normal-case|italic|not-italic|underline|overline|line-through|no-underline|truncate|line-clamp-(?:\d+|none)|whitespace-(?:normal|nowrap|pre|pre-line|pre-wrap|break-spaces)|overflow(?:-[xy])?-(?:auto|hidden|clip|visible|scroll)|object-(?:contain|cover|fill|none|scale-down)|aspect-(?:square|video|auto)|transition(?:-(?:all|colors|opacity|shadow|transform|none))?|duration-\d+|cursor-pointer)$/;
5306
+ ARBITRARY = /^(?:[a-z][a-z0-9-]*-)?(?:\[[^\]]+\]|\(--[\w-]+\))$/i;
5307
+ VARIANT = /^(?:(?:sm|md|lg|xl|2xl|dark|hover|focus|focus-visible|active|disabled|group-hover):)+(.+)$/;
5308
+ RAW_ELEMENTS = /<(script|style)\b((?:"[^"]*"|'[^']*'|[^'">])*)>[\s\S]*?(?:<\/\1\s*>|$)/gi;
5309
+ }
5310
+ });
5311
+
5213
5312
  // src/render/page.js
5214
5313
  function composePage({ html, overrides, images }) {
5215
5314
  const rewrite = (text) => rewriteImages(text, images);
5216
5315
  const captured = Boolean(overrides);
5217
5316
  const htmlAttrs = overrides?.htmlAttrs ? ` ${overrides.htmlAttrs.trimStart()}` : "";
5218
5317
  const bodyAttrs = overrides?.bodyAttrs ? ` ${rewrite(overrides.bodyAttrs.trimStart())}` : "";
5318
+ const tailwind = needsTailwindRuntime(tailwindScanInput(html, overrides ?? void 0)) ? TAILWIND_CDN_SCRIPT_TAG : "";
5219
5319
  return `<!DOCTYPE html>
5220
5320
  <html${htmlAttrs}>
5221
5321
  <head>
5222
5322
  <meta charset="utf-8">
5223
- ${captured ? rewrite(overrides?.head ?? "") : TAILWIND_CDN_SCRIPT_TAG}
5323
+ ${captured ? rewrite(overrides?.head ?? "") : tailwind}
5224
5324
  <style>${captured ? "" : FRAGMENT_RESET_CSS}
5225
5325
  ${ROOT_CSS}</style>
5226
5326
  </head>
@@ -5241,7 +5341,7 @@ var init_page = __esm({
5241
5341
  "src/render/page.js"() {
5242
5342
  "use strict";
5243
5343
  init_define_KOMBAI_TELEMETRY();
5244
- init_tailwind_script();
5344
+ init_tailwind_detection();
5245
5345
  FRAGMENT_RESET_CSS = "html, body { margin: 0; padding: 0; }";
5246
5346
  ROOT_CSS = "#root { display: contents; }";
5247
5347
  }
@@ -5438,13 +5538,7 @@ import dns from "node:dns/promises";
5438
5538
  import http from "node:http";
5439
5539
  import net2 from "node:net";
5440
5540
  function isPrivateAddress(ip) {
5441
- const v4 = net2.isIPv4(ip) ? ip : /^::ffff:(\d+\.\d+\.\d+\.\d+)$/i.exec(ip)?.[1];
5442
- if (v4) {
5443
- const [a, b] = v4.split(".").map(Number);
5444
- return a === 0 || a === 10 || a === 127 || a >= 224 || a === 100 && b >= 64 && b <= 127 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 168 || a === 198 && (b === 18 || b === 19);
5445
- }
5446
- const lower = ip.toLowerCase();
5447
- return lower === "::" || lower === "::1" || /^f[cd]/.test(lower) || /^fe[89ab]/.test(lower) || /^ff/.test(lower);
5541
+ return PRIVATE.check(ip, net2.isIPv4(ip) ? "ipv4" : "ipv6");
5448
5542
  }
5449
5543
  async function publicAddress(host) {
5450
5544
  const bare = host.replace(/^\[|\]$/g, "");
@@ -5538,12 +5632,44 @@ async function startProxy() {
5538
5632
  })
5539
5633
  };
5540
5634
  }
5541
- var PAGE_HOST;
5635
+ var PAGE_HOST, PRIVATE;
5542
5636
  var init_proxy = __esm({
5543
5637
  "src/render/proxy.js"() {
5544
5638
  "use strict";
5545
5639
  init_define_KOMBAI_TELEMETRY();
5546
5640
  PAGE_HOST = "render.kombai.invalid";
5641
+ PRIVATE = new net2.BlockList();
5642
+ for (
5643
+ const [prefix, bits] of
5644
+ /** @type {const} */
5645
+ [
5646
+ ["0.0.0.0", 8],
5647
+ ["10.0.0.0", 8],
5648
+ ["100.64.0.0", 10],
5649
+ ["127.0.0.0", 8],
5650
+ ["169.254.0.0", 16],
5651
+ ["172.16.0.0", 12],
5652
+ ["192.168.0.0", 16],
5653
+ ["198.18.0.0", 15],
5654
+ ["224.0.0.0", 3]
5655
+ ]
5656
+ ) {
5657
+ PRIVATE.addSubnet(prefix, bits, "ipv4");
5658
+ }
5659
+ for (
5660
+ const [prefix, bits] of
5661
+ /** @type {const} */
5662
+ [
5663
+ ["::", 96],
5664
+ ["64:ff9b::", 96],
5665
+ ["64:ff9b:1::", 48],
5666
+ ["fc00::", 7],
5667
+ ["fe80::", 10],
5668
+ ["ff00::", 8]
5669
+ ]
5670
+ ) {
5671
+ PRIVATE.addSubnet(prefix, bits, "ipv6");
5672
+ }
5547
5673
  }
5548
5674
  });
5549
5675
 
@@ -7026,6 +7152,151 @@ var init_dskit = __esm({
7026
7152
  }
7027
7153
  });
7028
7154
 
7155
+ // ../shared/src/utils/inspirationLibrary.ts
7156
+ var INSPIRATION_LIBRARY_SEGMENT, LIBRARY_PATH_PREFIX;
7157
+ var init_inspirationLibrary = __esm({
7158
+ "../shared/src/utils/inspirationLibrary.ts"() {
7159
+ "use strict";
7160
+ init_define_KOMBAI_TELEMETRY();
7161
+ INSPIRATION_LIBRARY_SEGMENT = "kombai-inspiration-library";
7162
+ LIBRARY_PATH_PREFIX = `${INSPIRATION_LIBRARY_SEGMENT}/`;
7163
+ }
7164
+ });
7165
+
7166
+ // ../design-mode/packages/shared/src/preset-design-system.ts
7167
+ function isSafePresetId(id) {
7168
+ return SAFE_PRESET_ID.test(id);
7169
+ }
7170
+ function isRecord2(v) {
7171
+ return typeof v === "object" && v !== null && !Array.isArray(v);
7172
+ }
7173
+ function isTextSpec(v) {
7174
+ return isRecord2(v) && isString(v.family) && typeof v.weight === "number" && isString(v.size) && isString(v.lineHeight);
7175
+ }
7176
+ function isPreview(v) {
7177
+ if (!isRecord2(v) || !isMode(v.mode) || !isRecord2(v.colors)) return false;
7178
+ const colors2 = v.colors;
7179
+ return PREVIEW_COLOR_ROLES.every((r) => isString(colors2[r])) && isTextSpec(v.heading) && isTextSpec(v.body) && isString(v.radius);
7180
+ }
7181
+ function isCard(v) {
7182
+ return isRecord2(v) && Array.isArray(v.tags) && v.tags.every(isString) && isOptionalString(v.thumbnailPath) && isOptionalString(v.videoLink) && isOptionalString(v.category) && isOptionalString(v.sourceUrl);
7183
+ }
7184
+ function isPresetDesignSystem(v) {
7185
+ return isRecord2(v) && isNonEmptyString(v.id) && isNonEmptyString(v.name) && isString(v.description) && Array.isArray(v.modes) && v.modes.every(isMode) && isPreview(v.preview) && isCard(v.card);
7186
+ }
7187
+ function resolveLibraryPath(p, base) {
7188
+ if (!p) return void 0;
7189
+ if (/^https?:\/\//i.test(p)) return p;
7190
+ return `${base}/${p.replace(/^\/+/, "")}`;
7191
+ }
7192
+ function toPresetListItem(preset, base) {
7193
+ const { card } = preset;
7194
+ return {
7195
+ id: preset.id,
7196
+ name: preset.name,
7197
+ description: preset.description,
7198
+ modes: preset.modes,
7199
+ preview: preset.preview,
7200
+ card: {
7201
+ thumbnailUrl: resolveLibraryPath(card.thumbnailPath, base),
7202
+ videoLink: card.videoLink,
7203
+ category: card.category,
7204
+ tags: card.tags,
7205
+ // Clients open this in a browser, so only an absolute http(s) URL is ever served.
7206
+ sourceUrl: card.sourceUrl && /^https?:\/\//i.test(card.sourceUrl) ? card.sourceUrl : void 0
7207
+ }
7208
+ };
7209
+ }
7210
+ function presetListItems(items, libraryBaseUrl) {
7211
+ const base = libraryBaseUrl.replace(/\/+$/, "");
7212
+ const seen = /* @__PURE__ */ new Set();
7213
+ const presets = [];
7214
+ const dropped = [];
7215
+ for (const item of items) {
7216
+ if (!isPresetDesignSystem(item)) {
7217
+ dropped.push({ id: isRecord2(item) ? item.id : void 0, reason: "malformed" /* Malformed */ });
7218
+ continue;
7219
+ }
7220
+ if (seen.has(item.id)) {
7221
+ dropped.push({ id: item.id, reason: "duplicate" /* Duplicate */ });
7222
+ continue;
7223
+ }
7224
+ seen.add(item.id);
7225
+ presets.push(item);
7226
+ }
7227
+ presets.sort((a, b) => a.name.localeCompare(b.name, "en", { sensitivity: "base" }));
7228
+ return { items: presets.map((preset) => toPresetListItem(preset, base)), dropped };
7229
+ }
7230
+ var PRESET_DESIGN_SYSTEM_FILE, PRESET_DESIGN_SYSTEM_FILE_VERSION, SAFE_PRESET_ID, PREVIEW_COLOR_ROLES, isString, isNonEmptyString, isOptionalString, isMode;
7231
+ var init_preset_design_system = __esm({
7232
+ "../design-mode/packages/shared/src/preset-design-system.ts"() {
7233
+ "use strict";
7234
+ init_define_KOMBAI_TELEMETRY();
7235
+ PRESET_DESIGN_SYSTEM_FILE = "preset-design-system.json";
7236
+ PRESET_DESIGN_SYSTEM_FILE_VERSION = 1;
7237
+ SAFE_PRESET_ID = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
7238
+ PREVIEW_COLOR_ROLES = ["background", "surface", "text", "primary", "accent"];
7239
+ isString = (v) => typeof v === "string";
7240
+ isNonEmptyString = (v) => isString(v) && v.trim() !== "";
7241
+ isOptionalString = (v) => v === void 0 || isString(v);
7242
+ isMode = (v) => v === "light" || v === "dark";
7243
+ }
7244
+ });
7245
+
7246
+ // src/lib/presets.js
7247
+ function libraryBase(web) {
7248
+ return `${web.replace(/\/+$/, "")}/${INSPIRATION_LIBRARY_SEGMENT}`;
7249
+ }
7250
+ async function libraryText(ctx, web, file2) {
7251
+ try {
7252
+ const res = await ctx.fetch(`${libraryBase(web)}/${file2}`, { signal: AbortSignal.timeout(LIBRARY_LIMIT_MS) });
7253
+ return { status: res.status, text: await res.text() };
7254
+ } catch (error2) {
7255
+ throw blockedRequest(ctx.sandbox, error2) ?? unavailable2("the library did not answer");
7256
+ }
7257
+ }
7258
+ async function listPublic(ctx, web) {
7259
+ const { status, text } = await libraryText(ctx, web, PRESET_DESIGN_SYSTEM_FILE);
7260
+ if (status !== 200 || !text.trimStart().startsWith("{")) throw unavailable2(`the library has no list (${status})`);
7261
+ let file2;
7262
+ try {
7263
+ file2 = JSON.parse(text);
7264
+ } catch {
7265
+ throw unavailable2("the list is not JSON");
7266
+ }
7267
+ if (file2?.version !== PRESET_DESIGN_SYSTEM_FILE_VERSION || !Array.isArray(file2.items))
7268
+ throw unavailable2("the list is in a version this CLI does not read");
7269
+ return presetListItems(file2.items, libraryBase(web)).items.filter((item) => isSafePresetId(item.id));
7270
+ }
7271
+ async function readPublicDoc(ctx, web, id) {
7272
+ const folder = `inspirations/${encodeURIComponent(id)}`;
7273
+ const ds = await libraryText(ctx, web, `${folder}/design.ds`);
7274
+ if (ds.status === 200 && ds.text.trimStart().startsWith("---")) return ds.text;
7275
+ if (ds.status !== 200 && ds.status !== 404) throw unavailable2(`the library answered ${ds.status} for ${id}`);
7276
+ const md = await libraryText(ctx, web, `${folder}/design.md`);
7277
+ if (md.status === 404) return "";
7278
+ if (md.status !== 200) throw unavailable2(`the library answered ${md.status} for ${id}`);
7279
+ return /^<(!doctype|html)\b/i.test(md.text.trimStart()) ? "" : md.text;
7280
+ }
7281
+ function unavailable2(reason) {
7282
+ return new CliError(
7283
+ "CLI_PUBLIC_UNAVAILABLE",
7284
+ `Kombai's public design systems could not be read: ${reason}. Try again later.`
7285
+ );
7286
+ }
7287
+ var LIBRARY_LIMIT_MS;
7288
+ var init_presets = __esm({
7289
+ "src/lib/presets.js"() {
7290
+ "use strict";
7291
+ init_define_KOMBAI_TELEMETRY();
7292
+ init_inspirationLibrary();
7293
+ init_preset_design_system();
7294
+ init_output();
7295
+ init_sandbox();
7296
+ LIBRARY_LIMIT_MS = 8e3;
7297
+ }
7298
+ });
7299
+
7029
7300
  // src/commands/ds.js
7030
7301
  import { randomBytes as randomBytes6 } from "node:crypto";
7031
7302
  import fs15 from "node:fs/promises";
@@ -7043,6 +7314,31 @@ function dsPaths(home, env, ownerKey, slug) {
7043
7314
  lock: path15.join(dir, `.${slug}.lock`)
7044
7315
  };
7045
7316
  }
7317
+ function publicDir(home, env) {
7318
+ return path15.join(home, env, "design-systems", "public");
7319
+ }
7320
+ async function pullPublic(ctx, id) {
7321
+ if (!isSafePresetId(id)) {
7322
+ throw badValues("ds pull", [`"${id}" is not a public design system id (letters, digits, _ and -)`]);
7323
+ }
7324
+ const session = await openSession(ctx);
7325
+ const [listed, doc] = await Promise.all([
7326
+ listPublic(ctx, session.hosts.web),
7327
+ readPublicDoc(ctx, session.hosts.web, id)
7328
+ ]);
7329
+ const found = listed.find((item) => item.id === id);
7330
+ if (!found || !doc.trim()) {
7331
+ throw new CliError(
7332
+ "CLI_PUBLIC_NOT_FOUND",
7333
+ found ? `Kombai's public design system ${id} has no published document.` : `Kombai has no public design system "${id}".`,
7334
+ { next: "kombai ds list", details: { id } }
7335
+ );
7336
+ }
7337
+ const file2 = path15.join(publicDir(ctx.home, session.env), `${id}.ds`);
7338
+ await ensureDir(path15.dirname(file2));
7339
+ await writeFileAtomic(file2, doc, { mode: 420 });
7340
+ return { id, name: found.name, public: true, file: file2 };
7341
+ }
7046
7342
  async function forgetDesignSystem(paths, slug, ownerKey) {
7047
7343
  if (!await fs15.stat(paths.dir).catch(() => null)) return null;
7048
7344
  return withLock(paths.lock, async () => {
@@ -7252,16 +7548,36 @@ var init_ds = __esm({
7252
7548
  init_fsx();
7253
7549
  init_lock();
7254
7550
  init_output();
7551
+ init_presets();
7255
7552
  init_project();
7256
7553
  init_session();
7257
7554
  init_store();
7258
7555
  UTF8 = new TextDecoder("utf-8", { fatal: true });
7259
7556
  dsList = {
7260
7557
  name: "ds list",
7261
- summary: "The user's design systems, across their organizations and their own. file is null when not pulled here.",
7558
+ summary: "The user's design systems, across their organizations and their own, and in publicDesignSystems Kombai's public ones (read-only; null, with a warning, when they cannot be read). file is null when not pulled here.",
7262
7559
  async run(ctx) {
7263
7560
  const session = await openSession(ctx);
7264
- const items = await listAll(session.api);
7561
+ const [items, listed] = await Promise.all([
7562
+ listAll(session.api),
7563
+ listPublic(ctx, session.hosts.web).catch((error2) => {
7564
+ if (!(error2 instanceof CliError)) throw error2;
7565
+ ctx.warnings.add({ code: error2.code, message: error2.message });
7566
+ return null;
7567
+ })
7568
+ ]);
7569
+ const publicFolder = publicDir(ctx.home, session.env);
7570
+ const publicDesignSystems = listed && await Promise.all(
7571
+ listed.map(async (item) => {
7572
+ const file2 = path15.join(publicFolder, `${item.id}.ds`);
7573
+ return {
7574
+ id: item.id,
7575
+ name: item.name,
7576
+ description: item.description,
7577
+ file: await exists(file2) ? file2 : null
7578
+ };
7579
+ })
7580
+ );
7265
7581
  return {
7266
7582
  designSystems: await Promise.all(
7267
7583
  items.map(async (item) => {
@@ -7275,16 +7591,26 @@ var init_ds = __esm({
7275
7591
  file: await hashFile(file2) === null ? null : file2
7276
7592
  };
7277
7593
  })
7278
- )
7594
+ ),
7595
+ publicDesignSystems
7279
7596
  };
7280
7597
  }
7281
7598
  };
7282
7599
  dsPull = {
7283
7600
  name: "ds pull",
7284
- summary: "Get a design system as a .ds file. --owner picks one when the slug is in several scopes. Refused (exit 2) over an edit that was not pushed, unless --discard.",
7601
+ summary: "Get a design system as a .ds file. --owner picks one when the slug is in several scopes. Refused (exit 2) over an edit that was not pushed, unless --discard. --public gets one of Kombai's public design systems by its id (ds list's publicDesignSystems): read-only, written over the last copy.",
7285
7602
  args: [{ name: "slug", required: true }],
7286
- flags: { owner: { type: "string", placeholder: "<ownerKey>" }, discard: { type: "boolean" } },
7603
+ flags: {
7604
+ owner: { type: "string", placeholder: "<ownerKey>" },
7605
+ discard: { type: "boolean" },
7606
+ public: { type: "boolean" }
7607
+ },
7608
+ exclusive: [
7609
+ ["public", "owner"],
7610
+ ["public", "discard"]
7611
+ ],
7287
7612
  async run(ctx, { args, flags }) {
7613
+ if (flags.public) return pullPublic(ctx, args[0]);
7288
7614
  const slug = args[0];
7289
7615
  let ownerKey = typeof flags.owner === "string" ? flags.owner : void 0;
7290
7616
  const problems = [];
@@ -7347,6 +7673,14 @@ var init_ds = __esm({
7347
7673
  async run(ctx, { args, flags }) {
7348
7674
  const session = await openSession(ctx);
7349
7675
  const given2 = path15.resolve(ctx.cwd, args[0]);
7676
+ const inPublic = path15.relative(publicDir(ctx.home, session.env), given2);
7677
+ if (!inPublic.startsWith("..") && !path15.isAbsolute(inPublic)) {
7678
+ throw new CliError(
7679
+ "CLI_PUBLIC_READ_ONLY",
7680
+ `${given2} is one of Kombai's public design systems, which are read-only: it cannot be pushed.`,
7681
+ { details: { path: given2 } }
7682
+ );
7683
+ }
7350
7684
  let bytes;
7351
7685
  try {
7352
7686
  bytes = await fs15.readFile(given2);
@@ -7503,6 +7837,19 @@ var init_ds = __esm({
7503
7837
  details: { ownerKeys: owners }
7504
7838
  });
7505
7839
  }
7840
+ if (!owners.length) {
7841
+ const listed = await listPublic(ctx, session.hosts.web).catch((error2) => {
7842
+ if (error2 instanceof CliError) return [];
7843
+ throw error2;
7844
+ });
7845
+ if (listed.some((item) => item.id === slug)) {
7846
+ throw new CliError(
7847
+ "CLI_PUBLIC_READ_ONLY",
7848
+ `${slug} is one of Kombai's public design systems, which are read-only: it cannot be deleted.`,
7849
+ { details: { id: slug } }
7850
+ );
7851
+ }
7852
+ }
7506
7853
  ownerKey = owners[0];
7507
7854
  }
7508
7855
  for (let attempt = 0; ; attempt++) {
@@ -7937,8 +8284,8 @@ var init_parseUtil = __esm({
7937
8284
  init_errors();
7938
8285
  init_en();
7939
8286
  makeIssue = (params) => {
7940
- const { data, path: path22, errorMaps, issueData } = params;
7941
- const fullPath = [...path22, ...issueData.path || []];
8287
+ const { data, path: path23, errorMaps, issueData } = params;
8288
+ const fullPath = [...path23, ...issueData.path || []];
7942
8289
  const fullIssue = {
7943
8290
  ...issueData,
7944
8291
  path: fullPath
@@ -8221,11 +8568,11 @@ var init_types = __esm({
8221
8568
  init_parseUtil();
8222
8569
  init_util();
8223
8570
  ParseInputLazyPath = class {
8224
- constructor(parent, value, path22, key) {
8571
+ constructor(parent, value, path23, key) {
8225
8572
  this._cachedPath = [];
8226
8573
  this.parent = parent;
8227
8574
  this.data = value;
8228
- this._path = path22;
8575
+ this._path = path23;
8229
8576
  this._key = key;
8230
8577
  }
8231
8578
  get path() {
@@ -11734,10 +12081,10 @@ function mergeDefs(...defs) {
11734
12081
  function cloneDef(schema) {
11735
12082
  return mergeDefs(schema._zod.def);
11736
12083
  }
11737
- function getElementAtPath(obj, path22) {
11738
- if (!path22)
12084
+ function getElementAtPath(obj, path23) {
12085
+ if (!path23)
11739
12086
  return obj;
11740
- return path22.reduce((acc, key) => acc?.[key], obj);
12087
+ return path23.reduce((acc, key) => acc?.[key], obj);
11741
12088
  }
11742
12089
  function promiseAllObject(promisesObj) {
11743
12090
  const keys = Object.keys(promisesObj);
@@ -12049,11 +12396,11 @@ function aborted(x, startIndex = 0) {
12049
12396
  }
12050
12397
  return false;
12051
12398
  }
12052
- function prefixIssues(path22, issues) {
12399
+ function prefixIssues(path23, issues) {
12053
12400
  return issues.map((iss) => {
12054
12401
  var _a2;
12055
12402
  (_a2 = iss).path ?? (_a2.path = []);
12056
- iss.path.unshift(path22);
12403
+ iss.path.unshift(path23);
12057
12404
  return iss;
12058
12405
  });
12059
12406
  }
@@ -25219,8 +25566,8 @@ var require_utils = __commonJS({
25219
25566
  }
25220
25567
  return ind;
25221
25568
  }
25222
- function removeDotSegments(path22) {
25223
- let input = path22;
25569
+ function removeDotSegments(path23) {
25570
+ let input = path23;
25224
25571
  const output = [];
25225
25572
  let nextSlash = -1;
25226
25573
  let len = 0;
@@ -25420,8 +25767,8 @@ var require_schemes = __commonJS({
25420
25767
  wsComponent.secure = void 0;
25421
25768
  }
25422
25769
  if (wsComponent.resourceName) {
25423
- const [path22, query] = wsComponent.resourceName.split("?");
25424
- wsComponent.path = path22 && path22 !== "/" ? path22 : void 0;
25770
+ const [path23, query] = wsComponent.resourceName.split("?");
25771
+ wsComponent.path = path23 && path23 !== "/" ? path23 : void 0;
25425
25772
  wsComponent.query = query;
25426
25773
  wsComponent.resourceName = void 0;
25427
25774
  }
@@ -29935,6 +30282,11 @@ function createLoginRunner(ctx) {
29935
30282
  };
29936
30283
  return {
29937
30284
  start,
30285
+ reopen: async () => {
30286
+ const url2 = current?.waiting?.url;
30287
+ if (typeof url2 !== "string" || !ctx.hasDisplay) return false;
30288
+ return ctx.openUrl(url2);
30289
+ },
29938
30290
  running: () => current !== null,
29939
30291
  takeUnread,
29940
30292
  takeFailure: (reader) => {
@@ -30405,8 +30757,18 @@ var init_tools = __esm({
30405
30757
 
30406
30758
  // src/mcp/sign-in-card.js
30407
30759
  function refused(code2, message, plansLink) {
30408
- const body = { error_code: code2, error_message: message, ...plansLink ? { plans_link: plansLink } : {} };
30409
- return { isError: true, content: [{ type: "text", text: JSON.stringify(body) }] };
30760
+ return { isError: true, content: [{ type: "text", text: refusalText(code2, message, plansLink) }] };
30761
+ }
30762
+ function cardWords(code2, message, plansLink, extra) {
30763
+ return { content: [{ type: "text", text: refusalText(code2, message, plansLink, extra) }] };
30764
+ }
30765
+ function refusalText(code2, message, plansLink, extra) {
30766
+ return JSON.stringify({
30767
+ error_code: code2,
30768
+ error_message: message,
30769
+ ...plansLink ? { plans_link: plansLink } : {},
30770
+ ...extra
30771
+ });
30410
30772
  }
30411
30773
  async function signInCardData(ctx, reason) {
30412
30774
  const reasons = (
@@ -30424,30 +30786,48 @@ async function signInCardData(ctx, reason) {
30424
30786
  const entry = await readEntry(ctx.home, env);
30425
30787
  if (!hasGuest(entry)) {
30426
30788
  const keyLive = typeof entry.key === "string" && entry.key !== "" && Date.parse(entry.expires ?? "") > ctx.now();
30427
- return keyLive ? refused("signed_in", "This machine is signed in to Kombai.") : refused("not_guest", "There is no guest canvas on this machine. Run kombai login in a terminal to sign in.");
30789
+ if (keyLive) return cardWords("signed_in", "This machine is signed in to Kombai.", void 0, emailOf(entry));
30790
+ return { reason: SignInReason.Start, line: LINES[SignInReason.Start], guest: !holdsAccount(entry) };
30428
30791
  }
30792
+ if (valid === SignInReason.Start) return { reason: SignInReason.Account, line: LINES[SignInReason.Account] };
30429
30793
  if (valid === SignInReason.Ending) {
30430
30794
  const daysLeft = Math.ceil((Date.parse(entry.guestExpires ?? "") - ctx.now()) / DAY_MS);
30431
30795
  if (!(daysLeft >= 1 && daysLeft <= ENDING_DAYS)) {
30432
- return refused("not_ending", `This guest canvas does not end within ${ENDING_DAYS} days.`);
30796
+ return cardWords(
30797
+ "not_ending",
30798
+ `This guest canvas does not end within ${ENDING_DAYS} days.`,
30799
+ void 0,
30800
+ typeof entry.guestExpires === "string" && daysLeft > ENDING_DAYS ? { ends_at: entry.guestExpires } : void 0
30801
+ );
30433
30802
  }
30434
30803
  const line = daysLeft === 1 ? "Your guest canvas ends tomorrow." : `Your guest canvas ends in ${daysLeft} days.`;
30435
30804
  return { reason: valid, line };
30436
30805
  }
30437
30806
  return { reason: valid, line: LINES[valid] };
30438
30807
  }
30808
+ function emailOf(entry) {
30809
+ return typeof entry.email === "string" && entry.email ? { email: entry.email } : void 0;
30810
+ }
30439
30811
  async function showSignIn(ctx, args) {
30440
30812
  const data = await signInCardData(ctx, args.reason);
30441
30813
  if ("content" in data) return data;
30442
- return {
30443
- structuredContent: { sign_in: data },
30444
- content: [
30445
- {
30446
- type: "text",
30447
- text: `Showing Kombai's sign-in card in the chat. The user signs in from it: ${END_TURN}`
30448
- }
30449
- ]
30450
- };
30814
+ const text = data.reason === SignInReason.Start ? data.guest ? `Showing Kombai's sign-in card in the chat, which asks the user to sign in or try Kombai without an account. Don't ask in text: ${END_TURN} When the user says to carry on, run kombai whoami.` : `Showing Kombai's sign-in card in the chat. This machine has signed in before, so it offers sign-in only: ${END_TURN} When the user says to carry on, run kombai whoami.` : data.reason === SignInReason.Ending ? (
30815
+ // A reminder, not a refusal: the guest can still design, so the request goes on.
30816
+ "Showing Kombai's sign-in card in the chat, which tells the user the guest canvas ends soon and offers sign-in. Carry on with the user's request; don't run or offer kombai login in text."
30817
+ ) : `Showing Kombai's sign-in card in the chat. The user signs in from it: ${END_TURN}`;
30818
+ return { structuredContent: { sign_in: data }, content: [{ type: "text", text }] };
30819
+ }
30820
+ async function chatGuest(ctx) {
30821
+ try {
30822
+ const line = (
30823
+ /** @type {Record<string, unknown>} */
30824
+ await guest.run(ctx, { flags: {}, args: [] })
30825
+ );
30826
+ return answer(line.status === "guest" ? { status: SignInStatus.Guest } : { status: SignInStatus.SignedIn });
30827
+ } catch (error2) {
30828
+ if (!(error2 instanceof CliError)) throw error2;
30829
+ return answer(failedWith(error2));
30830
+ }
30451
30831
  }
30452
30832
  function statusOfClaim(claim2) {
30453
30833
  if (claim2 === null) return { status: SignInStatus.SignedIn };
@@ -30469,17 +30849,18 @@ function statusOfClaim(claim2) {
30469
30849
  }
30470
30850
  }
30471
30851
  }
30472
- async function chatSignIn(ctx, runner, args) {
30852
+ async function chatSignIn(ctx, runner, args, besideChat) {
30473
30853
  const waitS = typeof args.wait === "number" && Number.isFinite(args.wait) ? Math.min(SIGN_IN_MAX_WAIT_S, Math.max(0, Math.floor(args.wait))) : 0;
30854
+ if (args.reopen === true) return answer({ reopened: await runner.reopen() });
30474
30855
  const { claimOrg } = args;
30475
30856
  if (claimOrg !== void 0) {
30476
30857
  if (typeof claimOrg !== "string" || !DESIGN_ID.orgId.test(claimOrg)) {
30477
30858
  return refused("invalid_arguments", "claimOrg must be an organization id.");
30478
30859
  }
30479
- return answer(await claimInto(ctx, claimOrg));
30860
+ return answer(await withCanvas(ctx, await claimInto(ctx, claimOrg), besideChat));
30480
30861
  }
30481
30862
  const unread = runner.running() ? null : runner.takeUnread(LoginReader.Card);
30482
- if (unread) return answer(statusOfLogin(unread));
30863
+ if (unread) return answer(await withCanvas(ctx, statusOfLogin(unread), besideChat));
30483
30864
  const state = runner.start();
30484
30865
  await state.started;
30485
30866
  const settled = await Promise.race([state.settled, ctx.sleep(waitS * 1e3).then(() => null)]);
@@ -30488,7 +30869,29 @@ async function chatSignIn(ctx, runner, args) {
30488
30869
  return answer({ status: SignInStatus.SigningIn, match_code: typeof matchCode === "string" ? matchCode : null });
30489
30870
  }
30490
30871
  runner.takeUnread(LoginReader.Card);
30491
- return answer(statusOfLogin(settled));
30872
+ return answer(await withCanvas(ctx, statusOfLogin(settled), besideChat));
30873
+ }
30874
+ async function withCanvas(ctx, claimed, besideChat) {
30875
+ const { canvas } = claimed;
30876
+ if (claimed.status !== SignInStatus.Claimed || typeof canvas !== "string") return claimed;
30877
+ const status = { ...claimed, beside_chat: besideChat };
30878
+ try {
30879
+ const session = await openSession(ctx, { claim: false });
30880
+ const read2 = (
30881
+ /** @type {{ document?: { name?: unknown, nodes?: Record<string, { type?: unknown }> } }} */
30882
+ (await session.api.call({ method: "GET", path: `/design/canvases/${canvas}` })).body
30883
+ );
30884
+ const nodes = read2?.document?.nodes;
30885
+ return {
30886
+ ...status,
30887
+ canvas_name: typeof read2?.document?.name === "string" ? read2.document.name : null,
30888
+ designs: nodes && typeof nodes === "object" ? Object.values(nodes).filter((n) => n?.type === "variant").length : null,
30889
+ url: `${session.hosts.web}/c/${canvas}`
30890
+ };
30891
+ } catch (error2) {
30892
+ if (!(error2 instanceof CliError)) throw error2;
30893
+ return status;
30894
+ }
30492
30895
  }
30493
30896
  async function claimInto(ctx, orgId) {
30494
30897
  try {
@@ -30513,6 +30916,7 @@ var init_sign_in_card = __esm({
30513
30916
  init_define_KOMBAI_TELEMETRY();
30514
30917
  init_contract();
30515
30918
  init_output();
30919
+ init_auth();
30516
30920
  init_session();
30517
30921
  init_store();
30518
30922
  init_login_runner();
@@ -30529,10 +30933,16 @@ var init_sign_in_card = __esm({
30529
30933
  /** Any other CLI_SIGNIN_REQUIRED or DESIGN_SIGNIN_REQUIRED. */
30530
30934
  Account: "account",
30531
30935
  /** Once, in the guest's last 7 days. */
30532
- Ending: "ending"
30936
+ Ending: "ending",
30937
+ /**
30938
+ * A machine with no key and no guest: the first choice, sign in or try Kombai as a guest (`guest: false` when this
30939
+ * machine has signed in before, which offers sign-in only). Any reason on such a machine shows it.
30940
+ */
30941
+ Start: "start"
30533
30942
  });
30534
30943
  END_TURN = "end your turn, and don't run or offer kombai login in text.";
30535
30944
  LINES = Object.freeze({
30945
+ [SignInReason.Start]: "Kombai works best signed in. Sign in now, or try it without an account?",
30536
30946
  [SignInReason.CanvasFull]: "This guest canvas is full.",
30537
30947
  [SignInReason.SecondCanvas]: "More canvases need a Kombai account.",
30538
30948
  [SignInReason.Taste]: "Taste needs a Kombai account.",
@@ -30551,7 +30961,9 @@ var init_sign_in_card = __esm({
30551
30961
  /** Signed in, with nothing left to claim. */
30552
30962
  SignedIn: "signed_in",
30553
30963
  /** The sign-in or the claim ended for good: `error` is its code and words. */
30554
- Failed: "failed"
30964
+ Failed: "failed",
30965
+ /** chat_guest made this machine a guest (or found it one already). */
30966
+ Guest: "guest"
30555
30967
  });
30556
30968
  DAY_MS = 24 * 60 * 60 * 1e3;
30557
30969
  ENDING_DAYS = 7;
@@ -30585,7 +30997,7 @@ function createCards(ctx, options) {
30585
30997
  const toolsOf = (spec) => {
30586
30998
  if (spec === TASTE) return [tasteTool(uriOf(spec))];
30587
30999
  if (spec === PLANS) return [plansTool(uriOf(spec)), checkoutTool()];
30588
- if (spec === SIGN_IN) return [signInTool(uriOf(spec)), chatSignInTool()];
31000
+ if (spec === SIGN_IN) return [signInTool(uriOf(spec)), chatSignInTool(), chatGuestTool()];
30589
31001
  return [];
30590
31002
  };
30591
31003
  return (await available(set2)).flatMap(toolsOf);
@@ -30630,7 +31042,10 @@ function createCards(ctx, options) {
30630
31042
  if (name === PLANS_CARD_TOOL && specs.includes(PLANS)) return showPlans(ctx, signInBuilt);
30631
31043
  if (name === CHECKOUT_TOOL && specs.includes(PLANS)) return checkout(ctx, args, signInBuilt);
30632
31044
  if (name === SIGN_IN_CARD_TOOL && specs.includes(SIGN_IN)) return showSignIn(ctx, args);
30633
- if (name === CHAT_SIGN_IN_TOOL && specs.includes(SIGN_IN)) return chatSignIn(ctx, options.login, args);
31045
+ if (name === CHAT_SIGN_IN_TOOL && specs.includes(SIGN_IN)) {
31046
+ return chatSignIn(ctx, options.login, args, set2 === Cards.All);
31047
+ }
31048
+ if (name === CHAT_GUEST_TOOL && specs.includes(SIGN_IN)) return chatGuest(ctx);
30634
31049
  return null;
30635
31050
  }
30636
31051
  };
@@ -30655,7 +31070,7 @@ async function showTaste(ctx, args, signInBuilt) {
30655
31070
  } catch (error2) {
30656
31071
  if (!(error2 instanceof CliError)) throw error2;
30657
31072
  if (error2.code === SIGNIN_REQUIRED) return guestRefusal(error2, SignInReason.Taste, signInBuilt);
30658
- return failed(`Kombai could not show this taste brief: ${error2.message}`);
31073
+ return shownWords(`Kombai could not show this taste brief: ${error2.message}`);
30659
31074
  }
30660
31075
  }
30661
31076
  async function showPlans(ctx, signInBuilt) {
@@ -30667,7 +31082,7 @@ async function showPlans(ctx, signInBuilt) {
30667
31082
  const session = await openSession(ctx);
30668
31083
  const status = await readSubscriptionStatus(session);
30669
31084
  if (status?.assistantSubscriptionIsTeamPlan) {
30670
- return refused("team_plan", "A team's plan is bought by the team's admin, on Kombai's plans page.", plansLink);
31085
+ return cardWords("team_plan", "A team's plan is bought by the team's admin, on Kombai's plans page.", plansLink);
30671
31086
  }
30672
31087
  account = accountOf(status);
30673
31088
  plans = (await session.api.call({
@@ -30679,7 +31094,7 @@ async function showPlans(ctx, signInBuilt) {
30679
31094
  } catch (error2) {
30680
31095
  if (!(error2 instanceof CliError)) throw error2;
30681
31096
  if (error2.code === SIGNIN_REQUIRED) return guestRefusal(error2, SignInReason.Account, signInBuilt);
30682
- return refused("plans_failed", `Kombai could not load its plans (${error2.code}).`, plansLink);
31097
+ return cardWords("plans_failed", `Kombai could not load its plans (${error2.code}).`, plansLink);
30683
31098
  }
30684
31099
  return {
30685
31100
  // The card hands workspace_root back on Buy, as it does to the gateway; chat_checkout does not read it.
@@ -30771,7 +31186,6 @@ function guestRefusal(error2, reason, signInBuilt) {
30771
31186
  error_message: `${line} Kombai's sign-in card is showing in the chat: ${END_TURN}`
30772
31187
  };
30773
31188
  return {
30774
- isError: true,
30775
31189
  structuredContent: { sign_in: { reason, line } },
30776
31190
  content: [{ type: "text", text: JSON.stringify(body) }]
30777
31191
  };
@@ -30779,7 +31193,10 @@ function guestRefusal(error2, reason, signInBuilt) {
30779
31193
  function failed(message) {
30780
31194
  return { isError: true, content: [{ type: "text", text: message }] };
30781
31195
  }
30782
- var TASTE_CARD_TOOL2, PLANS_CARD_TOOL, CHECKOUT_TOOL, SIGN_IN_CARD_TOOL, CHAT_SIGN_IN_TOOL, SIGNIN_REQUIRED, CARDS_DIR, GOOGLE_FONTS, INLINE, TASTE, PLANS, SIGN_IN, specsIn, reads, acts, icons, tasteTool, plansTool, checkoutTool, signInTool, chatSignInTool;
31196
+ function shownWords(message) {
31197
+ return { content: [{ type: "text", text: message }] };
31198
+ }
31199
+ var TASTE_CARD_TOOL2, PLANS_CARD_TOOL, CHECKOUT_TOOL, SIGN_IN_CARD_TOOL, CHAT_SIGN_IN_TOOL, CHAT_GUEST_TOOL, SIGNIN_REQUIRED, CARDS_DIR, GOOGLE_FONTS, INLINE, TASTE, PLANS, SIGN_IN, specsIn, reads, acts, icons, tasteTool, plansTool, checkoutTool, signInTool, chatSignInTool, chatGuestTool;
30783
31200
  var init_cards = __esm({
30784
31201
  "src/mcp/cards.js"() {
30785
31202
  "use strict";
@@ -30799,12 +31216,14 @@ var init_cards = __esm({
30799
31216
  CHECKOUT_TOOL = "chat_checkout";
30800
31217
  SIGN_IN_CARD_TOOL = "sign_in_card";
30801
31218
  CHAT_SIGN_IN_TOOL = "chat_sign_in";
31219
+ CHAT_GUEST_TOOL = "chat_guest";
30802
31220
  SIGNIN_REQUIRED = "CLI_SIGNIN_REQUIRED";
30803
31221
  CARDS_DIR = fileURLToPath(new URL("./mcp-apps/", import.meta.url));
30804
31222
  GOOGLE_FONTS = ["https://fonts.googleapis.com", "https://fonts.gstatic.com"];
30805
31223
  INLINE = {
30806
31224
  "openai/ui": { preferredDisplayMode: "inline", availableDisplayModes: ["inline"] },
30807
- "openai/widgetShowCodexWidgetInline": true
31225
+ "openai/widgetShowCodexWidgetInline": true,
31226
+ "openai/widgetMinFrameHeight": 120
30808
31227
  };
30809
31228
  TASTE = {
30810
31229
  uriBase: "ui://kombai/cli-design-taste",
@@ -30827,11 +31246,17 @@ var init_cards = __esm({
30827
31246
  SIGN_IN = {
30828
31247
  uriBase: "ui://kombai/cli-sign-in",
30829
31248
  bundle: "sign-in.js",
30830
- title: "Kombai sign-in",
31249
+ // Codex heads the card "Opened <title>": "Opened Kombai sign-in" read as if a sign-in page had opened.
31250
+ title: "Kombai",
30831
31251
  rootId: "kombai-sign-in",
30832
31252
  global: "__kombaiSignIn",
30833
31253
  // No fetches at all: the card's data comes in the tool result, and Sign in goes through chat_sign_in.
30834
- meta: { ui: { csp: { connectDomains: [], resourceDomains: [] }, prefersBorder: true }, ...INLINE }
31254
+ // Codex sizes a card at 480 px until it reports its height; the sign-in card's states are about a third of that.
31255
+ meta: {
31256
+ ui: { csp: { connectDomains: [], resourceDomains: [] }, prefersBorder: true },
31257
+ ...INLINE,
31258
+ "openai/widgetHeightHint": 180
31259
+ }
30835
31260
  };
30836
31261
  specsIn = (set2) => set2 === Cards.All ? [TASTE, PLANS, SIGN_IN] : set2 === Cards.Taste ? [TASTE, SIGN_IN] : [];
30837
31262
  reads = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
@@ -30890,8 +31315,8 @@ var init_cards = __esm({
30890
31315
  });
30891
31316
  signInTool = (resourceUri) => ({
30892
31317
  name: SIGN_IN_CARD_TOOL,
30893
- title: "Kombai sign-in",
30894
- description: "Show Kombai's sign-in card in this chat for a guest (kombai whoami printed status guest, or claim pending). Call it with the reason instead of offering kombai login in text: canvas_full for DESIGN_GUEST_LIMIT with no canvasId in details; second_canvas for DESIGN_GUEST_LIMIT with one (still use that canvas); taste when taste is refused or asked for; repo_images for CLI_SIGNIN_REQUIRED with images in details; account for any other CLI_SIGNIN_REQUIRED or DESIGN_SIGNIN_REQUIRED; ending once per conversation when whoami's expires is within 7 days. Then end your turn. The user signs in from the card; never run kombai login for them unless they ask in the chat. When they say they have signed in, run kombai whoami.",
31318
+ title: "Kombai",
31319
+ description: "Show Kombai's sign-in card in this chat for a guest (kombai whoami printed status guest, or claim pending), or for a machine with neither a guest nor an account (reason start). Call it with the reason instead of offering kombai login in text: start when kombai whoami exits 3 (CLI_NOT_SIGNED_IN), in place of asking whether to sign in or try Kombai without an account; canvas_full for DESIGN_GUEST_LIMIT with no canvasId in details; second_canvas for DESIGN_GUEST_LIMIT with one (still use that canvas); taste when taste is refused or asked for; repo_images for CLI_SIGNIN_REQUIRED with images in details; account for any other CLI_SIGNIN_REQUIRED or DESIGN_SIGNIN_REQUIRED; ending once per conversation when whoami's expires is within 7 days. Then end your turn, except after ending, a reminder, where you carry on with the request. The user signs in from the card; never run kombai login for them unless they ask in the chat. When they say they have signed in, run kombai whoami.",
30895
31320
  inputSchema: {
30896
31321
  type: "object",
30897
31322
  properties: { reason: { type: "string", enum: Object.values(SignInReason) } },
@@ -30910,7 +31335,8 @@ var init_cards = __esm({
30910
31335
  type: "object",
30911
31336
  properties: {
30912
31337
  wait: { type: "integer", minimum: 0, maximum: SIGN_IN_MAX_WAIT_S },
30913
- claimOrg: { type: "string" }
31338
+ claimOrg: { type: "string" },
31339
+ reopen: { type: "boolean" }
30914
31340
  },
30915
31341
  additionalProperties: false
30916
31342
  },
@@ -30918,6 +31344,15 @@ var init_cards = __esm({
30918
31344
  annotations: acts,
30919
31345
  _meta: { ui: { visibility: ["app"] } }
30920
31346
  });
31347
+ chatGuestTool = () => ({
31348
+ name: CHAT_GUEST_TOOL,
31349
+ title: "Try Kombai as a guest",
31350
+ description: "The start card's Try without an account: makes this machine a Kombai guest (kombai guest), with one canvas.",
31351
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
31352
+ icons: icons(),
31353
+ annotations: acts,
31354
+ _meta: { ui: { visibility: ["app"] } }
31355
+ });
30921
31356
  }
30922
31357
  });
30923
31358
 
@@ -30959,9 +31394,9 @@ var init_stdio3 = __esm({
30959
31394
 
30960
31395
  // src/mcp/view-html.js
30961
31396
  function viewHtml(version2, host, options = {}) {
30962
- return VIEW_HTML.replace("{{CLI_VERSION}}", version2).replaceAll("{{HOST_LABEL}}", host.label).replaceAll("{{HOST_EMBED}}", host.embed).replace("{{CLAIM_RETRY_MS}}", String(options.claimRetryMs ?? CLAIM_RETRY_MS));
31397
+ return VIEW_HTML.replace("{{CLI_VERSION}}", version2).replaceAll("{{HOST_LABEL}}", host.label).replaceAll("{{HOST_EMBED}}", host.embed).replace("{{CLAIM_RETRY_MS}}", String(options.claimRetryMs ?? CLAIM_RETRY_MS)).replace("{{COVER_MS}}", String(options.coverMs ?? COVER_MS)).replace("{{RECHECK_MS}}", String(options.recheckMs ?? RECHECK_MS));
30963
31398
  }
30964
- var VIEW_HTML, CLAIM_RETRY_MS;
31399
+ var VIEW_HTML, CLAIM_RETRY_MS, COVER_MS, RECHECK_MS;
30965
31400
  var init_view_html = __esm({
30966
31401
  "src/mcp/view-html.js"() {
30967
31402
  "use strict";
@@ -30977,34 +31412,57 @@ html,body{margin:0;height:100%;overflow:hidden;font:13px system-ui,sans-serif;co
30977
31412
  html.dark body{color:#f1f3f5;background:#1e1e1e}
30978
31413
  #frame{position:fixed;inset:0;width:100%;height:100%;border:0;display:none;background:transparent}
30979
31414
  #screen{position:fixed;inset:0;display:grid;place-items:center;text-align:center;padding:24px}
30980
- #screen b{display:block;font-size:15px;margin-bottom:6px}
30981
- #screen p{margin:0 0 14px;color:#68717b;max-width:36em}
31415
+ #screen.over{z-index:3;background:rgba(252,251,244,.72);backdrop-filter:blur(2px)}
31416
+ html.dark #screen.over{background:rgba(20,20,20,.72)}
31417
+ #panel{max-width:380px}
31418
+ #screen.over #panel{text-align:left;padding:24px;border:1px solid #e3e5e8;border-radius:12px;background:#fff;box-shadow:0 8px 28px rgba(0,0,0,.12)}
31419
+ html.dark #screen.over #panel{background:#262626;border-color:#3a3a3a;box-shadow:0 8px 28px rgba(0,0,0,.4)}
31420
+ #screen b{display:block;font-size:16px;font-weight:600;margin-bottom:6px}
31421
+ #screen p{margin:0 0 16px;color:#68717b;max-width:36em;line-height:1.5}
30982
31422
  html.dark #screen p{color:#9aa3ad}
30983
- #screen code{font:600 15px ui-monospace,Menlo,monospace;letter-spacing:.08em}
31423
+ #code{display:inline-block;margin:0 0 16px;padding:6px 12px;border:1px solid #d8dbdf;border-radius:8px;background:rgba(0,0,0,.03);font:600 20px ui-monospace,Menlo,monospace;letter-spacing:.08em}
31424
+ html.dark #code{border-color:#444;background:rgba(255,255,255,.05)}
31425
+ #actions{display:flex;flex-wrap:wrap;gap:8px;justify-content:center}
31426
+ #screen.over #actions{justify-content:flex-start}
31427
+ #actions.stack{flex-direction:column;align-items:stretch}
31428
+ #actions.stack button{text-align:left}
30984
31429
  button{font:inherit;padding:7px 14px;border-radius:8px;border:1px solid #c9ccd1;background:#fff;color:#272c31;cursor:pointer}
30985
31430
  html.dark button{background:#2a2a2a;color:#f1f3f5;border-color:#444}
30986
- button.primary{background:#1f6f5c;color:#fff;border-color:#1f6f5c}
31431
+ button:focus-visible{outline:2px solid #48de94;outline-offset:1px}
31432
+ /* Both selectors: html.dark button would otherwise win over a lone button.primary and grey the main action out. */
31433
+ button.primary,html.dark button.primary{background:#48de94;color:#151615;border-color:#48de94;font-weight:600}
31434
+ button.primary:hover,html.dark button.primary:hover{background:#3bc583;border-color:#3bc583}
30987
31435
  #link{position:fixed;left:0;right:0;top:0;display:none;align-items:center;gap:10px;padding:8px 12px;background:#fff;border-bottom:1px solid #e3e5e8;box-shadow:0 2px 8px rgba(0,0,0,.08);z-index:2}
30988
31436
  html.dark #link{background:#262626;border-color:#3a3a3a}
30989
31437
  #link span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
30990
31438
  #notice{position:fixed;left:0;right:0;top:0;display:none;align-items:center;gap:10px;padding:8px 12px;background:#fff;border-bottom:1px solid #e3e5e8;box-shadow:0 2px 8px rgba(0,0,0,.08);z-index:2}
30991
31439
  html.dark #notice{background:#262626;border-color:#3a3a3a}
30992
31440
  #notice span{flex:1;min-width:0}
31441
+ /* The cover over a page being replaced: a veil in the view's background that takes every click, under the hosted
31442
+ page's logo loader (components/ui/loader.tsx LogoLoader) as CSS can draw it: the logo's fill, size and glow. */
31443
+ #cover{position:fixed;inset:0;z-index:1;display:grid;place-items:center;cursor:progress;background:rgba(252,251,244,.6)}
31444
+ html.dark #cover{background:rgba(30,30,30,.6)}
31445
+ #cover::after{content:'';width:56px;height:56px;border-radius:10px;background:#48de94;animation:glow 1.5s ease-in-out infinite alternate}
31446
+ @keyframes glow{from{opacity:.35;filter:drop-shadow(0 0 0 rgba(72,222,148,0))}to{opacity:1;filter:drop-shadow(0 0 16px rgba(72,222,148,.55))}}
31447
+ @media (prefers-reduced-motion:reduce){#cover::after{animation:none}}
30993
31448
  [hidden]{display:none!important}
30994
31449
  </style>
30995
31450
  </head>
30996
31451
  <body>
30997
- <div id="screen" role="status"><div><b id="title">Kombai</b><p id="body">Connecting to {{HOST_LABEL}}…</p><div id="actions"></div></div></div>
31452
+ <div id="screen" role="status"><div id="panel"><b id="title">Kombai</b><p id="body">Connecting to {{HOST_LABEL}}…</p><code id="code" hidden></code><div id="actions"></div></div></div>
30998
31453
  <div id="link"><span id="link-text"></span><button id="link-open" class="primary" type="button">Open</button><button id="link-dismiss" type="button">Not now</button></div>
30999
31454
  <div id="notice"><span>Sign-in didn't finish.</span><button id="notice-retry" class="primary" type="button">Try again</button></div>
31000
31455
  <iframe id="frame" title="Kombai canvas" allow="clipboard-write"></iframe>
31456
+ <div id="cover" role="status" aria-label="Loading" hidden></div>
31001
31457
  <script>
31002
31458
  (() => {
31003
31459
  var CLI_VERSION = '{{CLI_VERSION}}';
31004
31460
  var HOST_LABEL = '{{HOST_LABEL}}', HOST_EMBED = '{{HOST_EMBED}}';
31005
31461
  var CLAIM_RETRY_MS = {{CLAIM_RETRY_MS}}, CLAIM_TRIES = 3;
31462
+ var COVER_MS = {{COVER_MS}}, RECHECK_MS = {{RECHECK_MS}};
31006
31463
  var SESSION_TOOL = 'canvas_app_session', ACCOUNT_TOOL = 'canvas_app_account', CREATE_TOOL = 'canvas_app_create';
31007
- // Until the hosted canvas frame fix lands, every message from the page is a draft, whatever the page asked.
31464
+ // Every message from the page is a draft, whatever the page asked, while this and the page's ACTIONS_SENT_INTO_CHAT
31465
+ // are off (embed-bridge.ts says why that is a product decision now, not a wait for the frame fix).
31008
31466
  var SEND_ACTIONS = false;
31009
31467
  var EMBED = 'embed', PROTOCOL = 1;
31010
31468
  var RESULT_WAIT_MS = 2000, SIGN_IN_WAIT_S = 20;
@@ -31015,15 +31473,24 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31015
31473
  var title = document.getElementById('title');
31016
31474
  var body = document.getElementById('body');
31017
31475
  var actions = document.getElementById('actions');
31476
+ var code = document.getElementById('code');
31018
31477
  var frame = document.getElementById('frame');
31019
31478
  var linkBar = document.getElementById('link');
31020
31479
  var linkText = document.getElementById('link-text');
31021
31480
  var notice = document.getElementById('notice');
31481
+ var cover = document.getElementById('cover');
31022
31482
 
31023
- function show(t, b, buttons) {
31483
+ // opts.code: a match code, shown on its own line to compare with the browser's. opts.over: drawn over the framed
31484
+ // canvas, which stays as it is underneath, so closing the screen needs no reload. opts.stack: one button per row.
31485
+ function show(t, b, buttons, opts) {
31486
+ opts = opts || {};
31487
+ unwatch();
31024
31488
  title.textContent = t;
31025
31489
  body.textContent = b;
31490
+ code.textContent = opts.code || '';
31491
+ code.hidden = !opts.code;
31026
31492
  actions.textContent = '';
31493
+ actions.className = opts.stack ? 'stack' : '';
31027
31494
  (buttons || []).forEach(function (spec) {
31028
31495
  var button = document.createElement('button');
31029
31496
  button.type = 'button';
@@ -31032,13 +31499,41 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31032
31499
  button.addEventListener('click', spec.onClick);
31033
31500
  actions.appendChild(button);
31034
31501
  });
31502
+ var over = !!opts.over && framed();
31503
+ screen.classList.toggle('over', over);
31035
31504
  screen.hidden = false;
31036
- frame.style.display = 'none';
31037
31505
  notice.style.display = 'none';
31038
- // A screen replaces the frame: the home is no longer what the person sees.
31506
+ // A screen replaces the cover over a page switch; one drawn over the page leaves the page as it is.
31507
+ uncoverFrame();
31508
+ if (over) return;
31509
+ frame.style.display = 'none';
31510
+ // A screen replaces the frame: the home is no longer what the person sees. One drawn over it leaves it there.
31039
31511
  framedHome = false;
31040
31512
  framedGuest = false;
31041
31513
  }
31514
+ function framed() { return frame.style.display === 'block' && !!frame.getAttribute('src'); }
31515
+
31516
+ // A sign-in or no-canvas screen asks again now and then while it is on screen, and when the view comes back into
31517
+ // sight: the user may have signed in, or made a canvas, from another chat since. Only an answer that changes the
31518
+ // screen is acted on; any other screen stops the asking.
31519
+ var watching = null, watchTimer = null;
31520
+ function watch(status) { watching = status; clearTimeout(watchTimer); watchTimer = setTimeout(recheck, RECHECK_MS); }
31521
+ function unwatch() { watching = null; clearTimeout(watchTimer); }
31522
+ function recheck() {
31523
+ var was = watching;
31524
+ if (!was) return;
31525
+ if (document.hidden) { watch(was); return; }
31526
+ callTool(SESSION_TOOL, sessionArgs()).then(function (answer) {
31527
+ if (watching !== was) return;
31528
+ if (answer.status === was) { watch(was); return; }
31529
+ unwatch();
31530
+ settle(answer);
31531
+ }, function () { if (watching === was) watch(was); });
31532
+ }
31533
+ document.addEventListener('visibilitychange', function () {
31534
+ if (!document.hidden && watching) { clearTimeout(watchTimer); recheck(); }
31535
+ });
31536
+ function closeScreen() { screen.hidden = true; screen.classList.remove('over'); }
31042
31537
 
31043
31538
  if (window.parent === window) { show('Kombai', 'Open this view from ' + HOST_LABEL + '.'); return; }
31044
31539
 
@@ -31063,6 +31558,8 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31063
31558
  var canvas = null, node = null;
31064
31559
  var openingResult = null, openingError = null, openingArgs = null;
31065
31560
  var claimTries = 0, retryTimer = null;
31561
+ // Each open's number: only the latest one's answer is used. The cover's own timer (coverFrame).
31562
+ var opens = 0, coverTimer = null;
31066
31563
  var sawResult;
31067
31564
  var resultSeen = new Promise(function (resolve) { sawResult = resolve; });
31068
31565
 
@@ -31201,14 +31698,15 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31201
31698
  function fromPage(m) {
31202
31699
  if (!m || m.kombai !== EMBED || m.v !== PROTOCOL || typeof m.kind !== 'string') return;
31203
31700
  if (m.kind === 'ready') { postToFrame(hello()); return; }
31204
- // A design's script can forge this: only the loaded home (no design in it) signs in at once.
31701
+ // A design's script can forge this: only the loaded home (no design in it), or a message right after a click,
31702
+ // signs in at once.
31205
31703
  if (m.kind === 'sign-in') {
31206
31704
  clearTimeout(retryTimer);
31207
- if (framedHome) signIn(); else signInScreen();
31705
+ if (framedHome || justClicked()) signIn(); else signInScreen();
31208
31706
  return;
31209
31707
  }
31210
31708
  // The page could not redeem its ticket: this page's sign-in screen (only a screen, so a forged one costs nothing).
31211
- if (m.kind === 'signed-out') { clearTimeout(retryTimer); signInScreen(); return; }
31709
+ if (m.kind === 'signed-out') { clearTimeout(retryTimer); signInScreen(null, true); return; }
31212
31710
  // The page finished a claim: a fresh ticket for the same canvas, framed again.
31213
31711
  if (m.kind === 'claimed') { claimTries = 0; open(); return; }
31214
31712
  if ((m.kind === 'action' || m.kind === 'draft') && typeof m.text === 'string' && m.text) {
@@ -31250,8 +31748,14 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31250
31748
  if (m.kind === 'open-link' && typeof m.url === 'string' && /^https:\/\//i.test(m.url)) offerLink(m.url);
31251
31749
  }
31252
31750
 
31751
+ /** The user clicked this page or the frame a moment ago (transient user activation). */
31752
+ function justClicked() { return !!(navigator.userActivation && navigator.userActivation.isActive); }
31753
+
31253
31754
  var offeredUrl = null;
31254
31755
  function offerLink(url) {
31756
+ var origin = '';
31757
+ try { origin = new URL(url).origin; } catch (e) { return; }
31758
+ if (origin === hosted && justClicked()) { request('ui/open-link', { url: url }).catch(function () {}); return; }
31255
31759
  // One offer at a time: a later message cannot swap the address under a bar the user is about to click.
31256
31760
  if (offeredUrl) return;
31257
31761
  offeredUrl = url;
@@ -31285,14 +31789,24 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31285
31789
  var mark = '&r=' + ++reloads;
31286
31790
  address = address.indexOf('#') < 0 ? address + mark : address.replace('#', mark + '#');
31287
31791
  }
31288
- screen.hidden = true;
31792
+ // The page already in the frame stays its window until the new one loads: covered, so it never shows bare again.
31793
+ // The timer runs from here, not from open(): a ticket call always ends (showFrame or show); a load may never come.
31794
+ if (current) {
31795
+ coverFrame();
31796
+ coverTimer = setTimeout(uncoverFrame, COVER_MS);
31797
+ }
31798
+ closeScreen();
31289
31799
  notice.style.display = 'none';
31290
31800
  frame.style.display = 'block';
31291
31801
  // Trusted as the home only once loaded; the account is read on each load of the signed-in home.
31292
31802
  var home = !canvas;
31293
31803
  framedHome = false;
31294
31804
  framedGuest = false;
31805
+ var shown = opens;
31295
31806
  frame.addEventListener('load', function () {
31807
+ // The page being left finishing its load after a later open: it neither lifts the cover nor is trusted.
31808
+ if (shown !== opens) return;
31809
+ uncoverFrame();
31296
31810
  framedHome = home;
31297
31811
  framedGuest = home && guest;
31298
31812
  if (home && !guest) readAccount();
@@ -31303,6 +31817,18 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31303
31817
  var reloads = 0;
31304
31818
  function stripReload(address) { return address.replace(/&r=\d+$/, ''); }
31305
31819
 
31820
+ // The cover (#cover) keeps the page on screen, veiled and taking no click, from the moment the next page is asked
31821
+ // for until that page's load. A screen replaces it (show); showFrame lifts it after COVER_MS with no load, so a
31822
+ // page that never loads does not hold the view.
31823
+ function coverFrame() {
31824
+ clearTimeout(coverTimer);
31825
+ cover.hidden = false;
31826
+ }
31827
+ function uncoverFrame() {
31828
+ clearTimeout(coverTimer);
31829
+ cover.hidden = true;
31830
+ }
31831
+
31306
31832
  // The session tool answers the canvas id (and the design) it normalised from what the view was given, which may
31307
31833
  // be the raw canvas_app argument (a link) when the view fell back to tool-input. With no canvas it sends none, and
31308
31834
  // the answer carries none: the ticket is for /canvases.
@@ -31317,13 +31843,22 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31317
31843
  if (typeof answer.node === 'string') node = answer.node;
31318
31844
  }
31319
31845
  var SIGNING_IN = 'Finish in the browser; this view follows.';
31320
- var MATCH_CODE = 'Approve in the browser only if it shows this code; this view follows.';
31321
- function signInScreen(message) {
31322
- var title = canvas ? 'Sign in to Kombai to see this canvas' : 'Sign in to Kombai to see your canvases';
31846
+ var CHECK_CODE = 'Check that your browser shows this code, then approve. This view follows.';
31847
+ // replace: the framed page is of no use behind the screen (it could not redeem its ticket), so the screen takes its
31848
+ // place, as with nothing framed.
31849
+ function signInScreen(message, replace) {
31323
31850
  var buttons = [{ label: 'Sign in', primary: true, onClick: function () { signIn(); } }];
31324
- // With a frame already loaded (a guest's canvas) the person can go back to it; with none there is nothing to go back to.
31851
+ // Over a framed canvas (a guest's, whose page asked to sign in): Not now just closes this, and the canvas is as it
31852
+ // was. A frame loaded but hidden by an earlier screen opens again; with none there is nothing to go back to.
31853
+ if (framed() && !replace) {
31854
+ buttons.push({ label: 'Not now', onClick: closeScreen });
31855
+ show('Sign in to Kombai', message || 'Your guest canvas comes with you, at the same link. Kombai\u2019s sign-in opens in your browser.', buttons, { over: true });
31856
+ return;
31857
+ }
31325
31858
  if (frame.getAttribute('src')) buttons.push({ label: 'Not now', onClick: function () { open(); } });
31326
- show(title, message || 'Your browser opens Kombai\u2019s sign-in; this view follows.', buttons);
31859
+ var title = canvas ? 'Sign in to Kombai to see this canvas' : 'Sign in to Kombai to see your canvases';
31860
+ show(title, message || 'Kombai\u2019s sign-in opens in your browser; this view follows.', buttons);
31861
+ watch('not_signed_in');
31327
31862
  }
31328
31863
 
31329
31864
  // The statuses every session answer shares. False for one it does not know: the caller words that.
@@ -31343,7 +31878,7 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31343
31878
  showFrame(null);
31344
31879
  return true;
31345
31880
  }
31346
- if (answer.status === 'no_canvas') { show('Kombai', 'Ask your agent to make a design.'); return true; }
31881
+ if (answer.status === 'no_canvas') { show('Kombai', 'Ask your agent to make a design.'); watch('no_canvas'); return true; }
31347
31882
  if (answer.status === 'needs_org') {
31348
31883
  var buttons = (Array.isArray(answer.orgs) ? answer.orgs : [])
31349
31884
  .filter(function (org) {
@@ -31351,7 +31886,7 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31351
31886
  })
31352
31887
  .map(function (org) { return { label: org.name, onClick: function () { claim(org.id); } }; });
31353
31888
  if (!buttons.length) { askAgent(); return true; }
31354
- show('Which organization gets this canvas?', 'Your guest canvas moves into the one you choose.', buttons);
31889
+ show('Choose where this canvas goes', 'You\u2019re in more than one organization. The canvas moves into the one you pick.', buttons, { over: true, stack: true });
31355
31890
  return true;
31356
31891
  }
31357
31892
  if (answer.status === 'claim_pending') {
@@ -31374,7 +31909,7 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31374
31909
  return false;
31375
31910
  }
31376
31911
  function claim(orgId) {
31377
- show('Signing in…', 'Moving this canvas into your account…');
31912
+ show('Signing in…', 'Moving this canvas into your account…', [], { over: true });
31378
31913
  callTool(SESSION_TOOL, sessionArgs({ claimOrg: orgId })).then(settle, function (error) { show('Kombai', error.message); });
31379
31914
  }
31380
31915
  function settle(answer) {
@@ -31398,7 +31933,7 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31398
31933
  function signIn(code, polling) {
31399
31934
  clearTimeout(retryTimer);
31400
31935
  signingIn = true;
31401
- show('Signing in…', code ? 'Match code ' + code + '. ' + MATCH_CODE : SIGNING_IN);
31936
+ show('Approve in your browser', code ? CHECK_CODE : SIGNING_IN, [], { code: code, over: true });
31402
31937
  callTool(SESSION_TOOL, sessionArgs({ signIn: true, wait: polling ? SIGN_IN_WAIT_S : 0 })).then(function (answer) {
31403
31938
  takeIds(answer);
31404
31939
  if (answer.status === 'signing_in') {
@@ -31411,11 +31946,26 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31411
31946
  }, function (error) { signingIn = false; signInScreen(error.message); });
31412
31947
  }
31413
31948
 
31414
- // retry is the claim's own timer: the screen it set stays.
31949
+ // retry is the claim's own timer: the screen it set stays. A page on screen stays there under the cover until the
31950
+ // next one loads; with none, the opening screen. Only the latest open's answer is used: an earlier one's frames
31951
+ // nothing, however late it comes.
31415
31952
  function open(retry) {
31416
31953
  clearTimeout(retryTimer);
31417
- if (!retry) show('Kombai', canvas ? 'Opening the canvas…' : 'Opening Kombai…');
31418
- callTool(SESSION_TOOL, sessionArgs()).then(settle, function (error) { show('Kombai', error.message); });
31954
+ var mine = ++opens;
31955
+ if (!retry && frame.style.display === 'block') {
31956
+ // As a screen would, the page being left is no longer trusted as the home, and the notice goes; the page stays.
31957
+ notice.style.display = 'none';
31958
+ framedHome = false;
31959
+ framedGuest = false;
31960
+ coverFrame();
31961
+ } else if (!retry) {
31962
+ show('Kombai', canvas ? 'Opening the canvas…' : 'Opening Kombai…');
31963
+ }
31964
+ callTool(SESSION_TOOL, sessionArgs()).then(function (answer) {
31965
+ if (mine === opens) settle(answer);
31966
+ }, function (error) {
31967
+ if (mine === opens) show('Kombai', error.message);
31968
+ });
31419
31969
  }
31420
31970
 
31421
31971
  request('ui/initialize', {
@@ -31446,6 +31996,8 @@ html.dark #notice{background:#262626;border-color:#3a3a3a}
31446
31996
  </body>
31447
31997
  </html>`;
31448
31998
  CLAIM_RETRY_MS = 3e3;
31999
+ COVER_MS = 1e4;
32000
+ RECHECK_MS = 2e4;
31449
32001
  }
31450
32002
  });
31451
32003
 
@@ -31654,7 +32206,7 @@ var init_claude_desktop = __esm({
31654
32206
  var design_system_default;
31655
32207
  var init_design_system = __esm({
31656
32208
  "src/skill/design-system.md"() {
31657
- design_system_default = '# Design systems\n\nA design system is a .ds file in the user\'s Kombai account, not the repo: YAML front matter between\n`---` lines holds the tokens; the markdown after it says how to use them. Read a pulled one as the\nmodel. `kombai ds push` checks it with ds-kit.\n\n- `name` (required) and `modes`: `[light]`, `[dark]` or `[light, dark]`.\n- `color.palette` (required): named colors as quoted hex, rgb() or hsl().\n- `color.semantic`: the 11 roles in the example. Each is a ref, or `{ light: <ref>, dark: <ref> }`.\n- `typography.family`, and `typography.textStyle` with fontFamily, fontSize, fontWeight, lineHeight.\n- Optional: spacing, radius, shadow, border, opacity, motion, breakpoint, components.\n\nEvery ref must name a key you defined: `{colors.X}` (palette, also written `{color.palette.X}`), `{typography.X}` (textStyle),\n`{radius.X}`, `{spacing.X}`, `{shadow.X}`. One ref per value. The body starts with a `>` line, then\noptional `##` sections: Instructions, Brand & Accent, Surface, Text, Status & Semantic, Fonts, Layout,\nComponents, Do, Don\'t, Notes. At most 1 MB.\n\n```\n---\nname: Acme\nmodes: [light]\ncolor:\n palette: { brand: "#3b5bdb", white: "#ffffff", ink: "#16181d", line: "#e4e7ec" }\n semantic:\n background.canvas: "{colors.white}"\n surface.default: "{colors.white}"\n surface.raised: "{colors.white}"\n text.primary: "{colors.ink}"\n text.secondary: "{colors.ink}"\n text.tertiary: "{colors.ink}"\n text.link: "{colors.brand}"\n border.default: "{colors.line}"\n border.focus: "{colors.brand}"\n primary.bg: "{colors.brand}"\n primary.fg: "{colors.white}"\ntypography:\n family: { sans: "Inter" }\n textStyle:\n body: { fontFamily: "Inter", fontSize: "16px", fontWeight: 400, lineHeight: 1.5 }\ncomponents:\n button: { type: button, label: "Get started", backgroundColor: "{colors.brand}", textColor: "{colors.white}", typography: "{typography.body}", padding: "10px 18px" }\n---\n\n> One indigo accent on white, Inter throughout.\n```\n\n## Commands\n\n- `kombai ds list`: each one\'s slug, name, ownerKey, and file (null if not pulled here).\n- `kombai ds pull <slug>` writes the file it prints. Edit it, then `kombai ds push <file>`.\n- To make one, write `<slug>.ds` outside the repo and push it. The file name gives the slug (lowercase\n letters, digits, dashes; a leading `ds-` is dropped); pick one `ds list` does not show. Then edit\n the file the push prints: pushing your first file again is a conflict.\n- A refused file exits 1 with CLI_INVALID_DESIGN_SYSTEM naming each problem: fix them and push again.\n Fix its warnings too.\n- `kombai ds delete <slug>` deletes one for everyone. Run it only when the user asks.\n\nownerKey is `org:<id>` (an organization\'s) or `user:<id>` (the user\'s own). A pulled file goes back to\nits owner; a new one goes to `--org <id>`, else the organization `kombai config org` saved. On\nDESIGN_ORG_REQUIRED, ask the user which of details.orgIds, then push with `--org <id>`. On\nCLI_OWNER_REQUIRED (a slug in several scopes), add `--owner <ownerKey>` from details.ownerKeys, asking\nthe user if unclear.\n\n## From a repo\n\n1. Read the Tailwind config, CSS custom properties (globals.css :root and .dark), theme or token\n files, the font setup and the shared components.\n2. Copy values; never invent a color. Name keys as the code does. Write `--primary: 222 47% 11%` as\n `"hsl(222 47% 11%)"`, and oklch or named colors as hex.\n3. Map each role by how the code uses a color: page, cards, text levels, links, dividers, focus ring,\n primary button and its text. With no match, reuse the closest ref.\n4. `[light, dark]` only when the code has dark values; roles that change become light/dark maps.\n5. Add text styles (headings, body, labels) and the spacing, radius, shadow and breakpoint scales the\n code defines.\n6. Add each real component and variant, typed button, link, icon, icon-round, input, tab, badge, nav,\n avatar, logo, section, card, divider or check, with a label from the UI.\n7. Body: up to 8 Instructions (which token for what), color sections naming `{colors.X}`, Fonts,\n Layout (max width, grid, gutters), a line per component, Do and Don\'t, and Notes for gaps.\n8. Check every ref, then push.\n\n## In designs\n\nDesigns do not link to a design system: canvas.json and nodes have no field for it. Pull it and write\nits values into the HTML (`bg-[#3b5bdb]`, or CSS variables in a `<style>`), following its\nInstructions, Do and Don\'t. The canvas\'s Apply menu asks to regenerate a design "with the <name>\ndesign system": find it by name in `kombai ds list`, pull it and the node, restyle the design keeping\nits content, and push the node. The user can view one at /ds/<slug> on the canvas site.\n\n## Conflicts\n\nExit 2 on a push (DESIGN_DESIGN_SYSTEM_CHANGED): it changed since you pulled it, or already existed.\nThe stored version is saved at details.remote. Merge it into your file and run the error\'s next\n(`kombai ds push <file> --merged`); if it is a different design system, rename your file instead.\n`kombai ds pull <slug> --discard` takes the stored one. Exit 2 on a pull: push your edits first, or\npull with --discard.\n';
32209
+ design_system_default = '# Design systems\n\nA design system is a .ds file in the user\'s Kombai account, not the repo: YAML front matter between\n`---` lines holds the tokens; the markdown after it says how to use them. Read a pulled one as the\nmodel. `kombai ds push` checks it with ds-kit.\n\n- `name` (required) and `modes`: `[light]`, `[dark]` or `[light, dark]`.\n- `color.palette` (required): named colors as quoted hex, rgb() or hsl().\n- `color.semantic`: the 11 roles in the example. Each is a ref, or `{ light: <ref>, dark: <ref> }`.\n- `typography.family`, and `typography.textStyle` with fontFamily, fontSize, fontWeight, lineHeight.\n- Optional: spacing, radius, shadow, border, opacity, motion, breakpoint, components.\n\nEvery ref must name a key you defined: `{colors.X}` (palette, also written `{color.palette.X}`), `{typography.X}` (textStyle),\n`{radius.X}`, `{spacing.X}`, `{shadow.X}`. One ref per value. The body starts with a `>` line, then\noptional `##` sections: Instructions, Brand & Accent, Surface, Text, Status & Semantic, Fonts, Layout,\nComponents, Do, Don\'t, Notes. At most 1 MB.\n\n```\n---\nname: Acme\nmodes: [light]\ncolor:\n palette: { brand: "#3b5bdb", white: "#ffffff", ink: "#16181d", line: "#e4e7ec" }\n semantic:\n background.canvas: "{colors.white}"\n surface.default: "{colors.white}"\n surface.raised: "{colors.white}"\n text.primary: "{colors.ink}"\n text.secondary: "{colors.ink}"\n text.tertiary: "{colors.ink}"\n text.link: "{colors.brand}"\n border.default: "{colors.line}"\n border.focus: "{colors.brand}"\n primary.bg: "{colors.brand}"\n primary.fg: "{colors.white}"\ntypography:\n family: { sans: "Inter" }\n textStyle:\n body: { fontFamily: "Inter", fontSize: "16px", fontWeight: 400, lineHeight: 1.5 }\ncomponents:\n button: { type: button, label: "Get started", backgroundColor: "{colors.brand}", textColor: "{colors.white}", typography: "{typography.body}", padding: "10px 18px" }\n---\n\n> One indigo accent on white, Inter throughout.\n```\n\n## Commands\n\n- `kombai ds list`: each one\'s slug, name, ownerKey, and file (null if not pulled here), and in\n publicDesignSystems Kombai\'s public ones, each with its id, name, description and file.\n- `kombai ds pull <slug>` writes the file it prints. Edit it, then `kombai ds push <file>`.\n- A public one is read-only: `kombai ds pull <id> --public` writes the file it prints. Use it as it is;\n never push or delete it.\n- To make one, write `<slug>.ds` outside the repo and push it. The file name gives the slug (lowercase\n letters, digits, dashes; a leading `ds-` is dropped); pick one `ds list` does not show. Then edit\n the file the push prints: pushing your first file again is a conflict.\n- A refused file exits 1 with CLI_INVALID_DESIGN_SYSTEM naming each problem: fix them and push again.\n Fix its warnings too.\n- `kombai ds delete <slug>` deletes one for everyone. Run it only when the user asks.\n\nownerKey is `org:<id>` (an organization\'s) or `user:<id>` (the user\'s own). A pulled file goes back to\nits owner; a new one goes to `--org <id>`, else the organization `kombai config org` saved. On\nDESIGN_ORG_REQUIRED, ask the user which of details.orgIds, then push with `--org <id>`. On\nCLI_OWNER_REQUIRED (a slug in several scopes), add `--owner <ownerKey>` from details.ownerKeys, asking\nthe user if unclear.\n\n## From a repo\n\n1. Read the Tailwind config, CSS custom properties (globals.css :root and .dark), theme or token\n files, the font setup and the shared components.\n2. Copy values; never invent a color. Name keys as the code does. Write `--primary: 222 47% 11%` as\n `"hsl(222 47% 11%)"`, and oklch or named colors as hex.\n3. Map each role by how the code uses a color: page, cards, text levels, links, dividers, focus ring,\n primary button and its text. With no match, reuse the closest ref.\n4. `[light, dark]` only when the code has dark values; roles that change become light/dark maps.\n5. Add text styles (headings, body, labels) and the spacing, radius, shadow and breakpoint scales the\n code defines.\n6. Add each real component and variant, typed button, link, icon, icon-round, input, tab, badge, nav,\n avatar, logo, section, card, divider or check, with a label from the UI.\n7. Body: up to 8 Instructions (which token for what), color sections naming `{colors.X}`, Fonts,\n Layout (max width, grid, gutters), a line per component, Do and Don\'t, and Notes for gaps.\n8. Check every ref, then push.\n\n## In designs\n\nDesigns do not link to a design system: canvas.json and nodes have no field for it. Pull it and write\nits values into the HTML (`bg-[#3b5bdb]`, or CSS variables in a `<style>`), following its\nInstructions, Do and Don\'t. The canvas\'s Apply menu asks to regenerate a design "with the <name>\ndesign system": find it by name in `kombai ds list`, pull it and the node, restyle the design keeping\nits content, and push the node. A pasted `Use the "<name>" design system: <link>` names it by its link:\nfor ?preset=<id> run `kombai ds pull <id> --public`, for /ds/<slug> run `kombai ds pull <slug>`. The\nuser can view one at /ds/<slug>, a public one at /ds?preset=<id>, on the canvas site.\n\n## Conflicts\n\nExit 2 on a push (DESIGN_DESIGN_SYSTEM_CHANGED): it changed since you pulled it, or already existed.\nThe stored version is saved at details.remote. Merge it into your file and run the error\'s next\n(`kombai ds push <file> --merged`); if it is a different design system, rename your file instead.\n`kombai ds pull <slug> --discard` takes the stored one. Exit 2 on a pull: push your edits first, or\npull with --discard.\n';
31658
32210
  }
31659
32211
  });
31660
32212
 
@@ -31694,7 +32246,7 @@ var init_opening = __esm({
31694
32246
  var overview_default;
31695
32247
  var init_overview = __esm({
31696
32248
  "src/skill/overview.md"() {
31697
- overview_default = '# Kombai design\n\nDesign UI on a hosted Kombai canvas; design systems need no canvas. `kombai <command> --help` gives its\nflags. Read each JSON result: next can be a command, a link or advice. Follow it after handling the error\nand any required user choice.\nSkill text and default help are plain text. Tell the user in one line before and after each step that\ntakes more than a few seconds.\n\n{{RUN}}\n\nRun `kombai` outside any sandbox from the first try: it needs network and writes ~/.kombai.\n\n{{APP}}\n\n## Choose the task\n\n- New design: follow New designs below.\n- Existing canvas or node (a link, "On my Kombai canvas" message, or a named canvas): read\n `kombai skill actions`, pull the target and follow that request. An edit needs no new canvas or\n taste; variants seeking new ideas do.\n- Create or edit a .ds file: read `kombai skill design-system`.\n- Shapes, pictures or layout: read `kombai skill drawings`.\n\nBefore account operations run `kombai whoami`. Unless it prints an email with no claim, read\n`kombai skill sign-in` and follow it. Read it before any `kombai login`.\n\n## New designs\n\n1. Read `kombai skill brief` and the repo before writing a brief outside the repo. The topic says\n when a reference or reflow skips taste.\n2. When taste is needed (never for a guest), tell the user their `kombai credits` balance first,\n then run `kombai taste start --brief <file> --variants <1-4>`, one per design. A run takes minutes:\n do step 3 meanwhile, then `kombai taste wait <run>`, again while its status is running. Follow\n directions.md. On TASTE_NO_CREDITS, call plans_card if listed, else show next\'s plan link; stop.\n3. Create a canvas: `kombai canvas create --name "<what it is>"`. Reuse one only when the user points\n to it or this conversation made it; `kombai canvas list` finds it by name. Ask if the target is\n unclear. On DESIGN_ORG_REQUIRED, ask which listed org, save `kombai config org <id>`, then retry.\n Read `kombai skill opening` and show the canvas once when creating or first using it.\n It starts private; share only when asked.\n4. Before writing HTML, read `kombai skill html`: it says how to build in passes. For each design,\n `kombai node start --canvas <id> --label "<label>"` (`--parent <node>` for a variant), then write\n and push it as that topic says.\n\n## Check a finished design\n\nAfter a design\'s last push, run the complete screenshot fill its next names in the background. Then run\n`kombai screenshot wait --canvas <id> --node <node> --tiles` and inspect each image it prints.\nRun node lock, fix and push again, at most 3 rounds. On CLI_NO_BROWSER or CLI_LAUNCH_FAILED from fill,\nask before the roughly 100 MB download; then `kombai browser install --yes` and retry fill.\nIf wait reports CLI_NOTHING_RENDERING, run its suggested fill only if none is running; on\nCLI_SCREENSHOT_FAILED, inspect the failure reason before retrying.\n\n## Recover from errors\n\nExit 2 is not always a changed node.\nFor DESIGN_NODE_CHANGED on node push, merge the stored version at error.details.remote into your\nfile, then `kombai node push --canvas <id> --node <node> --merged`. Only to discard your edit, use\n`kombai node pull --canvas <id> --node <node> --discard`.\n\nRun commands that change a canvas\'s files (node start, node push, node pull, canvas pull, canvas push)\none at a time per canvas, and edit files only between them; screenshot fill and screenshot wait can run\nbeside them.\n\nExit codes: 0 done, 1 failed, 2 refused or conflict, 3 not signed in, 4 timed out. A wait timeout\ndoes not mean the work failed: follow its next; check a fill\'s result if no image arrives.\n';
32249
+ overview_default = '# Kombai design\n\nDesign UI on a hosted Kombai canvas; design systems need no canvas. `kombai <command> --help` gives its\nflags. Read each JSON result: next can be a command, a link or advice. Follow it after handling the error\nand any required user choice.\nSkill text and default help are plain text. Tell the user in one line before and after each step that\ntakes more than a few seconds.\n\n{{RUN}}\n\nRun `kombai` outside any sandbox from the first try: it needs network and writes ~/.kombai.\n\n{{APP}}\n\n## Choose the task\n\n- New design: follow New designs below.\n- Existing canvas or node (a link, "On my Kombai canvas" message, or a named canvas): read\n `kombai skill actions`, pull the target and follow that request. An edit needs no new canvas or\n taste; variants seeking new ideas do.\n- Design systems (.ds): read `kombai skill design-system`.\n- Shapes, pictures or layout: read `kombai skill drawings`.\n\nBefore account operations run `kombai whoami`. Unless it prints an email with no claim, read\n`kombai skill sign-in` and follow it. Read it before any `kombai login`.\n\n## New designs\n\n1. Read `kombai skill brief` and the repo before writing a brief outside the repo. The topic says\n when a reference or reflow skips taste.\n2. When taste is needed (never for a guest), tell the user their `kombai credits` balance first,\n then run `kombai taste start --brief <file> --variants <1-4>`, one per design. A run takes minutes:\n do step 3 meanwhile, then `kombai taste wait <run>`, again while its status is running. Follow\n directions.md. On TASTE_NO_CREDITS, call plans_card if listed, else show next\'s plan link; stop.\n3. Create a canvas: `kombai canvas create --name "<what it is>"`. Reuse one only when the user points\n to it or this conversation made it; `kombai canvas list` finds it by name. Ask if the target is\n unclear. On DESIGN_ORG_REQUIRED, ask which listed org, save `kombai config org <id>`, then retry.\n Read `kombai skill opening` and show the canvas once when creating or first using it.\n It starts private; share only when asked.\n4. Before writing HTML, read `kombai skill html`: it says how to build in passes. For each design,\n `kombai node start --canvas <id> --label "<label>"` (`--parent <node>` for a variant), then write\n and push it as that topic says.\n\n## Check a finished design\n\nAfter a design\'s last push, run the complete screenshot fill its next names in the background. Then run\n`kombai screenshot wait --canvas <id> --node <node> --tiles` and inspect each image it prints.\nRun node lock, fix and push again, at most 3 rounds. On CLI_NO_BROWSER or CLI_LAUNCH_FAILED from fill,\nask before the roughly 100 MB download; then `kombai browser install --yes` and retry fill.\nIf wait reports CLI_NOTHING_RENDERING, run its suggested fill only if none is running; on\nCLI_SCREENSHOT_FAILED, inspect the failure reason before retrying.\n\n## Recover from errors\n\nExit 2 is not always a changed node.\nFor DESIGN_NODE_CHANGED on node push, merge the stored version at error.details.remote into your\nfile, then `kombai node push --canvas <id> --node <node> --merged`. Only to discard your edit, use\n`kombai node pull --canvas <id> --node <node> --discard`.\n\nRun commands that change a canvas\'s files (node start, node push, node pull, canvas pull, canvas push)\none at a time per canvas, and edit files only between them; screenshot fill and screenshot wait can run\nbeside them.\n\nExit codes: 0 done, 1 failed, 2 refused or conflict, 3 not signed in, 4 timed out. A wait timeout\ndoes not mean the work failed: follow its next; check a fill\'s result if no image arrives.\n';
31698
32250
  }
31699
32251
  });
31700
32252
 
@@ -31702,7 +32254,7 @@ var init_overview = __esm({
31702
32254
  var sign_in_default;
31703
32255
  var init_sign_in = __esm({
31704
32256
  "src/skill/sign-in.md"() {
31705
- sign_in_default = "# Signing in, or trying Kombai as a guest\n\nWhat `kombai whoami` printed decides. The reasons below apply to any exit-3 CLI_NOT_SIGNED_IN, not just whoami's:\n\n- Exit 3 with details.reason none: ask once, \"Kombai works best signed in. Sign in now, or try it without an account?\"\n Sign in: run `kombai login`. Try it: run `kombai guest`, then work as a guest (below).\n- Exit 3 with reason expired or signed_out: the user has an account. Offer sign-in only, never guest mode. With\n claim pending in details, signing in also moves the guest canvas into the account.\n- Any other or missing reason: offer sign-in only.\n- Exit 0 with status guest: the user already chose. Work as a guest without asking again.\n- An email with claim needs_org: ask which listed organization gets the guest canvas, then run\n `kombai claim --org <id>`. With claim pending, the next command finishes it.\n\nTo sign in, run `kombai login` in the background and show the matchCode from its first line; the user approves on\nthe page it opens in their browser, or, if they see none, at the url from that line. If you have a browser panel the\nuser can see, run `kombai login --no-browser` in the background instead, show the matchCode, and open the url from\nits first line in your panel: the user signs in and approves there. Never type into, click on or approve that page\nyourself: the approval is the user's check that the match code is theirs. If they'd rather use their own browser,\ngive them that url, for them alone: whoever approves it signs this CLI into their account. When the signed-in line\nhas claimed, the guest canvas is now in the account, same link. When it has claim needs_org, ask as above.\n\n## As a guest\n\n- Skip taste: no brief and no `kombai taste start`. Go straight to `kombai canvas create`. A guest has one canvas: when\n canvas create answers DESIGN_GUEST_LIMIT with a canvasId in details, use that canvas.\n- Use no repo images (/api/local/images/\u2026): CSS, inline SVG or public https images instead.\n- The canvas link is the user's own. Open it for them; don't suggest sending it to anyone.\n- When whoami's expires is within 7 days, say once in this conversation that the guest canvas ends on that date and\n that signing in keeps it.\n- End each turn with one line: signing in unlocks taste directions, repo images, design systems and sharing.\n\n## Refusals\n\n- DESIGN_SIGNIN_REQUIRED or CLI_SIGNIN_REQUIRED: tell the user in one line what signing in unlocks, and run\n `kombai login` only if they agree.\n- DESIGN_GUEST_LIMIT on any other command (node start, node push, screenshot fill): the guest canvas is full. Say so\n in one line, and that signing in keeps the canvas and lifts the limit; run `kombai login` only if they agree. Don't\n retry or work around it, and keep the unpushed files: push them again after sign-in.\n- SIGNIN_GUEST_EXPIRED as an error from a guest's own command: say the guest canvas expired, and ask again: sign in,\n or start fresh with `kombai guest`.\n- SIGNIN_GUEST_EXPIRED as a warning on a signed-in line (an email is printed): say in one line that the old guest\n canvas expired and is gone. Never offer `kombai guest`.\n- SIGNIN_GUEST_CLAIMED as an error from a guest's own command: the canvas moved into an account; signing in reaches\n it. As a warning on a signed-in line: nothing to do.\n\n## The sign-in card\n\nWhere your tools list `sign_in_card`, call it in place of the lines above, with the moment's reason, and end your\nturn; don't run or offer `kombai login` in text:\n\n- canvas_full: DESIGN_GUEST_LIMIT with no canvasId in details. second_canvas: with one (still use that canvas).\n- taste: taste refused or asked for. repo_images: CLI_SIGNIN_REQUIRED with images in details.\n- account: any other DESIGN_SIGNIN_REQUIRED or CLI_SIGNIN_REQUIRED.\n- ending: once, when whoami's expires is within 7 days.\n\nWithout `sign_in_card`, use the lines above.\n";
32257
+ sign_in_default = "# Signing in, or trying Kombai as a guest\n\nWhat `kombai whoami` printed decides. The reasons below apply to any exit-3 CLI_NOT_SIGNED_IN, not just whoami's:\n\n- Exit 3 with details.reason none: ask once, \"Kombai works best signed in. Sign in now, or try it without an account?\"\n Sign in: run `kombai login`. Try it: run `kombai guest`, then work as a guest (below).\n- Exit 3 with reason expired or signed_out: the user has an account. Offer sign-in only, never guest mode. With\n claim pending in details, signing in also moves the guest canvas into the account.\n- Any other or missing reason: offer sign-in only.\n- Exit 0 with status guest: the user already chose. Work as a guest without asking again.\n- An email with claim needs_org: ask which listed organization gets the guest canvas, then run\n `kombai claim --org <id>`. With claim pending, the next command finishes it.\n\nTo sign in, run `kombai login` in the background and show the matchCode from its first line; the user approves on\nthe page it opens in their browser, or, if they see none, at the url from that line. If you have a browser panel the\nuser can see, run `kombai login --no-browser` in the background instead, show the matchCode, and open the url from\nits first line in your panel: the user signs in and approves there. Never type into, click on or approve that page\nyourself: the approval is the user's check that the match code is theirs. If they'd rather use their own browser,\ngive them that url, for them alone: whoever approves it signs this CLI into their account. When the signed-in line\nhas claimed, the guest canvas is now in the account, same link. When it has claim needs_org, ask as above.\n\n## As a guest\n\n- Run `kombai whoami` again at the start of each new request: the user may have signed in since, in another chat\n or on a card. When it no longer says guest, drop everything below.\n- Skip taste: no brief and no `kombai taste start`. Go straight to `kombai canvas create`. A guest has one canvas: when\n canvas create answers DESIGN_GUEST_LIMIT with a canvasId in details, use that canvas.\n- Use no repo images (/api/local/images/\u2026): CSS, inline SVG or public https images instead.\n- The canvas link is the user's own. Open it for them; don't suggest sending it to anyone.\n- When whoami's expires is within 7 days, say once in this conversation that the guest canvas ends on that date and\n that signing in keeps it.\n- End each turn with one line: signing in unlocks taste directions, repo images, design systems and sharing.\n\n## Refusals\n\n- DESIGN_SIGNIN_REQUIRED or CLI_SIGNIN_REQUIRED: tell the user in one line what signing in unlocks, and run\n `kombai login` only if they agree.\n- DESIGN_GUEST_LIMIT on any other command (node start, node push, screenshot fill): the guest canvas is full. Say so\n in one line, and that signing in keeps the canvas and lifts the limit; run `kombai login` only if they agree. Don't\n retry or work around it, and keep the unpushed files: push them again after sign-in.\n- SIGNIN_GUEST_EXPIRED as an error from a guest's own command: say the guest canvas expired, and ask again: sign in,\n or start fresh with `kombai guest`.\n- SIGNIN_GUEST_EXPIRED as a warning on a signed-in line (an email is printed): say in one line that the old guest\n canvas expired and is gone. Never offer `kombai guest`.\n- SIGNIN_GUEST_CLAIMED as an error from a guest's own command: the canvas moved into an account; signing in reaches\n it. As a warning on a signed-in line: nothing to do.\n\n## The sign-in card\n\nWhere your tools list `sign_in_card`, call it in place of the lines above, with the moment's reason, and end your\nturn; don't run or offer `kombai login` in text:\n\n- start: whoami exits 3, in place of asking whether to sign in or try it without an account. The user chooses on the\n card; when they say to carry on, run `kombai whoami` and go on as it says.\n- canvas_full: DESIGN_GUEST_LIMIT with no canvasId in details. second_canvas: with one (still use that canvas).\n- taste: taste refused or asked for. repo_images: CLI_SIGNIN_REQUIRED with images in details.\n- account: any other DESIGN_SIGNIN_REQUIRED or CLI_SIGNIN_REQUIRED.\n- ending: once, when whoami's expires is within 7 days. It is a reminder, not a refusal: don't end your turn after\n it; carry on with the request.\n\nWithout `sign_in_card`, use the lines above.\n";
31706
32258
  }
31707
32259
  });
31708
32260
 
@@ -31712,7 +32264,7 @@ function fillSkillText(text, inClaudeDesktop) {
31712
32264
 
31713
32265
  ` : "").trimEnd();
31714
32266
  }
31715
- var TOPICS, TEAM_BUILD, RUN, skill, PLAIN_TEXT;
32267
+ var TOPICS, RUN, skill, PLAIN_TEXT;
31716
32268
  var init_skill = __esm({
31717
32269
  "src/commands/skill.js"() {
31718
32270
  "use strict";
@@ -31740,11 +32292,8 @@ var init_skill = __esm({
31740
32292
  "sign-in": sign_in_default,
31741
32293
  faq: faq_default
31742
32294
  };
31743
- TEAM_BUILD = CLI_RUN.includes("@kombai-io/");
31744
32295
  RUN = `Commands here are written as \`kombai <command>\`. If \`kombai --version\` does not run, put
31745
- \`${CLI_RUN}\` in place of \`kombai\` in every command, in full, never from a variable.${TEAM_BUILD ? `
31746
- That package is on GitHub Packages: npx finds it only once npm has @kombai-io:registry set to
31747
- https://npm.pkg.github.com and a token for it. If npx fails with 401 or 404, ask the user to set that up.` : ""}`;
32296
+ \`${CLI_RUN}\` in place of \`kombai\` in every command, in full, never from a variable.`;
31748
32297
  skill = {
31749
32298
  name: "skill",
31750
32299
  summary: "Print the skill's text, or one topic of it. Plain text: these are the agent's instructions.",
@@ -33350,6 +33899,87 @@ var init_commands = __esm({
33350
33899
  }
33351
33900
  });
33352
33901
 
33902
+ // src/lib/app-skills.js
33903
+ import { access, readdir, rm } from "node:fs/promises";
33904
+ import path21 from "node:path";
33905
+ function appSkillDirsOf(home, env) {
33906
+ const dirs = [
33907
+ path21.join(home, ".claude", "skills"),
33908
+ path21.join(home, ".agents", "skills"),
33909
+ path21.join(home, ".cursor", "skills"),
33910
+ path21.join(home, ".copilot", "skills"),
33911
+ path21.join(home, ".gemini", "skills"),
33912
+ path21.join(home, ".gemini", "config", "skills")
33913
+ ];
33914
+ if (env.CLAUDE_CONFIG_DIR) dirs.push(path21.join(path21.resolve(env.CLAUDE_CONFIG_DIR), "skills"));
33915
+ return [...new Set(dirs)];
33916
+ }
33917
+ async function removeAppSkillsOnce(ctx) {
33918
+ if (ctx.appSkillDirs.length === 0) return;
33919
+ const record2 = storePaths(ctx.home).appSkillsRemoved;
33920
+ try {
33921
+ await access(record2);
33922
+ return;
33923
+ } catch {
33924
+ }
33925
+ if (!await removeAppSkills(ctx.appSkillDirs)) return;
33926
+ try {
33927
+ await ensureDir(ctx.home);
33928
+ await writeFileAtomic(record2, `${new Date(ctx.now()).toISOString()}
33929
+ `);
33930
+ } catch {
33931
+ }
33932
+ }
33933
+ async function removeAppSkills(dirs) {
33934
+ const done = await Promise.all(
33935
+ dirs.map(async (dir) => {
33936
+ let names;
33937
+ try {
33938
+ names = await readdir(dir);
33939
+ } catch (error2) {
33940
+ const code2 = (
33941
+ /** @type {NodeJS.ErrnoException} */
33942
+ error2.code
33943
+ );
33944
+ return code2 === "ENOENT" || code2 === "ENOTDIR";
33945
+ }
33946
+ const removed = await Promise.all(
33947
+ names.filter((name) => APP_SKILL_NAMES.has(name)).map(
33948
+ (name) => rm(path21.join(dir, name), { recursive: true, force: true }).then(
33949
+ () => true,
33950
+ () => false
33951
+ )
33952
+ )
33953
+ );
33954
+ return removed.every(Boolean);
33955
+ })
33956
+ );
33957
+ return done.every(Boolean);
33958
+ }
33959
+ var APP_SKILL_NAMES;
33960
+ var init_app_skills = __esm({
33961
+ "src/lib/app-skills.js"() {
33962
+ "use strict";
33963
+ init_define_KOMBAI_TELEMETRY();
33964
+ init_fsx();
33965
+ init_store();
33966
+ APP_SKILL_NAMES = /* @__PURE__ */ new Set([
33967
+ "code-kombai-design",
33968
+ "code-with-kombai",
33969
+ "describe-kombai-canvas",
33970
+ "design-with-kombai",
33971
+ "detect-design-system-with-kombai",
33972
+ "improve-ui-with-kombai",
33973
+ "kombai-faq",
33974
+ "kombai-status",
33975
+ "report-to-kombai",
33976
+ "review-ui-with-kombai",
33977
+ "diagnose-kombai",
33978
+ "open-in-kombai"
33979
+ ]);
33980
+ }
33981
+ });
33982
+
33353
33983
  // src/lib/args.js
33354
33984
  function parseArgv(argv, commands) {
33355
33985
  const pretty = argv.includes("--pretty");
@@ -33569,6 +34199,15 @@ var init_posthog = __esm({
33569
34199
  import { spawn as spawn4 } from "node:child_process";
33570
34200
  import { randomUUID as randomUUID3 } from "node:crypto";
33571
34201
  import os3 from "node:os";
34202
+ async function guestBefore(ctx) {
34203
+ if (!ctx.telemetry.keys) return void 0;
34204
+ try {
34205
+ const { env } = await currentEnv(ctx);
34206
+ return isPureGuest(await readEntry(ctx.home, env));
34207
+ } catch {
34208
+ return false;
34209
+ }
34210
+ }
33572
34211
  async function sendTelemetry(ctx, ran) {
33573
34212
  const table = ctx.telemetry.keys;
33574
34213
  if (!table) return;
@@ -33583,7 +34222,7 @@ async function sendTelemetry(ctx, ran) {
33583
34222
  const scope = {
33584
34223
  env,
33585
34224
  userId: entry ? keyOf(entry)?.userId : void 0,
33586
- guest: entry ? isPureGuest(entry) : false,
34225
+ guest: (entry ? isPureGuest(entry) : false) || ran.wasGuest === true && !(entry && holdsAccount(entry)),
33587
34226
  command: ran.command
33588
34227
  };
33589
34228
  const requests = [];
@@ -33756,14 +34395,14 @@ var init_telemetry = __esm({
33756
34395
  // src/lib/context.js
33757
34396
  import { randomUUID as randomUUID4 } from "node:crypto";
33758
34397
  import os4 from "node:os";
33759
- import path21 from "node:path";
34398
+ import path22 from "node:path";
33760
34399
  function createContext(overrides = {}) {
33761
34400
  const platform2 = overrides.platform ?? process.platform;
33762
34401
  const stdout = overrides.stdout ?? process.stdout;
33763
34402
  const ctx = {
33764
34403
  stdout,
33765
34404
  stderr: process.stderr,
33766
- home: path21.join(os4.homedir(), ".kombai", "cli"),
34405
+ home: path22.join(os4.homedir(), ".kombai", "cli"),
33767
34406
  cwd: process.cwd(),
33768
34407
  fetch: globalThis.fetch,
33769
34408
  now: Date.now,
@@ -33785,6 +34424,7 @@ function createContext(overrides = {}) {
33785
34424
  sandbox: sandboxOf(process.env),
33786
34425
  claudeDesktop: process.env.CLAUDE_CODE_ENTRYPOINT === "claude-desktop",
33787
34426
  changeSent: false,
34427
+ appSkillDirs: appSkillDirsOf(os4.homedir(), process.env),
33788
34428
  ...overrides
33789
34429
  };
33790
34430
  return ctx;
@@ -33793,6 +34433,7 @@ var init_context = __esm({
33793
34433
  "src/lib/context.js"() {
33794
34434
  "use strict";
33795
34435
  init_define_KOMBAI_TELEMETRY();
34436
+ init_app_skills();
33796
34437
  init_deadline();
33797
34438
  init_open();
33798
34439
  init_output();
@@ -33809,10 +34450,12 @@ __export(cli_exports, {
33809
34450
  });
33810
34451
  async function run(argv, overrides = {}) {
33811
34452
  const ctx = createContext(overrides);
34453
+ const appSkills = removeAppSkillsOnce(ctx);
33812
34454
  ctx.pretty = argv.includes("--pretty");
33813
34455
  const started = ctx.now();
33814
- const ran = { command: null, help: false };
34456
+ const ran = { command: null, help: false, wasGuest: await guestBefore(ctx) };
33815
34457
  const exit = await execute(ctx, argv, ran);
34458
+ await appSkills;
33816
34459
  await sendTelemetry(ctx, { ...ran, exit, ms: ctx.now() - started });
33817
34460
  return exit;
33818
34461
  }
@@ -33900,6 +34543,7 @@ var init_cli = __esm({
33900
34543
  init_define_KOMBAI_TELEMETRY();
33901
34544
  init_commands();
33902
34545
  init_skill();
34546
+ init_app_skills();
33903
34547
  init_args();
33904
34548
  init_context();
33905
34549
  init_output();