beeops 0.1.7 → 0.1.9

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/bin/beeops.js CHANGED
@@ -117,6 +117,32 @@ function checkPrerequisites() {
117
117
  return allOk;
118
118
  }
119
119
 
120
+ // ── .gitignore management ──
121
+
122
+ const GITIGNORE_ENTRIES = [
123
+ ".claude/tasks/",
124
+ ".claude/worktrees/",
125
+ ];
126
+
127
+ function updateGitignore(root) {
128
+ const gitignorePath = path.join(root, ".gitignore");
129
+ let content = "";
130
+ if (fs.existsSync(gitignorePath)) {
131
+ content = fs.readFileSync(gitignorePath, "utf8");
132
+ }
133
+
134
+ const lines = content.split("\n");
135
+ const missing = GITIGNORE_ENTRIES.filter((entry) => !lines.some((line) => line.trim() === entry));
136
+
137
+ if (missing.length === 0) return;
138
+
139
+ const block = "\n# beeops runtime artifacts\n" + missing.join("\n") + "\n";
140
+ fs.writeFileSync(gitignorePath, content.trimEnd() + block);
141
+ for (const entry of missing) {
142
+ console.log(` gitignore: added ${entry}`);
143
+ }
144
+ }
145
+
120
146
  // ── Hook registration ──
121
147
 
122
148
  function resolveSettingsFile(root, mode) {
@@ -267,16 +293,19 @@ function init(opts) {
267
293
  }
268
294
  }
269
295
 
270
- // 4. Register hooks (UserPromptSubmit)
296
+ // 4. Update .gitignore (runtime artifacts should not be tracked)
297
+ updateGitignore(root);
298
+
299
+ // 5. Register hooks (UserPromptSubmit)
271
300
  updateSettingsHook(root, opts.hookMode);
272
301
 
273
- // 5. Save locale preference
302
+ // 6. Save locale preference
274
303
  const boDir = path.join(claudeDir, "beeops");
275
304
  ensureDir(boDir);
276
305
  fs.writeFileSync(path.join(boDir, "locale"), opts.locale + "\n");
277
306
  console.log(` locale: ${opts.locale} (saved to .claude/beeops/locale)`);
278
307
 
279
- // 6. Copy contexts if --with-contexts
308
+ // 7. Copy contexts if --with-contexts
280
309
  if (opts.withContexts) {
281
310
  const destContexts = path.join(claudeDir, "beeops", "contexts");
282
311
  copyDir(CONTEXTS_SRC, destContexts);
@@ -130,6 +130,11 @@ queued -> dispatched -> leader_working -> review_dispatched -> reviewing -> done
130
130
  ^ |
131
131
  +---- fixing <-- fix_required ----------------------------+
132
132
  (max 3 loops)
133
+
134
+ (shortcut: existing PR detected)
135
+ review_dispatched -> reviewing -> done
136
+ |
137
+ fixing <-- fix_required
133
138
  ```
134
139
 
135
140
  | Status | Meaning |
@@ -149,7 +154,7 @@ queued -> dispatched -> leader_working -> review_dispatched -> reviewing -> done
149
154
 
150
155
  ## Task Selection Rules
151
156
 
152
- 1. Select tasks that are `queued` and whose `depends_on` is empty (or all dependencies are `done`)
157
+ 1. Select tasks that are `queued` or `review_dispatched` (with existing PR) and whose `depends_on` is empty (or all dependencies are `done`)
153
158
  2. Skip tasks with a `blocked_reason` (record "Skipped: {reason}" in the log)
154
159
  3. Priority order: high -> medium -> low
155
160
  4. Within the same priority, process lower Issue numbers first
@@ -177,11 +182,17 @@ review_window: "review-42" # review window name
177
182
  3. Execute based on the task's type and assignee:
178
183
 
179
184
  ### type: issue (or assignee: leader)
180
- 1. Invoke **Skill: `bo-dispatch`** to launch a Leader
185
+
186
+ **First, check if the task already has a PR** (i.e. `pr` field is non-null when status is `review_dispatched`):
187
+ - **PR exists** → Skip Leader. Directly launch Review Leader via bo-dispatch to verify the existing PR meets the Issue requirements.
188
+ - **No PR** → Normal flow: launch Leader first.
189
+
190
+ After determining the starting point:
191
+ 1. Invoke **Skill: `bo-dispatch`** to launch a Leader (or Review Leader if PR exists)
181
192
  2. Based on the result (report content) returned by bo-dispatch:
182
193
  - Leader completed -> update to `review_dispatched` -> launch Review Leader (invoke bo-dispatch again)
183
194
  - Review Leader approve -> `ci_checking` -> verify CI
184
- - Review Leader fix_required -> if review_count < 3, set to `fixing` -> relaunch Leader (fix mode)
195
+ - Review Leader fix_required -> if review_count < 3, set to `fixing` -> relaunch Leader (fix mode, using existing branch)
185
196
  - Failure -> update to `error`
186
197
 
187
198
  ### type: adhoc, assignee: orchestrator
@@ -130,6 +130,11 @@ queued → dispatched → leader_working → review_dispatched → reviewing →
130
130
  ↑ │
131
131
  └──── fixing ←── fix_required ───────────────────────────┘
132
132
  (最大3回ループ)
133
+
134
+ (短縮パス: 既存 PR 検出時)
135
+ review_dispatched → reviewing → done
136
+
137
+ fixing ←── fix_required
133
138
  ```
134
139
 
135
140
  | ステータス | 意味 |
@@ -149,7 +154,7 @@ queued → dispatched → leader_working → review_dispatched → reviewing →
149
154
 
150
155
  ## タスク選択ルール
151
156
 
152
- 1. `queued` かつ `depends_on` が空(または全て `done`)のタスクを選択
157
+ 1. `queued` または `review_dispatched`(既存 PR あり)かつ `depends_on` が空(または全て `done`)のタスクを選択
153
158
  2. `blocked_reason` があるタスクはスキップ(ログに「スキップ: {理由}」を記録)
154
159
  3. 優先度順: high → medium → low
155
160
  4. 同一優先度内では Issue 番号が小さい方を先に
@@ -177,11 +182,17 @@ review_window: "review-42" # review window 名
177
182
  3. タスクの type と assignee に応じて実行:
178
183
 
179
184
  ### type: issue(または assignee: leader)
180
- 1. **Skill: `bo-dispatch`** を発動し、Leader を起動
185
+
186
+ **まず、タスクに既存 PR があるか確認する**(`pr` フィールドが非null かつ status が `review_dispatched`):
187
+ - **PR あり** → Leader をスキップ。bo-dispatch で Review Leader を直接起動し、既存 PR が Issue の要件を満たしているか検証する。
188
+ - **PR なし** → 通常フロー: まず Leader を起動。
189
+
190
+ 開始ポイントを決定した後:
191
+ 1. **Skill: `bo-dispatch`** を発動し、Leader(または PR 既存なら Review Leader)を起動
181
192
  2. bo-dispatch が返す結果(レポート内容)に基づいて判定:
182
193
  - Leader completed → `review_dispatched` に更新 → Review Leader 起動(再度 bo-dispatch)
183
194
  - Review Leader approve → `ci_checking` → CI 確認
184
- - Review Leader fix_required → review_count < 3 なら `fixing` → Leader 再起動 (fix mode)
195
+ - Review Leader fix_required → review_count < 3 なら `fixing` → Leader 再起動(fix mode、既存ブランチを再利用)
185
196
  - 失敗 → `error` に更新
186
197
 
187
198
  ### type: adhoc, assignee: orchestrator
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "beeops",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "3-layer multi-agent orchestration system (Queen → Leader → Worker) powered by tmux",
5
5
  "author": "YuugouOhno",
6
6
  "license": "MIT",
@@ -26,6 +26,22 @@ gh issue list -R "$REPO" --state open --json number,title,labels,assignees --lim
26
26
 
27
27
  If 0 issues, display "No issues to process" and exit.
28
28
 
29
+ ### 2.5. Detect Existing PRs
30
+
31
+ For each open Issue, check if a linked PR already exists:
32
+
33
+ ```bash
34
+ gh pr list -R "$REPO" --search "linked:issue:{number}" --state open --json number,url,headRefName --limit 1
35
+ ```
36
+
37
+ If no result, also try keyword search as fallback:
38
+
39
+ ```bash
40
+ gh pr list -R "$REPO" --search "{issue_number} in:title" --state open --json number,url,headRefName --limit 1
41
+ ```
42
+
43
+ Store the results (PR URL + branch name) for use in Step 4.
44
+
29
45
  ### 3. Load queue.yaml
30
46
 
31
47
  If `.claude/tasks/queue.yaml` exists, read it. Otherwise initialize:
@@ -37,7 +53,9 @@ tasks: []
37
53
 
38
54
  ### 4. Diff Detection and Raw Addition
39
55
 
40
- Add Issues not present in queue.yaml with `raw` status:
56
+ Add Issues not present in queue.yaml. If an existing PR was detected in Step 2.5, start from `review_dispatched`; otherwise use `raw` status:
57
+
58
+ **No existing PR (normal flow):**
41
59
 
42
60
  ```yaml
43
61
  - id: "ISSUE-{number}"
@@ -53,6 +71,22 @@ Add Issues not present in queue.yaml with `raw` status:
53
71
  - "{ISO8601} created from gh issue"
54
72
  ```
55
73
 
74
+ **Existing PR detected (skip to review):**
75
+
76
+ ```yaml
77
+ - id: "ISSUE-{number}"
78
+ issue: {number}
79
+ title: "{title}"
80
+ status: review_dispatched
81
+ priority: high
82
+ branch: "{headRefName from PR}"
83
+ depends_on: []
84
+ review_count: 0
85
+ pr: "{PR URL}"
86
+ log:
87
+ - "{ISO8601} created from gh issue (existing PR #{pr_number} detected, starting from review)"
88
+ ```
89
+
56
90
  - Skip Issues already in queue.yaml (with status other than done)
57
91
  - Update status to `done` for Issues in queue.yaml that are closed on GitHub
58
92