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.
1.8 KiB
1.8 KiB
+++
title = "Partial ID matching"
priority = 8
status = "done"
ticket_type = "feature"
dependencies = []
+++
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:
- If
id_or_prefixis exactly 6 characters, tryread_ticketas-is (fast path, existing behaviour). - Otherwise (or if not found), scan
.nbd/tickets/for files whose stem starts withid_or_prefix. - 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}, ..."
- 0 matches → error:
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 donesucceeds.- Ambiguous prefix exits non-zero with an informative message.
Files touched
src/store.rs— newresolve_idfunctionsrc/main.rs—cmd_read,cmd_update,validate_depsuseresolve_idsrc/tests.rs— unit teststests/integration.rs— integration tests