Repository navigation
Conversation
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>
…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>
5 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A web page can be hundreds of kilobytes, and an agent's command runner cuts long output: Claude Code keeps the first 2 KB of output over 30,000 characters, and others keep a head and a tail. So an agent that fetches a long page reads a fragment and doesn't know what it lost. Saving the page with
-oworks, but string then said onlySaved N bytes, so the agent had to read the whole file to find the part it needed. And a mistyped-opath failed only after the request had spent its credit.Summary
Stacked on usestring/cli "Add --errors json, and say ahead what changes for fetch in 0.4" (#57). Merge #42 to #57 in order first, then this.
Most agents cut output this long.The command repeats the one given, flags included, with-o page.md. stdout doesn't change.-o FILEchecks its path before the request. A directory, or a file in a directory that doesn't exist, exits 2 and sends nothing.-o FILEthen says what it saved:X-Status-Codeheader, and its host. A Markdown page adds an outline: up to 20 headings of the first three levels, each after the line it starts on, skipping fenced code. That waysed -n 618,700p page.mdreads one section.-o -writes to stdout.-q, or--quiet, leaves these status lines out of stderr: the size note, the receipt, a wait's first line and heartbeat, and notes and notices. Errors and the keyless allowance stay.string help formattingand the README describe all of it.Risks
-o, sees the new lines.-qremoves them.-ointo a missing directory failing after the request now fails before it, with exit 2 instead of 1.Tradeoffs
--max-tokensand--offset, read from a local copy so later pages spend nothing, is the next change. The note will name it then.Test plan
go vet ./...andgo test ./...pass on Go 1.27.4 and Go 1.25.0;go vetalso passes cross-compiled for Windows, macOS and FreeBSD.TestALargePageSaysItsSizeFirstchecks the exact stderr for a 20 KB page:It also checks that a person at a terminal,
-q, and a page of exactly 16 KB get no note.TestSavingAPageSaysWhatWasSavedchecks the receipt and outline, with a fenced#line skipped and a fourth-level heading left out. It checks the5 moreafter 20 headings, that--format jsonhas no outline, and that-qdrops the receipt. It checks-o -, and that a missing directory and a directory each exit 2 before any request.TestQuietWaitsSayOnlyHowTheyEndedchecks that a crawl's wait with-qsays only how it stopped.TestOutputWritesTheResponseToAFileexpects the receipt in place ofSaved N bytes.Each mutation fails the new tests: no size note, a note for a person too, no agent's cut, no path check, no outline (2 tests), and waits that ignore
-q.CI on Linux, macOS and Windows.
Generated with Claude Code