cursordoctrine 0.1.0 → 0.1.1

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.
@@ -83,8 +83,17 @@ if [ -z "$body" ]; then
83
83
  drop premature abstraction, unneeded deps, redundant comments, dead helpers.
84
84
  Fix now, re-run the scan + tests, then stop. If an axis is clean, say so in one line.'
85
85
  fi
86
-
87
- file_list="$(printf '%s\n' "$edited" | head -n 30 | sed 's/^/ /')"
86
+ body="$(expand_agent_paths "$body")"
87
+
88
+ file_list=""
89
+ while IFS= read -r p; do
90
+ [ -n "$p" ] || continue
91
+ rp="$(resolve_agent_path "$p")"
92
+ file_list="${file_list} ${rp}"$'\n'
93
+ done <<EOF
94
+ $edited
95
+ EOF
96
+ file_list="$(printf '%s' "$file_list" | head -n 30)"
88
97
  msg="FINAL REVIEW (end of implementation) - correctness, reliability, coverage, anti-slop.
89
98
 
90
99
  Files you changed this session:
@@ -87,6 +87,24 @@ is_cursor_config_path() {
87
87
  esac
88
88
  }
89
89
 
90
+ # Expand ~/ in agent-facing text to an absolute profile path (bash expands ~,
91
+ # but stop-hook followups should still emit literals agents can copy-paste).
92
+ expand_agent_paths() {
93
+ local text="$1"
94
+ local home="${HOME%/}"
95
+ text="${text//\~\//$home/}"
96
+ printf '%s' "$text"
97
+ }
98
+
99
+ # Normalize a file path for agent prompts (expand ~).
100
+ resolve_agent_path() {
101
+ local p="$1"
102
+ case "$p" in
103
+ "~/"*) printf '%s' "$HOME/${p#~/}" ;;
104
+ *) printf '%s' "$p" ;;
105
+ esac
106
+ }
107
+
90
108
  # merge_subagent_edit_markers <json> <parent_cid> -> 0 if anything was folded
91
109
  #
92
110
  # Subagent edits fire afterFileEdit under the SUBAGENT's conversation_id, so
@@ -24,7 +24,8 @@ cid="$(safe_conversation_id "$input")"
24
24
 
25
25
  fold_note=""
26
26
  if merge_subagent_edit_markers "$input" "$cid"; then
27
- fold_note="SUBAGENT WORK DETECTED - a subagent of this conversation edited files (its edits fired hooks in ITS context, not yours). YOU are the auditor of its work: audit its diff (git status / git diff on the files it touched) against ~/.agents/hooks/self-review.md. Fix real bugs; stay silent otherwise. Its files are folded into this conversation's end-of-implementation review."
27
+ self_review="$(expand_agent_paths "$HOME/.agents/hooks/self-review.md")"
28
+ fold_note="SUBAGENT WORK DETECTED - a subagent of this conversation edited files (its edits fired hooks in ITS context, not yours). YOU are the auditor of its work: audit its diff (git status / git diff on the files it touched) against $self_review. Fix real bugs; stay silent otherwise. Its files are folded into this conversation's end-of-implementation review."
28
29
  fi
29
30
 
30
31
  pending_file="$(hooks_pending_dir)/feedback-$cid.txt"
@@ -73,12 +73,22 @@ behaviour the task asked for):
73
73
  1. Correctness - logic, edge cases (null/empty/zero/boundary), language traps, security.
74
74
  2. Reliability - error paths handled, no swallowed errors, resources released.
75
75
  3. Coverage - behaviour-bearing changes have real tests; RUN the suite if present.
76
- 4. Anti-slop - no duplicate helpers, premature abstraction, unneeded deps,
77
- redundant comments, dead code.
76
+ 4. Anti-slop - if ~/.cursor/skills/anti-slop/scripts/scan_slop.py exists, run
77
+ `python ~/.cursor/skills/anti-slop/scripts/scan_slop.py --all`; otherwise
78
+ apply ~/.agents/hooks/anti-slop.md to the session diff.
78
79
  If an axis is clean, say so in one line. Then stop.'
79
80
  fi
81
+ body="$(expand_agent_paths "$body")"
80
82
 
81
- file_list="$(printf '%s\n' "$edited" | head -n 30 | sed 's/^/ /')"
83
+ file_list=""
84
+ while IFS= read -r p; do
85
+ [ -n "$p" ] || continue
86
+ rp="$(resolve_agent_path "$p")"
87
+ file_list="${file_list} ${rp}"$'\n'
88
+ done <<EOF
89
+ $edited
90
+ EOF
91
+ file_list="$(printf '%s' "$file_list" | head -n 30)"
82
92
  msg="SUBAGENT FINAL REVIEW - you just finished delegated implementation work. Before your result returns to the parent agent, audit it.
83
93
 
84
94
  Files you changed this run:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cursordoctrine",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Thin self-review hooks for Cursor — the model is the auditor. One command installs the doctrine, the hook pack, and the anti-slop skill.",
5
5
  "bin": {
6
6
  "cursordoctrine": "bin/cli.mjs"
@@ -94,12 +94,14 @@ FINAL REVIEW - audit everything you changed this session and FIX what fails
94
94
  Fix now, re-run the scan + tests, then stop. If an axis is clean, say so in one line.
95
95
  '@
96
96
  }
97
+ $body = Expand-AgentPaths $body
97
98
 
98
- $fileList = ($edited | Select-Object -First 30) -join "`n "
99
+ $resolved = @($edited | ForEach-Object { Resolve-AgentPath $_ })
100
+ $fileList = ($resolved | Select-Object -First 30) -join "`n "
99
101
  $msg = "FINAL REVIEW (end of implementation) - correctness, reliability, coverage, anti-slop.`n`nFiles you changed this session:`n $fileList`n`n$body"
100
102
 
101
103
  # Arm the one-shot brake BEFORE emitting, so a crash after emit can't re-fire.
102
- try { New-Item -ItemType File -Path $flag -Force | Out-Null } catch { }
104
+ New-Item -ItemType File -Path $flag -Force -ErrorAction SilentlyContinue | Out-Null
103
105
 
104
106
  Write-HookJson @{ followup_message = $msg }
105
107
  exit 0
@@ -51,6 +51,28 @@ function ConvertTo-FwdPath([string]$p) {
51
51
  return $p.Replace('\', '/')
52
52
  }
53
53
 
54
+ # Expand ~/ in agent-facing text to an absolute profile path. pwsh and many
55
+ # agent tools do not resolve ~ on Windows; stop-hook followups must be literal.
56
+ function Expand-AgentPaths([string]$text) {
57
+ if (-not $text) { return $text }
58
+ $homeFwd = $HOME.TrimEnd('\', '/').Replace('\', '/')
59
+ return $text.Replace('~/', "$homeFwd/")
60
+ }
61
+
62
+ # Normalize a file path for agent prompts (expand ~, forward slashes).
63
+ function Resolve-AgentPath([string]$p) {
64
+ if (-not $p) { return $p }
65
+ $p = $p.Trim()
66
+ if ($p -match '^~[\\/]') {
67
+ $p = Join-Path $HOME ($p.Substring(2))
68
+ }
69
+ if (Test-Path -LiteralPath $p -ErrorAction SilentlyContinue) {
70
+ $resolved = Resolve-Path -LiteralPath $p -ErrorAction SilentlyContinue
71
+ if ($resolved) { return ConvertTo-FwdPath $resolved.Path }
72
+ }
73
+ return ConvertTo-FwdPath $p
74
+ }
75
+
54
76
  # Subagent edits fire afterFileEdit under the SUBAGENT's conversation_id, so
55
77
  # their session-edits markers are invisible to the parent's stop-hook review.
56
78
  # Subagent transcripts live at <transcripts>/<parent-cid>/subagents/<sub-cid>.jsonl,
@@ -23,7 +23,8 @@ $cid = Get-SafeConversationId $obj
23
23
 
24
24
  $foldNote = ''
25
25
  if (Merge-SubagentEditMarkers $obj $cid) {
26
- $foldNote = "SUBAGENT WORK DETECTED - a subagent of this conversation edited files (its edits fired hooks in ITS context, not yours). YOU are the auditor of its work: audit its diff (git status / git diff on the files it touched) against ~/.agents/hooks/self-review.md. Fix real bugs; stay silent otherwise. Its files are folded into this conversation's end-of-implementation review."
26
+ $selfReview = Expand-AgentPaths (Join-Path $HOME '.agents/hooks/self-review.md')
27
+ $foldNote = "SUBAGENT WORK DETECTED - a subagent of this conversation edited files (its edits fired hooks in ITS context, not yours). YOU are the auditor of its work: audit its diff (git status / git diff on the files it touched) against $selfReview. Fix real bugs; stay silent otherwise. Its files are folded into this conversation's end-of-implementation review."
27
28
  }
28
29
 
29
30
  $pendingFile = Join-Path (Get-HooksPendingDir) "feedback-$cid.txt"
@@ -73,13 +73,16 @@ behaviour the task asked for):
73
73
  1. Correctness - logic, edge cases (null/empty/zero/boundary), language traps, security.
74
74
  2. Reliability - error paths handled, no swallowed errors, resources released.
75
75
  3. Coverage - behaviour-bearing changes have real tests; RUN the suite if present.
76
- 4. Anti-slop - no duplicate helpers, premature abstraction, unneeded deps,
77
- redundant comments, dead code.
76
+ 4. Anti-slop - if ~/.cursor/skills/anti-slop/scripts/scan_slop.py exists, run
77
+ `python ~/.cursor/skills/anti-slop/scripts/scan_slop.py --all`; otherwise
78
+ apply ~/.agents/hooks/anti-slop.md to the session diff.
78
79
  If an axis is clean, say so in one line. Then stop.
79
80
  '@
80
81
  }
82
+ $body = Expand-AgentPaths $body
81
83
 
82
- $fileList = ($edited | Select-Object -First 30) -join "`n "
84
+ $resolved = @($edited | ForEach-Object { Resolve-AgentPath $_ })
85
+ $fileList = ($resolved | Select-Object -First 30) -join "`n "
83
86
  $msg = "SUBAGENT FINAL REVIEW - you just finished delegated implementation work. Before your result returns to the parent agent, audit it.`n`nFiles you changed this run:`n $fileList`n`n$body"
84
87
 
85
88
  # Arm the one-shot brake BEFORE emitting, so a crash after emit can't re-fire.