cursordoctrine 0.2.1 → 0.2.3

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.
@@ -159,6 +159,9 @@ try:
159
159
  q = m.group(1).strip()
160
160
  if len(q) > 2000:
161
161
  q = q[:2000] + "..."
162
+ q = re.sub(r"\bnpm_[A-Za-z0-9]{10,}\b", "[REDACTED_NPM_TOKEN]", q)
163
+ q = re.sub(r"\b(sk-[A-Za-z0-9]{10,}|ghp_[A-Za-z0-9]{20,}|gho_[A-Za-z0-9]{20,})\b", "[REDACTED_TOKEN]", q)
164
+ q = re.sub(r"(?i)(api[_-]?key|token|secret|password)\s*[:=]\s*\S+", r"\1=[REDACTED]", q)
162
165
  print(q)
163
166
  break
164
167
  except Exception:
@@ -172,6 +175,7 @@ except Exception:
172
175
  printf '%s' "$reversed" |
173
176
  grep -m1 -oE '<user_query>[^<]*</user_query>' 2>/dev/null |
174
177
  sed -E 's@</?user_query>@@g' |
178
+ sed -E 's/\bnpm_[A-Za-z0-9]{10,}\b/[REDACTED_NPM_TOKEN]/g' |
175
179
  head -c 2000
176
180
  }
177
181
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cursordoctrine",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Thin self-review hooks for Cursor — the model is the auditor. Intent-trace final review (Tier 0), unified 13-item anti-slop checklist, operational slop detection.",
5
5
  "bin": {
6
6
  "cursordoctrine": "bin/cli.mjs"
@@ -635,13 +635,15 @@ def collect_defs(rel: str, lines: list[str]) -> list[Finding]:
635
635
  nb = normalize_body(raw, lang)
636
636
  sb = structural_body(raw, lang)
637
637
  # Non-blank lines only: the brace walk pads raw with edge newlines,
638
- # and counting them would let `super(props);` pass the 3-line floor.
638
+ # and counting them would let `super(props);` pad its body_line count.
639
639
  body_lines = sum(1 for s in raw.splitlines() if s.strip()) or 1
640
- # Exact-dup hash needs substance (>=3 lines or >=60 chars): one-line
641
- # boilerplate like `super(props);` is not knowledge worth consolidating.
640
+ # Exact-dup hash needs substance (>=12 normalized chars). An earlier
641
+ # >=3-lines-or->=60-chars floor excluded the skill's own marquee case -
642
+ # tiny predicates like isRecord/isObject (1 line, ~40 chars) whose
643
+ # byte-identical bodies are exactly the duplication worth surfacing.
644
+ # Boilerplate like `return;`/`return x;` stays under the 12-char floor.
642
645
  # A truncated body is a prefix, not the function - never call it exact.
643
- hash_exact = (not truncated and len(nb) >= 12
644
- and (body_lines >= 3 or len(nb) >= 60))
646
+ hash_exact = (not truncated and len(nb) >= 12)
645
647
  defs.append({
646
648
  "name": name, "file": rel, "line": i + 1,
647
649
  "exported": _is_exported(name, ln, lang),
@@ -73,7 +73,17 @@ function Resolve-AgentPath([string]$p) {
73
73
  return ConvertTo-FwdPath $p
74
74
  }
75
75
 
76
- # Extract the last user <user_query> from a Cursor transcript JSONL. The
76
+ # Strip secrets from text before embedding in agent-facing followups. Intent
77
+ # trace must not re-broadcast tokens the user pasted in chat.
78
+ function Redact-SecretsFromIntent([string]$text) {
79
+ if (-not $text) { return $text }
80
+ $text = $text -replace '\bnpm_[A-Za-z0-9]{10,}\b', '[REDACTED_NPM_TOKEN]'
81
+ $text = $text -replace '\b(sk-[A-Za-z0-9]{10,}|ghp_[A-Za-z0-9]{20,}|gho_[A-Za-z0-9]{20,})\b', '[REDACTED_TOKEN]'
82
+ $text = $text -replace '(?i)(api[_-]?key|token|secret|password)\s*[:=]\s*\S+', '$1=[REDACTED]'
83
+ return $text
84
+ }
85
+
86
+ # Extract the last user <user_query> from a Cursor transcript JSONL.
77
87
  # transcript is an array of {role, message} records; we walk backward from the
78
88
  # end, find the last user turn whose content has a <user_query> tag, and return
79
89
  # its text. Returns '' if there is no transcript or no user_query. Capped at
@@ -108,7 +118,7 @@ function Get-LastUserQuery($obj) {
108
118
  if ($text -match '(?s)<user_query>\s*(.+?)\s*</user_query>') {
109
119
  $q = $Matches[1].Trim()
110
120
  if ($q.Length -gt 2000) { $q = $q.Substring(0, 2000) + '...' }
111
- return $q
121
+ return (Redact-SecretsFromIntent $q)
112
122
  }
113
123
  }
114
124
  return ''