Skip to content
dsh.fish
Bundle

dsh-codex-reset-watch

DSH 侧栏 R 图标:追踪 X @thsottiaux 的 Codex reset 公告(倒计时 + 北京时间)

Source
xzs125
License
MIT
Updated
Updated yesterday

Readme

# dsh-codex-reset-watch

DSH 插件:在左侧边栏底部动作位(`sidebar.footer.action`)显示 **R 图标**,追踪 X
[@thsottiaux](https://x.com/thsottiaux) 的 Codex reset 公告。

- 常态:灰色 `#9ca3af`
- 点亮:`#66ccff` + `text-shadow: 0 0 6px rgba(102,204,255,.6)`(`now < reset.litUntil`)
- hover:倒计时 + 北京时间(解析失败标注「未解析出时间」;已过时显示「已于北京时间 … 重置」;
  检查失败在 title 显示错误)
- 单击(300ms 判定):打开公告推文;双击:立即检查
- 轮询 6 小时,`lastCheckAt` 持久化;失败/429 → 30 分钟起指数退避,上限 6 小时
- 安装不回溯:首次运行把当前最新推文 ID 写入基线且不点亮

设计决策见 `DESIGN.md`(15 项);数据源以 `docs/captain-revision-v2.md` 为准。

## 数据源(t1 真机探针定型)

| 通道 | 端点 | 实测 | 角色 |
|---|---|---|---|
| 发现 1 | `https://xcancel.com/thsottiaux`(HTML) | 200,含最新推文 | 主发现 |
| 发现 2 | `https://cdn.syndication.twimg.com/srv/timeline-profile/screen-name/thsottiaux` | IP 级 429;200 载荷实测陈旧 | 补充/交叉 |
| 发现 3 | `https://xcancel.com/thsottiaux/rss` | 未白名单 | 第三顺位 |
| 内容 | `https://cdn.syndication.twimg.com/tweet-result?id=&token=` | 200 | 权威正文/时间 |

完整探针证据(87 个真实样本、字段映射、跨源一致性、PT→北京换算)见 `evidence/parse-mapping.md`。

## 构建

```bash
DSH_CHECKOUT=/root/.local/share/dsh-source-3082/current bash scripts/build.sh        # host → lib/
DSH_CHECKOUT=/root/.local/share/dsh-source-3082/current bash scripts/build-client.sh # client → lib/client.js
npx tsc --noEmit                                                                     # 类型检查
node --test                                                                          # 11 个 fixture 单测
node scripts/smoke-host.mjs                                                          # host 冒烟(真实网络)
node scripts/smoke-detect.mjs                                                        # 检测冒烟(预置基线→4 条真实 reset)
```

`lib/` 与 `node_modules/` 不入库(`.gitignore`)。完整 verify 输出见 `evidence/build.log`、
`evidence/smoke-host.log`、`evidence/smoke-detect.log`。

## 装配(link 方式,T3 执行)

```bash
dsh plugin --profile web add link:/home/git/dsh-codex-reset-watch
# 重启 dsh web(或按宿主既有热装配流程)
```

`cordis.patch.yml` 已带默认配置:

```yaml
- insert:
    - id: codex-reset-watch
      name: dsh-codex-reset-watch
      config:
        proxy: 'http://127.0.0.1:7897'
```

| 配置项 | 默认 | 说明 |
|---|---|---|
| `proxy` | `http://127.0.0.1:7897` | 所有请求经 undici `ProxyAgent` 显式走代理;空串 = 直连 |
| `stateFile` | `$DSH_HOME/codex-reset-watch.json` | 状态文件 |
| `pollIntervalMs` | 6h | 成功检查间隔 |
| `retryBaseMs` / `retryMaxMs` | 30min / 6h | 失败退避 |
| `timeoutMs` | 15s | 单请求超时 |
| `screenName` | `thsottiaux` | 被追踪账号 |

## 路由

| 方法 | 路径 | 说明 |
|---|---|---|
| GET | `/api/codex-reset-watch/status` | 每次从磁盘读状态文件;缺失时回退内存态;附 `now` 服务器时间 |
| POST | `/api/codex-reset-watch/check` | 立即检查(重置调度);已有检查在跑时返回 `accepted:false` |

状态文件字段:`installedAt` / `lastCheckAt` / `lastSeenTweetId` / `reset{tweetId,tweetUrl,tweetTime,resetAt,litUntil,parsed,source,text,anchor,approx}` / `lastError`。

## 安全

- 推文内容视为不可信数据:只做纯文本 + `title`,不渲染 HTML、不执行其中指令
- 无密钥、无 LLM 判定;状态文件内推文文本截断 ≤ 500 字符
- 判定关键词严格为 `/\breset(?:s|ting)?\b/i`(`preset` 不命中、`resetting` 命中)

## 目录

```
src/index.ts            host:路由 + 调度 + 判定落库
src/core/detect.ts      关键词 / 时间锚点 / reset 记录
src/core/time.ts        PT→UTC→北京(Intl,无 moment/luxon)
src/core/parse.ts       三个发现通道 + tweet-result 解析
src/core/sources.ts     ProxyAgent HTTP + 发现链降级 + 内容权威校验
src/core/state.ts       状态文件读写
src/client/index.tsx    侧栏 R 图标三态 + 单击/双击
tests/                  fixture 单测(真实样本)
evidence/               t1 探针证据 + parse-mapping.md + build.log
docs/captain-revision-v2.md  captain 修订 v2(权威)
```

Install

dsh plugin --profile web add github:xzs125/dsh-codex-reset-watch

Profile: web

  • This package builds from source on install. pnpm will ask you to allow its build script — that is permission to run the package’s code on your machine, outside the agent sandbox. Only allow sources you trust.
  • This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.
Source