Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Archive?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/matthewwong525-archive-3e7ea6b5)
<!-- openspec-archive v1 2026-09-21-add-general-improve-skill -->
<!-- file proposal.md utf8 4003 -->
# Add a general repository improvement skill
**Status:** ready-to-ship
**Branch:** add-improve-skill-maintenance
**Open questions:** none
## Why
Fast delivery can leave duplicated rules, stale guidance, and faults that ordinary feature review misses. WongStack needs a repeatable spot check that finds useful maintenance work and delivers one supported improvement through the existing workflow.
## What Changes
- Add `/improve [area]` to investigate maintenance candidates and ship one coherent change through `/ship`; retain `--audit-only`, no-change, and blocked outcomes. (review.html#/delivery/after/handoff)
- Review recent changes plus a rotating older area, with a read-only survey script for inventory and bounded leads. Use prior change records to avoid repeating completed work. (review.html#/coverage/weekly)
- Provide general investigation guidance for documentation, consolidation, reliability, security, performance, and workflow tools. Require evidence and a verification probe before selecting work.
- Support interactive selection and explicitly unattended external jobs. Preserve user decisions, normal delivery gates, and complete stages for larger improvements. (review.html#/execution)
- Distribute the skill through the core payload, document its use, and publish an additive minor release. (review.html#/payload)
**Non-goals:** Installing a scheduler, a complete security audit, automatic feature retirement, broad dependency upgrades, a new backlog/report database, or changes to the existing delivery gates.
## Capabilities
### New Capabilities
- `repository-improvement`: Recurring repository spot checks, evidence-based selection, and one-change delivery.
### Modified Capabilities
None. The existing workflow remains the delivery owner.
## Impact
Add a skill, supporting references, and dependency-free Node scripts under `.agents/skills/improve/`. Update the payload inventory and applicable setup/discovery surfaces, README, generic agent instructions, and the owning workflow documentation. Add fixture-based script coverage to the existing payload CI. No application runtime or external service changes are required.
## Decision log
- 2026-09-21: Asked how far a normal run should go → user chose one change delivered through `/ship`.
- 2026-09-21: Asked whether scheduling belongs in this change → user chose support for manual/external weekly runs, with no scheduler installed here.
- 2026-09-21: Asked how to divide review effort → user chose recent changes plus a rotating older area.
- 2026-09-21: Assumed the skill belongs in the core payload because the request is to generalize ClaymooApp's maintenance workflow for WongStack repositories.
- 2026-09-21: Assumed `--audit-only`, meaningful staged consolidation, and a no-change result remain useful from ClaymooApp. They bound delivery without forcing cosmetic work.
- 2026-09-21: Assumed scheduled prompts or trusted host context explicitly identify unattended execution. A pending interactive question cannot establish that nobody can answer.
- 2026-09-21: Use deterministic code for inventory, date-based rotation, and bounded leads; retain model judgment for reachability, intended behavior, impact, and selection.
- 2026-09-21: Implemented the portable `/improve` skill, bounded survey and history rotation, scenario fixtures, core payload registration, external scheduling guide, and the 16.2.0 release surfaces. Required payload, configuration, review-scope, and strict OpenSpec checks passed; the delegated save now supplies the CI gate.
- 2026-09-21: CI passed for the completed implementation on PR #91. Archived the change with the synchronized `repository-improvement` capability spec; the delegated archive checkpoint now gates the exact record that will merge.
- 2026-09-21: Merged current `origin/main` after PR #90 landed the independent 16.1.1 payload-CI fix. Preserved that workflow, archive, spec, note, and changelog entry; 16.2.0 remains the next additive minor release.
<!-- end proposal.md -->
<!-- file design.md utf8 11212 -->
## Context
See [the proposal](proposal.md) for scope and user choices. ClaymooApp has a working maintenance skill, a tracked-file survey, and investigation references. Its fixed app paths, main-branch assumption, and ambiguous unattended fallback do not fit a general toolkit. WongStack owns delivery through `/ship` and distributes skills from a manifest.
## Goals / Non-Goals
**Goals:** Reuse the useful maintenance method, discover target structure, make repeated runs bounded, and keep evidence and delivery in existing records.
**Non-Goals:** Language-complete static analysis, a new scheduler or state database, guaranteed security coverage, or a separate implementation/merge pipeline.
## Decisions
### 1. A thin skill with deterministic survey helpers
Keep the run sequence and handoff in `SKILL.md`; put consolidation and security investigation guidance in references. Adapt the Node survey with no new runtime dependencies. Inventory tracked current text, missing local links, repeated blocks, large files, and security-sensitive locations. Emit bounded JSON with explicit exclusions, supported file types, read failures, and revision information. Do not emit source snippets or secret values.
Discover documentation and source roots from current files and owning docs. Do not require Cloudflare, React, TypeScript, or an app directory. Inspect unsupported languages manually when relevant and report the gap. Honor the real `.agents/` tracked layout and `.claude/` alias without counting both. Reject escaped scopes and file reads through symlinks outside the repo. A safely resolved in-repo scope alias can map to its real tracked path.
Alternative: model-only inventory repeats expensive work and can miss files inconsistently. A full cross-language scanner would add dependencies and overstate the scope of a spot check.
### 2. Recent changes plus rotation without a report database
Read relevant active OpenSpec changes, open PRs, and prior maintenance records before selection. Use the latest usable `Maintenance-Revision:` baseline from shipped maintenance records for the recent range; otherwise use the last seven days and state the fallback. If the baseline is unavailable or not an ancestor, report that and use the bounded fallback. A long gap can require sampling; name any omitted range.
Discover a stable, sorted list of maintained areas from tracked files. Group top-level roots, splitting skill and monorepo package roots into useful children. Exclude generated files, secrets, and historical records from routine candidate scanning. Choose a rotation start with a UTC week ordinal modulo the number of areas, then walk the list to find an area outside the recent-change set when possible. A testable date input keeps selection reproducible. With unchanged areas this cycles through the list across weeks, including weeks with no saved fix. Same-week runs can revisit an area; the skill still checks prior outcomes before choosing work. If all areas changed recently, state the overlap and select the rotation target anyway. A user-supplied area bounds both passes.
Use history to explain intent and recurrence, not as a bulk source of stale cleanup candidates. The selected change records `Maintenance-Origin: /improve`, `Maintenance-Revision: <surveyed commit>`, `Maintenance-Area: <rotation area>`, coverage limits, and the selection rationale in its Decision log. No-change and audit-only runs return this context in the captured output without creating a commit merely to advance rotation.
Alternative: a persistent cursor gives exact visit tracking but forces report-only writes. Calendar rotation needs no new store; it cannot guarantee that skipped weeks or a changed area list cover every area.
### 3. Investigate and select by real impact
Rank a short list with path/line evidence, concrete impact, confidence, relevant prior work, expected behavior, scope, and a verification probe. Trace security leads from controlled input through actual checks to the affected action. Verify advisories against current authoritative sources when dependency risk is investigated. Treat pattern matches and tool failures as leads or limits, never a clean bill of health.
Consolidation requires shared meaning, not similar syntax. Dead-code removal requires runtime and external caller investigation. Documentation changes must follow owning docs and the target's wiki rules. Treat selected documentation maintenance as explicit task scope. Preserve historical notes and archives. Broad dependency upgrades stay with a separately requested dependency workflow; a confirmed vulnerable dependency can be a bounded candidate.
Prefer confirmed faults and material recurring maintenance cost. Larger work can ship in independently correct stages, using ClaymooApp's `Maintenance-Stage:` and `Maintenance-Next:` markers in the normal Decision log. The final stage has no next marker. Recheck whether prior staged work is still needed instead of blindly continuing it.
### 4. Clear execution context and one delivery owner
Normal invocation authorizes one eligible improvement through `/ship`; merely discussing the skill does not. An interactive run shows the investigated candidates and uses one question group for material selection or behavior choices before editing. Carry answers into nested exploration so settled questions are not repeated.
A scheduled job supplies explicit unattended context, for example: `Run /improve unattended. Choose supported defaults within its eligible scope and report blockers.` Trusted host context can supply the same fact. Do not infer unattended execution from time, silence, or a tool returning no answer. In unattended mode record supported defaults as assumed, defer unresolved policy decisions, and continue with an independent eligible candidate only before delivery starts.
The scheduler supplies a clean dedicated checkout at the current remote default-branch revision and serializes runs. Discover the default branch; do not hard-code `main`. Read freshness and overlap context using available read-only mechanisms. If a required refresh or checkout is needed, leave it to the existing git-owning workflow or scheduler; `/improve` does not gain git mutation steps. Missing overlap/freshness evidence blocks normal delivery. Audit-only can report findings with those limits and does not fetch or write.
Pass the chosen intent, evidence, expected behavior, probe, user answers, and maintenance markers into `/ship`. Preserve its gates and blockers. Do not change candidates once delivery starts. Defer feature retirement, uncertain product/auth policy, destructive data work, and credential/account operations. Reports use shipped, audit only, no change, or blocked and include coverage, deferred decisions, and any delivery evidence.
Alternative: copying the git pipeline would create two workflow owners. A silence-based scheduled fallback cannot distinguish an absent user from a pending answer.
### 5. Distribute and verify as one additive release
Register the skill and its references/scripts in the core inventory. Update setup collision/seed surfaces only where the current implementation names skills. Add usage and scheduling guidance to the owning workflow docs and link it from discovery surfaces. Do not perform unrelated wiki cleanup. Use the next minor version at implementation time; the current base is 16.1.0.
Add Node fixture tests to existing payload CI for inventory, path containment, aliases, partial results, supported-type limits, deterministic rotation, changing area sets, baseline fallback, and read-only behavior. Review the skill against concrete scenarios for interactive/unattended selection, active work overlap, no-change, audit-only, staged work, and blocked delivery. Use `/save` for CI evidence during implementation. Run the required payload link and OpenSpec config release checks.
## Risks / Trade-offs
- Heuristics miss defects and can produce noise → require targeted investigation and explicit coverage limits.
- Rotation can repeat or skip areas when the tree changes or weeks are missed → disclose the selected area and do not claim full coverage.
- A clean local tree can still be stale → require verified remote freshness before normal delivery.
- Weekly changes can expand into broad refactors → select one coherent improvement; stage only independently correct changes.
- A dependency fix can become a general update → bound it to the verified finding and preserve the separate update workflow.
## Scenario review
| Specification scenario | Concrete implementation or fixture |
| --- | --- |
| Weekly run with unchanged areas | `selectRotation` uses the UTC week ordinal and the fixture advances the date by seven days. |
| First run, unavailable baseline, or no saved change | `selectRecentRange` reports seven-day or repository-start fallback; rotation depends on the date, not a saved cursor. Fixtures cover no record and rejected revisions. |
| Unsupported source or failed read | The survey lists supported extensions and returns bounded read errors with `partial`; the skill requires manual investigation or an unverified limit. |
| Escaped scope | Literal-path fixtures reject `..` and an external symlink while accepting an in-repo `.claude` alias to tracked `.agents` files. |
| Security pattern with protection | The security reference requires a reachable controlled input and an ineffective check. Its authentication and authorization example prevents a pattern-only finding. |
| No worthwhile candidate | The selection section returns `no change` and forbids filler work or a report commit. |
| Interactive user has not answered | The execution-context section keeps the question pending and forbids inference from silence, elapsed time, or tool availability. |
| External unattended job | The skill and owning guide give the exact unattended prompt and label defaults `assumed`. |
| Unavailable overlap or freshness | Normal delivery stops before selection; audit-only can continue with revision, dirty state, and limits reported. |
| Failed delivery | `/ship` retains all gates; the skill reports `blocked` and does not choose a second candidate or weaker path. |
| Audit-only on a dirty checkout | Audit-only performs no fetch or write and reports revision and dirty state. |
| Final staged delivery | The last stage records its terminal `Maintenance-Stage:` marker and omits `Maintenance-Next:`. |
| Documentation-only repository | A fixture surveys only root, `docs/`, and `wiki/` Markdown files and selects a rotation area without an app tree. |
| Existing target-owned skill | The core inventory uses the install record's local-name mapping; the manifest guide states that local mappings win and are not overwritten. |
No scenario remains unmet in the implementation or planned CI fixtures.
## Migration Plan
Ship as a new core skill through normal setup/sync adaptation. Preserve an existing target-owned `/improve` through collision handling and its recorded local name. No scheduler or application migration is needed. Revert the additive payload change through the normal workflow if necessary; retain historical maintenance records.
<!-- end design.md -->
<!-- file tasks.md utf8 2909 -->
## 1. Survey scripts and coverage
- [x] 1.1 Adapt a dependency-free tracked-file survey under `.agents/skills/improve/scripts/`, with literal scope handling, safe in-repo aliases, bounded output, explicit gaps, and no secret snippets. Follow [coverage](review.html#/coverage).
- [x] 1.2 Implement testable maintained-area discovery, UTC weekly rotation, recent-range baseline selection, and documented fallbacks. Follow [coverage](review.html#/coverage).
- [x] 1.3 Add fixture tests under `scripts/tests/` for docs-only and mixed-language repos, symlinks and escaped scopes, partial reads, bounded output, read-only behavior, week changes, changed/empty area lists, narrowed scope, and missing/non-ancestor baselines. Keep them in the existing payload CI test command.
## 2. Skill and investigation guidance
- [x] 2.1 Add `/improve [area]` and `--audit-only`, target discovery, clean/current checkout and overlap checks, evidence-based selection, no-change and blocked outcomes, and the one-intent `/ship` handoff. Follow [delivery](review.html#/delivery).
- [x] 2.2 Add general security and consolidation references, including intended behavior, actual callers, trust boundaries, source ownership, verification probes, and limitations. Remove ClaymooApp-specific assumptions.
- [x] 2.3 Define interactive candidate questions, explicit unattended context, maintenance revision/area records, staged continuation and terminal markers, and reporting. Preserve normal workflow authority and gates. Follow [execution](review.html#/execution).
- [x] 2.4 Review the skill against every specification scenario with concrete examples. Cover unanswered questions, audit-only dirty trees, unavailable overlap/freshness context, protected security patterns, no eligible work, staged completion, and failed delivery. Record any unmet scenario and resolve it before completion.
## 3. Payload and documentation
- [x] 3.1 Register the skill directory in the core payload inventory and update applicable installer/discovery surfaces. Preserve target-owned skill collision handling. Follow [payload](review.html#/payload).
- [x] 3.2 Add usage and external scheduling guidance to the owning workflow documentation and its discovery links. Update README and the generic agent-instruction block; keep unrelated wiki work out of scope. Follow [payload](review.html#/payload).
- [x] 3.3 Bump the current release to the next minor version and add a newest-first changelog entry. Follow [payload](review.html#/payload).
## 4. Release verification
- [x] 4.1 Run the required payload link and OpenSpec config release checks, validate this change strictly, and confirm the review page matches the final scope.
- [x] 4.2 Use `/save` to run the existing CI gate, including the new fixture coverage; resolve failures and record the result. This task supplies the completion checkpoint if it saves the final task state, per `/apply`.
<!-- end tasks.md -->
<!-- file specs/repository-improvement/spec.md utf8 5828 -->
## Purpose
Provide recurring, evidence-based repository spot checks that improve maintainability and catch supported defects through the existing delivery workflow.
## ADDED Requirements
### Requirement: Bounded review with disclosed coverage
The skill SHALL review recent changes and a rotating maintained area unless the user narrows scope. It SHALL use prior maintenance and active work records to avoid duplicate work and SHALL disclose exclusions, missing history, and incomplete reads.
#### Scenario: Weekly run with unchanged area inventory
- **WHEN** broad runs occur in successive weeks with multiple maintained areas
- **THEN** the rotation start advances reproducibly through the area list, the run prefers an area outside recent changes when available, and each run also reviews recent changes
#### Scenario: First run or unavailable baseline
- **WHEN** no usable prior maintenance revision exists
- **THEN** the run uses a stated bounded recent-history fallback and still selects a rotation area
#### Scenario: No change was saved last week
- **WHEN** the prior run found no eligible improvement
- **THEN** the next week's rotation can advance without requiring a maintenance-state commit
### Requirement: Read-only survey with explicit limits
The survey SHALL collect bounded current tracked-file leads without installing tools, contacting services, modifying repository files, or emitting secret values. It SHALL report its supported inputs, exclusions, and failures and SHALL NOT label a repository safe from an empty result.
#### Scenario: Unsupported source language or failed read
- **WHEN** files cannot be analyzed by a survey check
- **THEN** the report exposes the coverage gap and the agent investigates it or states it as unverified
#### Scenario: Escaped scope
- **WHEN** a scope or symlink resolves outside the repository
- **THEN** the survey refuses that read and does not scan the external target
### Requirement: Evidence-based maintenance selection
The skill SHALL investigate and rank candidates with concrete evidence, impact, expected behavior, and a verification probe. Eligible work SHALL include documentation, consolidation, reliability, security, measured performance, and workflow maintenance. It SHALL permit no change when no worthwhile candidate is supported.
#### Scenario: Security pattern with existing protection
- **WHEN** a sensitive pattern is found but investigation shows an effective existing check
- **THEN** the pattern alone does not justify a vulnerability finding or repair
#### Scenario: No worthwhile candidate
- **WHEN** investigation produces no supported eligible improvement
- **THEN** the run reports no change and its coverage limits without manufacturing a cleanup
### Requirement: Explicit execution context
Interactive runs SHALL present investigated candidates and ask one group of material questions before selection is handed off. Explicitly unattended runs SHALL use supported defaults, label them assumed, and defer decisions outside maintenance authority. An unanswered interactive question SHALL remain pending.
#### Scenario: Interactive user has not answered
- **WHEN** a material selection question remains unanswered
- **THEN** the run does not reinterpret silence as unattended execution or permission
#### Scenario: External unattended job
- **WHEN** the invocation or trusted host context explicitly establishes unattended execution
- **THEN** the run can choose an eligible candidate with recorded assumptions without waiting for interactive answers
### Requirement: One change through existing delivery
A normal run SHALL pass one coherent selected intent to `/ship`, preserve all delivery gates, and report blockers. It SHALL require a clean dedicated current checkout and sufficient active-work context before delivery. It SHALL NOT take over unrelated work, perform its own git mutations, or select another fix after delivery starts.
#### Scenario: Active work or freshness cannot be verified
- **WHEN** required context is unavailable or the checkout contains unrelated unfinished work
- **THEN** normal delivery stops with the condition reported
#### Scenario: Delivery fails a gate
- **WHEN** the existing workflow blocks the selected change
- **THEN** the run reports blocked and preserves the work without a weaker delivery path
### Requirement: Audit-only and staged outcomes
Audit-only runs SHALL report ranked findings without edits, fetches, delivery, or durable report creation. A larger improvement SHALL be split only into independently correct stages, with discoverable continuation and completion recorded in the normal change history.
#### Scenario: Audit-only on a dirty checkout
- **WHEN** the user invokes audit-only on local work
- **THEN** the run reports the revision and dirty state with findings and leaves the checkout unchanged
#### Scenario: Final stage completes
- **WHEN** a staged improvement's last independently correct change ships
- **THEN** its record identifies the terminal stage and contains no next-stage instruction
### Requirement: Portable payload and external cadence
The skill SHALL ship in the core payload and discover target repository conventions without requiring ClaymooApp paths or a particular stack. Scheduling SHALL remain external, with documented checkout, serialization, and unattended-context requirements.
#### Scenario: Documentation-only target repository
- **WHEN** the target has documentation and process files but no application source tree
- **THEN** the skill can investigate relevant maintenance without requiring an app runtime
#### Scenario: Existing target-owned improve skill
- **WHEN** setup or sync encounters a local skill with the same name
- **THEN** normal collision/adaptation rules preserve local work rather than silently replacing it
<!-- end specs/repository-improvement/spec.md -->
<!-- file .openspec.yaml utf8 40 fence=~~~ -->
~~~yaml
schema: spec-driven
created: 2026-09-21
~~~
<!-- end .openspec.yaml -->
<!-- file review-visuals.html utf8 11211 fence=~~~ -->
~~~html
<section class="visual flow" id="delivery" data-kind="flow" data-states="after today" data-state="after">
<p class="caption">One maintenance run has one delivery owner and an explicit result.</p>
<div class="frame">
<div class="state state-after"><div class="flow-sequence">
<div class="step flow-card" data-target-id="delivery-investigate"><h3>Investigate candidates <span class="tag">New</span></h3><p>Survey the repository, then confirm impact and a verification probe.</p><details><summary>Details</summary><p>Read owning documents, active work, and prior maintenance records. A pattern match is a lead. It does not establish a defect.</p></details></div>
<p class="flow-connector">↓ Choose the applicable path</p>
<div class="flow-branches">
<div class="flow-branch" data-target-id="delivery-ship" data-mark="handoff"><h3>Eligible change <span class="tag">Existing workflow</span> <i class="callout">1</i></h3><p>Select one change and invoke <code>/ship</code>.</p><details><summary>Details</summary><p>Pass the evidence, expected behavior, probe, answers, and maintenance markers. The existing workflow owns planning, implementation, git, checks, and merge. Do not switch candidates once delivery starts.</p></details></div>
<div class="flow-branch" data-target-id="delivery-audit"><h3>Audit only <span class="tag">New</span></h3><p>Return findings and limits without edits.</p><details><summary>Details</summary><p><code>--audit-only</code> does not fetch, write, or invoke delivery. It can report findings when freshness or overlap evidence is unavailable.</p></details></div>
<div class="flow-branch" data-target-id="delivery-none"><h3>No useful change <span class="tag">New</span></h3><p>Report no change.</p><details><summary>Details</summary><p>Do not force cosmetic work or create a commit just to record the run.</p></details></div>
<div class="flow-branch" data-target-id="delivery-blocked"><h3>Required condition missing <span class="tag">New</span></h3><p>Report blocked.</p><details><summary>Details</summary><p>Name missing context or the delivery gate that could not pass. A selected change is not shipped until the existing workflow completes.</p></details></div>
</div>
<p class="flow-connector">↓ All paths join at the run report</p>
<div class="step flow-card" data-target-id="delivery-report"><h3>Report the actual result <span class="tag">New</span></h3><p>Shipped · audit only · no change · blocked</p><details><summary>Details</summary><p>Include coverage, deferred decisions, and available delivery evidence. A failed delivery reports blocked, never shipped.</p></details></div>
</div></div>
<div class="state state-today"><div class="flow-sequence">
<div class="step flow-card" data-target-id="delivery-today-intent"><h3>User supplies an improvement <span class="tag">Today</span></h3><p>WongStack has no general recurring maintenance entry point.</p><details><summary>Details</summary><p>The user or a separate investigation identifies work worth doing.</p></details></div>
<p class="flow-connector">↓</p>
<div class="step flow-card" data-target-id="delivery-today-workflow"><h3>Run the normal change workflow <span class="tag">Unchanged</span></h3><p>Existing verbs plan, implement, check, and ship.</p><details><summary>Details</summary><p>The proposed skill supplies a supported intent to this workflow. It does not create a second delivery pipeline.</p></details></div>
</div></div>
</div>
<div class="notes"><ol><li>A normal invocation authorizes one eligible improvement through <code>/ship</code>. Discussing or reviewing this skill does not authorize a maintenance run.</li></ol></div>
</section>
<section class="visual flow" id="coverage" data-kind="flow">
<p class="caption">Two review passes feed one investigation. Rotation requires no new report database.</p>
<div class="frame"><div class="flow-sequence">
<div class="step flow-card" data-target-id="coverage-inventory"><h3>Discover maintained areas <span class="tag">New script</span></h3><p>Read tracked files and apply the optional area scope.</p><details><summary>Details</summary><p>Sort areas consistently. Split skill and package roots into useful children. Exclude generated files, secrets, and historical records from routine scanning. Report exclusions and read failures.</p></details></div>
<p class="flow-connector">↓ Run both passes</p>
<div class="flow-branches">
<div class="flow-branch" data-target-id="coverage-recent"><h3>Recent changes <span class="tag">New</span></h3><p>Inspect changes since the last usable maintenance baseline.</p><details><summary>Details</summary><p>Use the surveyed revision from a shipped maintenance record. If it is absent, unavailable, or no longer an ancestor, use the last seven days and state the fallback. Name any range omitted through sampling.</p></details></div>
<div class="flow-branch" data-target-id="coverage-rotation" data-mark="weekly"><h3>One rotating area <span class="tag">New</span> <i class="callout">1</i></h3><p>Use the UTC week to choose a start in the sorted area list.</p><details><summary>Details</summary><p>Walk from that start to an area outside the recent set when possible. If all areas changed recently, select the rotation target and report overlap. Same-week runs can revisit an area.</p></details></div>
</div>
<p class="flow-connector">↓ Both passes join at candidate investigation</p>
<div class="step flow-card" data-target-id="coverage-history"><h3>Check evidence and prior work <span class="tag">New</span></h3><p>Remove completed or overlapping work from the candidate list.</p><details><summary>Details</summary><p>Read active changes, open PRs, and past maintenance outcomes. History explains intent; old records are not a bulk source of cleanup candidates.</p></details></div>
<p class="flow-connector">↓</p>
<div class="step flow-card" data-target-id="coverage-record"><h3>Preserve coverage context <span class="tag">New</span></h3><p>Record revision, rotation area, limits, and selection rationale.</p><details><summary>Details</summary><p>A selected change carries the maintenance markers in its Decision log. Audit-only and no-change runs return this context in their output without a report-only commit.</p></details></div>
</div></div>
<div class="notes"><ol><li>Calendar rotation advances without a saved fix. Missed weeks and changes to the area list can leave gaps, so a run must not claim full repository coverage.</li></ol></div>
</section>
<section class="visual flow" id="execution" data-kind="flow">
<p class="caption">Execution context controls how the run resolves material choices.</p>
<div class="frame"><div class="flow-sequence">
<div class="step flow-card" data-target-id="execution-context"><h3>Read explicit run context <span class="tag">New</span> <i class="callout">1</i></h3><p>Interactive by default; unattended only when stated.</p><details><summary>Details</summary><p>A job prompt or trusted host context can establish unattended execution. Time, silence, and an unanswered question cannot.</p></details></div>
<p class="flow-connector">↓ Follow the declared context</p>
<div class="flow-branches">
<div class="flow-branch" data-target-id="execution-interactive"><h3>Interactive <span class="tag">New</span></h3><p>Show investigated candidates and resolve material choices in one question group.</p><details><summary>Details</summary><p>Wait for pending answers before dependent decisions. Carry those answers into nested exploration so settled questions are not repeated.</p></details></div>
<div class="flow-branch" data-target-id="execution-unattended"><h3>Explicitly unattended <span class="tag">New</span></h3><p>Use supported defaults and record them as assumptions.</p><details><summary>Details</summary><p>Defer unresolved product or policy choices. Before delivery starts, another independent eligible candidate can be selected. If none is eligible, report the blocker.</p></details></div>
</div>
<p class="flow-connector">↓ Both paths join at the same delivery checks</p>
<div class="step flow-card" data-target-id="execution-gates"><h3>Confirm delivery conditions <span class="tag">Preserved</span></h3><p>Verify freshness, work overlap, scope, and existing workflow gates.</p><details><summary>Details</summary><p>The scheduler supplies a clean dedicated checkout at the current remote default branch and serializes runs. Missing freshness or overlap evidence blocks normal delivery. Git changes remain with the existing workflow or scheduler.</p></details></div>
<p class="flow-connector">↓ Continue only if eligible; otherwise stop and report blocked</p>
<div class="step flow-card" data-target-id="execution-stage"><h3>Keep each delivered stage complete <span class="tag">New guidance</span></h3><p>One change per run can be a complete stage of larger work.</p><details><summary>Details</summary><p>Each stage must be correct on its own. Record its stage and possible next step in the normal Decision log. Recheck whether that next step is still useful on a later run.</p></details></div>
</div></div>
<div class="notes"><ol><li>The skill is ready for an external weekly job. This change installs no scheduler and does not treat silence as an answer.</li></ol></div>
</section>
<section class="visual tree" id="payload" data-kind="tree">
<p class="caption">Core payload additions and the surfaces that make them available to other repositories.</p>
<div class="frame"><ul>
<li class="add" data-target-id="distribution-skill"><code>.agents/skills/improve/SKILL.md</code> <span class="why">run sequence and handoff to the existing workflow</span></li>
<li class="add" data-target-id="distribution-references"><code>.agents/skills/improve/references/</code> <span class="why">general investigation guidance</span></li>
<li class="add" data-target-id="distribution-scripts"><code>.agents/skills/improve/scripts/</code> <span class="why">read-only survey; no new dependencies</span></li>
<li class="add" data-target-id="distribution-tests"><code>scripts/tests/</code> <span class="why">new survey fixture tests; the existing CI runner discovers them</span></li>
<li class="edit" data-target-id="distribution-inventory">Core payload inventory and setup discovery <span class="why">copy the new skill; preserve target-owned name collisions</span> <i class="callout">1</i></li>
<li class="edit" data-target-id="distribution-docs">README, generic agent instructions, and owning workflow docs <span class="why">discovery, manual use, and external job contract</span></li>
<li class="edit" data-target-id="distribution-release"><code>VERSION</code> and <code>CHANGELOG.md</code> <span class="why">next minor release at implementation time</span></li>
</ul></div>
<div class="notes"><ol><li>Ship through the normal core payload. Existing repositories receive the skill through their usual setup or sync workflow; an existing local <code>/improve</code> remains subject to collision handling.</li></ol></div>
</section>
~~~
<!-- end review-visuals.html -->
<!-- file review.html utf8 56101 fence=~~~ -->
~~~html
<!-- wong-review:2 -->
<!doctype html>
<!--
WongStack review kit. The shared offline viewer lives here.
Authors write review-visuals.html using review-author.md and review-examples.html.
build-review.mjs fills the proposal and visual slots. Generated pages contain
the viewer, so archives open without a server or adjacent source files.
-->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Review — add-general-improve-skill</title>
<style>
:root { --ink:#333; --line:#9a9a9a; --fill:#e9e9e9; --fill2:#f6f6f6; --note:#fff4c2; --mark:#1a73e8; --markbg:#eaf2fd; }
* { box-sizing:border-box; }
body { margin:0; font:14px/1.4 "Helvetica Neue", Arial, sans-serif; color:var(--ink); background:#d9d9d9; }
a { color:inherit; }
/* chrome: the reviewer's toolbar */
.chrome { position:sticky; top:0; z-index:9; background:#222; color:#eee; padding:8px 14px; display:flex; gap:18px; align-items:center; flex-wrap:wrap; font-size:13px; min-height:41px; }
.chrome b { font-weight:600; }
.chrome .group { display:flex; gap:6px; align-items:center; }
.chrome .group:empty { display:none; }
.chrome button { font:inherit; padding:3px 9px; background:#444; color:#eee; border:1px solid #666; border-radius:3px; cursor:pointer; }
.chrome button[aria-pressed="true"] { background:#eee; color:#222; }
.chrome button.annotate[aria-pressed="true"] { background:var(--mark); color:#fff; border-color:var(--mark); }
.chrome .hint { opacity:.7; margin-left:auto; }
.chrome .tools { display:contents; }
.chrome .tools-toggle { display:none; }
/* layout: What Changes panel + stage */
.layout { display:flex; align-items:flex-start; }
.panel { flex:0 0 340px; position:sticky; top:41px; max-height:calc(100vh - 41px); overflow:auto; background:#fff; border-right:2px solid var(--line); padding:16px 18px; font-size:13px; }
.panel h2 { font-size:11px; letter-spacing:.08em; text-transform:uppercase; color:#666; margin:18px 0 6px; }
.panel h2:first-child { margin-top:0; }
.panel p { margin:0 0 8px; }
.panel ol.changes { margin:0; padding:0; list-style:none; counter-reset:c; }
.panel ol.changes li { counter-increment:c; position:relative; margin:0 0 4px; padding:6px 8px 6px 30px; border:1px solid transparent; border-radius:3px; cursor:pointer; }
.panel ol.changes li::before { content:counter(c); position:absolute; left:8px; top:7px; width:16px; height:16px; border-radius:50%; background:var(--fill); color:#666; font-size:10px; font-weight:700; display:flex; align-items:center; justify-content:center; }
.panel ol.changes li:hover { background:var(--fill2); }
.panel ol.changes li.on { border-color:var(--mark); background:var(--markbg); }
.panel ol.changes li.on::before { background:var(--mark); color:#fff; }
.panel ol.changes li .kind { display:block; font-size:11px; color:var(--mark); margin-top:2px; }
.panel ol.changes li.dead .kind { color:#c00; }
.panel ol.changes li.text .kind { color:#888; }
.panel code { background:var(--fill); padding:0 3px; }
.panel .notes-list { margin:0; padding-left:18px; }
.panel .notes-list li { margin:0 0 6px; cursor:pointer; }
.panel .notes-list .where { color:#666; font-size:11px; display:block; }
.panel .notes-list button { border:0; background:none; color:var(--ink); text-align:left; cursor:pointer; font:inherit; padding:0; }
.panel .draft-list { margin:0; padding-left:18px; }
.panel .draft-list li { margin:0 0 6px; }
.panel .draft-list button { border:0; background:none; color:var(--ink); text-align:left; text-decoration:underline; cursor:pointer; font:inherit; padding:0; }
.panel .draft-count { display:inline-block; margin-left:6px; padding:0 6px; border:1px solid var(--line); border-radius:12px; white-space:nowrap; }
.panel .empty { color:#666; list-style:none; margin-left:-18px; }
.stage { flex:1; min-width:0; }
.item-header { max-width:960px; margin:24px auto 0; padding:20px 24px; background:#fff; border:2px solid var(--line); overflow-wrap:anywhere; }
.item-header[hidden] { display:none; }
.item-header h1 { margin:0; font-size:20px; scroll-margin-top:calc(var(--chrome-h, 41px) + 12px); }
.item-header .position { margin:0 0 10px; color:#666; font-size:13px; }
/* one visual at a time */
.visual:not([data-active]) { display:none !important; }
.visual[data-active] { display:block !important; }
.frame { max-width:960px; margin:12px auto 24px; background:#fff; border:2px solid var(--line); box-shadow:0 2px 0 #bbb; overflow-wrap:anywhere; }
.visual:not(.screen) .frame { padding:24px; }
.caption { max-width:960px; margin:12px auto 0; font-size:12px; color:#666; }
.caption + .frame { margin-top:6px; }
.state { display:none; }
.state[data-on] { display:block; }
/* lo-fi screen primitives — the screen visual's vocabulary */
.topbar { display:flex; align-items:center; gap:16px; padding:12px 20px; border-bottom:2px solid var(--line); background:var(--fill2); }
.logo { width:34px; height:34px; border:2px solid var(--line); background:var(--fill); position:relative; }
.logo::before, .logo::after { content:""; position:absolute; inset:0; background:linear-gradient(to top right, transparent 48%, var(--line) 48%, var(--line) 52%, transparent 52%); }
.logo::after { transform:scaleX(-1); }
.nav { display:flex; gap:14px; }
.nav span { padding:4px 0; border-bottom:2px solid transparent; }
.nav span.on { border-color:var(--ink); font-weight:600; }
.body { padding:20px; }
h1 { font-size:20px; margin:0; }
.row { display:flex; gap:12px; align-items:center; }
.row.between { justify-content:space-between; }
.btn { display:inline-block; padding:7px 14px; border:2px solid var(--ink); border-radius:3px; background:#fff; cursor:pointer; user-select:none; }
.btn.primary { background:var(--ink); color:#fff; }
.btn.ghost { border-color:transparent; text-decoration:underline; }
.input { display:inline-block; min-width:220px; padding:7px 10px; border:2px solid var(--line); border-radius:3px; background:#fff; color:#888; }
table { width:100%; border-collapse:collapse; margin-top:16px; }
th { text-align:left; font-size:12px; color:#666; border-bottom:2px solid var(--line); padding:8px 6px; }
td { padding:10px 6px; border-bottom:1px solid #ddd; }
tr.click { cursor:pointer; }
.tag { display:inline-block; padding:1px 8px; border:1px solid var(--line); border-radius:10px; font-size:12px; }
.box { border:2px dashed var(--line); background:var(--fill2); padding:30px; text-align:center; color:#666; margin-top:16px; }
.skeleton { height:14px; background:var(--fill); margin:14px 0; width:70%; }
.skeleton.s { width:40%; }
.kv { display:grid; grid-template-columns:140px 1fr; gap:8px 12px; margin:16px 0; }
.kv dt { color:#666; } .kv dd { margin:0; }
.muted { color:#666; }
.hero { height:120px; background:var(--fill); border:2px solid var(--line); position:relative; margin:12px 0; }
.hero::before, .hero::after { content:""; position:absolute; inset:0; background:linear-gradient(to top right, transparent 49.5%, var(--line) 49.5%, var(--line) 50.5%, transparent 50.5%); }
.hero::after { transform:scaleX(-1); }
.callout { display:inline-flex; width:18px; height:18px; border-radius:50%; background:#c00; color:#fff; font-size:11px; font-weight:700; align-items:center; justify-content:center; vertical-align:middle; margin-left:6px; }
.notes { max-width:960px; margin:0 auto 40px; background:var(--note); border:1px solid #d8c66a; padding:12px 18px; font-size:13px; }
.notes ol { margin:6px 0 0; padding-left:20px; }
.notes .brief { margin:0 0 6px; }
/* flow: lanes of steps */
.lane { display:flex; align-items:center; gap:10px; padding:10px 0; flex-wrap:wrap; }
.lane + .lane { border-top:1px solid #ddd; }
.lane .label { flex:0 0 70px; font-size:11px; text-transform:uppercase; letter-spacing:.06em; color:#666; }
.lane.today .step { color:#777; border-style:dashed; }
.step { padding:8px 12px; border:2px solid var(--line); border-radius:3px; background:var(--fill2); }
.flow-sequence { max-width:720px; margin:0 auto; }
.flow-card, .flow-branch { display:block; padding:14px; min-width:0; overflow-wrap:anywhere; border:2px solid var(--line); border-radius:3px; background:var(--fill2); }
.flow-card h3, .flow-branch h3 { margin:0 0 7px; font-size:15px; }
.flow-card p, .flow-branch p { margin:0; }
.flow-card details, .flow-branch details { border-top:1px solid #d5d5d5; margin-top:11px; padding-top:9px; }
.flow-card details p, .flow-branch details p { margin-top:8px; }
.flow-connector { text-align:center; margin:10px 0; color:#666; font-weight:600; }
.flow-branches { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr)); gap:12px; }
.step.gone { text-decoration:line-through; color:#999; }
.arrow { color:#999; }
.arrow::before { content:"→"; }
/* diff: before / after text */
.diff { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.diff > div > .label, .tree .label { font-size:11px; text-transform:uppercase; letter-spacing:.06em; color:#666; margin-bottom:6px; }
.diff pre { margin:0; padding:10px 12px; background:var(--fill2); border:1px solid #ddd; font:12px/1.5 Menlo, Consolas, monospace; white-space:pre-wrap; overflow-wrap:anywhere; }
.diff .line { display:block; }
.diff .del { color:#999; text-decoration:line-through; }
.diff .add { border-left:3px solid var(--mark); margin-left:-12px; padding-left:9px; background:var(--markbg); }
/* tree: files touched */
.tree ul { list-style:none; margin:0; padding:0; font:13px/1.8 Menlo, Consolas, monospace; }
.tree li { padding-left:4px; }
.tree li::before { display:inline-block; width:18px; color:#888; }
.tree li.add::before { content:"+"; color:var(--mark); font-weight:700; }
.tree li.edit::before { content:"~"; }
.tree li.del::before { content:"−"; }
.tree li.del { color:#999; text-decoration:line-through; }
.tree li .why { color:#666; font:12px "Helvetica Neue", Arial, sans-serif; margin-left:10px; }
/* text stage: a bullet with no visual, and the landing */
.textstage h1 { font-size:22px; margin:0 0 12px; }
.textstage p { font-size:16px; max-width:640px; }
.textstage ol { font-size:15px; max-width:640px; padding-left:22px; }
.textstage ol li { margin:0 0 6px; cursor:pointer; }
.textstage ol li:hover { text-decoration:underline; }
.textstage .muted { font-size:13px; }
/* highlight: the mark named by the hash */
.marked { outline:3px solid var(--mark); outline-offset:3px; box-shadow:0 0 0 6px var(--markbg); }
tr.marked { outline-offset:0; }
.diff .add.marked, .tree li.marked { outline-offset:0; box-shadow:none; }
/* annotate */
body.annotating .visual[data-active] .frame { cursor:crosshair; }
.hovering { outline:2px dashed var(--mark); outline-offset:2px; }
.pin { display:inline-flex; width:18px; height:18px; border-radius:3px; background:var(--mark); color:#fff; font-size:11px; font-weight:700; align-items:center; justify-content:center; vertical-align:middle; margin-left:6px; cursor:pointer; }
.pin.stale { background:#999; }
.popover { position:fixed; z-index:10; width:300px; background:#fff; border:2px solid var(--mark); border-radius:4px; padding:10px; box-shadow:0 4px 14px rgba(0,0,0,.25); font-size:13px; }
.popover .where { color:#666; font-size:11px; margin-bottom:6px; word-break:break-word; }
.popover textarea { width:100%; height:70px; font:inherit; padding:6px; border:1px solid var(--line); border-radius:3px; resize:vertical; }
.popover .row { margin-top:8px; }
.popover button { font:inherit; padding:4px 10px; border:1px solid var(--line); background:#fff; border-radius:3px; cursor:pointer; }
.popover button.save { background:var(--mark); color:#fff; border-color:var(--mark); }
.popover .del { margin-left:auto; color:#c00; }
.popover .status { margin:8px 0 0; color:#666; }
.storage-status { font-size:12px; color:#666; }
.toast { position:fixed; bottom:16px; left:50%; transform:translateX(-50%); background:#222; color:#eee; padding:8px 14px; border-radius:3px; font-size:13px; z-index:11; opacity:0; transition:opacity .2s; pointer-events:none; }
.toast.show { opacity:1; }
#copybuf { position:fixed; left:-9999px; top:0; }
.error { color:#c00; }
/* chrome extras: step through changes, phone/desktop view, the panel toggle */
.chrome .count { opacity:.8; min-width:44px; text-align:center; white-space:nowrap; }
.chrome .menu { display:none; }
.panel { top:var(--chrome-h, 41px); max-height:calc(100vh - var(--chrome-h, 41px)); }
/* viewport: walk a screen at phone width from a desktop */
body[data-viewport="phone"] .visual.screen .frame { max-width:390px; }
body[data-viewport="phone"] .desktop-only, body[data-viewport="desktop"] .phone-only { display:none !important; }
.visual.screen .body { min-width:0; overflow-wrap:anywhere; }
/* phone: stage full width, the list is a sheet, the note box docks to the bottom */
@media (max-width: 760px) {
body { font-size:15px; }
.chrome { display:grid; grid-template-columns:auto 1fr auto; gap:6px; padding:6px 8px; }
.chrome > b, .chrome .hint, .chrome #viewport { display:none !important; }
.chrome .menu, .chrome .tools-toggle { display:inline-block; }
.chrome > .group { justify-content:center; gap:4px; }
.chrome .tools { display:none; grid-column:1 / -1; min-width:0; }
.chrome .tools.open { display:flex; flex-wrap:wrap; gap:8px; padding-top:6px; }
.chrome .tools .group { flex-wrap:wrap; min-width:0; }
.chrome .tools button { max-width:100%; overflow-wrap:anywhere; }
.layout { display:block; }
.panel { display:none; position:fixed; left:0; right:0; bottom:0; z-index:8; border-right:0; padding:14px 16px 40px; }
body.menu .panel { display:block; }
.panel ol.changes li { padding:10px 10px 10px 32px; }
.frame { margin:12px 8px; }
.item-header { margin:12px 8px 0; padding:14px; }
.caption { margin:12px 8px 0; }
.notes { margin:0 8px 24px; }
.visual:not(.screen) .frame { padding:14px; }
.body { padding:14px; }
.diff { grid-template-columns:1fr; }
.flow-branches { grid-template-columns:1fr; }
.textstage p, .textstage ol { font-size:16px; }
.popover { left:8px !important; right:8px; bottom:8px; top:auto !important; width:auto; }
body.editor-open .stage { padding-bottom:240px; }
.popover textarea { font-size:16px; height:90px; }
.popover button { padding:8px 14px; }
.chrome button { min-height:40px; min-width:40px; padding:6px 8px; }
}
</style>
</head>
<body>
<div class="chrome">
<b>Review · add-general-improve-skill</b>
<button class="menu" id="menu" aria-expanded="false" aria-controls="panel">Changes</button>
<div class="group"><button id="prev" title="Previous change" aria-label="Previous change">‹</button><span class="count" id="count"></span><button id="next" title="Next change" aria-label="Next change">›</button></div>
<button class="tools-toggle" id="tools-toggle" aria-expanded="false" aria-controls="tools">Tools</button>
<div class="tools" id="tools">
<div class="group" id="states"></div>
<div class="group" id="viewport"><span>View:</span><button data-vp="desktop">Desktop</button><button data-vp="phone">Phone</button></div>
<div class="group">
<button class="annotate" id="annotate" aria-pressed="false">✎ Annotate</button>
<button id="copy">Copy notes</button>
<span class="storage-status" id="storage-status" hidden>Notes and drafts last for this session only.</span>
</div>
</div>
<span class="hint">Click a change on the left. Grey = layout only. Blue = what changes. Red dots = reasoning below.</span>
</div>
<script type="text/markdown" id="proposal">
<!-- proposal:start -->
## Why
Fast delivery can leave duplicated rules, stale guidance, and faults that ordinary feature review misses. WongStack needs a repeatable spot check that finds useful maintenance work and delivers one supported improvement through the existing workflow.
## What Changes
- Add `/improve [area]` to investigate maintenance candidates and ship one coherent change through `/ship`; retain `--audit-only`, no-change, and blocked outcomes. (review.html#/delivery/after/handoff)
- Review recent changes plus a rotating older area, with a read-only survey script for inventory and bounded leads. Use prior change records to avoid repeating completed work. (review.html#/coverage/weekly)
- Provide general investigation guidance for documentation, consolidation, reliability, security, performance, and workflow tools. Require evidence and a verification probe before selecting work.
- Support interactive selection and explicitly unattended external jobs. Preserve user decisions, normal delivery gates, and complete stages for larger improvements. (review.html#/execution)
- Distribute the skill through the core payload, document its use, and publish an additive minor release. (review.html#/payload)
**Non-goals:** Installing a scheduler, a complete security audit, automatic feature retirement, broad dependency upgrades, a new backlog/report database, or changes to the existing delivery gates.
<!-- proposal:end -->
</script>
<div class="layout">
<aside class="panel" id="panel"></aside>
<div class="stage" id="stage">
<header class="item-header" id="item-header" hidden><p class="position" id="item-position"></p><h1 id="item-title" tabindex="-1"></h1></header>
<!-- short fallback for an empty proposal or an invalid direct link -->
<section class="visual textstage" id="_landing" data-kind="text">
<div class="frame" id="landing"></div>
</section>
<!-- text stage for a bullet with no visual -->
<section class="visual textstage" id="_text" data-kind="text">
<div class="frame" id="textframe"></div>
</section>
<section class="visual flow" id="delivery" data-kind="flow" data-states="after today" data-state="after">
<p class="caption">One maintenance run has one delivery owner and an explicit result.</p>
<div class="frame">
<div class="state state-after"><div class="flow-sequence">
<div class="step flow-card" data-target-id="delivery-investigate"><h3>Investigate candidates <span class="tag">New</span></h3><p>Survey the repository, then confirm impact and a verification probe.</p><details><summary>Details</summary><p>Read owning documents, active work, and prior maintenance records. A pattern match is a lead. It does not establish a defect.</p></details></div>
<p class="flow-connector">↓ Choose the applicable path</p>
<div class="flow-branches">
<div class="flow-branch" data-target-id="delivery-ship" data-mark="handoff"><h3>Eligible change <span class="tag">Existing workflow</span> <i class="callout">1</i></h3><p>Select one change and invoke <code>/ship</code>.</p><details><summary>Details</summary><p>Pass the evidence, expected behavior, probe, answers, and maintenance markers. The existing workflow owns planning, implementation, git, checks, and merge. Do not switch candidates once delivery starts.</p></details></div>
<div class="flow-branch" data-target-id="delivery-audit"><h3>Audit only <span class="tag">New</span></h3><p>Return findings and limits without edits.</p><details><summary>Details</summary><p><code>--audit-only</code> does not fetch, write, or invoke delivery. It can report findings when freshness or overlap evidence is unavailable.</p></details></div>
<div class="flow-branch" data-target-id="delivery-none"><h3>No useful change <span class="tag">New</span></h3><p>Report no change.</p><details><summary>Details</summary><p>Do not force cosmetic work or create a commit just to record the run.</p></details></div>
<div class="flow-branch" data-target-id="delivery-blocked"><h3>Required condition missing <span class="tag">New</span></h3><p>Report blocked.</p><details><summary>Details</summary><p>Name missing context or the delivery gate that could not pass. A selected change is not shipped until the existing workflow completes.</p></details></div>
</div>
<p class="flow-connector">↓ All paths join at the run report</p>
<div class="step flow-card" data-target-id="delivery-report"><h3>Report the actual result <span class="tag">New</span></h3><p>Shipped · audit only · no change · blocked</p><details><summary>Details</summary><p>Include coverage, deferred decisions, and available delivery evidence. A failed delivery reports blocked, never shipped.</p></details></div>
</div></div>
<div class="state state-today"><div class="flow-sequence">
<div class="step flow-card" data-target-id="delivery-today-intent"><h3>User supplies an improvement <span class="tag">Today</span></h3><p>WongStack has no general recurring maintenance entry point.</p><details><summary>Details</summary><p>The user or a separate investigation identifies work worth doing.</p></details></div>
<p class="flow-connector">↓</p>
<div class="step flow-card" data-target-id="delivery-today-workflow"><h3>Run the normal change workflow <span class="tag">Unchanged</span></h3><p>Existing verbs plan, implement, check, and ship.</p><details><summary>Details</summary><p>The proposed skill supplies a supported intent to this workflow. It does not create a second delivery pipeline.</p></details></div>
</div></div>
</div>
<div class="notes"><ol><li>A normal invocation authorizes one eligible improvement through <code>/ship</code>. Discussing or reviewing this skill does not authorize a maintenance run.</li></ol></div>
</section>
<section class="visual flow" id="coverage" data-kind="flow">
<p class="caption">Two review passes feed one investigation. Rotation requires no new report database.</p>
<div class="frame"><div class="flow-sequence">
<div class="step flow-card" data-target-id="coverage-inventory"><h3>Discover maintained areas <span class="tag">New script</span></h3><p>Read tracked files and apply the optional area scope.</p><details><summary>Details</summary><p>Sort areas consistently. Split skill and package roots into useful children. Exclude generated files, secrets, and historical records from routine scanning. Report exclusions and read failures.</p></details></div>
<p class="flow-connector">↓ Run both passes</p>
<div class="flow-branches">
<div class="flow-branch" data-target-id="coverage-recent"><h3>Recent changes <span class="tag">New</span></h3><p>Inspect changes since the last usable maintenance baseline.</p><details><summary>Details</summary><p>Use the surveyed revision from a shipped maintenance record. If it is absent, unavailable, or no longer an ancestor, use the last seven days and state the fallback. Name any range omitted through sampling.</p></details></div>
<div class="flow-branch" data-target-id="coverage-rotation" data-mark="weekly"><h3>One rotating area <span class="tag">New</span> <i class="callout">1</i></h3><p>Use the UTC week to choose a start in the sorted area list.</p><details><summary>Details</summary><p>Walk from that start to an area outside the recent set when possible. If all areas changed recently, select the rotation target and report overlap. Same-week runs can revisit an area.</p></details></div>
</div>
<p class="flow-connector">↓ Both passes join at candidate investigation</p>
<div class="step flow-card" data-target-id="coverage-history"><h3>Check evidence and prior work <span class="tag">New</span></h3><p>Remove completed or overlapping work from the candidate list.</p><details><summary>Details</summary><p>Read active changes, open PRs, and past maintenance outcomes. History explains intent; old records are not a bulk source of cleanup candidates.</p></details></div>
<p class="flow-connector">↓</p>
<div class="step flow-card" data-target-id="coverage-record"><h3>Preserve coverage context <span class="tag">New</span></h3><p>Record revision, rotation area, limits, and selection rationale.</p><details><summary>Details</summary><p>A selected change carries the maintenance markers in its Decision log. Audit-only and no-change runs return this context in their output without a report-only commit.</p></details></div>
</div></div>
<div class="notes"><ol><li>Calendar rotation advances without a saved fix. Missed weeks and changes to the area list can leave gaps, so a run must not claim full repository coverage.</li></ol></div>
</section>
<section class="visual flow" id="execution" data-kind="flow">
<p class="caption">Execution context controls how the run resolves material choices.</p>
<div class="frame"><div class="flow-sequence">
<div class="step flow-card" data-target-id="execution-context"><h3>Read explicit run context <span class="tag">New</span> <i class="callout">1</i></h3><p>Interactive by default; unattended only when stated.</p><details><summary>Details</summary><p>A job prompt or trusted host context can establish unattended execution. Time, silence, and an unanswered question cannot.</p></details></div>
<p class="flow-connector">↓ Follow the declared context</p>
<div class="flow-branches">
<div class="flow-branch" data-target-id="execution-interactive"><h3>Interactive <span class="tag">New</span></h3><p>Show investigated candidates and resolve material choices in one question group.</p><details><summary>Details</summary><p>Wait for pending answers before dependent decisions. Carry those answers into nested exploration so settled questions are not repeated.</p></details></div>
<div class="flow-branch" data-target-id="execution-unattended"><h3>Explicitly unattended <span class="tag">New</span></h3><p>Use supported defaults and record them as assumptions.</p><details><summary>Details</summary><p>Defer unresolved product or policy choices. Before delivery starts, another independent eligible candidate can be selected. If none is eligible, report the blocker.</p></details></div>
</div>
<p class="flow-connector">↓ Both paths join at the same delivery checks</p>
<div class="step flow-card" data-target-id="execution-gates"><h3>Confirm delivery conditions <span class="tag">Preserved</span></h3><p>Verify freshness, work overlap, scope, and existing workflow gates.</p><details><summary>Details</summary><p>The scheduler supplies a clean dedicated checkout at the current remote default branch and serializes runs. Missing freshness or overlap evidence blocks normal delivery. Git changes remain with the existing workflow or scheduler.</p></details></div>
<p class="flow-connector">↓ Continue only if eligible; otherwise stop and report blocked</p>
<div class="step flow-card" data-target-id="execution-stage"><h3>Keep each delivered stage complete <span class="tag">New guidance</span></h3><p>One change per run can be a complete stage of larger work.</p><details><summary>Details</summary><p>Each stage must be correct on its own. Record its stage and possible next step in the normal Decision log. Recheck whether that next step is still useful on a later run.</p></details></div>
</div></div>
<div class="notes"><ol><li>The skill is ready for an external weekly job. This change installs no scheduler and does not treat silence as an answer.</li></ol></div>
</section>
<section class="visual tree" id="payload" data-kind="tree">
<p class="caption">Core payload additions and the surfaces that make them available to other repositories.</p>
<div class="frame"><ul>
<li class="add" data-target-id="distribution-skill"><code>.agents/skills/improve/SKILL.md</code> <span class="why">run sequence and handoff to the existing workflow</span></li>
<li class="add" data-target-id="distribution-references"><code>.agents/skills/improve/references/</code> <span class="why">general investigation guidance</span></li>
<li class="add" data-target-id="distribution-scripts"><code>.agents/skills/improve/scripts/</code> <span class="why">read-only survey; no new dependencies</span></li>
<li class="add" data-target-id="distribution-tests"><code>scripts/tests/</code> <span class="why">new survey fixture tests; the existing CI runner discovers them</span></li>
<li class="edit" data-target-id="distribution-inventory">Core payload inventory and setup discovery <span class="why">copy the new skill; preserve target-owned name collisions</span> <i class="callout">1</i></li>
<li class="edit" data-target-id="distribution-docs">README, generic agent instructions, and owning workflow docs <span class="why">discovery, manual use, and external job contract</span></li>
<li class="edit" data-target-id="distribution-release"><code>VERSION</code> and <code>CHANGELOG.md</code> <span class="why">next minor release at implementation time</span></li>
</ul></div>
<div class="notes"><ol><li>Ship through the normal core payload. Existing repositories receive the skill through their usual setup or sync workflow; an existing local <code>/improve</code> remains subject to collision handling.</li></ol></div>
</section>
</div><!-- /stage -->
</div><!-- /layout -->
<div class="toast" id="toast"></div>
<textarea id="copybuf" aria-hidden="true"></textarea>
<script>
// kit: a load-time failure shows on the page instead of a blank stage
window.addEventListener('error', function (e) {
var p = document.getElementById('panel');
if (p) p.innerHTML = '<p class="error"><b>Review script error:</b> ' + String(e.message).replace(/</g, '<') + ' <span class="muted">(line ' + e.lineno + ')</span></p>' + p.innerHTML;
});
// ── routing: #/<visual>[/<state>][/<mark>] ──
const FILE = 'review.html';
const CHANGE = document.title.replace(/^Review — /, '');
const visuals = [...document.querySelectorAll('.visual')];
const $states = document.getElementById('states');
const $panel = document.getElementById('panel');
let current = { id: '_landing', state: 'default', mark: null, bullet: -1 };
let bullets = []; // [{text, anchor, id, state, mark, ok}]
function statesOf(v) { return (v.dataset.states || 'default').split(' '); }
// resolve the two optional segments: a state if it names one, else a mark
function resolve(id, a, b) {
const v = visuals.find(x => x.id === id);
if (!v || id[0] === '_') return null;
const allowed = statesOf(v);
let state, mark;
if (a && allowed.includes(a)) { state = a; mark = b || null; }
else if (a && b) return null; // a is not a state, but a mark follows: bad state
else { state = allowed[0]; mark = a || null; }
if (mark && !v.querySelector('[data-mark="' + mark + '"]')) return null;
return { v, state, mark };
}
function ownerIndex(id) { return bullets.findIndex(x => x.ok && x.id === id); }
function show(id, a, b) {
if ($pop) closePopover(false);
const r = resolve(id, a, b);
const v = r ? r.v : visuals.find(x => x.id === (id === '_text' ? '_text' : '_landing'));
const state = r ? r.state : 'default', mark = r ? r.mark : null;
visuals.forEach(x => x.toggleAttribute('data-active', x === v));
v.dataset.state = state;
v.querySelectorAll('.state').forEach(function (block) { block.toggleAttribute('data-on', block.classList.contains('state-' + state)); });
current = { id: v.id, state, mark, bullet: r ? ownerIndex(v.id) : -1 };
document.querySelectorAll('.marked').forEach(x => x.classList.remove('marked'));
if (mark) v.querySelectorAll('[data-mark="' + mark + '"]').forEach(x => x.classList.add('marked'));
renderStates(v, state);
renderHeader();
renderPanelState();
renderFeedback();
const multi = statesOf(v).length > 1;
const want = v.id[0] === '_' ? '#/' : '#/' + v.id + (multi && (state !== statesOf(v)[0] || mark) ? '/' + state : '') + (mark ? '/' + mark : '');
if (location.hash !== want) { try { history.replaceState(null, '', want); } catch (e) { location.hash = want; } }
}
function showText(i) { // a bullet with no visual
document.getElementById('textframe').innerHTML = '<p class="muted">No visual for this change. Read its full text above and leave feedback if needed.</p>';
current = { id: '_text', state: 'default', mark: null, bullet: i };
document.querySelectorAll('.marked').forEach(function (x) { x.classList.remove('marked'); });
visuals.forEach(x => x.toggleAttribute('data-active', x.id === '_text'));
renderStates(null); renderHeader(); renderPanelState(); renderFeedback();
try { history.replaceState(null, '', '#/change/' + (i + 1)); } catch (e) { location.hash = '#/change/' + (i + 1); }
}
function renderStates(v, state) {
$states.innerHTML = '';
if (!v || statesOf(v).length < 2) return;
const lab = document.createElement('span'); lab.textContent = 'State:'; $states.appendChild(lab);
statesOf(v).forEach(st => {
const b = document.createElement('button');
b.textContent = st; b.setAttribute('aria-pressed', st === state);
b.onclick = () => { show(v.id, st, null); requestAnimationFrame(() => window.scrollTo(0, 0)); }; $states.appendChild(b);
});
}
function fromHash() {
const seg = location.hash.split('/').slice(1);
// no change chosen: a phone opens the list over the landing, a desktop opens the first bullet
if (!seg[0] && bullets.length) {
if (!phoneMedia.matches) return goBullet(0);
show('_landing', null, null);
return setMenu(true);
}
if (seg[0] === 'change' && bullets[+seg[1] - 1]) return goBullet(+seg[1] - 1);
show(seg[0] || '_landing', seg[1] || null, seg[2] || null);
}
window.addEventListener('hashchange', fromHash);
// ── proposal panel + landing ──
function inline(md) {
return md.replace(/&/g, '&').replace(/</g, '<')
.replace(/`([^`]+)`/g, '<code>$1</code>')
.replace(/\*\*([^*]+)\*\*/g, '<b>$1</b>')
.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>');
}
function renderHeader() {
const header = document.getElementById('item-header');
const b = bullets[current.bullet];
header.hidden = !b;
if (!b) return;
document.getElementById('item-position').textContent = 'Change ' + (current.bullet + 1) + ' of ' + bullets.length;
document.getElementById('item-title').innerHTML = inline(b.text);
}
function parseProposal() {
const raw = document.getElementById('proposal').textContent.replace(/<\\\/script/gi, '</script').replace(/<!--[\s\S]*?-->/g, '');
const sections = {}; let cur = null;
raw.split('\n').forEach(line => {
const h = line.match(/^## (.+)/);
if (h) { cur = h[1].trim(); sections[cur] = []; return; }
if (cur) sections[cur].push(line);
});
const why = (sections['Why'] || []).join('\n').trim().split(/\n\s*\n/).map(p => '<p>' + inline(p.replace(/\n/g, ' ')) + '</p>').join('');
bullets = []; let tail = [];
const items = []; let open = false; // fold a wrapped bullet back onto one line
(sections['What Changes'] || []).forEach(line => {
if (/^- /.test(line)) { items.push(line); open = true; return; }
if (open && line.trim()) { items[items.length - 1] += ' ' + line.trim(); return; }
if (!line.trim()) open = false;
items.push(line);
});
items.forEach(line => {
const li = line.match(/^- (.+)/);
if (!li) { if (line.trim()) tail.push(line.trim()); return; }
const m = li[1].match(/\(?(?:review\.html)?#\/([\w-]+)(?:\/([\w-]+))?(?:\/([\w-]+))?\)?\s*$/);
if (m) {
const r = resolve(m[1], m[2] || null, m[3] || null);
bullets.push({ text: li[1].slice(0, m.index).trim(), anchor: '#/' + [m[1], m[2], m[3]].filter(Boolean).join('/'), id: m[1], state: r ? r.state : null, mark: r ? r.mark : null, ok: !!r, kind: r ? r.v.dataset.kind : null });
} else bullets.push({ text: li[1].trim(), anchor: null });
});
const seen = new Set();
bullets.forEach(b => { if (!b.ok) return; if (seen.has(b.id)) b.ok = false; else seen.add(b.id); });
return { why, tail: tail.map(t => '<p>' + inline(t) + '</p>').join('') };
}
function renderPanel() {
const p = parseProposal();
let html = '<h2>Why</h2>' + p.why + '<h2>What Changes</h2><ol class="changes">';
bullets.forEach((b, i) => {
const cls = !b.anchor ? 'text' : b.ok ? '' : 'dead';
const kind = !b.anchor ? 'no visual' : b.ok ? b.kind + ' · ' + b.anchor : 'dead link · ' + b.anchor + ' — no such visual, state, or mark';
html += '<li class="' + cls + '" data-i="' + i + '" role="button" tabindex="0" aria-current="false">' + inline(b.text) + '<span class="kind">' + kind + '</span><span class="draft-count" hidden></span></li>';
});
html += '</ol>' + p.tail + '<h2>Notes <span id="notecount"></span></h2><ol class="notes-list" id="notelist"></ol><h2>Drafts <span id="draftcount"></span></h2><ol class="draft-list" id="draftlist"></ol>';
$panel.innerHTML = html;
document.getElementById('landing').innerHTML = bullets.length
? '<h1>Choose a change</h1><p class="muted">Use the change list or Next to open a visual.</p>'
: '<h1>No changes to review</h1><p class="muted">This proposal has no What Changes entries yet.</p>';
}
function renderPanelState() {
$panel.querySelectorAll('ol.changes li').forEach((li, i) => {
const b = bullets[i];
const on = current.bullet === i;
li.classList.toggle('on', on);
li.setAttribute('aria-current', on ? 'true' : 'false');
});
renderCount();
}
function goBullet(i) {
const b = bullets[i]; if (!b) return;
closePopover(); setMenu(false);
if (!b.anchor || !b.ok) showText(i); else show(b.id, b.state, b.mark);
requestAnimationFrame(() => { window.scrollTo(0, 0); document.getElementById('item-title').focus({ preventScroll:true }); });
}
// ── annotation and browser-local feedback ──
const ANNOTATABLE = '.btn, .input, tr, .box, .tag, .hero, .kv dt, .kv dd, h1, .nav span, .logo, .notes li, .notes .brief, .step, .flow-branch, .diff .line, .diff pre, .tree li, .caption, .textstage p';
const KEY = 'rv-notes:' + CHANGE;
const DRAFT_KEY = 'rv-drafts:v1:' + CHANGE;
let storageAvailable = true;
function readStored(key, fallback) {
try { const raw = localStorage.getItem(key); return raw ? JSON.parse(raw) : fallback; }
catch (e) { storageAvailable = false; return fallback; }
}
let notes = readStored(KEY, []);
if (!Array.isArray(notes)) notes = [];
const draftStore = readStored(DRAFT_KEY, { version:1, drafts:[] });
let drafts = draftStore && draftStore.version === 1 && Array.isArray(draftStore.drafts) ? draftStore.drafts : [];
function persist() {
if (storageAvailable) {
try {
localStorage.setItem(KEY, JSON.stringify(notes));
localStorage.setItem(DRAFT_KEY, JSON.stringify({ version:1, drafts:drafts }));
} catch (e) { storageAvailable = false; }
}
document.getElementById('storage-status').hidden = storageAvailable;
renderFeedback();
}
const $ann = document.getElementById('annotate');
let annotating = false, $pop = null, editor = null, editorTrigger = null;
$ann.onclick = () => setAnnotating(!annotating);
function setAnnotating(on) {
annotating = on; $ann.setAttribute('aria-pressed', String(on)); document.body.classList.toggle('annotating', on);
closePopover(false); document.querySelectorAll('.hovering').forEach(x => x.classList.remove('hovering'));
}
function target(el) {
if (el.closest('.popover, .chrome, .pin, details, a[href^="#/"]')) return null;
const scope = el.closest('.visual[data-active]');
if (!scope) return null;
const t = el.closest('.flow-card, .flow-branch') || el.closest(ANNOTATABLE);
return t && scope.contains(t) ? { scope:scope, el:t } : null;
}
document.addEventListener('mouseover', e => {
if (!annotating) return;
document.querySelectorAll('.hovering').forEach(x => x.classList.remove('hovering'));
const t = target(e.target); if (t) t.el.classList.add('hovering');
});
function pathOf(scope, el) {
const steps = [];
for (let n = el; n && n !== scope; n = n.parentElement) steps.unshift([...n.parentElement.children].indexOf(n));
return steps.join('.');
}
function elAt(scope, path) {
if (!scope || !path) return null;
let n = scope;
for (const i of path.split('.')) n = n && n.children[+i];
return n || null;
}
function labelOf(el) {
const c = el.cloneNode(true);
c.querySelectorAll('.pin, .callout, .kind, .why').forEach(x => x.remove());
if (el.matches('.flow-card, .flow-branch')) c.querySelectorAll('details').forEach(x => x.remove());
const content = el.tagName === 'TR' ? [...c.cells].map(td => td.textContent.trim()).join(' · ') : c.textContent;
const value = content.replace(/\s+/g, ' ').trim().slice(0, 60);
const kind = el.classList.contains('btn') ? 'button' : el.classList.contains('input') ? 'input' : el.tagName === 'TR' ? 'row'
: el.classList.contains('box') ? 'panel' : el.tagName === 'H1' ? 'heading' : el.classList.contains('flow-branch') ? 'branch'
: el.classList.contains('step') ? 'step' : el.classList.contains('line') ? 'line' : el.closest('.tree') ? 'file' : el.tagName.toLowerCase();
return kind + ' "' + value + '"';
}
function recordFor(el) {
const scope = el.closest('.visual[data-active]');
return { itemId:current.id === '_text' ? '_text:' + current.bullet : current.id,
scope:'visual', visual:current.id, state:current.state, targetId:el.dataset.targetId || null,
path:pathOf(scope, el), label:labelOf(el) };
}
function sameTarget(a, b) {
return a.itemId === b.itemId && a.visual === b.visual && a.state === b.state &&
(a.targetId && b.targetId ? a.targetId === b.targetId : a.path === b.path && a.label === b.label);
}
function findTarget(n) {
const scope = document.getElementById(n.visual);
if (!scope) return null;
let el = null;
if (n.targetId) el = [...scope.querySelectorAll('[data-target-id]')].find(x => x.dataset.targetId === n.targetId && (!x.closest('.state') || x.closest('.state').classList.contains('state-' + n.state)));
if (!el && !n.targetId) el = elAt(scope, n.path);
return el && labelOf(el) === n.label ? el : null;
}
function whereOf(n) {
if (n.visual === '_text') return '#/change/' + (Number(String(n.itemId).split(':')[1]) + 1);
const v = visuals.find(x => x.id === n.visual);
return '#/' + n.visual + (v && statesOf(v).length > 1 ? '/' + n.state : '');
}
function escapeHtml(value) { return String(value).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); }
function newId() { return String(Date.now()) + '-' + Math.random().toString(36).slice(2, 8); }
function renderFeedback() {
document.querySelectorAll('.pin').forEach(p => p.remove());
const list = document.getElementById('notelist'), draftList = document.getElementById('draftlist');
if (!list || !draftList) return;
list.innerHTML = ''; draftList.innerHTML = '';
document.getElementById('notecount').textContent = notes.length ? '(' + notes.length + ')' : '';
document.getElementById('draftcount').textContent = drafts.length ? '(' + drafts.length + ')' : '';
notes.forEach((n, i) => {
const el = findTarget(n), stale = !el;
if (el) {
const pin = document.createElement('button'); pin.className = 'pin'; pin.dataset.note = n.id;
pin.setAttribute('aria-label', 'Open note ' + (i + 1)); pin.textContent = String(i + 1);
(el.tagName === 'TR' ? el.cells[0] : el).appendChild(pin);
}
const li = document.createElement('li');
const button = document.createElement('button'); button.type = 'button';
button.innerHTML = '<span class="where">' + escapeHtml(whereOf(n)) + ' · ' + escapeHtml(n.label) + (stale ? ' · moved target' : '') + '</span>' + escapeHtml(n.text);
button.onclick = () => openRecord(n, false);
li.appendChild(button); list.appendChild(li);
});
if (!notes.length) list.innerHTML = '<li class="empty">No saved notes yet.</li>';
drafts.forEach(d => {
const li = document.createElement('li'), button = document.createElement('button'); button.type = 'button';
button.textContent = whereOf(d) + ' · ' + d.label + (findTarget(d) ? '' : ' · moved target');
button.onclick = () => openRecord(d, true);
li.appendChild(button); draftList.appendChild(li);
});
if (!drafts.length) draftList.innerHTML = '<li class="empty">No drafts.</li>';
$panel.querySelectorAll('ol.changes li').forEach((li, i) => {
const b = bullets[i], itemId = b && b.ok ? b.id : '_text:' + i;
const count = drafts.filter(d => d.itemId === itemId).length;
const badge = li.querySelector('.draft-count'); badge.hidden = !count;
badge.textContent = count + (count === 1 ? ' draft' : ' drafts');
});
document.getElementById('storage-status').hidden = storageAvailable;
}
function closePopover(restore) {
if ($pop) $pop.remove();
$pop = null; editor = null; document.body.classList.remove('editor-open');
if (restore && editorTrigger && editorTrigger.isConnected) editorTrigger.focus();
editorTrigger = null;
}
function openRecord(n, isDraft) {
closePopover(false); setMenu(false);
if (n.visual === '_text') goBullet(Number(String(n.itemId).split(':')[1]));
else show(n.visual, n.state, null);
const el = findTarget(n);
if (el) el.scrollIntoView({ block:'center' });
const saved = isDraft && n.savedId ? notes.find(x => x.id === n.savedId) : !isDraft ? n : null;
openPopover(isDraft ? n : saved || n, el, saved || null);
}
function openPopover(record, anchorEl, saved) {
closePopover(false);
const original = record || recordFor(anchorEl);
const prior = saved || (record && record.id ? record : null);
const matching = drafts.find(d => sameTarget(d, original) && (d.savedId || null) === (prior ? prior.id : null));
editor = { meta:{ itemId:original.itemId, scope:'visual', visual:original.visual, state:original.state,
targetId:original.targetId || null, path:original.path, label:original.label },
savedId:prior ? prior.id : null, draftId:matching ? matching.id : (record && record.savedId !== undefined ? record.id : null) };
editorTrigger = anchorEl;
const initial = matching ? matching.text : (record && record.text !== undefined ? record.text : prior ? prior.text : '');
$pop = document.createElement('div'); $pop.className = 'popover';
const moved = !anchorEl ? '<p class="status">Original target moved. This draft stays here until you choose a new target.</p>' : '';
$pop.innerHTML = '<div class="where">' + escapeHtml(whereOf(original)) + ' · ' + escapeHtml(original.label) + '</div>' + moved
+ '<textarea aria-label="Note text" placeholder="What should change here?"></textarea>'
+ '<div class="row"><button class="save">Save</button><button class="close">Close</button><button class="discard">Discard draft</button>'
+ (prior ? '<button class="del">Delete saved note</button>' : '') + '</div><p class="status">Drafts are excluded from Copy notes.'
+ (storageAvailable ? '' : ' Notes and drafts last for this session only.') + '</p>';
const ta = $pop.querySelector('textarea'); ta.value = initial;
ta.oninput = () => {
const text = ta.value;
let d = drafts.find(x => x.id === editor.draftId);
if (!text.trim() && !editor.savedId) {
if (d) drafts = drafts.filter(x => x.id !== d.id);
editor.draftId = null;
} else if (d) d.text = text;
else { d = Object.assign({ id:newId(), savedId:editor.savedId, text:text }, editor.meta); drafts.push(d); editor.draftId = d.id; }
persist();
};
$pop.querySelector('.save').onclick = () => {
const text = ta.value.trim(); if (!text) return;
const id = editor.savedId || newId();
const savedNote = Object.assign({ id:id, text:text }, editor.meta);
const index = notes.findIndex(x => x.id === id);
if (index < 0) notes.push(savedNote); else notes[index] = savedNote;
drafts = drafts.filter(x => x.id !== editor.draftId);
closePopover(true); persist();
};
$pop.querySelector('.close').onclick = () => closePopover(true);
$pop.querySelector('.discard').onclick = () => { drafts = drafts.filter(x => x.id !== editor.draftId); closePopover(true); persist(); };
const del = $pop.querySelector('.del');
if (del) del.onclick = () => { notes = notes.filter(x => x.id !== editor.savedId); drafts = drafts.filter(x => x.id !== editor.draftId); closePopover(true); persist(); };
ta.onkeydown = ev => { if (ev.key === 'Enter' && (ev.metaKey || ev.ctrlKey)) { ev.preventDefault(); $pop.querySelector('.save').click(); } };
document.body.appendChild($pop); document.body.classList.add('editor-open');
if (!phoneMedia.matches) {
const r = anchorEl ? anchorEl.getBoundingClientRect() : document.getElementById('item-header').getBoundingClientRect();
const W = 300, H = $pop.offsetHeight || 190;
let top = r.top, left = r.right + 10;
if (left + W > innerWidth) { left = Math.max(8, Math.min(r.left, innerWidth - W - 8)); top = r.bottom + 8; if (top + H > innerHeight) top = r.top - H - 8; }
$pop.style.top = Math.max(50, top) + 'px'; $pop.style.left = left + 'px';
}
ta.focus();
}
let touchStart = null, touchMoved = false;
document.addEventListener('touchstart', e => { const t = e.touches[0]; if (t) { touchStart = { x:t.clientX, y:t.clientY }; touchMoved = false; } }, { passive:true });
document.addEventListener('touchmove', e => { const t = e.touches[0]; if (t && touchStart && Math.hypot(t.clientX - touchStart.x, t.clientY - touchStart.y) > 8) touchMoved = true; }, { passive:true });
document.addEventListener('click', e => {
if (e.target.closest('.popover')) return;
const pin = e.target.closest('.pin');
if (pin) { e.preventDefault(); const n = notes.find(x => x.id === pin.dataset.note); if (n) openRecord(n, false); return; }
const li = e.target.closest('.panel ol.changes li');
if (li) { goBullet(+li.dataset.i); return; }
const panelLink = e.target.closest('.panel a[href*="#/"]');
if (panelLink) { e.preventDefault(); const s = panelLink.getAttribute('href').split('#/')[1].split('/'); show(s[0], s[1], s[2]); return; }
const local = e.target.closest('.visual[data-active] a[href^="#/"]');
if (local) {
e.preventDefault(); const s = local.getAttribute('href').split('#/')[1].split('/');
if (s[0] === current.id) { show(s[0], s[1], s[2]); requestAnimationFrame(() => window.scrollTo(0, 0)); }
else toast('Use Changes to select another change.');
return;
}
if (e.target.closest('details')) return;
if (touchMoved) { touchMoved = false; return; }
if (annotating) {
const t = target(e.target);
if (t) { e.preventDefault(); openPopover(recordFor(t.el), t.el, null); }
return;
}
const localState = e.target.closest('.visual[data-active] [data-local-state]');
if (localState) { show(current.id, localState.dataset.localState, null); return; }
const step = e.target.closest('.visual[data-active] .flow-card, .visual[data-active] .flow-branch');
if (step) { const detail = step.querySelector('details'); if (detail) detail.open = !detail.open; }
});
document.addEventListener('keydown', e => {
const editing = e.target.matches('textarea,input,[contenteditable="true"]') || !!e.target.closest('[contenteditable="true"]');
if (e.key === 'Escape') { if ($pop) closePopover(true); return; }
if (editing) return;
if (e.key === 'a') { setAnnotating(!annotating); return; }
if ((e.key === 'Enter' || e.key === ' ') && e.target.matches('.panel ol.changes li')) { e.preventDefault(); goBullet(+e.target.dataset.i); return; }
if ((e.key === 'Enter' || e.key === ' ') && e.target.matches('.flow-card, .flow-branch')) {
e.preventDefault();
if (annotating) openPopover(recordFor(e.target), e.target, null);
else { const detail = e.target.querySelector('details'); if (detail) { detail.open = !detail.open; detail.querySelector('summary').focus(); } }
}
});
document.querySelectorAll('.flow-card, .flow-branch').forEach(el => { if (!el.hasAttribute('tabindex')) el.tabIndex = 0; });
function notesText() {
const lines = ['/continue ' + CHANGE, 'Review notes from ' + FILE + ' (' + notes.length + '):'];
notes.forEach((n, i) => lines.push((i + 1) + '. ' + whereOf(n) + ' · ' + n.label + ' — ' + n.text));
return lines.join('\n');
}
document.getElementById('copy').onclick = function () {
if (!notes.length) return toast('No saved notes yet');
const text = notesText(), buf = document.getElementById('copybuf'); buf.value = text;
const done = () => toast('Copied ' + notes.length + ' saved note' + (notes.length === 1 ? '' : 's'));
const fallback = () => { buf.select(); buf.setSelectionRange(0, 99999); document.execCommand('copy'); done(); };
if (navigator.clipboard && navigator.clipboard.writeText) navigator.clipboard.writeText(text).then(done, fallback); else fallback();
};
function toast(msg) { const t = document.getElementById('toast'); t.textContent = msg; t.classList.add('show'); setTimeout(() => t.classList.remove('show'), 1800); }
// ── phone: the chrome's height drives the panel; the list is a sheet; step through changes ──
function chromeHeight() { document.documentElement.style.setProperty('--chrome-h', document.querySelector('.chrome').offsetHeight + 'px'); }
window.addEventListener('resize', chromeHeight);
function setMenu(open) {
document.body.classList.toggle('menu', open);
document.getElementById('menu').setAttribute('aria-expanded', open);
}
document.getElementById('menu').onclick = () => setMenu(!document.body.classList.contains('menu'));
document.getElementById('tools-toggle').onclick = function () {
const open = document.getElementById('tools').classList.toggle('open');
this.setAttribute('aria-expanded', open);
chromeHeight();
};
function currentBullet() { const li = document.querySelector('.panel ol.changes li.on'); return li ? +li.dataset.i : -1; }
function renderCount() {
const i = currentBullet();
document.getElementById('count').textContent = i < 0 ? bullets.length + ' changes' : (i + 1) + ' / ' + bullets.length;
document.getElementById('prev').disabled = i <= 0;
document.getElementById('next').disabled = i >= bullets.length - 1;
const v = document.querySelector('.visual[data-active]');
document.getElementById('viewport').style.display = v && v.classList.contains('screen') ? '' : 'none';
chromeHeight();
}
document.getElementById('prev').onclick = () => { const i = currentBullet(); if (i > 0) goBullet(i - 1); };
document.getElementById('next').onclick = () => { const i = currentBullet(); if (i < bullets.length - 1) goBullet(i + 1); };
document.addEventListener('keydown', e => { if (e.target.matches('textarea,input,[contenteditable="true"]') || e.target.closest('[contenteditable="true"]')) return; if (e.key === 'ArrowRight') document.getElementById('next').click(); if (e.key === 'ArrowLeft') document.getElementById('prev').click(); });
// ── viewport: phone or desktop layout of a screen; a phone is a phone already ──
const phoneMedia = matchMedia('(max-width: 760px)');
function setViewport(vp) {
document.body.dataset.viewport = vp;
document.querySelectorAll('#viewport button').forEach(b => b.setAttribute('aria-pressed', b.dataset.vp === vp));
}
document.querySelectorAll('#viewport button').forEach(b => b.onclick = () => setViewport(b.dataset.vp));
setViewport(phoneMedia.matches ? 'phone' : 'desktop');
phoneMedia.addEventListener('change', e => setViewport(e.matches ? 'phone' : 'desktop'));
renderPanel();
fromHash();
chromeHeight();
</script>
</body>
</html>
~~~
<!-- end review.html -->