prizmkit 1.0.143 → 1.0.144

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "frameworkVersion": "1.0.143",
3
- "bundledAt": "2026-03-28T23:59:01.821Z",
4
- "bundledFrom": "ea51479"
2
+ "frameworkVersion": "1.0.144",
3
+ "bundledAt": "2026-03-29T13:53:32.397Z",
4
+ "bundledFrom": "f48ed27"
5
5
  }
@@ -39,7 +39,7 @@ branch_create() {
39
39
 
40
40
  # Create and checkout new branch
41
41
  if ! git -C "$project_root" checkout -b "$branch_name" "$source_branch" 2>/dev/null; then
42
- log_error "Failed to create branch: $branch_name from $source_branch"
42
+ log_warn "Failed to create branch: $branch_name from $source_branch"
43
43
  return 1
44
44
  fi
45
45
 
@@ -138,29 +138,117 @@ prizm_check_common_dependencies() {
138
138
  fi
139
139
  }
140
140
 
141
- # Ensure git is installed and the current directory is a git repository.
142
- # If git is missing, print install instructions and exit.
141
+ # Ensure git is installed and a given directory is a git repository.
142
+ # If git is missing, attempt auto-install; on failure print instructions and exit.
143
143
  # If not inside a git repo, run git init + initial commit automatically.
144
+ #
145
+ # Usage: prizm_ensure_git_repo [directory]
146
+ # directory — path to check/initialize (defaults to current working directory)
144
147
  prizm_ensure_git_repo() {
148
+ local target_dir="${1:-.}"
149
+
150
+ # --- helper: run a command with a timeout (macOS-compatible) ---
151
+ # Uses GNU timeout / gtimeout if available, otherwise a background+kill fallback.
152
+ _run_with_timeout() {
153
+ local secs="$1"; shift
154
+ if command -v timeout &>/dev/null; then
155
+ timeout "$secs" "$@"
156
+ elif command -v gtimeout &>/dev/null; then
157
+ gtimeout "$secs" "$@"
158
+ else
159
+ # background + kill fallback
160
+ "$@" &
161
+ local pid=$!
162
+ ( sleep "$secs" && kill "$pid" 2>/dev/null ) &
163
+ local watchdog=$!
164
+ if wait "$pid" 2>/dev/null; then
165
+ kill "$watchdog" 2>/dev/null; wait "$watchdog" 2>/dev/null
166
+ return 0
167
+ else
168
+ kill "$watchdog" 2>/dev/null; wait "$watchdog" 2>/dev/null
169
+ return 1
170
+ fi
171
+ fi
172
+ }
173
+
145
174
  if ! command -v git &>/dev/null; then
146
- log_error "git is required but not installed."
147
- log_error "Install git:"
148
- log_error " macOS: brew install git or xcode-select --install"
149
- log_error " Ubuntu: sudo apt-get install git"
150
- log_error " Windows: https://git-scm.com/download/win"
175
+ log_warn "git is not installed. Attempting automatic installation..."
176
+ local _install_ok=false
177
+ case "$(uname -s)" in
178
+ Darwin)
179
+ if command -v brew &>/dev/null; then
180
+ log_info "Installing git via Homebrew..."
181
+ if _run_with_timeout 120 brew install git &>/dev/null; then
182
+ _install_ok=true
183
+ fi
184
+ else
185
+ # xcode-select --install opens a GUI dialog that cannot be automated;
186
+ # skip auto-install and fall through to manual instructions.
187
+ log_info "Homebrew not found; cannot auto-install git on macOS."
188
+ fi
189
+ ;;
190
+ Linux)
191
+ # Verify passwordless sudo is available (daemon/CI safety)
192
+ if ! sudo -n true 2>/dev/null; then
193
+ log_info "sudo requires a password; cannot auto-install git."
194
+ elif command -v apt-get &>/dev/null; then
195
+ log_info "Installing git via apt-get..."
196
+ _run_with_timeout 120 sudo apt-get update -y &>/dev/null
197
+ if _run_with_timeout 120 sudo apt-get install -y git &>/dev/null; then
198
+ _install_ok=true
199
+ fi
200
+ elif command -v yum &>/dev/null; then
201
+ log_info "Installing git via yum..."
202
+ if _run_with_timeout 120 sudo yum install -y git &>/dev/null; then
203
+ _install_ok=true
204
+ fi
205
+ elif command -v dnf &>/dev/null; then
206
+ log_info "Installing git via dnf..."
207
+ if _run_with_timeout 120 sudo dnf install -y git &>/dev/null; then
208
+ _install_ok=true
209
+ fi
210
+ elif command -v pacman &>/dev/null; then
211
+ log_info "Installing git via pacman..."
212
+ if _run_with_timeout 120 sudo pacman -S --noconfirm git &>/dev/null; then
213
+ _install_ok=true
214
+ fi
215
+ fi
216
+ ;;
217
+ esac
218
+
219
+ if $_install_ok && command -v git &>/dev/null; then
220
+ log_success "git installed successfully ($(git --version))."
221
+ else
222
+ log_error "Automatic git installation failed or timed out."
223
+ log_error "Please install git manually:"
224
+ log_error " macOS: brew install git or xcode-select --install"
225
+ log_error " Ubuntu: sudo apt-get install git"
226
+ log_error " CentOS: sudo yum install git"
227
+ log_error " Windows: https://git-scm.com/download/win"
228
+ exit 1
229
+ fi
230
+ fi
231
+
232
+ # Validate target directory exists
233
+ if [[ ! -d "$target_dir" ]]; then
234
+ log_error "Target directory does not exist: $target_dir"
151
235
  exit 1
152
236
  fi
153
237
 
154
- if ! git rev-parse --is-inside-work-tree &>/dev/null 2>&1; then
155
- log_warn "Current directory is not a git repository."
238
+ if ! git -C "$target_dir" rev-parse --is-inside-work-tree &>/dev/null 2>&1; then
239
+ log_warn "Directory is not a git repository: $target_dir"
156
240
  log_info "Initializing git repository..."
157
- git init -b main
241
+ git -C "$target_dir" init -b main
242
+ log_info "Git repository initialized at: $target_dir"
158
243
  # Create initial commit so branches and diffs work
159
- git add -A
160
- git commit --no-verify -m "chore: initial commit (auto-created by dev-pipeline)" || {
244
+ if ! git -C "$target_dir" add -A; then
245
+ log_error "Failed to stage files in: $target_dir"
246
+ exit 1
247
+ fi
248
+ git -C "$target_dir" commit --no-verify -m "chore: initial commit (auto-created by dev-pipeline)" || {
161
249
  # If nothing to commit (empty project), create an empty initial commit
162
- git commit --no-verify --allow-empty -m "chore: initial commit (auto-created by dev-pipeline)"
250
+ git -C "$target_dir" commit --no-verify --allow-empty -m "chore: initial commit (auto-created by dev-pipeline)"
163
251
  }
164
- log_success "Git repository initialized with initial commit."
252
+ log_success "Initial commit created workspace content committed."
165
253
  fi
166
254
  }
@@ -275,7 +275,9 @@ trap cleanup SIGINT SIGTERM
275
275
 
276
276
  check_dependencies() {
277
277
  prizm_check_common_dependencies "$CLI_CMD"
278
- prizm_ensure_git_repo
278
+ local _project_root
279
+ _project_root="$(cd "$SCRIPT_DIR/.." && pwd)"
280
+ prizm_ensure_git_repo "$_project_root"
279
281
  }
280
282
 
281
283
  run_log_cleanup() {
@@ -360,7 +360,9 @@ trap cleanup SIGINT SIGTERM
360
360
 
361
361
  check_dependencies() {
362
362
  prizm_check_common_dependencies "$CLI_CMD"
363
- prizm_ensure_git_repo
363
+ local _project_root
364
+ _project_root="$(cd "$SCRIPT_DIR/.." && pwd)"
365
+ prizm_ensure_git_repo "$_project_root"
364
366
  }
365
367
 
366
368
  run_log_cleanup() {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.143",
2
+ "version": "1.0.144",
3
3
  "skills": {
4
4
  "prizm-kit": {
5
5
  "description": "Full-lifecycle dev toolkit. Covers spec-driven development, Prizm context docs, code quality, debugging, deployment, and knowledge management.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prizmkit",
3
- "version": "1.0.143",
3
+ "version": "1.0.144",
4
4
  "description": "Create a new PrizmKit-powered project with clean initialization — no framework dev files, just what you need.",
5
5
  "type": "module",
6
6
  "bin": {