@johngaynor/entourage 0.0.0-stage → 0.1.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 CHANGED
@@ -1,3 +1,34 @@
1
- # Temporary Holding Version
1
+ # entourage
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A collection of agent skills for the software development lifecycle (SDLC).
4
+
5
+ ## Status
6
+
7
+ Early setup. Skills are being ported in.
8
+
9
+ ## Setting up a machine
10
+
11
+ ```sh
12
+ npm install -g @johngaynor/entourage
13
+ entourage install
14
+ ```
15
+
16
+ `entourage install` links this repo into the tools on a machine, and
17
+ `entourage update` keeps it current. Today that covers the Herdr setup; see
18
+ [herdr/README.md](herdr/README.md) for the full walkthrough.
19
+
20
+ To work on entourage itself, clone the repo and run `cli/entourage install`
21
+ from the clone instead. Run the CLI's tests with `npm test`.
22
+
23
+ ## Releasing
24
+
25
+ Machines get changes from the npm registry, so a merged change is live only
26
+ after a release:
27
+
28
+ ```sh
29
+ npm version patch # or minor / major; commits and tags vX.Y.Z
30
+ git push --follow-tags
31
+ ```
32
+
33
+ Then publish a GitHub release for that tag. The `Publish to npm` workflow runs
34
+ the tests and publishes the package. It needs a repo secret `NPM_TOKEN`.
package/cli/entourage ADDED
@@ -0,0 +1,227 @@
1
+ #!/usr/bin/env bash
2
+ # entourage: set up and maintain this machine's copy of the software factory.
3
+ # Today that means the Herdr mods and layouts under herdr/.
4
+ set -euo pipefail
5
+
6
+ usage() {
7
+ cat <<'EOF'
8
+ entourage: set up and maintain this machine from the entourage repo
9
+
10
+ Usage:
11
+ entourage install first-time setup: link everything into the tools on this machine
12
+ 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
14
+ entourage help
15
+
16
+ Herdr's folder is ~/.config/herdr-app (HERDR_APP_HOME picks another).
17
+ EOF
18
+ }
19
+
20
+ # --- where things are -------------------------------------------------------
21
+
22
+ # The repo root, found from this script's real location (it may be run through
23
+ # the ~/.local/bin/entourage link).
24
+ self=${BASH_SOURCE[0]}
25
+ while [ -L "$self" ]; do
26
+ dir=$(cd -P "$(dirname "$self")" && pwd)
27
+ self=$(readlink "$self")
28
+ case $self in /*) ;; *) self=$dir/$self ;; esac
29
+ done
30
+ REPO=$(cd -P "$(dirname "$self")/.." && pwd)
31
+
32
+ APP_HOME=${HERDR_APP_HOME:-$HOME/.config/herdr-app}
33
+ BIN_DIR=$HOME/.local/bin
34
+ HERDR_INSTALL='curl -fsSL https://releases.herdr.dev/app/install.sh | sh'
35
+ # What `update` reinstalls when entourage came from npm rather than a git clone.
36
+ NPM_SPEC=${ENTOURAGE_NPM_SPEC:-@johngaynor/entourage}
37
+
38
+ # A git clone updates with `git pull`; an npm install updates through npm.
39
+ is_clone() { [ -e "$REPO/.git" ]; }
40
+
41
+ say() { printf '%s\n' "$*"; }
42
+ die() { printf 'entourage: %s\n' "$*" >&2; exit 1; }
43
+
44
+ herdr_app() {
45
+ if command -v herdr-app >/dev/null 2>&1; then herdr-app "$@"
46
+ elif [ -x "$BIN_DIR/herdr-app" ]; then "$BIN_DIR/herdr-app" "$@"
47
+ else return 127
48
+ fi
49
+ }
50
+
51
+ have_herdr() { command -v herdr-app >/dev/null 2>&1 || [ -x "$BIN_DIR/herdr-app" ]; }
52
+
53
+ # --- linking ----------------------------------------------------------------
54
+
55
+ # Every (source, destination) pair this repo wants linked, one per line,
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
+ }
220
+
221
+ case ${1:-help} in
222
+ install) shift; cmd_install "$@" ;;
223
+ update) shift; cmd_update "$@" ;;
224
+ status) shift; cmd_status "$@" ;;
225
+ help | -h | --help) usage ;;
226
+ *) usage >&2; exit 2 ;;
227
+ esac
@@ -0,0 +1,93 @@
1
+ # herdr
2
+
3
+ Shared setup for the [Herdr](https://herdr.dev) desktop app: mods (panels) and
4
+ layouts (whole-window arrangements of mods).
5
+
6
+ ## What's here
7
+
8
+ | Path | What it is |
9
+ |---|---|
10
+ | `mods/cpu/` | Live CPU usage with a scrolling history. macOS only (reads `/usr/bin/top`). |
11
+ | `mods/layout-switch/` | A dropdown that shows the current layout and switches to another. |
12
+ | `layouts/default.json` | Herdr's own layout, plus the layout dropdown. |
13
+ | `layouts/test.json` | `default` plus the CPU mod in the sidebar. |
14
+
15
+ ## How it works
16
+
17
+ Herdr reads its whole interface from files in `~/.config/herdr-app`. This repo
18
+ holds the mods and layouts we own, and each machine symlinks them into that
19
+ folder. The linked files are the tracked files, so a `git pull` is all it
20
+ takes to update a machine.
21
+
22
+ Per-machine things stay out of the repo: the Herdr account, `settings.json`,
23
+ `keys.json`, and which layout is showing.
24
+
25
+ ## Set up a clean machine
26
+
27
+ 1. Install Herdr:
28
+
29
+ ```sh
30
+ curl -fsSL https://releases.herdr.dev/app/install.sh | sh
31
+ ```
32
+
33
+ This installs the Herdr app, herdr-core (which runs the terminals), and the
34
+ `herdr-app` and `hc` commands in `~/.local/bin`.
35
+
36
+ 2. Open Herdr once and sign in. The first start creates
37
+ `~/.config/herdr-app` and fills it with Herdr's own mods and layouts.
38
+
39
+ 3. Install entourage (needs Node):
40
+
41
+ ```sh
42
+ npm install -g @johngaynor/entourage
43
+ ```
44
+
45
+ 4. Run the installer:
46
+
47
+ ```sh
48
+ entourage install
49
+ ```
50
+
51
+ It links every mod and layout into Herdr and refreshes Herdr if it is
52
+ running. It is safe to re-run, and it never replaces a real file that is
53
+ already in Herdr's folder.
54
+
55
+ 5. Pick a layout from the Layout dropdown at the top of the sidebar, or press
56
+ `ctrl-shift-l` to cycle. The dropdown only appears on our layouts, so the
57
+ first switch from Herdr's own layout is `ctrl-shift-l`.
58
+
59
+ ## Keeping a machine up to date
60
+
61
+ ```sh
62
+ entourage update
63
+ ```
64
+
65
+ This reinstalls the latest entourage through npm, links any mod or layout that
66
+ is new, removes links to ones that were deleted, and refreshes Herdr so it
67
+ re-reads everything.
68
+
69
+ - **Check a machine:** `entourage status` lists each mod and layout and whether
70
+ it is linked.
71
+ - **Remove one from a machine:** delete its link in `~/.config/herdr-app/mods`
72
+ or `layouts`. The next `entourage update` will link it again, so remove it
73
+ from the repo to drop it everywhere.
74
+ - **Herdr updates itself:** it replaces its own shipped mods and layouts on
75
+ every start and leaves ours alone, because ours have different names.
76
+ - **Something broke the window:** `ctrl-alt-shift-escape` always returns Herdr
77
+ to its own default layout.
78
+
79
+ ## Changing things
80
+
81
+ - Work from a git clone, not the npm install: clone the repo and run
82
+ `cli/entourage install` from it. A clone links Herdr to the working files and
83
+ updates with `git pull`. If the machine was set up through npm first, remove
84
+ the old links in `~/.config/herdr-app/mods` and `layouts` before installing
85
+ from the clone, because existing links are never replaced.
86
+ - Edit files in the clone, not in `~/.config/herdr-app`: the links mean they
87
+ are the same files.
88
+ - Herdr does not notice edits made through a link straight away. Run
89
+ `entourage update --no-pull` to refresh it without pulling.
90
+ - Run `herdr-app check herdr/mods/<name>` after editing a mod.
91
+ - Herdr's shipped layouts and mods are read-only. To build on one, clone it
92
+ (`herdr-app do layout.clone '{"name":"main","as":"<name>"}'`) and move the
93
+ clone here.
@@ -0,0 +1,197 @@
1
+ {
2
+ "id": "root",
3
+ "cloned_from": {
4
+ "name": "main",
5
+ "version": "0.1.18"
6
+ },
7
+ "type": "row",
8
+ "children": [
9
+ {
10
+ "id": "sidebar",
11
+ "type": "column",
12
+ "children": [
13
+ {
14
+ "id": "brand",
15
+ "type": "block",
16
+ "content": {
17
+ "mod": "workspace-chrome"
18
+ },
19
+ "size": {
20
+ "px": 46
21
+ },
22
+ "window_drag": true
23
+ },
24
+ {
25
+ "id": "layout-switch",
26
+ "type": "block",
27
+ "size": {
28
+ "px": 40
29
+ },
30
+ "content": {
31
+ "mod": "layout-switch"
32
+ }
33
+ },
34
+ {
35
+ "id": "sidebar-lists",
36
+ "type": "column",
37
+ "children": [
38
+ {
39
+ "id": "spaces",
40
+ "type": "block",
41
+ "content": {
42
+ "mod": "spaces"
43
+ },
44
+ "size": {
45
+ "weight": 1
46
+ },
47
+ "min": 90
48
+ },
49
+ {
50
+ "id": "agents",
51
+ "type": "block",
52
+ "content": {
53
+ "mod": "agents"
54
+ },
55
+ "size": {
56
+ "weight": 1
57
+ },
58
+ "min": 90
59
+ }
60
+ ]
61
+ },
62
+ {
63
+ "id": "sidebar-footer",
64
+ "type": "block",
65
+ "content": {
66
+ "mod": "workspace-chrome",
67
+ "props": {
68
+ "footer": true
69
+ }
70
+ },
71
+ "size": {
72
+ "px": 69
73
+ }
74
+ }
75
+ ],
76
+ "size": {
77
+ "px": 268
78
+ },
79
+ "min": 44,
80
+ "max": 480,
81
+ "background": "chrome",
82
+ "resizable": false
83
+ },
84
+ {
85
+ "id": "work",
86
+ "type": "column",
87
+ "children": [
88
+ {
89
+ "id": "tabs",
90
+ "type": "block",
91
+ "content": {
92
+ "mod": "tabs"
93
+ },
94
+ "size": {
95
+ "px": 42
96
+ },
97
+ "window_drag": true
98
+ },
99
+ {
100
+ "id": "work-body",
101
+ "type": "row",
102
+ "children": [
103
+ {
104
+ "id": "main",
105
+ "type": "block",
106
+ "content": {
107
+ "tab": "active",
108
+ "pane": {
109
+ "header": {
110
+ "content": {
111
+ "mod": "pane"
112
+ },
113
+ "reveal": "always",
114
+ "height": 30,
115
+ "position": "top"
116
+ },
117
+ "background": "background",
118
+ "border": {
119
+ "width": 1,
120
+ "color": "border"
121
+ },
122
+ "focus": {
123
+ "width": 1,
124
+ "color": "accent"
125
+ },
126
+ "radius": 10,
127
+ "gap": 8,
128
+ "lone": true
129
+ }
130
+ }
131
+ },
132
+ {
133
+ "id": "panel",
134
+ "type": "column",
135
+ "children": [
136
+ {
137
+ "id": "panel-body",
138
+ "type": "stack",
139
+ "children": [
140
+ {
141
+ "id": "files",
142
+ "type": "block",
143
+ "content": {
144
+ "mod": "files"
145
+ }
146
+ },
147
+ {
148
+ "id": "changes",
149
+ "type": "block",
150
+ "content": {
151
+ "mod": "changes"
152
+ }
153
+ }
154
+ ],
155
+ "active": "files"
156
+ }
157
+ ],
158
+ "size": {
159
+ "px": 368
160
+ },
161
+ "min": 280,
162
+ "max": 900,
163
+ "hidden": true
164
+ }
165
+ ],
166
+ "padding": 8,
167
+ "gap": 8
168
+ },
169
+ {
170
+ "id": "status",
171
+ "type": "block",
172
+ "content": {
173
+ "mod": "workspace-status"
174
+ },
175
+ "size": {
176
+ "px": 28
177
+ }
178
+ }
179
+ ],
180
+ "resizable": false
181
+ }
182
+ ],
183
+ "background": "canvas",
184
+ "terminal_padding": [
185
+ 14,
186
+ 12
187
+ ],
188
+ "divider": {
189
+ "width": 1,
190
+ "color": "border"
191
+ },
192
+ "titlebar": "none",
193
+ "traffic_lights": [
194
+ 12,
195
+ 16
196
+ ]
197
+ }
@@ -0,0 +1,207 @@
1
+ {
2
+ "id": "root",
3
+ "cloned_from": {
4
+ "name": "main",
5
+ "version": "0.1.18"
6
+ },
7
+ "type": "row",
8
+ "children": [
9
+ {
10
+ "id": "sidebar",
11
+ "type": "column",
12
+ "children": [
13
+ {
14
+ "id": "brand",
15
+ "type": "block",
16
+ "content": {
17
+ "mod": "workspace-chrome"
18
+ },
19
+ "size": {
20
+ "px": 46
21
+ },
22
+ "window_drag": true
23
+ },
24
+ {
25
+ "id": "layout-switch",
26
+ "type": "block",
27
+ "size": {
28
+ "px": 40
29
+ },
30
+ "content": {
31
+ "mod": "layout-switch"
32
+ }
33
+ },
34
+ {
35
+ "id": "sidebar-lists",
36
+ "type": "column",
37
+ "children": [
38
+ {
39
+ "id": "spaces",
40
+ "type": "block",
41
+ "content": {
42
+ "mod": "spaces"
43
+ },
44
+ "size": {
45
+ "weight": 1
46
+ },
47
+ "min": 90
48
+ },
49
+ {
50
+ "id": "agents",
51
+ "type": "block",
52
+ "content": {
53
+ "mod": "agents"
54
+ },
55
+ "size": {
56
+ "weight": 1
57
+ },
58
+ "min": 90
59
+ }
60
+ ]
61
+ },
62
+ {
63
+ "id": "cpu",
64
+ "type": "block",
65
+ "size": {
66
+ "px": 64
67
+ },
68
+ "content": {
69
+ "mod": "cpu"
70
+ }
71
+ },
72
+ {
73
+ "id": "sidebar-footer",
74
+ "type": "block",
75
+ "content": {
76
+ "mod": "workspace-chrome",
77
+ "props": {
78
+ "footer": true
79
+ }
80
+ },
81
+ "size": {
82
+ "px": 69
83
+ }
84
+ }
85
+ ],
86
+ "size": {
87
+ "px": 268
88
+ },
89
+ "min": 44,
90
+ "max": 480,
91
+ "background": "chrome",
92
+ "resizable": false
93
+ },
94
+ {
95
+ "id": "work",
96
+ "type": "column",
97
+ "children": [
98
+ {
99
+ "id": "tabs",
100
+ "type": "block",
101
+ "content": {
102
+ "mod": "tabs"
103
+ },
104
+ "size": {
105
+ "px": 42
106
+ },
107
+ "window_drag": true
108
+ },
109
+ {
110
+ "id": "work-body",
111
+ "type": "row",
112
+ "children": [
113
+ {
114
+ "id": "main",
115
+ "type": "block",
116
+ "content": {
117
+ "tab": "active",
118
+ "pane": {
119
+ "header": {
120
+ "content": {
121
+ "mod": "pane"
122
+ },
123
+ "reveal": "always",
124
+ "height": 30,
125
+ "position": "top"
126
+ },
127
+ "background": "background",
128
+ "border": {
129
+ "width": 1,
130
+ "color": "border"
131
+ },
132
+ "focus": {
133
+ "width": 1,
134
+ "color": "accent"
135
+ },
136
+ "radius": 10,
137
+ "gap": 8,
138
+ "lone": true
139
+ }
140
+ }
141
+ },
142
+ {
143
+ "id": "panel",
144
+ "type": "column",
145
+ "children": [
146
+ {
147
+ "id": "panel-body",
148
+ "type": "stack",
149
+ "children": [
150
+ {
151
+ "id": "files",
152
+ "type": "block",
153
+ "content": {
154
+ "mod": "files"
155
+ }
156
+ },
157
+ {
158
+ "id": "changes",
159
+ "type": "block",
160
+ "content": {
161
+ "mod": "changes"
162
+ }
163
+ }
164
+ ],
165
+ "active": "files"
166
+ }
167
+ ],
168
+ "size": {
169
+ "px": 368
170
+ },
171
+ "min": 280,
172
+ "max": 900,
173
+ "hidden": true
174
+ }
175
+ ],
176
+ "padding": 8,
177
+ "gap": 8
178
+ },
179
+ {
180
+ "id": "status",
181
+ "type": "block",
182
+ "content": {
183
+ "mod": "workspace-status"
184
+ },
185
+ "size": {
186
+ "px": 28
187
+ }
188
+ }
189
+ ],
190
+ "resizable": false
191
+ }
192
+ ],
193
+ "background": "canvas",
194
+ "terminal_padding": [
195
+ 14,
196
+ 12
197
+ ],
198
+ "divider": {
199
+ "width": 1,
200
+ "color": "border"
201
+ },
202
+ "titlebar": "none",
203
+ "traffic_lights": [
204
+ 12,
205
+ 16
206
+ ]
207
+ }
@@ -0,0 +1,90 @@
1
+ // Live CPU usage, drawn as a scrolling history like Activity Monitor's.
2
+ // macOS only: it reads the "CPU usage" line that /usr/bin/top prints.
3
+ import { View, div } from "gpui-kit";
4
+ import { h_flex, v_flex } from "gpui-base";
5
+ import { exec, theme, window, checking, settings } from "herdr";
6
+
7
+ const SAMPLE_MS = 2000; // one reading every two seconds
8
+ const BAR = 3; // px per reading
9
+ const GAP = 1;
10
+ const KEEP = 600; // readings kept, enough for a very wide panel
11
+
12
+ export default class Cpu extends View {
13
+ init(_props, cx) {
14
+ this.samples = [];
15
+ this.busy = false;
16
+ this.error = null;
17
+ this.graph = { width: 240, height: 40 };
18
+ if (checking()) return;
19
+ cx.timer.every(SAMPLE_MS, (cx) => this.sample(cx));
20
+ this.sample(cx);
21
+ }
22
+
23
+ sample(cx) {
24
+ // Skip while a reading is in flight or nobody can see the window.
25
+ if (this.busy || window()?.visible === false) return;
26
+ this.busy = true;
27
+ cx.spawn(async (cx) => {
28
+ try {
29
+ // top's first sample averages since boot; the second covers the last second.
30
+ const r = await exec("/usr/bin/top", ["-l", "2", "-n", "0", "-s", "1"], { timeout: 10000 });
31
+ const line = r.stdout.split("\n").filter((l) => l.startsWith("CPU usage:")).at(-1);
32
+ const m = line?.match(/([\d.]+)% user, ([\d.]+)% sys/);
33
+ if (m) {
34
+ this.samples.push({ user: Number(m[1]), sys: Number(m[2]) });
35
+ if (this.samples.length > KEEP) this.samples.shift();
36
+ this.error = null;
37
+ } else {
38
+ this.error = "no CPU reading from top";
39
+ }
40
+ } catch (e) {
41
+ this.error = String(e?.message ?? e);
42
+ }
43
+ this.busy = false;
44
+ cx.notify();
45
+ });
46
+ }
47
+
48
+ render() {
49
+ const t = theme();
50
+ const userColor = t.ansi4;
51
+ const sysColor = t.ansi1;
52
+ const last = this.samples.at(-1);
53
+ const total = last ? Math.round(last.user + last.sys) : null;
54
+
55
+ const fit = Math.max(1, Math.floor(this.graph.width / (BAR + GAP)));
56
+ const shown = this.samples.slice(-fit);
57
+ const h = Math.max(1, this.graph.height);
58
+ const px = (pct) => Math.round((Math.min(100, pct) / 100) * h);
59
+
60
+ const legend = (color, text) =>
61
+ h_flex().gap(5).items_center().child(div().size(6).rounded(3).bg(color)).child(text);
62
+
63
+ const readout = v_flex().flex_none().w(132).gap(2).justify_center()
64
+ .child(h_flex().gap(8).items_end()
65
+ .child(div().text_size(11).text_color(t.muted).child("CPU"))
66
+ .child(div().text_size(20).font_semibold().text_color(t.foreground).child(total === null ? "–" : `${total}%`)))
67
+ .child(this.error
68
+ ? div().text_size(11).text_color(t.blocked).truncate().child(this.error)
69
+ : h_flex().gap(10).text_size(11).text_color(t.muted)
70
+ .child(legend(userColor, last ? `user ${Math.round(last.user)}%` : "user"))
71
+ .child(legend(sysColor, last ? `sys ${Math.round(last.sys)}%` : "sys")));
72
+
73
+ const bars = h_flex().id("cpu-graph").flex_1().h_full().min_w(0).overflow_hidden()
74
+ .items_end().justify_end().gap(GAP).rounded(4).bg(t.surface)
75
+ .on_size_change((size, cx) => {
76
+ const zoom = Number(settings().zoom) || 1;
77
+ this.graph = { width: size.width / zoom, height: size.height / zoom };
78
+ cx.notify();
79
+ })
80
+ .children(shown.map((s) =>
81
+ v_flex().flex_none().w(BAR)
82
+ .child(div().h(px(s.sys)).bg(sysColor))
83
+ .child(div().h(px(s.user)).bg(userColor))));
84
+
85
+ return h_flex().size_full().px(14).py(8).gap(12).items_center()
86
+ .bg(t.chrome).border_t(1).border_color(t.border)
87
+ .child(readout)
88
+ .child(bars);
89
+ }
90
+ }
@@ -0,0 +1 @@
1
+ { "place": "bottom", "size": 64 }
@@ -0,0 +1,48 @@
1
+ // A dropdown that shows the current layout and switches to another.
2
+ // One mod, two faces: the button a layout places, and the popup list it opens
3
+ // (the same mod again, with props { menu: true }).
4
+ import { View, div } from "gpui-kit";
5
+ import { v_flex, h_flex } from "gpui-base";
6
+ import { layouts, shared, run, theme, props, openOverlay, closeOverlay } from "herdr";
7
+
8
+ const ROW = 28;
9
+
10
+ export default class LayoutSwitch extends View {
11
+ render() {
12
+ return props()?.menu ? this.menu() : this.button();
13
+ }
14
+
15
+ button() {
16
+ const t = theme();
17
+ const current = shared("layout") ?? "main";
18
+ return h_flex().size_full().px(12).items_center().bg(t.chrome).child(
19
+ h_flex().id("layout-switch").flex_1().min_w(0).h(ROW).px(10).gap(8).items_center()
20
+ .rounded(6).border(1).border_color(t.border).bg(t.surface)
21
+ .text_size(12).hover((s) => s.bg(t.hover))
22
+ .on_click(() =>
23
+ openOverlay({
24
+ mod: "layout-switch", kind: "popup", width: 220,
25
+ height: layouts().length * ROW + 10, props: { menu: true },
26
+ }))
27
+ .child(div().flex_none().text_color(t.muted).child("Layout"))
28
+ .child(div().flex_1().min_w(0).truncate().text_color(t.foreground).child(String(current)))
29
+ .child(div().flex_none().text_color(t.dim).child("▾")));
30
+ }
31
+
32
+ menu() {
33
+ const t = theme();
34
+ const current = shared("layout") ?? "main";
35
+ const pick = (name) => {
36
+ closeOverlay(props().overlay);
37
+ if (name !== current) run("layout.switch", { name });
38
+ };
39
+ return v_flex().size_full().p(4).bg(t.popover).text_size(12).children(
40
+ layouts().map((name) =>
41
+ h_flex().id(`layout-${name}`).h(ROW).px(8).gap(8).items_center().rounded(4)
42
+ .hover((s) => s.bg(t.hover))
43
+ .on_click(() => pick(name))
44
+ .child(div().w(12).flex_none().text_color(t.accent).child(name === current ? "✓" : ""))
45
+ .child(div().flex_1().min_w(0).truncate()
46
+ .text_color(name === current ? t.foreground : t.muted).child(name))));
47
+ }
48
+ }
@@ -0,0 +1 @@
1
+ { "place": "none" }
package/package.json CHANGED
@@ -1,6 +1,23 @@
1
1
  {
2
2
  "name": "@johngaynor/entourage",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "A software factory: agent skills and the Herdr setup to run them, installed with one command.",
5
+ "bin": {
6
+ "entourage": "cli/entourage"
7
+ },
8
+ "files": [
9
+ "cli/entourage",
10
+ "herdr/"
11
+ ],
12
+ "scripts": {
13
+ "test": "cli/test.sh"
14
+ },
15
+ "os": [
16
+ "darwin",
17
+ "linux"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/johngaynor/entourage.git"
22
+ }
23
+ }