fraim-framework 1.0.12 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/.ai-agents/agent-guardrails.md +58 -0
  2. package/.ai-agents/mcp-template.jsonc +34 -0
  3. package/.ai-agents/rules/agent-testing-guidelines.md +545 -0
  4. package/.ai-agents/rules/architecture.md +52 -0
  5. package/.ai-agents/rules/communication.md +122 -0
  6. package/.ai-agents/rules/continuous-learning.md +55 -0
  7. package/.ai-agents/rules/git-safe-commands.md +34 -0
  8. package/.ai-agents/rules/integrity-and-test-ethics.md +223 -0
  9. package/.ai-agents/rules/local-development.md +252 -0
  10. package/.ai-agents/rules/merge-requirements.md +231 -0
  11. package/.ai-agents/rules/pr-workflow-completeness.md +191 -0
  12. package/.ai-agents/rules/simplicity.md +112 -0
  13. package/.ai-agents/rules/software-development-lifecycle.md +276 -0
  14. package/.ai-agents/rules/spike-first-development.md +199 -0
  15. package/.ai-agents/rules/successful-debugging-patterns.md +313 -0
  16. package/.ai-agents/scripts/cleanup-branch.ts +278 -0
  17. package/.ai-agents/scripts/exec-with-timeout.ts +122 -0
  18. package/.ai-agents/scripts/prep-issue.sh +162 -0
  19. package/.ai-agents/templates/evidence/Design-Evidence.md +30 -0
  20. package/.ai-agents/templates/evidence/Implementation-BugEvidence.md +48 -0
  21. package/.ai-agents/templates/evidence/Implementation-FeatureEvidence.md +54 -0
  22. package/.ai-agents/templates/evidence/Spec-Evidence.md +19 -0
  23. package/.ai-agents/templates/help/HelpNeeded.md +14 -0
  24. package/.ai-agents/templates/retrospective/RETROSPECTIVE-TEMPLATE.md +55 -0
  25. package/.ai-agents/templates/specs/BUGSPEC-TEMPLATE.md +37 -0
  26. package/.ai-agents/templates/specs/FEATURESPEC-TEMPLATE.md +29 -0
  27. package/.ai-agents/templates/specs/TECHSPEC-TEMPLATE.md +39 -0
  28. package/.ai-agents/workflows/design.md +121 -0
  29. package/.ai-agents/workflows/implement.md +170 -0
  30. package/.ai-agents/workflows/resolve.md +152 -0
  31. package/.ai-agents/workflows/retrospect.md +84 -0
  32. package/.ai-agents/workflows/spec.md +103 -0
  33. package/.ai-agents/workflows/test.md +90 -0
  34. package/.cursor/rules/cursor-rules.mdc +8 -0
  35. package/.cursor/rules/design.mdc +4 -0
  36. package/.cursor/rules/implement.mdc +6 -0
  37. package/.cursor/rules/resolve.mdc +5 -0
  38. package/.cursor/rules/retrospect.mdc +4 -0
  39. package/.cursor/rules/spec.mdc +4 -0
  40. package/.cursor/rules/test.mdc +5 -0
  41. package/.windsurf/rules/windsurf-rules.md +7 -0
  42. package/.windsurf/workflows/resolve-issue.md +6 -0
  43. package/.windsurf/workflows/retrospect.md +6 -0
  44. package/.windsurf/workflows/start-design.md +6 -0
  45. package/.windsurf/workflows/start-impl.md +6 -0
  46. package/.windsurf/workflows/start-spec.md +6 -0
  47. package/.windsurf/workflows/start-tests.md +6 -0
  48. package/CHANGELOG.md +66 -0
  49. package/CODEOWNERS +24 -0
  50. package/DISTRIBUTION.md +6 -6
  51. package/PUBLISH_INSTRUCTIONS.md +93 -0
  52. package/README.md +330 -104
  53. package/bin/fraim.js +49 -3
  54. package/index.js +30 -3
  55. package/install.sh +58 -58
  56. package/labels.json +52 -0
  57. package/linkedin-post.md +23 -0
  58. package/package.json +12 -7
  59. package/sample_package.json +18 -0
  60. package/setup.js +733 -384
  61. package/test-utils.ts +118 -0
  62. package/tsconfig.json +22 -0
  63. package/agents/claude/CLAUDE.md +0 -42
  64. package/agents/cursor/rules/architecture.mdc +0 -49
  65. package/agents/cursor/rules/continuous-learning.mdc +0 -48
  66. package/agents/cursor/rules/cursor-workflow.mdc +0 -29
  67. package/agents/cursor/rules/design.mdc +0 -25
  68. package/agents/cursor/rules/implement.mdc +0 -26
  69. package/agents/cursor/rules/local-development.mdc +0 -104
  70. package/agents/cursor/rules/prep.mdc +0 -15
  71. package/agents/cursor/rules/resolve.mdc +0 -46
  72. package/agents/cursor/rules/simplicity.mdc +0 -18
  73. package/agents/cursor/rules/software-development-lifecycle.mdc +0 -41
  74. package/agents/cursor/rules/test.mdc +0 -25
  75. package/agents/windsurf/rules/architecture.md +0 -49
  76. package/agents/windsurf/rules/continuous-learning.md +0 -47
  77. package/agents/windsurf/rules/local-development.md +0 -103
  78. package/agents/windsurf/rules/remote-development.md +0 -22
  79. package/agents/windsurf/rules/simplicity.md +0 -17
  80. package/agents/windsurf/rules/windsurf-workflow.md +0 -28
  81. package/agents/windsurf/workflows/prep.md +0 -20
  82. package/agents/windsurf/workflows/resolve-issue.md +0 -47
  83. package/agents/windsurf/workflows/start-design.md +0 -26
  84. package/agents/windsurf/workflows/start-impl.md +0 -27
  85. package/agents/windsurf/workflows/start-tests.md +0 -26
  86. package/github/phase-change.yml +0 -218
  87. package/github/status-change.yml +0 -68
  88. package/github/sync-on-pr-review.yml +0 -66
  89. package/scripts/__init__.py +0 -10
  90. package/scripts/cli.py +0 -141
  91. package/setup.py +0 -0
  92. package/test-config.json +0 -32
  93. package/workflows/setup-fraim.yml +0 -147
@@ -1,47 +0,0 @@
1
- ---
2
- trigger: always_on
3
- ---
4
-
5
- # Continuous Learning
6
-
7
- ## Retrospectives Review
8
- - **Always review** the `/retrospectives/` folder before starting work on similar issues
9
- - **Learn from past problems** - understand root cause analysis and lessons learned
10
- - **Apply previous solutions** - don't repeat mistakes that have already been solved
11
-
12
- ## Knowledge Integration
13
- - **Read related RFCs** in `/docs/rfcs/` to understand design decisions
14
- - **Review test cases** to see how similar problems were approached
15
- - **Check issue history** for patterns in failures and solutions
16
-
17
- ## Local Development Benefits
18
- - **Avoid known pitfalls** by learning from retrospectives
19
- - **Build on existing solutions** rather than starting from scratch
20
- - **Understand system constraints** from past architectural decisions
21
-
22
- ## Before Starting Work
23
- 1. **Search retrospectives** for related issues or similar problems
24
- 2. **Read relevant RFCs** to understand the design context
25
- 3. **Review test cases** to see expected behavior
26
- 4. **Check issue comments** for previous attempts and solutions
27
-
28
- ## Document Your Learning
29
- - **Update retrospectives** if you discover new insights
30
- - **Add to RFCs** if you find better approaches
31
- - **Share solutions** with other agents through issue comments
32
-
33
- ## Retrospective Triggers
34
-
35
- ### **Automatic Retrospective Requirements**
36
- - **Complex Issues (>3 iterations)**: Must create retrospective before issue closure
37
- - **Process Violations**: Any workflow rule violations require retrospectives
38
- - **Work Loss Incidents**: Any incidents where work is lost require detailed retrospectives
39
-
40
- ### **Retrospective Creation Process**
41
- 1. **Stop Current Work**: Pause issue resolution if retrospective is required
42
- 2. **Create Retrospective**: Use standard template in retrospectives folder
43
- 3. **Root Cause Analysis**: Identify underlying causes, not just symptoms
44
- 4. **Prevention Measures**: Document specific actions to prevent recurrence
45
- 5. **Process Updates**: Update rules and workflows based on learnings
46
-
47
- Remember: The best code is often written by those who learn from history rather than repeat it.
@@ -1,103 +0,0 @@
1
- ---
2
- trigger: manual
3
- ---
4
-
5
- # Local Development with Remote Coordination
6
-
7
- - Use local file system for development work in your own cloned repository folder
8
- - Push to feature branches only; never push to master
9
- - Do NOT open PRs; push and let Actions open/update Draft PRs
10
- - Always work in your own cloned repository folder: `git clone <repo> "<repo> - Issue {issue_number}"`
11
- - After you create the clone, do not forget to change into that working directory. All your work **MUST** be in your working directory.
12
- - Coordinate with other agents through GitHub issues and PRs
13
- - Each agent works independently in their own folder to enable true parallel development
14
-
15
- ## CRITICAL RULE: Absolute Workspace Separation
16
-
17
- ### Local Clone: WORK-ONLY
18
- - **Directory**: `<repo> - Issue <issue number>`
19
- - **Purpose**: All development work happens here exclusively
20
- - **Rule**: ALL file operations must be within this directory
21
-
22
- ## Mandatory Pre-File-Operation Checklist
23
-
24
- **Before ANY file operation (edit_file, delete_file, etc.), verify:**
25
-
26
- 1. ✅ **Directory Check**: `pwd` shows local clone with issue number in path
27
- 2. ✅ **Path Verification**: File path is relative (no "../" or main workspace name)
28
- 3. ✅ **Branch Check**: `git branch` shows correct feature branch
29
- 4. ❌ **If ANY check fails**: STOP immediately and fix location
30
-
31
- **This checklist is MANDATORY, not optional.**
32
-
33
-
34
- ## Enhanced Stop Conditions
35
-
36
- **Stop ALL work immediately if:**
37
- - You create a file and it appears in main workspace
38
- - You use edit_file with "../" paths
39
- - You work in directory without issue number in name
40
- - `pwd` shows main workspace path
41
- - Any file operation targets main workspace
42
-
43
- **Take corrective action before continuing.**
44
-
45
- ## Workspace Validation Commands
46
-
47
- **Before starting work, run:**
48
- ```bash
49
- echo "Working in: $(pwd)"
50
- echo "Should contain issue number in path"
51
- git branch
52
- echo "Should show feature branch"
53
- ```
54
-
55
- **If output doesn't match expectations, fix before proceeding.**
56
-
57
- ## Tool Usage Restrictions
58
-
59
- ### File Operations - Local Only
60
- - `edit_file()` - ONLY with relative paths in local repo
61
- - `delete_file()` - ONLY within local repo
62
- - `search_replace()` - ONLY on local repo files
63
-
64
- ### Reference Operations - Main Workspace OK
65
- - `read_file()` - OK to read from main workspace for reference
66
- - `list_dir()` - OK to explore main workspace structure
67
- - `grep()` - OK to search main workspace for patterns
68
-
69
- ## Violation Recovery Process
70
-
71
- **If you violate workspace boundaries:**
72
-
73
- 1. **Stop immediately** - Do not continue file operations
74
- 2. **Assess damage** - Check what was created in wrong location
75
- 3. **Clean up** - Delete files created in main workspace
76
- 4. **Recreate correctly** - Recreate files in local repo only
77
- 5. **Document violation** - Update post-mortem with details
78
-
79
-
80
- ## Enhanced Output Template
81
-
82
- ```
83
- Summary:
84
- - Work completed in local repository: [path]
85
- - Files created/modified: [list with relative paths]
86
- - Workspace violations: [none/details if any occurred]
87
-
88
- Artifacts:
89
- - Branch: [URL]
90
- - Local directory: [full path to local clone]
91
- ```
92
-
93
- ## Emergency Safeguards
94
-
95
- **If assistant shows signs of workspace confusion:**
96
- - User should immediately clarify working directory
97
- - Assistant should run `pwd` and verify location
98
- - All file operations should pause until location confirmed
99
- - Assistant should explicitly state file paths being used
100
-
101
- ---
102
-
103
- **Bottom Line**: The local development workflow requires absolute discipline about workspace boundaries.
@@ -1,22 +0,0 @@
1
- ---
2
- trigger: manual
3
- ---
4
-
5
- # Remote-only, headless execution, bot-authored PRs
6
- - Use GitHub MCP for file edits, commits, and labels. Do not touch the local FS or run local servers.
7
- - Push to feature branches only; never push to master.
8
- - Do NOT open PRs via MCP; push and let Actions open/update Draft PRs (authored by bot).
9
-
10
-
11
- # Stop Criteria
12
- - When the work given to you is complete.
13
- - When workflows tied to your PR are successful. If workflows fail, your work is not complete. Keep at it.
14
-
15
- Output Template (use verbatim)
16
- - Summary:
17
- - …
18
- - …
19
- - Artifacts:
20
- - Branch: <url>
21
- - PR: <url>
22
- - Issue: <url>
@@ -1,17 +0,0 @@
1
- ---
2
- trigger: always_on
3
- ---
4
-
5
-
6
- ****Keep it simple. Don't over-engineer. *****
7
- Don't over-think it.
8
- While fixing an issue, focus on that issue only. Don't fix other issues. Don't make unrelated changes. Instead, file a Git issue if you find other issues that aren't already tracked by an existing Git issue.
9
-
10
-
11
- Always verify the action you have taken. Do not expect the user to verify it for you.
12
- If you kicked off a Git workflow, verify it completed successfully (e.g., gh checks: list or PR status).
13
- If you wrote a test and expect it to pass, run it yourself and verify it passes; if you expect it to fail, verify it fails.
14
- Always link work to the issue (use “Closes #<n>” in the Implementation PR).
15
- Open Draft PRs early; review happens in the PR, not in chat.
16
-
17
- Agents must not run gh pr create. Push to the feature branch and let Actions open Draft PRs.
@@ -1,28 +0,0 @@
1
- ---
2
- trigger: always_on
3
- ---
4
-
5
- # Windsurf Development Workflow
6
-
7
- ## Goal
8
- Work efficiently in local environment while maintaining coordination with remote repository and other agents.
9
-
10
- ## Behavior
11
- - Use local file system for development work
12
- - ***NEVER*** commit unless asked to do so
13
- - Produce clear progress updates with:
14
- 1. Actions executed (imperative, past tense)
15
- 2. Local progress (files modified, tests run)
16
- 3. Remote artifacts (branch, PR status)
17
- 4. Next steps for this issue
18
- 5. Blocking issues (if any)
19
-
20
- ## Stop Criteria
21
- - When the assigned work is complete
22
- - When tests pass and PR is ready for review
23
- - When waiting for reviewer feedback
24
-
25
- ## Output Template
26
- - Summary:
27
- - Local progress: [what you accomplished locally]
28
- - Remote status: [branch/PR status]
@@ -1,20 +0,0 @@
1
- ---
2
- description: Prep environment for issue
3
- auto_execution_mode: 3
4
- ---
5
-
6
- Step 1: Ask for {issue_number}
7
-
8
- Step 2: Clone the repo to "<repo> - Issue {issue_number}"
9
- - **CRITICAL**: Clone ONE LEVEL ABOVE the current workspace directory
10
- - **DO NOT** clone inside the current workspace folder
11
- - **VERIFY LOCATION**: Use `pwd` to confirm you're in the parent directory before cloning
12
-
13
- Step 3: Confirm items in the checklist and say "Huzzah!"
14
-
15
-
16
- ## Safety Checklist
17
- - [ ] Confirmed current workspace path with `pwd`
18
- - [ ] Changed to parent directory (`cd ..`) before cloning
19
- - [ ] Verified clone location is outside current workspace
20
- - [ ] Successfully changed into cloned repository
@@ -1,47 +0,0 @@
1
- ---
2
- description: Resolve issue (once confirmed complete)
3
- auto_execution_mode: 3
4
- ---
5
-
6
- Ensure branch: feature/{issue}-{slug} is checked out (create if needed).
7
-
8
- Commit & push any pending changes.
9
-
10
- Sync from origin/master into this branch (merge or rebase), resolve conflicts, push again.
11
-
12
- Check the results of GitHub Action that runs the full tests in the cloud.
13
-
14
- If they pass: open/update the Implementation PR, label it, and enable auto-merge.
15
-
16
- If they fail: no PR is opened/updated; fix, push again, repeat.
17
-
18
- Once PR is approved and related actions succeed, do the following:
19
- - **MANDATORY**: Verify PR is actually merged to master before proceeding
20
- - **MANDATORY**: Run merge verification checks (see below)
21
- - Close the issue ONLY after merge verification passes
22
- - Delete the branch remotely.
23
- - If operating locally, delete the local branch and the local codebase.
24
- - Say Hoorah !
25
-
26
- ## Mandatory Merge Verification
27
-
28
- **Before closing ANY issue, verify the following:**
29
-
30
- 1. ✅ **PR Status**: PR shows "merged" status, not just "closed"
31
- 2. ✅ **Merge Commit**: Verify merge commit exists in master
32
- 3. ✅ **Files in Master**: Confirm expected files are present in master
33
-
34
- ### **Verification Commands**
35
- ```bash
36
- # Check PR is merged, not just closed
37
- gh pr view <PR_NUMBER> --json merged
38
-
39
- # Verify merge commit in master
40
- git fetch origin master
41
- git log origin/master --oneline | grep "PR #<PR_NUMBER>"
42
-
43
- # Verify files in master
44
- git show origin/master:path/to/expected/file
45
- ```
46
-
47
- **CRITICAL**: Do not close the issue until merge verification passes. This prevents work loss incidents like Issue #112.
@@ -1,26 +0,0 @@
1
- ---
2
- description: Start working on the issue
3
- auto_execution_mode: 3
4
- ---
5
-
6
- Step 1: Ask for {issue_number} (and optional {slug})
7
-
8
- Step 2: Label the issue 'phase:design' (GitHub Action will automatically create a branch, label the issue `status:wip`, create a draft PR)
9
-
10
- Step 3: Using GitHub MCP, wait for the branch to get created, then do a checkout to start your work.
11
-
12
- *** IMPORTANT IF YOU ARE WORKING LOCALLY **** switch into your branch and ensure you work in your own folder.
13
-
14
- Step 4: Do your work either remotely or locally as defined by the user. If unsure, ask the user. Once sure, let the user know.
15
-
16
- Step 5: Your work entails the following
17
-
18
- - Create docs/rfcs/{issue_number}-{slug}.md.
19
-
20
- - If the issue requires a small fix or bug fix, use this template - docs/rfcs/BUG-TEMPLATE.md
21
-
22
- - If the issue requires major changes, use this template - docs/rfcs/RFC-TEMPLATE.md
23
-
24
- - When ready for review, flip issue to 'status:needs-review' and remove 'status:wip'
25
-
26
- Step 6: If workflow actions or reviewer feedback indicates more work is needed, ensure the issue is set back to `status:wip` and continue working as above.
@@ -1,27 +0,0 @@
1
- ---
2
- description: Implement issue
3
- auto_execution_mode: 3
4
- ---
5
-
6
- Step 1: Ask for {issue_number} (and optional {slug}); confirm target branch feature/{issue_number}-{slug}.
7
-
8
- Step 2: Ensure the branch exists (your GitHub Action will usually auto-create it) and checkout it.
9
-
10
- Step 3: Label the issue 'phase:impl'. (GitHub Action will automatically label the issue `status:wip`, create a draft PR)
11
-
12
- Step 4: Do your work either remotely or locally as defined by the user. If unsure, ask the user. Once sure, let the user know.
13
-
14
- Step 5: Your work entails the following
15
-
16
- - Review the RFC associated with this issue.
17
-
18
- - Determine whether changes need to be made to existing code, or brand new code needs to be written.
19
-
20
- - Write the minimal set of code and test cases needed for this issue.
21
-
22
- - **Test cases must inherit from test-utils and follow the structure of the rest of the test suite**
23
- - Ensure test cases pass.
24
-
25
- - When ready for review, flip issue to 'status:needs-review' and remove 'status:wip'
26
-
27
- Step 6: If workflow actions or reviewer feedback indicates more work is needed, ensure the issue is set back to `status:wip` and continue working as above.
@@ -1,26 +0,0 @@
1
- ---
2
- description: Start writing tests
3
- auto_execution_mode: 3
4
- ---
5
-
6
- Step 1: Ask for {issue_number} (and optional {slug}); confirm target branch feature/{issue_number}-{slug}.
7
-
8
- Step 2: Using GitHub MCP, ensure the branch exists (your GitHub Action will usually auto-create it) and checkout it.
9
-
10
- Step 3: Label the issue 'phase:tests'. (GitHub Action will automatically label the issue `status:wip`, create a draft PR)
11
-
12
- Step 4: Do your work either remotely or locally as defined by the user. If unsure, ask the user. Once sure, let the user know.
13
-
14
- Step 5: Your work entails the following
15
-
16
- - Review the RFC associated with this issue.
17
-
18
- - Determine whether tests need to be added to an existing test suite, or a new one needs to be created.
19
-
20
- - Write the minimal set of test cases that accurately reproduce the issue
21
-
22
- - Run the test cases to ensure they fail
23
-
24
- - Flip issue to 'status:needs-review' and remove 'status:wip'
25
-
26
- Step 6: If workflow actions or reviewer feedback indicates more work is needed, ensure the issue is set back to `status:wip` and continue working as above.
@@ -1,218 +0,0 @@
1
- name: Phase Change Handler
2
-
3
- on:
4
- issues:
5
- types: [labeled]
6
-
7
- permissions:
8
- issues: write
9
- pull-requests: write
10
- contents: write
11
-
12
- jobs:
13
- handle-phase-change:
14
- runs-on: ubuntu-latest
15
- if: |
16
- contains(github.event.label.name, 'phase:') ||
17
- (github.event.action == 'unlabeled' && contains(github.event.label.name, 'phase:'))
18
-
19
- steps:
20
- - name: Checkout repository
21
- uses: actions/checkout@v4
22
- with:
23
- token: ${{ secrets.GITHUB_TOKEN }}
24
- fetch-depth: 0
25
-
26
- - name: Setup Git
27
- run: |
28
- git config --global user.name "github-actions[bot]"
29
- git config --global user.email "github-actions[bot]@users.noreply.github.com"
30
-
31
- - name: Auth GitHub CLI
32
- run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
33
-
34
- - name: Extract issue details
35
- id: issue-details
36
- run: |
37
- ISSUE_NUMBER="${{ github.event.issue.number }}"
38
- ISSUE_TITLE="${{ github.event.issue.title }}"
39
- BRANCH_NAME="feature/${ISSUE_NUMBER}-$(echo "$ISSUE_TITLE" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-\|-$//g')"
40
-
41
- echo "issue_number=$ISSUE_NUMBER" >> $GITHUB_OUTPUT
42
- echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
43
- echo "issue_title=$ISSUE_TITLE" >> $GITHUB_OUTPUT
44
-
45
- - name: Determine current phase
46
- id: current-phase
47
- run: |
48
- LABELS='${{ toJson(github.event.issue.labels) }}'
49
- CURRENT_PHASE=""
50
-
51
- # Extract current phase from labels
52
- for label in $(echo "$LABELS" | jq -r '.[].name'); do
53
- if [[ $label == phase:* ]]; then
54
- CURRENT_PHASE=$label
55
- break
56
- fi
57
- done
58
-
59
- echo "current_phase=$CURRENT_PHASE" >> $GITHUB_OUTPUT
60
- echo "Current phase: $CURRENT_PHASE"
61
-
62
- - name: Ensure branch exists and sync
63
- run: |
64
- BRANCH_NAME="${{ steps.issue-details.outputs.branch_name }}"
65
- BASE="master"
66
-
67
- git fetch origin "$BASE"
68
-
69
- if git ls-remote --exit-code --heads origin "$BRANCH_NAME" >/dev/null 2>&1; then
70
- echo "Branch $BRANCH_NAME exists, syncing..."
71
- git fetch origin "$BRANCH_NAME"
72
- git switch "$BRANCH_NAME"
73
- git pull --rebase origin "$BRANCH_NAME"
74
- else
75
- echo "Branch $BRANCH_NAME does not exist, creating from $BASE..."
76
- git switch -c "$BRANCH_NAME" "origin/$BASE"
77
- git push -u origin "$BRANCH_NAME"
78
- fi
79
-
80
- # Design: add EMPTY commit to guarantee a diff
81
- - name: phase:design → ensure empty commit (commit if missing)
82
- if: steps.current-phase.outputs.current_phase == 'phase:design'
83
- shell: bash
84
- env:
85
- ISSUE: ${{ github.event.issue.number }}
86
- run: |
87
- ISSUE_NUMBER="${{ steps.issue-details.outputs.issue_number }}"
88
- ISSUE_TITLE="${{ steps.issue-details.outputs.issue_title }}"
89
- BRANCH_NAME="${{ steps.issue-details.outputs.branch_name }}"
90
-
91
- # Create empty commit to guarantee branch has commits
92
- git commit --allow-empty -m "Design phase initiated for Issue #$ISSUE_NUMBER: $ISSUE_TITLE"
93
- git push origin "$BRANCH_NAME"
94
-
95
- # Create or update Design PR
96
- PR_TITLE="[Design] RFC for Issue #$ISSUE_NUMBER: $ISSUE_TITLE"
97
- PR_BODY="## Design RFC for Issue #$ISSUE_NUMBER
98
-
99
- This PR contains the design RFC for: $ISSUE_TITLE
100
-
101
- **Phase:** Design
102
- **Issue:** #$ISSUE_NUMBER
103
- **Branch:** \`$BRANCH_NAME\`
104
-
105
- ### RFC Document
106
- - 📋 [RFC Document]($RFC_FILE)
107
-
108
- **Note:** This is a Design PR. Implementation will follow in a separate PR after design approval.
109
-
110
- "
111
-
112
- # Check if PR already exists
113
- EXISTING_PR=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number' 2>/dev/null || echo "")
114
-
115
- if [ -n "$EXISTING_PR" ]; then
116
- echo "Updating existing PR #$EXISTING_PR"
117
- gh pr edit "$EXISTING_PR" --title "$PR_TITLE" --body "$PR_BODY"
118
- gh pr edit "$EXISTING_PR" --add-label "phase:design" --remove-label "phase:tests" --remove-label "phase:impl"
119
- else
120
- echo "Creating new Design PR"
121
- gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base master --head "$BRANCH_NAME" --draft
122
- # Add labels to the new PR
123
- sleep 2 # Brief delay to ensure PR is created
124
- NEW_PR=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number')
125
- gh pr edit "$NEW_PR" --add-label "phase:design" --remove-label "phase:tests" --remove-label "phase:impl"
126
- fi
127
-
128
- - name: Handle test phase
129
- if: steps.current-phase.outputs.current_phase == 'phase:tests'
130
- run: |
131
- ISSUE_NUMBER="${{ steps.issue-details.outputs.issue_number }}"
132
- ISSUE_TITLE="${{ steps.issue-details.outputs.issue_title }}"
133
- BRANCH_NAME="${{ steps.issue-details.outputs.branch_name }}"
134
-
135
- # Create or update Test Implementation PR
136
- PR_TITLE="[Testing] Test Cases for Issue #$ISSUE_NUMBER: $ISSUE_TITLE"
137
- PR_BODY="## Test cases for Issue #$ISSUE_NUMBER
138
-
139
- This PR contains the test cases for: $ISSUE_TITLE
140
-
141
- **Phase:** Tests
142
- **Issue:** #$ISSUE_NUMBER
143
- **Branch:** \`$BRANCH_NAME\`
144
-
145
- ### Test Cases
146
-
147
-
148
- **Note:** This is a Test PR. Implementation will follow after test approval.
149
-
150
- "
151
-
152
- # Check if PR already exists
153
- EXISTING_PR=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number' 2>/dev/null || echo "")
154
-
155
- if [ -n "$EXISTING_PR" ]; then
156
- echo "Updating existing PR #$EXISTING_PR"
157
- gh pr edit "$EXISTING_PR" --title "$PR_TITLE" --body "$PR_BODY"
158
- gh pr edit "$EXISTING_PR" --add-label "phase:tests" --remove-label "phase:design" --remove-label "phase:impl"
159
- else
160
- echo "Creating new Test Plan PR"
161
- gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base master --head "$BRANCH_NAME" --draft
162
- # Add labels to the new PR
163
- sleep 2 # Brief delay to ensure PR is created
164
- NEW_PR=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number')
165
- gh pr edit "$NEW_PR" --add-label "phase:tests" --remove-label "phase:design" --remove-label "phase:impl"
166
- fi
167
-
168
- - name: Handle implementation phase
169
- if: steps.current-phase.outputs.current_phase == 'phase:impl'
170
- run: |
171
- ISSUE_NUMBER="${{ steps.issue-details.outputs.issue_number }}"
172
- ISSUE_TITLE="${{ steps.issue-details.outputs.issue_title }}"
173
- BRANCH_NAME="${{ steps.issue-details.outputs.branch_name }}"
174
-
175
- # Create or update Implementation PR
176
- PR_TITLE="[Implementation] Fixes for Issue #$ISSUE_NUMBER: $ISSUE_TITLE"
177
- PR_BODY="## Fixes for Issue #$ISSUE_NUMBER
178
-
179
- This PR contains the fixes for: $ISSUE_TITLE
180
-
181
- **Phase:** Implementation
182
- **Issue:** #$ISSUE_NUMBER
183
- **Branch:** \`$BRANCH_NAME\`
184
-
185
- ### Fixes
186
-
187
-
188
- Closes #$ISSUE_NUMBER
189
-
190
- "
191
-
192
- # Check if PR already exists
193
- EXISTING_PR=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number' 2>/dev/null || echo "")
194
-
195
- if [ -n "$EXISTING_PR" ]; then
196
- echo "Updating existing PR #$EXISTING_PR"
197
- gh pr edit "$EXISTING_PR" --title "$PR_TITLE" --body "$PR_BODY"
198
- gh pr edit "$EXISTING_PR" --add-label "phase:impl" --remove-label "phase:design" --remove-label "phase:tests"
199
- else
200
- echo "Creating new Implementation PR"
201
- gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base master --head "$BRANCH_NAME" --draft
202
- # Add labels to the new PR
203
- sleep 2 # Brief delay to ensure PR is created
204
- NEW_PR=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number')
205
- gh pr edit "$NEW_PR" --add-label "phase:impl" --remove-label "phase:design" --remove-label "phase:tests"
206
- fi
207
-
208
- - name: Normalize ISSUE and PR status to WIP (authoritative)
209
- run: |
210
- gh issue edit ${{ github.event.issue.number }} --add-label "status:wip" --remove-label "status:needs-review" --remove-label "status:complete" || true
211
-
212
- # Get the PR number for the current branch and normalize its status
213
- BRANCH_NAME="${{ steps.issue-details.outputs.branch_name }}"
214
- PR_NUMBER=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number' 2>/dev/null || echo "")
215
-
216
- if [ -n "$PR_NUMBER" ]; then
217
- gh pr edit "$PR_NUMBER" --add-label "status:wip" --remove-label "status:needs-review" --remove-label "status:complete" || true
218
- fi
@@ -1,68 +0,0 @@
1
- name: Status Change → Flip PR Draft/Ready
2
-
3
- on:
4
- issues:
5
- types: [labeled]
6
-
7
- permissions:
8
- pull-requests: write
9
- issues: read
10
- contents: write
11
-
12
- # Serialize per ISSUE; last status wins
13
- concurrency:
14
- group: status-change-${{ github.event.issue.number }}
15
- cancel-in-progress: true
16
-
17
- jobs:
18
- status-change:
19
- if: startsWith(github.event.label.name, 'status:')
20
- runs-on: ubuntu-latest
21
- steps:
22
- - name: Checkout repository
23
- uses: actions/checkout@v4
24
- with:
25
- token: ${{ secrets.GITHUB_TOKEN }}
26
- fetch-depth: 0
27
-
28
- - name: Setup Git
29
- run: |
30
- git config --global user.name "github-actions[bot]"
31
- git config --global user.email "github-actions[bot]@users.noreply.github.com"
32
-
33
- - name: Auth GitHub CLI
34
- run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
35
-
36
- - name: Derive branch + find PR
37
- id: pr
38
- shell: bash
39
- env:
40
- ISSUE_NUMBER: ${{ github.event.issue.number }}
41
- ISSUE_TITLE: ${{ github.event.issue.title }}
42
- run: |
43
- set -euo pipefail
44
- slug=$(echo "$ISSUE_TITLE" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g;s/^-+|-+$//g')
45
- BR="feature/${ISSUE_NUMBER}-${slug}"
46
- PR=$(gh pr list --state open --head "$BR" --json number --jq '.[0].number')
47
- echo "pr=$PR" >> $GITHUB_OUTPUT
48
- echo "label=${{ github.event.label.name }}" >> $GITHUB_OUTPUT
49
-
50
- - name: Flip PR state (Draft/Ready) based on label
51
- if: steps.pr.outputs.pr != ''
52
- shell: bash
53
- env:
54
- PR: ${{ steps.pr.outputs.pr }}
55
- LABEL: ${{ steps.pr.outputs.label }}
56
- run: |
57
- set -euo pipefail
58
- case "$LABEL" in
59
- status:needs-review)
60
- gh pr ready "$PR"
61
- gh pr edit "$PR" --add-label "status:needs-review" --remove-label "status:wip" --remove-label "status:complete" || true
62
- ;;
63
- status:wip)
64
- gh pr edit "$PR" --add-label "status:wip" --remove-label "status:needs-review" --remove-label "status:complete" || true
65
- ;;
66
- *)
67
- echo "No action for label: $LABEL" ;;
68
- esac