Skip to content

Commit 37300b5

Browse files
committed
Added coz suggest-points.
1 parent bec7243 commit 37300b5

2 files changed

Lines changed: 1019 additions & 1 deletion

File tree

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,54 @@ To profile latency, you must place two progress points that correspond to the st
156156

157157
When coz tests a hypothetical optimization it will report the effect of that optimization on the average latency between these two points. Coz can track this information without any knowledge of individual transactions thanks to [Little's Law](https://en.wikipedia.org/wiki/Little%27s_law).
158158

159+
### AI-Suggested Progress Points (`coz suggest-points`)
160+
If you're new to Coz or working in an unfamiliar codebase, the hardest part is deciding *where* to place progress points. The `coz suggest-points` subcommand uses an LLM agent to read your source, identify what counts as a unit of work, and propose concrete `COZ_PROGRESS_NAMED` / `COZ_BEGIN` / `COZ_END` placements. Each proposal is shown with a rationale and a unified diff; nothing is written until you confirm.
161+
162+
```shell
163+
export ANTHROPIC_API_KEY=...
164+
165+
coz suggest-points src/ # explore src/, then prompt to apply
166+
coz suggest-points --dry-run src/ # print diffs only, no prompt
167+
coz suggest-points --apply src/ # skip the prompt, apply everything
168+
coz suggest-points --kind latency src/ # only propose COZ_BEGIN/COZ_END pairs
169+
coz suggest-points --hint "HTTP server" src/ # give the agent a domain hint
170+
```
171+
172+
The agent has read-only tools (`list_files`, `read_file`, `grep`) scoped to the paths you pass, and emits one proposal per call. When you accept a proposal, the macro is inserted at the chosen line (matching surrounding indentation), `#include "coz.h"` is added if missing, and the original file is backed up to `*.coz.bak`. Latency points are only applied in matched `BEGIN`/`END` pairs. Files that already contain Coz macros are left alone.
173+
174+
#### Choosing an LLM provider
175+
176+
`coz suggest-points` supports the same providers as the viewer's optimization assistant. Pick one with `--provider`; the agentic tool-use loop is used on all of them, so results are comparable across providers (quality depends on how well the chosen model follows tool-use instructions).
177+
178+
| Provider | Flag | Credentials | Default model |
179+
| --- | --- | --- | --- |
180+
| Anthropic (Claude) | `--provider anthropic` *(default)* | `ANTHROPIC_API_KEY` (or `--api-key`) | `claude-opus-4-7` |
181+
| OpenAI (GPT-4o, o3, …) | `--provider openai` | `OPENAI_API_KEY` (or `--api-key`) | `gpt-4o` |
182+
| Amazon Bedrock | `--provider bedrock` | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` (optional `AWS_SESSION_TOKEN`); region via `AWS_REGION` / `AWS_DEFAULT_REGION` or `--region`. Any credential source that boto3's default chain picks up (IAM role, `~/.aws/credentials`, SSO) also works. Requires `pip install boto3`. | `anthropic.claude-opus-4-20250514-v1:0` |
183+
| Ollama (local) | `--provider ollama` | No key. Endpoint via `OLLAMA_HOST` or `--ollama-host` (defaults to `http://localhost:11434`). Use a tool-capable model (e.g. `llama3.1`, `qwen2.5`). | `llama3.1` |
184+
185+
Examples:
186+
187+
```shell
188+
# Anthropic (default)
189+
export ANTHROPIC_API_KEY=...
190+
coz suggest-points src/
191+
192+
# OpenAI
193+
export OPENAI_API_KEY=...
194+
coz suggest-points --provider openai --model gpt-4o src/
195+
196+
# Amazon Bedrock — uses the boto3 credential chain
197+
export AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... AWS_REGION=us-west-2
198+
coz suggest-points --provider bedrock \
199+
--model anthropic.claude-opus-4-20250514-v1:0 src/
200+
201+
# Ollama on a local server (no API key)
202+
coz suggest-points --provider ollama --model llama3.1 src/
203+
```
204+
205+
You can also pass `--api-key <key>` inline for Anthropic or OpenAI instead of exporting an env var, and `--model <id>` to select a specific model on any provider. See `coz suggest-points --help` for the full option list (`--include`, `--exclude`, `--max-points`, `--region`, `--ollama-host`, etc.).
206+
159207
### Specifying Progress Points on the Command Line
160208
Coz has command line options to specify progress points when profiling the application instead of modifying its source. This feature is currently disabled because it did not work particularly well. Adding support for better command line-specified progress points is planned in the near future.
161209

0 commit comments

Comments
 (0)