robert-github-agent 0.1.0b1__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.
- robert_agent/__init__.py +1 -0
- robert_agent/acceptance.py +394 -0
- robert_agent/acceptance_suite.py +287 -0
- robert_agent/audit_result.py +501 -0
- robert_agent/authorize.py +117 -0
- robert_agent/board.py +538 -0
- robert_agent/chat_status.py +338 -0
- robert_agent/cli/__init__.py +1 -0
- robert_agent/cli/exit_codes.py +5 -0
- robert_agent/cli/main.py +535 -0
- robert_agent/cli/output.py +20 -0
- robert_agent/common.py +6 -0
- robert_agent/controlled_e2e_acceptance.py +394 -0
- robert_agent/daemon.py +607 -0
- robert_agent/daemon_state.py +319 -0
- robert_agent/diagnostics.py +119 -0
- robert_agent/discover.py +775 -0
- robert_agent/dispatch.py +217 -0
- robert_agent/doctor.py +94 -0
- robert_agent/github_api.py +12 -0
- robert_agent/init_config.py +126 -0
- robert_agent/integrations/__init__.py +1 -0
- robert_agent/integrations/openclaw.py +285 -0
- robert_agent/live_discovery_acceptance.py +70 -0
- robert_agent/live_worker_acceptance.py +363 -0
- robert_agent/live_worktree_acceptance.py +344 -0
- robert_agent/loop_engine.py +285 -0
- robert_agent/memory_curator.py +105 -0
- robert_agent/migrate.py +157 -0
- robert_agent/notify.py +74 -0
- robert_agent/paths.py +16 -0
- robert_agent/production_write_canary.py +254 -0
- robert_agent/project_memory.py +503 -0
- robert_agent/publish.py +743 -0
- robert_agent/publish_dedupe_acceptance.py +270 -0
- robert_agent/redaction.py +41 -0
- robert_agent/render_prompt.py +544 -0
- robert_agent/resource_files.py +8 -0
- robert_agent/resources/__init__.py +1 -0
- robert_agent/resources/acceptance-matrix.md +120 -0
- robert_agent/resources/classifier.md +19 -0
- robert_agent/resources/command-matrix.md +38 -0
- robert_agent/resources/config.example.yml +20 -0
- robert_agent/resources/db/migrations/001_legacy_dd_to_robert.sql +14 -0
- robert_agent/resources/db/schema.sql +479 -0
- robert_agent/resources/failure-modes.md +36 -0
- robert_agent/resources/fixtures/actor-permission.json +1 -0
- robert_agent/resources/fixtures/discovery.json +1 -0
- robert_agent/resources/fixtures/redaction.json +1 -0
- robert_agent/resources/fixtures/review-followup.json +1 -0
- robert_agent/resources/fixtures/worker-results.json +1 -0
- robert_agent/resources/fixtures/workstreams.json +1 -0
- robert_agent/resources/github-events.md +77 -0
- robert_agent/resources/kanban-control.md +165 -0
- robert_agent/resources/redaction.md +29 -0
- robert_agent/resources/result-contract.md +56 -0
- robert_agent/resources/routes.yml +82 -0
- robert_agent/resources/schemas/config.schema.json +123 -0
- robert_agent/resources/schemas/event.schema.json +18 -0
- robert_agent/resources/schemas/result.schema.json +99 -0
- robert_agent/resources/schemas/route.schema.json +23 -0
- robert_agent/resources/schemas/snapshot.schema.json +17 -0
- robert_agent/resources/schemas/task.schema.json +15 -0
- robert_agent/resources/trust-model.md +16 -0
- robert_agent/resources/worker-prompt.md +121 -0
- robert_agent/resources/worker-protocol.md +47 -0
- robert_agent/resources/workflow.yml +50 -0
- robert_agent/resources/workstream-model.md +17 -0
- robert_agent/route.py +232 -0
- robert_agent/route_config.py +64 -0
- robert_agent/run_once.py +5375 -0
- robert_agent/runtime_knowledge.py +392 -0
- robert_agent/service.py +161 -0
- robert_agent/skills.py +28 -0
- robert_agent/status.py +1051 -0
- robert_agent/storage.py +376 -0
- robert_agent/summarize.py +100 -0
- robert_agent/supervise.py +72 -0
- robert_agent/usage.py +192 -0
- robert_agent/validate_config.py +616 -0
- robert_agent/wakeup.py +261 -0
- robert_agent/web.py +2893 -0
- robert_agent/web_assets/board.css +255 -0
- robert_agent/web_assets/board.html +165 -0
- robert_agent/web_assets/board.js +660 -0
- robert_agent/web_assets/github-shell.css +122 -0
- robert_agent/web_assets/index.html +103 -0
- robert_agent/web_assets/operations.css +168 -0
- robert_agent/web_assets/workbench.css +131 -0
- robert_agent/web_assets/workbench.js +581 -0
- robert_agent/work_items.py +1016 -0
- robert_agent/workbench.py +701 -0
- robert_agent/worker/__init__.py +1 -0
- robert_agent/worker/heartbeat.py +190 -0
- robert_agent/worker/result.py +321 -0
- robert_agent/worker/snapshot.py +98 -0
- robert_agent/worker_adapters/__init__.py +138 -0
- robert_agent/worker_adapters/cbc.py +68 -0
- robert_agent/worker_adapters/codex.py +56 -0
- robert_agent/worker_adapters/command.py +33 -0
- robert_agent/worker_adapters/tcodex.py +56 -0
- robert_agent/worker_heartbeat.py +6 -0
- robert_agent/worker_result.py +6 -0
- robert_agent/worker_snapshot.py +6 -0
- robert_agent/workstream.py +55 -0
- robert_agent/worktree.py +297 -0
- robert_github_agent-0.1.0b1.dist-info/METADATA +217 -0
- robert_github_agent-0.1.0b1.dist-info/RECORD +111 -0
- robert_github_agent-0.1.0b1.dist-info/WHEEL +4 -0
- robert_github_agent-0.1.0b1.dist-info/entry_points.txt +2 -0
- robert_github_agent-0.1.0b1.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import argparse
|
|
3
|
+
from contextlib import closing
|
|
4
|
+
import json
|
|
5
|
+
import re
|
|
6
|
+
import sqlite3
|
|
7
|
+
import subprocess
|
|
8
|
+
import tempfile
|
|
9
|
+
from datetime import datetime, timezone
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from urllib.parse import urlparse
|
|
12
|
+
from uuid import uuid4
|
|
13
|
+
|
|
14
|
+
from robert_agent.common import emit
|
|
15
|
+
from robert_agent import storage
|
|
16
|
+
from robert_agent import publish
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
TARGET_RE = re.compile(r"^/([^/]+)/([^/]+)/(issues|pull)/([0-9]+)(?:/)?$")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _now():
|
|
23
|
+
return datetime.now(timezone.utc).isoformat()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _workspace_dir(workspace_dir):
|
|
27
|
+
if workspace_dir:
|
|
28
|
+
path = Path(workspace_dir).expanduser().resolve()
|
|
29
|
+
path.mkdir(parents=True, exist_ok=True)
|
|
30
|
+
return path
|
|
31
|
+
return Path(tempfile.mkdtemp(prefix="dd-production-write-canary-")).resolve()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _parse_target_url(target_url):
|
|
35
|
+
parsed = urlparse(target_url or "")
|
|
36
|
+
if parsed.scheme != "https" or parsed.netloc != "github.com":
|
|
37
|
+
return None
|
|
38
|
+
match = TARGET_RE.match(parsed.path)
|
|
39
|
+
if not match:
|
|
40
|
+
return None
|
|
41
|
+
owner, repo, source_type, number = match.groups()
|
|
42
|
+
full_name = f"{owner}/{repo}"
|
|
43
|
+
source_kind = "issue" if source_type == "issues" else "pull_request"
|
|
44
|
+
source_key = f"github:{full_name}{'#' if source_kind == 'issue' else '!'}{number}"
|
|
45
|
+
return {
|
|
46
|
+
"repo": full_name,
|
|
47
|
+
"source_type": source_kind,
|
|
48
|
+
"number": int(number),
|
|
49
|
+
"source_key": source_key,
|
|
50
|
+
"html_url": f"https://github.com/{full_name}/{source_type}/{number}",
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def comment_body(marker_id):
|
|
55
|
+
return (
|
|
56
|
+
"<!-- robert-comment task_id=task-production-canary "
|
|
57
|
+
"attempt_id=attempt-production-canary "
|
|
58
|
+
f"event_fingerprints=production-canary:{marker_id} -->\n"
|
|
59
|
+
"Robert production write canary.\n\n"
|
|
60
|
+
"This comment verifies that the configured publisher can create or "
|
|
61
|
+
"deduplicate one GitHub issue/PR comment through the audited action path."
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _insert_canary_fixture(db_path, target, marker_id):
|
|
66
|
+
storage.init_database(db_path)
|
|
67
|
+
now = _now()
|
|
68
|
+
body = comment_body(marker_id)
|
|
69
|
+
with closing(sqlite3.connect(db_path)) as conn, conn:
|
|
70
|
+
conn.execute(
|
|
71
|
+
"""
|
|
72
|
+
INSERT INTO repos(repo_id, full_name, github_account, default_base_branch, repo_root, worktree_root)
|
|
73
|
+
VALUES ('repo-production-canary', ?, 'robert', 'main', '', '')
|
|
74
|
+
""",
|
|
75
|
+
(target["repo"],),
|
|
76
|
+
)
|
|
77
|
+
conn.execute(
|
|
78
|
+
"""
|
|
79
|
+
INSERT INTO github_sources(source_id, repo_id, source_key, source_type, number, html_url)
|
|
80
|
+
VALUES ('source-production-canary', 'repo-production-canary', ?, ?, ?, ?)
|
|
81
|
+
""",
|
|
82
|
+
(target["source_key"], target["source_type"], target["number"], target["html_url"]),
|
|
83
|
+
)
|
|
84
|
+
conn.execute(
|
|
85
|
+
"""
|
|
86
|
+
INSERT INTO workstreams(workstream_id, repo_id, primary_source_id, lifecycle, created_at, updated_at)
|
|
87
|
+
VALUES (?, 'repo-production-canary', 'source-production-canary', 'completed', ?, ?)
|
|
88
|
+
""",
|
|
89
|
+
(target["source_key"], now, now),
|
|
90
|
+
)
|
|
91
|
+
conn.execute(
|
|
92
|
+
"""
|
|
93
|
+
INSERT INTO workstream_sources(workstream_id, source_id, relationship, created_at)
|
|
94
|
+
VALUES (?, 'source-production-canary', 'primary', ?)
|
|
95
|
+
""",
|
|
96
|
+
(target["source_key"], now),
|
|
97
|
+
)
|
|
98
|
+
conn.execute(
|
|
99
|
+
"""
|
|
100
|
+
INSERT INTO tasks(task_id, workstream_id, lifecycle, priority, route_id, expected_output, created_at, updated_at)
|
|
101
|
+
VALUES (
|
|
102
|
+
'task-production-canary', ?, 'completed', 'P2',
|
|
103
|
+
'production-write-canary', 'comment_analysis', ?, ?
|
|
104
|
+
)
|
|
105
|
+
""",
|
|
106
|
+
(target["source_key"], now, now),
|
|
107
|
+
)
|
|
108
|
+
conn.execute(
|
|
109
|
+
"""
|
|
110
|
+
INSERT INTO attempts(attempt_id, task_id, attempt_no, status, started_at, heartbeat_at, finished_at)
|
|
111
|
+
VALUES (
|
|
112
|
+
'attempt-production-canary', 'task-production-canary', 1,
|
|
113
|
+
'completed', ?, ?, ?
|
|
114
|
+
)
|
|
115
|
+
""",
|
|
116
|
+
(now, now, now),
|
|
117
|
+
)
|
|
118
|
+
conn.execute(
|
|
119
|
+
"""
|
|
120
|
+
INSERT INTO worker_results(
|
|
121
|
+
result_id, task_id, attempt_id, output_type,
|
|
122
|
+
consumed_event_fingerprints_json, verification_json, handoff,
|
|
123
|
+
created_at, metadata_json
|
|
124
|
+
)
|
|
125
|
+
VALUES (
|
|
126
|
+
'result-production-canary', 'task-production-canary',
|
|
127
|
+
'attempt-production-canary', 'comment_analysis',
|
|
128
|
+
?, '[]', 'production write canary', ?, '{}'
|
|
129
|
+
)
|
|
130
|
+
""",
|
|
131
|
+
(json.dumps([f"production-canary:{marker_id}"]), now),
|
|
132
|
+
)
|
|
133
|
+
conn.execute(
|
|
134
|
+
"""
|
|
135
|
+
INSERT INTO github_actions(
|
|
136
|
+
action_id, result_id, task_id, action_type, target_url,
|
|
137
|
+
audit_status, publish_status, created_at, metadata_json
|
|
138
|
+
)
|
|
139
|
+
VALUES (
|
|
140
|
+
'action-production-canary', 'result-production-canary',
|
|
141
|
+
'task-production-canary', 'comment', ?,
|
|
142
|
+
'accepted', 'not_published', ?, ?
|
|
143
|
+
)
|
|
144
|
+
""",
|
|
145
|
+
(
|
|
146
|
+
target["html_url"],
|
|
147
|
+
now,
|
|
148
|
+
json.dumps({"body": body, "marker_id": marker_id}, sort_keys=True),
|
|
149
|
+
),
|
|
150
|
+
)
|
|
151
|
+
return body
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def _action_state(db_path):
|
|
155
|
+
with closing(sqlite3.connect(db_path)) as conn:
|
|
156
|
+
row = conn.execute(
|
|
157
|
+
"""
|
|
158
|
+
SELECT publish_status, external_id, target_url, metadata_json
|
|
159
|
+
FROM github_actions
|
|
160
|
+
WHERE action_id = 'action-production-canary'
|
|
161
|
+
"""
|
|
162
|
+
).fetchone()
|
|
163
|
+
if not row:
|
|
164
|
+
return {}
|
|
165
|
+
metadata = json.loads(row[3] or "{}")
|
|
166
|
+
return {
|
|
167
|
+
"publish_status": row[0],
|
|
168
|
+
"external_id": row[1] or "",
|
|
169
|
+
"target_url": row[2] or "",
|
|
170
|
+
"deduplicated": bool((metadata.get("publish") or {}).get("deduplicated")),
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def production_write_canary(
|
|
175
|
+
target_url,
|
|
176
|
+
workspace_dir=None,
|
|
177
|
+
marker_id=None,
|
|
178
|
+
confirm_github_write=False,
|
|
179
|
+
run_command=subprocess.run,
|
|
180
|
+
):
|
|
181
|
+
target = _parse_target_url(target_url)
|
|
182
|
+
if not target:
|
|
183
|
+
return {
|
|
184
|
+
"ok": False,
|
|
185
|
+
"status": "invalid_target_url",
|
|
186
|
+
"safe_error": "target_url must be a https://github.com/<owner>/<repo>/issues|pull/<number> URL",
|
|
187
|
+
}
|
|
188
|
+
marker_id = marker_id or uuid4().hex[:12]
|
|
189
|
+
workspace = _workspace_dir(workspace_dir)
|
|
190
|
+
db_path = workspace / "dd.sqlite3"
|
|
191
|
+
body = _insert_canary_fixture(db_path, target, marker_id)
|
|
192
|
+
if not confirm_github_write:
|
|
193
|
+
publish_result = publish.publish_ready_actions(db_path, dry_run=True)
|
|
194
|
+
return {
|
|
195
|
+
"ok": True,
|
|
196
|
+
"status": "planned",
|
|
197
|
+
"write_confirmed": False,
|
|
198
|
+
"workspace_dir": str(workspace),
|
|
199
|
+
"db_path": str(db_path),
|
|
200
|
+
"target_url": target["html_url"],
|
|
201
|
+
"marker_id": marker_id,
|
|
202
|
+
"comment_body": body,
|
|
203
|
+
"publish_result": publish_result,
|
|
204
|
+
"next_action": (
|
|
205
|
+
"Rerun with --confirm-github-write to create or deduplicate the "
|
|
206
|
+
"canary comment through the real publisher."
|
|
207
|
+
),
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
publish_result = publish.publish_ready_actions(
|
|
211
|
+
db_path,
|
|
212
|
+
dry_run=False,
|
|
213
|
+
run_command=run_command,
|
|
214
|
+
)
|
|
215
|
+
action_state = _action_state(db_path)
|
|
216
|
+
status = "publish_failed"
|
|
217
|
+
if publish_result.get("ok"):
|
|
218
|
+
status = "deduplicated" if publish_result.get("deduplicated_count") else "published"
|
|
219
|
+
return {
|
|
220
|
+
"ok": bool(publish_result.get("ok")),
|
|
221
|
+
"status": status,
|
|
222
|
+
"write_confirmed": True,
|
|
223
|
+
"workspace_dir": str(workspace),
|
|
224
|
+
"db_path": str(db_path),
|
|
225
|
+
"target_url": target["html_url"],
|
|
226
|
+
"marker_id": marker_id,
|
|
227
|
+
"comment_body": body,
|
|
228
|
+
"publish_result": publish_result,
|
|
229
|
+
"action_state": action_state,
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def main(argv=None):
|
|
234
|
+
parser = argparse.ArgumentParser()
|
|
235
|
+
parser.add_argument("--target-url", required=True)
|
|
236
|
+
parser.add_argument("--workspace-dir")
|
|
237
|
+
parser.add_argument("--marker-id")
|
|
238
|
+
parser.add_argument("--confirm-github-write", action="store_true")
|
|
239
|
+
args = parser.parse_args(argv)
|
|
240
|
+
result = production_write_canary(
|
|
241
|
+
args.target_url,
|
|
242
|
+
workspace_dir=args.workspace_dir,
|
|
243
|
+
marker_id=args.marker_id,
|
|
244
|
+
confirm_github_write=args.confirm_github_write,
|
|
245
|
+
)
|
|
246
|
+
if result["status"] == "invalid_target_url":
|
|
247
|
+
return emit(result, 3)
|
|
248
|
+
if result.get("ok"):
|
|
249
|
+
return emit(result, 0)
|
|
250
|
+
return emit(result, 2)
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
if __name__ == "__main__":
|
|
254
|
+
raise SystemExit(main())
|