getapo 0.3.2__tar.gz → 0.3.3__tar.gz
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.
- {getapo-0.3.2 → getapo-0.3.3}/PKG-INFO +1 -1
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/__init__.py +1 -1
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/changelog.py +49 -4
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/cli.py +74 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/db.py +4 -3
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/resources/guide.md +3 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/app.py +7 -5
- {getapo-0.3.2 → getapo-0.3.3}/src/getapo.egg-info/PKG-INFO +1 -1
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_cli.py +215 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_entry_points.py +1 -1
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_landing.py +79 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_wheel.py +1 -1
- {getapo-0.3.2 → getapo-0.3.3}/LICENSE +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/README.md +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/THIRD_PARTY_NOTICES.md +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/pyproject.toml +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/setup.cfg +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/__main__.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/claude_runtime.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/config.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/credentials.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/installer.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/integrations/__init__.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/integrations/linear_client.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/integrations/linear_goals.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/integrations/sources.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/mcp_server.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/repo_writer.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/resources/hooks/session-decisions-nudge.sh +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/resources/skills/decisions/SKILL.md +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/transcripts.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/verify.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/__init__.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/static/app.css +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/static/app.js +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/static/fleet.js +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/static/live.js +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/static/notify.js +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/static/now.js +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/static/palette.js +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/static/round.js +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_agents_board.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_attachment_composer.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_bulk.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_decision_log.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_icons.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_macros.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_merge_result.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_new_work.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_now_item.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_project_macros.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_prompt_form.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_reply_form.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_resume_actions.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_session_card.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_week_overview.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_work_location.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_work_main.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/_work_status.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/accept.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/all_activity.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/all_agents.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/all_overview.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/all_work.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/base.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/decision.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/guide.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/now.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/outcome.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/project_activity.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/project_agents.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/project_overview.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/project_settings.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/project_work.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/projects_shell.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/report.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/round.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/search.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/session.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/apo/web/templates/settings.html +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/getapo.egg-info/SOURCES.txt +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/getapo.egg-info/dependency_links.txt +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/getapo.egg-info/entry_points.txt +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/getapo.egg-info/requires.txt +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/src/getapo.egg-info/top_level.txt +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_action_spec_render.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_actions.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_agents_hub.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_answering.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_app.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_assets.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_autonomy_rules.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_background.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_browser.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_bugs.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_bulk_and_keys.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_bulk_and_views.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_cancel_button.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_changelog.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_checklist_back.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_claude_profiles.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_claude_runtime.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_cli_hooks.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_close_rows.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_config.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_consolidation.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_continue.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_court.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_credentials.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_cross_site.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_dashboard_cli.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_db.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_decisions_skill.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_delivery.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_digest.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_due_stuck.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_edit_undo.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_events.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_folder_identity.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_goal_page.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_guide.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_installer.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_item_folder.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_item_page.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_layout_fixes.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_linear_client.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_linear_goals.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_links.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_live_stream.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_mcp_instructions.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_mcp_server.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_merge_branches.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_names.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_navigation.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_new_work.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_next_item.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_notes_labels.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_notify.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_now.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_now_leads.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_now_scan.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_outcome_pages.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_outcomes.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_overview_order.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_palette_js.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_poll_loop.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_preview_paths.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_priority_due.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_project_home.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_project_identity.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_project_overview.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_project_scope.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_project_settings.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_projects.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_prompt_answers.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_quiet_pages.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_rank_and_deps.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_reply_where_you_are.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_repo_writer.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_resume_folder.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_round.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_scheduled_resume.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_schema.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_schema_upgrade.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_search.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_session_page.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_session_states.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_session_verdict.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_sessions.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_small_fixes.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_snooze.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_sources.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_start_and_follow_up.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_station_read_api.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_status_export.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_sync_errors.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_task_attempts.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_task_effort.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_task_page.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_transcripts.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_ui_review.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_usage_limit.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_verify.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_week_and_trend.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_weekly_report.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_work_items.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_work_location.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_work_order.py +0 -0
- {getapo-0.3.2 → getapo-0.3.3}/tests/test_work_tab.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: getapo
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: apo (AI Project Orchestration): a local dashboard and MCP server for Claude Code. Agents ask instead of stopping; you answer every project's questions from one queue.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://getapo.pages.dev/
|
|
@@ -4,6 +4,7 @@ requests need the network, so they're fetched in the background and pages only e
|
|
|
4
4
|
read the cache."""
|
|
5
5
|
import json
|
|
6
6
|
import os
|
|
7
|
+
import re
|
|
7
8
|
import shlex
|
|
8
9
|
import subprocess
|
|
9
10
|
import tempfile
|
|
@@ -117,9 +118,11 @@ def worktrees(path: str) -> list[dict]:
|
|
|
117
118
|
found: list[dict] = []
|
|
118
119
|
for line in out.stdout.splitlines():
|
|
119
120
|
if line.startswith("worktree "):
|
|
120
|
-
found.append({"path": line[len("worktree "):], "branch": None})
|
|
121
|
+
found.append({"path": line[len("worktree "):], "branch": None, "locked": None})
|
|
121
122
|
elif line.startswith("branch refs/heads/") and found:
|
|
122
123
|
found[-1]["branch"] = line[len("branch refs/heads/"):]
|
|
124
|
+
elif (line == "locked" or line.startswith("locked ")) and found:
|
|
125
|
+
found[-1]["locked"] = line[len("locked "):] or "locked"
|
|
123
126
|
return found
|
|
124
127
|
|
|
125
128
|
|
|
@@ -356,21 +359,63 @@ def merge_branch(path: str, branch: str) -> dict:
|
|
|
356
359
|
_git(path, "worktree", "prune")
|
|
357
360
|
|
|
358
361
|
|
|
359
|
-
|
|
362
|
+
_CLAUDE_LOCK = re.compile(r"claude agent \S+ \(pid (\d+)(?: start (\d+))?\)")
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
def _process_alive(pid: int, start: str | None) -> bool:
|
|
366
|
+
"""Whether pid is still the process that took the lock: start is its start time in
|
|
367
|
+
/proc/<pid>/stat, so a pid the system has since handed to another process counts as ended."""
|
|
368
|
+
try:
|
|
369
|
+
os.kill(pid, 0)
|
|
370
|
+
except ProcessLookupError:
|
|
371
|
+
return False
|
|
372
|
+
except PermissionError:
|
|
373
|
+
pass
|
|
374
|
+
if not start:
|
|
375
|
+
return True
|
|
376
|
+
try:
|
|
377
|
+
fields = Path(f"/proc/{pid}/stat").read_text().rsplit(")", 1)[1].split()
|
|
378
|
+
except (OSError, IndexError):
|
|
379
|
+
return True
|
|
380
|
+
return len(fields) > 19 and fields[19] == start
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
def _lock_in_the_way(lock: str, finished: bool) -> str | None:
|
|
384
|
+
"""Why a locked worktree stays, or None when its lock can be lifted: Claude Code locks
|
|
385
|
+
a subagent's worktree for as long as the session that started it runs."""
|
|
386
|
+
claude = _CLAUDE_LOCK.search(lock)
|
|
387
|
+
if not claude:
|
|
388
|
+
return f"it's locked ({lock})"
|
|
389
|
+
if finished or not _process_alive(int(claude.group(1)), claude.group(2)):
|
|
390
|
+
return None
|
|
391
|
+
return "a Claude Code session still holds it"
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
def clean_up_branch(path: str, branch: str, finished: bool = False) -> dict:
|
|
360
395
|
"""After a merge: remove the added worktree the branch is checked out in, then delete
|
|
361
396
|
the branch, with git's own safety: a worktree with changes or untracked files stays,
|
|
362
397
|
and so does a branch git doesn't count as merged. The repository's own folder is never
|
|
363
|
-
removed.
|
|
398
|
+
removed. finished says the item's work is done, so a live Claude session's lock on the
|
|
399
|
+
worktree no longer keeps it."""
|
|
364
400
|
result = {"worktree": None, "worktree_removed": False, "branch_deleted": False, "error": None}
|
|
365
401
|
trees = worktrees(path)
|
|
366
402
|
main = trees[0]["path"] if trees else None
|
|
367
|
-
|
|
403
|
+
tree = next((w for w in trees if w["branch"] == branch), None)
|
|
404
|
+
where = tree["path"] if tree else None
|
|
368
405
|
if where and where == main:
|
|
369
406
|
return {**result, "error": f"{branch} is checked out in the repository's own folder, so it was kept."}
|
|
370
407
|
if where:
|
|
371
408
|
result["worktree"] = where
|
|
409
|
+
lock = tree.get("locked")
|
|
410
|
+
if lock:
|
|
411
|
+
why = _lock_in_the_way(lock, finished)
|
|
412
|
+
if why:
|
|
413
|
+
return {**result, "error": f"Kept {branch} and its worktree: {why}."}
|
|
414
|
+
_git(path, "worktree", "unlock", where)
|
|
372
415
|
out = _git(path, "worktree", "remove", where)
|
|
373
416
|
if not out or out.returncode != 0:
|
|
417
|
+
if lock:
|
|
418
|
+
_git(path, "worktree", "lock", "--reason", lock, where)
|
|
374
419
|
reason = (out.stderr.strip() if out else "") or "git failed"
|
|
375
420
|
return {**result, "error": f"Kept the worktree {_home(where)}: {reason}"}
|
|
376
421
|
result["worktree_removed"] = True
|
|
@@ -6,6 +6,8 @@ Claude Code calls, and a command line for agents and scripts that can't use MCP.
|
|
|
6
6
|
import argparse
|
|
7
7
|
import json
|
|
8
8
|
import os
|
|
9
|
+
import re
|
|
10
|
+
import shutil
|
|
9
11
|
import signal
|
|
10
12
|
import socket
|
|
11
13
|
import subprocess
|
|
@@ -155,6 +157,60 @@ def _cmd_list(args: argparse.Namespace) -> None:
|
|
|
155
157
|
print()
|
|
156
158
|
|
|
157
159
|
|
|
160
|
+
def _search_query(words: list[str]) -> str:
|
|
161
|
+
"""A shell-quoted argument with a space in it stays one phrase, as "two words" does in the dashboard."""
|
|
162
|
+
return " ".join(f'"{w}"' if len(w.split()) > 1 and '"' not in w else w for w in words)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def _search_date(value: str | None) -> str | None:
|
|
166
|
+
if value and re.fullmatch(r"\d{1,4}[dw]", value.strip().lower()):
|
|
167
|
+
return db.parse_since(value).astimezone(timezone.utc).date().isoformat()
|
|
168
|
+
return value
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def _cmd_search(args: argparse.Namespace) -> None:
|
|
172
|
+
conn = db.get_connection()
|
|
173
|
+
filters = {"status": args.status, "project": args.project, "owner": args.owner, "label": args.label,
|
|
174
|
+
"since": args.since, "until": args.until}
|
|
175
|
+
if args.transcripts:
|
|
176
|
+
query = " ".join(args.words).strip()
|
|
177
|
+
if any(filters.values()):
|
|
178
|
+
args.usage_error("--transcripts takes no filters, only --limit and --json")
|
|
179
|
+
if len(query) < 3:
|
|
180
|
+
args.usage_error("--transcripts needs at least three characters to look for")
|
|
181
|
+
if not shutil.which("rg"):
|
|
182
|
+
print("Searching transcripts needs ripgrep (rg) on your PATH.", file=sys.stderr)
|
|
183
|
+
sys.exit(1)
|
|
184
|
+
hits = db.search_transcripts(conn, query, limit=args.limit)
|
|
185
|
+
else:
|
|
186
|
+
query = _search_query(args.words)
|
|
187
|
+
if not query.strip() and not any(filters.values()):
|
|
188
|
+
args.usage_error("give some words to look for, or a filter")
|
|
189
|
+
if args.project:
|
|
190
|
+
project = db.find_project(conn, args.project)
|
|
191
|
+
if project is None:
|
|
192
|
+
print(f"No project named '{args.project}'.", file=sys.stderr)
|
|
193
|
+
sys.exit(1)
|
|
194
|
+
filters["project"] = project["name"]
|
|
195
|
+
try:
|
|
196
|
+
filters["since"], filters["until"] = _search_date(args.since), _search_date(args.until)
|
|
197
|
+
hits = db.search_filtered(conn, query, **filters, limit=args.limit)
|
|
198
|
+
except ValueError as exc:
|
|
199
|
+
print(exc, file=sys.stderr)
|
|
200
|
+
sys.exit(1)
|
|
201
|
+
if args.json:
|
|
202
|
+
print(json.dumps(hits))
|
|
203
|
+
return
|
|
204
|
+
if not hits:
|
|
205
|
+
print("Nothing found.")
|
|
206
|
+
return
|
|
207
|
+
rows = [(h["subkind"], f"#{h['ref']}" if h["kind"] == "item" else (h.get("session_id") or "")[:8],
|
|
208
|
+
h["status"].upper(), h["project_name"] or "-", " ".join(h["title"].split())) for h in hits]
|
|
209
|
+
widths = [max(len(row[i]) for row in rows) for i in range(4)]
|
|
210
|
+
for row in rows:
|
|
211
|
+
print(" ".join(cell.ljust(width) for cell, width in zip(row, widths)) + " " + row[4])
|
|
212
|
+
|
|
213
|
+
|
|
158
214
|
def _cmd_show(args: argparse.Namespace) -> None:
|
|
159
215
|
conn = db.get_connection()
|
|
160
216
|
decision = db.get_decision_request(conn, args.decision_id)
|
|
@@ -1073,6 +1129,24 @@ def main(argv: list[str] | None = None) -> None:
|
|
|
1073
1129
|
lst.add_argument("--json", action="store_true", help="Emit JSON instead of human-readable text")
|
|
1074
1130
|
lst.set_defaults(func=_cmd_list)
|
|
1075
1131
|
|
|
1132
|
+
search_p = sub.add_parser("search", help="Search items, session recaps and goals, as the dashboard's search does")
|
|
1133
|
+
search_p.add_argument("words", nargs="*",
|
|
1134
|
+
help='Words that all have to match ("two words" quoted is one phrase); 447 finds item #447, '
|
|
1135
|
+
"the start of a session's id finds that session")
|
|
1136
|
+
search_p.add_argument("--status", default=None,
|
|
1137
|
+
help="An item's open, in_progress, answered, resolved or cancelled; a session's running, "
|
|
1138
|
+
"idle or ended; a goal's active, paused, achieved or dropped")
|
|
1139
|
+
search_p.add_argument("--project", default=None)
|
|
1140
|
+
search_p.add_argument("--owner", choices=["me", "agent", "external"], default=None, help="Items only")
|
|
1141
|
+
search_p.add_argument("--label", default=None, help="Items only")
|
|
1142
|
+
search_p.add_argument("--since", default=None, help="Created on or after: YYYY-MM-DD, or 7d, 2w")
|
|
1143
|
+
search_p.add_argument("--until", default=None, help="Created on or before: YYYY-MM-DD, or 7d, 2w")
|
|
1144
|
+
search_p.add_argument("--limit", type=int, default=50, help="At most this many of each kind (default 50)")
|
|
1145
|
+
search_p.add_argument("--transcripts", action="store_true",
|
|
1146
|
+
help="Search session transcripts instead (needs ripgrep; takes no filters)")
|
|
1147
|
+
search_p.add_argument("--json", action="store_true", help="Emit JSON instead of human-readable text")
|
|
1148
|
+
search_p.set_defaults(func=_cmd_search, usage_error=search_p.error)
|
|
1149
|
+
|
|
1076
1150
|
show = sub.add_parser("show", help="Show full detail for one decision request")
|
|
1077
1151
|
show.add_argument("decision_id", type=int)
|
|
1078
1152
|
show.add_argument("--json", action="store_true", help="Emit JSON instead of human-readable text")
|
|
@@ -864,7 +864,8 @@ def _search_hit(conn: sqlite3.Connection, kind: str, rowid: int, terms: list[str
|
|
|
864
864
|
s = dict(row)
|
|
865
865
|
s["project_name"] = get_project_name(conn, s["project_id"]) if s["project_id"] else None
|
|
866
866
|
hit = {"title": _session_name(s), "status": s["status"], "subkind": "session",
|
|
867
|
-
"href": f"/sessions/{s['id']}",
|
|
867
|
+
"session_id": s["claude_session_id"], "href": f"/sessions/{s['id']}",
|
|
868
|
+
"resume_command": session_resume_command(s)}
|
|
868
869
|
else:
|
|
869
870
|
row = conn.execute("SELECT id, title, status, project_id FROM outcomes WHERE id = ?", (rowid,)).fetchone()
|
|
870
871
|
if row is None:
|
|
@@ -1050,8 +1051,8 @@ def search_transcripts(conn: sqlite3.Connection, query: str, timeout: float = 10
|
|
|
1050
1051
|
s = dict(row)
|
|
1051
1052
|
s["project_name"] = get_project_name(conn, s["project_id"]) if s["project_id"] else None
|
|
1052
1053
|
clean = excerpt.replace("\\n", " ").replace('\\"', '"')
|
|
1053
|
-
hits.append({"kind": "transcript", "ref": sid, "
|
|
1054
|
-
"subkind": "transcript", "project_name": s["project_name"], "snippet": _snippet(clean, [query]),
|
|
1054
|
+
hits.append({"kind": "transcript", "ref": sid, "session_id": sid, "title": _session_name(s),
|
|
1055
|
+
"status": s["status"], "subkind": "transcript", "project_name": s["project_name"], "snippet": _snippet(clean, [query]),
|
|
1055
1056
|
"href": f"/sessions/{s['id']}", "resume_command": session_resume_command(s),
|
|
1056
1057
|
"last_seen_at": s["last_seen_at"]})
|
|
1057
1058
|
hits.sort(key=lambda h: h["last_seen_at"] or "", reverse=True)
|
|
@@ -418,6 +418,8 @@ Press `/` anywhere (or `g` then `f`), or type anything in the palette and choose
|
|
|
418
418
|
|
|
419
419
|
In the results, `j`/`k` move and `↵` opens. `Esc` leaves the search box first.
|
|
420
420
|
|
|
421
|
+
From a terminal, `apo search stripe webhook` does the same search and prints one line per hit: its kind, the item's number (or the start of a session's id), status, project and title. `apo search 447` finds item #447 whatever its status (in a shell, `#447` needs quotes, since `#` starts a comment), and the start of a session's id finds that session. The filters are flags: `--status`, `--project`, `--owner me|agent|external`, `--label`, `--since` and `--until` (YYYY-MM-DD, or `7d`, `2w`), and `--limit`; filters alone list the newest matching rows. `--transcripts` searches the transcripts instead, and `--json` prints the hits as JSON.
|
|
422
|
+
|
|
421
423
|
## Notifications
|
|
422
424
|
|
|
423
425
|
Off until you turn them on: **Settings → Notifications → Turn on** (once per browser). Then a move interrupts you only when:
|
|
@@ -487,6 +489,7 @@ Without MCP, or in a session too old to have a tool, there's the `apo` CLI:
|
|
|
487
489
|
- **Decisions:** `apo ask`, `apo act`, `apo answer`, `apo list`, `apo pending [--all]`, `apo resolve`.
|
|
488
490
|
- **Tasks:** `apo tasks`, `apo claim <id>`, `apo complete <id> --note "..."`. `apo complete` also takes `--outcome partial`, `--done`, `--not-done`, `--left-for-human` and `--branch`; a partial completion shows as "Partly done". `apo retry <id>` puts a failed, cancelled, finished or stuck-claimed task back to READY (history is kept); `apo stuck` lists claimed tasks whose session has ended. A task's page shows its History: every claim, completion, release and retry.
|
|
489
491
|
- **Bugs:** `apo bug "What's wrong" [--happened ...] [--expected ...] [--steps ...] [--severity low|normal|urgent]`, from the project's folder or with `--project NAME`. It files a task labelled bug, like A bug in New work.
|
|
492
|
+
- **Search:** `apo search <words> [--status ...] [--project ...] [--owner ...] [--label ...] [--since ...] [--until ...] [--transcripts] [--json]`, the dashboard's search (see [Search](#search)).
|
|
490
493
|
|
|
491
494
|
## Settings
|
|
492
495
|
|
|
@@ -1193,14 +1193,15 @@ async def merge_branch_route(project_id: int, repository: int = Form(...), branc
|
|
|
1193
1193
|
item = db.items_by_branch(conn, project_id, [branch]).get(branch)
|
|
1194
1194
|
_record_merge(conn, project_id, item["id"] if item else None, result)
|
|
1195
1195
|
if result["ok"] and clean_up:
|
|
1196
|
-
result["cleaned"] = await _clean_up_after_merge(conn, folder["local_path"], branch)
|
|
1196
|
+
result["cleaned"] = await _clean_up_after_merge(conn, folder["local_path"], branch, finished=item is not None)
|
|
1197
1197
|
_landing_cache.pop(project_id, None)
|
|
1198
1198
|
return _merged_redirect(_safe_next(next, f"/projects/{project_id}#ready-to-merge"), result)
|
|
1199
1199
|
|
|
1200
1200
|
|
|
1201
|
-
async def _clean_up_after_merge(conn, path: str, branch: str) -> str:
|
|
1201
|
+
async def _clean_up_after_merge(conn, path: str, branch: str, finished: bool = False) -> str:
|
|
1202
1202
|
"""Stop the idle background sessions in the branch's worktree, then remove the worktree
|
|
1203
|
-
and delete the branch. Anything else still running there keeps it all in place
|
|
1203
|
+
and delete the branch. Anything else still running there keeps it all in place, and so
|
|
1204
|
+
does a Claude Code session's lock on it unless the item's work is finished."""
|
|
1204
1205
|
where = next((w["path"] for w in changelog.worktrees(path) if w["branch"] == branch), None)
|
|
1205
1206
|
if where:
|
|
1206
1207
|
inside = [s for s in db.list_sessions(conn) if s.get("cwd") and _path_under(s["cwd"], where)]
|
|
@@ -1214,7 +1215,7 @@ async def _clean_up_after_merge(conn, path: str, branch: str) -> str:
|
|
|
1214
1215
|
s["stopped"] = True
|
|
1215
1216
|
if any(not s.get("stopped") for s in inside):
|
|
1216
1217
|
return f"Kept {branch} and its worktree: a session is still open there."
|
|
1217
|
-
outcome = changelog.clean_up_branch(path, branch)
|
|
1218
|
+
outcome = changelog.clean_up_branch(path, branch, finished=finished)
|
|
1218
1219
|
if outcome["error"]:
|
|
1219
1220
|
return outcome["error"]
|
|
1220
1221
|
return f"Deleted {branch}" + (" and removed its worktree" if outcome["worktree_removed"] else "") + "."
|
|
@@ -1240,7 +1241,8 @@ async def merge_item_branch(decision_id: int, clean_up: str | None = Form(None))
|
|
|
1240
1241
|
result = changelog.merge_branch(repository["local_path"], merge["branch"])
|
|
1241
1242
|
_record_merge(conn, item["project_id"], decision_id, result)
|
|
1242
1243
|
if result["ok"] and clean_up:
|
|
1243
|
-
result["cleaned"] = await _clean_up_after_merge(conn, repository["local_path"], merge["branch"]
|
|
1244
|
+
result["cleaned"] = await _clean_up_after_merge(conn, repository["local_path"], merge["branch"],
|
|
1245
|
+
finished=item["status"] == "resolved")
|
|
1244
1246
|
_landing_cache.pop(item["project_id"], None)
|
|
1245
1247
|
return _merged_redirect(back, result)
|
|
1246
1248
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: getapo
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: apo (AI Project Orchestration): a local dashboard and MCP server for Claude Code. Agents ask instead of stopping; you answer every project's questions from one queue.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://getapo.pages.dev/
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import shutil
|
|
1
2
|
import subprocess
|
|
2
3
|
import sys
|
|
3
4
|
from pathlib import Path
|
|
4
5
|
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
5
8
|
|
|
6
9
|
|
|
7
10
|
def run_cli(*args, env, cwd=None, stdin=None):
|
|
@@ -647,3 +650,215 @@ def test_answering_into_a_missing_folder_says_so_instead_of_claiming_it_was_writ
|
|
|
647
650
|
assert "Written to" not in answer.stdout
|
|
648
651
|
assert f'apo repo-move "{old}" <new path>' in answer.stdout
|
|
649
652
|
assert not old.exists()
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
def _search_world(db, tmp_path):
|
|
656
|
+
conn = db.get_connection()
|
|
657
|
+
acme = db.get_or_create_project(conn, "acme")
|
|
658
|
+
beta = db.get_or_create_project(conn, "beta")
|
|
659
|
+
for project in (acme, beta):
|
|
660
|
+
(tmp_path / project["name"]).mkdir()
|
|
661
|
+
db.ensure_repository_for_project(conn, project["id"], str(tmp_path / project["name"]))
|
|
662
|
+
alpha = db.create_decision_request(conn, project_id=acme["id"], title="Stripe webhook alpha", question="Retry?")
|
|
663
|
+
beta_task = db.create_task(conn, project_id=beta["id"], title="Stripe webhook beta")
|
|
664
|
+
db.add_label(conn, beta_task, "payments")
|
|
665
|
+
db.cancel_request(conn, beta_task, "Not needed")
|
|
666
|
+
return alpha, beta_task
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
def test_search_prints_one_line_per_hit_of_every_kind(db_path, tmp_path):
|
|
670
|
+
import os
|
|
671
|
+
|
|
672
|
+
from apo import db
|
|
673
|
+
|
|
674
|
+
env = dict(os.environ, APO_DB=str(db_path))
|
|
675
|
+
conn = db.get_connection()
|
|
676
|
+
project = db.get_or_create_project(conn, "acme")
|
|
677
|
+
db.ensure_repository_for_project(conn, project["id"], str(tmp_path))
|
|
678
|
+
item = db.create_decision_request(conn, project_id=project["id"], title="Stripe webhook retries",
|
|
679
|
+
question="Retry failed deliveries?")
|
|
680
|
+
db.create_decision_request(conn, project_id=project["id"], title="Unrelated", question="Something else?")
|
|
681
|
+
db.register_session(conn, "5f2c91aa-0b1e-4c2d-8e3f-000000000001", str(tmp_path))
|
|
682
|
+
db.record_session_summary(conn, "5f2c91aa-0b1e-4c2d-8e3f-000000000001", "Wired the webhook handler",
|
|
683
|
+
title="Webhook handler")
|
|
684
|
+
db.create_outcome(conn, project["id"], "Webhooks never drop")
|
|
685
|
+
|
|
686
|
+
found = run_cli("search", "webhook", env=env)
|
|
687
|
+
|
|
688
|
+
assert found.returncode == 0, found.stderr
|
|
689
|
+
lines = found.stdout.splitlines()
|
|
690
|
+
assert len(lines) == 3, found.stdout
|
|
691
|
+
item_line = next(line for line in lines if f"#{item}" in line)
|
|
692
|
+
assert all(part in item_line for part in ("decision", "OPEN", "acme", "Stripe webhook retries"))
|
|
693
|
+
session_line = next(line for line in lines if "5f2c91aa" in line)
|
|
694
|
+
assert "session" in session_line and "Webhook handler" in session_line and "acme" in session_line
|
|
695
|
+
assert "5f2c91aa-0b1e" not in session_line
|
|
696
|
+
outcome_line = next(line for line in lines if "Webhooks never drop" in line)
|
|
697
|
+
assert "outcome" in outcome_line and "ACTIVE" in outcome_line
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
def test_search_finds_an_item_by_number_even_when_closed_and_a_session_by_the_start_of_its_id(db_path, tmp_path):
|
|
701
|
+
import os
|
|
702
|
+
|
|
703
|
+
from apo import db
|
|
704
|
+
|
|
705
|
+
env = dict(os.environ, APO_DB=str(db_path))
|
|
706
|
+
conn = db.get_connection()
|
|
707
|
+
project = db.get_or_create_project(conn, "acme")
|
|
708
|
+
db.ensure_repository_for_project(conn, project["id"], str(tmp_path))
|
|
709
|
+
task = db.create_task(conn, project_id=project["id"], title="Build checkout")
|
|
710
|
+
db.complete_task(conn, task, note="Done")
|
|
711
|
+
db.register_session(conn, "asker-0002-bbbb", str(tmp_path))
|
|
712
|
+
|
|
713
|
+
by_hash = run_cli("search", f"#{task}", env=env)
|
|
714
|
+
by_number = run_cli("search", str(task), env=env)
|
|
715
|
+
by_session = run_cli("search", "asker-00", env=env)
|
|
716
|
+
|
|
717
|
+
assert by_hash.returncode == 0, by_hash.stderr
|
|
718
|
+
assert len(by_hash.stdout.splitlines()) == 1
|
|
719
|
+
assert f"#{task}" in by_hash.stdout and "RESOLVED" in by_hash.stdout and "Build checkout" in by_hash.stdout
|
|
720
|
+
assert f"#{task}" in by_number.stdout.splitlines()[0]
|
|
721
|
+
assert "session" in by_session.stdout and "asker-00" in by_session.stdout
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
def test_search_keeps_a_quoted_phrase_together(db_path, tmp_path):
|
|
725
|
+
import os
|
|
726
|
+
|
|
727
|
+
from apo import db
|
|
728
|
+
|
|
729
|
+
env = dict(os.environ, APO_DB=str(db_path))
|
|
730
|
+
conn = db.get_connection()
|
|
731
|
+
project = db.get_or_create_project(conn, "acme")
|
|
732
|
+
db.ensure_repository_for_project(conn, project["id"], str(tmp_path))
|
|
733
|
+
db.create_decision_request(conn, project_id=project["id"], title="Ship it now", question="Go?")
|
|
734
|
+
db.create_decision_request(conn, project_id=project["id"], title="Should it ship", question="Go?")
|
|
735
|
+
|
|
736
|
+
phrase = run_cli("search", "ship it", env=env).stdout
|
|
737
|
+
words = run_cli("search", "ship", "it", env=env).stdout
|
|
738
|
+
|
|
739
|
+
assert "Ship it now" in phrase and "Should it ship" not in phrase
|
|
740
|
+
assert "Ship it now" in words and "Should it ship" in words
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
def test_search_takes_the_dashboards_filters(db_path, tmp_path, capsys):
|
|
744
|
+
from apo import cli, db
|
|
745
|
+
|
|
746
|
+
alpha, beta_task = _search_world(db, tmp_path)
|
|
747
|
+
|
|
748
|
+
def search(*args):
|
|
749
|
+
cli.main(["search", *args])
|
|
750
|
+
return capsys.readouterr().out
|
|
751
|
+
|
|
752
|
+
assert f"#{alpha}" in search("stripe", "--status", "open")
|
|
753
|
+
assert f"#{beta_task}" not in search("stripe", "--status", "open")
|
|
754
|
+
assert f"#{beta_task}" in search("stripe", "--status", "cancelled")
|
|
755
|
+
assert f"#{alpha}" not in search("stripe", "--project", "beta")
|
|
756
|
+
assert f"#{beta_task}" in search("stripe", "--project", "beta")
|
|
757
|
+
assert f"#{beta_task}" in search("stripe", "--owner", "agent")
|
|
758
|
+
assert f"#{beta_task}" not in search("stripe", "--owner", "me")
|
|
759
|
+
assert f"#{alpha}" not in search("stripe", "--label", "payments")
|
|
760
|
+
assert f"#{beta_task}" in search("stripe", "--label", "payments")
|
|
761
|
+
assert "Nothing found" in search("stripe", "--since", "2999-01-01")
|
|
762
|
+
both = search("stripe", "--until", "2999-01-01")
|
|
763
|
+
assert f"#{alpha}" in both and f"#{beta_task}" in both
|
|
764
|
+
recent = search("stripe", "--since", "7d")
|
|
765
|
+
assert f"#{alpha}" in recent and f"#{beta_task}" in recent
|
|
766
|
+
assert len(search("stripe", "--limit", "1").splitlines()) == 1
|
|
767
|
+
listed = search("--project", "beta")
|
|
768
|
+
assert f"#{beta_task}" in listed and f"#{alpha}" not in listed
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
def test_search_refuses_a_bad_date_an_unknown_project_and_an_unknown_owner(db_path, tmp_path, capsys):
|
|
772
|
+
from apo import cli, db
|
|
773
|
+
|
|
774
|
+
_search_world(db, tmp_path)
|
|
775
|
+
|
|
776
|
+
with pytest.raises(SystemExit) as bad_date:
|
|
777
|
+
cli.main(["search", "stripe", "--since", "yesterday"])
|
|
778
|
+
assert bad_date.value.code == 1 and "YYYY-MM-DD" in capsys.readouterr().err
|
|
779
|
+
with pytest.raises(SystemExit) as unknown:
|
|
780
|
+
cli.main(["search", "stripe", "--project", "nosuch"])
|
|
781
|
+
assert unknown.value.code == 1 and "No project named 'nosuch'" in capsys.readouterr().err
|
|
782
|
+
with pytest.raises(SystemExit) as owner:
|
|
783
|
+
cli.main(["search", "stripe", "--owner", "someone"])
|
|
784
|
+
assert owner.value.code == 2
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
def test_search_with_nothing_found_says_so_and_exits_0(db_path):
|
|
788
|
+
import os
|
|
789
|
+
|
|
790
|
+
found = run_cli("search", "zebra", env=dict(os.environ, APO_DB=str(db_path)))
|
|
791
|
+
|
|
792
|
+
assert found.returncode == 0, found.stderr
|
|
793
|
+
assert found.stdout.strip() == "Nothing found."
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
def test_search_without_words_or_filters_prints_usage_instead_of_every_row(db_path, tmp_path):
|
|
797
|
+
import os
|
|
798
|
+
|
|
799
|
+
from apo import db
|
|
800
|
+
|
|
801
|
+
_search_world(db, tmp_path)
|
|
802
|
+
|
|
803
|
+
bare = run_cli("search", env=dict(os.environ, APO_DB=str(db_path)))
|
|
804
|
+
|
|
805
|
+
assert bare.returncode == 2
|
|
806
|
+
assert bare.stdout == ""
|
|
807
|
+
assert "usage: apo search" in bare.stderr
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
def test_search_json(db_path, tmp_path):
|
|
811
|
+
import json
|
|
812
|
+
import os
|
|
813
|
+
|
|
814
|
+
from apo import db
|
|
815
|
+
|
|
816
|
+
env = dict(os.environ, APO_DB=str(db_path))
|
|
817
|
+
alpha, beta_task = _search_world(db, tmp_path)
|
|
818
|
+
|
|
819
|
+
hits = json.loads(run_cli("search", "stripe", "--json", env=env).stdout)
|
|
820
|
+
|
|
821
|
+
alpha_hit = next(h for h in hits if h["kind"] == "item" and h["ref"] == alpha)
|
|
822
|
+
assert alpha_hit["title"] == "Stripe webhook alpha" and alpha_hit["status"] == "open"
|
|
823
|
+
assert alpha_hit["project_name"] == "acme" and alpha_hit["href"] == f"/decisions/{alpha}"
|
|
824
|
+
assert json.loads(run_cli("search", "zebra", "--json", env=env).stdout) == []
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
@pytest.mark.skipif(shutil.which("rg") is None, reason="ripgrep not installed")
|
|
828
|
+
def test_search_transcripts(db_path, tmp_path):
|
|
829
|
+
import json
|
|
830
|
+
import os
|
|
831
|
+
|
|
832
|
+
from apo import db
|
|
833
|
+
|
|
834
|
+
env = dict(os.environ, APO_DB=str(db_path))
|
|
835
|
+
conn = db.get_connection()
|
|
836
|
+
project = db.get_or_create_project(conn, "acme")
|
|
837
|
+
db.ensure_repository_for_project(conn, project["id"], str(tmp_path))
|
|
838
|
+
db.register_session(conn, "11111111-2222-3333-4444-555555555555", str(tmp_path))
|
|
839
|
+
folder = tmp_path / "claude-config" / "projects" / "-tmp-acme"
|
|
840
|
+
folder.mkdir(parents=True)
|
|
841
|
+
(folder / "11111111-2222-3333-4444-555555555555.jsonl").write_text(
|
|
842
|
+
json.dumps({"type": "user", "message": {"content": "why does the flux capacitor overheat"}}) + "\n"
|
|
843
|
+
)
|
|
844
|
+
|
|
845
|
+
found = run_cli("search", "--transcripts", "flux", "capacitor", env=env)
|
|
846
|
+
plain = run_cli("search", "flux", "capacitor", env=env)
|
|
847
|
+
filtered = run_cli("search", "--transcripts", "flux", "--status", "open", env=env)
|
|
848
|
+
|
|
849
|
+
assert found.returncode == 0, found.stderr
|
|
850
|
+
assert len(found.stdout.splitlines()) == 1
|
|
851
|
+
assert "transcript" in found.stdout and "11111111" in found.stdout and "acme" in found.stdout
|
|
852
|
+
assert plain.stdout.strip() == "Nothing found."
|
|
853
|
+
assert filtered.returncode == 2 and "--transcripts" in filtered.stderr
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
def test_search_transcripts_without_ripgrep_says_so_instead_of_finding_nothing(db_path, capsys, monkeypatch):
|
|
857
|
+
from apo import cli
|
|
858
|
+
|
|
859
|
+
monkeypatch.setattr(cli.shutil, "which", lambda name: None)
|
|
860
|
+
|
|
861
|
+
with pytest.raises(SystemExit) as missing:
|
|
862
|
+
cli.main(["search", "--transcripts", "flux capacitor"])
|
|
863
|
+
|
|
864
|
+
assert missing.value.code == 1 and "ripgrep" in capsys.readouterr().err
|
|
@@ -27,7 +27,7 @@ def test_version(db_path):
|
|
|
27
27
|
result = _run(["-m", "apo", "--version"], _env(db_path))
|
|
28
28
|
|
|
29
29
|
assert result.stdout.strip() == f"apo {apo.__version__}"
|
|
30
|
-
assert apo.__version__ == "0.3.
|
|
30
|
+
assert apo.__version__ == "0.3.3"
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
def test_there_is_no_ado_command_any_more():
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Finished work lands without hunting for it: Now lists branches waiting to be merged
|
|
2
2
|
across projects, project rows count them, merging can clean up after itself, and what
|
|
3
3
|
an agent left for you becomes one of your items."""
|
|
4
|
+
import os
|
|
4
5
|
import re
|
|
5
6
|
import subprocess
|
|
6
7
|
|
|
@@ -100,6 +101,84 @@ def test_clean_up_leaves_a_worktree_with_changes_alone(repo):
|
|
|
100
101
|
assert result["error"]
|
|
101
102
|
|
|
102
103
|
|
|
104
|
+
def _start_time(pid):
|
|
105
|
+
return open(f"/proc/{pid}/stat").read().rsplit(")", 1)[1].split()[19]
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def _ended_pid():
|
|
109
|
+
proc = subprocess.Popen(["true"])
|
|
110
|
+
proc.wait()
|
|
111
|
+
return proc.pid
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def _merged_and_locked(repo, reason):
|
|
115
|
+
worktree = _branch(repo, "checkout-flow")
|
|
116
|
+
assert changelog.merge_branch(str(repo), "checkout-flow")["ok"]
|
|
117
|
+
_git(repo, "worktree", "lock", "--reason", reason, str(worktree))
|
|
118
|
+
return worktree
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def test_clean_up_removes_a_worktree_whose_claude_session_has_ended(repo):
|
|
122
|
+
worktree = _merged_and_locked(repo, f"claude agent agent-1 (pid {_ended_pid()} start 1)")
|
|
123
|
+
|
|
124
|
+
result = changelog.clean_up_branch(str(repo), "checkout-flow")
|
|
125
|
+
|
|
126
|
+
assert result["error"] is None and not worktree.exists()
|
|
127
|
+
assert "checkout-flow" not in _git(repo, "branch", "--list")
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def test_clean_up_keeps_a_worktree_a_live_claude_session_holds(repo):
|
|
131
|
+
worktree = _merged_and_locked(repo, f"claude agent agent-1 (pid {os.getpid()} start {_start_time(os.getpid())})")
|
|
132
|
+
|
|
133
|
+
result = changelog.clean_up_branch(str(repo), "checkout-flow")
|
|
134
|
+
|
|
135
|
+
assert worktree.exists() and "checkout-flow" in _git(repo, "branch", "--list")
|
|
136
|
+
assert "Claude Code session" in result["error"] and "fatal" not in result["error"]
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def test_clean_up_removes_a_live_sessions_worktree_once_its_work_is_finished(repo):
|
|
140
|
+
worktree = _merged_and_locked(repo, f"claude agent agent-1 (pid {os.getpid()} start {_start_time(os.getpid())})")
|
|
141
|
+
|
|
142
|
+
result = changelog.clean_up_branch(str(repo), "checkout-flow", finished=True)
|
|
143
|
+
|
|
144
|
+
assert result["error"] is None and not worktree.exists()
|
|
145
|
+
assert "checkout-flow" not in _git(repo, "branch", "--list")
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def test_finished_work_with_changes_left_in_its_worktree_stays_locked(repo):
|
|
149
|
+
reason = f"claude agent agent-1 (pid {os.getpid()} start {_start_time(os.getpid())})"
|
|
150
|
+
worktree = _merged_and_locked(repo, reason)
|
|
151
|
+
(worktree / "scratch.txt").write_text("not committed\n")
|
|
152
|
+
|
|
153
|
+
result = changelog.clean_up_branch(str(repo), "checkout-flow", finished=True)
|
|
154
|
+
|
|
155
|
+
assert worktree.exists() and result["error"]
|
|
156
|
+
assert f"locked {reason}" in _git(repo, "worktree", "list", "--porcelain")
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def test_clean_up_keeps_a_worktree_locked_for_another_reason(repo):
|
|
160
|
+
worktree = _merged_and_locked(repo, "on a USB drive")
|
|
161
|
+
|
|
162
|
+
result = changelog.clean_up_branch(str(repo), "checkout-flow", finished=True)
|
|
163
|
+
|
|
164
|
+
assert worktree.exists()
|
|
165
|
+
assert "on a USB drive" in result["error"] and "fatal" not in result["error"]
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def test_merging_an_items_finished_work_cleans_up_a_worktree_its_agent_still_holds(client, acme, repo):
|
|
169
|
+
worktree = _branch(repo, "checkout-flow")
|
|
170
|
+
_git(repo, "worktree", "lock", "--reason",
|
|
171
|
+
f"claude agent agent-1 (pid {os.getpid()} start {_start_time(os.getpid())})", str(worktree))
|
|
172
|
+
conn = db.get_connection()
|
|
173
|
+
task = db.create_task(conn, project_id=acme["id"], title="Build the checkout flow")
|
|
174
|
+
db.complete_task(conn, task, note="Built it", branch="checkout-flow")
|
|
175
|
+
|
|
176
|
+
resp = client.post(f"/decisions/{task}/merge", data={"clean_up": "1"}, follow_redirects=False)
|
|
177
|
+
|
|
178
|
+
assert resp.status_code == 303 and "merged=" in resp.headers["location"]
|
|
179
|
+
assert not worktree.exists() and "checkout-flow" not in _git(repo, "branch", "--list")
|
|
180
|
+
|
|
181
|
+
|
|
103
182
|
def test_what_an_agent_left_for_you_becomes_your_item(db_path, acme):
|
|
104
183
|
conn = db.get_connection()
|
|
105
184
|
task = db.create_task(conn, project_id=acme["id"], title="Ship the station")
|
|
@@ -68,7 +68,7 @@ def test_the_wheel_carries_the_package_data(wheel):
|
|
|
68
68
|
assert path in names, path
|
|
69
69
|
assert not any(n.startswith(("tests/", "docs/", "scripts/", "site/")) for n in names)
|
|
70
70
|
metadata = zipfile.ZipFile(wheel).read(next(n for n in names if n.endswith("METADATA"))).decode()
|
|
71
|
-
assert "Name: getapo" in metadata and "Version: 0.3.
|
|
71
|
+
assert "Name: getapo" in metadata and "Version: 0.3.3" in metadata
|
|
72
72
|
assert "License-Expression: MIT" in metadata
|
|
73
73
|
assert {n.rsplit("/", 1)[-1] for n in names if "/licenses/" in n} == {"LICENSE", "THIRD_PARTY_NOTICES.md"}
|
|
74
74
|
entry_points = zipfile.ZipFile(wheel).read(next(n for n in names if n.endswith("entry_points.txt"))).decode()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|