Files
cleveragents-core/_issue_state.py
T
HAL9000 abd4e83baa fix(cli): add timing.started ISO timestamp to plan prompt JSON envelope
- Capture started_at timestamp using datetime.now(UTC) before service call
- Add timing.started field to JSON envelope with ISO 8601 format
- Update step definitions to verify timing.started is present and valid
- Remove @tdd_expected_fail tag from plan_prompt_command.feature scenario

Fixes #9353
2026-06-03 03:03:14 -04:00

75 lines
2.5 KiB
Python

import urllib.request
import json
BASE = "https://git.cleverthis.com/api/v1"
TOKEN = "92224acff675c50c5958d1eaca9a688abd405e06"
HEADERS = {
"Authorization": f"token {TOKEN}",
"Content-Type": "application/json",
}
REPO = "cleveragents/cleveragents-core"
ISSUE_NUMBER = 8370
def api(method, path, data=None):
url = f"{BASE}/{path}"
body = json.dumps(data).encode() if data is not None else None
req = urllib.request.Request(url, method=method, data=body, headers=HEADERS)
try:
resp = urllib.request.urlopen(req)
raw = resp.read()
return json.loads(raw) if raw else {}, resp.status
except urllib.error.HTTPError as e:
raw = e.read()
return json.loads(raw) if raw else {}, e.code
# Fetch current issue labels
print("=== Fetching issue #8370 current labels ===")
issue, status = api("GET", f"repos/{REPO}/issues/{ISSUE_NUMBER}")
current_labels = issue.get("labels", [])
print(f"Current labels: {[l['name'] for l in current_labels]}")
# Find State/* labels
state_labels = [l for l in current_labels if l['name'].startswith('State/')]
non_state_labels = [l for l in current_labels if not l['name'].startswith('State/')]
print(f"State labels: {[l['name'] for l in state_labels]}")
print(f"Non-state labels: {[l['name'] for l in non_state_labels]}")
# Fetch org labels to find State/In Review
print("\n=== Fetching org labels to find State/In Review ===")
page = 1
all_labels = []
while True:
labels, status = api("GET", f"orgs/cleveragents/labels?limit=50&page={page}")
if not labels or status != 200:
break
all_labels.extend(labels)
if len(labels) < 50:
break
page += 1
in_review_label = next((l for l in all_labels if l['name'] == 'State/In Review'), None)
in_progress_label = next((l for l in all_labels if l['name'] == 'State/In Progress'), None)
print(f"State/In Review: {in_review_label}")
print(f"State/In Progress: {in_progress_label}")
if not in_review_label:
print("ERROR: State/In Review label not found!")
exit(1)
# Remove all State/* labels and add State/In Review
# Keep all non-state labels
new_label_ids = [l['id'] for l in non_state_labels] + [in_review_label['id']]
print(f"\n=== Setting labels to: {[l['name'] for l in non_state_labels] + ['State/In Review']} ===")
# Replace all labels
result, status = api("PUT", f"repos/{REPO}/issues/{ISSUE_NUMBER}/labels", {
"labels": new_label_ids
})
print(f"Status: {status}")
if isinstance(result, list):
print(f"New labels: {[l['name'] for l in result]}")
else:
print(f"Result: {json.dumps(result)[:300]}")