@misterhuydo/sentinel 1.4.44 → 1.4.45

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.
@@ -1,6 +1,6 @@
1
1
  {
2
- "message": "Auto-checkpoint at 2026-03-25T10:07:47.873Z",
3
- "checkpoint_at": "2026-03-25T10:07:47.874Z",
2
+ "message": "Auto-checkpoint at 2026-03-25T10:19:44.042Z",
3
+ "checkpoint_at": "2026-03-25T10:19:44.043Z",
4
4
  "active_files": [],
5
5
  "notes": [],
6
6
  "mtime_snapshot": {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@misterhuydo/sentinel",
3
- "version": "1.4.44",
3
+ "version": "1.4.45",
4
4
  "description": "Sentinel — Autonomous DevOps Agent installer and manager",
5
5
  "bin": {
6
6
  "sentinel": "./bin/sentinel.js"
@@ -129,6 +129,29 @@ def _build_prompt(event, repo: RepoConfig, log_file, marker: str, stale_markers:
129
129
  ]
130
130
  return "\n".join(lines_out)
131
131
 
132
+ def _fix_blank_context_lines(patch: str) -> str:
133
+ """
134
+ Ensure blank context lines inside hunks have a leading space.
135
+ Claude sometimes outputs empty lines in hunk bodies as bare '\\n'
136
+ instead of ' \\n', which causes git-apply to report 'corrupt patch'.
137
+ """
138
+ lines = patch.splitlines()
139
+ result = []
140
+ in_hunk = False
141
+ for line in lines:
142
+ if line.startswith("@@"):
143
+ in_hunk = True
144
+ result.append(line)
145
+ elif line.startswith(("diff ", "--- ", "+++ ", "index ")):
146
+ in_hunk = False
147
+ result.append(line)
148
+ elif in_hunk and line == "":
149
+ result.append(" ")
150
+ else:
151
+ result.append(line)
152
+ return "\n".join(result) + "\n"
153
+
154
+
132
155
  def _validate_patch(patch: str) -> tuple[bool, str]:
133
156
  files_changed = len(re.findall(r"^diff --git", patch, re.MULTILINE))
134
157
  lines_changed = len([
@@ -338,6 +361,8 @@ def generate_fix(
338
361
  logger.warning("No patch found in Claude output for %s", event.fingerprint)
339
362
  return "error", None, ""
340
363
 
364
+ patch = _fix_blank_context_lines(patch)
365
+
341
366
  ok, reason = _validate_patch(patch)
342
367
  if not ok:
343
368
  logger.warning("Patch rejected for %s: %s", event.fingerprint, reason)