task-ledger 1.2.4 → 1.2.6

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
@@ -118,7 +118,8 @@
118
118
  - 临时文件名唯一(`mkstemp`),写完 `fsync` 再 `os.replace`,无论成败都清理临时文件
119
119
  - key 按字母序落盘,减少两人同时新增时的文本冲突
120
120
  - 冲突时**报错要求重跑**,不静默覆盖
121
- - 写入成功后脚本会**自动同步**:把本次改动的台账文件 `git add <精确文件>` + `commit`(消息 `ledger(<命令>): <提交者>`);当前分支有上游跟踪分支时再 `push`。全程确定性脚本,不依赖大模型
121
+ - 写入成功后脚本会**自动同步**:把本次改动的台账文件 `git add <精确文件>` + `commit`(消息 `chore(ledger): <命令> <提交者>`,即 conventional commits 格式,多数仓库装了 commitlint 也认);当前分支有上游跟踪分支时再 `push`。全程确定性脚本,不依赖大模型
122
+ - 仓库若装了自定义提交检查并拒了这条消息,脚本会**再用 `--no-verify` 提交一次**(台账是数据文件,不过 lint);仍失败则把 git 的报错打到 stderr 并要求手动提交 —— **同步失败绝不静默**,但退出码保持 0(台账本身已写成功)
122
123
  - 无 git 仓库 / 无上游跟踪 / 被 `.gitignore` 排除 / 无实际变更 都会静默跳过;`--no-sync` 或环境变量 `TASK_LEDGER_NO_SYNC=1` 可关闭
123
124
  - 冲突**仍不靠 `git pull` / `rebase` 解决**:并发靠指纹复查 + 原子写防覆盖,冲突时**报错要求重跑**,不静默合并
124
125
 
@@ -194,7 +195,7 @@ stateDiagram-v2
194
195
  note right of doing
195
196
  set --owner 交接:owner 换成别人
196
197
  (只有当前 owner 能执行)
197
- 超期 = 接任务满 14 天;停滞 = 最后更新满 3 天
198
+ 逾期 = 接任务满 14 天;停滞 = 最后更新满 3 天
198
199
  积压 = 待认领满 30 天
199
200
  (都由看板按时间算,不是状态)
200
201
  end note
package/SKILL.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: task-ledger
3
3
  description: 本地任务台账,跨会话记录在办任务的归属、进度与起止。当用户要登记一件新的事(新建任务 / 建个坑 / 这活我领了)、记录已有任务的进展(接着做 / 记一条进展 / 这轮先记下)、查看任务状态或历史(现在该做什么 / 这活谁在做 / 上周做过什么)时加载;对某个具体任务要求结案或退回时,只认用户的明确指令;只是改代码、讨论方案时不要用。
4
- version: 1.2.2
4
+ version: 1.2.6
5
5
  allowed-tools: Read,Write,Bash,Grep
6
6
  ---
7
7
 
@@ -34,7 +34,7 @@ allowed-tools: Read,Write,Bash,Grep
34
34
  | 「谁在做 X」「有哪些在办」 | `list`;在等认领的加 `--status open` |
35
35
  | 「这个任务到哪一步了」「这轮做了什么」 | `show --id`(任务 JSON + worklog 全文) |
36
36
  | 「某件老活什么时候做的」「谁做过哪些活」 | `history`(可按 `--owner` / `--since` 筛) |
37
- | 「哪些任务停太久」 | `list --json`:`updated` 满 3 天=停滞、`started` 满 14 天=超期、`created` 满 30 天仍 `open`=积压(看板算,别改状态) |
37
+ | 「哪些任务停太久」 | `list --json`:`updated` 满 3 天=停滞、`started` 满 14 天=逾期、`created` 满 30 天仍 `open`=积压(看板算,别改状态) |
38
38
  | 「新建一个任务」 | `new`(`--self` = 建完即认领) |
39
39
  | 「这活我领了」 | `claim`(只对 `open` 有效) |
40
40
  | 「开始做 / 接着做 X」 | 还是 `open` 就先 `claim`;已是 `doing` 就直接改正文 + `log` |
@@ -61,7 +61,7 @@ python3 <本 SKILL.md 所在目录>/scripts/progress.py <子命令> --repo <当
61
61
 
62
62
  ## 铁律
63
63
 
64
- - **状态只有 `open` / `doing`**;`done` 只能由 `close` 产生。**没有 `blocked` 状态**:超期 = `started` 满 14 天、停滞 = `updated` 满 3 天、积压 = `created` 满 30 天且仍 `open`,都由看板按时间算,`progress.json` 里不存、不手改;卡在哪写进正文。
64
+ - **状态只有 `open` / `doing`**;`done` 只能由 `close` 产生。**没有 `blocked` 状态**:逾期 = `started` 满 14 天、停滞 = `updated` 满 3 天、积压 = `created` 满 30 天且仍 `open`,都由看板按时间算,`progress.json` 里不存、不手改;卡在哪写进正文。
65
65
  - **`log` 就是刷新 `updated` 的动作**:该记不记,任务会被看板标成停滞。
66
66
  - **owner = 当前 `git config user.name`**,不能由外部传入;读不到就报错(先让用户配 git)。**只能动自己名下**的任务(`open` 的先 `claim`),不是你的直接拒绝 —— 不要绕过脚本改 JSON。
67
67
  - **换人只能「释放 → 认领」**:skill 不提供交接,随便写的名字都是假的。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "task-ledger",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "description": "Task-ledger skill for coding agents: per-workspace progress tracking (ledger/progress.json, history, worklog) driven by a CLI script. Standalone install for CodeBuddy and other agents; also bundled inside the dsh-task-ledger DSH plugin.",
5
5
  "keywords": [
6
6
  "skill",
@@ -1,6 +1,6 @@
1
1
  # 状态与时间模型
2
2
 
3
- > TL;DR:状态只有 `open` / `doing`;`done` 由 `close` 产生。超期 = `started` 满 14 天、停滞 = `updated` 满 3 天、积压 = `created` 满 30 天仍 `open`,看板算、不存字段。`updated` 由 `new/claim/set/log` 刷新。owner 只取当前 git 身份。
3
+ > TL;DR:状态只有 `open` / `doing`;`done` 由 `close` 产生。逾期 = `started` 满 14 天、停滞 = `updated` 满 3 天、积压 = `created` 满 30 天仍 `open`,看板算、不存字段。`updated` 由 `new/claim/set/log` 刷新。owner 只取当前 git 身份。
4
4
 
5
5
  ## 状态机
6
6
 
@@ -17,7 +17,7 @@ doing ──set --status open──> open # 释放认领,执行记录
17
17
  | 标记 | 依据 | 阈值 |
18
18
  |---|---|---|
19
19
  | 积压 | `created`(建了)至今仍 `open`(没人认领) | 满 30 天 |
20
- | 超期 | `started`(接任务)至今,中途更新不影响 | 满 14 天 |
20
+ | 逾期 | `started`(接任务)至今,中途更新不影响 | 满 14 天 |
21
21
  | 停滞 | `updated`(最后推进)至今 | 满 3 天 |
22
22
 
23
23
  - 真源:`packages/plugin/src/host/services/home.service.ts` 的 `BACKLOG_DAYS = 30` / `OVERDUE_DAYS = 14` / `STALE_DAYS = 3`;看板随响应下发三个天数,界面文案不硬编码。
@@ -354,9 +354,17 @@ def commit_guarded(
354
354
  write_json(path, data)
355
355
 
356
356
 
357
- def _git(*args: str, timeout: int | None = None) -> subprocess.CompletedProcess:
358
- """跑一条 git 命令,吞掉输出(同步用,不污染 stdout)。"""
359
- return subprocess.run(list(args), capture_output=True, text=True, timeout=timeout)
357
+ def _git(
358
+ *args: str, timeout: int | None = None, check: bool = False
359
+ ) -> subprocess.CompletedProcess:
360
+ """跑一条 git 命令,吞掉输出(同步用,不污染 stdout)。
361
+
362
+ check=True 让失败抛异常(推送要能被下面的兜底捕获);提交则靠返回码分辨,
363
+ 因为不同仓库的提交检查(commitlint 等)会拒掉消息,需要看 stderr 原文。
364
+ """
365
+ return subprocess.run(
366
+ list(args), capture_output=True, text=True, timeout=timeout, check=check
367
+ )
360
368
 
361
369
 
362
370
  def _git_actor(repo_root: str) -> str:
@@ -369,7 +377,8 @@ def git_sync(action: str) -> None:
369
377
  """写成功后调用一次:把本次改动的台账文件提交;有上游跟踪分支则推送。
370
378
 
371
379
  纯脚本、确定性,不依赖大模型。无 git / 无上游 / 全被 ignore / 无实际变更 都静默跳过。
372
- 同步是尽力而为:任何异常都不影响已完成的台账写入(只打印提示)。
380
+ 同步失败(提交被仓库钩子拒后连 --no-verify 也失败、推送被拒、意外异常)一律打到
381
+ stderr 提示,绝不静默;但退出码不变 —— 台账本身已经写成功,别让调用方误判去重做。
373
382
  """
374
383
  if os.environ.get("TASK_LEDGER_NO_SYNC"):
375
384
  return
@@ -382,29 +391,49 @@ def git_sync(action: str) -> None:
382
391
  if top.returncode != 0:
383
392
  return # 不是 git 项目 → 跳过(规则1:有才提交)
384
393
  root = top.stdout.strip()
394
+ g = ("git", "-C", root)
385
395
  # 只 add 本次真实改动、且未被 ignore 的文件
386
396
  to_add = [
387
397
  str(f)
388
398
  for f in files
389
- if _git("git", "-C", root, "check-ignore", "-q", str(f)).returncode != 0
399
+ if _git(*g, "check-ignore", "-q", str(f)).returncode != 0
390
400
  ]
391
401
  if not to_add:
392
402
  return # 全被 ignore → 尊重用户选择,不强行提交
393
- _git("git", "-C", root, "add", *to_add)
394
- if _git("git", "-C", root, "diff", "--cached", "--quiet").returncode == 0:
403
+ _git(*g, "add", *to_add)
404
+ if _git(*g, "diff", "--cached", "--quiet").returncode == 0:
395
405
  return # 无实际变更
396
406
  actor = _git_actor(root)
397
- _git("git", "-C", root, "commit", "-m", f"ledger({action}): {actor}")
407
+ # 消息按 conventional commits 写:多数仓库装了 commitlint,只认白名单里的 type
408
+ msg = f"chore(ledger): {action} {actor}"
409
+ done = _git(*g, "commit", "-m", msg)
410
+ if done.returncode != 0:
411
+ # 各仓库提交规则各不相同(type 白名单、大小写、scope 枚举……),台账是数据文件,
412
+ # 过不了就让这一次跳过钩子提交,别把台账永久锁在本地暂存区。
413
+ done = _git(*g, "commit", "--no-verify", "-m", msg)
414
+ if done.returncode == 0:
415
+ print(
416
+ f"提示:仓库提交检查拒绝了消息「{msg}」,已用 --no-verify 提交本次台账改动。",
417
+ file=sys.stderr,
418
+ )
419
+ if done.returncode != 0:
420
+ print(
421
+ "提示:台账已写入本地,但自动提交失败,请手动提交 ledger/:"
422
+ f"{(done.stderr or done.stdout or '').strip()}",
423
+ file=sys.stderr,
424
+ )
425
+ return
398
426
  # 规则2:有上游跟踪分支才推
399
- if _git("git", "-C", root, "rev-parse", "--abbrev-ref", "@{upstream}").returncode != 0:
427
+ upstream = _git(*g, "rev-parse", "--abbrev-ref", "@{upstream}")
428
+ if upstream.returncode != 0:
400
429
  return
401
430
  try:
402
- _git("git", "-C", root, "push", timeout=30)
431
+ _git(*g, "push", timeout=30, check=True)
403
432
  except (subprocess.CalledProcessError, subprocess.TimeoutExpired):
404
433
  # 非快进:自动 rebase 一次再推;冲突 / 超时则放弃,绝不 --force
405
434
  try:
406
- _git("git", "-C", root, "pull", "--rebase", "--autostash", timeout=30)
407
- _git("git", "-C", root, "push", timeout=30)
435
+ _git(*g, "pull", "--rebase", "--autostash", timeout=30, check=True)
436
+ _git(*g, "push", timeout=30, check=True)
408
437
  except (subprocess.CalledProcessError, subprocess.TimeoutExpired):
409
438
  print(
410
439
  "提示:本地已提交,但推送被拒(他人已推 / 需认证 / 超时)。"
@@ -412,8 +441,10 @@ def git_sync(action: str) -> None:
412
441
  file=sys.stderr,
413
442
  )
414
443
  except Exception as exc: # noqa: BLE001 —— 同步失败不应污染台账主流程
415
- print(f"提示:写后自动同步未执行({type(exc).__name__}: {exc})。数据已写入本地。",
416
- file=sys.stderr)
444
+ print(
445
+ f"提示:写后自动同步未执行({type(exc).__name__}: {exc})。数据已写入本地。",
446
+ file=sys.stderr,
447
+ )
417
448
 
418
449
 
419
450
  def require_task_id(tid: str) -> str: