Skip to content

search: add --json flag for machine-readable output #1

@raphasouthall

Description

@raphasouthall

`neurostack search "query"` currently prints results as formatted text. This is useful for humans but hard to pipe into other tools.

Add a `--json` flag that outputs results as a JSON array instead. Each element should include at minimum: `path`, `title`, `score`, and `snippet`.

Example:

```bash
neurostack search "memory consolidation" --json
```

```json
[
{
"path": "neuroscience/memory.md",
"title": "Memory Consolidation",
"score": 0.91,
"snippet": "Consolidation transfers information from hippocampus to neocortex..."
}
]
```

Where to look:

  • CLI entry point: `src/neurostack/cli.py`
  • Search logic: `src/neurostack/search.py`
  • The `search` subcommand is defined in `cli.py` using Click or similar — look for the `@cli.command()` decorator for `search`

Acceptance criteria:

  • `neurostack search "query" --json` outputs valid JSON to stdout
  • Each result object includes `path`, `title`, `score`, and `snippet`
  • Default (non-JSON) output is unchanged
  • `--json` is documented in `--help`
  • At least one test covers the JSON output path

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliCLI-related issuesenhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions