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,121 @@
|
|
|
1
|
+
# Worker Prompt Contract
|
|
2
|
+
|
|
3
|
+
The agent-generated worker prompt must include:
|
|
4
|
+
|
|
5
|
+
- repo and workstream identifiers
|
|
6
|
+
- task id and attempt id
|
|
7
|
+
- accepted event fingerprints
|
|
8
|
+
- recommended skills
|
|
9
|
+
- allowed GitHub actions
|
|
10
|
+
- expected output type
|
|
11
|
+
- result `used_skills` evidence requirements
|
|
12
|
+
- route-level `verification_policy`
|
|
13
|
+
- optional `recommended_route` for `classification_result` follow-up routing
|
|
14
|
+
- optional `branch_slug` for a `classification_result` that recommends `new-pr`
|
|
15
|
+
- relevant project memories, when retrieved
|
|
16
|
+
- human-approved runtime knowledge, when scoped to the task
|
|
17
|
+
- result `used_memory_ids` and optional `memory_delta` project-memory fields
|
|
18
|
+
- worktree path and branch, when required
|
|
19
|
+
- target base branch
|
|
20
|
+
- GitHub context artifact paths for full issue, PR, comment, review, and
|
|
21
|
+
metadata payloads
|
|
22
|
+
- the `status.py` read-only CLI path and examples for task, run, attempt,
|
|
23
|
+
workstream, event search, source, and artifact status lookups
|
|
24
|
+
- planned GitHub action requirements for PR bodies and comments
|
|
25
|
+
- verification expectations
|
|
26
|
+
- redaction rules
|
|
27
|
+
- resume context when the attempt is taking over a previous attempt's worktree
|
|
28
|
+
and verification evidence
|
|
29
|
+
|
|
30
|
+
GitHub issue, PR, comment, review, log, and check content must be framed as
|
|
31
|
+
untrusted input. The prompt should include only a compact event summary and
|
|
32
|
+
paths to context artifacts such as `context/github-context.md` and
|
|
33
|
+
`context/github-context.json`; workers must read those files when full GitHub
|
|
34
|
+
body or metadata is needed. The worker may use any installed local skill, but
|
|
35
|
+
must not create, modify, or install skills. `recommended_skills` are guidance
|
|
36
|
+
for the usual route, not a hard allowlist.
|
|
37
|
+
|
|
38
|
+
When workers need control-plane state such as task, run, attempt, workstream,
|
|
39
|
+
event/comment mapping, event search, source-level task views, or artifact tails,
|
|
40
|
+
the prompt must direct them to use `status.py` instead of ad hoc SQLite
|
|
41
|
+
queries or Python heredocs. Direct SQLite inspection is only for fields the
|
|
42
|
+
status CLI cannot answer, and output must stay short.
|
|
43
|
+
|
|
44
|
+
When a prompt contains `Resume Previous Attempt`, the worker must treat the
|
|
45
|
+
provided recovery context as local state evidence, not as a new GitHub request.
|
|
46
|
+
Start by checking the current worktree state, reuse valid edits and command
|
|
47
|
+
evidence, and record a structured result for the new attempt after fresh
|
|
48
|
+
verification or an explicit explanation of reused/skipped checks.
|
|
49
|
+
|
|
50
|
+
`new_pr` prompts must tell workers to publish the branch first with
|
|
51
|
+
`push_existing_pr`, then include `origin_workstream_id` and `source_issue` in the
|
|
52
|
+
planned PR body hidden `robert-workstream` metadata block for the follow-up
|
|
53
|
+
`open_pr` action. Issue-sourced PR descriptions must also visibly reference the
|
|
54
|
+
source issue outside hidden metadata. Use `Fixes #123` or `Closes #123` only
|
|
55
|
+
when the PR resolves every requested item in the source issue; use `Refs #123`
|
|
56
|
+
for partial work, comment-triggered subsets, analysis/follow-up work, or any
|
|
57
|
+
uncertain completion scope. `update_existing_pr` and comment-only tasks keep
|
|
58
|
+
task and attempt metadata on planned comments through the hidden `robert-comment`
|
|
59
|
+
block. These hidden blocks are publisher idempotency markers; omitting them can
|
|
60
|
+
make retries unsafe.
|
|
61
|
+
|
|
62
|
+
The worker records planned GitHub actions in its structured result for agent
|
|
63
|
+
audit before publication. The structured result must include `used_skills` as
|
|
64
|
+
evidence of what local skills were actually used; do not copy every
|
|
65
|
+
`recommended_skills` entry unless it was actually used, and use an empty list
|
|
66
|
+
when no local skill was used. The internal worker runtime is not a skill and
|
|
67
|
+
must not appear in `used_skills`. The agent rejects
|
|
68
|
+
results that omit publisher-required fields.
|
|
69
|
+
|
|
70
|
+
The prompt must include the route's `verification_policy`. Routes that create
|
|
71
|
+
or update code through `new_pr` or `update_existing_pr` with `push_existing_pr`
|
|
72
|
+
require at least one command-backed verification entry with `required: true` and
|
|
73
|
+
`status: "passed"`. Each verification entry must include `command`, `status`,
|
|
74
|
+
`purpose`, and `required`; command-backed checks should include `exit_code`.
|
|
75
|
+
Skipped checks must include `skipped_reason`, and required checks cannot be
|
|
76
|
+
skipped when the route policy sets `allow_skipped: false`.
|
|
77
|
+
|
|
78
|
+
For `update_existing_pr` and `review_comment`, review-report handling is
|
|
79
|
+
response-required. The worker must use `fast-verify-review-point`, record
|
|
80
|
+
`review_point_evaluation`, and include a planned `comment` action that replies
|
|
81
|
+
to the triggering review report or review thread. If fixes are valid, push the
|
|
82
|
+
existing PR branch and then comment with what changed. If every point is
|
|
83
|
+
incorrect, already satisfied, unverified, or needs no code change, do not push;
|
|
84
|
+
comment with each point and the reason it was not changed. If the report says
|
|
85
|
+
there are no blocking items and the PR can merge, still comment to acknowledge
|
|
86
|
+
that no code change is needed.
|
|
87
|
+
|
|
88
|
+
For `pr_review_comment`, the worker is reviewing the requested PR source rather
|
|
89
|
+
than responding to an external review point. The prompt must include the review
|
|
90
|
+
worktree path and require `fast-review-github-pr`. The worker should compare
|
|
91
|
+
the PR merge base against HEAD, record only a planned comment action, and must
|
|
92
|
+
not push branches, open PRs, submit GitHub PR reviews, or publish comments
|
|
93
|
+
directly. This output type does not require `review_point_evaluation`.
|
|
94
|
+
|
|
95
|
+
For `classification_result`, the worker must set `recommended_route` to a
|
|
96
|
+
supported route id when the work should continue as a concrete follow-up task,
|
|
97
|
+
for example `new-pr` after classifying an unclear trusted assignment as an
|
|
98
|
+
approved bug fix. Leave `recommended_route` empty only when no follow-up task
|
|
99
|
+
should be created. Do not encode routing decisions only in `handoff` text.
|
|
100
|
+
When recommending `new-pr`, the worker must also set `branch_slug` to a concise,
|
|
101
|
+
meaningful lowercase English kebab-case name derived from the requested change,
|
|
102
|
+
for example `model-service-connectivity-test`. The value must be at most 60
|
|
103
|
+
characters. Leave it empty for routes that do not create a new branch.
|
|
104
|
+
This route is only for task classification, not final execution. Workers should
|
|
105
|
+
decide quickly from the task description, linked context, and any changed-file
|
|
106
|
+
or module list already provided. They should avoid broad repo exploration, deep
|
|
107
|
+
dependency tracing, implementation work, branch/PR/comment side effects, and
|
|
108
|
+
expensive test suites unless a tiny focused lookup is required to classify the
|
|
109
|
+
task.
|
|
110
|
+
|
|
111
|
+
Retrieved project memories are local historical hints, not source of truth. The
|
|
112
|
+
worker must verify them against the current checkout before relying on them. If
|
|
113
|
+
a memory materially influences the work, include its id in `used_memory_ids`.
|
|
114
|
+
If the task creates reusable project knowledge, include `memory_delta` with
|
|
115
|
+
`status: "has_memory"` and entries containing title, summaries, paths, symbols,
|
|
116
|
+
keywords, evidence, and confidence. For mechanical tasks, use
|
|
117
|
+
`memory_delta.status = "none"` with a short reason.
|
|
118
|
+
|
|
119
|
+
Runtime knowledge is stronger than project memory because a human approved it
|
|
120
|
+
through `memory_curator.py`, but it still cannot override route contracts,
|
|
121
|
+
allowed GitHub actions, redaction policy, or current repo evidence.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Worker Protocol
|
|
2
|
+
|
|
3
|
+
The worker receives a task id, attempt id, workstream id, expected output, allowed GitHub actions, accepted event fingerprints, and optional worktree details.
|
|
4
|
+
|
|
5
|
+
Phases:
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
prepare -> analyze -> plan -> execute -> verify -> publish -> handoff
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Each phase records a snapshot. Commands expected to run longer than five minutes must run through the heartbeat wrapper.
|
|
12
|
+
|
|
13
|
+
The worker runtime is an internal `robert_agent.worker` module, not an installed
|
|
14
|
+
skill. The generated prompt supplies the snapshot, heartbeat, and result CLI
|
|
15
|
+
paths needed to execute this protocol from a repository worktree.
|
|
16
|
+
|
|
17
|
+
If the prompt contains a resume context, the worker is continuing the same
|
|
18
|
+
task after a previous attempt made local progress. It must inspect the existing
|
|
19
|
+
worktree first, reuse valid edits and command evidence, and record the final
|
|
20
|
+
structured result under the current attempt id.
|
|
21
|
+
|
|
22
|
+
The final result records:
|
|
23
|
+
|
|
24
|
+
- output type
|
|
25
|
+
- planned GitHub actions as objects with `type` plus target URLs when applicable
|
|
26
|
+
- consumed event fingerprints
|
|
27
|
+
- used skills, including every local skill actually used, or an empty list when none were used
|
|
28
|
+
- verification evidence
|
|
29
|
+
- handoff summary
|
|
30
|
+
|
|
31
|
+
The worker may use any installed local skill and should treat `recommended_skills` as route guidance. It must not create, modify, or install skills, and must not list the internal worker runtime in `used_skills`.
|
|
32
|
+
|
|
33
|
+
The worker must not create or delete worktrees unless the agent explicitly
|
|
34
|
+
provided that operation. Before recording GitHub-facing text, it must apply the
|
|
35
|
+
agent redaction rules and stay within `allowed_github_actions`.
|
|
36
|
+
|
|
37
|
+
Use the latest action JSON shape only: each `planned_github_actions` item must include `type`, and workers must not emit the legacy `action` key.
|
|
38
|
+
|
|
39
|
+
Workers must include the fields required by the publisher for each planned action:
|
|
40
|
+
`comment` needs `target_url` and `body`, `open_pr` needs `repo`, `head`, `base`,
|
|
41
|
+
`title`, and `body`, and `push_existing_pr` needs `worktree_path` and `branch`.
|
|
42
|
+
For `new_pr`, record both `push_existing_pr` and `open_pr` so the branch exists
|
|
43
|
+
on the remote before the publisher calls `gh pr create`.
|
|
44
|
+
Comment bodies must include the `robert-comment` hidden idempotency marker. New PR
|
|
45
|
+
bodies must include the `robert-workstream` hidden metadata block so retries and
|
|
46
|
+
follow-up discovery can match the existing GitHub side effect instead of
|
|
47
|
+
creating another one.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: Robert Run Once
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
config:
|
|
7
|
+
description: Agent config path
|
|
8
|
+
required: true
|
|
9
|
+
dry_run:
|
|
10
|
+
description: Avoid external writes and worker launch
|
|
11
|
+
required: false
|
|
12
|
+
default: "true"
|
|
13
|
+
fixture:
|
|
14
|
+
description: Optional discovery fixture path
|
|
15
|
+
required: false
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
run_once:
|
|
19
|
+
runs-on: local-agent
|
|
20
|
+
steps:
|
|
21
|
+
- id: validate_config
|
|
22
|
+
name: Validate config and local skill index
|
|
23
|
+
uses: robert/validate-config@v1
|
|
24
|
+
- id: acquire_lease
|
|
25
|
+
name: Acquire agent lease
|
|
26
|
+
uses: robert/acquire-lease@v1
|
|
27
|
+
- id: supervise
|
|
28
|
+
name: Supervise active workstreams and attempts
|
|
29
|
+
uses: robert/supervise@v1
|
|
30
|
+
- id: audit_results
|
|
31
|
+
name: Audit completed worker results
|
|
32
|
+
uses: robert/audit-results@v1
|
|
33
|
+
- id: publish_actions
|
|
34
|
+
name: Publish audited GitHub actions and finalize published results
|
|
35
|
+
uses: robert/publish-actions@v1
|
|
36
|
+
- id: discover
|
|
37
|
+
name: Discover GitHub events
|
|
38
|
+
uses: robert/discover@v1
|
|
39
|
+
- id: authorize
|
|
40
|
+
name: Authorize trusted triggers and follow-up context
|
|
41
|
+
uses: robert/authorize@v1
|
|
42
|
+
- id: route
|
|
43
|
+
name: Route authorized tasks
|
|
44
|
+
uses: robert/route@v1
|
|
45
|
+
- id: dispatch
|
|
46
|
+
name: Prepare worktrees, prompts, and workers
|
|
47
|
+
uses: robert/dispatch@v1
|
|
48
|
+
- id: summarize
|
|
49
|
+
name: Summarize run
|
|
50
|
+
uses: robert/summarize@v1
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Workstream Model
|
|
2
|
+
|
|
3
|
+
`source_key` identifies one GitHub issue or PR. `workstream_id` identifies the mainline thread being processed for that source.
|
|
4
|
+
|
|
5
|
+
Example:
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
source_key(issue): github:example/backend#123
|
|
9
|
+
workstream_id(issue): github:example/backend#123
|
|
10
|
+
source_key(pr): github:example/backend!456
|
|
11
|
+
workstream_id(pr): github:example/backend!456
|
|
12
|
+
origin_workstream_id(pr): github:example/backend#123
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Issue events stay on the issue mainline. PR events stay on the PR mainline. A DD-created PR carries an origin link back to the issue workstream, but it does not share the issue workstream mutex.
|
|
16
|
+
|
|
17
|
+
At most one active task can run for a workstream. New events received during an active task become pending events. Workers declare the event fingerprints they consumed; unconsumed events create a child task after the current task finishes.
|
robert_agent/route.py
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import argparse
|
|
3
|
+
import json
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
from robert_agent.common import emit
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
DEFAULT_VERIFICATION_POLICIES = {
|
|
10
|
+
"comment-analysis": {
|
|
11
|
+
"mode": "optional",
|
|
12
|
+
"required_statuses": ["passed"],
|
|
13
|
+
"allow_skipped": True,
|
|
14
|
+
},
|
|
15
|
+
"local-result": {
|
|
16
|
+
"mode": "optional",
|
|
17
|
+
"required_statuses": ["passed"],
|
|
18
|
+
"allow_skipped": True,
|
|
19
|
+
},
|
|
20
|
+
"new-pr": {
|
|
21
|
+
"mode": "required",
|
|
22
|
+
"required_statuses": ["passed"],
|
|
23
|
+
"allow_skipped": False,
|
|
24
|
+
},
|
|
25
|
+
"update-existing-pr": {
|
|
26
|
+
"mode": "required_for_push",
|
|
27
|
+
"required_statuses": ["passed"],
|
|
28
|
+
"allow_skipped": False,
|
|
29
|
+
},
|
|
30
|
+
"review-comment": {
|
|
31
|
+
"mode": "optional",
|
|
32
|
+
"required_statuses": ["passed"],
|
|
33
|
+
"allow_skipped": True,
|
|
34
|
+
},
|
|
35
|
+
"review-pr": {
|
|
36
|
+
"mode": "optional",
|
|
37
|
+
"required_statuses": ["passed"],
|
|
38
|
+
"allow_skipped": True,
|
|
39
|
+
},
|
|
40
|
+
"classification-result": {
|
|
41
|
+
"mode": "none",
|
|
42
|
+
"required_statuses": [],
|
|
43
|
+
"allow_skipped": False,
|
|
44
|
+
},
|
|
45
|
+
"waiting-for-user": {
|
|
46
|
+
"mode": "none",
|
|
47
|
+
"required_statuses": [],
|
|
48
|
+
"allow_skipped": False,
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def verification_policy_for(route_id):
|
|
54
|
+
route_config = ROUTES.get(route_id) or {}
|
|
55
|
+
policy = route_config.get("verification_policy") or DEFAULT_VERIFICATION_POLICIES.get(
|
|
56
|
+
route_id,
|
|
57
|
+
{
|
|
58
|
+
"mode": "optional",
|
|
59
|
+
"required_statuses": ["passed"],
|
|
60
|
+
"allow_skipped": True,
|
|
61
|
+
},
|
|
62
|
+
)
|
|
63
|
+
return dict(policy)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
ROUTES = {
|
|
67
|
+
"local-result": {
|
|
68
|
+
"route_id": "local-result",
|
|
69
|
+
"expected_output": "local_result",
|
|
70
|
+
"allowed_github_actions": [],
|
|
71
|
+
"verification_policy": DEFAULT_VERIFICATION_POLICIES["local-result"],
|
|
72
|
+
"recommended_skills": ["fast-code-path", "fast-zoom-out"],
|
|
73
|
+
"needs_worktree": False,
|
|
74
|
+
"workspace_mode": "none",
|
|
75
|
+
"confidence": "high",
|
|
76
|
+
},
|
|
77
|
+
"comment-analysis": {
|
|
78
|
+
"route_id": "comment-analysis",
|
|
79
|
+
"expected_output": "comment_analysis",
|
|
80
|
+
"allowed_github_actions": ["comment"],
|
|
81
|
+
"verification_policy": DEFAULT_VERIFICATION_POLICIES["comment-analysis"],
|
|
82
|
+
"recommended_skills": [
|
|
83
|
+
"fast-code-path",
|
|
84
|
+
"fast-zoom-out",
|
|
85
|
+
"fast-verify-review-point",
|
|
86
|
+
],
|
|
87
|
+
"needs_worktree": False,
|
|
88
|
+
"workspace_mode": "analysis",
|
|
89
|
+
"confidence": "high",
|
|
90
|
+
},
|
|
91
|
+
"new-pr": {
|
|
92
|
+
"route_id": "new-pr",
|
|
93
|
+
"expected_output": "new_pr",
|
|
94
|
+
"allowed_github_actions": ["push_existing_pr", "open_pr", "comment"],
|
|
95
|
+
"verification_policy": DEFAULT_VERIFICATION_POLICIES["new-pr"],
|
|
96
|
+
"recommended_skills": [
|
|
97
|
+
"fast-small-pr",
|
|
98
|
+
"fast-code-path",
|
|
99
|
+
"fast-add-tests",
|
|
100
|
+
"fast-test-fix",
|
|
101
|
+
"fast-preflight",
|
|
102
|
+
],
|
|
103
|
+
"needs_worktree": True,
|
|
104
|
+
"workspace_mode": "new_branch",
|
|
105
|
+
"confidence": "high",
|
|
106
|
+
},
|
|
107
|
+
"update-existing-pr": {
|
|
108
|
+
"route_id": "update-existing-pr",
|
|
109
|
+
"expected_output": "update_existing_pr",
|
|
110
|
+
"allowed_github_actions": ["push_existing_pr", "comment"],
|
|
111
|
+
"verification_policy": DEFAULT_VERIFICATION_POLICIES["update-existing-pr"],
|
|
112
|
+
"recommended_skills": [
|
|
113
|
+
"fast-small-pr",
|
|
114
|
+
"fast-verify-review-point",
|
|
115
|
+
"fast-code-path",
|
|
116
|
+
"fast-add-tests",
|
|
117
|
+
"fast-test-fix",
|
|
118
|
+
"fast-code-simplify",
|
|
119
|
+
"fast-preflight",
|
|
120
|
+
],
|
|
121
|
+
"needs_worktree": True,
|
|
122
|
+
"workspace_mode": "existing_pr",
|
|
123
|
+
"confidence": "high",
|
|
124
|
+
},
|
|
125
|
+
"review-comment": {
|
|
126
|
+
"route_id": "review-comment",
|
|
127
|
+
"expected_output": "review_comment",
|
|
128
|
+
"allowed_github_actions": ["comment"],
|
|
129
|
+
"verification_policy": DEFAULT_VERIFICATION_POLICIES["review-comment"],
|
|
130
|
+
"recommended_skills": [
|
|
131
|
+
"fast-review-github-pr",
|
|
132
|
+
"fast-verify-review-point",
|
|
133
|
+
"fast-code-path",
|
|
134
|
+
],
|
|
135
|
+
"needs_worktree": False,
|
|
136
|
+
"workspace_mode": "analysis",
|
|
137
|
+
"confidence": "high",
|
|
138
|
+
},
|
|
139
|
+
"review-pr": {
|
|
140
|
+
"route_id": "review-pr",
|
|
141
|
+
"expected_output": "pr_review_comment",
|
|
142
|
+
"allowed_github_actions": ["comment"],
|
|
143
|
+
"verification_policy": DEFAULT_VERIFICATION_POLICIES["review-pr"],
|
|
144
|
+
"recommended_skills": [
|
|
145
|
+
"fast-review-github-pr",
|
|
146
|
+
"fast-code-path",
|
|
147
|
+
],
|
|
148
|
+
"needs_worktree": True,
|
|
149
|
+
"worktree_mode": "review_pr",
|
|
150
|
+
"workspace_mode": "review_pr",
|
|
151
|
+
"confidence": "high",
|
|
152
|
+
},
|
|
153
|
+
"classification-result": {
|
|
154
|
+
"route_id": "classification-result",
|
|
155
|
+
"expected_output": "classification_result",
|
|
156
|
+
"allowed_github_actions": [],
|
|
157
|
+
"recommended_skills": [],
|
|
158
|
+
"needs_worktree": False,
|
|
159
|
+
"workspace_mode": "none",
|
|
160
|
+
"verification_policy": DEFAULT_VERIFICATION_POLICIES["classification-result"],
|
|
161
|
+
"confidence": "low",
|
|
162
|
+
},
|
|
163
|
+
"waiting-for-user": {
|
|
164
|
+
"route_id": "waiting-for-user",
|
|
165
|
+
"expected_output": "waiting_for_user",
|
|
166
|
+
"allowed_github_actions": ["comment"],
|
|
167
|
+
"recommended_skills": [],
|
|
168
|
+
"needs_worktree": False,
|
|
169
|
+
"workspace_mode": "none",
|
|
170
|
+
"verification_policy": DEFAULT_VERIFICATION_POLICIES["waiting-for-user"],
|
|
171
|
+
"confidence": "high",
|
|
172
|
+
},
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
for route_config in ROUTES.values():
|
|
176
|
+
route_config.setdefault("required_skills", [])
|
|
177
|
+
route_config.setdefault("recommended_skills", [])
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def route_task(task):
|
|
181
|
+
intent = task.get("intent")
|
|
182
|
+
if task.get("origin_type") == "web" and intent in {
|
|
183
|
+
"analysis",
|
|
184
|
+
"discussion",
|
|
185
|
+
"requirement_analysis",
|
|
186
|
+
}:
|
|
187
|
+
return dict(ROUTES["local-result"])
|
|
188
|
+
if (
|
|
189
|
+
task.get("source_type") == "pull_request"
|
|
190
|
+
and task.get("authorization_status") == "accepted_review_participant"
|
|
191
|
+
):
|
|
192
|
+
return dict(ROUTES["review-comment"])
|
|
193
|
+
if task.get("source_type") == "pull_request" and (
|
|
194
|
+
task.get("event_type") == "review_request"
|
|
195
|
+
or task.get("requested_reviewer")
|
|
196
|
+
or task.get("requested_team")
|
|
197
|
+
):
|
|
198
|
+
return dict(ROUTES["review-pr"])
|
|
199
|
+
if task.get("source_type") == "pull_request" and task.get("has_open_dd_pr"):
|
|
200
|
+
if intent == "waiting_for_user":
|
|
201
|
+
return dict(ROUTES["waiting-for-user"])
|
|
202
|
+
if intent in {"analysis", "discussion", "requirement_analysis", "review_request"}:
|
|
203
|
+
return dict(ROUTES["review-comment"])
|
|
204
|
+
return dict(ROUTES["update-existing-pr"])
|
|
205
|
+
if (
|
|
206
|
+
task.get("source_type") == "pull_request"
|
|
207
|
+
and not task.get("has_open_dd_pr")
|
|
208
|
+
and intent in {"bug_fix", "small_change", "add_tests", "pr_followup_fix"}
|
|
209
|
+
):
|
|
210
|
+
return dict(ROUTES["review-comment"])
|
|
211
|
+
if intent in {"analysis", "discussion", "requirement_analysis"}:
|
|
212
|
+
return dict(ROUTES["comment-analysis"])
|
|
213
|
+
if intent in {"bug_fix", "small_change", "add_tests"}:
|
|
214
|
+
return dict(ROUTES["new-pr"])
|
|
215
|
+
if intent == "pr_followup_fix" and task.get("has_open_dd_pr"):
|
|
216
|
+
return dict(ROUTES["update-existing-pr"])
|
|
217
|
+
if intent == "review_request":
|
|
218
|
+
return dict(ROUTES["review-comment"])
|
|
219
|
+
if intent == "waiting_for_user":
|
|
220
|
+
return dict(ROUTES["waiting-for-user"])
|
|
221
|
+
return dict(ROUTES["classification-result"])
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def main(argv=None):
|
|
225
|
+
_parser = argparse.ArgumentParser()
|
|
226
|
+
_parser.parse_args(argv)
|
|
227
|
+
task = json.load(sys.stdin)
|
|
228
|
+
return emit({"ok": True, "status": "routed", "route": route_task(task)})
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
if __name__ == "__main__":
|
|
232
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import yaml
|
|
2
|
+
|
|
3
|
+
from robert_agent.resource_files import resource
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
ALLOWED_ROUTE_OVERRIDE_FIELDS = {
|
|
7
|
+
"worker",
|
|
8
|
+
"required_skills",
|
|
9
|
+
"recommended_skills",
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def load_route_policies():
|
|
14
|
+
data = yaml.safe_load(
|
|
15
|
+
resource("routes.yml").read_text(encoding="utf-8")
|
|
16
|
+
)
|
|
17
|
+
routes = data.get("routes") if isinstance(data, dict) else None
|
|
18
|
+
if not isinstance(routes, list) or not routes:
|
|
19
|
+
raise ValueError("packaged routes.yml must contain routes")
|
|
20
|
+
return routes
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _validated_override(raw, label):
|
|
24
|
+
raw = raw or {}
|
|
25
|
+
if not isinstance(raw, dict):
|
|
26
|
+
raise ValueError(f"{label} must be a mapping")
|
|
27
|
+
unsupported = sorted(set(raw) - ALLOWED_ROUTE_OVERRIDE_FIELDS)
|
|
28
|
+
if unsupported:
|
|
29
|
+
raise ValueError(
|
|
30
|
+
f"{label} contains unsupported fields: {', '.join(unsupported)}"
|
|
31
|
+
)
|
|
32
|
+
return raw
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def resolve_route_config(config, repo, route_policy):
|
|
36
|
+
route_id = route_policy["id"]
|
|
37
|
+
global_override = _validated_override(
|
|
38
|
+
config.get("routes", {}).get(route_id),
|
|
39
|
+
f"routes.{route_id}",
|
|
40
|
+
)
|
|
41
|
+
repo_override = _validated_override(
|
|
42
|
+
repo.get("routes", {}).get(route_id),
|
|
43
|
+
(
|
|
44
|
+
"repos."
|
|
45
|
+
f"{repo.get('full_name', 'unknown-repository')}."
|
|
46
|
+
f"routes.{route_id}"
|
|
47
|
+
),
|
|
48
|
+
)
|
|
49
|
+
result = dict(route_policy)
|
|
50
|
+
for field in ALLOWED_ROUTE_OVERRIDE_FIELDS:
|
|
51
|
+
if field in global_override:
|
|
52
|
+
result[field] = global_override[field]
|
|
53
|
+
if field in repo_override:
|
|
54
|
+
result[field] = repo_override[field]
|
|
55
|
+
workers = config["workers"]
|
|
56
|
+
default_worker = (
|
|
57
|
+
next(iter(workers))
|
|
58
|
+
if isinstance(workers, dict)
|
|
59
|
+
else workers[0]["name"]
|
|
60
|
+
)
|
|
61
|
+
result.setdefault("worker", default_worker)
|
|
62
|
+
result.setdefault("required_skills", [])
|
|
63
|
+
result.setdefault("recommended_skills", [])
|
|
64
|
+
return result
|