feat: add btw_task() for running pre-formatted task files#169
Merged
feat: add btw_task() for running pre-formatted task files#169
btw_task() for running pre-formatted task files#169Conversation
- Add test for unnamed args as additional context (previously untested despite being a documented feature) - Delete the skipped conditional-sections test, which covered no assertions and signalled an abandoned attempt rather than a known gap - Wrap the example-files test in a describe() block for consistency with the rest of the file
…data System prompt: - Replace the system prompt with the task-specific content rather than appending to btw's standard session/tool/project prompts, matching the pattern used by btw_task_create_readme() and btw_task_create_btw_md() Context args: - Switch from do.call(btw, ...) to enquos() + eval_tidy() + btw_this(), which preserves the original expressions so btw can derive object names (do.call passed evaluated values, losing the expression context that btw()'s NSE relies on) Tool metadata from YAML frontmatter: - Read optional name, title, description, icon fields from task file YAML - Derive tool name from name field or file basename (hyphens → underscores) - Derive display name from title field or title-cased name - Add ellmer::tool_annotations() with title/read_only_hint/open_world_hint - Apply custom_icon() when icon field is present in YAML, matching the btw_agent_tool() pattern Minor cleanup: - Remove redundant comments that restate what the next line does - Compute display_name once before mode dispatch instead of recomputing task_name separately inside the console and app branches - Derive tool description from description YAML field when present, otherwise take the first non-empty line of the task body (stripping markdown header markers) rather than blindly substr()-ing at 100 chars
btw_task() for running pre-formatted task files
The bundled example task files weren't ready to ship. Deleted inst/tasks/ entirely and replaced the test coverage with a minimal fixture at tests/testthat/fixtures/test-analyze-package.md.
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.
Summary
This PR adds
btw_task(), a new function for running pre-formatted task files with YAML frontmatter configuration and markdown body content. Task files use the same format asbtw.mdfiles but describe specific workflows that can be executed interactively or as tools.Key features:
{{ variable }}syntaxbtw()and appended to the system promptThe implementation includes:
btw_task()function (251 lines) with comprehensive documentationThis establishes the foundation for user-defined task workflows that can be shared, versioned, and invoked both interactively and programmatically.
Verification
Create a simple task file and run it: