@codemieai/code 0.0.3 → 0.0.4

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 (257) hide show
  1. package/README.md +375 -325
  2. package/bin/codemie-claude.js +23 -0
  3. package/bin/codemie-code.js +49 -11
  4. package/bin/codemie-codex.js +12 -13
  5. package/dist/agents/adapters/claude-code.d.ts +5 -0
  6. package/dist/agents/adapters/claude-code.d.ts.map +1 -1
  7. package/dist/agents/adapters/claude-code.js +76 -18
  8. package/dist/agents/adapters/claude-code.js.map +1 -1
  9. package/dist/agents/adapters/codex.d.ts +5 -0
  10. package/dist/agents/adapters/codex.d.ts.map +1 -1
  11. package/dist/agents/adapters/codex.js +75 -17
  12. package/dist/agents/adapters/codex.js.map +1 -1
  13. package/dist/agents/codemie-code/agent.d.ts.map +1 -1
  14. package/dist/agents/codemie-code/agent.js +187 -21
  15. package/dist/agents/codemie-code/agent.js.map +1 -1
  16. package/dist/agents/codemie-code/config.d.ts.map +1 -1
  17. package/dist/agents/codemie-code/config.js +29 -27
  18. package/dist/agents/codemie-code/config.js.map +1 -1
  19. package/dist/agents/codemie-code/index.d.ts +16 -2
  20. package/dist/agents/codemie-code/index.d.ts.map +1 -1
  21. package/dist/agents/codemie-code/index.js +74 -6
  22. package/dist/agents/codemie-code/index.js.map +1 -1
  23. package/dist/agents/codemie-code/modes/contextAwarePlanning.d.ts +87 -0
  24. package/dist/agents/codemie-code/modes/contextAwarePlanning.d.ts.map +1 -0
  25. package/dist/agents/codemie-code/modes/contextAwarePlanning.js +957 -0
  26. package/dist/agents/codemie-code/modes/contextAwarePlanning.js.map +1 -0
  27. package/dist/agents/codemie-code/modes/planMode.d.ts +116 -0
  28. package/dist/agents/codemie-code/modes/planMode.d.ts.map +1 -0
  29. package/dist/agents/codemie-code/modes/planMode.js +537 -0
  30. package/dist/agents/codemie-code/modes/planMode.js.map +1 -0
  31. package/dist/agents/codemie-code/prompts.d.ts +29 -0
  32. package/dist/agents/codemie-code/prompts.d.ts.map +1 -1
  33. package/dist/agents/codemie-code/prompts.js +129 -0
  34. package/dist/agents/codemie-code/prompts.js.map +1 -1
  35. package/dist/agents/codemie-code/storage/todoStorage.d.ts +78 -0
  36. package/dist/agents/codemie-code/storage/todoStorage.d.ts.map +1 -0
  37. package/dist/agents/codemie-code/storage/todoStorage.js +225 -0
  38. package/dist/agents/codemie-code/storage/todoStorage.js.map +1 -0
  39. package/dist/agents/codemie-code/tokenUtils.js +1 -1
  40. package/dist/agents/codemie-code/tokenUtils.js.map +1 -1
  41. package/dist/agents/codemie-code/tools/index.d.ts +26 -0
  42. package/dist/agents/codemie-code/tools/index.d.ts.map +1 -1
  43. package/dist/agents/codemie-code/tools/index.js +182 -14
  44. package/dist/agents/codemie-code/tools/index.js.map +1 -1
  45. package/dist/agents/codemie-code/tools/planning.d.ts +53 -0
  46. package/dist/agents/codemie-code/tools/planning.d.ts.map +1 -0
  47. package/dist/agents/codemie-code/tools/planning.js +224 -0
  48. package/dist/agents/codemie-code/tools/planning.js.map +1 -0
  49. package/dist/agents/codemie-code/types.d.ts +170 -6
  50. package/dist/agents/codemie-code/types.d.ts.map +1 -1
  51. package/dist/agents/codemie-code/types.js.map +1 -1
  52. package/dist/agents/codemie-code/ui/progressTracker.d.ts +125 -0
  53. package/dist/agents/codemie-code/ui/progressTracker.d.ts.map +1 -0
  54. package/dist/agents/codemie-code/ui/progressTracker.js +343 -0
  55. package/dist/agents/codemie-code/ui/progressTracker.js.map +1 -0
  56. package/dist/agents/codemie-code/ui/todoPanel.d.ts +112 -0
  57. package/dist/agents/codemie-code/ui/todoPanel.d.ts.map +1 -0
  58. package/dist/agents/codemie-code/ui/todoPanel.js +318 -0
  59. package/dist/agents/codemie-code/ui/todoPanel.js.map +1 -0
  60. package/dist/agents/codemie-code/ui.d.ts +106 -10
  61. package/dist/agents/codemie-code/ui.d.ts.map +1 -1
  62. package/dist/agents/codemie-code/ui.js +913 -129
  63. package/dist/agents/codemie-code/ui.js.map +1 -1
  64. package/dist/agents/codemie-code/utils/progressionEnforcer.d.ts +87 -0
  65. package/dist/agents/codemie-code/utils/progressionEnforcer.d.ts.map +1 -0
  66. package/dist/agents/codemie-code/utils/progressionEnforcer.js +293 -0
  67. package/dist/agents/codemie-code/utils/progressionEnforcer.js.map +1 -0
  68. package/dist/agents/codemie-code/utils/todoParser.d.ts +41 -0
  69. package/dist/agents/codemie-code/utils/todoParser.d.ts.map +1 -0
  70. package/dist/agents/codemie-code/utils/todoParser.js +305 -0
  71. package/dist/agents/codemie-code/utils/todoParser.js.map +1 -0
  72. package/dist/agents/codemie-code/utils/todoValidator.d.ts +65 -0
  73. package/dist/agents/codemie-code/utils/todoValidator.d.ts.map +1 -0
  74. package/dist/agents/codemie-code/utils/todoValidator.js +249 -0
  75. package/dist/agents/codemie-code/utils/todoValidator.js.map +1 -0
  76. package/dist/agents/codemie-code/validators/planValidator.d.ts +94 -0
  77. package/dist/agents/codemie-code/validators/planValidator.d.ts.map +1 -0
  78. package/dist/agents/codemie-code/validators/planValidator.js +281 -0
  79. package/dist/agents/codemie-code/validators/planValidator.js.map +1 -0
  80. package/dist/agents/registry.d.ts.map +1 -1
  81. package/dist/agents/registry.js +7 -5
  82. package/dist/agents/registry.js.map +1 -1
  83. package/dist/cli/commands/auth.d.ts +3 -0
  84. package/dist/cli/commands/auth.d.ts.map +1 -0
  85. package/dist/cli/commands/auth.js +170 -0
  86. package/dist/cli/commands/auth.js.map +1 -0
  87. package/dist/cli/commands/config.d.ts.map +1 -1
  88. package/dist/cli/commands/config.js +40 -13
  89. package/dist/cli/commands/config.js.map +1 -1
  90. package/dist/cli/commands/doctor.d.ts.map +1 -1
  91. package/dist/cli/commands/doctor.js +209 -16
  92. package/dist/cli/commands/doctor.js.map +1 -1
  93. package/dist/cli/commands/env.js +3 -3
  94. package/dist/cli/commands/env.js.map +1 -1
  95. package/dist/cli/commands/install.d.ts.map +1 -1
  96. package/dist/cli/commands/install.js +2 -1
  97. package/dist/cli/commands/install.js.map +1 -1
  98. package/dist/cli/commands/run.d.ts.map +1 -1
  99. package/dist/cli/commands/run.js +15 -9
  100. package/dist/cli/commands/run.js.map +1 -1
  101. package/dist/cli/commands/setup.d.ts.map +1 -1
  102. package/dist/cli/commands/setup.js +177 -11
  103. package/dist/cli/commands/setup.js.map +1 -1
  104. package/dist/cli/commands/tools.d.ts +6 -0
  105. package/dist/cli/commands/tools.d.ts.map +1 -0
  106. package/dist/cli/commands/tools.js +244 -0
  107. package/dist/cli/commands/tools.js.map +1 -0
  108. package/dist/cli/commands/version.js +1 -1
  109. package/dist/cli/commands/version.js.map +1 -1
  110. package/dist/cli/commands/workflow.d.ts +6 -0
  111. package/dist/cli/commands/workflow.d.ts.map +1 -0
  112. package/dist/cli/commands/workflow.js +424 -0
  113. package/dist/cli/commands/workflow.js.map +1 -0
  114. package/dist/cli/index.js +39 -5
  115. package/dist/cli/index.js.map +1 -1
  116. package/dist/clients/adapters/github.d.ts +17 -0
  117. package/dist/clients/adapters/github.d.ts.map +1 -0
  118. package/dist/clients/adapters/github.js +150 -0
  119. package/dist/clients/adapters/github.js.map +1 -0
  120. package/dist/clients/adapters/gitlab.d.ts +17 -0
  121. package/dist/clients/adapters/gitlab.d.ts.map +1 -0
  122. package/dist/clients/adapters/gitlab.js +147 -0
  123. package/dist/clients/adapters/gitlab.js.map +1 -0
  124. package/dist/clients/registry.d.ts +20 -0
  125. package/dist/clients/registry.d.ts.map +1 -0
  126. package/dist/clients/registry.js +27 -0
  127. package/dist/clients/registry.js.map +1 -0
  128. package/dist/tools/detector.d.ts +33 -0
  129. package/dist/tools/detector.d.ts.map +1 -0
  130. package/dist/tools/detector.js +145 -0
  131. package/dist/tools/detector.js.map +1 -0
  132. package/dist/tools/index.d.ts +8 -0
  133. package/dist/tools/index.d.ts.map +1 -0
  134. package/dist/tools/index.js +8 -0
  135. package/dist/tools/index.js.map +1 -0
  136. package/dist/tools/manager.d.ts +21 -0
  137. package/dist/tools/manager.d.ts.map +1 -0
  138. package/dist/tools/manager.js +104 -0
  139. package/dist/tools/manager.js.map +1 -0
  140. package/dist/tools/registry.d.ts +8 -0
  141. package/dist/tools/registry.d.ts.map +1 -0
  142. package/dist/tools/registry.js +36 -0
  143. package/dist/tools/registry.js.map +1 -0
  144. package/dist/tools/types.d.ts +41 -0
  145. package/dist/tools/types.d.ts.map +1 -0
  146. package/dist/tools/types.js +5 -0
  147. package/dist/tools/types.js.map +1 -0
  148. package/dist/types/sso.d.ts +42 -0
  149. package/dist/types/sso.d.ts.map +1 -0
  150. package/dist/types/sso.js +2 -0
  151. package/dist/types/sso.js.map +1 -0
  152. package/dist/utils/agent-compatibility.d.ts +32 -0
  153. package/dist/utils/agent-compatibility.d.ts.map +1 -0
  154. package/dist/utils/agent-compatibility.js +140 -0
  155. package/dist/utils/agent-compatibility.js.map +1 -0
  156. package/dist/utils/codemie-integration-validator.d.ts +17 -0
  157. package/dist/utils/codemie-integration-validator.d.ts.map +1 -0
  158. package/dist/utils/codemie-integration-validator.js +105 -0
  159. package/dist/utils/codemie-integration-validator.js.map +1 -0
  160. package/dist/utils/codemie-model-fetcher.d.ts +11 -0
  161. package/dist/utils/codemie-model-fetcher.d.ts.map +1 -0
  162. package/dist/utils/codemie-model-fetcher.js +242 -0
  163. package/dist/utils/codemie-model-fetcher.js.map +1 -0
  164. package/dist/utils/config-loader.d.ts +23 -1
  165. package/dist/utils/config-loader.d.ts.map +1 -1
  166. package/dist/utils/config-loader.js +73 -27
  167. package/dist/utils/config-loader.js.map +1 -1
  168. package/dist/utils/credential-store.d.ts +16 -0
  169. package/dist/utils/credential-store.d.ts.map +1 -0
  170. package/dist/utils/credential-store.js +109 -0
  171. package/dist/utils/credential-store.js.map +1 -0
  172. package/dist/utils/first-time.d.ts +1 -1
  173. package/dist/utils/first-time.d.ts.map +1 -1
  174. package/dist/utils/first-time.js +52 -71
  175. package/dist/utils/first-time.js.map +1 -1
  176. package/dist/utils/health-checker.d.ts.map +1 -1
  177. package/dist/utils/health-checker.js +5 -1
  178. package/dist/utils/health-checker.js.map +1 -1
  179. package/dist/utils/model-fetcher.d.ts.map +1 -1
  180. package/dist/utils/model-fetcher.js +15 -2
  181. package/dist/utils/model-fetcher.js.map +1 -1
  182. package/dist/utils/sso-auth.d.ts +15 -0
  183. package/dist/utils/sso-auth.d.ts.map +1 -0
  184. package/dist/utils/sso-auth.js +207 -0
  185. package/dist/utils/sso-auth.js.map +1 -0
  186. package/dist/utils/sso-gateway.d.ts +47 -0
  187. package/dist/utils/sso-gateway.d.ts.map +1 -0
  188. package/dist/utils/sso-gateway.js +298 -0
  189. package/dist/utils/sso-gateway.js.map +1 -0
  190. package/dist/workflows/detector.d.ts +37 -0
  191. package/dist/workflows/detector.d.ts.map +1 -0
  192. package/dist/workflows/detector.js +160 -0
  193. package/dist/workflows/detector.js.map +1 -0
  194. package/dist/workflows/index.d.ts +8 -0
  195. package/dist/workflows/index.d.ts.map +1 -0
  196. package/dist/workflows/index.js +8 -0
  197. package/dist/workflows/index.js.map +1 -0
  198. package/dist/workflows/installer.d.ts +24 -0
  199. package/dist/workflows/installer.d.ts.map +1 -0
  200. package/dist/workflows/installer.js +105 -0
  201. package/dist/workflows/installer.js.map +1 -0
  202. package/dist/workflows/registry.d.ts +29 -0
  203. package/dist/workflows/registry.d.ts.map +1 -0
  204. package/dist/workflows/registry.js +54 -0
  205. package/dist/workflows/registry.js.map +1 -0
  206. package/dist/workflows/templates/github/metadata.d.ts +6 -0
  207. package/dist/workflows/templates/github/metadata.d.ts.map +1 -0
  208. package/dist/workflows/templates/github/metadata.js +111 -0
  209. package/dist/workflows/templates/github/metadata.js.map +1 -0
  210. package/dist/workflows/templates/gitlab/metadata.d.ts +6 -0
  211. package/dist/workflows/templates/gitlab/metadata.d.ts.map +1 -0
  212. package/dist/workflows/templates/gitlab/metadata.js +14 -0
  213. package/dist/workflows/templates/gitlab/metadata.js.map +1 -0
  214. package/dist/workflows/types.d.ts +71 -0
  215. package/dist/workflows/types.d.ts.map +1 -0
  216. package/dist/workflows/types.js +5 -0
  217. package/dist/workflows/types.js.map +1 -0
  218. package/package.json +19 -6
  219. package/src/workflows/templates/github/code-ci.yml +529 -0
  220. package/src/workflows/templates/github/inline-fix.yml +665 -0
  221. package/src/workflows/templates/github/pr-review.yml +677 -0
  222. package/.claude/agents/README.md +0 -298
  223. package/.claude/agents/release-manager.md +0 -857
  224. package/.codemie/guides/git-workflow.md +0 -493
  225. package/CLAUDE.md +0 -225
  226. package/config.example.json +0 -10
  227. package/dist/agents/codemie-code/streaming/events.d.ts +0 -7
  228. package/dist/agents/codemie-code/streaming/events.d.ts.map +0 -1
  229. package/dist/agents/codemie-code/streaming/events.js +0 -7
  230. package/dist/agents/codemie-code/streaming/events.js.map +0 -1
  231. package/dist/agents/codemie-code/streaming/formatter.d.ts +0 -2
  232. package/dist/agents/codemie-code/streaming/formatter.d.ts.map +0 -1
  233. package/dist/agents/codemie-code/streaming/formatter.js +0 -2
  234. package/dist/agents/codemie-code/streaming/formatter.js.map +0 -1
  235. package/dist/agents/codemie-code/streaming/ui.d.ts +0 -2
  236. package/dist/agents/codemie-code/streaming/ui.d.ts.map +0 -1
  237. package/dist/agents/codemie-code/streaming/ui.js +0 -2
  238. package/dist/agents/codemie-code/streaming/ui.js.map +0 -1
  239. package/dist/agents/codemie-code/tools/command.d.ts +0 -2
  240. package/dist/agents/codemie-code/tools/command.d.ts.map +0 -1
  241. package/dist/agents/codemie-code/tools/command.js +0 -2
  242. package/dist/agents/codemie-code/tools/command.js.map +0 -1
  243. package/dist/agents/codemie-code/tools/filesystem.d.ts +0 -2
  244. package/dist/agents/codemie-code/tools/filesystem.d.ts.map +0 -1
  245. package/dist/agents/codemie-code/tools/filesystem.js +0 -2
  246. package/dist/agents/codemie-code/tools/filesystem.js.map +0 -1
  247. package/dist/agents/codemie-code/tools/git.d.ts +0 -2
  248. package/dist/agents/codemie-code/tools/git.d.ts.map +0 -1
  249. package/dist/agents/codemie-code/tools/git.js +0 -2
  250. package/dist/agents/codemie-code/tools/git.js.map +0 -1
  251. package/dist/agents/codemie-code/tools/security.d.ts +0 -2
  252. package/dist/agents/codemie-code/tools/security.d.ts.map +0 -1
  253. package/dist/agents/codemie-code/tools/security.js +0 -2
  254. package/dist/agents/codemie-code/tools/security.js.map +0 -1
  255. package/eslint.config.mjs +0 -43
  256. package/scripts/README.md +0 -80
  257. package/scripts/release.sh +0 -156
@@ -0,0 +1,677 @@
1
+ name: '🧐 CodeMie Code Pull Request Review'
2
+
3
+ on:
4
+ pull_request:
5
+ types:
6
+ - opened
7
+ - reopened
8
+ - synchronize
9
+ issue_comment:
10
+ types:
11
+ - created
12
+ pull_request_review_comment:
13
+ types:
14
+ - created
15
+ pull_request_review:
16
+ types:
17
+ - submitted
18
+ workflow_dispatch:
19
+ inputs:
20
+ pr_number:
21
+ description: 'PR number to review'
22
+ required: true
23
+ type: number
24
+
25
+ concurrency:
26
+ group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
27
+ cancel-in-progress: true
28
+
29
+ defaults:
30
+ run:
31
+ shell: bash
32
+
33
+ permissions:
34
+ contents: read
35
+ id-token: write
36
+ issues: write
37
+ pull-requests: write
38
+ statuses: write
39
+
40
+ jobs:
41
+ review-pr:
42
+ # Only run for trusted users to prevent abuse
43
+ # For private repos: all users with repo access
44
+ # For public repos: only OWNER, MEMBER, or COLLABORATOR
45
+ if: |
46
+ github.event_name == 'workflow_dispatch' ||
47
+ (
48
+ github.event_name == 'pull_request' &&
49
+ (
50
+ github.event.repository.private == true ||
51
+ contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association)
52
+ )
53
+ ) ||
54
+ (
55
+ (
56
+ (
57
+ github.event_name == 'issue_comment' &&
58
+ github.event.issue.pull_request
59
+ ) ||
60
+ github.event_name == 'pull_request_review_comment'
61
+ ) &&
62
+ (contains(github.event.comment.body, '@codemie-review') || contains(github.event.comment.body, '@codemie-ai-review')) &&
63
+ (
64
+ github.event.repository.private == true ||
65
+ contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)
66
+ )
67
+ ) ||
68
+ (
69
+ github.event_name == 'pull_request_review' &&
70
+ (contains(github.event.review.body, '@codemie-review') || contains(github.event.review.body, '@codemie-ai-review')) &&
71
+ (
72
+ github.event.repository.private == true ||
73
+ contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.review.author_association)
74
+ )
75
+ )
76
+
77
+ timeout-minutes: 15
78
+ runs-on: ubuntu-latest
79
+ environment: dev
80
+
81
+ steps:
82
+ - name: Checkout PR code
83
+ uses: actions/checkout@v4
84
+ with:
85
+ fetch-depth: 0
86
+
87
+ - name: Set up Node.js
88
+ uses: actions/setup-node@v4
89
+ with:
90
+ node-version: '24'
91
+
92
+ - name: Install CodeMie CLI
93
+ run: npm install -g @codemieai/code
94
+
95
+ - name: Install Claude Code
96
+ run: codemie install claude
97
+
98
+ - name: Setup GitHub Token
99
+ id: generate_token
100
+ run: |
101
+ # Use PAT_TOKEN if available for enhanced permissions, fallback to GITHUB_TOKEN
102
+ if [[ -n "${{ secrets.PAT_TOKEN }}" ]]; then
103
+ echo "Using PAT_TOKEN for enhanced GitHub API permissions"
104
+ echo "token=${{ secrets.PAT_TOKEN }}" >> $GITHUB_OUTPUT
105
+ else
106
+ echo "Using default GITHUB_TOKEN"
107
+ echo "token=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_OUTPUT
108
+ fi
109
+
110
+ - name: Get PR details (pull_request & workflow_dispatch)
111
+ id: get_pr
112
+ if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
113
+ env:
114
+ GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
115
+ EVENT_NAME: ${{ github.event_name }}
116
+ WORKFLOW_PR_NUMBER: ${{ github.event.inputs.pr_number }}
117
+ PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
118
+ run: |
119
+ set -euo pipefail
120
+
121
+ if [[ "${EVENT_NAME}" = "workflow_dispatch" ]]; then
122
+ PR_NUMBER="${WORKFLOW_PR_NUMBER}"
123
+ else
124
+ PR_NUMBER="${PULL_REQUEST_NUMBER}"
125
+ fi
126
+
127
+ echo "pr_number=${PR_NUMBER}" >> "${GITHUB_OUTPUT}"
128
+
129
+ # Get PR details
130
+ PR_DATA="$(gh pr view "${PR_NUMBER}" --json title,body,additions,deletions,changedFiles,baseRefName,headRefName)"
131
+ echo "pr_data=${PR_DATA}" >> "${GITHUB_OUTPUT}"
132
+
133
+ # Get file changes
134
+ CHANGED_FILES="$(gh pr diff "${PR_NUMBER}" --name-only)"
135
+ {
136
+ echo "changed_files<<EOF"
137
+ echo "${CHANGED_FILES}"
138
+ echo "EOF"
139
+ } >> "${GITHUB_OUTPUT}"
140
+
141
+ - name: Get PR details (issue_comment & reviews)
142
+ id: get_pr_comment
143
+ if: github.event_name == 'issue_comment' || github.event_name == 'pull_request_review' || github.event_name == 'pull_request_review_comment'
144
+ env:
145
+ GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
146
+ COMMENT_BODY: ${{ github.event.comment.body || github.event.review.body }}
147
+ PR_NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }}
148
+ run: |
149
+ set -euo pipefail
150
+
151
+ echo "pr_number=${PR_NUMBER}" >> "${GITHUB_OUTPUT}"
152
+
153
+ # Extract additional instructions from comment (handle @codemie-review or @codemie-ai-review)
154
+ ADDITIONAL_INSTRUCTIONS="$(
155
+ echo "${COMMENT_BODY}" | sed 's/.*@codemie\(-ai\)\?-review//' | xargs
156
+ )"
157
+ echo "additional_instructions=${ADDITIONAL_INSTRUCTIONS}" >> "${GITHUB_OUTPUT}"
158
+
159
+ # Get PR details
160
+ PR_DATA="$(gh pr view "${PR_NUMBER}" --json title,body,additions,deletions,changedFiles,baseRefName,headRefName)"
161
+ echo "pr_data=${PR_DATA}" >> "${GITHUB_OUTPUT}"
162
+
163
+ # Get file changes
164
+ CHANGED_FILES="$(gh pr diff "${PR_NUMBER}" --name-only)"
165
+ {
166
+ echo "changed_files<<EOF"
167
+ echo "${CHANGED_FILES}"
168
+ echo "EOF"
169
+ } >> "${GITHUB_OUTPUT}"
170
+
171
+ - name: Configure CodeMie Code with MCP
172
+ id: configure_mcp
173
+ env:
174
+ GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
175
+ run: |
176
+ # Create CodeMie Code settings directory
177
+ mkdir -p ~/.config/claude-code
178
+
179
+ # Create MCP configuration for GitHub integration
180
+ cat > ~/.config/claude-code/settings.json << 'EOF'
181
+ {
182
+ "mcpServers": {
183
+ "github": {
184
+ "command": "npx",
185
+ "args": [
186
+ "-y",
187
+ "@modelcontextprotocol/server-github"
188
+ ],
189
+ "env": {
190
+ "GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_TOKEN"
191
+ }
192
+ }
193
+ }
194
+ }
195
+ EOF
196
+
197
+ # Replace the token placeholder with actual token
198
+ sed -i "s|\$GITHUB_TOKEN|${GITHUB_TOKEN}|g" ~/.config/claude-code/settings.json
199
+
200
+ echo "✅ MCP GitHub server configured"
201
+ echo "Configuration location: ~/.config/claude-code/settings.json"
202
+
203
+ - name: Verify AWS Credentials
204
+ run: |
205
+ echo "Checking AWS Bedrock credentials..."
206
+ if [ -z "${{ secrets.AWS_REGION }}" ]; then
207
+ echo "❌ ERROR: AWS_REGION secret is not set"
208
+ exit 1
209
+ fi
210
+ if [ -z "${{ secrets.AWS_ACCESS_KEY_ID }}" ]; then
211
+ echo "❌ ERROR: AWS_ACCESS_KEY_ID secret is not set"
212
+ exit 1
213
+ fi
214
+ if [ -z "${{ secrets.AWS_SECRET_ACCESS_KEY }}" ]; then
215
+ echo "❌ ERROR: AWS_SECRET_ACCESS_KEY secret is not set"
216
+ exit 1
217
+ fi
218
+ echo "✅ All AWS secrets are configured"
219
+
220
+ - name: Run CodeMie Code PR Review
221
+ id: claude_review
222
+ env:
223
+ # AWS Bedrock Configuration
224
+ CLAUDE_CODE_USE_BEDROCK: "1"
225
+ AWS_REGION: ${{ secrets.AWS_REGION }}
226
+ AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
227
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
228
+ AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
229
+ # GitHub Configuration
230
+ GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
231
+ PR_NUMBER: ${{ steps.get_pr.outputs.pr_number || steps.get_pr_comment.outputs.pr_number }}
232
+ PR_DATA: ${{ steps.get_pr.outputs.pr_data || steps.get_pr_comment.outputs.pr_data }}
233
+ CHANGED_FILES: ${{ steps.get_pr.outputs.changed_files || steps.get_pr_comment.outputs.changed_files }}
234
+ ADDITIONAL_INSTRUCTIONS: ${{ steps.get_pr_comment.outputs.additional_instructions }}
235
+ REPOSITORY: ${{ github.repository }}
236
+ # CI Configuration
237
+ CI: "true"
238
+ GITHUB_ACTIONS: "true"
239
+ # Claude Configuration
240
+ MAX_TURNS: ${{ vars.CODEMIE_MAX_TURNS || '50' }}
241
+ run: |
242
+ set -euo pipefail
243
+
244
+ # Determine model
245
+ MODEL="${{ secrets.ANTHROPIC_MODEL }}"
246
+ if [ -z "$MODEL" ]; then
247
+ MODEL="anthropic.claude-3-5-sonnet-20241022-v2:0"
248
+ fi
249
+
250
+ echo "================================================"
251
+ echo "CodeMie Code PR Review Configuration"
252
+ echo "================================================"
253
+ echo "Repository: ${REPOSITORY}"
254
+ echo "PR Number: ${PR_NUMBER}"
255
+ echo "Model: ${MODEL}"
256
+ echo "AWS Region: ${AWS_REGION}"
257
+ echo "Additional Instructions: ${ADDITIONAL_INSTRUCTIONS:-None}"
258
+ echo "================================================"
259
+
260
+ # Create comprehensive review prompt
261
+ cat > /tmp/review-prompt.txt << 'PROMPT_EOF'
262
+ ## Role
263
+
264
+ You are a senior staff engineer performing critical code review. Your focus is on identifying
265
+ serious issues that impact system reliability, security, performance, and correctness.
266
+ You have access to GitHub MCP tools to leave comments directly on GitHub.
267
+
268
+ ## Core Principle: Quality Over Quantity
269
+
270
+ **ONLY comment on issues that are:**
271
+ - 🔴 **Critical**: Must be fixed before merge (security, data corruption, system failure)
272
+ - 🟠 **High**: Should be fixed before merge (bugs, performance issues, breaking changes)
273
+ - 🟡 **Medium**: Important quality issues that significantly impact maintainability
274
+
275
+ **DO NOT comment on:**
276
+ - ✅ Good code changes (no need to praise)
277
+ - 🟢 Minor style issues
278
+ - 🟢 Small refactoring suggestions
279
+ - 🟢 Documentation improvements (unless critical safety/security docs missing)
280
+ - 🔵 General observations without specific actionable fix
281
+
282
+ ## Requirements
283
+
284
+ 1. All feedback MUST be left on GitHub using MCP tools
285
+ 2. Only comment when you identify a REAL problem
286
+ 3. Every comment must include a specific fix or suggestion
287
+ 4. Focus on issues that genuinely impact code quality, security, or correctness
288
+
289
+ ## Steps
290
+
291
+ ### 1. Gather Information
292
+
293
+ Run these commands to collect PR details:
294
+ ```bash
295
+ echo "${REPOSITORY}" # Get repository in OWNER/REPO format
296
+ echo "${PR_DATA}" # Get PR metadata (JSON)
297
+ echo "${CHANGED_FILES}" # Get list of changed files
298
+ echo "${PR_NUMBER}" # Get PR number
299
+ echo "${ADDITIONAL_INSTRUCTIONS}" # Get specific review focus
300
+ gh pr diff "${PR_NUMBER}" --patch # Get full diff with patches
301
+ ```
302
+
303
+ For specific files, use:
304
+ ```bash
305
+ cat filename # View entire file
306
+ head -50 filename # View first 50 lines
307
+ tail -50 filename # View last 50 lines
308
+ grep -n "pattern" filename # Search in file
309
+ ```
310
+
311
+ ### 2. Analyze the Changes
312
+
313
+ - Understand PR title, description, and intent
314
+ - Review all code changes with focus on critical paths
315
+ - Consider ADDITIONAL_INSTRUCTIONS for focused review areas
316
+ - Scan for high-impact issues first, ignore trivial matters
317
+
318
+ ### 3. Review Criteria - CRITICAL & HIGH PRIORITY ONLY
319
+
320
+ #### 🔴 Critical Issues (MUST FIX - System/Security Impact)
321
+
322
+ **Security Vulnerabilities:**
323
+ - SQL injection, XSS, CSRF, command injection
324
+ - Authentication bypass, authorization flaws
325
+ - Hardcoded secrets, credentials in code
326
+ - Insecure cryptography, weak encryption
327
+ - Path traversal, arbitrary file access
328
+ - Deserialization of untrusted data
329
+
330
+ **Data Integrity:**
331
+ - Data corruption risks (race conditions, lost updates)
332
+ - Database transaction issues (missing rollback, isolation problems)
333
+ - Data loss scenarios (missing backups, unsafe deletes)
334
+ - Incorrect data validation leading to corruption
335
+
336
+ **System Stability:**
337
+ - Null pointer dereferences causing crashes
338
+ - Memory leaks in long-running processes
339
+ - Resource exhaustion (file handles, connections, memory)
340
+ - Deadlocks and livelocks
341
+ - Infinite loops or recursion
342
+
343
+ #### 🟠 High Priority Issues (SHOULD FIX - Correctness/Performance)
344
+
345
+ **Logic Errors:**
346
+ - Incorrect business logic implementation
347
+ - Off-by-one errors in loops or arrays
348
+ - Wrong conditional logic (AND vs OR, negation errors)
349
+ - Missing edge case handling
350
+ - Incorrect algorithm implementation
351
+
352
+ **Performance Issues:**
353
+ - N+1 query problems
354
+ - O(n²) or worse algorithms where better exists
355
+ - Missing database indexes for queries
356
+ - Unnecessary network calls in loops
357
+ - Memory-intensive operations without bounds
358
+
359
+ **Breaking Changes:**
360
+ - API contract changes without versioning
361
+ - Database schema changes without migration
362
+ - Removing public APIs without deprecation
363
+ - Changing function signatures in public interfaces
364
+
365
+ **Error Handling:**
366
+ - Swallowed exceptions hiding failures
367
+ - Missing error handling in critical paths
368
+ - Incorrect error propagation
369
+ - Silent failures in important operations
370
+
371
+ #### 🟡 Medium Priority Issues (IMPORTANT Quality)
372
+
373
+ **Maintainability Risks:**
374
+ - Overly complex code (cyclomatic complexity > 15)
375
+ - Significant code duplication (DRY violations)
376
+ - Poor separation of concerns
377
+ - Missing critical comments for complex logic
378
+
379
+ **Concurrency Issues:**
380
+ - Missing synchronization in shared state
381
+ - Potential race conditions
382
+ - Improper use of concurrent data structures
383
+
384
+ **Data Validation:**
385
+ - Missing input validation on external data
386
+ - Insufficient boundary checks
387
+ - Type coercion issues
388
+
389
+ ### 4. Severity Guidelines
390
+
391
+ Use ONLY these severity levels:
392
+ - 🔴 **Critical**: IMMEDIATE fix required - security/stability/data loss
393
+ - 🟠 **High**: MUST fix before merge - bugs/performance/breaking changes
394
+ - 🟡 **Medium**: SHOULD fix - significant maintainability/quality issues
395
+
396
+ **Do not use:**
397
+ - 🟢 Low severity (skip these issues)
398
+ - 🔵 Info severity (skip observations)
399
+
400
+ ### 5. Review Guidelines - STRICT FILTERING
401
+
402
+ **ONLY comment if:**
403
+ - ✅ You found a REAL bug or security issue
404
+ - ✅ The issue will cause actual problems (not hypothetical)
405
+ - ✅ You can provide a SPECIFIC fix
406
+ - ✅ The severity is 🔴 Critical, 🟠 High, or 🟡 Medium
407
+ - ✅ The issue is on changed lines (+ or - in diff)
408
+
409
+ **NEVER comment on:**
410
+ - ❌ Style issues (formatting, naming, etc.)
411
+ - ❌ "Consider doing X" suggestions without clear problem
412
+ - ❌ Documentation improvements (unless safety-critical)
413
+ - ❌ Test suggestions (unless testing is completely missing)
414
+ - ❌ Refactoring ideas without quality impact
415
+ - ❌ Good code practices ("this is well done")
416
+ - ❌ License headers or copyright notices
417
+ - ❌ Context lines (unchanged code)
418
+ - ❌ Hypothetical issues ("this might cause problems if...")
419
+ - ❌ Questions like "have you considered...?" without a concrete issue
420
+
421
+ **Comment Quality Standards:**
422
+ - Be direct: "This causes a SQL injection vulnerability"
423
+ - Provide fix: Show exact code to resolve the issue
424
+ - Explain impact: "This will crash when input is null"
425
+ - Be respectful but firm on critical issues
426
+
427
+ ### 6. Code Suggestion Format
428
+
429
+ **Critical security issue example:**
430
+ ```
431
+ 🔴 SQL injection vulnerability - user input concatenated directly into query
432
+ ```suggestion
433
+ # Use parameterized query
434
+ cursor.execute("SELECT * FROM users WHERE id = ?", (user_id,))
435
+ ```
436
+
437
+ **Impact**: Attacker can execute arbitrary SQL commands, steal data, or delete database.
438
+ ```
439
+
440
+ **High priority bug example:**
441
+ ```
442
+ 🟠 Null pointer exception when user.profile is None
443
+ ```suggestion
444
+ if user and user.profile:
445
+ return user.profile.email
446
+ return None
447
+ ```
448
+
449
+ **Impact**: Application crashes on users without profiles.
450
+ ```
451
+
452
+ **Medium priority quality issue example:**
453
+ ```
454
+ 🟡 Race condition - multiple threads can modify shared state
455
+ ```suggestion
456
+ with self._lock:
457
+ self._counter += 1
458
+ return self._counter
459
+ ```
460
+
461
+ **Impact**: Counter can be incorrect under concurrent load, causing data inconsistency.
462
+ ```
463
+
464
+ ### 7. Post Review to GitHub
465
+
466
+ Use MCP GitHub tools in this order:
467
+
468
+ **Step 1: Create pending review**
469
+ ```
470
+ mcp__github__create_pending_pull_request_review
471
+ - owner: {owner}
472
+ - repo: {repo}
473
+ - pull_number: {pr_number}
474
+ ```
475
+
476
+ **Step 2: Add inline comments** (repeat for each issue)
477
+ ```
478
+ mcp__github__add_comment_to_pending_review
479
+ - owner: {owner}
480
+ - repo: {repo}
481
+ - pull_number: {pr_number}
482
+ - body: "🟡 Issue description with code suggestion"
483
+ - path: "path/to/file.py"
484
+ - line: {line_number}
485
+ - side: "RIGHT" # or "LEFT" for old code
486
+ ```
487
+
488
+ **Step 3: Submit review with summary**
489
+ ```
490
+ mcp__github__submit_pending_pull_request_review
491
+ - owner: {owner}
492
+ - repo: {repo}
493
+ - pull_number: {pr_number}
494
+ - event: "COMMENT" # Use "REQUEST_CHANGES" only for critical issues
495
+ - body: "## 📋 Review Summary\n\n{summary}"
496
+ ```
497
+
498
+ ### 8. Review Summary Format
499
+
500
+ **IMPORTANT**: Only create summary if you found issues. If no critical/high/medium issues found, submit an empty review or just say "No critical issues found."
501
+
502
+ **If issues were found**, structure your summary:
503
+
504
+ ```markdown
505
+ ## 📋 Review Summary
506
+
507
+ Found {total_count} issues requiring attention before merge.
508
+
509
+ ## 🔍 Issues Found
510
+
511
+ - 🔴 Critical: {count} - MUST fix immediately
512
+ - 🟠 High: {count} - Should fix before merge
513
+ - 🟡 Medium: {count} - Important for code quality
514
+
515
+ ## 🎯 Required Actions
516
+
517
+ ### Critical Issues (Fix First)
518
+ 1. [Brief description of critical issue 1]
519
+ 2. [Brief description of critical issue 2]
520
+
521
+ ### High Priority (Fix Before Merge)
522
+ 1. [Brief description of high issue 1]
523
+ 2. [Brief description of high issue 2]
524
+
525
+ ### Medium Priority (Should Address)
526
+ 1. [Brief description of medium issue 1]
527
+
528
+ ## ⚠️ Review Notes
529
+
530
+ - All issues have inline comments with specific fixes
531
+ - Focus on critical and high-priority items first
532
+ - Review inline suggestions for exact code changes
533
+ ```
534
+
535
+ **If NO issues found:**
536
+ ```markdown
537
+ ## ✅ Review Complete
538
+
539
+ No critical, high, or medium priority issues found. Changes look good from a security, correctness, and quality perspective.
540
+ ```
541
+
542
+ ## Context
543
+
544
+ The PR changes are provided in unified diff format:
545
+
546
+ ```
547
+ FILE: path/to/file.py
548
+ DIFF:
549
+ @@ -10,7 +10,9 @@ def foo():
550
+ - old_code = 1
551
+ + new_code = 2
552
+ + additional_line = 3
553
+ ```
554
+
555
+ Line numbers in diff:
556
+ - LEFT side: old code (before changes) - use for comments on deleted code
557
+ - RIGHT side: new code (after changes) - use for comments on added code
558
+
559
+ ## Critical Reminders - READ CAREFULLY
560
+
561
+ **FILTERING RULES (MOST IMPORTANT):**
562
+ 1. ❗ ONLY comment if severity is 🔴 Critical, 🟠 High, or 🟡 Medium
563
+ 2. ❗ SKIP all low-severity and informational comments
564
+ 3. ❗ SKIP all style, formatting, and documentation suggestions
565
+ 4. ❗ SKIP praise and positive observations
566
+ 5. ❗ Every comment MUST identify a real problem with actual impact
567
+
568
+ **QUALITY OVER QUANTITY:**
569
+ - Better to have 3 critical comments than 20 trivial ones
570
+ - Each comment must be worth the PR author's time
571
+ - If no serious issues found, say so briefly and approve
572
+
573
+ **TECHNICAL REQUIREMENTS:**
574
+ 1. Use MCP GitHub tools - no other output reaches PR author
575
+ 2. Comment only on changed lines (+ or - in diff)
576
+ 3. Include specific code fix in every comment
577
+ 4. Explain the real-world impact of each issue
578
+ 5. Pay attention to line numbers accuracy
579
+
580
+ ## Begin Review
581
+
582
+ 1. Gather PR information using the commands above
583
+ 2. Scan for CRITICAL issues first (security, crashes, data loss)
584
+ 3. Then look for HIGH issues (bugs, performance, breaking changes)
585
+ 4. Then check for MEDIUM issues (significant quality problems)
586
+ 5. IGNORE everything else
587
+ 6. Post review with only the important findings
588
+
589
+ Remember: A PR with no comments is better than a PR with 15 nitpicks.
590
+ PROMPT_EOF
591
+
592
+ echo "Starting CodeMie Code PR review..."
593
+ echo ""
594
+
595
+ # Run CodeMie Code with MCP GitHub integration
596
+ timeout 15m claude \
597
+ -p "$(cat /tmp/review-prompt.txt)" \
598
+ --model "${MODEL}" \
599
+ --max-turns "${MAX_TURNS}" \
600
+ --dangerously-skip-permissions \
601
+ --allowedTools "Bash(*),Read(*),mcp__github__*" \
602
+ --debug \
603
+ 2>&1 | tee /tmp/codemie-review-output.log || {
604
+ EXIT_CODE=$?
605
+ echo "CodeMie Code exited with code: ${EXIT_CODE}"
606
+ if [ ${EXIT_CODE} -eq 124 ]; then
607
+ echo "Error: CodeMie Code review timed out after 15 minutes"
608
+ exit 1
609
+ fi
610
+ echo "=== Last 100 lines of output ==="
611
+ tail -n 100 /tmp/codemie-review-output.log
612
+ exit ${EXIT_CODE}
613
+ }
614
+
615
+ echo "✅ CodeMie Code PR review completed"
616
+
617
+ - name: Upload Review Output
618
+ if: always()
619
+ uses: actions/upload-artifact@v4
620
+ with:
621
+ name: codemie-review-output-${{ github.run_number }}
622
+ path: /tmp/codemie-review-output.log
623
+ retention-days: 30
624
+
625
+ - name: Post failure comment
626
+ if: failure() && steps.claude_review.outcome == 'failure'
627
+ uses: actions/github-script@v7
628
+ with:
629
+ github-token: ${{ steps.generate_token.outputs.token }}
630
+ script: |
631
+ const prNumber = ${{ steps.get_pr.outputs.pr_number || steps.get_pr_comment.outputs.pr_number }};
632
+ const runUrl = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}';
633
+
634
+ await github.rest.issues.createComment({
635
+ owner: context.repo.owner,
636
+ repo: context.repo.repo,
637
+ issue_number: prNumber,
638
+ body: `⚠️ **CodeMie Code PR Review Failed**
639
+
640
+ There was an issue running the automated code review. Please check the [workflow logs](${runUrl}) for details.
641
+
642
+ Common issues:
643
+ - AWS Bedrock credentials not configured
644
+ - GitHub token permissions insufficient
645
+ - Review timeout (complex PRs may need manual review)
646
+
647
+ You can retry by:
648
+ - Re-running the failed workflow
649
+ - Commenting \`@codemie-review\` with specific focus areas
650
+ - Running manually: \`Actions → CodeMie Code Pull Request Review → Run workflow\``
651
+ });
652
+
653
+ - name: Post Summary
654
+ if: always()
655
+ run: |
656
+ echo "## 🧐 CodeMie Code PR Review Summary" >> $GITHUB_STEP_SUMMARY
657
+ echo "" >> $GITHUB_STEP_SUMMARY
658
+ echo "**Repository**: ${{ github.repository }}" >> $GITHUB_STEP_SUMMARY
659
+ echo "**PR Number**: ${{ steps.get_pr.outputs.pr_number || steps.get_pr_comment.outputs.pr_number }}" >> $GITHUB_STEP_SUMMARY
660
+ echo "**Status**: ${{ job.status }}" >> $GITHUB_STEP_SUMMARY
661
+ echo "" >> $GITHUB_STEP_SUMMARY
662
+
663
+ echo "### 🔧 Configuration" >> $GITHUB_STEP_SUMMARY
664
+ echo "- **Provider**: AWS Bedrock" >> $GITHUB_STEP_SUMMARY
665
+ echo "- **Model**: ${{ secrets.ANTHROPIC_MODEL || 'anthropic.claude-3-5-sonnet-20241022-v2:0 (default)' }}" >> $GITHUB_STEP_SUMMARY
666
+ echo "- **MCP Integration**: GitHub (enabled)" >> $GITHUB_STEP_SUMMARY
667
+ echo "" >> $GITHUB_STEP_SUMMARY
668
+
669
+ echo "### 📦 Outputs" >> $GITHUB_STEP_SUMMARY
670
+ echo "- **Review Posted**: Check PR comments for detailed feedback" >> $GITHUB_STEP_SUMMARY
671
+ echo "- **Full Log**: Available in workflow artifacts" >> $GITHUB_STEP_SUMMARY
672
+ echo "" >> $GITHUB_STEP_SUMMARY
673
+
674
+ echo "### 💡 Usage Tips" >> $GITHUB_STEP_SUMMARY
675
+ echo "- Comment \`@codemie-review focus on security\` for targeted reviews" >> $GITHUB_STEP_SUMMARY
676
+ echo "- Comment \`@codemie-review check performance\` to focus on optimization" >> $GITHUB_STEP_SUMMARY
677
+ echo "- Review runs automatically on PR open/update (for trusted users)" >> $GITHUB_STEP_SUMMARY