Skip to content

feat(tsm): agent-friendly list search and JSON output - #28

Merged
tashian merged 2 commits into
mainfrom
feat/agent-friendly-json
Oct 6, 2026
Merged

tashian merged 2 commits into
mainfrom
feat/agent-friendly-json

Conversation

@tashian

@tashian tashian commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Why

Agent session logs show that agents use tsm list with difficulty:

  • To find an entry, agents send the full tsm list --json output to Python filters. They do this in 5 of 9 calls.
  • When the vault is locked, tsm list --json writes an error object to stdout. A filter that expects an array reads it as "no match". One agent decided that the vault had no OpenRouter key.
  • The JSON is indented, so tsm list --json | head -40 shows only about 5 entries. One agent did not see the second Anthropic key and used the wrong account.
  • tsm status shows Secrets: 0 when the vault is locked, so the vault looks empty.

What changes

  1. Errors go to stderr. If a command fails, stdout is empty and the exit code is 1. With --json, stderr gets {"error":{"code":-32002,"name":"auth_required","message":"..."}}. The name field is a stable word that scripts can match. Errors that do not come from the daemon have only message.
  2. tsm list [term...] shows the secrets where any term occurs in the id, display name, description, or a tag. Case is ignored. When nothing matches, --json gives [].
  3. Compact JSON when stdout is not a terminal. Arrays have one element on each line, so | head shows complete entries. The output is still one JSON document, so jq '.[]' and json.load continue to work. A terminal still gets indented output. This applies to all --json output.
  4. tsm status does not show the secret count while the vault is locked. This applies to text and --json. The change is in the CLI only, so it also works with an older daemon.

The skill and README describe the search, the output shape, and the error object.

Compatibility

  • Scripts that read --json errors from stdout must now read stderr.
  • secret_count is not in tsm status --json while the vault is locked.

Tests

  • New Go tests for the list filter, compact output, the error object, and status while locked. go test ./... passes.
  • I ran the built binary against a fake daemon on a temporary socket in two states, locked and unlocked:
    • When locked, stdout is empty, stderr has the JSON error, and the exit code is 1.
    • tsm list anthropic --json shows both Anthropic entries.
    • | head -4 shows 3 complete entries.
    • tsm status does not show the count while locked.
  • The daemon did not change, so I did not run the Swift tests.

The daemon reports secret_count 0 while the vault is locked, so a locked
vault looked empty. tsm status now omits the count (text and --json) until
the vault is unlocked.
- tsm list takes terms and lists the secrets where any term appears in the
  name, display name, description, or a tag (case-insensitive), so agents
  no longer pipe the full list into ad-hoc Python filters.
- --json output is compact when stdout is not a terminal; arrays put one
  element per line, so | head shows whole entries and the output stays one
  JSON document.
- Errors never go to stdout. With --json, stderr holds
  {"error":{"code","name","message"}}; name is a stable snake_case
  word (auth_required, vault_locked, ...). Before, a locked vault printed an
  error object to stdout, which a filter expecting an array read as empty.
- Skill and README document the search, the output shape, and the errors.
@tashian
tashian merged commit 6a2cb64 into main Oct 6, 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