workdash 0.1.0__py3-none-any.whl
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.
- workdash/__init__.py +12 -0
- workdash/__main__.py +5 -0
- workdash/analysis_cache.py +184 -0
- workdash/analyzer.py +229 -0
- workdash/backend.py +248 -0
- workdash/config.py +207 -0
- workdash/github_client.py +1079 -0
- workdash/included_items.py +58 -0
- workdash/launcher.py +378 -0
- workdash/models.py +50 -0
- workdash/prompts/__init__.py +0 -0
- workdash/prompts/analyze_issue.txt +120 -0
- workdash/prompts/analyze_pr.txt +147 -0
- workdash/prompts/launch_issue.txt +20 -0
- workdash/prompts/launch_pr.txt +20 -0
- workdash/prompts/launch_review.txt +20 -0
- workdash/repo_resolver.py +112 -0
- workdash/repo_worktree.py +304 -0
- workdash/tui.py +608 -0
- workdash/workdash.py +207 -0
- workdash-0.1.0.dist-info/METADATA +890 -0
- workdash-0.1.0.dist-info/RECORD +26 -0
- workdash-0.1.0.dist-info/WHEEL +5 -0
- workdash-0.1.0.dist-info/entry_points.txt +2 -0
- workdash-0.1.0.dist-info/licenses/LICENSE +674 -0
- workdash-0.1.0.dist-info/top_level.txt +1 -0
workdash/workdash.py
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"""Top-level app entrypoint."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import logging
|
|
7
|
+
import os
|
|
8
|
+
import shlex
|
|
9
|
+
import shutil
|
|
10
|
+
import sys
|
|
11
|
+
from collections.abc import Sequence
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
|
|
14
|
+
from . import __version__
|
|
15
|
+
from .backend import SuggestionMarkers, WorkdashBackend
|
|
16
|
+
from .config import configure, load_config, validate_config
|
|
17
|
+
from .launcher import (
|
|
18
|
+
exec_zellij_wrapped_workdash,
|
|
19
|
+
launch_agent_context,
|
|
20
|
+
launch_terminal_context,
|
|
21
|
+
launch_vscode_context,
|
|
22
|
+
open_in_browser,
|
|
23
|
+
prepare_launch_agent_prompt,
|
|
24
|
+
)
|
|
25
|
+
from .models import WorkItem, format_type_label
|
|
26
|
+
from .repo_worktree import ensure_worktree, get_merge_base
|
|
27
|
+
from .tui import WorkdashApp
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass(frozen=True)
|
|
31
|
+
class CLIOptions:
|
|
32
|
+
"""CLI configuration available during plumbing phases."""
|
|
33
|
+
|
|
34
|
+
debug: bool
|
|
35
|
+
print_mode: bool
|
|
36
|
+
refresh: bool
|
|
37
|
+
configure: bool
|
|
38
|
+
direct: bool
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _parse_args(argv: Sequence[str] | None = None) -> CLIOptions:
|
|
42
|
+
"""Parse CLI flags introduced in Phase 1 task 2."""
|
|
43
|
+
|
|
44
|
+
parser = argparse.ArgumentParser(
|
|
45
|
+
prog="workdash",
|
|
46
|
+
description="GitHub work triage dashboard.",
|
|
47
|
+
)
|
|
48
|
+
parser.add_argument(
|
|
49
|
+
"--version",
|
|
50
|
+
action="version",
|
|
51
|
+
version=f"%(prog)s {__version__}",
|
|
52
|
+
)
|
|
53
|
+
parser.add_argument(
|
|
54
|
+
"--debug",
|
|
55
|
+
action="store_true",
|
|
56
|
+
help="Enable verbose logging.",
|
|
57
|
+
)
|
|
58
|
+
parser.add_argument(
|
|
59
|
+
"--print",
|
|
60
|
+
dest="print_mode",
|
|
61
|
+
action="store_true",
|
|
62
|
+
help="Emit flattened data listing without launching the TUI.",
|
|
63
|
+
)
|
|
64
|
+
parser.add_argument(
|
|
65
|
+
"--refresh",
|
|
66
|
+
action="store_true",
|
|
67
|
+
help="Force a data refresh from GitHub sources.",
|
|
68
|
+
)
|
|
69
|
+
parser.add_argument(
|
|
70
|
+
"--configure",
|
|
71
|
+
action="store_true",
|
|
72
|
+
help="Interactively set up or update the configuration file.",
|
|
73
|
+
)
|
|
74
|
+
parser.add_argument(
|
|
75
|
+
"--direct",
|
|
76
|
+
action="store_true",
|
|
77
|
+
help="Start directly without wrapping the interactive dashboard in Zellij.",
|
|
78
|
+
)
|
|
79
|
+
namespace = parser.parse_args(argv) if argv is not None else parser.parse_args()
|
|
80
|
+
return CLIOptions(
|
|
81
|
+
debug=namespace.debug,
|
|
82
|
+
print_mode=namespace.print_mode,
|
|
83
|
+
refresh=namespace.refresh,
|
|
84
|
+
configure=namespace.configure,
|
|
85
|
+
direct=namespace.direct,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _should_wrap_interactive_start(options: CLIOptions) -> bool:
|
|
90
|
+
return (
|
|
91
|
+
not options.direct
|
|
92
|
+
and not options.print_mode
|
|
93
|
+
and not options.configure
|
|
94
|
+
and not os.getenv("ZELLIJ")
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _print_work_items(
|
|
99
|
+
work_items: Sequence[WorkItem], suggestion_markers: SuggestionMarkers
|
|
100
|
+
) -> None:
|
|
101
|
+
if not work_items:
|
|
102
|
+
print("No work items found.")
|
|
103
|
+
return
|
|
104
|
+
for item in sorted(work_items, key=lambda entry: entry.updated_at, reverse=True):
|
|
105
|
+
suggestion_marker = suggestion_markers.get((item.item_type, item.repo, item.number), "")
|
|
106
|
+
print(
|
|
107
|
+
f"{format_type_label(item):7} "
|
|
108
|
+
f"{item.repo}#{item.number:<5} "
|
|
109
|
+
f"{item.created_at.date().isoformat()} "
|
|
110
|
+
f"{f'* {item.title}' if suggestion_marker else item.title}"
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
115
|
+
"""Run the app entrypoint with backend data orchestration."""
|
|
116
|
+
|
|
117
|
+
options = _parse_args(argv)
|
|
118
|
+
if options.debug:
|
|
119
|
+
logging.basicConfig(level=logging.DEBUG)
|
|
120
|
+
|
|
121
|
+
if _should_wrap_interactive_start(options):
|
|
122
|
+
try:
|
|
123
|
+
exec_zellij_wrapped_workdash(argv)
|
|
124
|
+
except RuntimeError as error:
|
|
125
|
+
print(f"Error: {error}", file=sys.stderr, flush=True)
|
|
126
|
+
return 1
|
|
127
|
+
|
|
128
|
+
if options.configure:
|
|
129
|
+
configure()
|
|
130
|
+
return 0
|
|
131
|
+
|
|
132
|
+
if shutil.which("gh") is None:
|
|
133
|
+
print(
|
|
134
|
+
"Error: gh CLI is not installed or not on PATH. Install it from https://cli.github.com/",
|
|
135
|
+
file=sys.stderr,
|
|
136
|
+
flush=True,
|
|
137
|
+
)
|
|
138
|
+
return 1
|
|
139
|
+
|
|
140
|
+
config = load_config()
|
|
141
|
+
missing = validate_config(config)
|
|
142
|
+
if missing:
|
|
143
|
+
print(
|
|
144
|
+
f"Error: missing configuration fields: {', '.join(missing)}",
|
|
145
|
+
file=sys.stderr,
|
|
146
|
+
flush=True,
|
|
147
|
+
)
|
|
148
|
+
print(
|
|
149
|
+
"Run 'workdash --configure' to set up your configuration.",
|
|
150
|
+
file=sys.stderr,
|
|
151
|
+
flush=True,
|
|
152
|
+
)
|
|
153
|
+
return 1
|
|
154
|
+
|
|
155
|
+
backend = WorkdashBackend(config=config)
|
|
156
|
+
if not options.print_mode:
|
|
157
|
+
print("Loading work items from GitHub...", flush=True)
|
|
158
|
+
work_items, suggestion_markers = backend.load_items(
|
|
159
|
+
progress_callback=lambda message: print(message, flush=True)
|
|
160
|
+
)
|
|
161
|
+
else:
|
|
162
|
+
work_items, suggestion_markers = backend.load_items()
|
|
163
|
+
|
|
164
|
+
if options.print_mode:
|
|
165
|
+
_print_work_items(work_items, suggestion_markers)
|
|
166
|
+
return 0
|
|
167
|
+
|
|
168
|
+
def _analyze(item, tool="codex"):
|
|
169
|
+
ensure_worktree(config.workdir, item)
|
|
170
|
+
return backend.analyze_item(item, tool=tool)
|
|
171
|
+
|
|
172
|
+
def _launch(item: WorkItem, tool: str = "codex") -> None:
|
|
173
|
+
repo_path = ensure_worktree(config.workdir, item)
|
|
174
|
+
prompt = prepare_launch_agent_prompt(
|
|
175
|
+
item,
|
|
176
|
+
repo_path,
|
|
177
|
+
analysis_path=str(backend.analysis_cache.build_analysis_path(item))
|
|
178
|
+
if item.analysis is not None
|
|
179
|
+
else None,
|
|
180
|
+
merge_base=get_merge_base(repo_path),
|
|
181
|
+
)
|
|
182
|
+
if tool == "vscode":
|
|
183
|
+
launch_vscode_context(repo_path, prompt)
|
|
184
|
+
else:
|
|
185
|
+
launch_agent_context(
|
|
186
|
+
repo_path,
|
|
187
|
+
prompt,
|
|
188
|
+
agent_command_tokens=shlex.split(
|
|
189
|
+
config.claude.launch if tool == "claude" else config.codex.launch
|
|
190
|
+
),
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
app = WorkdashApp(
|
|
194
|
+
work_items=work_items,
|
|
195
|
+
suggestion_markers=suggestion_markers,
|
|
196
|
+
open_callback=lambda item: open_in_browser(item.url),
|
|
197
|
+
refresh_callback=backend.load_items,
|
|
198
|
+
worktree_callback=lambda item: ensure_worktree(config.workdir, item),
|
|
199
|
+
analyze_callback=_analyze,
|
|
200
|
+
launch_callback=_launch,
|
|
201
|
+
terminal_callback=lambda item: launch_terminal_context(
|
|
202
|
+
ensure_worktree(config.workdir, item)
|
|
203
|
+
),
|
|
204
|
+
include_callback=backend.include_item_by_url,
|
|
205
|
+
)
|
|
206
|
+
app.run()
|
|
207
|
+
return 0
|