Skip to content

Add 'phabfive edit' command with object type auto-detection#133

Open
holmboe wants to merge 6 commits intomasterfrom
feature/edit-command
Open

Add 'phabfive edit' command with object type auto-detection#133
holmboe wants to merge 6 commits intomasterfrom
feature/edit-command

Conversation

@holmboe
Copy link
Contributor

@holmboe holmboe commented Feb 20, 2026

Summary

Implements a unified phabfive edit command that auto-detects object types from monograms (T/K/P) and provides intelligent batch editing capabilities with atomic validation.

Fixes #132

Features Implemented

Core Functionality

  • Auto-detect object type from monograms (T123, K456, P789)
  • Auto-detect piped input using sys.stdin.isatty() (no --from-stdin flag needed)
  • Batch editing with atomic validation (validate ALL before modifying ANY)
  • Smart board/column handling with auto-detection and partition suggestions
  • Directional navigation for priority and columns (raise/lower, forward/backward)
  • Change detection to only apply actual changes
  • Comment support with --comment flag

Task Editing (Maniphest)

  • Priority management with special Triage(90) skip logic:
    • Ladder: Wish(0) → Low(25) → Normal(50) → High(80) → Unbreak(100)
    • Raise from High → Unbreak (skips Triage)
    • Lower from Unbreak → High (skips Triage)
  • Status management (open, resolved, wontfix, etc.)
  • Column navigation by name (case-insensitive) or direction (forward/backward)
  • Assignment to users
  • Board context validation with helpful error messages

Batch Operations

  • Atomic validation: All tasks validated before any are modified
  • Partition suggestions: Helpful commands when tasks span multiple boards
  • Multi-board handling: Auto-detect single board or require explicit --tag

Architecture

New Files

  • phabfive/edit.py (452 lines) - Edit handler with monogram detection, YAML parsing, and validation
  • tests/test_edit.py (498 lines) - Comprehensive test suite (34 tests)
  • docs/edit-cli.md (603 lines) - Complete documentation with examples and troubleshooting

Modified Files

  • phabfive/cli.py - Added edit command and routing
  • phabfive/maniphest.py - Added editing methods:
    • edit_task_by_id() - Main edit entry point with change detection
    • _get_task_data() - Fetch task with attachments
    • _navigate_priority() - Priority raise/lower with Triage skip
    • _navigate_column() - Column forward/backward navigation
    • _resolve_user_phid() - Username to PHID resolution
  • docs/index.md - Added Edit CLI to documentation index
  • README.md - Added edit command to features and examples

Test Coverage

34 comprehensive tests, all passing:

  • 6 tests for monogram detection (T/K/P from text and URLs)
  • 12 tests for priority navigation (including Triage special cases)
  • 7 tests for column navigation (forward/backward/by-name)
  • 3 tests for board/column validation
  • 2 tests for stdin auto-detection
  • 3 tests for YAML parsing
  • 1 test for object type grouping

Full test suite: 326/326 tests passing (no regressions)

Usage Examples

Single Task Edit

phabfive edit T123 --priority=high --status=resolved

Batch Edit from Search

phabfive maniphest search --assigned=@me | phabfive edit --status=resolved

Directional Navigation

# Move priority up one level (High → Unbreak, skips Triage)
phabfive edit T123 --priority=raise

# Move to next column
phabfive edit T123 --tag="Sprint" --column=forward

Multi-Board Handling

# Specify board when task is on multiple boards
phabfive maniphest search --assigned=@me | \
  phabfive edit --tag="Sprint 42" --column=Done

Error Handling

Partition Suggestions

When tasks are on different boards, the command provides helpful partition suggestions:

ERROR: Validation failed for 3 task(s):
  - T123: Task T123 is on multiple boards [Backend Team, Sprint 42]. Use --tag=BOARD to specify which board.
  - T124: Task T124 is on multiple boards [Backend Team, Sprint 42]. Use --tag=BOARD to specify which board.

Suggested partition commands:

# Tasks on Backend Team + Sprint 42:
echo "T123\nT124" | phabfive edit --tag="Backend Team" --column=Done

No tasks were modified (atomic batch failure).

Documentation

Complete documentation added in docs/edit-cli.md covering:

  • Quick start and command syntax
  • All editing capabilities (priority, status, columns, assignment)
  • Batch operations and atomic validation
  • Advanced workflows and examples by use case
  • Error handling and troubleshooting
  • Tips and best practices

Commits

  1. c4da86c - WIP: Add phabfive edit command skeleton (Add 'phabfive edit' command with object type auto-detection #132)
  2. 0d41708 - Implement edit command functionality in maniphest.py (Add 'phabfive edit' command with object type auto-detection #132)
  3. 0ee9de1 - Add comprehensive tests for edit command (Add 'phabfive edit' command with object type auto-detection #132)
  4. 728878f - Fix column navigation and add comprehensive tests for edit command
  5. 8d80b15 - Add comprehensive documentation for edit command

Testing Instructions

# Run edit command tests
uv run pytest tests/test_edit.py -v

# Run full test suite
uv run pytest -v

# Manual testing (requires Phabricator/Phorge instance)
phabfive edit T123 --priority=high --dry-run
phabfive maniphest search --assigned=@me | phabfive edit --column=forward --dry-run

Breaking Changes

None. This is a new command that doesn't affect existing functionality.

Future Work

  • Support for Passphrase editing (K monograms)
  • Support for Paste editing (P monograms)

The architecture is designed to easily extend to these object types through the existing monogram detection system.

Related

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

@holmboe holmboe requested a review from Timpan4 February 20, 2026 23:39
holmboe and others added 5 commits March 2, 2026 14:54
This is a work-in-progress commit for issue #132. The basic structure
is in place but requires additional implementation in maniphest.py.

Completed:
- Created edit.py module with Edit class
- Monogram detection (T/K/P) from CLI args or YAML Link field
- Auto-detect piped stdin (no --from-stdin flag needed!)
- YAML parser for batch operations from stdin
- Board/column validation logic with multi-board handling
- Batch error handling with partition suggestions
- CLI command registration and routing

Remaining work:
- Implement _get_task_data() in maniphest.py
- Implement edit_task_by_id() in maniphest.py
- Implement priority navigation (raise/lower with Triage skip)
- Implement column navigation (forward/backward)
- Add change detection logic
- Add PHID resolution helpers
- Add transaction builder
- Write tests
- Update documentation

The command structure is ready and follows the design:
- Auto-detects object type from monogram (T123, K456, P789)
- Auto-detects piped input vs CLI argument
- Supports batch editing with atomic validation
- Smart board/column handling with helpful error messages

Related to #132
Add all required methods to maniphest.py to support the edit command:

New methods:
- _get_task_data(): Fetch task with columns/projects attachments
- edit_task_by_id(): Main edit method with change detection
- _navigate_priority(): Raise/lower priority (skips Triage)
- _navigate_column(): Move to column by name or forward/backward
- _get_column_info(): Fetch column info for a board
- _resolve_user_phid(): Resolve username to PHID

Features implemented:
- Change detection: Only applies transactions for changed fields
- Priority navigation: Wish→Low→Normal→High→Unbreak (skips Triage)
- Column navigation: forward/backward by sequence, or by name
- Auto-add to board: Adds task to board if needed when setting column
- Dry-run support: Shows changes without applying
- Comment support: Adds comment transaction

The edit command is now fully functional for tasks!

Related to #132
Add 34 tests covering all edit command functionality:

Test coverage:
- Monogram detection (T/K/P from CLI and URLs)
- Priority navigation with Triage skip logic
  * Raise/lower through full ladder
  * Special Triage handling: raise→unbreak, lower→high
  * Edge cases (stay at min/max)
- Column navigation (forward/backward/by-name)
- Board/column validation
- Stdin auto-detection
- YAML parsing from stdin
- Object grouping by type

Also fixes priority navigation for Triage:
- Triage (90) sits between High (80) and Unbreak (100)
- When on Triage: raise→unbreak, lower→high
- Triage excluded from normal raise/lower ladder

All 34 tests pass ✓

Related to #132
- Fix duplicate _get_column_info() method by using existing implementation
- Update _navigate_column() to work with dict format instead of list
- Fix priority navigation to properly skip Triage priority:
  - Raise from Triage goes to Unbreak (not normal progression)
  - Lower from Triage goes to High (not normal progression)
- Add 34 comprehensive tests for edit command covering:
  - Monogram detection (T/K/P from text and URLs)
  - Priority raise/lower navigation with Triage skip logic
  - Column forward/backward navigation
  - Board/column validation
  - Stdin auto-detection
  - YAML parsing
  - Object type grouping

All 326 tests pass.

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Create docs/edit-cli.md with full edit command documentation:
  - Overview and quick start
  - Command syntax and input modes
  - Priority management with Triage skip logic
  - Workboard column management with directional navigation
  - Batch operations with atomic validation
  - Partition suggestions for multi-board scenarios
  - Advanced workflows and examples
  - Troubleshooting guide

- Update docs/index.md:
  - Add Edit CLI to feature list
  - Add link to edit-cli.md in CLI Reference section

- Update README.md:
  - Add Edit feature to features list
  - Add edit command examples to Quick Start

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

Co-Authored-By: Claude <noreply@anthropic.com>
@holmboe holmboe force-pushed the feature/edit-command branch from 8d80b15 to c8b0fef Compare March 2, 2026 13:58
- Remove duplicate _resolve_user_phid() definition (F811)
- Add None check in caller for user resolution
- Remove unnecessary list() in sorted() call (C414)
- Remove unused yaml_content variable (F841)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add 'phabfive edit' command with object type auto-detection

2 participants