From 8ae55945b53b8bffecaed3e0993d63134cafe5a5 Mon Sep 17 00:00:00 2001 From: liplus-lin-lay Date: Fri, 27 Mar 2026 21:24:44 +0900 Subject: [PATCH 1/5] spec(subagent): simplify delegation to hook-chain driven workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit サブエージェントへの伝達を最小化し、hook チェーン駆動で自律的にオペレーション ファイルを読み込むワークフローに変更。 変更前: Li+core.md パス、Li+operations.md パス、issue 番号、リポジトリ、意図を伝達 変更後: Li+core.md パスと issue URL のみ伝達。意図は issue body に記載済み。 Li+operations.md は hook チェーン(on_issue → on_branch → ...)で自動読み込み。 hook 非対応環境ではフォールバックとして operations パスも渡す。 Refs #890 --- Li+github.md | 18 +++++++++--------- docs/2.-Task.md | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Li+github.md b/Li+github.md index 9f4ff3d..7b39ff3 100644 --- a/Li+github.md +++ b/Li+github.md @@ -86,16 +86,11 @@ Issue Rules Parent close condition is structural = all child issues closed except deferred. Sub-issue = AI-trackable work unit. - Sub-issue does not get its own branch. - Session branch links to parent issue. - Multiple child issues can share one session branch. - Session branch = branch-side external memory and handoff surface. - Another AI may continue from parent issue + linked branch without relying on prior chat memory. Split by responsibility, not granularity. + Branch rules for sub-issues: see Li+operations.md Branch_And_Label_Flow. Simultaneous tasks require parent-child structure: If multiple tasks in same session = create parent issue + sub-issues. - Reason: gh issue develop links only one issue per branch. Do not create multiple independent issues for simultaneous work. Sub-issue API: @@ -130,9 +125,14 @@ Issue Rules Subagent executes: branch, implementation, commit, push, PR, CI loop, merge. Convey to subagent: - Li+core.md path, Li+operations.md path, issue number, repository, intent. - Do not convey: Li+github.md, step-by-step procedure, branch name, commit message. - Subagent reads Li+core.md and Li+operations.md, then decides execution details. + Li+core.md path, issue URL. + Do not convey: Li+github.md, Li+operations.md path, step-by-step procedure, branch name, commit message, intent. + Intent is already in issue body. + Subagent reads Li+core.md, then hook chain drives the rest: + self-assign → on_issue fires → Li+github.md loaded + branch create → on_branch fires → Li+operations.md loaded + commit / PR / CI → corresponding hooks fire → operations rules loaded + Fallback: if hooks are unavailable, also convey Li+operations.md path. Detailed parent instructions risk conflicting with operations rules. Issue body update: diff --git a/docs/2.-Task.md b/docs/2.-Task.md index 8972283..d77447f 100644 --- a/docs/2.-Task.md +++ b/docs/2.-Task.md @@ -148,7 +148,7 @@ issue / commit / PR の形式に適用する。 ### 伝達内容 -親はサブエージェントに Li+core.md パス、Li+operations.md パス、issue 番号、リポジトリ、意図を伝える。Li+github.md、手順の詳細、ブランチ名、コミットメッセージは伝えない。サブエージェントが Li+core.md と Li+operations.md を読んで実行詳細を自ら決定する。親からの詳細指示はオペレーションルールと矛盾するリスクがある。 +親はサブエージェントに Li+core.md パスと issue URL を伝える。Li+github.md、Li+operations.md パス、手順の詳細、ブランチ名、コミットメッセージ、意図は伝えない。意図は issue body に記載されている。サブエージェントは Li+core.md を読み、以降は hook チェーンで自律的にオペレーションファイルを読み込む(self-assign → on_issue → Li+github.md、branch 作成 → on_branch → Li+operations.md、以降 commit / PR / CI も同様)。hook が発火しない環境では、フォールバックとして Li+operations.md パスも伝える。親からの詳細指示はオペレーションルールと矛盾するリスクがある。 ### issue body 更新 From 1827eb175d5277f07f6ee75e4b0b6ea2a9c6f9a4 Mon Sep 17 00:00:00 2001 From: liplus-lin-lay Date: Fri, 27 Mar 2026 21:26:51 +0900 Subject: [PATCH 2/5] refactor(issue-flow): move branch rules from Issue_Flow to Branch_And_Label_Flow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue_Flow のブランチ関連記述(sub-issue ブランチルール、gh issue develop リンク制約、 ブランチリンクターゲット)を operations レイヤーの Branch_And_Label_Flow に移動。 on_issue で読み込む内容を issue 管理(ラベル・アサイン・body)に集中させる。 docs/2.-Task.md と docs/3.-Operations.md も対応更新。 Refs #891 --- Li+github.md | 4 +--- Li+operations.md | 12 ++++++++++++ docs/2.-Task.md | 10 ++++------ docs/3.-Operations.md | 6 +++++- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Li+github.md b/Li+github.md index 7b39ff3..657d240 100644 --- a/Li+github.md +++ b/Li+github.md @@ -142,9 +142,7 @@ Issue Rules Failure reporting: On failure, subagent writes failure report as issue comment. Format is not specified. - Branch linking: - gh issue develop targets child issue, not parent. - Reason: PR merge auto-closes the linked issue. Linking parent causes premature parent close. + Branch linking: see Li+operations.md Branch_And_Label_Flow. If subagent capability is unavailable: Parent executes operations directly. All rules still apply. diff --git a/Li+operations.md b/Li+operations.md index 405fcbe..b7ccb68 100644 --- a/Li+operations.md +++ b/Li+operations.md @@ -68,6 +68,18 @@ Event-Driven Operations Issue link via gh issue develop is always required. gh issue develop must precede first push to GitHub. + Sub-issue branch rules: + Sub-issue does not get its own branch. + Session branch links to parent issue. + Multiple child issues can share one session branch. + Session branch = branch-side external memory and handoff surface. + Another AI may continue from parent issue + linked branch without relying on prior chat memory. + Reason: gh issue develop links only one issue per branch. + + Branch linking target: + gh issue develop targets child issue, not parent. + Reason: PR merge auto-closes the linked issue. Linking parent causes premature parent close. + On local error: gh issue develop may fail locally but succeed on GitHub side. Check linked branches before retrying: diff --git a/docs/2.-Task.md b/docs/2.-Task.md index d77447f..547a2db 100644 --- a/docs/2.-Task.md +++ b/docs/2.-Task.md @@ -90,11 +90,9 @@ issue の完了判断は本文項目ではなく、issue 状態と PR/CI/release ### sub-issue -sub-issue は AI が追跡・実行できる作業単位として使う。sub-issue にはブランチを作らない。セッションブランチは親 issue にリンクする。複数の子 issue の作業を同じセッションブランチで進めてよい。 +sub-issue は AI が追跡・実行できる作業単位として使う。分割は**責務**で行う。粒度で分けない。同じ責務なら1つの issue にまとめる。複数ファイルにまたがっていても責務が同じなら1つでよい。 -セッションブランチは branch 側の外部記憶であり、引き継ぎ面でもある。別の AI は親 issue とリンク済みブランチを読めば、以前の会話に依存せず途中から継続できる状態を目指す。 - -分割は**責務**で行う。粒度で分けない。同じ責務なら1つの issue にまとめる。複数ファイルにまたがっていても責務が同じなら1つでよい。 +sub-issue のブランチルール(ブランチを作らない、セッションブランチは親 issue にリンクする等)はオペレーションレイヤー仕様書のブランチ運用セクションを参照。 sub-issue API: @@ -106,7 +104,7 @@ gh api repos/{owner}/{repo}/issues/{number} --jq '.id' gh api repos/{owner}/{repo}/issues/{parent}/sub_issues --method POST -f sub_issue_id={id} ``` -同時タスクは親子 issue 構造を使う。複数タスクを同一セッションで並行進行する場合、issue を個別に作成するとブランチリンクが1件にしか張れない(プラットフォーム制約)。 +同時タスクは親子 issue 構造を使う。複数タスクを同一セッションで並行進行する場合、独立した issue を個別に作成せず親子構造にまとめる。ブランチリンクの制約詳細はオペレーションレイヤー仕様書を参照。 ### チェックリスト @@ -160,7 +158,7 @@ issue / commit / PR の形式に適用する。 ### ブランチリンク -`gh issue develop` は子 issue に対して実行する。親 issue にリンクしない。理由:PR マージ時にリンクされた issue が自動クローズされるため、親にリンクすると親が早期クローズされる。 +ブランチリンクのターゲットルールはオペレーションレイヤー仕様書のブランチ運用セクションを参照。 ### フォールバック diff --git a/docs/3.-Operations.md b/docs/3.-Operations.md index 2b99a4d..64938ad 100644 --- a/docs/3.-Operations.md +++ b/docs/3.-Operations.md @@ -54,7 +54,11 @@ trigger mode でも issue の作成・本文更新とブランチ準備は待た ### ブランチ作成 -issue リンクは常に必須。リンクは GitHub への初回 push より前に実行する。sub-issue にはブランチを作らない。ブランチを持つのは実際に PR を出す作業単位(親 issue)だけ。 +issue リンクは常に必須。リンクは GitHub への初回 push より前に実行する。 + +sub-issue にはブランチを作らない。セッションブランチは親 issue にリンクする。複数の子 issue の作業を同じセッションブランチで進めてよい。セッションブランチは branch 側の外部記憶であり、引き継ぎ面でもある。別の AI は親 issue とリンク済みブランチを読めば、以前の会話に依存せず途中から継続できる状態を目指す。`gh issue develop` のリンクは1 issue につき1ブランチの制約があるため、同時タスクでは親子構造を使う。 + +`gh issue develop` は子 issue に対して実行する。親 issue にリンクしない。理由:PR マージ時にリンクされた issue が自動クローズされるため、親にリンクすると親が早期クローズされる。 ブランチ作成前にローカルとリモートの存在確認を行う。リモートに既存ブランチがある場合、後からリンクは張れない。 From 6a815583aa7c9a0cf0a5b7eeb81b88e24ef3cc00 Mon Sep 17 00:00:00 2001 From: liplus-lin-lay Date: Fri, 27 Mar 2026 21:52:54 +0900 Subject: [PATCH 3/5] fix(agent,hooks): align delegation and hook routing with simplified spec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Li+agent.md: 委譲ルールをhookチェーン駆動に更新(core path + issue URLのみ伝達)。 Li+github.md で適用済みの簡素化仕様と同じセマンティクスに統一。 Li+claude.md: assignees系APIコール(gh issue assign / gh api .*/issues/.*/assignees)を on_issueブロックより前でインターセプトし、Li+operations.md Branch_And_Label_Flow を 読み込むよう修正。assign = 即行動 = ブランチ作業開始のため。 Refs #890 --- Li+agent.md | 13 ++++++++----- Li+claude.md | 11 +++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Li+agent.md b/Li+agent.md index ec2e818..38febd1 100644 --- a/Li+agent.md +++ b/Li+agent.md @@ -81,11 +81,14 @@ Purpose: - Main agent retains Model Layer + Task Layer (dialogue, requirements, issue management, review). When delegating to a subagent, convey: -- Li+core.md path and Li+operations.md path (subagent reads both before any action). -- Issue number, repository, working directory, intent. -- Execute the full cycle (branch, implementation, commit, push, PR, CI loop) and report result. -Do not convey: Li+github.md, branch name, commit message, step-by-step procedure, file scope constraint. -Subagent reads the issue and operations rules, then decides execution details autonomously. +- Li+core.md path, issue URL. +Do not convey: Li+github.md, Li+operations.md path, branch name, commit message, step-by-step procedure, intent, file scope constraint. +Intent is already in issue body. +Subagent reads Li+core.md, then hook chain drives the rest: + self-assign → on_issue fires → Li+github.md loaded + branch create → on_branch fires → Li+operations.md loaded + commit / PR / CI → corresponding hooks fire → operations rules loaded +Fallback: if hooks are unavailable, also convey Li+operations.md path. Subagent issue management: - Subagent may update issue body when premise or constraints change during implementation. diff --git a/Li+claude.md b/Li+claude.md index b13e9e5..8879a4f 100644 --- a/Li+claude.md +++ b/Li+claude.md @@ -209,6 +209,17 @@ ${APPEND_MSG}" exit 0 fi +# on_branch (assignees): assign = act now = start of branch work → Li+operations.md Branch_And_Label_Flow +if echo "$CMD_LINE" | grep -qE 'gh(\.exe)? (issue assign|api .*/issues/.*/assignees)'; then + CONTEXT=$(get_section \ + "on_branch: Branch_And_Label_Flow re-read (assignees)" \ + "$OPERATIONS_MD" \ + "Branch And Label Flow" \ + "Docs And Requirement Ownership") + emit_context "$CONTEXT" + exit 0 +fi + # on_issue: gh issue → Li+github.md Issue_Flow section re-read if echo "$CMD_LINE" | grep -qE 'gh(\.exe)? (issue|api .*/issues)'; then CONTEXT=$(get_section \ From 5b81a862669acf9c06668f15ccc6d1121564be87 Mon Sep 17 00:00:00 2001 From: liplus-lin-lay Date: Fri, 27 Mar 2026 21:54:12 +0900 Subject: [PATCH 4/5] docs(adapter): update delegation and hook routing specs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 委任セクションをhookチェーン駆動仕様に更新。 post-tool-use.sh テーブルに assignees インターセプト行を追加。 Refs #890 --- docs/4.-Adapter.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/4.-Adapter.md b/docs/4.-Adapter.md index 7f0ba41..1807703 100644 --- a/docs/4.-Adapter.md +++ b/docs/4.-Adapter.md @@ -63,7 +63,8 @@ settings.json の hook command はプロジェクトディレクトリにスペ | コマンドパターン | 再読込対象 | 追加動作 | |---|---|---| -| `gh issue` / `gh api .*/issues` | タスクレイヤーの Issue Flow セクション | — | +| `gh issue assign` / `gh api .*/issues/.*/assignees` | オペレーションレイヤーの Branch And Label Flow セクション | assign = 即行動 = ブランチ作業開始 | +| `gh issue` / `gh api .*/issues`(assignees 以外) | タスクレイヤーの Issue Flow セクション | — | | `gh issue develop` / `git switch -c` / `git checkout -b` | オペレーションレイヤーの Branch And Label Flow セクション | — | | `git commit` | オペレーションレイヤーの Commit Rules セクション | — | | `gh pr create` | オペレーションレイヤーの PR Creation セクション | PR body への子 issue 参照の自動補完 | @@ -127,9 +128,14 @@ bootstrap は次回セッションから有効。現セッションは Li+config ### 伝達内容 -メインエージェントはサブエージェントに Li+core.md パス、Li+operations.md パス、issue 番号、リポジトリ、作業ディレクトリ、意図を伝える。サブエージェントはブランチ作成から実装、コミット、プッシュ、PR 作成、CI ループまでの全サイクルを実行し、結果を報告する。 +メインエージェントはサブエージェントに Li+core.md パスと issue URL のみを伝える。Li+github.md、Li+operations.md パス、ブランチ名、コミットメッセージ、手順の詳細、意図、ファイルスコープ制約は伝えない。意図は issue body に既に記載されている。 -Li+github.md、ブランチ名、コミットメッセージ、手順の詳細、ファイルスコープ制約は伝えない。サブエージェントが issue とオペレーションルールを読み、実行詳細を自律的に決定する。 +サブエージェントは Li+core.md を読み込んだ後、hook チェーンが残りを駆動する: +- self-assign → on_issue 発火 → Li+github.md 読込 +- branch create → on_branch 発火 → Li+operations.md 読込 +- commit / PR / CI → 対応 hook 発火 → operations ルール読込 + +フォールバック:hook が利用できない場合は Li+operations.md パスも追加で伝える。 ### issue 管理 From dc8e6e1fe8540f0bcddeacdbb0874016992f1a5c Mon Sep 17 00:00:00 2001 From: liplus-lin-lay Date: Fri, 27 Mar 2026 22:13:26 +0900 Subject: [PATCH 5/5] Add Li+github.md to hook-unavailable fallback in subagent delegation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #897 hook が利用できない環境でのフォールバックに Li+github.md パスを追加。 サブエージェントが hook チェーンなしで起動した場合、on_issue による Li+github.md 自動読込が発火しないため、明示的にパスを伝える必要がある。 対象ファイル: Li+github.md, Li+agent.md, docs/2.-Task.md, docs/4.-Adapter.md --- Li+agent.md | 2 +- Li+github.md | 2 +- docs/2.-Task.md | 2 +- docs/4.-Adapter.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Li+agent.md b/Li+agent.md index 38febd1..ef54f2b 100644 --- a/Li+agent.md +++ b/Li+agent.md @@ -88,7 +88,7 @@ Subagent reads Li+core.md, then hook chain drives the rest: self-assign → on_issue fires → Li+github.md loaded branch create → on_branch fires → Li+operations.md loaded commit / PR / CI → corresponding hooks fire → operations rules loaded -Fallback: if hooks are unavailable, also convey Li+operations.md path. +Fallback: if hooks are unavailable, also convey Li+github.md path and Li+operations.md path. Subagent issue management: - Subagent may update issue body when premise or constraints change during implementation. diff --git a/Li+github.md b/Li+github.md index 657d240..9f41d80 100644 --- a/Li+github.md +++ b/Li+github.md @@ -132,7 +132,7 @@ Issue Rules self-assign → on_issue fires → Li+github.md loaded branch create → on_branch fires → Li+operations.md loaded commit / PR / CI → corresponding hooks fire → operations rules loaded - Fallback: if hooks are unavailable, also convey Li+operations.md path. + Fallback: if hooks are unavailable, also convey Li+github.md path and Li+operations.md path. Detailed parent instructions risk conflicting with operations rules. Issue body update: diff --git a/docs/2.-Task.md b/docs/2.-Task.md index 547a2db..de1cfbf 100644 --- a/docs/2.-Task.md +++ b/docs/2.-Task.md @@ -146,7 +146,7 @@ issue / commit / PR の形式に適用する。 ### 伝達内容 -親はサブエージェントに Li+core.md パスと issue URL を伝える。Li+github.md、Li+operations.md パス、手順の詳細、ブランチ名、コミットメッセージ、意図は伝えない。意図は issue body に記載されている。サブエージェントは Li+core.md を読み、以降は hook チェーンで自律的にオペレーションファイルを読み込む(self-assign → on_issue → Li+github.md、branch 作成 → on_branch → Li+operations.md、以降 commit / PR / CI も同様)。hook が発火しない環境では、フォールバックとして Li+operations.md パスも伝える。親からの詳細指示はオペレーションルールと矛盾するリスクがある。 +親はサブエージェントに Li+core.md パスと issue URL を伝える。Li+github.md、Li+operations.md パス、手順の詳細、ブランチ名、コミットメッセージ、意図は伝えない。意図は issue body に記載されている。サブエージェントは Li+core.md を読み、以降は hook チェーンで自律的にオペレーションファイルを読み込む(self-assign → on_issue → Li+github.md、branch 作成 → on_branch → Li+operations.md、以降 commit / PR / CI も同様)。hook が発火しない環境では、フォールバックとして Li+github.md パスと Li+operations.md パスも伝える。親からの詳細指示はオペレーションルールと矛盾するリスクがある。 ### issue body 更新 diff --git a/docs/4.-Adapter.md b/docs/4.-Adapter.md index 1807703..cf6d084 100644 --- a/docs/4.-Adapter.md +++ b/docs/4.-Adapter.md @@ -135,7 +135,7 @@ bootstrap は次回セッションから有効。現セッションは Li+config - branch create → on_branch 発火 → Li+operations.md 読込 - commit / PR / CI → 対応 hook 発火 → operations ルール読込 -フォールバック:hook が利用できない場合は Li+operations.md パスも追加で伝える。 +フォールバック:hook が利用できない場合は Li+github.md パスと Li+operations.md パスも追加で伝える。 ### issue 管理