junjie.ding c22a511fe3 Add weekly-req-progress skill
把本周工作沉淀进团队共享的飞书「需求进度」多维表格的 skill:
按当前登录用户匹配相关需求行置顶追加进展/下周计划/阻碍,
无匹配则新建需求行,需求衍生的 bug/子任务建子记录,写前 --dry-run 预览确认。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 12:12:16 +08:00

64 lines
2.2 KiB
Python
Executable File
Raw 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
"""计算「需求进度」表里用的周期标记。
进展描述 / 阻碍 用「本周」块,下周计划 用「下周」块,格式固定为:
【YYYY/MM/DD ~ MM/DD 本周】
【YYYY/MM/DD ~ MM/DD 下周】
起始为周一(整周第一天)、结束为周五,跨月时结束也只写 MM/DD。
把"今天是星期几、本周/下周哪天到哪天"交给脚本算,避免每次人肉推算出错。
用法:
python week_range.py # 用今天
python week_range.py --date 2026-06-01
输出 JSON,字段见下方 build()。
"""
import argparse
import datetime
import json
def build(today: datetime.date) -> dict:
# weekday(): 周一=0 ... 周日=6。回退到本周一。
monday = today - datetime.timedelta(days=today.weekday())
friday = monday + datetime.timedelta(days=4)
next_monday = monday + datetime.timedelta(days=7)
next_friday = next_monday + datetime.timedelta(days=4)
def marker(start: datetime.date, end: datetime.date, label: str) -> str:
# 起始写完整年月日,结束只写月日(与表内既有数据一致)
return f"【{start:%Y/%m/%d} ~ {end:%m/%d} {label}】"
return {
"today": today.isoformat(),
"this_week": {
"monday": monday.isoformat(),
"friday": friday.isoformat(),
"marker": marker(monday, friday, "本周"),
},
"next_week": {
"monday": next_monday.isoformat(),
"friday": next_friday.isoformat(),
"marker": marker(next_monday, next_friday, "下周"),
},
# 给 datetime 字段写值时用(开始日期等需要 "YYYY-MM-DD HH:mm:ss")
"today_datetime": f"{today:%Y-%m-%d} 00:00:00",
}
def main() -> None:
parser = argparse.ArgumentParser(description="计算需求进度表的周期标记")
parser.add_argument("--date", help="基准日期 YYYY-MM-DD,默认今天")
args = parser.parse_args()
if args.date:
today = datetime.date.fromisoformat(args.date)
else:
today = datetime.date.today()
print(json.dumps(build(today), ensure_ascii=False, indent=2))
if __name__ == "__main__":
main()