Files
admin 19101acd65 init: workbuddy_skills 重建,仅收录 session-mechanism
- 按用户指示清空原有 25 技能内容,只提交 session-mechanism(57 文件)
- 附 .gitignore(产物 + 本机凭据)
- 令牌明文已脱敏(历史 .neodata_token 与 pitfalls 引用均不入库)
- 本提交为孤儿提交(父提交为空),历史自此重新开始
2026-10-05 14:13:24 +08:00

89 lines
3.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""handoff-status.py — 一条命令看清 05-交接单 里哪些单子【待执行】/【已完成】/【无状态】。
为什么需要它:`05-交接单/交接单-已完成/` 那层目录摊平后,**"目录位置"不再表达状态**。
状态改由**机读字段**承载(与布局解耦,摊平/搬家都不失效):
① 单子头部 `- 状态:…` 行(模板已有)→ ② 回退取 `05-交接单/README.md` 台账表的「状态」列
用法:python 07-scripts/handoff-status.py
"""
# [session-mechanism] roots.env 外置(由 install.py 生成;缺失则回落到按位置推导)
def _sm_load_roots():
import os as _os
_here = _os.path.dirname(_os.path.abspath(__file__))
for _up in range(4):
_p = _os.path.join(_here, *([".."] * _up), "roots.env")
_p = _os.path.normpath(_p)
if _os.path.isfile(_p):
try:
with open(_p, encoding="utf-8") as _f:
for _ln in _f:
_ln = _ln.strip()
if _ln and not _ln.startswith("#") and "=" in _ln:
_k, _v = _ln.split("=", 1)
_os.environ.setdefault(_k.strip(), _v.strip())
except Exception:
pass
return
_sm_load_roots()
import os
import re
ROOT = os.environ.get("DSH_DOCS_ROOT") or os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
D = os.path.join(ROOT, "05-交接单")
README = os.path.join(D, "README.md")
HEAD_STATUS = re.compile(r"^[\s>*\-|#]*\*{0,2}状态\*{0,2}\s*[::]\s*(.+?)\s*$", re.M)
DONE_KW = ("已完成", "已落地", "已归档", "已收口", "已闭合", "已实施", "已上线",
"已修复", "已释放", "已结束", "已通过", "全部完成", "全绿", "✅")
WAIT_KW = ("待执行", "待开工", "进行中", "在途", "待验证", "待跑", "规划中", "未开工",
"部分执行", "受阻", "未做", "设计定稿", "🔄", "⏳", "⏸", "🟡")
table = {}
if os.path.exists(README):
with open(README, encoding="utf-8") as fh:
for line in fh:
if not line.startswith("|"):
continue
cells = [c.strip() for c in line.strip().strip("|").split("|")]
if len(cells) < 2 or ".md" not in cells[0]:
continue
table[cells[0].strip("`").split("/")[-1].strip()] = cells[1]
groups = {"待执行": [], "已完成": [], "无状态": []}
targets = []
for root2, dirs2, _f in os.walk(D):
dirs2[:] = [x for x in dirs2 if not x.startswith(".")]
for f2 in _f:
if f2.endswith(".md") and f2 != "README.md" and not f2.startswith("."):
rel = os.path.relpath(os.path.join(root2, f2), D).replace("\\", "/")
targets.append((rel, os.path.join(root2, f2)))
for n, path in sorted(targets):
base = n.split("/")[-1]
with open(path, encoding="utf-8", errors="ignore") as fh:
head = "".join(fh.readlines()[:30])
m = HEAD_STATUS.search(head)
if m:
s, src = m.group(1)[:44], "头部"
elif base in table:
s, src = table[base][:44], "台账表"
else:
s, src = "", ""
if not s:
groups["无状态"].append((n, "—"))
elif any(k in s for k in DONE_KW):
groups["已完成"].append((n, "%s ·%s" % (s, src)))
elif any(k in s for k in WAIT_KW):
groups["待执行"].append((n, "%s ·%s" % (s, src)))
else:
groups["无状态"].append((n, "%s ·%s未识别" % (s, src)))
for g in ("待执行", "已完成", "无状态"):
print("【%s】%d 个" % (g, len(groups[g])))
for n, s in groups[g]:
print(" %-44s %s" % (n[:44], s))
print()
print("合计 %d 个单子(不含 README.md)" % sum(len(v) for v in groups.values()))