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/config.py
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"""Workdash configuration management."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import shutil
|
|
7
|
+
from collections.abc import Callable
|
|
8
|
+
from dataclasses import dataclass, field
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
CONFIG_PATH = Path.home() / ".config" / "workdash" / "config.json"
|
|
12
|
+
|
|
13
|
+
_REQUIRED_FIELDS = ("github_username", "repositories", "workdir")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass(frozen=True)
|
|
17
|
+
class AgentConfig:
|
|
18
|
+
"""Per-agent command configuration."""
|
|
19
|
+
|
|
20
|
+
analyze: str = ""
|
|
21
|
+
launch: str = ""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass(frozen=True)
|
|
25
|
+
class WorkdashConfig:
|
|
26
|
+
"""Runtime configuration loaded from ~/.config/workdash/config.json."""
|
|
27
|
+
|
|
28
|
+
github_username: str = ""
|
|
29
|
+
claude: AgentConfig = field(default_factory=AgentConfig)
|
|
30
|
+
codex: AgentConfig = field(default_factory=AgentConfig)
|
|
31
|
+
repositories: tuple[str, ...] = ()
|
|
32
|
+
workdir: str = ""
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _config_to_json(config: WorkdashConfig) -> str:
|
|
36
|
+
return (
|
|
37
|
+
json.dumps(
|
|
38
|
+
{
|
|
39
|
+
"github_username": config.github_username,
|
|
40
|
+
"agents": {
|
|
41
|
+
"claude": {"analyze": config.claude.analyze, "launch": config.claude.launch},
|
|
42
|
+
"codex": {"analyze": config.codex.analyze, "launch": config.codex.launch},
|
|
43
|
+
},
|
|
44
|
+
"repositories": list(config.repositories),
|
|
45
|
+
"workdir": config.workdir,
|
|
46
|
+
},
|
|
47
|
+
indent=2,
|
|
48
|
+
ensure_ascii=True,
|
|
49
|
+
)
|
|
50
|
+
+ "\n"
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def load_config(path: Path = CONFIG_PATH) -> WorkdashConfig:
|
|
55
|
+
"""Load config from *path*; missing file returns an empty configuration.
|
|
56
|
+
|
|
57
|
+
Raises :class:`RuntimeError` when the file exists but cannot be read or
|
|
58
|
+
parsed, so a corrupted config surfaces an actionable error instead of
|
|
59
|
+
silently reverting to defaults.
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
if not path.exists():
|
|
63
|
+
return WorkdashConfig()
|
|
64
|
+
try:
|
|
65
|
+
contents = path.read_text(encoding="utf-8")
|
|
66
|
+
except OSError as error:
|
|
67
|
+
raise RuntimeError(f"Failed to read configuration at {path}: {error}") from error
|
|
68
|
+
try:
|
|
69
|
+
raw = json.loads(contents)
|
|
70
|
+
except json.JSONDecodeError as error:
|
|
71
|
+
raise RuntimeError(
|
|
72
|
+
f"Configuration at {path} is not valid JSON: {error.msg} "
|
|
73
|
+
f"(line {error.lineno}, column {error.colno})"
|
|
74
|
+
) from error
|
|
75
|
+
if not isinstance(raw, dict):
|
|
76
|
+
raise RuntimeError(
|
|
77
|
+
f"Configuration at {path} must be a JSON object, got {type(raw).__name__}."
|
|
78
|
+
)
|
|
79
|
+
repositories_raw = raw.get("repositories")
|
|
80
|
+
repositories = tuple(repositories_raw) if isinstance(repositories_raw, list) else ()
|
|
81
|
+
agents_raw = raw.get("agents")
|
|
82
|
+
claude_config = AgentConfig()
|
|
83
|
+
codex_config = AgentConfig()
|
|
84
|
+
if isinstance(agents_raw, dict):
|
|
85
|
+
claude_raw = agents_raw.get("claude")
|
|
86
|
+
if isinstance(claude_raw, dict):
|
|
87
|
+
claude_config = AgentConfig(
|
|
88
|
+
analyze=claude_raw.get("analyze", ""),
|
|
89
|
+
launch=claude_raw.get("launch", ""),
|
|
90
|
+
)
|
|
91
|
+
codex_raw = agents_raw.get("codex")
|
|
92
|
+
if isinstance(codex_raw, dict):
|
|
93
|
+
codex_config = AgentConfig(
|
|
94
|
+
analyze=codex_raw.get("analyze", ""),
|
|
95
|
+
launch=codex_raw.get("launch", ""),
|
|
96
|
+
)
|
|
97
|
+
return WorkdashConfig(
|
|
98
|
+
github_username=raw.get("github_username", ""),
|
|
99
|
+
claude=claude_config,
|
|
100
|
+
codex=codex_config,
|
|
101
|
+
repositories=repositories,
|
|
102
|
+
workdir=raw.get("workdir", "") or raw.get("source_directory", ""),
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def save_config(config: WorkdashConfig, path: Path = CONFIG_PATH) -> None:
|
|
107
|
+
"""Write *config* to *path*, creating parent directories as needed."""
|
|
108
|
+
|
|
109
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
110
|
+
path.write_text(_config_to_json(config), encoding="utf-8")
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def validate_config(config: WorkdashConfig) -> list[str]:
|
|
114
|
+
"""Return names of required fields that are empty or missing."""
|
|
115
|
+
|
|
116
|
+
missing: list[str] = []
|
|
117
|
+
if not config.github_username:
|
|
118
|
+
missing.append("github_username")
|
|
119
|
+
if not config.repositories:
|
|
120
|
+
missing.append("repositories")
|
|
121
|
+
if not config.workdir:
|
|
122
|
+
missing.append("workdir")
|
|
123
|
+
if not config.claude.analyze:
|
|
124
|
+
missing.append("agents.claude.analyze")
|
|
125
|
+
if not config.claude.launch:
|
|
126
|
+
missing.append("agents.claude.launch")
|
|
127
|
+
if not config.codex.analyze:
|
|
128
|
+
missing.append("agents.codex.analyze")
|
|
129
|
+
if not config.codex.launch:
|
|
130
|
+
missing.append("agents.codex.launch")
|
|
131
|
+
return missing
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def configure(
|
|
135
|
+
path: Path = CONFIG_PATH,
|
|
136
|
+
*,
|
|
137
|
+
input_fn: Callable[[str], str] = input,
|
|
138
|
+
which_fn: Callable[[str], str | None] = shutil.which,
|
|
139
|
+
) -> WorkdashConfig:
|
|
140
|
+
"""Interactive configuration that fills in missing fields.
|
|
141
|
+
|
|
142
|
+
:param Path path: Config file path.
|
|
143
|
+
:param input_fn: Callable used to prompt the user (default: builtin input).
|
|
144
|
+
:param which_fn: Callable used to detect commands on PATH (default: shutil.which).
|
|
145
|
+
"""
|
|
146
|
+
|
|
147
|
+
config = load_config(path)
|
|
148
|
+
|
|
149
|
+
claude = config.claude
|
|
150
|
+
if not claude.analyze or not claude.launch:
|
|
151
|
+
if which_fn("claude"):
|
|
152
|
+
if not claude.analyze:
|
|
153
|
+
print("Detected 'claude' on PATH, using analyze: claude -p")
|
|
154
|
+
if not claude.launch:
|
|
155
|
+
print("Detected 'claude' on PATH, using launch: claude")
|
|
156
|
+
claude = AgentConfig(
|
|
157
|
+
analyze=claude.analyze or "claude -p",
|
|
158
|
+
launch=claude.launch or "claude",
|
|
159
|
+
)
|
|
160
|
+
else:
|
|
161
|
+
claude = AgentConfig(
|
|
162
|
+
analyze=claude.analyze
|
|
163
|
+
or input_fn("Claude analyze command (e.g. 'claude -p'): ").strip(),
|
|
164
|
+
launch=claude.launch or input_fn("Claude launch command (e.g. 'claude'): ").strip(),
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
codex = config.codex
|
|
168
|
+
if not codex.analyze or not codex.launch:
|
|
169
|
+
if which_fn("codex"):
|
|
170
|
+
if not codex.analyze:
|
|
171
|
+
print("Detected 'codex' on PATH, using analyze: codex exec")
|
|
172
|
+
if not codex.launch:
|
|
173
|
+
print("Detected 'codex' on PATH, using launch: codex")
|
|
174
|
+
codex = AgentConfig(
|
|
175
|
+
analyze=codex.analyze or "codex exec",
|
|
176
|
+
launch=codex.launch or "codex",
|
|
177
|
+
)
|
|
178
|
+
else:
|
|
179
|
+
codex = AgentConfig(
|
|
180
|
+
analyze=codex.analyze
|
|
181
|
+
or input_fn("Codex analyze command (e.g. 'codex exec'): ").strip(),
|
|
182
|
+
launch=codex.launch or input_fn("Codex launch command (e.g. 'codex'): ").strip(),
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
github_username = config.github_username
|
|
186
|
+
if not github_username:
|
|
187
|
+
github_username = input_fn("GitHub username: ").strip()
|
|
188
|
+
|
|
189
|
+
workdir = config.workdir
|
|
190
|
+
if not workdir:
|
|
191
|
+
workdir = input_fn("Work directory (e.g. '~/wrk'): ").strip()
|
|
192
|
+
|
|
193
|
+
repositories = config.repositories
|
|
194
|
+
if not repositories and github_username:
|
|
195
|
+
repositories = (f"{github_username}/*",)
|
|
196
|
+
print(f"Repositories set to: {github_username}/*")
|
|
197
|
+
|
|
198
|
+
new_config = WorkdashConfig(
|
|
199
|
+
github_username=github_username,
|
|
200
|
+
claude=claude,
|
|
201
|
+
codex=codex,
|
|
202
|
+
repositories=repositories,
|
|
203
|
+
workdir=workdir,
|
|
204
|
+
)
|
|
205
|
+
save_config(new_config, path)
|
|
206
|
+
print(f"Configuration saved to {path}")
|
|
207
|
+
return new_config
|