@henryqw/pi-herdr-done 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Henry Wang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # `@henryqw/pi-herdr-done`
2
+
3
+ Pi extension that closes and removes the current Herdr-managed linked worktree. Requires Pi Coding Agent 0.84.x (minimum 0.84.2) running inside Herdr.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pi install npm:@henryqw/pi-herdr-done
9
+ ```
10
+
11
+ ## Use
12
+
13
+ | Surface | Type | Purpose |
14
+ | --- | --- | --- |
15
+ | `/done` | command | Close current Herdr worktree workspace and remove its clean checkout. |
16
+ | `/done --force` | command | Close workspace and remove checkout even when worktree is dirty. |
17
+
18
+ Both forms wait for Pi to become idle. `/done` asks for confirmation first; `/done --force` skips it because the flag already states intent. Normal removal runs:
19
+
20
+ ```bash
21
+ herdr worktree remove --workspace "$HERDR_WORKSPACE_ID"
22
+ ```
23
+
24
+ Herdr closes the worktree workspace and removes its checkout. Command requires Pi running inside Herdr with `HERDR_ENV=1` and `HERDR_WORKSPACE_ID` set.
25
+
26
+ Dirty worktrees make `/done` fail. Commit or discard changes, or use `/done --force` to explicitly delete them.
27
+
28
+ ## Remove
29
+
30
+ ```bash
31
+ pi remove npm:@henryqw/pi-herdr-done
32
+ ```
33
+
34
+ ## Development
35
+
36
+ ```bash
37
+ npm test --workspace @henryqw/pi-herdr-done
38
+ npm run typecheck --workspace @henryqw/pi-herdr-done
39
+ npm run pack:check --workspace @henryqw/pi-herdr-done
40
+ ```
@@ -0,0 +1,31 @@
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import { createHerdrClient } from "@henryqw/pi-herdr";
3
+
4
+ export default function herdrDoneExtension(pi: ExtensionAPI): void {
5
+ const herdr = createHerdrClient<{ cwd: string }>((command, args, options) =>
6
+ pi.exec(command, [...args], options));
7
+
8
+ pi.registerCommand("done", {
9
+ description: "Close and remove the current Herdr worktree",
10
+ handler: async (args, ctx) => {
11
+ const option = args.trim();
12
+ if (option && option !== "--force") throw new Error("Usage: /done [--force]");
13
+ if (process.env.HERDR_ENV !== "1") {
14
+ throw new Error("/done requires the current Pi session inside Herdr (HERDR_ENV=1).");
15
+ }
16
+ const workspaceId = process.env.HERDR_WORKSPACE_ID?.trim();
17
+ if (!workspaceId) throw new Error("HERDR_WORKSPACE_ID is missing.");
18
+
19
+ if (option !== "--force") {
20
+ const confirmed = await ctx.ui.confirm("Done", "Close and remove the current Herdr worktree?");
21
+ if (!confirmed) return;
22
+ }
23
+
24
+ await ctx.waitForIdle();
25
+ await herdr.run([
26
+ "worktree", "remove", "--workspace", workspaceId,
27
+ ...(option === "--force" ? ["--force"] : []),
28
+ ], { cwd: ctx.cwd });
29
+ },
30
+ });
31
+ }
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@henryqw/pi-herdr-done",
3
+ "version": "0.2.0",
4
+ "description": "Close and remove the current Herdr worktree from Pi.",
5
+ "keywords": [
6
+ "pi-package",
7
+ "pi",
8
+ "herdr",
9
+ "worktree"
10
+ ],
11
+ "type": "module",
12
+ "engines": {
13
+ "node": ">=22.19.0"
14
+ },
15
+ "license": "MIT",
16
+ "files": [
17
+ "extensions",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "scripts": {
22
+ "test": "node --test test/*.test.ts",
23
+ "typecheck": "tsc --noEmit --allowImportingTsExtensions --target ES2022 --module NodeNext --moduleResolution NodeNext --skipLibCheck extensions/*.ts test/*.test.ts",
24
+ "pack:check": "npm pack --dry-run"
25
+ },
26
+ "peerDependencies": {
27
+ "@earendil-works/pi-coding-agent": "^0.84.2"
28
+ },
29
+ "dependencies": {
30
+ "@henryqw/pi-herdr": "^0.1.2"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/HenryQW/pi-packages.git",
35
+ "directory": "packages/pi-herdr-done"
36
+ },
37
+ "bugs": {
38
+ "url": "https://github.com/HenryQW/pi-packages/issues"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "pi": {
44
+ "extensions": [
45
+ "./extensions"
46
+ ]
47
+ }
48
+ }