@islamihab/kds 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +153 -37
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -14421,7 +14421,9 @@ var printHelp = (help) => {
14421
14421
  console.log(`${help.description}
14422
14422
  `);
14423
14423
  console.log(`Usage: ${help.path}${usageCommands}${usageOptions}${usagePositionals}`);
14424
- const printSection = (title, entries, width) => {
14424
+ const labels = [commands, positionals, options].flatMap((entries) => entries ?? []);
14425
+ const width = Math.max(...labels.map(({ label }) => label.length));
14426
+ const printSection = (title, entries) => {
14425
14427
  if (!entries?.length)
14426
14428
  return;
14427
14429
  console.log(`
@@ -14429,9 +14431,9 @@ ${title}:`);
14429
14431
  for (const entry of entries)
14430
14432
  console.log(` ${entry.label.padEnd(width)} ${entry.description}`);
14431
14433
  };
14432
- printSection("Commands", commands, 12);
14433
- printSection("Arguments", positionals, 28);
14434
- printSection("Options", options, 28);
14434
+ printSection("Commands", commands);
14435
+ printSection("Arguments", positionals);
14436
+ printSection("Options", options);
14435
14437
  };
14436
14438
  var baseType = (field) => {
14437
14439
  let t = field;
@@ -14585,7 +14587,7 @@ import { join } from "path";
14585
14587
  // package.json
14586
14588
  var package_default = {
14587
14589
  name: "cli",
14588
- version: "0.1.2",
14590
+ version: "0.1.4",
14589
14591
  private: true,
14590
14592
  type: "module",
14591
14593
  bin: {
@@ -14624,7 +14626,7 @@ var DEFAULT_SERVER_URL = "https://dashboard.kaidev.studio";
14624
14626
  var DISCOVERY_PATH = "/api/discovery";
14625
14627
  var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
14626
14628
  var REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
14627
- // ../../node_modules/.bun/convex@1.42.1+e14d3f224186685e/node_modules/convex/dist/esm/values/base64.js
14629
+ // ../../node_modules/.bun/convex@1.43.0+e14d3f224186685e/node_modules/convex/dist/esm/values/base64.js
14628
14630
  var lookup = [];
14629
14631
  var revLookup = [];
14630
14632
  var Arr = Uint8Array;
@@ -14708,7 +14710,7 @@ function fromByteArray(uint8) {
14708
14710
  return parts.join("");
14709
14711
  }
14710
14712
 
14711
- // ../../node_modules/.bun/convex@1.42.1+e14d3f224186685e/node_modules/convex/dist/esm/common/index.js
14713
+ // ../../node_modules/.bun/convex@1.43.0+e14d3f224186685e/node_modules/convex/dist/esm/common/index.js
14712
14714
  function parseArgs2(args) {
14713
14715
  if (args === undefined) {
14714
14716
  return {};
@@ -14744,13 +14746,33 @@ function isSimpleObject(value) {
14744
14746
  return isObject2 && isSimple;
14745
14747
  }
14746
14748
 
14747
- // ../../node_modules/.bun/convex@1.42.1+e14d3f224186685e/node_modules/convex/dist/esm/values/value.js
14749
+ // ../../node_modules/.bun/convex@1.43.0+e14d3f224186685e/node_modules/convex/dist/esm/values/value.js
14748
14750
  var LITTLE_ENDIAN = true;
14749
14751
  var MIN_INT64 = BigInt("-9223372036854775808");
14750
14752
  var MAX_INT64 = BigInt("9223372036854775807");
14751
14753
  var ZERO = BigInt("0");
14752
14754
  var EIGHT = BigInt("8");
14753
14755
  var TWOFIFTYSIX = BigInt("256");
14756
+ var COMMIT_TS_UNRESOLVED = "This commit timestamp is unresolved: its value is assigned when the mutation commits. Read the document after the mutation completes to get its value.";
14757
+
14758
+ class CommitTsPlaceholder {
14759
+ [Symbol.toPrimitive](hint) {
14760
+ if (hint === "string") {
14761
+ return this.toString();
14762
+ }
14763
+ throw new Error(COMMIT_TS_UNRESOLVED);
14764
+ }
14765
+ valueOf() {
14766
+ throw new Error(COMMIT_TS_UNRESOLVED);
14767
+ }
14768
+ toJSON() {
14769
+ throw new Error(COMMIT_TS_UNRESOLVED);
14770
+ }
14771
+ toString() {
14772
+ return "[unresolved commit timestamp]";
14773
+ }
14774
+ }
14775
+ var commitTsPlaceholder = new CommitTsPlaceholder;
14754
14776
  function isSpecial(n) {
14755
14777
  return Number.isNaN(n) || !Number.isFinite(n) || Object.is(n, -0);
14756
14778
  }
@@ -14867,6 +14889,12 @@ function jsonToConvex(value) {
14867
14889
  }
14868
14890
  return float;
14869
14891
  }
14892
+ if (key === "$commitTs") {
14893
+ if (value.$commitTs !== null) {
14894
+ throw new Error(`Malformed $commitTs field on ${value}`);
14895
+ }
14896
+ return commitTsPlaceholder;
14897
+ }
14870
14898
  if (key === "$set") {
14871
14899
  throw new Error(`Received a Set which is no longer supported as a Convex type.`);
14872
14900
  }
@@ -14935,6 +14963,9 @@ function convexToJsonInternal(value, originalValue, context, includeTopLevelUnde
14935
14963
  if (value instanceof ArrayBuffer) {
14936
14964
  return { $bytes: fromByteArray(new Uint8Array(value)) };
14937
14965
  }
14966
+ if (value instanceof CommitTsPlaceholder) {
14967
+ return { $commitTs: null };
14968
+ }
14938
14969
  if (Array.isArray(value)) {
14939
14970
  return value.map((value2, i2) => convexToJsonInternal(value2, originalValue, context + `[${i2}]`, false));
14940
14971
  }
@@ -14983,10 +15014,10 @@ function convexOrUndefinedToJsonInternal(value, originalValue, context) {
14983
15014
  function convexToJson(value) {
14984
15015
  return convexToJsonInternal(value, value, "", false);
14985
15016
  }
14986
- // ../../node_modules/.bun/convex@1.42.1+e14d3f224186685e/node_modules/convex/dist/esm/server/functionName.js
15017
+ // ../../node_modules/.bun/convex@1.43.0+e14d3f224186685e/node_modules/convex/dist/esm/server/functionName.js
14987
15018
  var functionName = Symbol.for("functionName");
14988
15019
 
14989
- // ../../node_modules/.bun/convex@1.42.1+e14d3f224186685e/node_modules/convex/dist/esm/server/components/paths.js
15020
+ // ../../node_modules/.bun/convex@1.43.0+e14d3f224186685e/node_modules/convex/dist/esm/server/components/paths.js
14990
15021
  var toReferencePath = Symbol.for("toReferencePath");
14991
15022
  function extractReferencePath(reference) {
14992
15023
  return reference[toReferencePath] ?? null;
@@ -15014,7 +15045,7 @@ function getFunctionAddress(functionReference) {
15014
15045
  return functionAddress;
15015
15046
  }
15016
15047
 
15017
- // ../../node_modules/.bun/convex@1.42.1+e14d3f224186685e/node_modules/convex/dist/esm/server/api.js
15048
+ // ../../node_modules/.bun/convex@1.43.0+e14d3f224186685e/node_modules/convex/dist/esm/server/api.js
15018
15049
  function getFunctionName(functionReference) {
15019
15050
  const address = getFunctionAddress(functionReference);
15020
15051
  if (address.name === undefined) {
@@ -15061,10 +15092,10 @@ function createApi(pathParts = []) {
15061
15092
  return new Proxy({}, handler);
15062
15093
  }
15063
15094
  var anyApi = createApi();
15064
- // ../../node_modules/.bun/convex@1.42.1+e14d3f224186685e/node_modules/convex/dist/esm/index.js
15065
- var version2 = "1.42.1";
15095
+ // ../../node_modules/.bun/convex@1.43.0+e14d3f224186685e/node_modules/convex/dist/esm/index.js
15096
+ var version2 = "1.43.0";
15066
15097
 
15067
- // ../../node_modules/.bun/convex@1.42.1+e14d3f224186685e/node_modules/convex/dist/esm/values/errors.js
15098
+ // ../../node_modules/.bun/convex@1.43.0+e14d3f224186685e/node_modules/convex/dist/esm/values/errors.js
15068
15099
  var __defProp2 = Object.defineProperty;
15069
15100
  var __defNormalProp = (obj, key, value) => (key in obj) ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15070
15101
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -15082,7 +15113,7 @@ class ConvexError extends (_b = Error, _a3 = IDENTIFYING_FIELD, _b) {
15082
15113
  }
15083
15114
  }
15084
15115
 
15085
- // ../../node_modules/.bun/convex@1.42.1+e14d3f224186685e/node_modules/convex/dist/esm/server/components/index.js
15116
+ // ../../node_modules/.bun/convex@1.43.0+e14d3f224186685e/node_modules/convex/dist/esm/server/components/index.js
15086
15117
  function createChildComponents(root, pathParts) {
15087
15118
  const handler = {
15088
15119
  get(_, prop) {
@@ -15111,13 +15142,15 @@ var components = componentsGeneric();
15111
15142
  var KDS_DEVICE_AUTH_CLIENT_ID = "kds-cli";
15112
15143
  var PAGE_MODES = ["themed", "raw"];
15113
15144
  var PAGE_VISIBILITIES = ["public", "private"];
15145
+ var MAX_PAGE_HTML_BYTES = 4000000;
15146
+ var MAX_PROJECT_REPO_LENGTH = 200;
15114
15147
 
15115
15148
  // src/commands/auth/login.ts
15116
15149
  import open from "open";
15117
- // ../../node_modules/.bun/@convex-dev+better-auth@0.12.1+7592867d216cc73d/node_modules/@convex-dev/better-auth/dist/version.js
15150
+ // ../../node_modules/.bun/@convex-dev+better-auth@0.12.1+2116c7faeda40f52/node_modules/@convex-dev/better-auth/dist/version.js
15118
15151
  var VERSION = "0.12.1";
15119
15152
 
15120
- // ../../node_modules/.bun/@convex-dev+better-auth@0.12.1+7592867d216cc73d/node_modules/@convex-dev/better-auth/dist/plugins/convex/client.js
15153
+ // ../../node_modules/.bun/@convex-dev+better-auth@0.12.1+2116c7faeda40f52/node_modules/@convex-dev/better-auth/dist/plugins/convex/client.js
15121
15154
  var convexClient = () => {
15122
15155
  return {
15123
15156
  id: "convex",
@@ -15309,7 +15342,7 @@ var BetterAuthError = class extends Error {
15309
15342
  }
15310
15343
  };
15311
15344
 
15312
- // ../../node_modules/.bun/better-auth@1.6.23+7367520ea0616224/node_modules/better-auth/dist/utils/url.mjs
15345
+ // ../../node_modules/.bun/better-auth@1.6.23+2c138958c46c0bcd/node_modules/better-auth/dist/utils/url.mjs
15313
15346
  var SLASH_CHAR_CODE = 47;
15314
15347
  function trimTrailingSlashes(value) {
15315
15348
  let end = value.length;
@@ -15399,13 +15432,13 @@ function getOrigin(url2) {
15399
15432
  return null;
15400
15433
  }
15401
15434
  }
15402
- // ../../node_modules/.bun/better-auth@1.6.23+7367520ea0616224/node_modules/better-auth/dist/package.mjs
15435
+ // ../../node_modules/.bun/better-auth@1.6.23+2c138958c46c0bcd/node_modules/better-auth/dist/package.mjs
15403
15436
  var version3 = "1.6.23";
15404
15437
 
15405
- // ../../node_modules/.bun/better-auth@1.6.23+7367520ea0616224/node_modules/better-auth/dist/version.mjs
15438
+ // ../../node_modules/.bun/better-auth@1.6.23+2c138958c46c0bcd/node_modules/better-auth/dist/version.mjs
15406
15439
  var PACKAGE_VERSION = version3;
15407
15440
 
15408
- // ../../node_modules/.bun/better-auth@1.6.23+7367520ea0616224/node_modules/better-auth/dist/client/broadcast-channel.mjs
15441
+ // ../../node_modules/.bun/better-auth@1.6.23+2c138958c46c0bcd/node_modules/better-auth/dist/client/broadcast-channel.mjs
15409
15442
  var kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
15410
15443
  var now = () => Math.floor(Date.now() / 1000);
15411
15444
  var WindowBroadcastChannel = class {
@@ -15639,7 +15672,7 @@ var onMount = ($store, initialize) => {
15639
15672
  };
15640
15673
  });
15641
15674
  };
15642
- // ../../node_modules/.bun/better-auth@1.6.23+7367520ea0616224/node_modules/better-auth/dist/client/equality.mjs
15675
+ // ../../node_modules/.bun/better-auth@1.6.23+2c138958c46c0bcd/node_modules/better-auth/dist/client/equality.mjs
15643
15676
  function isPlainObject2(value) {
15644
15677
  if (typeof value !== "object" || value === null)
15645
15678
  return false;
@@ -15676,7 +15709,7 @@ function withEquality(store, isEqual) {
15676
15709
  });
15677
15710
  }
15678
15711
 
15679
- // ../../node_modules/.bun/better-auth@1.6.23+7367520ea0616224/node_modules/better-auth/dist/client/focus-manager.mjs
15712
+ // ../../node_modules/.bun/better-auth@1.6.23+2c138958c46c0bcd/node_modules/better-auth/dist/client/focus-manager.mjs
15680
15713
  var kFocusManager = Symbol.for("better-auth:focus-manager");
15681
15714
  var WindowFocusManager = class {
15682
15715
  listeners = /* @__PURE__ */ new Set;
@@ -15708,7 +15741,7 @@ function getGlobalFocusManager() {
15708
15741
  return globalThis[kFocusManager];
15709
15742
  }
15710
15743
 
15711
- // ../../node_modules/.bun/better-auth@1.6.23+7367520ea0616224/node_modules/better-auth/dist/client/online-manager.mjs
15744
+ // ../../node_modules/.bun/better-auth@1.6.23+2c138958c46c0bcd/node_modules/better-auth/dist/client/online-manager.mjs
15712
15745
  var kOnlineManager = Symbol.for("better-auth:online-manager");
15713
15746
  var WindowOnlineManager = class {
15714
15747
  listeners = /* @__PURE__ */ new Set;
@@ -15742,7 +15775,7 @@ function getGlobalOnlineManager() {
15742
15775
  return globalThis[kOnlineManager];
15743
15776
  }
15744
15777
 
15745
- // ../../node_modules/.bun/better-auth@1.6.23+7367520ea0616224/node_modules/better-auth/dist/client/parser.mjs
15778
+ // ../../node_modules/.bun/better-auth@1.6.23+2c138958c46c0bcd/node_modules/better-auth/dist/client/parser.mjs
15746
15779
  var PROTO_POLLUTION_PATTERNS = {
15747
15780
  proto: /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,
15748
15781
  constructor: /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,
@@ -15820,7 +15853,7 @@ function parseJSON(value, options = { strict: true }) {
15820
15853
  return betterJSONParse(value, options);
15821
15854
  }
15822
15855
 
15823
- // ../../node_modules/.bun/better-auth@1.6.23+7367520ea0616224/node_modules/better-auth/dist/client/session-refresh.mjs
15856
+ // ../../node_modules/.bun/better-auth@1.6.23+2c138958c46c0bcd/node_modules/better-auth/dist/client/session-refresh.mjs
15824
15857
  var now2 = () => Math.floor(Date.now() / 1000);
15825
15858
  var FOCUS_REFETCH_RATE_LIMIT_SECONDS = 5;
15826
15859
  function createSessionRefreshManager(opts) {
@@ -15968,7 +16001,7 @@ function isSafeUrlScheme(value) {
15968
16001
  return !DANGEROUS_URL_SCHEMES.includes(parsed.protocol);
15969
16002
  }
15970
16003
 
15971
- // ../../node_modules/.bun/better-auth@1.6.23+7367520ea0616224/node_modules/better-auth/dist/client/fetch-plugins.mjs
16004
+ // ../../node_modules/.bun/better-auth@1.6.23+2c138958c46c0bcd/node_modules/better-auth/dist/client/fetch-plugins.mjs
15972
16005
  var redirectPlugin = {
15973
16006
  id: "redirect",
15974
16007
  name: "Redirect",
@@ -15984,7 +16017,7 @@ var redirectPlugin = {
15984
16017
  } }
15985
16018
  };
15986
16019
 
15987
- // ../../node_modules/.bun/better-auth@1.6.23+7367520ea0616224/node_modules/better-auth/dist/client/session-atom.mjs
16020
+ // ../../node_modules/.bun/better-auth@1.6.23+2c138958c46c0bcd/node_modules/better-auth/dist/client/session-atom.mjs
15988
16021
  var isServer = () => typeof window === "undefined";
15989
16022
  function normalizeSessionResponse(res) {
15990
16023
  if (typeof res === "object" && res !== null && "data" in res && "error" in res)
@@ -16825,7 +16858,7 @@ var betterFetch = async (url2, options) => {
16825
16858
  };
16826
16859
  };
16827
16860
 
16828
- // ../../node_modules/.bun/better-auth@1.6.23+7367520ea0616224/node_modules/better-auth/dist/client/config.mjs
16861
+ // ../../node_modules/.bun/better-auth@1.6.23+2c138958c46c0bcd/node_modules/better-auth/dist/client/config.mjs
16829
16862
  var resolvePublicAuthUrl = (basePath) => {
16830
16863
  if (typeof process === "undefined")
16831
16864
  return;
@@ -16935,7 +16968,7 @@ var getClientConfig = (options, loadEnv) => {
16935
16968
  };
16936
16969
  };
16937
16970
 
16938
- // ../../node_modules/.bun/better-auth@1.6.23+7367520ea0616224/node_modules/better-auth/dist/utils/is-atom.mjs
16971
+ // ../../node_modules/.bun/better-auth@1.6.23+2c138958c46c0bcd/node_modules/better-auth/dist/utils/is-atom.mjs
16939
16972
  function isAtom(value) {
16940
16973
  return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function" && "lc" in value && typeof value.lc === "number";
16941
16974
  }
@@ -16953,7 +16986,7 @@ function toKebabCase(input) {
16953
16986
  return splitWords(input).map((word) => word.toLowerCase()).join("-");
16954
16987
  }
16955
16988
 
16956
- // ../../node_modules/.bun/better-auth@1.6.23+7367520ea0616224/node_modules/better-auth/dist/client/proxy.mjs
16989
+ // ../../node_modules/.bun/better-auth@1.6.23+2c138958c46c0bcd/node_modules/better-auth/dist/client/proxy.mjs
16957
16990
  function getMethod2(path, knownPathMethods, args) {
16958
16991
  const method = knownPathMethods[path];
16959
16992
  const { fetchOptions, query: _query, ...body } = args || {};
@@ -17035,7 +17068,7 @@ function createDynamicPathProxy(routes, client3, knownPathMethods, atoms, atomLi
17035
17068
  return createProxy();
17036
17069
  }
17037
17070
 
17038
- // ../../node_modules/.bun/better-auth@1.6.23+7367520ea0616224/node_modules/better-auth/dist/client/vanilla.mjs
17071
+ // ../../node_modules/.bun/better-auth@1.6.23+2c138958c46c0bcd/node_modules/better-auth/dist/client/vanilla.mjs
17039
17072
  function createAuthClient(options) {
17040
17073
  const { pluginPathMethods, pluginsActions, pluginsAtoms, $fetch, atomListeners, $store } = getClientConfig(options);
17041
17074
  const resolvedHooks = {};
@@ -17048,7 +17081,7 @@ function createAuthClient(options) {
17048
17081
  $store
17049
17082
  }, $fetch, pluginPathMethods, pluginsAtoms, atomListeners);
17050
17083
  }
17051
- // ../../node_modules/.bun/better-auth@1.6.23+7367520ea0616224/node_modules/better-auth/dist/plugins/device-authorization/client.mjs
17084
+ // ../../node_modules/.bun/better-auth@1.6.23+2c138958c46c0bcd/node_modules/better-auth/dist/plugins/device-authorization/client.mjs
17052
17085
  var deviceAuthorizationClient = () => {
17053
17086
  return {
17054
17087
  id: "device-authorization",
@@ -17130,7 +17163,7 @@ var revokeCliSession = async (config2) => {
17130
17163
  throw new Error("The auth server did not confirm sign out");
17131
17164
  await saveConfig({ ...config2, sessionToken: undefined });
17132
17165
  };
17133
- // ../../node_modules/.bun/convex@1.42.1+e14d3f224186685e/node_modules/convex/dist/esm/browser/logging.js
17166
+ // ../../node_modules/.bun/convex@1.43.0+e14d3f224186685e/node_modules/convex/dist/esm/browser/logging.js
17134
17167
  var __defProp4 = Object.defineProperty;
17135
17168
  var __defNormalProp3 = (obj, key, value) => (key in obj) ? __defProp4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
17136
17169
  var __publicField2 = (obj, key, value) => __defNormalProp3(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -17236,7 +17269,7 @@ function logForFunction(logger2, type, source, udfPath, message) {
17236
17269
  }
17237
17270
  }
17238
17271
 
17239
- // ../../node_modules/.bun/convex@1.42.1+e14d3f224186685e/node_modules/convex/dist/esm/browser/http_client.js
17272
+ // ../../node_modules/.bun/convex@1.43.0+e14d3f224186685e/node_modules/convex/dist/esm/browser/http_client.js
17240
17273
  var __defProp5 = Object.defineProperty;
17241
17274
  var __defNormalProp4 = (obj, key, value) => (key in obj) ? __defProp5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
17242
17275
  var __publicField3 = (obj, key, value) => __defNormalProp4(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -17771,7 +17804,20 @@ var detectRepoGroup = async () => {
17771
17804
  var groupForCreate = async (group2) => group2 === null ? undefined : group2 ?? await detectRepoGroup();
17772
17805
 
17773
17806
  // src/lib/input.ts
17774
- var readBody = async (path) => path === "-" ? await Bun.stdin.text() : await Bun.file(path).text();
17807
+ var assertSize = (size) => {
17808
+ if (size > MAX_PAGE_HTML_BYTES)
17809
+ throw new Error(`Page is too large (${size} bytes; max ${MAX_PAGE_HTML_BYTES}).`);
17810
+ };
17811
+ var readBody = async (path) => {
17812
+ if (path === "-") {
17813
+ const html = await Bun.stdin.text();
17814
+ assertSize(new TextEncoder().encode(html).length);
17815
+ return html;
17816
+ }
17817
+ const file2 = Bun.file(path);
17818
+ assertSize(file2.size);
17819
+ return await file2.text();
17820
+ };
17775
17821
  var readPageId = (value) => {
17776
17822
  const trimmed = value.trim();
17777
17823
  try {
@@ -17968,6 +18014,76 @@ var pages = group({
17968
18014
  commands: [create, list, get, update, versions2, revert, remove]
17969
18015
  });
17970
18016
 
18017
+ // ../../packages/backend/convex/lib/projectRepo.ts
18018
+ var DEFAULT_REPO_HOST = "github.com";
18019
+ var REPO_FORMAT_ERROR = "Enter a repository like github.com/owner/name.";
18020
+ var HOST_PATTERN = /^[a-z0-9][a-z0-9.-]*\.[a-z]{2,}$/;
18021
+ var SEGMENT_PATTERN = /^[a-z0-9][a-z0-9._-]*$/;
18022
+ var normalizeProjectRepo = (value) => {
18023
+ const trimmed = value?.trim();
18024
+ if (!trimmed)
18025
+ return;
18026
+ if (trimmed.length > MAX_PROJECT_REPO_LENGTH) {
18027
+ throw new ConvexError(`Repository must be ${MAX_PROJECT_REPO_LENGTH} characters or fewer.`);
18028
+ }
18029
+ const path = trimmed.toLowerCase().replace(/^(https?|ssh|git):\/\//, "").replace(/^[^/@:]+@/, "").replace(":", "/").replace(/\/+$/, "").replace(/\.git$/, "");
18030
+ const segments = path.split("/");
18031
+ const [host, owner, name] = segments.length === 2 ? [DEFAULT_REPO_HOST, ...segments] : segments.length === 3 ? segments : [];
18032
+ if (!host || !owner || !name)
18033
+ throw new ConvexError(REPO_FORMAT_ERROR);
18034
+ if (!HOST_PATTERN.test(host) || !SEGMENT_PATTERN.test(owner) || !SEGMENT_PATTERN.test(name)) {
18035
+ throw new ConvexError(REPO_FORMAT_ERROR);
18036
+ }
18037
+ const key = `${host}/${owner}/${name}`;
18038
+ if (key.length > MAX_PROJECT_REPO_LENGTH) {
18039
+ throw new ConvexError(`Repository must be ${MAX_PROJECT_REPO_LENGTH} characters or fewer.`);
18040
+ }
18041
+ return key;
18042
+ };
18043
+ var tryNormalizeProjectRepo = (value) => {
18044
+ try {
18045
+ return normalizeProjectRepo(value);
18046
+ } catch {
18047
+ return;
18048
+ }
18049
+ };
18050
+
18051
+ // src/lib/repo.ts
18052
+ var currentRepoKey = async () => {
18053
+ const proc = Bun.spawn(["git", "remote", "get-url", "origin"], { stdout: "pipe", stderr: "ignore" });
18054
+ const url2 = await new Response(proc.stdout).text();
18055
+ return await proc.exited === 0 ? tryNormalizeProjectRepo(url2) : undefined;
18056
+ };
18057
+
18058
+ // src/commands/project.ts
18059
+ var project = command({
18060
+ name: "project",
18061
+ description: "Show the project connected to this checkout's repository",
18062
+ options: {
18063
+ repo: exports_external.string().optional().describe("Resolve this repository instead of the checkout's origin remote"),
18064
+ json: exports_external.boolean().default(false).describe("Print as JSON")
18065
+ },
18066
+ run: async ({ options: { repo: repoOption, json: json2 } }) => {
18067
+ const repo = repoOption ?? await currentRepoKey();
18068
+ if (!repo) {
18069
+ throw new Error("No repository here: not a git checkout with an origin remote. Pass --repo <owner/name>.");
18070
+ }
18071
+ const found = await (await backendClient()).query(api2.projects.findByRepo, { repo });
18072
+ if (!found)
18073
+ throw new Error(`No project is connected to ${repo}. Connect one on the project in the dashboard.`);
18074
+ if (json2)
18075
+ return console.log(JSON.stringify(found, null, 2));
18076
+ console.log(found.name);
18077
+ if (found.summary)
18078
+ console.log(found.summary);
18079
+ console.log(`Repo: ${found.repo}`);
18080
+ console.log(`Status: ${found.status}${found.health ? ` \xB7 Health: ${found.health}` : ""}`);
18081
+ console.log(`Progress: ${found.progress.done}/${found.progress.total} issues done`);
18082
+ if (found.targetDate)
18083
+ console.log(`Target date: ${found.targetDate}`);
18084
+ }
18085
+ });
18086
+
17971
18087
  // src/commands/upgrade.ts
17972
18088
  var upgrade = command({
17973
18089
  name: "upgrade",
@@ -17983,7 +18099,7 @@ var upgrade = command({
17983
18099
  var rootCommand = group({
17984
18100
  name: "kds",
17985
18101
  description: "KDS CLI",
17986
- commands: [auth, pages, upgrade],
18102
+ commands: [auth, pages, project, upgrade],
17987
18103
  options: {
17988
18104
  version: exports_external.boolean().default(false).describe("Show the version").meta({ short: "v" })
17989
18105
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@islamihab/kds",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Command-line client for Kai Dev Studio",
5
5
  "license": "MIT",
6
6
  "publishConfig": {