Skip to content

feat(flow-ai): issue Flow reads via flowbio CLI api get instead of curl - #9

Merged
mhusbynflow merged 7 commits into
mainfrom
mhusbynflow/flowbio-cli-flow-ai-skill
Jul 15, 2026
Merged

feat(flow-ai): issue Flow reads via flowbio CLI api get instead of curl#9
mhusbynflow merged 7 commits into
mainfrom
mhusbynflow/flowbio-cli-flow-ai-skill

Conversation

@mhusbynflow

Copy link
Copy Markdown
Contributor

What & why

The flow-ai skill previously performed every Flow read with curl, embedding the token via $(< ~/.config/flow/api-token) — a command substitution Claude Code won't prefix-allowlist, so every read re-prompted for approval (a bespoke opt-in hook existed solely to suppress those prompts).

This reworks reads onto the flowbio CLI's new read-only passthrough, flowbio api get <PATH> --param k=v --json. The CLI resolves the token itself (from ~/.config/flow/api-token, or anonymous), so read commands carry no embedded secret and share a stable, allowlistable prefix — which lets the hook be deleted entirely.

Changes

  • Reads → flowbio api get across SKILL.md, examples.md (17 recipes), and the endpoint reference; discovery reads inside the pipeline-run flow move too.
  • Removed the read-approve hook (hooks/flow-read-approve.sh + test + hooks.json) and its CI wiring; README now documents the recommended permissions.allow entries.
  • Shared flowbio pin bumped 0.7.00.9.0 (first release carrying api get alongside the upload commands — one pin for reads and uploads).
  • Auth guidance surfaced on auth failure / when a caller-scoped read has no token, instead of silently going anonymous.
  • Error handling for reads now parses the CLI's --json envelope, trusting the server status_code + message over the coarse exit code.
  • Plugin version 0.9.00.10.0; CHANGELOG entry added.

Deliberately kept on curl

POST /pipelines/versions/<id>/run (confirmation-gated; api get is GET-only) and GET /downloads/<id>/<file> (raw bytes; api get returns text). Both keep token discipline via $(< … ).

Breaking

Reads now require a runner (uv/pipx/flowbio) just like uploads — no curl fallback. On a machine with none, reads stop with an install message.

Verification

  • scripts/validate_skills.py passes; 18 eval JSON files valid (added 017-read-no-runner, 018-auth-guidance-when-expected).
  • Live smoke-tested flowbio api get against the public API: catalog fetch, --param filtered search, and the error envelope (count=99999 → exit 5 + {"message", "status_code": 400}).
  • Passed an adversarial fresh-eyes review (1 round, APPROVED; 3 findings fixed).

Out of scope

Adding a POST/mutation passthrough to the flowbio CLI; changing the upload flows beyond the pin bump; bulk multi-file (zip) downloads. A pre-existing missing CHANGELOG 0.9.0 entry (clip-analysis release) was not backfilled.

🤖 Generated with Claude Code

mhusbynflow and others added 6 commits July 15, 2026 16:37
Records the approved design to replace curl-based Flow reads with the
flowbio CLI's read-only 'api get' passthrough, so the CLI owns
authentication and reads stop re-prompting for approval. Captures the
two deliberate curl remnants (run POST, byte download), the shared
version pin bump to 0.9.0, hook removal, and the new auth guidance.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Flow reads are moving from curl to the flowbio CLI's 'api get' command,
which resolves the token itself. That produces a stable, secret-free
command prefix Claude Code can allowlist by normal means, so the opt-in
PreToolUse hook that auto-approved the curl reads is no longer needed.

Deletes the hook, its test, and the hooks manifest; drops the hook test
from CI; and replaces the README's env-var opt-in with allowlist
guidance.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Reads now run through the flowbio CLI's read-only 'api get' passthrough,
which resolves the token from ~/.config/flow/api-token itself. This lets
the CLI own authentication, so read commands carry no embedded secret
and share a stable, allowlistable prefix.

- §3 configuration rewritten for 'flowbio api get <PATH> --param k=v
  --json', CLI-resolved base URL and auth, and new authentication
  guidance shown on auth failure / when auth is expected.
- §4.1 runner preflight now gates the first CLI call of any kind (read
  or upload), with the shared pin bumped 0.7.0 -> 0.9.0 (first release
  carrying 'api get' plus the upload commands). No curl fallback for
  reads.
- §1 token discipline rescoped: only the pipeline-run curl references
  the token directly; reads and uploads never handle it.
- §6/§7 querying and output patterns updated (--param, drop the flow-ai
  read User-Agent). §8 error handling flips to the --json envelope,
  trusting the server status_code + message over the coarse exit code.

Pipeline runs and file downloads stay on curl (api get is GET-only and
returns text, unsuitable for binary downloads).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Rewrites the worked examples and endpoint references so every GET read
uses 'flowbio api get <PATH> --param k=v --json | jq' instead of curl.
The file download (Example 7) and pipeline run (Examples 22-23) keep
curl, since api get is GET-only and returns text; their discovery reads
still convert to api get.

- examples.md: all 17 read recipes converted; --data-urlencode -> --param;
  ?owned/?log query strings -> --param; auth preamble rewritten (the CLI
  attaches the token itself, no header to prepend).
- endpoints/pipelines.md: GET-auth prose no longer tells the agent to
  attach an Authorization header on reads (the CLI does it); run-POST
  User-Agent bumped to flow-ai/0.10.0.
- endpoints/downloads.md: authenticated download documents attaching the
  token to its curl directly (second curl remnant).
- endpoints/data.md, samples.md: upload pins bumped 0.7.0 -> 0.9.0.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Completes the read-mechanism migration across the supporting material:

- evals: read scenarios now assert 'flowbio api get … --json' with the
  CLI resolving the token (no hand-rolled Authorization header or
  flow-ai User-Agent); --data-urlencode -> --param; the 'HTTP 200 with
  nulls' framing reframed as 'a successful read returning nulls'; upload
  pins bumped 0.7.0 -> 0.9.0; stale SKILL.md section refs corrected to §6.
- README: token-file note and versioning section reflect CLI-owned auth
  and the UA surviving only on the run/download curls; lockstep grep
  updated to the current version.
- plugin.json bumped 0.9.0 -> 0.10.0; CHANGELOG documents the migration,
  the hook removal, the shared pin bump, and the breaking no-curl-fallback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…rage)

Round-1 review findings (all recommended/optional; verdict APPROVED):

- Make emitted read commands byte-identical to the README permission
  allowlist by dropping the quotes around the pinned spec
  (uvx --from flowbio==0.9.0 …). Claude Code prefix-matches the raw
  string, so the quoted form would never match the unquoted allowlist
  entry and reads would keep prompting — defeating the change's purpose.
  Added a note by the allowlist so the quoting can't drift again.
- Add eval coverage for the two new spec-central negative paths: a read
  with no runner present (017), and auth guidance when a caller-scoped
  read has no token (018).
- Rescope the README pre-release lockstep grep so it stops flagging the
  evals' flow-ai/<version> placeholder and historical release numbers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mhusbynflow

Copy link
Copy Markdown
Contributor Author

@claude please review this PR

Live testing revealed two issues surfaced by the move to api get:

1. The skill's long-standing claim that /me returns 'HTTP 200 with a
   record of nulls' for a missing/invalid token is stale — the current
   Flow API returns 401 (verified via both curl and the CLI, for absent
   and garbage tokens). Search endpoints (/samples/search etc.) DO still
   silently treat a bad token as anonymous and return a misleading
   owned=true count, which is why owned-scoped queries are still gated on
   a successful /me. Corrected the model across SKILL §8 (already had the
   401/403 row), examples.md (12, 14, preamble), endpoints/users.md and
   samples.md, and evals 001-004 + 018. This is a pre-existing inaccuracy
   (API drift) that the auth-guidance feature depends on getting right.

2. Reads pipe through jq (flowbio api get ... --json | jq ...). Claude
   Code auto-approves a piped command only when every segment is
   allowlisted and offers no one-click 'don't ask again' for multi-segment
   commands, so the documented allowlist now also includes Bash(jq:*) —
   otherwise reads keep prompting despite the flowbio api get rule.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mhusbynflow
mhusbynflow merged commit 30709cc into main Jul 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant