dsh-handoff-baton 0.0.0-stage → 0.3.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.
- package/CHANGELOG.md +73 -0
- package/LICENSE +21 -0
- package/README.md +143 -2
- package/README.zh-CN.md +144 -0
- package/bin/baton.mjs +492 -0
- package/cordis.patch.yml +15 -0
- package/docs/DETAIL.en.md +105 -0
- package/docs/DETAIL.md +105 -0
- package/examples/sample-handoff.md +49 -0
- package/icon.svg +4 -0
- package/index.js +498 -0
- package/lib/command.js +60 -0
- package/lib/maintenance.js +75 -0
- package/lib/nudge.js +108 -0
- package/lib/protocol.js +502 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +76 -4
- package/skills/baton/SKILL.md +145 -0
- package/skills/baton/references/PROTOCOL.md +168 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.1 · 2026-11-29
|
|
4
|
+
|
|
5
|
+
文档与元数据修正。
|
|
6
|
+
|
|
7
|
+
- README 的中英文互链改为 GitHub 绝对地址,npm 页面不再跳到 404
|
|
8
|
+
- `package.json` 补 `homepage` / `bugs`,`repository` 指向 WeiLuo114514/handoff-baton
|
|
9
|
+
|
|
10
|
+
## 0.3.0 · 2026-11-29
|
|
11
|
+
|
|
12
|
+
补完整性:先看后写、可续写、可对账、并发安全。
|
|
13
|
+
|
|
14
|
+
- `baton write --dry-run`:只渲染预览、不写盘;`--quiet` 只打印短码
|
|
15
|
+
- `baton_handoff` 加 `dryRun`:技能改成「先出预览给用户看,点头再落盘」,不再靠提示词自觉
|
|
16
|
+
- 新增 `baton update <file> --json payload.json`:就地改写七节,保留 `id` / `created`,头里加 `updated`,顺带刷新索引标题与时间
|
|
17
|
+
- 新增 `baton sync [--fix]`:目录与索引对账——未登记的补、指向已删文件的删、标题不一致的改;默认只报告
|
|
18
|
+
- `verify` 新增两类告警(章节仍是「(待补)」、单份超 8KB),`--strict` 时告警也算不通过
|
|
19
|
+
- 索引写入加目录锁 + 临时文件原子替换:多窗口同时交接不再互相覆盖,也不会留半截索引
|
|
20
|
+
- `/baton pick` 先查索引再排队:唯一时直接接手并告诉你哪份,多份直接给候选不排队,指定路径先校验存在
|
|
21
|
+
- `--json` 模式下失败也输出 `{ ok: false, error }`
|
|
22
|
+
- 测试 58 项(协议 13 + 文档 12 + 提醒 10 + 指令 7 + 索引 10 + 体检 6)
|
|
23
|
+
- 图标换成正式版:透明底、鲸鱼尾鳍递出接力棒,采用 256 PNG 内嵌 SVG(32KB),旧图备份在 `.preview/icon.old.svg`
|
|
24
|
+
- 全部用户可见文案改为正式书面语:插件名改为「任务交接棒」,工具描述、指令回执、提醒、体检提示、CLI 输出统一术语(接棒口令、进行中、在用)
|
|
25
|
+
- 新增 `COPY.md`:用户可见文案清单,标注可改项与不可改的结构字符串
|
|
26
|
+
- 中英双语:README 改为英文主文档并互链中文版;新增 `docs/DETAIL.en.md`,`locale/en.json` 的 `meta.detail` 指向英文正文(此前英文用户会看到中文详情页)
|
|
27
|
+
|
|
28
|
+
## 0.2.0 · 2026-11-29
|
|
29
|
+
|
|
30
|
+
索引维护。
|
|
31
|
+
|
|
32
|
+
- 索引行升级成 `- [标题](路径) — 状态 · YYYY-MM-DDTHH:mm`,状态三态:进行中 / 已接手 / 已关闭;只有日期的 v1 旧行照读(时间按当天零点)
|
|
33
|
+
- 新增 `baton resolve`:裸标记该接哪份。唯一目标退出 0 并给出路径;多份退出 2 并列候选;全关退出 1
|
|
34
|
+
- 新增 `baton touch <file> --status`:接手即标「已接手」,收尾标「已关闭」,顺带刷新更新时间
|
|
35
|
+
- `baton list` 显示状态与时间,`--open` 只看在用的
|
|
36
|
+
- 新增 `baton prune`:清理「已关闭且超过 N 天」的条目,默认只报告;`--apply` 挪进 `handoff/archive/`,不删除
|
|
37
|
+
- 「最近活跃」改为索引里的更新时间,不再按创建时间;裸标记只在唯一时直接接,多份列候选先问
|
|
38
|
+
- 索引读写忽略 BOM,Windows 编辑器保存过的索引不会污染行
|
|
39
|
+
- 新增 `baton status`:体检索引——在用/已关闭计数、超过 `--stale-days`(默认 7)天没更新的滞留任务、已关闭是否该归档;`/baton status` 也会带同样的提示
|
|
40
|
+
- 写交接后自动体检,有滞留或可清理项就在 stderr 提示一句(不打断 JSON 输出)
|
|
41
|
+
- `resolve` 命中超过 7 天没更新的条目时加一句「可能已经过时」
|
|
42
|
+
- 配置新增 `staleDays`(7)/ `closedDays`(30)/ `maxClosed`(20)
|
|
43
|
+
- 体检是纯数据计算:CLI 与斜杠指令直接给用户看,不花模型调用;只有 `baton_handoff` 工具的 `hints` 会进上下文(且仅在非空时)
|
|
44
|
+
- 测试 54 项(协议 11 + 文档 12 + 提醒 10 + 指令 7 + 索引 8 + 体检 6)
|
|
45
|
+
|
|
46
|
+
## 0.1.0 · 2026-11-29
|
|
47
|
+
|
|
48
|
+
首个版本。
|
|
49
|
+
|
|
50
|
+
- 交接棒协议 v1:HTML 注释头 + 七节正文,跨模型可读
|
|
51
|
+
- 技能 `baton-handoff`:判断压力 → 查用户已有归档习惯 → 确认 → 写文档 → 归档 → 出接棒码
|
|
52
|
+
- 工具 `baton_check`:按 token 数给 ok / warn / handoff 档位
|
|
53
|
+
- 工具 `baton_handoff`:一次调用完成写文档 + 追加索引 + 生成接棒码
|
|
54
|
+
- CLI `baton`:check / init / write / new / verify / code / archive / list,零依赖
|
|
55
|
+
- 自带测试 40 项:协议 11 项(自洽、缺章节、空章节、缺头、打码、slug、id、口令解析、写盘、索引幂等)+ 文档一致性 12 项(frontmatter、CLI 路径、命令清单、文件名约定、头部路径、口令可查、/baton 可查、歧义先问、files/版本)+ 提醒判定 10 项 + 指令解析 7 项
|
|
56
|
+
|
|
57
|
+
发布前修正:
|
|
58
|
+
|
|
59
|
+
- 头部 `workspace` 字段不再写绝对路径,只写工作区名或相对路径
|
|
60
|
+
- 技能与 README 的「拷哪个目录」说明改正:CLI 在包根 `bin/` 与 `lib/`,只拷 `skills/baton/` 时走手写路径
|
|
61
|
+
- 新增「没有 CLI 时」降级流程,技能不再隐含依赖 Node 或任何其他插件
|
|
62
|
+
- 新增 `test/docs.test.mjs` 防文档与实现脱节
|
|
63
|
+
- 新增 `PUBLISHING.md`:发布命令统一带 `--userconfig E:\DSH\.npmrc`
|
|
64
|
+
- 接棒口令加标记 `⟦baton⟧`(ASCII 别名 `<<baton>>` / `[[baton]]`):新会话只认第一个非空行,没标记就当普通对话,避免误触
|
|
65
|
+
- 口令三型:裸标记(接 `handoff/INDEX.md` 最新一条)/ 短码(带路径)/ 长码(自解释,跨模型)
|
|
66
|
+
- CLI 新增 `entry` 子命令识别口令;`code` 默认只打短码,`--long` 才打长码
|
|
67
|
+
- 新增压力提醒钩子:挂 `agent/pre-step` + `session/event`,读 `assistant/message` 的 usage 与 `request/context` 的 contextWindow,在 60% / 80% / 压缩后各提醒一次(每会话每档一次,约 25 token);判定在插件进程里,0 token
|
|
68
|
+
- 宿主 `@deepseek-ai/dsh-llm` 拿不到时自动降级:只注册技能与工具,不装钩子
|
|
69
|
+
- 配置新增 `nudge` / `warnRatio` / `handoffRatio`
|
|
70
|
+
- 新增 `/baton` 斜杠指令:`/baton [now|标题]` 写交接、`/baton pick [路径]` 接手、`/baton status` 看占比、`/baton list` 列已有交接;写与接手通过 `agent.followup()` 排进下一轮,status/list 直接回答不花模型调用
|
|
71
|
+
- 配置新增 `registerCommand`
|
|
72
|
+
- 裸标记接入改为「别猜」:进行中只有一份才直接用,多于一份列候选先问;文档与技能里写明并行任务一律用短码,裸标记只做同任务快速恢复
|
|
73
|
+
- 提醒新增 `minTokens`(默认 `0`):已用量低于此值一条都不提醒,用来压掉小会话噪音;只减少提醒,不改动 60%/80% 两条比例线
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 未洛 (Well)
|
|
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.md
CHANGED
|
@@ -1,3 +1,144 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Task Handoff Baton · dsh-handoff-baton
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
English | [简体中文](https://github.com/WeiLuo114514/handoff-baton/blob/main/README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Turn "one conversation that keeps growing" into "one document plus one marker".
|
|
6
|
+
|
|
7
|
+
A DeepSeek Harness plugin, a model-agnostic skill, and a zero-dependency CLI. When the context is about to run out, it turns the current work into a seven-section handoff document, files it in an index, and emits a continuation phrase a new session can act on directly.
|
|
8
|
+
|
|
9
|
+
## Why a handoff at all
|
|
10
|
+
|
|
11
|
+
A long conversation is charged on every request: 300k tokens of history are replayed each turn. In a real 30-day bill, 57% of the spend went to cached context replay, at an average of 359k tokens per request.
|
|
12
|
+
|
|
13
|
+
Opening a new session has always been cheaper. The reason it rarely happens is the retelling — requirements, progress, constraints, and what not to touch. This plugin turns that retelling into one symbol.
|
|
14
|
+
|
|
15
|
+
## What's in the box
|
|
16
|
+
|
|
17
|
+
| Piece | What it does |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| Protocol `baton:v1` | An HTML comment header plus seven sections. Plain Markdown, so any model that can read files can consume it. |
|
|
20
|
+
| Skill `baton-handoff` | Decides when a handoff is due, checks your existing archive convention, asks before writing, then writes, verifies, files, and emits the phrase. |
|
|
21
|
+
| Plugin | Two tools, one `/baton` command, one pressure nudge. |
|
|
22
|
+
| CLI `baton` | 15 subcommands, no dependencies, Node >= 20. Works without the plugin and without the host. |
|
|
23
|
+
|
|
24
|
+
The seven sections are: Goal / Status / Key files / Blockers / Next / Constraints / Evidence.
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
# DSH plugin (profile: desktop or web; restart afterwards)
|
|
30
|
+
dsh plugin --profile desktop add dsh-handoff-baton
|
|
31
|
+
|
|
32
|
+
# or from a local directory
|
|
33
|
+
dsh plugin --profile desktop add "file:/absolute/path/dsh-handoff-baton"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
After the restart: the plugin page reads "任务交接棒" (Task Handoff Baton), the skill is `baton-handoff`, the tools are `baton_check` and `baton_handoff`, and the command is `/baton`.
|
|
37
|
+
|
|
38
|
+
## Pick up a handoff
|
|
39
|
+
|
|
40
|
+
In the new session, make this the first message:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
⟦baton⟧ handoff/2026-11-29-0045-x.md
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
A bare `⟦baton⟧` continues from the open entry in `handoff/INDEX.md`, but only when exactly one entry is open. With several open, it lists the candidates and asks instead of guessing: picking the wrong task in a zero-context session is silent and expensive.
|
|
47
|
+
|
|
48
|
+
Only the first non-empty line counts. Anything without the marker is ordinary chat, so the skill cannot misfire. ASCII fallbacks: `<<baton>>`, `[[baton]]`.
|
|
49
|
+
|
|
50
|
+
For another model, or a host without the skill installed, use the long form:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
⟦baton⟧ 读 handoff/2026-11-29-0045-x.md(交接棒 v1 协议),从「下一步」第 1 条继续。
|
|
54
|
+
- 只按「关键文件」读真正需要的文件,别全量加载
|
|
55
|
+
- 动文件前先跟我确认
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Slash commands
|
|
59
|
+
|
|
60
|
+
| Command | Effect |
|
|
61
|
+
| --- | --- |
|
|
62
|
+
| `/baton` | Write a handoff. Asks for confirmation before anything is written. |
|
|
63
|
+
| `/baton <title>` | Same, with a title. |
|
|
64
|
+
| `/baton pick [path]` | Continue from a handoff. Without a path it resolves the index first. |
|
|
65
|
+
| `/baton status` | Context usage plus an index summary. |
|
|
66
|
+
| `/baton list` | List existing handoffs. |
|
|
67
|
+
| `/baton help` | Usage. |
|
|
68
|
+
|
|
69
|
+
`/baton` and `/baton pick` only queue a sentence for the next turn; the model still writes the document. `status` and `list` answer immediately and cost no model call.
|
|
70
|
+
|
|
71
|
+
## Index lifecycle
|
|
72
|
+
|
|
73
|
+
`handoff/INDEX.md` holds one line per handoff:
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
- [Audio pipeline](20261129-0939-audio.md) — 进行中 · 2026-11-29T09:39
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- States: 进行中 (open) → 已接手 (picked up) → 已关闭 (closed). "Live" means open or picked up, and ordering uses the update time, not the creation time.
|
|
80
|
+
- The receiving session flips a line to 已接手 after reading; the sender flips it to 已关闭 when the task ends. `baton touch <file> --status ...` does it in one command.
|
|
81
|
+
- `baton resolve` decides what a bare marker means: one target (exit 0), several candidates (exit 2), none (exit 1).
|
|
82
|
+
- `baton sync [--fix]` reconciles the directory with the index: unregistered files, entries pointing at deleted files, mismatched titles.
|
|
83
|
+
- `baton status` reports stuck entries (not updated for 7 days) and closed entries worth archiving. `baton prune` moves them to `handoff/archive/`; it reports by default and never deletes.
|
|
84
|
+
|
|
85
|
+
## CLI
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
node bin/baton.mjs check --tokens 300000 --window 800000
|
|
89
|
+
node bin/baton.mjs write --json payload.json [--dry-run] [--quiet]
|
|
90
|
+
node bin/baton.mjs update handoff/2026-11-29-0045-x.md --json payload.json
|
|
91
|
+
node bin/baton.mjs verify handoff/2026-11-29-0045-x.md [--strict]
|
|
92
|
+
node bin/baton.mjs code handoff/2026-11-29-0045-x.md [--long]
|
|
93
|
+
node bin/baton.mjs entry "⟦baton⟧ handoff/x.md"
|
|
94
|
+
node bin/baton.mjs archive handoff/x.md
|
|
95
|
+
node bin/baton.mjs list [--open]
|
|
96
|
+
node bin/baton.mjs status [--stale-days 7] [--closed-days 30] [--max-closed 20]
|
|
97
|
+
node bin/baton.mjs resolve [--json]
|
|
98
|
+
node bin/baton.mjs touch handoff/x.md [--status 进行中|已接手|已关闭]
|
|
99
|
+
node bin/baton.mjs sync [--fix]
|
|
100
|
+
node bin/baton.mjs prune [--older-than 30] [--apply]
|
|
101
|
+
node bin/baton.mjs new --title "标题"
|
|
102
|
+
node bin/baton.mjs init [--dir handoff]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Configuration
|
|
106
|
+
|
|
107
|
+
| Key | Default | Meaning |
|
|
108
|
+
| --- | --- | --- |
|
|
109
|
+
| `registerSkill` | `true` | Register the `baton-handoff` skill |
|
|
110
|
+
| `registerTools` | `true` | Register `baton_check` / `baton_handoff` |
|
|
111
|
+
| `registerCommand` | `true` | Register `/baton` |
|
|
112
|
+
| `defaultDir` | `handoff` | Handoff directory, relative to the workspace |
|
|
113
|
+
| `nudge` | `true` | Pressure reminders |
|
|
114
|
+
| `minTokens` | `0` | Stay quiet below this usage; reduces noise, never changes the thresholds |
|
|
115
|
+
| `warnRatio` | `0.6` | Halfway warning |
|
|
116
|
+
| `handoffRatio` | `0.8` | Handoff threshold |
|
|
117
|
+
| `staleDays` | `7` | Days without an update before an entry counts as stuck |
|
|
118
|
+
| `closedDays` | `30` | Days before a closed entry is eligible for archiving |
|
|
119
|
+
| `maxClosed` | `20` | Closed entries above this prompt a cleanup |
|
|
120
|
+
|
|
121
|
+
## How reminders work
|
|
122
|
+
|
|
123
|
+
The plugin subscribes to two host events: `session/event` for token usage and the context window, and `agent/pre-step` to decide once per turn.
|
|
124
|
+
|
|
125
|
+
Detection runs in the plugin process and costs no tokens. Only when a threshold is crossed does it inject a single line (about 25 tokens), at most once per session per tier — at 60%, at 80%, and after a compaction. There is no per-turn polling and no periodic prompt.
|
|
126
|
+
|
|
127
|
+
## Portability
|
|
128
|
+
|
|
129
|
+
- Whole package: `skills/` + `bin/` + `lib/`. Copy it anywhere Node >= 20 exists.
|
|
130
|
+
- Skill only: copy `skills/baton/` and write documents by hand; the CLI is optional.
|
|
131
|
+
- Claude Code: place it at `~/.claude/skills/baton-handoff/` — the directory name must match the frontmatter `name`.
|
|
132
|
+
- Codex / Cursor / others: merge `SKILL.md` into `AGENTS.md` or `.cursor/rules`, and keep `references/PROTOCOL.md` beside it.
|
|
133
|
+
|
|
134
|
+
## Limits
|
|
135
|
+
|
|
136
|
+
- Triggering still depends on the model or on you typing the command.
|
|
137
|
+
- Without host usage data, reminders switch off entirely.
|
|
138
|
+
- A timestamp cannot tell "actively worked" from "abandoned", so stuck-entry wording is a question, not a verdict.
|
|
139
|
+
- The index is not a backup of the conversation; export the original session separately if you need it.
|
|
140
|
+
- Verified mainly on Windows with DSH; cross-model was verified at the document level, not as a live trigger in another client.
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
MIT
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# 任务交接棒 · dsh-handoff-baton
|
|
2
|
+
|
|
3
|
+
[English](https://github.com/WeiLuo114514/handoff-baton/blob/main/README.md) | 简体中文
|
|
4
|
+
|
|
5
|
+
把「一条会话聊到爆」变成「一份文档 + 一个标记」。
|
|
6
|
+
|
|
7
|
+
DeepSeek Harness 插件 + 跨模型通用技能 + 零依赖 CLI。上下文即将耗尽时,将当前工作整理为七节交接文档、归档至索引,并生成新会话可直接使用的接棒口令。
|
|
8
|
+
|
|
9
|
+
## 为什么需要交接
|
|
10
|
+
|
|
11
|
+
长会话的每一次请求都要重放全部历史。一条 30 万 token 的会话,每轮都在为这 30 万 token 付费。真实账单中,30 天开销的 57% 花在缓存命中的上下文重放上,平均每请求 35.9 万 token。
|
|
12
|
+
|
|
13
|
+
新开会话一直更便宜,真正让人却步的是重新转述:需求、进度、约束、以及哪些东西不能动。本插件把这次转述压缩为一个标记。
|
|
14
|
+
|
|
15
|
+
## 组成
|
|
16
|
+
|
|
17
|
+
| 组成 | 说明 |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| 协议 `baton:v1` | 一个 HTML 注释头 + 七个章节。纯 Markdown,任何能读取文件的模型都能读取。 |
|
|
20
|
+
| 技能 `baton-handoff` | 判断何时交接,检查你已有的归档约定,写入前询问,随后写入、校验、归档并输出口令。 |
|
|
21
|
+
| 插件 | 两个工具、一个 `/baton` 指令、一个压力提醒。 |
|
|
22
|
+
| CLI `baton` | 15 个子命令,零依赖,Node >= 20。不安装插件、不依赖宿主也能使用。 |
|
|
23
|
+
|
|
24
|
+
七个章节为:目标 / 现状 / 关键文件 / 卡点与风险 / 下一步 / 约束 / 证据。
|
|
25
|
+
|
|
26
|
+
## 安装
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
# DSH 插件(profile 用 desktop 或 web,装完重启)
|
|
30
|
+
dsh plugin --profile desktop add dsh-handoff-baton
|
|
31
|
+
|
|
32
|
+
# 或从本地目录安装
|
|
33
|
+
dsh plugin --profile desktop add "file:/绝对路径/dsh-handoff-baton"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
重启后:插件页显示「任务交接棒」,技能名为 `baton-handoff`,工具为 `baton_check` 与 `baton_handoff`,指令为 `/baton`。
|
|
37
|
+
|
|
38
|
+
## 接手一份交接
|
|
39
|
+
|
|
40
|
+
在新会话的首条消息中使用:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
⟦baton⟧ handoff/2026-11-29-0045-x.md
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
仅发送裸标记 `⟦baton⟧` 时,将接手 `handoff/INDEX.md` 中处于进行中的那一份;但仅当恰好一条时才直接使用。多于一条时会列出候选并询问,不自行选择——在零上下文的新会话里接错任务是静默且代价高昂的。
|
|
47
|
+
|
|
48
|
+
只检查第一个非空行:没有标记即视为普通对话,技能不会误触。ASCII 备写形式为 `<<baton>>`、`[[baton]]`。
|
|
49
|
+
|
|
50
|
+
跨模型,或宿主未安装本技能时,使用长码:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
⟦baton⟧ 读 handoff/2026-11-29-0045-x.md(交接棒 v1 协议),从「下一步」第 1 条继续。
|
|
54
|
+
- 只按「关键文件」读真正需要的文件,别全量加载
|
|
55
|
+
- 动文件前先跟我确认
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 斜杠指令
|
|
59
|
+
|
|
60
|
+
| 指令 | 作用 |
|
|
61
|
+
| --- | --- |
|
|
62
|
+
| `/baton` | 编写交接。落盘前会先确认。 |
|
|
63
|
+
| `/baton <标题>` | 同上,并指定标题。 |
|
|
64
|
+
| `/baton pick [路径]` | 接手。未给路径时先查询索引。 |
|
|
65
|
+
| `/baton status` | 查看上下文用量与索引概况。 |
|
|
66
|
+
| `/baton list` | 列出已有交接。 |
|
|
67
|
+
| `/baton help` | 用法。 |
|
|
68
|
+
|
|
69
|
+
`/baton` 与 `/baton pick` 只将一条指令排入对话,文档仍由模型撰写;`status` 与 `list` 直接回答,不产生模型调用。
|
|
70
|
+
|
|
71
|
+
## 索引生命周期
|
|
72
|
+
|
|
73
|
+
`handoff/INDEX.md` 每行记录一次交接:
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
- [音频管线](20261129-0939-audio.md) — 进行中 · 2026-11-29T09:39
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- 状态:进行中 → 已接手 → 已关闭。「在用」包含前两者,排序使用更新时间而非创建时间。
|
|
80
|
+
- 接手方读取后将对应行改为「已接手」;发出方在任务结束时改为「已关闭」。`baton touch <文件> --status ...` 可一步完成。
|
|
81
|
+
- `baton resolve` 判断裸标记应接手哪一份:唯一目标(退出码 0)、多份候选(退出码 2)、无可用条目(退出码 1)。
|
|
82
|
+
- `baton sync [--fix]` 对账目录与索引:未登记文件、指向已删除文件的条目、标题不一致。
|
|
83
|
+
- `baton status` 报告滞留条目(超过 7 天未更新)与值得归档的已关闭条目。`baton prune` 将其移入 `handoff/archive/`,默认只报告,不删除。
|
|
84
|
+
|
|
85
|
+
## CLI
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
node bin/baton.mjs check --tokens 300000 --window 800000
|
|
89
|
+
node bin/baton.mjs write --json payload.json [--dry-run] [--quiet]
|
|
90
|
+
node bin/baton.mjs update handoff/2026-11-29-0045-x.md --json payload.json
|
|
91
|
+
node bin/baton.mjs verify handoff/2026-11-29-0045-x.md [--strict]
|
|
92
|
+
node bin/baton.mjs code handoff/2026-11-29-0045-x.md [--long]
|
|
93
|
+
node bin/baton.mjs entry "⟦baton⟧ handoff/x.md"
|
|
94
|
+
node bin/baton.mjs archive handoff/x.md
|
|
95
|
+
node bin/baton.mjs list [--open]
|
|
96
|
+
node bin/baton.mjs status [--stale-days 7] [--closed-days 30] [--max-closed 20]
|
|
97
|
+
node bin/baton.mjs resolve [--json]
|
|
98
|
+
node bin/baton.mjs touch handoff/x.md [--status 进行中|已接手|已关闭]
|
|
99
|
+
node bin/baton.mjs sync [--fix]
|
|
100
|
+
node bin/baton.mjs prune [--older-than 30] [--apply]
|
|
101
|
+
node bin/baton.mjs new --title "标题"
|
|
102
|
+
node bin/baton.mjs init [--dir handoff]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## 配置
|
|
106
|
+
|
|
107
|
+
| 键 | 默认 | 说明 |
|
|
108
|
+
| --- | --- | --- |
|
|
109
|
+
| `registerSkill` | `true` | 是否注册 `baton-handoff` 技能 |
|
|
110
|
+
| `registerTools` | `true` | 是否注册 `baton_check` / `baton_handoff` |
|
|
111
|
+
| `registerCommand` | `true` | 是否注册 `/baton` 指令 |
|
|
112
|
+
| `defaultDir` | `handoff` | 交接目录,相对当前工作区 |
|
|
113
|
+
| `nudge` | `true` | 是否启用压力提醒 |
|
|
114
|
+
| `minTokens` | `0` | 已用量低于此值时不再提醒;仅减少提醒,不改变阈值 |
|
|
115
|
+
| `warnRatio` | `0.6` | 过半提醒阈值 |
|
|
116
|
+
| `handoffRatio` | `0.8` | 交接阈值 |
|
|
117
|
+
| `staleDays` | `7` | 超过多少天未更新视为滞留 |
|
|
118
|
+
| `closedDays` | `30` | 已关闭超过多少天可归档 |
|
|
119
|
+
| `maxClosed` | `20` | 已关闭条目超过多少条提示清理 |
|
|
120
|
+
|
|
121
|
+
## 提醒如何工作
|
|
122
|
+
|
|
123
|
+
插件订阅两个宿主事件:`session/event` 用于获取 token 用量与上下文窗口,`agent/pre-step` 用于在每轮开始时判定一次。
|
|
124
|
+
|
|
125
|
+
判定在插件进程内完成,不消耗 token。只有当跨越阈值时才注入一行(约 25 token),且每会话每档最多一次——分别在 60%、80%、以及发生压缩之后。没有逐轮轮询,也没有周期性提示。
|
|
126
|
+
|
|
127
|
+
## 跨模型使用
|
|
128
|
+
|
|
129
|
+
- 整个包:`skills/` + `bin/` + `lib/`,复制到任何有 Node >= 20 的环境即可。
|
|
130
|
+
- 仅技能:复制 `skills/baton/`,按协议手写文档;CLI 为可选项。
|
|
131
|
+
- Claude Code:放置于 `~/.claude/skills/baton-handoff/`,目录名必须与 frontmatter 的 `name` 一致。
|
|
132
|
+
- Codex / Cursor / 其他:将 `SKILL.md` 并入 `AGENTS.md` 或 `.cursor/rules`,并保留 `references/PROTOCOL.md`。
|
|
133
|
+
|
|
134
|
+
## 局限
|
|
135
|
+
|
|
136
|
+
- 触发仍依赖模型判断或你主动执行指令。
|
|
137
|
+
- 没有宿主用量数据时,提醒功能整体关闭。
|
|
138
|
+
- 时间戳无法区分「仍在推进」与「已经搁置」,因此滞留提示是询问,不是结论。
|
|
139
|
+
- 索引不是对话备份;需要原始记录请另行导出会话。
|
|
140
|
+
- 主要在 Windows + DSH 环境验证;跨模型仅在文档层面验证,未在其他客户端实测触发。
|
|
141
|
+
|
|
142
|
+
## 许可
|
|
143
|
+
|
|
144
|
+
MIT
|