Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 13 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@

<!-- How was this tested? -->

- [ ] `make check` passes (format, lint, typecheck)
- [ ] `make dev` passes (format, lint, tests)
- [ ] `make verify` passes (format, lint, types, lockstep, READMEs, manifest, tests)
- [ ] Manual testing of affected commands

## Risk

<!-- What could this break, and for whom? If the risk is low, say why. Name any
change to public surface: a flag, output shape, exit code, environment
variable or config key. -->

## How to revert

<!-- Is reverting this PR enough? Once a version is released, users have it,
and a revert on main does not undo that. Say what a fix release would have to
clean up, such as a config key users may already have written. -->

## Related issues

<!-- Link related issues: Fixes #123, Related to #456 -->
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ jobs:
- name: Type check
run: uv run mypy src/ packages/*/src scripts/

# The sub-package READMEs and the marked sections of the root README
# are generated from pyproject metadata. Nothing else notices a stale
# one. Run `make readmes` to fix it.
- name: Check generated READMEs
run: make readmes-check

lockstep:
name: Lockstep versions
runs-on: ubuntu-latest
Expand Down
160 changes: 160 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Working in this repository

Guidance for AI coding agents, and a fast orientation for people. It says what
the project guarantees, how to check your work, and where your authority ends.
[CONTRIBUTING.md](CONTRIBUTING.md) has the contributor workflow and the release
mechanics; [REVIEW.md](REVIEW.md) has the review rubric. This file does not
repeat them.

## What this is

`dg` (the `deepctl` distribution) is the Deepgram CLI: Python 3.10+, a `uv`
workspace of 30 first-party packages that ship at one version.

| Path | Holds |
|---|---|
| `src/deepctl/` | Entry point, lazy command loading, the command manifest and help specs |
| `packages/deepctl-core/` | Config, credentials, transport, output, agent detection, the command base classes |
| `packages/deepctl-cmd-*/` | One package per command |
| `packages/deepctl-plugin-example/` | The third-party plugin fixture; versions on its own |
| `npm/` | The `@deepgram/cli` launcher (Node) |
| `web/` | The website |
| `bench/` | Benchmark harness and its gates |
| `tests/` | Cross-package tests; each package also has `tests/` |

## Check your work

One command runs what CI's lint, lockstep and test jobs run:

```bash
make verify # everything
make verify-fast # everything except the test suite
make verify ARGS="--json" # one JSON document on stdout
make verify ARGS="--only lint types"
```

With `--json`, every failure is a finding with a file, a line, a rule and,
where one exists, the command that fixes it. Work the loop: run it, fix what it
reports, run it again.

- Run `make verify-fast` after each change and `make verify` before you call
the work done.
- Stop after three rounds on the same failure. Report what you tried and the
findings that remain; do not keep going.
- Never make a check pass by weakening it. Editing a golden file, an
allowlist, `bench/gates.json`, a test's expectation or a skip marker is a
change to the project's rules. Do it only when the new behaviour is the
point of the change, and say so in the PR description.

CI also builds every package, installs at the lowest allowed dependency
versions, and runs the npm launcher on three operating systems. `make verify`
does not; a change to packaging, dependency floors or `npm/` needs CI.

## What must stay true

Most of these are enforced by a test, named in brackets. The test's docstring
holds the reason; read it before changing the behaviour. A rule with no test
named is held by review. Each rule says what its test checks and no more: do
not read a wider rule into it.

**Output**

- Warnings, errors and notices go to stderr, and each warning prints once. In
a machine format (`-o json`, `yaml`, `csv`), stdout holds the result and
nothing else (`tests/unit/test_stream_discipline.py`).
- Exit codes: `0` success, `1` error, `2` cancelled. Callers branch on them.
`tests/unit/test_main.py` covers the root handlers; a command's own paths
are held by review.
- Output must not fail on a stream whose encoding lacks a character, such as
cp1252 on Windows (`tests/unit/test_output_encoding.py`).

**Help and the manifest**

- Each built-in command has a fragment in `src/deepctl/_manifest.d/`. Its
`help` block is the command's `--help` as data, and must match the command
byte for byte (`tests/unit/test_help_parity.py`,
`tests/unit/test_manifest.py`). After changing a command's options or help
text, run `uv run python -m deepctl._manifest_build --write-help`.
- Every example a command advertises must parse against its real options
(`tests/unit/test_command_examples.py`). Agents are handed those examples.

**Startup cost**

- Command modules import no network stack at module level: `asyncio`, `ssl`,
`httpx`, `websockets` and the Deepgram SDK belong inside the functions that
use them (`tests/unit/test_command_imports.py`).
- `dg --version` and the `dg mcp` handshake start without Click or
`deepctl_core` (`tests/unit/test_import_budget.py`, `bench/gates.json`).

**Dependencies and versions**

- Every runtime dependency, direct or transitive, is named in
`tests/unit/dependency_allowlist.txt`. `numpy`, `ffmpeg-python`, `future`
and `aiohttp` must not come back
(`tests/unit/test_dependency_allowlist.py`).
- All first-party packages share one version and pin each other with `==`.
`make floors-check` fails on drift and `make floors-fix` repairs it.

**Credentials and trust**

- Shipped text never shows an API key on a `dg` command line or in an MCP
config's `args`: the READMEs, the website, the sources and the help specs.
`dg login --api-key` is the one exemption
(`tests/unit/test_mcp_docs_lint.py`). This is about what docs and examples
show. The root `--api-key` option exists and is not a violation.
- A user config that fails to parse never has its content shown; a line can
hold a key (`tests/unit/test_config_load_errors.py`).
- A base URL from `--base-url` or `DEEPGRAM_BASE_URL` is never saved to config
(`tests/unit/test_base_url_persistence.py`).
- User-facing strings about hosts, credentials and config live in
`deepctl_core/messages.py`, keyed by message ID. Hints from the host check
in agent mode never name a config key, environment variable or flag an
agent could use to approve its own host
(`packages/deepctl-core/tests/unit/test_agent_hints.py`).
- `deepctl_core/agents.py` is the one table for detecting agents
(`packages/deepctl-core/tests/unit/test_agents.py`). `is_agentic()` decides
presentation and prompts; `is_ai_agent()` decides trust, and trust follows
the raw agent markers, never `DG_AGENT`
(`packages/deepctl-core/tests/unit/test_agent_trust.py`). Do not use one
for the other's job.

**Docs**

- Shipped text must not promise `dg mcp` behaviour it doesn't have
(`tests/unit/test_mcp_docs_lint.py`).
- Sub-package READMEs and the marked sections of the root README are
generated. Run `make readmes`; do not edit them by hand.

**Tests**

- Tests run with `DEEPGRAM_*` variables stripped and telemetry off
(`conftest.py`).
- The live end-to-end suite in `tests/e2e/` calls the real API and is opt-in.
Do not set `RUN_LIVE_E2E` or `RUN_LIVE_E2E_PRODUCTION`.

## Changing things

- **A new command or package:** follow "Adding a New Command" in
[CONTRIBUTING.md](CONTRIBUTING.md). It lists every file that has to change.
- **A flag, option, output shape, exit code, environment variable or config
key:** this is public surface. Prefer adding the new form and deprecating
the old one over changing it in place.
- **Commits:** Conventional Commits. release-please builds the changelog and
picks the version bump from them, so `feat` versus `fix` is a decision, not
a label.
- **Pull requests:** one purpose each. There is no limit on size.

## Where your authority ends

You may read anything in the repository, and edit code, tests and docs on a
working branch. Leave these to a person unless one has asked you for exactly
that:

- Merging, releasing, or pushing to `main`.
- Changing workflow `permissions`, `allowed_non_write_users`, or anything
else under `.github/` that decides who or what can act on the repository.
- Loosening a gate, allowlist or golden file, as described above.
- Anything that needs a real API key or reaches a real Deepgram account.

When you are blocked, stop and leave the work legible: what is done, what is
not, and what you found.
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AGENTS.md
14 changes: 12 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,25 @@ cd cli
uv sync --group dev

# Run all checks
make dev # format + lint + test
make verify # what CI's lint, lockstep and test jobs check
make verify-fast # the same, without the test suite
make dev # format + fix lints + test
make check # format + lint + typecheck (no tests)
```

`make verify` reports each failure with its file, line and rule, and the
command that fixes it. `make verify ARGS="--json"` prints the same report as
one JSON document ([schema](docs/contracts/verify.schema.json)), which is the
form a coding agent should read. [AGENTS.md](AGENTS.md) lists what the project
guarantees and the test behind each guarantee; [REVIEW.md](REVIEW.md) is what
a review looks for.

## Development Workflow

1. **Create a branch** from `main`
2. **Make your changes** following the conventions below
3. **Run `make dev`** to ensure everything passes
3. **Run `make dev`** to format and fix lints, then **`make verify`** to
check what CI checks
4. **Run `make readmes`** if you added or modified packages
5. **Submit a pull request**

Expand Down
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ help: ## Show this help message
@echo "🧪 \033[1mTesting:\033[0m"
@echo " \033[36mtest\033[0m Run tests (development)"
@echo " \033[36mcheck\033[0m Quick quality check (no tests)"
@echo " \033[36mverify\033[0m Everything CI's lint, lockstep and test jobs check"
@echo " \033[36mverify-fast\033[0m verify without the test suite"
@echo ""
@echo "🔧 \033[1mCode Quality:\033[0m"
@echo " \033[36mformat\033[0m Auto-format code"
Expand Down Expand Up @@ -81,6 +83,18 @@ dev: format lint-fix test ## Run full development cycle: format, fix lints, test
check: format-check lint-check typecheck ## Quick quality check (no tests)
@echo "✅ Quick check complete!"

# What CI's lint, lockstep and test jobs check, as findings: a file, a line, a
# rule and the command that fixes it. ARGS passes options through, for example
# `make verify ARGS="--json"` or `make verify ARGS="--only lint types"`.
# See scripts/verify.py.
# The recipes are silent (`@`): make would otherwise echo the command to
# stdout, ahead of the JSON document.
verify: ## Run every check CI's lint, lockstep and test jobs run
@uv run python scripts/verify.py $(ARGS)

verify-fast: ## verify without the test suite
@uv run python scripts/verify.py --skip tests $(ARGS)

# ===================================================================
# TESTING
# ===================================================================
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ git clone https://github.com/deepgram/cli && cd cli
uv sync --group dev
make dev # Format + lint + test
make check # Format + lint + typecheck (no tests)
make verify # What CI's lint, lockstep and test jobs check
```

### Architecture
Expand Down
Loading
Loading