fix: Worktree scripts use $(pwd) for project root

Scripts now correctly determine project root from current working
directory instead of calculating relative to script location.
This fixes the issue when scripts are called via ${CLAUDE_PLUGIN_ROOT}.

Also adds CLAUDE.md and CHANGELOG.md for development guidance.

Bumps version to 1.0.3.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-22 11:07:39 +02:00
parent 34b12c5742
commit 730e5d6061
8 changed files with 139 additions and 15 deletions

View File

@@ -11,7 +11,7 @@
"name": "ab", "name": "ab",
"source": "./plugin", "source": "./plugin",
"description": "Spec-driven build orchestration with git worktree isolation and session memory", "description": "Spec-driven build orchestration with git worktree isolation and session memory",
"version": "1.0.2", "version": "1.0.3",
"keywords": ["build", "spec", "automation", "worktree", "qa"] "keywords": ["build", "spec", "automation", "worktree", "qa"]
} }
] ]

30
CHANGELOG.md Normal file
View File

@@ -0,0 +1,30 @@
# Changelog
All notable changes to Auto-Build plugin.
## [1.0.3] - 2024-12-22
### Fixed
- Worktree scripts now use `$(pwd)` for project root instead of calculating from script location
- Scripts work correctly when called via `${CLAUDE_PLUGIN_ROOT}/scripts/`
## [1.0.2] - 2024-12-21
### Added
- CLAUDE.md file for development guidance
## [1.0.1] - 2024-12-21
### Fixed
- hooks.json format corrected (use object instead of array)
## [1.0.0] - 2024-12-20
### Added
- Initial release
- 8 commands: spec, build, worktree, qa-review, memory-save, memory-search, status, help
- 5 agents: spec-writer, planner, coder, qa-reviewer, qa-fixer
- Git worktree isolation support
- Bidirectional memory system (JSON + Markdown)
- CLAUDE.md integration with context-aware agents
- Post-install hook for automatic setup

97
CLAUDE.md Normal file
View File

@@ -0,0 +1,97 @@
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
Auto-Build is a Claude Code plugin that provides spec-driven build orchestration with autonomous agents. It enables structured feature development through 5 specialized agents, git worktree isolation, and persistent cross-session memory.
## Repository Structure
This is a **plugin repository** with two levels:
- **Root level**: Marketplace configuration (`.claude-plugin/marketplace.json`)
- **`plugin/` directory**: The actual plugin that gets installed
```
auto-build-plugin/
├── .claude-plugin/marketplace.json # Marketplace catalog
├── plugin/ # Plugin source (copied on install)
│ ├── .claude-plugin/plugin.json # Plugin manifest (prefix: "ab")
│ ├── commands/ # 8 slash commands (/ab:*)
│ ├── agents/ # 5 specialized agents
│ ├── hooks/hooks.json # Lifecycle hooks config
│ ├── hooks/post-install.sh # Runs after plugin install
│ ├── scripts/ # Bash scripts for worktree ops
│ ├── rules/ # Auto-build patterns (copied to .claude/rules/)
│ └── templates/ # Templates for CLAUDE.md, specs, plans
└── README.md # User-facing documentation
```
## Key Architecture Concepts
### Plugin Installation Flow
1. User runs `/plugin install ab@roa2web-tools`
2. Plugin is copied to Claude Code cache at `${CLAUDE_PLUGIN_ROOT}`
3. `post-install.sh` hook executes and creates:
- `.auto-build-data/` directory structure
- `.claude/rules/auto-build-patterns.md`
- `.claude/rules/auto-build-memory.md`
- `CLAUDE.md` (if missing)
### Script Path Resolution
Scripts in `plugin/scripts/` are called via `${CLAUDE_PLUGIN_ROOT}/scripts/` but operate on the **current working directory** (user's project). Scripts must use `$(pwd)` for project root, not relative paths from script location.
### Memory System (Bidirectional)
- **JSON files** (`.auto-build-data/memory/*.json`): Searchable via `/ab:memory-search`
- **Markdown** (`.claude/rules/auto-build-memory.md`): Auto-loaded by Claude Code
### Agent Context Awareness
`spec-writer` and `planner` agents read CLAUDE.md and auto-build-memory.md to respect project conventions.
## Commands Reference
| Command | Implementation |
|---------|---------------|
| `/ab:spec <name>` | `commands/spec.md` → launches `agents/spec-writer.md` |
| `/ab:build <name>` | `commands/build.md` → launches `agents/planner.md` then `agents/coder.md` |
| `/ab:qa-review` | `commands/qa-review.md` → loops `agents/qa-reviewer.md` + `agents/qa-fixer.md` |
| `/ab:worktree <action>` | `commands/worktree.md` → calls `scripts/worktree-*.sh` |
| `/ab:memory-save` | `commands/memory-save.md` → saves to JSON + syncs to markdown |
| `/ab:memory-search` | `commands/memory-search.md` → searches JSON files |
| `/ab:status` | `commands/status.md` |
| `/ab:help` | `commands/help.md` |
## Development Guidelines
### Modifying Scripts
When editing `plugin/scripts/*.sh`:
- Use `PROJECT_ROOT="$(pwd)"` - never calculate from `BASH_SOURCE`
- Scripts execute from plugin cache but operate on user's project
- Reference plugin files via relative paths from script location
### Adding Commands
Create `.md` file in `plugin/commands/` with frontmatter:
```yaml
---
description: Short description
argument-hint: <required> [optional]
---
```
### Adding Agents
Create `.md` file in `plugin/agents/` with frontmatter:
```yaml
---
name: agent-name
description: What it does
model: sonnet|opus|haiku
color: blue|green|red
---
```
### Version Updates
**IMPORTANT**: When making any changes to the plugin, bump the version in BOTH files so users can update:
- `.claude-plugin/marketplace.json``plugins[0].version`
- `plugin/.claude-plugin/plugin.json``version`
Also update `CHANGELOG.md` with the changes.

View File

@@ -1,7 +1,7 @@
{ {
"name": "ab", "name": "ab",
"description": "Auto-Build: Spec-driven build orchestration with worktree isolation and session memory", "description": "Auto-Build: Spec-driven build orchestration with worktree isolation and session memory",
"version": "1.0.2", "version": "1.0.3",
"author": { "author": {
"name": "ROA2WEB Team" "name": "ROA2WEB Team"
} }

View File

@@ -7,9 +7,8 @@ set -e
FEATURE_NAME="$1" FEATURE_NAME="$1"
# Get project root (parent of .auto-build) # Get project root from current working directory (where Claude Code is running)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
PROJECT_NAME=$(basename "$PROJECT_ROOT") PROJECT_NAME=$(basename "$PROJECT_ROOT")
WORKTREES_DIR="$(dirname "$PROJECT_ROOT")/ab-worktrees" WORKTREES_DIR="$(dirname "$PROJECT_ROOT")/ab-worktrees"
@@ -104,5 +103,5 @@ else
echo "" echo ""
echo "To cleanup a specific worktree:" echo "To cleanup a specific worktree:"
echo " bash .auto-build/scripts/worktree-cleanup.sh <feature-name>" echo " /ab:worktree cleanup <feature-name>"
fi fi

View File

@@ -12,9 +12,9 @@ if [ -z "$FEATURE_NAME" ]; then
exit 1 exit 1
fi fi
# Get project root (parent of .auto-build) # Get project root from current working directory (where Claude Code is running)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Note: This script is called from ${CLAUDE_PLUGIN_ROOT}/scripts/ but operates on the project
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" PROJECT_ROOT="$(pwd)"
PROJECT_NAME=$(basename "$PROJECT_ROOT") PROJECT_NAME=$(basename "$PROJECT_ROOT")
# Define paths # Define paths

View File

@@ -4,9 +4,8 @@
set -e set -e
# Get project root (parent of .auto-build) # Get project root from current working directory (where Claude Code is running)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
echo "========================================" echo "========================================"
echo " Git Worktrees" echo " Git Worktrees"

View File

@@ -6,9 +6,8 @@ set -e
FEATURE_NAME="$1" FEATURE_NAME="$1"
# Get project root (parent of .auto-build) # Get project root from current working directory (where Claude Code is running)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
PROJECT_NAME=$(basename "$PROJECT_ROOT") PROJECT_NAME=$(basename "$PROJECT_ROOT")
WORKTREES_DIR="$(dirname "$PROJECT_ROOT")/ab-worktrees" WORKTREES_DIR="$(dirname "$PROJECT_ROOT")/ab-worktrees"