@johngaynor/entourage 0.1.0 → 0.2.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.
- package/README.md +83 -4
- package/cli/entourage +54 -184
- package/cli/lib/commands.sh +90 -0
- package/cli/lib/common.sh +47 -0
- package/cli/lib/links.sh +93 -0
- package/cli/lib/project.sh +184 -0
- package/cli/lib/recipes.sh +32 -0
- package/cli/lib/task.sh +317 -0
- package/herdr/README.md +146 -0
- package/herdr/projects/template/PROJECT.md +19 -0
- package/package.json +6 -3
- package/prompts/task-new.md +17 -0
- package/skills/sdlc-breakdown/SKILL.md +229 -0
- package/skills/sdlc-define/SKILL.md +183 -0
- package/skills/sdlc-plan/SKILL.md +188 -0
package/README.md
CHANGED
|
@@ -4,7 +4,22 @@ A collection of agent skills for the software development lifecycle (SDLC).
|
|
|
4
4
|
|
|
5
5
|
## Status
|
|
6
6
|
|
|
7
|
-
Early setup.
|
|
7
|
+
Early setup. Three skills are in, and none has been run on a real card yet:
|
|
8
|
+
|
|
9
|
+
| Skill | What it does |
|
|
10
|
+
|---|---|
|
|
11
|
+
| `sdlc-define` | Sets a card's type and writes its Specification |
|
|
12
|
+
| `sdlc-plan` | Reads the card and the code, and writes the Plan |
|
|
13
|
+
| `sdlc-breakdown` | Decides whether the card is one piece or several slices, then asks you to approve it |
|
|
14
|
+
|
|
15
|
+
They live in [skills/](skills/). `entourage install` links them into
|
|
16
|
+
`~/.claude/skills`, so any Claude Code session on the machine can run one by
|
|
17
|
+
name, such as `/sdlc-define ABC-122`.
|
|
18
|
+
|
|
19
|
+
Whenever a skill stops, it ends with a handoff block: which step it was, and
|
|
20
|
+
whether it is `done`, `needs-human` or `failed`. A `done` block also names the
|
|
21
|
+
step that comes next. Whoever is driving, you or `entourage task new`, reads
|
|
22
|
+
that block to know what happens next.
|
|
8
23
|
|
|
9
24
|
## Setting up a machine
|
|
10
25
|
|
|
@@ -14,8 +29,70 @@ entourage install
|
|
|
14
29
|
```
|
|
15
30
|
|
|
16
31
|
`entourage install` links this repo into the tools on a machine, and
|
|
17
|
-
`entourage update` keeps it current.
|
|
18
|
-
[herdr/README.md](herdr/README.md) for the full walkthrough.
|
|
32
|
+
`entourage update` keeps it current. That covers the Herdr setup and the
|
|
33
|
+
skills; see [herdr/README.md](herdr/README.md) for the full walkthrough.
|
|
34
|
+
|
|
35
|
+
## Projects
|
|
36
|
+
|
|
37
|
+
A project groups the repos that belong together, with a `PROJECT.md` saying
|
|
38
|
+
what each repo is for. Each project opens in Herdr as one space. A repo is
|
|
39
|
+
cloned once and can be in several projects.
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
entourage project new my-project
|
|
43
|
+
entourage project add my-project ~/Dev/api
|
|
44
|
+
entourage project add my-project ~/Dev/web
|
|
45
|
+
entourage project open my-project
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Your projects live in `~/.config/entourage/projects`, outside this repo, so
|
|
49
|
+
they are never published and survive updates. See
|
|
50
|
+
[herdr/README.md](herdr/README.md#projects) for how a project is laid out.
|
|
51
|
+
|
|
52
|
+
## Tasks
|
|
53
|
+
|
|
54
|
+
A task is one piece of work in a project, usually a Linear card. It has two
|
|
55
|
+
commands, used in this order.
|
|
56
|
+
|
|
57
|
+
`task new` writes the card up. It opens a tab in the project's Herdr space and
|
|
58
|
+
starts an agent there, which runs the three skills on the card and then asks
|
|
59
|
+
you to approve it:
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
entourage task new my-project ABC-122
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`task start` starts the work. It makes a branch and a git worktree of it in
|
|
66
|
+
every repo of the project, and opens a tab for it:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
entourage task start my-project feat/abc-122-insert-task-here
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Name targets after the branch to take only what the task needs: a repo, or
|
|
73
|
+
groups inside a repo (`app:athlete`, or `app:athlete,coach` for several).
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
entourage task start my-project feat/abc-122-insert-task-here app:athlete billing
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The branch is `<type>/<description>`, following
|
|
80
|
+
[Conventional Branch](https://conventionalbranch.org), with the card's ID in
|
|
81
|
+
the description. The description names the task:
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
~/.config/entourage/projects/my-project/
|
|
85
|
+
tasks/
|
|
86
|
+
abc-122-insert-task-here/ one folder per task
|
|
87
|
+
api/ a worktree of api on feat/abc-122-insert-task-here
|
|
88
|
+
web/ a worktree of web on the same branch
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
If a repo has a `justfile` with a `setup` recipe, `just setup` then runs in
|
|
92
|
+
the task's tab, so the checkout is ready to work in. See
|
|
93
|
+
[what a repo provides](herdr/README.md#what-a-repo-provides).
|
|
94
|
+
|
|
95
|
+
See [herdr/README.md](herdr/README.md#tasks) for the details.
|
|
19
96
|
|
|
20
97
|
To work on entourage itself, clone the repo and run `cli/entourage install`
|
|
21
98
|
from the clone instead. Run the CLI's tests with `npm test`.
|
|
@@ -31,4 +108,6 @@ git push --follow-tags
|
|
|
31
108
|
```
|
|
32
109
|
|
|
33
110
|
Then publish a GitHub release for that tag. The `Publish to npm` workflow runs
|
|
34
|
-
the tests and publishes the package. It
|
|
111
|
+
the tests and publishes the package. It signs in to npm by
|
|
112
|
+
[trusted publishing](https://docs.npmjs.com/trusted-publishers), so there is no
|
|
113
|
+
token to keep.
|
package/cli/entourage
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# entourage: set up and maintain this machine's copy of the software factory.
|
|
3
|
-
#
|
|
3
|
+
# It links the Herdr mods and layouts under herdr/ and the agent skills under
|
|
4
|
+
# skills/, and manages projects (groups of repos that show up in Herdr as
|
|
5
|
+
# spaces) and their tasks (a card an agent writes up, then a worktree of each
|
|
6
|
+
# repo on one branch, each shown as a tab in the project's space).
|
|
4
7
|
set -euo pipefail
|
|
5
8
|
|
|
6
9
|
usage() {
|
|
@@ -10,10 +13,37 @@ entourage: set up and maintain this machine from the entourage repo
|
|
|
10
13
|
Usage:
|
|
11
14
|
entourage install first-time setup: link everything into the tools on this machine
|
|
12
15
|
entourage update [--no-pull] get the latest entourage, link anything new, drop stale links, refresh Herdr
|
|
13
|
-
entourage status show what is linked and what is not
|
|
16
|
+
entourage status show what is linked and what is not, and check your projects
|
|
17
|
+
entourage project new <name> make a project from the template
|
|
18
|
+
entourage project add <name> <path> add a repo that is already on this machine
|
|
19
|
+
entourage project open <name> show the project as a Herdr space
|
|
20
|
+
entourage project ls list projects and their repos
|
|
21
|
+
entourage task new <project> <card> write a card up: an agent defines, plans and breaks it down
|
|
22
|
+
entourage task start <project> <branch> [<repo>[:<group>[,<group>...]] ...]
|
|
23
|
+
start the work: a worktree per repo, opened as a tab
|
|
14
24
|
entourage help
|
|
15
25
|
|
|
26
|
+
A project groups repos that belong together, with a PROJECT.md saying what
|
|
27
|
+
each repo is for. A repo can be in several projects.
|
|
28
|
+
|
|
29
|
+
A task is one piece of work in a project, usually a Linear card.
|
|
30
|
+
`task new` takes the card's ID, like ABC-122. It opens a tab in the project's
|
|
31
|
+
Herdr space and starts an agent there, which writes the card up with the
|
|
32
|
+
sdlc-define, sdlc-plan and sdlc-breakdown skills and asks you to approve it.
|
|
33
|
+
`task start` takes a branch, <type>/<description>, like
|
|
34
|
+
feat/abc-122-short-title (https://conventionalbranch.org). It makes a folder
|
|
35
|
+
in the project's tasks/ folder with a worktree of each repo on that branch,
|
|
36
|
+
and opens a tab for it. A repo with a justfile that has a `setup` recipe
|
|
37
|
+
gets `just setup` run in that tab, so the checkout is ready to work in.
|
|
38
|
+
Targets after the branch narrow the task: `app` takes only that repo, and
|
|
39
|
+
`app:athlete` sets it up for its athlete group (`just setup athlete`).
|
|
40
|
+
Join several groups with a comma: `app:athlete,coach`.
|
|
41
|
+
|
|
16
42
|
Herdr's folder is ~/.config/herdr-app (HERDR_APP_HOME picks another).
|
|
43
|
+
Skills are linked into ~/.claude/skills (CLAUDE_CONFIG_DIR picks another
|
|
44
|
+
~/.claude). The agent is claude (ENTOURAGE_AGENT picks another command).
|
|
45
|
+
Your projects are in ~/.config/entourage/projects (ENTOURAGE_HOME picks
|
|
46
|
+
another ~/.config/entourage).
|
|
17
47
|
EOF
|
|
18
48
|
}
|
|
19
49
|
|
|
@@ -30,198 +60,38 @@ done
|
|
|
30
60
|
REPO=$(cd -P "$(dirname "$self")/.." && pwd)
|
|
31
61
|
|
|
32
62
|
APP_HOME=${HERDR_APP_HOME:-$HOME/.config/herdr-app}
|
|
63
|
+
# Where Claude Code looks for a person's own skills.
|
|
64
|
+
SKILLS_HOME=${CLAUDE_CONFIG_DIR:-$HOME/.claude}/skills
|
|
33
65
|
BIN_DIR=$HOME/.local/bin
|
|
34
66
|
HERDR_INSTALL='curl -fsSL https://releases.herdr.dev/app/install.sh | sh'
|
|
35
67
|
# What `update` reinstalls when entourage came from npm rather than a git clone.
|
|
36
68
|
NPM_SPEC=${ENTOURAGE_NPM_SPEC:-@johngaynor/entourage}
|
|
37
69
|
|
|
38
|
-
#
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
#
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
# tab-separated.
|
|
57
|
-
wanted() {
|
|
58
|
-
local m l
|
|
59
|
-
for m in "$REPO"/herdr/mods/*/; do
|
|
60
|
-
[ -d "$m" ] || continue
|
|
61
|
-
m=${m%/}
|
|
62
|
-
printf '%s\t%s\n' "$m" "$APP_HOME/mods/${m##*/}"
|
|
63
|
-
done
|
|
64
|
-
for l in "$REPO"/herdr/layouts/*.json; do
|
|
65
|
-
[ -f "$l" ] || continue
|
|
66
|
-
printf '%s\t%s\n' "$l" "$APP_HOME/layouts/${l##*/}"
|
|
67
|
-
done
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
# linked | missing | elsewhere (a link to somewhere else) | blocked (a real file)
|
|
71
|
-
state_of() {
|
|
72
|
-
local src=$1 dst=$2
|
|
73
|
-
if [ -L "$dst" ]; then
|
|
74
|
-
[ "$(readlink "$dst")" = "$src" ] && echo linked || echo elsewhere
|
|
75
|
-
elif [ -e "$dst" ]; then echo blocked
|
|
76
|
-
else echo missing
|
|
77
|
-
fi
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
label() { local dst=$1; say "${dst#"$APP_HOME"/}"; }
|
|
81
|
-
|
|
82
|
-
# Link what is missing. Never touches a real file or someone else's link.
|
|
83
|
-
link_all() {
|
|
84
|
-
local src dst added=0 skipped=0
|
|
85
|
-
mkdir -p "$APP_HOME/mods" "$APP_HOME/layouts"
|
|
86
|
-
while IFS=$'\t' read -r src dst; do
|
|
87
|
-
case $(state_of "$src" "$dst") in
|
|
88
|
-
linked) ;;
|
|
89
|
-
missing) ln -s "$src" "$dst"; say " linked $(label "$dst")"; added=$((added + 1)) ;;
|
|
90
|
-
elsewhere) say " skipped $(label "$dst") (already a link to $(readlink "$dst"))"; skipped=$((skipped + 1)) ;;
|
|
91
|
-
blocked) say " skipped $(label "$dst") (a real file is in the way; move it aside to use ours)"; skipped=$((skipped + 1)) ;;
|
|
92
|
-
esac
|
|
93
|
-
done < <(wanted)
|
|
94
|
-
[ "$added" -gt 0 ] || say " nothing new to link"
|
|
95
|
-
CHANGED=$((CHANGED + added))
|
|
96
|
-
SKIPPED=$skipped
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
# Remove links that point into this repo at something that no longer exists
|
|
100
|
-
# (a mod or layout that was deleted or renamed upstream).
|
|
101
|
-
prune() {
|
|
102
|
-
local dst target
|
|
103
|
-
for dst in "$APP_HOME"/mods/* "$APP_HOME"/layouts/*; do
|
|
104
|
-
[ -L "$dst" ] || continue
|
|
105
|
-
target=$(readlink "$dst")
|
|
106
|
-
case $target in "$REPO"/herdr/*) ;; *) continue ;; esac
|
|
107
|
-
if [ ! -e "$target" ]; then
|
|
108
|
-
rm "$dst"; say " removed $(label "$dst") (no longer in the repo)"
|
|
109
|
-
CHANGED=$((CHANGED + 1))
|
|
110
|
-
fi
|
|
111
|
-
done
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
# Herdr does not notice edits made through a link. Switching to a shipped
|
|
115
|
-
# layout and back makes it re-read our layouts and mods.
|
|
116
|
-
refresh_herdr() {
|
|
117
|
-
local current
|
|
118
|
-
current=$(herdr_app status 2>/dev/null | sed -n 's/.*"layout": *"\([^"]*\)".*/\1/p' | head -n 1) || true
|
|
119
|
-
if [ -z "$current" ]; then
|
|
120
|
-
say " Herdr is not running; it will pick everything up when it starts"
|
|
121
|
-
return 0
|
|
122
|
-
fi
|
|
123
|
-
local other=main
|
|
124
|
-
[ "$current" = main ] && other=terminals
|
|
125
|
-
herdr_app do layout.switch "{\"name\":\"$other\"}" >/dev/null 2>&1 || true
|
|
126
|
-
if herdr_app do layout.switch "{\"name\":\"$current\"}" >/dev/null 2>&1; then
|
|
127
|
-
say " refreshed Herdr (layout: $current)"
|
|
128
|
-
else
|
|
129
|
-
say " could not switch Herdr back to '$current'; pick it from the Layout dropdown or press ctrl-shift-l"
|
|
130
|
-
fi
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
require_herdr() {
|
|
134
|
-
have_herdr || die "Herdr is not installed. Install it, open it once, then run this again:
|
|
135
|
-
$HERDR_INSTALL"
|
|
136
|
-
[ -d "$APP_HOME" ] || die "$APP_HOME does not exist yet. Open Herdr once so it creates its folder, then run this again."
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
# --- commands ---------------------------------------------------------------
|
|
140
|
-
|
|
141
|
-
cmd_install() {
|
|
142
|
-
require_herdr
|
|
143
|
-
CHANGED=0 SKIPPED=0
|
|
144
|
-
say "Linking mods and layouts into $APP_HOME"
|
|
145
|
-
link_all
|
|
146
|
-
|
|
147
|
-
# npm already put the command on PATH; a clone has to do it itself.
|
|
148
|
-
if is_clone; then
|
|
149
|
-
say "Putting entourage on your PATH"
|
|
150
|
-
mkdir -p "$BIN_DIR"
|
|
151
|
-
local me=$REPO/cli/entourage dst=$BIN_DIR/entourage
|
|
152
|
-
case $(state_of "$me" "$dst") in
|
|
153
|
-
linked) say " already at $dst" ;;
|
|
154
|
-
missing) ln -s "$me" "$dst"; say " linked $dst" ;;
|
|
155
|
-
*) say " skipped $dst (something else is already there)" ;;
|
|
156
|
-
esac
|
|
157
|
-
case ":$PATH:" in
|
|
158
|
-
*":$BIN_DIR:"*) ;;
|
|
159
|
-
*) say " note: $BIN_DIR is not on your PATH; add it to run 'entourage' from anywhere" ;;
|
|
160
|
-
esac
|
|
161
|
-
fi
|
|
162
|
-
|
|
163
|
-
say "Refreshing Herdr"
|
|
164
|
-
refresh_herdr
|
|
165
|
-
say "Done. Pick a layout from the Layout dropdown, or press ctrl-shift-l."
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
cmd_update() {
|
|
169
|
-
local pull=1
|
|
170
|
-
case ${1:-} in
|
|
171
|
-
--no-pull) pull=0 ;;
|
|
172
|
-
'') ;;
|
|
173
|
-
*) die "unknown option for update: $1" ;;
|
|
174
|
-
esac
|
|
175
|
-
require_herdr
|
|
176
|
-
CHANGED=0 SKIPPED=0
|
|
177
|
-
local before=none after=none
|
|
178
|
-
if [ "$pull" = 1 ] && ! is_clone; then
|
|
179
|
-
# Installed by npm: reinstall, then hand over to the new copy to relink.
|
|
180
|
-
command -v npm >/dev/null 2>&1 || die "npm is needed to update this install, and it is not on your PATH."
|
|
181
|
-
say "Updating entourage with npm ($NPM_SPEC)"
|
|
182
|
-
npm install -g "$NPM_SPEC" || die "npm install failed; nothing was changed in Herdr."
|
|
183
|
-
exec entourage update --no-pull
|
|
184
|
-
fi
|
|
185
|
-
if is_clone; then before=$(git -C "$REPO" rev-parse HEAD 2>/dev/null || echo none); fi
|
|
186
|
-
if [ "$pull" = 1 ]; then
|
|
187
|
-
say "Pulling $REPO"
|
|
188
|
-
git -C "$REPO" pull --ff-only || die "git pull failed; fix that in $REPO and run update again."
|
|
189
|
-
fi
|
|
190
|
-
if is_clone; then after=$(git -C "$REPO" rev-parse HEAD 2>/dev/null || echo none); fi
|
|
191
|
-
|
|
192
|
-
say "Linking mods and layouts into $APP_HOME"
|
|
193
|
-
link_all
|
|
194
|
-
prune
|
|
195
|
-
|
|
196
|
-
say "Refreshing Herdr"
|
|
197
|
-
if [ "$before" != "$after" ] || [ "$CHANGED" -gt 0 ] || [ "$pull" = 0 ]; then
|
|
198
|
-
refresh_herdr
|
|
199
|
-
else
|
|
200
|
-
say " nothing changed"
|
|
201
|
-
fi
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
cmd_status() {
|
|
205
|
-
say "Repo: $REPO"
|
|
206
|
-
say "Herdr: $APP_HOME"
|
|
207
|
-
have_herdr || say " Herdr is not installed ($HERDR_INSTALL)"
|
|
208
|
-
local src dst s problems=0
|
|
209
|
-
while IFS=$'\t' read -r src dst; do
|
|
210
|
-
s=$(state_of "$src" "$dst")
|
|
211
|
-
[ "$s" = linked ] || problems=$((problems + 1))
|
|
212
|
-
printf ' %-10s %s\n' "$s" "${dst#"$APP_HOME"/}"
|
|
213
|
-
done < <(wanted)
|
|
214
|
-
if [ "$problems" -gt 0 ]; then
|
|
215
|
-
say "$problems not linked. Run: entourage update"
|
|
216
|
-
return 1
|
|
217
|
-
fi
|
|
218
|
-
say "Everything is linked."
|
|
219
|
-
}
|
|
70
|
+
# The user's own projects. They live outside the repo so that they are never
|
|
71
|
+
# published and an npm reinstall does not delete them.
|
|
72
|
+
ENT_HOME=${ENTOURAGE_HOME:-$HOME/.config/entourage}
|
|
73
|
+
PROJECTS=$ENT_HOME/projects
|
|
74
|
+
TEMPLATE=$REPO/herdr/projects/template
|
|
75
|
+
# A PROJECT.md that still has this line has not been filled in.
|
|
76
|
+
TEMPLATE_MARK='<!-- entourage:template -->'
|
|
77
|
+
|
|
78
|
+
# --- the rest of the CLI ----------------------------------------------------
|
|
79
|
+
|
|
80
|
+
# Sourced, so every file shares the settings above and each other's functions.
|
|
81
|
+
LIB=$REPO/cli/lib
|
|
82
|
+
for part in common links recipes project task commands; do
|
|
83
|
+
[ -f "$LIB/$part.sh" ] ||
|
|
84
|
+
{ printf 'entourage: %s is missing; reinstall entourage\n' "$LIB/$part.sh" >&2; exit 1; }
|
|
85
|
+
# shellcheck source=/dev/null
|
|
86
|
+
. "$LIB/$part.sh"
|
|
87
|
+
done
|
|
220
88
|
|
|
221
89
|
case ${1:-help} in
|
|
222
90
|
install) shift; cmd_install "$@" ;;
|
|
223
91
|
update) shift; cmd_update "$@" ;;
|
|
224
92
|
status) shift; cmd_status "$@" ;;
|
|
93
|
+
project) shift; cmd_project "$@" ;;
|
|
94
|
+
task) shift; cmd_task "$@" ;;
|
|
225
95
|
help | -h | --help) usage ;;
|
|
226
96
|
*) usage >&2; exit 2 ;;
|
|
227
97
|
esac
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# The top-level commands: install, update, status. Sourced by cli/entourage.
|
|
2
|
+
|
|
3
|
+
cmd_install() {
|
|
4
|
+
require_herdr
|
|
5
|
+
CHANGED=0 SKIPPED=0
|
|
6
|
+
say "Linking mods and layouts into $APP_HOME, and skills into $SKILLS_HOME"
|
|
7
|
+
link_all
|
|
8
|
+
|
|
9
|
+
# npm already put the command on PATH; a clone has to do it itself.
|
|
10
|
+
if is_clone; then
|
|
11
|
+
say "Putting entourage on your PATH"
|
|
12
|
+
mkdir -p "$BIN_DIR"
|
|
13
|
+
local me=$REPO/cli/entourage dst=$BIN_DIR/entourage
|
|
14
|
+
case $(state_of "$me" "$dst") in
|
|
15
|
+
linked) say " already at $dst" ;;
|
|
16
|
+
missing) ln -s "$me" "$dst"; say " linked $dst" ;;
|
|
17
|
+
*) say " skipped $dst (something else is already there)" ;;
|
|
18
|
+
esac
|
|
19
|
+
case ":$PATH:" in
|
|
20
|
+
*":$BIN_DIR:"*) ;;
|
|
21
|
+
*) say " note: $BIN_DIR is not on your PATH; add it to run 'entourage' from anywhere" ;;
|
|
22
|
+
esac
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
say "Refreshing Herdr"
|
|
26
|
+
refresh_herdr
|
|
27
|
+
say "Done. Pick a layout from the Layout dropdown, or press ctrl-shift-l."
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
cmd_update() {
|
|
31
|
+
local pull=1
|
|
32
|
+
case ${1:-} in
|
|
33
|
+
--no-pull) pull=0 ;;
|
|
34
|
+
'') ;;
|
|
35
|
+
*) die "unknown option for update: $1" ;;
|
|
36
|
+
esac
|
|
37
|
+
require_herdr
|
|
38
|
+
CHANGED=0 SKIPPED=0
|
|
39
|
+
local before=none after=none
|
|
40
|
+
if [ "$pull" = 1 ] && ! is_clone; then
|
|
41
|
+
# Installed by npm: reinstall, then hand over to the new copy to relink.
|
|
42
|
+
command -v npm >/dev/null 2>&1 || die "npm is needed to update this install, and it is not on your PATH."
|
|
43
|
+
say "Updating entourage with npm ($NPM_SPEC)"
|
|
44
|
+
npm install -g "$NPM_SPEC" || die "npm install failed; nothing was changed in Herdr."
|
|
45
|
+
exec entourage update --no-pull
|
|
46
|
+
fi
|
|
47
|
+
if is_clone; then before=$(git -C "$REPO" rev-parse HEAD 2>/dev/null || echo none); fi
|
|
48
|
+
if [ "$pull" = 1 ]; then
|
|
49
|
+
say "Pulling $REPO"
|
|
50
|
+
git -C "$REPO" pull --ff-only || die "git pull failed; fix that in $REPO and run update again."
|
|
51
|
+
fi
|
|
52
|
+
if is_clone; then after=$(git -C "$REPO" rev-parse HEAD 2>/dev/null || echo none); fi
|
|
53
|
+
|
|
54
|
+
say "Linking mods and layouts into $APP_HOME, and skills into $SKILLS_HOME"
|
|
55
|
+
link_all
|
|
56
|
+
prune
|
|
57
|
+
|
|
58
|
+
say "Refreshing Herdr"
|
|
59
|
+
if [ "$before" != "$after" ] || [ "$CHANGED" -gt 0 ] || [ "$pull" = 0 ]; then
|
|
60
|
+
refresh_herdr
|
|
61
|
+
else
|
|
62
|
+
say " nothing changed"
|
|
63
|
+
fi
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
cmd_status() {
|
|
67
|
+
say "Repo: $REPO"
|
|
68
|
+
say "Herdr: $APP_HOME"
|
|
69
|
+
say "Skills: $SKILLS_HOME"
|
|
70
|
+
have_herdr || say " Herdr is not installed ($HERDR_INSTALL)"
|
|
71
|
+
local src dst s problems=0
|
|
72
|
+
while IFS=$'\t' read -r src dst; do
|
|
73
|
+
s=$(state_of "$src" "$dst")
|
|
74
|
+
[ "$s" = linked ] || problems=$((problems + 1))
|
|
75
|
+
printf ' %-10s %s\n' "$s" "$(label "$dst")"
|
|
76
|
+
done < <(wanted)
|
|
77
|
+
[ "$problems" = 0 ] || say "$problems not linked. Run: entourage update"
|
|
78
|
+
say "Projects: $PROJECTS"
|
|
79
|
+
local project_problems=0
|
|
80
|
+
check_projects || project_problems=$?
|
|
81
|
+
# Only worth saying on a machine that has projects to start tasks in.
|
|
82
|
+
if ! have_just && [ -n "$(ls -d "$PROJECTS"/*/ 2>/dev/null)" ]; then
|
|
83
|
+
say " note just is not installed, so tasks start without setup. Install it: https://just.systems"
|
|
84
|
+
fi
|
|
85
|
+
if [ "$problems" -gt 0 ] || [ "$project_problems" -gt 0 ]; then
|
|
86
|
+
[ "$project_problems" = 0 ] || say "$project_problems project problem(s)."
|
|
87
|
+
return 1
|
|
88
|
+
fi
|
|
89
|
+
say "Everything is in order."
|
|
90
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Helpers every part of the CLI uses. Sourced by cli/entourage.
|
|
2
|
+
|
|
3
|
+
# A git clone updates with `git pull`; an npm install updates through npm.
|
|
4
|
+
is_clone() { [ -e "$REPO/.git" ]; }
|
|
5
|
+
|
|
6
|
+
say() { printf '%s\n' "$*"; }
|
|
7
|
+
die() { printf 'entourage: %s\n' "$*" >&2; exit 1; }
|
|
8
|
+
|
|
9
|
+
herdr_app() {
|
|
10
|
+
if command -v herdr-app >/dev/null 2>&1; then herdr-app "$@"
|
|
11
|
+
elif [ -x "$BIN_DIR/herdr-app" ]; then "$BIN_DIR/herdr-app" "$@"
|
|
12
|
+
else return 127
|
|
13
|
+
fi
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
have_herdr() { command -v herdr-app >/dev/null 2>&1 || [ -x "$BIN_DIR/herdr-app" ]; }
|
|
17
|
+
|
|
18
|
+
# hc is the command for Herdr's terminals; it is installed beside herdr-app.
|
|
19
|
+
hc_cmd() {
|
|
20
|
+
if command -v hc >/dev/null 2>&1; then hc "$@"
|
|
21
|
+
elif [ -x "$BIN_DIR/hc" ]; then "$BIN_DIR/hc" "$@"
|
|
22
|
+
else return 127
|
|
23
|
+
fi
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
have_hc() { command -v hc >/dev/null 2>&1 || [ -x "$BIN_DIR/hc" ]; }
|
|
27
|
+
|
|
28
|
+
# Print a string quoted for a shell to read back as one word: it's -> 'it'\''s'.
|
|
29
|
+
# LC_ALL=C: sed must not give up on a name that is not valid text in this locale.
|
|
30
|
+
sh_quote() { printf "'%s'" "$(printf '%s' "$1" | LC_ALL=C sed "s/'/'\\\\''/g")"; }
|
|
31
|
+
|
|
32
|
+
# Herdr answers `status` with the layout it shows only while its window is open.
|
|
33
|
+
herdr_running() { herdr_app status 2>/dev/null | grep -q '"layout"'; }
|
|
34
|
+
|
|
35
|
+
require_herdr() {
|
|
36
|
+
have_herdr || die "Herdr is not installed. Install it, open it once, then run this again:
|
|
37
|
+
$HERDR_INSTALL"
|
|
38
|
+
[ -d "$APP_HOME" ] || die "$APP_HOME does not exist yet. Open Herdr once so it creates its folder, then run this again."
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
# Print a string as the inside of a JSON string. sed and awk do the work so
|
|
42
|
+
# that the result does not depend on the bash version's quoting rules.
|
|
43
|
+
json_str() {
|
|
44
|
+
printf '%s' "$1" | tr '\t\r' ' ' |
|
|
45
|
+
sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' |
|
|
46
|
+
awk 'BEGIN { ORS = "" } NR > 1 { print "\\n" } { print }'
|
|
47
|
+
}
|
package/cli/lib/links.sh
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Linking mods and layouts into Herdr, and skills into Claude Code. Sourced by
|
|
2
|
+
# cli/entourage.
|
|
3
|
+
|
|
4
|
+
# Every (source, destination) pair this repo wants linked, one per line,
|
|
5
|
+
# tab-separated.
|
|
6
|
+
wanted() {
|
|
7
|
+
local m l s
|
|
8
|
+
for m in "$REPO"/herdr/mods/*/; do
|
|
9
|
+
[ -d "$m" ] || continue
|
|
10
|
+
m=${m%/}
|
|
11
|
+
printf '%s\t%s\n' "$m" "$APP_HOME/mods/${m##*/}"
|
|
12
|
+
done
|
|
13
|
+
for l in "$REPO"/herdr/layouts/*.json; do
|
|
14
|
+
[ -f "$l" ] || continue
|
|
15
|
+
printf '%s\t%s\n' "$l" "$APP_HOME/layouts/${l##*/}"
|
|
16
|
+
done
|
|
17
|
+
for s in "$REPO"/skills/*/; do
|
|
18
|
+
[ -f "$s/SKILL.md" ] || continue
|
|
19
|
+
s=${s%/}
|
|
20
|
+
printf '%s\t%s\n' "$s" "$SKILLS_HOME/${s##*/}"
|
|
21
|
+
done
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# linked | missing | elsewhere (a link to somewhere else) | blocked (a real file)
|
|
25
|
+
state_of() {
|
|
26
|
+
local src=$1 dst=$2
|
|
27
|
+
if [ -L "$dst" ]; then
|
|
28
|
+
[ "$(readlink "$dst")" = "$src" ] && echo linked || echo elsewhere
|
|
29
|
+
elif [ -e "$dst" ]; then echo blocked
|
|
30
|
+
else echo missing
|
|
31
|
+
fi
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# A short name for a destination: mods/cpu, layouts/default.json, skills/sdlc-plan.
|
|
35
|
+
label() {
|
|
36
|
+
local dst=$1
|
|
37
|
+
case $dst in
|
|
38
|
+
"$SKILLS_HOME"/*) say "skills/${dst#"$SKILLS_HOME"/}" ;;
|
|
39
|
+
*) say "${dst#"$APP_HOME"/}" ;;
|
|
40
|
+
esac
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
# Link what is missing. Never touches a real file or someone else's link.
|
|
44
|
+
link_all() {
|
|
45
|
+
local src dst added=0 skipped=0
|
|
46
|
+
mkdir -p "$APP_HOME/mods" "$APP_HOME/layouts"
|
|
47
|
+
[ ! -d "$REPO/skills" ] || mkdir -p "$SKILLS_HOME"
|
|
48
|
+
while IFS=$'\t' read -r src dst; do
|
|
49
|
+
case $(state_of "$src" "$dst") in
|
|
50
|
+
linked) ;;
|
|
51
|
+
missing) ln -s "$src" "$dst"; say " linked $(label "$dst")"; added=$((added + 1)) ;;
|
|
52
|
+
elsewhere) say " skipped $(label "$dst") (already a link to $(readlink "$dst"))"; skipped=$((skipped + 1)) ;;
|
|
53
|
+
blocked) say " skipped $(label "$dst") (a real file is in the way; move it aside to use ours)"; skipped=$((skipped + 1)) ;;
|
|
54
|
+
esac
|
|
55
|
+
done < <(wanted)
|
|
56
|
+
[ "$added" -gt 0 ] || say " nothing new to link"
|
|
57
|
+
CHANGED=$((CHANGED + added))
|
|
58
|
+
SKIPPED=$skipped
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
# Remove links that point into this repo at something that no longer exists
|
|
62
|
+
# (a mod, layout or skill that was deleted or renamed upstream).
|
|
63
|
+
prune() {
|
|
64
|
+
local dst target
|
|
65
|
+
for dst in "$APP_HOME"/mods/* "$APP_HOME"/layouts/* "$SKILLS_HOME"/*; do
|
|
66
|
+
[ -L "$dst" ] || continue
|
|
67
|
+
target=$(readlink "$dst")
|
|
68
|
+
case $target in "$REPO"/herdr/* | "$REPO"/skills/*) ;; *) continue ;; esac
|
|
69
|
+
if [ ! -e "$target" ]; then
|
|
70
|
+
rm "$dst"; say " removed $(label "$dst") (no longer in the repo)"
|
|
71
|
+
CHANGED=$((CHANGED + 1))
|
|
72
|
+
fi
|
|
73
|
+
done
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
# Herdr does not notice edits made through a link. Switching to a shipped
|
|
77
|
+
# layout and back makes it re-read our layouts and mods.
|
|
78
|
+
refresh_herdr() {
|
|
79
|
+
local current
|
|
80
|
+
current=$(herdr_app status 2>/dev/null | sed -n 's/.*"layout": *"\([^"]*\)".*/\1/p' | head -n 1) || true
|
|
81
|
+
if [ -z "$current" ]; then
|
|
82
|
+
say " Herdr is not running; it will pick everything up when it starts"
|
|
83
|
+
return 0
|
|
84
|
+
fi
|
|
85
|
+
local other=main
|
|
86
|
+
[ "$current" = main ] && other=terminals
|
|
87
|
+
herdr_app do layout.switch "{\"name\":\"$other\"}" >/dev/null 2>&1 || true
|
|
88
|
+
if herdr_app do layout.switch "{\"name\":\"$current\"}" >/dev/null 2>&1; then
|
|
89
|
+
say " refreshed Herdr (layout: $current)"
|
|
90
|
+
else
|
|
91
|
+
say " could not switch Herdr back to '$current'; pick it from the Layout dropdown or press ctrl-shift-l"
|
|
92
|
+
fi
|
|
93
|
+
}
|