failproofai 0.0.4 → 0.0.5

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 (151) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +3 -3
  3. package/.next/standalone/.next/prerender-manifest.json +3 -3
  4. package/.next/standalone/.next/required-server-files.json +1 -1
  5. package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
  6. package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
  7. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
  10. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +2 -2
  11. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
  12. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +3 -3
  13. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +3 -3
  14. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  15. package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
  16. package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  17. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  18. package/.next/standalone/.next/server/app/_not-found.html +2 -2
  19. package/.next/standalone/.next/server/app/_not-found.rsc +15 -15
  20. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +15 -15
  21. package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
  22. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +10 -10
  23. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  24. package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  25. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  26. package/.next/standalone/.next/server/app/index.html +1 -1
  27. package/.next/standalone/.next/server/app/index.rsc +15 -15
  28. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  29. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +15 -15
  30. package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +4 -4
  31. package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +10 -10
  32. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  33. package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
  34. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  35. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  36. package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +8 -8
  37. package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
  38. package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
  39. package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
  40. package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
  41. package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
  42. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
  43. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
  44. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
  45. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
  46. package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
  47. package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
  48. package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  49. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0g72weg._.js +1 -1
  50. package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_0z7w.hh._.js +1 -1
  51. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__092s1ta._.js +2 -2
  52. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__09icjsf._.js +2 -2
  53. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0v1egkj._.js → [root-of-the-server]__0a~g15g._.js} +2 -2
  54. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0g.lg8b._.js +2 -2
  55. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0h..k-e._.js +2 -2
  56. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0okos0k._.js +2 -2
  57. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0lty_fo._.js → [root-of-the-server]__0qn95h3._.js} +2 -2
  58. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0w6l33k._.js +2 -2
  59. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__11pa2ra._.js +2 -2
  60. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__12t-wym._.js +2 -2
  61. package/.next/standalone/.next/server/chunks/ssr/_10lm7or._.js +2 -2
  62. package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_0xerkr6._.js +1 -1
  63. package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_0q-m0y-._.js +1 -1
  64. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  65. package/.next/standalone/.next/server/pages/404.html +2 -2
  66. package/.next/standalone/.next/server/pages/500.html +1 -1
  67. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  68. package/.next/standalone/.next/server/server-reference-manifest.json +9 -9
  69. package/.next/standalone/.next/static/chunks/{0de3q2juhg_dr.js → 09ikntpt2-o9b.js} +1 -1
  70. package/.next/standalone/.next/static/chunks/{11zlh73ggln0w.js → 0_yayar~bpphd.js} +1 -1
  71. package/.next/standalone/.next/static/chunks/{0b2_069x5qnxg.js → 0em7tspi4kylh.js} +2 -2
  72. package/.next/standalone/.next/static/chunks/{0y-bi_mp2rv4l.js → 0lgbwkfqmnsmc.js} +1 -1
  73. package/.next/standalone/.next/static/chunks/{0uxpbrcv44lga.js → 0sme4lkv.tgn-.js} +1 -1
  74. package/.next/standalone/.next/static/chunks/{0tw_xfxb1tto..js → 0yumumfzx_f27.js} +1 -1
  75. package/.next/standalone/.next/static/chunks/{0p5sfob-upg0g.js → 13juklu.vksks.js} +1 -1
  76. package/.next/standalone/.next/static/chunks/17manv47o-~wp.js +1 -0
  77. package/.next/standalone/CHANGELOG.md +9 -0
  78. package/.next/standalone/README.md +2 -2
  79. package/.next/standalone/dist/cli.mjs +52 -11
  80. package/.next/standalone/docs/ar/architecture.mdx +2 -2
  81. package/.next/standalone/docs/ar/configuration.mdx +1 -1
  82. package/.next/standalone/docs/ar/custom-policies.mdx +2 -5
  83. package/.next/standalone/docs/architecture.mdx +2 -2
  84. package/.next/standalone/docs/configuration.mdx +1 -1
  85. package/.next/standalone/docs/custom-policies.mdx +2 -6
  86. package/.next/standalone/docs/de/architecture.mdx +2 -2
  87. package/.next/standalone/docs/de/configuration.mdx +1 -1
  88. package/.next/standalone/docs/de/custom-policies.mdx +2 -5
  89. package/.next/standalone/docs/es/architecture.mdx +2 -2
  90. package/.next/standalone/docs/es/configuration.mdx +1 -1
  91. package/.next/standalone/docs/es/custom-policies.mdx +2 -5
  92. package/.next/standalone/docs/fr/architecture.mdx +2 -2
  93. package/.next/standalone/docs/fr/configuration.mdx +1 -1
  94. package/.next/standalone/docs/fr/custom-policies.mdx +2 -5
  95. package/.next/standalone/docs/he/architecture.mdx +2 -2
  96. package/.next/standalone/docs/he/configuration.mdx +1 -1
  97. package/.next/standalone/docs/he/custom-policies.mdx +2 -5
  98. package/.next/standalone/docs/hi/architecture.mdx +2 -2
  99. package/.next/standalone/docs/hi/configuration.mdx +1 -1
  100. package/.next/standalone/docs/hi/custom-policies.mdx +2 -5
  101. package/.next/standalone/docs/i18n/README.ar.md +2 -2
  102. package/.next/standalone/docs/i18n/README.de.md +2 -2
  103. package/.next/standalone/docs/i18n/README.es.md +2 -2
  104. package/.next/standalone/docs/i18n/README.fr.md +2 -2
  105. package/.next/standalone/docs/i18n/README.he.md +2 -2
  106. package/.next/standalone/docs/i18n/README.hi.md +2 -2
  107. package/.next/standalone/docs/i18n/README.it.md +2 -2
  108. package/.next/standalone/docs/i18n/README.ja.md +2 -2
  109. package/.next/standalone/docs/i18n/README.ko.md +2 -2
  110. package/.next/standalone/docs/i18n/README.pt-br.md +2 -2
  111. package/.next/standalone/docs/i18n/README.ru.md +2 -2
  112. package/.next/standalone/docs/i18n/README.tr.md +2 -2
  113. package/.next/standalone/docs/i18n/README.vi.md +2 -2
  114. package/.next/standalone/docs/i18n/README.zh.md +2 -2
  115. package/.next/standalone/docs/it/architecture.mdx +2 -2
  116. package/.next/standalone/docs/it/configuration.mdx +1 -1
  117. package/.next/standalone/docs/it/custom-policies.mdx +2 -5
  118. package/.next/standalone/docs/ja/architecture.mdx +2 -2
  119. package/.next/standalone/docs/ja/configuration.mdx +1 -1
  120. package/.next/standalone/docs/ja/custom-policies.mdx +2 -5
  121. package/.next/standalone/docs/ko/architecture.mdx +2 -2
  122. package/.next/standalone/docs/ko/configuration.mdx +1 -1
  123. package/.next/standalone/docs/ko/custom-policies.mdx +2 -5
  124. package/.next/standalone/docs/pt-br/architecture.mdx +2 -2
  125. package/.next/standalone/docs/pt-br/configuration.mdx +1 -1
  126. package/.next/standalone/docs/pt-br/custom-policies.mdx +2 -5
  127. package/.next/standalone/docs/ru/architecture.mdx +2 -2
  128. package/.next/standalone/docs/ru/configuration.mdx +1 -1
  129. package/.next/standalone/docs/ru/custom-policies.mdx +2 -5
  130. package/.next/standalone/docs/tr/architecture.mdx +2 -2
  131. package/.next/standalone/docs/tr/configuration.mdx +1 -1
  132. package/.next/standalone/docs/tr/custom-policies.mdx +2 -5
  133. package/.next/standalone/docs/vi/architecture.mdx +2 -2
  134. package/.next/standalone/docs/vi/configuration.mdx +1 -1
  135. package/.next/standalone/docs/vi/custom-policies.mdx +2 -5
  136. package/.next/standalone/docs/zh/architecture.mdx +2 -2
  137. package/.next/standalone/docs/zh/configuration.mdx +1 -1
  138. package/.next/standalone/docs/zh/custom-policies.mdx +2 -5
  139. package/.next/standalone/package.json +1 -1
  140. package/.next/standalone/server.js +1 -1
  141. package/.next/standalone/src/hooks/builtin-policies.ts +40 -8
  142. package/.next/standalone/src/hooks/policy-evaluator.ts +15 -1
  143. package/README.md +2 -2
  144. package/dist/cli.mjs +52 -11
  145. package/package.json +1 -1
  146. package/src/hooks/builtin-policies.ts +40 -8
  147. package/src/hooks/policy-evaluator.ts +15 -1
  148. package/.next/standalone/.next/static/chunks/0xjz3w.yw5tza.js +0 -1
  149. /package/.next/standalone/.next/static/{LayjxQulxIcNH19Lqgjbf → hYQM6iCWnF1W5XDpsIRhV}/_buildManifest.js +0 -0
  150. /package/.next/standalone/.next/static/{LayjxQulxIcNH19Lqgjbf → hYQM6iCWnF1W5XDpsIRhV}/_clientMiddlewareManifest.js +0 -0
  151. /package/.next/standalone/.next/static/{LayjxQulxIcNH19Lqgjbf → hYQM6iCWnF1W5XDpsIRhV}/_ssgManifest.js +0 -0
@@ -212,6 +212,36 @@ function getThirdPartyCheckRuns(cwd: string, sha: string): CiCheck[] {
212
212
  }
213
213
  }
214
214
 
215
+ /** Fetch commit statuses (legacy Status API) and normalize to CiCheck format. */
216
+ function getCommitStatuses(cwd: string, sha: string): CiCheck[] {
217
+ try {
218
+ const json = execFileSync(
219
+ "gh",
220
+ [
221
+ "api",
222
+ `repos/{owner}/{repo}/commits/${sha}/statuses`,
223
+ "--jq",
224
+ 'map({name: .context, state: .state}) | unique_by(.name)',
225
+ ],
226
+ {
227
+ cwd,
228
+ encoding: "utf8",
229
+ timeout: 15000,
230
+ },
231
+ ).trim();
232
+
233
+ if (!json || json === "[]") return [];
234
+ const statuses = JSON.parse(json) as Array<{ name: string; state: string }>;
235
+ return statuses.map((s) => ({
236
+ name: s.name,
237
+ status: s.state === "pending" ? "in_progress" : "completed",
238
+ conclusion: s.state === "pending" ? "" : s.state === "success" ? "success" : "failure",
239
+ }));
240
+ } catch {
241
+ return [];
242
+ }
243
+ }
244
+
215
245
  /**
216
246
  * Check if a command matches an allow pattern using token-by-token comparison.
217
247
  * The "*" token is a wildcard. Extra command tokens beyond the pattern are allowed,
@@ -859,7 +889,7 @@ function requireCommitBeforeStop(ctx: PolicyContext): PolicyResult {
859
889
 
860
890
  if (status.length > 0) {
861
891
  return deny(
862
- "You have uncommitted changes in the working directory. Commit all changes before stopping.",
892
+ "You have uncommitted changes in the working directory. Commit all changes now.",
863
893
  );
864
894
  }
865
895
  return allow("All changes are committed.");
@@ -937,7 +967,7 @@ function requirePushBeforeStop(ctx: PolicyContext): PolicyResult {
937
967
  if (!hasTracking) {
938
968
  return deny(
939
969
  `Branch "${branch}" has not been pushed to remote "${remote}". ` +
940
- `Push your branch with: git push -u ${remote} ${branch}`,
970
+ `Run now: git push -u ${remote} ${branch}`,
941
971
  );
942
972
  }
943
973
 
@@ -952,7 +982,7 @@ function requirePushBeforeStop(ctx: PolicyContext): PolicyResult {
952
982
  const commitCount = unpushed.split("\n").length;
953
983
  return deny(
954
984
  `You have ${commitCount} unpushed commit${commitCount > 1 ? "s" : ""} on branch "${branch}". ` +
955
- `Push your changes with: git push`,
985
+ `Run now: git push`,
956
986
  );
957
987
  }
958
988
 
@@ -1024,7 +1054,7 @@ function requirePrBeforeStop(ctx: PolicyContext): PolicyResult {
1024
1054
  // gh pr view exits non-zero when no PR exists
1025
1055
  return deny(
1026
1056
  `No pull request found for branch "${branch}". ` +
1027
- `Create one with: gh pr create`,
1057
+ `Run now: gh pr create`,
1028
1058
  );
1029
1059
  }
1030
1060
 
@@ -1035,7 +1065,7 @@ function requirePrBeforeStop(ctx: PolicyContext): PolicyResult {
1035
1065
  }
1036
1066
 
1037
1067
  return deny(
1038
- `Pull request for branch "${branch}" is ${pr.state.toLowerCase()}. Create a new PR with: gh pr create`,
1068
+ `Pull request for branch "${branch}" is ${pr.state.toLowerCase()}. Run now: gh pr create`,
1039
1069
  );
1040
1070
  } catch {
1041
1071
  return allow("Could not check PR status, skipping.");
@@ -1075,13 +1105,15 @@ function requireCiGreenBeforeStop(ctx: PolicyContext): PolicyResult {
1075
1105
 
1076
1106
  // 2. Third-party check runs (CodeRabbit, SonarCloud, Codecov, etc.)
1077
1107
  let thirdPartyChecks: CiCheck[] = [];
1108
+ let commitStatuses: CiCheck[] = [];
1078
1109
  const sha = getHeadSha(cwd);
1079
1110
  if (sha) {
1080
1111
  thirdPartyChecks = getThirdPartyCheckRuns(cwd, sha);
1112
+ commitStatuses = getCommitStatuses(cwd, sha);
1081
1113
  }
1082
1114
 
1083
1115
  // 3. Merge all checks
1084
- const allChecks = [...workflowRuns, ...thirdPartyChecks];
1116
+ const allChecks = [...workflowRuns, ...thirdPartyChecks, ...commitStatuses];
1085
1117
 
1086
1118
  if (allChecks.length === 0) return allow(`No CI runs found for branch "${branch}".`);
1087
1119
 
@@ -1091,7 +1123,7 @@ function requireCiGreenBeforeStop(ctx: PolicyContext): PolicyResult {
1091
1123
  if (failing.length > 0) {
1092
1124
  const names = failing.map((r) => `"${r.name}"`).join(", ");
1093
1125
  return deny(
1094
- `CI checks are failing on branch "${branch}": ${names}. Fix the failing checks before stopping.`,
1126
+ `CI checks are failing on branch "${branch}": ${names}. Fix the failing checks now.`,
1095
1127
  );
1096
1128
  }
1097
1129
 
@@ -1101,7 +1133,7 @@ function requireCiGreenBeforeStop(ctx: PolicyContext): PolicyResult {
1101
1133
  if (pending.length > 0) {
1102
1134
  const names = pending.map((r) => `"${r.name}"`).join(", ");
1103
1135
  return deny(
1104
- `CI checks are still running on branch "${branch}": ${names}. Wait for all checks to complete and verify they pass.`,
1136
+ `CI checks are still running on branch "${branch}": ${names}. Wait for all checks to complete, then verify they pass.`,
1105
1137
  );
1106
1138
  }
1107
1139
 
@@ -130,6 +130,17 @@ export async function evaluatePolicies(
130
130
  };
131
131
  }
132
132
 
133
+ if (eventType === "Stop") {
134
+ return {
135
+ exitCode: 2,
136
+ stdout: "",
137
+ stderr: `MANDATORY ACTION REQUIRED from failproofai (policy: ${policy.name}): ${reason}\n\nYou MUST complete the above action NOW. Do NOT ask the user for confirmation — execute the required action, then attempt to finish your task again.`,
138
+ policyName: policy.name,
139
+ reason,
140
+ decision: "deny",
141
+ };
142
+ }
143
+
133
144
  // Other event types: exit 2
134
145
  return {
135
146
  exitCode: 2,
@@ -165,10 +176,13 @@ export async function evaluatePolicies(
165
176
  if (eventType === "Stop") {
166
177
  // Stop hook: exitCode 2 blocks Claude from stopping.
167
178
  // Reason goes to stderr so Claude Code receives it as context.
179
+ const policyAttribution = policyNames.length === 1
180
+ ? `policy: ${policyNames[0]}`
181
+ : `policies: ${policyNames.join(", ")}`;
168
182
  return {
169
183
  exitCode: 2,
170
184
  stdout: "",
171
- stderr: combined,
185
+ stderr: `MANDATORY ACTION REQUIRED from failproofai (${policyAttribution}): ${combined}\n\nYou MUST complete the above action(s) NOW. Do NOT ask the user for confirmation — execute the required action(s), then attempt to finish your task again.`,
172
186
  policyName: policyNames[0],
173
187
  policyNames,
174
188
  reason: combined,
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,53348,e=>{"use strict";var r=e.i(43476),t=e.i(71645),n=e.i(5888),i=e.i(9969);e.s(["default",0,function({error:e,reset:o}){return(0,t.useEffect)(()=>{(0,n.getTelemetryConfig)().then(r=>{(0,i.setClientTelemetryConfig)(r),(0,i.captureClientEvent)("client_error",{error_message:e.message,error_name:e.name,error_digest:e.digest,boundary:"global"})}).catch(()=>{})},[e]),(0,r.jsx)("html",{children:(0,r.jsx)("body",{children:(0,r.jsx)("main",{style:{minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",background:"#031035",color:"#f8fafc",fontFamily:"system-ui, sans-serif"},children:(0,r.jsxs)("div",{style:{textAlign:"center",padding:"2rem",border:"1px solid rgba(239,68,68,0.4)",borderRadius:"0.5rem",maxWidth:"500px"},children:[(0,r.jsx)("h2",{style:{color:"#ef4444",marginBottom:"0.5rem",fontSize:"1.25rem"},children:"Something went wrong"}),(0,r.jsx)("p",{style:{color:"#94a3b8",marginBottom:"1.5rem"},children:e.message||"An unexpected error occurred."}),(0,r.jsx)("button",{onClick:o,style:{padding:"0.5rem 1.25rem",background:"#3b82f6",color:"white",border:"none",borderRadius:"0.375rem",cursor:"pointer",fontSize:"0.875rem"},children:"Try again"})]})})})})}])}]);