@johngaynor/entourage 0.0.0-stage → 0.1.2
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 +96 -2
- package/cli/entourage +92 -0
- package/cli/lib/commands.sh +86 -0
- package/cli/lib/common.sh +33 -0
- package/cli/lib/links.sh +93 -0
- package/cli/lib/project.sh +172 -0
- package/cli/lib/task.sh +194 -0
- package/herdr/README.md +185 -0
- package/herdr/layouts/default.json +197 -0
- package/herdr/layouts/test.json +207 -0
- package/herdr/mods/cpu/main.js +90 -0
- package/herdr/mods/cpu/mod.json +1 -0
- package/herdr/mods/layout-switch/main.js +48 -0
- package/herdr/mods/layout-switch/mod.json +1 -0
- package/herdr/projects/template/PROJECT.md +19 -0
- package/package.json +24 -4
- package/prompts/task-new.md +14 -0
- package/skills/sdlc-breakdown/SKILL.md +178 -0
- package/skills/sdlc-define/SKILL.md +153 -0
- package/skills/sdlc-plan/SKILL.md +159 -0
package/README.md
CHANGED
|
@@ -1,3 +1,97 @@
|
|
|
1
|
-
#
|
|
1
|
+
# entourage
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A collection of agent skills for the software development lifecycle (SDLC).
|
|
4
|
+
|
|
5
|
+
## Status
|
|
6
|
+
|
|
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
|
+
## Setting up a machine
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm install -g @johngaynor/entourage
|
|
23
|
+
entourage install
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`entourage install` links this repo into the tools on a machine, and
|
|
27
|
+
`entourage update` keeps it current. That covers the Herdr setup and the
|
|
28
|
+
skills; see [herdr/README.md](herdr/README.md) for the full walkthrough.
|
|
29
|
+
|
|
30
|
+
## Projects
|
|
31
|
+
|
|
32
|
+
A project groups the repos that belong together, with a `PROJECT.md` saying
|
|
33
|
+
what each repo is for. Each project opens in Herdr as one space. A repo is
|
|
34
|
+
cloned once and can be in several projects.
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
entourage project new my-project
|
|
38
|
+
entourage project add my-project ~/Dev/api
|
|
39
|
+
entourage project add my-project ~/Dev/web
|
|
40
|
+
entourage project open my-project
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Your projects live in `~/.config/entourage/projects`, outside this repo, so
|
|
44
|
+
they are never published and survive updates. See
|
|
45
|
+
[herdr/README.md](herdr/README.md#projects) for how a project is laid out.
|
|
46
|
+
|
|
47
|
+
## Tasks
|
|
48
|
+
|
|
49
|
+
A task is one piece of work in a project, usually a Linear card. It has two
|
|
50
|
+
commands, used in this order.
|
|
51
|
+
|
|
52
|
+
`task new` writes the card up. It opens a tab in the project's Herdr space and
|
|
53
|
+
starts an agent there, which runs the three skills on the card and then asks
|
|
54
|
+
you to approve it:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
entourage task new my-project ABC-122
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`task start` starts the work. It makes a branch and a git worktree of it in
|
|
61
|
+
every repo of the project, and opens a tab for it:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
entourage task start my-project feat/abc-122-insert-task-here
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The branch is `<type>/<description>`, following
|
|
68
|
+
[Conventional Branch](https://conventionalbranch.org), with the card's ID in
|
|
69
|
+
the description. The description names the task:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
~/.config/entourage/projects/my-project/
|
|
73
|
+
tasks/
|
|
74
|
+
abc-122-insert-task-here/ one folder per task
|
|
75
|
+
api/ a worktree of api on feat/abc-122-insert-task-here
|
|
76
|
+
web/ a worktree of web on the same branch
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
See [herdr/README.md](herdr/README.md#tasks) for the details.
|
|
80
|
+
|
|
81
|
+
To work on entourage itself, clone the repo and run `cli/entourage install`
|
|
82
|
+
from the clone instead. Run the CLI's tests with `npm test`.
|
|
83
|
+
|
|
84
|
+
## Releasing
|
|
85
|
+
|
|
86
|
+
Machines get changes from the npm registry, so a merged change is live only
|
|
87
|
+
after a release:
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
npm version patch # or minor / major; commits and tags vX.Y.Z
|
|
91
|
+
git push --follow-tags
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Then publish a GitHub release for that tag. The `Publish to npm` workflow runs
|
|
95
|
+
the tests and publishes the package. It signs in to npm by
|
|
96
|
+
[trusted publishing](https://docs.npmjs.com/trusted-publishers), so there is no
|
|
97
|
+
token to keep.
|
package/cli/entourage
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# entourage: set up and maintain this machine's copy of the software factory.
|
|
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).
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
usage() {
|
|
10
|
+
cat <<'EOF'
|
|
11
|
+
entourage: set up and maintain this machine from the entourage repo
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
entourage install first-time setup: link everything into the tools on this machine
|
|
15
|
+
entourage update [--no-pull] get the latest entourage, link anything new, drop stale links, refresh Herdr
|
|
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> start the work: a worktree per repo, opened as a tab
|
|
23
|
+
entourage help
|
|
24
|
+
|
|
25
|
+
A project groups repos that belong together, with a PROJECT.md saying what
|
|
26
|
+
each repo is for. A repo can be in several projects.
|
|
27
|
+
|
|
28
|
+
A task is one piece of work in a project, usually a Linear card.
|
|
29
|
+
`task new` takes the card's ID, like ABC-122. It opens a tab in the project's
|
|
30
|
+
Herdr space and starts an agent there, which writes the card up with the
|
|
31
|
+
sdlc-define, sdlc-plan and sdlc-breakdown skills and asks you to approve it.
|
|
32
|
+
`task start` takes a branch, <type>/<description>, like
|
|
33
|
+
feat/abc-122-short-title (https://conventionalbranch.org). It makes a folder
|
|
34
|
+
in the project's tasks/ folder with a worktree of each repo on that branch,
|
|
35
|
+
and opens a tab for it.
|
|
36
|
+
|
|
37
|
+
Herdr's folder is ~/.config/herdr-app (HERDR_APP_HOME picks another).
|
|
38
|
+
Skills are linked into ~/.claude/skills (CLAUDE_CONFIG_DIR picks another
|
|
39
|
+
~/.claude). The agent is claude (ENTOURAGE_AGENT picks another command).
|
|
40
|
+
Your projects are in ~/.config/entourage/projects (ENTOURAGE_HOME picks
|
|
41
|
+
another ~/.config/entourage).
|
|
42
|
+
EOF
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# --- where things are -------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
# The repo root, found from this script's real location (it may be run through
|
|
48
|
+
# the ~/.local/bin/entourage link).
|
|
49
|
+
self=${BASH_SOURCE[0]}
|
|
50
|
+
while [ -L "$self" ]; do
|
|
51
|
+
dir=$(cd -P "$(dirname "$self")" && pwd)
|
|
52
|
+
self=$(readlink "$self")
|
|
53
|
+
case $self in /*) ;; *) self=$dir/$self ;; esac
|
|
54
|
+
done
|
|
55
|
+
REPO=$(cd -P "$(dirname "$self")/.." && pwd)
|
|
56
|
+
|
|
57
|
+
APP_HOME=${HERDR_APP_HOME:-$HOME/.config/herdr-app}
|
|
58
|
+
# Where Claude Code looks for a person's own skills.
|
|
59
|
+
SKILLS_HOME=${CLAUDE_CONFIG_DIR:-$HOME/.claude}/skills
|
|
60
|
+
BIN_DIR=$HOME/.local/bin
|
|
61
|
+
HERDR_INSTALL='curl -fsSL https://releases.herdr.dev/app/install.sh | sh'
|
|
62
|
+
# What `update` reinstalls when entourage came from npm rather than a git clone.
|
|
63
|
+
NPM_SPEC=${ENTOURAGE_NPM_SPEC:-@johngaynor/entourage}
|
|
64
|
+
|
|
65
|
+
# The user's own projects. They live outside the repo so that they are never
|
|
66
|
+
# published and an npm reinstall does not delete them.
|
|
67
|
+
ENT_HOME=${ENTOURAGE_HOME:-$HOME/.config/entourage}
|
|
68
|
+
PROJECTS=$ENT_HOME/projects
|
|
69
|
+
TEMPLATE=$REPO/herdr/projects/template
|
|
70
|
+
# A PROJECT.md that still has this line has not been filled in.
|
|
71
|
+
TEMPLATE_MARK='<!-- entourage:template -->'
|
|
72
|
+
|
|
73
|
+
# --- the rest of the CLI ----------------------------------------------------
|
|
74
|
+
|
|
75
|
+
# Sourced, so every file shares the settings above and each other's functions.
|
|
76
|
+
LIB=$REPO/cli/lib
|
|
77
|
+
for part in common links project task commands; do
|
|
78
|
+
[ -f "$LIB/$part.sh" ] ||
|
|
79
|
+
{ printf 'entourage: %s is missing; reinstall entourage\n' "$LIB/$part.sh" >&2; exit 1; }
|
|
80
|
+
# shellcheck source=/dev/null
|
|
81
|
+
. "$LIB/$part.sh"
|
|
82
|
+
done
|
|
83
|
+
|
|
84
|
+
case ${1:-help} in
|
|
85
|
+
install) shift; cmd_install "$@" ;;
|
|
86
|
+
update) shift; cmd_update "$@" ;;
|
|
87
|
+
status) shift; cmd_status "$@" ;;
|
|
88
|
+
project) shift; cmd_project "$@" ;;
|
|
89
|
+
task) shift; cmd_task "$@" ;;
|
|
90
|
+
help | -h | --help) usage ;;
|
|
91
|
+
*) usage >&2; exit 2 ;;
|
|
92
|
+
esac
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
if [ "$problems" -gt 0 ] || [ "$project_problems" -gt 0 ]; then
|
|
82
|
+
[ "$project_problems" = 0 ] || say "$project_problems project problem(s)."
|
|
83
|
+
return 1
|
|
84
|
+
fi
|
|
85
|
+
say "Everything is in order."
|
|
86
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
# Herdr answers `status` with the layout it shows only while its window is open.
|
|
19
|
+
herdr_running() { herdr_app status 2>/dev/null | grep -q '"layout"'; }
|
|
20
|
+
|
|
21
|
+
require_herdr() {
|
|
22
|
+
have_herdr || die "Herdr is not installed. Install it, open it once, then run this again:
|
|
23
|
+
$HERDR_INSTALL"
|
|
24
|
+
[ -d "$APP_HOME" ] || die "$APP_HOME does not exist yet. Open Herdr once so it creates its folder, then run this again."
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# Print a string as the inside of a JSON string. sed and awk do the work so
|
|
28
|
+
# that the result does not depend on the bash version's quoting rules.
|
|
29
|
+
json_str() {
|
|
30
|
+
printf '%s' "$1" | tr '\t\r' ' ' |
|
|
31
|
+
sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' |
|
|
32
|
+
awk 'BEGIN { ORS = "" } NR > 1 { print "\\n" } { print }'
|
|
33
|
+
}
|
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
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Projects: groups of repos shown in Herdr as spaces. Sourced by cli/entourage.
|
|
2
|
+
|
|
3
|
+
# A project is a folder in $PROJECTS:
|
|
4
|
+
# PROJECT.md what the project is and what belongs in each repo
|
|
5
|
+
# repos one repo path per line (~/ for the home folder, # for comments)
|
|
6
|
+
# links/ generated: a link to each repo, named after its folder
|
|
7
|
+
# CLAUDE.md, AGENTS.md generated: links to PROJECT.md, so agents read it
|
|
8
|
+
|
|
9
|
+
valid_name() { case ${1:-} in '' | *[!a-z0-9-]*) return 1 ;; esac; }
|
|
10
|
+
|
|
11
|
+
# Print a project's folder, or stop if there is no such project.
|
|
12
|
+
project_dir() {
|
|
13
|
+
local name=${1:-}
|
|
14
|
+
[ -n "$name" ] || die "which project? See: entourage project ls"
|
|
15
|
+
valid_name "$name" && [ -d "$PROJECTS/$name" ] ||
|
|
16
|
+
die "no project called '$name'. Make it with: entourage project new $name"
|
|
17
|
+
(cd -P "$PROJECTS/$name" && pwd)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
# Print a project's repo paths, absolute, one per line.
|
|
21
|
+
project_repos() {
|
|
22
|
+
local dir=$1 line
|
|
23
|
+
[ -f "$dir/repos" ] || return 0
|
|
24
|
+
while IFS= read -r line || [ -n "$line" ]; do
|
|
25
|
+
case $line in
|
|
26
|
+
'' | '#'*) continue ;;
|
|
27
|
+
'~/'*) line=$HOME/${line#'~/'} ;;
|
|
28
|
+
esac
|
|
29
|
+
printf '%s\n' "$line"
|
|
30
|
+
done < "$dir/repos"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
is_repo() { [ -e "$1/.git" ]; }
|
|
34
|
+
|
|
35
|
+
# Rebuild what is generated in a project folder. Only links are ever removed
|
|
36
|
+
# or replaced; a real file in the way is reported and left alone.
|
|
37
|
+
sync_links() {
|
|
38
|
+
local dir=$1 src dst base names=$'\n'
|
|
39
|
+
mkdir -p "$dir/links"
|
|
40
|
+
while IFS= read -r src; do
|
|
41
|
+
base=${src##*/}
|
|
42
|
+
dst=$dir/links/$base
|
|
43
|
+
names+=$base$'\n'
|
|
44
|
+
is_repo "$src" || say " warning: $src is missing or is not a git repo"
|
|
45
|
+
if [ -L "$dst" ]; then
|
|
46
|
+
[ "$(readlink "$dst")" = "$src" ] || { rm "$dst"; ln -s "$src" "$dst"; }
|
|
47
|
+
elif [ -e "$dst" ]; then
|
|
48
|
+
say " skipped links/$base (a real file is in the way)"
|
|
49
|
+
else
|
|
50
|
+
ln -s "$src" "$dst"
|
|
51
|
+
fi
|
|
52
|
+
done < <(project_repos "$dir")
|
|
53
|
+
for dst in "$dir"/links/*; do
|
|
54
|
+
[ -L "$dst" ] || continue
|
|
55
|
+
case $names in *$'\n'"${dst##*/}"$'\n'*) ;; *) rm "$dst" ;; esac
|
|
56
|
+
done
|
|
57
|
+
for base in CLAUDE.md AGENTS.md; do
|
|
58
|
+
[ -e "$dir/$base" ] || [ -L "$dir/$base" ] || ln -s PROJECT.md "$dir/$base"
|
|
59
|
+
done
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
project_new() {
|
|
63
|
+
local name=${1:-} dir
|
|
64
|
+
valid_name "$name" || die "a project name is lowercase letters, digits and dashes, like: my-project"
|
|
65
|
+
dir=$PROJECTS/$name
|
|
66
|
+
[ ! -e "$dir" ] || die "project '$name' already exists at $dir"
|
|
67
|
+
[ -f "$TEMPLATE/PROJECT.md" ] || die "the project template is missing from $TEMPLATE"
|
|
68
|
+
mkdir -p "$dir"
|
|
69
|
+
sed "s/__NAME__/$name/" "$TEMPLATE/PROJECT.md" > "$dir/PROJECT.md"
|
|
70
|
+
: > "$dir/repos"
|
|
71
|
+
sync_links "$dir"
|
|
72
|
+
say "Made project '$name' at $dir"
|
|
73
|
+
say "Next:"
|
|
74
|
+
say " entourage project add $name <path to a repo>"
|
|
75
|
+
say " fill in $dir/PROJECT.md"
|
|
76
|
+
say " entourage project open $name"
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
project_add() {
|
|
80
|
+
local name=${1:-} path=${2:-} dir abs other stored
|
|
81
|
+
dir=$(project_dir "$name")
|
|
82
|
+
[ -n "$path" ] || die "which repo? Usage: entourage project add $name <path>"
|
|
83
|
+
[ -d "$path" ] || die "$path is not a folder"
|
|
84
|
+
abs=$(cd "$path" && pwd -P)
|
|
85
|
+
is_repo "$abs" || die "$abs is not a git repo (the top folder of a clone is needed)"
|
|
86
|
+
while IFS= read -r other; do
|
|
87
|
+
[ "$other" != "$abs" ] || die "$abs is already in project '$name'"
|
|
88
|
+
[ "${other##*/}" != "${abs##*/}" ] ||
|
|
89
|
+
die "project '$name' already has a repo called ${abs##*/} ($other); two repos in a project cannot share a folder name"
|
|
90
|
+
done < <(project_repos "$dir")
|
|
91
|
+
case $abs in
|
|
92
|
+
"$HOME"/*) stored="~/${abs#"$HOME"/}" ;;
|
|
93
|
+
*) stored=$abs ;;
|
|
94
|
+
esac
|
|
95
|
+
printf '%s\n' "$stored" >> "$dir/repos"
|
|
96
|
+
sync_links "$dir"
|
|
97
|
+
say "Added ${abs##*/} to project '$name'"
|
|
98
|
+
say "Describe what it owns in $dir/PROJECT.md"
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# Show the Herdr space for a project, making it if it is not open.
|
|
102
|
+
show_space() {
|
|
103
|
+
local name=$1 dir=$2 id
|
|
104
|
+
# Find an open space whose folder is this project's. `herdr-app ls` prints
|
|
105
|
+
# indented JSON; a space's own "id" and "folder" sit at six spaces. Closed
|
|
106
|
+
# spaces are listed after "recent" in the same shape, so stop there.
|
|
107
|
+
id=$(herdr_app ls 2>/dev/null | awk -v want="$dir" '
|
|
108
|
+
/^ "recent"/ { exit }
|
|
109
|
+
/^ "id": / { id = $2; gsub(/[",]/, "", id) }
|
|
110
|
+
/^ "folder": / { f = $0; sub(/^ *"folder": "/, "", f); sub(/",?$/, "", f)
|
|
111
|
+
if (f == want) { print id; exit } }') || true
|
|
112
|
+
if [ -n "$id" ]; then
|
|
113
|
+
herdr_app do space.select "{\"id\":\"$id\"}" >/dev/null 2>&1 ||
|
|
114
|
+
die "could not show the space for '$name'. Is Herdr open?"
|
|
115
|
+
say "Showing the space for '$name'"
|
|
116
|
+
else
|
|
117
|
+
herdr_app do space.new "{\"name\":\"$name\",\"folder\":\"$dir\"}" >/dev/null 2>&1 ||
|
|
118
|
+
die "could not make a space for '$name'. Is Herdr open?"
|
|
119
|
+
say "Opened a space for '$name' in $dir"
|
|
120
|
+
fi
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
project_open() {
|
|
124
|
+
local name=${1:-} dir
|
|
125
|
+
dir=$(project_dir "$name")
|
|
126
|
+
require_herdr
|
|
127
|
+
sync_links "$dir"
|
|
128
|
+
show_space "$name" "$dir"
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
project_ls() {
|
|
132
|
+
local d any=0 repo
|
|
133
|
+
for d in "$PROJECTS"/*/; do
|
|
134
|
+
[ -d "$d" ] || continue
|
|
135
|
+
any=1
|
|
136
|
+
d=${d%/}
|
|
137
|
+
say "${d##*/}"
|
|
138
|
+
while IFS= read -r repo; do say " $repo"; done < <(project_repos "$d")
|
|
139
|
+
done
|
|
140
|
+
[ "$any" = 1 ] || say "No projects yet. Make one with: entourage project new <name>"
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
# Print what is wrong with each project; return how many problems there are.
|
|
144
|
+
check_projects() {
|
|
145
|
+
local d repo problems=0 bad
|
|
146
|
+
for d in "$PROJECTS"/*/; do
|
|
147
|
+
[ -d "$d" ] || continue
|
|
148
|
+
d=${d%/}
|
|
149
|
+
bad=0
|
|
150
|
+
if [ ! -f "$d/PROJECT.md" ]; then
|
|
151
|
+
say " problem ${d##*/}: PROJECT.md is missing"; bad=$((bad + 1))
|
|
152
|
+
elif grep -qF -- "$TEMPLATE_MARK" "$d/PROJECT.md"; then
|
|
153
|
+
say " problem ${d##*/}: PROJECT.md is still the template; fill it in and delete its first line"; bad=$((bad + 1))
|
|
154
|
+
fi
|
|
155
|
+
while IFS= read -r repo; do
|
|
156
|
+
is_repo "$repo" || { say " problem ${d##*/}: $repo is missing or is not a git repo"; bad=$((bad + 1)); }
|
|
157
|
+
done < <(project_repos "$d")
|
|
158
|
+
[ "$bad" -gt 0 ] || say " ok ${d##*/}"
|
|
159
|
+
problems=$((problems + bad))
|
|
160
|
+
done
|
|
161
|
+
return "$problems"
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
cmd_project() {
|
|
165
|
+
case ${1:-} in
|
|
166
|
+
new) shift; project_new "$@" ;;
|
|
167
|
+
add) shift; project_add "$@" ;;
|
|
168
|
+
open) shift; project_open "$@" ;;
|
|
169
|
+
ls | list) shift; project_ls ;;
|
|
170
|
+
*) die "usage: entourage project new|add|open|ls (see: entourage help)" ;;
|
|
171
|
+
esac
|
|
172
|
+
}
|