You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.8 KiB
Markdown
47 lines
1.8 KiB
Markdown
---
|
|
# nbd-rulc
|
|
title: Partial ID matching
|
|
status: completed
|
|
type: feature
|
|
priority: critical
|
|
created_at: 2026-03-10T23:30:31Z
|
|
updated_at: 2026-03-10T23:30:31Z
|
|
---
|
|
|
|
Allow `nbd read`, `nbd update`, and dependency resolution to accept a prefix of a ticket ID (e.g. `nbd read a3f` resolves to `a3f9c2`).
|
|
|
|
## Motivation
|
|
|
|
6-character hex IDs are tedious to type in full. Prefix matching — like git's short-SHA resolution — significantly improves interactive ergonomics and makes agent-generated commands shorter.
|
|
|
|
## Approach
|
|
|
|
Add `resolve_id(root: &Path, id_or_prefix: &str) -> Result<String>` in `store.rs`:
|
|
1. If `id_or_prefix` is exactly 6 characters, try `read_ticket` as-is (fast path, existing behaviour).
|
|
2. Otherwise (or if not found), scan `.nbd/tickets/` for files whose stem starts with `id_or_prefix`.
|
|
3. Collect all matches.
|
|
- 0 matches → error: `"no ticket found matching '{prefix}'"`
|
|
- 1 match → return the full ID
|
|
- 2+ matches → error: `"ambiguous prefix '{prefix}' matches: {id1}, {id2}, ..."`
|
|
|
|
Use `resolve_id` inside `cmd_read` and `cmd_update` (replacing the bare `id` string passed to `read_ticket`). Also use it inside `validate_deps` so dependency flags can use short IDs too.
|
|
|
|
## Tests
|
|
|
|
Unit tests in `src/tests.rs`:
|
|
- Exact 6-char match still works.
|
|
- 3-char prefix resolves correctly.
|
|
- Ambiguous prefix returns an error listing all matching IDs.
|
|
- Unknown prefix returns a not-found error.
|
|
|
|
Integration tests in `tests/integration.rs`:
|
|
- `nbd read <3-char-prefix>` resolves and prints the ticket.
|
|
- `nbd update <3-char-prefix> --status done` succeeds.
|
|
- Ambiguous prefix exits non-zero with an informative message.
|
|
|
|
## Files touched
|
|
- `src/store.rs` — new `resolve_id` function
|
|
- `src/main.rs` — `cmd_read`, `cmd_update`, `validate_deps` use `resolve_id`
|
|
- `src/tests.rs` — unit tests
|
|
- `tests/integration.rs` — integration tests
|