Skip to content

Add insights-context skill with cross-referenced friction resolution - #1

Merged
RasputinKaiser merged 1 commit into
mainfrom
skill/insights-context
Jun 25, 2026
Merged

Add insights-context skill with cross-referenced friction resolution#1
RasputinKaiser merged 1 commit into
mainfrom
skill/insights-context

Conversation

@RasputinKaiser

Copy link
Copy Markdown
Owner

Summary

Adds a new user-installed skill, /insights-context, that produces a context-aware HTML insights report mirroring the bundled /insights command, but cross-references friction signals against git history + auto-memory so resolved issues are not reported as currently broken.

The skill ships three project-agnostic Python scripts under skills/insights-context/scripts/:

  • scan.py — walks NCode session JSONLs into friction + stats JSON
  • resolve.py — builds resolved + environmental ledger from memory files and git log
  • render.py — cross-references scan output against the resolved ledger, emits a standalone HTML report
  • compare.py — delta view between two scan windows (for --compare)
  • test_smoke.py — end-to-end fixture test with zero-identity-leak assertions

Classifier

The resolver matches friction topics to resolved entries using signal-based keys (file paths, commit hashes, code symbols) with three confidence tiers:

  • Match + friction before fix date → RESOLVED (suppressed from At a Glance)
  • Match + friction after fix date → REGRESSION (flagged in red)
  • Match + environmental marker → ENVIRONMENTAL (routed to a separate section)
  • No match → OPEN

Informational interrupts (user adds context or preference mid-task) are tracked separately from friction so they don't inflate the friction count.

Redaction

All paths and snippets are scrubbed before emission: home directory → ~, bare username → <redacted>, API keys / tokens / Artifactory URLs / basic-auth URLs → <redacted-*>, GitHub noreply emails (12345+handle@users.noreply.github.com) → <redacted-github-email>, /users/<numeric-id> profile URLs → <redacted-github-url>. Optional per-user tokens load from ~/.ncode/identity-redact.txt.

Latest commit — bug fixes from deep review

The third commit (8ce23ad) fixes correctness, redaction, and test-isolation issues found in a focused review of the scripts:

  • render.py — classifier no longer breaks on first match. It iterates all resolved entries and prefers ones with a real fixed_at so an undated early match cannot shadow a later dated entry (restoring the documented "Match + friction before fix → RESOLVED" invariant).
  • resolve.pyfixed_at now picks dates anchored to fix keywords (fixed/resolved/patched/landed/merged/shipped) in prose over naive last-position, so "originally seen X, fixed Y" picks the right date. Git-log parser handles empty commit bodies (4-field split no longer rejected).
  • scan.pyparse_ts normalizes tz-aware timestamps to naive UTC so mixed aware/naive streams no longer crash on subtraction. is_err filters negated forms ("no error", "error: none") and word-bounds the error: marker. Added a bare-token secret redaction pattern catching values like api_key abc123... that the =/: form misses. OTHER_USERS_RE also scrubs /home/<name>/ on Linux.
  • render.pyopen subprocess is cross-platform (xdg-open on Linux, open on macOS).
  • test_smoke.py — synthesizes its own temp git repo with a baseline + fix commit touching OnDemandVerificationStore.swift, dated after the fixture friction, so the RESOLVED assertion exercises a real classifier path instead of relying on the host repo happening to contain that file. Removes lstrip("-") so the memory-dir path keeps its leading dash.

Test plan

  • python3 test_smoke.py passes end-to-end (scan → resolve → render → leak scan)
  • Live /insights-context run on this repo: 13 sessions scanned, 9 OPEN / 1 RESOLVED / 0 REGRESSIONS, zero identity leaks in rendered HTML
  • All scripts pass python3 -c "import ast; [ast.parse(open(f).read()) for f in [...]]"
  • Leak check: grep -iE "noreply.github|/users/[0-9]" /tmp/insights-context-*.html returns zero matches

Notes

  • This is a user-installed skill living under skills/. It does not modify any core CLI code, build, or test path. Default bun install && bun run build is unaffected.
  • All scripts are project-agnostic — paths are derived from cwd/argv, none are hardcoded.
  • No new dependencies. Python 3 stdlib only.

Rebased onto latest fork/main (which already had several of the hardening
fixes: /home/ + /root redaction, secure mkstemp, CSS injection defense,
subprocess timeouts, xdg-open on Linux). The remaining five correctness
and redaction bugs are fixed here:

- scan.py: parse_ts normalizes tz-aware -> naive UTC so mixed streams don't
  crash on subtraction on Python 3.11+. is_err filters negated forms
  ("no error", "error: none", "0 errors") and word-bounds the "error:"
  marker so successful tool results don'"'"'t pollute friction. Added a
  bare-token secret redaction pattern catching traceback values like
  `api_key abc123...` that the =/: form misses.
- resolve.py: fixed_at picks dates anchored to fix keywords in prose
  (fixed/resolved/patched/landed/merged/shipped) over naive last-position,
  so "originally seen X, fixed Y" picks the right date. Git-log parser
  handles empty commit bodies (4-field split padded to 5 so fix commits
  with no body still classify).
- render.py: cross_reference no longer breaks on first match — collects
  all matches and prefers entries with a real fixed_at so a later dated
  entry beats an earlier undated one, restoring the documented
  "Match + friction before fix -> RESOLVED" invariant.
- test_smoke.py: synthesizes a temp git repo with a baseline + fix commit
  touching OnDemandVerificationStore.swift, dated after the fixture
  friction so the RESOLVED classifier asserts a real path instead of
  relying on the host repo happening to contain that file. atexit cleanup.

Co-Authored-By: GLM 5.2 [1m] <noreply@anthropic.com>
@RasputinKaiser
RasputinKaiser force-pushed the skill/insights-context branch from 8ce23ad to 43b8709 Compare June 25, 2026 05:42
@RasputinKaiser
RasputinKaiser merged commit a2c28f7 into main Jun 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant