workdash 0.3.0__tar.gz → 0.4.0__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.
- {workdash-0.3.0 → workdash-0.4.0}/PKG-INFO +49 -9
- {workdash-0.3.0 → workdash-0.4.0}/README.md +47 -8
- {workdash-0.3.0 → workdash-0.4.0}/pyproject.toml +3 -2
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash/analyzer.py +7 -94
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash/backend.py +63 -4
- workdash-0.4.0/src/workdash/branchdiff.py +528 -0
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash/config.py +20 -0
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash/control.py +124 -2
- workdash-0.4.0/src/workdash/git.py +315 -0
- workdash-0.4.0/src/workdash/github.py +201 -0
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash/github_client.py +580 -67
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash/launcher.py +82 -77
- workdash-0.4.0/src/workdash/models.py +103 -0
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash/prompts/analyze_issue.txt +2 -2
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash/prompts/analyze_pr.txt +2 -2
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash/prompts/launch_issue.txt +3 -3
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash/prompts/launch_review.txt +1 -1
- workdash-0.4.0/src/workdash/repo_worktree.py +156 -0
- workdash-0.4.0/src/workdash/todo.py +173 -0
- workdash-0.4.0/src/workdash/tui.py +952 -0
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash/workdash.py +65 -2
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash.egg-info/PKG-INFO +49 -9
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash.egg-info/SOURCES.txt +8 -1
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash.egg-info/requires.txt +1 -0
- {workdash-0.3.0 → workdash-0.4.0}/tests/test_analyzer.py +38 -0
- {workdash-0.3.0 → workdash-0.4.0}/tests/test_backend.py +445 -10
- workdash-0.4.0/tests/test_branchdiff.py +382 -0
- {workdash-0.3.0 → workdash-0.4.0}/tests/test_config.py +78 -5
- {workdash-0.3.0 → workdash-0.4.0}/tests/test_control.py +103 -8
- workdash-0.4.0/tests/test_git.py +100 -0
- workdash-0.4.0/tests/test_github.py +91 -0
- {workdash-0.3.0 → workdash-0.4.0}/tests/test_github_client.py +938 -138
- {workdash-0.3.0 → workdash-0.4.0}/tests/test_launcher.py +178 -19
- {workdash-0.3.0 → workdash-0.4.0}/tests/test_normalization.py +16 -0
- {workdash-0.3.0 → workdash-0.4.0}/tests/test_repo_worktree.py +411 -11
- workdash-0.4.0/tests/test_todo.py +164 -0
- {workdash-0.3.0 → workdash-0.4.0}/tests/test_tui.py +681 -19
- {workdash-0.3.0 → workdash-0.4.0}/tests/test_workdash.py +13 -9
- workdash-0.3.0/src/workdash/models.py +0 -50
- workdash-0.3.0/src/workdash/prompts/launch_pr.txt +0 -20
- workdash-0.3.0/src/workdash/repo_worktree.py +0 -374
- workdash-0.3.0/src/workdash/tui.py +0 -682
- {workdash-0.3.0 → workdash-0.4.0}/LICENSE +0 -0
- {workdash-0.3.0 → workdash-0.4.0}/setup.cfg +0 -0
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash/__init__.py +0 -0
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash/__main__.py +0 -0
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash/analysis_cache.py +0 -0
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash/included_items.py +0 -0
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash/prompts/__init__.py +0 -0
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash/repo_resolver.py +0 -0
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash.egg-info/dependency_links.txt +0 -0
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash.egg-info/entry_points.txt +0 -0
- {workdash-0.3.0 → workdash-0.4.0}/src/workdash.egg-info/top_level.txt +0 -0
- {workdash-0.3.0 → workdash-0.4.0}/tests/test_analysis_cache.py +0 -0
- {workdash-0.3.0 → workdash-0.4.0}/tests/test_included_items.py +0 -0
- {workdash-0.3.0 → workdash-0.4.0}/tests/test_repo_resolver.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: workdash
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Text-based GitHub work triage dashboard.
|
|
5
5
|
Author-email: Alessandro Molina <alessandro@molina.fyi>
|
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
|
@@ -700,6 +700,7 @@ License-File: LICENSE
|
|
|
700
700
|
Requires-Dist: markdown>=3.6
|
|
701
701
|
Requires-Dist: TurboGears2>=2.5.0
|
|
702
702
|
Requires-Dist: textual>=0.58
|
|
703
|
+
Requires-Dist: textual-diff-view>=0.1.0
|
|
703
704
|
Provides-Extra: test
|
|
704
705
|
Requires-Dist: pytest>=8; extra == "test"
|
|
705
706
|
Requires-Dist: pytest-bdd>=7; extra == "test"
|
|
@@ -772,6 +773,8 @@ The wizard fills in:
|
|
|
772
773
|
is still handled by `gh`; run `gh auth login` if startup reports that `gh` is
|
|
773
774
|
not authenticated.
|
|
774
775
|
- The list of repositories to track (see *Repository selectors* below).
|
|
776
|
+
- The todo repository where captured todos are created (defaults to
|
|
777
|
+
`<username>/todos`, see *Todos* below).
|
|
775
778
|
- A working directory where per-item git worktrees will live.
|
|
776
779
|
- The analyze and launch commands for Claude and Codex (auto-detected when the
|
|
777
780
|
tools are on your `PATH`).
|
|
@@ -801,6 +804,7 @@ workdash list --json # list items as machine-readable JSON
|
|
|
801
804
|
workdash info [--all] [--json] # report live Workdash-owned Zellij panes
|
|
802
805
|
workdash analyze ITEM [--agent NAME] [--json] # analyze a current server item
|
|
803
806
|
workdash code ITEM [--agent NAME] [--json] # launch a terminal-backed coding agent
|
|
807
|
+
workdash todo TEXT [--target owner/repo] [--json] # capture a todo
|
|
804
808
|
workdash read PANE_ID [--full] [--json] # read text from a live pane
|
|
805
809
|
workdash write PANE_ID TEXT [--raw] [--json] # send text to a live pane
|
|
806
810
|
workdash show-config [--json] # show configured agents and fixed server address
|
|
@@ -814,14 +818,17 @@ workdash --version # print version and exit
|
|
|
814
818
|
|
|
815
819
|
`workdash` gathers the following for your configured GitHub username:
|
|
816
820
|
|
|
817
|
-
- Open pull requests you authored.
|
|
821
|
+
- Open pull requests you authored (shown as `PR`).
|
|
818
822
|
- Open pull requests where you are a requested reviewer, plus open pull
|
|
819
823
|
requests you have already reviewed (shown as `REVIEW`).
|
|
820
|
-
- Open issues assigned to you.
|
|
821
|
-
- Open issues and pull requests across the tracked repositories.
|
|
824
|
+
- Open issues assigned to you (shown as `ISSUE`).
|
|
825
|
+
- Open issues and pull requests across the tracked repositories. A pull request
|
|
826
|
+
that is neither yours nor yours to review is shown as `CHECK`; once you review
|
|
827
|
+
it, the next refresh lists it as `REVIEW`.
|
|
822
828
|
|
|
823
|
-
Items are merged, deduplicated, and sorted by last update.
|
|
824
|
-
|
|
829
|
+
Items are merged, deduplicated, and sorted by last update. A pull request that
|
|
830
|
+
closes an issue replaces that issue, so the same work never takes two rows. One
|
|
831
|
+
item is marked with `*` as the suggested next thing to pick up.
|
|
825
832
|
|
|
826
833
|
### Repository selectors
|
|
827
834
|
|
|
@@ -832,6 +839,8 @@ The `repositories` list in `config.json` accepts:
|
|
|
832
839
|
|
|
833
840
|
## TUI keybindings
|
|
834
841
|
|
|
842
|
+
- `/` — search/filter the listed items by Type, Repo, or Title. Press `/` again
|
|
843
|
+
to clear.
|
|
835
844
|
- `o` — open the selected item in your browser.
|
|
836
845
|
- `r` — refresh the list from GitHub.
|
|
837
846
|
- `a` — analyze the selected item. Opens a dialog to open the cached analysis
|
|
@@ -842,8 +851,24 @@ The `repositories` list in `config.json` accepts:
|
|
|
842
851
|
worktree for the item and starts the chosen tool in it, preloaded with
|
|
843
852
|
context about the issue or PR.
|
|
844
853
|
- `t` — open a terminal in the selected item's worktree (no agent launched).
|
|
854
|
+
- `w` — capture a todo. Opens a dialog asking for the todo text and an
|
|
855
|
+
optional target repository.
|
|
845
856
|
- `q` — quit.
|
|
846
857
|
|
|
858
|
+
## Todos
|
|
859
|
+
|
|
860
|
+
Ideas and chores that show up while triaging can be captured as todos with `w`
|
|
861
|
+
in the TUI, `workdash todo TEXT`, or the JSON API. A todo is an ordinary GitHub
|
|
862
|
+
issue created in the single `todo_repository` from `config.json`, assigned to
|
|
863
|
+
you and labeled `workdash-todo`, so it shows up on the dashboard like any other
|
|
864
|
+
assigned issue. Create the repository on GitHub yourself; the label is created
|
|
865
|
+
on first use.
|
|
866
|
+
|
|
867
|
+
A todo may name a target repository (`--target owner/repo`). The issue still
|
|
868
|
+
lives in the todo repository, but the item is listed under its target and its
|
|
869
|
+
coding, terminal, and analysis actions run in a worktree of the target checked
|
|
870
|
+
out on a `wt-<number>` branch.
|
|
871
|
+
|
|
847
872
|
## Worktrees
|
|
848
873
|
|
|
849
874
|
Coding and analysis actions operate on a per-item git worktree rooted under the
|
|
@@ -851,11 +876,24 @@ configured `workdir`. Each tracked repository gets a local clone, and each work
|
|
|
851
876
|
item gets its own worktree alongside it, so you can hop between items without
|
|
852
877
|
disturbing other in-progress work.
|
|
853
878
|
|
|
879
|
+
A pull request you authored that closes an issue in the same repository is the
|
|
880
|
+
implementation of that issue, so it shares the issue's worktree directory (named
|
|
881
|
+
after the issue number) while staying checked out on the pull request's own
|
|
882
|
+
branch. That shared checkout is only reused while it holds the pull request's
|
|
883
|
+
branch; a checkout sitting on another branch belongs to other work, so it is left
|
|
884
|
+
alone and the pull request gets its own pull-request-numbered worktree instead.
|
|
885
|
+
Worktree directories created before this behavior existed are still named
|
|
886
|
+
after the pull request number; they are not migrated and keep working, so the
|
|
887
|
+
pull request stays in the checkout it already has and only a pull request with no
|
|
888
|
+
checkout yet gets an issue-numbered one. The link between a pull request and the
|
|
889
|
+
issue it closes is resolved while the dashboard refreshes, so a pull request
|
|
890
|
+
added by URL only shares the issue's worktree from the next refresh onwards.
|
|
891
|
+
|
|
854
892
|
## Local control server
|
|
855
893
|
|
|
856
894
|
`workdash --server` starts the normal TUI and a localhost JSON control API in the
|
|
857
895
|
same process. V0 listens on `127.0.0.1:8765`, accepts JSON only, and stops when
|
|
858
|
-
the TUI exits. Client commands such as `list`, `info`, `analyze`, `code`,
|
|
896
|
+
the TUI exits. Client commands such as `list`, `info`, `analyze`, `code`, `todo`,
|
|
859
897
|
`read`, and `write` connect to this server instead of loading GitHub or Zellij
|
|
860
898
|
state themselves.
|
|
861
899
|
|
|
@@ -868,8 +906,10 @@ per server-known item, sorted by last update (most recent first):
|
|
|
868
906
|
TYPE repo#TYPE-N YYYY-MM-DD title
|
|
869
907
|
```
|
|
870
908
|
|
|
871
|
-
`TYPE` is `ISSUE`, `PR
|
|
872
|
-
|
|
909
|
+
`TYPE` is `ISSUE`, `PR` (a PR you authored), `REVIEW` (for review-requested or
|
|
910
|
+
already reviewed PRs), or `CHECK` (any other PR). The row ID is
|
|
911
|
+
copy/paste-friendly: `repo#ISSUE-N`, `repo#PR-N`, `repo#REVIEW-N`,
|
|
912
|
+
`repo#CHECK-N`, or `<target>#ISSUE-WT<n>` for a targeted todo. The suggested
|
|
873
913
|
item's title is prefixed with `* `. If nothing matches, the output is
|
|
874
914
|
`No work items found.`.
|
|
875
915
|
|
|
@@ -65,6 +65,8 @@ The wizard fills in:
|
|
|
65
65
|
is still handled by `gh`; run `gh auth login` if startup reports that `gh` is
|
|
66
66
|
not authenticated.
|
|
67
67
|
- The list of repositories to track (see *Repository selectors* below).
|
|
68
|
+
- The todo repository where captured todos are created (defaults to
|
|
69
|
+
`<username>/todos`, see *Todos* below).
|
|
68
70
|
- A working directory where per-item git worktrees will live.
|
|
69
71
|
- The analyze and launch commands for Claude and Codex (auto-detected when the
|
|
70
72
|
tools are on your `PATH`).
|
|
@@ -94,6 +96,7 @@ workdash list --json # list items as machine-readable JSON
|
|
|
94
96
|
workdash info [--all] [--json] # report live Workdash-owned Zellij panes
|
|
95
97
|
workdash analyze ITEM [--agent NAME] [--json] # analyze a current server item
|
|
96
98
|
workdash code ITEM [--agent NAME] [--json] # launch a terminal-backed coding agent
|
|
99
|
+
workdash todo TEXT [--target owner/repo] [--json] # capture a todo
|
|
97
100
|
workdash read PANE_ID [--full] [--json] # read text from a live pane
|
|
98
101
|
workdash write PANE_ID TEXT [--raw] [--json] # send text to a live pane
|
|
99
102
|
workdash show-config [--json] # show configured agents and fixed server address
|
|
@@ -107,14 +110,17 @@ workdash --version # print version and exit
|
|
|
107
110
|
|
|
108
111
|
`workdash` gathers the following for your configured GitHub username:
|
|
109
112
|
|
|
110
|
-
- Open pull requests you authored.
|
|
113
|
+
- Open pull requests you authored (shown as `PR`).
|
|
111
114
|
- Open pull requests where you are a requested reviewer, plus open pull
|
|
112
115
|
requests you have already reviewed (shown as `REVIEW`).
|
|
113
|
-
- Open issues assigned to you.
|
|
114
|
-
- Open issues and pull requests across the tracked repositories.
|
|
116
|
+
- Open issues assigned to you (shown as `ISSUE`).
|
|
117
|
+
- Open issues and pull requests across the tracked repositories. A pull request
|
|
118
|
+
that is neither yours nor yours to review is shown as `CHECK`; once you review
|
|
119
|
+
it, the next refresh lists it as `REVIEW`.
|
|
115
120
|
|
|
116
|
-
Items are merged, deduplicated, and sorted by last update.
|
|
117
|
-
|
|
121
|
+
Items are merged, deduplicated, and sorted by last update. A pull request that
|
|
122
|
+
closes an issue replaces that issue, so the same work never takes two rows. One
|
|
123
|
+
item is marked with `*` as the suggested next thing to pick up.
|
|
118
124
|
|
|
119
125
|
### Repository selectors
|
|
120
126
|
|
|
@@ -125,6 +131,8 @@ The `repositories` list in `config.json` accepts:
|
|
|
125
131
|
|
|
126
132
|
## TUI keybindings
|
|
127
133
|
|
|
134
|
+
- `/` — search/filter the listed items by Type, Repo, or Title. Press `/` again
|
|
135
|
+
to clear.
|
|
128
136
|
- `o` — open the selected item in your browser.
|
|
129
137
|
- `r` — refresh the list from GitHub.
|
|
130
138
|
- `a` — analyze the selected item. Opens a dialog to open the cached analysis
|
|
@@ -135,8 +143,24 @@ The `repositories` list in `config.json` accepts:
|
|
|
135
143
|
worktree for the item and starts the chosen tool in it, preloaded with
|
|
136
144
|
context about the issue or PR.
|
|
137
145
|
- `t` — open a terminal in the selected item's worktree (no agent launched).
|
|
146
|
+
- `w` — capture a todo. Opens a dialog asking for the todo text and an
|
|
147
|
+
optional target repository.
|
|
138
148
|
- `q` — quit.
|
|
139
149
|
|
|
150
|
+
## Todos
|
|
151
|
+
|
|
152
|
+
Ideas and chores that show up while triaging can be captured as todos with `w`
|
|
153
|
+
in the TUI, `workdash todo TEXT`, or the JSON API. A todo is an ordinary GitHub
|
|
154
|
+
issue created in the single `todo_repository` from `config.json`, assigned to
|
|
155
|
+
you and labeled `workdash-todo`, so it shows up on the dashboard like any other
|
|
156
|
+
assigned issue. Create the repository on GitHub yourself; the label is created
|
|
157
|
+
on first use.
|
|
158
|
+
|
|
159
|
+
A todo may name a target repository (`--target owner/repo`). The issue still
|
|
160
|
+
lives in the todo repository, but the item is listed under its target and its
|
|
161
|
+
coding, terminal, and analysis actions run in a worktree of the target checked
|
|
162
|
+
out on a `wt-<number>` branch.
|
|
163
|
+
|
|
140
164
|
## Worktrees
|
|
141
165
|
|
|
142
166
|
Coding and analysis actions operate on a per-item git worktree rooted under the
|
|
@@ -144,11 +168,24 @@ configured `workdir`. Each tracked repository gets a local clone, and each work
|
|
|
144
168
|
item gets its own worktree alongside it, so you can hop between items without
|
|
145
169
|
disturbing other in-progress work.
|
|
146
170
|
|
|
171
|
+
A pull request you authored that closes an issue in the same repository is the
|
|
172
|
+
implementation of that issue, so it shares the issue's worktree directory (named
|
|
173
|
+
after the issue number) while staying checked out on the pull request's own
|
|
174
|
+
branch. That shared checkout is only reused while it holds the pull request's
|
|
175
|
+
branch; a checkout sitting on another branch belongs to other work, so it is left
|
|
176
|
+
alone and the pull request gets its own pull-request-numbered worktree instead.
|
|
177
|
+
Worktree directories created before this behavior existed are still named
|
|
178
|
+
after the pull request number; they are not migrated and keep working, so the
|
|
179
|
+
pull request stays in the checkout it already has and only a pull request with no
|
|
180
|
+
checkout yet gets an issue-numbered one. The link between a pull request and the
|
|
181
|
+
issue it closes is resolved while the dashboard refreshes, so a pull request
|
|
182
|
+
added by URL only shares the issue's worktree from the next refresh onwards.
|
|
183
|
+
|
|
147
184
|
## Local control server
|
|
148
185
|
|
|
149
186
|
`workdash --server` starts the normal TUI and a localhost JSON control API in the
|
|
150
187
|
same process. V0 listens on `127.0.0.1:8765`, accepts JSON only, and stops when
|
|
151
|
-
the TUI exits. Client commands such as `list`, `info`, `analyze`, `code`,
|
|
188
|
+
the TUI exits. Client commands such as `list`, `info`, `analyze`, `code`, `todo`,
|
|
152
189
|
`read`, and `write` connect to this server instead of loading GitHub or Zellij
|
|
153
190
|
state themselves.
|
|
154
191
|
|
|
@@ -161,8 +198,10 @@ per server-known item, sorted by last update (most recent first):
|
|
|
161
198
|
TYPE repo#TYPE-N YYYY-MM-DD title
|
|
162
199
|
```
|
|
163
200
|
|
|
164
|
-
`TYPE` is `ISSUE`, `PR
|
|
165
|
-
|
|
201
|
+
`TYPE` is `ISSUE`, `PR` (a PR you authored), `REVIEW` (for review-requested or
|
|
202
|
+
already reviewed PRs), or `CHECK` (any other PR). The row ID is
|
|
203
|
+
copy/paste-friendly: `repo#ISSUE-N`, `repo#PR-N`, `repo#REVIEW-N`,
|
|
204
|
+
`repo#CHECK-N`, or `<target>#ISSUE-WT<n>` for a targeted todo. The suggested
|
|
166
205
|
item's title is prefixed with `* `. If nothing matches, the output is
|
|
167
206
|
`No work items found.`.
|
|
168
207
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "workdash"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.0"
|
|
8
8
|
description = "Text-based GitHub work triage dashboard."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.12"
|
|
@@ -31,6 +31,7 @@ dependencies = [
|
|
|
31
31
|
"markdown>=3.6",
|
|
32
32
|
"TurboGears2>=2.5.0",
|
|
33
33
|
"textual>=0.58",
|
|
34
|
+
"textual-diff-view>=0.1.0",
|
|
34
35
|
]
|
|
35
36
|
|
|
36
37
|
[project.urls]
|
|
@@ -65,7 +66,7 @@ filterwarnings = [
|
|
|
65
66
|
[tool.ruff]
|
|
66
67
|
line-length = 100
|
|
67
68
|
target-version = "py312"
|
|
68
|
-
src = ["src"]
|
|
69
|
+
src = ["src", "tests"]
|
|
69
70
|
|
|
70
71
|
[tool.ruff.lint]
|
|
71
72
|
select = [
|
|
@@ -11,19 +11,12 @@ import tempfile
|
|
|
11
11
|
from pathlib import Path
|
|
12
12
|
from typing import Any
|
|
13
13
|
|
|
14
|
-
from .
|
|
14
|
+
from .github import GithubHelper
|
|
15
|
+
from .models import WorkItem, WorkItemType, display_repo
|
|
15
16
|
|
|
16
17
|
logger = logging.getLogger(__name__)
|
|
17
18
|
|
|
18
19
|
_DEFAULT_AGENT_COMMAND_TOKENS = ("codex", "exec")
|
|
19
|
-
_ISSUE_CONTEXT_JSON_FIELDS = (
|
|
20
|
-
"number,title,body,author,assignees,labels,url,state,createdAt,updatedAt,comments"
|
|
21
|
-
)
|
|
22
|
-
_PR_CONTEXT_JSON_FIELDS = (
|
|
23
|
-
"number,title,body,author,assignees,labels,url,state,createdAt,updatedAt,"
|
|
24
|
-
"isDraft,reviewDecision,additions,deletions,changedFiles,headRefName,baseRefName,"
|
|
25
|
-
"comments,reviews,latestReviews"
|
|
26
|
-
)
|
|
27
20
|
_PROMPTS_DIR = Path(__file__).parent / "prompts"
|
|
28
21
|
|
|
29
22
|
|
|
@@ -41,96 +34,13 @@ class Analyzer:
|
|
|
41
34
|
else list(_DEFAULT_AGENT_COMMAND_TOKENS)
|
|
42
35
|
)
|
|
43
36
|
|
|
44
|
-
def _run_gh_context_command(
|
|
45
|
-
self,
|
|
46
|
-
*,
|
|
47
|
-
item: WorkItem,
|
|
48
|
-
command: list[str],
|
|
49
|
-
) -> dict[str, Any]:
|
|
50
|
-
try:
|
|
51
|
-
completed = subprocess.run(
|
|
52
|
-
command,
|
|
53
|
-
check=True,
|
|
54
|
-
capture_output=True,
|
|
55
|
-
text=True,
|
|
56
|
-
)
|
|
57
|
-
except FileNotFoundError as error:
|
|
58
|
-
raise RuntimeError(
|
|
59
|
-
"Failed to gather GitHub context with gh: gh CLI is not installed or not on PATH."
|
|
60
|
-
) from error
|
|
61
|
-
except subprocess.CalledProcessError as error:
|
|
62
|
-
stderr = (error.stderr or "").strip()
|
|
63
|
-
raise RuntimeError(
|
|
64
|
-
f"Failed to gather gh context for {item.item_type.value} "
|
|
65
|
-
f"{item.repo}#{item.number}: "
|
|
66
|
-
f"{stderr or f'process exited with code {error.returncode}'}"
|
|
67
|
-
) from error
|
|
68
|
-
try:
|
|
69
|
-
payload = json.loads(completed.stdout)
|
|
70
|
-
except json.JSONDecodeError as error:
|
|
71
|
-
raise RuntimeError(
|
|
72
|
-
f"Failed to parse gh context JSON for {item.item_type.value} "
|
|
73
|
-
f"{item.repo}#{item.number}: {error.msg}"
|
|
74
|
-
) from error
|
|
75
|
-
if not isinstance(payload, dict):
|
|
76
|
-
raise RuntimeError(
|
|
77
|
-
f"Invalid gh context payload for {item.item_type.value} "
|
|
78
|
-
f"{item.repo}#{item.number}: expected a JSON object."
|
|
79
|
-
)
|
|
80
|
-
return payload
|
|
81
|
-
|
|
82
37
|
def _collect_github_context(self, item: WorkItem) -> dict[str, Any]:
|
|
83
|
-
|
|
84
|
-
command = [
|
|
85
|
-
"gh",
|
|
86
|
-
"issue",
|
|
87
|
-
"view",
|
|
88
|
-
str(item.number),
|
|
89
|
-
"--repo",
|
|
90
|
-
item.repo,
|
|
91
|
-
"--json",
|
|
92
|
-
_ISSUE_CONTEXT_JSON_FIELDS,
|
|
93
|
-
]
|
|
94
|
-
return self._run_gh_context_command(item=item, command=command)
|
|
95
|
-
|
|
96
|
-
return self._run_gh_context_command(
|
|
97
|
-
item=item,
|
|
98
|
-
command=[
|
|
99
|
-
"gh",
|
|
100
|
-
"pr",
|
|
101
|
-
"view",
|
|
102
|
-
str(item.number),
|
|
103
|
-
"--repo",
|
|
104
|
-
item.repo,
|
|
105
|
-
"--json",
|
|
106
|
-
_PR_CONTEXT_JSON_FIELDS,
|
|
107
|
-
],
|
|
108
|
-
)
|
|
38
|
+
return GithubHelper().fetch_analysis_context(item)
|
|
109
39
|
|
|
110
40
|
def _fetch_pr_diff(self, item: WorkItem) -> str:
|
|
111
41
|
"""Fetch the unified diff for a pull request via ``gh pr diff``."""
|
|
112
42
|
|
|
113
|
-
|
|
114
|
-
try:
|
|
115
|
-
completed = subprocess.run(
|
|
116
|
-
command,
|
|
117
|
-
check=True,
|
|
118
|
-
capture_output=True,
|
|
119
|
-
text=True,
|
|
120
|
-
)
|
|
121
|
-
except FileNotFoundError as error:
|
|
122
|
-
raise RuntimeError(
|
|
123
|
-
"Failed to gather GitHub diff context with gh: "
|
|
124
|
-
"gh CLI is not installed or not on PATH."
|
|
125
|
-
) from error
|
|
126
|
-
except subprocess.CalledProcessError as error:
|
|
127
|
-
stderr = (error.stderr or "").strip()
|
|
128
|
-
raise RuntimeError(
|
|
129
|
-
f"Failed to gather gh diff context for {item.item_type.value} "
|
|
130
|
-
f"{item.repo}#{item.number}: "
|
|
131
|
-
f"{stderr or f'process exited with code {error.returncode}'}"
|
|
132
|
-
) from error
|
|
133
|
-
return completed.stdout
|
|
43
|
+
return GithubHelper().fetch_diff(item)
|
|
134
44
|
|
|
135
45
|
def _build_agent_prompt(
|
|
136
46
|
self,
|
|
@@ -147,6 +57,9 @@ class Analyzer:
|
|
|
147
57
|
"item_type": item.item_type.value,
|
|
148
58
|
"kind": item.kind.value,
|
|
149
59
|
"repo": item.repo,
|
|
60
|
+
# Source links must point at the code being analyzed, which for a
|
|
61
|
+
# targeted todo is the target and not the todo repository.
|
|
62
|
+
"code_repo": display_repo(item),
|
|
150
63
|
"number": item.number,
|
|
151
64
|
"title": item.title,
|
|
152
65
|
"url": item.url,
|
|
@@ -19,6 +19,7 @@ from .github_client import (
|
|
|
19
19
|
normalize_authored_pull_requests,
|
|
20
20
|
normalize_recent_tracked_items,
|
|
21
21
|
normalize_review_requested_pull_requests,
|
|
22
|
+
normalize_todo_issues,
|
|
22
23
|
parse_github_item_url,
|
|
23
24
|
)
|
|
24
25
|
from .included_items import IncludedItemsStore
|
|
@@ -44,6 +45,8 @@ class IncludeResult:
|
|
|
44
45
|
|
|
45
46
|
|
|
46
47
|
_SUGGESTION_MARKER = "*"
|
|
48
|
+
# Rows the dashboard shows; the oldest discovered work beyond this is dropped.
|
|
49
|
+
_MAX_WORK_ITEMS = 100
|
|
47
50
|
_DEFAULT_CACHE_ROOT = Path.home() / ".config" / "workdash" / "cache"
|
|
48
51
|
_DEFAULT_INCLUDED_STORE_PATH = Path.home() / ".config" / "workdash" / "included.json"
|
|
49
52
|
|
|
@@ -106,10 +109,12 @@ class WorkdashBackend:
|
|
|
106
109
|
for repository in repositories:
|
|
107
110
|
report_progress(f" - {repository}")
|
|
108
111
|
github_username = self.config.github_username
|
|
109
|
-
with ThreadPoolExecutor(max_workers=
|
|
112
|
+
with ThreadPoolExecutor(max_workers=6) as executor:
|
|
110
113
|
report_progress("Fetching open authored pull requests...")
|
|
111
114
|
authored_future = executor.submit(
|
|
112
|
-
self.github_client.list_open_authored_prs,
|
|
115
|
+
self.github_client.list_open_authored_prs,
|
|
116
|
+
github_username,
|
|
117
|
+
progress_callback=report_progress,
|
|
113
118
|
)
|
|
114
119
|
report_progress("Fetching open review-requested pull requests...")
|
|
115
120
|
review_requested_future = executor.submit(
|
|
@@ -131,6 +136,12 @@ class WorkdashBackend:
|
|
|
131
136
|
repositories,
|
|
132
137
|
progress_callback=report_progress,
|
|
133
138
|
)
|
|
139
|
+
report_progress("Fetching open todo issues...")
|
|
140
|
+
todo_future = executor.submit(
|
|
141
|
+
self.github_client.list_open_todo_issues,
|
|
142
|
+
self.config.todo_repository,
|
|
143
|
+
progress_callback=report_progress,
|
|
144
|
+
)
|
|
134
145
|
|
|
135
146
|
authored_pull_requests = authored_future.result()
|
|
136
147
|
report_progress(f"Fetched {len(authored_pull_requests)} open authored pull request(s).")
|
|
@@ -143,6 +154,8 @@ class WorkdashBackend:
|
|
|
143
154
|
assigned_issues = assigned_future.result()
|
|
144
155
|
report_progress(f"Fetched {len(assigned_issues)} open assigned issue(s).")
|
|
145
156
|
recent_tracked_items = tracked_future.result()
|
|
157
|
+
todo_issues = todo_future.result()
|
|
158
|
+
report_progress(f"Fetched {len(todo_issues)} open todo issue(s).")
|
|
146
159
|
merged_review_items = merge_normalized_work_items(
|
|
147
160
|
normalize_review_requested_pull_requests(review_requested_pull_requests),
|
|
148
161
|
normalize_review_requested_pull_requests(reviewed_pull_requests),
|
|
@@ -159,9 +172,55 @@ class WorkdashBackend:
|
|
|
159
172
|
merged_items,
|
|
160
173
|
normalize_recent_tracked_items(recent_tracked_items),
|
|
161
174
|
)
|
|
175
|
+
# Tracked repositories can hold years of open work, so only the most
|
|
176
|
+
# recently updated discovered items are kept. Todo and included items
|
|
177
|
+
# are merged after the cap because the user asked for those by hand and
|
|
178
|
+
# must not lose them to a busy week elsewhere.
|
|
179
|
+
if len(merged_items) > _MAX_WORK_ITEMS:
|
|
180
|
+
report_progress(
|
|
181
|
+
f"Keeping the {_MAX_WORK_ITEMS} most recently updated "
|
|
182
|
+
f"of {len(merged_items)} discovered work item(s)."
|
|
183
|
+
)
|
|
184
|
+
merged_items = sorted(merged_items, key=lambda item: item.updated_at, reverse=True)[
|
|
185
|
+
:_MAX_WORK_ITEMS
|
|
186
|
+
]
|
|
187
|
+
# Todo records go first so the target they carry survives dedupe against
|
|
188
|
+
# the same issue found through the assigned-issue source.
|
|
189
|
+
merged_items = merge_normalized_work_items(
|
|
190
|
+
normalize_todo_issues(todo_issues),
|
|
191
|
+
merged_items,
|
|
192
|
+
)
|
|
162
193
|
included_work_items = self._load_included_items(report_progress)
|
|
163
194
|
if included_work_items:
|
|
164
195
|
merged_items = merge_normalized_work_items(merged_items, included_work_items)
|
|
196
|
+
pull_request_items = [item for item in merged_items if item.item_type == WorkItemType.PR]
|
|
197
|
+
if pull_request_items:
|
|
198
|
+
report_progress(
|
|
199
|
+
f"Fetching linked issues for {len(pull_request_items)} pull request(s)..."
|
|
200
|
+
)
|
|
201
|
+
linked_issues = self.github_client.fetch_linked_issues(
|
|
202
|
+
[(item.repo, item.number) for item in pull_request_items],
|
|
203
|
+
progress_callback=report_progress,
|
|
204
|
+
)
|
|
205
|
+
for item in pull_request_items:
|
|
206
|
+
# Only an issue in the pull request's own repository can name the
|
|
207
|
+
# pull request's worktree, so a foreign closing issue is not the
|
|
208
|
+
# item's linked issue even though it is still hidden below.
|
|
209
|
+
own_repo_issues = [
|
|
210
|
+
issue
|
|
211
|
+
for issue in linked_issues.get((item.repo, item.number), [])
|
|
212
|
+
if issue[0] == item.repo
|
|
213
|
+
]
|
|
214
|
+
item.linked_issue = min(own_repo_issues, key=lambda issue: issue[1], default=None)
|
|
215
|
+
# A pull request already carries the work of the issue it closes, so
|
|
216
|
+
# listing that issue as well would show the same work twice.
|
|
217
|
+
hidden_issues = {issue for issues in linked_issues.values() for issue in issues}
|
|
218
|
+
merged_items = [
|
|
219
|
+
item
|
|
220
|
+
for item in merged_items
|
|
221
|
+
if item.item_type != WorkItemType.ISSUE
|
|
222
|
+
or (item.repo, item.number) not in hidden_issues
|
|
223
|
+
]
|
|
165
224
|
report_progress(
|
|
166
225
|
f"Merged {len(merged_items)} unique work item(s); loading cached analyses..."
|
|
167
226
|
)
|
|
@@ -190,7 +249,7 @@ class WorkdashBackend:
|
|
|
190
249
|
if parsed is None:
|
|
191
250
|
continue
|
|
192
251
|
try:
|
|
193
|
-
item = self.github_client.fetch_item_by_url(parsed)
|
|
252
|
+
item = self.github_client.fetch_item_by_url(parsed, self.config.github_username)
|
|
194
253
|
except TransientFetchError:
|
|
195
254
|
survivors.append(parsed.canonical_url)
|
|
196
255
|
continue
|
|
@@ -227,7 +286,7 @@ class WorkdashBackend:
|
|
|
227
286
|
self.included_items_store.add(parsed.canonical_url)
|
|
228
287
|
return IncludeResult(duplicate_identity=identity)
|
|
229
288
|
try:
|
|
230
|
-
item = self.github_client.fetch_item_by_url(parsed)
|
|
289
|
+
item = self.github_client.fetch_item_by_url(parsed, self.config.github_username)
|
|
231
290
|
except TransientFetchError:
|
|
232
291
|
return IncludeResult(transient_failure=True)
|
|
233
292
|
if item is None:
|