Skip to content

Fit the help for all of string on one screen - #66

Merged
asavor merged 51 commits into
mainfrom
root-help
Nov 21, 2026
Merged

asavor merged 51 commits into
mainfrom
root-help

Conversation

@asavor

@asavor asavor commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

Why

string --help, and string alone, printed 171 lines and 10.9 KB: every detail of every command, in prose. An agent that runs string to learn what it can do spent about 2,800 tokens on that before doing any work, and a person had to scroll past it to find the commands. Each command has its own page now, and string help --all puts every command on one page, so the help for all of string can be short and point at them.

Summary

Stacked on usestring/cli "Describe every command in one table, and add help --all and help --json" (#65). Merge #42 to #65 in order first, then this.

  • string --help and string alone are now 25 lines, at most 80 columns and 1.6 KB:

    • what works without a key, which commands need one, and how to get one;
    • the usage, with string URL for a page;
    • a line for each command, made from its own page, so a new command's page adds its line;
    • that API fields are flags, and where the rest is, ending with string help --all.

    Under an agent the three lines for agents still come first, so it's 29 lines in all, down from 175.

  • string help --all now says what each flag every command takes does. Only the old help said that, and this way an agent still learns --timeout, --no-input and the rest in the same call. It is 51 lines and 3.4 KB, under 1k tokens.

  • What the old help said and no page did is on the pages now:

    • login: by default --device-name sends the system and short hostname, as in Mac · work-laptop, which the organization sees. --env-file keeps the file's other lines and makes a new file readable only by you.
    • init: where the skill goes. That's ~/.agents/skills, ~/.claude/skills when Claude Code is here, and its own directory for any other agent.
    • update: a release goes in only once its signature and checksum check out.
    • trial: it takes a few seconds' proof of work.
    • --timeout: 120s for a request, 300s for integrations run, 90s under an agent, for each request or a whole --wait or --poll.
  • Six hand-wrapped lines on the fetch, sitemap, integrations and trial pages ran one to three columns past 80 under the page's indent, so an 80-column terminal wrapped them. They're rewrapped. The integrations example stays one line, since it's a command to copy.

  • init's summary is shorter so its line fits: "install the string-cli skill for your coding agents".

  • The README says what the shorter help holds. It still names STRING_API_BASE_URL, now beside string help environment.

Risks

  • A person or agent who found a detail in the old help now finds it on the command's page, in a topic or in the README. The skill's own check still passes: every flag the skill uses is on some page.
  • string help --json grows by 249 bytes to 23,795, under its 24,000-byte bound, because the flag descriptions are longer. Later steps have about 200 bytes left before the bound. A step that needs more has to make room or argue for a bigger bound.

Tradeoffs

  • Some details of the old help are now only in the README and in the messages themselves:

    • the 15-second progress line of a wait;
    • the 60-second stall that exits 7;
    • the parts of a text error;
    • the kebab-case and snake_case spellings of a flag, which are also in help --json's spellings.

    Each page links to its section of the README.

  • The help for all of string names the commands that need a key (request, sitemap, integrations run and balance) by hand. The table could generate that list later. Until then, a new command that needs a key has to be added to that sentence.

  • No test checks the pages' wording. Each changed page is diffed against Describe every command in one table, and add help --all and help --json #65's head instead, and every page and topic is checked for lines over 80 columns.

Test plan

  • go vet ./... and go test ./... pass on Go 1.27.4 and Go 1.25.0 for each commit alone; go vet also passes cross-compiled for Windows, macOS and FreeBSD.
  • TestTheHelpForAllOfStringFitsOnOneScreen checks the help for all of string:
    • at most 25 lines and 80 columns;
    • the last line names string help --all;
    • every page has a line, with its summary.
  • TestHelpAllListsEveryCommandOnOnePage now checks that each flag every command takes is there with what it does.
  • TestHelpDescribesSignInAsItWorks reads the login and init pages and the help for all of string, where those facts are now. It still checks that none of them names the old settings page or "the API key you choose".
  • TestTheHelpForAllOfStringGreetsAnAgent is unchanged and passes: the lines for agents come first under an agent, and only there.
  • Each of 10 mutations fails a test:
    • a page left out of the help for all of string, or its last line gone;
    • a line per subcommand, which makes 32 lines;
    • a line past 80 columns;
    • no lines for agents;
    • the settings page named, or "the API key you choose";
    • init's exit note gone;
    • help --all naming flags without what they do, or leaving one out.
  • go test -count=50 -cpu 1 over the four tests passes 200 of 200, with two busy loops in the same 2-CPU scope.
  • Every page and topic fits 80 columns except the one integrations example, counted in characters per line of each page's output.
  • CI on Linux, macOS and Windows.

Generated with Claude Code

asavor and others added 30 commits November 20, 2026 00:43
main now builds one execCtx before the command runs: which of stdin,
stdout and stderr are terminals, whether a coding agent runs string, and
whether it is a CI job. The two terminal flags the runtime carried become
its stdinTTY and stderrTTY, with no change in behavior.

The agent is named from the variables only an agent's command runner
sets, in a fixed order: STRING_AGENT, which can also force the person's
view; AI_AGENT, cut to its name; the runners' own variables; CLAUDECODE
or CLAUDE_CODE_ENTRYPOINT only when stdin is not a terminal, since IDE
terminals set them for people too; then AGENT. TERM, TERM_PROGRAM and
the process tree are never read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An update notice used to show whenever stderr was a terminal. Coding
agents can run string in a pseudo-terminal, so the notice landed in
what the agent read. Now it shows only when stdout and stderr are both
terminals, no coding agent runs string, and it isn't a CI job. A copy
that only gets notices is checked for a release under the same rule.

A copy the install script installed still updates itself in the
background as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The help says that string finds a coding agent from the variables agents
set and then shows no update notices, and how STRING_AGENT names the
agent or a person. The README gets a Coding agents section with the
variables string reads and what changes under an agent, and the Updating
section says notices are for a person at a terminal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Requests to String's API, portal and sign-in service now carry a
User-Agent of string-cli/<version> (<os>/<arch>), with "; agent=<name>"
when a coding agent runs string, in place of Go's default. They also
carry X-String-CLI-Mode (interactive, agent, non-interactive or ci),
X-String-Agent with the agent's name, and X-String-Agent-Raw with
AI_AGENT as the agent set it. String can then tell people, scripts, CI
and each agent apart in its own request logs. string sends nothing
else, and no events of its own.

DO_NOT_TRACK=1 sends only string-cli/<version> and none of the
X-String headers.

The download host keeps its own User-Agent, as the README promises.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The help now says that requests to String carry string's version, the
system and the agent's name, and that DO_NOT_TRACK=1 sends only the
version. The README's Coding agents section lists each header, what it
carries and what DO_NOT_TRACK leaves out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Update checks and downloads now carry userAgent(): string-cli/<version>
(<os>/<arch>), with the agent's name under a coding agent, and only
string-cli/<version> under DO_NOT_TRACK, so the two can't drift apart.
They still send none of the X-String headers, which the download host
doesn't read. The README's Updating section says what the host gets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
login and init started the system's browser opener on every sign-in:
under a coding agent, in CI, with stdout piped and with --json. Now they
open the link only when execCtx says a person is at a terminal (stdin and
stdout terminals, no agent, no CI), and --no-open, anywhere before --,
stops it there too. What they print is unchanged.

One function now takes --json and --no-open out of the arguments, and
afterCommand uses it too, so a switch before the command name doesn't
hide the command from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
login, init and trial claim waited for an approval whenever stdin was a
terminal, so a coding agent running string in a pseudo-terminal, or a CI
job with one, blocked until the code expired. They now wait only when
execCtx says a person is at the terminal: stdin and stdout terminals, no
agent, no CI and no --no-input. Anywhere else they print the link and
code and return, and only --poll waits.

--no-input, or STRING_NO_INPUT=1, says nobody will answer, for scripts
and anyone else. -y and --yes are taken by every command, to confirm
what it would ask first; none asks yet. trial claim without --email now
names the flag, with exit 2 and the code missing_input.

The sign-in test fixture builds its execCtx from its variables, as main
does, so a test sets CI, an agent or STRING_NO_INPUT there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
afterCommand finds the command after the global switches, as run()
does, so string --no-open update and string -y update start no update
check. The test now covers both, so the two can't drift apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A request that never answered held string for five minutes, and an
answer that stalled halfway held it for good. Under a coding agent that
runs past the two minutes some agents allow a command, and the agent
stops string without an error to read.

Each request to String now has a time limit: 120s, 300s for an
integration's action, and 90s for any request under an agent.
--timeout DURATION sets another, as 90s, 5m or seconds, or 0 for none,
anywhere before --. An answer that sends nothing for 60s ends too.
Either exits 7 with code timeout, and the error offers twice the limit,
to run in the background where an agent's shell stops commands at two
minutes.

The client no longer stops at five minutes without response headers;
the request's own limit does that now. Downloads keep their deadlines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sitemap --wait polled until the crawl ended: in silence unless stderr was
a terminal, and forever on a status it didn't know. Under a coding agent
a crawl outlasts the two minutes some agents give a command, so the agent
stopped string with no word of the job or how to pick it up.

--wait now first prints the job and the command that resumes the wait.
A person who sees stderr at a terminal still gets one progress line
redrawn in place; anywhere else, an agent's terminal included, a plain
line comes every 15s. Under an agent the wait stops after 90s, and
--timeout sets another limit for anyone. The limit counts from the
command's first request, and each poll gets only what is left of it.

A wait that reaches its limit, or meets a status string doesn't know,
exits 7 with code wait_timeout, prints the last status on stdout and
names the resume command. The crawl keeps running.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A request that ran past its time limit now fails with exit 7 rather than
as a bare network error, and string login --poll took any failure but a
busy server as the end of the code: it deleted the waiting sign-in. A
server that didn't answer in time hasn't spent the code either, so the
sign-in now stays saved, and the error says that string login --poll can
still finish it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
login --poll and trial claim --poll waited in silence for as long as
their code lived, longer than the two minutes some coding agents give a
command. They now use the waiter that sitemap --wait uses: under an
agent they stop after 90s, and --timeout sets another limit for anyone.
A wait that reaches its limit exits 7 with code wait_timeout, and the
sign-in or claim stays saved for the next --poll. Where no person
watches stderr at a terminal, the wait first says what it waits for and
how to resume, then prints a line every 15s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ctrl-C ended string with exit 130 and said nothing. The first Ctrl-C
now says what keeps running and the command that picks it up: a crawl
that --wait was watching, or a sign-in or claim that is still open. For
a request that changes something, it says the request may already have
been processed. On a person's terminal it clears the line first, and
under --json it prints the error envelope. Then string ends the way
SIGINT ends a program, so the shell sees 128+2 and a script that runs
string stops too; Windows still exits 130. A second Ctrl-C ends string
at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Eight of the thirteen commands printed the help for all of string when
asked for theirs. Every command now has its own page: usage, examples,
what it prints and how it exits, what it costs, its flags, and where to
read more. --help, -h anywhere before --, and string help COMMAND all
print it without a request. -v prints the version, as --version does,
and string version adds the commit, its date, the system and the Go
version, as one object with --json. None of these starts the daily
update check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A mistyped command said only "Unknown command". Now a near miss of a
command, or a word other tools use for one (scrape, crawl, setup, auth,
credits, doctor), names the command meant, with the same command line
as the next step, and string exits 2 without running it. Every flag of
more than one word takes its camelCase, kebab-case and snake_case
spellings, the CLI's own flags and the global switches included, and a
near miss of any flag names the one meant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
string example.com said "Unknown command", and string fetch example.com
said "Invalid URL". A first argument with a dot or :// that is no
command is now fetched, and a URL with no scheme given to fetch,
request or sitemap submit gets https://, with a note on stderr that
names the URL string uses. A scheme in capitals works anywhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…agents

string help exit-codes, environment, formatting and agents cover what
no one command owns: what each exit code means and what to do next,
every variable string reads and what each request tells String, where
output goes and in what shape, and what changes under an agent. A near
miss of a topic names it. Under an agent, bare string, string help and
string --help start with three lines on where to find one command's
page and how to keep big pages out of its context.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s out

A --json error now always carries exit_code, retryable,
user_action_required and next_commands. retryable is the API's word, or
true after a rate limit, a failure at String or a timeout.
user_action_required is true when a person must act: a key, credit, a
crawl's approval, or a blocked network. Each of next_commands has a type
(fix_command, wait, retry, login, trial, env, pay or tell_user), so an
agent can take the steps that need no person. A request that got no
answer gives its reason: dns, connect or tls, and it can be sent again.
Inside a sandbox that blocks the network, the error says so, is not
retryable, and its step is to ask the person to let string reach the
host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An error's text was its message, which for an API error held the status
and up to 2,000 characters of the raw body, an HTML page included, and
for a request that got no answer Go's own words, such as dial tcp. Now
the first line is error: and one sentence: the API's message with its
status when the API sends one, a short plain answer, or the CLI's own
sentence. The details follow, indented, then next: after a blank line.
A request that got no answer says whether the name didn't resolve, the
connection was refused, TLS failed, or the connection was lost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--errors json gives JSON errors, as --json does, and leaves stdout as it
is, so a script can keep fetch's Markdown and still read errors as JSON
in 0.3 and 0.4 alike. fetch --json now says once, on stderr, that its
stdout becomes a JSON object in 0.4. A fetch whose site answered 404 or
410 warns that it will exit 8 then, and another error that it will exit
6, from the X-Status-Code the API sends. STRING_NO_DEPRECATION_WARNINGS=1
silences both, and so does STRING_COMPAT=0.2. string help formatting
lists the changes, and string help environment the two variables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
asavor and others added 20 commits November 20, 2026 06:10
…n 0.4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A fetched page over 16 KB now says its size on stderr before the page,
wherever no person reads stdout at a terminal: the bytes and tokens,
what the agent running string keeps of output that long, and the same
command with -o page.md. -o checks its path before the request, so a
bad path no longer spends the call, and says what it saved: the size,
the tokens, a fetch's status and host, and a Markdown page's outline,
each heading after the line it starts on. -o - is stdout. -q leaves
these status lines, and a wait's, out of stderr.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fetch --max-tokens N prints about N tokens of the page, at four
characters a token, and stderr says which part it is of how many and
gives the command for the next part. Parts end on whole tokens, mostly
at a line's end, so the next part starts exactly at its --offset and
the parts give the page back with nothing lost or repeated. The first
part saves a local copy for 15 minutes, readable only by its owner, and
the parts after it read that copy: no request, no credit, and no
keyless allowance spent. The size note for a large page now names
--max-tokens too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
whoami read only local files and always exited 0, so a key String had
revoked still looked fine. Now it checks the key with one request to
the balance endpoint, which spends no credit: it says the key's source,
the account it was saved for, the key's first characters and that
String accepts it; exits 3 when String refuses the key, with the step
for that source; and exits 6 when it couldn't ask. whoami --offline
keeps the old local-only answer, and --json gives one object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…from stdin

A field that only comes back in JSON, such as --jsonSchema, with
--format markdown or raw was dropped without a word. It now exits 2 and
names the fix. request --body-file - reads the body from stdin, where it
used to look for a file called -; with --input - too, it exits 2, since
only one can read stdin. --body still sends its text as written, and
warns when it is @ and the name of a file that exists, since
--body-file was likely meant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…here

Page content is untrusted. When stdout is a person's terminal, a page
now loses ESC, so no escape sequence runs; every other control
character but tab and newline, C1 included; and bidi overrides and
isolates, which can make text read differently from its bytes. Bytes
that aren't text, such as a PDF from --format raw, are refused there
with exit 2 and the command with -o. Piped, or under a coding agent,
output goes out byte for byte, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
string init now installs the string-cli skill in ~/.agents/skills, which
Codex, Cursor, Gemini CLI and most other agents read, and in
~/.claude/skills for Claude Code. An agent found here that reads neither
still gets a copy of its own. Releases before 0.3 put a copy in each
agent's directory, and Gemini CLI, which reads both ~/.gemini/skills and
~/.agents/skills, warned of a skill conflict at every start, so init
removes that copy and says so. It removes only a plain copy as init
wrote it; a link, extra files or another skill's name stay, with the
reason. --agent NAME still writes exactly the agents it names.

string skill prints the skill this release carries, so an agent can read
it without installing anything, and --path lists the installed copies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The skill now teaches what 0.3 changes for agents: --errors json rather
than fetch --json, -o with the outline and sed -n, --max-tokens parts
from the local copy, exit 7 as "run the next command" for --poll and
--wait, whoami's check, the typed next_commands and the help topics.
Its description says when to reach for string: a page or search that
curl or WebFetch can't read, a crawl, or structured site data. The trial
key stays the fallback for when nobody can approve a key.

A test keeps it at 150 lines or fewer, and fails on a command or flag it
names that no help page has.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… skill does

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
string whoami --offline printed its text line even with --json, so an
agent that adds --json to every command got prose where it expected an
object. With --json it now prints the same object as the checked whoami,
without accepted, since nothing asked String.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each help page now declares the commands it covers next to its usage,
examples, flags and fields: their arguments, what they cost, whether
they read, spend, write or stay on this machine, their exit codes, what
they print, and whether --json gives one object. string help --all and
string help --json come from that one declaration.

string help --all is a line for each command with what it costs, then
the flags every command takes, the exit codes and a line for each topic,
about 660 tokens. string help --json [COMMAND], and --json on any
--help, is the same as JSON for programs and agents, about 23 KB for the
whole CLI. It lists each set of API fields once, so request shares
fetch's, and one note covers every flag's other spellings. Under an
agent, the help for all of string now points at both.

Tests check the two against the pages, the parser and the fields each
command sends: every documented flag parses in each spelling, every
example and usage line runs its own command, a page names only exit
codes its commands have, and the field sets and keyless fields match
what the code sends.

The table showed gaps in the pages, fixed here: sitemap submit's --input
was missing, status didn't say it exits 3 when String refuses the key,
and several commands listed too few exit codes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The usage in string --help and the agents topic name both, and the
README says what each holds and how the lines for agents point at them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
string --help, and string alone, were a 173-line dump of every detail.
They are now 25 lines of 80 columns at most: what works without a key
and how to get a key, a line for each command from its own page, and
where the rest is, ending with string help --all. A new command's page
adds its line. Under an agent the three lines for agents still come
first.

string help --all now says what each flag every command takes does,
which only the old dump said, so an agent still learns them in one call.
init's summary is shorter so its line fits.

Tests: the help for all of string stays within 25 lines and 80 columns,
ends with string help --all and has a line for every page; help --all
describes every flag every command takes; the sign-in test reads the
login and init pages, where those facts are now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The login page says what --device-name sends by default, as in
Mac · work-laptop, and that --env-file keeps the file's other lines and
makes a new file readable only by you. The init page says where the
skill goes, the update page that a release goes in only once its
signature and checksum check out, and the trial page that it takes a few
seconds' proof of work. --timeout gives its limits: 120s for a request,
300s for integrations run and 90s under an agent, for each request or a
whole --wait or --poll.

Six hand-wrapped lines on the fetch, sitemap, integrations and trial
pages ran one to three columns past 80 under the page's indent, and are
rewrapped. The README describes the shorter help.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@asavor asavor added claude PR primarily authored by Claude merge:same-repo-dependency Needs an unmerged PR in this repo first; no known cross-repo prerequisite. Checks and holds apply. labels Nov 21, 2026
@asavor
asavor changed the base branch from command-table to main November 21, 2026 14:08
@asavor
asavor merged commit 08fdb93 into main Nov 21, 2026
5 checks passed
@asavor
asavor deleted the root-help branch November 21, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude PR primarily authored by Claude merge:same-repo-dependency Needs an unmerged PR in this repo first; no known cross-repo prerequisite. Checks and holds apply.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant