@kryd/cli 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +71 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -14666,6 +14666,23 @@ function date4(params) {
14666
14666
  config(en_default());
14667
14667
 
14668
14668
  // ../../packages/shared-types/dist/usage.js
14669
+ var USAGE_OUTCOME = {
14670
+ ok: "ok",
14671
+ /** Refused by the request-rate limiter. */
14672
+ throttledRate: "throttled_rate",
14673
+ /** Refused by the daily token cap. */
14674
+ throttledCap: "throttled_cap"
14675
+ };
14676
+ var USAGE_OUTCOMES = [
14677
+ USAGE_OUTCOME.ok,
14678
+ USAGE_OUTCOME.throttledRate,
14679
+ USAGE_OUTCOME.throttledCap
14680
+ ];
14681
+ var STORAGE_FRESHNESS_MS = 3 * 60 * 60 * 1e3;
14682
+ var USAGE_THROTTLED_OUTCOMES = [
14683
+ USAGE_OUTCOME.throttledRate,
14684
+ USAGE_OUTCOME.throttledCap
14685
+ ];
14669
14686
  var usageEventSchema = external_exports.object({
14670
14687
  // Gateway-assigned id (stable across POST retries) → the ingest inserts `onConflictDoNothing` on
14671
14688
  // it, so a re-sent batch after a lost ACK never double-counts (KRYD-35 review).
@@ -14688,7 +14705,7 @@ var usageEventSchema = external_exports.object({
14688
14705
  // fail the whole batch — so one malformed outcome can't discard up to 999 valid usage events in the
14689
14706
  // same POST (the batch-loss failure mode the FK-free `account_id` decision already guards, KRYD-35).
14690
14707
  // Because only in-set values are ever persisted, the DB column needs no CHECK constraint.
14691
- outcome: external_exports.enum(["ok", "throttled_rate", "throttled_cap"]).default("ok").catch("ok")
14708
+ outcome: external_exports.enum(USAGE_OUTCOMES).default(USAGE_OUTCOME.ok).catch(USAGE_OUTCOME.ok)
14692
14709
  });
14693
14710
  var usageIngestBatchSchema = external_exports.object({
14694
14711
  events: external_exports.array(usageEventSchema).min(1).max(1e3)
@@ -15750,6 +15767,29 @@ var VITE_META_FRAMEWORKS = [
15750
15767
  "vike"
15751
15768
  ];
15752
15769
  var SERVER_FRAMEWORKS = ["hono", "express", "fastify", "koa"];
15770
+ var NON_NODE_START_TOOLS = [
15771
+ "vite",
15772
+ "next",
15773
+ "astro",
15774
+ "nuxt",
15775
+ "remix",
15776
+ "react-router",
15777
+ "svelte",
15778
+ "solid-start",
15779
+ "qwik",
15780
+ "vike",
15781
+ "parcel",
15782
+ "webpack",
15783
+ "rollup",
15784
+ "serve",
15785
+ "http-server"
15786
+ ];
15787
+ function startScriptLooksLikePlainNode(start) {
15788
+ const s = start.toLowerCase();
15789
+ return !NON_NODE_START_TOOLS.some(
15790
+ (tool) => new RegExp(`(^|[\\s/"'\`=])${tool}([\\s@/"'\`]|$)`).test(s)
15791
+ );
15792
+ }
15753
15793
  function readPackageJson(cwd) {
15754
15794
  try {
15755
15795
  return JSON.parse(readFileSync2(join2(cwd, "package.json"), "utf8"));
@@ -15767,6 +15807,8 @@ function frameworkFrom(pkg, cwd) {
15767
15807
  if (VITE_META_FRAMEWORKS.some(has)) return null;
15768
15808
  if (SERVER_FRAMEWORKS.some(has)) return "node";
15769
15809
  if (has("vite")) return "vite-spa";
15810
+ const start = pkg?.scripts?.start?.trim();
15811
+ if (start && startScriptLooksLikePlainNode(start)) return "node";
15770
15812
  return null;
15771
15813
  }
15772
15814
  function nameFrom(pkg, cwd) {
@@ -15885,16 +15927,34 @@ function configureGitRemote(cwd, remote, url2) {
15885
15927
  }
15886
15928
  try {
15887
15929
  const remotes = run(["remote"]).split(/\s+/).filter(Boolean);
15888
- if (remotes.includes(remote)) {
15889
- run(["remote", "set-url", remote, url2]);
15890
- return { status: "updated", remote };
15891
- }
15892
- run(["remote", "add", remote, url2]);
15893
- return { status: "added", remote };
15930
+ const status = remotes.includes(remote) ? "updated" : "added";
15931
+ if (status === "updated") run(["remote", "set-url", remote, url2]);
15932
+ else run(["remote", "add", remote, url2]);
15933
+ return { status, remote, tracking: setUpstreamIfUnset(run, remote) };
15894
15934
  } catch {
15895
15935
  return { status: "unavailable" };
15896
15936
  }
15897
15937
  }
15938
+ function setUpstreamIfUnset(run, remote) {
15939
+ let branch;
15940
+ try {
15941
+ branch = run(["symbolic-ref", "--short", "HEAD"]);
15942
+ } catch {
15943
+ return "detached";
15944
+ }
15945
+ if (!branch) return "detached";
15946
+ try {
15947
+ if (run(["config", "--get", `branch.${branch}.remote`])) return "kept-existing";
15948
+ } catch {
15949
+ }
15950
+ try {
15951
+ run(["config", `branch.${branch}.remote`, remote]);
15952
+ run(["config", `branch.${branch}.merge`, `refs/heads/${branch}`]);
15953
+ return "set";
15954
+ } catch {
15955
+ return "unavailable";
15956
+ }
15957
+ }
15898
15958
  function probe(cwd, args) {
15899
15959
  try {
15900
15960
  const value = execFileSync("git", args, {
@@ -16063,7 +16123,9 @@ async function runInit(opts) {
16063
16123
  case "added":
16064
16124
  case "updated":
16065
16125
  nextStep = `${remote.status === "added" ? "Added" : "Updated"} git remote "${remote.remote}" (with your push credential).
16066
- Next: kryd push # push to deploy (same as \`git push ${remote.remote} ${branch}\`)
16126
+ ` + (remote.tracking === "set" ? `Tracking set: \`git push\` and \`kryd push\` both deploy this branch.
16127
+ ` : remote.tracking === "kept-existing" ? `This branch already tracks another remote, so it was left alone \u2014 deploy with \`kryd push\`.
16128
+ ` : "") + `Next: kryd push # push to deploy (same as \`git push ${remote.remote} ${branch}\`)
16067
16129
  `;
16068
16130
  break;
16069
16131
  case "not-a-repo":
@@ -17212,7 +17274,7 @@ Run \`kryd env list\` to see what is set. (If you meant the runtime variable of
17212
17274
  reportError(err);
17213
17275
  }
17214
17276
  }
17215
- var CLI_VERSION = true ? "0.4.0" : "0.0.0-dev";
17277
+ var CLI_VERSION = true ? "0.4.1" : "0.0.0-dev";
17216
17278
  var program = new Command();
17217
17279
  program.name("kryd").description("Kryd CLI").version(CLI_VERSION);
17218
17280
  program.command("login").description("Sign in via the browser (default) and store a token").option("--email <email>", "account email (with --password; non-interactive escape hatch)").option("--password <password>", "account password (with --email; visible in `ps` \u2014 prefer the browser flow)").option(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kryd/cli",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Kryd CLI — push a React / Vite / Next.js app to the European cloud for your AI: git push → live with SSL, one-click managed Postgres & object storage, and an EU-hosted AI gateway already wired in. Your code and your model calls stay in the EU.",
5
5
  "keywords": [
6
6
  "kryd",