-
Notifications
You must be signed in to change notification settings - Fork 10
fix: support legacy baut automator installs #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,6 +113,112 @@ cleanup_obsolete_command_shims() { | |
| done | ||
| } | ||
|
|
||
| migrate_legacy_baut_manifest() { | ||
| node - "$TARGET_BMAD" <<'NODE' | ||
| const fs = require("node:fs"); | ||
| const path = require("node:path"); | ||
|
|
||
| const bmadDir = process.argv[2]; | ||
| const timestamp = new Date().toISOString().replace(/[-:]/g, "").replace(/\.\d{3}Z$/, "Z"); | ||
|
|
||
| function isManifestFile(file) { | ||
| return /^manifest\.ya?ml$/i.test(path.basename(file)); | ||
| } | ||
|
|
||
| function walk(dir, files = []) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Severity: medium 🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage. |
||
| for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { | ||
| const full = path.join(dir, entry.name); | ||
| if (entry.isDirectory()) { | ||
| walk(full, files); | ||
| } else if (entry.isFile() && isManifestFile(full)) { | ||
| files.push(full); | ||
| } | ||
| } | ||
| return files; | ||
| } | ||
|
|
||
| function nextBackupPath(file) { | ||
| const backup = `${file}.bak`; | ||
| return fs.existsSync(backup) ? `${backup}-${timestamp}` : backup; | ||
| } | ||
|
|
||
| function shouldEndBlock(line, itemIndent, moduleIndent) { | ||
| if (/^\s*$/.test(line) || /^\s*#/.test(line)) return false; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Severity: low 🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage. |
||
| const indent = line.match(/^\s*/)[0].length; | ||
| return indent <= moduleIndent || (indent === itemIndent && line.trimStart().startsWith("- ")); | ||
| } | ||
|
|
||
| function removeBautBlocks(content) { | ||
| const lines = content.split("\n"); | ||
| const output = []; | ||
| let changed = false; | ||
| let moduleIndent = null; | ||
|
|
||
| for (let index = 0; index < lines.length; index += 1) { | ||
| const line = lines[index]; | ||
| const modulesMatch = line.match(/^(\s*)modules:\s*$/); | ||
| if (modulesMatch) { | ||
| moduleIndent = modulesMatch[1].length; | ||
| output.push(line); | ||
| continue; | ||
| } | ||
|
|
||
| if (moduleIndent !== null && !/^\s*$/.test(line) && !/^\s*#/.test(line)) { | ||
| const indent = line.match(/^\s*/)[0].length; | ||
| if (indent <= moduleIndent) { | ||
| moduleIndent = null; | ||
| } | ||
| } | ||
|
|
||
| const bautMatch = moduleIndent === null ? null : line.match(/^(\s*)-\s+name:\s+['"]?baut['"]?\s*$/); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Severity: medium 🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage. |
||
| if (!bautMatch) { | ||
| output.push(line); | ||
| continue; | ||
| } | ||
|
|
||
| const itemIndent = bautMatch[1].length; | ||
| if (itemIndent <= moduleIndent) { | ||
| output.push(line); | ||
| continue; | ||
| } | ||
|
|
||
| changed = true; | ||
| index += 1; | ||
| const trailingTrivia = []; | ||
| while (index < lines.length && !shouldEndBlock(lines[index], itemIndent, moduleIndent)) { | ||
| if (/^\s*$/.test(lines[index]) || /^\s*#/.test(lines[index])) { | ||
| trailingTrivia.push(lines[index]); | ||
| } else { | ||
| trailingTrivia.length = 0; | ||
| } | ||
| index += 1; | ||
| } | ||
| output.push(...trailingTrivia); | ||
| index -= 1; | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| return changed ? output.join("\n").replace(/\n*$/, "\n") : null; | ||
| } | ||
|
|
||
| for (const file of walk(bmadDir)) { | ||
| const content = fs.readFileSync(file, "utf8"); | ||
| if (!content.includes("modules:") || !/^\s*-\s+name:\s+['"]?baut['"]?\s*$/m.test(content)) { | ||
| continue; | ||
| } | ||
|
|
||
| const migrated = removeBautBlocks(content); | ||
| if (migrated === null) continue; | ||
|
|
||
| const backup = nextBackupPath(file); | ||
| fs.copyFileSync(file, backup); | ||
| fs.writeFileSync(file, migrated, "utf8"); | ||
| const relFile = path.relative(path.dirname(bmadDir), file); | ||
| const relBackup = path.relative(path.dirname(bmadDir), backup); | ||
| console.log(`Migrated legacy baut manifest entry: ${relFile} (backup: ${relBackup})`); | ||
| } | ||
| NODE | ||
| } | ||
|
|
||
| resolve_workflow_path() { | ||
| local candidate | ||
| for candidate in "$@"; do | ||
|
|
@@ -274,6 +380,7 @@ STORY_REVIEW_SOURCE="$SKILL_SOURCE_ROOT/bmad-story-automator-review" | |
| [ -f "$STORY_SOURCE/pyproject.toml" ] || err "Missing runtime pyproject: $STORY_SOURCE/pyproject.toml" | ||
| [ -f "$STORY_REVIEW_SOURCE/SKILL.md" ] || err "Missing review SKILL.md: $STORY_REVIEW_SOURCE/SKILL.md" | ||
|
|
||
| migrate_legacy_baut_manifest | ||
| collect_target_skills_roots | ||
|
|
||
| if [ "${#TARGET_SKILLS_RELS[@]}" -eq 0 ]; then | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | ||
| TMP_DIR="$(mktemp -d "${TMPDIR:-/tmp}/bmad-story-automator-compat.XXXXXX")" | ||
| PACK_TARBALL="" | ||
|
|
||
| cleanup() { | ||
| if [ -n "$PACK_TARBALL" ] && [ -f "$PACK_TARBALL" ]; then | ||
| rm -f "$PACK_TARBALL" | ||
| fi | ||
| rm -rf "$TMP_DIR" | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| assert_file() { | ||
| local path="$1" | ||
| [ -f "$path" ] || { | ||
| echo "Missing file: $path" >&2 | ||
| exit 1 | ||
| } | ||
| } | ||
|
|
||
| assert_contains() { | ||
| local needle="$1" | ||
| local path="$2" | ||
| grep -Fq "$needle" "$path" || { | ||
| echo "Missing content in $path: $needle" >&2 | ||
| exit 1 | ||
| } | ||
| } | ||
|
|
||
| assert_not_contains() { | ||
| local needle="$1" | ||
| local path="$2" | ||
| if grep -Fq "$needle" "$path"; then | ||
| echo "Unexpected content in $path: $needle" >&2 | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| make_skill() { | ||
| local root="$1" | ||
| local name="$2" | ||
| mkdir -p "$root/.claude/skills/$name" | ||
| printf -- '---\nname: %s\n---\n\nFollow ./workflow.md.\n' "$name" >"$root/.claude/skills/$name/SKILL.md" | ||
| printf '# %s\n' "$name" >"$root/.claude/skills/$name/workflow.md" | ||
| } | ||
|
|
||
| make_project() { | ||
| local root="$1" | ||
| local manifest="$root/_bmad/_config/manifest.yaml" | ||
| mkdir -p "$root/_bmad/_config" "$root/.claude/commands" | ||
| make_skill "$root" bmad-create-story | ||
| make_skill "$root" bmad-dev-story | ||
| make_skill "$root" bmad-retrospective | ||
| make_skill "$root" bmad-qa-generate-e2e-tests | ||
| cat >"$manifest" <<'EOF' | ||
| installation: | ||
| version: 6.6.0 | ||
| installDate: 2026-05-17T00:00:00.000Z | ||
| lastUpdated: 2026-05-17T00:00:00.000Z | ||
| modules: | ||
| - name: core | ||
| version: 6.6.0 | ||
| source: built-in | ||
| - name: baut | ||
| version: v1.14.2 | ||
| installDate: 2026-05-17T00:00:00.000Z | ||
| lastUpdated: 2026-05-17T00:00:00.000Z | ||
| source: external | ||
| npmPackage: bmad-story-automator | ||
| repoUrl: https://github.com/bmad-code-org/bmad-automator | ||
| channel: stable | ||
| sha: 593f338532ea730b5c1a2dd86681e87b5b4f04dd | ||
|
|
||
| # Keep separator comment attached to the next module. | ||
| - name: bmm | ||
| version: 6.6.0 | ||
| source: built-in | ||
| ides: | ||
| - claude-code | ||
| metadata: | ||
| examples: | ||
| - name: baut | ||
| note: keep unrelated baut list entry | ||
| EOF | ||
| cat >"$root/_bmad/other.yaml" <<'EOF' | ||
| modules: | ||
| - name: baut | ||
| note: keep non-manifest yaml untouched | ||
| EOF | ||
| printf 'team config untouched\n' >"$root/_bmad/config.toml" | ||
| printf 'user config untouched\n' >"$root/_bmad/config.user.toml" | ||
| } | ||
|
|
||
| pack_fixture_tarball() { | ||
| PACK_TARBALL="$(cd "$ROOT_DIR" && npm pack --silent)" | ||
| PACK_TARBALL="$ROOT_DIR/$PACK_TARBALL" | ||
| assert_file "$PACK_TARBALL" | ||
| } | ||
|
|
||
| run_legacy_baut_manifest_migration_case() { | ||
| local root="$TMP_DIR/legacy-baut-manifest-migration" | ||
| local manifest="$root/_bmad/_config/manifest.yaml" | ||
| local install_log="$root/install.log" | ||
|
|
||
| make_project "$root" | ||
| npx --yes --package "file:$PACK_TARBALL" bmad-story-automator "$root" >"$install_log" 2>&1 | ||
|
|
||
| assert_file "$manifest.bak" | ||
| assert_contains "name: baut" "$manifest.bak" | ||
| assert_contains "name: core" "$manifest" | ||
| assert_contains "name: bmm" "$manifest" | ||
| assert_contains "Keep separator comment attached to the next module." "$manifest" | ||
| assert_contains "note: keep unrelated baut list entry" "$manifest" | ||
| assert_not_contains "npmPackage: bmad-story-automator" "$manifest" | ||
| assert_contains "note: keep non-manifest yaml untouched" "$root/_bmad/other.yaml" | ||
| assert_contains "team config untouched" "$root/_bmad/config.toml" | ||
| assert_contains "user config untouched" "$root/_bmad/config.user.toml" | ||
| assert_contains "Migrated legacy baut manifest entry: _bmad/_config/manifest.yaml" "$install_log" | ||
| assert_file "$root/.claude/skills/bmad-story-automator/SKILL.md" | ||
| assert_file "$root/.claude/skills/bmad-story-automator-review/SKILL.md" | ||
| } | ||
|
|
||
| pack_fixture_tarball | ||
| run_legacy_baut_manifest_migration_case | ||
|
|
||
| echo "compat ok" |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
.claude-plugin/marketplace.jsonline 41, the newbautplugin entry doesn’t include askillslist (unlikebmad-automator) and usessource: "./skills", which may not match the custom-source resolver expectations (docs/plans mention plugin-levelskillsentries). This could cause legacy source discovery to still fail or to pull an unexpected set of skills.Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.