AGENT SKILL

kimchi-surface-scan

Use when you need to re-derive, verify or update the Kimchi CLI's server-side HTTP surface — which hosts it talks to, which endpoints, how each target is repointed, and what breaks when one is unreachable. Covers finding every released source tree in the store, identifying it by NAR hash, reading the compiled bun binary when no tree exists, and attributing a path to Kimchi rather than to a vendored SDK. Also regenerates the reference doc's diagrams.

License 许可
Unlicense
最近更新
2026-11-15
Stars
★ 2
Forks
0

01 前言 Front Matter

name
kimchi-surface-scan
description
Use when you need to re-derive, verify or update the Kimchi CLI's server-side HTTP surface — which hosts it talks to, which endpoints, how each target is repointed, and what breaks when one is unreachable. Covers finding every released source tree in the store, identifying it by NAR hash, reading the compiled bun binary when no tree exists, and attributing a path to Kimchi rather than to a vendored SDK. Also regenerates the reference doc's diagrams.
disable-model-invocation
false

02 资源文件 1

03 SKILL.md 正文

Re-run the extraction that produced dev/references/kimchi-surface/kimchi-server-surface.md.

Cost, so you size this correctly

The original discovery burned 23 agents and roughly 4.4M tokens, and nearly all of it went on not knowing the six things below. A rescan that starts from them is a single pass over one source tree. Do not fan out. Read source, cite source, and use a second agent only to check attribution on the handful of paths that a vendored SDK could also own.

Output

All three live in dev/references/kimchi-surface/.

Artifact What it is
kimchi-server-surface.md The census. Authoritative; edit this.
kimchi-capabilities.svg Rendered from it. Never edited by hand.
kimchi-endpoints.svg Rendered from it. Never edited by hand.

1. Find every version's source tree, then identify it by hash

nix build yields a compiled bun binary, but the package builds it from the release source pinned as extraction.kimchiSource, and the extractor reads the same tree. So every version this clone has built or extracted left its source tree in the store. Find those.

for p in /nix/store/*-source; do
  [ -f "$p/package.json" ] && grep -q '@kimchi-dev/cli' "$p/package.json" \
    && echo "$p  $(nix hash path --type sha256 --sri "$p")"
done

That enumerates the trees. To put a VERSION on one, map its NAR hash against the source hash each branch pinned. That pin has lived in two places: a top-level src key on the older build/kimchi-from-source refs, and extraction.kimchiSource once the source build and the extractor shared one pin. Guard the JSON read, because older refs carry neither and some carry no sources.json at all. Unguarded, the ~180 refs in a working clone bury the handful of real lines under a couple of hundred tracebacks, and 2>/dev/null silences git but not Python.

git for-each-ref --format='%(refname:short)' refs/heads refs/remotes | while read -r br; do
  git show "$br:packages/kimchi/sources.json" 2>/dev/null | python3 -c '
import json, sys
try:
    d = json.load(sys.stdin)
    src = d.get("src") or d["extraction"]["kimchiSource"]
    print(d["version"], src["hash"])
except (KeyError, TypeError, ValueError):
    pass
'
done | sort -u

Run against this clone on 2026-09-22, that is the whole of its output:

1.1.21 sha256-46UKL5Wxh+aaJFH6/yWacg+FhXBzO27duo/70tfIj08=
1.1.25 sha256-5dTaqgZbuppRQbd6rpA822mX1hyLatXEwxONM4p8zos=
1.1.26 sha256-dcq7CE5YpXx7DN/pxfrO0dOzzq7mG3FR4tcWVcY0oJ4=
1.1.27 sha256-DAzjhZPML0ujQkTommNgvhWOLTQBbOUdAHTvsn1UINc=

Four versions against nine source trees, so the hash map is not a complete method. It resolves only the versions some ref still pins, and on that run neither 1.1.29 nor 1.1.30 was among them — which are the two you are most likely to care about. The other five trees were identified by content instead. 1.1.30 was settled by finding three strings unique to it present in the 1.1.30 binary (section 2). Treat the hash map as the cheap first pass and a content probe as the ordinary fallback, not as an exception.

Never trust a .drv label, a directory name, or which branch pinned a tree. Two misidentifications happened during discovery and both looked authoritative: one agent read a .drv whose commit message named a version and reported that version; the orchestrator inferred a tree's version from the PR branch that pinned it. Both were wrong. Only nix hash path against sources.json settled it.

At the time of writing the store held nine trees, covering 1.1.21, 1.1.25, 1.1.26, 1.1.27, 1.1.29 and 1.1.30, plus 1.1.22 through 1.1.24 for bisecting. That list is a snapshot of what the method returned once, not a lookup table — re-run the loops rather than assuming it.

When no tree exists for the version you want

A rescan normally starts on a version nobody has built from source, which is exactly the case neither loop above can help with. It is also the common case after a garbage collection: on 2026-09-28 the first loop found one tree, the pinned 1.1.37, where it had found nine a week earlier. Fetch the release tree directly; nothing needs to build:

nix store prefetch-file --json --unpack \
  "https://github.com/getkimchi/kimchi/archive/refs/tags/v<version>.tar.gz"

storePath in the output is the unpacked tree, and hash is its NAR hash — the same value extraction.kimchiSource.hash pins for that release. So the fetch is its own identification: the tag is in the URL you supplied, and the hash can be checked against any pin this repository ever recorded with git log --all -p -- packages/kimchi/sources.json. On 2026-09-28 the 1.1.30, 1.1.31, 1.1.32, 1.1.33 and 1.1.36 fetches matched their recorded pins exactly. Fetch every release since the last census, not just the newest, so each change can be bisected to the version that landed it.

This beats the binary route in section 2 for anything more than a couple of call sites.

2. With no source tree, read the binary

A bun single-file executable embeds its JS bundle as plaintext with identifiers intact.

strings -n 6 /nix/store/<hash>-kimchi-<ver>/bin/kimchi > bundle.txt

Lines are enormous. Re-wrap on ;{} boundaries at about 600 characters before grepping, or every match returns the same line. Use the bundle only to confirm that something is present or absent in a version with no tree. A source citation beats a bundle offset every time, and the reference marks bundle-only citations B<version>:L… (B30, B36) for exactly that reason. A vendored library that only the binary contains — mem0, since 1.1.33 — is the other legitimate use.

3. Attribution is the job. Finding paths is not

A grep for URL-shaped strings returns roughly the right count and badly the wrong set. The bundle vendors the OpenAI SDK, the Anthropic SDK, Google auth, AWS STS, Cloudflare, xAI, GitHub, and the upstream @earendil-works/pi-coding-agent harness (host pi.dev).

  • /v1/messages, /v1/models, /v1/files, /v1/batches and /v1/organizations/* are byte-identical whether a vendored SDK owns them or Kimchi does.
  • Around 150 such literals have zero call sites and are unreachable.
  • But Kimchi does rebind both SDK base URLs through pi's provider config, so the two entry points it actually calls — chat.completions.create and beta.messages.create — really do land on llm.kimchi.dev.

A finding counts only when you show which base URL the path is joined to at the call site. Trace the variable to its construction and to its default, and report that chain in the cell. A path with no reachable call site belongs in the "never called" tables, not in the capability matrix.

4. Run source first, binary second

Discovery ran the binary first and the source second, and the source pass corrected the binary pass in several places. Source is cheaper, gives real file paths, and its *.test.ts fixtures pin wire shapes that the bundle only hints at. Confirm against the binary only for a version that has no tree.

5. Known base URLs — re-derive, do not assume

They are recorded so a rescan can see what moved.

llm.kimchi.dev                 inference gateway + control plane
                               (models/metadata, route through 1.1.36, search, credits, budget)
llm.kimchi.dev/openai/v1       OpenAI wire; vendored OpenAI SDK rebound here
llm.kimchi.dev/anthropic       Anthropic wire; vendored Anthropic SDK rebound here
app.kimchi.dev/api             sandbox control plane AND account identity
<workspace>.remote.kimchi.dev  per-workspace worker; host is server-assigned
api.cast.ai                    telemetry ingest, /stats analytics, key validation
llm.eu.kimchi.dev              EU counterparts of the three region hosts above,
app.eu.kimchi.dev                selected by KIMCHI_REGION or the config key
api.eu.cast.ai                   region (1.1.35 on)

From 1.1.35 every first-party host but the worker comes from src/regions.ts, and each surface layers its own override on top of the region. Read that file first, then trace which override wins per call site: llmEndpoint beats the region for inference but not for web search. The Go ssh helper under tools/ keeps its own hard-coded base and does not follow the region.

api.kimchi.dev does not appear in any tree or in the binary. The documentation page that names it is stale.

6. What an endpoint diff will not show you

The endpoint surface was frozen across 1.1.21 to 1.1.30: nothing was added, removed or rehosted. 1.1.31 to 1.1.37 did add, remove and move endpoints, but the changes that mattered most there were still about when calls fire — memory calls that only exist once an experimental resource is enabled, and a region that moves hosts without any path changing. A rescan that diffs endpoint lists alone sees that both exist, but not when they fire or which host wins. Check at least:

  • KIMCHI_REMOTE_RUN polarity. It inverted from opt-in to opt-out in 1.1.22. Read the variable's default, not its name.
  • Account gates on features. A capability can become unreachable for an account class without any endpoint changing.
  • The global fetch patch's match rule. Widening it re-routes calls the endpoint table still lists under their old host.
  • Default-on telemetry. Check whether a call fires unasked, not only whether its endpoint exists.
  • Opt-in resources. src/resources/definitions.ts lists every extension with its defaultEnabled. An extension that is off by default can still carry a whole new endpoint family.
  • The region registry. A host that follows the region at one call site and a hard-coded base at another is a split a path diff cannot show.

Write these into the reference's "what did change" table with the version each landed in. That table, not the matrix, is what a reader needs on a bump.

7. Regenerate the diagrams

scripts/surface-tables.py reads the reference's GFM tables, so the SVGs are never edited by hand. It is stdlib-only Python, but run it through the task:

devenv tasks run --mode before generate:references:kimchi-surface

The render arguments live in dev/references/kimchi-surface/renders.nix and nowhere else — title, subtitle, which columns each sheet projects, and the per-column widths. That task and checks/references/kimchi-surface-diagrams.nix both read it, so the command that fixes a drift failure cannot disagree with the check that raised it. Bump the version in subtitle THERE; a hand-typed --subtitle renders an SVG the check then rejects.

That check re-renders both SVGs from the tracked markdown and fails on any byte difference, so a markdown edit committed without regenerating cannot reach main. The committed pair renders at 1834x3552 and 1849x4972; an unchanged reference must reproduce those exactly.

To read a projection in a terminal instead, or to check one capability without opening the whole sheet:

python3 dev/skills/kimchi-surface-scan/scripts/surface-tables.py preview \
  dev/references/kimchi-surface/kimchi-server-surface.md \
  --width 150 --cols 0,3,4 --filter search

The renderer keeps the table shape that recurs — the six-column capability matrix — and drops the one-off tables around it. A new section needs no registration, but its header has to match the matrix word for word. Reword one cell of one header and that section stops being the matrix and leaves the sheet. dominant() is what makes that loud: it names every table it drops on stderr, and hard-fails when a dropped one still carries six columns. The drift check cannot see it — re-rendering after a reword produces a committed and a re-rendered SVG that agree with each other and both omit the section.

Local validation

  • treefmt <file> on everything you touch. Markdown is prettier with proseWrap = "always".
  • New vocabulary goes in config/cspell/project-terms.txt, sorted, and only if it is a real term.
  • devenv tasks run devenv:git-hooks:run for the all-files diagnostic.

If a second CLI ever needs this

Three steps carry over unchanged: hashing store paths to identify a version, reading a bun bundle with strings when no tree exists, and refusing a finding that cannot name the base URL its path is joined to at the call site. The renderer is already generic — it takes any markdown with a repeated GFM table and needs no Kimchi knowledge. What does not carry over is everything in sections 5 and 6, which is a census of one product's hosts and one product's behavior changes. One sample is not a pattern, so none of this has been generalized; extract a shared skill when a second CLI actually needs it, not before.

04 同仓库更多 Skills

higherorderfunctor
higherorderfunctor/nix-agentic-tools

stack-test

Use when you need to run tests or formatters across commits in a stack. Use INSTEAD of manual git test run or looping git checkout + test. Prevents: testing every commit when only the tip has to pass, unbounded parallel jobs exhausting memory, cache misunderstandings.

★ 2
higherorderfunctor
higherorderfunctor/nix-agentic-tools

stack-summary

Use when you need to audit, analyze, or review stack quality before restructuring. Produces a structured summary with per-commit classification, philosophy audit, and violation flags. Output feeds directly into /stack-plan restructure mode. Use INSTEAD of manual git log inspection.

★ 2
higherorderfunctor
higherorderfunctor/nix-agentic-tools

stack-submit

Use when you need to push, submit, or create pull requests for a commit stack. Rebases only the current stack onto upstream main, validates, and pushes INSTEAD of manual git sync + git submit + PR/MR creation. Handles branch creation, stacked PR/MR creation with correct base branches.

★ 2
higherorderfunctor
higherorderfunctor/nix-agentic-tools

stack-split

Use when you need to break up, split, or decompose a large commit into smaller atomic commits. Use INSTEAD of manual git rebase -i + edit or git reset HEAD^. Prevents: non-working intermediate commits, wrong split ordering, missed downstream restack.

★ 2
higherorderfunctor
higherorderfunctor/nix-agentic-tools

stack-plan

Use when you need to plan commits, restructure a stack, or commit uncommitted work as organized atomic commits. Builds a stack from a description, uncommitted work, or existing commits INSTEAD of dumping everything into one monolithic commit with git add -A && git commit, or manual git rebase -i, git reset --soft, or ad-hoc git move sequences. Prevents: wrong commit ordering, forward references, git move -F panics, untested intermediates.

★ 2
higherorderfunctor
higherorderfunctor/nix-agentic-tools

stack-fix

Use when you need to fix, correct, or update content in an earlier commit — line-level edits, content moves, or structural changes. Absorbs staged changes into correct stack commits INSTEAD of running git absorb or git commit --fixup via Bash, or hand-running git prev + edit + git amend + git restack --merge. Prevents: missed dry-run preview, leftover staged changes going unnoticed, forgetting to restack. Falls back to guided manual amend when absorb cannot route hunks.

★ 2