Skip to content

refactor: LLM-based concept extraction and two-pass hook protocol#30

Merged
anormang1992 merged 1 commit intomainfrom
chore/refactor-bash-primitive-callback-to-demo
Mar 19, 2026
Merged

refactor: LLM-based concept extraction and two-pass hook protocol#30
anormang1992 merged 1 commit intomainfrom
chore/refactor-bash-primitive-callback-to-demo

Conversation

@anormang1992
Copy link
Owner

Summary

  • Demo: Refactor get_concepts into ConceptExtractor class — ChatOllama chain constructed once in __init__, reused across calls. Few-shot flag-to-concept examples in the prompt, negative constraint against returning flag names as primitives, and try/except with clear "is Ollama running?" error. Add --concepts-model CLI arg.
  • Claude Code hook: Replace parse_bash_primitives static mapping with a two-pass protocol — first call blocks and asks Claude to identify primitives, second call carries a # vre:concept1,concept2 prefix that the hook extracts, grounds, and strips via updatedInput before execution. Claude proposes the concepts itself.
  • Remove src/vre/builtins/: SHELL_ALIASES and parse_bash_primitives are no longer imported anywhere in the package. Dead code after the hook refactor.
  • Docs: Update README (concepts parameter, demo agent, Claude Code integration sections), docs/index.html landing page, and project structure.

Closes #26.

Test plan

  • All 201 tests pass, ruff clean, coverage 79%
  • TestParseVrePrefix — 5 new tests for prefix parsing edge cases
  • TestRunHook — updated tests verify two-pass protocol (block without prefix, allow with updatedInput, policy deferral without updatedInput)
  • Live-tested hook end-to-end: first call blocked requesting concepts, second call with # vre: prefix grounded and executed with prefix stripped
  • Live-tested grounding enforcement: execute primitive not in graph → blocked; create + file with insufficient depth → blocked with full trace

🤖 Generated with Claude Code

…d two-pass hook protocol

Demo: Refactor get_concepts into ConceptExtractor class with __call__,
few-shot flag-to-concept examples, and error handling. Add --concepts-model
CLI arg.

Claude Code: Replace parse_bash_primitives with a two-pass protocol where
Claude proposes concepts via a # vre: prefix, the hook extracts and grounds
them, then returns updatedInput with the prefix stripped.

Remove src/vre/builtins/ (SHELL_ALIASES, parse_bash_primitives) — no longer
imported by anything in the package.

Update README, docs/index.html, and tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@anormang1992 anormang1992 merged commit 31fa5b6 into main Mar 19, 2026
2 checks passed
@anormang1992 anormang1992 deleted the chore/refactor-bash-primitive-callback-to-demo branch March 19, 2026 18:55
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.

Move primitive extraction to integrators; introduce LLM-based extraction

1 participant