@codewizard-dt/bootstrap 2.13.0 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,7 +25,7 @@ All scripts use `set -euo pipefail`. Every script that touches a target project
25
25
  | `sync-wiki-scaffold.sh` | `setup-project.sh`, `update-project.sh`, `migrate-project.sh` | Scaffolds an **empty** wiki into the target project from `templates/wiki/`: creates `raw/` + all `wiki/` family directories, lifecycle docs, per-family `index.md`, and stub `index.md`/`log.md`. Copy-once for project-owned files; always-refreshes `conventions.md` and `lifecycle.md`. Delivers guides from `raw/guides/` tier-wise into `wiki/guides/`: `command-anti-patterns.md` required (always refreshed); `evals-framework.md` + `type-checking-templates/` optional (`--interactive` prompts on first delivery, sticky refresh once present — legacy `.docs/guides/` presence counts, opt out by deleting); migrates legacy `.docs/guides/` (template-owned files removed or relocated, deprecated `task-spec.md` deleted, empty dirs pruned). Also delivers the `## LLM Wiki` section and `.env` safety policy (copy-once, sentinel-guarded, from `templates/CLAUDE-wiki.md` / `templates/CLAUDE-env-safety.md`) into the target's `CLAUDE.md` — when a `CLAUDE.md` already exists without the schema, prompts whether to modify it or write `CLAUDE.local.md` instead (non-interactive default: `CLAUDE.local.md`). |
26
26
  | `build-mcp-guide.sh` | `setup-project.sh`, `update-project.sh`, `migrate-project.sh` | Assembles `wiki/guides/mcp-tools.md` in the target project from the per-server stub files in `templates/guides/stubs/`, including only the sections for MCPs actually installed. |
27
27
  | `bootstrap-serena.sh` | `setup-project.sh`, `update-project.sh` | Headlessly triggers `.serena/project.yml` creation via `claude --print` and enables the optional Serena tools needed by this template's workflow. Preflights `claude` and `python3`. |
28
- | `merge-gitignore.sh` | `setup-project.sh`, `update-project.sh` | Copies the packaged `.gitignore` template into the target project if none exists; otherwise merges in only the missing lines, leaving the project's existing `.gitignore` content untouched. |
28
+ | `merge-gitignore.sh` | `setup-project.sh`, `update-project.sh` | Merges the packaged `.gitignore` template into the target per titled section: sections already represented in the target (any entry present) get their missing lines merged silently; new sections are offered interactively by title (`Add .gitignore section 'Node / TypeScript / JavaScript'? [y/N]`), skipped when declined or non-interactive. A missing `.gitignore` is copied wholesale when there is no tty to prompt on. Never touches existing project content. |
29
29
  | `merge-settings-deny.js` | `install-global.sh` | Zero-dependency Node script that merges the canonical Bash deny list (`templates/settings-deny.json`) into `~/.claude/settings.json` `permissions.deny`. Additive union only: missing entries are appended, user entries are never removed or reordered, all other settings keys pass through untouched. Atomic write, preserves existing indentation, and always exits 0 (warns + skips on unparseable or unexpected file shapes so an install never aborts over a settings merge). `--target`/`--source` flags exist as test seams. |
30
30
 
31
31
  ## Standalone infra scripts (not wired to the CLI)
@@ -141,7 +141,7 @@ run_project_sync() {
141
141
 
142
142
  echo "Syncing wiki scaffold..."
143
143
  "$script_dir/sync-wiki-scaffold.sh" --interactive "$project_dir"
144
- "$script_dir/merge-gitignore.sh" "$project_dir"
144
+ "$script_dir/merge-gitignore.sh" --interactive "$project_dir"
145
145
  echo ""
146
146
 
147
147
  echo "Building MCP tools guide..."
@@ -6,8 +6,30 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
6
  # Packed copy of the repo .gitignore (dotfiles are never included in npm packages)
7
7
  TEMPLATE_GITIGNORE="$SCRIPT_DIR/templates/gitignore"
8
8
 
9
+ # merge-gitignore.sh [--interactive] <path-to-project>
10
+ #
11
+ # The template is split into titled sections (delimited by `# ---` banner
12
+ # comments). Per section:
13
+ # - already represented in the target (any of its entries present, exact
14
+ # line match) => merge the section's missing lines silently (sticky opt-in)
15
+ # - otherwise, --interactive => prompt "Add .gitignore section '<title>'?"
16
+ # (default no); non-interactive => skip silently
17
+ # A missing .gitignore is copied wholesale in non-interactive mode; in
18
+ # interactive mode the same per-section prompts build it from scratch.
19
+
20
+ INTERACTIVE=false
21
+ POSITIONAL=()
22
+ for arg in "$@"; do
23
+ case "$arg" in
24
+ --interactive) INTERACTIVE=true ;;
25
+ *) POSITIONAL+=("$arg") ;;
26
+ esac
27
+ done
28
+ # bash 3.2 + set -u: expanding an empty array is an unbound-variable error
29
+ set -- ${POSITIONAL[@]+"${POSITIONAL[@]}"}
30
+
9
31
  if [ $# -ne 1 ]; then
10
- echo "Usage: $0 <path-to-project>" >&2
32
+ echo "Usage: $0 [--interactive] <path-to-project>" >&2
11
33
  exit 1
12
34
  fi
13
35
 
@@ -15,48 +37,99 @@ PROJECT_DIR="$(resolve_project_dir "$1")" || exit 1
15
37
 
16
38
  TARGET="$PROJECT_DIR/.gitignore"
17
39
 
18
- # No target → copy wholesale
19
- if [ ! -f "$TARGET" ]; then
40
+ # No target + non-interactive (or no tty to prompt on) → copy wholesale, so
41
+ # headless setup keeps full coverage instead of creating an empty file.
42
+ if [ ! -f "$TARGET" ] && { [ "$INTERACTIVE" = false ] || [ ! -t 0 ]; }; then
20
43
  cp "$TEMPLATE_GITIGNORE" "$TARGET"
21
44
  echo ".gitignore: copied to $PROJECT_DIR"
22
45
  exit 0
23
46
  fi
24
47
 
25
- # Snapshot existing lines for exact-match lookups during the merge loop
26
- EXISTING=$(mktemp)
48
+ WORK_DIR=$(mktemp -d)
49
+ trap 'rm -rf "$WORK_DIR"' EXIT
50
+
51
+ # Split the template into per-section files. Banner delimiters come in pairs
52
+ # (open dash line, title comment, close dash line); every odd dash line starts
53
+ # a new section. Titles land in $WORK_DIR/title.N, bodies in $WORK_DIR/sec.N.
54
+ SECTION_COUNT=$(awk -v dir="$WORK_DIR" '
55
+ /^# -----/ {
56
+ dash++
57
+ if (dash % 2 == 1) n++
58
+ print >> (dir "/sec." n)
59
+ next
60
+ }
61
+ n > 0 {
62
+ print >> (dir "/sec." n)
63
+ if (dash % 2 == 1 && $0 ~ /^# / && !(n in ttl)) {
64
+ t = $0; sub(/^# +/, "", t); ttl[n] = t
65
+ print t > (dir "/title." n)
66
+ }
67
+ }
68
+ END { print n }
69
+ ' "$TEMPLATE_GITIGNORE")
70
+
71
+ [ -f "$TARGET" ] || : > "$TARGET"
72
+
73
+ # Snapshot existing lines for exact-match lookups during the merge loops
74
+ EXISTING="$WORK_DIR/existing"
27
75
  cp "$TARGET" "$EXISTING"
28
- trap 'rm -f "$EXISTING"' EXIT
29
76
 
30
- added=0
31
- pending="" # comment/blank lines buffered until we know the next content line is new
77
+ # section_represented <section-file>: any non-comment entry already in target?
78
+ section_represented() {
79
+ local line trimmed
80
+ while IFS= read -r line || [ -n "$line" ]; do
81
+ trimmed="${line#"${line%%[![:space:]]*}"}"
82
+ [ -z "$trimmed" ] && continue
83
+ case "$trimmed" in \#*) continue ;; esac
84
+ if grep -qFx -- "$line" "$EXISTING"; then return 0; fi
85
+ done < "$1"
86
+ return 1
87
+ }
32
88
 
33
- while IFS= read -r line || [ -n "$line" ]; do
34
- trimmed="${line#"${line%%[![:space:]]*}"}" # leading-whitespace stripped
89
+ added=0
35
90
 
36
- if [ -z "$trimmed" ] || [[ "$trimmed" == \#* ]]; then
37
- # Blank or comment line — hold in buffer; only flush if a new content line follows
38
- pending+="${line}"$'\n'
39
- else
40
- # Content line
41
- if grep -qFx -- "$line" "$EXISTING"; then
42
- # Already present — discard buffered headers (their section is already represented)
43
- pending=""
91
+ # merge_section <section-file>: append the section's missing lines, keeping
92
+ # comment/blank lines buffered so headers only land when new entries follow.
93
+ merge_section() {
94
+ local line trimmed pending=""
95
+ while IFS= read -r line || [ -n "$line" ]; do
96
+ trimmed="${line#"${line%%[![:space:]]*}"}"
97
+ if [ -z "$trimmed" ] || [[ "$trimmed" == \#* ]]; then
98
+ pending+="${line}"$'\n'
44
99
  else
45
- # New line — pre-flight the file on first append, then flush buffer + add line
46
- if [ "$added" -eq 0 ] && [ -s "$TARGET" ]; then
47
- # Ensure target ends with a newline before we start appending
48
- [[ $(tail -c1 "$TARGET") ]] && printf '\n' >> "$TARGET"
49
- fi
50
- if [ -n "$pending" ]; then
51
- printf '%s' "$pending" >> "$TARGET"
100
+ if grep -qFx -- "$line" "$EXISTING"; then
52
101
  pending=""
102
+ else
103
+ if [ "$added" -eq 0 ] && [ -s "$TARGET" ]; then
104
+ # Ensure target ends with a newline before we start appending
105
+ [[ $(tail -c1 "$TARGET") ]] && printf '\n' >> "$TARGET"
106
+ fi
107
+ if [ -n "$pending" ]; then
108
+ printf '%s' "$pending" >> "$TARGET"
109
+ pending=""
110
+ fi
111
+ printf '%s\n' "$line" >> "$TARGET"
112
+ echo " + $line"
113
+ added=$((added + 1))
53
114
  fi
54
- printf '%s\n' "$line" >> "$TARGET"
55
- echo " + $line"
56
- added=$((added + 1))
57
115
  fi
116
+ done < "$1"
117
+ }
118
+
119
+ i=1
120
+ while [ "$i" -le "$SECTION_COUNT" ]; do
121
+ SEC="$WORK_DIR/sec.$i"
122
+ TITLE="section $i"
123
+ [ -f "$WORK_DIR/title.$i" ] && TITLE="$(cat "$WORK_DIR/title.$i")"
124
+ if section_represented "$SEC"; then
125
+ merge_section "$SEC"
126
+ elif [ "$INTERACTIVE" = true ] && prompt_yn " Add .gitignore section '$TITLE'? [y/N]: "; then
127
+ merge_section "$SEC"
128
+ else
129
+ echo " .gitignore section '$TITLE': skipped (opt in via 'npx @codewizard-dt/bootstrap update')."
58
130
  fi
59
- done < "$TEMPLATE_GITIGNORE"
131
+ i=$((i + 1))
132
+ done
60
133
 
61
134
  if [ "$added" -eq 0 ]; then
62
135
  echo ".gitignore: already up to date in $PROJECT_DIR"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codewizard-dt/bootstrap",
3
- "version": "2.13.0",
3
+ "version": "2.14.0",
4
4
  "description": "Bootstrap Claude Code projects with an LLM Wiki, reusable skills, hooks, and MCP setup",
5
5
  "homepage": "https://github.com/codewizard-dt/bootstrap-wiki#readme",
6
6
  "bugs": {