@thecms/cli 0.20.2-dev.130 → 0.20.3-dev.133

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.
@@ -175,7 +175,7 @@ function realContext(env = process.env) {
175
175
  import { parseArgs } from "util";
176
176
 
177
177
  // src/context.ts
178
- var CLI_VERSION = "0.20.2-dev.130";
178
+ var CLI_VERSION = "0.20.3-dev.133";
179
179
  function call(ctx, path, init = {}) {
180
180
  const { token, client = "cli", ...rest } = init;
181
181
  const headers = new Headers(rest.headers);
@@ -1545,6 +1545,20 @@ function workingApps(start) {
1545
1545
  if (!apps.length && dir !== root && existsSync3(join4(dir, PATHS.manifest))) return { root, apps: [dir], problems };
1546
1546
  return { root, apps, problems };
1547
1547
  }
1548
+ function projectCli(start) {
1549
+ const dir = resolve(start);
1550
+ for (const app of [dir, ...workingApps(dir).apps]) {
1551
+ const pkg = join4(app, "node_modules", "@thecms", "cli");
1552
+ const bin = join4(pkg, "dist", "cli.js");
1553
+ if (!existsSync3(bin)) continue;
1554
+ try {
1555
+ const version = JSON.parse(readFileSync4(join4(pkg, "package.json"), "utf8")).version;
1556
+ if (typeof version === "string") return { bin, version };
1557
+ } catch {
1558
+ }
1559
+ }
1560
+ return null;
1561
+ }
1548
1562
  var tokensOf = (app) => join4(projectRoot(app) ?? dirname(resolve(app)), PATHS.tokens);
1549
1563
  var CODE = /\.(ts|tsx|js|jsx|mjs|cjs|vue|svelte|astro)$/;
1550
1564
  var SKIP = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "out", "coverage", ".next", ".nuxt", ".svelte-kit", ".turbo", ".vercel"]);
@@ -8505,11 +8519,11 @@ async function upgradeOne(ctx, wanted, opts) {
8505
8519
  ctx.out("\xB7 No project here: only the CLI. In a project, thecms upgrade also brings its theCMS. packages to the same version");
8506
8520
  return 0;
8507
8521
  }
8508
- {
8522
+ const text2 = readFileSync17(file, "utf8");
8523
+ if (!Object.keys(declaredPackages(JSON.parse(text2))).includes(CLI_PACKAGE)) {
8509
8524
  const failed = await upgradeTheCli(ctx, version, opts.install !== false);
8510
8525
  if (failed !== null) return failed;
8511
8526
  }
8512
- const text2 = readFileSync17(file, "utf8");
8513
8527
  const npmrcBefore = readNpmrc(ctx.cwd);
8514
8528
  const manifest = JSON.parse(text2);
8515
8529
  const changed = [];
@@ -9506,15 +9520,23 @@ import { z } from "zod";
9506
9520
  // src/mcp/decide.ts
9507
9521
  var HOW_TO_ASK = "Ask the person now with your own interactive question tool: these options, the recommended first, the why in one line; then call again with the answer";
9508
9522
  var elicits = (server) => !!server.getClientCapabilities()?.elicitation?.form;
9523
+ var ASK_WAIT = { ms: 4e4 };
9509
9524
  function askerOf(server) {
9510
- return async ({ message, options }) => {
9525
+ const asker = async ({ message, options }) => {
9526
+ asker.timedOut = false;
9511
9527
  if (!elicits(server)) return null;
9512
- const result = await server.elicitInput({
9513
- message,
9514
- requestedSchema: { type: "object", properties: { choice: { type: "string", title: message, oneOf: options.map((o) => ({ const: o.value, title: o.label })) } }, required: ["choice"] }
9515
- });
9516
- return result.action === "accept" && typeof result.content?.choice === "string" ? result.content.choice : null;
9528
+ try {
9529
+ const result = await server.elicitInput({
9530
+ message,
9531
+ requestedSchema: { type: "object", properties: { choice: { type: "string", title: message, oneOf: options.map((o) => ({ const: o.value, title: o.label })) } }, required: ["choice"] }
9532
+ }, { timeout: ASK_WAIT.ms });
9533
+ return result.action === "accept" && typeof result.content?.choice === "string" ? result.content.choice : null;
9534
+ } catch {
9535
+ asker.timedOut = true;
9536
+ return null;
9537
+ }
9517
9538
  };
9539
+ return asker;
9518
9540
  }
9519
9541
  function planText(target, where, plan, checks = []) {
9520
9542
  const list = (items) => items.slice(0, 10).join("; ") + (items.length > 10 ? `; and ${items.length - 10} more` : "");
@@ -12217,6 +12239,7 @@ async function createMcp(ctx, opts = {}) {
12217
12239
  const open = review.length ? review : null;
12218
12240
  if (elicits(server.server)) {
12219
12241
  const choice = await session.asker({ message: planText(target, where, first.plan, first.checks), options: open ? REVIEW_OPTIONS : CONFIRM_OPTIONS });
12242
+ if (choice === null && session.asker.timedOut) return { ...first, workspace: where, ask: open ? reviewAsk(target, open) : confirmAsk(target, typeof why === "string" ? why : why(first)), note: "Nobody answered the confirmation window in time: nothing written \u2014 ask the person in the conversation, then call again with confirm: true" };
12220
12243
  if (choice === "write") return { ...await act({ ...input, confirm: true }), workspace: where, askedThrough: "elicitation" };
12221
12244
  return { ...first, workspace: where, note: choice === "review" ? "The person reviews the checks first: nothing written \u2014 change the wanted state and call again" : "The person did not confirm: nothing written", askedThrough: "elicitation" };
12222
12245
  }
@@ -13567,6 +13590,8 @@ function personalToken(ctx = realContext()) {
13567
13590
  }
13568
13591
 
13569
13592
  export {
13593
+ CLI_VERSION,
13594
+ projectCli,
13570
13595
  run,
13571
13596
  personalToken
13572
13597
  };
package/dist/cli.js CHANGED
@@ -1,11 +1,40 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ CLI_VERSION,
4
+ projectCli,
3
5
  run
4
- } from "./chunk-XA5W7CT3.js";
6
+ } from "./chunk-2CDNPQDR.js";
5
7
 
6
8
  // src/cli.ts
7
- run(process.argv.slice(2)).then((code) => process.exit(code)).catch((err) => {
8
- process.stderr.write(`\u2717 ${err.message}
9
+ import { spawn } from "child_process";
10
+ import { realpathSync } from "fs";
11
+ import { fileURLToPath } from "url";
12
+ var argv = process.argv.slice(2);
13
+ function localCli() {
14
+ if (process.env.THECMS_LOCAL_CLI) return null;
15
+ const local2 = projectCli(process.cwd());
16
+ if (!local2 || local2.version === CLI_VERSION) return null;
17
+ try {
18
+ if (realpathSync(local2.bin) === realpathSync(fileURLToPath(import.meta.url))) return null;
19
+ } catch {
20
+ return null;
21
+ }
22
+ return local2.bin;
23
+ }
24
+ var local = localCli();
25
+ if (local) {
26
+ const child = spawn(process.execPath, [local, ...argv], { stdio: "inherit", env: { ...process.env, THECMS_LOCAL_CLI: "1" } });
27
+ for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) process.on(signal, () => child.kill(signal));
28
+ child.on("exit", (code, signal) => process.exit(code ?? (signal ? 1 : 0)));
29
+ child.on("error", (err) => {
30
+ process.stderr.write(`\u2717 ${err.message}
9
31
  `);
10
- process.exit(1);
11
- });
32
+ process.exit(1);
33
+ });
34
+ } else {
35
+ run(argv).then((code) => process.exit(code)).catch((err) => {
36
+ process.stderr.write(`\u2717 ${err.message}
37
+ `);
38
+ process.exit(1);
39
+ });
40
+ }
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  personalToken,
4
4
  run
5
- } from "./chunk-XA5W7CT3.js";
5
+ } from "./chunk-2CDNPQDR.js";
6
6
  export {
7
7
  personalToken,
8
8
  run
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecms/cli",
3
- "version": "0.20.2-dev.130",
3
+ "version": "0.20.3-dev.133",
4
4
  "license": "UNLICENSED",
5
5
  "description": "theCMS. command line: the standard's starter, checks, brand, the method's docs, sign-in with a personal token",
6
6
  "type": "module",
@@ -36,7 +36,7 @@
36
36
  "dependencies": {
37
37
  "@modelcontextprotocol/sdk": "1.32.1",
38
38
  "@resvg/resvg-wasm": "2.6.2",
39
- "@thecms/sdk": "0.20.2-dev.130",
39
+ "@thecms/sdk": "0.20.3-dev.133",
40
40
  "libpg-query": "18.2.0",
41
41
  "zod": "4.6.5"
42
42
  },