From 09a3dfa6442cfeb73a0d5a7666d1a1118d754999 Mon Sep 17 00:00:00 2001 From: Sereja Date: Mon, 6 Apr 2026 00:19:37 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20address=20PR=20review=20=E2=80=94=20corr?= =?UTF-8?q?ect=20path=20mismatch,=20relocate=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .gitignore | 3 +- .../cli-anything/README.md | 45 ++++++------------- .../cli-anything/index.ts | 0 .../cli-anything/install.sh | 8 ++++ .../cli-anything/tests/test_extension.test.ts | 0 README.md | 17 ++++--- .../tests/test_skill_generator.py | 15 ++++--- 7 files changed, 41 insertions(+), 47 deletions(-) rename {pi-extension => .pi-extension}/cli-anything/README.md (67%) rename {pi-extension => .pi-extension}/cli-anything/index.ts (100%) rename {pi-extension => .pi-extension}/cli-anything/install.sh (95%) rename {pi-extension => .pi-extension}/cli-anything/tests/test_extension.test.ts (100%) rename {pi-extension/cli-anything => cli-anything-plugin}/tests/test_skill_generator.py (96%) diff --git a/.gitignore b/.gitignore index 8eae149b6..6ed085494 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,8 @@ !/CONTRIBUTING.md !/SECURITY.md !/assets/ -!/pi-extension/ +!/.pi-extension/ +/.pi-extension/cli-anything/node_modules !/.claude-plugin/ !/.github/ /.github/* diff --git a/pi-extension/cli-anything/README.md b/.pi-extension/cli-anything/README.md similarity index 67% rename from pi-extension/cli-anything/README.md rename to .pi-extension/cli-anything/README.md index 583aaad09..e7934dda7 100644 --- a/pi-extension/cli-anything/README.md +++ b/.pi-extension/cli-anything/README.md @@ -13,20 +13,16 @@ The CLI-Anything Pi extension provides 5 slash commands that inject the HARNESS. Install the extension globally so `/cli-anything` commands are available in **all** Pi projects: ```bash -cd CLI-Anything/.pi-extension/extensions/cli-anything -bash install.sh +cd CLI-Anything +bash .pi-extension/cli-anything/install.sh ``` To uninstall: ```bash -bash install.sh --uninstall +bash .pi-extension/cli-anything/install.sh --uninstall ``` -### Option 2: Project-Local - -Pi auto-discovers extensions in `.pi-extension/extensions/` within a project. If you're working inside the CLI-Anything repo, the extension is already active — no installation needed. - ### Verify After installing, run `/reload` in Pi or restart Pi. Then type `/cli-anything` to verify the command is available. @@ -70,34 +66,21 @@ After installing, run `/reload` in Pi or restart Pi. Then type `/cli-anything` t ## Extension Structure ``` -.pi-extension/extensions/cli-anything/ +.pi-extension/cli-anything/ ├── index.ts # Main extension entry point +├── install.sh # Global installation script ├── README.md # This file -├── commands/ # Command specifications -│ ├── cli-anything.md # Main build command -│ ├── refine.md # Refinement command -│ ├── test.md # Test runner command -│ ├── validate.md # Validation command -│ └── list.md # List tools command -├── guides/ # Detailed implementation guides -│ ├── filter-translation.md -│ ├── mcp-backend.md -│ ├── pypi-publishing.md -│ ├── session-locking.md -│ ├── skill-generation.md -│ └── timecode-precision.md -├── scripts/ # Utility scripts -│ └── skill_generator.py # SKILL.md generator -├── templates/ # Templates -│ └── SKILL.md.template # Skill definition template -└── tests/ # Test suite - ├── test_extension.test.ts # Command registration tests - └── test_skill_generator.py # Skill generator tests +└── tests/ + └── test_extension.test.ts # Command registration tests ``` -> **Note:** HARNESS.md is NOT duplicated here. The extension reads it directly -> from `cli-anything-plugin/HARNESS.md` (canonical source) using a relative path. -> When installed globally via `install.sh`, a copy is placed alongside the extension. +Tests for `skill_generator.py` live in `cli-anything-plugin/tests/` (next to the source). + +> **Note:** Command specs, guides, scripts (skill_generator.py, repl_skin.py), +> templates, and HARNESS.md live in `cli-anything-plugin/` (canonical source). +> `install.sh` copies them into `~/.pi/agent/extensions/cli-anything/` alongside +> `index.ts` at install time. The extension reads them from its own directory +> via `__dirname`. ## How It Works diff --git a/pi-extension/cli-anything/index.ts b/.pi-extension/cli-anything/index.ts similarity index 100% rename from pi-extension/cli-anything/index.ts rename to .pi-extension/cli-anything/index.ts diff --git a/pi-extension/cli-anything/install.sh b/.pi-extension/cli-anything/install.sh similarity index 95% rename from pi-extension/cli-anything/install.sh rename to .pi-extension/cli-anything/install.sh index f0d34c9c8..4c6fddea2 100755 --- a/pi-extension/cli-anything/install.sh +++ b/.pi-extension/cli-anything/install.sh @@ -113,6 +113,14 @@ if [ -f "$SKILL_GEN_SRC" ]; then echo "✓ skill_generator.py copied from $SKILL_GEN_SRC" fi +# Copy tests from the canonical location +TESTS_SRC="$REPO_ROOT/cli-anything-plugin/tests" +if [ -d "$TESTS_SRC" ]; then + mkdir -p "$TARGET_DIR/tests" + cp "$TESTS_SRC"/*.py "$TARGET_DIR/tests/" + echo "✓ tests copied from $TESTS_SRC" +fi + echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo " ✓ CLI-Anything extension installed globally!" diff --git a/pi-extension/cli-anything/tests/test_extension.test.ts b/.pi-extension/cli-anything/tests/test_extension.test.ts similarity index 100% rename from pi-extension/cli-anything/tests/test_extension.test.ts rename to .pi-extension/cli-anything/tests/test_extension.test.ts diff --git a/README.md b/README.md index 29ef2e7c8..c197cbf72 100644 --- a/README.md +++ b/README.md @@ -213,26 +213,25 @@ cp -r CLI-Anything/cli-anything-plugin ~/.claude/plugins/cli-anything **Step 1: Install the Extension** -Pi extensions are loaded automatically from the `.pi-extension/extensions/` directory. To install CLI-Anything: +The extension lives at `.pi-extension/cli-anything/` in this repository. Install it globally so `/cli-anything` commands are available in **all** Pi projects: ```bash # Clone the repo git clone https://github.com/HKUDS/CLI-Anything.git +cd CLI-Anything -# The extension is already included in the repository at: -# CLI-Anything/.pi-extension/extensions/cli-anything/ +# Install globally into Pi's extensions directory +bash .pi-extension/cli-anything/install.sh ``` -If you're developing the extension locally, symlink it to your Pi extensions directory: +To uninstall: ```bash -# Create Pi extensions directory if it doesn't exist -mkdir -p ~/.pi/extensions - -# Symlink the CLI-Anything extension -ln -s $(pwd)/CLI-Anything/.pi-extension/extensions/cli-anything ~/.pi/extensions/cli-anything +bash .pi-extension/cli-anything/install.sh --uninstall ``` +> **How it works:** `install.sh` copies the extension files (including HARNESS.md, commands, guides, scripts, and templates from `cli-anything-plugin/`) into `~/.pi/agent/extensions/cli-anything/`, which Pi auto-discovers on startup. Run `/reload` in Pi or restart Pi to activate. + **Step 2: Build a CLI in One Command** Once the extension is loaded, the following commands are available: diff --git a/pi-extension/cli-anything/tests/test_skill_generator.py b/cli-anything-plugin/tests/test_skill_generator.py similarity index 96% rename from pi-extension/cli-anything/tests/test_skill_generator.py rename to cli-anything-plugin/tests/test_skill_generator.py index 26c2fdf53..dec23e868 100644 --- a/pi-extension/cli-anything/tests/test_skill_generator.py +++ b/cli-anything-plugin/tests/test_skill_generator.py @@ -14,12 +14,15 @@ from pathlib import Path import pytest -# skill_generator lives in cli-anything-plugin/ (canonical) or scripts/ (installed) -EXT_DIR = Path(__file__).resolve().parent.parent -SCRIPTS_DIR = EXT_DIR / "scripts" -if not (SCRIPTS_DIR / "skill_generator.py").exists(): - SCRIPTS_DIR = EXT_DIR.parents[1] / "cli-anything-plugin" -sys.path.insert(0, str(SCRIPTS_DIR)) +# Resolve skill_generator.py location: +# - In the repo: cli-anything-plugin/skill_generator.py (parent dir) +# - After install.sh: scripts/skill_generator.py (sibling dir) +_PLUGIN_DIR = Path(__file__).resolve().parent.parent +_SCRIPTS_DIR = _PLUGIN_DIR / "scripts" +if (_SCRIPTS_DIR / "skill_generator.py").exists(): + sys.path.insert(0, str(_SCRIPTS_DIR)) +else: + sys.path.insert(0, str(_PLUGIN_DIR)) from skill_generator import ( extract_cli_metadata,