Commit Graph

6 Commits

Author SHA1 Message Date
Peter Chanthamynavong
d371baf2ca feat(dates): add --due and --defer timestamp options with natural language parsing (#847)
* feat(dates): add due date schema and --due flag

- Add due_at and defer_until columns to issues table via migration 035
- Implement --due flag on create command with ISO date parsing
- Extend RPC protocol and daemon to pass DueAt from CLI to storage
- Display DueAt and DeferUntil in show command output
- Update Issue type with new date fields

Users can now set due dates when creating issues, enabling deadline-based
task management.

* feat(dates): add compact duration parser (+6h, +1d, +2w)

- Create internal/timeparsing package with layered parser architecture
- Implement parseCompactDuration with regex pattern [+-]?\d+[hdwmy]
- Add comprehensive test suite (22 cases) for duration parsing
- Integrate into create.go with fallback to ISO format

Supports hours (h), days (d), weeks (w), months (m), and years (y).
Negative values allowed for past dates.

* feat(dates): add NLP parsing for natural language dates

Integrate olebedev/when library for natural language time expressions.
The layered parser now handles: compact duration → absolute formats → NLP.

Changes:
- Add olebedev/when dependency for NLP parsing
- Implement ParseNaturalLanguage and ParseRelativeTime functions
- Reorder layers: absolute formats before NLP to avoid misinterpretation
- Simplify create.go to use unified ParseRelativeTime
- Add comprehensive NLP test coverage (22 test cases)

Supports: tomorrow, next monday, in 3 days, 3 days ago

* feat(dates): add --defer flag to create/update/defer commands

Add time-based deferral support alongside existing status-based defer.
Issues can now be hidden from bd ready until a specific time.

Changes:
- Add --defer flag to bd create (sets defer_until on creation)
- Add --due and --defer flags to bd update (modify existing issues)
- Add --until flag to bd defer (combines status=deferred with defer_until)
- Add DueAt/DeferUntil fields to UpdateArgs in protocol.go

Supports: +1h, tomorrow, next monday, 2025-01-15

* feat(dates): add defer_until filtering to ready command

Add time-based deferral support to bd ready:

- Add --include-deferred flag to show issues with future defer_until
- Filter out issues where defer_until > now by default
- Update undefer to clear defer_until alongside status change
- Add IncludeDeferred to WorkFilter and RPC ReadyArgs

Part of GH#820: Relative Date Parsing (Phase 5)

* feat(dates): add polish and tests for relative date parsing

Add user-facing warnings when defer date is in the past to help catch
common mistakes. Expand help text with format examples and document
the olebedev/when September parsing quirk.

Tests:
- TestCreateSuite/WithDueAt, WithDeferUntil, WithBothDueAndDefer
- TestReadyWorkDeferUntil (ExcludesFutureDeferredByDefault, IncludeDeferredShowsAll)

Docs:
- CLAUDE.md quick reference updated with new flags
- Help text examples for --due, --defer on create/update

Closes: Phase 6 of beads-820-relative-dates spec

* feat(list): add time-based query filters for defer/due dates

Add --deferred, --defer-before, --defer-after, --due-before, --due-after,
and --overdue flags to bd list command. All date filters now support
relative time expressions (+6h, tomorrow, next monday) via the
timeparsing package.

Filters:
- --deferred: issues with defer_until set
- --defer-before/after: filter by defer_until date range
- --due-before/after: filter by due_at date range
- --overdue: due_at in past AND status != closed

Existing date filters (--created-after, etc.) now also support relative
time expressions through updated parseTimeFlag().

* build(nix): update vendorHash for olebedev/when dependency

The olebedev/when library was added for natural language date parsing
(GH#820). This changes go.sum, requiring an updated vendorHash in the
Nix flake configuration.
2026-01-01 20:06:13 -08:00
Steve Yegge
64771a28d2 feat(ready): add --unassigned filter for bd ready
Add -u/--unassigned flag to bd ready command to show only issues
with no assignee. This supports the SCAVENGE protocol where polecats
query the 'Salvage Yard' for unassigned ready work.

Changes:
- Add NoAssignee field to WorkFilter struct
- Update SQLite GetReadyWork to filter by empty/null assignee
- Add --unassigned/-u flag to ready command
- Update RPC protocol and daemon handler
- Add test for NoAssignee filter functionality

Fixes: gt-3rp

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 00:38:57 -08:00
Steve Yegge
53342732b5 feat: add --unassigned flag to bd ready command
Adds the ability to filter ready work for issues with no assignee,
which is useful for the SCAVENGE protocol in Gas Town where polecats
need to query the "Salvage Yard" for unclaimed work.

Changes:
- Add Unassigned bool field to types.WorkFilter
- Add --unassigned/-u flag to bd ready command
- Update SQL query in GetReadyWork to filter for NULL/empty assignee
- Add Unassigned field to RPC ReadyArgs for daemon support
- Add tests for the new functionality

Closes: gt-3rp

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 00:37:12 -08:00
Steve Yegge
0b1a86a207 test: Refactor P1 test files to use shared DB pattern (bd-1rh)
Refactored 6 high-priority test files to reduce database initializations
and improve test suite performance:

- create_test.go: Combined 11 tests into TestCreateSuite (11 DBs → 1 DB)
- dep_test.go: Combined into TestDependencySuite (4 DBs → 1 DB)
- comments_test.go: Combined into TestCommentsSuite (2 DBs → 1 DB)
- list_test.go: Split into 2 suites to avoid data pollution (2 DBs → 2 DBs)
- ready_test.go: Combined into TestReadySuite (3 DBs → 1 DB)
- stale_test.go: Kept as individual functions due to data isolation needs

Added TEST_SUITE_AUDIT.md documenting the refactoring plan, results,
and key learnings for future test development.

Results:
- P1 tests now run in 0.43 seconds
- Estimated 10-20x speedup
- All tests passing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:51:07 -05:00
Steve Yegge
6821b8ad4c Fix failing tests
- Replace --db flag tests with BEADS_DB env var tests in TestInitWithCustomDBPath
- Fix database closure issue in TestGitPullSyncIntegration by using local stores in subtests
- Remove backup files

Amp-Thread-ID: https://ampcode.com/threads/T-81a1f961-23c1-440b-b36f-d0ce823a5b16
Co-authored-by: Amp <amp@ampcode.com>
2025-10-27 20:08:50 -07:00
Steve Yegge
9111d1e573 Add test coverage for compact, ready, and dep commands
- Add comprehensive tests for cmd/bd/compact.go
  - Test dry run, validation, stats, progress bar, uptime formatting
  - Test compaction eligibility checks

- Add comprehensive tests for cmd/bd/ready.go
  - Test ready work filtering by priority, assignee, limit
  - Test blocking dependencies exclusion
  - Test in-progress issues inclusion

- Add comprehensive tests for cmd/bd/dep.go
  - Test dependency add/remove operations
  - Test all dependency types (blocks, related, parent-child, discovered-from)
  - Test cycle detection and prevention

Coverage improved from 45.6% to 46.0% overall
cmd/bd coverage improved from 20.0% to 20.4%

Amp-Thread-ID: https://ampcode.com/threads/T-0707eb82-f56e-4b2d-b64a-f18cc5bc7421
Co-authored-by: Amp <amp@ampcode.com>
2025-10-24 16:35:40 -07:00