Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0e90461
fix(conversation): send shows what the agent said first
Bradenream Nov 30, 2026
61166a4
fix(conversation): send --text says something in plain words
Bradenream Nov 30, 2026
0801b23
fix(conversation): an end action works as written, and action errors …
Bradenream Nov 30, 2026
4ca167f
feat(cli): a delete asks before it sends, at a terminal
Bradenream Nov 30, 2026
ddf8cc1
feat(environment): merge says it goes live at once, and asks first
Bradenream Nov 30, 2026
7888067
fix(output): --jq prints a string raw, as jq -r and gh --jq do
Bradenream Nov 30, 2026
8588060
fix(output): a --jq that fails after a write says the write happened
Bradenream Nov 30, 2026
6b2d419
fix(output): -o table shows a union's fields and a document's name
Bradenream Nov 30, 2026
b5380c5
fix(output): -o table fits the terminal and keeps each row on one line
Bradenream Nov 30, 2026
af6ec4e
fix(flagutil): -p and -e mean the project and environment on every co…
Bradenream Nov 30, 2026
3b0e02c
fix(help): flags say what they are, not their type or a generated name
Bradenream Nov 30, 2026
9499a49
fix(help): name vf commands and flags, not MCP tools and API fields
Bradenream Nov 30, 2026
52ba685
fix(help): a form's fields say they are required with that form
Bradenream Nov 30, 2026
ea059a7
fix(help): a union that can't be left out is listed as required
Bradenream Nov 30, 2026
52301ab
fix(cli): a command that takes no arguments rejects stray words
Bradenream Nov 30, 2026
55991a0
fix(flagutil): warn about JSON body keys the request has no field for
Bradenream Nov 30, 2026
7bcb967
fix(flagutil): each union form's flag shows its JSON in help and --usage
Bradenream Nov 30, 2026
99bad4a
fix(flagutil): a JSON flag's hints come from the type it takes
Bradenream Nov 30, 2026
b7a7378
fix(conversation): stray words on send point at --text
Bradenream Nov 30, 2026
59f2b57
feat(cli)!: give each kind of failure its own exit code
Bradenream Nov 30, 2026
46bf337
feat(output)!: one JSON shape for every error, local or from the API
Bradenream Nov 30, 2026
c3d74be
fix(output): agent-mode errors name the flag a refused field is set with
Bradenream Nov 30, 2026
541067b
fix(cli): name every missing required flag in one error
Bradenream Nov 30, 2026
4b4d10e
fix(cli): say what's wrong with JSON input in plain words
Bradenream Nov 30, 2026
05129c1
fix(cli): analytics queries take a day, and say what a date must be
Bradenream Nov 30, 2026
d5d7087
fix(conversation): a send without an action names --text first
Bradenream Nov 30, 2026
d2b4554
fix(cli): a command declaring cobra.NoArgs gets the stray-word error too
Bradenream Nov 30, 2026
1d4b463
fix(output): a --jq filter that calls error() exits 1, not 5
Bradenream Nov 30, 2026
a8bbb77
fix(cli): a lone stray word is offered as the ID it likely was
Bradenream Nov 30, 2026
451bc2e
fix(help): a form's kind stays the value typed in its JSON
Bradenream Nov 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 47 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Worth knowing before you script against the CLI:
- **`--action '{"type":"launch"}'` is optional.** Sending a `text` action straight away works; the runtime starts the conversation itself. The launch step is shown because it makes the first turn explicit.
- **A conversation with the draft runs your latest edits.** The draft runs as last compiled, so vf compiles it before `conversation run-script` and before a `send` with a `launch` action. If a later turn still ran an older build (you edited mid-conversation, or started with a `text` action), vf compiles right after it and warns, so the next turn runs the edits. `--no-compile` talks to the last build as it is; the published version is never compiled.
- **Pass `--output-format json` explicitly when piping.** Inside AI coding agents (`CLAUDECODE`, `CURSOR_AGENT`, …) the default output is TOON, not JSON.
- **Capture values with `--output-format json | jq -r`** — the built-in `--jq` flag emits JSON, so strings keep their quotes.
- **Capture values with `--jq`**: `ID=$(vf project create … --jq .project.id)`. A string result prints raw, as `jq -r` prints it; anything else prints as JSON.
- **`vf whoami` is offline** — it shows which credential source is configured but does not validate the token. `vf workspace list` is the real check.
- **Look things up in-band**: `vf docs search "publish an environment"` and `vf docs get <page>` bring the documentation to the terminal — no browser, no auth.

Expand Down Expand Up @@ -849,7 +849,7 @@ vf <command> --output-format json | jq '.fieldName'

### jq filtering

Use `--jq` to filter or transform the response inline using a [jq](https://jqlang.org) expression. This always outputs JSON and overrides `--output-format`:
Use `--jq` to filter or transform the response inline using a [jq](https://jqlang.org) expression. A string result prints raw, as `jq -r` and `gh --jq` print it, so it can be captured as is; any other result prints as JSON (`| tojson` keeps a string quoted). `--jq` overrides `--output-format`:

```bash
# Extract a single field
Expand Down Expand Up @@ -886,21 +886,60 @@ When using `--all` (pagination) or streaming operations, output is written incre
<!-- Start Error Handling [errors] -->
## Error Handling

The CLI uses standard exit codes to indicate success or failure:
Each kind of failure has its own exit code, so a script can tell them apart without reading stderr:

| Exit Code | Meaning |
|-----------|---------|
| `0` | Success |
| `1` | Error (API error, invalid input, etc.) |
| `1` | Any other failure, including API errors not listed below |
| `2` | Usage error, caught before any request: an unknown or invalid flag, a missing required flag, a bad argument |
| `3` | Authentication: not signed in, no token, HTTP 401, an expired session |
| `4` | Not found: HTTP 404 |
| `5` | Timed out: `--timeout`, or a wait's `--max-wait` ran out with runs still going |
| `6` | A test run didn't pass: `test run wait`, `test run wait-suite`, `test run create-suite --wait` |

`vf --help` lists them too.

In agent mode, and with `-o json` or `--jq`, an error is printed to stderr as one JSON object, with the same keys whether vf found the problem itself or the API answered with it:

| Key | When | Meaning |
|-----|------|---------|
| `error` | always | The headline a person sees: `Couldn't get project · HTTP 404 Not Found` |
| `error_type` | always | The kind of failure: `not_found`, `missing_flag`, `validation_error`, … |
| `exit_code` | always | The code the process exits with |
| `message` | always | What went wrong, in one line: the API's own message, or the headline |
| `hints` | always | What to do next; an empty list when there is nothing to add |
| `explanation` | when vf can tell | Why it failed |
| `details` | when the API names fields, or flags are missing | The fields the request was refused for: `field`, the `flag` that sets it, `message`, `code`. A `missing_flag` error lists every missing flag here |
| `docs_url` | for most commands | The page that covers the command |
| `status_code` | when a response came back | The HTTP status |
| `body` | when a response came back | The response body as the API sent it, its own keys (such as `statusCode`) included |

```json
{
"error": "Couldn't get project · HTTP 404 Not Found",
"error_type": "not_found",
"exit_code": 4,
"message": "Project not found",
"explanation": "Check --project-id abc: it may be wrong, or belong to another workspace or environment.",
"hints": ["'vf project list' lists the IDs you can use"],
"docs_url": "https://www.voiceflow.com/docs/cli/commands/project",
"status_code": 404,
"body": { "statusCode": 404, "message": "Project not found" }
}
```

On success, the response data is printed to **stdout** as JSON. On failure, error details are printed to **stderr**.
On success, the response data is printed to **stdout**. On failure, error details are printed to **stderr**.

```bash
# Capture output and handle errors
vf ... > output.json 2> error.log
if [ $? -ne 0 ]; then
echo "Error occurred, see error.log"
fi
case $? in
0) ;;
4) echo "Not found" ;;
5) echo "Timed out; try again" ;;
*) echo "Failed, see error.log" ;;
esac
```
<!-- End Error Handling [errors] -->

Expand Down
2 changes: 1 addition & 1 deletion cmd/vf/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ func main() {
if msg := err.Error(); msg != "" {
fmt.Fprintln(os.Stderr, msg)
}
os.Exit(1)
os.Exit(cli.ExitCode(err)) // internal/cli/exitcode.go: each kind of failure has its own code
}
}
109 changes: 109 additions & 0 deletions internal/cli/analytics/query/daterange.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// This file is not generated by Speakeasy. It lets an analytics query's
// --start-date and --end-date take a day, and checks the range before it is
// sent.
//
// The API takes only a UTC time, 2026-06-01T00:00:00Z. Given a day, the
// usual way to ask for one, vf sent it as typed and printed what the API
// said: "Invalid ISO datetime", then "Invalid string: must match pattern
// /^(?:(?:\d\d[2468][048]|…/" for each date, 3 KB of regex and no format a
// person could read. A start after its end was sent too. Now a day is taken
// and sent as the time it starts, or for --end-date the time it ends, any
// other value is refused with the format, and a start after the end is
// refused before anything is sent.

package query

import (
"fmt"
"strings"
"time"

"github.com/spf13/cobra"

"github.com/voiceflow/cli/internal/flagutil"
"github.com/voiceflow/cli/internal/usage"
)

// dateRanges gives each query under query that takes --start-date and
// --end-date dates that take a day, with help that says so.
func dateRanges(query *cobra.Command) {
for _, c := range query.Commands() {
start, end := c.Flags().Lookup("start-date"), c.Flags().Lookup("end-date")
if start == nil || end == nil || start.Value.Type() != "string" || end.Value.Type() != "string" {
continue
}
from := &dateValue{flag: "start-date"}
to := &dateValue{flag: "end-date", end: true}
start.Value, end.Value = from, to
ownHelp(c, "start-date", "Start of the range: a day, 2026-06-01, from 00:00 UTC, or a UTC time, 2026-06-01T09:30:00Z [required]")
ownHelp(c, "end-date", "End of the range: a day, 2026-06-30, through 23:59:59.999 UTC, or a UTC time, 2026-06-30T17:00:00Z [required]")
c.Example = strings.NewReplacer("--start-date <value>", "--start-date 2026-06-01", "--end-date <value>", "--end-date 2026-06-30").Replace(c.Example)
run := c.RunE
c.RunE = func(cmd *cobra.Command, args []string) error {
if from.given != "" && to.given != "" && from.at.After(to.at) {
Comment on lines +42 to +43
return &flagutil.FlagValueError{
Flag: "start-date",
Value: from.given,
Expected: "it is after --end-date " + to.given,
Hints: []string{"the start comes first: --start-date " + to.given + " --end-date " + from.given},
}
}
return run(cmd, args)
}
}
}

// ownHelp sets flag name's help on c, for --help and --usage alike.
func ownHelp(c *cobra.Command, name, help string) {
c.Flags().Lookup(name).Usage = help
_ = c.Flags().SetAnnotation(name, usage.OwnHelp, []string{"true"})
}

// dateValue is a range's start or end: a day, or a time. It is sent as a
// UTC time; a day as the time it starts, or, for an end, the time it ends.
type dateValue struct {
flag string
end bool
given string // as passed
at time.Time // the time it stands for
sent string // as sent
}

func (d *dateValue) String() string { return d.sent }

func (d *dateValue) Type() string { return "string" }

func (d *dateValue) Set(s string) error {
s = strings.TrimSpace(s)
day, err := time.Parse(time.DateOnly, s)
switch {
case err == nil:
d.at = day
if d.end {
d.at = day.Add(24*time.Hour - time.Millisecond)
}
d.sent = d.at.Format("2006-01-02T15:04:05.000Z")
default:
at, err := parseTime(s)
if err != nil {
return fmt.Errorf("--%s takes a day (2026-06-01) or a UTC time (2026-06-01T09:30:00Z)", d.flag)
}
d.at, d.sent = at, s
if !strings.HasSuffix(s, "Z") {
// The API takes UTC only; a time with an offset is the same
// moment in UTC.
d.sent = at.UTC().Format(time.RFC3339Nano)
}
}
d.given = s
return nil
}

// parseTime reads an ISO 8601 time with a zone, its seconds optional.
func parseTime(s string) (time.Time, error) {
at, err := time.Parse(time.RFC3339Nano, s)
if err != nil {
at, err = time.Parse("2006-01-02T15:04Z07:00", s)
}
return at, err
}
1 change: 1 addition & 0 deletions internal/cli/analytics/query/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func InitQueryRoot(parent *cobra.Command) error {
return err
}

dateRanges(QueryCmd) // daterange.go: dates take a day, and a range is checked
parent.AddCommand(QueryCmd)
return nil
}
39 changes: 39 additions & 0 deletions internal/cli/bodyerror_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// This file is not generated by Speakeasy. It covers how errors.go explains
// a request body, given with --body or on stdin, that vf couldn't use.

package cli

import (
"strings"
"testing"

"github.com/voiceflow/cli/internal/output"
)

func TestABadBodyIsAnInvalidBodyError(t *testing.T) {
x := runWithStdin(t, "", "transcript", "search", "-p", "p1", "--body", `{"take":"ten"}`)
if x.Type != "invalid_body" || output.ExitCodeFor(x.Type, 0) != output.ExitUsage {
t.Errorf("type = %q", x.Type)
}
all := explained(x)
for _, want := range []string{
`invalid --body: take should be a whole number, not "ten"`,
"The request wasn't sent.",
`You passed: {"take":"ten"}`,
"--body takes an object: `vf transcript search --help` shows what goes in it",
} {
if !strings.Contains(all, want) {
t.Errorf("missing %q in:\n%s", want, all)
}
}
}

func TestABadBodyOnStdinSaysItCameOnStdin(t *testing.T) {
x := runWithStdin(t, `{"take":[1]}`+"\n", "transcript", "search", "-p", "p1")
if x.Type != "invalid_body" || x.Title != "invalid body on stdin: take should be a whole number, not a list" {
t.Errorf("got %q: %q", x.Type, x.Title)
}
if all := explained(x); !strings.Contains(all, "The body takes an object") {
t.Errorf("got:\n%s", all)
}
}
Loading
Loading