@krysoworks/kryso 0.0.2 → 2.0.0-rc.1
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.
- package/LICENSE +21 -0
- package/README.md +146 -6
- package/bin/kryso +31 -0
- package/bin/ship-it-status +14 -0
- package/bin/ship-ledger +14 -0
- package/bin/ship-loop +14 -0
- package/bin/ship-pass +14 -0
- package/bin/warden +14 -0
- package/dist/answer.d.ts +38 -0
- package/dist/answer.js +48 -0
- package/dist/bytes.d.ts +5 -0
- package/dist/bytes.js +35 -0
- package/dist/cleanup.d.ts +1 -0
- package/dist/cleanup.js +629 -0
- package/dist/commands.d.ts +48 -0
- package/dist/commands.js +293 -0
- package/dist/completions.d.ts +24 -0
- package/dist/completions.js +239 -0
- package/dist/daemon.d.ts +15 -0
- package/dist/daemon.js +23 -0
- package/dist/diagnose.d.ts +47 -0
- package/dist/diagnose.js +314 -0
- package/dist/doctor.d.ts +1 -0
- package/dist/doctor.js +241 -0
- package/dist/env.d.ts +9 -0
- package/dist/env.js +17 -0
- package/dist/evidence.d.ts +39 -0
- package/dist/evidence.js +327 -0
- package/dist/home.d.ts +3 -0
- package/dist/home.js +27 -0
- package/dist/install.d.ts +59 -0
- package/dist/install.js +137 -0
- package/dist/isolate.d.ts +28 -0
- package/dist/isolate.js +402 -0
- package/dist/leftovers.d.ts +5 -0
- package/dist/leftovers.js +156 -0
- package/dist/machine.d.ts +6 -0
- package/dist/machine.js +185 -0
- package/dist/palette.d.ts +147 -0
- package/dist/palette.js +167 -0
- package/dist/plan.d.ts +1 -0
- package/dist/plan.js +133 -0
- package/dist/proc.d.ts +23 -0
- package/dist/proc.js +23 -0
- package/dist/read.d.ts +1 -0
- package/dist/read.js +297 -0
- package/dist/readiness.d.ts +5 -0
- package/dist/readiness.js +64 -0
- package/dist/remote.d.ts +6 -0
- package/dist/remote.js +85 -0
- package/dist/self-update.d.ts +1 -0
- package/dist/self-update.js +224 -0
- package/dist/semver.d.ts +7 -0
- package/dist/semver.js +42 -0
- package/dist/style.d.ts +71 -0
- package/dist/style.js +187 -0
- package/dist/update.d.ts +47 -0
- package/dist/update.js +190 -0
- package/dist/work.d.ts +25 -0
- package/dist/work.js +449 -0
- package/dist/workflows.d.ts +4 -0
- package/dist/workflows.js +73 -0
- package/docker/entrypoint.sh +44 -0
- package/docker/runner.Dockerfile +39 -0
- package/package.json +55 -22
- package/scripts/install-skills.sh +607 -0
- package/skills/code-review/SKILL.md +231 -0
- package/skills/kryso/SKILL.md +107 -0
- package/skills/kryso/golden/help.rounded.ansi +23 -0
- package/skills/kryso/golden/help.square.ansi +23 -0
- package/skills/kryso/golden/help.txt +23 -0
- package/skills/kryso/golden/table-narrow.json +11 -0
- package/skills/kryso/golden/table-narrow.rounded.ansi +4 -0
- package/skills/kryso/golden/table-narrow.square.ansi +4 -0
- package/skills/kryso/golden/table.ansi +5 -0
- package/skills/kryso/golden/table.json +11 -0
- package/skills/kryso/ledger.sh +2146 -0
- package/skills/kryso/palette.json +57 -0
- package/skills/kryso/reference/resuming.md +30 -0
- package/skills/kryso/reference/routing.md +23 -0
- package/skills/kryso/reference/stage-1-claim.md +79 -0
- package/skills/kryso/reference/stage-2-build.md +133 -0
- package/skills/kryso/reference/stage-3-prove.md +51 -0
- package/skills/kryso/reference/stage-4-pr.md +76 -0
- package/skills/kryso/reference/stage-5-reconcile.md +81 -0
- package/skills/kryso/reference/stage-6-merge-or-park.md +73 -0
- package/skills/kryso/reference/stage-7-close-out.md +62 -0
- package/skills/kryso/reference/terminal.md +7 -0
- package/skills/kryso/ship-it-status.sh +1503 -0
- package/skills/kryso/ui.py +274 -0
- package/skills/kryso/ui.sh +609 -0
- package/skills/kryso-build/SKILL.md +168 -0
- package/skills/kryso-shift/SKILL.md +167 -0
- package/skills/kryso-shift/archive.py +2784 -0
- package/skills/kryso-shift/archive_checker.py +462 -0
- package/skills/kryso-shift/archive_checker_lambda.py +155 -0
- package/skills/kryso-shift/archive_health.py +364 -0
- package/skills/kryso-shift/archive_launchd.py +140 -0
- package/skills/kryso-shift/archive_remote.py +990 -0
- package/skills/kryso-shift/archiving-checker.md +140 -0
- package/skills/kryso-shift/archiving-keep.md +115 -0
- package/skills/kryso-shift/archiving-recovery.md +112 -0
- package/skills/kryso-shift/archiving-remote.md +166 -0
- package/skills/kryso-shift/archiving.md +146 -0
- package/skills/kryso-shift/coverage.schema.json +225 -0
- package/skills/kryso-shift/deadline.sh +254 -0
- package/skills/kryso-shift/feedback.schema.json +35 -0
- package/skills/kryso-shift/feedback.sh +228 -0
- package/skills/kryso-shift/history-manifest.schema.json +331 -0
- package/skills/kryso-shift/keep-after.sh +55 -0
- package/skills/kryso-shift/measure.sh +611 -0
- package/skills/kryso-shift/merge-ready.sh +207 -0
- package/skills/kryso-shift/outcome.schema.json +16 -0
- package/skills/kryso-shift/pass-rules.md +8 -0
- package/skills/kryso-shift/profile.schema.json +42 -0
- package/skills/kryso-shift/reader.sh +692 -0
- package/skills/kryso-shift/reads.sh +151 -0
- package/skills/kryso-shift/reference/allowance.md +21 -0
- package/skills/kryso-shift/reference/driver.md +95 -0
- package/skills/kryso-shift/reference/measuring.md +67 -0
- package/skills/kryso-shift/reference/outputs.md +21 -0
- package/skills/kryso-shift/reference/pass-script.md +115 -0
- package/skills/kryso-shift/reference/reconcile-and-merge.md +55 -0
- package/skills/kryso-shift/reference/second-reader.md +9 -0
- package/skills/kryso-shift/reference/sweeps.md +83 -0
- package/skills/kryso-shift/repair.schema.json +14 -0
- package/skills/kryso-shift/report-template.html +679 -0
- package/skills/kryso-shift/report.py +389 -0
- package/skills/kryso-shift/report_fixture.py +65 -0
- package/skills/kryso-shift/reporting.md +58 -0
- package/skills/kryso-shift/result.sh +91 -0
- package/skills/kryso-shift/runner.sh +1178 -0
- package/skills/kryso-shift/ship-loop.sh +3977 -0
- package/skills/kryso-shift/ship-pass.sh +4987 -0
- package/skills/kryso-shift/steps.jq +19 -0
- package/skills/kryso-shift/workflow.mjs +830 -0
- package/skills/kryso-shift/workflows/default.json +22 -0
- package/skills/kryso-shift/workflows/ralph.json +13 -0
- package/skills/kryso-watch/SKILL.md +100 -0
- package/skills/kryso-watch/answer.schema.json +23 -0
- package/skills/kryso-watch/base-refs.sh +44 -0
- package/skills/kryso-watch/board.sh +58 -0
- package/skills/kryso-watch/reference/config.md +23 -0
- package/skills/kryso-watch/reference/outputs.md +30 -0
- package/skills/kryso-watch/reference/report.md +29 -0
- package/skills/kryso-watch/reference/scheduler.md +32 -0
- package/skills/kryso-watch/reference/settlement.md +29 -0
- package/skills/kryso-watch/reference/shift.md +44 -0
- package/skills/kryso-watch/reference/shim-limits.md +22 -0
- package/skills/kryso-watch/reference/triage.md +26 -0
- package/skills/kryso-watch/schema.jq +40 -0
- package/skills/kryso-watch/settle.schema.json +36 -0
- package/skills/kryso-watch/stage-common.sh +187 -0
- package/skills/kryso-watch/stages/report.sh +525 -0
- package/skills/kryso-watch/stages/settle.sh +722 -0
- package/skills/kryso-watch/stages/shift.sh +466 -0
- package/skills/kryso-watch/stages/triage.sh +379 -0
- package/skills/kryso-watch/tracker.sh +27 -0
- package/skills/kryso-watch/triage.schema.json +77 -0
- package/skills/kryso-watch/warden.launchd.plist +50 -0
- package/skills/kryso-watch/warden.schema.json +98 -0
- package/skills/kryso-watch/warden.sh +1004 -0
- package/bin/kryso.js +0 -11
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# install-skills: install this checkout's skills for the current user, in the layout
|
|
3
|
+
# `npx skills add krysoworks/kryso` makes, and, from a checkout whose packages/cli is built,
|
|
4
|
+
# install the kryso command beside them and link it onto PATH with the five old command names
|
|
5
|
+
# it answers to for one release. `npx skills add` installs from GitHub's main branch, so this is the way to install
|
|
6
|
+
# a branch before it merges. Each skill is copied whole to ~/.agents/skills/<name> and linked
|
|
7
|
+
# from ~/.claude/skills/<name>. A skill whose copy differs from the installed one replaces it,
|
|
8
|
+
# and the installed one moves to ~/.agents/skills-backup-<date>/, where no earlier backup is
|
|
9
|
+
# overwritten. It refuses to replace a copy while a process runs a script from it, and it
|
|
10
|
+
# leaves alone anything in a link's place that it did not make, and `--check-running` runs only
|
|
11
|
+
# that check, for kryso self-update. From a git checkout, the command's copy carries install.json,
|
|
12
|
+
# which names the checkout, its branch, the sha installed, when, and the bin directory, so kryso
|
|
13
|
+
# self-update can tell a checkout install and repeat it. The skills CLI's lock file is
|
|
14
|
+
# not touched. When a skill renamed in #176 installs under its new name, the old name's agent
|
|
15
|
+
# link goes and the old copy stays. See docs/agents/updating-installed-skills.md.
|
|
16
|
+
#
|
|
17
|
+
# Attended, the report takes kryso status's look, through kryso's ui.sh: the brand line, then a
|
|
18
|
+
# pill and a table each for the skills and the commands. Unattended, or with no ui.sh to find,
|
|
19
|
+
# it is the plain lines, which never change (ADR 0006).
|
|
20
|
+
set -uo pipefail
|
|
21
|
+
|
|
22
|
+
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
23
|
+
SRC="$(dirname "$HERE")/skills"
|
|
24
|
+
DEST="$HOME/.agents/skills"
|
|
25
|
+
AGENT_LINKS="$HOME/.claude/skills"
|
|
26
|
+
BACKUP="$HOME/.agents/skills-backup-$(date +%Y-%m-%d)"
|
|
27
|
+
BIN="$HOME/bin"
|
|
28
|
+
# The kryso command: its launcher, its planner and its package.json, copied from the checkout
|
|
29
|
+
# to ~/.agents/kryso, where it finds the installed skills beside it. A shift started through it
|
|
30
|
+
# so runs the installed copies, never the checkout's.
|
|
31
|
+
CLI_SRC="$(dirname "$HERE")/packages/cli"
|
|
32
|
+
CLI_DEST="$HOME/.agents/kryso"
|
|
33
|
+
CLI_PARTS="bin dist package.json"
|
|
34
|
+
# The runner image's files, at the repository's root, copied beside the command so that
|
|
35
|
+
# `kryso isolate build` finds them in an install.
|
|
36
|
+
CLI_DOCKER="$(dirname "$HERE")/docker"
|
|
37
|
+
# The skills the command runs. It installs only when all three are installed or being installed.
|
|
38
|
+
CLI_NEEDS="kryso kryso-shift kryso-watch"
|
|
39
|
+
# The skills #176 renamed are the kryso package's, in its package.json under kryso.retired, old
|
|
40
|
+
# name first, where kryso doctor and kryso cleanup read them too, so a rename is one edit. The
|
|
41
|
+
# package.json is packages/cli's in a checkout and the one beside scripts/ in the npm package.
|
|
42
|
+
# When a new name installs, the old one's agent link goes, so a session lists each skill once.
|
|
43
|
+
# The old copy stays, because a LaunchAgent or a script may still run it by path, and the update
|
|
44
|
+
# guide says when to remove it.
|
|
45
|
+
RETIRED_FROM="$CLI_SRC/package.json"
|
|
46
|
+
[[ -f "$RETIRED_FROM" ]] || RETIRED_FROM="$(dirname "$HERE")/package.json"
|
|
47
|
+
|
|
48
|
+
usage() {
|
|
49
|
+
cat <<'EOF'
|
|
50
|
+
Usage: kryso skills install [options] [skill ...]
|
|
51
|
+
|
|
52
|
+
It installs the named skills from this checkout, or every skill under skills/
|
|
53
|
+
when you name none. From a checkout whose packages/cli is built, it also
|
|
54
|
+
installs the kryso command and links it onto PATH, with ship-loop, ship-pass,
|
|
55
|
+
ship-ledger, ship-it-status and warden as its old names.
|
|
56
|
+
|
|
57
|
+
--bin DIR where the command links go (default ~/bin)
|
|
58
|
+
--no-bin link no commands
|
|
59
|
+
--dry-run print what would change, and change nothing
|
|
60
|
+
--check-running
|
|
61
|
+
only check: name each process that runs a script from a copy this
|
|
62
|
+
install would replace, and exit 75, or exit 0 when none does. It
|
|
63
|
+
changes nothing. From a checkout, it covers the installed command
|
|
64
|
+
and its links, built or not
|
|
65
|
+
--also DIR count DIR as a copy this install replaces too. kryso self-update
|
|
66
|
+
names the package it is about to replace
|
|
67
|
+
--ignore-pid PID
|
|
68
|
+
leave process PID out of that check. kryso self-update names its
|
|
69
|
+
own, which loaded all it runs before the copy changes
|
|
70
|
+
-h, --help print this help
|
|
71
|
+
|
|
72
|
+
While a process runs a script from a copy it would replace, the install changes
|
|
73
|
+
nothing and exits 75.
|
|
74
|
+
EOF
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
# ── Styled output ─────────────────────────────────────────────────────────────────────────
|
|
78
|
+
# ui.sh is kryso's, this checkout's copy first and the installed one after, found before the
|
|
79
|
+
# arguments are read, so the help and a bad argument are drawn on an attended run too. The rows
|
|
80
|
+
# the tables are drawn from collect under TMP, and only a styled run makes it.
|
|
81
|
+
STYLED=0
|
|
82
|
+
for ui_sh in "$SRC/kryso/ui.sh" "$DEST/kryso/ui.sh"; do
|
|
83
|
+
[[ -f "$ui_sh" ]] || continue
|
|
84
|
+
# shellcheck source=/dev/null
|
|
85
|
+
. "$ui_sh" && ui_stream 1 && ui_attended && STYLED=1
|
|
86
|
+
break
|
|
87
|
+
done
|
|
88
|
+
# Without ui.sh nothing is attended, so every line is the plain one.
|
|
89
|
+
declare -F ui_err_attended > /dev/null || { ui_attended() { return 1; }; ui_err_attended() { return 1; }; }
|
|
90
|
+
# bad_args <plain line> <message>: an argument this cannot take, exit 64. An attended stderr gets
|
|
91
|
+
# the message under an ERROR pill, with the help as its hint. Plain gets the line, when there is
|
|
92
|
+
# one, then the usage.
|
|
93
|
+
bad_args() {
|
|
94
|
+
if ui_err_attended; then ui_error "$2" "kryso skills install --help lists the options"
|
|
95
|
+
else
|
|
96
|
+
[[ -z "$1" ]] || echo "install-skills: $1" >&2
|
|
97
|
+
usage >&2
|
|
98
|
+
fi
|
|
99
|
+
exit 64
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
DRY_RUN=0
|
|
103
|
+
LINK_BIN=1
|
|
104
|
+
CHECK_RUNNING=0
|
|
105
|
+
ALSO=()
|
|
106
|
+
IGNORE_PIDS=()
|
|
107
|
+
SKILLS=()
|
|
108
|
+
while [[ $# -gt 0 ]]; do
|
|
109
|
+
case "$1" in
|
|
110
|
+
--bin) [[ $# -ge 2 ]] || bad_args "" "--bin takes a directory"; BIN="$2"; shift 2 ;;
|
|
111
|
+
--no-bin) LINK_BIN=0; shift ;;
|
|
112
|
+
--dry-run) DRY_RUN=1; shift ;;
|
|
113
|
+
--check-running) CHECK_RUNNING=1; shift ;;
|
|
114
|
+
--also) [[ $# -ge 2 ]] || bad_args "" "--also takes a directory"; ALSO+=("${2%/}"); shift 2 ;;
|
|
115
|
+
--ignore-pid) [[ "${2:-}" =~ ^[0-9]+$ ]] || bad_args "" "--ignore-pid takes a process id"; IGNORE_PIDS+=("$2"); shift 2 ;;
|
|
116
|
+
-h|--help)
|
|
117
|
+
if [[ "$STYLED" -eq 1 ]]; then ui_brand "skills install" help; usage | ui_help; else usage; fi
|
|
118
|
+
exit 0 ;;
|
|
119
|
+
-*) bad_args "unknown option $1" "unknown option $1" ;;
|
|
120
|
+
*) SKILLS+=("$1"); shift ;;
|
|
121
|
+
esac
|
|
122
|
+
done
|
|
123
|
+
|
|
124
|
+
if [[ ${#SKILLS[@]} -eq 0 ]]; then
|
|
125
|
+
for dir in "$SRC"/*/; do
|
|
126
|
+
[[ -f "$dir/SKILL.md" ]] && SKILLS+=("$(basename "$dir")")
|
|
127
|
+
done
|
|
128
|
+
fi
|
|
129
|
+
for skill in "${SKILLS[@]}"; do
|
|
130
|
+
if [[ ! -f "$SRC/$skill/SKILL.md" ]]; then
|
|
131
|
+
if ui_err_attended; then ui_error "no skill '$skill' under $SRC" "kryso skills install with no names installs every skill"
|
|
132
|
+
else echo "install-skills: no skill '$skill' under $SRC" >&2; fi
|
|
133
|
+
exit 64
|
|
134
|
+
fi
|
|
135
|
+
done
|
|
136
|
+
|
|
137
|
+
# The kryso command comes from a checkout, which carries packages/cli, built or not. The npm
|
|
138
|
+
# package does not, because npm already put kryso and its old names on PATH. It is installed
|
|
139
|
+
# when this run installs one of the skills it runs and the others are installed too, because it
|
|
140
|
+
# finds them beside it: CLI is none, unbuilt, partial (CLI_MISSING names what is not there) or
|
|
141
|
+
# built. Its commands are the names in its package.json's bin, kryso and the old five.
|
|
142
|
+
CLI=none; CLI_MISSING=""; COMMANDS=""
|
|
143
|
+
if [[ -f "$CLI_SRC/bin/kryso" ]]; then
|
|
144
|
+
for need in $CLI_NEEDS; do
|
|
145
|
+
if [[ " ${SKILLS[*]} " == *" $need "* ]]; then CLI=wanted
|
|
146
|
+
elif [[ ! -f "$DEST/$need/SKILL.md" ]]; then CLI_MISSING+=" $need"; fi
|
|
147
|
+
done
|
|
148
|
+
if [[ "$CLI" == wanted ]]; then
|
|
149
|
+
if [[ ! -f "$CLI_SRC/dist/plan.js" ]]; then CLI=unbuilt
|
|
150
|
+
elif [[ -n "$CLI_MISSING" ]]; then CLI=partial
|
|
151
|
+
else
|
|
152
|
+
CLI=built
|
|
153
|
+
COMMANDS="$(jq -r '.bin | keys[]' "$CLI_SRC/package.json" 2>/dev/null)" \
|
|
154
|
+
|| { echo "install-skills: cannot read the commands in $CLI_SRC/package.json" >&2; exit 1; }
|
|
155
|
+
fi
|
|
156
|
+
fi
|
|
157
|
+
fi
|
|
158
|
+
# The command's copy and links the running-copy check covers: the ones this run installs, and in
|
|
159
|
+
# a check from a checkout, the ones the checkout's command would replace, built or not.
|
|
160
|
+
GUARD_CLI=0
|
|
161
|
+
if [[ "$CLI" == built ]]; then
|
|
162
|
+
GUARD_CLI=1
|
|
163
|
+
elif [[ "$CHECK_RUNNING" -eq 1 && -f "$CLI_SRC/bin/kryso" ]]; then
|
|
164
|
+
GUARD_CLI=1
|
|
165
|
+
COMMANDS="$(jq -r '.bin | keys[]' "$CLI_SRC/package.json" 2>/dev/null)" || COMMANDS=kryso
|
|
166
|
+
fi
|
|
167
|
+
# The old names whose new names this run installs. --check-running unlinks nothing, so it needs none.
|
|
168
|
+
RENAMED=""
|
|
169
|
+
if [[ "$CHECK_RUNNING" -eq 0 ]]; then
|
|
170
|
+
RENAMED="$(jq -r '.kryso.retired | to_entries[] | "\(.key):\(.value)"' "$RETIRED_FROM" 2>/dev/null)" \
|
|
171
|
+
|| { echo "install-skills: cannot read the retired skill names in $RETIRED_FROM" >&2; exit 1; }
|
|
172
|
+
fi
|
|
173
|
+
OLD_NAMES=()
|
|
174
|
+
for pair in $RENAMED; do
|
|
175
|
+
[[ " ${SKILLS[*]} " == *" ${pair#*:} "* ]] && OLD_NAMES+=("${pair%%:*}")
|
|
176
|
+
done
|
|
177
|
+
|
|
178
|
+
if [[ "$STYLED" -eq 1 ]]; then
|
|
179
|
+
TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
|
|
180
|
+
: > "$TMP/skills"; : > "$TMP/commands"
|
|
181
|
+
fi
|
|
182
|
+
|
|
183
|
+
# say <message>: a plain line, which a styled run leaves to its tables.
|
|
184
|
+
say() { [[ "$STYLED" -eq 1 ]] && return 0; printf 'install-skills: %s\n' "$*"; }
|
|
185
|
+
# row <table> <state> <name> [note ...]: one row of a styled table, its notes one line each.
|
|
186
|
+
row() {
|
|
187
|
+
[[ "$STYLED" -eq 1 ]] || return 0
|
|
188
|
+
local table="$1" state="$2" name="$3" notes=""; shift 3
|
|
189
|
+
(( $# )) && notes="$(printf '%s\x1e' "$@")"
|
|
190
|
+
printf '%s\x1f%s\x1f%s\n' "$state" "$name" "${notes%$'\x1e'}" >> "$TMP/$table"
|
|
191
|
+
}
|
|
192
|
+
tilde() { printf '%s' "${1/#$HOME/\~}"; }
|
|
193
|
+
# act <command...>: run it, unless this is a dry run.
|
|
194
|
+
act() { [[ "$DRY_RUN" -eq 1 ]] || "$@"; }
|
|
195
|
+
|
|
196
|
+
glyph() { # <state>: the palette's glyph for it
|
|
197
|
+
case "$1" in
|
|
198
|
+
installed|linked) ui_glyph dot ;; replaced|relinked) ui_glyph refresh ;; "left alone") ui_glyph pause ;;
|
|
199
|
+
"not on PATH"|"not built"|"not installed"|"old copy") ui_glyph alert ;; "dry run") ui_glyph pending ;;
|
|
200
|
+
renamed) ui_glyph minus ;; *) ui_glyph ring ;;
|
|
201
|
+
esac
|
|
202
|
+
}
|
|
203
|
+
state_tone() { # <state>: the palette tone its cell is drawn in
|
|
204
|
+
case "$1" in
|
|
205
|
+
installed|linked) echo ok ;; replaced|relinked|"not on PATH"|"not built"|"not installed"|"old copy") echo warn ;; "left alone") echo fail ;;
|
|
206
|
+
*) echo dim ;;
|
|
207
|
+
esac
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
# draw_table <rows file> <name column> <note column>: one table of the rows a run recorded, the
|
|
211
|
+
# state in its tone and the name a value. A row with more than one note gives each after the
|
|
212
|
+
# first a row of its own under it, so a note is never cut, and a terminal wraps a long one.
|
|
213
|
+
draw_table() {
|
|
214
|
+
local file="$1" state name notes note first
|
|
215
|
+
[[ -s "$file" ]] || return 0
|
|
216
|
+
{
|
|
217
|
+
ui_table_row STATE "$(tr '[:lower:]' '[:upper:]' <<< "$2")" "$(tr '[:lower:]' '[:upper:]' <<< "$3")"
|
|
218
|
+
while IFS=$'\x1f' read -r state name notes; do
|
|
219
|
+
first=1
|
|
220
|
+
while IFS= read -r -d $'\x1e' note; do
|
|
221
|
+
if [[ "$first" -eq 1 ]]; then
|
|
222
|
+
ui_table_row "$(state_tone "$state")"$'\x1f'"$(glyph "$state") $state" value$'\x1f'"$name" "$note"
|
|
223
|
+
first=0
|
|
224
|
+
else
|
|
225
|
+
ui_table_row "" "" "$note"
|
|
226
|
+
fi
|
|
227
|
+
done <<< "$notes"$'\x1e'
|
|
228
|
+
done < "$file"
|
|
229
|
+
} | ui_table --indent 2 --header
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
# The commands this run links, as "<command> <target under the installed command>" lines:
|
|
233
|
+
# each name in the command's bin, when it installs, and none otherwise.
|
|
234
|
+
commands() {
|
|
235
|
+
local cmd
|
|
236
|
+
[[ "$CLI" == built ]] || return 0
|
|
237
|
+
for cmd in $COMMANDS; do printf '%s %s\n' "$cmd" "bin/$cmd"; done
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
# Bash reads a script as it runs it, and a shift started from the old copy would finish on a
|
|
241
|
+
# mix of the two, so no copy is replaced under a process running a script from it, whether
|
|
242
|
+
# started by its path or through its command link. This run and its own subshells are left out,
|
|
243
|
+
# because --also may name the directory it runs from, and so is each --ignore-pid.
|
|
244
|
+
#
|
|
245
|
+
# A process names a copy by whatever path started it, and a Claude session starts a skill's
|
|
246
|
+
# scripts through its link in ~/.claude/skills. So each entry there that resolves to a copy
|
|
247
|
+
# this would replace is watched as that copy, whatever the link is called or points through.
|
|
248
|
+
# WATCH is the list of those paths, one "<name><tab><path>" a line. The name is the skill or
|
|
249
|
+
# command the path holds, and it is empty for the command's copy and for each --also. A path
|
|
250
|
+
# to a directory ends in a slash, and a path to a file does not.
|
|
251
|
+
real_dir() { (cd -P -- "$1" 2>/dev/null && pwd); }
|
|
252
|
+
LINK_AT=(); LINK_REAL=()
|
|
253
|
+
for at in "$AGENT_LINKS"/*; do
|
|
254
|
+
[[ -L "$at" ]] || continue
|
|
255
|
+
real="$(real_dir "$at")" || continue
|
|
256
|
+
LINK_AT+=("$at"); LINK_REAL+=("$real")
|
|
257
|
+
done
|
|
258
|
+
WATCH=""
|
|
259
|
+
for skill in "${SKILLS[@]}"; do
|
|
260
|
+
WATCH+="$skill"$'\t'"$DEST/$skill/"$'\n'
|
|
261
|
+
real="$(real_dir "$DEST/$skill")" || continue
|
|
262
|
+
for ((i = 0; i < ${#LINK_AT[@]}; i++)); do
|
|
263
|
+
[[ "${LINK_REAL[i]}" == "$real" ]] && WATCH+="$skill"$'\t'"${LINK_AT[i]}/"$'\n'
|
|
264
|
+
done
|
|
265
|
+
done
|
|
266
|
+
[[ "$GUARD_CLI" -eq 1 ]] && WATCH+=$'\t'"$CLI_DEST/"$'\n'
|
|
267
|
+
for dir in ${ALSO[@]+"${ALSO[@]}"}; do
|
|
268
|
+
WATCH+=$'\t'"$dir/"$'\n'
|
|
269
|
+
done
|
|
270
|
+
if [[ "$LINK_BIN" -eq 1 && "$GUARD_CLI" -eq 1 ]]; then
|
|
271
|
+
for cmd in $COMMANDS; do
|
|
272
|
+
WATCH+="$cmd"$'\t'"$BIN/$cmd"$'\n'
|
|
273
|
+
done
|
|
274
|
+
fi
|
|
275
|
+
# PATHS_AWK holds the awk functions both checks share. load(var, name, path) reads a list in
|
|
276
|
+
# WATCH's form from the environment variable var into name[1..n] and path[1..n], and returns n.
|
|
277
|
+
# at_path(s, p) is 1 when s names the path p as a whole word: what comes before p cannot
|
|
278
|
+
# continue a path, and when p is a file, neither can what follows it. So /x/home/bin/kryso-old
|
|
279
|
+
# and /mirror/home/.agents/skills/kryso/ do not read as ~/bin/kryso or the copy
|
|
280
|
+
# ~/.agents/skills/kryso/, but //home/.agents/skills/kryso/ does. on(s, path, n) is the index
|
|
281
|
+
# of the first path that s names, or 0.
|
|
282
|
+
PATHS_AWK='
|
|
283
|
+
function load(var, name, path, n, i, k, lines, tab) {
|
|
284
|
+
n = split(ENVIRON[var], lines, "\n")
|
|
285
|
+
for (i = 1; i <= n; i++) {
|
|
286
|
+
if (lines[i] == "") continue
|
|
287
|
+
tab = index(lines[i], "\t"); k++
|
|
288
|
+
name[k] = substr(lines[i], 1, tab - 1); path[k] = substr(lines[i], tab + 1)
|
|
289
|
+
}
|
|
290
|
+
return k
|
|
291
|
+
}
|
|
292
|
+
function at_path(s, p, from, i, n, before, after) {
|
|
293
|
+
n = length(p); from = 0
|
|
294
|
+
while ((i = index(substr(s, from + 1), p)) > 0) {
|
|
295
|
+
i += from
|
|
296
|
+
before = i == 1 ? "" : substr(s, i - 1, 1)
|
|
297
|
+
after = substr(s, i + n, 1)
|
|
298
|
+
if (before !~ /[[:alnum:]._~-]/ && (p ~ /\/$/ || after !~ /[[:alnum:]\/._~-]/)) return 1
|
|
299
|
+
from = i
|
|
300
|
+
}
|
|
301
|
+
return 0
|
|
302
|
+
}
|
|
303
|
+
function on(s, path, n, i) {
|
|
304
|
+
for (i = 1; i <= n; i++) if (at_path(s, path[i])) return i
|
|
305
|
+
return 0
|
|
306
|
+
}'
|
|
307
|
+
# Every process whose chain of parents reaches this one is left out, not only its children: the
|
|
308
|
+
# pipeline below runs in a command substitution's subshell, and a member ps lists between its
|
|
309
|
+
# fork and its exec still shows this installer's own command line, which names the copy (#518).
|
|
310
|
+
busy="$(ps -Aww -o pid=,ppid=,args= 2>/dev/null | WATCH="$WATCH" awk -v me="$$" -v skip=" ${IGNORE_PIDS[*]-} " "$PATHS_AWK"'
|
|
311
|
+
BEGIN { nw = load("WATCH", wn, wp) }
|
|
312
|
+
{
|
|
313
|
+
n++; pids[n] = $1; parent[$1] = $2
|
|
314
|
+
line = $0; sub(/^[[:space:]]*[0-9]+[[:space:]]+[0-9]+[[:space:]]+/, "", line); args[n] = line
|
|
315
|
+
}
|
|
316
|
+
function ours(p, hops) {
|
|
317
|
+
for (hops = 0; p != "" && p != "0" && p != "1" && hops < 64; hops++) {
|
|
318
|
+
if (p == me) return 1
|
|
319
|
+
p = parent[p]
|
|
320
|
+
}
|
|
321
|
+
return 0
|
|
322
|
+
}
|
|
323
|
+
END {
|
|
324
|
+
for (i = 1; i <= n; i++) {
|
|
325
|
+
if (ours(pids[i]) || index(skip, " " pids[i] " ")) continue
|
|
326
|
+
if (on(args[i], wp, nw)) printf "%5s %s\n", pids[i], args[i]
|
|
327
|
+
}
|
|
328
|
+
}' | sort -u)"
|
|
329
|
+
if [[ "$CHECK_RUNNING" -eq 1 ]]; then
|
|
330
|
+
refused="these run from a copy an update would replace, so nothing was changed"
|
|
331
|
+
advice="wait for them to finish, then run it again"
|
|
332
|
+
else
|
|
333
|
+
refused="these run from a copy this would replace, so nothing was installed"
|
|
334
|
+
advice="wait for them to finish, or name only the other skills"
|
|
335
|
+
fi
|
|
336
|
+
if [[ -n "$busy" ]]; then
|
|
337
|
+
if [[ "$STYLED" -eq 1 ]]; then
|
|
338
|
+
# One row a run. A process whose parent also runs an installed copy or command is folded
|
|
339
|
+
# into that parent, so a shift's subshells, its spinner and the spinner's watcher make one
|
|
340
|
+
# row under the shift. The row names each skill or command the run holds, the pass its
|
|
341
|
+
# spinner shows, and the outermost command line in full, which a terminal wraps. The table
|
|
342
|
+
# stands under a yellow pill, and the refusal follows under an ERROR pill, its advice the hint.
|
|
343
|
+
# A parent is folded into when it runs a watched path, any installed copy, or one of the
|
|
344
|
+
# command's links, even with --no-bin, when the links are not watched. FOLD lists the last
|
|
345
|
+
# two in WATCH's form. The holds of a run, its names behind the record separator, are the
|
|
346
|
+
# skills being installed whose copy a member runs, by any watched path, then the commands
|
|
347
|
+
# being linked that a member runs through, each once.
|
|
348
|
+
fold=$'\t'"$DEST/"$'\n'
|
|
349
|
+
for cmd in $COMMANDS; do fold+=$'\t'"$BIN/$cmd"$'\n'; done
|
|
350
|
+
ps -Aww -o pid=,ppid=,args= 2>/dev/null | WATCH="$WATCH" FOLD="$fold" awk \
|
|
351
|
+
-v busy="$(awk '{print $1}' <<< "$busy" | tr '\n' ' ')" "$PATHS_AWK"'
|
|
352
|
+
BEGIN {
|
|
353
|
+
nw = load("WATCH", wn, wp); nf = load("FOLD", fname, fpath)
|
|
354
|
+
n = split(busy, b, " "); for (i = 1; i <= n; i++) held[b[i]] = 1
|
|
355
|
+
}
|
|
356
|
+
{
|
|
357
|
+
line = $0; sub(/^[[:space:]]*[0-9]+[[:space:]]+[0-9]+[[:space:]]+/, "", line)
|
|
358
|
+
parent[$1] = $2; args[$1] = line
|
|
359
|
+
}
|
|
360
|
+
function ours(p) { return (p in args) && (on(args[p], wp, nw) || on(args[p], fpath, nf)) }
|
|
361
|
+
END {
|
|
362
|
+
for (p in held) {
|
|
363
|
+
if (!(p in args)) continue
|
|
364
|
+
r = p; while (ours(parent[r])) r = parent[r]
|
|
365
|
+
members[r] = members[r] "\036" args[p]
|
|
366
|
+
if (args[p] ~ /^gum spin / && match(args[p], /--title .* -- /)) title[r] = substr(args[p], RSTART + 8, RLENGTH - 12)
|
|
367
|
+
}
|
|
368
|
+
for (r in members) {
|
|
369
|
+
holds = "\036"; n = split(args[r] members[r], m, "\036")
|
|
370
|
+
for (i = 1; i <= nw; i++) {
|
|
371
|
+
if (wn[i] == "" || index(holds, "\036" wn[i] "\036")) continue
|
|
372
|
+
for (j = 1; j <= n; j++) if (at_path(m[j], wp[i])) { holds = holds wn[i] "\036"; break }
|
|
373
|
+
}
|
|
374
|
+
holds = substr(holds, 2, length(holds) - 2)
|
|
375
|
+
printf "%s\037%s\037%s\037%s\n", r, holds, title[r], args[r]
|
|
376
|
+
}
|
|
377
|
+
}' | sort -n > "$TMP/runs"
|
|
378
|
+
ui_brand "skills install" "$(tilde "$SRC") → $(tilde "$DEST")"
|
|
379
|
+
ui_section warn RUNNING
|
|
380
|
+
{
|
|
381
|
+
ui_table_row HOLDS PID PASS COMMAND
|
|
382
|
+
while IFS=$'\x1f' read -r pid holds title args; do
|
|
383
|
+
first=1
|
|
384
|
+
while IFS= read -r -d $'\x1e' name; do
|
|
385
|
+
if [[ "$first" -eq 1 ]]; then
|
|
386
|
+
ui_table_row ok$'\x1f'"$(ui_glyph dot) $name" dim$'\x1f'"$pid" value$'\x1f'"$title" "$args"
|
|
387
|
+
first=0
|
|
388
|
+
else
|
|
389
|
+
ui_table_row ok$'\x1f'" $name"
|
|
390
|
+
fi
|
|
391
|
+
done <<< "$holds"$'\x1e'
|
|
392
|
+
done < "$TMP/runs"
|
|
393
|
+
} | ui_table --indent 2 --header
|
|
394
|
+
ui_error "$refused" "$advice"
|
|
395
|
+
else
|
|
396
|
+
say "$refused:"
|
|
397
|
+
printf '%s\n' "$busy"
|
|
398
|
+
say "$advice"
|
|
399
|
+
fi
|
|
400
|
+
# EX_TEMPFAIL: the same run succeeds once they finish, and a caller can tell it from a failure.
|
|
401
|
+
exit 75
|
|
402
|
+
fi
|
|
403
|
+
[[ "$CHECK_RUNNING" -eq 1 ]] && exit 0
|
|
404
|
+
|
|
405
|
+
# backup_slot <skill>: the first free backup path for a skill today.
|
|
406
|
+
backup_slot() {
|
|
407
|
+
local slot="$BACKUP/$1" n=2
|
|
408
|
+
while [[ -e "$slot" ]]; do slot="$BACKUP/$1.$n"; n=$((n + 1)); done
|
|
409
|
+
printf '%s\n' "$slot"
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
# install_skill and link_agent leave the skill's row in STATE and NOTES.
|
|
413
|
+
install_skill() {
|
|
414
|
+
local skill="$1" to="$DEST/$1" stage="$DEST/.$1.new" slot
|
|
415
|
+
if [[ -L "$to" ]]; then
|
|
416
|
+
say "$to is a link to $(readlink "$to"), left alone"
|
|
417
|
+
STATE="left alone"; NOTES+=("$(tilde "$to") is a link to $(tilde "$(readlink "$to")")")
|
|
418
|
+
return
|
|
419
|
+
fi
|
|
420
|
+
if [[ -d "$to" ]] && diff -rq "$SRC/$skill" "$to" >/dev/null 2>&1; then
|
|
421
|
+
say "$skill: unchanged"
|
|
422
|
+
STATE=unchanged
|
|
423
|
+
return
|
|
424
|
+
fi
|
|
425
|
+
act mkdir -p "$DEST"
|
|
426
|
+
act rm -rf "$stage"
|
|
427
|
+
act cp -R "$SRC/$skill" "$stage"
|
|
428
|
+
if [[ -e "$to" ]]; then
|
|
429
|
+
slot="$(backup_slot "$skill")"
|
|
430
|
+
act mkdir -p "$BACKUP"
|
|
431
|
+
act mv "$to" "$slot"
|
|
432
|
+
say "$skill: replaced, old copy in $slot"
|
|
433
|
+
STATE=replaced; NOTES+=("old copy in $(tilde "$slot")")
|
|
434
|
+
else
|
|
435
|
+
say "$skill: installed"
|
|
436
|
+
STATE=installed
|
|
437
|
+
fi
|
|
438
|
+
act mv "$stage" "$to"
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
# The agent link is the one `npx skills add` makes: relative, from ~/.claude/skills.
|
|
442
|
+
link_agent() {
|
|
443
|
+
local skill="$1" at="$AGENT_LINKS/$1" want="../../.agents/skills/$1"
|
|
444
|
+
if [[ -L "$at" ]]; then
|
|
445
|
+
if [[ "$(readlink "$at")" != "$want" ]]; then
|
|
446
|
+
say "$at points at $(readlink "$at"), left alone"
|
|
447
|
+
NOTES+=("$(tilde "$at") points at $(tilde "$(readlink "$at")"), left alone")
|
|
448
|
+
fi
|
|
449
|
+
elif [[ -e "$at" ]]; then
|
|
450
|
+
say "$at is not a link, left alone"
|
|
451
|
+
NOTES+=("$(tilde "$at") is not a link, left alone")
|
|
452
|
+
else
|
|
453
|
+
act mkdir -p "$AGENT_LINKS"
|
|
454
|
+
act ln -s "$want" "$at"
|
|
455
|
+
say "linked $at"
|
|
456
|
+
NOTES+=("linked in $(tilde "$AGENT_LINKS")")
|
|
457
|
+
fi
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
# install_cli: the kryso command's parts, copied to CLI_DEST as a skill is, with the same
|
|
461
|
+
# backup of a copy it replaces. Its row joins the skills table.
|
|
462
|
+
install_cli() {
|
|
463
|
+
local stage="$CLI_DEST.new" slot part state same=1 notes=()
|
|
464
|
+
[[ -d "$CLI_DEST" ]] || same=0
|
|
465
|
+
for part in $CLI_PARTS; do
|
|
466
|
+
diff -rq "$CLI_SRC/$part" "$CLI_DEST/$part" >/dev/null 2>&1 || same=0
|
|
467
|
+
done
|
|
468
|
+
[[ ! -d "$CLI_DOCKER" ]] || diff -rq "$CLI_DOCKER" "$CLI_DEST/docker" >/dev/null 2>&1 || same=0
|
|
469
|
+
if [[ "$same" -eq 1 ]]; then
|
|
470
|
+
say "kryso command: unchanged"
|
|
471
|
+
row skills unchanged "kryso command"
|
|
472
|
+
return
|
|
473
|
+
fi
|
|
474
|
+
act rm -rf "$stage"
|
|
475
|
+
act mkdir -p "$stage"
|
|
476
|
+
for part in $CLI_PARTS; do act cp -R "$CLI_SRC/$part" "$stage/$part"; done
|
|
477
|
+
[[ ! -d "$CLI_DOCKER" ]] || act cp -R "$CLI_DOCKER" "$stage/docker"
|
|
478
|
+
if [[ -e "$CLI_DEST" ]]; then
|
|
479
|
+
slot="$(backup_slot kryso-command)"
|
|
480
|
+
act mkdir -p "$BACKUP"
|
|
481
|
+
act mv "$CLI_DEST" "$slot"
|
|
482
|
+
say "kryso command: replaced, old copy in $slot"
|
|
483
|
+
state=replaced; notes+=("old copy in $(tilde "$slot")")
|
|
484
|
+
else
|
|
485
|
+
say "kryso command: installed in $CLI_DEST"
|
|
486
|
+
state=installed; notes+=("in $(tilde "$CLI_DEST")")
|
|
487
|
+
fi
|
|
488
|
+
act mv "$stage" "$CLI_DEST"
|
|
489
|
+
row skills "$state" "kryso command" "${notes[@]}"
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
# record_install: install.json in the installed command, written whole and then renamed into
|
|
493
|
+
# place, when the checkout is a git work tree at its top level. kryso self-update reads it to
|
|
494
|
+
# tell a checkout install, and repeats the install with the same bin. Elsewhere none is left.
|
|
495
|
+
record_install() {
|
|
496
|
+
local root top sha branch bin tmp="$CLI_DEST/.install.json.new"
|
|
497
|
+
root="$(cd "$(dirname "$HERE")" && pwd -P)"
|
|
498
|
+
top="$(git -C "$root" rev-parse --show-toplevel 2>/dev/null)" && top="$(cd "$top" && pwd -P)" || top=""
|
|
499
|
+
sha="$(git -C "$root" rev-parse --verify -q HEAD 2>/dev/null)" || sha=""
|
|
500
|
+
if [[ "$top" != "$root" || -z "$sha" ]]; then
|
|
501
|
+
rm -f "$CLI_DEST/install.json"
|
|
502
|
+
return 0
|
|
503
|
+
fi
|
|
504
|
+
branch="$(git -C "$root" symbolic-ref --short -q HEAD)" || branch=""
|
|
505
|
+
bin=""; [[ "$LINK_BIN" -eq 1 ]] && bin="$BIN"
|
|
506
|
+
if jq -n --arg checkout "$root" --arg branch "$branch" --arg sha "$sha" \
|
|
507
|
+
--arg installed "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg bin "$bin" \
|
|
508
|
+
'{checkout: $checkout, branch: ($branch | if . == "" then null else . end), sha: $sha,
|
|
509
|
+
installed: $installed, bin: ($bin | if . == "" then null else . end)}' > "$tmp"; then
|
|
510
|
+
mv "$tmp" "$CLI_DEST/install.json"
|
|
511
|
+
else
|
|
512
|
+
rm -f "$tmp"
|
|
513
|
+
echo "install-skills: could not write $CLI_DEST/install.json" >&2
|
|
514
|
+
fi
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
# unlink_old <old>: an old name whose new name installed this run. The agent link `npx skills
|
|
518
|
+
# add` made for it goes, so a session lists the skill once. The old copy stays where it is.
|
|
519
|
+
unlink_old() {
|
|
520
|
+
local old="$1" link="$AGENT_LINKS/$1"
|
|
521
|
+
[[ -L "$link" && "$(readlink "$link")" == "../../.agents/skills/$old" ]] || return 0
|
|
522
|
+
act rm "$link"
|
|
523
|
+
say "$old: renamed, unlinked $link, the old copy kept in $DEST/$old"
|
|
524
|
+
row skills renamed "$old" "unlinked from $(tilde "$AGENT_LINKS")" "the old copy kept in $(tilde "$DEST/$old")"
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
# old_links: a command link into an old copy that this run does not relink still runs that
|
|
528
|
+
# copy, so it is named, and left as it is.
|
|
529
|
+
old_links() {
|
|
530
|
+
local at was old
|
|
531
|
+
for at in "$BIN"/*; do
|
|
532
|
+
[[ -L "$at" ]] || continue
|
|
533
|
+
was="$(readlink "$at")"
|
|
534
|
+
for old in ${OLD_NAMES[@]+"${OLD_NAMES[@]}"}; do
|
|
535
|
+
[[ "$was" == "$DEST/$old/"* ]] || continue
|
|
536
|
+
say "$at still runs the old copy $was"
|
|
537
|
+
row commands "old copy" "${at##*/}" "still runs $(tilde "$was")"
|
|
538
|
+
done
|
|
539
|
+
done
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
link_command() {
|
|
543
|
+
local cmd="$1" target="$CLI_DEST/$2" at="$BIN/$1" was
|
|
544
|
+
if [[ -L "$at" ]]; then
|
|
545
|
+
was="$(readlink "$at")"
|
|
546
|
+
[[ "$was" == "$target" ]] && { row commands current "$cmd" "$2"; return; }
|
|
547
|
+
act ln -sfn "$target" "$at"
|
|
548
|
+
say "linked $at -> $target (was $was)"
|
|
549
|
+
row commands relinked "$cmd" "$2" "was $(tilde "$was")"
|
|
550
|
+
elif [[ -e "$at" ]]; then
|
|
551
|
+
say "$at is not a link, left alone"
|
|
552
|
+
row commands "left alone" "$cmd" "$(tilde "$at") is not a link"
|
|
553
|
+
else
|
|
554
|
+
act mkdir -p "$BIN"
|
|
555
|
+
act ln -s "$target" "$at"
|
|
556
|
+
say "linked $at -> $target"
|
|
557
|
+
row commands linked "$cmd" "$2"
|
|
558
|
+
fi
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
for skill in "${SKILLS[@]}"; do
|
|
562
|
+
STATE=""; NOTES=()
|
|
563
|
+
install_skill "$skill"
|
|
564
|
+
link_agent "$skill"
|
|
565
|
+
row skills "$STATE" "$skill" ${NOTES[@]+"${NOTES[@]}"}
|
|
566
|
+
done
|
|
567
|
+
for old in ${OLD_NAMES[@]+"${OLD_NAMES[@]}"}; do unlink_old "$old"; done
|
|
568
|
+
case "$CLI" in
|
|
569
|
+
built) install_cli; [[ "$DRY_RUN" -eq 1 ]] || record_install ;;
|
|
570
|
+
unbuilt)
|
|
571
|
+
say "packages/cli has no dist/, so the kryso command is not installed: run pnpm install and pnpm build, then this again"
|
|
572
|
+
row skills "not built" "kryso command" "run pnpm install and pnpm build, then this again" ;;
|
|
573
|
+
partial)
|
|
574
|
+
say "the kryso command runs$CLI_MISSING too, so it is not installed: name them as well, or install every skill"
|
|
575
|
+
row skills "not installed" "kryso command" "it runs$CLI_MISSING too: name them as well" ;;
|
|
576
|
+
esac
|
|
577
|
+
if [[ "$LINK_BIN" -eq 1 ]]; then
|
|
578
|
+
while read -r cmd path; do
|
|
579
|
+
[[ -n "$cmd" ]] && link_command "$cmd" "$path"
|
|
580
|
+
done <<< "$(commands)"
|
|
581
|
+
old_links
|
|
582
|
+
fi
|
|
583
|
+
|
|
584
|
+
# The closing lines, which a styled run gives as rows: the PATH warning closes the commands
|
|
585
|
+
# table, when it has commands, and the dry run closes the skills table.
|
|
586
|
+
if [[ "$LINK_BIN" -eq 1 ]]; then
|
|
587
|
+
case ":$PATH:" in *":$BIN:"*) ;; *)
|
|
588
|
+
say "$BIN is not on PATH, so the commands need it added"
|
|
589
|
+
[[ -z "$(commands)" ]] || row commands "not on PATH" "$(tilde "$BIN")" "add it to PATH for the commands to run" ;;
|
|
590
|
+
esac
|
|
591
|
+
fi
|
|
592
|
+
if [[ "$DRY_RUN" -eq 1 ]]; then
|
|
593
|
+
say "dry run, nothing written"
|
|
594
|
+
row skills "dry run" "" "nothing written"
|
|
595
|
+
fi
|
|
596
|
+
|
|
597
|
+
# Styled, the brand line naming where the skills come from and go, then a pill and a table each
|
|
598
|
+
# for the skills and the commands.
|
|
599
|
+
if [[ "$STYLED" -eq 1 ]]; then
|
|
600
|
+
title="$(tilde "$SRC") → $(tilde "$DEST")"
|
|
601
|
+
[[ "$LINK_BIN" -eq 1 ]] && title+=", $(tilde "$BIN")"
|
|
602
|
+
[[ "$DRY_RUN" -eq 1 ]] && title+=", dry run"
|
|
603
|
+
ui_brand "skills install" "$title"
|
|
604
|
+
[[ ! -s "$TMP/skills" ]] || { ui_section primary SKILLS; draw_table "$TMP/skills" skill note; }
|
|
605
|
+
[[ ! -s "$TMP/commands" ]] || { ui_section primary COMMANDS; draw_table "$TMP/commands" command target; }
|
|
606
|
+
fi
|
|
607
|
+
exit 0
|