Commit Graph

11 Commits

Author SHA1 Message Date
Дмитрий ccad7e7b29 fix(brain-install): remove dead-branch mapping; add catch-all to filter case
Two code-quality fixes after review of dc71e23 (Task 1):

I1 — Dead-branch logic in install.sh:
The plugin-install block sits inside the `elif [ "$mode" = "user" ]` branch,
so `[ "$mode" = "project" ] && plugin_target="consumer"` is unreachable
(`$mode` is always "user" here). Replaced with hardcoded `--install-target=user`
plus clarifying comment about future consumer-mode wiring.

I2 — Filter case missing catch-all in install-plugins.sh:
The two `case "$install_target"` blocks (validation at lines 40-43, filter at
lines 75-82) were physically separate. If a future enum value is added to
validation without updating filter, $filter would be unset → set -u crash.
Added explicit `*)` catch-all with log_error + exit 1.

Plan §Task 1 Step 1.7 contained the same I1 bug as dc71e23 — implementer
followed plan faithfully. This fix corrects the code; plan stays as historical
record. Future plans referencing this pattern should match THIS fix, not the
original plan text.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 15:07:29 +03:00
Дмитрий dc71e2338e refactor(brain-install): filter plugins by target ENUM in install-plugins.sh
Closes тех-долг из routing.md v1.1 §4.1 — install-plugins.sh теперь
фильтрует entries по полю `target` относительно режима install'а.

Added флаг `--install-target=user|consumer` (required, с fallback на 'user'
+ warning для backwards-compat прямых вызовов из тестов). Filter jq-выражение:

  user:     target ∈ {"user-level", "user-level+consumer"}
  consumer: target ∈ {"consumer", "user-level+consumer"}

scripts/install.sh теперь передаёт --install-target автоматически на основе
detected $mode (user|project). Regression: текущие 8 entries → 8 plugins при
--install-target=user, 2 plugins (FD + UPM, target=user-level+consumer) при
--install-target=consumer.

Подготовка под Phase 1: добавление 4 consumer-only entries (target=consumer)
и 1 user-level+consumer entry (context7) в plugins-manifest.json — filter
обеспечит, что в brain user-level попадут только нужные.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 15:00:39 +03:00
Дмитрий 52584df34e fix(scripts): 5 critical bugs from Phase 9 self-test
Bug 1: merge-mcp.sh fails on Cyrillic brain repo paths (jq fopen UTF-8 issue)
  → use --argjson with $(cat ...) instead of --slurpfile

Bug 2: install.sh stripped only trailing .template, missed middle .template.
  → strip both '.template.' middle and '.template' trailing patterns

Bug 3: manifest.json used brain-repo paths but verify.sh checked target paths
  → restructure manifest.files into {project-mode, user-mode, brain-internal} maps
  → verify.sh now picks map based on detected target mode

Bug 4: make_backup_dir created empty backup dir, no file preservation
  → rsync/cp -r target tree to backup before any modifications

Bug 5: brain's project-files/README.md overwrote consumer's README.md
  → install.sh now skips brain-internal READMEs in project/user copy loops

Phase 9 self-test re-run on c:/tmp/test-consumer-fix: install + verify both PASS.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 01:24:52 +03:00
Дмитрий 3d24925d6e feat(scripts): extract.sh — reverse sync diff/apply for brain templates
Plan simplification: dropped the broken middle elif heuristic that had
unbalanced shell expression. Kept clean two-step fallback: .template
suffix first, bare filename second.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 00:58:57 +03:00
Дмитрий 6949a9d047 feat(scripts): install.sh — orchestrates project/user mode sync with plugins+MCP
Plan correction E: cp -r replaced with find-loop that strips .template
suffix on copy. Without this Test 3 (project mode: CLAUDE.md copied) can't
pass — fixture creates CLAUDE.md.template, target expects CLAUDE.md.
Real intent: brain stores templates as *.template, consumed without suffix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 00:58:10 +03:00
Дмитрий dd238e52f4 feat(scripts): verify.sh — .brain-version + sha256 + strict-secrets check
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 00:57:03 +03:00
Дмитрий ba0a28b2a0 feat(scripts): install-plugins.sh — marketplace add + plugin install + SHA verify
Uses corrected Claude CLI subcommand shape:
  claude plugin marketplace add <repo>   (NOT `claude marketplace add`)
  claude plugin marketplace list
  claude plugin install <name@marketplace>
  claude plugin info <name@marketplace> --json

Includes fallback for environments where `claude` CLI is not in PATH
(VSCode-extension install on Windows): logs manual edit instructions
and exits 0 so the parent installer can continue.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 00:53:48 +03:00
Дмитрий 042316ea6a feat(scripts): setup-secrets.sh — placeholder resolution with --secret/--skip/--list modes
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 00:52:54 +03:00
Дмитрий c37fd3c9e2 feat(scripts): merge-mcp.sh — preserves laravel-boost, replaces brain-managed MCP
Uses jq --slurpfile pattern (NOT broken `.[1].mcpServers` form from plan):
  jq --slurpfile brain "$brain_mcp" \
     '.mcpServers = ((.mcpServers // {}) + $brain[0].mcpServers)' "$target"

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 00:52:05 +03:00
Дмитрий 0ba32c29dc feat(scripts): merge-settings.sh — jq merge with preservation of theme/editorMode
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 00:50:56 +03:00
Дмитрий 9557109a17 feat(scripts): common.sh helpers (log_*, require_cmd, make_backup_dir)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 00:49:39 +03:00