Skip to content

idd-all: direct-commit mode 加 passive warning (dirty tree / on default branch) #2

@kiki830621

Description

@kiki830621

Problem

From verification of #1 (P2/P3 findings 9 + 19 — security+devils reviewers):
direct-commit mode 兩個 safety gap:

  1. 跳過 clean-tree gate:Phase 0.5 在 direct-commit 路徑下不檢查 working tree clean。HITL user 若有 staged 的 .env / API key / .idea/ 等敏感檔案,會被下游 sub-skill 的 git add / git commit -a 連帶 commit 進 history。
  2. direct-commit + main branch 缺顯眼 warning:commits 直接 land 主 branch,沒 PR review gate 保護;user 可能沒意識到自己當下在 main。

Spec rationale 認為 "user 自負其責" 是合理 trade-off,但完全 silent skip 的 UX 缺乏 hint。

Type

enhancement

Why P2/P3 not P1

不阻擋 #1 close — direct-commit + dirty tree 是有意設計選擇,只是缺 user-facing notice。但「常見足以該被防」的 sensitive-file scenario 值得 passive warning。

Recommendation

Phase 0.5 direct-commit 分支加 passive warning(不 abort,只 echo):

if [ "$PATH_AXIS" = "direct-commit" ]; then
  CURRENT_BRANCH=$(git -C "$CWD" branch --show-current)
  echo "→ direct-commit path: committing to ${CURRENT_BRANCH}, no PR will be opened"

  # Passive warning: dirty tree
  if [ -n "$(git -C "$CWD" status --porcelain)" ]; then
    echo "⚠ Working tree has uncommitted changes — these will be intermingled with idd-all commits."
    echo "  If sensitive (e.g. .env, secrets), abort now and commit/stash them first."
  fi

  # Passive warning: on default branch
  DEFAULT=$(gh repo view "$GITHUB_REPO" --json defaultBranchRef -q .defaultBranchRef.name)
  if [ "$CURRENT_BRANCH" = "$DEFAULT" ]; then
    echo "⚠ direct-commit on default branch '${DEFAULT}' — no PR review gate."
  fi
fi

Pure additive,不改 abort 行為,只 surface 風險給 user。

Source

Related: #1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions