feat: add Stop hook example policy (closes #40)#409
Conversation
New file: examples/policies-stop.js Demonstrates intercepting the Stop event to: - Block the stop if there are uncommitted git changes - Allow the stop and log a task-completion summary otherwise Both code paths have inline comments explaining *why* each decision is made.
📝 WalkthroughWalkthroughAdds a new example policy hook, ChangesStop Event Policy Example
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
examples/policies-stop.js (1)
27-27: 💤 Low valueRemove unnecessary
asynckeyword.The function body uses only synchronous operations (
execSync,appendFileSync) and never awaits. Declaring the function asasyncis misleading.♻️ Simplify function signature
- fn: async (ctx) => { + fn: (ctx) => {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@examples/policies-stop.js` at line 27, The policy handler "fn" is declared async but contains only synchronous calls (execSync, appendFileSync) and never awaits; remove the unnecessary async keyword from the "fn" function declaration (change "fn: async (ctx) => { ... }" to "fn: (ctx) => { ... }") to avoid misleading callers and potential unneeded Promise wrapping, and confirm there are no await usages inside the function before committing the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@examples/policies-stop.js`:
- Line 27: The policy handler "fn" is declared async but contains only
synchronous calls (execSync, appendFileSync) and never awaits; remove the
unnecessary async keyword from the "fn" function declaration (change "fn: async
(ctx) => { ... }" to "fn: (ctx) => { ... }") to avoid misleading callers and
potential unneeded Promise wrapping, and confirm there are no await usages
inside the function before committing the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a496c0b5-8ecc-4b4e-a280-86122e50a921
📒 Files selected for processing (1)
examples/policies-stop.js
|
Hey @NiveditJain 👋 I've raised a PR for this: 409 It adds examples/policies-stop.js covering all four acceptance criteria: ✅ Runnable with failproofai p -i -c |
New file: examples/policies-stop.js
Demonstrates intercepting the Stop event to:
Block the stop if there are uncommitted git changes
Allow the stop and log a task-completion summary otherwise
Both code paths have inline comments explaining why each decision is made.
Description
Type of Change
Checklist
npm run lintpassesnpx tsc --noEmitpassesnpm run test:runpassesnpm run buildsucceedsSummary by CodeRabbit