inbox-update

This commit is contained in:
Build Bot
2026-05-07 01:13:24 +08:00
parent ff654b91f2
commit 53b0de51a2
12 changed files with 423 additions and 808 deletions

View File

@@ -0,0 +1,50 @@
# Context Snapshot: scheduled-task-git-sync-gant
## Task Statement
为该路径添加一个定时任务,每天晚上十点半的时候 git pull & push然后把 inbox 中的内容使用 skill:gant
## Desired Outcome
A nightly scheduled task at 22:30 that:
1. Syncs the repo via `git pull && git push`
2. Processes InBox markdown notes through the `gant-cli` skill
## Stated Solution
Add a cron/scheduled task running at 22:30 daily
## Probable Intent Hypothesis
User wants automated end-of-day sync of Obsidian notes to Gitee remote, plus automatic conversion of inbox notes into Gantt task manager entries. This suggests a daily capture → organize → sync workflow.
## Known Facts
- Repo: `C:\app\unity_project\obsidian-notes`
- Remote: `https://gitee.com/zzzisfunnyboy/obsidian-notes.git` (Gitee)
- InBox currently contains 4 `.md` files
- Git has uncommitted changes: `.obsidian/workspace.json` (modified) + one untracked InBox file
- `gant-cli` skill: manages Gantt desktop tasks via `gant.exe`/`gantt-app.exe` CLI (list, add, update, delete, lock)
- Platform: Windows, shell: bash
- No existing `.omx/context/` snapshots
- Claude Code `CronCreate` tool exists for scheduling recurring tasks
## Constraints
- Must use Claude Code's `CronCreate` (not Windows Task Scheduler or system cron)
- Git operations need to handle potential merge conflicts gracefully
- InBox processing: what exactly should happen to inbox files after processing? (Move? Delete? Leave?)
## Unknowns / Open Questions
1. **What does "process InBox content with skill:gant" mean concretely?** Extract tasks from each markdown note into Gantt? Convert the whole note into a Gantt task? Something else?
2. **What should happen to InBox files after processing?** Delete them? Move them to an archive? Mark as processed?
3. **Should the scheduled task also commit local changes before push?** Currently there are uncommitted modifications.
4. **What's the relationship between Obsidian notes and Gantt tasks?** Is there a specific format or template?
5. **Error handling expectations?** What if git pull has conflicts? What if gantt-app isn't running?
6. **Is the gantt-app.exe path known and stable?**
## Decision-Boundary Unknowns
- Whether to auto-commit changes or only pull/push
- How to handle InBox files post-processing (archive vs delete)
- Error notification strategy (silent fail? log? notify?)
- Whether this should be durable (persist across Claude sessions)
## Likely Codebase Touchpoints
- Cron job: `CronCreate` tool or `.claude/scheduled_tasks.json`
- Git operations: bash commands
- Gantt integration: `gant-cli` skill invocation
- InBox: `C:\app\unity_project\obsidian-notes\InBox\` directory

View File

@@ -0,0 +1,30 @@
# Interview Transcript: scheduled-task-git-sync-gant
**Profile:** Standard
**Timestamp:** 20260429T161523Z
**Final Ambiguity:** 0.16
**Threshold:** 0.20
**Type:** Brownfield
## Round Summary
| R | Target | Focus | Key Finding |
|---|--------|-------|-------------|
| 1 | Intent | Why automate? | Goal: InBox notes auto-appear in Gantt chart, eliminating manual transfer |
| 2 | Outcome | Concrete format | Gantt task format: `待看:{文件名}` |
| 3 | Outcome | Post-processing | InBox files stay; deleted files → tasks removed from Gantt; de-duplicated |
| 4 | Scope | Git range | Only `PARA/` and `InBox/` folders |
| 5 | Scope | Auto-commit | Auto `add PARA/ InBox/ && commit -m "auto nightly sync"` before push |
| 6 | Constraints | Gantt offline | Silent skip, try next day |
| 7 | Decision Boundaries | Technical choices | abort on merge conflict; push failure → Windows toast notification |
| 8 | Non-goals | Persistence model | User wants system-level script, not Claude session-dependent |
| 9 | Constraints | Trigger mechanism | Windows Task Scheduler, self-chosen |
| 10 | Success Criteria | Verification | 10:30 PM: open Gantt chart, see expected "待看:xxx" tasks |
| 11 | Non-goals | Boundaries | Only PARA/InBox git, only "待看" task type, only .md files |
| 12 | Decision Boundaries | Remaining choices | Script alongside gantt-app.exe; toast notifications; no log; update existing |
## Exposed Assumptions
- gantt-app.exe CLI supports add/delete/list/toggle-lock operations
- Windows Task Scheduler can trigger bash scripts
- Git merge conflicts are rare enough that abort is acceptable
- User's computer is on at 22:30

View File

@@ -0,0 +1,69 @@
# Implementation Plan: InBox → Gantt Nightly Sync
## Source of Truth
- Spec: `.omx/specs/deep-interview-scheduled-task-git-sync-gant.md`
- Context: `.omx/context/scheduled-task-git-sync-gant-20260429T161523Z.md`
## Architecture
```
Windows Task Scheduler (22:30 daily)
└─ powershell.exe -ExecutionPolicy Bypass -File "sync-inbox-to-gantt.ps1"
├─ 1. Git sync (pull, add, commit, push)
├─ 2. Gantt bidirectional mirror (InBox ↔ Gantt "待看:*" tasks)
└─ 3. Notifications (push failure toast)
```
## Files to Create
| File | Path | Purpose |
|------|------|---------|
| Sync script | `C:\Users\Zane\Desktop\Gantt App\sync-inbox-to-gantt.ps1` | Main nightly script |
| Setup script | `C:\app\unity_project\obsidian-notes\.omx\setup-task.ps1` | One-shot Task Scheduler registration |
## Algorithm
### Phase A — Git Sync
1. `cd C:\app\unity_project\obsidian-notes`
2. `git pull` — if conflict → `git merge --abort` → exit git phase
3. `git add PARA/ InBox/`
4. `git diff --cached --quiet` → if no changes, skip commit
5. `git commit -m "auto nightly sync"`
6. `git push` — if failure → Show-Toast "Git push failed" → continue
### Phase B — Gantt Mirror
1. Call `gantt-app.exe --cli list-tasks` → parse JSON
- If Gantt not running (process error / non-zero exit) → skip phase B
2. Extract `"待看:*"` tasks → set `{baseName}` from task name
3. Scan `InBox\*.md` → set `{baseName}` from filename (strip .md)
4. **Add**: For each InBox file NOT in Gantt → `add-task --name "待看:{baseName}" --start {today} --end "" --progress 0`
5. **Delete**: For each Gantt "待看:*" NOT in InBox → `delete-task --id {id}`
6. **Existing matches**: No-op (already correct)
### Error Handling Matrix
| Failure | Behavior |
|---------|----------|
| Git pull conflict | `git merge --abort`, skip rest of git phase |
| Git push fails | PowerShell toast notification, continue to Gantt phase |
| Gantt CLI not found | Write-Error, exit 1 |
| Gantt not running | Skip Gantt phase silently |
| Gantt add/delete fails | Write-Error for that item, continue |
| Script not in gantt dir | Resolve gantt dir from script location dynamically |
## Task Scheduler Registration
```powershell
$action = New-ScheduledTaskAction -Execute "powershell.exe" `
-Argument "-ExecutionPolicy Bypass -File `"C:\Users\Zane\Desktop\Gantt App\sync-inbox-to-gantt.ps1`""
$trigger = New-ScheduledTaskTrigger -Daily -At 22:30
Register-ScheduledTask -TaskName "InBox-Gantt-Nightly-Sync" `
-Action $action -Trigger $trigger -RunLevel Highest `
-Description "Nightly sync Obsidian InBox to Gantt tasks with git auto-commit"
```
## Implementation Tasks
1. **Create sync-inbox-to-gantt.ps1** — the main sync script with all logic
2. **Create setup-task.ps1** — registers the scheduled task
3. **Manual dry-run test** — run script manually, verify Gantt tasks created

25
.omx/setup-task.ps1 Normal file
View File

@@ -0,0 +1,25 @@
# setup-task.ps1
# Register the nightly InBox→Gantt sync task in Windows Task Scheduler.
# Run once, as Administrator.
$taskName = "InBox-Gantt-Nightly-Sync"
$scriptPath = "C:\Users\Zane\Desktop\Gantt-App\sync-inbox-to-gantt.ps1"
# Remove existing task if present
$existing = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
if ($existing) {
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false
Write-Host "Removed existing task: $taskName"
}
$action = New-ScheduledTaskAction -Execute "powershell.exe" `
-Argument "-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$scriptPath`""
$trigger = New-ScheduledTaskTrigger -Daily -At 22:30
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable
Register-ScheduledTask -TaskName $taskName `
-Action $action -Trigger $trigger -Settings $settings `
-Description "Nightly: git sync PARA/InBox + mirror InBox .md files to Gantt '待看:*' tasks"
Write-Host "Task '$taskName' registered. Next run: $(Get-Date -Format 'yyyy-MM-dd') 22:30"
Write-Host "Script: $scriptPath"

View File

@@ -0,0 +1,85 @@
# Spec: Deep Interview — scheduled-task-git-sync-gant
## Metadata
- **Profile:** Standard
- **Rounds:** 12
- **Final Ambiguity:** 0.16
- **Threshold:** 0.20 (met)
- **Type:** Brownfield
- **Context Snapshot:** `.omx/context/scheduled-task-git-sync-gant-20260429T161523Z.md`
## Clarity Breakdown
| Dimension | Weight | Score | Notes |
|-----------|--------|-------|-------|
| Intent | 0.25 | 0.85 | InBox notes visible in Gantt chart without manual steps |
| Outcome | 0.20 | 0.85 | New → added, deleted → removed, existing → de-duplicated |
| Scope | 0.20 | 0.85 | PARA/InBox git only; "待看" type only; .md files only |
| Constraints | 0.15 | 0.80 | Win Task Scheduler; gantt-app.exe; toast; abort on conflict; no logs |
| Success | 0.10 | 0.80 | At 22:30, Gantt shows "待看:xxx" for all InBox .md files |
| Context | 0.10 | 0.90 | Well-understood repo and tooling |
| **Weighted** | | **0.84** | Ambiguity = 0.16 |
## Intent
用户希望每晚 22:30 自动将 InBox 中的待读笔记同步到甘特图软件中,消除手动搬运步骤。
## Desired Outcome
- 甘特图出现所有 InBox 中 `.md` 文件对应的 "待看:{文件名}" 任务
- 已存在的不重复添加(更新)
- InBox 中已删除的文件对应任务也从甘特图中移除
- Git 自动拉取/提交/推送 PARA/ 和 InBox/ 目录
## In-Scope
1. 每晚 22:30 通过 Windows Task Scheduler 触发
2. `git pull && git add PARA/ InBox/ && git commit -m "auto nightly sync" && git push`
3. 扫描 InBox/*.md为每个文件在甘特图创建/更新 "待看:{文件名}" 任务
4. 检测甘特图中已存在的 "待看:xxx" 任务,若 InBox 中对应文件已删除则移除
5. 去重:已在甘特图中的任务不重复创建,仅更新
6. 脚本文件与 gantt-app.exe 放在同一目录
## Out-of-Scope / Non-goals
1. 不操作 PARA/ 和 InBox/ 之外的任何文件
2. 不创建 "待看" 之外的甘特图任务类型
3. 不处理非 `.md` 文件
## Decision Boundaries (OMX 可自行决定)
- 具体用哪个 Windows 通知 APIPowerShell toast / `msg` / 其他)
- Git commit 消息的具体格式
- 脚本语言选择bash / PowerShell / 混合)
- 甘特图 CLI 的 command/subcommand 细节(从 gant-cli skill 获取)
## Constraints
- **触发机制:** Windows Task Scheduler非 Claude session 依赖)
- **甘特图 CLI:** `gantt-app.exe`
- **脚本位置:** 与 gantt-app.exe 同目录
- **Git 冲突:** abort保留本地
- **Push 失败:** Windows 右下角 toast 通知
- **甘特图未运行:** 静默跳过,次日重试
- **日志:** 不需要
- **重名任务:** 更新而非跳过
- **持久化:** 无 Claude session 依赖(系统级调度)
## Testable Acceptance Criteria
- [ ] 晚上 22:30打开甘特图能看到所有 InBox/*.md 对应的 "待看:{文件名}" 任务
- [ ] 在 InBox 中新增一个 .md 文件 → 下次执行后甘特图出现对应任务
- [ ] 在 InBox 中删除一个 .md 文件 → 下次执行后甘特图移除对应任务
- [ ] 非 .md 文件被忽略
- [ ] PARA/ 和 InBox/ 外文件不受 git 影响
- [ ] Git 冲突时 abort 不丢数据
- [ ] 甘特图未运行时脚本不崩溃
## Assumptions Exposed + Resolved
1. **gantt-app.exe CLI 能力:** 假设支持 add/delete/list 操作 → 实现时通过 gant-cli skill 确认
2. **Session-only vs durable:** 初始误解为 Claude session 调度 → 澄清为系统级 Windows Task Scheduler
3. **文件处理后:** 最初未明确 → 澄清为保留文件、双向同步
## Pressure-Pass Findings
- Round 2 追问了具体格式("到底长什么样")→ 从模糊的"处理"收缩到 `待看:{标题}`
- Round 8 追问了 session-only 假设 → 推翻了 CronCreate 方案,转向系统级 Task Scheduler
- Round 11 追问了明确的 non-goals → 三条边界锁定
## Handoff Contract
This spec is the requirements source of truth. Downstream execution must preserve:
- Intent, non-goals, decision boundaries, and acceptance criteria
- The bidirectional mirror model (InBox ↔ Gantt)
- System-level scheduling (not Claude session-dependent)