aisync-cli 0.2.7__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.
- ai_sync/__init__.py +2 -0
- ai_sync/__main__.py +5 -0
- ai_sync/board.py +285 -0
- ai_sync/cli.py +932 -0
- ai_sync/collab.py +476 -0
- ai_sync/core.py +974 -0
- ai_sync/demo.py +285 -0
- ai_sync/enforcement.py +328 -0
- ai_sync/gate.py +265 -0
- ai_sync/guard.py +390 -0
- ai_sync/hooks.py +577 -0
- ai_sync/instincts.py +113 -0
- ai_sync/landq.py +182 -0
- ai_sync/layers.py +113 -0
- ai_sync/mcp_server.py +134 -0
- ai_sync/nonvacuous.py +110 -0
- ai_sync/rulecheck.py +153 -0
- ai_sync/ruleids.py +162 -0
- ai_sync/rulespec.py +202 -0
- ai_sync/tidy.py +145 -0
- ai_sync/ui.py +162 -0
- ai_sync/update.py +73 -0
- ai_sync/watch.py +191 -0
- ai_sync/webinbox.py +173 -0
- ai_sync/worktree.py +168 -0
- aisync_cli-0.2.7.dist-info/METADATA +308 -0
- aisync_cli-0.2.7.dist-info/RECORD +31 -0
- aisync_cli-0.2.7.dist-info/WHEEL +5 -0
- aisync_cli-0.2.7.dist-info/entry_points.txt +2 -0
- aisync_cli-0.2.7.dist-info/licenses/LICENSE +21 -0
- aisync_cli-0.2.7.dist-info/top_level.txt +1 -0
ai_sync/demo.py
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"""aisync demo: a throwaway hub with a synthetic two-week journal, so `aisync status` has a story to tell.
|
|
2
|
+
|
|
3
|
+
What: five tools (claude-code, codex, cursor, windsurf, gemini-cli) working on three fictional repos
|
|
4
|
+
(checkout-api, storefront-web, infra) for two weeks: commits, decisions, overlapping claims,
|
|
5
|
+
a blocker that got unblocked, one still open, shared rules added along the way, and a
|
|
6
|
+
rule conflict that the real sync engine detects (a copy and the truth edited differently).
|
|
7
|
+
Why: a new user sees what the hub looks like after real use before wiring it into their own tools.
|
|
8
|
+
How: `aisync demo [--dir D]`. Everything is written under D (default: a new temp dir); the real
|
|
9
|
+
hub, tool configs and git config are never touched. All names and data are made up.
|
|
10
|
+
"""
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import hashlib
|
|
14
|
+
import json
|
|
15
|
+
import os
|
|
16
|
+
import random
|
|
17
|
+
import tempfile
|
|
18
|
+
from datetime import datetime, timedelta
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
|
|
21
|
+
from . import board, collab, core
|
|
22
|
+
|
|
23
|
+
TOOLS = ("claude-code", "codex", "cursor", "windsurf", "gemini-cli")
|
|
24
|
+
|
|
25
|
+
BASE_RULES = [
|
|
26
|
+
"- Before editing a repo other agents may touch, run `aisync claim`; exit code 3 means someone else holds those files.",
|
|
27
|
+
"- After each unit of work, log one line with `aisync log`.",
|
|
28
|
+
"- Every commit ends with an `Agent: <tool>` trailer.",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
# (days ago, "HH:MM" or "-<minutes>" for today, agent, kind, project, summary, files, refs)
|
|
32
|
+
STORY = [
|
|
33
|
+
(13, "09:12", "claude-code", "decision", "checkout-api",
|
|
34
|
+
"move payment retries out of the request path into a queue worker; p99 on /pay was 2.8 s",
|
|
35
|
+
["docs/adr/0007-payment-retries.md"], {}),
|
|
36
|
+
(13, "09:40", "claude-code", "commit", "checkout-api", "docs(adr): 0007 payment retries via queue worker",
|
|
37
|
+
["docs/adr/0007-payment-retries.md"], {}),
|
|
38
|
+
(13, "11:05", "cursor", "claim", "storefront-web", "claimed: cart drawer redesign",
|
|
39
|
+
["src/components/CartDrawer.tsx", "src/components/CartDrawer.css"], {}),
|
|
40
|
+
(13, "14:30", "cursor", "commit", "storefront-web", "feat(cart): slide-over drawer with line-item editing",
|
|
41
|
+
["src/components/CartDrawer.tsx", "src/components/CartDrawer.css", "src/hooks/useCart.ts"], {}),
|
|
42
|
+
(13, "14:32", "cursor", "release", "storefront-web", "released: cart drawer redesign", [], {}),
|
|
43
|
+
(13, "16:48", "codex", "dev_log", "infra",
|
|
44
|
+
"split the staging VPC module so checkout-api and storefront-web get separate subnets",
|
|
45
|
+
["modules/vpc/main.tf", "envs/staging/main.tf"], {}),
|
|
46
|
+
(12, "08:55", "gemini-cli", "dev_log", "infra", "terraform plan for staging is clean after the VPC split; no drift",
|
|
47
|
+
[], {}),
|
|
48
|
+
(12, "10:20", "claude-code", "claim", "checkout-api", "claimed: retry worker + idempotency keys",
|
|
49
|
+
["app/workers/", "app/payments/idempotency.py"], {}),
|
|
50
|
+
(12, "13:02", "claude-code", "commit", "checkout-api", "feat(payments): retry worker with exponential backoff",
|
|
51
|
+
["app/workers/retry.py", "app/workers/__init__.py", "tests/test_retry_worker.py"], {}),
|
|
52
|
+
(12, "15:40", "claude-code", "commit", "checkout-api", "feat(payments): idempotency keys on POST /pay",
|
|
53
|
+
["app/payments/idempotency.py", "app/api/pay.py", "tests/test_idempotency.py"], {}),
|
|
54
|
+
(12, "15:41", "claude-code", "release", "checkout-api", "released: retry worker + idempotency keys", [], {}),
|
|
55
|
+
(12, "17:15", "windsurf", "dev_log", "storefront-web",
|
|
56
|
+
"replaced the hand-rolled price formatter with Intl.NumberFormat; fixes JPY showing two decimals",
|
|
57
|
+
["src/lib/money.ts", "src/lib/money.test.ts"], {}),
|
|
58
|
+
(11, "09:30", "codex", "commit", "checkout-api", "test: contract tests for the /pay response schema",
|
|
59
|
+
["tests/contract/test_pay_schema.py", "tests/contract/pay.schema.json"], {}),
|
|
60
|
+
(11, "10:05", "claude-code", "rule_change", "checkout-api",
|
|
61
|
+
"shared rule added: never log full card numbers or tokens; mask to the last 4 digits", ["preferences.md"], {}),
|
|
62
|
+
(11, "11:48", "cursor", "commit", "storefront-web", "fix(cart): drawer focus trap on Safari", [
|
|
63
|
+
"src/components/CartDrawer.tsx"], {}),
|
|
64
|
+
(11, "14:10", "git:alex", "commit", "storefront-web", "bump next to 14.2.5", ["package.json", "package-lock.json"], {}),
|
|
65
|
+
(11, "16:22", "gemini-cli", "commit", "infra", "chore(staging): enable RDS performance insights",
|
|
66
|
+
["envs/staging/rds.tf"], {}),
|
|
67
|
+
(10, "09:00", "windsurf", "claim", "storefront-web", "claimed: checkout page a11y pass", ["src/pages/checkout/"], {}),
|
|
68
|
+
(10, "09:03", "cursor", "claim", "storefront-web", "claimed: promo code field on checkout",
|
|
69
|
+
["src/pages/checkout/PromoCode.tsx"], {"overlap_with": "windsurf"}),
|
|
70
|
+
(10, "09:10", "cursor", "note", "storefront-web",
|
|
71
|
+
"windsurf holds src/pages/checkout/; moved the promo field work to src/components/PromoCode.tsx instead",
|
|
72
|
+
["src/components/PromoCode.tsx"], {}),
|
|
73
|
+
(10, "12:35", "windsurf", "commit", "storefront-web", "fix(a11y): labels and error announcements on checkout form",
|
|
74
|
+
["src/pages/checkout/AddressForm.tsx", "src/pages/checkout/CardForm.tsx"], {}),
|
|
75
|
+
(10, "12:36", "windsurf", "release", "storefront-web", "released: checkout page a11y pass", [], {}),
|
|
76
|
+
(10, "15:05", "cursor", "commit", "storefront-web", "feat(checkout): promo code component",
|
|
77
|
+
["src/components/PromoCode.tsx", "src/components/PromoCode.test.tsx"], {}),
|
|
78
|
+
(10, "15:06", "cursor", "release", "storefront-web", "released: promo code field on checkout", [], {}),
|
|
79
|
+
(9, "10:15", "codex", "blocked", "checkout-api",
|
|
80
|
+
"integration tests need a payment-sandbox key in CI; the secret is missing from the staging environment",
|
|
81
|
+
[".github/workflows/ci.yml"], {}),
|
|
82
|
+
(9, "11:00", "claude-code", "dev_log", "checkout-api",
|
|
83
|
+
"worked around the missing sandbox key locally with the recorded fixtures; CI still blocked",
|
|
84
|
+
["tests/fixtures/sandbox/"], {}),
|
|
85
|
+
(9, "13:40", "gemini-cli", "commit", "infra", "feat(ci): OIDC role for checkout-api to read sandbox secrets",
|
|
86
|
+
["modules/ci-oidc/main.tf", "envs/staging/ci.tf"], {}),
|
|
87
|
+
(9, "13:52", "gemini-cli", "unblocked", "checkout-api",
|
|
88
|
+
"sandbox key now comes from the secrets manager through the new OIDC role; CI can read it",
|
|
89
|
+
["envs/staging/ci.tf"], {"blocked_id": "@blocked:checkout-api"}),
|
|
90
|
+
(9, "14:30", "codex", "commit", "checkout-api", "ci: run integration tests against the payment sandbox",
|
|
91
|
+
[".github/workflows/ci.yml"], {}),
|
|
92
|
+
(8, "09:20", "windsurf", "decision", "storefront-web",
|
|
93
|
+
"keep client-side price math only for display; totals always come from checkout-api /quote",
|
|
94
|
+
["docs/decisions/pricing.md"], {}),
|
|
95
|
+
(8, "10:45", "claude-code", "commit", "checkout-api", "feat(api): /quote returns tax and discount lines",
|
|
96
|
+
["app/api/quote.py", "app/pricing/tax.py", "tests/test_quote.py"], {}),
|
|
97
|
+
(8, "14:00", "cursor", "commit", "storefront-web", "feat(checkout): totals from /quote, remove local tax math",
|
|
98
|
+
["src/lib/quote.ts", "src/pages/checkout/Summary.tsx", "src/lib/tax.ts"], {}),
|
|
99
|
+
(8, "16:30", "codex", "rule_change", "storefront-web",
|
|
100
|
+
"shared rule added: every API change ships with a contract test in the same PR", ["preferences.md"], {}),
|
|
101
|
+
(7, "09:05", "git:alex", "commit", "checkout-api", "hotfix: allow 0-amount quotes for gift cards",
|
|
102
|
+
["app/api/quote.py"], {}),
|
|
103
|
+
(7, "09:40", "claude-code", "commit", "checkout-api", "test: contract test for zero-amount quotes",
|
|
104
|
+
["tests/contract/test_quote_schema.py"], {}),
|
|
105
|
+
(7, "11:15", "gemini-cli", "dev_log", "infra", "prod plan shows 3 drifted security group rules; left untouched, opened ticket",
|
|
106
|
+
[], {}),
|
|
107
|
+
(7, "15:20", "codex", "commit", "storefront-web", "test(e2e): checkout happy path with Playwright",
|
|
108
|
+
["e2e/checkout.spec.ts", "playwright.config.ts"], {}),
|
|
109
|
+
(6, "10:00", "cursor", "dev_log", "storefront-web", "Lighthouse on /checkout: LCP 3.1 s -> 1.9 s after lazy-loading the map",
|
|
110
|
+
["src/pages/checkout/AddressForm.tsx"], {}),
|
|
111
|
+
(6, "13:25", "windsurf", "commit", "storefront-web", "perf: preload the payment iframe on cart open",
|
|
112
|
+
["src/components/CartDrawer.tsx", "src/lib/preload.ts"], {}),
|
|
113
|
+
(6, "16:10", "claude-code", "decision", "checkout-api",
|
|
114
|
+
"webhook handler becomes idempotent on event id; duplicates were double-capturing on retries",
|
|
115
|
+
["app/webhooks/payments.py"], {}),
|
|
116
|
+
(5, "09:35", "claude-code", "commit", "checkout-api", "fix(webhooks): dedupe on provider event id",
|
|
117
|
+
["app/webhooks/payments.py", "app/models/webhook_event.py", "migrations/0031_webhook_event.py"], {}),
|
|
118
|
+
(5, "11:50", "codex", "commit", "checkout-api", "test: replay duplicate webhooks in integration suite",
|
|
119
|
+
["tests/integration/test_webhook_replay.py"], {}),
|
|
120
|
+
(5, "14:05", "gemini-cli", "commit", "infra", "fix(prod): import the 3 drifted security group rules into state",
|
|
121
|
+
["envs/prod/sg.tf"], {}),
|
|
122
|
+
(4, "10:10", "cursor", "commit", "storefront-web", "feat(account): saved cards list",
|
|
123
|
+
["src/pages/account/Cards.tsx", "src/lib/api.ts"], {}),
|
|
124
|
+
(4, "11:30", "windsurf", "rule_change", "storefront-web",
|
|
125
|
+
"shared rule added: UI changes include a screenshot or a Playwright trace in the PR", ["preferences.md"], {}),
|
|
126
|
+
(4, "15:45", "claude-code", "commit", "checkout-api", "feat(api): list and delete saved cards",
|
|
127
|
+
["app/api/cards.py", "tests/test_cards.py", "tests/contract/test_cards_schema.py"], {}),
|
|
128
|
+
(3, "09:15", "codex", "dev_log", "checkout-api", "flaky test_retry_worker traced to a real clock; switched to a fake clock",
|
|
129
|
+
["tests/test_retry_worker.py"], {}),
|
|
130
|
+
(3, "12:40", "git:alex", "commit", "infra", "raise staging RDS to db.t4g.medium", ["envs/staging/rds.tf"], {}),
|
|
131
|
+
(3, "14:20", "gemini-cli", "dev_log", "infra", "staging RDS resize applied in a 4 min window; no errors in checkout-api logs",
|
|
132
|
+
[], {}),
|
|
133
|
+
(2, "10:00", "claude-code", "claim", "checkout-api", "claimed: refunds endpoint", ["app/api/refunds.py", "app/payments/"], {}),
|
|
134
|
+
(2, "10:20", "codex", "claim", "checkout-api", "claimed: payment provider SDK upgrade", ["app/payments/provider.py"],
|
|
135
|
+
{"overlap_with": "claude-code"}),
|
|
136
|
+
(2, "10:24", "codex", "release", "checkout-api", "released: payment provider SDK upgrade", [], {}),
|
|
137
|
+
(2, "10:25", "codex", "note", "checkout-api", "SDK upgrade waits until claude-code lands refunds; app/payments/ is claimed",
|
|
138
|
+
[], {}),
|
|
139
|
+
(2, "16:55", "claude-code", "commit", "checkout-api", "feat(api): partial refunds",
|
|
140
|
+
["app/api/refunds.py", "app/payments/refunds.py", "tests/test_refunds.py", "tests/contract/test_refunds_schema.py"], {}),
|
|
141
|
+
(2, "16:56", "claude-code", "release", "checkout-api", "released: refunds endpoint", [], {}),
|
|
142
|
+
(1, "09:30", "codex", "commit", "checkout-api", "chore(deps): payment provider SDK 4.2 -> 5.0",
|
|
143
|
+
["app/payments/provider.py", "pyproject.toml", "uv.lock"], {}),
|
|
144
|
+
(1, "11:10", "cursor", "commit", "storefront-web", "feat(account): refund status on order page",
|
|
145
|
+
["src/pages/account/Order.tsx"], {}),
|
|
146
|
+
(1, "14:45", "windsurf", "dev_log", "storefront-web", "visual diff on 14 checkout screens after the font swap: 0 regressions",
|
|
147
|
+
[], {}),
|
|
148
|
+
(1, "17:20", "gemini-cli", "decision", "infra", "prod changes go through a plan comment on the PR; no local applies",
|
|
149
|
+
["docs/runbooks/terraform.md"], {}),
|
|
150
|
+
(0, "-190", "gemini-cli", "blocked", "infra",
|
|
151
|
+
"prod plan needs a read-only role on the billing account; waiting for access", [], {}),
|
|
152
|
+
(0, "-150", "claude-code", "dev_log", "checkout-api", "refund webhooks now update order status within one retry cycle",
|
|
153
|
+
["app/webhooks/payments.py"], {}),
|
|
154
|
+
(0, "-95", "codex", "commit", "checkout-api", "test: refund webhook end-to-end in the sandbox",
|
|
155
|
+
["tests/integration/test_refund_webhook.py"], {}),
|
|
156
|
+
]
|
|
157
|
+
|
|
158
|
+
# Claims that are live right now: cursor and claude-code overlap on the checkout summary.
|
|
159
|
+
LIVE_CLAIMS = [
|
|
160
|
+
("windsurf", "storefront-web", ["src/styles/tokens.css", "src/components/Button.tsx"], "design tokens for dark mode", 95),
|
|
161
|
+
("cursor", "storefront-web", ["src/pages/checkout/"], "show refund credit on checkout summary", 110),
|
|
162
|
+
("claude-code", "storefront-web", ["src/pages/checkout/Summary.tsx"], "wire /quote credit lines into Summary", 120),
|
|
163
|
+
]
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def _ts(now: datetime, days_ago: int, when: str) -> str:
|
|
167
|
+
if when.startswith("-"):
|
|
168
|
+
t = now - timedelta(minutes=int(when[1:]))
|
|
169
|
+
else:
|
|
170
|
+
hh, mm = map(int, when.split(":"))
|
|
171
|
+
t = (now - timedelta(days=days_ago)).replace(hour=hh, minute=mm, second=0, microsecond=0)
|
|
172
|
+
return t.isoformat(timespec="seconds")
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def _sha(*parts: str) -> str:
|
|
176
|
+
return hashlib.sha1("\x00".join(parts).encode()).hexdigest()[:12]
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def _rules_block(rules: list[str]) -> str:
|
|
180
|
+
return "\n".join([core.BLOCK_START + " (shared by every AI tool; edit it in the hub's preferences.md) -->",
|
|
181
|
+
*BASE_RULES, "", collab.RULES_HEAD, *rules, core.BLOCK_END])
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def _write_journal(cfg: core.Config, now: datetime) -> list[str]:
|
|
185
|
+
rules, blocked_ids = [], {}
|
|
186
|
+
for days_ago, when, agent, kind, project, summary, files, refs in sorted(
|
|
187
|
+
STORY, key=lambda e: _ts(now, e[0], e[1])):
|
|
188
|
+
ts = _ts(now, days_ago, when)
|
|
189
|
+
refs = dict(refs)
|
|
190
|
+
if kind == "commit":
|
|
191
|
+
refs["commit"] = _sha(project, summary)
|
|
192
|
+
if refs.get("blocked_id", "").startswith("@blocked:"):
|
|
193
|
+
refs["blocked_id"] = blocked_ids.pop(refs["blocked_id"].split(":", 1)[1])
|
|
194
|
+
ev = core.append_event(cfg, agent=agent, kind=kind, summary=summary, project=project,
|
|
195
|
+
files=files, refs=refs, ts=ts)
|
|
196
|
+
if kind == "blocked":
|
|
197
|
+
blocked_ids[project] = ev["id"]
|
|
198
|
+
if kind == "rule_change":
|
|
199
|
+
stamp = datetime.fromisoformat(ts).strftime("%Y-%m-%d %H:%M")
|
|
200
|
+
rules.append(f"- {stamp} ({agent}, {project}): {summary.split(': ', 1)[1]}")
|
|
201
|
+
return rules
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def _write_runs(cfg: core.Config, now: datetime) -> None:
|
|
205
|
+
"""Sync-cycle history: event-driven cycles during working hours, a short push outage on day 6.
|
|
206
|
+
Each cycle harvests exactly the journal's commits made since the previous cycle."""
|
|
207
|
+
rnd = random.Random(14)
|
|
208
|
+
commits = sorted(e["ts"] for e in core.read_events(cfg) if e["kind"] == "commit")
|
|
209
|
+
lines, prev = [], ""
|
|
210
|
+
for days_ago in range(13, -1, -1):
|
|
211
|
+
day = now - timedelta(days=days_ago)
|
|
212
|
+
t = day.replace(hour=8, minute=rnd.randint(30, 59), second=0, microsecond=0)
|
|
213
|
+
while t.hour < 19 and t < now - timedelta(minutes=5):
|
|
214
|
+
failed = days_ago == 6 and 15 <= t.hour < 16
|
|
215
|
+
steps = {name: {"ok": True, "ms": rnd.randint(2, 40), "result": {}}
|
|
216
|
+
for name in ("harvest", "rules", "distribute", "render", "progress")}
|
|
217
|
+
stamp = t.isoformat(timespec="seconds")
|
|
218
|
+
steps["harvest"]["result"] = {"events": sum(prev < c <= stamp for c in commits), "projects": 3, "errors": []}
|
|
219
|
+
prev = stamp
|
|
220
|
+
steps["distribute"]["result"] = {"updated": [], "conflicts": []}
|
|
221
|
+
steps["flush"] = ({"ok": False, "ms": 20000, "error": "GitError: git push: timeout after 20.0s"} if failed
|
|
222
|
+
else {"ok": True, "ms": rnd.randint(60, 420), "result": {}})
|
|
223
|
+
lines.append({"ts": stamp, "reason": rnd.choice(("event", "event", "event", "reconcile")),
|
|
224
|
+
"steps": steps, "ok": not failed, "ms": sum(s["ms"] for s in steps.values())})
|
|
225
|
+
t += timedelta(minutes=rnd.randint(25, 70))
|
|
226
|
+
cfg.state.mkdir(parents=True, exist_ok=True)
|
|
227
|
+
(cfg.state / "runs.jsonl").write_text("".join(json.dumps(r) + "\n" for r in lines))
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def _write_hook_log(cfg: core.Config, now: datetime) -> None:
|
|
231
|
+
rnd = random.Random(24)
|
|
232
|
+
recs = []
|
|
233
|
+
for tool, n in (("claude-code", 64), ("codex", 41), ("cursor", 37)):
|
|
234
|
+
for i in range(n):
|
|
235
|
+
t = now - timedelta(minutes=rnd.randint(5, 23 * 60))
|
|
236
|
+
injected = rnd.random() < 0.18
|
|
237
|
+
recs.append({"ts": t.isoformat(timespec="seconds"), "tool": tool, "event": "PostToolUse",
|
|
238
|
+
"session": f"{tool[:2]}-{rnd.randint(1000, 9999)}", "ok": True,
|
|
239
|
+
"events": rnd.randint(1, 4) if injected else 0, "rules": 0,
|
|
240
|
+
"chars": rnd.randint(300, 900) if injected else 0, "ms": rnd.randint(9, 48)})
|
|
241
|
+
recs.sort(key=lambda r: r["ts"])
|
|
242
|
+
(cfg.state / "hooks.jsonl").write_text("".join(json.dumps(r) + "\n" for r in recs))
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def build(root: Path | None = None) -> Path:
|
|
246
|
+
os.environ.setdefault("AISYNC_NO_NOTIFY", "1") # the demo never pops desktop notifications
|
|
247
|
+
root = Path(root) if root else Path(tempfile.mkdtemp(prefix="aisync-demo-"))
|
|
248
|
+
if (root / "journal.jsonl").exists():
|
|
249
|
+
raise ValueError(f"{root} already holds a hub; pick an empty --dir")
|
|
250
|
+
tools_dir = root / "tool-files"
|
|
251
|
+
targets = {"claude-code": tools_dir / "claude" / "CLAUDE.md", "codex": tools_dir / "codex" / "AGENTS.md",
|
|
252
|
+
"windsurf": tools_dir / "windsurf" / "global_rules.md"}
|
|
253
|
+
root.mkdir(parents=True, exist_ok=True)
|
|
254
|
+
(root / "config.toml").write_text(
|
|
255
|
+
f"roster = {json.dumps(list(TOOLS))}\n" + "".join(
|
|
256
|
+
f'\n[[target]]\nlabel = "{label}"\npath = "{path}"\n' for label, path in targets.items()))
|
|
257
|
+
(root / ".gitignore").write_text("backups/\ngithooks/\nstate/*\n!state/current.json\nSTOP\n")
|
|
258
|
+
(root / "journal.jsonl").write_text("")
|
|
259
|
+
(root / board.DEMO_MARKER).write_text("Synthetic hub built by `aisync demo`: every tool, repo and event is made up.\n")
|
|
260
|
+
cfg = core.load_config(root)
|
|
261
|
+
now = datetime.now().astimezone().replace(microsecond=0)
|
|
262
|
+
|
|
263
|
+
rules = _write_journal(cfg, now)
|
|
264
|
+
block = _rules_block(rules)
|
|
265
|
+
(root / "preferences.md").write_text(f"# Shared rules (source of truth)\n\n{block}\n")
|
|
266
|
+
for label, path in targets.items():
|
|
267
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
268
|
+
path.write_text(f"# {label} rules\n\nProject notes for {label} live above the shared block.\n\n{block}\n")
|
|
269
|
+
_write_runs(cfg, now)
|
|
270
|
+
_write_hook_log(cfg, now)
|
|
271
|
+
core.run_cycle(cfg, "demo") # all copies in sync, hashes recorded
|
|
272
|
+
|
|
273
|
+
for agent, project, files, summary, ttl in LIVE_CLAIMS:
|
|
274
|
+
collab.claim(cfg, agent=agent, project=project, summary=summary, files=files, ttl_min=ttl)
|
|
275
|
+
# The conflict: a new rule lands in the truth while someone hand-edits the codex copy differently.
|
|
276
|
+
collab.rule_add(cfg, agent="cursor", project="storefront-web",
|
|
277
|
+
text="feature flags are removed within two weeks of full rollout",
|
|
278
|
+
reason="three stale flags were found in checkout")
|
|
279
|
+
codex = targets["codex"]
|
|
280
|
+
lines = codex.read_text().split("\n") # the first cycle gave each rule an ID, so match by its words
|
|
281
|
+
at = next(i for i, ln in enumerate(lines) if BASE_RULES[1].removeprefix("- ") in ln)
|
|
282
|
+
lines.insert(at + 1, "- Prefer small PRs: under 400 changed lines unless it is a rename.")
|
|
283
|
+
codex.write_text("\n".join(lines))
|
|
284
|
+
core.run_cycle(cfg, "demo")
|
|
285
|
+
return root
|
ai_sync/enforcement.py
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
"""What enforces each shared rule (a test beats an agent's judgment).
|
|
2
|
+
|
|
3
|
+
What: ~/.ai-sync/rules-enforcement.toml, keyed by rule ID, says for every rule either
|
|
4
|
+
enforced_by = ["<path>", ...] a test, hook or checker that catches a break of the rule
|
|
5
|
+
judgment_only = "<reason>" nothing in code checks it, and why
|
|
6
|
+
or neither (= none). A none rule should still say what its check would be:
|
|
7
|
+
planned = "<the check>" size = "S|M|L" since = "YYYY-MM-DD"
|
|
8
|
+
An enforced rule may carry the same three keys for a gap its enforcer leaves. `note` says how far
|
|
9
|
+
the enforcer reaches. It is a sidecar on purpose: the rules block is loaded into every session, this file is not.
|
|
10
|
+
Why: a rule that only an agent's judgment keeps is weaker than one a test keeps; the count makes that visible.
|
|
11
|
+
A none rule with no plan in this file had no way to close (16 sat for ten days, 2026-11-12): the plan lived
|
|
12
|
+
in a markdown file nobody read, and no command could record an enforcer once someone wrote it.
|
|
13
|
+
How: `aisync rule add` must name one of the three (collab.rule_add); AGENTS.md imports are recorded as none.
|
|
14
|
+
`aisync rule enforce R-### ...` sets the entry of an existing rule. Paths are stored absolute (with ~), so
|
|
15
|
+
the answer does not depend on the reader's directory.
|
|
16
|
+
`aisync rule enforcement [--json]` counts active rules and prints one next action per open line; it exits 1
|
|
17
|
+
when a Meta rule is none, a path is gone or relative, a none rule has no plan, a plan is past its due
|
|
18
|
+
days (S 7, M 30, L 90), or no rule was read at all. A plan's clock only runs: moving it later needs a reason.
|
|
19
|
+
"""
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import json
|
|
23
|
+
import os
|
|
24
|
+
import re
|
|
25
|
+
import tomllib
|
|
26
|
+
from datetime import date
|
|
27
|
+
from pathlib import Path
|
|
28
|
+
|
|
29
|
+
from . import collab, core, ruleids
|
|
30
|
+
|
|
31
|
+
FILE = "rules-enforcement.toml"
|
|
32
|
+
HEAD = """# What enforces each shared rule, keyed by rule ID (see ~/.ai-sync/preferences.md).
|
|
33
|
+
# enforced_by = paths of the test, hook or checker that catches a break of the rule (each must exist, absolute or ~);
|
|
34
|
+
# judgment_only = why only an agent's judgment keeps it; neither = none: a check is possible and not written yet.
|
|
35
|
+
# planned = what that check would be, size = S, M or L, since = the day it was planned (also allowed beside
|
|
36
|
+
# enforced_by, for a gap the enforcer leaves). note = how far the enforcer reaches.
|
|
37
|
+
# Written by `aisync rule add` and `aisync rule enforce`; counted by `aisync rule enforcement`.
|
|
38
|
+
"""
|
|
39
|
+
_META = re.compile(r"^- \[R-\d{3,}\] Meta rule\b")
|
|
40
|
+
SIZES = {"S": 7, "M": 30, "L": 90} # days a planned check may stay unwritten before it counts as overdue
|
|
41
|
+
_KEYS = ("enforced_by", "judgment_only", "note", "planned", "size", "since")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def path(cfg: core.Config) -> Path:
|
|
45
|
+
return cfg.root / FILE
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def load(cfg: core.Config) -> dict:
|
|
49
|
+
p = path(cfg)
|
|
50
|
+
return tomllib.loads(p.read_text()) if p.exists() else {}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _num(rid: str) -> int:
|
|
54
|
+
return int(rid.split("-")[1]) if re.fullmatch(r"R-\d+", rid) else 1 << 30
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def save(cfg: core.Config, data: dict) -> None:
|
|
58
|
+
"""Whole-file rewrite, entries in ID order. Values are strings or lists of strings (JSON escapes are valid TOML)."""
|
|
59
|
+
out = [HEAD]
|
|
60
|
+
for rid in sorted(data, key=_num):
|
|
61
|
+
out.append(f"[{rid}]")
|
|
62
|
+
for k, v in data[rid].items():
|
|
63
|
+
if isinstance(v, list):
|
|
64
|
+
v = "[" + ", ".join(json.dumps(x, ensure_ascii=False) for x in v) + "]"
|
|
65
|
+
else: # a hand-edited bare date or number is written back as a string
|
|
66
|
+
v = json.dumps(v if isinstance(v, str) else str(v), ensure_ascii=False)
|
|
67
|
+
out.append(f"{k} = {v}")
|
|
68
|
+
out.append("")
|
|
69
|
+
core.atomic_write(path(cfg), "\n".join(out))
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _tilde(p: str) -> str:
|
|
73
|
+
p, home = str(p), str(Path.home())
|
|
74
|
+
return "~" + p[len(home):] if p == home or p.startswith(home + os.sep) else p
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _abs(p: str) -> str:
|
|
78
|
+
"""Absolute, ~ for home. abspath, not resolve: a hook path that is a symlink stays the path people know."""
|
|
79
|
+
return _tilde(os.path.abspath(os.path.expanduser(str(p))))
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def is_relative(p: str) -> bool:
|
|
83
|
+
return not os.path.isabs(os.path.expanduser(str(p)))
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def missing(paths: list[str]) -> list[str]:
|
|
87
|
+
return [p for p in paths if not Path(p).expanduser().exists()]
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _paths(enforced_by: str) -> list[str]:
|
|
91
|
+
paths = [p.strip() for p in (enforced_by or "").split(",") if p.strip()]
|
|
92
|
+
gone = [p for p in paths if not Path(p).expanduser().is_file()]
|
|
93
|
+
if gone:
|
|
94
|
+
raise ValueError(f"--enforced-by path does not exist (or is not a file): {', '.join(gone)}")
|
|
95
|
+
return [_abs(p) for p in paths]
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _plan(planned: str, size: str, since: str = "") -> dict:
|
|
99
|
+
size = (size or "").strip().upper()
|
|
100
|
+
if size not in SIZES:
|
|
101
|
+
raise ValueError("--planned needs --size S, M or L (S under 30 min, M a few hours, L a day or more)")
|
|
102
|
+
since = (since or "").strip() or date.today().isoformat()
|
|
103
|
+
try:
|
|
104
|
+
day = date.fromisoformat(since)
|
|
105
|
+
except ValueError:
|
|
106
|
+
raise ValueError(f"--since must be YYYY-MM-DD, got {since!r}") from None
|
|
107
|
+
if day > date.today():
|
|
108
|
+
raise ValueError(f"--since {since} is in the future; a plan starts the day it was made")
|
|
109
|
+
return {"planned": " ".join(planned.split()), "size": size, "since": since}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def check_args(enforced_by: str, judgment_only: str, planned: str = "", size: str = "") -> dict:
|
|
113
|
+
"""The sidecar entry for a new rule, or ValueError unless exactly one of the three is given and it is valid."""
|
|
114
|
+
reason = " ".join((judgment_only or "").split())
|
|
115
|
+
plan = " ".join((planned or "").split())
|
|
116
|
+
given = [bool((enforced_by or "").strip()), bool(reason), bool(plan)]
|
|
117
|
+
if sum(given) != 1:
|
|
118
|
+
raise ValueError("say what enforces the rule: --enforced-by <path>[,<path>] (a test, hook or checker), "
|
|
119
|
+
"--judgment-only \"<why nothing in code can check it>\", or "
|
|
120
|
+
"--planned \"<the check to write>\" --size S|M|L")
|
|
121
|
+
if given[0]:
|
|
122
|
+
return {"enforced_by": _paths(enforced_by)}
|
|
123
|
+
if given[1]:
|
|
124
|
+
return {"judgment_only": reason}
|
|
125
|
+
return _plan(plan, size)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def kind(entry: dict) -> str:
|
|
129
|
+
return "enforced" if entry.get("enforced_by") else "judgment_only" if entry.get("judgment_only") else "none"
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def put(cfg: core.Config, rid: str, entry: dict) -> None:
|
|
133
|
+
"""Set one rule's entry. Call under core.locked."""
|
|
134
|
+
data = load(cfg)
|
|
135
|
+
data[rid] = entry
|
|
136
|
+
save(cfg, data)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def active_ids(cfg: core.Config) -> list[str]:
|
|
140
|
+
block = core.extract_block((cfg.root / "preferences.md").read_text()) or ""
|
|
141
|
+
return [rid for rid in (ruleids.bullet_id(l) for l in collab.rule_lines(block)) if rid]
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def set_entry(cfg: core.Config, rid: str, *, enforced_by: str = "", judgment_only: str = "", planned: str = "",
|
|
145
|
+
size: str = "", since: str = "", note: str = "", reason: str = "") -> dict:
|
|
146
|
+
"""Set the enforcement of an existing rule. Returns {"id", "before", "after", "entry"}.
|
|
147
|
+
|
|
148
|
+
--enforced-by replaces the paths and closes the plan (pass --planned with it to keep a gap on record).
|
|
149
|
+
--planned alone records the check to write. It also turns a judgment_only rule into a planned one (a check is
|
|
150
|
+
possible after all) and drops enforcer files that are gone, so a dead enforcer becomes a plan.
|
|
151
|
+
The clock of a plan only runs: a later --since or a larger --size on a rule that already has a plan needs
|
|
152
|
+
--reason, and so does --judgment-only on such a rule (a possible check is not a judgment). The old plan and
|
|
153
|
+
the reason stay in `note`.
|
|
154
|
+
"""
|
|
155
|
+
rid = (rid or "").strip().upper()
|
|
156
|
+
reason_j = " ".join((judgment_only or "").split())
|
|
157
|
+
plan = " ".join((planned or "").split())
|
|
158
|
+
note = " ".join((note or "").split())
|
|
159
|
+
why = " ".join((reason or "").split())
|
|
160
|
+
paths_in = (enforced_by or "").strip()
|
|
161
|
+
if sum(map(bool, (paths_in, reason_j))) > 1 or (reason_j and plan):
|
|
162
|
+
raise ValueError("give one of --enforced-by, --judgment-only, --planned (--planned may go with --enforced-by)")
|
|
163
|
+
if not (paths_in or reason_j or plan or note):
|
|
164
|
+
raise ValueError("nothing to set: give --enforced-by, --judgment-only, --planned (with --size) or --note")
|
|
165
|
+
with core.locked(cfg):
|
|
166
|
+
if rid not in active_ids(cfg):
|
|
167
|
+
raise ValueError(f"{rid or '(no id)'} is not a current rule (see `aisync rule list`)")
|
|
168
|
+
data = load(cfg)
|
|
169
|
+
old = {k: (v if isinstance(v, (str, list)) else str(v)) for k, v in (data.get(rid) or {}).items()}
|
|
170
|
+
new = {k: old[k] for k in _KEYS if k in old}
|
|
171
|
+
was_plan = (f"({old.get('size', '?')}, since {old.get('since', '?')}): {old['planned']}" if old.get("planned") else "")
|
|
172
|
+
if paths_in:
|
|
173
|
+
new["enforced_by"] = _paths(paths_in)
|
|
174
|
+
new.pop("judgment_only", None)
|
|
175
|
+
if not plan:
|
|
176
|
+
for k in ("planned", "size", "since"):
|
|
177
|
+
new.pop(k, None)
|
|
178
|
+
elif reason_j:
|
|
179
|
+
if was_plan and not why:
|
|
180
|
+
raise ValueError(f"{rid} has a planned check {was_plan[:80]}; a possible check is not a judgment. "
|
|
181
|
+
"Write the check, or pass --reason \"<why no check can exist after all>\"")
|
|
182
|
+
new = {"judgment_only": reason_j}
|
|
183
|
+
if was_plan:
|
|
184
|
+
new["note"] = f"was planned {was_plan}. Dropped {date.today().isoformat()}: {why}"
|
|
185
|
+
elif old.get("note") and not old.get("enforced_by"):
|
|
186
|
+
new["note"] = old["note"]
|
|
187
|
+
if plan:
|
|
188
|
+
if new.get("judgment_only"): # a check is possible after all: no longer a judgment
|
|
189
|
+
new.setdefault("note", f"was judgment_only: {new['judgment_only']}")
|
|
190
|
+
del new["judgment_only"]
|
|
191
|
+
if not paths_in and new.get("enforced_by"): # a file that is gone enforces nothing
|
|
192
|
+
alive = [p for p in new["enforced_by"] if not missing([p])]
|
|
193
|
+
if alive:
|
|
194
|
+
new["enforced_by"] = alive
|
|
195
|
+
else:
|
|
196
|
+
del new["enforced_by"]
|
|
197
|
+
p = _plan(plan, size or old.get("size", ""), since or (old.get("since", "") if was_plan else ""))
|
|
198
|
+
if was_plan:
|
|
199
|
+
slower = (SIZES[p["size"]] > SIZES.get(old.get("size", ""), 0) or p["since"] > str(old.get("since", "")))
|
|
200
|
+
if slower and not why:
|
|
201
|
+
raise ValueError(f"{rid} is already planned {was_plan[:80]}; a larger --size or a later --since "
|
|
202
|
+
"moves its due day, so it needs --reason \"<why>\"")
|
|
203
|
+
if slower:
|
|
204
|
+
new["note"] = (f"{new['note']} " if new.get("note") else "") + \
|
|
205
|
+
f"Plan moved {date.today().isoformat()} from {old.get('size', '?')} since {old.get('since', '?')}: {why}"
|
|
206
|
+
new.update(p)
|
|
207
|
+
if note:
|
|
208
|
+
new["note"] = note if not new.get("note") or new.get("note") == old.get("note") else f"{note} {new['note']}"
|
|
209
|
+
data[rid] = new
|
|
210
|
+
save(cfg, data)
|
|
211
|
+
return {"id": rid, "before": kind(old), "after": kind(new), "entry": new}
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def rebase(cfg: core.Config, root: str) -> dict:
|
|
215
|
+
"""Make relative enforced_by paths absolute against `root`, for those that exist there. One-time repair of
|
|
216
|
+
entries written when the path was stored as typed."""
|
|
217
|
+
base = Path(root).expanduser()
|
|
218
|
+
fixed, left = [], []
|
|
219
|
+
with core.locked(cfg):
|
|
220
|
+
data = load(cfg)
|
|
221
|
+
for rid, e in data.items():
|
|
222
|
+
new = []
|
|
223
|
+
for p in e.get("enforced_by") or []:
|
|
224
|
+
if is_relative(p) and (base / p).exists():
|
|
225
|
+
new.append(_abs(str(base / p)))
|
|
226
|
+
fixed.append({"id": rid, "path": p, "now": new[-1]})
|
|
227
|
+
else:
|
|
228
|
+
if is_relative(p):
|
|
229
|
+
left.append({"id": rid, "path": p})
|
|
230
|
+
new.append(p)
|
|
231
|
+
if e.get("enforced_by"):
|
|
232
|
+
e["enforced_by"] = new
|
|
233
|
+
if fixed:
|
|
234
|
+
save(cfg, data)
|
|
235
|
+
return {"fixed": fixed, "left": left}
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def prune(cfg: core.Config) -> dict:
|
|
239
|
+
"""Drop entries of rules that are no longer current. Only an ID found in rules-archive.md goes (the rule is
|
|
240
|
+
provably retired); with no current rule read at all it refuses, so a rules block that failed to parse cannot
|
|
241
|
+
empty the registry. Returns {"removed": [...], "kept": [...]} (kept = not current, not in the archive)."""
|
|
242
|
+
with core.locked(cfg):
|
|
243
|
+
active = set(active_ids(cfg))
|
|
244
|
+
if not active:
|
|
245
|
+
raise ValueError("refusing to prune: no current rules were read from preferences.md")
|
|
246
|
+
data = load(cfg)
|
|
247
|
+
arch = cfg.root / ruleids.ARCHIVE
|
|
248
|
+
archived = set(re.findall(r"\[(R-\d{3,})\]", arch.read_text())) if arch.exists() else set()
|
|
249
|
+
gone = [rid for rid in data if rid not in active and rid in archived]
|
|
250
|
+
kept = [rid for rid in data if rid not in active and rid not in archived]
|
|
251
|
+
for rid in gone:
|
|
252
|
+
del data[rid]
|
|
253
|
+
if gone:
|
|
254
|
+
save(cfg, data)
|
|
255
|
+
return {"removed": sorted(gone, key=_num), "kept": sorted(kept, key=_num)}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def report(cfg: core.Config, today: date | None = None) -> dict:
|
|
259
|
+
block = core.extract_block((cfg.root / "preferences.md").read_text()) or ""
|
|
260
|
+
data = load(cfg)
|
|
261
|
+
today = today or date.today()
|
|
262
|
+
rep = {"total": 0, "enforced": 0, "judgment_only": 0, "none": 0, "meta_none": [], "missing_paths": [],
|
|
263
|
+
"meta": {}, "relative_paths": [], "planned": [], "overdue": [], "unplanned": []}
|
|
264
|
+
seen = set()
|
|
265
|
+
for line in collab.rule_lines(block):
|
|
266
|
+
rid = ruleids.bullet_id(line)
|
|
267
|
+
if not rid:
|
|
268
|
+
continue
|
|
269
|
+
seen.add(rid)
|
|
270
|
+
e = data.get(rid, {})
|
|
271
|
+
k = kind(e)
|
|
272
|
+
rep["total"] += 1
|
|
273
|
+
rep[k] += 1
|
|
274
|
+
for p in e.get("enforced_by") or []:
|
|
275
|
+
if is_relative(p):
|
|
276
|
+
rep["relative_paths"].append({"id": rid, "path": p})
|
|
277
|
+
elif missing([p]):
|
|
278
|
+
rep["missing_paths"].append({"id": rid, "path": p})
|
|
279
|
+
if e.get("planned"):
|
|
280
|
+
try:
|
|
281
|
+
days = (today - date.fromisoformat(str(e.get("since", "")))).days
|
|
282
|
+
except ValueError:
|
|
283
|
+
days = -1
|
|
284
|
+
size = e.get("size") if e.get("size") in SIZES else "M"
|
|
285
|
+
late = days < 0 or days > SIZES[size] # no date, a bad date or a future one counts as overdue
|
|
286
|
+
row = {"id": rid, "check": str(e["planned"]), "size": size, "since": str(e.get("since", "")),
|
|
287
|
+
"days": max(days, 0), "overdue": late, "kind": k}
|
|
288
|
+
rep["planned"].append(row)
|
|
289
|
+
if row["overdue"]:
|
|
290
|
+
rep["overdue"].append(rid)
|
|
291
|
+
elif k == "none":
|
|
292
|
+
rep["unplanned"].append(rid)
|
|
293
|
+
if _META.match(line):
|
|
294
|
+
rep["meta"][rid] = k
|
|
295
|
+
if k == "none":
|
|
296
|
+
rep["meta_none"].append(rid)
|
|
297
|
+
rep["stale"] = sorted((rid for rid in data if rid not in seen), key=_num)
|
|
298
|
+
# a hub that does not require enforcers (the public default) is not failed for rules nobody labelled
|
|
299
|
+
strict = bool(getattr(cfg, "require_enforcer", True))
|
|
300
|
+
rep["ok"] = not (rep["meta_none"] or rep["missing_paths"] or rep["relative_paths"]
|
|
301
|
+
or (strict and (rep["unplanned"] or rep["overdue"] or not rep["total"])))
|
|
302
|
+
return rep
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
def lines(rep: dict, registry: str = FILE) -> list[str]:
|
|
306
|
+
"""The report as text: counts, then one line per open item with its next action."""
|
|
307
|
+
out = (["NO RULES READ: preferences.md has no rules block, or it is empty"] if not rep["total"] else [])
|
|
308
|
+
out += [f"rules {rep['total']}: enforced {rep['enforced']}, judgment_only {rep['judgment_only']}, "
|
|
309
|
+
f"none {rep['none']} (planned {sum(1 for p in rep['planned'] if p['kind'] == 'none')}, "
|
|
310
|
+
f"no plan {len(rep['unplanned'])})",
|
|
311
|
+
"meta " + ", ".join(f"{k} {v}" for k, v in rep["meta"].items())]
|
|
312
|
+
out += [f"META NONE {rid}: say what enforces it -> aisync rule enforce {rid} --enforced-by <path>"
|
|
313
|
+
for rid in rep["meta_none"]]
|
|
314
|
+
out += [f"MISSING {m['id']}: {m['path']} -> aisync rule enforce {m['id']} --enforced-by <a path that exists>, "
|
|
315
|
+
f"or --planned \"<the check to rewrite>\" --size S|M|L"
|
|
316
|
+
for m in rep["missing_paths"]]
|
|
317
|
+
out += [f"RELATIVE {m['id']}: {m['path']} -> aisync rule enforcement --rebase <the repo it lives in>"
|
|
318
|
+
for m in rep["relative_paths"]]
|
|
319
|
+
for p in rep["planned"]:
|
|
320
|
+
tag = "OVERDUE" if p["overdue"] else "PLANNED"
|
|
321
|
+
gap = " (gap beside its enforcer)" if p["kind"] != "none" else ""
|
|
322
|
+
out.append(f"{tag} {p['id']} ({p['size']}, since {p['since']}, {p['days']} d){gap}: {p['check']}"
|
|
323
|
+
+ (f" -> write it, then aisync rule enforce {p['id']} --enforced-by <path>" if p["overdue"] else ""))
|
|
324
|
+
out += [f"NO PLAN {rid} -> aisync rule enforce {rid} --planned \"<the check>\" --size S|M|L"
|
|
325
|
+
for rid in rep["unplanned"]]
|
|
326
|
+
if rep["stale"]:
|
|
327
|
+
out.append(f"STALE {len(rep['stale'])} entries of retired rules -> aisync rule enforcement --prune")
|
|
328
|
+
return out
|