Skip to content

Refactors and enhances Kagan for Phase 2#2

Merged
aorumbayev merged 27 commits intomainfrom
phase2
Jan 29, 2026
Merged

Refactors and enhances Kagan for Phase 2#2
aorumbayev merged 27 commits intomainfrom
phase2

Conversation

@aorumbayev
Copy link
Copy Markdown
Member

Improves core functionality with the following modifications:

  • Updates documentation for accuracy and clarity
  • Enhances ACP support, including JSON-RPC and terminal handling
  • Includes various code improvements

@aorumbayev aorumbayev force-pushed the phase2 branch 3 times, most recently from 885d268 to 3d066c3 Compare January 28, 2026 17:16
- chore: add yo.txt with Hello text
- feat: create randomly named text file with random word content
- feat: create randomly named text file with random word content
- test: Add dummy text file
- test: Add dummy test.txt file
- chore: Add .mcp.json to gitignore
- feat(bla22): Add bla22 file with blll21 content
- chore: add hello.txt with blabla text
@aorumbayev aorumbayev force-pushed the phase2 branch 5 times, most recently from 9bf5cc8 to 8d866cf Compare January 29, 2026 00:41
@aorumbayev aorumbayev marked this pull request as ready for review January 29, 2026 00:55
- feat: create halo.txt with Master Chief content
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors Kagan’s Phase 2 architecture and expands functionality around agent workflows (ACP), MCP tooling, session management, and the TUI, while adding substantial documentation and test coverage.

Changes:

  • Introduces MCP server + tools (get_context, update_scratchpad, request_review) and tmux-backed PAIR sessions alongside AUTO agent workflow enhancements.
  • Extends the database schema/models to support new ticket fields (type, review metadata, scratchpads, session tracking) and adds corresponding tests.
  • Major TUI restructure: new screens/modals/widgets, first-boot Welcome flow, theme system, and E2E smoke tests + docs/CI/CD tooling.

Reviewed changes

Copilot reviewed 118 out of 119 changed files in this pull request and generated 21 comments.

Show a summary per file
File Description
tests/test_ui.py Removes older UI behavior tests (replaced by new E2E flow helpers/tests).
tests/test_signals.py Adds unit tests for agent signal parsing.
tests/test_prompt_loader.py Adds tests ensuring prompt templates contain required placeholders/signals.
tests/test_models.py Refactors model tests to parametrized coverage.
tests/test_mcp_tools.py Adds tests for MCP tool behavior and git status filtering.
tests/test_lock.py Adds tests for single-instance lock behavior.
tests/test_e2e_smoke.py Adds E2E smoke coverage for critical UI workflows.
tests/test_database.py Expands DB tests for scratchpads and new ticket fields/type.
tests/helpers/pages.py Adds reusable UI test helpers (“page” functions).
tests/helpers/init.py Declares helpers package.
src/kagan/ui/widgets/streaming_output.py Adds streaming Markdown output widget for AI responses/logs.
src/kagan/ui/widgets/status_bar.py Adds status bar widget for agent state + hints.
src/kagan/ui/widgets/search_bar.py Adds search bar widget with query-change messaging.
src/kagan/ui/widgets/header.py Enhances header with logo/version/branch/sessions and reactive updates.
src/kagan/ui/widgets/empty_state.py Adds planner empty state/tutorial widget.
src/kagan/ui/widgets/column.py Refactors Kanban column to update DOM incrementally (no full recompose).
src/kagan/ui/widgets/init.py Exposes new widgets via package exports.
src/kagan/ui/screens/welcome.py Adds first-boot welcome/configuration screen (agent/base branch/auto-mode).
src/kagan/ui/screens/ticket_editor.py Adds ticket editor screen for refining planner-proposed tickets.
src/kagan/ui/screens/kanban/focus.py Adds focus/navigation helpers for Kanban.
src/kagan/ui/screens/kanban/actions.py Adds kanban ticket operations (delete/merge/reopen/reject handling).
src/kagan/ui/screens/kanban/init.py Declares kanban screen package export.
src/kagan/ui/screens/base.py Adds typed base screen to access KaganApp.
src/kagan/ui/screens/approval.py Adds approval modal screen for planner-proposed tickets.
src/kagan/ui/screens/init.py Updates screen exports to include new screens/apps.
src/kagan/ui/modals/ticket_form.py Removes older ticket form modal.
src/kagan/ui/modals/ticket_details/form.py Introduces shared ticket-details form builder/validation utilities.
src/kagan/ui/modals/ticket_details/init.py Declares ticket details modal package export.
src/kagan/ui/modals/ticket_details.py Removes older ticket details modal (replaced by new module structure).
src/kagan/ui/modals/settings.py Adds settings modal for editing config at runtime.
src/kagan/ui/modals/review.py Adds review modal including optional AI-generated review output.
src/kagan/ui/modals/rejection_input.py Adds rejection feedback input modal.
src/kagan/ui/modals/diff.py Adds diff viewer modal.
src/kagan/ui/modals/description_editor.py Adds full-screen description editor modal.
src/kagan/ui/modals/confirm.py Adds footer to confirm modal layout.
src/kagan/ui/modals/agent_output.py Adds agent output streaming modal for AUTO tickets.
src/kagan/ui/modals/actions.py Updates modal action enum (removes EDIT).
src/kagan/ui/modals/init.py Updates modal exports to include new modals and remove deleted ones.
src/kagan/theme.py Adds shared Textual theme definition.
src/kagan/sessions/tmux.py Adds async tmux command runner and error type.
src/kagan/sessions/manager.py Adds tmux-backed SessionManager with MCP config generation and startup prompt injection.
src/kagan/sessions/init.py Exports SessionManager.
src/kagan/mcp/tools.py Adds MCP tool implementations (context/scratchpad/review + git status filtering).
src/kagan/mcp/server.py Adds FastMCP server wiring and CLI entrypoint for stdio transport.
src/kagan/mcp/init.py Exports MCP entrypoint and server wrapper.
src/kagan/lock.py Adds file-based instance lock to prevent multiple concurrent runs.
src/kagan/limits.py Adds centralized numeric limits/timeouts.
src/kagan/git_utils.py Adds git repo detection/init helpers (including base branch + initial commit).
src/kagan/database/schema.sql Extends schema with new ticket fields + scratchpads table.
src/kagan/database/queries.py Adds query helpers and row mapping for new schema fields.
src/kagan/database/models.py Extends models with ticket type and review/session/scratchpad-related fields.
src/kagan/data/builtin_agents.py Adds built-in agent definitions (Claude/OpenCode) + metadata.
src/kagan/data/init.py Exports built-in agent helpers.
src/kagan/constants.py Expands constants: UI sizing/truncation, generated files list, limits re-exports.
src/kagan/config.py Refactors config into agent definitions with OS-specific command matrices.
src/kagan/app.py Major app init refactor: theme, signals, first-boot welcome flow, scheduler/session/worktree wiring, instance lock integration.
src/kagan/agents/signals.py Adds signal parsing for agent completion/review outcomes.
src/kagan/agents/prompt_loader.py Adds hardcoded prompts (iteration + review).
src/kagan/agents/prompt.py Builds iteration prompts combining description, criteria, hat instructions, scratchpad.
src/kagan/agents/planner.py Adds planner prompt and XML plan parsing into TicketCreate objects.
src/kagan/agents/config_resolver.py Adds unified agent config resolution precedence logic.
src/kagan/agents/init.py Exports agents utilities and signals.
src/kagan/acp/terminals.py Adds terminal manager for ACP terminal lifecycle.
src/kagan/acp/terminal.py Adds terminal runner implementation for ACP commands (subprocess capture).
src/kagan/acp/rpc.py Adds ACP RPC handlers for streaming, permission prompts, fs ops, terminal ops.
src/kagan/acp/messages.py Adds Textual message types for ACP agent events.
src/kagan/acp/buffers.py Adds bounded buffers for streaming responses/messages.
src/kagan/acp/api.py Adds ACP client API method stubs for JSON-RPC layer.
src/kagan/acp/init.py Declares ACP package.
src/kagan/main.py Replaces argparse CLI with click, adds tui + mcp commands and preflight/lock handling.
src/kagan/init.py Uses package metadata version + re-exports OS helpers.
pyproject.toml Updates deps, scripts, pytest/coverage/xdist settings, docs/release tooling config.
mkdocs.yml Adds MkDocs site config.
docs/user-guide.md Adds user guide documentation.
docs/index.md Adds docs landing page.
docs/contributing.md Adds docs-level contributing pointer.
docs/config.md Adds configuration documentation.
README.md Adds top-level README content.
LICENSE Adds MIT license text.
CONTRIBUTING.md Adds contributor guide and codebase conventions.
CLAUDE.md Adds short agent guidance pointer.
.pre-commit-config.yaml Adds/updates pre-commit hooks (formatting, yaml checks, etc.).
.gitignore Adds ignore for generated MCP config file.
.github/workflows/ci.yml Adjusts CI triggers to only run on relevant file changes.
.github/workflows/cd.yaml Adds CD workflow using python-semantic-release + docs publish to Pages.
.github/dependabot.yml Adds Dependabot config for pip ecosystem.
.github/copilot-instructions.md Adds Copilot instruction pointer to AGENTS.md.
.github/PULL_REQUEST_TEMPLATE.md Adds PR template.
.github/ISSUE_TEMPLATE/feature_request.md Adds feature request template.
.github/ISSUE_TEMPLATE/config.yml Adds issue template config + contact links.
.github/ISSUE_TEMPLATE/bug_report.md Adds bug report template.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/kagan/database/queries.py Outdated
Comment thread src/kagan/database/queries.py
Comment thread src/kagan/ui/screens/kanban/actions.py
Comment thread src/kagan/git_utils.py Outdated
Comment thread src/kagan/agents/worktree.py Outdated
Comment thread src/kagan/ui/screens/kanban/screen.py
Comment thread src/kagan/ui/widgets/streaming_output.py
Comment thread src/kagan/ui/widgets/streaming_output.py
Comment thread src/kagan/ui/widgets/streaming_output.py
Comment thread src/kagan/acp/terminal.py
Removed the Star History section from the README.
Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 29, 2026

@aorumbayev I've opened a new pull request, #4, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 4 commits January 29, 2026 01:27
- Add return code checking for `git add` command
- Add return code checking for `git commit` command
- Return False when either command fails (e.g., missing git user.name/user.email)
- Ensures function only returns True when initial commit is successfully created
- Prevents subsequent worktree creation failures due to missing base branch ref

Addresses review feedback on PR #2

Co-authored-by: aorumbayev <[email protected]>
- Check return code of `git branch -M` command in the fallback path
- Ensures consistent error handling across all git commands
- Prevents continuing with commit attempts when branch rename fails

Co-authored-by: aorumbayev <[email protected]>
Enhances database query robustness by adding a helper function to safely retrieve values from database rows, handling missing keys gracefully.
Also, it simplifies the `_run_git` call during squash merges in the worktree manager.
@aorumbayev aorumbayev merged commit 6c03871 into main Jan 29, 2026
1 check passed
@aorumbayev aorumbayev deleted the phase2 branch January 29, 2026 02:10
aorumbayev added a commit that referenced this pull request Feb 13, 2026
Implement GH-2 connect flow with deterministic gh CLI preflight checks,
repo-level metadata persistence through project service boundaries, and
machine-readable failure codes with actionable hints.

Co-authored-by: Altynbek Orumbayev <[email protected]>
aorumbayev added a commit that referenced this pull request Feb 13, 2026
Implement repo-level GitHub connect flow with deterministic gh CLI preflight checks per .github/context/github-plugin-v1/tickets/GH-2-repo-connect-preflight.md.

References to completed tickets:
- @.github/context/github-plugin-v1/tickets/GH-1-plugin-scaffold.md (task 98fe70ec)
aorumbayev added a commit that referenced this pull request Feb 13, 2026
Reference: .github/context/github-plugin-v1/tickets/GH-3-issue-sync-mapping.md

Depends On: GH-2

Outcome
GitHub issues are synchronized into Kagan task projections.

Scope
- Add incremental sync operation and checkpoint tracking.
- Upsert task projection from issue metadata.
- Maintain issue-to-task mapping and repair hooks.
- Resolve task mode from labels/default policy during sync.

Prior work references
- bb261e3
- 79b958b
- 02622f7
- ce4416c
- 64e0179

---
**Review Feedback (2026-02-13 02:29):**
rebase against latest state on the branch 55e4b44
aorumbayev added a commit that referenced this pull request Feb 13, 2026
Mark GH-1 and GH-2 as Done in ticket index, add implementation
summaries to GH-1, GH-2, and GH-7 tickets, and update
scratchpad next actions with current blocked/unblocked status.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
aorumbayev added a commit that referenced this pull request Feb 14, 2026
Source: .github/context/github-plugin-v1/tickets/GH-2-repo-connect-preflight.md
Dependency: GH-1 (already merged in commit 35a301a).
Implement deterministic GitHub repo connect flow with gh preflight checks and persisted connection metadata.
aorumbayev added a commit that referenced this pull request Feb 14, 2026
Source: .github/context/github-plugin-v1/tickets/GH-3-issue-sync-mapping.md
Dependency: GH-2.
Implement incremental issue sync, task projection upsert, mapping maintenance, and deterministic mode resolution.
aorumbayev added a commit that referenced this pull request Feb 21, 2026
* chore: wip

* chore: acp support

* chore: docs and other polish

* chore: codex tweaks

* chore: refactor

* feat: prompt customization

* chore: the pair mode

* chore: pair mode continuiation

* chore: refinements

* chore: tests

* chore: refine

* test: Test

- chore: add yo.txt with Hello text

* feat(randomly): Create Randomly Named Text Fil

- feat: create randomly named text file with random word content

* feat(randomly): Create Randomly Named Text Fil

- feat: create randomly named text file with random word content

* test: Test

- test: Add dummy text file

* test: Test

- test: Add dummy test.txt file

* test: Test

- chore: Add .mcp.json to gitignore

* chore: Bla 22

- feat(bla22): Add bla22 file with blll21 content

* chore: wip

* feat(extra): Create Extra File

- chore: add hello.txt with blabla text

* test: Test

- feat: create halo.txt with Master Chief content

* Remove Star History section from README

Removed the Star History section from the README.

* Initial plan

* fix: Check return codes in init_git_repo for git add and commit

- Add return code checking for `git add` command
- Add return code checking for `git commit` command
- Return False when either command fails (e.g., missing git user.name/user.email)
- Ensures function only returns True when initial commit is successfully created
- Prevents subsequent worktree creation failures due to missing base branch ref

Addresses review feedback on PR #2

Co-authored-by: aorumbayev <[email protected]>

* fix: Also check return code for git branch -M in fallback path

- Check return code of `git branch -M` command in the fallback path
- Ensures consistent error handling across all git commands
- Prevents continuing with commit attempts when branch rename fails

Co-authored-by: aorumbayev <[email protected]>

* fix: Improves data handling and git merge process

Enhances database query robustness by adding a helper function to safely retrieve values from database rows, handling missing keys gracefully.
Also, it simplifies the `_run_git` call during squash merges in the worktree manager.

---------

Co-authored-by: Test User <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
aorumbayev added a commit that referenced this pull request Mar 29, 2026
* chore: wip

* chore: acp support

* chore: docs and other polish

* chore: codex tweaks

* chore: refactor

* feat: prompt customization

* chore: the pair mode

* chore: pair mode continuiation

* chore: refinements

* chore: tests

* chore: refine

* test: Test

- chore: add yo.txt with Hello text

* feat(randomly): Create Randomly Named Text Fil

- feat: create randomly named text file with random word content

* feat(randomly): Create Randomly Named Text Fil

- feat: create randomly named text file with random word content

* test: Test

- test: Add dummy text file

* test: Test

- test: Add dummy test.txt file

* test: Test

- chore: Add .mcp.json to gitignore

* chore: Bla 22

- feat(bla22): Add bla22 file with blll21 content

* chore: wip

* feat(extra): Create Extra File

- chore: add hello.txt with blabla text

* test: Test

- feat: create halo.txt with Master Chief content

* Remove Star History section from README

Removed the Star History section from the README.

* Initial plan

* fix: Check return codes in init_git_repo for git add and commit

- Add return code checking for `git add` command
- Add return code checking for `git commit` command
- Return False when either command fails (e.g., missing git user.name/user.email)
- Ensures function only returns True when initial commit is successfully created
- Prevents subsequent worktree creation failures due to missing base branch ref

Addresses review feedback on PR #2

* fix: Also check return code for git branch -M in fallback path

- Check return code of `git branch -M` command in the fallback path
- Ensures consistent error handling across all git commands
- Prevents continuing with commit attempts when branch rename fails

* fix: Improves data handling and git merge process

Enhances database query robustness by adding a helper function to safely retrieve values from database rows, handling missing keys gracefully.
Also, it simplifies the `_run_git` call during squash merges in the worktree manager.

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
aorumbayev added a commit that referenced this pull request Mar 29, 2026
* chore: wip

* chore: acp support

* chore: docs and other polish

* chore: codex tweaks

* chore: refactor

* feat: prompt customization

* chore: the pair mode

* chore: pair mode continuiation

* chore: refinements

* chore: tests

* chore: refine

* test: Test

- chore: add yo.txt with Hello text

* feat(randomly): Create Randomly Named Text Fil

- feat: create randomly named text file with random word content

* feat(randomly): Create Randomly Named Text Fil

- feat: create randomly named text file with random word content

* test: Test

- test: Add dummy text file

* test: Test

- test: Add dummy test.txt file

* test: Test

- chore: Add .mcp.json to gitignore

* chore: Bla 22

- feat(bla22): Add bla22 file with blll21 content

* chore: wip

* feat(extra): Create Extra File

- chore: add hello.txt with blabla text

* test: Test

- feat: create halo.txt with Master Chief content

* Remove Star History section from README

Removed the Star History section from the README.

* Initial plan

* fix: Check return codes in init_git_repo for git add and commit

- Add return code checking for `git add` command
- Add return code checking for `git commit` command
- Return False when either command fails (e.g., missing git user.name/user.email)
- Ensures function only returns True when initial commit is successfully created
- Prevents subsequent worktree creation failures due to missing base branch ref

Addresses review feedback on PR #2

Co-authored-by: aorumbayev <[email protected]>

* fix: Also check return code for git branch -M in fallback path

- Check return code of `git branch -M` command in the fallback path
- Ensures consistent error handling across all git commands
- Prevents continuing with commit attempts when branch rename fails

Co-authored-by: aorumbayev <[email protected]>

* fix: Improves data handling and git merge process

Enhances database query robustness by adding a helper function to safely retrieve values from database rows, handling missing keys gracefully.
Also, it simplifies the `_run_git` call during squash merges in the worktree manager.

---------

Co-authored-by: Test User <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants