@johngaynor/entourage 0.3.0 → 0.4.1-next.10
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 +42 -8
- package/cli/entourage +24 -7
- package/cli/lib/commands.sh +3 -0
- package/cli/lib/handoff.sh +336 -0
- package/cli/lib/project.sh +53 -11
- package/cli/lib/task.sh +12 -3
- package/cli/lib/trust.sh +70 -0
- package/herdr/README.md +71 -5
- package/herdr/layouts/test.json +11 -0
- package/herdr/mods/projects/main.js +195 -5
- package/herdr/mods/steps/main.js +191 -0
- package/herdr/mods/steps/mod.json +1 -0
- package/package.json +1 -1
- package/prompts/task-new.md +2 -2
- package/skills/sdlc-breakdown/SKILL.md +25 -10
- package/skills/sdlc-define/SKILL.md +22 -9
- package/skills/sdlc-plan/SKILL.md +22 -9
package/cli/lib/trust.sh
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Folders Claude Code starts in without asking. Sourced by cli/entourage.
|
|
2
|
+
|
|
3
|
+
# Claude Code asks "do you trust this folder?" the first time it starts in one,
|
|
4
|
+
# and keeps the answer in its own file, $CLAUDE_STATE, as
|
|
5
|
+
# .projects["<the folder's real path>"].hasTrustDialogAccepted
|
|
6
|
+
# A folder cannot answer for itself. entourage answers for the folders it made
|
|
7
|
+
# itself (a project's folder), so that an agent `task new` starts there is not
|
|
8
|
+
# left waiting on the question. It never answers for a repo.
|
|
9
|
+
#
|
|
10
|
+
# The file is Claude Code's. It holds much more than this, and every running
|
|
11
|
+
# session rewrites it. So this is the only place that writes it, it changes one
|
|
12
|
+
# value, and what it cannot do cleanly it leaves undone and says so.
|
|
13
|
+
|
|
14
|
+
# The jq test for "this folder is trusted". $d is the folder.
|
|
15
|
+
TRUST_TEST='.projects[$d].hasTrustDialogAccepted == true'
|
|
16
|
+
|
|
17
|
+
# Whether a state file ($2) says a folder ($1) is trusted. The answer is read
|
|
18
|
+
# from what jq prints, never from its exit code: jq 1.6 exits zero for an
|
|
19
|
+
# empty file even with -e. One "true" and nothing else is a yes, so a file
|
|
20
|
+
# holding two values where there should be one is a no as well.
|
|
21
|
+
trust_recorded() { [ "$(jq --arg d "$1" "$TRUST_TEST" "$2" 2>/dev/null)" = true ]; }
|
|
22
|
+
|
|
23
|
+
# "may ask": not every case below can tell whether the folder is trusted.
|
|
24
|
+
trust_note() { say " note Claude Code may ask to trust $1: $2"; }
|
|
25
|
+
|
|
26
|
+
# Record a folder as trusted. The folder is a real path, as project_dir prints
|
|
27
|
+
# it, because that is what Claude Code looks up. Always returns 0: a project or
|
|
28
|
+
# a task is never held up by this, so every command here that can fail is
|
|
29
|
+
# guarded.
|
|
30
|
+
trust_folder() {
|
|
31
|
+
local dir=$1 file=$CLAUDE_STATE lock tmp tries=0 ok=0
|
|
32
|
+
lock=$file.lock
|
|
33
|
+
tmp=$file.entourage.$$
|
|
34
|
+
if [ ! -e "$file" ] && [ ! -L "$file" ]; then trust_note "$dir" "there is no $file yet"; return 0; fi
|
|
35
|
+
if ! command -v jq >/dev/null 2>&1; then trust_note "$dir" "jq is not installed"; return 0; fi
|
|
36
|
+
# Reading is harmless, through a link too, so this comes before anything
|
|
37
|
+
# that refuses to write.
|
|
38
|
+
if trust_recorded "$dir" "$file"; then return 0; fi
|
|
39
|
+
# Replacing a link with a plain file would break whatever keeps the real
|
|
40
|
+
# file somewhere else.
|
|
41
|
+
if [ -L "$file" ]; then trust_note "$dir" "$file is a link, so it was left alone"; return 0; fi
|
|
42
|
+
|
|
43
|
+
# Claude Code's own lock: a folder beside the file, held while it writes. It
|
|
44
|
+
# clears a lock that nobody refreshes, so a run killed in here does no
|
|
45
|
+
# lasting harm. A lock someone else holds is waited for, never removed.
|
|
46
|
+
until mkdir "$lock" 2>/dev/null; do
|
|
47
|
+
tries=$((tries + 1))
|
|
48
|
+
if [ "$tries" -ge 10 ]; then trust_note "$dir" "$file is in use, so it was left alone"; return 0; fi
|
|
49
|
+
sleep 0.1 || true
|
|
50
|
+
done
|
|
51
|
+
# The new file is made for its owner's eyes only, as Claude Code makes it.
|
|
52
|
+
# It is checked before it replaces the old one: jq prints nothing for an
|
|
53
|
+
# empty file and still exits zero.
|
|
54
|
+
if (umask 077 && jq --arg d "$dir" \
|
|
55
|
+
'if type == "object" then .projects[$d].hasTrustDialogAccepted = true else error("not an object") end' \
|
|
56
|
+
"$file" > "$tmp") 2>/dev/null &&
|
|
57
|
+
trust_recorded "$dir" "$tmp" &&
|
|
58
|
+
mv -f "$tmp" "$file" 2>/dev/null; then
|
|
59
|
+
ok=1
|
|
60
|
+
fi
|
|
61
|
+
rm -f "$tmp" 2>/dev/null || true
|
|
62
|
+
rmdir "$lock" 2>/dev/null || true
|
|
63
|
+
|
|
64
|
+
if [ "$ok" = 1 ]; then
|
|
65
|
+
say " trusted $dir (Claude Code will not ask to trust it)"
|
|
66
|
+
else
|
|
67
|
+
trust_note "$dir" "$file could not be updated, so it was left alone"
|
|
68
|
+
fi
|
|
69
|
+
return 0
|
|
70
|
+
}
|
package/herdr/README.md
CHANGED
|
@@ -9,9 +9,10 @@ layouts (whole-window arrangements of mods).
|
|
|
9
9
|
|---|---|
|
|
10
10
|
| `mods/cpu/` | Live CPU usage with a scrolling history. macOS only (reads `/usr/bin/top`). |
|
|
11
11
|
| `mods/layout-switch/` | A dropdown that shows the current layout and switches to another. |
|
|
12
|
-
| `mods/projects/` | Every project in your config, open or not. Click one to show its space. |
|
|
12
|
+
| `mods/projects/` | Every project in your config, open or not. Click one to show its space; `+` makes a new one. |
|
|
13
|
+
| `mods/steps/` | The steps of the card whose tab is selected: what each did, how long it took, and how long it waited on you. |
|
|
13
14
|
| `layouts/default.json` | Herdr's own layout, plus the layout dropdown. |
|
|
14
|
-
| `layouts/test.json` | `default` with the projects list in place of spaces, plus the CPU mod in the sidebar. |
|
|
15
|
+
| `layouts/test.json` | `default` with the projects list in place of spaces, plus the Steps panel and the CPU mod in the sidebar. |
|
|
15
16
|
| `projects/template/` | The starting `PROJECT.md` for every new project. |
|
|
16
17
|
|
|
17
18
|
The skills are in [../skills/](../skills/), outside this folder. They are
|
|
@@ -99,7 +100,14 @@ template is in this repo. Your own projects are in
|
|
|
99
100
|
|
|
100
101
|
- **Make one:** `entourage project new <name>`, then
|
|
101
102
|
`entourage project add <name> <path>` for each repo. The repo must already
|
|
102
|
-
be cloned on this machine.
|
|
103
|
+
be cloned on this machine. Paths after the name add those repos as the
|
|
104
|
+
project is made: `entourage project new <name> <path>...`. Every one is
|
|
105
|
+
checked first, and a path that is not a repo stops it with nothing made.
|
|
106
|
+
- **Make one in Herdr:** click the `+` above the projects list (on the `test`
|
|
107
|
+
layout) and choose a repo's folder. A dialog suggests a name from the
|
|
108
|
+
folder, lists the repo, and can add more. Create makes the project with
|
|
109
|
+
`entourage project new` and shows its space; whatever the command refuses
|
|
110
|
+
(a name in use, a folder that is not a repo) is shown in the dialog.
|
|
103
111
|
- **Open it:** `entourage project open <name>` rebuilds the links and shows
|
|
104
112
|
the project's space, making it if it is not open. The space's folder is the
|
|
105
113
|
project folder.
|
|
@@ -115,8 +123,9 @@ template is in this repo. Your own projects are in
|
|
|
115
123
|
|
|
116
124
|
## Tasks
|
|
117
125
|
|
|
118
|
-
A task is one piece of work in a project, usually a Linear card.
|
|
119
|
-
commands,
|
|
126
|
+
A task is one piece of work in a project, usually a Linear card. You run two
|
|
127
|
+
commands, in this order: `task new`, then `task start`. Two more, `task
|
|
128
|
+
handoff` and `task log`, record and show how each step of the write-up ended.
|
|
120
129
|
|
|
121
130
|
### Writing the card up
|
|
122
131
|
|
|
@@ -128,6 +137,14 @@ entourage task new <project> <card>
|
|
|
128
137
|
- **It opens a tab named after the card** in the project's space, in the
|
|
129
138
|
project folder, and starts an agent in it. The agent is `claude`;
|
|
130
139
|
`ENTOURAGE_AGENT` picks another command.
|
|
140
|
+
- **The project folder is trusted first.** Claude Code asks "do you trust this
|
|
141
|
+
folder?" the first time it starts somewhere, which would leave the agent
|
|
142
|
+
waiting. So `project new`, and `task new` before it opens the tab, mark the
|
|
143
|
+
project's folder as trusted in Claude Code's own file (`~/.claude.json`).
|
|
144
|
+
Only a project folder entourage made is marked: never a repo, and not a
|
|
145
|
+
project folder you linked in from somewhere else. Where it cannot be done
|
|
146
|
+
(no `jq`, or Claude Code has never run on the machine), entourage says so
|
|
147
|
+
and Claude Code asks once.
|
|
131
148
|
- **The agent's first message** is [prompts/task-new.md](../prompts/task-new.md)
|
|
132
149
|
with the card and project filled in. It tells the agent to start with
|
|
133
150
|
`sdlc-define` and follow each skill's handoff block to the next
|
|
@@ -140,6 +157,55 @@ entourage task new <project> <card>
|
|
|
140
157
|
`~/.claude/skills` stops it before anything is opened. Run
|
|
141
158
|
`entourage update` to link the skills.
|
|
142
159
|
|
|
160
|
+
### Hand-offs
|
|
161
|
+
|
|
162
|
+
Each step of a write-up ends by handing off: which step it was, how it ended
|
|
163
|
+
(`done`, `needs-human` or `failed`) and what comes next. The agent records
|
|
164
|
+
that itself, with the block on stdin:
|
|
165
|
+
|
|
166
|
+
```sh
|
|
167
|
+
entourage task handoff <project> <card> <<'EOF'
|
|
168
|
+
phase: define
|
|
169
|
+
status: done
|
|
170
|
+
next: plan
|
|
171
|
+
summary: Set the type to fix. The Specification has six Done when items.
|
|
172
|
+
EOF
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
```sh
|
|
176
|
+
entourage task log <project> <card>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
- **The command holds the rules.** It refuses a block with a missing line, an
|
|
180
|
+
unknown status or step, a line that doesn't belong to that status, or a
|
|
181
|
+
value that runs onto a second line, and says what to fix. Run it with no
|
|
182
|
+
block to see the rules.
|
|
183
|
+
- **It is a command because wording wasn't enough.** An agent going from one
|
|
184
|
+
skill straight into the next writes nothing in between, but it does run
|
|
185
|
+
commands.
|
|
186
|
+
- **`task new` records the start,** so the time each step took can be read
|
|
187
|
+
from the hand-offs alone.
|
|
188
|
+
- **It records your answers too.** When you reply to a question, the agent
|
|
189
|
+
records a hand-off with `status: answered` and what you said in a few
|
|
190
|
+
words. `task log` shows how long each step took, and the time a question
|
|
191
|
+
waited on you as a line of its own, counted in no step. A question with no
|
|
192
|
+
answer yet shows how long it has been waiting. A step that followed a
|
|
193
|
+
question with no recorded answer is marked as including the wait.
|
|
194
|
+
- **They are kept in `~/.config/entourage/entourage.db`,** a SQLite file
|
|
195
|
+
beside your projects, on this machine only. It needs `sqlite3`, which macOS
|
|
196
|
+
ships; `ENTOURAGE_SQLITE` picks another command. Without it `task new`
|
|
197
|
+
still starts the agent, the hand-offs are not recorded, and
|
|
198
|
+
`entourage status` says so.
|
|
199
|
+
- **The card stays in Linear.** The store records how a step ended, not what
|
|
200
|
+
was written.
|
|
201
|
+
- **The Steps panel shows it in Herdr.** Select a card's tab, the one `task
|
|
202
|
+
new` opened, and the panel lists that card's steps: the time of day, what
|
|
203
|
+
the step did, how long it took, and its summary. A wait on you stands out,
|
|
204
|
+
and so does a question still waiting. It shows the latest run of a card
|
|
205
|
+
written up more than once. The panel draws what
|
|
206
|
+
`entourage task log <project> <card> --json` prints and works nothing out
|
|
207
|
+
itself, so the two always agree.
|
|
208
|
+
|
|
143
209
|
### Starting the work
|
|
144
210
|
|
|
145
211
|
One branch, checked out as a git worktree of the repos the task needs, and
|
package/herdr/layouts/test.json
CHANGED
|
@@ -2,9 +2,17 @@
|
|
|
2
2
|
// project while its space has a tab, so the list comes from the entourage
|
|
3
3
|
// command, which owns where projects live and what counts as one. Click a
|
|
4
4
|
// project to show its space; one with no space is opened by the command.
|
|
5
|
+
//
|
|
6
|
+
// One mod, two faces: the list a layout places, and the New project dialog
|
|
7
|
+
// (the same mod again, with props { create: true }). The + above the list
|
|
8
|
+
// asks for a repo's folder with the system's picker, then opens the dialog on
|
|
9
|
+
// it. The dialog makes the project with the command too.
|
|
5
10
|
import { View, div } from "gpui-kit";
|
|
6
|
-
import { v_flex, h_flex } from "gpui-base";
|
|
7
|
-
import {
|
|
11
|
+
import { v_flex, h_flex, InputState, Input } from "gpui-base";
|
|
12
|
+
import {
|
|
13
|
+
exec, spaces, run, notify, theme, layout, window, checking, appHome, home, props,
|
|
14
|
+
pickFolder, openOverlay, closeOverlay, nextCommand,
|
|
15
|
+
} from "herdr";
|
|
8
16
|
|
|
9
17
|
const REFRESH_MS = 15000; // projects change rarely; the open marks are live anyway
|
|
10
18
|
const TIMEOUT_MS = 10000;
|
|
@@ -12,7 +20,7 @@ const ROW = 30;
|
|
|
12
20
|
const RAIL_CELL = 32;
|
|
13
21
|
// How this mod's own link into the repo that ships it ends.
|
|
14
22
|
const LINKED_AT = "/herdr/mods/projects";
|
|
15
|
-
const EMPTY = "No projects yet. Make one with
|
|
23
|
+
const EMPTY = "No projects yet. Make one with the + above.";
|
|
16
24
|
const OLD_CLI = "This entourage cannot list projects as JSON. Run: entourage update";
|
|
17
25
|
|
|
18
26
|
function find(node, id) {
|
|
@@ -41,6 +49,14 @@ function parse(text) {
|
|
|
41
49
|
// What a failed command said, without the name it starts its errors with.
|
|
42
50
|
const said = (r) => (r.stderr || r.stdout).trim().replace(/^entourage: /, "");
|
|
43
51
|
|
|
52
|
+
// A picked folder without the slash a picker may end it with.
|
|
53
|
+
const tidy = (path) => (path.length > 1 ? path.replace(/\/+$/, "") : path);
|
|
54
|
+
const base = (path) => path.split("/").pop();
|
|
55
|
+
const tilde = (path) => (path.startsWith(`${home()}/`) ? `~${path.slice(home().length)}` : path);
|
|
56
|
+
// A name to start the dialog with, from the first repo's folder. Only a
|
|
57
|
+
// suggestion: the command decides what a project may be called.
|
|
58
|
+
const suggest = (text) => text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
59
|
+
|
|
44
60
|
export default class Projects extends View {
|
|
45
61
|
init(_props, cx) {
|
|
46
62
|
this.projects = null; // null until the first listing answers
|
|
@@ -48,11 +64,43 @@ export default class Projects extends View {
|
|
|
48
64
|
this.busy = false;
|
|
49
65
|
this.opening = null; // the project a click is making a space for
|
|
50
66
|
this.cmd = "entourage"; // the one on PATH, until that cannot start
|
|
67
|
+
this.picking = false; // the system's folder picker is up
|
|
68
|
+
if (props()?.create) return this.initForm(cx);
|
|
51
69
|
if (checking()) return;
|
|
52
70
|
cx.timer.every(REFRESH_MS, (cx) => this.refresh(cx));
|
|
71
|
+
// The dialog says when it has made a project, so its row need not wait
|
|
72
|
+
// for the timer.
|
|
73
|
+
cx.spawn(async (cx) => {
|
|
74
|
+
for (;;) {
|
|
75
|
+
if ((await nextCommand()) === "refresh") this.refresh(cx);
|
|
76
|
+
cx.notify();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
53
79
|
this.refresh(cx);
|
|
54
80
|
}
|
|
55
81
|
|
|
82
|
+
// The dialog. props: { create: true, folder: the first repo, cmd: the
|
|
83
|
+
// entourage command the list found, overlay }.
|
|
84
|
+
initForm(cx) {
|
|
85
|
+
const p = props() ?? {};
|
|
86
|
+
if (p.cmd) this.cmd = p.cmd;
|
|
87
|
+
this.repos = p.folder ? [tidy(p.folder)] : [];
|
|
88
|
+
this.name = suggest(base(this.repos[0] ?? ""));
|
|
89
|
+
this.error = "";
|
|
90
|
+
this.working = false;
|
|
91
|
+
this.input = InputState.new({ value: this.name, placeholder: "my-project" });
|
|
92
|
+
if (this.name) this.input.set_selected_range({ start: 0, end: this.name.length });
|
|
93
|
+
this.input.on("change", (_e, cx) => { this.name = this.input.value(); this.error = ""; cx.notify(); });
|
|
94
|
+
this.input.on("submit", (_e, cx) => this.submit(cx));
|
|
95
|
+
this.inputFocused = true;
|
|
96
|
+
this.input.on("focus", (_e, cx) => { this.inputFocused = true; cx.notify(); });
|
|
97
|
+
this.input.on("blur", (_e, cx) => { this.inputFocused = false; cx.notify(); });
|
|
98
|
+
this.handle = cx.focus_handle();
|
|
99
|
+
// Twice, as Herdr's own prompt does: the first lands before the dialog shows.
|
|
100
|
+
this.input.focus();
|
|
101
|
+
cx.timer.after(600, () => this.input.focus());
|
|
102
|
+
}
|
|
103
|
+
|
|
56
104
|
// Runs the entourage command. With `fallback`, a command that cannot run is
|
|
57
105
|
// tried again as the copy this mod is linked from (Herdr may have been
|
|
58
106
|
// started without the user's PATH). Only the listing asks for that: it is
|
|
@@ -115,6 +163,28 @@ export default class Projects extends View {
|
|
|
115
163
|
});
|
|
116
164
|
}
|
|
117
165
|
|
|
166
|
+
// The + above the list: choose the first repo, then name the project.
|
|
167
|
+
create(cx) {
|
|
168
|
+
if (this.picking) return;
|
|
169
|
+
this.picking = true;
|
|
170
|
+
cx.spawn(async (cx) => {
|
|
171
|
+
let folder = null;
|
|
172
|
+
try {
|
|
173
|
+
folder = await pickFolder({ prompt: "Choose" });
|
|
174
|
+
} catch (e) {
|
|
175
|
+
notify({ title: "Could not open the folder picker", body: String(e?.message ?? e), level: "error" });
|
|
176
|
+
}
|
|
177
|
+
this.picking = false;
|
|
178
|
+
if (folder) {
|
|
179
|
+
openOverlay({
|
|
180
|
+
mod: "projects", kind: "dialog", modal: true, width: 480,
|
|
181
|
+
props: { create: true, folder, cmd: this.cmd },
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
cx.notify();
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
118
188
|
row(p, space, t) {
|
|
119
189
|
const on = Boolean(space?.active);
|
|
120
190
|
const n = (p.repos ?? []).length;
|
|
@@ -143,6 +213,10 @@ export default class Projects extends View {
|
|
|
143
213
|
}
|
|
144
214
|
|
|
145
215
|
render() {
|
|
216
|
+
return props()?.create ? this.form() : this.list();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
list() {
|
|
146
220
|
const t = theme();
|
|
147
221
|
const collapsed = narrow();
|
|
148
222
|
// A project is open when a space on this computer has its folder.
|
|
@@ -159,9 +233,125 @@ export default class Projects extends View {
|
|
|
159
233
|
items.push(collapsed ? this.compact(p, space, t) : this.row(p, space, t));
|
|
160
234
|
}
|
|
161
235
|
return v_flex().size_full().min_h(0).bg(t.chrome).text_size(13)
|
|
162
|
-
.child(h_flex().h(31).flex_none().pl(16).pr(10).items_center().
|
|
163
|
-
.
|
|
236
|
+
.child(h_flex().h(31).flex_none().pl(16).pr(10).items_center().justify_between()
|
|
237
|
+
.text_size(11.5).text_color(t.dim)
|
|
238
|
+
.when(collapsed, (el) => el.pl(0).pr(0).justify_center())
|
|
239
|
+
.when(!collapsed, (el) => el.child("Projects"))
|
|
240
|
+
.child(div().id("project-new").size(26).flex_none().flex().items_center().justify_center()
|
|
241
|
+
.rounded(6).text_size(15).tooltip("New project")
|
|
242
|
+
.hover((s) => s.bg(t.hover).text_color(t.foreground))
|
|
243
|
+
.on_click((_e, cx) => this.create(cx))
|
|
244
|
+
.child("+")))
|
|
164
245
|
.child(v_flex().id("project-list").flex_1().min_h(0).px(collapsed ? 0 : 8).pb(14)
|
|
165
246
|
.overflow_y_scrollbar().mode("always").children(items));
|
|
166
247
|
}
|
|
248
|
+
|
|
249
|
+
// --- the New project dialog ----------------------------------------------
|
|
250
|
+
|
|
251
|
+
close() {
|
|
252
|
+
closeOverlay(props().overlay);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Another repo for the project, from the system's picker.
|
|
256
|
+
addRepo(cx) {
|
|
257
|
+
if (this.picking || this.working) return;
|
|
258
|
+
this.picking = true;
|
|
259
|
+
cx.spawn(async (cx) => {
|
|
260
|
+
try {
|
|
261
|
+
const folder = await pickFolder({ prompt: "Add" });
|
|
262
|
+
if (folder && !this.repos.includes(tidy(folder))) this.repos.push(tidy(folder));
|
|
263
|
+
this.error = "";
|
|
264
|
+
} catch (e) {
|
|
265
|
+
this.error = `Could not open the folder picker: ${e?.message ?? e}`;
|
|
266
|
+
}
|
|
267
|
+
this.picking = false;
|
|
268
|
+
this.input.focus();
|
|
269
|
+
cx.notify();
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Makes the project and shows its space. The command checks the name and
|
|
274
|
+
// every repo before it makes anything, so what it refuses is shown here and
|
|
275
|
+
// the dialog stays open to be put right.
|
|
276
|
+
submit(cx) {
|
|
277
|
+
if (this.working) return;
|
|
278
|
+
const name = this.name.trim();
|
|
279
|
+
this.working = true;
|
|
280
|
+
this.error = "";
|
|
281
|
+
cx.notify();
|
|
282
|
+
cx.spawn(async (cx) => {
|
|
283
|
+
let failed = null;
|
|
284
|
+
try {
|
|
285
|
+
const r = await this.entourage(["project", "new", name, ...this.repos]);
|
|
286
|
+
if (r.code !== 0) failed = said(r) || "entourage project new failed";
|
|
287
|
+
} catch (e) {
|
|
288
|
+
failed = `Could not run entourage: ${e?.message ?? e}`;
|
|
289
|
+
}
|
|
290
|
+
if (failed !== null) {
|
|
291
|
+
this.working = false;
|
|
292
|
+
this.error = failed;
|
|
293
|
+
cx.notify();
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
// Tell the list. With no list showing there is nobody to tell, and that
|
|
297
|
+
// must not stop the space from opening.
|
|
298
|
+
try { run("projects.refresh"); } catch {}
|
|
299
|
+
// The project is made, so a space that will not open is not this
|
|
300
|
+
// dialog's to keep asking about: say so and leave it in the list.
|
|
301
|
+
let unopened = null;
|
|
302
|
+
try {
|
|
303
|
+
const r = await this.entourage(["project", "open", name]);
|
|
304
|
+
if (r.code !== 0) unopened = said(r);
|
|
305
|
+
} catch (e) {
|
|
306
|
+
unopened = String(e?.message ?? e);
|
|
307
|
+
}
|
|
308
|
+
if (unopened !== null) notify({ title: `Made ${name}, but could not open it`, body: unopened, level: "error" });
|
|
309
|
+
this.close();
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
form() {
|
|
314
|
+
const t = theme();
|
|
315
|
+
const label = (text) => div().pt(16).pb(7).text_size(11.5).text_color(t.dim).child(text);
|
|
316
|
+
const button = (id, text, primary, action) =>
|
|
317
|
+
h_flex().id(id).h(32).px(14).items_center().rounded(8)
|
|
318
|
+
.border_1().border_color(primary ? t.solid : t.input).bg(primary ? t.solid : t.raised)
|
|
319
|
+
.text_color(primary ? t.solid_foreground : t.foreground).text_size(12.5).font_medium()
|
|
320
|
+
.cursor_pointer().hover((s) => s.opacity(0.88)).on_click(action).child(text);
|
|
321
|
+
const repo = (path, i) =>
|
|
322
|
+
h_flex().h(ROW).flex_none().pl(10).pr(4).gap(10).items_center().rounded(8).bg(t.raised)
|
|
323
|
+
.child(div().flex_none().max_w(180).truncate().child(base(path)))
|
|
324
|
+
.child(div().flex_1().min_w(0).truncate().text_size(11.5).text_color(t.dim).child(tilde(path)))
|
|
325
|
+
.child(div().id(`project-new-drop-${i}`).size(22).flex_none().flex().items_center().justify_center()
|
|
326
|
+
.rounded(6).text_color(t.dim).tooltip("Leave this repo out")
|
|
327
|
+
.hover((s) => s.bg(t.hover).text_color(t.foreground))
|
|
328
|
+
.on_click((_e, cx) => { this.repos.splice(i, 1); this.error = ""; cx.notify(); })
|
|
329
|
+
.child("×"));
|
|
330
|
+
return v_flex().id("project-new-form").track_focus(this.handle)
|
|
331
|
+
.on_key_down((e, cx) => { if (e.key === "escape") { this.close(); cx.stop_propagation(); } })
|
|
332
|
+
.w_full().min_h(0).p(18).bg(t.popover).text_color(t.foreground).text_size(13)
|
|
333
|
+
.child(h_flex().items_center()
|
|
334
|
+
.child(div().flex_1().text_size(15).font_semibold().child("New project"))
|
|
335
|
+
.child(div().text_size(11).text_color(t.dim).child("Esc")))
|
|
336
|
+
.child(div().pt(6).text_size(12.8).text_color(t.muted)
|
|
337
|
+
.child("A project groups the repos that belong together and opens as one space."))
|
|
338
|
+
.child(label("Name"))
|
|
339
|
+
.child(Input.new(this.input).h(36).px(10).rounded(9).border_1()
|
|
340
|
+
.border_color(this.inputFocused ? t.accent : t.input).bg(t.background)
|
|
341
|
+
.text_size(12.8).text_color(t.foreground))
|
|
342
|
+
.child(label("Repos"))
|
|
343
|
+
.child(v_flex().id("project-new-repos").max_h(200).min_h(0).flex_shrink(1).gap(4)
|
|
344
|
+
.overflow_y_scroll().children(this.repos.map(repo)))
|
|
345
|
+
.child(h_flex().id("project-new-add").h(ROW).flex_none().mt(this.repos.length ? 4 : 0).px(10)
|
|
346
|
+
.items_center().rounded(8).text_color(t.muted).cursor_pointer()
|
|
347
|
+
.hover((s) => s.bg(t.hover).text_color(t.foreground))
|
|
348
|
+
.on_click((_e, cx) => this.addRepo(cx))
|
|
349
|
+
.child(this.repos.length ? "+ Add another repo…" : "+ Add a repo…"))
|
|
350
|
+
.when(Boolean(this.error), (el) =>
|
|
351
|
+
el.child(div().pt(12).text_size(12).text_color(t.blocked).child(this.error)))
|
|
352
|
+
.child(h_flex().pt(20).gap(8).justify_end()
|
|
353
|
+
.child(button("project-new-cancel", "Cancel", false, () => this.close()))
|
|
354
|
+
.child(button("project-new-create", this.working ? "Creating…" : "Create", true,
|
|
355
|
+
(_e, cx) => this.submit(cx))));
|
|
356
|
+
}
|
|
167
357
|
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// The steps of the card whose tab is selected: what each step of its write-up
|
|
2
|
+
// did, how long it took, and how long it waited on the human.
|
|
3
|
+
//
|
|
4
|
+
// All of that is worked out by `entourage task log <project> <card> --json`.
|
|
5
|
+
// This mod draws the view that command returns and holds no rules about
|
|
6
|
+
// hand-offs: every label and every length of time arrives as text.
|
|
7
|
+
import { View, div } from "gpui-kit";
|
|
8
|
+
import { v_flex, h_flex } from "gpui-base";
|
|
9
|
+
import { exec, spaces, theme, layout, window, checking, appHome } from "herdr";
|
|
10
|
+
|
|
11
|
+
const LOOK_MS = 2000; // how often to see whether another card is selected
|
|
12
|
+
const REREAD_MS = 6000; // how often to read the selected card's steps again
|
|
13
|
+
const PROJECTS_MS = 60000; // projects change rarely
|
|
14
|
+
const TIMEOUT_MS = 10000;
|
|
15
|
+
// How this mod's own link into the repo that ships it ends.
|
|
16
|
+
const LINKED_AT = "/herdr/mods/steps";
|
|
17
|
+
// A tab is a card's when it is named as `entourage task new` names it.
|
|
18
|
+
const CARD = /^[A-Za-z][A-Za-z0-9]*-[0-9]+$/;
|
|
19
|
+
const OLD_CLI = "This entourage cannot give a card's steps as JSON. Run: entourage update";
|
|
20
|
+
// A time longer than this goes on a line of its own.
|
|
21
|
+
const SHORT = 14;
|
|
22
|
+
|
|
23
|
+
// `herdr-app check` draws the mod once, with no card selected, which would
|
|
24
|
+
// show one line of text and none of the rows. It is given these to draw, so a
|
|
25
|
+
// mistake in a row fails the check.
|
|
26
|
+
const SAMPLE = {
|
|
27
|
+
run: 1,
|
|
28
|
+
steps: [
|
|
29
|
+
{ run: 1, clock: "10:00", kind: "start", label: "started", took: "" },
|
|
30
|
+
{ run: 1, clock: "10:00", kind: "step", label: "define done", took: "50s", summary: "A summary.", flags: "A flag." },
|
|
31
|
+
{ run: 1, clock: "10:09", kind: "wait", label: "answered", took: "waited 7m 04s", answer: "approve" },
|
|
32
|
+
{ run: 1, clock: "10:17", kind: "step", label: "plan done", took: "7m 24s, includes waiting on the human" },
|
|
33
|
+
{ run: 1, clock: "10:17", kind: "step", label: "breakdown asked a question", took: "5s", question: "Approve?", waiting: "waiting on the human for 2m 05s" },
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
function find(node, id) {
|
|
38
|
+
if (node?.id === id) return node;
|
|
39
|
+
for (const child of node?.children ?? []) {
|
|
40
|
+
const found = find(child, id);
|
|
41
|
+
if (found) return found;
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// The sidebar's rail goes by its width, as in Herdr's own lists.
|
|
47
|
+
const narrow = () => (find(layout(), "sidebar")?.size?.px ?? Infinity) < 160;
|
|
48
|
+
|
|
49
|
+
function parse(text) {
|
|
50
|
+
try {
|
|
51
|
+
return JSON.parse(text);
|
|
52
|
+
} catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// What a failed command said, without the name it starts its errors with.
|
|
58
|
+
const said = (r) => (r.stderr || r.stdout).trim().replace(/^entourage: /, "");
|
|
59
|
+
|
|
60
|
+
// What is selected on this computer: the shown space's folder, and the card
|
|
61
|
+
// its shown tab is for, if it is a card's tab.
|
|
62
|
+
function selected() {
|
|
63
|
+
const space = spaces().find((s) => s.active && !s.machine) ?? null;
|
|
64
|
+
const tab = space?.tabs.find((t) => t.active) ?? null;
|
|
65
|
+
const card = tab && CARD.test(tab.name) ? tab.name.toUpperCase() : null;
|
|
66
|
+
return { folder: space?.folder ?? null, card, key: `${space?.folder ?? ""}\n${card ?? ""}` };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default class Steps extends View {
|
|
70
|
+
init(_props, cx) {
|
|
71
|
+
this.cmd = "entourage"; // the one on PATH, until that cannot start
|
|
72
|
+
this.projects = null; // the last listing of projects
|
|
73
|
+
this.projectsAt = 0;
|
|
74
|
+
this.key = null; // what the view on hand was read for
|
|
75
|
+
this.project = null; // the entourage project of the shown space, or null
|
|
76
|
+
this.view = null;
|
|
77
|
+
this.error = null;
|
|
78
|
+
this.busy = false;
|
|
79
|
+
this.readAt = 0;
|
|
80
|
+
if (checking()) return;
|
|
81
|
+
cx.timer.every(LOOK_MS, (cx) => this.look(cx));
|
|
82
|
+
this.look(cx);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Runs the entourage command. One that cannot run is tried again as the
|
|
86
|
+
// copy this mod is linked from: Herdr may have been started without the
|
|
87
|
+
// user's PATH. Everything this mod runs only reads, so twice is safe.
|
|
88
|
+
async entourage(args) {
|
|
89
|
+
try {
|
|
90
|
+
return await exec(this.cmd, args, { timeout: TIMEOUT_MS });
|
|
91
|
+
} catch (e) {
|
|
92
|
+
if (this.cmd !== "entourage") throw e;
|
|
93
|
+
const link = await exec("readlink", [`${appHome()}/mods/steps`]);
|
|
94
|
+
const at = link.stdout.trim();
|
|
95
|
+
if (link.code !== 0 || !at.endsWith(LINKED_AT)) throw e;
|
|
96
|
+
this.cmd = `${at.slice(0, -LINKED_AT.length)}/cli/entourage`;
|
|
97
|
+
return exec(this.cmd, args, { timeout: TIMEOUT_MS });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Read again when another card is selected, or the one on hand is stale.
|
|
102
|
+
look(cx) {
|
|
103
|
+
if (this.busy || window()?.visible === false) return;
|
|
104
|
+
const now = selected();
|
|
105
|
+
if (now.key === this.key && Date.now() - this.readAt < REREAD_MS) return;
|
|
106
|
+
this.busy = true;
|
|
107
|
+
cx.spawn(async (cx) => {
|
|
108
|
+
let project = null;
|
|
109
|
+
let view = null;
|
|
110
|
+
let error = null;
|
|
111
|
+
try {
|
|
112
|
+
if (!this.projects || Date.now() - this.projectsAt > PROJECTS_MS) {
|
|
113
|
+
const r = await this.entourage(["project", "ls", "--json"]);
|
|
114
|
+
const list = r.code === 0 ? parse(r.stdout)?.projects : null;
|
|
115
|
+
if (Array.isArray(list)) {
|
|
116
|
+
this.projects = list;
|
|
117
|
+
this.projectsAt = Date.now();
|
|
118
|
+
} else {
|
|
119
|
+
error = r.code === 0 ? OLD_CLI : said(r) || "entourage project ls failed";
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
project = (this.projects ?? []).find((p) => p.folder === now.folder)?.name ?? null;
|
|
123
|
+
if (!error && project && now.card) {
|
|
124
|
+
const r = await this.entourage(["task", "log", project, now.card, "--json"]);
|
|
125
|
+
const got = r.code === 0 ? parse(r.stdout) : null;
|
|
126
|
+
if (got && Array.isArray(got.steps)) view = got;
|
|
127
|
+
else error = r.code === 0 ? OLD_CLI : said(r) || "entourage task log failed";
|
|
128
|
+
}
|
|
129
|
+
} catch (e) {
|
|
130
|
+
error = `Could not run entourage: ${e?.message ?? e}`;
|
|
131
|
+
}
|
|
132
|
+
this.key = now.key;
|
|
133
|
+
this.project = project;
|
|
134
|
+
this.view = view;
|
|
135
|
+
this.error = error;
|
|
136
|
+
this.readAt = Date.now();
|
|
137
|
+
this.busy = false;
|
|
138
|
+
cx.notify();
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// One hand-off. `s` is a step of the view: its clock, label and took are
|
|
143
|
+
// text to show as they are, and its kind says whether it is a wait.
|
|
144
|
+
row(s, i, t) {
|
|
145
|
+
const wait = s.kind === "wait";
|
|
146
|
+
const start = s.kind === "start";
|
|
147
|
+
const took = s.took ?? "";
|
|
148
|
+
const beside = took.length <= SHORT;
|
|
149
|
+
const detail = s.question ?? s.answer ?? s.reason ?? s.summary ?? null;
|
|
150
|
+
const small = (text, color) =>
|
|
151
|
+
div().pl(46).pr(4).text_size(11.5).text_color(color).whitespace_normal().child(text);
|
|
152
|
+
return v_flex().id(`step-${i}`).flex_none().px(8).py(5).gap(2).rounded(8)
|
|
153
|
+
.child(h_flex().gap(8).items_center()
|
|
154
|
+
.child(div().w(38).flex_none().text_size(11.5).text_color(t.dim).child(s.clock ?? ""))
|
|
155
|
+
.child(div().flex_1().min_w(0).truncate()
|
|
156
|
+
.text_color(wait ? t.blocked : start ? t.muted : t.foreground).child(s.label ?? ""))
|
|
157
|
+
.when(beside && took !== "", (el) =>
|
|
158
|
+
el.child(div().flex_none().text_size(11.5).text_color(wait ? t.blocked : t.dim).child(took))))
|
|
159
|
+
.when(!beside, (el) => el.child(small(took, t.dim)))
|
|
160
|
+
.when(Boolean(detail), (el) => el.child(small(detail, t.muted)))
|
|
161
|
+
.when(Boolean(s.flags), (el) => el.child(small(`Flags: ${s.flags}`, t.dim)))
|
|
162
|
+
.when(Boolean(s.waiting), (el) => el.child(small(s.waiting, t.blocked)));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
render() {
|
|
166
|
+
const t = theme();
|
|
167
|
+
if (narrow()) return v_flex().size_full().bg(t.chrome);
|
|
168
|
+
const sample = checking();
|
|
169
|
+
const now = selected();
|
|
170
|
+
const view = sample ? SAMPLE : this.view;
|
|
171
|
+
const note = (text, color) =>
|
|
172
|
+
div().px(8).py(6).text_size(12).text_color(color).whitespace_normal().child(text);
|
|
173
|
+
const items = [];
|
|
174
|
+
// The latest run only: a card written up twice keeps both in its log.
|
|
175
|
+
const steps = (view?.steps ?? []).filter((s) => s.run === view.run);
|
|
176
|
+
if (sample) steps.forEach((s, i) => items.push(this.row(s, i, t)));
|
|
177
|
+
else if (!now.card) items.push(note("Select a card's tab to see its steps.", t.dim));
|
|
178
|
+
else if (now.key !== this.key) items.push(note("Loading…", t.dim));
|
|
179
|
+
else if (this.error) items.push(note(this.error, t.blocked));
|
|
180
|
+
else if (!this.project) items.push(note("This space is not an entourage project.", t.dim));
|
|
181
|
+
else if (steps.length === 0) items.push(note(`No hand-offs recorded for ${now.card} yet.`, t.dim));
|
|
182
|
+
else steps.forEach((s, i) => items.push(this.row(s, i, t)));
|
|
183
|
+
return v_flex().size_full().min_h(0).bg(t.chrome).text_size(13)
|
|
184
|
+
.child(h_flex().h(31).flex_none().pl(16).pr(14).items_center().justify_between()
|
|
185
|
+
.text_size(11.5).text_color(t.dim)
|
|
186
|
+
.child("Steps")
|
|
187
|
+
.child(div().child(now.card ?? "")))
|
|
188
|
+
.child(v_flex().id("step-list").flex_1().min_h(0).px(8).pb(14)
|
|
189
|
+
.overflow_y_scrollbar().mode("always").children(items));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "place": "none", "title": "Steps" }
|
package/package.json
CHANGED
package/prompts/task-new.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Write up Linear card {card} so that it is ready to build. This session is in the entourage project `{project}`.
|
|
2
2
|
|
|
3
|
-
Start with the sdlc-define skill. Each skill ends by
|
|
3
|
+
Start with the sdlc-define skill. Each skill ends by recording a hand-off with `entourage task handoff {project} {card}`, as the skill describes. Record each one before you start the next skill, even though you carry straight on: the hand-offs are how I see how each step ended. You are driving this run, so act on the `status` you recorded:
|
|
4
4
|
|
|
5
5
|
- `done`: go straight on to the step in `next`, without waiting for me. `plan` is the sdlc-plan skill and `breakdown` is the sdlc-breakdown skill.
|
|
6
|
-
- `needs-human`: wait for my answer, then carry on with the same skill.
|
|
6
|
+
- `needs-human`: wait for my answer. When it comes, record my answer as the skill describes, then carry on with the same skill.
|
|
7
7
|
- `failed`: stop there. Don't start the next skill.
|
|
8
8
|
|
|
9
9
|
If I ask for a change when I'm approving, sdlc-breakdown tells you which skill makes it. When that skill hands off, go back to sdlc-breakdown, not on to `next`.
|