-
Notifications
You must be signed in to change notification settings - Fork 0
Milestone
Description
Summary
As a package developer, in order to give AI agents the ability to create well-structured GitHub issues for my package, I would like to install a pkgskills
create-issueskill with a single function call.
Proposed signature
use_skill_create_issue(
target_dir = ".github",
use_skills_subdir = TRUE,
overwrite = TRUE,
open = rlang::is_interactive(),
gh_token = gh::gh_token()
)Arguments
target_dir(character(1)) — Directory where the skill will be installed, relative to the project root. Defaults to".github".use_skills_subdir(logical(1)) — Whether to place thecreate-issuefolder under askillssubdirectory oftarget_dir. Defaults toTRUE, producing.github/skills/create-issue/SKILL.md.overwrite(logical(1)) — Whether to overwrite an existing skill file. Defaults toTRUE.open(logical(1)) — Whether to open the installed file in the editor after creation. Defaults torlang::is_interactive().gh_token(character(1)) — A GitHub personal access token. Defaults togh::gh_token().
Returns the path to the installed skill file, invisibly (following the usethis convention).
Under the hood, use_skill_create_issue() delegates to an internal helper with this signature:
.use_skill(
skill,
data,
target_dir = ".github",
use_skills_subdir = TRUE,
overwrite = TRUE,
open = rlang::is_interactive()
).use_skill() arguments
skill(character(1)) — Skill name (folder name underinst/templates/skills/), e.g."create-issue". Determines the template path (inst/templates/skills/{skill}/SKILL.md) and the install subdirectory.data(list) — Named list of whisker template variables to fill into the skill template.- Other arguments are the same as those of
use_skill_create_issue()above.
Behavior
use_skill_create_issue()
- Validates all arguments using
stbl(following ther-codeskill conventions).target_dirandgh_tokenarecharacter(1);use_skills_subdirandoverwritearelogical(1). - Validates that the active project has a
BugReportsfield inDESCRIPTIONpointing to a GitHub URL. If not, errors with a{cli}message that includes{.run usethis::use_github()}. - Extracts the repo
ownerandreponame from theBugReportsURL. - Uses
gh::gh()(withgh_token) to fetch:- The repository's node ID (
repoId) - All available issue types via
issueTypesGraphQL query, requestingid,name, anddescriptionfor each node
- The repository's node ID (
- Builds a
datalist containingowner,repo,repo_id, andissue_types: a list of lists, each withname,id, anddescriptionkeys. - Calls
.use_skill("create-issue", data = data, target_dir, use_skills_subdir, overwrite, open).
.use_skill()
- Validates all arguments using
stbl. - Computes
save_as:- If
use_skills_subdir = TRUE:fs::path(target_dir, "skills", skill, "SKILL.md") - If
use_skills_subdir = FALSE:fs::path(target_dir, skill, "SKILL.md")
- If
- Reads the
trigger:field from the YAML front matter of the source template (inst/templates/skills/{skill}/SKILL.mdwithin the pkgskills package). The front matter uses simplekey: valuelines between---delimiters. - Calls
.use_template()(defined inR/use_agent.R) pointing toskills/{skill}/SKILL.md, with the derivedsave_asargument and the provideddataandopenarguments. - If
AGENTS.mdexists at the project root, upserts a row for this skill into the## Skillstable:| {trigger} | @{save_as} |. If a row forsave_asalready exists, its trigger is updated in place; otherwise a new row is appended. IfAGENTS.mdexists but has no## Skillssection, the section is created. - Emits a
cli::cli_inform()message confirming the skill was installed and its path. - Returns the installed file path invisibly.
.use_skill() is the general pattern for how all use_skill_*() functions in this package will work — analogous to how use_agent() calls .use_template() internally.
Details
- Add
trigger:to the YAML front matter of all skill files under.github/skills/and all templates underinst/templates/skills/. The value is the trigger phrase as it will appear in the## Skillstable ofAGENTS.md. - Create
inst/templates/skills/create-issue/SKILL.md: a whisker-rendered version of.github/skills/create-issue/SKILL.mdin which hardcoded values are replaced with template variables:{{{owner}}}and{{{repo}}}— repo owner and name (used in the GraphQL lookup examples){{{repo_id}}}— repository node ID (replaces the hardcodedR_kgDORkNSGw){{#issue_types}}/{{/issue_types}}whisker section iterating over a list of lists, each with{{name}},{{id}}, and{{description}}— renders one table row per issue type (replaces the hardcoded table rows)
- Create
R/use_skill.Rcontaining.use_skill(). Unlike usual convention, this helper gets its own file because it will likely be exported eventually. The AGENTS.md upsert logic can live in a private helper in the same file (e.g..upsert_agents_skills_row()). - Create
R/use_skill_create_issue.Rcontaininguse_skill_create_issue(). - Add
ghtoImportsinDESCRIPTION(needed forgh::gh()andgh::gh_token()). - Update the
issueTypeslookup query in.github/skills/create-issue/SKILL.mdto requestdescriptionalongsideidandname.
References
use_agent()inR/use_agent.R— model for how the public function calls an internal helper (.use_template()) and the general shape ofuse_skill_*()functions.ghpackage — for GitHub API calls and token management.usethis::use_template()— for rendering and writing the skill file.- Existing
.github/skills/create-issue/SKILL.md— source for the template.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels