From 3a24da8a8e08a1ffc8b42cc8cac0c3104e26503f Mon Sep 17 00:00:00 2001 From: WaterrrForever Date: Mon, 9 Nov 2026 15:49:21 +0000 Subject: [PATCH] fix(cli): spaced-path hint takes the longest path and reads --flag=value; telemetry docs name the reverse session id (#7452) Follow-ups from review on #7443 and #7444: - The quote hint returned the first run of words that existed, so a "Final Cut/" folder hid "Final Cut export.mp4". It now names the longest. - "--compare=my clip.mp4" got no hint; the value after = now starts a run. - The telemetry section lists the skill a reverse or templates command ran for, and the HeyGen session id a recorded reverse run carries. --- docs/packages/cli.mdx | 3 ++- .../utils/reject-extra-positionals.test.ts | 25 ++++++++++++++----- .../cli/src/utils/reject-extra-positionals.ts | 15 ++++++++--- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/docs/packages/cli.mdx b/docs/packages/cli.mdx index c27c9aa1e1..8595ee1889 100644 --- a/docs/packages/cli.mdx +++ b/docs/packages/cli.mdx @@ -2307,7 +2307,8 @@ duration and tween count, aggregate video-extraction workload counts (extracted frames, VFR preflights), aggregate counts of what a motion-blur render's composition holds (movers, videos, iframes, canvases, custom elements, and similar), example choices, the names of registry items `add` or Studio installs and which of the two installed them, the names of the HyperFrames skills installed (and which are out of -date) as of the last background skills check, and system info — including a coarse +date) as of the last background skills check, which skill ran `reverse start` or `templates pull` (with the +HeyGen session id of a recorded reverse run, so a retry counts once), and system info — including a coarse environment fingerprint: OS, kernel string, CPU and memory shape, sandbox runtime such as gVisor or Docker, and the _name_ of a coding agent driving the CLI when one is detected (`claude_code`, `codex`, `cursor`). That name is diff --git a/packages/cli/src/utils/reject-extra-positionals.test.ts b/packages/cli/src/utils/reject-extra-positionals.test.ts index 17bce54ade..771e024746 100644 --- a/packages/cli/src/utils/reject-extra-positionals.test.ts +++ b/packages/cli/src/utils/reject-extra-positionals.test.ts @@ -1,4 +1,4 @@ -import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; +import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { afterEach, describe, expect, it, vi } from "vitest"; @@ -26,7 +26,7 @@ describe("resolveExtraPositionals", () => { }); it.each([ - ["the positional", (dir: string) => ["measure", "probe", join(dir, "ref"), "one.mp4"]], + ["the positional", (dir: string) => ["measure", "probe", join(dir, "ref"), "one", "take.mp4"]], [ "a flag value", (dir: string) => [ @@ -35,22 +35,35 @@ describe("resolveExtraPositionals", () => { join(dir, "a.mp4"), "--compare", join(dir, "ref"), - "one.mp4", + "one", + "take.mp4", + ], + ], + [ + "a flag=value", + (dir: string) => [ + "measure", + "look", + join(dir, "a.mp4"), + `--compare=${join(dir, "ref")}`, + "one", + "take.mp4", ], ], ])("says to quote a path the shell split at its spaces in %s", (_label, argvOf) => { const dir = mkdtempSync(join(tmpdir(), "hf-extra-")); - writeFileSync(join(dir, "ref one.mp4"), ""); + mkdirSync(join(dir, "ref one")); + writeFileSync(join(dir, "ref one take.mp4"), ""); const error = vi.spyOn(console, "error").mockImplementation(() => {}); const argv = process.argv; process.argv = ["node", "hyperframes", ...argvOf(dir)]; const single = { args: { video: { type: "positional" } } } as CommandDef; try { expect(() => - resolveExtraPositionals(single, "measure", { _: ["x", "one.mp4"], video: "x" }), + resolveExtraPositionals(single, "measure", { _: ["x", "take.mp4"], video: "x" }), ).toThrow(CliUsageError); expect(error.mock.calls[0]![0]).toContain( - `'${join(dir, "ref")} one.mp4' is one path with spaces: quote it.`, + `'${join(dir, "ref")} one take.mp4' is one path with spaces: quote it.`, ); } finally { process.argv = argv; diff --git a/packages/cli/src/utils/reject-extra-positionals.ts b/packages/cli/src/utils/reject-extra-positionals.ts index 15980b7254..ab465e505a 100644 --- a/packages/cli/src/utils/reject-extra-positionals.ts +++ b/packages/cli/src/utils/reject-extra-positionals.ts @@ -46,15 +46,22 @@ function usageLine(path: string, args: ArgsDef): string { } // An unquoted path with spaces reaches us as several words; the longest run of them that is a file names it. +function runStart(word: string): string { + if (!word.startsWith("-")) return word; + const eq = word.indexOf("="); + return eq < 0 ? "" : word.slice(eq + 1); +} + function spacedPath(argv: readonly string[]): string | undefined { + let longest = ""; for (let i = 0; i < argv.length; i++) { - let joined = argv[i]!; - for (let j = i + 1; j < argv.length && !argv[j]!.startsWith("-"); j++) { + let joined = runStart(argv[i]!); + for (let j = i + 1; joined && j < argv.length && !argv[j]!.startsWith("-"); j++) { joined = `${joined} ${argv[j]}`; - if (existsSync(joined)) return joined; + if (joined.length > longest.length && existsSync(joined)) longest = joined; } } - return undefined; + return longest || undefined; } /** Join a free-text command's trailing words, else throw a usage error naming the extras. */