Files
only-cli 90d5c20ef9 fix: hand over code an agent can actually run
A syntax highlighter gives every token of a command its own element, so
`s3://bucket/` reached the walk as `s3`, `:`, `//`, `bucket`, `/`, and the
rule that reassembles text fragments only glues the ones sharing a parent.
The rest were space-joined. The AWS CLI reference handed over

  aws s3 cp test . txt s3 : // amzn - s3 - demo - bucket / test2 . txt

and Node's fs docs handed over `console . log` and `fd ?. close ()`. Any
command or snippet an agent took from a docs page was wrong, and nothing in
the output said so. Highlighting is not an edge case: of 172 pre elements on
the AWS CLI reference, the Rust book, the Node API docs and the Python
library docs, 159 are split this way.

A pre or code subtree is now read as one string. That costs nothing to
follow, because not one of those 172 blocks contains a link, and it also
fixes inline code, which was inserting a space into `Byte ( u8 only)`.

Two things fall out of it.

Page furniture had to stop riding along. Node puts a language label beside a
copy button inside every code block, so the subtree's text ended in
`javascriptcopy`. A control is chrome, and so is the block-level element
holding it, which is how the label leaves with the button it sits beside.
The test stays on block-level wrappers because a highlighter's own elements
are inline, so a stray control can never take a line of code out with it.

Code blocks keep their lines. Collapsing them was survivable while the code
was already wrecked; once it reads correctly, `// read it back` in front of
the statements that followed it is worse, because the output now looks
trustworthy. Blank runs and the indentation the whole block shares carry no
meaning and still go. A cut lands on a line end for the same reason it
already lands on a sentence end, and a snippet stays one line, because that
is what find's index promises.

Measured over five real pages, the compact view moves by -15, -7, +208, -45
and 0 characters, about 35 tokens in total, all of the growth being Python's
pretty-printed output getting its indentation back.
2026-08-23 09:12:25 -04:00

43 lines
2.2 KiB
HTML

<!doctype html>
<html><head><title>cp - Fixture CLI Command Reference</title></head>
<body>
<main>
<h1>cp</h1>
<!-- What a syntax highlighter does to a command: one element per token, so
the walk sees `s3`, `:`, `//`, `bucket` as separate fragments with
different parents. Every real highlighter emits this shape. -->
<p>Copy a file to the bucket:</p>
<pre class="highlight"><code><span class="nb">aws</span> <span class="n">s3</span> <span class="n">cp</span> <span class="n">test</span><span class="p">.</span><span class="n">txt</span> <span class="n">s3</span><span class="p">:</span><span class="p">//</span><span class="n">amzn</span><span class="p">-</span><span class="n">demo</span><span class="p">/</span> <span class="p">--</span><span class="n">recursive</span></code></pre>
<!-- A sample the page wrote across lines, with a shell continuation. Joining
these would hide the break; joining the next one would comment out the
call that follows the comment. -->
<pre><code>aws s3 cp test.txt s3://amzn-demo/ \
--expires 2014-10-01T20:30:00Z</code></pre>
<pre><code>const fs = require('node:fs');
// read it back
fs.readFileSync('out.txt');</code></pre>
<!-- Node's docs put a toolbar inside the block itself: a language label
sitting beside a copy button, plus a flavour toggle. None of it is part
of the sample. -->
<pre class="shiki"><input class="js-flavor-toggle" type="checkbox"><div class="code-toolbar"><span class="code-language">javascript</span><button class="copy-button">copy</button></div><code><span>import</span> <span>fs</span> <span>from</span> <span>'node:fs'</span><span>;</span></code></pre>
<!-- Indentation the whole block shares says nothing; indentation inside it
is the program. -->
<pre><code> def load(path):
with open(path) as fh:
return json.load(fh)</code></pre>
<!-- Inline code belongs to the sentence it sits in, and it gets split into
tokens the same way. -->
<p>Pass the <code><span class="p">--</span><span class="n">recursive</span></code> flag to copy a directory.</p>
<p>A period (<code>.</code>) means the working directory.</p>
</main>
</body></html>