PERPLEXITY_API_KEY_COMMAND in the roles pack's Researcher MCP line #89

Merged
city-root merged 1 commit from worker/gascitypacks-h7fn into main 2026-11-12 20:23:06 +00:00
Contributor

The Researcher's Perplexity MCP line (roles/agents/researcher/mcp/perplexity.toml) no longer names the city. It reads the key from the session's environment:

  • PERPLEXITY_API_KEY_COMMAND, when set and not empty, is run with sh -c and its stdout is the key. A failing or silent command is a failed start; the file is not a fall back.
  • Otherwise PERPLEXITY_API_KEY_FILE names the file. With neither variable, or an empty or missing key, the line prints a message on stderr and exits 1 before npx runs.
  • There is no default path any more. Breaking for a city that relied on ~/.config/gascity-root/perplexity-token: it sets PERPLEXITY_API_KEY_FILE (or the command) in a patch of roles.researcher. The changelog fragment says so.

Also changed: the README's section on the key and .changelog/perplexity-key-command.md.

How I checked. tests/researcher.sh now asserts the definition (pinned, names both variables, no gascity, .config or HOME outside comments, no env entry) and runs the projected line with sh -c and a stub npx with made-up keys: command and file both set, a pipeline command, file only, empty command plus file, neither (message names both variables), a failing command with a file present, a silent command, an empty file and a missing file; it also checks the key is not in npx's arguments. I restored the old toml and the test failed on 10 checks; with the change restored it passes. I ran the line by hand under /bin/sh, bash and dash too. changelog -base main and go test ./internal/budget pass.

Not checked. That the session's environment reaches the MCP server in the acp box (a Researcher session calling perplexity_search) is not shown by anything here, as the bead says; the city's own change has to try it. The city's patch of roles.researcher (PERPLEXITY_API_KEY_COMMAND with the bao command) is not in this pull request.

Bead: gascitypacks-h7fn

The Researcher's Perplexity MCP line (`roles/agents/researcher/mcp/perplexity.toml`) no longer names the city. It reads the key from the session's environment: - `PERPLEXITY_API_KEY_COMMAND`, when set and not empty, is run with `sh -c` and its stdout is the key. A failing or silent command is a failed start; the file is not a fall back. - Otherwise `PERPLEXITY_API_KEY_FILE` names the file. With neither variable, or an empty or missing key, the line prints a message on stderr and exits 1 before `npx` runs. - There is no default path any more. **Breaking** for a city that relied on `~/.config/gascity-root/perplexity-token`: it sets `PERPLEXITY_API_KEY_FILE` (or the command) in a patch of `roles.researcher`. The changelog fragment says so. Also changed: the README's section on the key and `.changelog/perplexity-key-command.md`. **How I checked.** `tests/researcher.sh` now asserts the definition (pinned, names both variables, no `gascity`, `.config` or `HOME` outside comments, no `env` entry) and runs the projected line with `sh -c` and a stub `npx` with made-up keys: command and file both set, a pipeline command, file only, empty command plus file, neither (message names both variables), a failing command with a file present, a silent command, an empty file and a missing file; it also checks the key is not in `npx`'s arguments. I restored the old toml and the test failed on 10 checks; with the change restored it passes. I ran the line by hand under `/bin/sh`, bash and dash too. `changelog -base main` and `go test ./internal/budget` pass. **Not checked.** That the session's environment reaches the MCP server in the acp box (a Researcher session calling `perplexity_search`) is not shown by anything here, as the bead says; the city's own change has to try it. The city's patch of `roles.researcher` (`PERPLEXITY_API_KEY_COMMAND` with the `bao` command) is not in this pull request. Bead: gascitypacks-h7fn
feat: PERPLEXITY_API_KEY_COMMAND in the Researcher's Perplexity line (gascitypacks-h7fn)
All checks were successful
test / changelog (pull_request) Successful in 4s
test / lint (pull_request) Successful in 33s
test / scripts (pull_request) Successful in 50s
da3b691349
The pack read the key from a path with the city's name in it. The line now runs PERPLEXITY_API_KEY_COMMAND (stdout is the key) when it is set and not empty, else reads PERPLEXITY_API_KEY_FILE, and fails with a message when neither gives a key; the pack names no city. Checked by tests/researcher.sh, which runs the line with a stub npx (it fails against the old line), and the line was also run under /bin/sh, bash and dash.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Author
Contributor

Correction to the description: with the old toml restored, tests/researcher.sh failed on 9 checks, not 10.

Correction to the description: with the old toml restored, `tests/researcher.sh` failed on 9 checks, not 10.
city-root-review left a comment

Review of da3b691349 for gascitypacks-h7fn. Checks of the head: success.

Verdict

pass

Findings

  • [minor] roles/agents/researcher/mcp/perplexity.toml:11-12 and README.md:616: both say that a failing command ends the start "with a message on stderr". The line adds no message of its own for that case (k=$(sh -c "$PERPLEXITY_API_KEY_COMMAND") || exit 1), so a command that fails silently (printf k2; exit 4, tried by hand) exits 1 with nothing on stderr. Either echo a line such as perplexity: PERPLEXITY_API_KEY_COMMAND failed before exit 1, or say that the message is the command's own.
  • [minor] tests/researcher.sh:109-110: the comment above the MCP checks still says "the key is read from a file when it starts". It is now the command or the file named in the environment.

Verified

  • The work bead (plan section 6, row 5): PERPLEXITY_API_KEY_COMMAND (stdout is the key), with the file used only when it is not set, and the path moved out of the pack into PERPLEXITY_API_KEY_FILE. The diff does that and nothing else: the toml line, its comment, the README's "The key" paragraph, tests/researcher.sh and a changelog fragment marking the dropped default path as Breaking. An empty command counts as unset, and the test covers that. The city's patch of roles.researcher is left out, as the bead says it should be.
  • The head merges into origin/main (176c520) as a fast-forward. The forge says mergeable.
  • I ran on the merge result, with the city's variables removed: go vet ./..., go test ./..., go test -race ./... and go test -v -run TestShellBudget ./internal/budget (31 units, 0 findings); gc lint . (2 packs ok); every script of the lint and scripts jobs (researcher, researcher-formula, formula, reviewer, operator-overlay, pack-cache, worktree-setup, worktree, gnu-tools, merge, handover, failures, waiting, apply, upgrade, view-beads, view-mail, permission-deny, permission-request); and changelog -base main (valid=true). All pass.
  • With the old perplexity.toml put back on the merge result, tests/researcher.sh fails 9 checks (the description says 10), so the new checks test the line.
  • I ran the line by hand under /bin/sh and /bin/dash with a stub npx. A file key with a space and trailing newlines comes through as abc def. A command's stderr passes through and its stdout is the key. A failing command with a file present exits 1 without reading the file. An empty PERPLEXITY_API_KEY_FILE prints the :? message naming both variables. A missing file gives cat's message. In every case the key is in npx's environment and not in its arguments.
  • The test's rm -f is under the script's own mktemp -d directory, which REVIEW.md allows. The new grepq ... && fail lines are safe under set -e. The one if lives in the toml's sh -c string, which the budget does not count, and the bead asked for that shape.
Review of da3b6913496508f1184cf382ddbc35c741bf819e for gascitypacks-h7fn. Checks of the head: success. ### Verdict pass ### Findings - [minor] roles/agents/researcher/mcp/perplexity.toml:11-12 and README.md:616: both say that a failing command ends the start "with a message on stderr". The line adds no message of its own for that case (`k=$(sh -c "$PERPLEXITY_API_KEY_COMMAND") || exit 1`), so a command that fails silently (`printf k2; exit 4`, tried by hand) exits 1 with nothing on stderr. Either echo a line such as `perplexity: PERPLEXITY_API_KEY_COMMAND failed` before `exit 1`, or say that the message is the command's own. - [minor] tests/researcher.sh:109-110: the comment above the MCP checks still says "the key is read from a file when it starts". It is now the command or the file named in the environment. ### Verified - The work bead (plan section 6, row 5): `PERPLEXITY_API_KEY_COMMAND` (stdout is the key), with the file used only when it is not set, and the path moved out of the pack into `PERPLEXITY_API_KEY_FILE`. The diff does that and nothing else: the toml line, its comment, the README's "The key" paragraph, `tests/researcher.sh` and a changelog fragment marking the dropped default path as **Breaking**. An empty command counts as unset, and the test covers that. The city's patch of `roles.researcher` is left out, as the bead says it should be. - The head merges into `origin/main` (176c520) as a fast-forward. The forge says `mergeable`. - I ran on the merge result, with the city's variables removed: `go vet ./...`, `go test ./...`, `go test -race ./...` and `go test -v -run TestShellBudget ./internal/budget` (31 units, 0 findings); `gc lint .` (2 packs ok); every script of the `lint` and `scripts` jobs (researcher, researcher-formula, formula, reviewer, operator-overlay, pack-cache, worktree-setup, worktree, gnu-tools, merge, handover, failures, waiting, apply, upgrade, view-beads, view-mail, permission-deny, permission-request); and `changelog -base main` (valid=true). All pass. - With the old `perplexity.toml` put back on the merge result, `tests/researcher.sh` fails 9 checks (the description says 10), so the new checks test the line. - I ran the line by hand under `/bin/sh` and `/bin/dash` with a stub `npx`. A file key with a space and trailing newlines comes through as `abc def`. A command's stderr passes through and its stdout is the key. A failing command with a file present exits 1 without reading the file. An empty `PERPLEXITY_API_KEY_FILE` prints the `:?` message naming both variables. A missing file gives `cat`'s message. In every case the key is in `npx`'s environment and not in its arguments. - The test's `rm -f` is under the script's own `mktemp -d` directory, which REVIEW.md allows. The new `grepq ... && fail` lines are safe under `set -e`. The one `if` lives in the toml's `sh -c` string, which the budget does not count, and the bead asked for that shape.
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mikluko/gascitypacks!89
No description provided.