ai-core-framework 0.1.0

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 (103) hide show
  1. package/.claude-plugin/plugin.json +21 -0
  2. package/.codex-plugin/plugin.json +35 -0
  3. package/.cursor-plugin/plugin.json +22 -0
  4. package/README.md +173 -0
  5. package/bin/ai-core-framework.js +110 -0
  6. package/core/README.md +162 -0
  7. package/core/agents/README.md +32 -0
  8. package/core/agents/business-analyst.md +269 -0
  9. package/core/agents/developer.md +375 -0
  10. package/core/agents/qa-tester.md +477 -0
  11. package/core/agents/scrum-master.md +136 -0
  12. package/core/agents/tech-lead.md +345 -0
  13. package/core/config/backlog.schema.json +38 -0
  14. package/core/config/docs-policy.default.json +37 -0
  15. package/core/config/release.schema.json +120 -0
  16. package/core/config/ticket.schema.json +253 -0
  17. package/core/rules/00-global-rules.md +373 -0
  18. package/core/rules/01-git-workflow.md +388 -0
  19. package/core/rules/02-code-quality.md +77 -0
  20. package/core/rules/03-security.md +78 -0
  21. package/core/rules/04-documentation.md +72 -0
  22. package/core/rules/05-testing-mandatory.md +374 -0
  23. package/core/rules/06-approval-gates.md +388 -0
  24. package/core/rules/07-definition-of-ready.md +112 -0
  25. package/core/rules/08-definition-of-done.md +149 -0
  26. package/core/scripts/ai-core.sh +456 -0
  27. package/core/scripts/generate-views.sh +210 -0
  28. package/core/scripts/install-codex-prompts.sh +127 -0
  29. package/core/scripts/log-user-request.sh +113 -0
  30. package/core/scripts/setup-project.sh +183 -0
  31. package/core/scripts/sync-platforms.sh +322 -0
  32. package/core/scripts/validate-audit-log.sh +73 -0
  33. package/core/scripts/validate-docs.sh +365 -0
  34. package/core/scripts/validate-permissions.sh +132 -0
  35. package/core/scripts/validate-state.sh +611 -0
  36. package/core/scripts/workflow.sh +513 -0
  37. package/core/skills/README.md +21 -0
  38. package/core/skills/ai-core-commands/SKILL.md +86 -0
  39. package/core/skills/brainstorming/SKILL.md +40 -0
  40. package/core/skills/development-implement-task/SKILL.md +308 -0
  41. package/core/skills/executing-ticket/SKILL.md +28 -0
  42. package/core/skills/git-branch-status/SKILL.md +56 -0
  43. package/core/skills/git-cleanup-branches/SKILL.md +57 -0
  44. package/core/skills/git-scan-untracked/SKILL.md +50 -0
  45. package/core/skills/meta-generate-views/SKILL.md +54 -0
  46. package/core/skills/meta-request-log/SKILL.md +61 -0
  47. package/core/skills/meta-sprint-report/SKILL.md +59 -0
  48. package/core/skills/meta-sync-platforms/SKILL.md +53 -0
  49. package/core/skills/meta-ticket-health/SKILL.md +61 -0
  50. package/core/skills/meta-validate-audit-log/SKILL.md +42 -0
  51. package/core/skills/meta-validate-docs/SKILL.md +58 -0
  52. package/core/skills/meta-validate-permissions/SKILL.md +53 -0
  53. package/core/skills/meta-validate-state/SKILL.md +58 -0
  54. package/core/skills/planning-analyze-requirements/SKILL.md +471 -0
  55. package/core/skills/planning-backlog-status/SKILL.md +57 -0
  56. package/core/skills/planning-document-existing-requirements/SKILL.md +246 -0
  57. package/core/skills/planning-estimate-task/SKILL.md +60 -0
  58. package/core/skills/planning-groom-ticket/SKILL.md +442 -0
  59. package/core/skills/planning-mark-ready/SKILL.md +111 -0
  60. package/core/skills/planning-plan-refactor/SKILL.md +66 -0
  61. package/core/skills/planning-plan-sprint/SKILL.md +112 -0
  62. package/core/skills/planning-prioritize-backlog/SKILL.md +62 -0
  63. package/core/skills/planning-write-plan/SKILL.md +68 -0
  64. package/core/skills/project-detect-stack/SKILL.md +71 -0
  65. package/core/skills/project-discover-codebase/SKILL.md +74 -0
  66. package/core/skills/project-setup-project/SKILL.md +113 -0
  67. package/core/skills/qa-bug-status/SKILL.md +52 -0
  68. package/core/skills/qa-report-bug/SKILL.md +518 -0
  69. package/core/skills/qa-smoke-test/SKILL.md +387 -0
  70. package/core/skills/qa-triage-bug/SKILL.md +62 -0
  71. package/core/skills/qa-verify-fix/SKILL.md +446 -0
  72. package/core/skills/release-hotfix/SKILL.md +117 -0
  73. package/core/skills/release-release/SKILL.md +123 -0
  74. package/core/skills/release-rollback/SKILL.md +62 -0
  75. package/core/skills/review-create-pr/SKILL.md +418 -0
  76. package/core/skills/review-merge-pr/SKILL.md +425 -0
  77. package/core/skills/review-techlead-review/SKILL.md +547 -0
  78. package/core/skills/using-ai-core/SKILL.md +72 -0
  79. package/core/skills/verification-before-done/SKILL.md +35 -0
  80. package/core/skills/writing-implementation-plan/SKILL.md +45 -0
  81. package/core/templates/ci/ai-core-governance.yml +112 -0
  82. package/core/templates/ci/node-pnpm.yml +35 -0
  83. package/core/templates/pm/retrospective-template.md +47 -0
  84. package/core/templates/pm/sprint-plan-template.md +45 -0
  85. package/core/templates/pr/pull-request-template.md +247 -0
  86. package/core/templates/project/CODEOWNERS +11 -0
  87. package/core/templates/project/docs-policy.json +3 -0
  88. package/core/templates/project/project-config.yaml +137 -0
  89. package/core/templates/project/project-structure.yaml +76 -0
  90. package/core/templates/qa/bug-report-template.md +371 -0
  91. package/core/templates/qa/test-plan-template.md +57 -0
  92. package/core/templates/release/release-record-template.json +67 -0
  93. package/core/templates/requirements/PRD-template.md +58 -0
  94. package/core/templates/requirements/user-story-template.md +381 -0
  95. package/core/templates/technical/ADR-template.md +46 -0
  96. package/core/templates/technical/refactor-plan-template.md +84 -0
  97. package/core/templates/technical/tech-design-template.md +71 -0
  98. package/core/workflows/bug-lifecycle.md +56 -0
  99. package/core/workflows/feature-lifecycle.md +347 -0
  100. package/core/workflows/hotfix-lifecycle.md +65 -0
  101. package/core/workflows/sprint-lifecycle.md +56 -0
  102. package/lib/install-codex.js +85 -0
  103. package/package.json +36 -0
@@ -0,0 +1,425 @@
1
+ ---
2
+ name: review-merge-pr
3
+ description: Use when the user asks to run /merge-pr, merge an approved pull request, enforce merge prerequisites, delete the branch, or advance the linked ticket to QA.
4
+ command: /merge-pr
5
+ display_name: "Merge Pull Request"
6
+ version: 1.0.0
7
+ owner_agent: tech-lead
8
+ model_preference: sonnet
9
+ args:
10
+ - name: pr_number
11
+ required: true
12
+ type: integer
13
+ description: "PR number to merge"
14
+ - name: strategy
15
+ required: false
16
+ type: string
17
+ default: "squash"
18
+ enum: [squash, merge, rebase]
19
+ description: "Merge strategy (squash default per RULE GIT-008)"
20
+ preconditions:
21
+ - pr_exists: true
22
+ - pr_open: true
23
+ - pr_approved: true # ≥1 approval from tech-lead
24
+ - pr_not_own: true # Cannot merge own PR (RULE TL-005)
25
+ - ci_status: green
26
+ - no_unresolved_comments: true
27
+ - ticket_status: IN_REVIEW
28
+ - branch_up_to_date: true # Merged with develop latest
29
+ postconditions:
30
+ - pr_merged: true
31
+ - branch_deleted: true
32
+ - ticket_status: QA
33
+ - ci_triggered_on_develop: true
34
+ ---
35
+
36
+ # /merge-pr
37
+
38
+ > Merge approved PR into develop. Transitions ticket IN_REVIEW → QA.
39
+ > **Final gate before code enters integration branch.**
40
+
41
+ ## 🎯 Purpose
42
+
43
+ After review is approved, merge the PR with:
44
+ 1. Verify all gates still green (CI, approvals, comments resolved)
45
+ 2. Execute merge with correct strategy
46
+ 3. Delete source branch
47
+ 4. Update ticket → QA state
48
+ 5. Trigger QA smoke test notification
49
+
50
+ ## 🚦 Trigger
51
+
52
+ **Manual** (primary):
53
+ ```
54
+ /merge-pr 123
55
+ ```
56
+
57
+ **With strategy override**:
58
+ ```
59
+ /merge-pr 123 --strategy=merge # For release PRs (preserve history)
60
+ ```
61
+
62
+ **NOT auto-merge** — human/agent decision every time.
63
+
64
+ ## 📋 Preconditions (STRICT)
65
+
66
+ ### 1. PR exists + open
67
+ ```bash
68
+ gh pr view "$PR_NUMBER" --json state | jq -e '.state == "OPEN"' || ABORT
69
+ ```
70
+
71
+ ### 2. Not own PR (RULE TL-005)
72
+ ```bash
73
+ pr_author=$(gh pr view "$PR_NUMBER" --json author --jq .author.login)
74
+ current_user=$(gh api user --jq .login)
75
+ [ "$pr_author" != "$current_user" ] || ABORT "Cannot merge own PR (RULE TL-005)"
76
+ ```
77
+
78
+ ### 3. Approved by tech-lead
79
+ ```bash
80
+ approvals=$(gh pr view "$PR_NUMBER" --json reviews --jq '[.reviews[] | select(.state == "APPROVED")] | length')
81
+ [ "$approvals" -ge 1 ] || ABORT "No approval. Need tech-lead review first."
82
+ ```
83
+
84
+ Verify approval is from tech-lead role (not just any developer).
85
+
86
+ ### 4. CI green
87
+ ```bash
88
+ ci_state=$(gh pr checks "$PR_NUMBER" --json status --jq '.[].status' | sort -u)
89
+ echo "$ci_state" | grep -q "SUCCESS" && ! echo "$ci_state" | grep -qE "(FAILURE|ERROR|PENDING)" || ABORT
90
+ ```
91
+
92
+ ### 5. No unresolved review comments
93
+ ```bash
94
+ unresolved=$(gh api "repos/{owner}/{repo}/pulls/$PR_NUMBER/reviews" | jq '[.[] | select(.state == "CHANGES_REQUESTED")] | length')
95
+ [ "$unresolved" -eq 0 ] || ABORT "Unresolved CHANGES_REQUESTED. Resolve first."
96
+ ```
97
+
98
+ ### 6. Ticket status = IN_REVIEW
99
+ Read ticket from branch name. Must be IN_REVIEW.
100
+
101
+ ### 7. Branch up-to-date with develop
102
+ ```bash
103
+ behind=$(gh pr view "$PR_NUMBER" --json mergeable --jq '.mergeable')
104
+ [ "$behind" = "MERGEABLE" ] || ABORT "Merge conflict or stale. Rebase first."
105
+ ```
106
+
107
+ ### 8. No merge commits in feature branch (RULE GIT-012)
108
+ Check commit history doesn't contain merge commits from other feature branches.
109
+
110
+ ## 🔄 Execution Flow
111
+
112
+ ```
113
+ ┌──────────────────────────────────────────────────────────┐
114
+ │ STEP 1: Validate preconditions (above) │
115
+ ├──────────────────────────────────────────────────────────┤
116
+ │ STEP 2: Load context │
117
+ │ - PR metadata │
118
+ │ - Ticket JSON │
119
+ │ - Linked ADRs │
120
+ ├──────────────────────────────────────────────────────────┤
121
+ │ STEP 3: Final sanity checks │
122
+ │ - Recheck CI status (in case just turned red) │
123
+ │ - Verify approving reviewer is actually tech-lead role │
124
+ │ - Verify no new unresolved comments since approval │
125
+ ├──────────────────────────────────────────────────────────┤
126
+ │ STEP 4: Prepare merge message │
127
+ │ Format (squash): │
128
+ │ <type>(TICKET-XXX): <PR title> (#PR_NUMBER) │
129
+ │ │
130
+ │ <PR description summary - first paragraph> │
131
+ │ │
132
+ │ Refs: ADR-XXXX (if any) │
133
+ │ Closes: TICKET-XXX │
134
+ │ Reviewed-by: <tech-lead-handle> │
135
+ ├──────────────────────────────────────────────────────────┤
136
+ │ STEP 5: Execute merge │
137
+ │ gh pr merge $PR_NUMBER \ │
138
+ │ --<strategy> \ │
139
+ │ --subject "<merge subject>" \ │
140
+ │ --body "<merge body>" \ │
141
+ │ --delete-branch │
142
+ ├──────────────────────────────────────────────────────────┤
143
+ │ STEP 6: Verify merge success │
144
+ │ - Check PR status = MERGED │
145
+ │ - Check branch deleted │
146
+ │ - Check commit in develop history │
147
+ ├──────────────────────────────────────────────────────────┤
148
+ │ STEP 7: Update ticket │
149
+ │ - state: IN_REVIEW → QA │
150
+ │ - merge_commit_sha: <sha> │
151
+ │ - merged_at: <timestamp> │
152
+ │ - state_history append │
153
+ ├──────────────────────────────────────────────────────────┤
154
+ │ STEP 8: Notify QA │
155
+ │ - Suggest: /smoke-test TICKET-XXX │
156
+ │ - (Optional) Slack notification │
157
+ ├──────────────────────────────────────────────────────────┤
158
+ │ STEP 9: Log metrics │
159
+ ├──────────────────────────────────────────────────────────┤
160
+ │ STEP 10: Output summary │
161
+ └──────────────────────────────────────────────────────────┘
162
+ ```
163
+
164
+ ## 🔒 Hard Rules
165
+
166
+ ### RULE MP-001: Only tech-lead merges
167
+ `/merge-pr` **MUST** be invoked by tech-lead agent. Developer cannot merge.
168
+
169
+ ### RULE MP-002: No self-merge
170
+ **MUST NOT** merge PR authored by the merger. Per RULE TL-005.
171
+
172
+ ### RULE MP-003: All gates must be green
173
+ **MUST NOT** override:
174
+ - Failing CI (even "flaky" — fix flakiness first)
175
+ - Missing approval
176
+ - Unresolved comments
177
+ - Ticket wrong state
178
+
179
+ No `--force` flag exists for a reason.
180
+
181
+ ### RULE MP-004: Squash by default
182
+ Default strategy = `squash` (per RULE GIT-008). Keeps develop history clean.
183
+
184
+ **Exceptions** (use merge commit):
185
+ - Release PRs (develop → main)
186
+ - PRs with valuable commit history (ADR: document decision)
187
+
188
+ ### RULE MP-005: Delete branch after merge
189
+ **MUST** delete source branch. Enforce via `--delete-branch` flag.
190
+
191
+ ### RULE MP-006: Hotfix special flow
192
+ If branch is `hotfix/*`:
193
+ - Base = `main` (not develop)
194
+ - After merge to main → MUST trigger cherry-pick to develop
195
+ - See `commands/release/hotfix.md`
196
+
197
+ ### RULE MP-007: Ticket transition mandatory
198
+ **MUST** update ticket IN_REVIEW → QA. Not PR merged is a BUG state.
199
+
200
+ ### RULE MP-008: Audit trail
201
+ **MUST** log merge event:
202
+ - Who merged
203
+ - When
204
+ - Which PR/ticket
205
+ - Merge commit SHA
206
+ - Strategy used
207
+
208
+ Store in `project/audit-log.jsonl`.
209
+
210
+ ### RULE MP-009: Rollback plan for risky merges
211
+ If PR flagged as `high-risk` (auth changes, DB migration, payment):
212
+ - Document rollback plan in merge comment
213
+ - Notify scrum-master
214
+
215
+ ### RULE MP-010: No merge Friday afternoon (configurable)
216
+ If project policy: `config.merge_freeze.friday_afternoon: true`:
217
+ - Block merges Friday 15:00+ (unless hotfix)
218
+ - Rationale: avoid weekend fire
219
+
220
+ Configurable in `project-config.yaml`.
221
+
222
+ ## 📥 Input Examples
223
+
224
+ ```
225
+ /merge-pr 123 # Standard squash merge
226
+ /merge-pr 123 --strategy=merge # Preserve history (release PR)
227
+ /merge-pr 123 --force-flaky # NOT ALLOWED - no such flag
228
+ ```
229
+
230
+ ## 📤 Output Format (Success)
231
+
232
+ ```markdown
233
+ ## ✅ PR Merged: #123
234
+
235
+ **PR**: feat(TICKET-042): add password reset via email
236
+ **Branch**: feature/TICKET-042-password-reset → develop
237
+ **Merged by**: tech-lead-agent
238
+ **Strategy**: squash
239
+ **Merge commit**: abc1234def5678 on develop
240
+
241
+ ### Pre-merge Verification
242
+ | Check | Status |
243
+ |-------|--------|
244
+ | CI | ✅ All green (47 checks) |
245
+ | Approvals | ✅ 1 (tech-lead) |
246
+ | Comments | ✅ All resolved |
247
+ | Conflicts | ✅ None (auto-merge clean) |
248
+ | Up-to-date | ✅ Rebased on develop@xyz890 |
249
+
250
+ ### Merge Message
251
+ ```
252
+ feat(TICKET-042): add password reset via email (#123)
253
+
254
+ Implements self-service password reset flow with email verification:
255
+ - New endpoint POST /auth/request-reset
256
+ - Rate limiting 5/hour/email
257
+ - Secure 32-byte tokens, 24h expiration
258
+ - SendGrid email integration
259
+
260
+ Refs: ADR-0012
261
+ Closes: TICKET-042
262
+ Reviewed-by: tech-lead-agent
263
+ ```
264
+
265
+ ### Post-merge Actions
266
+ - ✅ Source branch deleted (remote + suggest local cleanup)
267
+ - ✅ CI triggered on develop (build + integration tests)
268
+ - ✅ Ticket TICKET-042 transitioned IN_REVIEW → QA
269
+ - ✅ Notification sent (Slack #releases)
270
+
271
+ ### Ticket Updated
272
+ ```json
273
+ {
274
+ "id": "TICKET-042",
275
+ "status": "QA",
276
+ "merge_info": {
277
+ "pr_number": 123,
278
+ "merge_commit_sha": "abc1234",
279
+ "merged_at": "2026-04-18T16:30:00Z",
280
+ "merged_by": "tech-lead-agent",
281
+ "strategy": "squash"
282
+ }
283
+ }
284
+ ```
285
+
286
+ ### Audit Log Entry
287
+ ```json
288
+ {
289
+ "timestamp": "2026-04-18T16:30:00Z",
290
+ "event": "pr_merged",
291
+ "pr_number": 123,
292
+ "ticket_id": "TICKET-042",
293
+ "merger": "tech-lead-agent",
294
+ "author": "developer-agent",
295
+ "strategy": "squash",
296
+ "lines_changed": 279,
297
+ "commits_squashed": 7
298
+ }
299
+ ```
300
+
301
+ ### Next Steps
302
+ 1. **QA**: `/smoke-test TICKET-042` on next deploy to staging
303
+ 2. **Developer**: Local cleanup - `git branch -D feature/TICKET-042-password-reset`
304
+ 3. **Scrum Master**: Update sprint board if using external tracker
305
+
306
+ ### Deployment
307
+ - **Next deploy window**: Staging daily auto-deploy at 18:00 UTC
308
+ - **Production**: Next release train (Tuesday)
309
+
310
+ ---
311
+ HANDOFF → qa-tester
312
+ Action needed: /smoke-test TICKET-042 after staging deploy
313
+ ```
314
+
315
+ ## 📤 Output Format (Failure)
316
+
317
+ ```markdown
318
+ ## ❌ Cannot Merge PR #123
319
+
320
+ **Blockers**:
321
+ 1. CI failing (2 checks red)
322
+ 2. 1 unresolved review comment
323
+
324
+ ### Details
325
+
326
+ #### Blocker 1: CI failing
327
+ - `lint` ✅
328
+ - `unit-tests` ✅
329
+ - `integration-tests` ❌ (2 failures)
330
+ - `e2e-tests` ❌ (timeout)
331
+
332
+ **Action**: Check CI output, fix failures, push again.
333
+
334
+ #### Blocker 2: Unresolved comment
335
+ - Tech-lead comment on `src/auth/reset.ts:45` marked CHANGES_REQUESTED
336
+ - Not yet resolved
337
+
338
+ **Action**: Developer address comment, reply "Resolved" or update code.
339
+
340
+ ### State
341
+ - PR: remains OPEN (unchanged)
342
+ - Ticket: remains IN_REVIEW (unchanged)
343
+
344
+ ### Retry
345
+ Once blockers resolved:
346
+ ```
347
+ /merge-pr 123
348
+ ```
349
+ ```
350
+
351
+ ## 📤 Output Format (Self-merge attempt)
352
+
353
+ ```markdown
354
+ ## ❌ Cannot Merge Own PR
355
+
356
+ **Reason**: You are the PR author.
357
+
358
+ Per RULE TL-005: Tech lead cannot approve/merge own PR.
359
+
360
+ ### Options
361
+ 1. **Request review from another tech-lead** (if available)
362
+ 2. **Escalate to human** (solo tech-lead scenario)
363
+ 3. **Pair with a developer** on next PR (shared ownership)
364
+
365
+ ### State
366
+ Unchanged. PR remains OPEN.
367
+ ```
368
+
369
+ ## 🚨 Failure Modes
370
+
371
+ | Scenario | Action |
372
+ |----------|--------|
373
+ | PR closed | ABORT |
374
+ | PR already merged | Notify, exit gracefully |
375
+ | CI red | ABORT, show which checks |
376
+ | No approval | ABORT, request /techlead-review |
377
+ | Self-merge | ABORT with RULE TL-005 |
378
+ | Conflicts | ABORT, instruct rebase |
379
+ | Ticket wrong state | ABORT, show expected state |
380
+ | Merge API fails | Retry 3x, escalate on persist |
381
+ | Branch deletion fails | Non-fatal, log warning |
382
+ | Ticket update fails | CRITICAL - manually sync |
383
+
384
+ ## 🔗 Related Commands
385
+
386
+ - **Before**: `/techlead-review` (approval required)
387
+ - **After**: `/smoke-test` (QA's next step)
388
+ - **Alternatives**:
389
+ - `/hotfix` (for emergency merges to main)
390
+ - **Rollback**: `git revert <merge_sha>` + create new PR
391
+
392
+ ## 📊 Metrics Tracked
393
+
394
+ ```json
395
+ {
396
+ "timestamp": "2026-04-18T16:30:00Z",
397
+ "pr_number": 123,
398
+ "ticket_id": "TICKET-042",
399
+ "merger": "tech-lead-agent",
400
+ "duration_from_pr_created_hours": 26.5,
401
+ "duration_from_approval_hours": 2.3,
402
+ "review_iterations": 1,
403
+ "strategy": "squash",
404
+ "commits_squashed": 7,
405
+ "lines_added": 234,
406
+ "lines_removed": 45,
407
+ "size_category": "M"
408
+ }
409
+ ```
410
+
411
+ ## 💡 Best Practices
412
+
413
+ **For Tech Leads**:
414
+ - Merge within 1 hour of final approval (keep momentum)
415
+ - Don't accumulate PRs waiting to merge (context switch)
416
+ - Communicate if delaying merge (dev waiting)
417
+
418
+ **For Developers (your PR about to merge)**:
419
+ - Keep terminal open, watch for merge notification
420
+ - Clean local branch after: `git checkout develop && git pull && git branch -D <feature>`
421
+ - Celebrate small wins 🎉
422
+
423
+ ---
424
+ **Last updated**: 2026-04-18
425
+ **Maintainer**: Tech Lead