Skip to content

feat(hooklife): auto-activation hook (SessionStart + UserPrompt)#211

Merged
Delqhi merged 1 commit into
mainfrom
feat/issue-176
Jun 16, 2026
Merged

feat(hooklife): auto-activation hook (SessionStart + UserPrompt)#211
Delqhi merged 1 commit into
mainfrom
feat/issue-176

Conversation

@Delqhi

@Delqhi Delqhi commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Closes #176

Adds cmd/sin-code/internal/hooklife/autoactivate/, a per-session rule-injection subpackage for the hooklife subsystem. Mirrors JuliusBrussee/caveman's caveman-activate.js (SessionStart) + caveman-mode-tracker.js (UserPrompt) flow: state + trigger file + per-turn re-inject.

Files

  • Internal package: cmd/sin-code/internal/hooklife/autoactivate/
    • doc.go — package overview + privacy-first semantics
    • rules.go — Rule, RuleSet, deterministic byte-stable Render()
    • triggers.go — TOML-ish parser for .sin-code/autoactivate.toml
    • activator.go — Activator, SessionState, SessionStartHook, UserPromptHook, Register(reg)
    • *_test.go — 35 race-safe unit tests (+ chat integration suite = 8)
    • activator.doc.md / rules.doc.md / triggers.doc.md — prose docs
  • Wired into cmd/sin-code/chat_cmd.go via:
    • --activate comma-separated rule names
    • --no-trigger disables prompt-phrase activation
    • newChatActivator reads .sin-code/autoactivate.toml silently
  • AGENTS.md §10 hooklife event table updated; roadmap v3.19.0 added.
  • CHANGELOG.md [Unreleased] v3.19.0 entry added.

Verification

  • gofmt -l . clean (only pre-existing unrelated diffs in worktree)
  • go vet clean
  • go build ./... clean (binary builds, 39.5 MB; --version works; --activate flag visible)
  • go test -race -count=1 ./cmd/sin-code/internal/hooklife/autoactivate/ PASS (35 tests, 91.5% cov)
  • go test -race -count=1 ./cmd/sin-code/ PASS (chat integration tests pass)
  • go test -race -count=1 ./... PASS (no regressions)
  • golangci-lint run ./cmd/sin-code/internal/hooklife/autoactivate/ 0 issues
  • go tool cover -func 91.5% on autoactivate
  • gosec -no-fail -fmt sarif clean
  • govulncheck No vulnerabilities found.
  • python3 scripts/validate_skill.py --all-bundled --strict 34 skills, 0 failed.
  • python3 scripts/check_consistency.py all consistency checks passed.

Design notes

  • Decision verb: both hooks return Warn (not Allow) so the runner's existing aggregation surfaces the rendered rule body. The runner drops Allow-with-Message.
  • Privacy-first: Activator starts empty; AutoOn only flips on when --activate or .sin-code/autoactivate.toml is present. EndSession drops state on exit.
  • Race discipline: one sync.RWMutex over the sessions map. Tested with 16 goroutines × 64 ops parallel Activate/Deactivate/Snapshot — pass.
  • Built-in defaults: stored under the reserved builtins pseudo-session; never reachable via Snapshot("") or Activate("builtins", …).

@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sin-code Ready Ready Preview, Comment, Open in v0 Jun 16, 2026 7:36pm

Adds cmd/sin-code/internal/hooklife/autoactivate/, a per-session
rule-injection subpackage for the hooklife subsystem. Inspired by
caveman's caveman-activate.js: writes a flag-file equivalent at
session start, then re-emits the rule body on every UserPrompt.

Wire-up:

* autoactivate.NewActivator(defaults) — constructor
* Activator.OnSessionStart/OnUserPrompt — per-session lifecycle
* SessionStartHook + UserPromptHook — wire into any *hooklife.Registry
  via Activator.Register(reg); both return Warn so the runner's
  aggregation surfaces the rendered rule body
* sin-code chat --activate <rule-list> + --no-trigger flags
* Project-local .sin-code/autoactivate.toml (pure-stdlib, no new deps)

Determinism:

* RuleSet is map[name]Rule with sorted-Names() iteration
* Render() is byte-stable for any same-content RuleSet (mandate M2 +
  pre-req for the system-prompt hash metric, issue #2)
* EndSession(sid) drops state on exit — privacy-first

Race discipline:

* Single sync.RWMutex (mandate M7) over the sessions map
* go test -race -count=1 passes 35 unit + 8 integration tests
* 91.5% statement coverage

Docs:

* autoactivate/{activator,rules,triggers}.doc.md
* AGENTS.md §10 hooklife event table updated (SessionStart +
  UserPrompt rows)
* CHANGELOG.md Unreleased [v3.19.0] entry added
* Last verified bumped to v3.19.0
@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Deployment failed with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-young-hobby-team-24h").

Learn More: https://vercel.com/manheiler-8784s-projects?upgradeToPro=build-rate-limit

@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Deployment failed with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/aragonheld-7756s-projects?upgradeToPro=build-rate-limit

@Delqhi
Delqhi merged commit a15d79c into main Jun 16, 2026
8 of 11 checks passed
@github-actions

Copy link
Copy Markdown

🏆 CEO Audit — A+ (100.0/100)

Metric Value
Grade A+
Score 100.0/100
Critical findings 0
High findings 0
Profile QUICK
Min grade gate B

📥 Download full report (Markdown)
📊 Download SARIF (for Code Scanning)

Run ~/.config/opencode/skills/ceo-audit/scripts/audit.sh . --profile=QUICK locally to reproduce.

@github-actions

Copy link
Copy Markdown

🏆 CEO Audit — A+ (100.0/100)

Metric Value
Grade A+
Score 100.0/100
Critical findings 0
High findings 0
Medium findings 0
Profile QUICK
Min grade gate B

📥 Download full report (Markdown)

Run ID: 27643069618 · Commit: ${github.sha}

Run ~/.config/opencode/skills/ceo-audit/scripts/audit.sh . --profile=QUICK locally to reproduce.

// never errors for a missing file (privacy-first: silent, opt-in by
// presence).
func LoadFile(path string) (RuleSet, Default, error) {
f, err := os.Open(path)
@Delqhi
Delqhi deleted the feat/issue-176 branch June 16, 2026 20:37
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.

feat(hooklife): auto-activation hook (SessionStart + UserPrompt) for per-session rule injection (caveman activate-mode analog)

2 participants