dsh-offhours 0.1.2 → 0.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/README.md CHANGED
@@ -26,9 +26,12 @@ npx dsh-offhours init --repo . --name myapp
26
26
  # 2) 体检(依赖、路径、worker 权限)
27
27
  npx dsh-offhours doctor
28
28
 
29
- # 3) 建一张卡(自动盖当前会话;没有 session 的卡跑批不会捡)
29
+ # 3) 建一张卡(必须在 dsh 会话里,或显式传当前会话 id)
30
+ # 最省事:在 dsh 里对 agent 说「用 offhours 技能建一张卡:给登录页补错误提示」。
31
+ # 终端命令需要带 --session;没有 sourceSessionId 的卡跑批永远不会捡。
30
32
  npx dsh-offhours card add "给登录页补错误提示" \
31
- --summary "目标:登录失败有提示。判据:npm test 通过。不做什么:不改后端。"
33
+ --summary "目标:登录失败有提示。判据:npm test 通过。不做什么:不改后端。" \
34
+ --session <当前 dsh 会话 id>
32
35
  ```
33
36
 
34
37
  之后低谷时段自动跑;也可以用面板「立即跑」或 `npx dsh-offhours run --once`。
@@ -70,7 +73,7 @@ npx dsh-offhours card add "给登录页补错误提示" \
70
73
  |---|---|
71
74
  | `npx dsh-offhours init --repo .` | 初始化配置/看板/特性 |
72
75
  | `npx dsh-offhours doctor` | 依赖与权限体检(失败退出非 0) |
73
- | `npx dsh-offhours card add "<标题>" --summary "<目标/判据/边界>"` | 建卡并盖章当前会话 |
76
+ | `npx dsh-offhours card add "<标题>" --summary "<目标/判据/边界>" [--session <id>]` | 建卡并盖章会话(无 session 不会跑) |
74
77
  | `npx dsh-offhours card list` | 列卡 |
75
78
  | `npx dsh-offhours run --once` / `--dry-run` | 手动跑一轮 / 只看会挑哪张 |
76
79
  | `npx dsh-offhours status` | 看板计数、心跳、最近状态(JSON) |
@@ -89,6 +92,15 @@ macOS 暂不支持(引擎用到 `flock`、`/proc`、GNU `readlink -f` 等)
89
92
  - 送审只留 5 类:选型不确定 / 影响演进 / 实施成本 / 条件做不成 / 政策风险。
90
93
  - 卡里必须有可机械核对的判据(命令),否则 worker 不得报 done。
91
94
 
95
+ ## 社区 / Community
96
+
97
+ - **源码**:https://github.com/shuke52tt/dsh-offhours
98
+ - **npm**:https://www.npmjs.com/package/dsh-offhours(`npx dsh-offhours ...`)
99
+ - **dshmarket 索引 PR**:https://github.com/awesome-dsh-plugin/awesome-dsh-plugin/pull/13017
100
+ - **官方 Show Your Plugins**:https://github.com/deepseek-ai/deepseek-harness/discussions/12568
101
+
102
+ 欢迎在官方帖或 issue 里反馈;插件按 MIT 发布。
103
+
92
104
  ## 开发
93
105
 
94
106
  ```bash
package/bin/offhours.mjs CHANGED
@@ -198,14 +198,17 @@ function cmdCard(args, flags) {
198
198
  if (sub !== 'add') die('用法:offhours card add "<标题>" --summary "..."')
199
199
  const title = args.slice(1).join(' ').trim()
200
200
  if (!title) die('card add 需要一个标题')
201
- const pyArgs = [nsPy(cfg), 'card-add', board.file, title,
202
- '--session', String(flags.session || process.env.DSH_SESSION_ID || ''),
203
- ]
201
+ const sessionId = String(flags.session || process.env.DSH_SESSION_ID || '')
202
+ if (!sessionId && !flags['allow-no-session']) {
203
+ die('缺少会话 id:在 dsh 会话里运行,或显式加 --session <sessionId>。\n' +
204
+ '没有 sourceSessionId 的卡不会被跑批捡起;确需建无主卡(只人工看)时加 --allow-no-session。')
205
+ }
206
+ const pyArgs = [nsPy(cfg), 'card-add', board.file, title, '--session', sessionId]
204
207
  for (const k of ['summary', 'description', 'rationale', 'rejected', 'tags', 'status', 'run-timeout']) {
205
208
  if (flags[k] !== undefined) pyArgs.push(`--${k}`, String(flags[k]))
206
209
  }
207
210
  if (flags['no-explain']) pyArgs.push('--no-explain')
208
- const env = { ...process.env, DSH_SESSION_ID: String(flags.session || process.env.DSH_SESSION_ID || '') }
211
+ const env = { ...process.env, DSH_SESSION_ID: sessionId }
209
212
  const r = spawnSync('python3', pyArgs, { env, encoding: 'utf8' })
210
213
  process.stdout.write(r.stdout || '')
211
214
  process.stderr.write(r.stderr || '')
package/lib/runtime.js CHANGED
@@ -69,6 +69,10 @@ export function startScheduler(ctx, cfg, log = () => {}) {
69
69
  let stopped = false
70
70
  let inFlight = false
71
71
 
72
+ // 首帧心跳:面板/CLI 在启动后的第一秒就能看到“调度器在跑”,
73
+ // 而不是等第一个 interval/抖动(默认最多 30s)才出现,避免新用户一打开面板就看到假故障。
74
+ try { writeJsonAtomic(heartbeatPath(cfg), { at: Date.now(), startedAt: Date.now(), fired: [], initial: true }) } catch { /* 忽略 */ }
75
+
72
76
  const tick = async () => {
73
77
  if (stopped || inFlight) return
74
78
  inFlight = true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-offhours",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "DSH 社区插件:把看板待办在低谷/夜间自动做掉(挑卡 → 独占 worktree → worker → 证据 → 合并回收),只依赖配置里的 git 仓库。",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/panel/index.js CHANGED
@@ -387,7 +387,11 @@ async function buildStatus(boardArg) {
387
387
  }
388
388
  } catch { out.problems.push('systemctl 查询失败(定时器状态未知)') }
389
389
  }
390
- if (configured && CFG.scheduler === 'plugin' && out.timer.active === 'unknown') {
390
+ if (CFG.scheduler === 'plugin' && !CFG.schedule.enabled) {
391
+ out.timer.active = 'disabled'
392
+ out.timer.raw = 'plugin schedule disabled'
393
+ }
394
+ if (configured && CFG.scheduler === 'plugin' && CFG.schedule.enabled && out.timer.active === 'unknown') {
391
395
  out.problems.push('插件内调度器没有心跳(确认 dsh 进程在跑,或 schedule.enabled=false)')
392
396
  }
393
397
 
@@ -536,11 +540,14 @@ async function buildStatus(boardArg) {
536
540
 
537
541
  // 最近日志(只取本板的行;我的日志格式是 `<时间> [<板>] ...`)
538
542
  try {
539
- const lines = readText(LOG).split('\n').filter((l) => l.includes(`[${board.key}]`))
540
- out.recent.log = tailLines(lines.length ? lines.join('\n') : readText(LOG), LOG_TAIL)
541
- } catch {
542
- out.problems.push('读不到 nightshift.log')
543
- }
543
+ const raw = readText(LOG)
544
+ if (raw) {
545
+ const lines = raw.split('\n').filter((l) => l.includes(`[${board.key}]`))
546
+ out.recent.log = tailLines(lines.length ? lines.join('\n') : raw, LOG_TAIL)
547
+ } else {
548
+ out.recent.log = []
549
+ }
550
+ } catch { /* 没有日志=还没跑过,不是故障 */ }
544
551
  try {
545
552
  out.recent.runs = readdirSync(RUNS)
546
553
  .filter((f) => f.endsWith('.out') || f.endsWith('.err'))
@@ -22,6 +22,7 @@ npx dsh-offhours card add "<标题>" --summary "<目标 + 判据(命令) + 涉
22
22
 
23
23
  - 必须在 dsh 会话里执行:它会用 `DSH_SESSION_ID` 盖章 `sourceSessionId`;
24
24
  - CLI 没进全局 PATH:统一用 `npx dsh-offhours ...`(或 profile 里的 `node_modules/.bin/offhours`)。
25
+ - 不在 dsh 会话里时,`card add` 必须加 `--session <id>`;无 session 的卡不会被跑批捡。
25
26
  **没有 sourceSessionId 的卡跑批永远不会捡**(不是 bug,是隔离要求)。
26
27
  - 用 dsh-kanban 的 `board_add` 建的卡不带 session,只适合人工看板,不适合跑批。
27
28
  - 判据必须是命令,不是形容词;一张卡 = 一个可独立合并的成果。