Skip to content

feat(cli): Phase 4 - Hook management and approval actions#1

Open
therichardngai-wolf wants to merge 7 commits intotherichardngai-code:mainfrom
therichardngai-wolf:feat/cli-phase4
Open

feat(cli): Phase 4 - Hook management and approval actions#1
therichardngai-wolf wants to merge 7 commits intotherichardngai-code:mainfrom
therichardngai-wolf:feat/cli-phase4

Conversation

@therichardngai-wolf
Copy link
Contributor

Summary

Adds CLI commands for managing the approval gate hook and approving/rejecting pending approvals.

New CLI Commands

Hook Management

  • notecode hook list — List configured CLI provider hooks
  • notecode hook provision — Provision approval gate hook for Claude CLI
  • notecode hook unprovision — Remove approval gate hook
  • notecode hook sync — Sync all hooks to filesystem

Approval Actions

  • notecode approval approve <id> — Approve pending approval
  • notecode approval reject <id> — Reject pending approval

Backend Changes

  • Added POST /api/cli-hooks/approval-gate/provision endpoint
  • Added POST /api/cli-hooks/approval-gate/unprovision endpoint

Testing

Full approval flow verified:

  1. notecode hook provision — Set up approval gate ✅
  2. Created task and started session with default permission mode
  3. Claude attempted Write → Approval gate triggered ✅
  4. notecode approval list — Saw pending approval ✅
  5. notecode approval approve <id> — Approved via CLI ✅
  6. Session completed successfully ✅

Why

Enables AI agents (like Wolf) to set up and manage the approval gate via terminal without needing the UI.

Adds a command-line interface for NoteCode management:

Task commands:
- notecode task list [--status, --priority, --project, --assignee, --search, --json]
- notecode task get <id> [--json]
- notecode task create --title '...' [--description, --priority, --assignee, --project, ...]
- notecode task update <id> [--status, --priority, --title, ...]

Session commands:
- notecode session list [--task-id, --status, --limit, --json]
- notecode session status <id> [--json]
- notecode session get <id> [--json]

Features:
- All commands support --json flag for machine-readable output
- Colored, formatted output for human readability
- Calls REST API at http://localhost:41920
- Server start preserved: 'notecode' or 'notecode serve' starts the server
- Uses Commander.js for CLI parsing
- Add commander.js for subcommand structure
- Task commands: list, get, create, update
- Session commands: list, get
- Support --json output for AI agents
- Backward compatible with legacy invocation
- Global --api-url flag for custom server URL
Phase 2 CLI enhancements:

Approval Commands:
- notecode approval list [--session <id>] [--json]
- notecode approval get <id> [--json]
- notecode approval approve <id> [-m message]
- notecode approval reject <id> -r <reason>

Watch Command (real-time monitoring):
- notecode watch [--json] - SSE-based activity streaming
- notecode watch --poll - Polling fallback mode
- Outputs: session events, approval pending, task changes

Status Command (system overview):
- notecode status [--json]
- Shows: server status, task counts, sessions, pending approvals

All commands support --json for AI agent consumption.
- Add 'approval list' to show pending approvals
- Add 'approval get <id>' to view approval details with diffs
- Add 'watch' command for real-time session/approval monitoring
- Add 'status' command for server overview (sessions, tasks, approvals)
- All commands support --json output format
- Watch supports --interval for custom poll timing
Phase 3 CLI enhancements:

Agent commands:
- notecode agent list [--project <id>] [--provider <p>] [--json]
- notecode agent get <name> [--project <id>] [--json]
- notecode agent skills [--project <id>] [--provider <p>]
- notecode agent spawn --task <id> --prompt <p> (experimental)

Project commands:
- notecode project list [--favorite] [--recent] [--search] [--json]
- notecode project get <id> [--json]
- notecode project switch <id>
- notecode project current [--json]

Batch operations:
- notecode task export [--status] [--project] [-o file]
- notecode task import <file> [--project] [--dry-run]

All commands support --json output for programmatic usage.
Builds on Phase 1 (task, session) and Phase 2 (approval, watch, status).
New CLI commands:
- hook list: List configured CLI provider hooks
- hook provision: Provision approval gate hook for Claude CLI
- hook unprovision: Remove approval gate hook
- hook sync: Sync all hooks to filesystem
- approval approve <id>: Approve pending approval
- approval reject <id>: Reject pending approval

Backend changes:
- Added /api/cli-hooks/approval-gate/provision endpoint
- Added /api/cli-hooks/approval-gate/unprovision endpoint

This enables AI agents to set up and manage the approval gate
via terminal without needing the UI.
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.

1 participant