@nicknisi/pi-stash 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/index.ts +9 -9
  2. package/package.json +9 -9
package/index.ts CHANGED
@@ -13,9 +13,9 @@
13
13
  * one-line preview of the most recent one.
14
14
  */
15
15
 
16
- import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
16
+ import type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent';
17
17
 
18
- const WIDGET_KEY = "message-stash";
18
+ const WIDGET_KEY = 'message-stash';
19
19
 
20
20
  export default function stash(pi: ExtensionAPI) {
21
21
  const stack: string[] = [];
@@ -28,22 +28,22 @@ export default function stash(pi: ExtensionAPI) {
28
28
  }
29
29
  const theme = ctx.ui.theme;
30
30
  const latest = stack[stack.length - 1]!;
31
- const firstLine = latest.split("\n")[0] ?? "";
31
+ const firstLine = latest.split('\n')[0] ?? '';
32
32
  const preview = firstLine.length > 60 ? `${firstLine.slice(0, 60)}…` : firstLine;
33
- const count = stack.length > 1 ? theme.fg("dim", ` (+${stack.length - 1} more)`) : "";
33
+ const count = stack.length > 1 ? theme.fg('dim', ` (+${stack.length - 1} more)`) : '';
34
34
  ctx.ui.setWidget(WIDGET_KEY, [
35
- `${theme.fg("accent", "⧉ stashed:")} ${theme.fg("muted", preview)}${count} ${theme.fg("dim", "· ctrl+s to restore")}`,
35
+ `${theme.fg('accent', '⧉ stashed:')} ${theme.fg('muted', preview)}${count} ${theme.fg('dim', '· ctrl+s to restore')}`,
36
36
  ]);
37
37
  };
38
38
 
39
- pi.registerShortcut("ctrl+s", {
40
- description: "Stash / restore the typed message",
39
+ pi.registerShortcut('ctrl+s', {
40
+ description: 'Stash / restore the typed message',
41
41
  handler: async (ctx) => {
42
42
  if (!ctx.hasUI) return;
43
43
  const text = ctx.ui.getEditorText();
44
44
  if (text.trim().length > 0) {
45
45
  stack.push(text);
46
- ctx.ui.setEditorText("");
46
+ ctx.ui.setEditorText('');
47
47
  } else if (stack.length > 0) {
48
48
  ctx.ui.setEditorText(stack.pop()!);
49
49
  }
@@ -53,7 +53,7 @@ export default function stash(pi: ExtensionAPI) {
53
53
 
54
54
  // After a message is submitted, auto-restore the most recent stash into
55
55
  // the now-empty editor (mirrors Claude Code's behavior).
56
- pi.on("before_agent_start", async (_event, ctx) => {
56
+ pi.on('before_agent_start', async (_event, ctx) => {
57
57
  if (!ctx.hasUI || stack.length === 0) return;
58
58
  if (ctx.ui.getEditorText().trim().length > 0) return;
59
59
  ctx.ui.setEditorText(stack.pop()!);
package/package.json CHANGED
@@ -1,12 +1,19 @@
1
1
  {
2
2
  "name": "@nicknisi/pi-stash",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Stash and restore the current prompt draft",
5
5
  "keywords": [
6
6
  "pi",
7
7
  "pi-coding-agent",
8
8
  "pi-package"
9
9
  ],
10
+ "homepage": "https://github.com/nicknisi/pi-extensions/tree/main/packages/stash#readme",
11
+ "license": "MIT",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/nicknisi/pi-extensions.git",
15
+ "directory": "packages/stash"
16
+ },
10
17
  "files": [
11
18
  "index.ts"
12
19
  ],
@@ -21,12 +28,5 @@
21
28
  "extensions": [
22
29
  "./index.ts"
23
30
  ]
24
- },
25
- "license": "MIT",
26
- "repository": {
27
- "type": "git",
28
- "url": "git+https://github.com/nicknisi/pi-extensions.git",
29
- "directory": "packages/stash"
30
- },
31
- "homepage": "https://github.com/nicknisi/pi-extensions/tree/main/packages/stash#readme"
31
+ }
32
32
  }