Skip to content

Commit eaec8dc

Browse files
authored
Merge pull request #231 from PsychQuant/idd/199-bridge-state-path-migration
fix: idd-comment bridge state onto .claude/.idd/state/bridge.json (namespace migration completion)
2 parents 8d913ff + 3fef9ae commit eaec8dc

4 files changed

Lines changed: 48 additions & 11 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"issue": 199,
3+
"fetched_at": "2026-07-05T15:19:46Z",
4+
"fetched_by": "idd-diagnose",
5+
"files": []
6+
}

plugins/issue-driven-dev/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ GitHub mentions are an irreversible side effect; the rule is mandatory not advis
8989

9090
When `spectra-discuss` is interrupted mid-flow to invoke an IDD skill (e.g. "let me capture this finding to the issue"), the bridge protocol preserves and resumes context:
9191

92-
- **Step 0.7 Detect**`--resume-spectra="<topic>"` flag, `--source` contains `spectra-discuss`, `spectra list --json` shows in-flight changes, or `.claude/state/idd-bridge.json` exists → `SPECTRA_BRIDGE_ACTIVE=1`
93-
- **Step N-1 Bookmark**`.claude/state/idd-bridge.json` written with verbatim `spectra_topic` + `issue_url` + `open_questions[]` + `idd_action_url` + `next_step_hint`
92+
- **Step 0.7 Detect**`--resume-spectra="<topic>"` flag, `--source` contains `spectra-discuss`, `spectra list --json` shows in-flight changes, or `.claude/.idd/state/bridge.json` exists (legacy fallback: `.claude/state/idd-bridge.json`)`SPECTRA_BRIDGE_ACTIVE=1`
93+
- **Step N-1 Bookmark**`.claude/.idd/state/bridge.json` written with verbatim `spectra_topic` + `issue_url` + `open_questions[]` + `idd_action_url` + `next_step_hint`
9494
- **Step N Resume Prompt** — final output prints a clearly-delimited `↩ Resume spectra-discuss` block with a copy-pasteable `/spectra-discuss <topic>...` prompt
9595

9696
Hard rules: never auto-invoke `/spectra-discuss` (user controls pacing); never paraphrase `spectra_topic`; resume prompt is the actual recovery — bookmark file is convenience.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
# test.sh — drift lock for spectra-bridge state path (#199)
3+
# idd-comment must READ new-path-first (legacy fallback allowed) and WRITE the
4+
# new path ONLY. rules/spectra-bridge.md L116 is the contract.
5+
set -u
6+
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
SKILL="$HERE/../../../skills/idd-comment/SKILL.md"
8+
PASS=0; FAIL=0
9+
ok(){ echo "$1"; PASS=$((PASS+1)); }
10+
no(){ echo "$1"; FAIL=$((FAIL+1)); }
11+
12+
# 1. write path: mkdir/cat must target .claude/.idd/state/, never .claude/state/
13+
if grep -qE 'cat > \.claude/state/idd-bridge\.json|mkdir -p \.claude/state' "$SKILL"; then
14+
no "no legacy-path WRITE in idd-comment SKILL.md"
15+
else ok "no legacy-path WRITE in idd-comment SKILL.md"; fi
16+
# 2. new path present as primary read + write
17+
grep -q '\.claude/\.idd/state/bridge\.json' "$SKILL" && ok "new path referenced" || no "new path referenced"
18+
# 3. legacy path may appear ONLY as documented fallback (with the word fallback/legacy nearby)
19+
LEGACY_LINES=$(grep -n '\.claude/state/idd-bridge\.json' "$SKILL" | grep -viE 'fallback|legacy' | wc -l | tr -d ' ')
20+
[ "$LEGACY_LINES" = "0" ] && ok "legacy path only in fallback context" || no "legacy path only in fallback context ($LEGACY_LINES bare refs)"
21+
22+
echo "================================"
23+
echo "Results: $PASS passed, $FAIL failed"
24+
[ "$FAIL" -eq 0 ]

plugins/issue-driven-dev/skills/idd-comment/SKILL.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ idd-issue source.docx # auto-trigger when source contains ≥2 findings
7474

7575
```
7676
TaskCreate(name="parse_args", description="Parse #NNN + --type + --body / --quote / --source / --target / --target-comment / --deadline / --mention / --resume-spectra 等 options")
77-
TaskCreate(name="detect_spectra_context", description="Step 0.7: 偵測是否從 spectra-discuss 中斷進來(--resume-spectra flag / --source 含 spectra / spectra list 有 in-flight / .claude/state/idd-bridge.json)— 詳見 rules/spectra-bridge.md")
77+
TaskCreate(name="detect_spectra_context", description="Step 0.7: 偵測是否從 spectra-discuss 中斷進來(--resume-spectra flag / --source 含 spectra / spectra list 有 in-flight / .claude/.idd/state/bridge.json(legacy fallback: .claude/state/idd-bridge.json)— 詳見 rules/spectra-bridge.md")
7878
TaskCreate(name="validate_type_requirements", description="依 type 檢查必填欄位(decision 要 quote、note 要 source、link 要 target、errata 要 target-comment)")
7979
TaskCreate(name="resolve_mentions", description="Step 1.5: 若有 --mention 或 body 含 @xxx,強制走 rules/tagging-collaborators.md 協定(gh api 取 collaborators → fuzzy match → AskUserQuestion fallback → 用 @login 不用 display name)")
8080
TaskCreate(name="build_comment_body", description="按 type 對應 template 組 markdown(emoji header + blockquote + body + metadata marker),插入已驗證的 @login mentions")
8181
TaskCreate(name="verify_mentions", description="post 前 grep body 的 @\\w+ 全部 cross-check 已驗證的 collaborator set;未驗證 token 直接 abort")
8282
TaskCreate(name="post_comment", description="gh issue comment #NNN 用 --body-file 避免 escape 問題;errata type 額外 auto-call idd-edit")
8383
TaskCreate(name="report_result", description="輸出 ✓ Comment posted + URL;errata type 加報 idd-edit 結果")
8484
TaskCreate(name="auto_update_body", description="跑 /idd-update #NNN 同步 issue body Current Status(強制,常被漏;同 idd-close Step 6 模式)")
85-
TaskCreate(name="spectra_bridge_resume", description="Step 7: 若 SPECTRA_BRIDGE_ACTIVE,寫 .claude/state/idd-bridge.json bookmark + 輸出 ↩ Resume spectra-discuss 區塊(rules/spectra-bridge.md)")
85+
TaskCreate(name="spectra_bridge_resume", description="Step 7: 若 SPECTRA_BRIDGE_ACTIVE,寫 .claude/.idd/state/bridge.json bookmark + 輸出 ↩ Resume spectra-discuss 區塊(rules/spectra-bridge.md)")
8686
```
8787

8888
完成每一步立即 `TaskUpdate → completed`**靜默完成 = 違規****TaskCreate 清單 = 真實的步驟清單;任何寫在 skill 裡但沒列進 TaskCreate 的步驟,都視為 skill 的 bug,必須補進 Task 清單。**
@@ -120,9 +120,16 @@ if command -v spectra >/dev/null 2>&1; then
120120
fi
121121
fi
122122

123-
# Signal 4: bookmark 已存在
124-
if [ -f ".claude/state/idd-bridge.json" ]; then
125-
ACTIVE=$(jq -r '.active_spectra_session // false' .claude/state/idd-bridge.json 2>/dev/null)
123+
# Signal 4: bookmark 已存在 — new path first, legacy fallback(#199; rule L116 契約)
124+
BRIDGE_FILE=""
125+
if [ -f ".claude/.idd/state/bridge.json" ]; then
126+
BRIDGE_FILE=".claude/.idd/state/bridge.json"
127+
elif [ -f ".claude/state/idd-bridge.json" ]; then # legacy fallback (#199)
128+
BRIDGE_FILE=".claude/state/idd-bridge.json" # legacy fallback
129+
echo "ℹ Found legacy bridge at .claude/state/idd-bridge.json. Move to .claude/.idd/state/bridge.json."
130+
fi
131+
if [ -n "$BRIDGE_FILE" ]; then
132+
ACTIVE=$(jq -r '.active_spectra_session // false' "$BRIDGE_FILE" 2>/dev/null)
126133
[ "$ACTIVE" = "true" ] && SPECTRA_BRIDGE_ACTIVE=1
127134
fi
128135
```
@@ -365,8 +372,8 @@ Skill(skill="issue-driven-dev:idd-update", args="#NNN")
365372
#### 7.1 寫 bookmark 檔
366373

367374
```bash
368-
mkdir -p .claude/state
369-
cat > .claude/state/idd-bridge.json <<EOF
375+
mkdir -p .claude/.idd/state
376+
cat > .claude/.idd/state/bridge.json <<EOF
370377
{
371378
"version": 1,
372379
"created_at": "$(date -u +%Y-%m-%dT%H:%M:%S%z)",
@@ -397,7 +404,7 @@ to continue with full context preserved:
397404
待解問題:
398405
${OPEN_QUESTIONS_BULLETS}
399406
400-
State saved to: .claude/state/idd-bridge.json
407+
State saved to: .claude/.idd/state/bridge.json
401408
═══════════════════════════════════════════════════════════
402409
```
403410

@@ -467,7 +474,7 @@ HTML comment 在 GitHub 不渲染,但可 parse:
467474
--body="..."
468475
```
469476

470-
→ Step 0.7 detect 命中 → Step 7 寫 `.claude/state/idd-bridge.json` + 印 `↩ Resume spectra-discuss` 區塊讓使用者貼回 spectra session。
477+
→ Step 0.7 detect 命中 → Step 7 寫 `.claude/.idd/state/bridge.json` + 印 `↩ Resume spectra-discuss` 區塊讓使用者貼回 spectra session。
471478

472479
## 鐵律
473480

0 commit comments

Comments
 (0)