@wirecat/cli-core 0.737.0 → 0.738.0

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/CHANGELOG.md CHANGED
@@ -5,6 +5,15 @@ Notable changes to `@wirecat/cli-core` (`@wirecat/cli-messaging` up to 0.261.0,
5
5
  minor version may break callers, and says how under "Changed — may break callers". `pnpm docs:check` checks the
6
6
  shape of this file.
7
7
 
8
+ ## 0.738.0 — 24.11.2026
9
+
10
+ ### Added
11
+
12
+ - **A token guide and the setup walk-through draw their links as links** in a terminal known to show OSC 8 links
13
+ (GNOME Terminal and other VTE ones, iTerm2, kitty, WezTerm, Windows Terminal, VS Code, Ghostty; `FORCE_HYPERLINK`
14
+ decides elsewhere), so a long address no longer fills the screen. Elsewhere the address is printed beside the words.
15
+ `session start` prints its guide as plain text with its own headings, not as a note line.
16
+
8
17
  ## 0.737.0 — 23.11.2026
9
18
 
10
19
  ### Added
@@ -58,8 +58,8 @@ export interface CopyAge {
58
58
  }
59
59
  export declare const ageOf: (lastSync: string | undefined, now?: number) => CopyAge;
60
60
  export declare const staleCopy: (provider: string, lastSync: string | undefined, now?: number) => {
61
- missing?: undefined;
62
61
  next?: undefined;
62
+ readonly missing?: undefined;
63
63
  meta?: undefined;
64
64
  } | {
65
65
  missing: {
@@ -6,6 +6,7 @@ import { agentOf } from "../runs/run-context.js";
6
6
  import { checkField, holds, nextOf, walk, } from "../setup/answers.js";
7
7
  import { SETUP_LIMITS } from "../setup/document.js";
8
8
  import { plainSetupText } from "../setup/plain.js";
9
+ import { drawsHyperlinks, hyperlink } from "../terminal/hyperlink.js";
9
10
  import { answerStdinOption, lineReader, signInSteps } from "../terminal/sign-in-steps.js";
10
11
  import { refuseGuardedKey } from "./config-command.js";
11
12
  import { baseContext, environmentOf, secretInputOf } from "./context.js";
@@ -265,7 +266,8 @@ export const setupCommand = (setup) => {
265
266
  const text = (id, params = {}) => id === undefined
266
267
  ? ""
267
268
  : (document.texts[language]?.[id] ?? document.texts.en[id] ?? id).replace(/\{([a-z][a-z0-9_]*)\}/g, (all, name) => params[name] ?? all);
268
- const say = (line) => renderer.note(plainSetupText(line));
269
+ const drawn = drawsHyperlinks(env) ? { link: hyperlink } : {};
270
+ const say = (line) => renderer.note(plainSetupText(line, drawn));
269
271
  const environment = environmentOf(command);
270
272
  const input = secretInputOf(command);
271
273
  const ask = async (prompt, hidden) => {
@@ -369,7 +371,7 @@ export const setupCommand = (setup) => {
369
371
  say(text(block.caption));
370
372
  break;
371
373
  case "link":
372
- say(`${text(block.text)}: ${block.href}`);
374
+ say(`[${text(block.text)}](${block.href})`);
373
375
  break;
374
376
  case "requirement":
375
377
  say(`${text(block.text)}${block.fix ? ` — ${text(block.fix)}` : ""}`);
@@ -48,8 +48,10 @@ export interface TokenSessionOptions {
48
48
  /** One sentence more for `session start --help`: which token, and what it can see. */
49
49
  about?: string;
50
50
  /**
51
- * How a person who never made one gets the token: the steps and their links, in plain words. `session start` prints
52
- * it before the question at a terminal, and `session start --help` ends with it.
51
+ * How a person who never made one gets the token: the steps and their links, in plain words, as the restricted
52
+ * Markdown of a setup text (a `##` heading, `**bold**`, `[words](link)`). `session start` prints it before the
53
+ * question at a terminal, its links drawn as links where the terminal shows them, and `session start --help` ends
54
+ * with it.
53
55
  */
54
56
  guide?: string;
55
57
  /** One sentence more for `session end --help`, such as what of the service's own tools it leaves alone. */
@@ -2,6 +2,8 @@ import { CliError } from "@wirecat/cli-base";
2
2
  import { annotate } from "@wirecat/cli-base/commands";
3
3
  import { Command } from "commander";
4
4
  import { at as valueAt } from "../crm/manifest/map.js";
5
+ import { plainSetupText } from "../setup/plain.js";
6
+ import { drawsHyperlinks, hyperlink } from "../terminal/hyperlink.js";
5
7
  import { readSecret } from "../terminal/prompt.js";
6
8
  import { baseContext, environmentOf, outputFor, secretInputOf } from "./context.js";
7
9
  import { refuseOffline } from "./early-refusal.js";
@@ -75,13 +77,13 @@ export const tokenSessionCommand = (options) => {
75
77
  (options.about ? `. ${options.about}` : ""))
76
78
  .option("--credential-storage <storage>", "where the token is kept: keyring, which falls back to a private file by itself, or file", storageOf, "keyring");
77
79
  if (options.guide)
78
- start.addHelpText("after", `\n${options.guide}`);
80
+ start.addHelpText("after", `\n${plainSetupText(options.guide)}`);
79
81
  if (options.login)
80
82
  start.option("--login <name>", `the ${service} user name the password belongs to`);
81
83
  if (options.site)
82
84
  start.option("--site <address>", `the ${service} site, as https://${options.site.example} or ${options.site.example}`);
83
85
  start.action(async function (args) {
84
- const { env, profile, tokens, run, renderer, keyring } = contextOf(this);
86
+ const { env, profile, tokens, run, renderer, keyring, streams } = contextOf(this);
85
87
  refuseCommandName(profile, commandWords(rootOf(this)), app.command);
86
88
  if (options.site && args.site === undefined)
87
89
  throw new CliError("validation_error", `give the ${service} site: --site ${options.site.example}`);
@@ -97,8 +99,10 @@ export const tokenSessionCommand = (options) => {
97
99
  const input = secretInputOf(this).input ?? process.stdin;
98
100
  // Only a person at a terminal pastes it; piped in, the note would stand before the answer on stderr.
99
101
  if (input.isTTY) {
100
- if (options.guide)
101
- renderer.note(options.guide);
102
+ if (options.guide) {
103
+ const link = drawsHyperlinks(env) ? hyperlink : undefined;
104
+ streams.diagnostic(`${plainSetupText(options.guide, link ? { link } : {})}\n\n`);
105
+ }
102
106
  if (page)
103
107
  renderer.note(`the ${word} of ${login}: make one at ${page}, then paste it here`);
104
108
  }
@@ -1,6 +1,9 @@
1
1
  /**
2
- * A setup text for a terminal: Desktop draws its restricted Markdown, a terminal shows `**`, backticks and `[…](…)`
3
- * as typed. Bold and code lose their marks, and a link keeps its address beside its words, since the address is what
4
- * a person copies. Single `*` and `_` stay: in plain text they are as often a product or a name as italics.
2
+ * A setup text for a terminal: Desktop draws its restricted Markdown, a terminal shows `#`, `**`, backticks and
3
+ * `[…](…)` as typed. Headings, bold and code lose their marks. A link keeps its address beside its words, since the
4
+ * address is what a person copies, unless `link` draws it, as a terminal that shows OSC 8 links does. Single `*` and
5
+ * `_` stay: in plain text they are as often a product or a name as italics.
5
6
  */
6
- export declare const plainSetupText: (text: string) => string;
7
+ export declare const plainSetupText: (text: string, { link, }?: {
8
+ link?: (label: string, href: string) => string;
9
+ }) => string;
@@ -1,9 +1,11 @@
1
1
  /**
2
- * A setup text for a terminal: Desktop draws its restricted Markdown, a terminal shows `**`, backticks and `[…](…)`
3
- * as typed. Bold and code lose their marks, and a link keeps its address beside its words, since the address is what
4
- * a person copies. Single `*` and `_` stay: in plain text they are as often a product or a name as italics.
2
+ * A setup text for a terminal: Desktop draws its restricted Markdown, a terminal shows `#`, `**`, backticks and
3
+ * `[…](…)` as typed. Headings, bold and code lose their marks. A link keeps its address beside its words, since the
4
+ * address is what a person copies, unless `link` draws it, as a terminal that shows OSC 8 links does. Single `*` and
5
+ * `_` stay: in plain text they are as often a product or a name as italics.
5
6
  */
6
- export const plainSetupText = (text) => text
7
- .replace(/\[([^\]\n]*)\]\(([^)\s]*)\)/g, (_all, label, href) => !label || [href, href.replace(/^https:\/\//, "")].includes(label) ? href : `${label} (${href})`)
7
+ export const plainSetupText = (text, { link = (label, href) => `${label} (${href})`, } = {}) => text
8
+ .replace(/^#{1,3} +/gm, "")
9
+ .replace(/\[([^\]\n]*)\]\(([^)\s]*)\)/g, (_all, label, href) => !label || [href, href.replace(/^https:\/\//, "")].includes(label) ? href : link(label, href))
8
10
  .replace(/\*\*([^*\n]+)\*\*/g, "$1")
9
11
  .replace(/`([^`\n]+)`/g, "$1");
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Whether the terminal draws an OSC 8 link. One that does not drops the escape and shows only the words, so the address
3
+ * would be lost: only terminals known to draw it get one, and `FORCE_HYPERLINK=1` or `=0` decides for any other.
4
+ * tmux and screen pass the escape on only when set up to, so they get the address.
5
+ */
6
+ export declare const drawsHyperlinks: (env: NodeJS.ProcessEnv) => boolean;
7
+ /** The words as a link to the address; a BEL or ESC in either would end the sequence early, so they are dropped. */
8
+ export declare const hyperlink: (label: string, href: string) => string;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Whether the terminal draws an OSC 8 link. One that does not drops the escape and shows only the words, so the address
3
+ * would be lost: only terminals known to draw it get one, and `FORCE_HYPERLINK=1` or `=0` decides for any other.
4
+ * tmux and screen pass the escape on only when set up to, so they get the address.
5
+ */
6
+ export const drawsHyperlinks = (env) => {
7
+ if (env.FORCE_HYPERLINK !== undefined)
8
+ return env.FORCE_HYPERLINK !== "0";
9
+ if (env.TMUX || env.STY || env.CI || env.TERM === "dumb")
10
+ return false;
11
+ if (Number(env.VTE_VERSION) >= 5000)
12
+ return true;
13
+ if (env.WT_SESSION || env.KITTY_WINDOW_ID || env.KONSOLE_VERSION || env.WEZTERM_EXECUTABLE)
14
+ return true;
15
+ return ["iTerm.app", "WezTerm", "vscode", "ghostty"].includes(env.TERM_PROGRAM ?? "");
16
+ };
17
+ /** The words as a link to the address; a BEL or ESC in either would end the sequence early, so they are dropped. */
18
+ export const hyperlink = (label, href) => {
19
+ const clean = (text) => [...text].filter((char) => char >= " " && char !== "\u007f").join("");
20
+ return `\u001b]8;;${clean(href)}\u0007${clean(label)}\u001b]8;;\u0007`;
21
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-core",
3
- "version": "0.737.0",
3
+ "version": "0.738.0",
4
4
  "description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Viacheslav Ptsarev",