{"_id":"@ddv12138/pi-enter-no-send","_rev":"7-37839cdcc73359710f62bbd256a36a57","name":"@ddv12138/pi-enter-no-send","dist-tags":{"latest":"0.1.4"},"versions":{"0.1.2":{"name":"@ddv12138/pi-enter-no-send","version":"0.1.2","keywords":["pi-package","pi-extension","editor","autocomplete","slash-command"],"_id":"@ddv12138/pi-enter-no-send@0.1.2","maintainers":[{"name":"ddv12138","email":"644077730@qq.com"}],"pi":{"extensions":["./index.ts"]},"dist":{"shasum":"2a088fdb35f46e856891be5ce4176e3e75620c28","tarball":"https://registry.npmjs.org/@ddv12138/pi-enter-no-send/-/pi-enter-no-send-0.1.2.tgz","fileCount":3,"integrity":"sha512-7slVxkgmQq4NvqNO4lxiuLaku/7sVx4TrLMQ2va2RcP7SMj2ObmozVQHO0mSwsk41F/hqFUFCkUBBmqNrcFqPQ==","signatures":[{"sig":"MEQCIHuVZyJ1yVNvcctr7uQJ2e/un6hXuOPMSWuvS6SUvsbWAiB32Ba2Qckr5zZ3rqzrWKnwveALIjQtA4kfF+lkDdqKXw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8415},"type":"module","scripts":{"smoke":"node scripts/smoke.mjs","install:local":"./install.sh"},"_npmUser":{"name":"ddv12138","email":"644077730@qq.com"},"_npmVersion":"10.9.8","description":"pi extension: while a slash-command autocomplete menu is open, Enter accepts the completion without submitting (like Tab), so you can keep typing after selecting a skill/command","directories":{},"_nodeVersion":"22.22.3","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"@earendil-works/pi-tui":"*","@earendil-works/pi-coding-agent":"*"},"_npmOperationalInternal":{"tmp":"tmp/pi-enter-no-send_0.1.2_1786692268202_0.5776780812662443","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@ddv12138/pi-enter-no-send","version":"0.1.3","keywords":["pi-package","pi-extension","editor","autocomplete","slash-command"],"_id":"@ddv12138/pi-enter-no-send@0.1.3","maintainers":[{"name":"ddv12138","email":"644077730@qq.com"}],"pi":{"extensions":["./index.ts"]},"dist":{"shasum":"2f1a823970bf9463d80ee39209b479a795ce8bf9","tarball":"https://registry.npmjs.org/@ddv12138/pi-enter-no-send/-/pi-enter-no-send-0.1.3.tgz","fileCount":3,"integrity":"sha512-3KFA7j9i/0D7NnH3KMdBqKiyPzw1+YvIucX5QDs4UyywMc826gpPGAY45wsT7I2wprhqPVhxV5dp/O6oZqejoQ==","signatures":[{"sig":"MEQCIHPcAv6qxGlE/y2zAeaUZUGrhRgK3DNBhIGkU/7cHV5CAiAfe5tSHnEGhw2hh7IxXWlJZ+LOFZPaLbzHuFh+XHPVaw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8273},"type":"module","scripts":{"smoke":"node scripts/smoke.mjs","install:local":"./install.sh"},"_npmUser":{"name":"ddv12138","email":"644077730@qq.com"},"_npmVersion":"10.9.8","description":"pi extension: while a slash-command autocomplete menu is open, Enter accepts the completion without submitting (like Tab), so you can keep typing after selecting a skill/command","directories":{},"_nodeVersion":"22.22.3","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"@earendil-works/pi-tui":"*","@earendil-works/pi-coding-agent":"*"},"_npmOperationalInternal":{"tmp":"tmp/pi-enter-no-send_0.1.3_1786692506611_0.9560537423691358","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@ddv12138/pi-enter-no-send","version":"0.1.4","type":"module","description":"pi extension: while a slash-command autocomplete menu is open, Enter accepts the completion without submitting (like Tab), so you can keep typing after selecting a skill/command","license":"MIT","keywords":["pi-package","pi-extension","editor","autocomplete","slash-command"],"scripts":{"smoke":"node scripts/smoke.mjs","install:local":"./install.sh"},"peerDependencies":{"@earendil-works/pi-coding-agent":"*","@earendil-works/pi-tui":"*"},"publishConfig":{"access":"public"},"pi":{"extensions":["./index.ts"]},"_id":"@ddv12138/pi-enter-no-send@0.1.4","_nodeVersion":"22.22.3","_npmVersion":"10.9.8","dist":{"integrity":"sha512-89jQjN5aSWmHGQoYWhHicU6/Mgb7xCzBvoADQ6t1WAcnBsgJjR1mI7+dlX8aVGqxAPelzygmW8nXsrJ+R3cD7A==","shasum":"e163ac8af9d452810c33b00a9da7fe4e8d45558e","tarball":"https://registry.npmjs.org/@ddv12138/pi-enter-no-send/-/pi-enter-no-send-0.1.4.tgz","fileCount":3,"unpackedSize":8293,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCnjaOznby9xrIP3dvOT2nACkYxie9bYKJ8CQJzp4d+uAIgVYNgg4uES+4k/osyKm8UFEfvLiwfJN83216uIcjtiY0="}]},"_npmUser":{"name":"ddv12138","email":"644077730@qq.com"},"directories":{},"maintainers":[{"name":"ddv12138","email":"644077730@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pi-enter-no-send_0.1.4_1786696699096_0.2898997649323356"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-14T07:24:28.049Z","modified":"2026-08-14T08:38:19.479Z","0.1.0":"2026-08-14T07:13:36.951Z","0.1.1":"2026-08-14T07:18:05.700Z","0.1.2":"2026-08-14T07:24:28.345Z","0.1.3":"2026-08-14T07:28:26.753Z","0.1.4":"2026-08-14T08:38:19.252Z"},"keywords":["pi-package","pi-extension","editor","autocomplete","slash-command"],"description":"pi extension: while a slash-command autocomplete menu is open, Enter accepts the completion without submitting (like Tab), so you can keep typing after selecting a skill/command","maintainers":[{"name":"ddv12138","email":"644077730@qq.com"}],"readme":"# pi-enter-no-send\n\n一个 pi 扩展：当斜杠命令（`/`）补全菜单打开时，**回车 = 只接受补全、不发送**（与 Tab 相同），这样选中技能/命令后可以继续补充说明，再按一次回车才发送。\n\n## 解决的问题\n\npi 原版行为（pi-tui `Editor.handleInput` 中写死）：`/` 前缀的补全（斜杠命令、技能）按回车会**接受补全并立即提交**；而路径、`@`、`#` 补全按回车只接受不提交。\n\n例如输入 `/grill-me` 后按回车，技能直接被发出去了，没机会补一句说明。本扩展把 `/` 菜单打开时的回车改为走 Tab 路径：接受补全、留在输入框，继续打字。\n\n## 安装\n\n```bash\npi install npm:@ddv12138/pi-enter-no-send\n```\n\n然后在 pi 里执行 `/reload`（或重启 pi）即可生效。\n\n验证是否加载：输入 `/` 打开补全菜单后按回车，技能名被填入输入框且消息不发送，即说明已生效。\n\n## 使用\n\n- 输入 `/` + 技能名 → 补全菜单打开 → 按**回车** → 技能名填入输入框（不发送）→ 继续输入补充说明 → 再按**回车**发送。\n- 不想要补全时，按 `Esc` 关掉菜单再回车，或直接用 Tab。\n- 路径 / `@` / `#` 补全行为不变（原版已是接受不发送）。\n\n## 工作原理\n\n扩展在 `resources_discover` 事件中注册编辑器组件（该事件在所有扩展的 `session_start` 之后触发，保证最后注册、必定生效），然后**包装当前编辑器**而不是替换：\n\n```ts\n// 关键逻辑：在内层编辑器的 handleInput 外再包一层\nconst originalHandleInput = editor.handleInput.bind(editor);\neditor.handleInput = (data) => {\n  if (matchesKey(data, \"enter\") && editor.isShowingAutocomplete()) {\n    // 光标前是 \"/\"（斜杠命令/技能菜单）时，把回车转成 Tab 语义\n    if (beforeCursor.trimStart().startsWith(\"/\")) {\n      originalHandleInput(\"\\t\"); // 接受补全，不提交\n      return;\n    }\n  }\n  originalHandleInput(data);\n};\n```\n\n- 若无其他扩展占用编辑器，则直接用 `CustomEditor` 子类（行为相同）。\n- 若已有扩展占用（如 `pi-powerline-footer`），则包装它返回的编辑器实例——footer、bash 模式、幽灵补全等全部保留，只改变回车行为。\n- `matchesKey(data, \"enter\")` 只匹配纯回车，不影响 `shift+enter`（换行）、`alt+enter`（follow-up）。\n- 转发 `\"\\t\"` 走 pi-tui 的 Tab 分支：应用补全、关闭菜单、留在编辑器。\n- 菜单关闭时回车原样走提交路径，行为不变。\n\n## 本地开发\n\n```bash\ngit clone <本仓库地址>\ncd pi-enter-no-send\nnode scripts/smoke.mjs   # 行为级冒烟测试\n```\n\n冒烟测试用与 pi 相同的 jiti + alias 加载真实模块，覆盖：\n\n1. `/` 菜单打开 + 回车 → 接受补全、不提交 ✓\n2. Tab 行为一致（基线） ✓\n3. 无菜单 + 回车 → 正常提交 ✓\n4. `#` 菜单 + 回车 → 保持原版接受不发送 ✓\n5. Esc 仍可取消菜单 ✓\n6. 已有其他编辑器扩展时，包装（patch）该编辑器实例而非替换 ✓\n\n## 限制\n\n- 若另一个扩展在 `resources_discover` 中注册编辑器组件且加载顺序在本扩展之后，它可能覆盖本扩展的包装。已与 pi-powerline-footer 验证可正常叠加。\n- 菜单打开时回车不再\"接受+立即发送\"，需要按两次回车（一次接受、一次发送）——这是本扩展的预期行为。\n- 若你把 `tui.input.tab` 的默认键位（`\\t`）改掉了，回车转 Tab 的兼容逻辑会失效。\n","readmeFilename":"README.md","license":"MIT"}