taskcarry 0.3.2__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.
- taskcarry/__init__.py +3 -0
- taskcarry/__main__.py +4 -0
- taskcarry/adapter_contracts.py +166 -0
- taskcarry/agy_turns.py +282 -0
- taskcarry/api.py +111 -0
- taskcarry/board.py +313 -0
- taskcarry/board_assets/board.css +1087 -0
- taskcarry/board_assets/board.js +1187 -0
- taskcarry/board_assets/browse.js +214 -0
- taskcarry/board_assets/index.html +43 -0
- taskcarry/board_assets/taskcarry-icon.ico +0 -0
- taskcarry/board_assets/taskcarry-mark.svg +28 -0
- taskcarry/board_data.py +466 -0
- taskcarry/chat_joins.py +157 -0
- taskcarry/cli.py +119 -0
- taskcarry/codex_capture.py +184 -0
- taskcarry/codex_host.py +293 -0
- taskcarry/collaboration_exchange.py +316 -0
- taskcarry/connection.py +159 -0
- taskcarry/continuity.py +300 -0
- taskcarry/contracts.py +165 -0
- taskcarry/conversation_capture.py +669 -0
- taskcarry/core.py +896 -0
- taskcarry/cycle_contracts.py +73 -0
- taskcarry/discovery.py +434 -0
- taskcarry/discovery_contracts.py +52 -0
- taskcarry/exchange_contracts.py +67 -0
- taskcarry/exchange_endpoint.py +377 -0
- taskcarry/exchange_packets.py +142 -0
- taskcarry/experience_contracts.py +129 -0
- taskcarry/experience_exchange.py +214 -0
- taskcarry/experience_notes.py +433 -0
- taskcarry/experience_storage.py +125 -0
- taskcarry/experience_tools.py +26 -0
- taskcarry/feishu/__init__.py +1 -0
- taskcarry/feishu/display.py +122 -0
- taskcarry/feishu/project_watch.py +145 -0
- taskcarry/feishu/review_sets.py +80 -0
- taskcarry/feishu/sender.py +42 -0
- taskcarry/feishu/subscription.py +193 -0
- taskcarry/feishu/windows_agent.py +287 -0
- taskcarry/feishu/windows_secret.py +34 -0
- taskcarry/gitops.py +170 -0
- taskcarry/governance.py +88 -0
- taskcarry/governance_cycle.py +775 -0
- taskcarry/identification.py +82 -0
- taskcarry/integration.py +663 -0
- taskcarry/maintenance.py +118 -0
- taskcarry/mcp.py +183 -0
- taskcarry/member_join.py +184 -0
- taskcarry/member_routing.py +145 -0
- taskcarry/onboarding.py +272 -0
- taskcarry/onboarding_complete.py +252 -0
- taskcarry/path_batches.py +19 -0
- taskcarry/preservation.py +257 -0
- taskcarry/project_collaboration.py +453 -0
- taskcarry/project_history.py +166 -0
- taskcarry/project_identity.py +51 -0
- taskcarry/project_recovery.py +824 -0
- taskcarry/recovery_contracts.py +25 -0
- taskcarry/recovery_files.py +153 -0
- taskcarry/recovery_git.py +234 -0
- taskcarry/remote_capture.py +89 -0
- taskcarry/remote_transfer.py +356 -0
- taskcarry/role_connection.py +215 -0
- taskcarry/setup.py +597 -0
- taskcarry/shared_workbench.py +480 -0
- taskcarry/skill_data/taskcarry-experience-recovery/SKILL.md +37 -0
- taskcarry/skill_data/taskcarry-governance-reconcile/SKILL.md +47 -0
- taskcarry/skill_data/taskcarry-governance-reconcile/references/daily-governance.md +72 -0
- taskcarry/skill_data/taskcarry-project-setup/SKILL.md +48 -0
- taskcarry/skill_data/taskcarry-project-setup/references/onboarding.md +198 -0
- taskcarry/skill_data/taskcarry-task-delivery/SKILL.md +32 -0
- taskcarry/skill_data/taskcarry-task-delivery/references/conditional-experience.md +93 -0
- taskcarry/skill_data/taskcarry-task-delivery/references/worker-channel.md +41 -0
- taskcarry/source_review_set.py +80 -0
- taskcarry/state_format.py +47 -0
- taskcarry/store.py +472 -0
- taskcarry/task_context.py +141 -0
- taskcarry/text_handback.py +98 -0
- taskcarry/transfer_contracts.py +18 -0
- taskcarry/updates.py +351 -0
- taskcarry/workbench.py +625 -0
- taskcarry/workbench_contracts.py +32 -0
- taskcarry/workbuddy_capture.py +451 -0
- taskcarry/workbuddy_setup.py +212 -0
- taskcarry/worker_channel.py +859 -0
- taskcarry/worker_contracts.py +190 -0
- taskcarry/worker_storage.py +60 -0
- taskcarry/worker_tools.py +111 -0
- taskcarry-0.3.2.dist-info/METADATA +203 -0
- taskcarry-0.3.2.dist-info/RECORD +105 -0
- taskcarry-0.3.2.dist-info/WHEEL +5 -0
- taskcarry-0.3.2.dist-info/entry_points.txt +5 -0
- taskcarry-0.3.2.dist-info/licenses/LICENSE +21 -0
- taskcarry-0.3.2.dist-info/licenses/LICENSE_SCOPE.md +31 -0
- taskcarry-0.3.2.dist-info/top_level.txt +2 -0
- taskcarry_https/__init__.py +1 -0
- taskcarry_https/consent.py +207 -0
- taskcarry_https/reader.py +132 -0
- taskcarry_https/review.py +116 -0
- taskcarry_https/server.py +163 -0
- taskcarry_https/team.py +335 -0
- taskcarry_https/team_host.py +109 -0
- taskcarry_https/web_host.py +82 -0
taskcarry/board.py
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"""A single-project loopback board. The browser and group reminders have independent lifetimes."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
6
|
+
from importlib import resources
|
|
7
|
+
import json
|
|
8
|
+
import os
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
import secrets
|
|
11
|
+
import shutil
|
|
12
|
+
import sqlite3
|
|
13
|
+
import subprocess
|
|
14
|
+
import threading
|
|
15
|
+
from urllib.parse import parse_qs, urlsplit
|
|
16
|
+
import webbrowser
|
|
17
|
+
|
|
18
|
+
from . import __version__
|
|
19
|
+
from .board_data import BoardData
|
|
20
|
+
from .conversation_capture import Capture
|
|
21
|
+
from .worker_tools import SCHEMAS as WORKER_SCHEMAS
|
|
22
|
+
from .feishu.windows_agent import change_reminders, reminder_status
|
|
23
|
+
from .store import GovernanceError
|
|
24
|
+
from .updates import Updates
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
ASSETS = {"/": ("index.html", "text/html"), "/board.css": ("board.css", "text/css"),
|
|
28
|
+
"/board.js": ("board.js", "text/javascript"), "/browse.js": ("browse.js", "text/javascript"),
|
|
29
|
+
"/taskcarry-mark.svg": ("taskcarry-mark.svg", "image/svg+xml"),
|
|
30
|
+
"/taskcarry-icon.ico": ("taskcarry-icon.ico", "image/vnd.microsoft.icon")}
|
|
31
|
+
CSP = ("default-src 'none'; script-src 'self'; style-src 'self'; connect-src 'self'; "
|
|
32
|
+
"img-src 'self' data:; frame-ancestors 'none'; base-uri 'none'; form-action 'none'")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def routes_status():
|
|
36
|
+
exe = None
|
|
37
|
+
if os.name == "nt" and os.environ.get("ProgramFiles"):
|
|
38
|
+
installed = Path(os.environ["ProgramFiles"]) / "Tailscale" / "tailscale.exe"
|
|
39
|
+
if installed.is_file():
|
|
40
|
+
exe = str(installed)
|
|
41
|
+
exe = exe or shutil.which("tailscale")
|
|
42
|
+
if not exe:
|
|
43
|
+
return {"state": "unavailable"}
|
|
44
|
+
try:
|
|
45
|
+
reply = subprocess.run([exe, "serve", "status", "--json"], stdin=subprocess.DEVNULL, capture_output=True,
|
|
46
|
+
timeout=4, creationflags=getattr(subprocess, "CREATE_NO_WINDOW", 0), check=True)
|
|
47
|
+
if len(reply.stdout) > 256 * 1024:
|
|
48
|
+
return {"state": "unknown"}
|
|
49
|
+
cfg = json.loads(reply.stdout)
|
|
50
|
+
return _https_routes(cfg)
|
|
51
|
+
except subprocess.TimeoutExpired:
|
|
52
|
+
return {"state": "timeout"}
|
|
53
|
+
except (OSError, ValueError, subprocess.SubprocessError):
|
|
54
|
+
return {"state": "unknown"}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _https_routes(cfg):
|
|
58
|
+
# Report node HTTPS settings only. Never return hostnames, proxy targets or credentials.
|
|
59
|
+
if not isinstance(cfg, dict) or not isinstance(cfg.get("Foreground", {}), dict):
|
|
60
|
+
return {"state": "unknown"}
|
|
61
|
+
hosts, public = set(), set()
|
|
62
|
+
for part in (cfg, *cfg.get("Foreground", {}).values()):
|
|
63
|
+
if not isinstance(part, dict):
|
|
64
|
+
return {"state": "unknown"}
|
|
65
|
+
tcp, web, funnel = (part.get(key, {}) for key in ("TCP", "Web", "AllowFunnel"))
|
|
66
|
+
if not all(isinstance(value, dict) for value in (tcp, web, funnel)):
|
|
67
|
+
return {"state": "unknown"}
|
|
68
|
+
for host, site in web.items():
|
|
69
|
+
port = host.rpartition(":")[2]
|
|
70
|
+
handler = tcp.get(port)
|
|
71
|
+
if not isinstance(handler, dict) or not isinstance(site, dict):
|
|
72
|
+
return {"state": "unknown"}
|
|
73
|
+
if handler.get("HTTPS") is True and site.get("Handlers"):
|
|
74
|
+
hosts.add(host)
|
|
75
|
+
public.update(host for host, allowed in funnel.items() if allowed is True)
|
|
76
|
+
return {"state": "checked", "serve": bool(hosts - public), "funnel": bool(hosts & public)}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class BoardServer(ThreadingHTTPServer):
|
|
80
|
+
daemon_threads = True
|
|
81
|
+
|
|
82
|
+
def __init__(self, project, *, settings_enabled=True):
|
|
83
|
+
self.data = BoardData(project)
|
|
84
|
+
self.key = secrets.token_urlsafe(32)
|
|
85
|
+
self.settings_enabled = settings_enabled
|
|
86
|
+
self.settings_lock = threading.Lock()
|
|
87
|
+
self._database = None
|
|
88
|
+
super().__init__(("127.0.0.1", 0), BoardHandler)
|
|
89
|
+
try:
|
|
90
|
+
# Keep SQLite's WAL open between page requests. Closing the last
|
|
91
|
+
# reader can otherwise race a worker opening the same database.
|
|
92
|
+
# Autocommit leaves no snapshot or read lock between requests.
|
|
93
|
+
self._database = sqlite3.connect(self.data.store.path.as_uri() + "?mode=ro", uri=True,
|
|
94
|
+
isolation_level=None, check_same_thread=False)
|
|
95
|
+
self._database.execute("SELECT 1 FROM records LIMIT 1").fetchall()
|
|
96
|
+
except sqlite3.Error:
|
|
97
|
+
self.server_close()
|
|
98
|
+
raise
|
|
99
|
+
self.authority = "127.0.0.1:" + str(self.server_port)
|
|
100
|
+
self.origin = "http://" + self.authority
|
|
101
|
+
|
|
102
|
+
def server_close(self):
|
|
103
|
+
try:
|
|
104
|
+
super().server_close()
|
|
105
|
+
finally:
|
|
106
|
+
if self._database is not None:
|
|
107
|
+
self._database.close()
|
|
108
|
+
self._database = None
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def url(self):
|
|
112
|
+
# The fragment is read in the browser and removed from its address bar.
|
|
113
|
+
return self.origin + "/#" + self.key
|
|
114
|
+
|
|
115
|
+
def update_reminders(self, action, url, secret):
|
|
116
|
+
return change_reminders(self.data.store.root, action, url, secret)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class BoardHandler(BaseHTTPRequestHandler):
|
|
120
|
+
server_version = "TaskCarry"
|
|
121
|
+
sys_version = ""
|
|
122
|
+
|
|
123
|
+
def setup(self):
|
|
124
|
+
super().setup()
|
|
125
|
+
self.connection.settimeout(8)
|
|
126
|
+
|
|
127
|
+
def log_message(self, *args):
|
|
128
|
+
pass
|
|
129
|
+
|
|
130
|
+
def send_data(self, status, data, mime="application/json"):
|
|
131
|
+
if mime == "application/json":
|
|
132
|
+
data = json.dumps(data, ensure_ascii=False, separators=(",", ":")).encode("utf-8")
|
|
133
|
+
self.send_response(status)
|
|
134
|
+
self.send_header("Content-Type", mime if mime.startswith("image/") else mime + "; charset=utf-8")
|
|
135
|
+
self.send_header("Content-Length", str(len(data)))
|
|
136
|
+
self.send_header("Cache-Control", "no-store")
|
|
137
|
+
self.send_header("Content-Security-Policy", CSP)
|
|
138
|
+
self.send_header("X-Content-Type-Options", "nosniff")
|
|
139
|
+
self.send_header("Referrer-Policy", "no-referrer")
|
|
140
|
+
self.end_headers()
|
|
141
|
+
try:
|
|
142
|
+
self.wfile.write(data)
|
|
143
|
+
except (BrokenPipeError, ConnectionResetError, ConnectionAbortedError):
|
|
144
|
+
pass
|
|
145
|
+
|
|
146
|
+
def allowed(self, *, session=False, write=False):
|
|
147
|
+
if self.headers.get_all("Host") != [self.server.authority]:
|
|
148
|
+
return False
|
|
149
|
+
if self.headers.get("Sec-Fetch-Site") == "cross-site" and (session or write):
|
|
150
|
+
return False
|
|
151
|
+
origin = self.headers.get("Origin")
|
|
152
|
+
if (write or origin is not None) and origin != self.server.origin:
|
|
153
|
+
return False
|
|
154
|
+
token = self.headers.get("X-TaskCarry-Board", "")
|
|
155
|
+
return not session or (token.isascii() and secrets.compare_digest(self.server.key, token))
|
|
156
|
+
|
|
157
|
+
def do_GET(self):
|
|
158
|
+
route = urlsplit(self.path)
|
|
159
|
+
if not self.allowed(session=route.path not in ASSETS):
|
|
160
|
+
return self.send_data(403, {"error": "access"})
|
|
161
|
+
if route.path in ASSETS:
|
|
162
|
+
file, mime = ASSETS[route.path]
|
|
163
|
+
return self.send_data(200, resources.files("taskcarry").joinpath("board_assets", file).read_bytes(), mime)
|
|
164
|
+
data = self.server.data
|
|
165
|
+
try:
|
|
166
|
+
params = {k: v[0] for k,v in parse_qs(route.query, max_num_fields=8, strict_parsing=True).items()}
|
|
167
|
+
if route.path == "/api/board" and not params:
|
|
168
|
+
result = data.brief()
|
|
169
|
+
result.update(settings_enabled=self.server.settings_enabled and not result["standby"], runtime_version=__version__)
|
|
170
|
+
elif route.path == "/api/page" and {"section", "page", "stamp"} <= set(params) <= {"section", "page", "stamp", "query", "owner", "state"}:
|
|
171
|
+
result = data.brief(params["section"], int(params["page"]), int(params["stamp"]),
|
|
172
|
+
query=params.get("query", ""), owner=params.get("owner", ""), state=params.get("state", ""))
|
|
173
|
+
elif route.path == "/api/history" and set(params) == {"id", "rev", "sha", "page", "stamp"}:
|
|
174
|
+
result = data.history({"reference_id": params["id"], "revision": int(params["rev"]),
|
|
175
|
+
"content_sha256": params["sha"]}, int(params["page"]), int(params["stamp"]))
|
|
176
|
+
elif route.path == "/api/source" and set(params) == {"id", "rev", "sha", "offset"}:
|
|
177
|
+
result = data.preview({"reference_id": params["id"], "revision": int(params["rev"]),
|
|
178
|
+
"content_sha256": params["sha"]}, int(params["offset"]))
|
|
179
|
+
elif route.path == "/api/reminders" and not params:
|
|
180
|
+
with data.snapshot():
|
|
181
|
+
pass
|
|
182
|
+
result = reminder_status(data.store.root)
|
|
183
|
+
elif route.path in ("/api/project_overview", "/api/project_history"):
|
|
184
|
+
method = route.path.rsplit("/", 1)[-1]
|
|
185
|
+
fields = WORKER_SCHEMAS[method]["properties"]
|
|
186
|
+
if set(params) - set(fields) or any(k not in params for k in WORKER_SCHEMAS[method].get("required", [])):
|
|
187
|
+
raise ValueError("Unexpected query arguments")
|
|
188
|
+
for k, v in list(params.items()):
|
|
189
|
+
rule = fields[k]
|
|
190
|
+
if rule.get("type") == "integer":
|
|
191
|
+
params[k] = int(v)
|
|
192
|
+
if not rule.get("minimum", 0) <= params[k] <= rule.get("maximum", 2**31-1):
|
|
193
|
+
raise ValueError("Invalid page")
|
|
194
|
+
elif "enum" in rule and v not in rule["enum"]:
|
|
195
|
+
raise ValueError("Invalid filter")
|
|
196
|
+
result = data.channel.invoke(method, params)
|
|
197
|
+
elif route.path == "/api/capture" and not params and self.server.settings_enabled:
|
|
198
|
+
result = Capture(data.store.root).options()
|
|
199
|
+
else:
|
|
200
|
+
return self.send_data(404, {"error": "missing"})
|
|
201
|
+
self.send_data(200, result)
|
|
202
|
+
except GovernanceError as exc:
|
|
203
|
+
self.send_data(409, {"error": exc.code})
|
|
204
|
+
except (ValueError, TypeError):
|
|
205
|
+
self.send_data(400, {"error": "invalid"})
|
|
206
|
+
except (sqlite3.Error, OSError):
|
|
207
|
+
self.send_data(503, {"error": "unavailable"})
|
|
208
|
+
|
|
209
|
+
def do_POST(self):
|
|
210
|
+
if not self.allowed(session=True, write=True):
|
|
211
|
+
return self.send_data(403, {"error": "access"})
|
|
212
|
+
if self.headers.get_content_type() != "application/json":
|
|
213
|
+
return self.send_data(415, {"error": "format"})
|
|
214
|
+
try:
|
|
215
|
+
length = int(self.headers.get("Content-Length", "-1"))
|
|
216
|
+
if not 2 <= length <= 8192:
|
|
217
|
+
return self.send_data(413, {"error": "size"})
|
|
218
|
+
body = json.loads(self.rfile.read(length))
|
|
219
|
+
if not isinstance(body, dict):
|
|
220
|
+
raise ValueError("Expected object")
|
|
221
|
+
project = self.server.data
|
|
222
|
+
with project.snapshot() as (_, cfg):
|
|
223
|
+
active = cfg.get("recovery_writer_state", "active") == "active"
|
|
224
|
+
if self.path == "/api/reminders" and self.server.settings_enabled and active:
|
|
225
|
+
action = body.get("action")
|
|
226
|
+
form = {"action", "url", "secret"} if action == "enable" else {"action"}
|
|
227
|
+
if set(body) != form or not all(isinstance(v, str) for v in body.values()):
|
|
228
|
+
raise ValueError("Invalid settings")
|
|
229
|
+
with self.server.settings_lock:
|
|
230
|
+
result = self.server.update_reminders(action, body.get("url", "").strip(), body.get("secret", ""))
|
|
231
|
+
elif self.path == "/api/capture" and self.server.settings_enabled and active:
|
|
232
|
+
fields = {"conversation_id", "action", "generation"}
|
|
233
|
+
if (set(body) not in (fields, fields | {"owner"}) or type(body["generation"]) is not int
|
|
234
|
+
or not all(isinstance(body[k], str) and body[k] for k in body if k != "generation")):
|
|
235
|
+
raise ValueError("Invalid conversation setting")
|
|
236
|
+
with self.server.settings_lock:
|
|
237
|
+
result = Capture(project.store.root).change(body["conversation_id"], body["action"],
|
|
238
|
+
body["generation"], body.get("owner"))
|
|
239
|
+
elif self.path == "/api/discussion-notices" and self.server.settings_enabled and active and os.name == "nt":
|
|
240
|
+
from .feishu.project_watch import ProjectWatch
|
|
241
|
+
from .feishu.windows_agent import local_dir
|
|
242
|
+
if set(body) != {"mode"} or body["mode"] not in ("off","mentions","all"):
|
|
243
|
+
raise ValueError("Invalid group preference")
|
|
244
|
+
path = local_dir(project.store.root) / "subscription.sqlite3"
|
|
245
|
+
if not path.is_file():
|
|
246
|
+
raise ValueError("Configure this project's robot first")
|
|
247
|
+
with self.server.settings_lock:
|
|
248
|
+
watch = ProjectWatch(path)
|
|
249
|
+
cfg = watch.settings()
|
|
250
|
+
if not cfg or not cfg["sealed"] or cfg["project"] != project.project_id:
|
|
251
|
+
raise ValueError("Select the configured group")
|
|
252
|
+
watch.collect(project.store.root)
|
|
253
|
+
result = {"mode":watch.discussion_mode(cfg["sealed"],body["mode"])}
|
|
254
|
+
elif self.path == "/api/routes" and not body:
|
|
255
|
+
result = routes_status()
|
|
256
|
+
elif self.path == "/api/release" and not body:
|
|
257
|
+
report = Updates(project.store.root).check_running_release()
|
|
258
|
+
candidate = report.get("candidate") or {}
|
|
259
|
+
result = {"state": report["status"], "version": candidate.get("version"),
|
|
260
|
+
"confirmed": report.get("latest_verified", False), "checked_at": report["checked_at"],
|
|
261
|
+
"url": candidate.get("release_url") if candidate.get("identity_verified") else None}
|
|
262
|
+
elif self.path == "/api/close" and not body:
|
|
263
|
+
self.send_data(200, {"closed": True})
|
|
264
|
+
threading.Thread(target=self.server.shutdown, daemon=True).start()
|
|
265
|
+
return
|
|
266
|
+
else:
|
|
267
|
+
return self.send_data(403, {"error": "unavailable"})
|
|
268
|
+
self.send_data(200, result)
|
|
269
|
+
except GovernanceError as exc:
|
|
270
|
+
self.send_data(409, {"error": exc.code})
|
|
271
|
+
except (ValueError, TypeError):
|
|
272
|
+
self.send_data(400, {"error": "invalid"})
|
|
273
|
+
except (sqlite3.Error, OSError, RuntimeError):
|
|
274
|
+
self.send_data(503, {"error": "unavailable"})
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def serve(project, *, open_browser=False, settings_enabled=True):
|
|
278
|
+
with BoardServer(project, settings_enabled=settings_enabled) as server:
|
|
279
|
+
config = server.data.store.get('config', 'project')
|
|
280
|
+
if settings_enabled and config.get('recovery_writer_state', 'active') == 'active':
|
|
281
|
+
Capture(server.data.store.root).resume_readers()
|
|
282
|
+
if open_browser:
|
|
283
|
+
# Some browser launchers wait for the first page to finish loading.
|
|
284
|
+
threading.Thread(target=webbrowser.open, args=(server.url,), daemon=True).start()
|
|
285
|
+
if os.isatty(1) or not open_browser:
|
|
286
|
+
print(server.url, flush=True)
|
|
287
|
+
try:
|
|
288
|
+
server.serve_forever()
|
|
289
|
+
except KeyboardInterrupt:
|
|
290
|
+
pass
|
|
291
|
+
return 0
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
def launch(argv=None):
|
|
295
|
+
"""Desktop entry point. A shortcut may supply the existing project directory."""
|
|
296
|
+
parser = argparse.ArgumentParser(description="Open a local TaskCarry project board")
|
|
297
|
+
parser.add_argument("project", nargs="?", type=Path)
|
|
298
|
+
parser.add_argument("--view-only", action="store_true")
|
|
299
|
+
args = parser.parse_args(argv)
|
|
300
|
+
project = args.project
|
|
301
|
+
if project is None:
|
|
302
|
+
from tkinter import filedialog
|
|
303
|
+
selected = filedialog.askdirectory(title="选择已有 TaskCarry 项目的治理目录", mustexist=True)
|
|
304
|
+
if not selected:
|
|
305
|
+
return 0
|
|
306
|
+
project = Path(selected)
|
|
307
|
+
try:
|
|
308
|
+
return serve(project, open_browser=True, settings_enabled=not args.view_only)
|
|
309
|
+
except (GovernanceError, OSError, sqlite3.Error):
|
|
310
|
+
from tkinter import messagebox
|
|
311
|
+
messagebox.showerror("TaskCarry", "无法打开项目看板。请选择已有 TaskCarry 项目的治理目录。")
|
|
312
|
+
return 1
|
|
313
|
+
|