pi-cowboy 0.4.1 → 0.5.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 +9 -1
- package/dist/index.js +14 -2
- package/dist/infrastructure/git/git-runner.js +22 -0
- package/dist/registration.js +17 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -71,7 +71,7 @@ Depending on your concurrency settings, some of the tasks queue. The default glo
|
|
|
71
71
|
|
|
72
72
|
Each agent runs as a separate pi process in its own Herdr workspace. Open a workspace at any time to monitor the agent or to steer it.
|
|
73
73
|
|
|
74
|
-
Three Herdr terms recur below: a **workspace** is the outermost Herdr container and holds tabs, a **tab** holds panes, and a **pane** is one terminal session — the one the agent's pi process runs in. pi-cowboy gives each agent its own workspace and tab, and puts the agent in that tab's root pane
|
|
74
|
+
Three Herdr terms recur below: a **workspace** is the outermost Herdr container and holds tabs, a **tab** holds panes, and a **pane** is one terminal session — the one the agent's pi process runs in. pi-cowboy gives each agent its own workspace and tab, and puts the agent in that tab's root pane — which is why pi-cowboy needs a git repository: outside one there is no worktree to open, so the extension stays inactive for that session. The pane id is the durable handle `cleanup_cowboy_agent` uses to find that pane again.
|
|
75
75
|
|
|
76
76
|
The agents work in separate git worktrees placed under `$HOME/.pi/agent/pi-cowboy/worktrees/`.
|
|
77
77
|
|
|
@@ -120,13 +120,21 @@ If pi-cowboy cannot remove one of them, it reports the failure and completes the
|
|
|
120
120
|
`/cowboy` opens a menu. See [Menu](docs/Menu.md).
|
|
121
121
|
|
|
122
122
|
<code>/cowboy # pi-cowboy menu</code><br>
|
|
123
|
+
|
|
123
124
|
<code>/cowboy status # List spawned, queued, and settled agents</code><br>
|
|
125
|
+
|
|
124
126
|
<code>/cowboy spawn # Spawn an agent manually</code><br>
|
|
127
|
+
|
|
125
128
|
<code>/cowboy worktree # Create a git worktree with no agent attached</code><br>
|
|
129
|
+
|
|
126
130
|
<code>/cowboy model # Model selection for the agents</code><br>
|
|
131
|
+
|
|
127
132
|
<code>/cowboy model provider/model-id # Set the model for this session</code><br>
|
|
133
|
+
|
|
128
134
|
<code>/cowboy model clear # Clear the model set for this session</code><br>
|
|
135
|
+
|
|
129
136
|
<code>/cowboy enable # Enables pi-cowboy</code><br>
|
|
137
|
+
|
|
130
138
|
<code>/cowboy disable. # Disables pi-cowboy</code>
|
|
131
139
|
|
|
132
140
|
## Tools
|
package/dist/index.js
CHANGED
|
@@ -6,10 +6,13 @@
|
|
|
6
6
|
import { setPiInstance, setRuntime, isInsideHerdr, detectSubagentSpawn, } from "./shell.js";
|
|
7
7
|
import { createHerdrRuntime } from "./infrastructure/herdr-host.js";
|
|
8
8
|
import { missingCloneProgramReport } from "./infrastructure/git/cow-clone.js";
|
|
9
|
-
import {
|
|
9
|
+
import { isInsideGitRepository } from "./infrastructure/git-client.js";
|
|
10
|
+
import { registerCowboyCommand, registerTools, registerUnavailableCowboyCommand, } from "./registration.js";
|
|
10
11
|
import { setupEventListeners } from "./events.js";
|
|
11
12
|
import { startCowSupportProbe } from "./cow-support-launch.js";
|
|
12
13
|
import { startHarnessAvailabilityProbe } from "./harness-availability-launch.js";
|
|
14
|
+
/** The one reason the extension is unavailable when the session is not inside a git repository. */
|
|
15
|
+
const NOT_INSIDE_GIT_REPOSITORY = "pi-cowboy needs a git repository: this directory is not inside one, so pi-cowboy stays inactive";
|
|
13
16
|
/**
|
|
14
17
|
* Report a failed prerequisite once the UI exists. The entry point has no
|
|
15
18
|
* context, so the message waits for the session event; the extension stays
|
|
@@ -18,7 +21,7 @@ import { startHarnessAvailabilityProbe } from "./harness-availability-launch.js"
|
|
|
18
21
|
function reportInactive(pi, message) {
|
|
19
22
|
pi.on("session_start", async (_event, ctx) => {
|
|
20
23
|
if (ctx.hasUI) {
|
|
21
|
-
ctx.ui.notify(message, "
|
|
24
|
+
ctx.ui.notify(message, "warning");
|
|
22
25
|
}
|
|
23
26
|
});
|
|
24
27
|
}
|
|
@@ -37,6 +40,15 @@ export default function (pi) {
|
|
|
37
40
|
reportInactive(pi, prereq);
|
|
38
41
|
return;
|
|
39
42
|
}
|
|
43
|
+
// No git repository means nowhere to build an agent's worktree, so the
|
|
44
|
+
// extension stays inactive. `/cowboy` is still registered, in its
|
|
45
|
+
// unavailable mode, so the human reads the reason on the command they would
|
|
46
|
+
// have used.
|
|
47
|
+
if (!isInsideGitRepository(process.cwd())) {
|
|
48
|
+
reportInactive(pi, NOT_INSIDE_GIT_REPOSITORY);
|
|
49
|
+
registerUnavailableCowboyCommand(pi, NOT_INSIDE_GIT_REPOSITORY);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
40
52
|
setPiInstance(pi);
|
|
41
53
|
setRuntime(createHerdrRuntime(pi));
|
|
42
54
|
// Registered once, here: the switch toggles them through the active set.
|
|
@@ -126,6 +126,28 @@ export function locateMainCheckout(commonDirOutput, cwd) {
|
|
|
126
126
|
: path.resolve(cwd, commonDirOutput);
|
|
127
127
|
return { commonDir, mainRoot: path.dirname(commonDir) };
|
|
128
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Whether `cwd` sits inside a git repository, by git's own discovery rule: an
|
|
131
|
+
* ancestor — `cwd` itself included — holds a `.git` entry, a directory in the
|
|
132
|
+
* main checkout or a file whose `gitdir:` points at a linked worktree's real
|
|
133
|
+
* git dir.
|
|
134
|
+
*
|
|
135
|
+
* Reads the filesystem rather than asking git: a git that cannot run — a stray
|
|
136
|
+
* `GIT_DIR`, a broken global config, a checkout whose ownership git refuses —
|
|
137
|
+
* answers nothing, and "git could not say" must never be read as "not a
|
|
138
|
+
* repository".
|
|
139
|
+
*/
|
|
140
|
+
export function isInsideGitRepository(cwd) {
|
|
141
|
+
let dir = path.resolve(cwd);
|
|
142
|
+
for (;;) {
|
|
143
|
+
if (fs.existsSync(path.join(dir, ".git")))
|
|
144
|
+
return true;
|
|
145
|
+
const parent = path.dirname(dir);
|
|
146
|
+
if (parent === dir)
|
|
147
|
+
return false;
|
|
148
|
+
dir = parent;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
129
151
|
/**
|
|
130
152
|
* Main checkout root for any in-repo cwd. Herdr rejects a linked worktree as an
|
|
131
153
|
* adoption source, and the caller may itself sit in one — hence the common-dir
|
package/dist/registration.js
CHANGED
|
@@ -164,10 +164,26 @@ function subagentModelOptions(ctx) {
|
|
|
164
164
|
? scoped.map((s) => `${s.model.provider}/${s.model.id}`)
|
|
165
165
|
: ctx.modelRegistry.getAvailable().map((m) => `${m.provider}/${m.id}`);
|
|
166
166
|
}
|
|
167
|
+
/** The one place the command name is spelled. */
|
|
168
|
+
const COWBOY_COMMAND = "cowboy";
|
|
169
|
+
/**
|
|
170
|
+
* The `/cowboy` command in its unavailable mode: a prerequisite the entry point
|
|
171
|
+
* could not meet means every invocation reports the reason instead of opening a
|
|
172
|
+
* menu. Registered so the human reads the reason on the command they would have
|
|
173
|
+
* used.
|
|
174
|
+
*/
|
|
175
|
+
export function registerUnavailableCowboyCommand(pi, reason) {
|
|
176
|
+
pi.registerCommand(COWBOY_COMMAND, {
|
|
177
|
+
description: reason,
|
|
178
|
+
handler: async (_args, ctx) => {
|
|
179
|
+
ctx.ui.notify(reason, "warning");
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
}
|
|
167
183
|
/** The /cowboy command — the human surface that turns the extension back on. */
|
|
168
184
|
export function registerCowboyCommand(pi) {
|
|
169
185
|
// Named cowboy so it never clashes with other subagent extensions' /agents.
|
|
170
|
-
pi.registerCommand(
|
|
186
|
+
pi.registerCommand(COWBOY_COMMAND, {
|
|
171
187
|
description: "Manage agents: status, spawn, settings. `status` lists spawned, queued and settled agents; `spawn` opens the spawn wizard; `worktree` creates one git worktree with no agent attached to it. `enable`/`disable` load or unload the cowboy tools. Pass `model` (optionally a provider/model-id) to set the model agents use for this session — opens pi's model picker.",
|
|
172
188
|
getArgumentCompletions: async (prefix) => (await import("./ui/menu/model-picker.js")).cowboyCompletions(prefix),
|
|
173
189
|
handler: async (args, ctx) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-cowboy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"packageManager": "pnpm@12.9.1",
|
|
6
6
|
"description": "Agent orchestrator for pi: each subagent runs as its own pi process in a background Herdr pane, isolated by a copy-on-write git worktree.",
|