149 lines
5.1 KiB
Markdown
149 lines
5.1 KiB
Markdown
# SGClaw Configurable Skills Directory Implementation Plan
|
|
|
|
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
|
|
|
|
**Goal:** Let `sgclaw` own skill-directory resolution and allow users to set a custom skills directory in `sgclaw_config.json` without relying on SuperRPA to copy skills into the runtime workspace.
|
|
|
|
**Architecture:** Extend the existing browser JSON config parser so `sgclaw` can read an optional `skillsDir` field alongside DeepSeek settings. Keep the current embedded ZeroClaw workspace for memory/config internals, but decouple skill loading from that fixed path by resolving a configurable skills root at runtime. Preserve backward compatibility by defaulting to `<workspace_root>/.sgclaw-zeroclaw-workspace/skills` when `skillsDir` is absent or empty.
|
|
|
|
**Tech Stack:** Rust, serde JSON parsing, existing ZeroClaw compatibility runtime, cargo test
|
|
|
|
### Task 1: Capture browser config requirements
|
|
|
|
**Files:**
|
|
- Modify: `/home/zyl/projects/sgClaw/claw/src/config/settings.rs`
|
|
- Test: `/home/zyl/projects/sgClaw/claw/tests/compat_config_test.rs`
|
|
|
|
**Step 1: Write the failing test**
|
|
|
|
Add tests that load `sgclaw_config.json` containing:
|
|
- no `skillsDir`
|
|
- a relative `skillsDir`
|
|
- an absolute `skillsDir`
|
|
|
|
Assert that:
|
|
- `skillsDir` missing falls back to default workspace skills path
|
|
- relative values resolve against the browser config directory
|
|
- absolute values are preserved
|
|
|
|
**Step 2: Run test to verify it fails**
|
|
|
|
Run: `cargo test compat_config -- --nocapture`
|
|
|
|
Expected: FAIL because `DeepSeekSettings` / config adapter do not expose any skills directory override yet.
|
|
|
|
**Step 3: Write minimal implementation**
|
|
|
|
Add a browser-config structure that parses `skillsDir` and expose a resolver function that returns the effective skills directory for `sgclaw`.
|
|
|
|
**Step 4: Run test to verify it passes**
|
|
|
|
Run: `cargo test compat_config -- --nocapture`
|
|
|
|
Expected: PASS for the new parsing and path-resolution cases.
|
|
|
|
### Task 2: Route compat runtime skill loading through sgclaw-owned resolution
|
|
|
|
**Files:**
|
|
- Modify: `/home/zyl/projects/sgClaw/claw/src/compat/config_adapter.rs`
|
|
- Modify: `/home/zyl/projects/sgClaw/claw/src/compat/runtime.rs`
|
|
- Test: `/home/zyl/projects/sgClaw/claw/tests/compat_runtime_test.rs`
|
|
|
|
**Step 1: Write the failing test**
|
|
|
|
Add a compat runtime test that creates:
|
|
- a default workspace skill package under `.sgclaw-zeroclaw-workspace/skills`
|
|
- a custom skill package under another directory configured via `skillsDir`
|
|
|
|
Assert that provider request payload contains only the configured skill name when `skillsDir` is set, and still contains workspace skill names when the override is absent.
|
|
|
|
**Step 2: Run test to verify it fails**
|
|
|
|
Run: `cargo test compat_runtime -- --nocapture`
|
|
|
|
Expected: FAIL because the runtime currently always loads skills from `config.workspace_dir`.
|
|
|
|
**Step 3: Write minimal implementation**
|
|
|
|
Keep `config.workspace_dir` for ZeroClaw internal state, but load skills from the resolved effective skills directory by calling `load_skills_from_directory` directly when a custom directory is configured.
|
|
|
|
**Step 4: Run test to verify it passes**
|
|
|
|
Run: `cargo test compat_runtime -- --nocapture`
|
|
|
|
Expected: PASS and provider request payload shows the right `Available Skills` content.
|
|
|
|
### Task 3: Document and verify backward compatibility
|
|
|
|
**Files:**
|
|
- Modify: `/home/zyl/projects/sgClaw/claw/docs/README.md`
|
|
- Modify: `/home/zyl/projects/sgClaw/claw/docs/L5-提示词分布与安全改造方案.md`
|
|
|
|
**Step 1: Write the failing check**
|
|
|
|
Record the expected runtime behavior:
|
|
- `sgclaw` owns skill lookup
|
|
- SuperRPA only passes `--config-path`
|
|
- `skillsDir` is optional
|
|
|
|
**Step 2: Run verification**
|
|
|
|
Run: `rg -n "skillsDir|sgclaw owns skill lookup|config-path" docs`
|
|
|
|
Expected: missing text before docs are updated.
|
|
|
|
**Step 3: Write minimal documentation**
|
|
|
|
Document:
|
|
- JSON field name
|
|
- relative-path resolution base
|
|
- default fallback
|
|
- operational implication for SuperRPA integration
|
|
|
|
**Step 4: Run verification**
|
|
|
|
Run: `rg -n "skillsDir|sgclaw owns skill lookup|config-path" docs`
|
|
|
|
Expected: PASS with updated docs.
|
|
|
|
### Task 4: Final verification
|
|
|
|
**Files:**
|
|
- Review only: `/home/zyl/projects/sgClaw/claw/src/config/settings.rs`
|
|
- Review only: `/home/zyl/projects/sgClaw/claw/src/compat/config_adapter.rs`
|
|
- Review only: `/home/zyl/projects/sgClaw/claw/src/compat/runtime.rs`
|
|
- Review only: `/home/zyl/projects/sgClaw/claw/tests/compat_config_test.rs`
|
|
- Review only: `/home/zyl/projects/sgClaw/claw/tests/compat_runtime_test.rs`
|
|
|
|
**Step 1: Run targeted tests**
|
|
|
|
Run: `cargo test compat_config -- --nocapture`
|
|
|
|
Expected: PASS
|
|
|
|
**Step 2: Run runtime tests**
|
|
|
|
Run: `cargo test compat_runtime -- --nocapture`
|
|
|
|
Expected: PASS
|
|
|
|
**Step 3: Run skill-lib structural validation**
|
|
|
|
Run: `python3 -m unittest tests.skill_lib_validation_test -v`
|
|
|
|
Expected: PASS
|
|
|
|
**Step 4: Commit**
|
|
|
|
```bash
|
|
git add docs/plans/2026-03-27-sgclaw-configurable-skills-dir-plan.md \
|
|
src/config/settings.rs \
|
|
src/compat/config_adapter.rs \
|
|
src/compat/runtime.rs \
|
|
tests/compat_config_test.rs \
|
|
tests/compat_runtime_test.rs \
|
|
docs/README.md \
|
|
docs/L5-提示词分布与安全改造方案.md
|
|
git commit -m "feat: make sgclaw skills directory configurable"
|
|
```
|