@ligeti/testing 2.1.1 → 3.0.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 +4 -38
- package/dist/agents.d.ts +0 -1
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +1 -4
- package/dist/agents.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/bin/fake-herdr.mjs +0 -468
- package/dist/herdr.d.ts +0 -9
- package/dist/herdr.d.ts.map +0 -1
- package/dist/herdr.js +0 -16
- package/dist/herdr.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @ligeti/testing
|
|
2
2
|
|
|
3
|
-
Ligeti's test kit: throwaway Postgres databases, a fake `claude`,
|
|
3
|
+
Ligeti's test kit: throwaway Postgres databases, a fake `claude`, fake GitLab,
|
|
4
4
|
GitHub, Bitbucket, Jira and Telegram servers, and helpers that run a workflow package under a real
|
|
5
5
|
`ligeti-worker`. It is a `devDependency` everywhere it appears — no package's runtime code imports
|
|
6
6
|
it. It is published, so a workflow package outside this repository can run its acceptance tests
|
|
@@ -11,7 +11,7 @@ its exports are a public contract.
|
|
|
11
11
|
[ADR-0007](../../adr/0007-test-doubles-are-real-processes.md) decides that every test double in
|
|
12
12
|
this workspace is a real process or a real server the system under test talks to over a real
|
|
13
13
|
process boundary or socket, never a module mock — this package exists to make that possible for
|
|
14
|
-
`claude
|
|
14
|
+
`claude` and the GitLab REST API, the external tools/services whose real, workspace-wide
|
|
15
15
|
fakes it ships. (A step package's own test double for a tool only it drives — e.g.
|
|
16
16
|
`steps/beads/test/fixtures/fake-bd.mjs` — lives in that package instead, per the same ADR.)
|
|
17
17
|
|
|
@@ -20,9 +20,9 @@ fakes it ships. (A step package's own test double for a tool only it drives —
|
|
|
20
20
|
- **`createTestDatabase`** (`src/postgres.ts`) — creates a uniquely named, empty Postgres
|
|
21
21
|
database against an admin connection and returns its URL plus a `drop()` that gives connections
|
|
22
22
|
up to 2s to close on their own, terminates the rest and drops it. One database per test file.
|
|
23
|
-
- **`fakeClaudePath`** / **`fakeOpencodePath`** / **`fakeOpencodeV2Path`**
|
|
23
|
+
- **`fakeClaudePath`** / **`fakeOpencodePath`** / **`fakeOpencodeV2Path`**
|
|
24
24
|
(`src/agents.ts`) — absolute
|
|
25
|
-
paths to the fake `claude
|
|
25
|
+
paths to the fake `claude` and `opencode` (1.x and 2.x) executables shipped in `bin/`, resolved via `import.meta.url` so they work
|
|
26
26
|
from `src/` or `dist/`.
|
|
27
27
|
- `bin/fake-claude.mjs` parses the same CLI flags the real `claude` binary accepts and fires
|
|
28
28
|
real Stop/StopFailure hooks read from `$CLAUDE_CONFIG_DIR/settings.json`, exactly as the real
|
|
@@ -36,9 +36,6 @@ fakes it ships. (A step package's own test double for a tool only it drives —
|
|
|
36
36
|
- `bin/fake-opencode-v2.mjs` is the same for opencode 2.x: `--version` prints
|
|
37
37
|
`opencode v${FAKE_OPENCODE_VERSION:-2.4.1}`, and the final text event echoes the prompt
|
|
38
38
|
after `--`.
|
|
39
|
-
- `bin/fake-herdr.mjs` implements `workspace`/`pane` subcommands as a real subprocess, with its
|
|
40
|
-
`workspaces`/`panes` state persisted to a JSON file (`FAKE_HERDR_STATE`) so separate
|
|
41
|
-
invocations — as real `herdr` calls are — see consistent state.
|
|
42
39
|
- `bin/argv-recorder.mjs` is a generic stand-in binary that records the argv/env it was invoked
|
|
43
40
|
with, for tests asserting what a step actually executed.
|
|
44
41
|
- **A fake Bitbucket server** (`src/bitbucket.ts`) — the same kind of loopback server for
|
|
@@ -120,8 +117,6 @@ describe`. The binary is the one declared by the `@ligeti/sdk` installed next to
|
|
|
120
117
|
request and answers each with a successful `sendMessage` result.
|
|
121
118
|
- **`makeRepo`** / **`git`** (`src/repo.ts`) — a throwaway repository with a bare `origin` and one
|
|
122
119
|
pushed commit, and a `git -C` runner.
|
|
123
|
-
- **`writeHerdrShim`** / **`readHerdrWorktrees`** (`src/herdr.ts`) — a shim that runs the fake
|
|
124
|
-
herdr with a given state and log file, and the worktrees the fake recorded.
|
|
125
120
|
- **`readRecordedTurns`** (`src/recorded-turns.ts`) — every agent turn under a state directory:
|
|
126
121
|
prompt, agent, session id and `--resume` flag, oldest first.
|
|
127
122
|
- **`waitUntil`** (`src/wait.ts`) — polls a condition until it holds, or rejects with
|
|
@@ -193,35 +188,6 @@ environment and a 30 s timeout. A command that exits non-zero (without `allowFai
|
|
|
193
188
|
claude's own message on stderr, before anything else happens. Everything after a literal `--` is the
|
|
194
189
|
prompt in interactive mode, and `-p` is print mode only when it appears before `--`.
|
|
195
190
|
|
|
196
|
-
### `bin/fake-herdr.mjs`
|
|
197
|
-
|
|
198
|
-
`FAKE_HERDR_STATE` (required) is the path of the JSON state file this process reads and writes.
|
|
199
|
-
Each invocation holds a lock, the directory `<FAKE_HERDR_STATE>.lock`, for its whole run so that
|
|
200
|
-
concurrent invocations do not lose updates; it waits up to 30 s for it, and releases it on exit,
|
|
201
|
-
SIGTERM (exit 143) and SIGINT (exit 130).
|
|
202
|
-
|
|
203
|
-
| Variable | Effect |
|
|
204
|
-
| ----------------------- | --------------------------------------------------------------------------------------------- |
|
|
205
|
-
| `FAKE_HERDR_LOG` | Path; appends one JSON line with the argv of every invocation. |
|
|
206
|
-
| `FAKE_HERDR_FAIL_PHASE` | Makes one subcommand always fail with a JSON error on stderr. One of the phases listed below. |
|
|
207
|
-
| `FAKE_HERDR_FAIL_CODE` | The error code `FAKE_HERDR_FAIL_PHASE` reports (default `boom`). |
|
|
208
|
-
|
|
209
|
-
Failure phases: `create`, `tab_create`, `run`, `rename` (`workspace rename` and `tab rename`),
|
|
210
|
-
`close` (`workspace close`, `tab close` and `pane close`), `reclaim` (only a `tab close` of a tab
|
|
211
|
-
still showing herdr's default label), `tab_create_and_close` (both `tab create` and `tab close`),
|
|
212
|
-
`worktree_create` and `worktree_remove`.
|
|
213
|
-
|
|
214
|
-
`pane exit <pane_id>` is not a real herdr command. It models an agent process finishing inside its
|
|
215
|
-
pane: the pane goes idle while the pane, its tab and its label stay as they are.
|
|
216
|
-
|
|
217
|
-
A tab's displayed default label is its live position, so it renumbers after an earlier tab closes.
|
|
218
|
-
`tab focus` is globally exclusive: focusing a tab unfocuses every other tab. `worktree remove`
|
|
219
|
-
prints JSON on success because `@ligeti/agent-runtime`'s `runHerdr` rejects empty stdout.
|
|
220
|
-
|
|
221
|
-
`worktree create/list/remove` run a real `git` for the checkout, so the directory exists on disk
|
|
222
|
-
afterwards. `--branch` is tried as a new branch first, then as an existing one. Closing a tab's last
|
|
223
|
-
pane closes the tab, and closing a workspace's last tab closes the workspace.
|
|
224
|
-
|
|
225
191
|
## Environment variables
|
|
226
192
|
|
|
227
193
|
| Variable | Required | Default | Purpose |
|
package/dist/agents.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export declare function fakeClaudePath(): string;
|
|
2
2
|
export declare function fakeOpencodePath(): string;
|
|
3
3
|
export declare function fakeOpencodeV2Path(): string;
|
|
4
|
-
export declare function fakeHerdrPath(): string;
|
|
5
4
|
export declare function argvRecorderPath(): string;
|
|
6
5
|
//# sourceMappingURL=agents.d.ts.map
|
package/dist/agents.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAUA,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAgB,
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAUA,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC"}
|
package/dist/agents.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ABOUTME: Path resolvers for the fake claude/opencode/
|
|
1
|
+
// ABOUTME: Path resolvers for the fake claude/opencode/argv-recorder executables shipped in bin/,
|
|
2
2
|
// ABOUTME: resolved via import.meta.url so they work whether this module runs from src/ or dist/.
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import path from "node:path";
|
|
@@ -15,9 +15,6 @@ export function fakeOpencodePath() {
|
|
|
15
15
|
export function fakeOpencodeV2Path() {
|
|
16
16
|
return path.join(binDir(), "fake-opencode-v2.mjs");
|
|
17
17
|
}
|
|
18
|
-
export function fakeHerdrPath() {
|
|
19
|
-
return path.join(binDir(), "fake-herdr.mjs");
|
|
20
|
-
}
|
|
21
18
|
export function argvRecorderPath() {
|
|
22
19
|
return path.join(binDir(), "argv-recorder.mjs");
|
|
23
20
|
}
|
package/dist/agents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,kGAAkG;AAClG,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,SAAS,MAAM;IACb,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1D,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,iBAAiB,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,mBAAmB,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,sBAAsB,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,mBAAmB,CAAC,CAAC;AAClD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createTestDatabase, type TestDatabase } from "./postgres.js";
|
|
2
|
-
export { fakeClaudePath, fakeOpencodePath, fakeOpencodeV2Path,
|
|
2
|
+
export { fakeClaudePath, fakeOpencodePath, fakeOpencodeV2Path, argvRecorderPath, } from "./agents.js";
|
|
3
3
|
export { sanitizedEnv } from "./env.js";
|
|
4
4
|
export { copyClaudeProfile, fixtureClaudeProfileDir } from "./claude-profile.js";
|
|
5
5
|
export { startFakeGitLab, type FakeGitLab, type FakeGitLabRequest, type FakeGitLabResponse, type FakeGitLabHandler, } from "./gitlab.js";
|
|
@@ -12,6 +12,5 @@ export { ligetiWorkerBin, startWorker, describeWorkflowPackage, type WorkerProce
|
|
|
12
12
|
export { git, makeRepo } from "./repo.js";
|
|
13
13
|
export { startCallbackServer, type CallbackMessageSender, type CallbackServerOptions, type AttestRequest, } from "./callback-server.js";
|
|
14
14
|
export { startFakeTelegram, type FakeTelegram, type FakeTelegramRequest } from "./telegram.js";
|
|
15
|
-
export { writeHerdrShim, readHerdrWorktrees, type FakeHerdrWorktreeEntry } from "./herdr.js";
|
|
16
15
|
export { readRecordedTurns, type RecordedTurn } from "./recorded-turns.js";
|
|
17
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EACL,eAAe,EACf,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,eAAe,EACf,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,aAAa,EACb,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,2BAA2B,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,GACnC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,eAAe,EACf,WAAW,EACX,uBAAuB,EACvB,KAAK,aAAa,EAClB,KAAK,QAAQ,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,mBAAmB,EACnB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// ABOUTME: Public entry point of @ligeti/testing: the Postgres fixture, the fake executables, fake
|
|
2
2
|
// ABOUTME: HTTP services, the fixture Claude profile and the helpers that run a real ligeti-worker.
|
|
3
3
|
export { createTestDatabase } from "./postgres.js";
|
|
4
|
-
export { fakeClaudePath, fakeOpencodePath, fakeOpencodeV2Path,
|
|
4
|
+
export { fakeClaudePath, fakeOpencodePath, fakeOpencodeV2Path, argvRecorderPath, } from "./agents.js";
|
|
5
5
|
export { sanitizedEnv } from "./env.js";
|
|
6
6
|
export { copyClaudeProfile, fixtureClaudeProfileDir } from "./claude-profile.js";
|
|
7
7
|
export { startFakeGitLab, } from "./gitlab.js";
|
|
@@ -14,6 +14,5 @@ export { ligetiWorkerBin, startWorker, describeWorkflowPackage, } from "./worker
|
|
|
14
14
|
export { git, makeRepo } from "./repo.js";
|
|
15
15
|
export { startCallbackServer, } from "./callback-server.js";
|
|
16
16
|
export { startFakeTelegram } from "./telegram.js";
|
|
17
|
-
export { writeHerdrShim, readHerdrWorktrees } from "./herdr.js";
|
|
18
17
|
export { readRecordedTurns } from "./recorded-turns.js";
|
|
19
18
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,oGAAoG;AACpG,OAAO,EAAE,kBAAkB,EAAqB,MAAM,eAAe,CAAC;AACtE,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,oGAAoG;AACpG,OAAO,EAAE,kBAAkB,EAAqB,MAAM,eAAe,CAAC;AACtE,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EACL,eAAe,GAKhB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,eAAe,GAsBhB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,GAKnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,aAAa,GAKd,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,2BAA2B,GAI5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,eAAe,EACf,WAAW,EACX,uBAAuB,GAGxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,mBAAmB,GAIpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAA+C,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAqB,MAAM,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ligeti/testing",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Ligeti test kit: real-process test doubles (throwaway Postgres databases, fake claude/opencode
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Ligeti test kit: real-process test doubles (throwaway Postgres databases, fake claude/opencode, fake GitLab, Bitbucket, Jira and Telegram) and helpers that run a workflow package under a real ligeti-worker.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
package/bin/fake-herdr.mjs
DELETED
|
@@ -1,468 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// ABOUTME: Stand-in for the real `herdr` CLI, used by HerdrBackend's own unit/integration tests
|
|
3
|
-
// ABOUTME: and by small-factory's full workflow integration test.
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
readFileSync,
|
|
7
|
-
writeFileSync,
|
|
8
|
-
appendFileSync,
|
|
9
|
-
existsSync,
|
|
10
|
-
mkdirSync,
|
|
11
|
-
rmSync,
|
|
12
|
-
} from "node:fs";
|
|
13
|
-
import path from "node:path";
|
|
14
|
-
import { execFileSync } from "node:child_process";
|
|
15
|
-
|
|
16
|
-
function loadState(statePath) {
|
|
17
|
-
if (!existsSync(statePath)) {
|
|
18
|
-
return { nextId: 0, workspaces: {}, tabs: {}, panes: {}, worktrees: {} };
|
|
19
|
-
}
|
|
20
|
-
return JSON.parse(readFileSync(statePath, "utf8"));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function saveState(statePath, state) {
|
|
24
|
-
writeFileSync(statePath, JSON.stringify(state));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function fail(code, message) {
|
|
28
|
-
process.stderr.write(JSON.stringify({ error: { code, message } }));
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function ok(payload) {
|
|
33
|
-
if (payload !== undefined) {
|
|
34
|
-
process.stdout.write(JSON.stringify(payload));
|
|
35
|
-
}
|
|
36
|
-
process.exit(0);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function shouldFail(phase) {
|
|
40
|
-
return process.env.FAKE_HERDR_FAIL_PHASE === phase;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function failCode() {
|
|
44
|
-
return process.env.FAKE_HERDR_FAIL_CODE ?? "boom";
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function flagValue(args, flag) {
|
|
48
|
-
const idx = args.indexOf(flag);
|
|
49
|
-
return idx >= 0 ? args[idx + 1] : undefined;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function openTab(state, workspaceId, label, cwd) {
|
|
53
|
-
const workspace = state.workspaces[workspaceId];
|
|
54
|
-
const index = workspace.nextTab++;
|
|
55
|
-
const number = index + 1;
|
|
56
|
-
const tabId = `${workspaceId}:t${String(index)}`;
|
|
57
|
-
const paneId = `${workspaceId}:${String(index)}`;
|
|
58
|
-
state.tabs[tabId] = { workspaceId, customLabel: label ?? null, number, closed: false };
|
|
59
|
-
state.panes[paneId] = { workspaceId, tabId, running: false, closed: false, cwd };
|
|
60
|
-
return { tabId, paneId };
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function tabDisplayLabel(state, tabId) {
|
|
64
|
-
const tab = state.tabs[tabId];
|
|
65
|
-
if (tab.customLabel !== null) {
|
|
66
|
-
return tab.customLabel;
|
|
67
|
-
}
|
|
68
|
-
const openTabsOfWorkspace = Object.keys(state.tabs).filter(
|
|
69
|
-
(id) => state.tabs[id].workspaceId === tab.workspaceId && !state.tabs[id].closed,
|
|
70
|
-
);
|
|
71
|
-
return String(openTabsOfWorkspace.indexOf(tabId) + 1);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function openWorkspace(state, workspaceId, fields) {
|
|
75
|
-
state.workspaces[workspaceId] = { ...fields, nextTab: 0, closed: false };
|
|
76
|
-
return openTab(state, workspaceId, undefined, fields.cwd);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function closeWorkspace(state, workspaceId) {
|
|
80
|
-
state.workspaces[workspaceId].closed = true;
|
|
81
|
-
for (const tab of Object.values(state.tabs)) {
|
|
82
|
-
if (tab.workspaceId === workspaceId) {
|
|
83
|
-
tab.closed = true;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
for (const pane of Object.values(state.panes)) {
|
|
87
|
-
if (pane.workspaceId === workspaceId) {
|
|
88
|
-
pane.closed = true;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function closeTab(state, tabId) {
|
|
94
|
-
const tab = state.tabs[tabId];
|
|
95
|
-
tab.closed = true;
|
|
96
|
-
for (const pane of Object.values(state.panes)) {
|
|
97
|
-
if (pane.tabId === tabId) {
|
|
98
|
-
pane.closed = true;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
const remaining = Object.values(state.tabs).filter(
|
|
102
|
-
(t) => t.workspaceId === tab.workspaceId && !t.closed,
|
|
103
|
-
);
|
|
104
|
-
if (remaining.length === 0) {
|
|
105
|
-
closeWorkspace(state, tab.workspaceId);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function closePane(state, paneId) {
|
|
110
|
-
const pane = state.panes[paneId];
|
|
111
|
-
pane.closed = true;
|
|
112
|
-
const remaining = Object.values(state.panes).filter((p) => p.tabId === pane.tabId && !p.closed);
|
|
113
|
-
if (remaining.length === 0) {
|
|
114
|
-
closeTab(state, pane.tabId);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const LOCK_TIMEOUT_MS = 30_000;
|
|
119
|
-
const LOCK_POLL_MS = 20;
|
|
120
|
-
|
|
121
|
-
function holdStateLock(statePath) {
|
|
122
|
-
const lockDir = `${statePath}.lock`;
|
|
123
|
-
const deadline = Date.now() + LOCK_TIMEOUT_MS;
|
|
124
|
-
for (;;) {
|
|
125
|
-
try {
|
|
126
|
-
mkdirSync(lockDir);
|
|
127
|
-
break;
|
|
128
|
-
} catch (err) {
|
|
129
|
-
if (err.code !== "EEXIST") {
|
|
130
|
-
throw err;
|
|
131
|
-
}
|
|
132
|
-
if (Date.now() > deadline) {
|
|
133
|
-
fail("lock_timeout", `fake-herdr: could not take ${lockDir} within ${LOCK_TIMEOUT_MS}ms`);
|
|
134
|
-
}
|
|
135
|
-
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, LOCK_POLL_MS);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
const release = () => {
|
|
139
|
-
rmSync(lockDir, { recursive: true, force: true });
|
|
140
|
-
};
|
|
141
|
-
process.on("exit", release);
|
|
142
|
-
process.on("SIGTERM", () => {
|
|
143
|
-
process.exit(143);
|
|
144
|
-
});
|
|
145
|
-
process.on("SIGINT", () => {
|
|
146
|
-
process.exit(130);
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function main() {
|
|
151
|
-
const statePath = process.env.FAKE_HERDR_STATE;
|
|
152
|
-
if (!statePath) {
|
|
153
|
-
console.error("fake-herdr: FAKE_HERDR_STATE env var is required");
|
|
154
|
-
process.exit(2);
|
|
155
|
-
}
|
|
156
|
-
const logPath = process.env.FAKE_HERDR_LOG;
|
|
157
|
-
const argv = process.argv.slice(2);
|
|
158
|
-
if (logPath) {
|
|
159
|
-
appendFileSync(logPath, JSON.stringify(argv) + "\n");
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
holdStateLock(statePath);
|
|
163
|
-
const state = loadState(statePath);
|
|
164
|
-
const [group, action, ...rest] = argv;
|
|
165
|
-
|
|
166
|
-
if (group === "workspace" && action === "create") {
|
|
167
|
-
if (shouldFail("create")) {
|
|
168
|
-
fail(failCode(), "fake create failure");
|
|
169
|
-
}
|
|
170
|
-
const cwd = flagValue(rest, "--cwd");
|
|
171
|
-
const label = flagValue(rest, "--label");
|
|
172
|
-
const id = state.nextId++;
|
|
173
|
-
const workspaceId = `ws-${String(id)}`;
|
|
174
|
-
const { tabId, paneId } = openWorkspace(state, workspaceId, { label, cwd });
|
|
175
|
-
saveState(statePath, state);
|
|
176
|
-
ok({
|
|
177
|
-
result: {
|
|
178
|
-
root_pane: { pane_id: paneId, tab_id: tabId, workspace_id: workspaceId },
|
|
179
|
-
tab: { tab_id: tabId, label: tabDisplayLabel(state, tabId), workspace_id: workspaceId },
|
|
180
|
-
},
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (group === "workspace" && action === "rename") {
|
|
185
|
-
const [workspaceId, label] = rest;
|
|
186
|
-
if (shouldFail("rename")) {
|
|
187
|
-
fail(failCode(), "fake rename failure");
|
|
188
|
-
}
|
|
189
|
-
const workspace = state.workspaces[workspaceId];
|
|
190
|
-
if (!workspace) {
|
|
191
|
-
fail("workspace_not_found", `no such workspace: ${workspaceId}`);
|
|
192
|
-
}
|
|
193
|
-
workspace.label = label;
|
|
194
|
-
saveState(statePath, state);
|
|
195
|
-
ok();
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
if (group === "workspace" && action === "list") {
|
|
199
|
-
const workspaces = Object.entries(state.workspaces)
|
|
200
|
-
.filter(([, w]) => !w.closed)
|
|
201
|
-
.map(([workspace_id, w]) => ({
|
|
202
|
-
workspace_id,
|
|
203
|
-
label: w.label,
|
|
204
|
-
...(w.checkoutPath ? { worktree: { checkout_path: w.checkoutPath } } : {}),
|
|
205
|
-
}));
|
|
206
|
-
ok({ result: { workspaces } });
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (group === "workspace" && action === "close") {
|
|
210
|
-
if (shouldFail("close")) {
|
|
211
|
-
fail(failCode(), "fake workspace close failure");
|
|
212
|
-
}
|
|
213
|
-
const [workspaceId] = rest;
|
|
214
|
-
const workspace = state.workspaces[workspaceId];
|
|
215
|
-
if (!workspace || workspace.closed) {
|
|
216
|
-
fail("workspace_not_found", `no such workspace: ${workspaceId}`);
|
|
217
|
-
}
|
|
218
|
-
closeWorkspace(state, workspaceId);
|
|
219
|
-
saveState(statePath, state);
|
|
220
|
-
ok();
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if (group === "tab" && action === "create") {
|
|
224
|
-
if (shouldFail("tab_create") || shouldFail("tab_create_and_close")) {
|
|
225
|
-
fail(failCode(), "fake tab create failure");
|
|
226
|
-
}
|
|
227
|
-
const workspaceId = flagValue(rest, "--workspace");
|
|
228
|
-
const workspace = workspaceId ? state.workspaces[workspaceId] : undefined;
|
|
229
|
-
if (!workspace || workspace.closed) {
|
|
230
|
-
fail("workspace_not_found", `no such workspace: ${String(workspaceId)}`);
|
|
231
|
-
}
|
|
232
|
-
const { tabId, paneId } = openTab(
|
|
233
|
-
state,
|
|
234
|
-
workspaceId,
|
|
235
|
-
flagValue(rest, "--label"),
|
|
236
|
-
flagValue(rest, "--cwd"),
|
|
237
|
-
);
|
|
238
|
-
saveState(statePath, state);
|
|
239
|
-
ok({
|
|
240
|
-
result: {
|
|
241
|
-
root_pane: { pane_id: paneId, tab_id: tabId, workspace_id: workspaceId },
|
|
242
|
-
tab: { tab_id: tabId, label: tabDisplayLabel(state, tabId), workspace_id: workspaceId },
|
|
243
|
-
},
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (group === "tab" && action === "list") {
|
|
248
|
-
const workspaceId = flagValue(rest, "--workspace");
|
|
249
|
-
const tabs = Object.entries(state.tabs)
|
|
250
|
-
.filter(([, t]) => !t.closed && (workspaceId === undefined || t.workspaceId === workspaceId))
|
|
251
|
-
.map(([tab_id, t]) => ({
|
|
252
|
-
tab_id,
|
|
253
|
-
workspace_id: t.workspaceId,
|
|
254
|
-
label: tabDisplayLabel(state, tab_id),
|
|
255
|
-
number: t.number,
|
|
256
|
-
focused: tab_id === state.focusedTabId,
|
|
257
|
-
}));
|
|
258
|
-
ok({ result: { tabs } });
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (group === "tab" && action === "focus") {
|
|
262
|
-
const [tabId] = rest;
|
|
263
|
-
const tab = state.tabs[tabId];
|
|
264
|
-
if (!tab || tab.closed) {
|
|
265
|
-
fail("tab_not_found", `tab ${tabId} not found`);
|
|
266
|
-
}
|
|
267
|
-
state.focusedTabId = tabId;
|
|
268
|
-
saveState(statePath, state);
|
|
269
|
-
ok({ result: { type: "ok" } });
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (group === "tab" && action === "rename") {
|
|
273
|
-
const [tabId, label] = rest;
|
|
274
|
-
if (shouldFail("rename")) {
|
|
275
|
-
fail(failCode(), "fake rename failure");
|
|
276
|
-
}
|
|
277
|
-
const tab = state.tabs[tabId];
|
|
278
|
-
if (!tab || tab.closed) {
|
|
279
|
-
fail("tab_not_found", `tab ${tabId} not found`);
|
|
280
|
-
}
|
|
281
|
-
tab.customLabel = label;
|
|
282
|
-
saveState(statePath, state);
|
|
283
|
-
ok({ result: { type: "ok" } });
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (group === "tab" && action === "close") {
|
|
287
|
-
const [tabId] = rest;
|
|
288
|
-
const tab = state.tabs[tabId];
|
|
289
|
-
if (!tab || tab.closed) {
|
|
290
|
-
fail("tab_not_found", `tab ${tabId} not found`);
|
|
291
|
-
}
|
|
292
|
-
const isDefaultLabelled = tabDisplayLabel(state, tabId) === "1";
|
|
293
|
-
if (
|
|
294
|
-
shouldFail("close") ||
|
|
295
|
-
shouldFail("tab_create_and_close") ||
|
|
296
|
-
(shouldFail("reclaim") && isDefaultLabelled)
|
|
297
|
-
) {
|
|
298
|
-
fail(failCode(), "fake tab close failure");
|
|
299
|
-
}
|
|
300
|
-
closeTab(state, tabId);
|
|
301
|
-
saveState(statePath, state);
|
|
302
|
-
ok({ result: { type: "ok" } });
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
if (group === "pane" && action === "run") {
|
|
306
|
-
const [paneId] = rest;
|
|
307
|
-
if (shouldFail("run")) {
|
|
308
|
-
fail(failCode(), "fake run failure");
|
|
309
|
-
}
|
|
310
|
-
const pane = state.panes[paneId];
|
|
311
|
-
if (!pane) {
|
|
312
|
-
fail("pane_not_found", `no such pane: ${paneId}`);
|
|
313
|
-
}
|
|
314
|
-
pane.running = true;
|
|
315
|
-
pane.command = rest.slice(1).join(" ");
|
|
316
|
-
saveState(statePath, state);
|
|
317
|
-
ok();
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
if (group === "pane" && action === "exit") {
|
|
321
|
-
const [paneId] = rest;
|
|
322
|
-
const pane = state.panes[paneId];
|
|
323
|
-
if (!pane || pane.closed) {
|
|
324
|
-
fail("pane_not_found", `no such pane: ${paneId}`);
|
|
325
|
-
}
|
|
326
|
-
pane.running = false;
|
|
327
|
-
saveState(statePath, state);
|
|
328
|
-
ok();
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
if (group === "pane" && action === "list") {
|
|
332
|
-
const workspaceIdx = rest.indexOf("--workspace");
|
|
333
|
-
const workspaceId = workspaceIdx >= 0 ? rest[workspaceIdx + 1] : undefined;
|
|
334
|
-
const panes = Object.entries(state.panes)
|
|
335
|
-
.filter(([, p]) => p.workspaceId === workspaceId && !p.closed)
|
|
336
|
-
.map(([pane_id, p]) => ({
|
|
337
|
-
pane_id,
|
|
338
|
-
tab_id: p.tabId,
|
|
339
|
-
workspace_id: p.workspaceId,
|
|
340
|
-
...(p.cwd !== undefined ? { cwd: p.cwd } : {}),
|
|
341
|
-
}));
|
|
342
|
-
ok({ result: { panes } });
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (group === "pane" && action === "process-info") {
|
|
346
|
-
const paneIdx = rest.indexOf("--pane");
|
|
347
|
-
const paneId = paneIdx >= 0 ? rest[paneIdx + 1] : undefined;
|
|
348
|
-
const pane = paneId ? state.panes[paneId] : undefined;
|
|
349
|
-
if (!pane || pane.closed) {
|
|
350
|
-
fail("pane_not_found", `no such pane: ${String(paneId)}`);
|
|
351
|
-
}
|
|
352
|
-
const shellPid = 1;
|
|
353
|
-
const foreground_processes = pane.running
|
|
354
|
-
? [{ pid: shellPid }, { pid: 2 }]
|
|
355
|
-
: [{ pid: shellPid }];
|
|
356
|
-
ok({ result: { process_info: { shell_pid: shellPid, foreground_processes } } });
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
if (group === "pane" && action === "close") {
|
|
360
|
-
if (shouldFail("close")) {
|
|
361
|
-
fail(failCode(), "fake pane close failure");
|
|
362
|
-
}
|
|
363
|
-
const [paneId] = rest;
|
|
364
|
-
const pane = state.panes[paneId];
|
|
365
|
-
if (!pane || pane.closed) {
|
|
366
|
-
fail("pane_not_found", `no such pane: ${paneId}`);
|
|
367
|
-
}
|
|
368
|
-
closePane(state, paneId);
|
|
369
|
-
saveState(statePath, state);
|
|
370
|
-
ok();
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
if (group === "worktree" && action === "create") {
|
|
374
|
-
if (shouldFail("worktree_create")) {
|
|
375
|
-
fail(failCode(), "fake worktree create failure");
|
|
376
|
-
}
|
|
377
|
-
const cwdIdx = rest.indexOf("--cwd");
|
|
378
|
-
const branchIdx = rest.indexOf("--branch");
|
|
379
|
-
const pathIdx = rest.indexOf("--path");
|
|
380
|
-
const labelIdx = rest.indexOf("--label");
|
|
381
|
-
const cwd = cwdIdx >= 0 ? rest[cwdIdx + 1] : undefined;
|
|
382
|
-
const branch = branchIdx >= 0 ? rest[branchIdx + 1] : undefined;
|
|
383
|
-
const worktreePath = pathIdx >= 0 ? rest[pathIdx + 1] : undefined;
|
|
384
|
-
const label = labelIdx >= 0 ? rest[labelIdx + 1] : branch;
|
|
385
|
-
if (!cwd || !branch || !worktreePath) {
|
|
386
|
-
fail("invalid_args", "worktree create requires --cwd, --branch and --path");
|
|
387
|
-
}
|
|
388
|
-
mkdirSync(path.dirname(worktreePath), { recursive: true });
|
|
389
|
-
try {
|
|
390
|
-
execFileSync("git", ["-C", cwd, "worktree", "add", worktreePath, "-b", branch], {
|
|
391
|
-
stdio: "pipe",
|
|
392
|
-
});
|
|
393
|
-
} catch {
|
|
394
|
-
try {
|
|
395
|
-
execFileSync("git", ["-C", cwd, "worktree", "add", worktreePath, branch], {
|
|
396
|
-
stdio: "pipe",
|
|
397
|
-
});
|
|
398
|
-
} catch (err) {
|
|
399
|
-
fail("worktree_create_failed", err instanceof Error ? err.message : String(err));
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
const id = state.nextId++;
|
|
403
|
-
const workspaceId = `ws-wt-${String(id)}`;
|
|
404
|
-
state.worktrees[workspaceId] = {
|
|
405
|
-
repoPath: cwd,
|
|
406
|
-
worktreePath,
|
|
407
|
-
branchName: branch,
|
|
408
|
-
label,
|
|
409
|
-
closed: false,
|
|
410
|
-
};
|
|
411
|
-
openWorkspace(state, workspaceId, { label, cwd: worktreePath, checkoutPath: worktreePath });
|
|
412
|
-
saveState(statePath, state);
|
|
413
|
-
ok({
|
|
414
|
-
result: {
|
|
415
|
-
workspace: { workspace_id: workspaceId },
|
|
416
|
-
worktree: { path: worktreePath, branch },
|
|
417
|
-
},
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
if (group === "worktree" && action === "list") {
|
|
422
|
-
const cwdIdx = rest.indexOf("--cwd");
|
|
423
|
-
const cwd = cwdIdx >= 0 ? rest[cwdIdx + 1] : undefined;
|
|
424
|
-
const worktrees = Object.entries(state.worktrees)
|
|
425
|
-
.filter(([, w]) => w.repoPath === cwd)
|
|
426
|
-
.map(([workspace_id, w]) => ({
|
|
427
|
-
path: w.worktreePath,
|
|
428
|
-
branch: w.branchName,
|
|
429
|
-
...(w.closed ? {} : { open_workspace_id: workspace_id }),
|
|
430
|
-
}));
|
|
431
|
-
ok({ result: { worktrees } });
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
if (group === "worktree" && action === "remove") {
|
|
435
|
-
const workspaceIdx = rest.indexOf("--workspace");
|
|
436
|
-
const workspaceId = workspaceIdx >= 0 ? rest[workspaceIdx + 1] : undefined;
|
|
437
|
-
const worktree = workspaceId ? state.worktrees[workspaceId] : undefined;
|
|
438
|
-
if (!worktree || worktree.closed) {
|
|
439
|
-
fail("workspace_not_found", `no such workspace: ${String(workspaceId)}`);
|
|
440
|
-
}
|
|
441
|
-
if (shouldFail("worktree_remove")) {
|
|
442
|
-
fail(failCode(), "fake worktree remove failure");
|
|
443
|
-
}
|
|
444
|
-
try {
|
|
445
|
-
execFileSync(
|
|
446
|
-
"git",
|
|
447
|
-
["-C", worktree.repoPath, "worktree", "remove", worktree.worktreePath, "--force"],
|
|
448
|
-
{
|
|
449
|
-
stdio: "pipe",
|
|
450
|
-
},
|
|
451
|
-
);
|
|
452
|
-
} catch (err) {
|
|
453
|
-
const stderr = err.stderr?.toString() ?? "";
|
|
454
|
-
if (!/is not a working tree|not a valid path/.test(stderr)) {
|
|
455
|
-
fail("worktree_remove_failed", err instanceof Error ? err.message : String(err));
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
worktree.closed = true;
|
|
459
|
-
closeWorkspace(state, workspaceId);
|
|
460
|
-
saveState(statePath, state);
|
|
461
|
-
ok({ result: {} });
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
console.error(`fake-herdr: unrecognized command: ${argv.join(" ")}`);
|
|
465
|
-
process.exit(2);
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
main();
|
package/dist/herdr.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare function writeHerdrShim(dir: string, statePath: string, logPath: string): Promise<string>;
|
|
2
|
-
export interface FakeHerdrWorktreeEntry {
|
|
3
|
-
readonly repoPath: string;
|
|
4
|
-
readonly worktreePath: string;
|
|
5
|
-
readonly branchName: string;
|
|
6
|
-
readonly closed: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare function readHerdrWorktrees(statePath: string): Promise<readonly FakeHerdrWorktreeEntry[]>;
|
|
9
|
-
//# sourceMappingURL=herdr.d.ts.map
|
package/dist/herdr.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"herdr.d.ts","sourceRoot":"","sources":["../src/herdr.ts"],"names":[],"mappings":"AAMA,wBAAsB,cAAc,CAClC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAKD,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,SAAS,sBAAsB,EAAE,CAAC,CAI5C"}
|
package/dist/herdr.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// ABOUTME: Points a workflow at the fake herdr through a shim script, and reads the worktrees the
|
|
2
|
-
// ABOUTME: fake recorded in its state file.
|
|
3
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { fakeHerdrPath } from "./agents.js";
|
|
6
|
-
export async function writeHerdrShim(dir, statePath, logPath) {
|
|
7
|
-
const shim = path.join(dir, "herdr-shim.sh");
|
|
8
|
-
await writeFile(shim, `#!/bin/sh\nFAKE_HERDR_STATE='${statePath}' FAKE_HERDR_LOG='${logPath}' exec '${process.execPath}' '${fakeHerdrPath()}' "$@"\n`, { mode: 0o755 });
|
|
9
|
-
return shim;
|
|
10
|
-
}
|
|
11
|
-
export async function readHerdrWorktrees(statePath) {
|
|
12
|
-
const raw = await readFile(statePath, "utf8");
|
|
13
|
-
const state = JSON.parse(raw);
|
|
14
|
-
return Object.values(state.worktrees ?? {});
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=herdr.js.map
|
package/dist/herdr.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"herdr.js","sourceRoot":"","sources":["../src/herdr.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,4CAA4C;AAC5C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAAW,EACX,SAAiB,EACjB,OAAe;IAEf,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;IAC7C,MAAM,SAAS,CACb,IAAI,EACJ,gCAAgC,SAAS,qBAAqB,OAAO,WAAW,OAAO,CAAC,QAAQ,MAAM,aAAa,EAAE,UAAU,EAC/H,EAAE,IAAI,EAAE,KAAK,EAAE,CAChB,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC;AAYD,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,SAAiB;IAEjB,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAmB,CAAC;IAChD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;AAC9C,CAAC"}
|