diff --git a/AGENTS.md b/AGENTS.md index 529b1ef..35b05c5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -22,10 +22,9 @@ This repository's custom command prompts are designed for **OpenCode / oh-my-ope ### Prompt format constraints -- Do **not** rely on `allowed-tools` frontmatter for deployed OpenCode commands. Our deploy step strips non-OpenCode frontmatter and keeps only `description`. -- `argument-hint` may exist in source command files for authoring convenience, but it is not preserved in deployed `.opencode/commands/` files. - Avoid prompt text that assumes Claude Code-only primitives such as `AskUserQuestion` or Claude-specific plugin agent names. -- When describing delegation, prefer generic subagent language over implementation-specific names so the same prompt remains portable across OpenCode setups. +- When describing delegation, prefer generic subagent language over implementation-specific names so the same prompt remains portable across setups. +- `zest-dev init` installs packaged skills only to `~/.agents/skills//`; it does not deploy editor-specific command or agent paths. ## Development diff --git a/README.md b/README.md index a1773b8..2d7e45e 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A lightweight, human-interactive development workflow for AI-assisted coding. ## Quick Start -Install the CLI from npm, then initialize the editor-facing commands and skills in your project: +Install the CLI from npm, then install the packaged skills into `~/.agents/skills/`: ```bash npm install -g zest-dev @@ -24,13 +24,9 @@ zest-dev --version zest-dev --help ``` -### Initialize a Project +### Install Skills -From the project where you want to use Zest Dev, run: - -```bash -zest-dev init -``` +`zest-dev init` copies every packaged skill under `skills//` to `~/.agents/skills//`. ### Local Development Setup @@ -75,28 +71,14 @@ If publishing fails, inspect the `Publish npm` workflow run on `main` before ret ## Usage Workflow -Zest Dev uses a **content-contract skill / approach command** model: +Zest Dev uses a **content-contract skill** model: - the `zest-dev` skill owns Spec lifecycle and recording contracts - Section Guides define Overview, Design, Plan, and Implementation content -- two thin commands choose how a new Spec reaches Designed Status +- Design Approaches (lightweight or grilling) are chosen inside the skill workflow - the `zest-dev` CLI manages Spec files and lifecycle state -### Design Approaches - -Use the lightweight route for straightforward work: - -```bash -/zest-dev:lightweight "My new feature" -``` - -Use grilling when the design needs an intensive, one-question-at-a-time decision process: - -```bash -/zest-dev:grilling "My complex feature" -``` - -Both commands create and activate a new Spec, establish its Overview, and reach the same Designed Status. The grilling route composes the registered `grilling` and `domain-modeling` skills. Research is not a separate status or required step; source-backed Research Findings live beside Design Decisions in the Design Record. +Research is not a separate status or required step; source-backed Research Findings live beside Design Decisions in the Design Record. New-format Specs progress through `new → designed → planned → implemented`. @@ -108,6 +90,7 @@ The `zest-dev` CLI manages spec files. Use it to inspect and update specs outsid | Command | Purpose | |---------|---------| +| `zest-dev init` | Install packaged skills to `~/.agents/skills/` | | `zest-dev status` | View project status | | `zest-dev show ` | View spec content | | `zest-dev create ` | Create new spec | @@ -143,13 +126,7 @@ Valid status values: `new`, `designed`, `planned`, `implemented` ### Resource Layout -Zest Dev's editor-facing resources are stored in top-level directories: - -- `commands/` - the lightweight and grilling Design Approach entrypoints -- `skills/` - the Zest Dev skill and its Section Guides -- `agents/` - reusable subagent definitions - -The `plugin/` directory is a Claude Code compatibility layer. It keeps plugin metadata under `plugin/.claude-plugin/`, while `plugin/commands`, `plugin/skills`, and `plugin/agents` are symlinks to the top-level source directories. +Packaged agent skills live under `skills/` and are installed by `zest-dev init` into `~/.agents/skills//`. ### Project Structure diff --git a/bin/zest-dev.js b/bin/zest-dev.js index 2bff330..66f1951 100755 --- a/bin/zest-dev.js +++ b/bin/zest-dev.js @@ -18,64 +18,29 @@ const { dumpSpec, loadIssueRepresentation } = require('../lib/spec-manager'); -const { deployPlugin } = require('../lib/plugin-deployer'); +const { installSkills, getGlobalSkillsDir } = require('../lib/skill-installer'); const { setupRalphFromActiveSpec } = require('../lib/ralph-setup'); const packageJson = require('../package.json'); const program = new Command(); -function getOptionalGlobalOpenCodeCommandDir() { - const xdgConfigHome = process.env.XDG_CONFIG_HOME; - if (xdgConfigHome) { - return path.isAbsolute(xdgConfigHome) - ? path.join(xdgConfigHome, 'opencode', 'commands') - : null; - } - - const homeDir = process.env.HOME || process.env.USERPROFILE; - if (!homeDir || !path.isAbsolute(homeDir)) { +function getOptionalGlobalSkillsDir() { + try { + return getGlobalSkillsDir(); + } catch { return null; } - - return path.join(homeDir, '.config', 'opencode', 'commands'); } -function getOptionalHomeDir() { - const homeDir = process.env.HOME || process.env.USERPROFILE; - return homeDir && path.isAbsolute(homeDir) ? homeDir : null; -} - -function getDeployedCommandDirs() { - const dirs = [ - path.join(process.cwd(), '.cursor/commands'), - path.join(process.cwd(), '.opencode/commands') - ]; - - const globalOpenCodeCommandDir = getOptionalGlobalOpenCodeCommandDir(); - if (globalOpenCodeCommandDir) { - dirs.push(globalOpenCodeCommandDir); - } - - return dirs; -} - -function getDeployedZestDevSkillDirs() { - const dirs = [ - path.join(process.cwd(), '.opencode/skills/zest-dev'), - path.join(process.cwd(), '.agents/skills/zest-dev') - ]; - - const globalOpenCodeCommandDir = getOptionalGlobalOpenCodeCommandDir(); - if (globalOpenCodeCommandDir) { - dirs.push(path.join(path.dirname(globalOpenCodeCommandDir), 'skills/zest-dev')); - } - - const homeDir = getOptionalHomeDir(); - if (homeDir) { - dirs.push(path.join(homeDir, '.agents/skills/zest-dev')); +function hasDeployedSkills() { + const skillsDir = getOptionalGlobalSkillsDir(); + if (!skillsDir || !fs.existsSync(skillsDir)) { + return false; } - return dirs; + return fs.readdirSync(skillsDir, { withFileTypes: true }).some(entry => + entry.isDirectory() && fs.existsSync(path.join(skillsDir, entry.name, 'SKILL.md')) + ); } function isFzfAvailable() { @@ -136,23 +101,6 @@ async function selectSpecInteractively(specs) { }); } -function hasDeployedCommandMarkdowns() { - return getDeployedCommandDirs().some(dirPath => { - if (!fs.existsSync(dirPath)) { - return false; - } - - const files = fs.readdirSync(dirPath); - return files.some(file => /^zest-dev-.*\.md$/.test(file)); - }); -} - -function hasDeployedZestDevSkill() { - return getDeployedZestDevSkillDirs().some(dirPath => - fs.existsSync(path.join(dirPath, 'SKILL.md')) - ); -} - program .name('zest-dev') .description('A lightweight, human-interactive development workflow for AI-assisted coding') @@ -165,9 +113,9 @@ program .action(() => { try { const status = getSpecsStatus(); - if (hasDeployedCommandMarkdowns() || hasDeployedZestDevSkill()) { + if (hasDeployedSkills()) { status.agent_hints = [ - 'Run `zest-dev init` to update deployed commands and skills.' + 'Run `zest-dev init` to update deployed skills.' ]; } @@ -305,19 +253,10 @@ program // zest-dev init program .command('init') - .description('Initialize plugin deployment for OpenCode and/or Codex') - .option('--global', 'Deploy to global user locations (default)') - .option('--local', 'Deploy to the current project directory') - .option('-t, --target ', 'Deployment target (all|opencode|codex)') - .action((options) => { + .description('Install packaged skills to ~/.agents/skills') + .action(() => { try { - if (options.global && options.local) { - throw new Error('Cannot specify both --global and --local'); - } - - const scope = options.local ? 'local' : 'global'; - const target = options.target || (scope === 'local' ? 'opencode' : 'all'); - const result = deployPlugin({ scope, target }); + const result = installSkills(); console.log(yaml.dump(result)); } catch (error) { console.error('Error:', error.message); diff --git a/e2e/tests/conftest.py b/e2e/tests/conftest.py index 94923cb..7a0989b 100644 --- a/e2e/tests/conftest.py +++ b/e2e/tests/conftest.py @@ -11,13 +11,11 @@ from helpers.paths import REPO_ROOT -EXPECTED_COMMANDS = [ - "zest-dev-grilling.md", - "zest-dev-lightweight.md", +EXPECTED_SKILLS = [ + "t3-task", + "zest-dev", ] -THIN_COMMANDS = EXPECTED_COMMANDS SKILL_SECTION_FILES = ["overview.md", "design.md", "plan.md", "implementation.md"] -CODEX_SUBAGENTS = ["code-architect.toml", "code-explorer.toml", "code-reviewer.toml"] FINAL_RALPH_TASK = ( "Make sure all tasks are done in ralph loops, and then create PR. " "If there is a related issue, make sure to link it in the PR." @@ -106,13 +104,6 @@ def frontmatter(content: str, filename: str) -> dict: return parsed -def assert_plugin_resource_symlink_at(root_dir: Path, name: str) -> None: - plugin_path = root_dir / "plugin" / name - top_level_path = root_dir / name - assert plugin_path.is_symlink(), f"plugin/{name} should be a symlink" - assert plugin_path.resolve() == top_level_path.resolve() - - def create_dangling_active_symlink(project_dir: Path, target_id: str) -> None: active_link = project_dir / "specs" / "change" / "active" try: diff --git a/e2e/tests/test_init_deployment.py b/e2e/tests/test_init_deployment.py index 527c59f..03e30c2 100644 --- a/e2e/tests/test_init_deployment.py +++ b/e2e/tests/test_init_deployment.py @@ -1,105 +1,60 @@ from pathlib import Path from conftest import ( - CODEX_SUBAGENTS, - EXPECTED_COMMANDS, + EXPECTED_SKILLS, SKILL_SECTION_FILES, - THIN_COMMANDS, - assert_plugin_resource_symlink_at, - frontmatter, isolated_global_env, ) -def test_plugin_resource_directories_are_compatibility_symlinks(): - repo_root = Path(__file__).resolve().parents[2] - for name in ["commands", "skills", "agents"]: - assert_plugin_resource_symlink_at(repo_root, name) - - -def test_packaged_plugin_resource_directories_are_compatibility_symlinks(cli): - if not cli.is_packaged: - import pytest - - pytest.skip("packaged CLI root is only available in package E2E runs") - - for name in ["commands", "skills", "agents"]: - assert_plugin_resource_symlink_at(cli.packaged_cli_root, name) - - -def test_default_global_init_deploys_expected_artifacts(cli): +def test_default_global_init_installs_all_packaged_skills(cli): env = isolated_global_env(cli.project_dir) fake_home = Path(env["HOME"]) - fake_xdg = Path(env["XDG_CONFIG_HOME"]) - global_open_code = fake_xdg / "opencode" output = cli.yaml("init", env=env) assert output["ok"] is True - assert output["scope"] == "global" - assert output["target"] == "all" - assert "cursor" not in output - assert output["opencode"]["baseDir"] == str(global_open_code) - assert output["codex"]["baseDir"] == str(fake_home) - assert output["codex"]["commands"] == [] - assert output["opencode"]["agents"] == [] - assert output["opencode"]["commands"] == EXPECTED_COMMANDS - assert output["codex"]["agents"] == CODEX_SUBAGENTS - - commands_dir = global_open_code / "commands" - skills_dir = global_open_code / "skills" - codex_skill_dir = fake_home / ".agents" / "skills" / "zest-dev" - codex_agents_dir = fake_home / ".codex" / "agents" - assert commands_dir.exists() - assert skills_dir.exists() - assert codex_skill_dir.exists() - assert codex_agents_dir.exists() - assert not (skills_dir / "brainstorming").exists() - assert not (fake_home / ".agents" / "skills" / "brainstorming").exists() + assert output["skillsDir"] == str(fake_home / ".agents" / "skills") + assert output["skills"] == [f"{name}/" for name in EXPECTED_SKILLS] + assert "opencode" not in output + assert "codex" not in output + assert "scope" not in output + assert "target" not in output + assert not (cli.project_dir / ".opencode").exists() + assert not (cli.project_dir / ".codex").exists() assert not (cli.project_dir / ".cursor").exists() assert not (cli.project_dir / "AGENTS.md").exists() + assert not (Path(env["XDG_CONFIG_HOME"]) / "opencode").exists() + assert not (fake_home / ".codex").exists() - for filename in EXPECTED_COMMANDS: - assert (commands_dir / filename).exists() - - assert sorted(p.name for p in codex_agents_dir.iterdir()) == CODEX_SUBAGENTS - assert not (codex_skill_dir / "commands").exists() - - for filename in EXPECTED_COMMANDS: - assert (commands_dir / filename).read_text(encoding="utf-8").startswith("---\n") + skills_dir = fake_home / ".agents" / "skills" + assert skills_dir.exists() + assert sorted(p.name for p in skills_dir.iterdir() if p.is_dir()) == EXPECTED_SKILLS - lightweight_command = commands_dir / "zest-dev-lightweight.md" - metadata = frontmatter(lightweight_command.read_text(encoding="utf-8"), "zest-dev-lightweight.md") - assert metadata.get("description") - assert "argument-hint" not in metadata - assert "allowed-tools" not in metadata - assert list(metadata) == ["description"] + source_root = cli.packaged_cli_root if cli.is_packaged else Path(__file__).resolve().parents[2] - for filename in EXPECTED_COMMANDS: - assert "$ARGUMENTS" in (commands_dir / filename).read_text(encoding="utf-8") + for skill_name in EXPECTED_SKILLS: + skill_dir = skills_dir / skill_name + assert (skill_dir / "SKILL.md").exists() + source_skill = (source_root / "skills" / skill_name / "SKILL.md").read_text(encoding="utf-8") + assert (skill_dir / "SKILL.md").read_text(encoding="utf-8") == source_skill - for filename in THIN_COMMANDS: - assert "**Step 1:" not in (commands_dir / filename).read_text(encoding="utf-8") + zest_dev_dir = skills_dir / "zest-dev" + for filename in SKILL_SECTION_FILES: + assert (zest_dev_dir / filename).exists() + expected = (source_root / "skills" / "zest-dev" / filename).read_text(encoding="utf-8") + assert (zest_dev_dir / filename).read_text(encoding="utf-8") == expected - skill_content = (skills_dir / "zest-dev" / "SKILL.md").read_text(encoding="utf-8") + skill_content = (zest_dev_dir / "SKILL.md").read_text(encoding="utf-8") assert "new → designed → planned → implemented" in skill_content assert "Statuses describe content maturity" in skill_content assert "Section Guide routing" in skill_content assert "Do not stop at an intermediate status" in skill_content - for filename in SKILL_SECTION_FILES: - assert (skills_dir / "zest-dev" / filename).exists() - - source_root = cli.packaged_cli_root if cli.is_packaged else Path(__file__).resolve().parents[2] - source_skill_dir = source_root / "skills" / "zest-dev" - for filename in ["SKILL.md", *SKILL_SECTION_FILES]: - expected = (source_skill_dir / filename).read_text(encoding="utf-8") - assert (skills_dir / "zest-dev" / filename).read_text(encoding="utf-8") == expected - assert (codex_skill_dir / filename).read_text(encoding="utf-8") == expected - overview_guide = (skills_dir / "zest-dev" / "overview.md").read_text(encoding="utf-8") + overview_guide = (zest_dev_dir / "overview.md").read_text(encoding="utf-8") assert "Overview content contract" in overview_guide assert "recommended next" not in overview_guide - design_guide = (skills_dir / "zest-dev" / "design.md").read_text(encoding="utf-8") + design_guide = (zest_dev_dir / "design.md").read_text(encoding="utf-8") assert "Research Findings" in design_guide assert "Design Decisions" in design_guide assert "Lightweight Design Approach" in design_guide @@ -116,7 +71,7 @@ def test_default_global_init_deploys_expected_artifacts(cli): assert "one-time, Spec-local acceptance step" in design_guide assert "## Deferred Follow-Ups (DFU)" in design_guide - plan_guide = (skills_dir / "zest-dev" / "plan.md").read_text(encoding="utf-8") + plan_guide = (zest_dev_dir / "plan.md").read_text(encoding="utf-8") assert "`to-tickets`" in plan_guide assert "Do not create GitHub issues or external issue-tracker entries unless the user explicitly asks for that." in plan_guide assert "Do not use markdown checkboxes in `## Plan`." in plan_guide @@ -125,7 +80,7 @@ def test_default_global_init_deploys_expected_artifacts(cli): assert "Add or update `spec.md` → `## Progress` with a thin progress checklist:" in plan_guide assert "EAG Validation ticket" in plan_guide - implementation_guide = (skills_dir / "zest-dev" / "implementation.md").read_text(encoding="utf-8") + implementation_guide = (zest_dev_dir / "implementation.md").read_text(encoding="utf-8") assert "`tdd`" not in implementation_guide assert "tests relevant to changed behavior" in implementation_guide assert "If required evidence, configuration, credentials, or a consequential Design decision is missing" in implementation_guide @@ -136,169 +91,44 @@ def test_default_global_init_deploys_expected_artifacts(cli): assert "`## Progress` checkbox as `[x]`" in implementation_guide assert "Design Phase" not in implementation_guide - codex_skill = (codex_skill_dir / "SKILL.md").read_text(encoding="utf-8") - assert "new → designed → planned → implemented" in codex_skill - for subagent in CODEX_SUBAGENTS: - content = (codex_agents_dir / subagent).read_text(encoding="utf-8") - assert "name = " in content - assert "developer_instructions = " in content + assert (skills_dir / "t3-task" / "SKILL.md").exists() -def test_global_init_reruns_clean_only_managed_files(cli): +def test_init_reruns_clean_only_removed_zest_dev_files(cli): env = isolated_global_env(cli.project_dir) cli.yaml("init", env=env) - global_open_code = Path(env["XDG_CONFIG_HOME"]) / "opencode" - - skill_dirs = [ - global_open_code / "skills" / "zest-dev", - Path(env["HOME"]) / ".agents" / "skills" / "zest-dev", - ] - for skill_dir in skill_dirs: - for legacy_name in ["new.md", "research.md", "implement.md"]: - (skill_dir / legacy_name).write_text("# stale section guide", encoding="utf-8") - (skill_dir / "my-notes.md").write_text("# user file", encoding="utf-8") - explicit = cli.yaml("init", "--global", env=env) - assert explicit["scope"] == "global" - assert explicit["target"] == "all" - assert sorted(p.name for p in (global_open_code / "commands").iterdir()) == EXPECTED_COMMANDS - for skill_dir in skill_dirs: - for legacy_name in ["new.md", "research.md", "implement.md"]: - assert not (skill_dir / legacy_name).exists() - assert (skill_dir / "my-notes.md").exists() + skill_dir = Path(env["HOME"]) / ".agents" / "skills" / "zest-dev" + for legacy_name in ["new.md", "research.md", "implement.md"]: + (skill_dir / legacy_name).write_text("# stale section guide", encoding="utf-8") + (skill_dir / "my-notes.md").write_text("# user file", encoding="utf-8") - agents_dir = global_open_code / "agents" - nested_dir = agents_dir / "nested-dir" - nested_dir.mkdir(parents=True, exist_ok=True) - stale_legacy = agents_dir / "code-explorer.md" - user_agent = agents_dir / "my-custom-agent.md" - stale_legacy.write_text("# stale legacy agent", encoding="utf-8") - user_agent.write_text("# user agent", encoding="utf-8") - - assert cli.yaml("init", env=env)["ok"] is True - assert not stale_legacy.exists() - assert user_agent.exists() - assert agents_dir.exists() - assert nested_dir.exists() - - commands_dir = global_open_code / "commands" - stale_managed = commands_dir / "zest-dev-archive.md" - user_command = commands_dir / "my-command.md" - stale_managed.write_text("# stale managed command", encoding="utf-8") - user_command.write_text("# user command", encoding="utf-8") - - assert cli.yaml("init", env=env)["ok"] is True - assert not stale_managed.exists() - assert user_command.exists() - assert sorted(p.name for p in commands_dir.iterdir()) == sorted([*EXPECTED_COMMANDS, "my-command.md"]) - user_command.unlink() - - assert cli.yaml("init", env=env)["ok"] is True - assert len(list((global_open_code / "commands").iterdir())) == len(EXPECTED_COMMANDS) - assert sorted(p.name for p in (Path(env["HOME"]) / ".codex" / "agents").iterdir()) == CODEX_SUBAGENTS - - -def test_local_and_target_specific_init_layouts(cli): - env = isolated_global_env(cli.project_dir / "global-env") - local_output = cli.yaml("init", "--local", env=env) - assert local_output["scope"] == "local" - assert local_output["target"] == "opencode" - assert local_output["opencode"]["baseDir"] == str(cli.project_dir) - assert local_output["codex"]["baseDir"] == str(cli.project_dir) - assert (cli.project_dir / ".opencode" / "commands").exists() - assert (cli.project_dir / ".opencode" / "skills").exists() - assert not (cli.project_dir / ".agents" / "skills" / "zest-dev").exists() - assert not (cli.project_dir / ".codex" / "agents").exists() - - codex_output = cli.yaml("init", "--local", "--target", "codex", env=env) - assert codex_output["scope"] == "local" - assert codex_output["target"] == "codex" - assert codex_output["opencode"]["commands"] == [] - assert (cli.project_dir / ".agents" / "skills" / "zest-dev").exists() - assert (cli.project_dir / ".codex" / "agents").exists() - assert sorted(p.name for p in (cli.project_dir / ".codex" / "agents").iterdir()) == CODEX_SUBAGENTS - assert not (cli.project_dir / ".agents" / "skills" / "zest-dev" / "commands").exists() - - legacy_commands = cli.project_dir / ".agents" / "skills" / "zest-dev" / "commands" - legacy_commands.mkdir(parents=True, exist_ok=True) - legacy_zest = legacy_commands / "zest-dev-new.md" - user_command = legacy_commands / "my-command.md" - legacy_zest.write_text("# legacy zest command", encoding="utf-8") - user_command.write_text("# user command", encoding="utf-8") - assert cli.yaml("init", "--local", "--target", "codex", env=env)["ok"] is True - assert not legacy_zest.exists() - assert user_command.exists() - - local_all_dir = cli.project_dir / "local-all" - local_all_dir.mkdir() - local_all_env = isolated_global_env(local_all_dir) - local_all = cli.yaml("init", "--local", "--target", "all", cwd=local_all_dir, env=local_all_env) - assert local_all["scope"] == "local" - assert local_all["target"] == "all" - assert (local_all_dir / ".opencode" / "commands").exists() - assert (local_all_dir / ".opencode" / "skills").exists() - assert (local_all_dir / ".agents" / "skills" / "zest-dev").exists() - assert (local_all_dir / ".codex" / "agents").exists() - assert not (local_all_dir / ".agents" / "skills" / "zest-dev" / "commands").exists() - - opencode_only = cli.project_dir / "opencode-only" - opencode_only.mkdir() - opencode_env = isolated_global_env(opencode_only) - opencode_result = cli.yaml("init", "--target", "opencode", cwd=opencode_only, env=opencode_env) - assert opencode_result["target"] == "opencode" - assert opencode_result["codex"]["baseDir"] is None - assert (Path(opencode_env["XDG_CONFIG_HOME"]) / "opencode" / "commands").exists() - assert not (Path(opencode_env["HOME"]) / ".codex" / "agents").exists() + output = cli.yaml("init", env=env) + assert output["ok"] is True + assert output["skills"] == [f"{name}/" for name in EXPECTED_SKILLS] - codex_only = cli.project_dir / "codex-only" - codex_only.mkdir() - codex_env = isolated_global_env(codex_only) - codex_result = cli.yaml("init", "--target", "codex", cwd=codex_only, env=codex_env) - assert codex_result["target"] == "codex" - assert codex_result["opencode"]["baseDir"] is None - assert (Path(codex_env["HOME"]) / ".codex" / "agents").exists() - assert not (Path(codex_env["XDG_CONFIG_HOME"]) / "opencode" / "commands").exists() + for legacy_name in ["new.md", "research.md", "implement.md"]: + assert not (skill_dir / legacy_name).exists() + assert (skill_dir / "my-notes.md").exists() - no_home_dir = cli.project_dir / "opencode-without-home" - no_home_dir.mkdir() - no_home_env = {"HOME": "", "XDG_CONFIG_HOME": str(no_home_dir / "xdg-config")} - no_home = cli.yaml("init", "--target", "opencode", cwd=no_home_dir, env=no_home_env) - assert no_home["target"] == "opencode" - assert (Path(no_home_env["XDG_CONFIG_HOME"]) / "opencode" / "commands").exists() - relative_xdg_dir = cli.project_dir / "codex-with-relative-xdg" - relative_xdg_dir.mkdir() - relative_env = {"HOME": str(relative_xdg_dir / "home"), "XDG_CONFIG_HOME": "relative-config"} - Path(relative_env["HOME"]).mkdir() - relative_result = cli.yaml("init", "--target", "codex", cwd=relative_xdg_dir, env=relative_env) - assert relative_result["target"] == "codex" - assert (Path(relative_env["HOME"]) / ".codex" / "agents").exists() - assert not (relative_xdg_dir / "relative-config").exists() +def test_init_rejects_removed_flags(cli): + env = isolated_global_env(cli.project_dir) + for args in [("--local",), ("--global",), ("--target", "opencode"), ("--target", "codex")]: + failed = cli.fail("init", *args, env=env) + assert "unknown option" in failed.lower() or "unknown command" in failed.lower() or "error:" in failed.lower() + assert not (Path(env["HOME"]) / ".agents" / "skills").exists() + assert not (cli.project_dir / ".opencode").exists() + assert not (cli.project_dir / ".codex").exists() def test_init_failures_write_nothing(cli): - invalid_dir = cli.project_dir / "invalid-target" - invalid_dir.mkdir() - invalid_env = isolated_global_env(invalid_dir) - failed = cli.fail("init", "--target", "invalid", cwd=invalid_dir, env=invalid_env) - assert "Invalid target: invalid. Expected one of: all, opencode, codex" in failed - assert not (Path(invalid_env["XDG_CONFIG_HOME"]) / "opencode").exists() - assert not (Path(invalid_env["HOME"]) / ".codex").exists() - - conflicting_dir = cli.project_dir / "conflicting-scope" - conflicting_dir.mkdir() - conflicting_env = isolated_global_env(conflicting_dir) - failed = cli.fail("init", "--global", "--local", cwd=conflicting_dir, env=conflicting_env) - assert "Cannot specify both --global and --local" in failed - assert not (conflicting_dir / ".opencode").exists() - assert not (Path(conflicting_env["XDG_CONFIG_HOME"]) / "opencode").exists() - relative_dir = cli.project_dir / "relative-env" relative_dir.mkdir() - failed = cli.fail("init", cwd=relative_dir, env={"HOME": str(relative_dir / "home"), "XDG_CONFIG_HOME": "relative-config"}) - assert "XDG_CONFIG_HOME must be an absolute path: relative-config" in failed - assert not (relative_dir / "relative-config").exists() - failed = cli.fail("init", cwd=relative_dir, env={"HOME": "relative-home", "XDG_CONFIG_HOME": ""}) + failed = cli.fail("init", cwd=relative_dir, env={"HOME": "relative-home", "USERPROFILE": ""}) assert "HOME must be an absolute path: relative-home" in failed assert not (relative_dir / "relative-home").exists() + + failed = cli.fail("init", cwd=relative_dir, env={"HOME": "", "USERPROFILE": ""}) + assert "HOME is not set" in failed diff --git a/e2e/tests/test_prompt.py b/e2e/tests/test_prompt.py index 1c74ec5..f7ba887 100644 --- a/e2e/tests/test_prompt.py +++ b/e2e/tests/test_prompt.py @@ -1,23 +1,3 @@ def test_cli_removes_general_prompt_generation(cli): failed = cli.fail("prompt", "lightweight") assert "unknown command 'prompt'" in failed - - -def test_init_deploys_design_approach_entrypoints(cli): - cli.ok("init", "--local") - commands_dir = cli.project_dir / ".opencode" / "commands" - - lightweight = (commands_dir / "zest-dev-lightweight.md").read_text(encoding="utf-8") - assert "Lightweight Design Approach" in lightweight - assert "Designed Status" in lightweight - assert "$ARGUMENTS" in lightweight - - grilling = (commands_dir / "zest-dev-grilling.md").read_text(encoding="utf-8") - assert "Grilling Design Approach" in grilling - assert "Designed Status" in grilling - assert "$ARGUMENTS" in grilling - - assert sorted(path.name for path in commands_dir.glob("zest-dev-*.md")) == [ - "zest-dev-grilling.md", - "zest-dev-lightweight.md", - ] diff --git a/e2e/tests/test_spec_lifecycle.py b/e2e/tests/test_spec_lifecycle.py index 9c77be4..845b9ef 100644 --- a/e2e/tests/test_spec_lifecycle.py +++ b/e2e/tests/test_spec_lifecycle.py @@ -185,33 +185,21 @@ def test_status_agent_hints(cli): cli.ok("create", "first-spec") cli.ok("create", "second-spec") - cursor_commands = cli.project_dir / ".cursor" / "commands" - cursor_commands.mkdir(parents=True) - (cursor_commands / "zest-dev-new.md").write_text("# test", encoding="utf-8") - update_hint = "Run `zest-dev init` to update deployed commands and skills." - assert cli.yaml("status", env=status_env)["agent_hints"] == [update_hint] + update_hint = "Run `zest-dev init` to update deployed skills." + assert "agent_hints" not in cli.yaml("status", env=status_env) - global_env = isolated_global_env(cli.project_dir / "global-hint-env") - (cursor_commands / "zest-dev-new.md").unlink() - global_commands = Path(global_env["XDG_CONFIG_HOME"]) / "opencode" / "commands" - global_commands.mkdir(parents=True) - (global_commands / "zest-dev-new.md").write_text("# test", encoding="utf-8") - assert cli.yaml("status", env=global_env)["agent_hints"] == [update_hint] + skills_dir = Path(status_env["HOME"]) / ".agents" / "skills" / "zest-dev" + skills_dir.mkdir(parents=True) + (skills_dir / "SKILL.md").write_text("# deployed skill", encoding="utf-8") + assert cli.yaml("status", env=status_env)["agent_hints"] == [update_hint] - status = cli.yaml("status", env={"HOME": "", "XDG_CONFIG_HOME": "relative-config"}) + status = cli.yaml("status", env={"HOME": "", "USERPROFILE": "", "XDG_CONFIG_HOME": "relative-config"}) assert status["specs_count"] == 2 + assert "agent_hints" not in status - other_commands = cli.project_dir / ".opencode" / "commands" - other_commands.mkdir(parents=True) - (other_commands / "pr.md").write_text("# unrelated", encoding="utf-8") - (global_commands / "zest-dev-new.md").unlink() + (skills_dir / "SKILL.md").unlink() assert "agent_hints" not in cli.yaml("status", env=status_env) - local_codex_skill = cli.project_dir / ".agents" / "skills" / "zest-dev" - local_codex_skill.mkdir(parents=True) - (local_codex_skill / "SKILL.md").write_text("# deployed skill", encoding="utf-8") - assert cli.yaml("status", env=status_env)["agent_hints"] == [update_hint] - def test_update_and_active_alias(cli): first = cli.yaml("create", "first-spec")["spec"]["id"] diff --git a/lib/plugin-deployer.js b/lib/plugin-deployer.js deleted file mode 100644 index 918333c..0000000 --- a/lib/plugin-deployer.js +++ /dev/null @@ -1,460 +0,0 @@ -const fs = require('fs'); -const path = require('path'); -const yaml = require('js-yaml'); - -const VALID_TARGETS = ['all', 'opencode', 'codex']; -const VALID_SCOPES = ['global', 'local']; -const SOURCE_COMMANDS_DIR = path.join(__dirname, '../commands'); -const SOURCE_SKILLS_DIR = path.join(__dirname, '../skills'); -const SOURCE_AGENTS_DIR = path.join(__dirname, '../agents'); -const LEGACY_OPENCODE_AGENT_FILENAMES = new Set([ - 'code-architect.md', - 'code-explorer.md', - 'code-reviewer.md' -]); -const REMOVED_ZEST_DEV_SKILL_FILES = new Set(['new.md', 'research.md', 'implement.md']); - -/** - * Parse markdown file with frontmatter - * @param {string} filePath - Path to markdown file - * @returns {{ frontmatter: Object, content: string }} Parsed frontmatter and content - */ -function parseMarkdownWithFrontmatter(filePath) { - const content = fs.readFileSync(filePath, 'utf-8'); - const match = content.match(/^---\n([\s\S]*?)\n---/); - - if (!match) { - // No frontmatter, return empty object and full content - return { frontmatter: {}, content: content }; - } - - const frontmatterYaml = match[1]; - const bodyContent = content.slice(match[0].length).trim(); - - try { - const frontmatter = yaml.load(frontmatterYaml) || {}; - return { frontmatter, content: bodyContent }; - } catch (error) { - throw new Error(`Failed to parse frontmatter in ${filePath}: ${error.message}`); - } -} - -/** - * Transform frontmatter for OpenCode (remove Claude Code specific fields) - * @param {Object} frontmatter - Original frontmatter object - * @returns {Object} Transformed frontmatter with only description - */ -function transformFrontmatter(frontmatter) { - // Keep only description field - const transformed = {}; - if (frontmatter.description) { - transformed.description = frontmatter.description; - } - return transformed; -} - -/** - * Write markdown file with frontmatter - * @param {string} targetPath - Target file path - * @param {Object} frontmatter - Frontmatter object - * @param {string} content - Body content - */ -function writeMarkdownWithFrontmatter(targetPath, frontmatter, content) { - const frontmatterYaml = yaml.dump(frontmatter, { lineWidth: -1 }).trim(); - const fileContent = `---\n${frontmatterYaml}\n---\n\n${content}`; - fs.writeFileSync(targetPath, fileContent, 'utf-8'); -} - -/** - * Create target directories if they don't exist - */ -function getHomeDirectory() { - return process.env.HOME || process.env.USERPROFILE; -} - -function assertAbsolutePath(name, value) { - if (!path.isAbsolute(value)) { - throw new Error(`${name} must be an absolute path: ${value}`); - } -} - -function getGlobalOpenCodeBaseDir() { - const xdgConfigHome = process.env.XDG_CONFIG_HOME; - if (xdgConfigHome) { - assertAbsolutePath('XDG_CONFIG_HOME', xdgConfigHome); - return path.join(xdgConfigHome, 'opencode'); - } - - const homeDir = getHomeDirectory(); - if (!homeDir) { - throw new Error('HOME is not set'); - } - assertAbsolutePath('HOME', homeDir); - - return path.join(homeDir, '.config', 'opencode'); -} - -function getTargetPaths(scope) { - if (!VALID_SCOPES.includes(scope)) { - throw new Error(`Invalid scope: ${scope}. Expected one of: ${VALID_SCOPES.join(', ')}`); - } - - if (scope === 'local') { - const baseDir = process.cwd(); - return { - baseDir, - opencode: getLocalOpenCodePaths(baseDir), - codex: getLocalCodexPaths(baseDir) - }; - } - - return { - opencode: getGlobalOpenCodePaths, - codex: getGlobalCodexPaths - }; -} - -function getLocalOpenCodePaths(baseDir = process.cwd()) { - return { - baseDir, - commandsDir: path.join(baseDir, '.opencode/commands'), - skillsDir: path.join(baseDir, '.opencode/skills'), - legacyAgentsDir: path.join(baseDir, '.opencode/agents') - }; -} - -function getLocalCodexPaths(baseDir = process.cwd()) { - return { - baseDir, - commandsDir: null, - skillsDir: path.join(baseDir, '.agents/skills/zest-dev'), - agentsDir: path.join(baseDir, '.codex/agents') - }; -} - -function getGlobalOpenCodePaths() { - const openCodeBaseDir = getGlobalOpenCodeBaseDir(); - - return { - baseDir: openCodeBaseDir, - commandsDir: path.join(openCodeBaseDir, 'commands'), - skillsDir: path.join(openCodeBaseDir, 'skills'), - legacyAgentsDir: path.join(openCodeBaseDir, 'agents') - }; -} - -function getGlobalCodexPaths() { - const homeDir = getHomeDirectory(); - if (!homeDir) { - throw new Error('HOME is not set'); - } - assertAbsolutePath('HOME', homeDir); - - return { - baseDir: homeDir, - commandsDir: null, - skillsDir: path.join(homeDir, '.agents/skills/zest-dev'), - agentsDir: path.join(homeDir, '.codex/agents') - }; -} - -function resolveTargetPaths(scope, target) { - const targetPathResolvers = getTargetPaths(scope); - if (typeof targetPathResolvers.opencode !== 'function' && typeof targetPathResolvers.codex !== 'function') { - return targetPathResolvers; - } - - const paths = {}; - - if (target === 'all' || target === 'opencode') { - paths.opencode = typeof targetPathResolvers.opencode === 'function' - ? targetPathResolvers.opencode() - : targetPathResolvers.opencode; - } - - if (target === 'all' || target === 'codex') { - paths.codex = typeof targetPathResolvers.codex === 'function' - ? targetPathResolvers.codex() - : targetPathResolvers.codex; - } - - return paths; -} - -function ensureDirectories(dirs) { - dirs.forEach(dir => { - fs.mkdirSync(dir, { recursive: true }); - }); -} - -/** - * Remove legacy deployed agent files without deleting directories - * - * Legacy installs may have written files into .opencode/agents. - * We no longer deploy agents, but should clean stale files on init. - */ -function cleanupLegacyAgentFiles(agentsDir) { - if (!fs.existsSync(agentsDir)) { - return; - } - - const entries = fs.readdirSync(agentsDir, { withFileTypes: true }); - entries.forEach(entry => { - if (entry.isFile() && LEGACY_OPENCODE_AGENT_FILENAMES.has(entry.name)) { - fs.unlinkSync(path.join(agentsDir, entry.name)); - } - }); -} - -function cleanupLegacyCodexCommandPrompts(skillDir) { - const commandsDir = path.join(skillDir, 'commands'); - if (!fs.existsSync(commandsDir)) { - return; - } - - const entries = fs.readdirSync(commandsDir, { withFileTypes: true }); - entries.forEach(entry => { - if (entry.isFile() && /^zest-dev-.*\.md$/.test(entry.name)) { - fs.unlinkSync(path.join(commandsDir, entry.name)); - } - }); - - if (fs.readdirSync(commandsDir).length === 0) { - fs.rmdirSync(commandsDir); - } -} - -function cleanupRemovedZestDevSkillFiles(skillDir) { - if (!fs.existsSync(skillDir)) { - return; - } - - REMOVED_ZEST_DEV_SKILL_FILES.forEach(filename => { - const filePath = path.join(skillDir, filename); - if (fs.existsSync(filePath)) { - fs.unlinkSync(filePath); - } - }); -} - -function cleanupRemovedCommandPrompts(commandsDir, expectedCommandFiles) { - if (!fs.existsSync(commandsDir)) { - return; - } - - const expectedFiles = new Set(expectedCommandFiles); - const entries = fs.readdirSync(commandsDir, { withFileTypes: true }); - - entries.forEach(entry => { - if (!entry.isFile()) { - return; - } - - if (/^zest-dev-.*\.md$/.test(entry.name) && !expectedFiles.has(entry.name)) { - fs.unlinkSync(path.join(commandsDir, entry.name)); - } - }); -} - -/** - * Copy directory recursively - * @param {string} source - Source directory - * @param {string} target - Target directory - */ -function copyDirectoryRecursive(source, target) { - const entries = fs.readdirSync(source, { withFileTypes: true }); - - entries.forEach(entry => { - const sourcePath = path.join(source, entry.name); - const targetPath = path.join(target, entry.name); - - if (entry.isDirectory()) { - fs.mkdirSync(targetPath, { recursive: true }); - copyDirectoryRecursive(sourcePath, targetPath); - } else { - fs.copyFileSync(sourcePath, targetPath); - } - }); -} - -/** - * Deploy command files to OpenCode directory - * @returns {string[]} Deployed file lists - */ -function deployCommands(commandsDir) { - const sourceDir = SOURCE_COMMANDS_DIR; - const commandFiles = fs.readdirSync(sourceDir) - .filter(f => f.endsWith('.md')) - .sort(); // Ensure consistent order - const deployedCommandFiles = commandFiles.map(filename => `zest-dev-${filename}`); - - cleanupRemovedCommandPrompts(commandsDir, deployedCommandFiles); - - const result = []; - - commandFiles.forEach(filename => { - const sourcePath = path.join(sourceDir, filename); - const { frontmatter, content } = parseMarkdownWithFrontmatter(sourcePath); - - // Transform frontmatter (same for both targets) - const transformedFrontmatter = transformFrontmatter(frontmatter); - - // Generate prefixed filename - const prefixedFilename = `zest-dev-${filename}`; - - // Deploy to OpenCode - const targetPath = path.join(commandsDir, prefixedFilename); - writeMarkdownWithFrontmatter(targetPath, transformedFrontmatter, content); - result.push(prefixedFilename); - }); - - return result; -} - -/** - * Deploy skill files to OpenCode directory - * @returns {string[]} Deployed directory lists - */ -function deploySkills(skillsRootDir) { - const skillsDir = SOURCE_SKILLS_DIR; - const skillDirs = fs.readdirSync(skillsDir, { withFileTypes: true }) - .filter(entry => entry.isDirectory()) - .map(entry => entry.name) - .sort(); - - const result = []; - - skillDirs.forEach(skillName => { - const sourceDir = path.join(skillsDir, skillName); - - // Copy to OpenCode - const opencodeTarget = path.join(skillsRootDir, skillName); - fs.mkdirSync(opencodeTarget, { recursive: true }); - if (skillName === 'zest-dev') { - cleanupRemovedZestDevSkillFiles(opencodeTarget); - } - copyDirectoryRecursive(sourceDir, opencodeTarget); - result.push(skillName + '/'); - }); - - return result; -} - -/** - * Deploy skills for Codex layout - * @returns {string[]} Deployed files/dirs - */ -function deployCodexSkills(targetDir) { - const sourceDir = path.join(SOURCE_SKILLS_DIR, 'zest-dev'); - fs.mkdirSync(targetDir, { recursive: true }); - cleanupLegacyCodexCommandPrompts(targetDir); - cleanupRemovedZestDevSkillFiles(targetDir); - copyDirectoryRecursive(sourceDir, targetDir); - - const entries = fs.readdirSync(targetDir, { withFileTypes: true }) - .map(entry => entry.isDirectory() ? `${entry.name}/` : entry.name) - .sort(); - - return entries; -} - -function toTomlMultiline(value) { - return `"""${value.replace(/"""/g, '\\"\\"\\"')}"""`; -} - -/** - * Deploy exactly three codex subagent TOML files - * @returns {string[]} deployed agent filenames - */ -function deployCodexSubagents(targetDir) { - const sourceDir = SOURCE_AGENTS_DIR; - const expectedAgents = ['code-architect', 'code-explorer', 'code-reviewer']; - const deployed = []; - - expectedAgents.forEach(agentName => { - const sourcePath = path.join(sourceDir, `${agentName}.md`); - const { frontmatter, content } = parseMarkdownWithFrontmatter(sourcePath); - - const tomlContent = [ - `name = "${frontmatter.name || agentName}"`, - `description = ${toTomlMultiline(frontmatter.description || '')}`, - `developer_instructions = ${toTomlMultiline(content)}`, - '' - ].join('\n'); - - const targetFilename = `${agentName}.toml`; - fs.writeFileSync(path.join(targetDir, targetFilename), tomlContent, 'utf-8'); - deployed.push(targetFilename); - }); - - return deployed; -} - -/** - * Main deployment function - * @returns {Object} Deployment result with status and deployed files - */ -function createEmptyTargetResult(baseDir) { - return { - commands: [], - skills: [], - agents: [], - baseDir - }; -} - -function deployPlugin(options = {}) { - try { - const pluginDir = path.join(__dirname, '../plugin'); - if (!fs.existsSync(pluginDir)) { - throw new Error('Plugin directory not found. Make sure you are in the zest-dev project root.'); - } - - const scope = options.scope || 'global'; - const target = options.target || (scope === 'local' ? 'opencode' : 'all'); - - if (!VALID_TARGETS.includes(target)) { - throw new Error(`Invalid target: ${target}. Expected one of: ${VALID_TARGETS.join(', ')}`); - } - - if (!VALID_SCOPES.includes(scope)) { - throw new Error(`Invalid scope: ${scope}. Expected one of: ${VALID_SCOPES.join(', ')}`); - } - - const targetPaths = resolveTargetPaths(scope, target); - const result = { - ok: true, - scope, - target, - opencode: createEmptyTargetResult(targetPaths.opencode ? targetPaths.opencode.baseDir : null), - codex: createEmptyTargetResult(targetPaths.codex ? targetPaths.codex.baseDir : null) - }; - - if (target === 'all' || target === 'opencode') { - ensureDirectories([targetPaths.opencode.commandsDir, targetPaths.opencode.skillsDir]); - cleanupLegacyAgentFiles(targetPaths.opencode.legacyAgentsDir); - result.opencode.commands = deployCommands(targetPaths.opencode.commandsDir); - result.opencode.skills = deploySkills(targetPaths.opencode.skillsDir); - } - - if (target === 'all' || target === 'codex') { - ensureDirectories([targetPaths.codex.skillsDir, targetPaths.codex.agentsDir]); - result.codex.skills = deployCodexSkills(targetPaths.codex.skillsDir); - result.codex.agents = deployCodexSubagents(targetPaths.codex.agentsDir); - } - - return result; - } catch (error) { - if (error.code === 'EACCES') { - throw new Error(`Permission denied: ${error.path}`); - } else if (error.code === 'ENOENT' && error.path) { - throw new Error(`File not found: ${error.path}`); - } else { - throw error; - } - } -} - -module.exports = { - deployPlugin -}; diff --git a/lib/skill-installer.js b/lib/skill-installer.js new file mode 100644 index 0000000..582f899 --- /dev/null +++ b/lib/skill-installer.js @@ -0,0 +1,110 @@ +const fs = require('fs'); +const path = require('path'); + +const SOURCE_SKILLS_DIR = path.join(__dirname, '../skills'); +const REMOVED_ZEST_DEV_SKILL_FILES = new Set(['new.md', 'research.md', 'implement.md']); + +function getHomeDirectory() { + return process.env.HOME || process.env.USERPROFILE; +} + +function assertAbsolutePath(name, value) { + if (!path.isAbsolute(value)) { + throw new Error(`${name} must be an absolute path: ${value}`); + } +} + +function getGlobalSkillsDir() { + const homeDir = getHomeDirectory(); + if (!homeDir) { + throw new Error('HOME is not set'); + } + assertAbsolutePath('HOME', homeDir); + return path.join(homeDir, '.agents', 'skills'); +} + +function listPackagedSkillNames() { + if (!fs.existsSync(SOURCE_SKILLS_DIR)) { + throw new Error('Skills directory not found. Make sure the zest-dev package is installed correctly.'); + } + + return fs.readdirSync(SOURCE_SKILLS_DIR, { withFileTypes: true }) + .filter(entry => entry.isDirectory()) + .map(entry => entry.name) + .sort(); +} + +function cleanupRemovedZestDevSkillFiles(skillDir) { + if (!fs.existsSync(skillDir)) { + return; + } + + REMOVED_ZEST_DEV_SKILL_FILES.forEach(filename => { + const filePath = path.join(skillDir, filename); + if (fs.existsSync(filePath)) { + fs.unlinkSync(filePath); + } + }); +} + +function copyDirectoryRecursive(source, target) { + const entries = fs.readdirSync(source, { withFileTypes: true }); + + entries.forEach(entry => { + const sourcePath = path.join(source, entry.name); + const targetPath = path.join(target, entry.name); + + if (entry.isDirectory()) { + fs.mkdirSync(targetPath, { recursive: true }); + copyDirectoryRecursive(sourcePath, targetPath); + } else { + fs.copyFileSync(sourcePath, targetPath); + } + }); +} + +/** + * Install every packaged skill under ~/.agents/skills// + * @returns {{ ok: true, skillsDir: string, skills: string[] }} + */ +function installSkills() { + try { + const skillsDir = getGlobalSkillsDir(); + const skillNames = listPackagedSkillNames(); + + fs.mkdirSync(skillsDir, { recursive: true }); + + const installed = []; + + skillNames.forEach(skillName => { + const sourceDir = path.join(SOURCE_SKILLS_DIR, skillName); + const targetDir = path.join(skillsDir, skillName); + + fs.mkdirSync(targetDir, { recursive: true }); + if (skillName === 'zest-dev') { + cleanupRemovedZestDevSkillFiles(targetDir); + } + copyDirectoryRecursive(sourceDir, targetDir); + installed.push(`${skillName}/`); + }); + + return { + ok: true, + skillsDir, + skills: installed + }; + } catch (error) { + if (error.code === 'EACCES') { + throw new Error(`Permission denied: ${error.path}`); + } + if (error.code === 'ENOENT' && error.path) { + throw new Error(`File not found: ${error.path}`); + } + throw error; + } +} + +module.exports = { + installSkills, + getGlobalSkillsDir +}; diff --git a/package.json b/package.json index 70b8f46..c6ed527 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zest-dev", - "version": "1.0.15", + "version": "1.0.16", "description": "A lightweight, human-interactive development workflow for AI-assisted coding", "author": { "name": "nettee", @@ -24,18 +24,14 @@ }, "files": [ "bin/", - "commands/", "skills/", - "agents/", "lib/", "scripts/", - "plugin/", "index.js", "README.md", "LICENSE" ], "scripts": { - "postinstall": "node scripts/ensure-plugin-symlinks.js", "test": "pnpm test:local", "test:ci-version-freshness": "node scripts/ci/test-check-version-freshness.js", "test:ci-pr-bump": "node scripts/ci/test-should-bump-pr-version.js", diff --git a/plugin/.claude-plugin/plugin.json b/plugin/.claude-plugin/plugin.json deleted file mode 100644 index 2583504..0000000 --- a/plugin/.claude-plugin/plugin.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "zest-dev", - "version": "0.1.0", - "description": "Human-interactive, spec-driven workflow with lightweight and grilling design approaches", - "author": { - "name": "nettee", - "email": "nettee.liu@gmail.com" - }, - "keywords": ["feature-dev", "workflow", "spec-driven", "development", "planning"] -} diff --git a/plugin/.gitignore b/plugin/.gitignore deleted file mode 100644 index 5d1d1f1..0000000 --- a/plugin/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -# Local settings -.claude/*.local.md - -# Node modules (if any scripts use npm) -node_modules/ - -# OS files -.DS_Store -Thumbs.db - -# IDE -.vscode/ -.idea/ diff --git a/plugin/README.md b/plugin/README.md deleted file mode 100644 index 5650f4b..0000000 --- a/plugin/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# Zest Dev Plugin - -A plugin for Zest Dev's spec-driven development workflow. - -## Architecture - -- the `zest-dev` skill owns Spec lifecycle and recording contracts -- Section Guides define Overview, Design, Plan, and Implementation content -- commands select a Design Approach without duplicating skill rules -- `plugin/commands`, `plugin/skills`, and `plugin/agents` are symlinks for plugin compatibility -- the `zest-dev` CLI manages Spec lifecycle and Ralph setup - -New-format Specs progress through `new → designed → planned → implemented`. - -## Commands - -| Command | Purpose | -|---------|---------| -| `/zest-dev:lightweight ` | Create a new Spec and reach Designed Status through the Lightweight Design Approach | -| `/zest-dev:grilling ` | Create a new Spec and reach Designed Status through the Grilling Design Approach | - -Both commands preserve the user's language and route into the same Designed Contract. The grilling route composes the registered `grilling` and `domain-modeling` skills. - -## Spec content - -- `Overview` records the requested change and its boundaries. -- `Design` keeps the concise Summary and E2E Acceptance Gate. -- `design.md` is the Design Record containing Research Findings and Design Decisions. -- `Plan` contains Spec-local tracer-bullet Plan Tickets; external publication requires an explicit request. -- `implementation.md` records high-signal outcomes, deviations, verification, and retrospective lessons. - -## Installation - -```bash -zest-dev init -``` - -The default global initialization deploys the two OpenCode commands, the `zest-dev` skill, and the supported Codex subagents. Target-specific and local initialization remain available through the CLI options. diff --git a/plugin/agents b/plugin/agents deleted file mode 120000 index fd65c79..0000000 --- a/plugin/agents +++ /dev/null @@ -1 +0,0 @@ -../agents \ No newline at end of file diff --git a/plugin/commands b/plugin/commands deleted file mode 120000 index 047455e..0000000 --- a/plugin/commands +++ /dev/null @@ -1 +0,0 @@ -../commands \ No newline at end of file diff --git a/plugin/skills b/plugin/skills deleted file mode 120000 index 42c5394..0000000 --- a/plugin/skills +++ /dev/null @@ -1 +0,0 @@ -../skills \ No newline at end of file diff --git a/scripts/ensure-plugin-symlinks.js b/scripts/ensure-plugin-symlinks.js deleted file mode 100644 index 57168fc..0000000 --- a/scripts/ensure-plugin-symlinks.js +++ /dev/null @@ -1,62 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -const rootDir = path.join(__dirname, '..'); -const pluginDir = path.join(rootDir, 'plugin'); - -const links = [ - ['commands', 'commands'], - ['skills', 'skills'], - ['agents', 'agents'] -]; - -function ensureDirectory(name, dirPath) { - if (!fs.existsSync(dirPath)) { - throw new Error(`${name} directory not found: ${dirPath}`); - } -} - -function createPluginSymlink(linkPath, targetPath) { - const symlinkTarget = process.platform === 'win32' - ? targetPath - : path.relative(pluginDir, targetPath); - const symlinkType = process.platform === 'win32' ? 'junction' : 'dir'; - fs.symlinkSync(symlinkTarget, linkPath, symlinkType); -} - -function ensurePluginSymlink(linkName, targetName) { - ensureDirectory(targetName, path.join(rootDir, targetName)); - ensureDirectory('plugin', pluginDir); - - const linkPath = path.join(pluginDir, linkName); - const targetPath = path.join(rootDir, targetName); - - let stat = null; - try { - stat = fs.lstatSync(linkPath); - } catch (error) { - if (error.code !== 'ENOENT') { - throw error; - } - } - - if (stat) { - if (!stat.isSymbolicLink()) { - fs.rmSync(linkPath, { recursive: true, force: true }); - createPluginSymlink(linkPath, targetPath); - return; - } - - const actualTarget = fs.realpathSync(linkPath); - const expectedTarget = fs.realpathSync(targetPath); - if (actualTarget !== expectedTarget) { - throw new Error(`Expected ${linkPath} to point to ${expectedTarget}, got ${actualTarget}`); - } - - return; - } - - createPluginSymlink(linkPath, targetPath); -} - -links.forEach(([linkName, targetName]) => ensurePluginSymlink(linkName, targetName));