Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1870,6 +1870,12 @@ class Session(BaseModel):
- Keeps failed immediate saves dirty and retryable through `Ctrl+S`
- Adds focused regression coverage and documents the save behavior

- ✓ Explicit Git operations in development sessions (itdove/devaiflow#695)
- Permits explicitly requested staging, commits, fetch/sync, and pushes on the active feature branch
- Keeps DAF lifecycle and metadata commands outside active agent sessions
- Documents that manual Git operations do not complete sessions or update status/time tracking
- Verifies completion skips redundant commit/push work for pre-committed and pre-pushed changes

## Release Management

### Overview
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- All internal references updated from `daf upgrade` to `daf skills`

### Fixed
- **Allow explicit Git operations in `daf open`/`daf new` sessions** (#695)
- Permits user-requested staging, commits, fetch/sync, and pushes on the active feature branch
- Keeps DAF lifecycle and metadata commands outside active agent sessions
- Documents that manual Git operations do not complete sessions or update status/time tracking
- Preserves read-only restrictions for issue-creation and investigation sessions
- Verifies completion skips redundant commit/push work for pre-committed and pre-pushed changes
- **Use a Kilo-specific native session capture budget** (#693)
- Gives Kilo's version detection and session-list startup a bounded 10-second budget instead of OpenCode's 2-second budget
- Preserves exact project-scoped ID capture and post-exit DAF title updates for full-TUI launches
Expand Down
34 changes: 29 additions & 5 deletions devflow/cli_skills/daf-workflow/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,23 @@ provided source. Multi-project creation cancels if any project has no selected b
gh issue comment <number> --body "Progress update" # or: glab issue note <number> -m "Progress update"
```

**Git and DAF command boundaries:**
- In a development session, perform repository Git operations when the user
explicitly requests them. This includes staging and committing changes,
fetching or synchronizing the active session branch, and pushing that branch
to its remote.
- Keep branch safety rules in force: never commit directly to `main` or another
protected/default branch, never force-push without explicit direction, and do
not make Git changes automatically just because a session is active.
- Manual Git commits or pushes change the repository only. They do not mark the
DAF session complete, stop time tracking, update DAF metadata, or replace
`daf complete`.
- Run DAF lifecycle and metadata commands such as `daf complete`, `daf open`,
`daf new`, and `daf update` outside the active agent session. `daf complete`
retains its optional PR/MR and issue-update workflow and skips redundant
commit/push work when changes are already committed or the branch is already
synchronized with its remote.

**Testing Requirements:**
- Identify the project's testing framework from the codebase
- Run the project's test suite after making code changes
Expand All @@ -196,7 +213,7 @@ provided source. Multi-project creation cancels if any project has no selected b
- Verify your current working directory before making changes
- Each project has its own git repository and branch

**When work is complete**, inform the user that all acceptance criteria are met and the session is ready for completion. The user runs `daf complete` outside the active agent session to commit, create PR/MR, and close.
**When work is complete**, inform the user that all acceptance criteria are met and the session is ready for completion. The user runs `daf complete` outside the active agent session to update DAF metadata, optionally create a PR/MR, and close; it does not require another commit or push when the repository is already up to date.

For sessions using temporary clones/worktrees, the user must first **exit editing
agents**. A live DAF launch lock always refuses completion. When only cwd holders
Expand Down Expand Up @@ -276,9 +293,11 @@ recovery metadata, and never silently switch repositories or replace a recoverab
conversation. Do not delete local work to resolve retention/recovery warnings.

**Do NOT:**
- Create git commits (handled by `daf complete`)
- Create pull/merge requests (handled by `daf complete`)
- Run user-facing daf commands (new, open, complete, config, init, upgrade)
- Run DAF lifecycle or metadata commands (`daf new`, `daf open`, `daf complete`,
`daf update`, `daf config`, `daf init`, or `daf upgrade`) from inside the
active agent session
- Create pull/merge requests from inside the active agent session; let
`daf complete` handle its optional PR/MR workflow

---

Expand All @@ -296,6 +315,7 @@ select a starting branch, including the repository default, use `daf new` or

**CRITICAL CONSTRAINTS:**
- DO NOT modify any code or create/checkout git branches
- DO NOT create git commits or push changes
- DO NOT make any file changes — only READ and ANALYZE
- Focus on understanding the codebase to write a good issue

Expand Down Expand Up @@ -330,6 +350,7 @@ Analysis-only session for creating a JIRA ticket.

**CRITICAL CONSTRAINTS:**
- DO NOT modify any code or create/checkout git branches
- DO NOT create git commits or push changes
- DO NOT make any file changes — only READ and ANALYZE
- Focus on understanding the codebase to write a good JIRA ticket

Expand Down Expand Up @@ -362,6 +383,7 @@ Read-only investigation and analysis session.

**CRITICAL CONSTRAINTS:**
- DO NOT modify any code or create/checkout git branches
- DO NOT create git commits or push changes
- DO NOT make any file changes — only READ and ANALYZE
- Focus on understanding the codebase and documenting findings

Expand Down Expand Up @@ -431,7 +453,9 @@ daf config refresh-jira-fields # Refresh from JIRA API
3. Use `daf note` for local implementation details
4. Verify work meets acceptance criteria before exiting
5. Run `daf active` before making changes in multi-project sessions
6. Defer git commits and PR/MR creation to `daf complete`
6. In development sessions, make Git commits or pushes only when explicitly
requested; defer DAF lifecycle/metadata updates and PR/MR creation to
`daf complete`

**For detailed command syntax:** See **daf-cli skill**
**For JIRA field rules:** See **daf-jira-fields skill**
Expand Down
6 changes: 6 additions & 0 deletions docs/guides/session-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ Manual Git commits or pushes alone do not complete the DAF session or update its
status/time tracking. To reopen a session, move terminals outside every managed
workspace, verify no other clients use the workspaces, release remaining holders
through their supported owner/backend lifecycle, then retry `daf open <session>`.
In a normal `daf open` or `daf new` development session, an agent may run
explicitly requested Git operations on the active feature branch, including
`git add`, `git commit`, fetch/sync, and `git push`. DAF lifecycle and metadata
commands still belong outside the agent session; when `daf complete` runs, it
skips commit and push steps that are already satisfied and retains its existing
PR/MR and session-metadata workflow.

Worktrees are retained on completion by default. With
`concurrency.cleanup_on_complete: true`, `daf complete` removes a worktree only
Expand Down
7 changes: 7 additions & 0 deletions docs/reference/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,13 @@ or time tracking. To reopen after a refusal, move terminals outside every manage
workspace, release remaining holders only through their supported owner/backend
lifecycle after verifying no other clients use the workspaces, then retry
`daf open <session>`.
During a normal `daf open` or `daf new` development session, explicitly requested
Git operations on the active feature branch are permitted, including staging,
committing, fetching/synchronizing, and pushing. They do not replace DAF
lifecycle or metadata commands, which remain outside the active agent session.
If the work is already committed or the branch is already synchronized with its
remote, `daf complete` does not require a redundant commit or push; its existing
PR/MR and session-metadata behavior remains available.

For OpenCode v2, DAF launches and resumes temporary-clone sessions with
`--standalone`: OpenCode owns a private server and its resource teardown rather
Expand Down
197 changes: 197 additions & 0 deletions tests/test_complete_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -4344,6 +4344,203 @@ def mock_confirm_ask(prompt, **kwargs):
"No new commits - skipping PR creation" in captured.out)


def test_complete_skips_redundant_git_operations_for_precommitted_changes(
temp_daf_home, tmp_path, monkeypatch
):
"""Completion accepts user-created commits without committing or pushing again."""
import subprocess

repo_dir = tmp_path / "test-precommitted"
repo_dir.mkdir()
subprocess.run(
["git", "init", "-b", "main"],
cwd=repo_dir,
check=True,
capture_output=True,
)
subprocess.run(
["git", "config", "user.email", "test@example.com"],
cwd=repo_dir,
check=True,
capture_output=True,
)
subprocess.run(
["git", "config", "user.name", "Test User"],
cwd=repo_dir,
check=True,
capture_output=True,
)
(repo_dir / "test.txt").write_text("initial")
subprocess.run(["git", "add", "."], cwd=repo_dir, check=True, capture_output=True)
subprocess.run(
["git", "commit", "-m", "Initial"],
cwd=repo_dir,
check=True,
capture_output=True,
)
subprocess.run(
["git", "checkout", "-b", "feature-precommitted"],
cwd=repo_dir,
check=True,
capture_output=True,
)
(repo_dir / "feature.txt").write_text("precommitted work")
subprocess.run(["git", "add", "."], cwd=repo_dir, check=True, capture_output=True)
subprocess.run(
["git", "commit", "-m", "Add precommitted work"],
cwd=repo_dir,
check=True,
capture_output=True,
)

config_loader = ConfigLoader()
session_manager = SessionManager(config_loader)
session_manager.create_session(
name="precommitted-test",
goal="Test precommitted changes",
working_directory="test-precommitted",
project_path=str(repo_dir),
ai_agent_session_id="uuid-precommitted",
branch="feature-precommitted",
)
session_manager.start_work_session("precommitted-test")
session_manager.end_work_session("precommitted-test")

monkeypatch.setattr(
"devflow.cli.commands.complete_command._get_pr_for_branch",
lambda _working_dir, _branch: None,
)
commit = Mock()
push = Mock()
monkeypatch.setattr(GitUtils, "commit_all", commit)
monkeypatch.setattr(GitUtils, "push_branch", push)

complete_session(
"precommitted-test",
no_pr=True,
no_issue_update=True,
yes=True,
)

commit.assert_not_called()
push.assert_not_called()
completed = SessionManager(config_loader).get_session("precommitted-test")
assert completed.status == "complete"
assert completed.active_conversation.branch == "feature-precommitted"


def test_complete_skips_push_for_pre_pushed_branch_with_open_pr(
temp_daf_home, tmp_path, monkeypatch, capsys
):
"""Completion does not push again when a user-pushed branch backs an open PR."""
import subprocess

repo_dir = tmp_path / "test-pre-pushed"
repo_dir.mkdir()
remote_dir = tmp_path / "remote-pre-pushed.git"
remote_dir.mkdir()
subprocess.run(
["git", "init", "--bare"], cwd=remote_dir, check=True, capture_output=True
)
subprocess.run(
["git", "init", "-b", "main"],
cwd=repo_dir,
check=True,
capture_output=True,
)
subprocess.run(
["git", "config", "user.email", "test@example.com"],
cwd=repo_dir,
check=True,
capture_output=True,
)
subprocess.run(
["git", "config", "user.name", "Test User"],
cwd=repo_dir,
check=True,
capture_output=True,
)
subprocess.run(
["git", "remote", "add", "origin", str(remote_dir)],
cwd=repo_dir,
check=True,
capture_output=True,
)
(repo_dir / "test.txt").write_text("initial")
subprocess.run(["git", "add", "."], cwd=repo_dir, check=True, capture_output=True)
subprocess.run(
["git", "commit", "-m", "Initial"],
cwd=repo_dir,
check=True,
capture_output=True,
)
subprocess.run(
["git", "push", "-u", "origin", "main"],
cwd=repo_dir,
check=True,
capture_output=True,
)
subprocess.run(
["git", "checkout", "-b", "feature-pre-pushed"],
cwd=repo_dir,
check=True,
capture_output=True,
)
(repo_dir / "feature.txt").write_text("pushed work")
subprocess.run(["git", "add", "."], cwd=repo_dir, check=True, capture_output=True)
subprocess.run(
["git", "commit", "-m", "Add pushed work"],
cwd=repo_dir,
check=True,
capture_output=True,
)
subprocess.run(
["git", "push", "-u", "origin", "feature-pre-pushed"],
cwd=repo_dir,
check=True,
capture_output=True,
)

config_loader = ConfigLoader()
session_manager = SessionManager(config_loader)
session_manager.create_session(
name="pre-pushed-test",
goal="Test pre-pushed changes",
working_directory="test-pre-pushed",
project_path=str(repo_dir),
ai_agent_session_id="uuid-pre-pushed",
branch="feature-pre-pushed",
)
session_manager.start_work_session("pre-pushed-test")
session_manager.end_work_session("pre-pushed-test")

pr_url = "https://example.com/pull/1"
monkeypatch.setattr(
"devflow.cli.commands.complete_command._get_pr_for_branch",
lambda _working_dir, _branch: {"state": "open", "url": pr_url},
)
commit = Mock()
push = Mock()
monkeypatch.setattr(GitUtils, "commit_all", commit)
monkeypatch.setattr(GitUtils, "push_branch", push)

complete_session(
"pre-pushed-test",
no_pr=True,
no_issue_update=True,
yes=True,
)

commit.assert_not_called()
push.assert_not_called()
assert (
"Branch is up to date with remote - no push needed"
in capsys.readouterr().out
)
completed = SessionManager(config_loader).get_session("pre-pushed-test")
assert completed.status == "complete"


def test_complete_prompts_pr_when_commit_made(temp_daf_home, tmp_path, monkeypatch, capsys, clean_ci_env):
"""Test that daf complete DOES prompt for PR when a commit was made this cycle."""
# Ensure interactive mode for this test
Expand Down
38 changes: 38 additions & 0 deletions tests/test_daf_workflow_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ def _title_policy_section() -> str:
return " ".join(content[start:end].split())


def _development_section() -> str:
"""Return the managed development-session guidance."""
content = SKILL_PATH.read_text(encoding="utf-8")
start = content.index("## Development Sessions")
end = content.index("## GitHub/GitLab Issue Creation", start)
return " ".join(content[start:end].split())


def test_github_issue_lookup_is_repo_qualified_and_structured() -> None:
"""Require one deterministic GitHub lookup when metadata includes a repo."""
section = _issue_lookup_section()
Expand Down Expand Up @@ -83,6 +91,35 @@ def test_title_policy_preserves_backend_capabilities_and_reports_mismatches() ->
assert "```" not in section


def test_development_guidance_allows_explicit_git_operations() -> None:
"""Development sessions distinguish requested Git work from DAF lifecycle work."""
section = _development_section()

assert (
"perform repository Git operations when the user explicitly requests them"
in section
)
assert "staging and committing changes" in section
assert "fetching or synchronizing the active session branch" in section
assert "pushing that branch to its remote" in section
assert "never commit directly to `main`" in section
assert "do not make Git changes automatically" in section
assert "Manual Git commits or pushes change the repository only" in section
assert "do not mark the DAF session complete" in section
assert "Create git commits (handled by `daf complete`)" not in section


def test_development_guidance_keeps_daf_lifecycle_outside_agent_session() -> None:
"""Explicit Git permission must not allow DAF metadata mutations in-session."""
section = _development_section()

assert "Run DAF lifecycle and metadata commands" in section
for command in ("daf complete", "daf open", "daf new", "daf update"):
assert command in section
assert "skips redundant commit/push work" in section
assert "Create pull/merge requests from inside the active agent session" in section


@pytest.mark.parametrize(
"command", ["daf new", "daf open", "daf git new", "daf jira new", "daf investigate"]
)
Expand Down Expand Up @@ -112,6 +149,7 @@ def test_title_policy_preserves_analysis_only_workflow_constraints(
section = content[start:end]

assert "DO NOT modify any code or create/checkout git branches" in section
assert "DO NOT create git commits or push changes" in section
assert "DO NOT make any file changes — only READ and ANALYZE" in section


Expand Down
Loading