@qilin-agent/client-ui-sidebar-plans 0.0.0-stage → 3.1.4
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 +21 -0
- package/README.i18n.yaml +34 -0
- package/README.md +78 -2
- package/README.zh.md +79 -0
- package/lib/client.js +630 -0
- package/lib/index.js +6 -0
- package/lib/types/client/PlansBody.d.ts +35 -0
- package/lib/types/client/definition.d.ts +20 -0
- package/lib/types/client/face.d.ts +56 -0
- package/lib/types/client/index.d.ts +25 -0
- package/lib/types/client/locales.d.ts +37 -0
- package/lib/types/client/plans.d.ts +149 -0
- package/lib/types/client/store.d.ts +45 -0
- package/lib/types/index.d.ts +4 -0
- package/package.json +74 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kkutysllb
|
|
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.i18n.yaml
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
|
|
2
|
+
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
|
|
3
|
+
# After editing either side, bring the other along and re-record with:
|
|
4
|
+
# pnpm run verify-translation-pairing --write packages/client/ui-sidebar-plans/README.md
|
|
5
|
+
/:
|
|
6
|
+
en: 29e399ec8c59fbd2
|
|
7
|
+
zh: 0077a5cea2646f31
|
|
8
|
+
/qilin-agent-client-ui-sidebar-plans:
|
|
9
|
+
en: 84428082222332c9
|
|
10
|
+
zh: 5a29eaf9a061f5e9
|
|
11
|
+
/qilin-agent-client-ui-sidebar-plans/summary:
|
|
12
|
+
en: 2d7a2167c37b3368
|
|
13
|
+
zh: 8b8bd6ff986cbbb7
|
|
14
|
+
/qilin-agent-client-ui-sidebar-plans/table-of-contents:
|
|
15
|
+
en: e55f13c476e426c1
|
|
16
|
+
zh: 5a4d2a44c2197d8b
|
|
17
|
+
/qilin-agent-client-ui-sidebar-plans/what-it-registers:
|
|
18
|
+
en: b552ed59c87a14d0
|
|
19
|
+
zh: 8a1c7c1766a77434
|
|
20
|
+
/qilin-agent-client-ui-sidebar-plans/the-plan-list:
|
|
21
|
+
en: 9e49ec4c2386f42d
|
|
22
|
+
zh: fa57d28d22a9699d
|
|
23
|
+
/qilin-agent-client-ui-sidebar-plans/model-experience:
|
|
24
|
+
en: f3d22b6014339f99
|
|
25
|
+
zh: caaff278db33a124
|
|
26
|
+
/qilin-agent-client-ui-sidebar-plans/model-experience/kv-cache-effect:
|
|
27
|
+
en: a3ac5b34bc1d3088
|
|
28
|
+
zh: 82d0bf4c62f76bcf
|
|
29
|
+
/qilin-agent-client-ui-sidebar-plans/known-limitations-and-deferred-work:
|
|
30
|
+
en: bb82180fc7e4d50f
|
|
31
|
+
zh: 87c1d56974f8e60f
|
|
32
|
+
/qilin-agent-client-ui-sidebar-plans/known-limitations-and-deferred-work/dev-note:
|
|
33
|
+
en: e67f633dc6fe7773
|
|
34
|
+
zh: cdd2a143b725accd
|
package/README.md
CHANGED
|
@@ -1,3 +1,79 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
description: "The right Sidebar's task-plan page for the qilin web client: the session workspace's plan documents, from the agreed conventions over the wire, opened into the Sidebar by resource address."
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
# @qilin-agent/client-ui-sidebar-plans
|
|
7
|
+
|
|
8
|
+
English | [中文](README.zh.md)
|
|
9
|
+
|
|
10
|
+
## Summary
|
|
11
|
+
|
|
12
|
+
The right Sidebar's task-plan page: the plan documents of the session's workspace, found by convention and listed over the wire, opening into the Sidebar. It is a page type reached from the guide and claims no address; each row opens its document by address for the `qilin-resource://file` viewers to claim — nothing in `ui-sidebar-right` knows this package.
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [What it registers](#what-it-registers)
|
|
17
|
+
- [The plan list](#the-plan-list)
|
|
18
|
+
- [Model Experience](#model-experience)
|
|
19
|
+
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
|
|
20
|
+
- [Dev Note](#dev-note)
|
|
21
|
+
|
|
22
|
+
-----
|
|
23
|
+
|
|
24
|
+
<a id="what-it-registers"></a>
|
|
25
|
+
## What it registers
|
|
26
|
+
|
|
27
|
+
- **The type** — `ctx.sidebarRightTabs.register(...)` with kind `plans`, id `@qilin-agent/client-ui-sidebar-plans`, band `builtin`, no patterns, `single`, and one guide entry (order 50, its title and description from the `sidebarPlans` namespace, its glyph the shared checklist icon) that opens the type.
|
|
28
|
+
- **The body** — the keyed `sidebar.right.pane.tab` seat under that id: a 38px search row under the strip — the shared `Input` with a search glyph, and the reload control at its end — then one row per plan document, its title over its workspace-relative path.
|
|
29
|
+
|
|
30
|
+
Seven source files under `src/client/`: `definition.tsx` (the type), `store.ts` (what it keeps), `plans.ts` (the convention and its pure rules), `face.ts` (how it reads, Remote binding included), `PlansBody.tsx` (what it draws, with its status-line helper), `locales.ts` (what it says), and `index.ts` (the wiring).
|
|
31
|
+
|
|
32
|
+
<a id="the-plan-list"></a>
|
|
33
|
+
## The plan list
|
|
34
|
+
|
|
35
|
+
A scan looks where agents already write plans: the top level of `plans/`, `docs/plans/`, and `.plans/` contributes its `*.md` files, and the root `plan.md`, `PLAN.md`, and `docs/plan.md` count whether or not any such directory exists. Deeper nesting is deliberately ignored — a plan tree is a convention, not a filesystem walk.
|
|
36
|
+
|
|
37
|
+
Identity is the document's absolute path, case-folded. The `workspaceFiles` wire reports no device or inode, so on a case-insensitive volume — where `plan.md` and `PLAN.md` are one file under two spellings — the folded path is what keeps it from being listed twice. The list is capped at 20.
|
|
38
|
+
|
|
39
|
+
Rows keep the order the convention declares: `plans/`, then `docs/plans/`, then `.plans/`, then the well-known documents. The wire carries no modification time — a file's `version` is an opaque freshness token the Client never parses — so there is no newest-first order to sort by, and the convention's own order is at least stable across polls.
|
|
40
|
+
|
|
41
|
+
A row's title is the document's first `#`–`###` heading, read from the first page of its lines (`remote.workspaceFiles.read(sessionId, path, { offset: 1, limit: 20 })`) and bounded to 512 characters of it; a head with no heading, an unreadable document, and a document past a heading fall back to the file name without its `.md`.
|
|
42
|
+
|
|
43
|
+
| Call | Answer |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `list` on each convention directory | Its `*.md` files become candidates; a directory that is not there is the normal case. |
|
|
46
|
+
| `stat` on each well-known document | Present and a regular file becomes a candidate; a name that is absent or is not a regular file is skipped. |
|
|
47
|
+
| `read` on each surviving document | The title's head. A failure here is not the scan's: the file name is still a truthful row title. |
|
|
48
|
+
|
|
49
|
+
A failure that is not one of those absences — a transport failure, say — is carried out of the scan and takes the panel over, because reporting no plans when the workspace was never read would be a lie. Clicking a row opens `fileAddressFor(sessionId, root, path)` through `useTabInfo().tab.actions.openResource`, landing in the tab's own pane.
|
|
50
|
+
|
|
51
|
+
The root is the session's working directory, read from `useSessions().byId[sessionId].cwd`. A scan runs when the tab mounts, whenever the reload control is pressed, and every five seconds while the tab is visible; a hidden tab draws what it already scanned and polls nothing.
|
|
52
|
+
|
|
53
|
+
State lives in the type's own store, bucketed by tab id: the last scan's `rows`, whether a scan is `scanning`, and the `failure` that scan reported. A new scan of a tab retires the one in flight for it, and the owner's `signal` ends a bucket: on abort the tab is forgotten and a scan that settles afterwards writes nothing.
|
|
54
|
+
|
|
55
|
+
<a id="model-experience"></a>
|
|
56
|
+
## Model Experience
|
|
57
|
+
|
|
58
|
+
None, as this package draws a workspace's plan documents in the browser and registers nothing model-facing.
|
|
59
|
+
|
|
60
|
+
#### KV Cache effect
|
|
61
|
+
|
|
62
|
+
None; directory listings and document reads travel over the Remote and assemble no model request.
|
|
63
|
+
|
|
64
|
+
## Known Limitations and Deferred Work
|
|
65
|
+
|
|
66
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
67
|
+
- **No modification time.** The wire reports no `mtime`, so the list cannot put the freshest plan first; it keeps the convention's order instead.
|
|
68
|
+
- **One bounded title read.** The heading search reads the first page of a document only, so a heading past that page falls back to the file name.
|
|
69
|
+
- **One root, read only.** The list is rooted at the session's working directory; there is no way to scan elsewhere, and the panel neither creates, renames, nor deletes a plan.
|
|
70
|
+
|
|
71
|
+
<a id="dev-note"></a>
|
|
72
|
+
### Dev Note
|
|
73
|
+
|
|
74
|
+
<details>
|
|
75
|
+
<summary>Working context for maintainers — click to expand</summary>
|
|
76
|
+
|
|
77
|
+
None.
|
|
78
|
+
|
|
79
|
+
</details>
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "qilin Web 客户端右侧边栏的任务计划页:按约定扫描会话工作区的计划文档,列成清单,并以资源地址打开到侧栏。"
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @qilin-agent/client-ui-sidebar-plans
|
|
7
|
+
|
|
8
|
+
[English](README.md) | 中文
|
|
9
|
+
|
|
10
|
+
## 概述
|
|
11
|
+
|
|
12
|
+
右侧边栏的任务计划页:按约定找到会话工作区里的计划文档并读取成清单,再打开到侧栏。它是一个从引导页进入的页面型 tab,不认领任何地址;每一行用自己的地址打开文档,交给 `qilin-resource://file` 的查看器认领 —— `ui-sidebar-right` 完全不知道这个包。
|
|
13
|
+
|
|
14
|
+
## 目录
|
|
15
|
+
|
|
16
|
+
- [注册了什么](#what-it-registers)
|
|
17
|
+
- [计划清单](#the-plan-list)
|
|
18
|
+
- [Model Experience](#model-experience)
|
|
19
|
+
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
|
|
20
|
+
- [Dev Note](#dev-note)
|
|
21
|
+
|
|
22
|
+
-----
|
|
23
|
+
|
|
24
|
+
<a id="what-it-registers"></a>
|
|
25
|
+
## 注册了什么
|
|
26
|
+
|
|
27
|
+
- **类型** —— `ctx.sidebarRightTabs.register(...)`,kind 为 `plans`,id 为 `@qilin-agent/client-ui-sidebar-plans`,band 为 `builtin`,不声明 patterns,`single`,并给引导页一个入口(order 50,标题与描述取自 `sidebarPlans` 命名空间,图标是共用的清单字形),点它即打开这个类型。
|
|
28
|
+
- **主体** —— 该 id 下键控的 `sidebar.right.pane.tab` 座位:条带下方一行 38px 的搜索行 —— 共用的 `Input` 加搜索字形,末尾是重新扫描按钮 —— 再往下每个计划文档一行,标题在上、工作区相对路径在下。
|
|
29
|
+
|
|
30
|
+
`src/client/` 下七个源文件:`definition.tsx`(类型)、`store.ts`(它保存什么)、`plans.ts`(约定与其中的纯规则)、`face.ts`(怎么读,含 Remote 绑定)、`PlansBody.tsx`(画什么,含状态行助手)、`locales.ts`(说什么)、`index.ts`(接线)。
|
|
31
|
+
|
|
32
|
+
<a id="the-plan-list"></a>
|
|
33
|
+
## 计划清单
|
|
34
|
+
|
|
35
|
+
一次扫描只看 agent 本来就会写计划的地方:`plans/`、`docs/plans/`、`.plans/` 的**一层** `*.md`,以及根的 `plan.md`、`PLAN.md`、`docs/plan.md`(这些目录存不存在都算)。更深的层级有意不看 —— 计划树是约定,不是文件系统遍历。
|
|
36
|
+
|
|
37
|
+
身份是文档的绝对路径,且大小写折叠。`workspaceFiles` 线上没有 device 或 inode,所以在大小写不敏感的卷上(那里 `plan.md` 与 `PLAN.md` 是同一个文件的两种拼写),折叠后的路径才是"同一个文件不会列两次"的依据。清单最多 20 条。
|
|
38
|
+
|
|
39
|
+
行的顺序就是约定声明的顺序:先 `plans/`,再 `docs/plans/`,再 `.plans/`,最后是那几个固定文档。线上没有修改时间 —— 文件的 `version` 是客户端从不解析的新鲜度令牌 —— 所以没有"最新在前"可排,而约定自身的顺序至少在轮询之间是稳定的。
|
|
40
|
+
|
|
41
|
+
行的标题是文档第一个 `#`–`###` 标题,取自它第一页行内容(`remote.workspaceFiles.read(sessionId, path, { offset: 1, limit: 20 })`)并截到其中 512 个字符;没有标题、读不到、页内没有标题时,都退回去掉 `.md` 的文件名。
|
|
42
|
+
|
|
43
|
+
| 调用 | 结果 |
|
|
44
|
+
|---|---|
|
|
45
|
+
| 对每个约定目录 `list` | 其中的 `*.md` 成为候选;目录不存在是正常情况。 |
|
|
46
|
+
| 对每个固定文档 `stat` | 存在且是普通文件即成为候选;不存在或不是普通文件的跳过。 |
|
|
47
|
+
| 对每个留下的文档 `read` | 标题所需的那段开头。这里失败不算扫描失败:文件名仍是如实的行标题。 |
|
|
48
|
+
|
|
49
|
+
不属于上述"不存在"的失败 —— 比如传输失败 —— 会被带出扫描并接管整个面板:工作区根本没读成的时候说"没有计划"是假话。点一行会用 `fileAddressFor(sessionId, root, path)` 经 `useTabInfo().tab.actions.openResource` 打开,落在该 tab 自己的窗格里。
|
|
50
|
+
|
|
51
|
+
根是会话的工作目录,取自 `useSessions().byId[sessionId].cwd`。扫描会在 tab 挂载时跑一次、每次按下重新扫描按钮时跑一次,并在 tab 可见时每五秒跑一次;隐藏的 tab 只画已经扫到的内容,不做任何轮询。
|
|
52
|
+
|
|
53
|
+
状态存在类型自己的 store 里,按 tab id 分桶:上一次扫描的 `rows`、是否有扫描在 `scanning`、该次扫描报出的 `failure`。同一 tab 的新扫描会作废仍在进行的那次;属主的 `signal` 结束一个桶:中止时该 tab 被遗忘,之后落地的扫描什么都不会写。
|
|
54
|
+
|
|
55
|
+
<a id="model-experience"></a>
|
|
56
|
+
## Model Experience
|
|
57
|
+
|
|
58
|
+
无:本包只在浏览器里画出工作区的计划文档,不注册任何面向模型的东西。
|
|
59
|
+
|
|
60
|
+
#### KV Cache effect
|
|
61
|
+
|
|
62
|
+
无;目录列表与文档读取都走 Remote,不组装任何模型请求。
|
|
63
|
+
|
|
64
|
+
## Known Limitations and Deferred Work
|
|
65
|
+
|
|
66
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
67
|
+
- **没有修改时间。** 线上不报 `mtime`,清单无法把最新的计划排到最前,只能保留约定的顺序。
|
|
68
|
+
- **只读一页标题。** 找标题只读文档第一页,页外还有标题的文档退回文件名。
|
|
69
|
+
- **只有一个根,且只读。** 清单以会话工作目录为根,没有别处可扫;面板也不新建、重命名或删除计划。
|
|
70
|
+
|
|
71
|
+
<a id="dev-note"></a>
|
|
72
|
+
### 开发备注
|
|
73
|
+
|
|
74
|
+
<details>
|
|
75
|
+
<summary>Working context for maintainers — click to expand</summary>
|
|
76
|
+
|
|
77
|
+
None.
|
|
78
|
+
|
|
79
|
+
</details>
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,630 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "@qilin-agent/client-ui-sidebar-plans",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
let _qilin_agent_client_ui_primitives = require("@qilin-agent/client-ui-primitives");
|
|
9
|
+
let react = require("react");
|
|
10
|
+
let _qilin_agent_client_store = require("@qilin-agent/client-store");
|
|
11
|
+
//#region lib/types/client/definition.js
|
|
12
|
+
/** The tab kind this package owns. */
|
|
13
|
+
const PLANS_KIND = "plans";
|
|
14
|
+
/** This implementation's identity in the tab system, and the key its body registers under. */
|
|
15
|
+
const PLANS_ID = "@qilin-agent/client-ui-sidebar-plans";
|
|
16
|
+
/** The type's checklist glyph at whatever size the drawing surface asks for. */
|
|
17
|
+
function ChecklistGlyph({ size, className }) {
|
|
18
|
+
return (0, react_jsx_runtime.jsx)(_qilin_agent_client_ui_primitives.IconChecklistOutline14, {
|
|
19
|
+
size,
|
|
20
|
+
className
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The plans type's registry definition.
|
|
25
|
+
* @param t - namespace-bound translate, read fresh on every label call.
|
|
26
|
+
* @returns the definition to register.
|
|
27
|
+
*/
|
|
28
|
+
function plansDefinition(t) {
|
|
29
|
+
return {
|
|
30
|
+
id: PLANS_ID,
|
|
31
|
+
kind: PLANS_KIND,
|
|
32
|
+
priority: "builtin",
|
|
33
|
+
label: () => t("type.label"),
|
|
34
|
+
icon: ChecklistGlyph,
|
|
35
|
+
single: true,
|
|
36
|
+
title: () => t("type.label"),
|
|
37
|
+
guide: [{
|
|
38
|
+
id: "plans",
|
|
39
|
+
order: 50,
|
|
40
|
+
title: () => t("guide.title"),
|
|
41
|
+
description: () => t("guide.description"),
|
|
42
|
+
icon: ChecklistGlyph
|
|
43
|
+
}]
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region lib/types/client/plans.js
|
|
48
|
+
/** Directories whose top level is scanned for `*.md` plan documents. */
|
|
49
|
+
const PLAN_DIRS = [
|
|
50
|
+
"plans",
|
|
51
|
+
"docs/plans",
|
|
52
|
+
".plans"
|
|
53
|
+
];
|
|
54
|
+
/**
|
|
55
|
+
* Well-known plan document paths, relative to the workspace root.
|
|
56
|
+
*
|
|
57
|
+
* The docs-directory member is built from its directory's name because a
|
|
58
|
+
* literal `docs/….md` reads to `verify-doc-refs` as a path into this
|
|
59
|
+
* repository's own documentation; this one names a file in the user's
|
|
60
|
+
* workspace.
|
|
61
|
+
*/
|
|
62
|
+
const PLAN_FILES = [
|
|
63
|
+
"plan.md",
|
|
64
|
+
"PLAN.md",
|
|
65
|
+
`docs/plan.md`
|
|
66
|
+
];
|
|
67
|
+
/** Characters of a document's head the title search reads, never the whole file. */
|
|
68
|
+
const TITLE_HEAD_LIMIT = 512;
|
|
69
|
+
/** Lines one title read asks the endpoint for. */
|
|
70
|
+
const TITLE_HEAD_LINES = 20;
|
|
71
|
+
/**
|
|
72
|
+
* Failures that mean "this part of the convention is not here": a directory
|
|
73
|
+
* that was never created, a name that is not a directory, a well-known file
|
|
74
|
+
* that is absent or is not a regular file, and a path the Host will not read
|
|
75
|
+
* because it lies outside the workspace. Every other failure is the scan's own.
|
|
76
|
+
*/
|
|
77
|
+
const ABSENT_CODES = new Set([
|
|
78
|
+
"workspace-file/not-found",
|
|
79
|
+
"workspace-file/not-directory",
|
|
80
|
+
"workspace-file/not-regular-file",
|
|
81
|
+
"workspace-file/outside-workspace"
|
|
82
|
+
]);
|
|
83
|
+
/**
|
|
84
|
+
* Join the workspace root and a root-relative path with `/`.
|
|
85
|
+
*
|
|
86
|
+
* Whatever separators the root already uses: the Host resolves mixed
|
|
87
|
+
* separators, and the scan only needs one stable string.
|
|
88
|
+
* @param root - absolute workspace root.
|
|
89
|
+
* @param rel - path relative to the root.
|
|
90
|
+
* @returns the absolute path the endpoint receives.
|
|
91
|
+
*/
|
|
92
|
+
function joinWorkspacePath(root, rel) {
|
|
93
|
+
return `${root.replace(/[/\\]+$/, "")}/${rel}`;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The row title for one document: its first `#`/`##`/`###` heading from the
|
|
97
|
+
* head, else the file name without its `.md`. A blank heading falls through to
|
|
98
|
+
* the fallback.
|
|
99
|
+
* @param head - the document's opening text, already bounded.
|
|
100
|
+
* @param base - the document's file name.
|
|
101
|
+
* @returns the title to show.
|
|
102
|
+
*/
|
|
103
|
+
function planTitleFromHead(head, base) {
|
|
104
|
+
const fallback = base.replace(/\.md$/i, "");
|
|
105
|
+
const heading = /^#{1,3}\s+(.+)$/m.exec(head)?.[1]?.trim() ?? "";
|
|
106
|
+
return heading === "" ? fallback : heading;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Dedupe by case-folded absolute path and cap.
|
|
110
|
+
*
|
|
111
|
+
* Never by document identity: this endpoint reports none, and a path-keyed set
|
|
112
|
+
* is what keeps one file listed twice under two spellings on a
|
|
113
|
+
* case-insensitive volume.
|
|
114
|
+
* @param found - the documents in discovery order.
|
|
115
|
+
* @param limit - how many to keep.
|
|
116
|
+
* @returns the unique documents, capped.
|
|
117
|
+
*/
|
|
118
|
+
function selectPlans(found, limit = 20) {
|
|
119
|
+
const seen = /* @__PURE__ */ new Set();
|
|
120
|
+
const unique = [];
|
|
121
|
+
for (const item of found) {
|
|
122
|
+
const id = item.path.toLowerCase();
|
|
123
|
+
if (seen.has(id)) continue;
|
|
124
|
+
seen.add(id);
|
|
125
|
+
unique.push(item);
|
|
126
|
+
}
|
|
127
|
+
return unique.slice(0, limit);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The rows a search keeps: a case-insensitive substring of the title or the
|
|
131
|
+
* display path. A blank query keeps every row.
|
|
132
|
+
* @param rows - the scanned rows.
|
|
133
|
+
* @param query - what the search box holds.
|
|
134
|
+
* @returns the rows to draw, in their scanned order.
|
|
135
|
+
*/
|
|
136
|
+
function filterPlans(rows, query) {
|
|
137
|
+
const needle = query.trim().toLowerCase();
|
|
138
|
+
if (needle === "") return rows;
|
|
139
|
+
return rows.filter((row) => row.title.toLowerCase().includes(needle) || row.rel.toLowerCase().includes(needle));
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Read one document's title from a bounded head.
|
|
143
|
+
* @param sessionId - the session whose workspace resolves the path.
|
|
144
|
+
* @param candidate - the document to title.
|
|
145
|
+
* @param reader - the reads the scan performs.
|
|
146
|
+
* @param signal - the tab record's lifetime.
|
|
147
|
+
* @returns the heading, or the file name when the head is unreadable.
|
|
148
|
+
*/
|
|
149
|
+
async function titleOf(sessionId, candidate, reader, signal) {
|
|
150
|
+
const result = await reader.read(sessionId, candidate.path, {
|
|
151
|
+
offset: 1,
|
|
152
|
+
limit: TITLE_HEAD_LINES
|
|
153
|
+
}, signal);
|
|
154
|
+
return planTitleFromHead(result.ok ? result.value.text.slice(0, TITLE_HEAD_LIMIT) : "", candidate.base);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Scan one workspace for plan documents: the convention directories' top
|
|
158
|
+
* level, then the well-known paths, each surviving document's title resolved.
|
|
159
|
+
*
|
|
160
|
+
* A missing directory or file is the normal case — any subset of the
|
|
161
|
+
* convention may exist — and is skipped. A failure that is not an absence is
|
|
162
|
+
* carried out so the panel can say the workspace was not read, rather than
|
|
163
|
+
* report that it holds no plans.
|
|
164
|
+
* @param sessionId - the session whose workspace is scanned.
|
|
165
|
+
* @param root - absolute path of the workspace root.
|
|
166
|
+
* @param reader - the reads the scan performs.
|
|
167
|
+
* @param signal - the tab record's lifetime.
|
|
168
|
+
* @returns the rows found and the first failure worth reporting.
|
|
169
|
+
*/
|
|
170
|
+
async function scanPlans(sessionId, root, reader, signal) {
|
|
171
|
+
const found = [];
|
|
172
|
+
let failure;
|
|
173
|
+
for (const rel of PLAN_DIRS) {
|
|
174
|
+
const result = await reader.list(sessionId, joinWorkspacePath(root, rel), signal);
|
|
175
|
+
if (!result.ok) {
|
|
176
|
+
if (!ABSENT_CODES.has(result.error.code) && failure === void 0) failure = result.error;
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
for (const entry of result.value.entries) {
|
|
180
|
+
if (entry.type !== "file" || !entry.name.toLowerCase().endsWith(".md")) continue;
|
|
181
|
+
found.push({
|
|
182
|
+
path: joinWorkspacePath(root, `${rel}/${entry.name}`),
|
|
183
|
+
base: entry.name,
|
|
184
|
+
rel: `${rel}/${entry.name}`
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
for (const rel of PLAN_FILES) {
|
|
189
|
+
const result = await reader.stat(sessionId, joinWorkspacePath(root, rel), signal);
|
|
190
|
+
if (!result.ok) {
|
|
191
|
+
if (!ABSENT_CODES.has(result.error.code) && failure === void 0) failure = result.error;
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
const base = rel.slice(rel.lastIndexOf("/") + 1);
|
|
195
|
+
found.push({
|
|
196
|
+
path: joinWorkspacePath(root, rel),
|
|
197
|
+
base,
|
|
198
|
+
rel
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
const rows = [];
|
|
202
|
+
for (const candidate of selectPlans(found)) rows.push({
|
|
203
|
+
...candidate,
|
|
204
|
+
title: await titleOf(sessionId, candidate, reader, signal)
|
|
205
|
+
});
|
|
206
|
+
return failure === void 0 ? { rows } : {
|
|
207
|
+
rows,
|
|
208
|
+
failure
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region lib/types/client/face.js
|
|
213
|
+
/**
|
|
214
|
+
* Bind the scan to one Remote face.
|
|
215
|
+
*
|
|
216
|
+
* The namespace's three methods already have the reader's signatures: the
|
|
217
|
+
* session travels with every call because the endpoint resolves the workspace
|
|
218
|
+
* root from it, and a Remote call does not reject.
|
|
219
|
+
* @param remote - the Client Remote face carrying the `workspaceFiles` namespace.
|
|
220
|
+
* @returns the reader the pure scan performs.
|
|
221
|
+
*/
|
|
222
|
+
function createReader(remote) {
|
|
223
|
+
return remote.workspaceFiles;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Bind the panel's face to one reader.
|
|
227
|
+
* @param reader - the reader the scan performs.
|
|
228
|
+
* @returns the Slot `inject` factory: session and bound actions in, face out.
|
|
229
|
+
*/
|
|
230
|
+
function plansFace(reader) {
|
|
231
|
+
return (sessionId, actions) => {
|
|
232
|
+
/** Per tab: the scan generation a settlement must match; the latest request wins. */
|
|
233
|
+
const generations = /* @__PURE__ */ new Map();
|
|
234
|
+
return { refresh(tabId, root, signal) {
|
|
235
|
+
if (signal.aborted) return;
|
|
236
|
+
if (!generations.has(tabId)) signal.addEventListener("abort", () => {
|
|
237
|
+
generations.delete(tabId);
|
|
238
|
+
actions.forget(tabId);
|
|
239
|
+
}, { once: true });
|
|
240
|
+
const generation = (generations.get(tabId) ?? 0) + 1;
|
|
241
|
+
generations.set(tabId, generation);
|
|
242
|
+
actions.scanning(tabId);
|
|
243
|
+
scanPlans(sessionId, root, reader, signal).then((scan) => {
|
|
244
|
+
if (generations.get(tabId) !== generation) return;
|
|
245
|
+
actions.settled(tabId, scan.rows, scan.failure);
|
|
246
|
+
});
|
|
247
|
+
} };
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
251
|
+
//#region ../../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
|
|
252
|
+
function r(e) {
|
|
253
|
+
var t, f, n = "";
|
|
254
|
+
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
255
|
+
else if ("object" == typeof e) if (Array.isArray(e)) {
|
|
256
|
+
var o = e.length;
|
|
257
|
+
for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
|
|
258
|
+
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
|
259
|
+
return n;
|
|
260
|
+
}
|
|
261
|
+
function clsx() {
|
|
262
|
+
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
263
|
+
return n;
|
|
264
|
+
}
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region ../../util/workspace-path/src/file-address.ts
|
|
267
|
+
/** The scheme and type every file address opens with. */
|
|
268
|
+
const FILE_ADDRESS_PREFIX = "qilin-resource://file/";
|
|
269
|
+
/** Component-encode one id or path segment, keeping `:` literal for drive letters. */
|
|
270
|
+
function encodeSegment(segment) {
|
|
271
|
+
return encodeURIComponent(segment).replace(/%3A/gi, ":");
|
|
272
|
+
}
|
|
273
|
+
/** Encode a `/`-separated path segment by segment. */
|
|
274
|
+
function encodePath(path) {
|
|
275
|
+
return path.split("/").map(encodeSegment).join("/");
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Build the address of a file read through one Session.
|
|
279
|
+
* @param sessionId - the Session whose Host workspace resolves the path.
|
|
280
|
+
* @param path - absolute or workspace-relative path; backslashes are normalized to `/`, and leading `./` prefixes are dropped.
|
|
281
|
+
* @returns the `qilin-resource://file/session/<sessionId>/<path>` address.
|
|
282
|
+
*/
|
|
283
|
+
function sessionFileAddress(sessionId, path) {
|
|
284
|
+
const normalized = path.replace(/\\/g, "/").replace(/^(?:\.\/)+/, "");
|
|
285
|
+
return `${FILE_ADDRESS_PREFIX}session/${encodeSegment(sessionId)}/${encodePath(normalized)}`;
|
|
286
|
+
}
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region ../../util/workspace-path/src/index.ts
|
|
289
|
+
/**
|
|
290
|
+
* Browser-safe Workspace path and display helpers.
|
|
291
|
+
* @module @qilin-agent/util-workspace-path
|
|
292
|
+
*/
|
|
293
|
+
/** Whether a path uses a Windows drive or UNC prefix. */
|
|
294
|
+
function isWindowsStylePath(value) {
|
|
295
|
+
return /^[A-Za-z]:[/\\]/.test(value) || value.startsWith("\\\\");
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Whether a path is absolute in either spelling the Host accepts: POSIX (`/a/b`) or Windows drive or UNC.
|
|
299
|
+
* @param path - the path to classify.
|
|
300
|
+
* @returns `true` for an absolute path; `false` for a Workspace-relative one.
|
|
301
|
+
*/
|
|
302
|
+
function isAbsoluteWorkspacePath(path) {
|
|
303
|
+
return path.startsWith("/") || isWindowsStylePath(path);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* The address for a path as a caller holds it: a relative path, or an absolute
|
|
307
|
+
* path inside the Session's workspace, becomes a `session`-scoped address; an
|
|
308
|
+
* absolute path outside it, or one whose workspace root is unknown, keeps its
|
|
309
|
+
* absolute path in that Session's address.
|
|
310
|
+
* @param sessionId - the Session the path is read in.
|
|
311
|
+
* @param cwd - that Session's workspace root, when known.
|
|
312
|
+
* @param path - absolute or workspace-relative path, in either separator spelling.
|
|
313
|
+
* @returns the `qilin-resource://file/…` address.
|
|
314
|
+
*/
|
|
315
|
+
function fileAddressFor(sessionId, cwd, path) {
|
|
316
|
+
const normalized = path.replace(/\\/g, "/");
|
|
317
|
+
if (!isAbsoluteWorkspacePath(normalized)) return sessionFileAddress(sessionId, normalized);
|
|
318
|
+
const root = cwd === void 0 ? "" : cwd.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
319
|
+
if (root !== "" && normalized === root) return sessionFileAddress(sessionId, "");
|
|
320
|
+
if (root !== "" && normalized.startsWith(`${root}/`)) return sessionFileAddress(sessionId, normalized.slice(root.length + 1));
|
|
321
|
+
return sessionFileAddress(sessionId, normalized);
|
|
322
|
+
}
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region \0qilin-css:/home/runner/work/QiLin/QiLin/packages/client/ui-sidebar-plans/src/client/PlansBody.module.css.mjs
|
|
325
|
+
const css = ".pg4pta_root{height:100%;min-height:0;color:var(--qilin-alias-label-primary);font-size:var(--qilin-content-font-size-secondary,13px);flex-direction:column;flex:auto;line-height:1.5;display:flex}.pg4pta_header{box-sizing:border-box;border-bottom:.5px solid var(--qilin-alias-border-l3);flex:none;align-items:center;gap:4px;height:38px;padding:0 6px 0 10px;display:flex}.pg4pta_search{flex:auto;min-width:0}.pg4pta_body{scrollbar-gutter:stable;flex:auto;min-height:0;margin-right:2px;padding:8px 0 8px 8px;overflow:auto}.pg4pta_body::-webkit-scrollbar-track{margin:2px}.pg4pta_list{flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.pg4pta_item{margin:0;padding:0}.pg4pta_row{width:100%;min-width:0;color:inherit;font:inherit;text-align:left;cursor:pointer;background:0 0;border:0;border-radius:10px;flex-direction:column;gap:2px;padding:6px 10px;display:flex}.pg4pta_row:hover{background:var(--qilin-alias-interactive-bg-hover)}.pg4pta_title{white-space:nowrap;text-overflow:ellipsis;min-width:0;overflow:hidden}.pg4pta_path{min-width:0;color:var(--qilin-alias-label-tertiary);white-space:nowrap;text-overflow:ellipsis;font-size:12px;overflow:hidden}.pg4pta_note{color:var(--qilin-alias-label-tertiary);margin:0;padding:3px 10px;font-size:12px}.pg4pta_failed{color:var(--qilin-alias-label-secondary)}.pg4pta_status{flex-direction:column;padding:12px 10px;display:flex}.pg4pta_statusLine{color:var(--qilin-alias-label-secondary);font-size:var(--qilin-content-font-size-secondary,13px);margin:0;line-height:1.6}.pg4pta_tool{width:28px;height:28px;color:var(--qilin-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:28px;flex:none;justify-content:center;align-items:center;padding:6px;line-height:1;display:inline-flex}.pg4pta_tool svg{width:15px;height:15px}.pg4pta_tool:hover{color:var(--qilin-alias-label-primary);background:var(--qilin-alias-interactive-bg-hover)}";
|
|
326
|
+
const tagId = "@qilin-agent/client-ui-sidebar-plans/PlansBody.module.css";
|
|
327
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
328
|
+
const tag = document.createElement("style");
|
|
329
|
+
tag.dataset.plugin = "@qilin-agent/client-ui-sidebar-plans";
|
|
330
|
+
tag.dataset.pluginCss = tagId;
|
|
331
|
+
tag.textContent = css;
|
|
332
|
+
document.head.appendChild(tag);
|
|
333
|
+
}
|
|
334
|
+
var PlansBody_module_css_default = {
|
|
335
|
+
"body": "pg4pta_body",
|
|
336
|
+
"failed": "pg4pta_failed",
|
|
337
|
+
"header": "pg4pta_header",
|
|
338
|
+
"item": "pg4pta_item",
|
|
339
|
+
"list": "pg4pta_list",
|
|
340
|
+
"note": "pg4pta_note",
|
|
341
|
+
"path": "pg4pta_path",
|
|
342
|
+
"root": "pg4pta_root",
|
|
343
|
+
"row": "pg4pta_row",
|
|
344
|
+
"search": "pg4pta_search",
|
|
345
|
+
"status": "pg4pta_status",
|
|
346
|
+
"statusLine": "pg4pta_statusLine",
|
|
347
|
+
"title": "pg4pta_title",
|
|
348
|
+
"tool": "pg4pta_tool"
|
|
349
|
+
};
|
|
350
|
+
//#endregion
|
|
351
|
+
//#region lib/types/client/PlansBody.js
|
|
352
|
+
/**
|
|
353
|
+
* The plan panel's body: the session workspace's plan documents, as rows.
|
|
354
|
+
*
|
|
355
|
+
* Everything the panel keeps lives in its store, keyed by tab; everything it
|
|
356
|
+
* asks for goes through its injected face. The component decides when to scan
|
|
357
|
+
* — on mount, on the reload gesture, and on a poll that runs only while the
|
|
358
|
+
* tab is visible — what the search box filters, and what a click means: open
|
|
359
|
+
* the document through the owner's `tabActions` for a `file` viewer to claim.
|
|
360
|
+
*/
|
|
361
|
+
/**
|
|
362
|
+
* How often a visible panel scans again.
|
|
363
|
+
*
|
|
364
|
+
* The scan is a handful of directory listings and short reads, and this
|
|
365
|
+
* interval is what makes a plan document the agent just wrote appear without a
|
|
366
|
+
* gesture. A hidden tab polls nothing.
|
|
367
|
+
*/
|
|
368
|
+
const PLAN_POLL_MS = 5e3;
|
|
369
|
+
/**
|
|
370
|
+
* The panel's single status line, or `undefined` while it lists rows.
|
|
371
|
+
*
|
|
372
|
+
* A scan that could not be trusted takes the panel over: reporting no plans
|
|
373
|
+
* because the wire is down would be a lie about the workspace.
|
|
374
|
+
* @param t - namespace-bound translate.
|
|
375
|
+
* @param state - the tab's bucket.
|
|
376
|
+
* @param matches - how many rows the search kept.
|
|
377
|
+
* @returns the notice to draw, or `undefined` while rows are listed.
|
|
378
|
+
*/
|
|
379
|
+
function plansNotice(t, state, matches) {
|
|
380
|
+
if (state.failure !== void 0) return {
|
|
381
|
+
kind: "failed",
|
|
382
|
+
line: t("error.failed", { message: state.failure.message })
|
|
383
|
+
};
|
|
384
|
+
if (state.rows.length === 0) return state.scanning ? {
|
|
385
|
+
kind: "loading",
|
|
386
|
+
line: t("loading")
|
|
387
|
+
} : {
|
|
388
|
+
kind: "empty",
|
|
389
|
+
line: t("empty")
|
|
390
|
+
};
|
|
391
|
+
return matches === 0 ? {
|
|
392
|
+
kind: "noMatch",
|
|
393
|
+
line: t("noMatch")
|
|
394
|
+
} : void 0;
|
|
395
|
+
}
|
|
396
|
+
/** The panel: the search row, then the plan documents of the session's workspace. */
|
|
397
|
+
function PlansBody({ useTabInfo, sessionId, useSessions, useStore, refresh, t }) {
|
|
398
|
+
const { tab } = useTabInfo();
|
|
399
|
+
const { signal, visible, actions: tabActions } = tab;
|
|
400
|
+
const cwd = useSessions((sessions) => sessions.byId[sessionId]?.cwd);
|
|
401
|
+
const state = useStore((store) => store.byTab[tab.id]);
|
|
402
|
+
const [query, setQuery] = (0, react.useState)("");
|
|
403
|
+
(0, react.useEffect)(() => {
|
|
404
|
+
if (cwd === void 0 || signal.aborted) return void 0;
|
|
405
|
+
refresh(tab.id, cwd, signal);
|
|
406
|
+
if (!visible) return void 0;
|
|
407
|
+
const timer = setInterval(() => {
|
|
408
|
+
refresh(tab.id, cwd, signal);
|
|
409
|
+
}, PLAN_POLL_MS);
|
|
410
|
+
return () => {
|
|
411
|
+
clearInterval(timer);
|
|
412
|
+
};
|
|
413
|
+
}, [
|
|
414
|
+
cwd,
|
|
415
|
+
visible,
|
|
416
|
+
tab.id,
|
|
417
|
+
signal,
|
|
418
|
+
refresh
|
|
419
|
+
]);
|
|
420
|
+
if (cwd === void 0) return (0, react_jsx_runtime.jsx)("div", {
|
|
421
|
+
className: PlansBody_module_css_default.status,
|
|
422
|
+
"data-plans-state": "no-workspace",
|
|
423
|
+
children: (0, react_jsx_runtime.jsx)("p", {
|
|
424
|
+
className: PlansBody_module_css_default.statusLine,
|
|
425
|
+
children: t("noWorkspace")
|
|
426
|
+
})
|
|
427
|
+
});
|
|
428
|
+
if (state === void 0) return null;
|
|
429
|
+
const shown = filterPlans(state.rows, query);
|
|
430
|
+
const notice = plansNotice(t, state, shown.length);
|
|
431
|
+
return (0, react_jsx_runtime.jsxs)("div", {
|
|
432
|
+
className: PlansBody_module_css_default.root,
|
|
433
|
+
"data-plans-state": "plans",
|
|
434
|
+
"data-plans-root": cwd,
|
|
435
|
+
children: [(0, react_jsx_runtime.jsxs)("div", {
|
|
436
|
+
className: PlansBody_module_css_default.header,
|
|
437
|
+
children: [(0, react_jsx_runtime.jsx)(_qilin_agent_client_ui_primitives.Input, {
|
|
438
|
+
className: clsx(PlansBody_module_css_default.search),
|
|
439
|
+
type: "search",
|
|
440
|
+
icon: (0, react_jsx_runtime.jsx)(_qilin_agent_client_ui_primitives.IconSearchOutline16, {}),
|
|
441
|
+
value: query,
|
|
442
|
+
placeholder: t("search.placeholder"),
|
|
443
|
+
"aria-label": t("search.label"),
|
|
444
|
+
"data-plans-search": true,
|
|
445
|
+
onChange: (event) => {
|
|
446
|
+
setQuery(event.target.value);
|
|
447
|
+
}
|
|
448
|
+
}), (0, react_jsx_runtime.jsx)("button", {
|
|
449
|
+
type: "button",
|
|
450
|
+
className: PlansBody_module_css_default.tool,
|
|
451
|
+
"aria-label": t("reload"),
|
|
452
|
+
title: t("reload"),
|
|
453
|
+
"data-plans-reload": true,
|
|
454
|
+
onClick: () => {
|
|
455
|
+
refresh(tab.id, cwd, signal);
|
|
456
|
+
},
|
|
457
|
+
children: (0, react_jsx_runtime.jsx)(_qilin_agent_client_ui_primitives.IconRefreshOutline16, {})
|
|
458
|
+
})]
|
|
459
|
+
}), (0, react_jsx_runtime.jsxs)("div", {
|
|
460
|
+
className: PlansBody_module_css_default.body,
|
|
461
|
+
children: [notice !== void 0 && (0, react_jsx_runtime.jsx)("p", {
|
|
462
|
+
className: clsx(PlansBody_module_css_default.note, notice.kind === "failed" && PlansBody_module_css_default.failed),
|
|
463
|
+
"data-plans-row": notice.kind,
|
|
464
|
+
children: notice.line
|
|
465
|
+
}), (0, react_jsx_runtime.jsx)("ul", {
|
|
466
|
+
className: PlansBody_module_css_default.list,
|
|
467
|
+
children: shown.map((row) => (0, react_jsx_runtime.jsx)("li", {
|
|
468
|
+
className: PlansBody_module_css_default.item,
|
|
469
|
+
children: (0, react_jsx_runtime.jsxs)("button", {
|
|
470
|
+
type: "button",
|
|
471
|
+
className: PlansBody_module_css_default.row,
|
|
472
|
+
"data-plans-path": row.rel,
|
|
473
|
+
onClick: () => {
|
|
474
|
+
tabActions.openResource(fileAddressFor(sessionId, cwd, row.path));
|
|
475
|
+
},
|
|
476
|
+
children: [(0, react_jsx_runtime.jsx)("span", {
|
|
477
|
+
className: PlansBody_module_css_default.title,
|
|
478
|
+
children: row.title
|
|
479
|
+
}), (0, react_jsx_runtime.jsx)("span", {
|
|
480
|
+
className: PlansBody_module_css_default.path,
|
|
481
|
+
children: row.rel
|
|
482
|
+
})]
|
|
483
|
+
})
|
|
484
|
+
}, row.path))
|
|
485
|
+
})]
|
|
486
|
+
})]
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
//#endregion
|
|
490
|
+
//#region lib/types/client/locales.js
|
|
491
|
+
/** Simplified Chinese dictionary and key-set source of truth. */
|
|
492
|
+
const zh = {
|
|
493
|
+
"type.label": "任务计划",
|
|
494
|
+
"guide.title": "任务计划",
|
|
495
|
+
"guide.description": "扫描工作区里的计划文档",
|
|
496
|
+
"search.placeholder": "搜索标题或路径",
|
|
497
|
+
"search.label": "搜索计划",
|
|
498
|
+
reload: "重新扫描",
|
|
499
|
+
loading: "正在扫描…",
|
|
500
|
+
empty: "这个工作区里没有计划文档。",
|
|
501
|
+
noMatch: "没有匹配的计划。",
|
|
502
|
+
"error.failed": "扫描失败:{message}",
|
|
503
|
+
noWorkspace: "这个会话没有工作区目录。"
|
|
504
|
+
};
|
|
505
|
+
/** English dictionary, checked against the Chinese key set. */
|
|
506
|
+
const en = {
|
|
507
|
+
"type.label": "Task plans",
|
|
508
|
+
"guide.title": "Task plans",
|
|
509
|
+
"guide.description": "Scan this workspace for plan documents",
|
|
510
|
+
"search.placeholder": "Search titles or paths",
|
|
511
|
+
"search.label": "Search plans",
|
|
512
|
+
reload: "Scan again",
|
|
513
|
+
loading: "Scanning…",
|
|
514
|
+
empty: "This workspace has no plan documents.",
|
|
515
|
+
noMatch: "No plan matches the search.",
|
|
516
|
+
"error.failed": "Scan failed: {message}",
|
|
517
|
+
noWorkspace: "This session has no workspace directory."
|
|
518
|
+
};
|
|
519
|
+
//#endregion
|
|
520
|
+
//#region lib/types/client/store.js
|
|
521
|
+
/**
|
|
522
|
+
* The plan panel's view state: what each tab last scanned.
|
|
523
|
+
*
|
|
524
|
+
* A scan per tab is state the type owns, so it lives in a Slot-standard
|
|
525
|
+
* exclusive store (one instance per session), bucketed by tab id because two
|
|
526
|
+
* tabs of this kind scan independently. Keeping it here is also what makes a
|
|
527
|
+
* tab switch cheap: the body unmounts and remounts while its record lives, and
|
|
528
|
+
* the list it already scanned is still in its bucket.
|
|
529
|
+
*
|
|
530
|
+
* Writers run between `scanning` and `forget`, and the face stops dispatching
|
|
531
|
+
* once the record's signal aborts.
|
|
532
|
+
*/
|
|
533
|
+
/**
|
|
534
|
+
* Declare the plan panel's store.
|
|
535
|
+
*
|
|
536
|
+
* A factory rather than a shared handle: the registration declares it as an
|
|
537
|
+
* exclusive store, so the framework mints one instance per session.
|
|
538
|
+
* @returns the store handle to declare on the registration.
|
|
539
|
+
*/
|
|
540
|
+
function createPlansStore() {
|
|
541
|
+
return (0, _qilin_agent_client_store.defineStore)({
|
|
542
|
+
init: () => ({ byTab: {} }),
|
|
543
|
+
actions: {
|
|
544
|
+
/**
|
|
545
|
+
* Mark one tab as scanning, keeping the rows it already holds.
|
|
546
|
+
* @param d - draft state.
|
|
547
|
+
* @param tabId - the tab being drawn.
|
|
548
|
+
*/
|
|
549
|
+
scanning: (d, tabId) => {
|
|
550
|
+
const held = d.byTab[tabId];
|
|
551
|
+
d.byTab[tabId] = held === void 0 ? {
|
|
552
|
+
rows: [],
|
|
553
|
+
scanning: true
|
|
554
|
+
} : {
|
|
555
|
+
...held,
|
|
556
|
+
scanning: true
|
|
557
|
+
};
|
|
558
|
+
},
|
|
559
|
+
/**
|
|
560
|
+
* Record what one scan settled on.
|
|
561
|
+
* @param d - draft state.
|
|
562
|
+
* @param tabId - the tab being drawn.
|
|
563
|
+
* @param rows - the rows the scan produced.
|
|
564
|
+
* @param failure - why the scan could not be trusted, or `undefined`.
|
|
565
|
+
*/
|
|
566
|
+
settled: (d, tabId, rows, failure) => {
|
|
567
|
+
d.byTab[tabId] = failure === void 0 ? {
|
|
568
|
+
rows,
|
|
569
|
+
scanning: false
|
|
570
|
+
} : {
|
|
571
|
+
rows,
|
|
572
|
+
scanning: false,
|
|
573
|
+
failure
|
|
574
|
+
};
|
|
575
|
+
},
|
|
576
|
+
/**
|
|
577
|
+
* Forget one tab's list, for a tab record that is gone.
|
|
578
|
+
* @param d - draft state.
|
|
579
|
+
* @param tabId - the tab that went away.
|
|
580
|
+
*/
|
|
581
|
+
forget: (d, tabId) => {
|
|
582
|
+
d.byTab = Object.fromEntries(Object.entries(d.byTab).filter(([id]) => id !== tabId));
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
//#endregion
|
|
588
|
+
//#region lib/types/client/index.js
|
|
589
|
+
/** This package's copy namespace. */
|
|
590
|
+
const NS = "sidebarPlans";
|
|
591
|
+
/**
|
|
592
|
+
* Required browser services: the tab registry, the keyed seat, the Remote
|
|
593
|
+
* carrier and its namespace, and copy.
|
|
594
|
+
*/
|
|
595
|
+
const inject = [
|
|
596
|
+
"slots",
|
|
597
|
+
"locale",
|
|
598
|
+
"sidebarRightTabs",
|
|
599
|
+
"remote",
|
|
600
|
+
"remote.workspaceFiles"
|
|
601
|
+
];
|
|
602
|
+
/**
|
|
603
|
+
* Client plugin body: register the type, its dictionaries, and its body seat.
|
|
604
|
+
* @param ctx - client root context carrying the registry, the slots, and the Remote face.
|
|
605
|
+
*/
|
|
606
|
+
function apply(ctx) {
|
|
607
|
+
const t = ctx.locale.bind(NS);
|
|
608
|
+
ctx.effect(() => ctx.sidebarRightTabs.register(plansDefinition(t)), "ui-sidebar-plans: plans type");
|
|
609
|
+
ctx.effect(() => ctx.locale.register(NS, {
|
|
610
|
+
zh,
|
|
611
|
+
en
|
|
612
|
+
}), "ui-sidebar-plans: dictionaries");
|
|
613
|
+
const store = createPlansStore();
|
|
614
|
+
const inject = plansFace(createReader(ctx.remote));
|
|
615
|
+
ctx.effect(() => ctx.slots.inject("sidebar.right.pane.tab", () => ctx.slots.register({
|
|
616
|
+
name: "sidebar.right.pane.tab",
|
|
617
|
+
key: PLANS_ID,
|
|
618
|
+
locale: NS,
|
|
619
|
+
store,
|
|
620
|
+
inject
|
|
621
|
+
}, PlansBody)), "ui-sidebar-plans: plans tab body");
|
|
622
|
+
}
|
|
623
|
+
//#endregion
|
|
624
|
+
exports.apply = apply;
|
|
625
|
+
exports.inject = inject;
|
|
626
|
+
return module.exports;
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
//# sourceMappingURL=client.js.map
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { InjectFace, PropsLocale, PropsRuntime, PropsStore, TranslateNS } from '@qilin-agent/client-ui-slots';
|
|
3
|
+
import type { PlansInjected } from './face.ts';
|
|
4
|
+
import type { PlansTabState, createPlansStore } from './store.ts';
|
|
5
|
+
/**
|
|
6
|
+
* How often a visible panel scans again.
|
|
7
|
+
*
|
|
8
|
+
* The scan is a handful of directory listings and short reads, and this
|
|
9
|
+
* interval is what makes a plan document the agent just wrote appear without a
|
|
10
|
+
* gesture. A hidden tab polls nothing.
|
|
11
|
+
*/
|
|
12
|
+
export declare const PLAN_POLL_MS = 5000;
|
|
13
|
+
/** The body's composed props: the tab it draws, its store, its face, and its copy. */
|
|
14
|
+
export type PlansBodyProps = PropsRuntime<'sidebar.right.pane.tab'> & PropsStore<ReturnType<typeof createPlansStore>> & InjectFace<PlansInjected> & PropsLocale<'sidebarPlans'>;
|
|
15
|
+
/** The one status line the panel shows in place of rows. */
|
|
16
|
+
export interface PlansNotice {
|
|
17
|
+
/** Which state the panel is in; the value a spec reads off the DOM. */
|
|
18
|
+
readonly kind: 'loading' | 'empty' | 'noMatch' | 'failed';
|
|
19
|
+
/** The line to show. */
|
|
20
|
+
readonly line: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The panel's single status line, or `undefined` while it lists rows.
|
|
24
|
+
*
|
|
25
|
+
* A scan that could not be trusted takes the panel over: reporting no plans
|
|
26
|
+
* because the wire is down would be a lie about the workspace.
|
|
27
|
+
* @param t - namespace-bound translate.
|
|
28
|
+
* @param state - the tab's bucket.
|
|
29
|
+
* @param matches - how many rows the search kept.
|
|
30
|
+
* @returns the notice to draw, or `undefined` while rows are listed.
|
|
31
|
+
*/
|
|
32
|
+
export declare function plansNotice(t: TranslateNS<'sidebarPlans'>, state: PlansTabState, matches: number): PlansNotice | undefined;
|
|
33
|
+
/** The panel: the search row, then the plan documents of the session's workspace. */
|
|
34
|
+
export declare function PlansBody({ useTabInfo, sessionId, useSessions, useStore, refresh, t }: PlansBodyProps): ReactNode;
|
|
35
|
+
//# sourceMappingURL=PlansBody.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage one of this package's registration: what the `plans` tab type IS.
|
|
3
|
+
*
|
|
4
|
+
* The type is a page, not a viewer: it claims no address. The guide page
|
|
5
|
+
* offers it as an entry box, and each row opens its document through
|
|
6
|
+
* `tabActions.openResource` for the `qilin-resource://file` viewers to claim.
|
|
7
|
+
*/
|
|
8
|
+
import type { SidebarRightTabDefinition } from '@qilin-agent/client-ui-sidebar-right/client';
|
|
9
|
+
import type { TranslateNS } from '@qilin-agent/client-ui-slots';
|
|
10
|
+
/** The tab kind this package owns. */
|
|
11
|
+
export declare const PLANS_KIND = "plans";
|
|
12
|
+
/** This implementation's identity in the tab system, and the key its body registers under. */
|
|
13
|
+
export declare const PLANS_ID = "@qilin-agent/client-ui-sidebar-plans";
|
|
14
|
+
/**
|
|
15
|
+
* The plans type's registry definition.
|
|
16
|
+
* @param t - namespace-bound translate, read fresh on every label call.
|
|
17
|
+
* @returns the definition to register.
|
|
18
|
+
*/
|
|
19
|
+
export declare function plansDefinition(t: TranslateNS<'sidebarPlans'>): SidebarRightTabDefinition;
|
|
20
|
+
//# sourceMappingURL=definition.d.ts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plan list's asynchronous half: scanning the workspace into the store.
|
|
3
|
+
*
|
|
4
|
+
* The component never awaits anything. It calls `refresh`, and this face runs
|
|
5
|
+
* the pure {@link scanPlans} through the reader bound here and writes the
|
|
6
|
+
* outcome through the store's own actions — the Slot-standard `inject` shape,
|
|
7
|
+
* so the session id is resolved by the framework and the write set stays the
|
|
8
|
+
* store's.
|
|
9
|
+
*
|
|
10
|
+
* One tab has one scan in force: asking again — the reload gesture, the poll —
|
|
11
|
+
* retires the scan still in flight for it, whose settlement then writes
|
|
12
|
+
* nothing. Cleanup rides the owner's `signal`: no scan starts for a record
|
|
13
|
+
* that already ended, and when the record goes away its bucket and its
|
|
14
|
+
* generation are forgotten together.
|
|
15
|
+
*/
|
|
16
|
+
import type { ClientRemote } from '@qilin-agent/api-remotes/client';
|
|
17
|
+
import type { BoundActions } from '@qilin-agent/client-store';
|
|
18
|
+
import type { TabId } from '@qilin-agent/client-ui-dockkit';
|
|
19
|
+
import type { SessionId } from '@qilin-agent/session/types';
|
|
20
|
+
import type { PlanReader } from './plans.ts';
|
|
21
|
+
import type { createPlansStore } from './store.ts';
|
|
22
|
+
/**
|
|
23
|
+
* The slice of the Client Remote face this package calls: the
|
|
24
|
+
* `workspaceFiles` namespace's `list`, `read`, and `stat`, exactly as the
|
|
25
|
+
* Host's generated client declares them.
|
|
26
|
+
*/
|
|
27
|
+
export type WorkspaceFilesPlanRemote = {
|
|
28
|
+
readonly workspaceFiles: Pick<ClientRemote['workspaceFiles'], 'list' | 'read' | 'stat'>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Bind the scan to one Remote face.
|
|
32
|
+
*
|
|
33
|
+
* The namespace's three methods already have the reader's signatures: the
|
|
34
|
+
* session travels with every call because the endpoint resolves the workspace
|
|
35
|
+
* root from it, and a Remote call does not reject.
|
|
36
|
+
* @param remote - the Client Remote face carrying the `workspaceFiles` namespace.
|
|
37
|
+
* @returns the reader the pure scan performs.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createReader(remote: WorkspaceFilesPlanRemote): PlanReader;
|
|
40
|
+
/** The panel's injected business face, as the body receives it. */
|
|
41
|
+
export interface PlansInjected {
|
|
42
|
+
/**
|
|
43
|
+
* Scan this tab's workspace and write the outcome into its bucket.
|
|
44
|
+
* @param tabId - the tab being drawn.
|
|
45
|
+
* @param root - absolute path of the workspace root.
|
|
46
|
+
* @param signal - the tab record's lifetime.
|
|
47
|
+
*/
|
|
48
|
+
readonly refresh: (tabId: TabId, root: string, signal: AbortSignal) => void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Bind the panel's face to one reader.
|
|
52
|
+
* @param reader - the reader the scan performs.
|
|
53
|
+
* @returns the Slot `inject` factory: session and bound actions in, face out.
|
|
54
|
+
*/
|
|
55
|
+
export declare function plansFace(reader: PlanReader): (sessionId: SessionId, actions: BoundActions<ReturnType<typeof createPlansStore>>) => PlansInjected;
|
|
56
|
+
//# sourceMappingURL=face.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser half: register `plans` as a right-Sidebar page tab type.
|
|
3
|
+
*
|
|
4
|
+
* The public two-stage path, unmodified: the type into `ctx.sidebarRightTabs`,
|
|
5
|
+
* and the body into the keyed `sidebar.right.pane.tab` seat under the type's
|
|
6
|
+
* `id`.
|
|
7
|
+
*
|
|
8
|
+
* The file split is this package's layering: what the type IS
|
|
9
|
+
* (`definition.tsx`), what it keeps (`store.ts`), what the convention finds
|
|
10
|
+
* and how it is read (`plans.ts`, with its Remote binding in `face.ts`), what
|
|
11
|
+
* it draws (`PlansBody.tsx`), what it says (`locales.ts`), and this module,
|
|
12
|
+
* which only wires them together.
|
|
13
|
+
*/
|
|
14
|
+
import type { Context as ClientContext } from '@qilin-agent/kylin';
|
|
15
|
+
/**
|
|
16
|
+
* Required browser services: the tab registry, the keyed seat, the Remote
|
|
17
|
+
* carrier and its namespace, and copy.
|
|
18
|
+
*/
|
|
19
|
+
export declare const inject: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Client plugin body: register the type, its dictionaries, and its body seat.
|
|
22
|
+
* @param ctx - client root context carrying the registry, the slots, and the Remote face.
|
|
23
|
+
*/
|
|
24
|
+
export declare function apply(ctx: ClientContext): void;
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
declare module '@qilin-agent/client-ui-slots' {
|
|
2
|
+
interface LocaleNamespaceMap {
|
|
3
|
+
/** Task-plan type name, guide entry, search row, row states, and failure line. */
|
|
4
|
+
sidebarPlans: SidebarPlansKey;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/** Simplified Chinese dictionary and key-set source of truth. */
|
|
8
|
+
export declare const zh: {
|
|
9
|
+
'type.label': string;
|
|
10
|
+
'guide.title': string;
|
|
11
|
+
'guide.description': string;
|
|
12
|
+
'search.placeholder': string;
|
|
13
|
+
'search.label': string;
|
|
14
|
+
reload: string;
|
|
15
|
+
loading: string;
|
|
16
|
+
empty: string;
|
|
17
|
+
noMatch: string;
|
|
18
|
+
'error.failed': string;
|
|
19
|
+
noWorkspace: string;
|
|
20
|
+
};
|
|
21
|
+
/** Plans dictionary key union. */
|
|
22
|
+
export type SidebarPlansKey = keyof typeof zh;
|
|
23
|
+
/** English dictionary, checked against the Chinese key set. */
|
|
24
|
+
export declare const en: {
|
|
25
|
+
'type.label': string;
|
|
26
|
+
'guide.title': string;
|
|
27
|
+
'guide.description': string;
|
|
28
|
+
'search.placeholder': string;
|
|
29
|
+
'search.label': string;
|
|
30
|
+
reload: string;
|
|
31
|
+
loading: string;
|
|
32
|
+
empty: string;
|
|
33
|
+
noMatch: string;
|
|
34
|
+
'error.failed': string;
|
|
35
|
+
noWorkspace: string;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=locales.d.ts.map
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task-plan discovery: which workspace documents count as a plan, in what
|
|
3
|
+
* order, and what each row is titled.
|
|
4
|
+
*
|
|
5
|
+
* The convention is the one agents already write against, so the same files
|
|
6
|
+
* keep showing up: `plans/`, `docs/plans/`, and `.plans/` contribute their
|
|
7
|
+
* top-level `*.md` entries, and the root `plan.md`, `PLAN.md`, and the same
|
|
8
|
+
* name in the workspace's docs directory are well-known documents whether or
|
|
9
|
+
* not any such directory exists. Deeper nesting is deliberately ignored — a plan tree is a
|
|
10
|
+
* convention, not a filesystem walk.
|
|
11
|
+
*
|
|
12
|
+
* Two facts of the `workspaceFiles` wire shape these rules:
|
|
13
|
+
*
|
|
14
|
+
* - Identity comes from the path, case-folded. The endpoint's `stat` reports no
|
|
15
|
+
* device or inode — {@link WorkspaceFileStat} carries an absolute path, an
|
|
16
|
+
* opaque `version`, and a byte size — so the file a case-insensitive volume
|
|
17
|
+
* holds under two spellings (`plan.md` and `PLAN.md` on macOS) is deduped
|
|
18
|
+
* by its folded path rather than by `dev:ino`.
|
|
19
|
+
* - There is no modification time to order by: `version` is an opaque
|
|
20
|
+
* freshness token the Client never parses. Rows therefore keep the order the
|
|
21
|
+
* convention declares — `plans/`, then `docs/plans/`, then `.plans/`, then
|
|
22
|
+
* the well-known documents — which is stable across polls.
|
|
23
|
+
*
|
|
24
|
+
* Everything here is pure over an injected {@link PlanReader}, so discovery,
|
|
25
|
+
* dedupe, cap, title, and filter rules are unit-tested without a filesystem.
|
|
26
|
+
*/
|
|
27
|
+
import type { RemoteFailure, RemoteResult } from '@qilin-agent/api-remotes/client';
|
|
28
|
+
import type { WorkspaceDirectoryListing, WorkspaceFileRange, WorkspaceFileStat, WorkspaceFileText } from '@qilin-agent/api-workspace-files/types';
|
|
29
|
+
import type { SessionId } from '@qilin-agent/session/types';
|
|
30
|
+
/** Directories whose top level is scanned for `*.md` plan documents. */
|
|
31
|
+
export declare const PLAN_DIRS: readonly ["plans", "docs/plans", ".plans"];
|
|
32
|
+
/**
|
|
33
|
+
* Well-known plan document paths, relative to the workspace root.
|
|
34
|
+
*
|
|
35
|
+
* The docs-directory member is built from its directory's name because a
|
|
36
|
+
* literal `docs/….md` reads to `verify-doc-refs` as a path into this
|
|
37
|
+
* repository's own documentation; this one names a file in the user's
|
|
38
|
+
* workspace.
|
|
39
|
+
*/
|
|
40
|
+
export declare const PLAN_FILES: readonly ["plan.md", "PLAN.md", "docs/plan.md"];
|
|
41
|
+
/** How many plans one scan lists; a runaway `plans/` directory stays bounded. */
|
|
42
|
+
export declare const PLAN_LIMIT = 20;
|
|
43
|
+
/** One plan document as the panel consumes it. */
|
|
44
|
+
export interface PlanRow {
|
|
45
|
+
/** Absolute path inside the session's workspace; the resource address's target. */
|
|
46
|
+
readonly path: string;
|
|
47
|
+
/** File name, the title fallback. */
|
|
48
|
+
readonly base: string;
|
|
49
|
+
/** Display path relative to the workspace root (`plans/plan.md`). */
|
|
50
|
+
readonly rel: string;
|
|
51
|
+
/** The document's first heading, or its extension-less file name. */
|
|
52
|
+
readonly title: string;
|
|
53
|
+
}
|
|
54
|
+
/** One discovered document before dedupe and title resolution. */
|
|
55
|
+
export interface PlanCandidate {
|
|
56
|
+
/** Absolute path inside the session's workspace. */
|
|
57
|
+
readonly path: string;
|
|
58
|
+
/** File name. */
|
|
59
|
+
readonly base: string;
|
|
60
|
+
/** Display path relative to the workspace root. */
|
|
61
|
+
readonly rel: string;
|
|
62
|
+
}
|
|
63
|
+
/** What one scan produced. */
|
|
64
|
+
export interface PlanScan {
|
|
65
|
+
/** The documents found, in the convention's order. */
|
|
66
|
+
readonly rows: readonly PlanRow[];
|
|
67
|
+
/**
|
|
68
|
+
* The first failure that is not a convention entry's absence, when the scan
|
|
69
|
+
* could not be trusted. A failed title read is not one: the file name is
|
|
70
|
+
* still a truthful row title.
|
|
71
|
+
*/
|
|
72
|
+
readonly failure?: RemoteFailure;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The reads one scan performs, injected so the rules above stay pure.
|
|
76
|
+
*
|
|
77
|
+
* A call does not reject: the endpoint's result carries the failure.
|
|
78
|
+
*/
|
|
79
|
+
export interface PlanReader {
|
|
80
|
+
/**
|
|
81
|
+
* List one directory's direct children.
|
|
82
|
+
* @param sessionId - the session whose workspace resolves the path.
|
|
83
|
+
* @param path - absolute directory path.
|
|
84
|
+
* @param signal - cancels the call.
|
|
85
|
+
* @returns the listing, or the failure the Host declares.
|
|
86
|
+
*/
|
|
87
|
+
list(sessionId: SessionId, path: string, signal: AbortSignal): Promise<RemoteResult<WorkspaceDirectoryListing>>;
|
|
88
|
+
/**
|
|
89
|
+
* Read one page of a document's lines.
|
|
90
|
+
* @param sessionId - the session whose workspace resolves the path.
|
|
91
|
+
* @param path - absolute document path.
|
|
92
|
+
* @param range - 1-based first line and the page's line count.
|
|
93
|
+
* @param signal - cancels the call.
|
|
94
|
+
* @returns the page, or the failure the Host declares.
|
|
95
|
+
*/
|
|
96
|
+
read(sessionId: SessionId, path: string, range: WorkspaceFileRange, signal: AbortSignal): Promise<RemoteResult<WorkspaceFileText>>;
|
|
97
|
+
/**
|
|
98
|
+
* Report one document's identity without its content.
|
|
99
|
+
* @param sessionId - the session whose workspace resolves the path.
|
|
100
|
+
* @param path - absolute document path.
|
|
101
|
+
* @param signal - cancels the call.
|
|
102
|
+
* @returns the file's identity, or the failure the Host declares.
|
|
103
|
+
*/
|
|
104
|
+
stat(sessionId: SessionId, path: string, signal: AbortSignal): Promise<RemoteResult<WorkspaceFileStat>>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The row title for one document: its first `#`/`##`/`###` heading from the
|
|
108
|
+
* head, else the file name without its `.md`. A blank heading falls through to
|
|
109
|
+
* the fallback.
|
|
110
|
+
* @param head - the document's opening text, already bounded.
|
|
111
|
+
* @param base - the document's file name.
|
|
112
|
+
* @returns the title to show.
|
|
113
|
+
*/
|
|
114
|
+
export declare function planTitleFromHead(head: string, base: string): string;
|
|
115
|
+
/**
|
|
116
|
+
* Dedupe by case-folded absolute path and cap.
|
|
117
|
+
*
|
|
118
|
+
* Never by document identity: this endpoint reports none, and a path-keyed set
|
|
119
|
+
* is what keeps one file listed twice under two spellings on a
|
|
120
|
+
* case-insensitive volume.
|
|
121
|
+
* @param found - the documents in discovery order.
|
|
122
|
+
* @param limit - how many to keep.
|
|
123
|
+
* @returns the unique documents, capped.
|
|
124
|
+
*/
|
|
125
|
+
export declare function selectPlans(found: readonly PlanCandidate[], limit?: number): PlanCandidate[];
|
|
126
|
+
/**
|
|
127
|
+
* The rows a search keeps: a case-insensitive substring of the title or the
|
|
128
|
+
* display path. A blank query keeps every row.
|
|
129
|
+
* @param rows - the scanned rows.
|
|
130
|
+
* @param query - what the search box holds.
|
|
131
|
+
* @returns the rows to draw, in their scanned order.
|
|
132
|
+
*/
|
|
133
|
+
export declare function filterPlans(rows: readonly PlanRow[], query: string): readonly PlanRow[];
|
|
134
|
+
/**
|
|
135
|
+
* Scan one workspace for plan documents: the convention directories' top
|
|
136
|
+
* level, then the well-known paths, each surviving document's title resolved.
|
|
137
|
+
*
|
|
138
|
+
* A missing directory or file is the normal case — any subset of the
|
|
139
|
+
* convention may exist — and is skipped. A failure that is not an absence is
|
|
140
|
+
* carried out so the panel can say the workspace was not read, rather than
|
|
141
|
+
* report that it holds no plans.
|
|
142
|
+
* @param sessionId - the session whose workspace is scanned.
|
|
143
|
+
* @param root - absolute path of the workspace root.
|
|
144
|
+
* @param reader - the reads the scan performs.
|
|
145
|
+
* @param signal - the tab record's lifetime.
|
|
146
|
+
* @returns the rows found and the first failure worth reporting.
|
|
147
|
+
*/
|
|
148
|
+
export declare function scanPlans(sessionId: SessionId, root: string, reader: PlanReader, signal: AbortSignal): Promise<PlanScan>;
|
|
149
|
+
//# sourceMappingURL=plans.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plan panel's view state: what each tab last scanned.
|
|
3
|
+
*
|
|
4
|
+
* A scan per tab is state the type owns, so it lives in a Slot-standard
|
|
5
|
+
* exclusive store (one instance per session), bucketed by tab id because two
|
|
6
|
+
* tabs of this kind scan independently. Keeping it here is also what makes a
|
|
7
|
+
* tab switch cheap: the body unmounts and remounts while its record lives, and
|
|
8
|
+
* the list it already scanned is still in its bucket.
|
|
9
|
+
*
|
|
10
|
+
* Writers run between `scanning` and `forget`, and the face stops dispatching
|
|
11
|
+
* once the record's signal aborts.
|
|
12
|
+
*/
|
|
13
|
+
import { type EngineStoreHandle } from '@qilin-agent/client-store';
|
|
14
|
+
import type { RemoteFailure } from '@qilin-agent/api-remotes/client';
|
|
15
|
+
import type { TabId } from '@qilin-agent/client-ui-dockkit';
|
|
16
|
+
import type { PlanRow } from './plans.ts';
|
|
17
|
+
/** What one tab last scanned. */
|
|
18
|
+
export interface PlansTabState {
|
|
19
|
+
/** The rows the last settled scan produced, in the convention's order; empty until one settles. */
|
|
20
|
+
readonly rows: readonly PlanRow[];
|
|
21
|
+
/** Whether a scan is in flight. */
|
|
22
|
+
readonly scanning: boolean;
|
|
23
|
+
/** Why the last settled scan could not be trusted; absent while there is nothing to report. */
|
|
24
|
+
readonly failure?: RemoteFailure;
|
|
25
|
+
}
|
|
26
|
+
/** Every tab's plan list, keyed by tab id. */
|
|
27
|
+
export interface PlansState {
|
|
28
|
+
byTab: Record<TabId, PlansTabState>;
|
|
29
|
+
}
|
|
30
|
+
/** The panel store's write set; every action names the tab it writes. */
|
|
31
|
+
type PlansActions = {
|
|
32
|
+
scanning: (draft: PlansState, tabId: TabId) => void;
|
|
33
|
+
settled: (draft: PlansState, tabId: TabId, rows: readonly PlanRow[], failure: RemoteFailure | undefined) => void;
|
|
34
|
+
forget: (draft: PlansState, tabId: TabId) => void;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Declare the plan panel's store.
|
|
38
|
+
*
|
|
39
|
+
* A factory rather than a shared handle: the registration declares it as an
|
|
40
|
+
* exclusive store, so the framework mints one instance per session.
|
|
41
|
+
* @returns the store handle to declare on the registration.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createPlansStore(): EngineStoreHandle<PlansState, PlansActions>;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=store.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,77 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qilin-agent/client-ui-sidebar-plans",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"description": "Task-plan tab type for the right Sidebar: scans the session workspace's convention plan documents and opens one as a file resource",
|
|
4
|
+
"version": "3.1.4",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/kkutysllb/QiLin.git",
|
|
11
|
+
"directory": "packages/client/ui-sidebar-plans"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": "^22.19.0 || >=24.0.0"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "lib/index.js",
|
|
18
|
+
"types": "lib/types/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./lib/types/index.d.ts",
|
|
22
|
+
"default": "./lib/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./client": {
|
|
25
|
+
"types": "./lib/types/client/index.d.ts",
|
|
26
|
+
"default": "./lib/client.js"
|
|
27
|
+
},
|
|
28
|
+
"./src/*": "./src/*",
|
|
29
|
+
"./package.json": "./package.json"
|
|
30
|
+
},
|
|
31
|
+
"qilin": {
|
|
32
|
+
"client": {
|
|
33
|
+
"inject": [
|
|
34
|
+
"@qilin-agent/api-workspace-files",
|
|
35
|
+
"@qilin-agent/client-ui-sidebar-right",
|
|
36
|
+
"@qilin-agent/client-ui-session",
|
|
37
|
+
"@qilin-agent/api-remotes"
|
|
38
|
+
],
|
|
39
|
+
"platform": "web"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@qilin-agent/kylin": "~4.0.3"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@testing-library/react": "^16.1.0",
|
|
48
|
+
"@types/react": "~18.3.1",
|
|
49
|
+
"@types/react-dom": "~18.3.0",
|
|
50
|
+
"react": "^18.2.0",
|
|
51
|
+
"clsx": "^2.0.0",
|
|
52
|
+
"react-dom": "^18.2.0",
|
|
53
|
+
"@qilin-agent/kylin": "~4.0.3",
|
|
54
|
+
"@qilin-agent/client-locale": "3.1.4",
|
|
55
|
+
"@qilin-agent/api-workspace-files": "3.1.4",
|
|
56
|
+
"@qilin-agent/client-test-runtime": "3.1.4",
|
|
57
|
+
"@qilin-agent/api-remotes": "3.1.4",
|
|
58
|
+
"@qilin-agent/client-store": "3.1.4",
|
|
59
|
+
"@qilin-agent/client-ui-dockkit": "3.1.4",
|
|
60
|
+
"@qilin-agent/client-ui-primitives": "3.1.4",
|
|
61
|
+
"@qilin-agent/client-ui-renderer": "3.1.4",
|
|
62
|
+
"@qilin-agent/client-ui-session": "3.1.4",
|
|
63
|
+
"@qilin-agent/session": "3.1.4",
|
|
64
|
+
"@qilin-agent/client-ui-sidebar-right": "3.1.4",
|
|
65
|
+
"@qilin-agent/client-ui-slots": "3.1.4",
|
|
66
|
+
"@qilin-agent/util-workspace-path": "3.1.4"
|
|
67
|
+
},
|
|
68
|
+
"files": [
|
|
69
|
+
"lib/index.js",
|
|
70
|
+
"lib/client.js",
|
|
71
|
+
"lib/types/**/*.d.ts"
|
|
72
|
+
],
|
|
73
|
+
"scripts": {
|
|
74
|
+
"bundle": "tsdown",
|
|
75
|
+
"watch": "tsdown --watch"
|
|
76
|
+
}
|
|
6
77
|
}
|