fix: address PR review — correct path mismatch, relocate tests

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.
This commit is contained in:
Sereja
2026-04-06 00:19:37 +03:00
parent a1ee8756ef
commit 262502f93e
7 changed files with 41 additions and 47 deletions

3
.gitignore vendored
View File

@@ -16,7 +16,8 @@
!/CONTRIBUTING.md
!/SECURITY.md
!/assets/
!/pi-extension/
!/.pi-extension/
/.pi-extension/cli-anything/node_modules
!/.claude-plugin/
!/.github/
/.github/*

View File

@@ -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

View File

@@ -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!"

View File

@@ -203,26 +203,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:

View File

@@ -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,