claude-dev-env 1.89.0 → 1.92.0
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.
- package/CLAUDE.md +0 -13
- package/_shared/pr-loop/scripts/code_rules_gate.py +106 -14
- package/_shared/pr-loop/scripts/pr_loop_shared_constants/code_rules_gate_constants.py +26 -0
- package/_shared/pr-loop/scripts/tests/test_code_rules_gate.py +160 -0
- package/agents/clean-coder.md +2 -2
- package/agents/code-verifier.md +0 -1
- package/agents/test_agent_frontmatter.py +78 -0
- package/audit-rubrics/category_rubrics/category-j-code-rules-compliance.md +1 -1
- package/audit-rubrics/prompts/category-j-code-rules-compliance.md +1 -1
- package/bin/install.mjs +1 -0
- package/docs/CODE_RULES.md +2 -2
- package/hooks/blocking/CLAUDE.md +6 -2
- package/hooks/blocking/code_rules_comments.py +2 -2
- package/hooks/blocking/code_verifier_spawn_preflight_gate.py +44 -0
- package/hooks/blocking/config/verified_commit_constants.py +2 -0
- package/hooks/blocking/conftest.py +115 -0
- package/hooks/blocking/nas_ssh_binary_enforcer.py +191 -0
- package/hooks/blocking/pr_description_enforcer.py +46 -22
- package/hooks/blocking/pr_description_pr_number.py +5 -3
- package/hooks/blocking/pr_description_proof_of_work.py +367 -0
- package/hooks/blocking/precommit_code_rules_gate.py +5 -1
- package/hooks/blocking/test_code_rules_enforcer_comment_string_awareness.py +8 -2
- package/hooks/blocking/test_code_verifier_spawn_preflight_gate.py +71 -0
- package/hooks/blocking/test_nas_ssh_binary_enforcer.py +168 -0
- package/hooks/blocking/test_pr_description_enforcer_proof_gate.py +175 -0
- package/hooks/blocking/test_pr_description_proof_of_work.py +162 -0
- package/hooks/blocking/test_precommit_code_rules_gate.py +89 -0
- package/hooks/blocking/test_verdict_directory_write_blocker.py +4 -0
- package/hooks/blocking/test_verification_verdict_store.py +11 -0
- package/hooks/blocking/test_verified_commit_config_bootstrap.py +49 -0
- package/hooks/blocking/test_verified_commit_gate.py +11 -0
- package/hooks/blocking/test_verifier_verdict_minter.py +11 -0
- package/hooks/blocking/test_volatile_path_in_post_blocker.py +210 -0
- package/hooks/blocking/verdict_directory_write_blocker.py +6 -0
- package/hooks/blocking/verification_verdict_store.py +73 -5
- package/hooks/blocking/verified_commit_config_bootstrap.py +51 -0
- package/hooks/blocking/verified_commit_gate.py +6 -0
- package/hooks/blocking/verifier_verdict_minter.py +6 -0
- package/hooks/blocking/volatile_path_in_post_blocker.py +351 -0
- package/hooks/hooks.json +32 -2
- package/hooks/hooks_constants/CLAUDE.md +4 -0
- package/hooks/hooks_constants/code_rules_path_utils_constants.py +1 -0
- package/hooks/hooks_constants/code_verifier_spawn_preflight_gate_constants.py +3 -0
- package/hooks/hooks_constants/enter_worktree_prefetch_constants.py +18 -0
- package/hooks/hooks_constants/nas_ssh_binary_enforcer_constants.py +59 -0
- package/hooks/hooks_constants/pr_description_enforcer_constants.py +2 -0
- package/hooks/hooks_constants/pr_description_proof_of_work_constants.py +111 -0
- package/hooks/hooks_constants/volatile_path_in_post_blocker_constants.py +48 -0
- package/hooks/lifecycle/CLAUDE.md +3 -1
- package/hooks/lifecycle/enter_worktree_origin_prefetch.py +146 -0
- package/hooks/lifecycle/test_enter_worktree_origin_prefetch.py +178 -0
- package/hooks/validators/run_all_validators.py +216 -4
- package/hooks/validators/test_run_all_validators_pretooluse.py +102 -0
- package/package.json +1 -1
- package/rules/CLAUDE.md +3 -0
- package/rules/durable-post-artifacts.md +35 -0
- package/rules/nas-ssh-invocation.md +21 -0
- package/rules/proof-of-work-pr-comments.md +26 -0
- package/scripts/CLAUDE.md +2 -0
- package/scripts/claude-chain.example.json +8 -0
- package/scripts/claude_chain_runner.py +400 -0
- package/scripts/dev_env_scripts_constants/CLAUDE.md +2 -0
- package/scripts/dev_env_scripts_constants/claude_chain_constants.py +124 -0
- package/scripts/dev_env_scripts_constants/gh_artifact_upload_constants.py +43 -0
- package/scripts/gh_artifact_upload.py +256 -0
- package/scripts/sync_to_cursor/rules.py +1 -1
- package/scripts/test_claude_chain_runner.py +472 -0
- package/scripts/tests/test_gh_artifact_upload.py +205 -0
- package/skills/CLAUDE.md +3 -0
- package/skills/team-advisor/SKILL.md +188 -0
- package/skills/team-advisor-refresh/SKILL.md +25 -0
- package/skills/usage-pause/SKILL.md +108 -0
- package/skills/usage-pause/scripts/resolve_usage_window.py +462 -0
- package/skills/usage-pause/scripts/test_resolve_usage_window.py +278 -0
- package/skills/usage-pause/scripts/usage_pause_constants/__init__.py +1 -0
- package/skills/usage-pause/scripts/usage_pause_constants/resolve_usage_window_constants.py +65 -0
- package/system-prompts/software-engineer.xml +3 -2
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: team-advisor
|
|
3
|
+
description: >-
|
|
4
|
+
Turns the session into the advisor-orchestrator — the user's sole interface,
|
|
5
|
+
to plan
|
|
6
|
+
and delegate while workflow-backed agent spawns do the token-heavy
|
|
7
|
+
execution with the required agent type and model for each work category.
|
|
8
|
+
Executors do the code editing, verification, script driving, PR
|
|
9
|
+
descriptions, and searches; the advisor answers blockers with one of three
|
|
10
|
+
brief signals — a plan, a correction, or a stop. The advisor never edits
|
|
11
|
+
code or runs tests itself. Caps consultations per task (default 5), reuses
|
|
12
|
+
warm workflow agents before spawning new ones, and re-asserts the
|
|
13
|
+
discipline every 20 minutes through the /team-advisor-refresh loop. Adapts
|
|
14
|
+
Anthropic's coordinator pattern (plan big, execute small) to Claude Code.
|
|
15
|
+
Triggers: '/team-advisor', 'team advisor strategy', 'run with a team
|
|
16
|
+
advisor', 'executor-advisor mode', 'team advisor enforcement', 'agent
|
|
17
|
+
routing', 'orchestrate'.
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# Team Advisor Strategy
|
|
21
|
+
|
|
22
|
+
## Principle
|
|
23
|
+
|
|
24
|
+
A frontier model plans and synthesizes while cheap workers do the
|
|
25
|
+
token-heavy reading and doing — Anthropic's coordinator pattern, source:
|
|
26
|
+
https://github.com/anthropics/claude-cookbooks/blob/main/managed_agents/CMA_plan_big_execute_small.ipynb
|
|
27
|
+
("Coordinator pattern: big models for planning, small models for
|
|
28
|
+
execution"). On the cookbook's own measured run, a coordinator
|
|
29
|
+
delegating to Sonnet-5 workers came out cheaper and faster
|
|
30
|
+
than a solo frontier agent held to the same verification rigor, with
|
|
31
|
+
84-98% of the team's input tokens billed at the worker rate.
|
|
32
|
+
|
|
33
|
+
Claude Code has no `multiagent` coordinator field or Managed-Agents-style
|
|
34
|
+
`create_agent`/`send_to_agent` primitives; this skill reaches the same
|
|
35
|
+
shape with the tools Claude Code already has. Under this skill the session
|
|
36
|
+
is the advisor-orchestrator. In Claude Code the user always talks to the session and never to a
|
|
37
|
+
subagent, so the session is the user's sole interface: all user-facing
|
|
38
|
+
communication flows through it. It spawns and resumes executor subagents
|
|
39
|
+
— `clean-coder` and the like — and those executors do every bit of the
|
|
40
|
+
execution: the code edits, the build runs, the test runs. The advisor
|
|
41
|
+
drives the plan and answers the executors when they get stuck.
|
|
42
|
+
|
|
43
|
+
## Gotchas
|
|
44
|
+
|
|
45
|
+
- **Double invocation duplicates the reminder loop.** A second `/team-advisor`
|
|
46
|
+
in the same session schedules a second refresh loop. Check whether the loop
|
|
47
|
+
is already running before you schedule one (see the invocation guard in
|
|
48
|
+
Process step 1).
|
|
49
|
+
- **The advisor never executes.** The moment it edits a file or runs the tests
|
|
50
|
+
itself, the pairing breaks and the executor's warm context is wasted. Hand
|
|
51
|
+
every code edit and every build or test run to an executor; keep the
|
|
52
|
+
advisor's own tool use to orchestration and light verification reads.
|
|
53
|
+
- **Flat ad hoc spawns bypass routing.** Every execution task goes through a
|
|
54
|
+
workflow-backed spawn or workflow resume so the required agent type, model,
|
|
55
|
+
prompt packet, and sidecar metadata stay attached to the work.
|
|
56
|
+
- **Wrong agent or model is an enforcement failure.** If a task category maps
|
|
57
|
+
to `clean-coder` on `opus`, a `general-purpose` Sonnet spawn is not a cost
|
|
58
|
+
optimization; it is the wrong executor for the contract.
|
|
59
|
+
- **Resuming an unnamed background agent needs its agentId.** A background
|
|
60
|
+
spawn returns an `agentId` (format `a...-...`); keep it so `SendMessage` can
|
|
61
|
+
reach that agent later. A named agent is reachable by name.
|
|
62
|
+
- **Consultations past the cap signal a scoping problem.** When five
|
|
63
|
+
consultations do not clear the blocker, the task needs re-scoping or a
|
|
64
|
+
hand-off to the user — not a sixth round of advice.
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
## Process
|
|
68
|
+
|
|
69
|
+
1. **Check whether the refresh loop is already running this
|
|
70
|
+
session. If it is, skip straight to orchestration — do not schedule a
|
|
71
|
+
second loop.
|
|
72
|
+
|
|
73
|
+
2. **Register the discipline reminder.** By default, schedule it with
|
|
74
|
+
`ScheduleWakeup` at `delaySeconds: 1200`, prompt `/team-advisor-refresh`,
|
|
75
|
+
where each refresh re-schedules the next one — a 1200-second wakeup costs
|
|
76
|
+
one prompt-cache miss per firing and nothing more (see Gotchas). The loop
|
|
77
|
+
mechanism (`/loop 20m /team-advisor-refresh`) is the escape hatch when
|
|
78
|
+
`ScheduleWakeup` is not available. Either way the reminder is the
|
|
79
|
+
enforcement surface: each firing re-asserts the discipline while the run is
|
|
80
|
+
in flight.
|
|
81
|
+
|
|
82
|
+
3. **Orchestrate the task.** Hold the plan and the user conversation. Execute
|
|
83
|
+
workflow-backed spawns or resumes using the routing table below, and keep
|
|
84
|
+
driving while they work. Your own tool use stays orchestration and light
|
|
85
|
+
verification reads. Keep your task list updated religiously.
|
|
86
|
+
|
|
87
|
+
## Workflow Agent Routing
|
|
88
|
+
|
|
89
|
+
Every delegated task runs through a workflow-backed agent invocation. Do not
|
|
90
|
+
spawn a flat subagent directly when a workflow invocation or workflow resume is
|
|
91
|
+
available.
|
|
92
|
+
|
|
93
|
+
| Work | Agent type | Model |
|
|
94
|
+
|---|---|---|
|
|
95
|
+
| Feature, bug, and refactor coding | `clean-coder` | `opus` |
|
|
96
|
+
| Verification passes | `code-verifier` | `opus` |
|
|
97
|
+
| Script runs, GitHub posting, and backfill driving | `general-purpose` runner | `sonnet` |
|
|
98
|
+
| PR descriptions | `pr-description-writer` | `sonnet`, with file-list grounding check |
|
|
99
|
+
| Fan-out searches and checklist verification reads | `Explore` | `haiku`; use `sonnet` when judgment-heavy |
|
|
100
|
+
| Escalated blockers needing a second opinion beyond the orchestrator's own judgment | `code-advisor` | Fable preferred (matches the orchestrating session); opus if Fable is unavailable. |
|
|
101
|
+
|
|
102
|
+
Routing rules:
|
|
103
|
+
|
|
104
|
+
- Use a workflow invocation or resume for each row above. The workflow prompt
|
|
105
|
+
must name the selected agent type, model, work category, task scope, and
|
|
106
|
+
expected output.
|
|
107
|
+
- Resume a warm workflow agent before creating a new workflow run when the warm
|
|
108
|
+
agent holds the relevant context.
|
|
109
|
+
- `clean-coder` owns code edits. `code-verifier` owns verification. The same
|
|
110
|
+
workflow agent never grades work it wrote.
|
|
111
|
+
- PR-description workflows include the actual changed-file list in the prompt
|
|
112
|
+
and verify the final body against that file list before posting or returning
|
|
113
|
+
it.
|
|
114
|
+
- Exploration workflows return file paths, line numbers, and direct evidence;
|
|
115
|
+
they do not write code or mutate repo state.
|
|
116
|
+
|
|
117
|
+
4. **Executors consult at a hard decision.** Each executor's spawn prompt tells
|
|
118
|
+
it to stop and message you — with the task, what it tried, and the exact
|
|
119
|
+
blocker (plus any short code excerpt that helps) — when one of these holds:
|
|
120
|
+
- It has tried the same problem twice or more and it still fails.
|
|
121
|
+
- A decision changes the deliverable's scope or a contract that is hard to
|
|
122
|
+
reverse.
|
|
123
|
+
- Two constraints conflict and it cannot satisfy both.
|
|
124
|
+
- It is unsure whether to stop or keep going.
|
|
125
|
+
|
|
126
|
+
5. **Answer with one signal.** On a consultation, reply with exactly one
|
|
127
|
+
signal, brief (about 400 to 700 tokens):
|
|
128
|
+
- **PLAN** — a different approach, as concrete ordered steps the executor
|
|
129
|
+
can run. When a warm agent fits the plan, name which one to resume.
|
|
130
|
+
- **CORRECTION** — the executor's approach is right, one thing is wrong;
|
|
131
|
+
name the wrong step and the fix.
|
|
132
|
+
- **STOP** — no path satisfies the task as assigned; say why so it can be
|
|
133
|
+
reported upward.
|
|
134
|
+
The executor resumes the moment your reply lands.
|
|
135
|
+
|
|
136
|
+
A worked consultation:
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
Executor → advisor
|
|
140
|
+
Task: add a retry to the upload client.
|
|
141
|
+
Tried: wrapped upload() in a three-attempt loop; the second attempt
|
|
142
|
+
double-posts.
|
|
143
|
+
Blocker: the server takes no idempotency key, so a retry after a timeout
|
|
144
|
+
creates a duplicate record.
|
|
145
|
+
|
|
146
|
+
Advisor → executor
|
|
147
|
+
CORRECTION — the retry loop is right; the missing piece is a stable request
|
|
148
|
+
id. Generate one client-side on the first attempt and send the same id on
|
|
149
|
+
every retry, so the server treats the retries as one request.
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
For a decision the advisor itself cannot settle, it may use a workflow
|
|
153
|
+
escalation to the tool-less `code-advisor` agent for a second opinion — an
|
|
154
|
+
optional escalation, not a required step.
|
|
155
|
+
|
|
156
|
+
## Agent reuse (non-negotiable)
|
|
157
|
+
|
|
158
|
+
- **Resume before you spawn, always.** A warm agent carries its context and
|
|
159
|
+
cached tokens; a fresh spawn starts cold and pays to rebuild both.
|
|
160
|
+
Resume the existing workflow agent by name or `agentId` when it holds
|
|
161
|
+
relevant context. Prefer that path every time an existing workflow agent
|
|
162
|
+
matches the routing table.
|
|
163
|
+
- **Spawn a fresh agent only when** no existing agent holds relevant context,
|
|
164
|
+
or a genuine task switch needs a clean context.
|
|
165
|
+
- **Name the agent to resume.** When you answer with a PLAN and a warm agent
|
|
166
|
+
fits, say which agent to resume and where.
|
|
167
|
+
|
|
168
|
+
## Constraints
|
|
169
|
+
|
|
170
|
+
- One `/team-advisor` per session; the invocation guard blocks a second
|
|
171
|
+
reminder loop.
|
|
172
|
+
- The advisor orchestrates and advises but never edits code or runs a build or
|
|
173
|
+
test itself — executors do that.
|
|
174
|
+
- Delegated execution uses workflow-backed agent invocations and follows the
|
|
175
|
+
Workflow Agent Routing table exactly.
|
|
176
|
+
- Consultations are capped at five per task by default. At the cap, re-scope
|
|
177
|
+
or hand off; do not keep answering.
|
|
178
|
+
- Reuse a warm agent over a cold spawn whenever one holds relevant context.
|
|
179
|
+
|
|
180
|
+
## File Index
|
|
181
|
+
|
|
182
|
+
| File | Purpose |
|
|
183
|
+
|---|---|
|
|
184
|
+
| `SKILL.md` | Advisor strategy, workflow routing contract, consultation protocol, reuse rules, and constraints. |
|
|
185
|
+
|
|
186
|
+
## Folder Map
|
|
187
|
+
|
|
188
|
+
- `SKILL.md` — complete advisor workflow instructions.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: team-advisor-refresh
|
|
3
|
+
description: >-
|
|
4
|
+
Fired by the /team-advisor loop reminder about every 20 minutes to
|
|
5
|
+
re-assert the advisor discipline mid-run. A compressed restatement of
|
|
6
|
+
/team-advisor: orchestrate rather than execute, answer a blocked executor
|
|
7
|
+
with a plan, correction, or stop, and reuse warm agents before spawning new
|
|
8
|
+
ones. Triggers: '/team-advisor-refresh'.
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Team Advisor Refresh
|
|
12
|
+
|
|
13
|
+
1. **You are the advisor.** Orchestrate and hold the user conversation; spawn
|
|
14
|
+
executor subagents to do all the work — every code edit and build or test
|
|
15
|
+
run.
|
|
16
|
+
2. **An executor blocked twice on the same thing?** Answer it with one signal
|
|
17
|
+
— a plan, a correction, or a stop — brief. Never take over the edit or the
|
|
18
|
+
tests yourself.
|
|
19
|
+
3. **Resume before you spawn.** `SendMessage` an existing agent by name or
|
|
20
|
+
`agentId` to reuse its warm context; prefer that over a cold spawn.
|
|
21
|
+
4. **Fresh spawn only for a genuine task switch.** No tool compacts or clears a
|
|
22
|
+
subagent's context, so a clean context comes from a fresh spawn — never tell
|
|
23
|
+
an agent to compact.
|
|
24
|
+
5. **Re-schedule the next refresh** (about 1200 seconds out) when the loop
|
|
25
|
+
mechanism needs each firing to queue the following one.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: usage-pause
|
|
3
|
+
description: Waits out the account's 5-hour usage window in ScheduleWakeup stages that keep every agent context warm. Resolves the window's reset time and remaining headroom by probing the OAuth usage endpoint, or takes a manual override ('/usage-pause 10:20pm', '/usage-pause 74m'). Warns and stops when the weekly limit is near its cap. Each wakeup pings live and idle-warm agents with a one-line no-new-work checkpoint and records finished results; the final wakeup restores the crons the skill cancelled at pause time. Triggers: '/usage-pause', 'pause until the usage window resets', 'wait out the usage limit', 'usage limit pause'.
|
|
4
|
+
argument-hint: "[reset time like 10:20pm | duration like 74m]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /usage-pause
|
|
8
|
+
|
|
9
|
+
Pause on purpose before a usage limit kills in-flight work. The skill reads the 5-hour session window's reset time and remaining headroom, breaks the wait into ScheduleWakeup stages, keeps every agent context warm through the pause with checkpoint pings, and hands control back after the reset.
|
|
10
|
+
|
|
11
|
+
## Step 1 — resolve the usage window
|
|
12
|
+
|
|
13
|
+
Run the bundled resolver:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
python "${CLAUDE_SKILL_DIR}/scripts/resolve_usage_window.py"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
With an argument (`/usage-pause 10:20pm`, `/usage-pause 74m`), skip the probe and pass it through:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
python "${CLAUDE_SKILL_DIR}/scripts/resolve_usage_window.py" --override "10:20pm"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
On exit 0 the script prints one JSON object:
|
|
26
|
+
|
|
27
|
+
| Field | Meaning |
|
|
28
|
+
|---|---|
|
|
29
|
+
| `source` | `probe` or `override` |
|
|
30
|
+
| `reset_at` | When the 5-hour window resets (ISO-8601, local zone) |
|
|
31
|
+
| `seconds_until_reset` | The wait the stage plan covers |
|
|
32
|
+
| `stages_seconds` | The ScheduleWakeup stage durations, in firing order |
|
|
33
|
+
| `session_utilization` | Percent of the 5-hour window spent (null on override) |
|
|
34
|
+
| `weekly_utilization` | Percent of the weekly window spent (null on override) |
|
|
35
|
+
| `weekly_resets_at` | When the weekly window resets (null on override) |
|
|
36
|
+
| `weekly_near_cap` | True when the weekly meter is at or past 90 percent |
|
|
37
|
+
|
|
38
|
+
On exit 2 the script prints `{"error": ...}`. Ask the user for a manual reset time via AskUserQuestion (offer clock-time and duration examples), then rerun with `--override`.
|
|
39
|
+
|
|
40
|
+
### Probe mechanism
|
|
41
|
+
|
|
42
|
+
The resolver reads the Claude Code CLI's OAuth access token from `~/.claude/.credentials.json` (`claudeAiOauth.accessToken`, honored only while its `expiresAt` sits in the future) and sends `GET https://api.anthropic.com/api/oauth/usage` with `Authorization: Bearer <token>` and `anthropic-beta: oauth-2025-04-20`. This is the same endpoint the interactive `/usage` panel reads. The response carries a `five_hour` bucket and a `seven_day` bucket, each with `utilization` (percent spent) and `resets_at`.
|
|
43
|
+
|
|
44
|
+
Fallbacks, in order: an expired or unreadable stored token, a failed request, or a response with no readable `five_hour` reset time all end in exit 2 — the manual-override ask above. The manual path works with no probe at all, so the skill functions even when the credential file is stale.
|
|
45
|
+
|
|
46
|
+
Why this probe and not the others:
|
|
47
|
+
|
|
48
|
+
- The interactive `/usage` panel shows the same data but has no scriptable output.
|
|
49
|
+
- `claude -p --output-format json` spends usage to answer and its metadata reports per-call token counts, not the account window clock.
|
|
50
|
+
- `anthropic-ratelimit-*` response headers cover API-key Messages traffic, not the subscription session window, and reading them also costs a request.
|
|
51
|
+
- Refreshing the OAuth token from a script is out of scope: token rotation would desync the refresh token the CLI has on disk and log the CLI out. The resolver only ever reads the credential file.
|
|
52
|
+
|
|
53
|
+
## Weekly limit guard
|
|
54
|
+
|
|
55
|
+
When `weekly_near_cap` is true, WARN the user — report `weekly_utilization` and `weekly_resets_at` — and stop. No pause choreography runs around the weekly limit; waiting out a weekly window is its own later build.
|
|
56
|
+
|
|
57
|
+
## Step 2 — the pause chain
|
|
58
|
+
|
|
59
|
+
Before the first sleep:
|
|
60
|
+
|
|
61
|
+
1. List active recurring loops (CronList). Record each one's schedule and prompt, then cancel it (CronDelete). Carry the recorded list inside the wakeup prompts so the state survives every stage.
|
|
62
|
+
2. Schedule the first stage with ScheduleWakeup, using the first duration in `stages_seconds` and the stage prompt template below.
|
|
63
|
+
|
|
64
|
+
The stage plan keeps every stage at or under 58 minutes (3480 seconds, inside the 3600-second clamp) and ends with a roughly 2-minute tail stage so the final firing lands just past the reset. A leftover too short to stand alone folds into the tail.
|
|
65
|
+
|
|
66
|
+
Every wakeup does exactly three things — ping, record, schedule — and dispatches no new work. The cache rationale: an unpinged idle agent left past the cache window resumes cold and re-reads its whole transcript, so pings run tighter than the cache lifetime and keep each agent's next real invocation cheap.
|
|
67
|
+
|
|
68
|
+
### Stage wakeup prompt template
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
/usage-pause stage <stage_number> of <stage_total>: pausing until <reset_time_local>.
|
|
72
|
+
Remaining chain (seconds): <remaining_stage_durations>. Cancelled crons: <cancelled_crons_json>.
|
|
73
|
+
1. Ping every live agent AND every idle-but-warm agent with exactly this one line:
|
|
74
|
+
"status checkpoint: reply with where you stand, do not start new work"
|
|
75
|
+
An unpinged idle agent past the cache window resumes cold and re-reads its whole
|
|
76
|
+
transcript; the ping keeps its next real invocation cheap.
|
|
77
|
+
2. Record any finished agent results on the task list. Dispatch nothing.
|
|
78
|
+
3. Take the first duration off the remaining chain and ScheduleWakeup it, passing this
|
|
79
|
+
same prompt with that duration removed and the stage number advanced. When the
|
|
80
|
+
remaining chain is empty, schedule nothing further and treat the next firing as final.
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Final wakeup prompt template
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
/usage-pause final stage: the 5-hour window reset at <reset_time_local>.
|
|
87
|
+
1. Ping every live and idle-but-warm agent with exactly:
|
|
88
|
+
"status checkpoint: reply with where you stand, do not start new work"
|
|
89
|
+
2. Record any finished agent results on the task list.
|
|
90
|
+
3. Restore every cron in <cancelled_crons_json>: CronCreate each one with its recorded
|
|
91
|
+
schedule and prompt.
|
|
92
|
+
4. Hand control back to normal orchestration and resume work from the task list.
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Fill each `<slot>` at schedule time: `<remaining_stage_durations>` is the tail of `stages_seconds` after the stage being scheduled, and `<cancelled_crons_json>` is the recorded cron list from pause time, carried verbatim through every stage.
|
|
96
|
+
|
|
97
|
+
## Layout
|
|
98
|
+
|
|
99
|
+
| File | Role |
|
|
100
|
+
|---|---|
|
|
101
|
+
| `SKILL.md` | This flow: resolve, weekly guard, stage chain, templates |
|
|
102
|
+
| `scripts/resolve_usage_window.py` | The window resolver and stage planner CLI |
|
|
103
|
+
| `scripts/test_resolve_usage_window.py` | Behavioral tests for parsing, staging, token reading, extraction, CLI |
|
|
104
|
+
| `scripts/usage_pause_constants/resolve_usage_window_constants.py` | Endpoint, credential keys, stage sizing, thresholds, result keys |
|
|
105
|
+
|
|
106
|
+
## Gotchas
|
|
107
|
+
|
|
108
|
+
- The stored access token lives about 8 hours and the CLI rewrites it on its own schedule, so a mid-afternoon probe can find it expired even while the CLI itself still works. That is the designed exit-2 path: give a manual time.
|