pi-session-peek 0.5.2 → 0.6.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/CHANGELOG.md +9 -0
- package/README.md +6 -2
- package/README.zh-CN.md +6 -2
- package/package.json +1 -1
- package/src/i18n.ts +2 -2
- package/src/peek-component.ts +5 -2
- package/src/query.ts +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
- Search: plain terms match the working directory again, but only in the all-projects scope. The current-directory scope keeps the 0.5.2 behaviour (conversation and session name only), since every session there shares the same path prefix.
|
|
6
|
+
搜索:普通词重新支持匹配工作目录,但仅在「全部项目」范围下生效;当前目录树范围保持 0.5.2 的行为(只匹配对话和会话名),因为该范围下所有会话共享同一段路径前缀。
|
|
7
|
+
- `Ctrl+Y` replaces `Ctrl+F` for scrolling the preview down half a page. In pi's fullscreen mode `Ctrl+F` is captured by pi's own transcript search on Windows/WSL before the picker ever sees it.
|
|
8
|
+
预览向下翻半页由 `Ctrl+F` 改为 `Ctrl+Y`:pi 全屏模式下 `Ctrl+F` 会被 pi 自己的全文搜索(Windows/WSL)先行截获,选择器根本收不到。
|
|
9
|
+
- The picker now declares `capturesViewportInput`, so in pi's fullscreen mode `PgUp` / `PgDn` reach the picker instead of scrolling pi's transcript.
|
|
10
|
+
选择器现在声明了 `capturesViewportInput`,pi 全屏模式下 `PgUp` / `PgDn` 会送达选择器,不再被 pi 截去滚动主对话记录。
|
|
11
|
+
|
|
3
12
|
## 0.5.2
|
|
4
13
|
|
|
5
14
|
- Wheel over the list now scrolls the list like a scrollbar instead of moving the selection. The selection stays where it is and comes back into view on `↑` / `↓`, a click, a new filter or a delete.
|
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ In TUI mode, run `/peek` and start typing. Press `Enter` on a session to continu
|
|
|
64
64
|
| `Tab` | Current directory tree ↔ all projects |
|
|
65
65
|
| `↑` `↓` | Select session |
|
|
66
66
|
| `PgUp` `PgDn` | Scroll preview by a page |
|
|
67
|
-
| `Ctrl+U` `Ctrl+
|
|
67
|
+
| `Ctrl+U` `Ctrl+Y` | Scroll preview by half a page |
|
|
68
68
|
| `Shift+↑` `Shift+↓` | Scroll preview by three lines |
|
|
69
69
|
| `Ctrl+N` `Ctrl+P` | Next / previous hit line outside the current view; the top-right corner shows `hit k/n` |
|
|
70
70
|
| `Ctrl+T` | Show / hide tool calls in the preview. Each call is one line with the tool name and its main argument (command, path, URL, query). Results are never shown. |
|
|
@@ -107,7 +107,7 @@ The filter is case-insensitive and matches anywhere in the text. Whitespace sepa
|
|
|
107
107
|
|
|
108
108
|
Quotes are the escape hatch: `"-foo"`, `"a|b"`, `"name:x"` and `"/x/"` search for those characters literally. A regex that fails to compile is searched as plain text. Only positive terms are highlighted in the preview, and `name:` / `dir:` terms never touch the conversation, so `name:auth` alone shows the full conversation with no highlights.
|
|
109
109
|
|
|
110
|
-
The search index holds user and assistant messages and the session name.
|
|
110
|
+
The search index holds user and assistant messages and the session name. Plain words also match the working directory, but only in the all-projects scope: with the current-directory scope every session shares the same path prefix, so a plain word from the path would match all of them; use `dir:` / `cwd:` to match the path in that scope. The index does not hold tool call arguments or tool results, and the tool lines shown by `Ctrl+T` are never matched or highlighted.
|
|
111
111
|
|
|
112
112
|
## 🌐 Language
|
|
113
113
|
|
|
@@ -183,6 +183,10 @@ git push --follow-tags
|
|
|
183
183
|
|
|
184
184
|
`npm version` first checks that the working tree is clean and stops with `Git working directory not clean.` otherwise, so everything, including `CHANGELOG.md`, has to be committed before the bump. Untracked files are fine. It then runs the hooks declared in `package.json`: `preversion` checks that `CHANGELOG.md` has a non-empty `## Unreleased` section and runs `npm run check`, aborting the bump before anything is touched if either fails; `version` runs `scripts/release-changelog.mjs`, which renames `## Unreleased` to the new version and stages the file. npm then commits `package.json`, the lockfile and `CHANGELOG.md` as `chore: release X.Y.Z` (message set in `.npmrc`) and tags it `vX.Y.Z`.
|
|
185
185
|
|
|
186
|
+
## 🔗 Friend links
|
|
187
|
+
|
|
188
|
+
- [LinuxDo — sincere, friendly, united, professional](https://linux.do)
|
|
189
|
+
|
|
186
190
|
## 📄 License
|
|
187
191
|
|
|
188
192
|
MIT. See [`LICENSE`](./LICENSE).
|
package/README.zh-CN.md
CHANGED
|
@@ -64,7 +64,7 @@ pi 扩展以你的用户权限运行,只装信得过的包。
|
|
|
64
64
|
| `Tab` | 当前目录树 ↔ 全部项目 |
|
|
65
65
|
| `↑` `↓` | 选会话 |
|
|
66
66
|
| `PgUp` `PgDn` | 预览翻页 |
|
|
67
|
-
| `Ctrl+U` `Ctrl+
|
|
67
|
+
| `Ctrl+U` `Ctrl+Y` | 预览翻半页 |
|
|
68
68
|
| `Shift+↑` `Shift+↓` | 预览滚三行 |
|
|
69
69
|
| `Ctrl+N` `Ctrl+P` | 跳到当前屏幕外的下一处 / 上一处命中行,右上角显示「命中 k/n」 |
|
|
70
70
|
| `Ctrl+T` | 预览里显示 / 隐藏工具调用。每次调用一行:工具名和主参数(命令、路径、URL、查询词)。不显示结果。 |
|
|
@@ -107,7 +107,7 @@ pi 扩展以你的用户权限运行,只装信得过的包。
|
|
|
107
107
|
|
|
108
108
|
引号是万能转义:`"-foo"`、`"a|b"`、`"name:x"`、`"/x/"` 都按字面搜这些字符。正则写错了就当普通文字搜。预览里只高亮正向的词,`name:` / `dir:` 的词不碰对话正文,所以只输入 `name:auth` 时右栏显示完整对话、没有高亮。
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
索引里有用户和助手的消息和会话名。普通词在「全部项目」范围下也匹配工作目录;当前目录树范围下所有会话的路径都带同一段前缀,普通词一碰到路径就会命中全部会话,所以这个范围下不匹配路径,要搜路径用 `dir:` / `cwd:`。没有工具调用的参数和结果,`Ctrl+T` 显示的工具行也不参与匹配和高亮。
|
|
111
111
|
|
|
112
112
|
## 🌐 界面语言
|
|
113
113
|
|
|
@@ -183,6 +183,10 @@ git push --follow-tags
|
|
|
183
183
|
|
|
184
184
|
`npm version` 一上来先检查 git 工作区是否干净,不干净就报 `Git working directory not clean.` 退出,所以 `CHANGELOG.md` 在内的所有改动都要先提交(未跟踪的文件不影响)。然后才跑 `package.json` 里声明的钩子:`preversion` 先确认 `CHANGELOG.md` 里有非空的 `## Unreleased` 段落,再跑 `npm run check`,任一不通过就在改动任何文件之前中止;`version` 跑 `scripts/release-changelog.mjs`,把 `## Unreleased` 改成新版本号并 `git add`。然后 npm 把 `package.json`、lockfile 和 `CHANGELOG.md` 一起提交成 `chore: release X.Y.Z`(提交信息定义在 `.npmrc`),并打上 `vX.Y.Z` 的 tag。
|
|
185
185
|
|
|
186
|
+
## 🔗 友情链接
|
|
187
|
+
|
|
188
|
+
- [LinuxDo — 真诚、友善、团结、专业](https://linux.do)
|
|
189
|
+
|
|
186
190
|
## 📄 许可证
|
|
187
191
|
|
|
188
192
|
MIT,见 [`LICENSE`](./LICENSE)。
|
package/package.json
CHANGED
package/src/i18n.ts
CHANGED
|
@@ -32,7 +32,7 @@ const zh = {
|
|
|
32
32
|
ai: "🤖 AI",
|
|
33
33
|
renamePrefix: "✏ 重命名: ",
|
|
34
34
|
confirmDelete: "⚠ 删除会话 [{desc}]?按 y / Enter 确认,任意其他键取消",
|
|
35
|
-
footer: "↑↓ 选择 PgUp/Dn·^U/^
|
|
35
|
+
footer: "↑↓ 选择 PgUp/Dn·^U/^Y·⇧↑↓ 滚动 ^N/^P 命中 ^T 工具 Tab 范围 ^D 删除 ^R 改名 ^O 分叉 Enter 进入 Esc/^C 关闭 🖱 点选·双击进入·拖选·滚轮",
|
|
36
36
|
selHint: "▭ 已选 {n} 行 ^C 复制 点击别处取消",
|
|
37
37
|
copied: "✓ 已复制 {n} 行",
|
|
38
38
|
copyFailed: "✗ 复制失败",
|
|
@@ -75,7 +75,7 @@ const en: Record<keyof typeof zh, string> = {
|
|
|
75
75
|
ai: "🤖 AI",
|
|
76
76
|
renamePrefix: "✏ Rename: ",
|
|
77
77
|
confirmDelete: "⚠ Delete session [{desc}]? y / Enter to confirm, any other key to cancel",
|
|
78
|
-
footer: "↑↓ select PgUp/Dn·^U/^
|
|
78
|
+
footer: "↑↓ select PgUp/Dn·^U/^Y·⇧↑↓ scroll ^N/^P hits ^T tools Tab scope ^D del ^R rename ^O fork Enter open Esc close 🖱 click·dbl-click·drag·wheel",
|
|
79
79
|
selHint: "▭ {n} lines selected ^C copy click elsewhere to clear",
|
|
80
80
|
copied: "✓ Copied {n} lines",
|
|
81
81
|
copyFailed: "✗ Copy failed",
|
package/src/peek-component.ts
CHANGED
|
@@ -29,6 +29,9 @@ const WHEEL_ITEMS = 1; // 滚轮每格滚几个列表项(每项两行)。只
|
|
|
29
29
|
const HINT_MS = 1500; // 底部"已复制"提示停留时间
|
|
30
30
|
|
|
31
31
|
export class PeekComponent implements Component, Focusable {
|
|
32
|
+
// 声明了它,pi 全屏模式才把 PageUp/PageDown 等视口按键交给组件(shouldDeferViewportInput),
|
|
33
|
+
// 否则被 pi 截去滚主对话记录。Ctrl+F 例外:pi 的全文搜索绑定在 defer 检查之前,永远到不了组件
|
|
34
|
+
readonly capturesViewportInput = true;
|
|
32
35
|
private input: Input;
|
|
33
36
|
private scope: "current" | "all";
|
|
34
37
|
private filtered: PeekSession[] = [];
|
|
@@ -122,7 +125,7 @@ export class PeekComponent implements Component, Focusable {
|
|
|
122
125
|
let out = this.all;
|
|
123
126
|
if (this.scope === "current") out = out.filter((s) => this.inCurrentTree(s));
|
|
124
127
|
if (since) out = out.filter((s) => s.mtime >= since);
|
|
125
|
-
if (terms.length) out = out.filter((s) => matchesSession(s, terms));
|
|
128
|
+
if (terms.length) out = out.filter((s) => matchesSession(s, terms, this.scope === "all"));
|
|
126
129
|
this.filtered = out;
|
|
127
130
|
const idx = prev ? out.indexOf(prev) : -1;
|
|
128
131
|
this.selected = idx >= 0 ? idx : keepSelection ? Math.min(this.selected, Math.max(0, out.length - 1)) : 0;
|
|
@@ -271,7 +274,7 @@ export class PeekComponent implements Component, Focusable {
|
|
|
271
274
|
this.invalidate();
|
|
272
275
|
return;
|
|
273
276
|
}
|
|
274
|
-
if (matchesKey(data, Key.pageDown) || matchesKey(data, Key.ctrl("
|
|
277
|
+
if (matchesKey(data, Key.pageDown) || matchesKey(data, Key.ctrl("y"))) {
|
|
275
278
|
const step = matchesKey(data, Key.pageDown) ? this.bodyHeight() : Math.max(1, this.bodyHeight() >> 1);
|
|
276
279
|
this.previewOffset += step;
|
|
277
280
|
this.invalidate();
|
package/src/query.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { PeekMsg, PeekSession } from "./sessions.ts";
|
|
|
4
4
|
import { stylePrefix, type PeekTheme } from "./theme.ts";
|
|
5
5
|
|
|
6
6
|
// 搜索框语法。空白分隔多个词,全部满足才算(AND)。每个词可以是:
|
|
7
|
-
// foo
|
|
7
|
+
// foo 子串,大小写不敏感,在对话正文和会话名里找;全局范围下还看工作目录(见 termHits)
|
|
8
8
|
// "foo bar" 短语,引号里的一段空白匹配正文里任意一段空白(含换行)
|
|
9
9
|
// a|b 任一命中(OR);要搜字面的 | 就加引号
|
|
10
10
|
// /re/ 正则(JS 语法,自动带 i 和 m 标志,不能含空白,用 \s 代替);写错了按普通文字搜
|
|
@@ -116,7 +116,7 @@ function hit(re: RegExp, s: string): boolean {
|
|
|
116
116
|
return execFrom(re, s, 0) !== null;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
function termHits(s: PeekSession, t: Term): boolean {
|
|
119
|
+
function termHits(s: PeekSession, t: Term, includeCwd: boolean): boolean {
|
|
120
120
|
switch (t.field) {
|
|
121
121
|
case "name":
|
|
122
122
|
return hit(t.re, s.name);
|
|
@@ -126,16 +126,17 @@ function termHits(s: PeekSession, t: Term): boolean {
|
|
|
126
126
|
case "assistant":
|
|
127
127
|
return s.msgs.some((m) => m.role === t.field && hit(t.re, m.text));
|
|
128
128
|
default:
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
return hit(t.re, s.name) || s.msgs.some((m) => hit(t.re, m.text));
|
|
129
|
+
// 普通词只在全局范围看工作目录:当前目录树范围下所有会话都带同一段前缀,路径词会命中全部会话。
|
|
130
|
+
// 当前范围下要搜路径仍可用 dir:
|
|
131
|
+
return hit(t.re, s.name) || s.msgs.some((m) => hit(t.re, m.text)) || (includeCwd && hit(t.re, s.cwd));
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
// 每个词都要满足:普通词在会话名或某条消息里出现,排除词则哪里都不出现;带前缀的只看对应的地方。
|
|
136
|
+
// includeCwd:普通词是否也匹配工作目录,调用方传 scope === "all"
|
|
136
137
|
// 正文不预存小写副本,直接在原文上用不区分大小写的正则匹配
|
|
137
|
-
export function matchesSession(s: PeekSession, terms: Term[]): boolean {
|
|
138
|
-
return terms.every((t) => termHits(s, t) !== t.negate);
|
|
138
|
+
export function matchesSession(s: PeekSession, terms: Term[], includeCwd = false): boolean {
|
|
139
|
+
return terms.every((t) => termHits(s, t, includeCwd) !== t.negate);
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
// 单段文字用:命中任意一个词就算
|