Repository navigation
Skills Phase 4: scripts/, references/, assets/ runtime surfacing - #60
Conversation
Final phase of the four-PR skills overhaul. After #55 (SKILL.md format), #56 (GitHub install), and #57 (ClawHub install + search), this PR wires up the picoclaw / nanobot / Anthropic agent-skills bundled-resource layout so the model can actually use the files each registry-installed skill ships alongside its SKILL.md. TSkillSpec gains three dynamic-array fields (via a local TSkillStringArray alias to avoid pulling PasClaw.Tools.Registry's TStringArray into the skills layer for one type): Scripts - absolute paths under <skill>/scripts/. The model invokes them via shell_exec — subject to whatever sandbox policy is active (PR #53). For knowledge skills with no shell/prompt kind, this is where non-trivial automations live. References - absolute paths under <skill>/references/. Markdown the model loads on demand via fs_read. Anthropic agent-skills' "lazy context" pattern: advertise the path but don't bloat the system prompt with the body. Assets - absolute paths under <skill>/assets/. Templates / fixtures / images. Advertised so the model knows they exist; consumption is task-dependent. ParseSkillMD now calls ScanSkillSubdir three times after parsing the frontmatter — each call lists files (not subdirs) directly under the named subdirectory, sorted by name for stable system-prompt output. Missing subdirectories return an empty array, which is the common case for skills with only a SKILL.md. LoadJsonSkill explicitly zeroes the new arrays so the legacy single-file layout (PR #55's backwards-compat path) yields the same shape downstream. BuildSkillsSection in PasClaw.Agent.Prompt now emits indented sub-bullets under each skill listing scripts/, references/, and assets/ contents with their absolute paths and a one-liner saying how the model should consume each kind: - **code-review** — Static review. Read `<path>/SKILL.md` … scripts (invoke via shell_exec): - `<path>/scripts/lint.sh` - `<path>/scripts/fix.py` references (read with fs_read as needed): - `<path>/references/style-guide.md` Empty subdir => the section is skipped, so skills that ship only a SKILL.md (still the most common shape) print exactly as before. Sample updates: samples/skills/hello/scripts/greet.sh Minimal /usr/bin/env sh script that echoes its argv. Comments document the shell_exec contract and the workspace-pinned sandbox interaction. samples/skills/hello/references/style-guide.md Sample reference describing what references are for — project conventions, domain knowledge, worked examples. samples/skills/hello/SKILL.md body updated to describe the three subdirectories and point at the sample resources. README's skills section gets a "Skill bundle layout (Phase 4, this release)" subsection with the directory tree and a paragraph explaining how each kind reaches the model. Design notes: - Scripts are NOT auto-registered as separate tools. Picoclaw takes the same path — letting the model invoke them through shell_exec keeps the sandbox in the loop and avoids forcing each script author to spec a JSON schema for its argv. The model decides when to run; the sandbox decides whether to allow. - References / assets are NOT auto-loaded into context. The system prompt advertises the paths; the model uses fs_read only when SKILL.md's body says to. This is the "lazy context" pattern Anthropic's agent-skills documentation calls out as the right default — eager loading explodes prompt size for skills the model never reaches for. - ScanSkillSubdir returns a TSkillStringArray (local alias for `array of string`) rather than mutating an open-array parameter. Open arrays disallow SetLength inside the procedure under both compilers; returning is cleaner and matches the Pascal idiom for dynamic-array producers. This closes out the four-phase roadmap discussed earlier in the session. PasClaw is now wire-compatible with the picoclaw / nanobot / ClawHub / Anthropic agent-skills ecosystem at every documented layer — file format, registry protocols, bundle layout, and runtime surfacing. https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e6e9a7129
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,17 @@ | |||
| #!/usr/bin/env sh | |||
There was a problem hiding this comment.
Mark bundled scripts executable
When a user copies this sample skill as documented and the model follows the new prompt hint by running the advertised absolute path through shell_exec, this script will fail with permission denied because it is committed with mode 100644 (git ls-tree shows non-executable) even though the docs describe scripts/ entries as executables. Please commit it with the executable bit set so the canonical sample actually works when invoked as /path/to/greet.sh.
Useful? React with 👍 / 👎.
Three related changes around the Phase 4 scripts/ runtime: 1. Sample greet.sh is now executable (PR #60 P2 review) git update-index --chmod=+x on samples/skills/hello/scripts/ greet.sh — committed mode flips from 100644 to 100755. The reviewer's point was correct: a model copying the sample and invoking the advertised absolute path through shell_exec would otherwise hit "permission denied" because the canonical sample on disk was non-executable. 2. Install-time chmod for the GitHub + ClawHub paths Both installers' CopyTree uses TFileStream which preserves bytes but not Unix mode bits. Even a source repo that committed scripts as mode 100755 (per fix #1) would land on the user's POSIX disk as 0644. Added ChmodPlusXScriptsTree to both PasClaw.Skills.GitHub and PasClaw.Skills.ClawHub, called immediately after CopyTree. Walks <skill>/scripts/ non-recursively and chmods every file to 0755. Best-effort (ignores errors; the file was just created so we own it). FPC UNIX uses BaseUnix.FpChmod(Path, &755); Delphi POSIX uses Posix.SysStat.chmod(p, $1ED). No-op on Windows where NTFS has no execute bit. Mirrors the existing pattern in PasClaw.Updater for the self-update binary chmod. 3. Windows-aware invocation hints in the system prompt cmd.exe (what PasClaw.Platform.RunOneShot wraps on Windows) cannot execute a .sh file natively — the file has no default Win32 association and shebang lines are ignored. Even with git-bash installed, the model needs to type `bash /path/to/script.sh` for shell_exec to find a working interpreter. New ScriptInvocation helper in PasClaw.Agent.Prompt renders each script's path with the OS-appropriate invocation: {$IFDEF MSWINDOWS} .sh -> `bash <path>` (resolves through git-bash, WSL, or MSYS if any is on PATH; fails clearly otherwise so the model can pivot) .ps1 -> `powershell -ExecutionPolicy Bypass -File <path>` other -> bare path {$ELSE} always bare path (shebang + executable bit handle it) {$ENDIF} The scripts: header line in BuildSkillsSection also picks up an OS-aware hint string mentioning the bash / powershell requirement on Windows. samples/skills/hello/SKILL.md updated to describe the chmod behaviour and the Windows .sh -> bash dance. README's "Skill bundle layout" subsection grows a "Cross-platform scripts" paragraph documenting the chmod and the per-OS invocation rendering. https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
Phase 4 of 4. Stacked on #59 (ClawHub).
When #59 lands, this PR's base can be retargeted to
main(one-click in the GitHub UI) and the diff collapses to just the Phase 4 commit.What this closes
After #55 (SKILL.md format), #56 (GitHub install), #57/#59 (ClawHub install + search), this PR wires up the bundled-resource layout so the model can actually use the files each registry-installed skill ships alongside its SKILL.md. PasClaw is now wire-compatible with the picoclaw / nanobot / ClawHub / Anthropic agent-skills ecosystem at every documented layer — file format, registry protocols, bundle layout, and runtime surfacing.
Layout (matches picoclaw / nanobot / Anthropic agent-skills exactly)
Parser changes
TSkillSpecgains three dynamic-array fields (localTSkillStringArrayalias — avoiding a tools-layer import for one type):Scripts<skill>/scripts/References<skill>/references/Assets<skill>/assets/ParseSkillMDnow callsScanSkillSubdirthree times after parsing the frontmatter. Files only (no subdirs), sorted by name for stable system-prompt output. Missing subdir → empty array → section skipped downstream.LoadJsonSkillexplicitly zeroes the new arrays so legacy single-file skills (PR #55's backwards-compat path) yield the same shape downstream.System prompt (
BuildSkillsSection)Skills that ship only a SKILL.md (still the most common shape) print exactly as before.
Sample (
samples/skills/hello/)scripts/greet.sh— minimal/usr/bin/env shecho, documents the shell_exec contract + workspace-pin interaction with the PR Tool sandbox: workspace boundary + regex-free shell denylist #53 sandboxreferences/style-guide.md— sample reference describing the "project conventions / domain knowledge / worked examples" use casesDesign rationale
shell_execkeeps the PR #53 sandbox in the loop and avoids forcing each script author to spec a JSON schema for its argv. Model decides when; sandbox decides whether.fs_readonly when SKILL.md's body says to. Eager loading explodes prompt size for skills the model never reaches for.ScanSkillSubdirreturns rather than mutates an open-array paramSetLengthinside the procedure under both FPC and Delphi. Returning matches the Pascal idiom for dynamic-array producers and is cleaner.Test plan
make) + Delphi.dprojbuild cleanlycp -r samples/skills/hello ~/.pasclaw/workspace/skills/thenpasclaw skills list— entry still shows;pasclaw agent "what's in the hello skill?"— system prompt now advertisesgreet.sh+style-guide.mdwith absolute pathsscripts/andreferences/— files copy through the install pipeline intact; system prompt picks them upscripts/(e.g.scripts/lib/subdir) —ScanSkillSubdirskips it (files-only)<name>.jsonskill — system prompt shape unchanged (PR Skills Phase 1: per-directory SKILL.md format + frontmatter parser #55 path, no resource arrays populated)https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
Generated by Claude Code