Skip to content

refactor(skills): unify SkillDir / resolvePath skill-name→path resolution (flat-skill frontmatter caveat) #273

Description

@initializ-mk

Context

Deferred non-blocking follow-up from the #257 review (commit 851b0bc, item #4). Tracking it so it isn't lost in the commit message.

Two near-duplicate skill-name → path resolvers exist after #257:

  • resolvePath in forge-core/tools/builtins/read_skill.go (tries skills/<name>.md, skills/<name>/SKILL.md, underscore→hyphen variant, then a frontmatter-name index)
  • SkillDir / SafeSkillJoin in forge-cli/tools/run_skill_script.go (resolves a skill's own directory for skill-relative reads/execution)

They encode overlapping resolution logic. Divergence risks bugs where read_skill resolves a skill but run_skill_script can't (or resolves it to a different path).

Proposal

Extract a single shared skill-name → directory/path resolver and have both call it.

The caveat that makes this non-trivial

Flat single-file skills (skills/<name>.md) have no companion directory, and their frontmatter name may differ from the file/dir name. The unified resolver must:

  • resolve both layouts (flat skills/<name>.md and dir skills/<name>/SKILL.md)
  • key on BOTH frontmatter name and dir/file name (as resolvePath already does)
  • define a well-specified answer for "skill directory" of a flat skill (there is none — callers doing skill-relative file ops must handle that case explicitly rather than getting a bogus dir)

Acceptance

  • One shared resolver; read_skill and run_skill_script both use it
  • Flat-skill frontmatter/name divergence handled and tested
  • No regression in existing read_skill / run_skill_script resolution tests

Depends on #257 merging first (the code lives on that branch). Related: #251, #257

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttoolsAffects builtin or adapter tools (cli_execute, http_request, browser, etc.)

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions