Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ If `install.sh` sees an existing manifest, it always adds `setup.sh --update`. W

Rules to remember: verify fresh install, `setup.sh --update`/`/update-kit`, and saved config reuse for any new `ENABLE_*`; do not overwrite explicit user choices. Legacy `~/.claude/AGENTS.md` is removed during update/uninstall because the kit no longer deploys it.

Web-content-extraction dependency lock (`skills/web-content-extraction/logs/.update.lock`, shared with `update-deps.mjs`; never taken under MDM): `setup_deploy` runs `_wce_runtime_update_lock_preflight` before any write — before `backup_existing` on update, before deployment state on fresh. It waits up to 60s for a running owner, removes a lock only when the owner is a kit-written token whose PID no longer exists and whose owner file is over 60 minutes old (never on MSYS), and otherwise exits 75 with a diagnosis and no file changed. `_wce_runtime_update_lock_acquire` itself never takes over an existing lock — keep reclaim confined to the preflight. Both acquirers (bash and `update-deps.mjs`) withdraw their own lock when `<lock>.reclaim` exists after their owner write, which is what makes the reclaimer's re-read under the mutex sufficient; a quarantined lock is put back by claiming the canonical name with `mkdir`, never `mv dir`. A symlink or non-directory on the path is state `unusable` (no lock held, no `rm`/`rmdir` offered). `update-deps.mjs` holds the lock only while applying updates, not during its `npm view` check.

`CLAUDE.md` is marker-managed: only the kit section between `BEGIN/END STARTER-KIT-MANAGED` is snapshotted/updated, while the user section is preserved. `--dry-run` redirects `CLAUDE_DIR` to a temp simulation dir, disables merge prompts, logs external side effects as `[WOULD RUN]`, and compares real `~/.claude` with the simulated result.

### Deploy Targets
Expand Down
1 change: 1 addition & 0 deletions commands/update-kit-dry-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ fi
- **Files to skip**: User-owned files that would be preserved
- **External operations**: Actions like plugin installs, shown as `[WOULD RUN]`
- **settings.json diff**: Unified diff of what would change in settings
- **Dependency lock warning** (only when present): if the real `~/.claude/skills/web-content-extraction/logs/.update.lock` is held, the preview ends with a warning that names the lock, its owner and PID state, and says whether `/update-kit` would recover it automatically or stop with exit code 75. The preview only reads the lock and still exits 0
3. After showing the summary, let the user know:
- If they want to proceed: run `/update-kit`
- If they want to cancel: no starter-kit deployment was applied; the selected
Expand Down
25 changes: 25 additions & 0 deletions commands/update-kit.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ Before running the update:
- If successful: show the previous and new version printed by the update block
- If the kit is already up to date: report "Already on the latest version"
- If it fails: show the error and suggest manual steps
- If it exits with code 75: the web-content-extraction dependency lock (`~/.claude/skills/web-content-extraction/logs/.update.lock`) could not be acquired. `setup.sh` prints the lock path, its owner, its creation time, the owner PID and whether that PID is running, and a recovery command. Relay those lines unchanged, then follow **Recovery**. The closing note says how far the run got (the wording follows the configured language): no starter-kit file was changed (stopped before the backup and before Step 1); settings.json and CLAUDE.md were processed but the remaining kit files were not (stopped after Step 2); or the kit files were updated but the dependency install (`npm ci`) did not run. Whatever the note says, the run stopped before its final steps (writing the install manifest, saving the config, plugin setup), so after resolving the lock rerun the same update block; do not substitute a manual `npm ci`
- If it exits with code 74: the lock could not be released cleanly. The kit files written before that point are in place, but the run stopped before its remaining steps (writing the install manifest, saving the config, plugin setup, and the dependency install if it had not run yet). Relay the printed lines, follow **Recovery** for the lock, then run the same update block again
4. After a successful update, tell the user how to reload the new configuration:
- Always suggest `/compact` to refresh the current session cleanly.
- Also mention that some changes may require starting a new Claude Code session or opening a new terminal, especially settings/env changes, hook updates, MCP-related changes, or newly added slash commands.
Expand Down Expand Up @@ -401,6 +403,29 @@ If an update goes wrong:
its final setup command changed to
`(cd "$kit_repo_physical" && bash setup.sh --update --reset-prefs)`

If the update stops with exit code 75 (web-content-extraction dependency lock):
- `setup.sh --update` checks the lock before the backup. It waits up to 60
seconds for a running owner, and removes the lock by itself only when the
owner is a token the kit writes, that PID no longer exists, and the lock is
at least 60 minutes old. Every other case stops with exit 75
- To recover by hand: confirm that the PID `setup.sh` printed does not exist
and that no `update-deps.mjs`, `setup.sh`, or `npm ci` process is running,
get the user's approval, run the printed
`rm -f <lock>/owner && rmdir <lock>` command, then rerun the update block
- Do not remove the lock while the printed PID is running one of those
processes. If the PID is running but is an unrelated process (a PID can be
reused), tell the user so and let them decide
- If `setup.sh` also names `<lock>.reclaim`, an earlier recovery was
interrupted; remove it with the printed `rmdir` command after the same check.
While it exists, no lock can be acquired even when `<lock>` itself is absent
- If `setup.sh` reports that the lock path is a symlink or not a directory, no
lock is held and no `rm`/`rmdir` command is printed. Show the user the path
it names (the skill directory, `logs`, or `<lock>`) and let them decide what
to replace or remove; do not delete anything through that path
- If `setup.sh` names a `<lock>.stale-*` directory it left for inspection, a
lock taken by another writer during recovery could not be put back. Show it
to the user; remove it only after the same check as for the lock

### Notes

- This updates the checkout recorded as `KIT_REPO` in the manifest-bound active
Expand Down
32 changes: 32 additions & 0 deletions i18n/en/strings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,37 @@ STR_WCE_NPM_INSTALLING="Installing web-content-extraction skill dependencies..."
STR_WCE_NPM_DONE="web-content-extraction dependencies installed"
STR_WCE_NPM_FAILED="npm ci failed for web-content-extraction; skill scripts may not run until dependencies are installed."

# web-content-extraction dependency lock (logs/.update.lock) diagnosis and recovery
STR_WCE_LOCK_BUSY="Another web-content-extraction dependency update or kit setup is still running, so this run stopped (exit 75)."
STR_WCE_LOCK_STALE="A web-content-extraction dependency lock was left behind by a process that is no longer running, so this run stopped (exit 75)."
STR_WCE_LOCK_UNKNOWN="The web-content-extraction dependency lock is held in a form the kit cannot verify, so it was left untouched and this run stopped (exit 75)."
STR_WCE_LOCK_UNAVAILABLE="The web-content-extraction dependency lock could not be acquired, so this run stopped (exit 75). Nothing holds it right now: run the same command again, and if this repeats, check that its parent is a writable directory."
STR_WCE_LOCK_UNUSABLE="The web-content-extraction dependency lock path cannot be used because it is a symlink or not a directory, so this run stopped (exit 75). No lock is held."
STR_WCE_LOCK_MUTEX_BLOCKED="The web-content-extraction dependency lock could not be acquired because a marker from an interrupted recovery exists, so this run stopped (exit 75)."
STR_WCE_LOCK_RELEASE_FAILED="The web-content-extraction dependency lock could not be released cleanly (exit 74)."
STR_WCE_LOCK_LABEL_PATH="Lock"
STR_WCE_LOCK_LABEL_UNUSABLE="Not a directory"
STR_WCE_LOCK_LABEL_OWNER="Owner"
STR_WCE_LOCK_LABEL_CREATED="Created"
STR_WCE_LOCK_LABEL_PID="Owner PID"
STR_WCE_LOCK_PID_ALIVE="running"
STR_WCE_LOCK_PID_DEAD="not running"
STR_WCE_LOCK_PID_UNKNOWN="cannot be determined"
STR_WCE_LOCK_HINT_BUSY="Wait for it to finish, then run the same command again. Only if that PID is not update-deps.mjs, setup.sh, or npm (a PID can be reused), remove the lock:"
STR_WCE_LOCK_HINT_STALE="setup.sh recovers it automatically once it is 60 minutes old. To recover now, confirm that PID is not running, then run:"
STR_WCE_LOCK_HINT_UNKNOWN="Confirm that no update-deps.mjs, setup.sh, or npm ci process is running, then remove the lock and run the same command again:"
STR_WCE_LOCK_HINT_UNUSABLE="Check what that path is and replace it with a regular directory (or remove it), then run the same command again. Do not remove anything through it."
STR_WCE_LOCK_HINT_MUTEX="An interrupted recovery left a marker that disables automatic recovery. After the same check, remove it too:"
STR_WCE_LOCK_QUARANTINE_LEFT="A lock that was moved aside during recovery could not be put back and was left for inspection:"
STR_WCE_LOCK_WAITING="Waiting for a running web-content-extraction dependency update or kit setup to finish"
STR_WCE_LOCK_RECOVERED="Recovered a web-content-extraction dependency lock left behind by a process that is no longer running."
STR_WCE_LOCK_UNTOUCHED_NOTE="No starter-kit file was changed by this run."
STR_WCE_LOCK_PARTIAL_NOTE="settings.json and CLAUDE.md were already processed by this run; the remaining kit files were not. Resolve the lock and run the same command again to apply the rest."
STR_WCE_LOCK_DEPS_NOTE="The starter-kit files were already updated by this run, but the web-content-extraction dependency install (npm ci) and the remaining steps (the install manifest, saving the settings, and plugin setup) did not run. Resolve the lock and run the same command again."
STR_WCE_LOCK_RELEASE_NOTE="This run stopped before its remaining steps, including the install manifest, saving the settings, and plugin setup. Resolve the lock and run the same command again."
STR_WCE_LOCK_DRYRUN_BLOCKED="The web-content-extraction dependency lock is held. The real run waits up to 60 seconds for a running owner and otherwise stops (exit 75) before changing any file."
STR_WCE_LOCK_DRYRUN_RECOVERABLE="A web-content-extraction dependency lock was left behind by a process that is no longer running. The real run recovers it automatically before updating."

# Step 6: Plugins
STR_PLUGINS_TITLE="Select plugins to install (enter numbers separated by spaces):"
STR_PLUGINS_NOTE="Note: Plugins are installed inside a Claude Code session after setup."
Expand Down Expand Up @@ -352,6 +383,7 @@ STR_CLAUDEMD_MIGRATION_PROMPT="[M]erge (add kit section + keep yours) / [S]kip ?
STR_CLAUDEMD_MIGRATION_SKIP="CLAUDE.md migration skipped (non-interactive). Run interactively to merge."
STR_CLAUDEMD_KIT_UPDATED="CLAUDE.md kit section updated"
STR_CLAUDEMD_KIT_UNCHANGED="CLAUDE.md kit section unchanged"
STR_CLAUDEMD_KIT_BASELINE_REFRESHED="CLAUDE.md kit section already matches this version; snapshot refreshed"
STR_CLAUDEMD_KIT_CONFLICT="CLAUDE.md kit section: both you and kit have changes"
STR_CLAUDEMD_KIT_CONFLICT_PROMPT="[U]se new kit / [K]eep yours / [D]iff ?"
STR_CLAUDEMD_KIT_CONFLICT_KEPT="CLAUDE.md kit section has updates, but your local edits were kept (re-run interactively to choose whether to adopt them)"
Expand Down
32 changes: 32 additions & 0 deletions i18n/ja/strings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,37 @@ STR_WCE_NPM_INSTALLING="web-content-extraction スキルの依存をインスト
STR_WCE_NPM_DONE="web-content-extraction の依存をインストールしました"
STR_WCE_NPM_FAILED="web-content-extraction の npm ci に失敗しました(依存導入までスクリプトは動作しません)"

# web-content-extraction dependency lock (logs/.update.lock) diagnosis and recovery
STR_WCE_LOCK_BUSY="web-content-extraction の依存更新または kit の setup が実行中のため、この実行を中止しました(終了コード 75)。"
STR_WCE_LOCK_STALE="すでに終了したプロセスが web-content-extraction の依存 lock を残しているため、この実行を中止しました(終了コード 75)。"
STR_WCE_LOCK_UNKNOWN="web-content-extraction の依存 lock が kit で確認できない形式で保持されているため、lock には触れずにこの実行を中止しました(終了コード 75)。"
STR_WCE_LOCK_UNAVAILABLE="web-content-extraction の依存 lock を取得できなかったため、この実行を中止しました(終了コード 75)。現在は誰も保持していません。同じコマンドを再実行し、繰り返す場合は親ディレクトリが書き込み可能なディレクトリか確認してください。"
STR_WCE_LOCK_UNUSABLE="web-content-extraction の依存 lock のパスが symlink またはディレクトリ以外のため使用できず、この実行を中止しました(終了コード 75)。lock は保持されていません。"
STR_WCE_LOCK_MUTEX_BLOCKED="中断された回収処理の目印が残っているため web-content-extraction の依存 lock を取得できず、この実行を中止しました(終了コード 75)。"
STR_WCE_LOCK_RELEASE_FAILED="web-content-extraction の依存 lock を正常に解放できませんでした(終了コード 74)。"
STR_WCE_LOCK_LABEL_PATH="lock"
STR_WCE_LOCK_LABEL_UNUSABLE="ディレクトリでないパス"
STR_WCE_LOCK_LABEL_OWNER="owner"
STR_WCE_LOCK_LABEL_CREATED="作成時刻"
STR_WCE_LOCK_LABEL_PID="owner の PID"
STR_WCE_LOCK_PID_ALIVE="実行中"
STR_WCE_LOCK_PID_DEAD="存在しない"
STR_WCE_LOCK_PID_UNKNOWN="判定できない"
STR_WCE_LOCK_HINT_BUSY="終了を待ってから同じコマンドを再実行してください。その PID が update-deps.mjs / setup.sh / npm のいずれでもない場合(PID は再利用されることがあります)に限り、lock を削除してください:"
STR_WCE_LOCK_HINT_STALE="作成から 60 分が経過すると setup.sh が自動で回収します。今すぐ回復する場合は、その PID が存在しないことを確認してから次を実行してください:"
STR_WCE_LOCK_HINT_UNKNOWN="update-deps.mjs / setup.sh / npm ci が動いていないことを確認してから lock を削除し、同じコマンドを再実行してください:"
STR_WCE_LOCK_HINT_UNUSABLE="そのパスが何かを確認し、通常のディレクトリに置き換える(または取り除く)うえで、同じコマンドを再実行してください。そのパスを経由して何かを削除しないでください。"
STR_WCE_LOCK_HINT_MUTEX="中断された回収処理の目印が残っており、自動回収が無効になっています。同じ確認をしたうえで、これも削除してください:"
STR_WCE_LOCK_QUARANTINE_LEFT="回収中に退避した lock を元の場所に戻せなかったため、確認用に残しました:"
STR_WCE_LOCK_WAITING="実行中の web-content-extraction 依存更新または kit の setup の終了を待っています"
STR_WCE_LOCK_RECOVERED="すでに終了したプロセスが残した web-content-extraction の依存 lock を回収しました。"
STR_WCE_LOCK_UNTOUCHED_NOTE="この実行では starter kit のファイルを変更していません。"
STR_WCE_LOCK_PARTIAL_NOTE="settings.json と CLAUDE.md はこの実行で処理済みですが、残りの kit ファイルは未処理です。lock を解消してから同じコマンドを再実行すると残りが適用されます。"
STR_WCE_LOCK_DEPS_NOTE="starter kit のファイルはこの実行で更新済みですが、web-content-extraction の依存インストール(npm ci)と、その後の処理(インストール manifest の書き込み、設定の保存、plugin のセットアップ)は実行されていません。lock を解消してから同じコマンドを再実行してください。"
STR_WCE_LOCK_RELEASE_NOTE="この実行は、インストール manifest の書き込み、設定の保存、plugin のセットアップを含む残りの処理の前で止まりました。lock を解消してから同じコマンドを再実行してください。"
STR_WCE_LOCK_DRYRUN_BLOCKED="web-content-extraction の依存 lock が保持されています。実際の実行では、owner が実行中なら最大 60 秒待ち、それ以外はファイルを変更する前に中止します(終了コード 75)。"
STR_WCE_LOCK_DRYRUN_RECOVERABLE="すでに終了したプロセスが web-content-extraction の依存 lock を残しています。実際の実行では、更新の前に自動で回収します。"

# Step 6: Plugins
STR_PLUGINS_TITLE="インストールするプラグインを選択してください(番号をスペース区切りで入力):"
STR_PLUGINS_NOTE="注意: プラグインはセットアップ後に Claude Code セッション内でインストールします。"
Expand Down Expand Up @@ -350,6 +381,7 @@ STR_CLAUDEMD_MIGRATION_PROMPT="[M] マージ(kit セクション追加 + 既
STR_CLAUDEMD_MIGRATION_SKIP="CLAUDE.md のマイグレーションをスキップしました(非対話モード)。対話モードで再実行してください。"
STR_CLAUDEMD_KIT_UPDATED="CLAUDE.md の kit セクションを更新しました"
STR_CLAUDEMD_KIT_UNCHANGED="CLAUDE.md の kit セクションに変更なし"
STR_CLAUDEMD_KIT_BASELINE_REFRESHED="CLAUDE.md の kit セクションはすでにこの版と一致しています(snapshot を更新)"
STR_CLAUDEMD_KIT_CONFLICT="CLAUDE.md の kit セクション: ユーザーと kit の両方に変更があります"
STR_CLAUDEMD_KIT_CONFLICT_PROMPT="[U] 新しい kit を使用 / [K] 現在のまま / [D] 差分表示 ?"
STR_CLAUDEMD_KIT_CONFLICT_KEPT="CLAUDE.md の kit セクションに更新がありますが、ユーザー編集があるため現状を保持しました(対話モードで再実行すると取り込みを選択できます)"
Expand Down
19 changes: 12 additions & 7 deletions lib/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1820,19 +1820,24 @@ maybe_install_web_content_deps() {
return 1
fi
local npm_rc=0
# In update mode this is a second acquisition after run_update released the
# lock, so a writer can take it in between. Every kit file is already in
# place by then, but setup stops on a 74/75 before its final steps
# (manifest, saved config, plugins); the helper's diagnosis appends the
# matching note.
local _WCE_RUNTIME_LOCK_FAILURE_NOTE="${STR_WCE_LOCK_DEPS_NOTE:-The starter-kit files were already updated by this run, but the web-content-extraction dependency install (npm ci) and the remaining steps (the install manifest, saving the settings, and plugin setup) did not run. Resolve the lock and run the same command again.}"
local _WCE_RUNTIME_LOCK_RELEASE_NOTE="${STR_WCE_LOCK_RELEASE_NOTE:-This run stopped before its remaining steps, including the install manifest, saving the settings, and plugin setup. Resolve the lock and run the same command again.}"
_wce_with_runtime_update_lock \
"$skill_dir" _wce_run_non_mdm_npm_ci "$skill_dir" || npm_rc=$?
case "$npm_rc" in
0)
ok "${STR_WCE_NPM_DONE:-web-content-extraction dependencies installed}"
;;
74)
warn "web-content-extraction dependency lock could not be released; retry setup"
return 1
;;
75)
warn "web-content-extraction dependency update is already active; retry setup after it finishes"
return 1
74|75)
# The lock helper already reported the lock path, owner, PID state, and
# recovery steps on stderr, naming this exit code; keep it so the
# process exits with the code the diagnosis announced.
return "$npm_rc"
;;
129|130|143)
return "$npm_rc"
Expand Down
Loading
Loading