Skip to content

feat: add Pi Coding Agent extension#178

Merged
omerarslan0 merged 5 commits into
HKUDS:mainfrom
ruttybob:feat/pi-coding-agent
Apr 7, 2026
Merged

feat: add Pi Coding Agent extension#178
omerarslan0 merged 5 commits into
HKUDS:mainfrom
ruttybob:feat/pi-coding-agent

Conversation

@ruttybob

@ruttybob ruttybob commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Description

Adds Pi Coding Agent extension support to CLI-Anything, enabling AI agents to build CLI harnesses for any GUI application directly from the Pi TUI.

Closes #179

Type of Change

  • New Feature — adds Pi Coding Agent extension with 5 slash commands

What This Adds

Extension (.pi-extension/cli-anything/index.ts)

  • Registers 5 slash commands: /cli-anything, /cli-anything:refine, /cli-anything:test, /cli-anything:validate, /cli-anything:list
  • Injects HARNESS.md methodology + command specs into agent session via sendUserMessage()
  • Path remapping from containerized environment to local system

Global Install (.pi-extension/cli-anything/install.sh)

  • Copies extension + all assets (HARNESS.md, commands, guides, scripts, templates, tests) from cli-anything-plugin/ into ~/.pi/agent/extensions/cli-anything/ for all-project availability
  • Supports --uninstall flag

Tests

  • cli-anything-plugin/tests/test_skill_generator.py — 31 pytest tests covering metadata extraction, SKILL.md generation, and edge cases (lives next to skill_generator.py)
  • .pi-extension/cli-anything/tests/test_extension.test.ts — 8 Vitest tests for command registration

Review Feedback Addressed

1. Path mismatch in docs

  • Renamed pi-extension/ to .pi-extension/ to match Pi's expected convention
  • Updated root README install instructions to reflect actual path (.pi-extension/cli-anything/) and the install.sh-based workflow instead of incorrect .pi-extension/extensions/cli-anything/
  • Updated extension README directory tree to show only files that actually live in the extension dir (command specs, guides, scripts, templates come from cli-anything-plugin/ via install.sh)

2. test_skill_generator.py can now run standalone

  • Moved test_skill_generator.py from .pi-extension/cli-anything/tests/ to cli-anything-plugin/tests/ (next to skill_generator.py)
  • Simplified import resolution — no more fragile parent-navigation fallback
  • install.sh copies tests into the installed extension so they work there too
  • 31/31 tests pass

Single Source of Truth

All shared files are referenced from their canonical locations — no duplicates:

File Canonical Location How Extension Accesses It
HARNESS.md cli-anything-plugin/HARNESS.md install.sh copies it alongside extension; readAsset() reads from __dirname
skill_generator.py cli-anything-plugin/skill_generator.py install.sh copies to scripts/; test imports from parent dir
repl_skin.py cli-anything-plugin/repl_skin.py install.sh copies to scripts/
Commands, guides, templates cli-anything-plugin/{commands,guides,templates}/ install.sh copies them into the extension

Changes to Existing Files

  • README.md (repo root) — added Pi as a supported platform; fixed install instructions
  • .gitignore — whitelisted .pi-extension/ directory

General Checklist

  • Code follows existing patterns and conventions
  • --json flag is supported on any new commands (/cli-anything:list)
  • Commit messages follow the conventional format (feat:, fix:, docs:, test:)
  • I have tested my changes locally

Test Results

Python tests (31 passed)

$ cd cli-anything-plugin && python3 -m pytest tests/test_skill_generator.py -v

31 passed in 0.06s

Install script verified

$ bash .pi-extension/cli-anything/install.sh
✓ commands copied from .../cli-anything-plugin/commands
✓ guides copied from .../cli-anything-plugin/guides
✓ templates copied from .../cli-anything-plugin/templates
✓ HARNESS.md copied from .../cli-anything-plugin/HARNESS.md
✓ repl_skin.py copied from .../cli-anything-plugin/repl_skin.py
✓ skill_generator.py copied from .../cli-anything-plugin/skill_generator.py
✓ tests copied from .../cli-anything-plugin/tests
✓ CLI-Anything extension installed globally!

$ bash .pi-extension/cli-anything/install.sh --uninstall
✓ CLI-Anything extension uninstalled

Adds .pi-extension directory with full CLI-Anything plugin support:
- 5 slash commands: /cli-anything, /cli-anything:refine,
  /cli-anything:test, /cli-anything:validate, /cli-anything:list
- Full HARNESS.md methodology documentation
- Guides for skill generation, PyPI publishing, MCP backend, etc.
- Utility scripts: repl_skin.py, skill_generator.py, setup-cli-anything.sh
- SKILL.md template for AI-discoverable skill definitions
- README.md documenting the extension structure and usage
- Updated root README.md to include Pi as a supported platform
@omerarslan0

Copy link
Copy Markdown
Collaborator

Hey @ruttybob, looked through the PR. Pi support is a welcome addition but a few things need fixing before merge.

Blockers:

  1. HARNESS.md duplication — The 592-line HARNESS.md is copied into .pi-extension/ but the file itself says "do NOT duplicate it." I understand the Pi extension needs a local copy for readAsset(), but if we update the original in .claude-plugin/, this one goes stale silently. Move the shared file to the repo root or add a sync mechanism so we don't maintain two copies.

  2. No tests — 3289 lines added, zero tests. CONTRIBUTING.md requires tests for new functionality. skill_generator.py alone has 527 lines of regex-heavy parsing logic that needs coverage. At minimum: a test that commands register correctly and that the generator can parse a sample harness.

  3. Hardcoded path in setup-cli-anything.shHARNESS_PATH="/root/cli-anything/HARNESS.md" is a container path, won't exist on real machines. Leftover from the Claude plugin setup that wasn't adapted.

  4. Syntax error in commands/list.md — The glob scanning example has broken indentation:

    for init_file in glob.glob(pattern, recursive=True):
    parts = Path(init_file).parts  # not inside the loop

    Anyone copying this gets a SyntaxError.

Should fix:

  1. No error handling in readAsset()readFileSync in index.ts will crash the entire extension if any file is missing. Needs a try/catch.

  2. No linked issue — CONTRIBUTING.md asks to open an issue before starting feature work.

  3. PR template incomplete — "I have tested my changes locally" isn't checked.

Minor:

  1. repl_skin.py under scripts/ is the standard copy, fine for now — but same drift problem as HARNESS.md. All shared files need a single-source-of-truth strategy.

Fix 1-4 and this is good to go.

@ruttybob

ruttybob commented Apr 4, 2026

Copy link
Copy Markdown
Contributor Author

@omerarslan0
hello, im so sorry...

The PR turned out quite messy, as there are currently a lot of duplicates in the repository. I understand, however, that PI has a different installation method since this is TypeScript—it installs packages from NPM or a separate GitHub repository.

In this case, would it make more sense to add support here as a separate directory, or should I publish the package to NPM and reference it in the README.md of this repository instead?

Apologies for opening such a messy PR intentionally.

I’m very new to the open-source community, and I feel quite embarrassed about how I handled this. I hope I haven’t taken up too much of your time. 😢

@omerarslan0

Copy link
Copy Markdown
Collaborator

@ruttybob Good progress — you've addressed all 4 blockers from the previous review. Tests added, HARNESS.md duplication resolved, indentation fixed, hardcoded path removed. Appreciated.

Still needs fixes before merge:

  1. Path mismatch in docs — The root README install instructions reference .pi-extension/extensions/cli-anything/ but the actual directory is pi-extension/cli-anything/. Pi auto-discovery won't work with this path. Either move the directory to .pi-extension/extensions/cli-anything/ or update the docs to reflect the correct path + manual symlink step.

  2. test_skill_generator.py can't run standalone — It depends on skill_generator.py which only exists after install.sh copies it from cli-anything-plugin/. Add the script to the extension directory or adjust the test to import from the canonical location.

  3. Re: your NPM question — Keeping it in-repo under pi-extension/ is fine for now. If Pi's ecosystem matures to support NPM-based extensions natively, we can extract it later. No need to over-engineer the distribution at this stage.

And no need to feel embarrassed — the first PR is always the hardest. You responded to feedback quickly and addressed every blocker, that's exactly how open-source works. Keep contributing.

Fix 1-2 and this is ready to merge.

1. Rename pi-extension/ to .pi-extension/ to match Pi auto-discovery
   convention. Update root README install instructions to reference
   correct path and install.sh workflow instead of non-existent
   .pi-extension/extensions/cli-anything/.

2. Move test_skill_generator.py from .pi-extension/cli-anything/tests/
   to cli-anything-plugin/tests/ (next to skill_generator.py) so it
   runs standalone without fragile parent-navigation fallbacks.
   Update install.sh to copy tests during global install.

31/31 pytest tests pass.
@ruttybob

ruttybob commented Apr 6, 2026

Copy link
Copy Markdown
Contributor Author

@omerarslan0
By default, Pi loads extensions from the .pi/extensions/ directory.
However, if an extension is structured this way and its code depends on paths within the repository, it effectively becomes project-specific rather than global.

That’s why I decided to add an install.sh script that installs the extension globally for Pi.

@yuh-yang yuh-yang requested review from omerarslan0 and yuh-yang April 6, 2026 13:30

@yuh-yang yuh-yang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current status LGTM. It's okay to include a bash script for installing if certain coding agents need that.

@omerarslan0

Copy link
Copy Markdown
Collaborator

LGTM! Thx for this.

@omerarslan0 omerarslan0 merged commit 47ee93d into HKUDS:main Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: add Pi Coding Agent extension support

3 participants