Files
discord-rpg-concept/.agent/workflows/work.md
2026-01-09 22:04:40 +01:00

4.8 KiB

description
description
Work on a ticket

WORKFLOW: Automated Feature Implementation and Review Cycle

1. High-Level Goal

The objective of this workflow is to autonomously ingest a task from a local /tickets directory, establish a dedicated development environment via Git branching, implement the requested changes with incremental commits, validate the work through an internal review process, and finalize the lifecycle by cleaning up ticket artifacts and seeking user authorization for the final merge.


2. Assumptions & Clarifications

  • Assumptions:
    • The /tickets directory contains one or more files representing tasks (e.g., .md or .txt).
    • The agent has authenticated access to the local Git repository.
    • A "Review Workflow" exists as an executable command or internal process.
    • The branch naming convention is feature/[ticket-filename-slug].
  • Ambiguities:
    • If multiple tickets exist, the agent will select the one with the earliest "Last Modified" timestamp.
    • "Regular commits" are defined as committing after every logically complete file change or functional milestone.

3. Stage Breakdown

Stage 1: Ticket Selection and Branch Initialization

  • Purpose: Identify the next task and prepare the workspace.
  • Inputs: Contents of the /tickets directory.
  • Actions:
    1. Scan /tickets and select the oldest file.
    2. Parse the ticket content to understand requirements.
    3. Ensure the current working directory is a Git repository.
    4. Create and switch to a new branch: feature/[ticket-id].
  • Outputs: Active feature branch.
  • Persistence Strategy: Save state.json to /temp containing ticket_path, branch_name, and start_time.

Stage 2: Implementation and Incremental Committing

  • Purpose: Execute the technical requirements of the ticket.
  • Inputs: /temp/state.json, Ticket requirements.
  • Actions:
    1. Modify codebase according to requirements.
    2. For every distinct file change or logical unit of work:
      • Run basic syntax checks.
      • Execute git add [file].
      • Execute git commit -m "feat: [brief description of change]"
    3. Repeat until the feature is complete.
  • Outputs: Committed code changes on the feature branch.
  • Persistence Strategy: Update state.json with implementation_complete: true and a list of modified_files.

Stage 3: Review Workflow Execution

  • Purpose: Validate the implementation against quality standards.
  • Inputs: /temp/state.json, Modified codebase.
  • Actions:
    1. Trigger the "Review Workflow" (static analysis, tests, or linter).
    2. If errors are found:
      • Log errors to /temp/review_log.txt.
      • Re-enter Stage 2 to apply fixes and commit.
    3. If review passes:
      • Proceed to Stage 4.
  • Outputs: Review results/logs.
  • Persistence Strategy: Update state.json with review_passed: true.

Stage 4: Cleanup and User Handoff

  • Purpose: Finalize the ticket lifecycle and request merge permission.
  • Inputs: /temp/state.json.
  • Actions:
    1. Delete the ticket file from /tickets using the path stored in state.json.
    2. Format a summary of changes and a request for merge.
  • Outputs: Deletion of the ticket file; user-facing summary.
  • Persistence Strategy: Clear /temp/state.json upon successful completion.

4. Data & File Contracts

  • State File: /temp/state.json
    • Format: JSON
    • Schema: { "ticket_path": string, "branch_name": string, "implementation_complete": boolean, "review_passed": boolean }
  • Ticket Files: Located in /tickets/* (Markdown or Plain Text).
  • Logs: /temp/review_log.txt (Plain Text) for capturing stderr from review tools.

5. Failure & Recovery Handling

  • Empty Ticket Directory: If no files are found in /tickets, the agent will output "NO_TICKETS_FOUND" and terminate the workflow.
  • Commit Failures: If a commit fails (e.g., pre-commit hooks), the agent must resolve the hook violation before retrying the commit.
  • Review Failure Loop: If the review fails more than 3 times for the same issue, the agent must halt and output a "BLOCKER_REPORT" detailing the persistent errors to the user.
  • State Recovery: On context reset, the agent must check /temp/state.json to resume the workflow from the last recorded stage.

6. Final Deliverable Specification

  • Final Output: A clear message to the user in the following format:

    Task Completed: [Ticket Name] Branch: [Branch Name] Changes: [Brief list of modified files] Review Status: Passed Cleanup: Ticket file removed from /tickets. Action Required: Would you like me to merge [Branch Name] into main? (Yes/No)

  • Quality Bar: Code must be committed with descriptive messages; the ticket file must be successfully deleted; the workspace must be left on the feature branch awaiting the merge command.