git-contribution-analyzer 0.8.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.
- git_contribution_analyzer/__init__.py +3 -0
- git_contribution_analyzer/adapters/__init__.py +1 -0
- git_contribution_analyzer/adapters/git/__init__.py +1 -0
- git_contribution_analyzer/adapters/git/local_identity.py +51 -0
- git_contribution_analyzer/adapters/git/native_git.py +353 -0
- git_contribution_analyzer/adapters/git/pydriller_history.py +57 -0
- git_contribution_analyzer/adapters/git/repository_discovery.py +75 -0
- git_contribution_analyzer/adapters/gui/__init__.py +1 -0
- git_contribution_analyzer/adapters/gui/app.py +63 -0
- git_contribution_analyzer/adapters/gui/controller.py +1084 -0
- git_contribution_analyzer/adapters/gui/models/__init__.py +3 -0
- git_contribution_analyzer/adapters/gui/models/base_table.py +108 -0
- git_contribution_analyzer/adapters/gui/settings.py +53 -0
- git_contribution_analyzer/adapters/gui/task_runner.py +196 -0
- git_contribution_analyzer/adapters/llm/__init__.py +1 -0
- git_contribution_analyzer/adapters/llm/anthropic.py +52 -0
- git_contribution_analyzer/adapters/llm/base.py +142 -0
- git_contribution_analyzer/adapters/llm/cache.py +148 -0
- git_contribution_analyzer/adapters/llm/claude_cli.py +52 -0
- git_contribution_analyzer/adapters/llm/codex_cli.py +52 -0
- git_contribution_analyzer/adapters/llm/command_base.py +153 -0
- git_contribution_analyzer/adapters/llm/mock.py +82 -0
- git_contribution_analyzer/adapters/llm/ollama.py +53 -0
- git_contribution_analyzer/adapters/llm/openai_compatible.py +61 -0
- git_contribution_analyzer/adapters/llm/registry.py +117 -0
- git_contribution_analyzer/adapters/mcp/__init__.py +13 -0
- git_contribution_analyzer/adapters/mcp/installer.py +175 -0
- git_contribution_analyzer/adapters/mcp/prompts_resources.py +218 -0
- git_contribution_analyzer/adapters/mcp/protocol.py +361 -0
- git_contribution_analyzer/adapters/mcp/server.py +52 -0
- git_contribution_analyzer/adapters/mcp/tools.py +621 -0
- git_contribution_analyzer/adapters/outcomes/__init__.py +1 -0
- git_contribution_analyzer/adapters/outcomes/yaml_loader.py +55 -0
- git_contribution_analyzer/adapters/outcomes/yaml_store.py +104 -0
- git_contribution_analyzer/adapters/reporting/__init__.py +1 -0
- git_contribution_analyzer/adapters/reporting/brag_markdown.py +115 -0
- git_contribution_analyzer/adapters/reporting/html_report.py +1413 -0
- git_contribution_analyzer/adapters/reporting/markdown.py +217 -0
- git_contribution_analyzer/adapters/reporting/portfolio_markdown.py +167 -0
- git_contribution_analyzer/adapters/reporting/recap_markdown.py +212 -0
- git_contribution_analyzer/adapters/reporting/resume_markdown.py +37 -0
- git_contribution_analyzer/adapters/reporting/work_assessment_csv.py +117 -0
- git_contribution_analyzer/adapters/reporting/work_assessment_markdown.py +90 -0
- git_contribution_analyzer/adapters/reporting/work_assessment_series_markdown.py +31 -0
- git_contribution_analyzer/adapters/storage/__init__.py +1 -0
- git_contribution_analyzer/adapters/storage/sqlite/__init__.py +1 -0
- git_contribution_analyzer/adapters/storage/sqlite/analysis.py +708 -0
- git_contribution_analyzer/adapters/storage/sqlite/database.py +98 -0
- git_contribution_analyzer/adapters/storage/sqlite/git_index.py +482 -0
- git_contribution_analyzer/adapters/storage/sqlite/identity_merge.py +373 -0
- git_contribution_analyzer/adapters/storage/sqlite/llm_audit.py +109 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/env.py +34 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/script.py.mako +22 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0001_initial.py +51 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0002_git_index.py +146 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0003_analysis.py +79 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0004_llm_audit.py +69 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0005_run_types.py +42 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0006_identity_merges.py +83 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0007_structural_baselines.py +173 -0
- git_contribution_analyzer/adapters/storage/sqlite/models.py +354 -0
- git_contribution_analyzer/adapters/storage/sqlite/structural_baseline.py +841 -0
- git_contribution_analyzer/adapters/workspace/__init__.py +1 -0
- git_contribution_analyzer/adapters/workspace/config.py +135 -0
- git_contribution_analyzer/adapters/workspace/git_exclude.py +32 -0
- git_contribution_analyzer/adapters/workspace/layout.py +40 -0
- git_contribution_analyzer/adapters/workspace/locks.py +27 -0
- git_contribution_analyzer/adapters/workspace/portfolio_workspace.py +380 -0
- git_contribution_analyzer/adapters/workspace/ranking_config.py +17 -0
- git_contribution_analyzer/application/__init__.py +1 -0
- git_contribution_analyzer/application/dto/__init__.py +19 -0
- git_contribution_analyzer/application/dto/gui.py +86 -0
- git_contribution_analyzer/application/dto/results.py +21 -0
- git_contribution_analyzer/application/facades/__init__.py +3 -0
- git_contribution_analyzer/application/facades/gui.py +568 -0
- git_contribution_analyzer/application/ports/__init__.py +22 -0
- git_contribution_analyzer/application/ports/cancellation.py +50 -0
- git_contribution_analyzer/application/ports/git_history.py +22 -0
- git_contribution_analyzer/application/ports/llm.py +44 -0
- git_contribution_analyzer/application/ports/portfolio_store.py +34 -0
- git_contribution_analyzer/application/ports/progress.py +43 -0
- git_contribution_analyzer/application/ports/structural_baseline.py +93 -0
- git_contribution_analyzer/application/services/__init__.py +1 -0
- git_contribution_analyzer/application/services/assessment_explanation.py +127 -0
- git_contribution_analyzer/application/services/default_person.py +61 -0
- git_contribution_analyzer/application/services/evidence_snapshot.py +64 -0
- git_contribution_analyzer/application/services/person_selection.py +88 -0
- git_contribution_analyzer/application/services/resume_generation.py +318 -0
- git_contribution_analyzer/application/services/semantic_enhancement.py +157 -0
- git_contribution_analyzer/application/services/time_boundaries.py +49 -0
- git_contribution_analyzer/application/use_cases/__init__.py +1 -0
- git_contribution_analyzer/application/use_cases/analyze_contributions.py +276 -0
- git_contribution_analyzer/application/use_cases/analyze_project.py +295 -0
- git_contribution_analyzer/application/use_cases/assess_portfolio.py +327 -0
- git_contribution_analyzer/application/use_cases/assess_work.py +602 -0
- git_contribution_analyzer/application/use_cases/assess_work_series.py +212 -0
- git_contribution_analyzer/application/use_cases/compare_assessment_runs.py +121 -0
- git_contribution_analyzer/application/use_cases/export_report.py +49 -0
- git_contribution_analyzer/application/use_cases/generate_brag.py +308 -0
- git_contribution_analyzer/application/use_cases/generate_portfolio_recap.py +244 -0
- git_contribution_analyzer/application/use_cases/generate_portfolio_resume.py +152 -0
- git_contribution_analyzer/application/use_cases/generate_recap.py +316 -0
- git_contribution_analyzer/application/use_cases/generate_report.py +32 -0
- git_contribution_analyzer/application/use_cases/generate_resume.py +209 -0
- git_contribution_analyzer/application/use_cases/get_portfolio_status.py +83 -0
- git_contribution_analyzer/application/use_cases/get_run.py +16 -0
- git_contribution_analyzer/application/use_cases/get_status.py +69 -0
- git_contribution_analyzer/application/use_cases/index_repository.py +267 -0
- git_contribution_analyzer/application/use_cases/init_portfolio.py +89 -0
- git_contribution_analyzer/application/use_cases/init_project.py +71 -0
- git_contribution_analyzer/application/use_cases/list_identities.py +16 -0
- git_contribution_analyzer/application/use_cases/list_providers.py +29 -0
- git_contribution_analyzer/application/use_cases/list_runs.py +17 -0
- git_contribution_analyzer/application/use_cases/manage_identity_merges.py +48 -0
- git_contribution_analyzer/application/use_cases/manage_outcomes.py +189 -0
- git_contribution_analyzer/application/use_cases/manage_structural_baselines.py +262 -0
- git_contribution_analyzer/application/use_cases/map_identity.py +28 -0
- git_contribution_analyzer/application/use_cases/recover_runs.py +22 -0
- git_contribution_analyzer/application/use_cases/run_doctor.py +81 -0
- git_contribution_analyzer/application/use_cases/sync_portfolio.py +232 -0
- git_contribution_analyzer/application/use_cases/test_provider.py +22 -0
- git_contribution_analyzer/application/use_cases/uninit_project.py +23 -0
- git_contribution_analyzer/application/use_cases/verify_portfolio.py +165 -0
- git_contribution_analyzer/cli/__init__.py +1 -0
- git_contribution_analyzer/cli/app.py +1430 -0
- git_contribution_analyzer/cli/exit_codes.py +13 -0
- git_contribution_analyzer/cli/output.py +26 -0
- git_contribution_analyzer/cli/portfolio_commands.py +629 -0
- git_contribution_analyzer/domain/__init__.py +1 -0
- git_contribution_analyzer/domain/errors.py +55 -0
- git_contribution_analyzer/domain/models/__init__.py +3 -0
- git_contribution_analyzer/domain/models/analysis.py +29 -0
- git_contribution_analyzer/domain/models/assessment.py +12 -0
- git_contribution_analyzer/domain/models/brag.py +148 -0
- git_contribution_analyzer/domain/models/contribution.py +55 -0
- git_contribution_analyzer/domain/models/git_history.py +69 -0
- git_contribution_analyzer/domain/models/person_selection.py +46 -0
- git_contribution_analyzer/domain/models/portfolio.py +498 -0
- git_contribution_analyzer/domain/models/ranking.py +48 -0
- git_contribution_analyzer/domain/models/recap.py +235 -0
- git_contribution_analyzer/domain/models/repository.py +10 -0
- git_contribution_analyzer/domain/models/resume.py +59 -0
- git_contribution_analyzer/domain/models/run.py +10 -0
- git_contribution_analyzer/domain/models/semantic.py +34 -0
- git_contribution_analyzer/domain/models/snapshot.py +208 -0
- git_contribution_analyzer/domain/models/structural_baseline.py +120 -0
- git_contribution_analyzer/domain/models/work_assessment.py +81 -0
- git_contribution_analyzer/domain/services/assessment_periods.py +182 -0
- git_contribution_analyzer/domain/services/brag_rules.py +250 -0
- git_contribution_analyzer/domain/services/capability_rules.py +91 -0
- git_contribution_analyzer/domain/services/contribution_clustering.py +98 -0
- git_contribution_analyzer/domain/services/contribution_rules.py +79 -0
- git_contribution_analyzer/domain/services/difficulty_rules.py +191 -0
- git_contribution_analyzer/domain/services/dimensional_summary.py +117 -0
- git_contribution_analyzer/domain/services/portfolio_aggregation.py +250 -0
- git_contribution_analyzer/domain/services/portfolio_resume_rules.py +265 -0
- git_contribution_analyzer/domain/services/portfolio_verifier.py +238 -0
- git_contribution_analyzer/domain/services/ranking_rules.py +226 -0
- git_contribution_analyzer/domain/services/recap_rules.py +268 -0
- git_contribution_analyzer/domain/services/resume_claim_rules.py +70 -0
- git_contribution_analyzer/domain/services/structural_baseline.py +317 -0
- git_contribution_analyzer/domain/services/structural_signals.py +151 -0
- git_contribution_analyzer/domain/services/workload_rules.py +185 -0
- git_contribution_analyzer/gui/__init__.py +1 -0
- git_contribution_analyzer/gui/qml/Main.qml +1141 -0
- git_contribution_analyzer/gui/qml/__init__.py +1 -0
- git_contribution_analyzer/prompts/__init__.py +1 -0
- git_contribution_analyzer/prompts/assessment/__init__.py +1 -0
- git_contribution_analyzer/prompts/assessment/v1/__init__.py +1 -0
- git_contribution_analyzer/prompts/assessment/v1/explanation.txt +4 -0
- git_contribution_analyzer/prompts/resume/__init__.py +1 -0
- git_contribution_analyzer/prompts/resume/v1/__init__.py +1 -0
- git_contribution_analyzer/prompts/resume/v1/style-concise.txt +1 -0
- git_contribution_analyzer/prompts/resume/v1/style-star.txt +1 -0
- git_contribution_analyzer/prompts/resume/v1/style-xyz.txt +1 -0
- git_contribution_analyzer/prompts/resume/v1/system.txt +3 -0
- git_contribution_analyzer/prompts/v1/__init__.py +1 -0
- git_contribution_analyzer/prompts/v1/capability_explanation.txt +2 -0
- git_contribution_analyzer/prompts/v1/contribution_summary.txt +2 -0
- git_contribution_analyzer/prompts/v1/overall_summary.txt +2 -0
- git_contribution_analyzer/prompts/v1/resume_bullet.txt +2 -0
- git_contribution_analyzer-0.8.0.dist-info/METADATA +667 -0
- git_contribution_analyzer-0.8.0.dist-info/RECORD +187 -0
- git_contribution_analyzer-0.8.0.dist-info/WHEEL +4 -0
- git_contribution_analyzer-0.8.0.dist-info/entry_points.txt +3 -0
- git_contribution_analyzer-0.8.0.dist-info/licenses/LICENSE +201 -0
- git_contribution_analyzer-0.8.0.dist-info/licenses/NOTICE +6 -0
|
@@ -0,0 +1,1084 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import webbrowser
|
|
6
|
+
from collections.abc import Callable
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from PySide6.QtCore import Property, QObject, QUrl, Signal, Slot
|
|
11
|
+
|
|
12
|
+
from git_contribution_analyzer import __version__
|
|
13
|
+
from git_contribution_analyzer.adapters.gui.models.base_table import Column, DictTableModel
|
|
14
|
+
from git_contribution_analyzer.adapters.gui.settings import GuiSettings
|
|
15
|
+
from git_contribution_analyzer.adapters.gui.task_runner import RepositoryTaskRunner
|
|
16
|
+
from git_contribution_analyzer.application.dto.gui import (
|
|
17
|
+
AssessmentRequest,
|
|
18
|
+
ExportRequest,
|
|
19
|
+
IdentityMapRequest,
|
|
20
|
+
IdentityMergeRequest,
|
|
21
|
+
ResumeRequest,
|
|
22
|
+
StructuralBaselineRequest,
|
|
23
|
+
)
|
|
24
|
+
from git_contribution_analyzer.application.facades.gui import GuiApplicationFacade
|
|
25
|
+
from git_contribution_analyzer.application.ports.cancellation import CancellationToken
|
|
26
|
+
from git_contribution_analyzer.application.ports.progress import ProgressReporter
|
|
27
|
+
|
|
28
|
+
TaskCallable = Callable[[ProgressReporter, CancellationToken], Any]
|
|
29
|
+
SuccessCallback = Callable[[Any], None]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class GuiController(QObject):
|
|
33
|
+
repositoryChanged = Signal()
|
|
34
|
+
statusChanged = Signal()
|
|
35
|
+
taskChanged = Signal()
|
|
36
|
+
errorChanged = Signal()
|
|
37
|
+
resultChanged = Signal()
|
|
38
|
+
structuralChanged = Signal()
|
|
39
|
+
recapChanged = Signal()
|
|
40
|
+
outcomesChanged = Signal()
|
|
41
|
+
recentChanged = Signal()
|
|
42
|
+
notification = Signal(str)
|
|
43
|
+
|
|
44
|
+
def __init__(
|
|
45
|
+
self,
|
|
46
|
+
*,
|
|
47
|
+
facade: GuiApplicationFacade | None = None,
|
|
48
|
+
task_runner: RepositoryTaskRunner | None = None,
|
|
49
|
+
settings: GuiSettings | None = None,
|
|
50
|
+
) -> None:
|
|
51
|
+
super().__init__()
|
|
52
|
+
self._facade = facade or GuiApplicationFacade()
|
|
53
|
+
self._runner = task_runner or RepositoryTaskRunner()
|
|
54
|
+
self._settings = settings or GuiSettings()
|
|
55
|
+
self._repository_path = ""
|
|
56
|
+
self._status: dict[str, Any] = {}
|
|
57
|
+
self._active_tasks: set[str] = set()
|
|
58
|
+
self._task_stage = ""
|
|
59
|
+
self._task_message = ""
|
|
60
|
+
self._error_message = ""
|
|
61
|
+
self._error_detail = ""
|
|
62
|
+
self._current_run_id = ""
|
|
63
|
+
self._completed_items = 0
|
|
64
|
+
self._pending_items = 0
|
|
65
|
+
self._current_report_json = ""
|
|
66
|
+
self._recap_markdown = ""
|
|
67
|
+
self._last_html_report_path = ""
|
|
68
|
+
self._callbacks: dict[str, SuccessCallback] = {}
|
|
69
|
+
|
|
70
|
+
self._people_model = DictTableModel(
|
|
71
|
+
columns=(
|
|
72
|
+
Column("name", "Name"),
|
|
73
|
+
Column("email", "Email"),
|
|
74
|
+
Column("kind", "Kind"),
|
|
75
|
+
Column("confirmed", "Confirmed"),
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
self._work_items_model = DictTableModel(
|
|
79
|
+
columns=(
|
|
80
|
+
Column("id", "ID"),
|
|
81
|
+
Column("title", "Work item"),
|
|
82
|
+
Column("completion", "Completion"),
|
|
83
|
+
Column("size", "Size"),
|
|
84
|
+
Column("difficulty", "Difficulty"),
|
|
85
|
+
)
|
|
86
|
+
)
|
|
87
|
+
self._evidence_model = DictTableModel(
|
|
88
|
+
columns=(
|
|
89
|
+
Column("id", "ID"),
|
|
90
|
+
Column("type", "Type"),
|
|
91
|
+
Column("summary", "Evidence"),
|
|
92
|
+
)
|
|
93
|
+
)
|
|
94
|
+
self._runs_model = DictTableModel(
|
|
95
|
+
columns=(
|
|
96
|
+
Column("id", "Run ID"),
|
|
97
|
+
Column("runType", "Type"),
|
|
98
|
+
Column("status", "Status"),
|
|
99
|
+
Column("startedAt", "Started"),
|
|
100
|
+
)
|
|
101
|
+
)
|
|
102
|
+
self._trends_model = DictTableModel(
|
|
103
|
+
columns=(
|
|
104
|
+
Column("periodIndex", "Index"),
|
|
105
|
+
Column("label", "Period"),
|
|
106
|
+
Column("completedItems", "Completed"),
|
|
107
|
+
Column("pendingItems", "Pending"),
|
|
108
|
+
Column("commits", "Commits"),
|
|
109
|
+
)
|
|
110
|
+
)
|
|
111
|
+
self._providers_model = DictTableModel(
|
|
112
|
+
columns=(
|
|
113
|
+
Column("id", "Provider"),
|
|
114
|
+
Column("selected", "Selected"),
|
|
115
|
+
Column("localExecution", "Local"),
|
|
116
|
+
Column("requiresApiKey", "API key"),
|
|
117
|
+
)
|
|
118
|
+
)
|
|
119
|
+
self._structural_hotspots_model = DictTableModel(
|
|
120
|
+
columns=(
|
|
121
|
+
Column("path", "Path"),
|
|
122
|
+
Column("changeCount", "Changes"),
|
|
123
|
+
Column("percentile", "Percentile"),
|
|
124
|
+
Column("confidence", "Confidence"),
|
|
125
|
+
)
|
|
126
|
+
)
|
|
127
|
+
self._structural_couplings_model = DictTableModel(
|
|
128
|
+
columns=(
|
|
129
|
+
Column("leftPath", "Left path"),
|
|
130
|
+
Column("rightPath", "Right path"),
|
|
131
|
+
Column("coChangeCount", "Co-changes"),
|
|
132
|
+
Column("jaccard", "Jaccard"),
|
|
133
|
+
Column("confidence", "Confidence"),
|
|
134
|
+
)
|
|
135
|
+
)
|
|
136
|
+
self._outcomes_model = DictTableModel(
|
|
137
|
+
columns=(
|
|
138
|
+
Column("id", "ID"),
|
|
139
|
+
Column("text", "Outcome"),
|
|
140
|
+
Column("verifiedBy", "Verified by"),
|
|
141
|
+
Column("verifiedAt", "Date"),
|
|
142
|
+
Column("evidenceSummary", "Evidence"),
|
|
143
|
+
)
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
self._runner.taskStarted.connect(self._task_started)
|
|
147
|
+
self._runner.taskProgress.connect(self._task_progress)
|
|
148
|
+
self._runner.taskSucceeded.connect(self._task_succeeded)
|
|
149
|
+
self._runner.taskFailed.connect(self._task_failed)
|
|
150
|
+
self._runner.taskCancelled.connect(self._task_cancelled)
|
|
151
|
+
|
|
152
|
+
@Property(str, notify=repositoryChanged)
|
|
153
|
+
def repositoryPath(self) -> str:
|
|
154
|
+
return self._repository_path
|
|
155
|
+
|
|
156
|
+
@Property(str, notify=repositoryChanged)
|
|
157
|
+
def repositoryName(self) -> str:
|
|
158
|
+
return Path(self._repository_path).name if self._repository_path else "No repository"
|
|
159
|
+
|
|
160
|
+
@Property(str, constant=True)
|
|
161
|
+
def appVersion(self) -> str:
|
|
162
|
+
return __version__
|
|
163
|
+
|
|
164
|
+
@Property(bool, constant=True)
|
|
165
|
+
def chartsEnabled(self) -> bool:
|
|
166
|
+
return os.environ.get("QT_QPA_PLATFORM", "").casefold() != "offscreen"
|
|
167
|
+
|
|
168
|
+
@Property(bool, notify=statusChanged)
|
|
169
|
+
def workspaceInitialized(self) -> bool:
|
|
170
|
+
return bool(self._status.get("workspaceInitialized", False))
|
|
171
|
+
|
|
172
|
+
@Property(bool, notify=statusChanged)
|
|
173
|
+
def databaseHealthy(self) -> bool:
|
|
174
|
+
return bool(self._status.get("databaseHealthy", False))
|
|
175
|
+
|
|
176
|
+
@Property(str, notify=statusChanged)
|
|
177
|
+
def indexStatus(self) -> str:
|
|
178
|
+
return str(self._status.get("indexStatus", "not initialized"))
|
|
179
|
+
|
|
180
|
+
@Property(int, notify=statusChanged)
|
|
181
|
+
def indexedCommits(self) -> int:
|
|
182
|
+
return int(self._status.get("indexedCommits", 0))
|
|
183
|
+
|
|
184
|
+
@Property(int, notify=statusChanged)
|
|
185
|
+
def identityCount(self) -> int:
|
|
186
|
+
return int(self._status.get("identities", 0))
|
|
187
|
+
|
|
188
|
+
@Property(int, notify=statusChanged)
|
|
189
|
+
def unresolvedIdentityCount(self) -> int:
|
|
190
|
+
return int(self._status.get("unresolvedIdentities", 0))
|
|
191
|
+
|
|
192
|
+
@Property(int, notify=structuralChanged)
|
|
193
|
+
def structuralBaselineCount(self) -> int:
|
|
194
|
+
return int(self._structural_status().get("baselineCount", 0))
|
|
195
|
+
|
|
196
|
+
@Property(str, notify=structuralChanged)
|
|
197
|
+
def structuralLatestBaselineId(self) -> str:
|
|
198
|
+
return str(self._structural_status().get("latestBaselineId") or "")
|
|
199
|
+
|
|
200
|
+
@Property(int, notify=structuralChanged)
|
|
201
|
+
def structuralProcessedCommits(self) -> int:
|
|
202
|
+
return int(self._structural_status().get("processedCommits", 0))
|
|
203
|
+
|
|
204
|
+
@Property(bool, notify=taskChanged)
|
|
205
|
+
def busy(self) -> bool:
|
|
206
|
+
return bool(self._active_tasks)
|
|
207
|
+
|
|
208
|
+
@Property(str, notify=taskChanged)
|
|
209
|
+
def taskStage(self) -> str:
|
|
210
|
+
return self._task_stage
|
|
211
|
+
|
|
212
|
+
@Property(str, notify=taskChanged)
|
|
213
|
+
def taskMessage(self) -> str:
|
|
214
|
+
return self._task_message
|
|
215
|
+
|
|
216
|
+
@Property(str, notify=errorChanged)
|
|
217
|
+
def errorMessage(self) -> str:
|
|
218
|
+
return self._error_message
|
|
219
|
+
|
|
220
|
+
@Property(str, notify=errorChanged)
|
|
221
|
+
def errorDetail(self) -> str:
|
|
222
|
+
return self._error_detail
|
|
223
|
+
|
|
224
|
+
@Property(str, notify=resultChanged)
|
|
225
|
+
def currentRunId(self) -> str:
|
|
226
|
+
return self._current_run_id
|
|
227
|
+
|
|
228
|
+
@Property(int, notify=resultChanged)
|
|
229
|
+
def completedItems(self) -> int:
|
|
230
|
+
return self._completed_items
|
|
231
|
+
|
|
232
|
+
@Property(int, notify=resultChanged)
|
|
233
|
+
def pendingItems(self) -> int:
|
|
234
|
+
return self._pending_items
|
|
235
|
+
|
|
236
|
+
@Property(str, notify=resultChanged)
|
|
237
|
+
def currentReportJson(self) -> str:
|
|
238
|
+
return self._current_report_json
|
|
239
|
+
|
|
240
|
+
@Property(list, notify=recentChanged)
|
|
241
|
+
def recentRepositories(self) -> list[str]:
|
|
242
|
+
return self._settings.recent_repositories()
|
|
243
|
+
|
|
244
|
+
@Property(QObject, constant=True)
|
|
245
|
+
def peopleModel(self) -> QObject:
|
|
246
|
+
return self._people_model
|
|
247
|
+
|
|
248
|
+
@Property(QObject, constant=True)
|
|
249
|
+
def workItemsModel(self) -> QObject:
|
|
250
|
+
return self._work_items_model
|
|
251
|
+
|
|
252
|
+
@Property(QObject, constant=True)
|
|
253
|
+
def evidenceModel(self) -> QObject:
|
|
254
|
+
return self._evidence_model
|
|
255
|
+
|
|
256
|
+
@Property(QObject, constant=True)
|
|
257
|
+
def runsModel(self) -> QObject:
|
|
258
|
+
return self._runs_model
|
|
259
|
+
|
|
260
|
+
@Property(QObject, constant=True)
|
|
261
|
+
def trendsModel(self) -> QObject:
|
|
262
|
+
return self._trends_model
|
|
263
|
+
|
|
264
|
+
@Property(QObject, constant=True)
|
|
265
|
+
def providersModel(self) -> QObject:
|
|
266
|
+
return self._providers_model
|
|
267
|
+
|
|
268
|
+
@Property(QObject, constant=True)
|
|
269
|
+
def structuralHotspotsModel(self) -> QObject:
|
|
270
|
+
return self._structural_hotspots_model
|
|
271
|
+
|
|
272
|
+
@Property(QObject, constant=True)
|
|
273
|
+
def structuralCouplingsModel(self) -> QObject:
|
|
274
|
+
return self._structural_couplings_model
|
|
275
|
+
|
|
276
|
+
@Property(QObject, constant=True)
|
|
277
|
+
def outcomesModel(self) -> QObject:
|
|
278
|
+
return self._outcomes_model
|
|
279
|
+
|
|
280
|
+
@Property(str, notify=recapChanged)
|
|
281
|
+
def recapMarkdown(self) -> str:
|
|
282
|
+
return self._recap_markdown
|
|
283
|
+
|
|
284
|
+
@Property(str, notify=recapChanged)
|
|
285
|
+
def lastHtmlReportPath(self) -> str:
|
|
286
|
+
return self._last_html_report_path
|
|
287
|
+
|
|
288
|
+
@Slot(str)
|
|
289
|
+
def openRepository(self, value: str) -> None:
|
|
290
|
+
path = self._path_from_value(value)
|
|
291
|
+
self._clear_error()
|
|
292
|
+
self._submit(
|
|
293
|
+
path,
|
|
294
|
+
"open_repository",
|
|
295
|
+
False,
|
|
296
|
+
lambda reporter, token: self._facade.open_repository(path),
|
|
297
|
+
lambda result: self._apply_open_repository(path, result),
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
@Slot()
|
|
301
|
+
def initializeRepository(self) -> None:
|
|
302
|
+
path = self._require_repository()
|
|
303
|
+
if path is None:
|
|
304
|
+
return
|
|
305
|
+
self._submit(
|
|
306
|
+
path,
|
|
307
|
+
"initialize",
|
|
308
|
+
True,
|
|
309
|
+
lambda reporter, token: self._facade.initialize(
|
|
310
|
+
path,
|
|
311
|
+
progress=reporter,
|
|
312
|
+
cancellation=token,
|
|
313
|
+
),
|
|
314
|
+
lambda result: self._apply_status(result, "Workspace initialized"),
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
@Slot()
|
|
318
|
+
def syncRepository(self) -> None:
|
|
319
|
+
self._run_index(False)
|
|
320
|
+
|
|
321
|
+
@Slot()
|
|
322
|
+
def rebuildIndex(self) -> None:
|
|
323
|
+
self._run_index(True)
|
|
324
|
+
|
|
325
|
+
@Slot()
|
|
326
|
+
def runDoctor(self) -> None:
|
|
327
|
+
path = self._require_repository()
|
|
328
|
+
if path is None:
|
|
329
|
+
return
|
|
330
|
+
self._submit(
|
|
331
|
+
path,
|
|
332
|
+
"doctor",
|
|
333
|
+
False,
|
|
334
|
+
lambda reporter, token: self._facade.doctor(path),
|
|
335
|
+
lambda result: self._show_json_result(result, "Doctor completed"),
|
|
336
|
+
)
|
|
337
|
+
|
|
338
|
+
@Slot()
|
|
339
|
+
def refreshStructural(self) -> None:
|
|
340
|
+
path = self._require_repository()
|
|
341
|
+
if path is None or not self.workspaceInitialized:
|
|
342
|
+
return
|
|
343
|
+
self._submit(
|
|
344
|
+
path,
|
|
345
|
+
"structural_status",
|
|
346
|
+
False,
|
|
347
|
+
lambda reporter, token: self._facade.structural_status(path),
|
|
348
|
+
self._apply_structural_status,
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
@Slot("QVariantMap")
|
|
352
|
+
def rebuildStructural(self, values: dict[str, Any]) -> None:
|
|
353
|
+
path = self._require_repository()
|
|
354
|
+
if path is None:
|
|
355
|
+
return
|
|
356
|
+
request = StructuralBaselineRequest(
|
|
357
|
+
repository=path,
|
|
358
|
+
cutoff_text=self._optional_text(values.get("cutoff")),
|
|
359
|
+
branch=self._optional_text(values.get("branch")),
|
|
360
|
+
scope=self._optional_text(values.get("scope")),
|
|
361
|
+
time_strategy=str(values.get("timeStrategy", "lifetime")),
|
|
362
|
+
)
|
|
363
|
+
self._submit(
|
|
364
|
+
path,
|
|
365
|
+
"structural_rebuild",
|
|
366
|
+
True,
|
|
367
|
+
lambda reporter, token: self._facade.rebuild_structural(
|
|
368
|
+
request,
|
|
369
|
+
progress=reporter,
|
|
370
|
+
cancellation=token,
|
|
371
|
+
),
|
|
372
|
+
self._apply_structural_baseline,
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
@Slot(str)
|
|
376
|
+
def showStructural(self, baseline_id: str) -> None:
|
|
377
|
+
path = self._require_repository()
|
|
378
|
+
if path is None:
|
|
379
|
+
return
|
|
380
|
+
target = baseline_id.strip() or str(
|
|
381
|
+
self._structural_status().get("latestBaselineId") or ""
|
|
382
|
+
)
|
|
383
|
+
if not target:
|
|
384
|
+
self.notification.emit("No structural baseline is available")
|
|
385
|
+
return
|
|
386
|
+
self._submit(
|
|
387
|
+
path,
|
|
388
|
+
"structural_show",
|
|
389
|
+
False,
|
|
390
|
+
lambda reporter, token: self._facade.show_structural(path, target),
|
|
391
|
+
self._apply_structural_baseline,
|
|
392
|
+
)
|
|
393
|
+
|
|
394
|
+
@Slot(int)
|
|
395
|
+
def pruneStructural(self, keep: int) -> None:
|
|
396
|
+
path = self._require_repository()
|
|
397
|
+
if path is None:
|
|
398
|
+
return
|
|
399
|
+
self._submit(
|
|
400
|
+
path,
|
|
401
|
+
"structural_prune",
|
|
402
|
+
True,
|
|
403
|
+
lambda reporter, token: self._facade.prune_structural(path, keep=keep),
|
|
404
|
+
self._apply_structural_prune,
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
@Slot()
|
|
408
|
+
def refreshIdentities(self) -> None:
|
|
409
|
+
path = self._require_repository()
|
|
410
|
+
if path is None or not self.workspaceInitialized:
|
|
411
|
+
return
|
|
412
|
+
self._submit(
|
|
413
|
+
path,
|
|
414
|
+
"identities",
|
|
415
|
+
False,
|
|
416
|
+
lambda reporter, token: self._facade.list_identities(path),
|
|
417
|
+
self._apply_identities,
|
|
418
|
+
)
|
|
419
|
+
|
|
420
|
+
@Slot()
|
|
421
|
+
def refreshRuns(self) -> None:
|
|
422
|
+
path = self._require_repository()
|
|
423
|
+
if path is None or not self.workspaceInitialized:
|
|
424
|
+
return
|
|
425
|
+
self._submit(
|
|
426
|
+
path,
|
|
427
|
+
"runs",
|
|
428
|
+
False,
|
|
429
|
+
lambda reporter, token: self._facade.list_runs(path),
|
|
430
|
+
self._apply_runs,
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
@Slot()
|
|
434
|
+
def refreshProviders(self) -> None:
|
|
435
|
+
path = self._require_repository()
|
|
436
|
+
if path is None or not self.workspaceInitialized:
|
|
437
|
+
return
|
|
438
|
+
self._submit(
|
|
439
|
+
path,
|
|
440
|
+
"providers",
|
|
441
|
+
False,
|
|
442
|
+
lambda reporter, token: self._facade.list_providers(path),
|
|
443
|
+
self._apply_providers,
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
@Slot("QVariantMap")
|
|
447
|
+
def runAssessment(self, values: dict[str, Any]) -> None:
|
|
448
|
+
path = self._require_repository()
|
|
449
|
+
if path is None:
|
|
450
|
+
return
|
|
451
|
+
request = AssessmentRequest(
|
|
452
|
+
repository=path,
|
|
453
|
+
person_selectors=tuple(str(item) for item in values.get("persons", [])),
|
|
454
|
+
all_people=bool(values.get("allPeople", False)),
|
|
455
|
+
exclude_selectors=tuple(str(item) for item in values.get("excludePersons", [])),
|
|
456
|
+
rank_by=tuple(str(item) for item in values.get("rankBy", [])),
|
|
457
|
+
since_text=self._optional_text(values.get("since")),
|
|
458
|
+
until_text=self._optional_text(values.get("until")),
|
|
459
|
+
period=self._optional_text(values.get("period")),
|
|
460
|
+
branch=self._optional_text(values.get("branch")),
|
|
461
|
+
release=self._optional_text(values.get("release")),
|
|
462
|
+
scope=self._optional_text(values.get("scope")),
|
|
463
|
+
delivery=self._optional_text(values.get("delivery")),
|
|
464
|
+
time_basis=str(values.get("timeBasis", "authored")),
|
|
465
|
+
use_llm=bool(values.get("useLlm", True)),
|
|
466
|
+
)
|
|
467
|
+
self._submit(
|
|
468
|
+
path,
|
|
469
|
+
"assess",
|
|
470
|
+
True,
|
|
471
|
+
lambda reporter, token: self._facade.assess(
|
|
472
|
+
request,
|
|
473
|
+
progress=reporter,
|
|
474
|
+
cancellation=token,
|
|
475
|
+
),
|
|
476
|
+
self._apply_report,
|
|
477
|
+
)
|
|
478
|
+
|
|
479
|
+
@Slot(str)
|
|
480
|
+
def loadRun(self, run_id: str) -> None:
|
|
481
|
+
path = self._require_repository()
|
|
482
|
+
if path is None:
|
|
483
|
+
return
|
|
484
|
+
self._submit(
|
|
485
|
+
path,
|
|
486
|
+
"load_run",
|
|
487
|
+
False,
|
|
488
|
+
lambda reporter, token: self._facade.get_run(path, run_id),
|
|
489
|
+
self._apply_report,
|
|
490
|
+
)
|
|
491
|
+
|
|
492
|
+
@Slot(str, str)
|
|
493
|
+
def compareRuns(self, base_run_id: str, target_run_id: str) -> None:
|
|
494
|
+
path = self._require_repository()
|
|
495
|
+
if path is None:
|
|
496
|
+
return
|
|
497
|
+
self._submit(
|
|
498
|
+
path,
|
|
499
|
+
"compare_runs",
|
|
500
|
+
False,
|
|
501
|
+
lambda reporter, token: self._facade.compare_runs(path, base_run_id, target_run_id),
|
|
502
|
+
lambda result: self._show_json_result(result, "Run comparison loaded"),
|
|
503
|
+
)
|
|
504
|
+
|
|
505
|
+
@Slot(str, str, str, bool, bool)
|
|
506
|
+
def exportRun(
|
|
507
|
+
self,
|
|
508
|
+
run_id: str,
|
|
509
|
+
report_format: str,
|
|
510
|
+
target_value: str,
|
|
511
|
+
include_email: bool,
|
|
512
|
+
overwrite: bool,
|
|
513
|
+
) -> None:
|
|
514
|
+
path = self._require_repository()
|
|
515
|
+
if path is None:
|
|
516
|
+
return
|
|
517
|
+
request = ExportRequest(
|
|
518
|
+
repository=path,
|
|
519
|
+
run_id=run_id,
|
|
520
|
+
report_format=report_format,
|
|
521
|
+
target=self._path_from_value(target_value),
|
|
522
|
+
include_email=include_email,
|
|
523
|
+
overwrite=overwrite,
|
|
524
|
+
)
|
|
525
|
+
self._submit(
|
|
526
|
+
path,
|
|
527
|
+
"export",
|
|
528
|
+
False,
|
|
529
|
+
lambda reporter, token: self._facade.export_report(request),
|
|
530
|
+
lambda result: self.notification.emit(f"Report written: {result}"),
|
|
531
|
+
)
|
|
532
|
+
|
|
533
|
+
@Slot(str, str, str, str)
|
|
534
|
+
def mapIdentity(
|
|
535
|
+
self,
|
|
536
|
+
name: str,
|
|
537
|
+
email: str,
|
|
538
|
+
person_name: str,
|
|
539
|
+
person_email: str,
|
|
540
|
+
) -> None:
|
|
541
|
+
path = self._require_repository()
|
|
542
|
+
if path is None:
|
|
543
|
+
return
|
|
544
|
+
request = IdentityMapRequest(
|
|
545
|
+
repository=path,
|
|
546
|
+
name=name,
|
|
547
|
+
email=email,
|
|
548
|
+
person_name=person_name,
|
|
549
|
+
person_email=person_email,
|
|
550
|
+
)
|
|
551
|
+
self._submit(
|
|
552
|
+
path,
|
|
553
|
+
"map_identity",
|
|
554
|
+
True,
|
|
555
|
+
lambda reporter, token: self._facade.map_identity(request),
|
|
556
|
+
lambda result: self._identity_changed("Identity mapped"),
|
|
557
|
+
)
|
|
558
|
+
|
|
559
|
+
@Slot(str, str, bool)
|
|
560
|
+
def mergeIdentities(self, sources_text: str, target: str, preview_only: bool) -> None:
|
|
561
|
+
path = self._require_repository()
|
|
562
|
+
if path is None:
|
|
563
|
+
return
|
|
564
|
+
request = IdentityMergeRequest(
|
|
565
|
+
repository=path,
|
|
566
|
+
sources=self._split_values(sources_text),
|
|
567
|
+
target=target.strip(),
|
|
568
|
+
)
|
|
569
|
+
operation_name = "preview_identity_merge" if preview_only else "merge_identities"
|
|
570
|
+
|
|
571
|
+
def operation(reporter: ProgressReporter, token: CancellationToken) -> Any:
|
|
572
|
+
del reporter, token
|
|
573
|
+
if preview_only:
|
|
574
|
+
return self._facade.preview_identity_merge(request)
|
|
575
|
+
return self._facade.merge_identities(request)
|
|
576
|
+
|
|
577
|
+
self._submit(
|
|
578
|
+
path,
|
|
579
|
+
operation_name,
|
|
580
|
+
not preview_only,
|
|
581
|
+
operation,
|
|
582
|
+
lambda result: (
|
|
583
|
+
self._show_json_result(result, "Merge preview loaded")
|
|
584
|
+
if preview_only
|
|
585
|
+
else self._identity_changed("Identities merged")
|
|
586
|
+
),
|
|
587
|
+
)
|
|
588
|
+
|
|
589
|
+
@Slot(str)
|
|
590
|
+
def listIdentityMerges(self, status: str = "ALL") -> None:
|
|
591
|
+
path = self._require_repository()
|
|
592
|
+
if path is None:
|
|
593
|
+
return
|
|
594
|
+
self._submit(
|
|
595
|
+
path,
|
|
596
|
+
"list_identity_merges",
|
|
597
|
+
False,
|
|
598
|
+
lambda reporter, token: self._facade.list_identity_merges(path, status=status),
|
|
599
|
+
lambda result: self._show_json_result(result, "Identity merge history loaded"),
|
|
600
|
+
)
|
|
601
|
+
|
|
602
|
+
@Slot(str)
|
|
603
|
+
def unmergeIdentity(self, merge_id: str) -> None:
|
|
604
|
+
path = self._require_repository()
|
|
605
|
+
if path is None:
|
|
606
|
+
return
|
|
607
|
+
self._submit(
|
|
608
|
+
path,
|
|
609
|
+
"unmerge_identity",
|
|
610
|
+
True,
|
|
611
|
+
lambda reporter, token: self._facade.unmerge_identities(path, merge_id.strip()),
|
|
612
|
+
lambda result: self._identity_changed("Identity merge reverted"),
|
|
613
|
+
)
|
|
614
|
+
|
|
615
|
+
@Slot("QVariantMap")
|
|
616
|
+
def generateResume(self, values: dict[str, Any]) -> None:
|
|
617
|
+
path = self._require_repository()
|
|
618
|
+
if path is None:
|
|
619
|
+
return
|
|
620
|
+
request = ResumeRequest(
|
|
621
|
+
repository=path,
|
|
622
|
+
person_selector=str(values.get("person", "")),
|
|
623
|
+
since_text=self._optional_text(values.get("since")),
|
|
624
|
+
until_text=self._optional_text(values.get("until")),
|
|
625
|
+
target_role=str(values.get("targetRole", "")),
|
|
626
|
+
language=str(values.get("language", "zh-CN")),
|
|
627
|
+
style=str(values.get("style", "concise")),
|
|
628
|
+
max_bullets=int(values.get("maxBullets", 6)),
|
|
629
|
+
include_pending=bool(values.get("includePending", False)),
|
|
630
|
+
use_llm=bool(values.get("useLlm", True)),
|
|
631
|
+
)
|
|
632
|
+
self._submit(
|
|
633
|
+
path,
|
|
634
|
+
"resume",
|
|
635
|
+
True,
|
|
636
|
+
lambda reporter, token: self._facade.generate_resume(request),
|
|
637
|
+
self._apply_report,
|
|
638
|
+
)
|
|
639
|
+
|
|
640
|
+
@Slot("QVariantMap")
|
|
641
|
+
def generateRecap(self, values: dict[str, Any]) -> None:
|
|
642
|
+
path = self._require_repository()
|
|
643
|
+
if path is None:
|
|
644
|
+
return
|
|
645
|
+
person = self._optional_text(values.get("person"))
|
|
646
|
+
window = self._optional_text(values.get("window")) or "7d"
|
|
647
|
+
language = str(values.get("language", "zh-CN"))
|
|
648
|
+
export_html = bool(values.get("exportHtml", False))
|
|
649
|
+
open_html = bool(values.get("openHtml", False))
|
|
650
|
+
|
|
651
|
+
def on_success(result: dict[str, Any]) -> None:
|
|
652
|
+
self._recap_markdown = str(result.get("markdown") or "")
|
|
653
|
+
html_path = str(result.get("htmlPath") or "")
|
|
654
|
+
self._last_html_report_path = html_path
|
|
655
|
+
self.recapChanged.emit()
|
|
656
|
+
if open_html and html_path:
|
|
657
|
+
webbrowser.open(Path(html_path).resolve().as_uri())
|
|
658
|
+
self.notification.emit(
|
|
659
|
+
f"Recap ready ({html_path})" if html_path else "Recap generated"
|
|
660
|
+
)
|
|
661
|
+
|
|
662
|
+
self._submit(
|
|
663
|
+
path,
|
|
664
|
+
"recap",
|
|
665
|
+
False,
|
|
666
|
+
lambda reporter, token: self._facade.generate_recap(
|
|
667
|
+
path,
|
|
668
|
+
person_selector=person,
|
|
669
|
+
window=window,
|
|
670
|
+
language=language,
|
|
671
|
+
export_html=export_html or open_html,
|
|
672
|
+
progress=reporter,
|
|
673
|
+
cancellation=token,
|
|
674
|
+
),
|
|
675
|
+
on_success,
|
|
676
|
+
)
|
|
677
|
+
|
|
678
|
+
@Slot("QVariantMap")
|
|
679
|
+
def generateBrag(self, values: dict[str, Any]) -> None:
|
|
680
|
+
path = self._require_repository()
|
|
681
|
+
if path is None:
|
|
682
|
+
return
|
|
683
|
+
person = self._optional_text(values.get("person"))
|
|
684
|
+
year_text = self._optional_text(values.get("year"))
|
|
685
|
+
year = int(year_text) if year_text and year_text.isdigit() else None
|
|
686
|
+
quarter = self._optional_text(values.get("quarter"))
|
|
687
|
+
language = str(values.get("language", "zh-CN"))
|
|
688
|
+
export_html = bool(values.get("exportHtml", False))
|
|
689
|
+
open_html = bool(values.get("openHtml", False))
|
|
690
|
+
|
|
691
|
+
def on_success(result: dict[str, Any]) -> None:
|
|
692
|
+
self._recap_markdown = str(result.get("markdown") or "")
|
|
693
|
+
html_path = str(result.get("htmlPath") or "")
|
|
694
|
+
self._last_html_report_path = html_path
|
|
695
|
+
self.recapChanged.emit()
|
|
696
|
+
if open_html and html_path:
|
|
697
|
+
webbrowser.open(Path(html_path).resolve().as_uri())
|
|
698
|
+
self.notification.emit(
|
|
699
|
+
f"Brag document ready ({html_path})"
|
|
700
|
+
if html_path
|
|
701
|
+
else "Brag document generated"
|
|
702
|
+
)
|
|
703
|
+
|
|
704
|
+
self._submit(
|
|
705
|
+
path,
|
|
706
|
+
"brag",
|
|
707
|
+
False,
|
|
708
|
+
lambda reporter, token: self._facade.generate_brag(
|
|
709
|
+
path,
|
|
710
|
+
person_selector=person,
|
|
711
|
+
year=year,
|
|
712
|
+
quarter=quarter,
|
|
713
|
+
language=language,
|
|
714
|
+
export_html=export_html or open_html,
|
|
715
|
+
progress=reporter,
|
|
716
|
+
cancellation=token,
|
|
717
|
+
),
|
|
718
|
+
on_success,
|
|
719
|
+
)
|
|
720
|
+
|
|
721
|
+
@Slot()
|
|
722
|
+
def refreshOutcomes(self) -> None:
|
|
723
|
+
path = self._require_repository()
|
|
724
|
+
if path is None:
|
|
725
|
+
return
|
|
726
|
+
|
|
727
|
+
def on_success(result: dict[str, Any]) -> None:
|
|
728
|
+
rows = [
|
|
729
|
+
{
|
|
730
|
+
**item,
|
|
731
|
+
"evidenceSummary": ", ".join(item.get("evidenceIds", [])),
|
|
732
|
+
}
|
|
733
|
+
for item in result.get("outcomes", [])
|
|
734
|
+
]
|
|
735
|
+
self._outcomes_model.set_rows(rows)
|
|
736
|
+
self.outcomesChanged.emit()
|
|
737
|
+
|
|
738
|
+
self._submit(
|
|
739
|
+
path,
|
|
740
|
+
"list_outcomes",
|
|
741
|
+
False,
|
|
742
|
+
lambda reporter, token: self._facade.list_outcomes(path),
|
|
743
|
+
on_success,
|
|
744
|
+
)
|
|
745
|
+
|
|
746
|
+
@Slot("QVariantMap")
|
|
747
|
+
def addOutcome(self, values: dict[str, Any]) -> None:
|
|
748
|
+
path = self._require_repository()
|
|
749
|
+
if path is None:
|
|
750
|
+
return
|
|
751
|
+
evidence_ids = self._split_values(str(values.get("evidenceIds", "")))
|
|
752
|
+
tags = self._split_values(str(values.get("tags", "")))
|
|
753
|
+
verify_ev = bool(values.get("verifyEvidence", True))
|
|
754
|
+
|
|
755
|
+
def on_success(result: dict[str, Any]) -> None:
|
|
756
|
+
added_id = str((result.get("outcome") or {}).get("id") or "")
|
|
757
|
+
self.notification.emit(f"Saved outcome {added_id}")
|
|
758
|
+
self.refreshOutcomes()
|
|
759
|
+
|
|
760
|
+
self._submit(
|
|
761
|
+
path,
|
|
762
|
+
"add_outcome",
|
|
763
|
+
True,
|
|
764
|
+
lambda reporter, token: self._facade.add_outcome(
|
|
765
|
+
path,
|
|
766
|
+
text=str(values.get("text", "")),
|
|
767
|
+
source=str(values.get("source", "")),
|
|
768
|
+
verified_by=str(values.get("verifiedBy", "")),
|
|
769
|
+
verified_at=self._optional_text(values.get("verifiedAt")),
|
|
770
|
+
evidence_ids=evidence_ids,
|
|
771
|
+
tags=tags,
|
|
772
|
+
verify_evidence=verify_ev,
|
|
773
|
+
),
|
|
774
|
+
on_success,
|
|
775
|
+
)
|
|
776
|
+
|
|
777
|
+
@Slot(str)
|
|
778
|
+
def removeOutcome(self, outcome_id: str) -> None:
|
|
779
|
+
path = self._require_repository()
|
|
780
|
+
if path is None:
|
|
781
|
+
return
|
|
782
|
+
|
|
783
|
+
def on_success(result: dict[str, Any]) -> None:
|
|
784
|
+
self.notification.emit(f"Removed outcome {result.get('removedId', '')}")
|
|
785
|
+
self.refreshOutcomes()
|
|
786
|
+
|
|
787
|
+
self._submit(
|
|
788
|
+
path,
|
|
789
|
+
"remove_outcome",
|
|
790
|
+
True,
|
|
791
|
+
lambda reporter, token: self._facade.remove_outcome(path, outcome_id.strip()),
|
|
792
|
+
on_success,
|
|
793
|
+
)
|
|
794
|
+
|
|
795
|
+
@Slot(str)
|
|
796
|
+
def openLocalReport(self, file_path: str) -> None:
|
|
797
|
+
cleaned = file_path.strip()
|
|
798
|
+
if not cleaned:
|
|
799
|
+
return
|
|
800
|
+
target = Path(cleaned).expanduser().resolve()
|
|
801
|
+
if target.is_file():
|
|
802
|
+
webbrowser.open(target.as_uri())
|
|
803
|
+
|
|
804
|
+
@Slot()
|
|
805
|
+
def testProvider(self) -> None:
|
|
806
|
+
path = self._require_repository()
|
|
807
|
+
if path is None:
|
|
808
|
+
return
|
|
809
|
+
self._submit(
|
|
810
|
+
path,
|
|
811
|
+
"test_provider",
|
|
812
|
+
False,
|
|
813
|
+
lambda reporter, token: self._facade.test_provider(path),
|
|
814
|
+
lambda result: self._show_json_result(result, "Provider check completed"),
|
|
815
|
+
)
|
|
816
|
+
|
|
817
|
+
@Slot(str)
|
|
818
|
+
def cancelTask(self, task_id: str = "") -> None:
|
|
819
|
+
target = task_id or next(iter(self._active_tasks), "")
|
|
820
|
+
if target and self._runner.cancel(target):
|
|
821
|
+
self._task_stage = "cancelling"
|
|
822
|
+
self._task_message = "Waiting for a safe cancellation point"
|
|
823
|
+
self.taskChanged.emit()
|
|
824
|
+
|
|
825
|
+
@Slot()
|
|
826
|
+
def clearError(self) -> None:
|
|
827
|
+
self._clear_error()
|
|
828
|
+
|
|
829
|
+
@Slot()
|
|
830
|
+
def clearRecentRepositories(self) -> None:
|
|
831
|
+
self._settings.clear_recent_repositories()
|
|
832
|
+
self.recentChanged.emit()
|
|
833
|
+
|
|
834
|
+
@Slot()
|
|
835
|
+
def shutdown(self) -> None:
|
|
836
|
+
self._runner.cancel_all()
|
|
837
|
+
self._runner.wait_for_done(-1)
|
|
838
|
+
|
|
839
|
+
def _run_index(self, full_rebuild: bool) -> None:
|
|
840
|
+
path = self._require_repository()
|
|
841
|
+
if path is None:
|
|
842
|
+
return
|
|
843
|
+
self._submit(
|
|
844
|
+
path,
|
|
845
|
+
"index" if full_rebuild else "sync",
|
|
846
|
+
True,
|
|
847
|
+
lambda reporter, token: self._facade.index(
|
|
848
|
+
path,
|
|
849
|
+
full_rebuild=full_rebuild,
|
|
850
|
+
progress=reporter,
|
|
851
|
+
cancellation=token,
|
|
852
|
+
),
|
|
853
|
+
lambda result: self._refresh_status("Repository index updated"),
|
|
854
|
+
)
|
|
855
|
+
|
|
856
|
+
def _submit(
|
|
857
|
+
self,
|
|
858
|
+
repository: Path,
|
|
859
|
+
operation_name: str,
|
|
860
|
+
mutates_workspace: bool,
|
|
861
|
+
operation: TaskCallable,
|
|
862
|
+
success: SuccessCallback,
|
|
863
|
+
) -> None:
|
|
864
|
+
self._clear_error()
|
|
865
|
+
task_id = self._runner.submit(
|
|
866
|
+
repository,
|
|
867
|
+
operation_name,
|
|
868
|
+
mutates_workspace=mutates_workspace,
|
|
869
|
+
operation=operation,
|
|
870
|
+
)
|
|
871
|
+
self._callbacks[task_id] = success
|
|
872
|
+
|
|
873
|
+
@Slot(str, str)
|
|
874
|
+
def _task_started(self, task_id: str, operation_name: str) -> None:
|
|
875
|
+
self._active_tasks.add(task_id)
|
|
876
|
+
self._task_stage = operation_name
|
|
877
|
+
self._task_message = operation_name.replace("_", " ").title()
|
|
878
|
+
self.taskChanged.emit()
|
|
879
|
+
|
|
880
|
+
@Slot(str, dict)
|
|
881
|
+
def _task_progress(self, task_id: str, event: dict[str, Any]) -> None:
|
|
882
|
+
if task_id not in self._active_tasks:
|
|
883
|
+
return
|
|
884
|
+
self._task_stage = str(event.get("stage", ""))
|
|
885
|
+
self._task_message = str(event.get("message", ""))
|
|
886
|
+
self.taskChanged.emit()
|
|
887
|
+
|
|
888
|
+
@Slot(str, object)
|
|
889
|
+
def _task_succeeded(self, task_id: str, payload: object) -> None:
|
|
890
|
+
self._active_tasks.discard(task_id)
|
|
891
|
+
callback = self._callbacks.pop(task_id, None)
|
|
892
|
+
if callback is not None:
|
|
893
|
+
callback(payload)
|
|
894
|
+
self._finish_task_state()
|
|
895
|
+
|
|
896
|
+
@Slot(str, object)
|
|
897
|
+
def _task_failed(self, task_id: str, payload: object) -> None:
|
|
898
|
+
self._active_tasks.discard(task_id)
|
|
899
|
+
self._callbacks.pop(task_id, None)
|
|
900
|
+
error = payload if isinstance(payload, Exception) else RuntimeError(str(payload))
|
|
901
|
+
mapped = self._facade.map_error(error)
|
|
902
|
+
self._error_message = f"{mapped.title}: {mapped.message}"
|
|
903
|
+
self._error_detail = mapped.detail
|
|
904
|
+
self.errorChanged.emit()
|
|
905
|
+
self._finish_task_state()
|
|
906
|
+
|
|
907
|
+
@Slot(str)
|
|
908
|
+
def _task_cancelled(self, task_id: str) -> None:
|
|
909
|
+
self._active_tasks.discard(task_id)
|
|
910
|
+
self._callbacks.pop(task_id, None)
|
|
911
|
+
self.notification.emit("Operation cancelled")
|
|
912
|
+
self._finish_task_state()
|
|
913
|
+
|
|
914
|
+
def _finish_task_state(self) -> None:
|
|
915
|
+
if not self._active_tasks:
|
|
916
|
+
self._task_stage = ""
|
|
917
|
+
self._task_message = ""
|
|
918
|
+
self.taskChanged.emit()
|
|
919
|
+
|
|
920
|
+
def _apply_open_repository(self, path: Path, result: Any) -> None:
|
|
921
|
+
self._repository_path = str(path.resolve())
|
|
922
|
+
self._settings.remember_repository(path)
|
|
923
|
+
self._status = dict(result)
|
|
924
|
+
self.repositoryChanged.emit()
|
|
925
|
+
self.statusChanged.emit()
|
|
926
|
+
self.structuralChanged.emit()
|
|
927
|
+
self.recentChanged.emit()
|
|
928
|
+
if self.workspaceInitialized:
|
|
929
|
+
self.refreshIdentities()
|
|
930
|
+
self.refreshRuns()
|
|
931
|
+
self.refreshProviders()
|
|
932
|
+
|
|
933
|
+
def _apply_status(self, result: Any, message: str) -> None:
|
|
934
|
+
self._status = dict(result)
|
|
935
|
+
self.statusChanged.emit()
|
|
936
|
+
self.structuralChanged.emit()
|
|
937
|
+
self.notification.emit(message)
|
|
938
|
+
self.refreshIdentities()
|
|
939
|
+
self.refreshRuns()
|
|
940
|
+
self.refreshProviders()
|
|
941
|
+
|
|
942
|
+
def _refresh_status(self, message: str) -> None:
|
|
943
|
+
path = self._require_repository()
|
|
944
|
+
if path is None:
|
|
945
|
+
return
|
|
946
|
+
self._status = self._facade.status(path)
|
|
947
|
+
self.statusChanged.emit()
|
|
948
|
+
self.structuralChanged.emit()
|
|
949
|
+
self.notification.emit(message)
|
|
950
|
+
self.refreshIdentities()
|
|
951
|
+
|
|
952
|
+
def _apply_identities(self, result: Any) -> None:
|
|
953
|
+
self._people_model.set_rows(list(result.get("persons", [])))
|
|
954
|
+
self._status["identities"] = int(result.get("count", 0))
|
|
955
|
+
self.statusChanged.emit()
|
|
956
|
+
|
|
957
|
+
def _apply_runs(self, result: Any) -> None:
|
|
958
|
+
self._runs_model.set_rows(list(result.get("runs", [])))
|
|
959
|
+
|
|
960
|
+
def _apply_providers(self, result: Any) -> None:
|
|
961
|
+
self._providers_model.set_rows(list(result.get("providers", [])))
|
|
962
|
+
|
|
963
|
+
def _apply_structural_status(self, result: Any) -> None:
|
|
964
|
+
self._status["structural"] = dict(result)
|
|
965
|
+
self.structuralChanged.emit()
|
|
966
|
+
|
|
967
|
+
def _apply_structural_baseline(self, result: Any) -> None:
|
|
968
|
+
data = dict(result)
|
|
969
|
+
materialization = data.get("materialization", {})
|
|
970
|
+
self._structural_hotspots_model.set_rows(list(materialization.get("hotspots", [])))
|
|
971
|
+
self._structural_couplings_model.set_rows(
|
|
972
|
+
list(materialization.get("couplings", []))
|
|
973
|
+
)
|
|
974
|
+
self._current_report_json = json.dumps(data, ensure_ascii=False, indent=2)
|
|
975
|
+
self.resultChanged.emit()
|
|
976
|
+
self.structuralChanged.emit()
|
|
977
|
+
self.notification.emit("Structural observation loaded")
|
|
978
|
+
self.refreshStructural()
|
|
979
|
+
|
|
980
|
+
def _apply_structural_prune(self, result: Any) -> None:
|
|
981
|
+
self._show_json_result(result, "Structural baselines pruned")
|
|
982
|
+
self.refreshStructural()
|
|
983
|
+
|
|
984
|
+
def _apply_report(self, report: Any) -> None:
|
|
985
|
+
data = dict(report)
|
|
986
|
+
run = data.get("run", {})
|
|
987
|
+
self._current_run_id = str(run.get("id", ""))
|
|
988
|
+
workload = data.get("workloadSummary", {})
|
|
989
|
+
self._completed_items = int(workload.get("completedItems", 0))
|
|
990
|
+
self._pending_items = int(workload.get("pendingItems", 0))
|
|
991
|
+
self._work_items_model.set_rows(self._flatten_work_items(data))
|
|
992
|
+
self._evidence_model.set_rows(list(data.get("evidence", [])))
|
|
993
|
+
self._trends_model.set_rows(self._flatten_periods(data))
|
|
994
|
+
self._current_report_json = json.dumps(data, ensure_ascii=False, indent=2)
|
|
995
|
+
self.resultChanged.emit()
|
|
996
|
+
self.notification.emit("Result loaded")
|
|
997
|
+
self.refreshRuns()
|
|
998
|
+
|
|
999
|
+
def _show_json_result(self, result: Any, message: str) -> None:
|
|
1000
|
+
self._current_report_json = json.dumps(result, ensure_ascii=False, indent=2)
|
|
1001
|
+
self.resultChanged.emit()
|
|
1002
|
+
self.notification.emit(message)
|
|
1003
|
+
|
|
1004
|
+
def _identity_changed(self, message: str) -> None:
|
|
1005
|
+
self.notification.emit(message)
|
|
1006
|
+
self.refreshIdentities()
|
|
1007
|
+
|
|
1008
|
+
def _require_repository(self) -> Path | None:
|
|
1009
|
+
if self._repository_path:
|
|
1010
|
+
return Path(self._repository_path)
|
|
1011
|
+
self._error_message = "Open a Git repository first"
|
|
1012
|
+
self._error_detail = ""
|
|
1013
|
+
self.errorChanged.emit()
|
|
1014
|
+
return None
|
|
1015
|
+
|
|
1016
|
+
def _clear_error(self) -> None:
|
|
1017
|
+
if self._error_message or self._error_detail:
|
|
1018
|
+
self._error_message = ""
|
|
1019
|
+
self._error_detail = ""
|
|
1020
|
+
self.errorChanged.emit()
|
|
1021
|
+
|
|
1022
|
+
def _structural_status(self) -> dict[str, Any]:
|
|
1023
|
+
value = self._status.get("structural", {})
|
|
1024
|
+
return value if isinstance(value, dict) else {}
|
|
1025
|
+
|
|
1026
|
+
@staticmethod
|
|
1027
|
+
def _path_from_value(value: str) -> Path:
|
|
1028
|
+
url = QUrl(value)
|
|
1029
|
+
return Path(url.toLocalFile()) if url.isLocalFile() else Path(value)
|
|
1030
|
+
|
|
1031
|
+
@staticmethod
|
|
1032
|
+
def _optional_text(value: Any) -> str | None:
|
|
1033
|
+
text = str(value or "").strip()
|
|
1034
|
+
return text or None
|
|
1035
|
+
|
|
1036
|
+
@staticmethod
|
|
1037
|
+
def _split_values(value: str) -> tuple[str, ...]:
|
|
1038
|
+
return tuple(item.strip() for item in value.split(",") if item.strip())
|
|
1039
|
+
|
|
1040
|
+
@staticmethod
|
|
1041
|
+
def _flatten_work_items(report: dict[str, Any]) -> list[dict[str, Any]]:
|
|
1042
|
+
rows: list[dict[str, Any]] = []
|
|
1043
|
+
for item in report.get("contributionItems", []):
|
|
1044
|
+
row = dict(item)
|
|
1045
|
+
assessment = row.get("assessment", {})
|
|
1046
|
+
if isinstance(assessment, dict):
|
|
1047
|
+
row.setdefault("completion", assessment.get("completion", ""))
|
|
1048
|
+
row.setdefault("size", assessment.get("size", ""))
|
|
1049
|
+
row.setdefault("difficulty", assessment.get("difficulty", ""))
|
|
1050
|
+
rows.append(row)
|
|
1051
|
+
for subject in report.get("subjects", []):
|
|
1052
|
+
person = subject.get("person", {})
|
|
1053
|
+
for assessment in subject.get("itemAssessments", []):
|
|
1054
|
+
size = assessment.get("size", {})
|
|
1055
|
+
difficulty = assessment.get("difficulty", {})
|
|
1056
|
+
item_id = str(assessment.get("contributionItemId", ""))
|
|
1057
|
+
rows.append(
|
|
1058
|
+
{
|
|
1059
|
+
"id": item_id,
|
|
1060
|
+
"title": item_id,
|
|
1061
|
+
"person": person.get("name", ""),
|
|
1062
|
+
"completion": assessment.get("completionBucket", ""),
|
|
1063
|
+
"size": size.get("band", "") if isinstance(size, dict) else size,
|
|
1064
|
+
"difficulty": (
|
|
1065
|
+
difficulty.get("level", "")
|
|
1066
|
+
if isinstance(difficulty, dict)
|
|
1067
|
+
else difficulty
|
|
1068
|
+
),
|
|
1069
|
+
"evidenceIds": assessment.get("evidenceIds", []),
|
|
1070
|
+
}
|
|
1071
|
+
)
|
|
1072
|
+
return rows
|
|
1073
|
+
|
|
1074
|
+
@staticmethod
|
|
1075
|
+
def _flatten_periods(report: dict[str, Any]) -> list[dict[str, Any]]:
|
|
1076
|
+
rows = []
|
|
1077
|
+
for index, period in enumerate(report.get("periods", []), start=1):
|
|
1078
|
+
row = dict(period)
|
|
1079
|
+
row["periodIndex"] = index
|
|
1080
|
+
metrics = period.get("metrics", {})
|
|
1081
|
+
if isinstance(metrics, dict):
|
|
1082
|
+
row.update(metrics)
|
|
1083
|
+
rows.append(row)
|
|
1084
|
+
return rows
|