Commit graph

24 commits

Author SHA1 Message Date
5334097c84 fix(graceful-handoff): two defects found by the first real smoke test (v3.2.1) v3.2.1
The pipeline had never been run against an actual repository — every test in
the suite is either a prose-grep over SKILL.md or a unit test that asserts key
presence. Running it against scratch repos (private remote, and public `open/`
remote with and without a gitignored STATE.md) found two defects living under
a 42/42-green suite.

1. dirty_files truncated the first path. gitOk() trims every command's output,
   but `git status --porcelain` puts the worktree status in column 2, so a
   modified-but-unstaged file is " M path". The trim ate the leading space and
   the fixed slice(3) then ate the first character: app.js was reported as
   pp.js. Only the first line is affected, which is why it survived — no test
   asserted dirty_files VALUES, only that the key existed. Porcelain now goes
   through a non-trimming gitOkRaw().

2. The commit message claimed a STATE.md update it did not contain. The
   message was hardcoded to "oppdater STATE.md" regardless of what was staged.
   On every `open/` repo STATE.md is gitignored, so the handoff commit carries
   only the --also paths. Git history is the regime's long-term log; it was
   systematically wrong about its own contents.

Also promotes the leak condition from advisory to hard gate. A public remote
whose STATE.md is not yet gitignored is the state a FRESH open/ repo starts
in, and should_commit_state was true there — the ritual only mentioned
leak_warning, then committed. It now lands in errors[] (step 2 stops on a
non-empty errors[]), should_commit_state is false, and --commit refuses to
stage STATE.md. Explicit --also paths are still honoured: the gate protects
STATE.md, not the commit as a whole.

And corrects SKILL.md's justification for the single-line rule. It claimed a
wrapped rationale= replaces the board's next step with garbage; board.sh in
repo-mailbox 0.20.3 tracks a comment to its closer, so that no longer follows.
The rule stands, restated with the risk that is still real: a rationale
containing the closer sequence ends its own comment early.

Tests 42 -> 48, all six written failing first.

Still unverified: that /graceful-handoff loads as a user command (#26251), and
that a cross-plugin Skill invocation of repo-mailbox:route passes from a
sub-scoped skill. Both need the catalog ref bumped so the version is installed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RvLY4FwbzY157oVqwnkHD8
2026-08-09 21:49:08 +02:00
be0a463e02 docs(graceful-handoff): correct the release command — it was silently wrong v3.2.0
The documented form `release-plugin.mjs graceful-handoff <versjon>` drops the
version argument on the floor. parseArgs only accepts a version via
`--version X.Y.Z`; a bare positional is discarded because `name` is already
set and the token does not start with `--`. It appeared to work solely
because plugin.json happened to carry the intended version. The first time
those disagree, the wrong version ships.

The documented form was also missing `--create-tag --write --commit --push`.
Without them the script is a dry-run, and without `--create-tag` it exits
BLOCKED when the tag does not exist yet — which is every first release.

Also replaces the "check-versions.mjs grønn / 0 ERROR" criterion. That gate is
unreachable: the run exit-codes 1 on a pre-existing repo-mailbox ERROR owned
by another repo. The honest criterion is that the graceful-handoff row reads
✓ OK.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017kWX5Si98v64DQ7MWHzt8P
2026-08-09 21:31:02 +02:00
96a22474bd feat(graceful-handoff): sync the ritual with the global session-end mechanism (v3.2.0)
SKILL.md had drifted from the global CLAUDE.md on two counts, both verified by
grep before the rewrite: the STATE.md template predated the mandatory `board:`
line and the `route:`/`route-last:` lines, and the closing line still demanded
three fields where six are now required (Innboks, Modell neste okt,
Oppstartskommando were missing).

- New step 3 routes the next session via `repo-mailbox:route` BEFORE the Write.
  It cannot run after the commit: the emitted lines live inside STATE.md, so
  routing afterwards would dirty a file that was just committed. One invocation
  feeds both the three comment lines and the closing line's model fields.
- `repo-mailbox` stays a soft dependency — documented fallback if it is absent
  or the cross-plugin Skill invocation is blocked. `route.sh`'s path is
  deliberately not hardcoded (plugin cache, versioned, drifts).
- The single-line constraint on the three comments is now in prose: `board.sh`
  reads the first non-blank, non-heading, non-`<!--` line under the heading as
  the repo's next step, so a wrapped `rationale=` corrupts the board.
- Closing line 3 -> 6 fields. The Innboks field reports what the session did
  rather than re-querying the mailbox — inbox handling belongs first in a
  session, and "no inbox injected" must never be reported as "empty".
- STATE format consolidated to ONE copy. Repo CLAUDE.md restated it with the
  same defect; it now points at SKILL.md step 4 as the authority, following the
  model-rubric precedent (two copies drift, prose cannot be tested).
- allowed-tools gains `Skill`. `plugin.json` description left unchanged on
  purpose — editing it would require the manual marketplace.json edit that
  release-plugin.mjs does not perform.

Tests 30 -> 42, all green. They are prose greps: drift guards, not proof the
ritual runs. Verifying that means a manual /graceful-handoff against a scratch
repo.

Release (tag + catalog ref bump) is operator-gated and NOT done here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013V59bNbWa5x2oTH2NMBJy4
2026-08-09 21:23:39 +02:00
9f84234440 docs(graceful-handoff): add ownership-basis clause to AI-disclosure line (org D12)
org-ops D12 (docs/decisions.md, decided 2026-08-01) requires the plugin-class
disclosure line to be self-contained on three elements — generator, process,
and the ownership basis (Anthropic Consumer Terms §4). Our line had the first
two only; wording matches the one repo in the org that already carries the
clause (playground-design-system).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fd9dj1eevWo96bP68VxxpV
2026-08-09 20:59:23 +02:00
5e17409275 docs(graceful-handoff): drop the hooks-0 badge (repo-standard BADGE-COUNT)
repo-standard v0.2.0 flagged 6 badges as past the measured inflection of 5,
where a badge row reads as clutter rather than evidence. Removed the
hooks-0 badge: a badge asserting an absence is not something a reader acts
on, and "No hooks" is already stated twice in prose, where it carries its
actual argument.

Kept skill-1 deliberately — with the tests badge already dropped and the
STATE-helper badge non-numeric, it is the only axis the catalog's version
gate can still verify for this plugin.

Gate: 0 ERROR / 0 WARN, 14 checks passed. Docs only, no version bump.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019x1C8tjmB2vUCM9jE668ZF
2026-08-04 11:51:37 +02:00
13e29723a7 docs(graceful-handoff): bring README in line with the org repo standard
Ran the repo-standard gate (plugin class): 5 ERROR + 2 WARN + 2 SKIP.
Now 0 ERROR / 0 WARN / 0 SKIP, 13 checks passing. Docs only — no plugin
code, version or behaviour changed.

- H1 is the repo name; opening line is verbatim the forge description, so
  description == catalog == README is machine-checkable.
- `## Install` promoted to a top-level heading on the first screen and given
  the CLI command `claude plugin install graceful-handoff@ktg-plugin-marketplace`
  next to `marketplace add` (the enabledPlugins JSON stays as a second form).
  Prerequisites split out as `## Requirements`; Quick Start keeps the usage.
- Added `## Non-goals` (what it deliberately does not do) and `## Changelog`.
- Dropped the static tests-30 badge: no CI runner exists on this forge, so it
  asserted a run nothing verifies. The Testing section now states the command
  and that nothing runs it automatically.
- Fixed two dead `../../README.md` references inherited from the monorepo —
  both point outside a standalone repo and 404.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019x1C8tjmB2vUCM9jE668ZF
2026-08-03 21:53:11 +02:00
192d4403eb feat(graceful-handoff): remove hardcoded push window — push is now unconditional (v3.1.0) v3.1.0
The regime-wide push-window restriction (man–tor 08:00–17:00, fre 08:00–16:00)
was lifted permanently, so SKILL.md no longer gates the push on a weekday/time
window — it would otherwise park a push in the middle of working hours.

Two invariants are unchanged: push is Forgejo only (never GitHub), and push
stays user-triggered (the skill is disable-model-invocation: true). The pipeline
script had no window logic — only its header comment was corrected.

If a future repo needs a window again, reintroduce it as per-repo config, never
as a hardcoded default.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BcNX2QdgmXyLd2Bt6Z25GU
2026-06-24 11:00:10 +02:00
2c4e5e425b feat(graceful-handoff)!: integrate with STATE.md continuity system (v3.0.0) v3.0.0
BREAKING: replace the NEXT-SESSION artifact + 3 hooks with a STATE.md-centric,
skill-only design. /graceful-handoff now overwrites the nearest STATE.md (with the
mandatory 👉 NESTE block) instead of writing a separate handover file.

- Remove hooks/ entirely: Stop auto-trigger (operator choice), SessionStart loader
  (redundant with global session-start.sh), statusLine hint (dead — user settings win).
- Invert the pipeline: the model writes STATE.md (only it has the context for 👉 NESTE);
  handoff-pipeline.mjs becomes a slim deterministic helper (--plan / --commit / --dry-run).
- Remote-aware policy: STATE.md tracked on private remotes, local-only (gitignored) on
  public/open mirrors. Authoritative signal: git check-ignore STATE.md.
- SKILL.md rewritten as the Session-Slutt ritual; dropped the Sonnet model pin.
- Docs (README, CLAUDE.md, CHANGELOG), plugin.json 2.1.0→3.0.0, .gitignore cleanup.
- Tests rewritten for --plan/--commit; no-`git add -A` regression preserved. 30/30 green.

Release-cut (tag v3.0.0 + catalog ref bump) pending — separate gated action.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019SiKr4c6GAzQH5n6E6f5NA
2026-06-23 21:09:44 +02:00
a6f3ad4e93 docs: add full-depth plugin review (2026-06-20)
Grade B — strong git path; one MEDIUM indirect-injection surface in the SessionStart hook. Part of the marketplace-wide review (config-audit v5.4.0 + llm-security + structure + version). Read-only; this file is the only artifact.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ter3E2JSi1Khgmuf2kady8
2026-06-20 09:14:08 +02:00
06da2e55f9 chore(gitignore): add session/local-state baseline (polyrepo split) 2026-06-18 10:21:12 +02:00
b5229d0538 chore: WIP marketplace doc adjustments across plugins v2.1.0
Pre-trekexecute snapshot of in-progress CLAUDE.md/SKILL.md edits and
extracted docs/ files. Captured as one commit so /trekexecute claude-design
can run against a clean working tree.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 12:04:02 +02:00
b1d6f4bede docs: add Communication patterns section to all plugin CLAUDE.md
Standardize named-markdown-link guidance across all plugins so file://
references render as independently clickable links in terminals like
Ghostty (bare file:// URLs only make the first clickable).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-16 21:01:45 +02:00
21f32b3362 docs: introduce GOVERNANCE.md and unify fork-and-own blurb
Establish a single governance document at marketplace root and copy
it into each of the 9 plugins so every plugin folder remains 100%
self-contained. Replace the inconsistent provocative blurb across
all READMEs with a uniform fork-and-own paragraph that links to
the local GOVERNANCE.md.

[skip-docs]

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-03 14:57:00 +02:00
Kjell Tore Guttormsen
69fef0afeb docs(graceful-handoff): align README with marketplace standard
Plugin README rewritten from 187 to 354 lines in the same shape as
ai-psychosis, llm-security, config-audit, and ms-ai-architect:

- English (other plugin READMEs are English)
- Standard solo-project + AI-generated disclaimers
- Badges row (version, platform, skill/hooks/pipeline counts, tests, license)
- Table of Contents
- Mermaid architecture diagram (detection / pipeline / resumption / manual)
- 4-step context resolution table (v2.1)
- Components section (skill, pipeline, hooks)
- Workflow examples + safety guarantees + limitations
- Inline version history + Feedback & Contributing

Root README graceful-handoff card updated to reflect v2.1 model-aware
detection and 57-test count (was 36).
2026-05-01 09:14:10 +02:00
Kjell Tore Guttormsen
6906e04906 fix(graceful-handoff): model-aware context window detection (v2.1.0)
Stop hook fallback antok 200K-vindu. På Opus 4.7 (faktisk 1M) kunne
auto-handoff fyre 5–7x for tidlig — estimert 70% når reell bruk var
~14%. Erstatter enkel fallback med 4-stegs resolution-kjede:

  1. payload.context_window.used_percentage  (autoritativ)
  2. payload.context_window.context_window_size + transcript-estimat
  3. MODEL_WINDOWS[payload.model.id] + estimat
  4. FALLBACK_WINDOW=1_000_000 + estimat (2026-default)

additionalContext-meldinger inkluderer nå [kilde: <source>] for innsyn.
Brief som kilde-artefakt i docs/brief-context-window-detection.md.
6 nye tester (57 totalt). Ingen regresjoner.
2026-05-01 09:08:24 +02:00
Kjell Tore Guttormsen
1b88ebaacb docs(graceful-handoff): 2.0 — sync README, CLAUDE.md, root README 2026-05-01 06:07:02 +02:00
Kjell Tore Guttormsen
55a1765532 chore(graceful-handoff): 2.0.0 — bump version, remove auto_discover, update CHANGELOG [skip-docs]
Step 8 of v2.0 plan.
2026-05-01 06:06:25 +02:00
Kjell Tore Guttormsen
374581ad19 feat(graceful-handoff): 2.0 — register hooks and statusLine in hooks.json [skip-docs]
Step 7 of v2.0 plan. Registers SessionStart, Stop, and statusLine hooks.
Note: statusLine top-level placement in hooks.json is an open assumption
(brief Assumption 1) — verified to be valid JSON syntax; live smoke-test
required to confirm Claude Code loads it from this location vs requiring
settings.json placement.
2026-05-01 06:06:25 +02:00
Kjell Tore Guttormsen
658b868012 feat(graceful-handoff): 2.0 — SessionStart auto-load handoff on resume/compact [skip-docs]
Step 6 of v2.0 plan. SessionStart hook fires on source: resume or
source: compact, walks up to 3 levels searching for
NEXT-SESSION-*.local.md, injects content via additionalContext, and
archives the file (rename to *.archived.local.md) to prevent stale-load
in later sessions. 9 tests cover sources, multi-level search,
topic-slug variants, archive filtering, malformed payload.
2026-05-01 06:06:25 +02:00
Kjell Tore Guttormsen
dda450e3a7 feat(graceful-handoff): 2.0 — Stop hook auto-execute + pipeline staging fix [skip-docs]
Step 5 of v2.0 plan + critical pipeline fix.

Stop hook (hooks/scripts/stop-context-monitor.mjs):
- Estimates context usage from transcript size (chars/3.5 / window_size)
- At ≥70%, spawns handoff-pipeline.mjs --auto --no-push synchronously
- Reads context_window_size from payload (supports 1M windows)
- Lock file at <transcript_dir>/.handoff-lock-<session_id>
- Gracefully handles missing CLAUDE_PLUGIN_ROOT, missing transcript

Pipeline fix (scripts/handoff-pipeline.mjs):
- REMOVED `git add -A` (CLAUDE.md anti-pattern: scoops up unrelated WIP)
- Now stages ONLY artifact + REMEMBER.md/TODO.md if present
- New regression test 'pipeline never stages unrelated dirty files'

Tests: 7 stop-hook tests use stub pipeline (no real git operations);
11 pipeline tests including new regression for explicit staging.
2026-05-01 06:06:25 +02:00
Kjell Tore Guttormsen
f20e95a553 feat(graceful-handoff): 2.0 — statusLine context-percent hint [skip-docs]
Step 4 of v2.0 plan. statusLine hook reads context_window.used_percentage
from stdin payload and prints display-only hint at 60% / 70%. NEVER runs
git (research/03 — statusLine scripts can be cancelled mid-flight, unsafe
for side effects). 9 tests cover thresholds, null payload, malformed JSON.
Includes hook-helper.mjs copied from llm-security as test infrastructure.
2026-05-01 06:06:25 +02:00
Kjell Tore Guttormsen
cb6f878c19 feat(graceful-handoff): 2.0 — JSON pipeline script with idempotency and confirm-on-commit [skip-docs]
Step 2 of v2.0 plan. Deterministic Node script that classifies handoff
type, renders artifact, and orchestrates commit/push with explicit
confirmation. Handles detached HEAD, no-upstream, and idempotency
(60s cooldown on clean tree). 10 tests cover dry-run, --auto path,
interactive y/n, idempotency, robustness edge cases.
2026-05-01 06:06:25 +02:00
Kjell Tore Guttormsen
e6db35418d feat(graceful-handoff): 2.0 — migrate to skills/ with disable-model-invocation [skip-docs]
Step 1 of v2.0 plan. Hard cut from commands/ to skills/ per Anthropic
recommendation for new plugins. Frontmatter sets disable-model-invocation:
true and pins model: claude-sonnet-4-6. Docs (README, CLAUDE.md, root
README) deferred to Step 9 per plan.
2026-05-01 05:45:26 +02:00
Kjell Tore Guttormsen
5c68c2c7f8 feat(graceful-handoff): initial plugin with /graceful-handoff command
New plugin that produces a complete session handoff in under 60s:
NEXT-SESSION artifact, commit+push, and copy-paste prompt for next
session. Built for context-constrained models like Opus 4.7 where
sessions fill fast.

- Single declarative command, no hooks/agents/skills
- Detects handoff type: multi-session / plugin-work / single-task
- Default filename NEXT-SESSION-PROMPT.local.md; slug-override
- Flags: --no-commit, --dry-run
- Auto-generated Conventional Commits message from git diff --stat
- Respects pre-commit hooks (secrets, pathguard) — never bypasses

Also: add *.local.md to root .gitignore (existing NEXT-SESSION files
were untracked but not ignored) and list plugin in marketplace
README + CLAUDE.md per docs-convention.
2026-04-19 22:54:10 +02:00