Extract /statusline install logic into a tested script#12
Open
gering wants to merge 3 commits into
Open
Conversation
Move install/enable/disable/uninstall/status out of 24 KB of SKILL.md
prose into scripts/statusline-install.sh; the skill becomes a thin
wrapper (parse argument, invoke script, relay output).
- New statusline-install.sh: marker-block injection/removal, # {{cks}}
placement priority, version-gated renderer copy, per-project sentinel,
atomic python3 mutation with backup + post-write verify
- Shrink SKILL.md from 24 KB to 4.6 KB
- Bump knowledge-system to 1.8.0 (plugin.json + marketplace.json)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Address findings from a multi-angle review of statusline-install.sh: - restore_and_die: report a failed restore truthfully instead of a false "Restored from backup" when the cp itself fails - mutate_file: read/write bytes so CRLF and non-ASCII host files survive untouched (text mode normalized newlines and choked under a C locale) - inspect_markers: single marker-pair classifier shared by install, uninstall, and status — status now applies the BEGIN<END check and reports INVALID consistently instead of "installed and current" - project_dir helper: per-project sentinel ops mirror the renderer's DIR-first precedence so disable/enable/status agree with render time - validate START_LINE/END_LINE before mutation (grep-misfire failsafe) - backup via mktemp (no same-second collision); post-write chmod warns instead of failing a correct install; status distinguishes an unreadable target from an absent marker; empty argument token defaults to status Covered by a 22-case sandbox suite (all green); check-structure clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Second review-round findings on statusline-install.sh: - mutate_file split on \n only (matching grep -n) instead of bytes.splitlines(), which also breaks on a lone \r and desynced the Python line indices from the bash-computed ones — a lone-CR line above the marker would splice the block at the wrong offset - preserve the host file's permission bits across os.replace (copy the original mode onto the temp file), so install no longer drops group/other bits (e.g. 0770 -> 0644) or print a spurious "was dropped during write" on every run - project_dir back to CLAUDE_PROJECT_DIR-first: a stray $DIR in the environment must not redirect the per-project sentinel (and this matches the SKILL.md contract) Sandbox suite extended to 24 cases (lone-CR placement, mode preservation, stray-$DIR sentinel); all green; check-structure clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/statuslineinstall/enable/disable/uninstall/status logic out of 24 KB ofSKILL.mdprose into a deterministic, locally-testable shell script.statusline-cks.sh) was already a script; now the install half is too.Changes
plugins/knowledge-system/scripts/statusline-install.sh(518 lines): marker-block injection/removal,# {{cks}}placement priority (placeholder → auto-detect → guided abort), version-gated renderer copy, per-project sentinel management, atomicpython3mutation with session backup + post-write verify (non-empty / marker-pair /bash -n/ executable-bit), restore-on-failure.SKILL.mdshrunk 24 KB → 4.6 KB: argument parsing + script invocation + result presentation; user-facing docs (output format, custom placement, third-party tools) retained.plugin.json+marketplace.json, in sync).Readiness
.claude/knowledge; applies the established prose→script pattern from/define,/rebase)scripts/check-structure.py0 errors; 16/16 functional sandbox tests passbash -ncovered by the structure check)Test plan
python3 scripts/check-structure.py→ 0 errorsbash -n plugins/knowledge-system/scripts/statusline-install.sh/statusline statusin a project with.claude/knowledgeor.claude/rules/statusline installagainst a custom~/.claude/statusline.sh(placeholder + auto-detect paths), thenuninstall— confirm clean round-trip and backup🤖 Generated with Claude Code