-
Notifications
You must be signed in to change notification settings - Fork 0
Add prompt_runtime setting to Deepwork Rules #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nhorton
wants to merge
21
commits into
main
Choose a base branch
from
claude/add-prompt-runtime-setting-gPJDA
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Adds a new `prompt_runtime` frontmatter setting for DeepWork rules: - `send_to_stopping_agent` (default): Returns prompt to the triggering agent - `claude`: Invokes Claude Code in headless mode to process the rule This enables rules to be processed by a dedicated Claude instance instead of being returned to the agent that triggered the hook, useful for: - Cross-platform rule processing (e.g., when Gemini triggers a rule) - Autonomous rule handling without blocking the main agent - Consistent rule processing regardless of triggering agent Changes: - Add prompt_runtime field to rules schema - Add PromptRuntime enum and parsing logic to rules_parser.py - Implement Claude headless invocation in rules_check.py - Update all existing rules with prompt_runtime: send_to_stopping_agent - Update documentation with examples and field reference
… Claude prompt Tests: - Add TestPromptRuntime class for PromptRuntime enum behavior - Add TestLoadPromptRuntimeFromFile class for parsing from rule files - Add TestFormatClaudePrompt class for Claude prompt formatting - Add TestParseClaudeResponse class for parsing Claude's structured output - Add tests for transcript_path parameter in format_claude_prompt Implementation: - Update format_claude_prompt to accept optional transcript_path parameter - Include conversation context section in Claude prompt when transcript provided - Pass hook_input.transcript_path to format_claude_prompt in hook
These rules now invoke Claude Code in headless mode to autonomously check and update documentation when source code changes, rather than returning prompts to the triggering agent.
Creates test_claude_runtime/ directory with a simple Python file that triggers the new prompt_runtime: claude feature. When edited, the rule invokes Claude Code in headless mode to review the code changes. Updates manual tests README with test documentation.
- Bump version to 0.5.0 - Add CHANGELOG entry for prompt_runtime setting - Document prompt_runtime in README and architecture docs - Add pytest and gitpython as dev dependencies Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The prompt_runtime setting only applies to prompt actions, not command actions. Removed it from: - manual-test-command-action.md - manual-test-infinite-block-command.md - uv-lock-sync.md The parser still accepts prompt_runtime on command rules (for backwards compatibility) but ignores it since command rules don't use prompts.
When CLAUDE_CODE_REMOTE=true, the claude command cannot be executed. Instead of hanging, the system now returns the prompt to the agent with instructions to evaluate it manually via a sub-agent. Changes: - Add is_claude_code_remote() function to detect remote environment - Update invoke_claude_headless() to return fallback prompt when remote - Add "Rules Requiring Sub-Agent Evaluation" section in hook output - Add tests for the new fallback behavior
Updated instructions to explain that testers should introduce a blatant error (e.g., division by zero) to verify Claude detects and blocks it. Also noted the fallback behavior in Claude Code Web environments.
Tests cover: - Successful allow/block decisions - Non-zero exit code handling - Subprocess timeout handling - Generic exception handling - Correct command-line arguments
Claude Code now has separate Stop and SubagentStop events. Previously, Stop would trigger for both the main agent and subagents. This change ensures that when a Stop hook is defined, it is also registered for SubagentStop so the same validation logic triggers for both events. Changes: - generator.py: Duplicate Stop hooks to SubagentStop in skill templates - hooks_syncer.py: Duplicate Stop hooks to SubagentStop in global hooks - Add tests verifying SubagentStop hook registration
Resolves merge conflicts in: - manual_tests/README.md - tests/shell_script_tests/test_rules_stop_hook.py - tests/unit/test_stop_hooks.py Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Resolves conflict in src/deepwork/hooks/rules_check.py by incorporating both changes: - Promised rules handling (from main): updates FAILED queue entries to SKIPPED when they have a promise tag - Prompt runtime separation (from this branch): separates prompt results by runtime type for Claude vs agent processing
Consolidated all changes from 0.4.0-0.5.2 into a single 0.4.0 release: Added: - Doc specs feature for document quality criteria - prompt_runtime setting for rules (send_to_stopping_agent vs claude) - Claude headless mode execution for automated rule remediation - deepwork rules clear_queue CLI command - Code review stage in commit job - Session start hook for version checking - Manual tests job Changed: - BREAKING: Renamed document_type to doc_spec - Step.outputs now uses OutputSpec dataclass - Updated deepwork_jobs to v0.6.0 Fixed: - Infinite loop bug in rules system with promise tags - COMMAND rules promise handling queue status - Quality criteria validation logic - compare_to: prompt mode file detection Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
4b9f026 to
dcea5e4
Compare
Documents the findings from debugging why `prompt_runtime: claude` hangs when running inside Claude Code. Key findings: - Direct bash execution works, Python subprocess doesn't - The hang appears to be at the process management level - Nested Claude invocation seems intentionally limited - Feature should work from external automation (CI, cron) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
Adds a new
prompt_runtimefrontmatter setting for DeepWork rules:send_to_stopping_agent(default): Returns prompt to the triggering agentclaude: Invokes Claude Code in headless mode to process the ruleThis enables rules to be processed by a dedicated Claude instance instead of being returned to the agent that triggered the hook, useful for:
Changes: