@hcflabs/pi-undo 0.0.0-stage → 3.3.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 +22 -0
- package/README.md +18 -2
- package/extensions/undo.ts +20 -0
- package/package.json +46 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Henry Wang
|
|
4
|
+
Copyright (c) 2026 hcflabs
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@hcflabs/pi-undo`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Return to the latest user prompt on the current branch, without later conversation context. Edit and resend the prompt in place instead of copying it into a new turn.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pi install npm:@hcflabs/pi-undo
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Use
|
|
12
|
+
|
|
13
|
+
Run `/undo` with no arguments. It cancels active work, waits for it to stop, then returns to the undo target.
|
|
14
|
+
|
|
15
|
+
The command does not select prompts on other branches. If the current branch has no user message, Pi displays `Nothing to undo.`
|
|
16
|
+
|
|
17
|
+
## Limits and recovery
|
|
18
|
+
|
|
19
|
+
Conversation rewind does not revert filesystem changes. Review or restore files separately before you resend the prompt.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
export default function undoExtension(pi: ExtensionAPI): void {
|
|
4
|
+
pi.registerCommand("undo", {
|
|
5
|
+
description: "Rewind context to the latest user prompt",
|
|
6
|
+
handler: async (args, ctx) => {
|
|
7
|
+
if (args.trim()) throw new Error("Usage: /undo");
|
|
8
|
+
|
|
9
|
+
ctx.abort();
|
|
10
|
+
await ctx.waitForIdle();
|
|
11
|
+
const turn = ctx.sessionManager.getBranch()
|
|
12
|
+
.findLast((entry) => entry.type === "message" && entry.message.role === "user");
|
|
13
|
+
if (!turn) {
|
|
14
|
+
ctx.ui.notify("Nothing to undo.", "info");
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
await ctx.navigateTree(turn.id, { summarize: false });
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hcflabs/pi-undo",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "3.3.0",
|
|
4
|
+
"description": "Rewind Pi conversation context to the latest user prompt.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package",
|
|
7
|
+
"pi",
|
|
8
|
+
"undo",
|
|
9
|
+
"conversation"
|
|
10
|
+
],
|
|
11
|
+
"type": "module",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=22.19.0"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"files": [
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"extensions",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "node --test test/*.test.ts",
|
|
23
|
+
"typecheck": "tsc --noEmit --allowImportingTsExtensions --target ES2023 --module NodeNext --moduleResolution NodeNext --skipLibCheck extensions/undo.ts test/undo.test.ts",
|
|
24
|
+
"pack:check": "npm pack --dry-run"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@earendil-works/pi-coding-agent": "^1.6.0"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/hcflabs/pi-harness.git",
|
|
32
|
+
"directory": "extensions/pi-undo"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/hcflabs/pi-harness/issues"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"pi": {
|
|
41
|
+
"extensions": [
|
|
42
|
+
"./extensions/undo.ts"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@earendil-works/pi-coding-agent": "1.6.0"
|
|
47
|
+
}
|
|
48
|
+
}
|