feat(hooks): opt-in auto-lint + auto-test after every edit (#376) - #403
Closed
Delqhi wants to merge 1 commit into
Closed
feat(hooks): opt-in auto-lint + auto-test after every edit (#376)#403Delqhi wants to merge 1 commit into
Delqhi wants to merge 1 commit into
Conversation
Adds two programmatic PostListeners to the agent loop's tool.post
event so the operator can opt in to:\n
- agentloop.auto_lint=true \u2014 after every sin_write/sin_edit to a
.go file: gofmt -l + go vet on the file's package, advisory only.\n
- agentloop.auto_test=true \u2014 after every sin_write/sin_edit to a
*_test.go file: go test -race -count=1 on the file's package,
advisory (may mutate state).\n
Both default off (legacy behaviour preserved). Both can be overridden
via agentloop.auto_lint_timeout / agentloop.auto_test_timeout.\n
Implementation:\n
- internal/hooks: new PostListener type + Engine.RegisterPostListener.\n
Engine.Fire invokes registered listeners on tool.post events in\n
registration order; their return values are merged into Result.\n
PromptInjects so the agent sees the feedback in its next turn.\n
Listeners never block (tool.post is not in the blockable set).\n
safeInvokePostListener recovers from any panic so a misbehaving\n
listener cannot crash the agent loop.\n
- internal/hooks/auto_hook.go: AutoLintListener + AutoTestListener\n
+ AutoHookConfig + AutoLintDefaultTimeout=30s /\n
AutoTestDefaultTimeout=120s.\n
- internal/hooks/auto_hook_test.go: 5 tests including the 3 required\n
(TestAutoLintFiresAfterSinEdit / TestAutoTestFiresAfterTestFileEdit\n
/ TestAutoLintDisabledByDefault) plus nil-engine and panic-recovery.\n
- internal/config.go: 4 new keys (auto_lint, auto_test, auto_lint_timeout,\n
auto_test_timeout) wired through SinCodeConfig defaults, TOML\n
template, get/set/parsers/pairs output.\n
- cmd/sin-code/chat_cmd.go: --help advertises the new opt-ins\n
("set agentloop.auto_lint=true to auto-lint after edits") and\n
registers the listeners on the hook engine only when the operator\n
has opted in via config.\n
Constraints honored:\n
- Opt-in: both default false (legacy single-shot behaviour preserved).\n
- read-only lint vs mutating test documented in --help.\n
- Hooks emit warnings only (PromptInject + stderr) and never block.\n
- go test -race -count=1 of internal/hooks passes; session-mutating\n
tests properly skip when go / gofmt binaries are missing.\n
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🏆 CEO Audit — A+ (100.0/100)
📥 Download full report (Markdown)
|
🏆 CEO Audit — A+ (100.0/100)
📥 Download full report (Markdown) Run ID:
|
| } | ||
| gofmtCtx, cancel := context.WithTimeout(ctx, timeout) | ||
| defer cancel() | ||
| gofmtCmd := exec.CommandContext(gofmtCtx, "gofmt", "-l", goFile) |
| if cmdWorkdir == "" { | ||
| cmdWorkdir = "." | ||
| } | ||
| vetCmd := exec.CommandContext(vetCtx, "go", "vet", "./"+pkgDir) |
| "./" + filepath.Base(dirOfFile), | ||
| "-count=1", | ||
| } | ||
| cmd := exec.CommandContext(ctx, "go", args...) |
| } | ||
|
|
||
| hookEngine := chatNewHooksFn(loadHooks(workspace)) | ||
| // --- post-edit auto listeners (issue #376) ------------------ |
| // --- post-edit auto listeners (issue #376) ------------------ | ||
| // Register the lint + test listeners ONLY when the operator has opted | ||
| // in via config. Default behaviour (no listener registered) preserves | ||
| // the legacy single-shot semantics and stays off in headless / CI runs. |
Collaborator
Author
|
Closing as duplicate. Issue #376 (Auto-lint + auto-test after edits) was already shipped by a parallel agent on
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Auto-lint + auto-test after sin_write/sin_edit, opt-in. 5 tests race-clean.