Compare commits
7 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5334097c84 | |||
| be0a463e02 | |||
| 96a22474bd | |||
| 9f84234440 | |||
| 5e17409275 | |||
| 13e29723a7 | |||
| 192d4403eb |
9 changed files with 487 additions and 95 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "graceful-handoff",
|
||||
"version": "3.0.0",
|
||||
"version": "3.2.1",
|
||||
"description": "One-command session handoff into the STATE.md continuity system. /graceful-handoff reaches a natural stopping point, overwrites the nearest STATE.md with a complete state-of-play (mandatory '👉 NESTE' block), and commits per remote policy (private → tracked, public mirror → local-only). Skill-only, deterministic STATE helper, no hooks.",
|
||||
"author": {
|
||||
"name": "Kjell Tore Guttormsen"
|
||||
|
|
|
|||
53
CHANGELOG.md
53
CHANGELOG.md
|
|
@ -4,6 +4,59 @@ All notable changes to graceful-handoff are documented here.
|
|||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
|
||||
## [3.2.1] - 2026-08-09
|
||||
|
||||
The first time the pipeline was ever run against real repositories. It found two defects sitting under a 42/42-green suite — which is the point the repo's own docs had been making about what prose-grep tests can and cannot prove.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **`dirty_files` truncated the first path.** `gitOk()` called `.trim()` on every command's output, but `git status --porcelain` encodes the worktree status in column 2 — a modified-but-unstaged file is `" M path"`. The trim ate that leading space, and the fixed `slice(3)` then ate the first character of the first path: `app.js` was reported as `pp.js`. Only the first line was affected, which is exactly why it survived: no existing test asserted `dirty_files` **values**, only that the key existed. Porcelain output is now read through a non-trimming `gitOkRaw()`.
|
||||
- **The commit message claimed a STATE.md update it did not contain.** `generateCommitMessage()` always produced `docs(<repo>): oppdater STATE.md (session handoff)`. On every `open/` repo — including this one — STATE.md is gitignored, so the handoff commit carries only the explicit `--also` paths. Git history is the regime's long-term log; it was systematically wrong about its own contents. The message now branches on what was actually staged.
|
||||
|
||||
### Changed
|
||||
|
||||
- **The leak condition is a hard gate, not an advisory.** 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 merely *mentioned* `leak_warning` and committed anyway. The warning now also lands in `errors[]` (step 2 stops on a non-empty `errors[]`), `should_commit_state` is `false`, and `--commit` refuses to stage STATE.md (`state-leak-blocked`). Explicit `--also` paths are still honoured: the gate protects STATE.md, not the commit as a whole. Both `--plan` and `--commit` now consult one exported `leakBlock()` so they cannot disagree.
|
||||
- **SKILL.md's justification for the single-line rule was outdated.** It claimed a wrapped `rationale=` replaces the repo's next step on the board with garbage. `board.sh` in repo-mailbox 0.20.3 tracks an HTML comment to its closer, so that no longer follows. The rule stands, now stated with the risk that *is* still real: a `rationale=` containing `-->` ends its own comment early.
|
||||
|
||||
### Tests
|
||||
|
||||
- 42 → 48. Four pipeline tests (first-character preservation in `dirty_files`, the `--plan` and `--commit` halves of the leak gate, commit-message honesty) and two SKILL.md drift guards (the corrected single-line rationale, and step 2 stopping rather than reporting). All six were written failing first.
|
||||
|
||||
### Not verified
|
||||
|
||||
- That `/graceful-handoff` loads as a user command (issue [#26251](https://github.com/anthropics/claude-code/issues/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 actually installed; the smoke test could exercise the pipeline but not the slash command.
|
||||
|
||||
## [3.2.0] - 2026-08-09
|
||||
|
||||
### Changed
|
||||
|
||||
- **The ritual is back in sync with the global "Session Slutt" mechanism.** SKILL.md had drifted: its STATE.md template predated the mandatory `board:` line and the `route:` / `route-last:` lines, and its closing line still demanded three fields where the global CLAUDE.md now requires six. Both are fixed, and the ordering matters — see below.
|
||||
- **New step 3: route the next session *before* STATE.md is written.** The ritual now invokes the `repo-mailbox:route` skill between `--plan` and 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 two consumers — the three comment lines in the template, and the `Modell neste økt` / `Oppstartskommando` fields in the closing line. Deriving the model by hand in the closing line is exactly what the lookup exists to prevent.
|
||||
- **`repo-mailbox` is a soft dependency.** The plugin is separately installable, so step 3 documents a fallback: if `repo-mailbox` is absent (or the cross-plugin `Skill` invocation is blocked), the ritual continues, fills `next-cost` by judgement, and says so explicitly rather than passing it off as a rubric lookup. `route.sh`'s path is deliberately **not** hardcoded — it sits in the plugin cache behind a version number that drifts.
|
||||
- **The template now carries the single-line constraint in prose, not just by example.** `board.sh` reads the first line under the `👉 NESTE` heading that is non-blank, non-heading and does not *start* with `<!--`, and shows it as that repo's next step across every repo — so a `rationale=` wrapped across two lines replaces the repo's next step on the board with garbage.
|
||||
- **Closing line: 3 fields → 6.** Added `Innboks`, `Modell neste økt` and `Oppstartskommando`. The inbox field **reports what the session did** rather than re-querying the mailbox: inbox handling belongs first in a session, and a fresh read at handoff time surfaces messages too late to act on. A new light step 7 makes the distinction explicit, including that "no inbox was injected" must never be reported as "empty ✅".
|
||||
- **STATE.md format consolidated to one copy.** The repo's own `CLAUDE.md` restated the format — with the same missing lines, the identical defect in a second location. It now points at SKILL.md step 4 as the authority instead, following the precedent set when the model rubric was removed from the global CLAUDE.md: two copies drift, and prose in a doc file cannot be tested.
|
||||
- `allowed-tools` gains `Skill` (needed to invoke `repo-mailbox:route`). `Bash` stays sub-scoped; `curl`/`wget` remain unapproved.
|
||||
- **`plugin.json`'s `description` is deliberately unchanged** — it is still accurate, and editing it would require the manual `marketplace.json` description edit that `release-plugin.mjs` does not perform.
|
||||
|
||||
### Tests
|
||||
|
||||
- 30 → 42. Eleven new guards in `skill-structure.test.mjs` (all three comment lines present, closed status-token set, single-line warning, `repo-mailbox:route` referenced, route step ordered *before* the Write, documented fallback, all six closing-line fields, the "three items" phrasing gone, the inbox honesty rule, and repo `CLAUDE.md` deferring to SKILL.md) plus the version/CHANGELOG pins in `plugin-manifest.test.mjs`.
|
||||
- **These are prose greps — drift guards, not correctness proofs.** None of them executes the ritual. Verifying it means running `/graceful-handoff` manually against a scratch repo.
|
||||
|
||||
### Changed (documentation, released with this version)
|
||||
|
||||
- **README brought in line with the org repo standard** (`repo-standard` gate, 0 ERROR). Documentation only — no plugin code, version, or behaviour changed. H1 is now the repo name; the opening line is verbatim the forge description (so description == catalog == README is machine-checkable); `## Install` is a top-level heading on the first screen and carries the CLI command `claude plugin install graceful-handoff@ktg-plugin-marketplace` next to `marketplace add`; `## Non-goals` and `## Changelog` sections added.
|
||||
- **Dropped the static `tests-30` badge.** This forge has no CI runner, so the badge asserted a run nothing verifies. The Testing section now states the command and says plainly that nothing runs it automatically. Note for the catalog: the tests axis no longer has a badge backing it.
|
||||
- **Fixed two dead `../../README.md` references** inherited from the monorepo (README lines 7 and the marketplace footer) — both pointed outside a standalone repo and 404'd.
|
||||
- **Dropped the `hooks-0` badge** (6 → 5 badges, clearing the `repo-standard` BADGE-COUNT warning). A badge asserting an absence is not something a reader acts on, and "No hooks" is already stated in prose where it carries its actual argument. The `skill-1` badge was deliberately kept: it is the only axis the catalog's version gate can still verify for this plugin.
|
||||
|
||||
## [3.1.0] - 2026-06-24
|
||||
|
||||
### Changed
|
||||
|
||||
- **Removed the hardcoded push window — push is now unconditional, Forgejo only.** 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. The two other invariants are unchanged: **push is Forgejo only, never GitHub**, and **push stays user-triggered** (the skill is `disable-model-invocation: true` and never auto-pushes outside a user-invoked handoff). `handoff-pipeline.mjs` 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.
|
||||
|
||||
## [3.0.0] - 2026-06-23
|
||||
|
||||
### BREAKING
|
||||
|
|
|
|||
68
CLAUDE.md
68
CLAUDE.md
|
|
@ -1,4 +1,4 @@
|
|||
# graceful-handoff (v3.0)
|
||||
# graceful-handoff (v3.2)
|
||||
|
||||
Én-kommandos sesjonsoverlevering inn i **STATE.md-kontinuitetssystemet**. `/graceful-handoff`
|
||||
når et naturlig stoppunkt, overskriver nærmeste `STATE.md` med en komplett state-of-play
|
||||
|
|
@ -24,17 +24,25 @@ Bare sesjonsmodellen har konteksten til å fylle «👉 NESTE»-blokken meningsf
|
|||
|
||||
| Fil | Rolle |
|
||||
|-----|-------|
|
||||
| `skills/graceful-handoff/SKILL.md` | Rituelet, modell-drevet (full kontekst). Frontmatter: `disable-model-invocation: true`, **ingen `model:`-pin** (arver sesjonsmodell — STATE.md er human-facing syntese → Opus-kvalitet), sub-scoped `allowed-tools` inkl. `Write`. |
|
||||
| `skills/graceful-handoff/SKILL.md` | Rituelet, modell-drevet (full kontekst). Frontmatter: `disable-model-invocation: true`, **ingen `model:`-pin** (arver sesjonsmodell — STATE.md er human-facing syntese → Opus-kvalitet), sub-scoped `allowed-tools` inkl. `Write` og `Skill` (sistnevnte for `repo-mailbox:route`). |
|
||||
| `scripts/handoff-pipeline.mjs` | Slank deterministisk STATE-hjelper. `--plan` (resolver nærmeste STATE.md + klassifiser remote + git-fakta, read-only), `--commit` (stager KUN STATE.md når tracked + eksplisitte `--also`-stier; aldri `git add -A`), `--dry-run`. Returnerer JSON. Testbar uten LLM. |
|
||||
|
||||
Rituelet (SKILL.md): nå naturlig stoppunkt → `--plan` → skriv/overskriv STATE.md i fast format
|
||||
→ `--commit` → push kun i vindu → fast avslutningslinje.
|
||||
Rituelet (SKILL.md): nå naturlig stoppunkt → `--plan` → rut neste økt (`repo-mailbox:route`) →
|
||||
skriv/overskriv STATE.md i fast format → `--commit` → push (Forgejo) → fast avslutningslinje.
|
||||
|
||||
## STATE.md-format (ufravikelig)
|
||||
## STATE.md-format (ufravikelig) — ÉN kopi, og den bor i SKILL.md
|
||||
|
||||
`# STATE — <navn>` + undertittel → **`## 👉 NESTE — START HER`** ØVERST (hvor vi er + nummererte
|
||||
neste steg + pekere til hva som må leses) → faste seksjoner (oppdrag/kjøremodus, gotchas,
|
||||
push-status, repo/env) + kort historikk UNDER. Maks ~60 linjer. Overskriv, ikke append.
|
||||
Formatet sto tidligere gjengitt her. Det er **fjernet med vilje**: to kopier av samme mal drifter
|
||||
fra hverandre, og en mal i en prosa-fil kan ikke testes. **Ikke gjenopprett den her.**
|
||||
|
||||
Autoriteten er `skills/graceful-handoff/SKILL.md` steg 4 («Skriv/overskriv STATE.md — UFRAVIKELIG
|
||||
FORMAT»), som er der rituelet faktisk leses fra ved kjøring, og som `tests/skill-structure.test.mjs`
|
||||
låser. Endres formatet (globalt CLAUDE.md er kilden), endres SKILL.md — og testen fanger drift.
|
||||
|
||||
Det ene som hører hjemme her, fordi det er en avhengighet og ikke en mal: `repo-mailbox` er en
|
||||
**myk** avhengighet. Steg 3 invokerer `repo-mailbox:route` for board-/route-linjene og for
|
||||
avslutningslinjens modellfelt; er den ikke installert, faller rituelet tilbake til et uttalt
|
||||
skjønnsvalg og fortsetter.
|
||||
|
||||
## Remote-policy (STATE må aldri nå et offentlig speil)
|
||||
|
||||
|
|
@ -42,8 +50,11 @@ Hjelperen klassifiserer `origin`:
|
|||
- `github.com` eller `open/`-Forgejo-namespace → **public** → STATE.md local-only (gitignored), committes aldri.
|
||||
- ellers (privat Forgejo `ktg/…`) → **private** → STATE.md tracked + committet.
|
||||
|
||||
Den autoritative commit-beslutningen er `git check-ignore STATE.md`; `remote_class` driver kun et
|
||||
`leak_warning` når de to er inkonsistente (offentlig remote, men STATE.md ikke gitignored).
|
||||
Den autoritative commit-beslutningen er `git check-ignore STATE.md`. Er de to inkonsistente
|
||||
(offentlig remote, men STATE.md IKKE gitignored) er det fra v3.2.1 en **hard gate**, ikke et varsel:
|
||||
`leak_warning` legges i `errors[]` (rituelet stopper i steg 2), `should_commit_state` blir `false`, og
|
||||
`--commit` nekter å stage STATE.md (`state-leak-blocked`). Det var den tilstanden et ferskt
|
||||
`open/`-repo starter i — å bare *nevne* den gjorde default-stien til lekkasjestien.
|
||||
|
||||
**Denne repoen har `open/`-remote → STATE.md er gitignored (local-only).** Plugin-koden er offentlig;
|
||||
state-of-play er det ikke.
|
||||
|
|
@ -59,20 +70,49 @@ ubeslektet WIP. Regresjonstest håndhever dette. Pre-commit hooks respekteres ut
|
|||
node --test 'tests/**/*.test.mjs'
|
||||
```
|
||||
|
||||
30 tester på tvers av 3 filer (`skill-structure`, `scripts/handoff-pipeline`, `plugin-manifest`).
|
||||
48 tester på tvers av 3 filer (`skill-structure`, `scripts/handoff-pipeline`, `plugin-manifest`).
|
||||
Pipelinen er deterministisk og testes uten LLM-kall: `--plan`/`--commit`-JSON, nærmeste-STATE-resolusjon,
|
||||
remote-klassifisering, staging-disiplin (no-`git add -A`-regresjon), gitignored-STATE-skip, detached-HEAD,
|
||||
`--dry-run`.
|
||||
|
||||
**Vær ærlig om hva de beviser.** Ritual-testene i `skill-structure` er prosa-grep — de er
|
||||
drift-vakter, ikke korrekthetsbevis. Ingen av dem kjører rituelet. Grønne tester er ikke det
|
||||
samme som et verifisert ritual: smoke-testen 2026-08-09 kjørte pipelinen mot ekte scratch-repo
|
||||
og fant **to defekter under en 42/42-grønn suite** (`dirty_files` mistet første tegn; commit-
|
||||
meldingen påsto STATE-oppdatering den ikke inneholdt). Begge er fikset i v3.2.1 med test først.
|
||||
|
||||
**Fortsatt uverifisert:** at `/graceful-handoff` laster som user-command (issue #26251), og at
|
||||
kryss-plugin-`Skill`-invokering av `repo-mailbox:route` slipper gjennom fra en sub-scopet skill.
|
||||
Begge krever at katalogens `ref` er bumpet slik at versjonen faktisk er installert.
|
||||
|
||||
## Versjonering
|
||||
|
||||
- v1.0.0 (2026-04-19): deklarativ command, NEXT-SESSION-artefakt
|
||||
- v2.0.0 (2026-05-01): skill-arkitektur + JSON-pipeline + 3 hooks + auto-trigger (BREAKING)
|
||||
- v2.1.0 (2026-05-01): modell-bevisst kontekstvindu (4-stegs resolution-kjede)
|
||||
- v3.0.0 (2026-06-23): **STATE.md-integrasjon (BREAKING).** Fjernet NEXT-SESSION-artefakt + alle 3 hooks; invertert pipeline (modellen skriver STATE.md, skriptet assisterer); remote-aware tracked/local-only-policy; fjernet Sonnet-pin.
|
||||
- v3.1.0 (2026-06-24): fjernet hardkodet push-vindu — push er nå ubetinget (kun Forgejo, fortsatt user-triggered).
|
||||
- v3.2.1 (2026-08-09): **første ekte smoke-test.** Fikset `dirty_files`-trunkering (`gitOk().trim()` spiste porcelain-linjens ledende mellomrom → `app.js` ble `pp.js`), commit-melding som påsto STATE-oppdatering på local-only-repo, og gjorde lekkasje-tilstanden til en hard gate. SKILL.md-begrunnelsen for én-linjes-regelen korrigert mot `board.sh` 0.20.3.
|
||||
- v3.2.0 (2026-08-09): ritualet synket med global «Session Slutt» — nytt route-steg (`repo-mailbox:route`) før STATE-skrivingen, board-/route-/route-last-linjer i malen, avslutningslinjen utvidet fra 3 til 6 felt (Innboks, Modell neste økt, Oppstartskommando), STATE-formatet konsolidert til én kopi (SKILL.md).
|
||||
|
||||
## Release (polyrepo — egen gated handling)
|
||||
|
||||
En versjonsbump er ikke fullført før: (1) `v3.0.0`-tag laget + pushet i denne repoen, OG (2)
|
||||
katalogens `ref` bumpet til samme tag med `check-versions.mjs` grønn. Bruk
|
||||
`../catalog/scripts/release-plugin.mjs graceful-handoff <versjon>` (atomisk). Krever push-vindu + operatør-go.
|
||||
En versjonsbump er ikke fullført før: (1) `vX.Y.Z`-tag laget + pushet i denne repoen, OG (2)
|
||||
katalogens `ref` bumpet til samme tag. Krever operatør-go.
|
||||
|
||||
```bash
|
||||
node ../catalog/scripts/release-plugin.mjs graceful-handoff --create-tag --write --commit --push
|
||||
```
|
||||
|
||||
**Skriptet er dry-run uten flagg** — bar invokasjon printer bare planen. De fire flaggene gjør tag
|
||||
+ katalog-ref atomisk i én kjøring; `--create-tag` er ikke valgfri når taggen ennå ikke finnes
|
||||
(uten den stopper kjøringen med `BLOCKED`).
|
||||
|
||||
**Versjonen tas fra `plugin.json`, og overstyres KUN med `--version X.Y.Z`.** En bar posisjonell
|
||||
versjon (`… graceful-handoff 3.2.0`) blir **stilltiende ignorert** — `parseArgs` har allerede satt
|
||||
`name`, og argumentet starter ikke med `--`, så det faller ut. Det ser ut til å virke så lenge
|
||||
`plugin.json` tilfeldigvis er enig; første gang den ikke er det, slipper feil versjon gjennom.
|
||||
|
||||
**Verifisering:** `node ../catalog/scripts/check-versions.mjs` — kriteriet er at **raden for
|
||||
`graceful-handoff` er `✓ OK`**, ikke at kjøringen er grønn. Skriptet exit-koder på hele katalogen,
|
||||
så ERROR/WARN fra andre plugins (som er andre repos ansvar) holder den rød uansett hva vi gjør.
|
||||
|
|
|
|||
102
README.md
102
README.md
|
|
@ -1,26 +1,50 @@
|
|||
# Graceful Handoff Plugin for Claude Code
|
||||
# graceful-handoff
|
||||
|
||||
> One command to end a session cleanly and hand it to the next one — `/graceful-handoff` reaches a natural stopping point and overwrites the nearest `STATE.md` with a complete, self-standing state-of-play.
|
||||
One-command session handoff into the STATE.md continuity system. Overwrites the nearest STATE.md with a complete state-of-play and commits per remote policy.
|
||||
|
||||
> **Solo-maintained, fork-and-own.** This plugin is a starting point, not a vendor product. Issues are welcome as signals; pull requests are not accepted. See [GOVERNANCE.md](GOVERNANCE.md) for the full model and what upstream provides.
|
||||
|
||||
*AI-generated: all code produced by Claude Code through dialog-driven development. [Full disclosure →](../../README.md#ai-generated-code-disclosure)*
|
||||
*AI-generated: all code produced by Claude Code through dialog-driven development. Every change is human-directed, reviewed, and validated before commit. Per Anthropic Consumer Terms §4, ownership of outputs is assigned to the user.*
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
A Claude Code plugin that makes session handoff a single deliberate command, fully integrated with a `STATE.md`-based continuity system. When a session is filling up — or you simply want to stop — `/graceful-handoff` reaches a natural stopping point, **overwrites the nearest `STATE.md`** with where you are, the next concrete step, and what to read, then commits per your remote policy. The next session reads that `STATE.md` and stands on its own.
|
||||
|
||||
---
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
claude plugin marketplace add https://git.fromaitochitta.com/open/ktg-plugin-marketplace.git
|
||||
claude plugin install graceful-handoff@ktg-plugin-marketplace
|
||||
```
|
||||
|
||||
Or enable directly in `~/.claude/settings.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"enabledPlugins": {
|
||||
"graceful-handoff@ktg-plugin-marketplace": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Claude Code](https://docs.anthropic.com/en/docs/claude-code) v2.x+
|
||||
- Node.js (any recent LTS — for the helper script)
|
||||
- A git repository (the helper detects detached HEAD / missing upstream and reports gracefully)
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [What Is This?](#what-is-this)
|
||||
- [Non-goals](#non-goals)
|
||||
- [The Problem](#the-problem)
|
||||
- [The STATE.md Model](#the-statemd-model)
|
||||
- [Quick Start](#quick-start)
|
||||
|
|
@ -33,6 +57,7 @@ A Claude Code plugin that makes session handoff a single deliberate command, ful
|
|||
- [Testing](#testing)
|
||||
- [What Changed in v3.0 (BREAKING)](#what-changed-in-v30-breaking)
|
||||
- [Limitations & Open Assumptions](#limitations--open-assumptions)
|
||||
- [Changelog](#changelog)
|
||||
- [License](#license)
|
||||
- [Feedback & Contributing](#feedback--contributing)
|
||||
|
||||
|
|
@ -47,12 +72,25 @@ Invoke it whenever you want to hand off. The session:
|
|||
1. **Reaches the first natural stopping point** — finishes the current logical unit, leaves the code working.
|
||||
2. **Overwrites the nearest `STATE.md`** with a complete state-of-play in a fixed format, headed by a mandatory `👉 NESTE — START HER` block (where we are + the next concrete step + what to read).
|
||||
3. **Commits per remote policy** — staging *only* `STATE.md` (when tracked), never `git add -A`.
|
||||
4. **Leaves push to you**, gated by your push window.
|
||||
4. **Leaves push to you** — push to Forgejo, you-triggered (no window gate).
|
||||
|
||||
The skill is `disable-model-invocation: true`: the model cannot trigger a handoff on its own. Handoff is a deliberate, user-initiated moment.
|
||||
|
||||
---
|
||||
|
||||
## Non-goals
|
||||
|
||||
What this plugin deliberately does *not* do — read this before adopting it:
|
||||
|
||||
- **It never triggers itself.** No hooks, no Stop auto-trigger, no context-percentage threshold. If you want a handoff written automatically when a session fills up, this is the wrong plugin — v2 did that and v3 removed it on purpose.
|
||||
- **It does not read `STATE.md` back.** Injecting the nearest `STATE.md` at session start is the job of a global `session-start.sh` hook you own. This plugin only writes.
|
||||
- **It does not push.** The helper has no push path at all; pushing stays a separate, user-triggered step.
|
||||
- **It is not a general-purpose commit tool.** `--commit` stages `STATE.md` plus explicitly named `--also` paths, and nothing else. Unrelated dirty files stay dirty — by design.
|
||||
- **It does not edit `MEMORY.md` or `CLAUDE.md`.** It warns when `MEMORY.md` grows past 200 lines; the edit is yours.
|
||||
- **It does not publish anything.** `STATE.md` is internal state-of-play, never a public artifact — on a public remote it stays gitignored and uncommitted.
|
||||
|
||||
---
|
||||
|
||||
## The Problem
|
||||
|
||||
Long sessions fill the context window. The classic failure mode is summarizing, committing, and writing a continuation prompt under time pressure — or skipping steps and losing continuity. Earlier versions of this plugin attacked that with auto-trigger hooks that wrote a separate `NEXT-SESSION-PROMPT` artifact.
|
||||
|
|
@ -104,29 +142,7 @@ The `👉 NESTE` block is always first, right after the title — it carries the
|
|||
|
||||
## Quick Start
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- [Claude Code](https://docs.anthropic.com/en/docs/claude-code) v2.x+
|
||||
- Node.js (any recent LTS — for the helper script)
|
||||
- A git repository (the helper detects detached HEAD / missing upstream and reports gracefully)
|
||||
|
||||
### Install
|
||||
|
||||
```bash
|
||||
claude plugin marketplace add https://git.fromaitochitta.com/open/ktg-plugin-marketplace.git
|
||||
```
|
||||
|
||||
Or enable directly in `~/.claude/settings.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"enabledPlugins": {
|
||||
"graceful-handoff@ktg-plugin-marketplace": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Hand off
|
||||
Installed? Then the whole workflow is one command:
|
||||
|
||||
```
|
||||
> /graceful-handoff
|
||||
|
|
@ -154,7 +170,7 @@ flowchart TB
|
|||
SK -->|2. fetch facts| PLAN
|
||||
PLAN -->|JSON| SK
|
||||
SK -->|4. safe commit| COMMIT
|
||||
User -->|5. git push, in-window| Done((done))
|
||||
User -->|5. git push (Forgejo)| Done((done))
|
||||
```
|
||||
|
||||
Two pieces, one responsibility each: the **skill** synthesizes `STATE.md` (only it has the context); the **helper** does the deterministic mechanics (path resolution, remote classification, safe staging). The helper has no LLM dependencies and runs under `node:test` in seconds.
|
||||
|
|
@ -169,7 +185,7 @@ Two pieces, one responsibility each: the **skill** synthesizes `STATE.md` (only
|
|||
2. **`--plan`** — fetch deterministic facts (resolved `STATE.md` path, remote class, git status, recent commits).
|
||||
3. **Write / overwrite `STATE.md`** in the mandatory format (title → `👉 NESTE` block → fixed sections → short history). Max ~60 lines. Overwrite, never append.
|
||||
4. **`--commit`** — stage only `STATE.md` (when tracked) plus any explicit `--also` paths the model judges belong to the unit. Never `git add -A`.
|
||||
5. **Push** — check the window (`date '+%u %H:%M'`). In-window: push (Forgejo only, never GitHub). Out-of-window: park it and say so explicitly.
|
||||
5. **Push** — Forgejo only, never GitHub. Push is unconditional — no window gate.
|
||||
6. **MEMORY.md check** — if it exceeds 200 lines, warn (don't auto-edit).
|
||||
7. **Fixed closing line** — STATE.md status (path) · next session's first action (= the `👉 NESTE` block) · commit/push status.
|
||||
|
||||
|
|
@ -240,7 +256,7 @@ Enforced by tests, not convention:
|
|||
|
||||
- **Staging is explicit.** `--commit` stages *only* `STATE.md` (plus explicit `--also` paths). `git add -A` is never used — a regression test (`never stages unrelated dirty files`) enforces this.
|
||||
- **STATE.md never leaks to a public mirror.** On a public/`open/` remote `STATE.md` is gitignored and the helper refuses to commit it (`local-only-skipped`), verified by test.
|
||||
- **Push is never automatic.** The helper never pushes; push stays user-triggered and window-gated.
|
||||
- **Push is never automatic.** The helper never pushes; push stays user-triggered (no window gate); never automatic.
|
||||
- **Pre-commit hooks are respected.** The helper never uses `--no-verify`.
|
||||
- **No network calls.** No WebSearch, no Agent delegation, no MCP — fully local.
|
||||
- **Bash sub-scoped.** Skill `allowed-tools` enumerates `Bash(git:*) Bash(node:*) Bash(date:*)`.
|
||||
|
|
@ -253,15 +269,17 @@ Enforced by tests, not convention:
|
|||
node --test 'tests/**/*.test.mjs'
|
||||
```
|
||||
|
||||
30 tests across 3 files:
|
||||
48 tests across 3 files:
|
||||
|
||||
| File | Coverage |
|
||||
|------|----------|
|
||||
| `tests/skill-structure.test.mjs` | SKILL.md frontmatter (no `model:` pin, `Write` in allowed-tools, `disable-model-invocation`), `👉 NESTE` mandate, removal of `commands/` and `hooks/` |
|
||||
| `tests/skill-structure.test.mjs` | SKILL.md frontmatter (no `model:` pin, `Write` + `Skill` in allowed-tools, `disable-model-invocation`), `👉 NESTE` mandate, the three STATE header comment lines + their single-line constraint, route-before-write ordering, the six closing-line fields, removal of `commands/` and `hooks/` |
|
||||
| `tests/scripts/handoff-pipeline.test.mjs` | `--plan`/`--commit`/`--dry-run`, nearest-STATE resolution, remote classification, **no-`git add -A` regression**, gitignored-STATE skip, detached HEAD |
|
||||
| `tests/plugin-manifest.test.mjs` | plugin.json version + description, CHANGELOG `[3.0.0]` BREAKING + preserved history |
|
||||
| `tests/plugin-manifest.test.mjs` | plugin.json version + description, CHANGELOG `[3.2.1]`, `[3.2.0]` and `[3.0.0]` BREAKING + preserved history |
|
||||
|
||||
The suite runs in a few seconds — no LLM involvement.
|
||||
The suite runs in a few seconds — no LLM involvement. **Nothing runs it automatically:** this forge has no CI runner, so the command above from a clean clone is the only verification. That is also why this README carries no test badge — a static one would assert a run nobody performed.
|
||||
|
||||
**What the ritual tests do and do not prove.** The `skill-structure` checks are prose greps over `SKILL.md` — drift guards that catch the file falling out of step with the global session-end convention. None of them executes the ritual. Verifying the ritual itself means running `/graceful-handoff` manually against a scratch repo.
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -273,8 +291,6 @@ The suite runs in a few seconds — no LLM involvement.
|
|||
- **Remote-aware tracked/local-only policy** so `STATE.md` never leaks to a public mirror.
|
||||
- **Removed the Sonnet pin** — handoff synthesis inherits the session model.
|
||||
|
||||
Full history in [`CHANGELOG.md`](CHANGELOG.md).
|
||||
|
||||
---
|
||||
|
||||
## Limitations & Open Assumptions
|
||||
|
|
@ -285,6 +301,12 @@ Full history in [`CHANGELOG.md`](CHANGELOG.md).
|
|||
|
||||
---
|
||||
|
||||
## Changelog
|
||||
|
||||
See [CHANGELOG.md](CHANGELOG.md).
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
MIT. See [`LICENSE`](LICENSE).
|
||||
|
|
@ -295,4 +317,4 @@ MIT. See [`LICENSE`](LICENSE).
|
|||
|
||||
- **Bug reports + feature requests:** open an issue on [Forgejo](https://git.fromaitochitta.com/open/ktg-plugin-marketplace)
|
||||
- **Pull requests:** not accepted on this repo (solo project, dialog-driven development with Claude Code). Fork freely if you need to extend.
|
||||
- **Marketplace:** part of [ktg-plugin-marketplace](https://git.fromaitochitta.com/open/ktg-plugin-marketplace) — see the [root README](../../README.md) for related plugins.
|
||||
- **Marketplace:** part of [ktg-plugin-marketplace](https://git.fromaitochitta.com/open/ktg-plugin-marketplace) — see the catalog for related plugins.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
// STATE.md.
|
||||
// --commit : stage STATE.md (ONLY if it is NOT gitignored) plus any
|
||||
// explicit --also paths, then commit. NEVER `git add -A`.
|
||||
// Never pushes (push stays window-gated + user-triggered).
|
||||
// Never pushes (push stays user-triggered — no window gate).
|
||||
// --dry-run : never writes, never touches git.
|
||||
//
|
||||
// Why STATE.md must never be auto-committed on a public mirror: a repo whose only
|
||||
|
|
@ -59,10 +59,23 @@ function gitOk(cmd, opts = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
// Same as gitOk, but WITHOUT trim(). `git status --porcelain` puts the worktree
|
||||
// status in column 2, so a modified-but-unstaged file is " M path" — a leading
|
||||
// space that carries meaning. Trimming it shifted the first line left, and the
|
||||
// fixed slice(3) below then ate the first character of the first path ("app.js"
|
||||
// → "pp.js"). Only ever use this where leading whitespace is significant.
|
||||
function gitOkRaw(cmd, opts = {}) {
|
||||
try {
|
||||
return execSync(cmd, { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'pipe'], ...opts });
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function gitStatus(cwd) {
|
||||
const o = { cwd };
|
||||
const branch = gitOk('git branch --show-current', o) || gitOk('git rev-parse --abbrev-ref HEAD', o);
|
||||
const porcelain = gitOk('git status --porcelain', o) || '';
|
||||
const porcelain = (gitOkRaw('git status --porcelain', o) || '').replace(/\n+$/, '');
|
||||
const dirty = porcelain.length > 0;
|
||||
let ahead = 0;
|
||||
const upstream = gitOk('git rev-parse --abbrev-ref @{u} 2>/dev/null', o);
|
||||
|
|
@ -110,6 +123,18 @@ export function classifyRemote(url) {
|
|||
return 'private';
|
||||
}
|
||||
|
||||
// The leak gate. A public remote whose STATE.md is NOT gitignored is not an
|
||||
// advisory condition — it is the single state in which continuing the ritual is
|
||||
// itself what causes the leak, and it is exactly the state a fresh `open/` repo
|
||||
// starts in. Both --plan and --commit consult this one function so they cannot
|
||||
// disagree about whether STATE.md may be staged.
|
||||
export function leakBlock({ shouldBeLocalOnly, stateGitignored, remoteClass, remoteUrl }) {
|
||||
if (!shouldBeLocalOnly || stateGitignored) return null;
|
||||
return `BLOKKERT: STATE.md er IKKE gitignored, men remote er ${remoteClass} (${remoteUrl || 'ingen'}) — `
|
||||
+ `å committe den ville lekket intern state-of-play ved push. Legg 'STATE.md' i .gitignore `
|
||||
+ `(den skal være local-only på denne remoten), så kjør rituelet på nytt.`;
|
||||
}
|
||||
|
||||
// ---------- Plan (read-only) ----------
|
||||
|
||||
function buildPlan(cwd, errors) {
|
||||
|
|
@ -131,10 +156,9 @@ function buildPlan(cwd, errors) {
|
|||
{ cwd: dirname(statePath) }
|
||||
);
|
||||
|
||||
const leakWarning = (shouldBeLocalOnly && !stateGitignored)
|
||||
? `STATE.md er IKKE gitignored, men remote er ${remoteClass} (${remoteUrl || 'ingen'}) — `
|
||||
+ `legg STATE.md i .gitignore for å unngå å lekke intern state-of-play ved push.`
|
||||
: null;
|
||||
const leakWarning = leakBlock({ shouldBeLocalOnly, stateGitignored, remoteClass, remoteUrl });
|
||||
// Blocking, not advisory: step 2 of the ritual stops on a non-empty errors[].
|
||||
if (leakWarning) errors.push(leakWarning);
|
||||
|
||||
const git = gitStatus(cwd);
|
||||
const recentCommits = (gitOk('git log --oneline -8', { cwd }) || '').split('\n').filter(Boolean);
|
||||
|
|
@ -149,7 +173,7 @@ function buildPlan(cwd, errors) {
|
|||
remote_url: remoteUrl,
|
||||
remote_class: remoteClass,
|
||||
should_be_local_only: shouldBeLocalOnly,
|
||||
should_commit_state: !stateGitignored,
|
||||
should_commit_state: !stateGitignored && !leakWarning,
|
||||
leak_warning: leakWarning,
|
||||
git_status: { branch: git.branch, dirty: git.dirty, ahead: git.ahead, detached: git.detached, upstream: git.upstream },
|
||||
dirty_files: git.dirtyFiles,
|
||||
|
|
@ -161,9 +185,15 @@ function buildPlan(cwd, errors) {
|
|||
|
||||
// ---------- Commit (write) ----------
|
||||
|
||||
function generateCommitMessage(statePath, root) {
|
||||
// The message must describe what the commit actually contains. On every `open/`
|
||||
// repo STATE.md is gitignored, so the handoff commit carries only the explicit
|
||||
// --also paths — claiming a STATE.md update there made git history, the regime's
|
||||
// long-term log, systematically wrong about its own contents.
|
||||
function generateCommitMessage(statePath, root, includesState) {
|
||||
const name = root ? basename(root) : basename(dirname(statePath));
|
||||
return `docs(${name}): oppdater STATE.md (session handoff)`;
|
||||
return includesState
|
||||
? `docs(${name}): oppdater STATE.md (session handoff)`
|
||||
: `chore(${name}): session handoff (STATE.md local-only, ikke committet)`;
|
||||
}
|
||||
|
||||
function doCommit(cwd, args, errors) {
|
||||
|
|
@ -185,8 +215,20 @@ function doCommit(cwd, args, errors) {
|
|||
|
||||
// Build the stage list. CRITICAL: never `git add -A` — stage ONLY STATE.md
|
||||
// (when it is tracked, i.e. not gitignored) plus any explicit --also paths.
|
||||
// Same gate as --plan: never stage STATE.md onto a public remote. --also paths
|
||||
// stay honoured — the operator named those explicitly, and the gate protects
|
||||
// STATE.md specifically, not the commit as a whole.
|
||||
const remoteUrl = gitOk('git remote get-url origin 2>/dev/null', { cwd });
|
||||
const remoteClass = classifyRemote(remoteUrl);
|
||||
const leakWarning = leakBlock({
|
||||
shouldBeLocalOnly: remoteClass !== 'private', stateGitignored, remoteClass, remoteUrl,
|
||||
});
|
||||
|
||||
const stageList = [];
|
||||
if (!stateGitignored) {
|
||||
if (leakWarning) {
|
||||
errors.push(leakWarning);
|
||||
actions.push('state-leak-blocked (STATE.md ikke gitignored på offentlig remote — ikke staget)');
|
||||
} else if (!stateGitignored) {
|
||||
if (existsSync(statePath)) stageList.push(statePath);
|
||||
else errors.push(`STATE.md finnes ikke på ${statePath} — skriv den før commit`);
|
||||
} else {
|
||||
|
|
@ -199,11 +241,11 @@ function doCommit(cwd, args, errors) {
|
|||
}
|
||||
|
||||
if (stageList.length === 0) {
|
||||
actions.push('intet-å-committe (STATE.md gitignored og ingen --also-stier)');
|
||||
actions.push('intet-å-committe (STATE.md ikke committerbar og ingen --also-stier)');
|
||||
return { mode: 'commit', actions_taken: actions, errors, git_status: git };
|
||||
}
|
||||
|
||||
const message = args.message || generateCommitMessage(statePath, root);
|
||||
const message = args.message || generateCommitMessage(statePath, root, stageList.includes(statePath));
|
||||
|
||||
try {
|
||||
execFileSync('git', ['add', '--', ...stageList], { cwd, stdio: ['ignore', 'pipe', 'pipe'] });
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ name: graceful-handoff
|
|||
description: Avslutt sesjonen kontrollert og overlever til neste. Nå første naturlige stoppunkt, overskriv nærmeste STATE.md komplett (med «👉 NESTE — START HER»-blokk), commit per remote-policy, og skriv den faste avslutningslinjen. Bruk når du vil overlevere uten kontekst-tap.
|
||||
argument-hint: "[--no-commit] [--dry-run]"
|
||||
disable-model-invocation: true
|
||||
allowed-tools: Bash(git:*) Bash(node:*) Bash(date:*) Read Write Edit Glob
|
||||
allowed-tools: Bash(git:*) Bash(node:*) Bash(date:*) Read Write Edit Glob Skill
|
||||
---
|
||||
|
||||
# Graceful Handoff — STATE.md-sesjonsoverlevering (v3.0)
|
||||
# Graceful Handoff — STATE.md-sesjonsoverlevering (v3.2)
|
||||
|
||||
Dette er **én-kommandos-eksekvering av «Session Slutt»-rituelen** fra den globale
|
||||
CLAUDE.md, sentrert på STATE.md. Du (modellen) har full sesjonskontekst — bare du
|
||||
|
|
@ -15,7 +15,8 @@ deterministisk skript (`scripts/handoff-pipeline.mjs`) gjør kun de mekaniske bi
|
|||
resolverer nærmeste STATE.md, klassifiserer remoten (privat → tracked, offentlig/`open/`
|
||||
→ local-only), og committer trygt (KUN STATE.md, aldri `git add -A`).
|
||||
|
||||
**Tidsbudsjett:** hele rituelet under 60 sekunder. Ingen Agent-delegering, ingen WebSearch.
|
||||
**Tidsbudsjett:** hele rituelet på et par minutter — steg 3 (routing) er det eneste som
|
||||
koster tenkning. Ingen Agent-delegering, ingen WebSearch.
|
||||
|
||||
## Hvorfor STATE.md (ikke en NEXT-SESSION-artefakt)
|
||||
|
||||
|
|
@ -48,10 +49,32 @@ Parse JSON:
|
|||
"errors": []
|
||||
}
|
||||
```
|
||||
Hvis `errors[]` ikke er tom: rapporter og stopp. Hvis `leak_warning` er satt: nevn det
|
||||
for bruker (STATE.md burde vært gitignored på denne remoten).
|
||||
Hvis `errors[]` ikke er tom: rapporter og **STOPP** — ikke skriv STATE.md, ikke commit.
|
||||
|
||||
### 3. Skriv/overskriv STATE.md — UFRAVIKELIG FORMAT
|
||||
`leak_warning` er ett av dem, og det er en hard gate, ikke et varsel: er remoten offentlig
|
||||
mens STATE.md ennå IKKE er gitignored, er det å fortsette nettopp det som lekker intern
|
||||
state-of-play. Det er også tilstanden et ferskt `open/`-repo starter i. Si fra til bruker
|
||||
med remedien i klartekst — legg `STATE.md` i `.gitignore` — og kjør rituelet på nytt
|
||||
etterpå. Skriptet nekter uansett å stage STATE.md i denne tilstanden (`state-leak-blocked`).
|
||||
|
||||
### 3. Rut neste økt (FØR du skriver STATE.md)
|
||||
Bestem først HVA «👉 NESTE» skal si — selve arbeidet neste økt skal gjøre. Så scorer du
|
||||
den oppgaven med **`repo-mailbox:route`**-skillen (Skill-verktøyet). Rekkefølgen er ikke
|
||||
valgfri: routingen produserer linjer som skal STÅ I fila du skriver i steg 4. Rutes det
|
||||
etterpå, skitner du til en STATE.md du allerede har committet.
|
||||
|
||||
Én invokering dekker to forbrukere:
|
||||
1. de tre kommentar-linjene i STATE-malen under (`board` / `route` / `route-last`), og
|
||||
2. feltene **Modell neste økt** + **Oppstartskommando** i avslutningslinjen (steg 8).
|
||||
|
||||
Ikke utled modellen for hånd i steg 8 — det er nøyaktig det oppslaget finnes for. Splei
|
||||
`next-cost` inn i board-linjen; `status` og `blocked-on` er dine, skillen kan dem ikke.
|
||||
|
||||
**Hvis `repo-mailbox` ikke er installert** (eller Skill-invokeringen blokkeres): fortsett
|
||||
rituelet. Behold linjene i malen, fyll `next-cost` etter eget skjønn, og si eksplisitt i
|
||||
avslutningslinjen at modellvalget er en vurdering — ikke et rubrikk-oppslag.
|
||||
|
||||
### 4. Skriv/overskriv STATE.md — UFRAVIKELIG FORMAT
|
||||
Skriv `state_path` (Write, overskriv — ALDRI append). Maks ~60 linjer (kun første 160
|
||||
injiseres). Struktur, i denne rekkefølgen:
|
||||
|
||||
|
|
@ -60,6 +83,9 @@ injiseres). Struktur, i denne rekkefølgen:
|
|||
_Current state-of-play. Overskrives (ikke append) ved sesjonsslutt. Historikk → git._
|
||||
|
||||
## 👉 NESTE — START HER
|
||||
<!-- board: status=<planned|in-progress|blocked|deferred|done>; blocked-on=<repo|->; next-cost=<modell/effort> -->
|
||||
<!-- route: path=…; verification=…; reversibility=…; scope=…; rationale=… -->
|
||||
<!-- route-last: model=…; effort=…; completed=<yes|no>; corrections=<n> -->
|
||||
**<én setning: hvor vi er + hva som er neste konkrete handling>**
|
||||
1. **(du/meg)** <konkret steg>
|
||||
2. **(du/meg)** <konkret steg>
|
||||
|
|
@ -67,7 +93,7 @@ _Current state-of-play. Overskrives (ikke append) ved sesjonsslutt. Historikk
|
|||
|
||||
## <Oppdrag & kjøremodus> ← fast/uforanderlig: hva er målet, hvordan jobbes det
|
||||
## <Gotchas / ufravikelige regler> ← det neste sesjon MÅ vite for ikke å trå feil
|
||||
## <Push-status> ← hva er pushet vs parkert, og push-vindu-regel
|
||||
## <Push-status> ← hva er pushet vs parkert (push er fritt — ingen vindu-regel)
|
||||
## <Repo & env> ← branch, remote-klasse, tester, sentrale tall
|
||||
## <Sesjonssekvens / historikk> ← KORT; det meste hører i git
|
||||
```
|
||||
|
|
@ -75,13 +101,25 @@ _Current state-of-play. Overskrives (ikke append) ved sesjonsslutt. Historikk
|
|||
Krav til innholdet:
|
||||
- **👉 NESTE øverst, alltid** — rett etter tittel+undertittel, FØR alt annet. Den bærer
|
||||
det handlingsrettede. Operatøren skal aldri måtte lete.
|
||||
- **De tre kommentar-linjene MÅ stå på ÉN linje hver** — aldri brutt over flere, aldri
|
||||
som YAML-blokk. `board.sh` leser første linje under overskriften som ikke er blank,
|
||||
ikke en overskrift og ikke er del av en HTML-kommentar, og viser den som repoets neste
|
||||
steg på tvers av alle repo. Den sporer nå kommentaren til sin **closer** (repo-mailbox
|
||||
0.20.3), så en brukket linje river ikke lenger i seg tavlens neste steg — regelen står
|
||||
fordi den fortsatte risikoen er reell: en `rationale=` som selv inneholder `-->`
|
||||
avslutter sin egen kommentar for tidlig, og da er det kommentar-innmat som havner på
|
||||
tavlen. Skriv aldri closer-sekvensen inne i en rationale. `route-last` utelates helt
|
||||
hvis ett av de fire feltene er ukjent — en gjettet verdi leses tilbake senere som en
|
||||
måling.
|
||||
- **Board-linjen er den eneste kilden til hvem repoet venter PÅ** (`blocked-on`).
|
||||
Innboks-tall betyr det motsatte: at andre venter på DEG.
|
||||
- Konkret, ikke vagt. «Kjør `node --test tests/`, bekreft grønn, så release-cut» — ikke
|
||||
«fortsett arbeidet».
|
||||
- Skill mellom verifisert og antatt. Aldri skriv «gå til X» med mindre X eksisterer.
|
||||
- `[[memory-slug]]`-lenker til relevante auto-memory-fakta der det hjelper.
|
||||
- Selvtilstrekkelig for kald start: en fersk sesjon som KUN leser STATE.md skal vite nok.
|
||||
|
||||
### 4. Commit (med mindre `--no-commit` eller `--dry-run`)
|
||||
### 5. Commit (med mindre `--no-commit` eller `--dry-run`)
|
||||
```bash
|
||||
node ${CLAUDE_PLUGIN_ROOT}/scripts/handoff-pipeline.mjs --commit [--also <relatert-fil>...] [-m "melding"]
|
||||
```
|
||||
|
|
@ -92,24 +130,42 @@ node ${CLAUDE_PLUGIN_ROOT}/scripts/handoff-pipeline.mjs --commit [--also <relate
|
|||
ev. kode-endringer (via `--also`) og sier fra at STATE er local-only.
|
||||
- Pre-commit hooks respekteres — aldri `--no-verify`.
|
||||
|
||||
### 5. Push — vindu-gated, aldri automatisk
|
||||
```bash
|
||||
date '+%u %H:%M' # ukedag 1-7 + tid, norsk lokaltid
|
||||
```
|
||||
Sperret vindu: **man–tor 08:00–17:00** og **fre 08:00–16:00**. Ellers fritt.
|
||||
- I vindu: `git push origin <branch>` (kun Forgejo, ALDRI GitHub).
|
||||
- Utenfor vindu: IKKE push. Hold commiten lokalt og si eksplisitt at pushen er parkert
|
||||
til neste vindu åpner.
|
||||
### 6. Push (Forgejo, aldri automatisk utenfor handoff)
|
||||
Push er fritt — ingen ukedag/tidspunkt-gate. Etter `--commit`:
|
||||
- `git push origin <branch>` — **kun Forgejo, ALDRI GitHub**.
|
||||
- Hvis et repo har gitignored STATE.md (offentlig/`open/`-remote) committes/pushes kun
|
||||
ev. kode (`--also`-stier); STATE selv er local-only.
|
||||
- Skillen pusher kun innenfor en bruker-invokert handoff (den er
|
||||
`disable-model-invocation: true`) — aldri spontant.
|
||||
|
||||
### 6. MEMORY.md-sjekk (lett)
|
||||
Hvis auto-memory `MEMORY.md` finnes og er > 200 linjer: varsle bruker (flytt detalj til
|
||||
topic-filer). Ikke auto-rediger den her.
|
||||
### 7. Lette sluttsjekker
|
||||
- **MEMORY.md:** hvis auto-memory `MEMORY.md` finnes og er > 200 linjer: varsle bruker
|
||||
(flytt detalj til topic-filer). Ikke auto-rediger den her.
|
||||
- **Innboks:** gjør opp status for coord-meldingene DENNE økten faktisk fikk injisert —
|
||||
hver skal ha nådd en terminaltilstand (besvart med `coord-send --reply-to`, eller
|
||||
markert håndtert med `coord-done`). Ligger én igjen, er det lov, men det skal uttales
|
||||
med begrunnelse. **Ikke re-spør postkassen her:** innboksen håndteres FØRST i en økt,
|
||||
ikke ved avslutning — et ferskt oppslag på dette tidspunktet finner meldinger for sent
|
||||
til å gjøre noe med. Du rapporterer hva økten gjorde, ikke hva som ligger der nå.
|
||||
Ble **ingen innboks injisert** (eller er `repo-mailbox` ikke installert), skriv nettopp
|
||||
det — aldri «tom ✅» om noe du aldri så.
|
||||
|
||||
### 7. Avslutningslinje (FAST — droppes aldri)
|
||||
Avslutt svaret med eksakt tre ting (speiler den globale avslutningsinstruksen):
|
||||
### 8. Avslutningslinje (FAST — droppes aldri)
|
||||
Avslutt svaret med eksakt disse seks tingene, i denne rekkefølgen (speiler den globale
|
||||
avslutningsinstruksen — ingen av dem er valgfrie):
|
||||
- **STATE.md:** oppdatert ✅ + sti (eller «ikke endret» + hvorfor).
|
||||
- **Innboks:** tom ✅ / «ingen innboks ble injisert denne økten» / «N ubesvart» + hvorfor
|
||||
hver enkelt ble liggende.
|
||||
- **Neste sesjon:** den konkrete første handlingen (samme tekst som 👉 NESTE-blokken).
|
||||
- **Commit/push:** hash + pushet/parkert-status.
|
||||
- **Modell neste økt:** `next-cost` fra steg 3 + fallback én rad billigere, og hvilken
|
||||
regel som slo til (f.eks. «path=partial») — så valget er etterprøvbart.
|
||||
- **Oppstartskommando:** `command`-strengen fra steg 3, i egen kodeblokk, med `/exit`
|
||||
nevnt. **Aldri `cd` foran** (én repo per terminal-tab). Hører neste steg hjemme i et
|
||||
ANNET repo, si det i klartekst — det er en annen tab. Lim `--advisor`-flagget inn
|
||||
verbatim slik det kom; aldri legg det til på egen hånd. Holder `/clear` (samme modell
|
||||
OG samme advisor som nå), si det i stedet — men husk at bare en ny prosess plukker opp
|
||||
nyinstallerte plugins/skills.
|
||||
|
||||
## Flagg
|
||||
|
||||
|
|
@ -121,7 +177,16 @@ Avslutt svaret med eksakt tre ting (speiler den globale avslutningsinstruksen):
|
|||
## Begrensninger / antakelser (smoke-test)
|
||||
|
||||
- `disable-model-invocation: true` har en åpen issue (#26251) som potensielt kan blokkere
|
||||
user-invocation. Smoke-test at `/graceful-handoff` fungerer etter installasjon.
|
||||
user-invocation. **Fortsatt uverifisert** — smoke-testen 2026-08-09 kjørte pipelinen mot
|
||||
ekte repo, men kunne ikke teste selve slash-kommandoen. Smoke-test den etter installasjon.
|
||||
- Remote-klassifisering er heuristisk (`open/`/`github` → offentlig). Den autoritative
|
||||
commit-beslutningen er likevel `git check-ignore STATE.md` — så feilklassifisering
|
||||
fører ikke til lekkasje, kun til et `leak_warning` hvis konfigurasjonen er inkonsistent.
|
||||
commit-beslutningen er `git check-ignore STATE.md`. Er de to inkonsistente, stopper
|
||||
rituelet (steg 2) og skriptet nekter å stage STATE.md — feilklassifisering kan derfor
|
||||
koste deg en ekstra runde, men aldri en lekkasje.
|
||||
- **`repo-mailbox` er en myk avhengighet, ikke en hard.** Steg 3 invokerer
|
||||
`repo-mailbox:route` via Skill-verktøyet. To ting er ikke verifisert her: at
|
||||
`repo-mailbox` i det hele tatt er installert i et gitt repo, og at en `Skill`-oppføring
|
||||
i `allowed-tools` faktisk slipper gjennom en kryss-plugin-invokering fra en sub-scopet
|
||||
skill. Begge feiler likt og håndteres likt — fallback-stien i steg 3. Rituelet skal
|
||||
aldri stoppe på dette. Skriptstien til `route.sh` er bevisst IKKE hardkodet: den ligger
|
||||
i plugin-cachen bak et versjonsnummer som drifter.
|
||||
|
|
|
|||
|
|
@ -10,9 +10,16 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
|
|||
const MANIFEST = join(__dirname, '..', '.claude-plugin', 'plugin.json');
|
||||
const CHANGELOG = join(__dirname, '..', 'CHANGELOG.md');
|
||||
|
||||
test('plugin.json version is 3.0.0', () => {
|
||||
test('plugin.json version is 3.2.1', () => {
|
||||
const m = JSON.parse(readFileSync(MANIFEST, 'utf-8'));
|
||||
assert.equal(m.version, '3.0.0');
|
||||
assert.equal(m.version, '3.2.1');
|
||||
});
|
||||
|
||||
test('CHANGELOG has a [3.2.0] entry describing the ritual sync', () => {
|
||||
const c = readFileSync(CHANGELOG, 'utf-8');
|
||||
const match = c.match(/## \[3\.2\.0\][\s\S]*?(?=## \[3\.1\.0\]|$)/);
|
||||
assert.ok(match, '[3.2.0] section missing');
|
||||
assert.match(match[0], /route/);
|
||||
});
|
||||
|
||||
test('plugin.json description mentions STATE.md', () => {
|
||||
|
|
|
|||
|
|
@ -118,6 +118,54 @@ test('--plan: private remote → should_commit_state true, not local-only', asyn
|
|||
rmSync(repo, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
test('--plan: dirty_files keeps the first character of a worktree-only change', async () => {
|
||||
// Regression (smoke-test 2026-08-09): `git status --porcelain` encodes the
|
||||
// worktree status in column 2, so a modified-but-unstaged file is " M path".
|
||||
// gitOk() trimmed the whole command output, eating that leading space, and
|
||||
// the fixed slice(3) then ate the first character of the FIRST path:
|
||||
// "app.js" was reported as "pp.js". Only the first line is affected, which is
|
||||
// why it survived every existing test — none asserted dirty_files values.
|
||||
const repo = makeTempRepo({ remote: 'ssh://git@git.fromaitochitta.com/ktg/secret.git' });
|
||||
writeFileSync(join(repo, 'README.md'), '# test modified\n', 'utf-8'); // tracked → " M README.md"
|
||||
writeFileSync(join(repo, 'zz-untracked.txt'), 'x\n', 'utf-8'); // sorts after → "?? zz-..."
|
||||
const result = await runPipeline(repo, ['--plan']);
|
||||
const json = JSON.parse(result.stdout);
|
||||
assert.ok(
|
||||
json.dirty_files.includes('README.md'),
|
||||
`first dirty path truncated: ${JSON.stringify(json.dirty_files)}`
|
||||
);
|
||||
assert.ok(json.dirty_files.includes('zz-untracked.txt'), 'untracked path missing');
|
||||
rmSync(repo, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
// ---------- leak hard-gate (public remote + STATE.md not gitignored) ----------
|
||||
|
||||
test('--plan: public remote + STATE not gitignored BLOCKS the ritual (errors, no commit)', async () => {
|
||||
const repo = makeTempRepo({ remote: 'ssh://git@git.fromaitochitta.com/open/foo.git' });
|
||||
const result = await runPipeline(repo, ['--plan']);
|
||||
const json = JSON.parse(result.stdout);
|
||||
assert.equal(json.should_commit_state, false, 'must not advertise STATE.md as committable');
|
||||
assert.ok(
|
||||
json.errors.some(e => /gitignore/i.test(e)),
|
||||
`expected a blocking leak error naming the remedy, got ${JSON.stringify(json.errors)}`
|
||||
);
|
||||
rmSync(repo, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
test('--commit refuses to stage STATE.md on a public remote when it is not gitignored', async () => {
|
||||
const repo = makeTempRepo({ remote: 'ssh://git@git.fromaitochitta.com/open/foo.git' });
|
||||
writeFileSync(join(repo, 'STATE.md'), '# STATE would leak\n');
|
||||
const result = await runPipeline(repo, ['--commit']);
|
||||
const json = JSON.parse(result.stdout);
|
||||
const tracked = execFileSync('git', ['ls-files', 'STATE.md'], { cwd: repo, encoding: 'utf-8' }).trim();
|
||||
assert.equal(tracked, '', 'STATE.md must never become tracked on a public remote');
|
||||
assert.ok(
|
||||
json.errors.some(e => /gitignore/i.test(e)),
|
||||
`expected a blocking leak error, got ${JSON.stringify(json.errors)}`
|
||||
);
|
||||
rmSync(repo, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
// ---------- --commit ----------
|
||||
|
||||
test('--commit on private repo stages and commits ONLY STATE.md', async () => {
|
||||
|
|
@ -175,6 +223,26 @@ test('--commit on public repo does NOT commit gitignored STATE.md', async () =>
|
|||
rmSync(repo, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
test('--commit message does not claim a STATE.md update when STATE.md was skipped', async () => {
|
||||
// On every `open/` repo STATE.md is gitignored, so the handoff commit carries
|
||||
// only the explicit --also paths. The message claimed "oppdater STATE.md"
|
||||
// regardless, making git history — the regime's long-term log — systematically
|
||||
// wrong about what the commit contains.
|
||||
const repo = makeTempRepo({ remote: 'ssh://git@git.fromaitochitta.com/open/foo.git', gitignoreState: true });
|
||||
writeFileSync(join(repo, 'STATE.md'), '# STATE local-only\n');
|
||||
writeFileSync(join(repo, 'code.mjs'), 'export const x = 1;\n');
|
||||
const result = await runPipeline(repo, ['--commit', '--also', 'code.mjs']);
|
||||
const json = JSON.parse(result.stdout);
|
||||
assert.ok(json.actions_taken.includes('committed'), `expected a commit, got ${JSON.stringify(json.actions_taken)}`);
|
||||
assert.doesNotMatch(
|
||||
json.commit_message,
|
||||
/oppdater STATE\.md/,
|
||||
`commit claims a STATE.md update it does not contain: ${json.commit_message}`
|
||||
);
|
||||
assert.match(json.commit_message, /local-only/, 'message should say why STATE.md is absent');
|
||||
rmSync(repo, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
test('--commit on detached HEAD is detected (no commit attempted)', async () => {
|
||||
const repo = makeTempRepo({ remote: 'ssh://git@git.fromaitochitta.com/ktg/secret.git' });
|
||||
const sha = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: repo, encoding: 'utf-8' }).trim();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { fileURLToPath } from 'node:url';
|
|||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const PLUGIN_ROOT = join(__dirname, '..');
|
||||
const SKILL = join(PLUGIN_ROOT, 'skills', 'graceful-handoff', 'SKILL.md');
|
||||
const REPO_CLAUDE_MD = join(PLUGIN_ROOT, 'CLAUDE.md');
|
||||
|
||||
function skill() {
|
||||
return readFileSync(SKILL, 'utf-8');
|
||||
|
|
@ -67,3 +68,97 @@ test('SKILL.md is STATE.md-centric (overwrites the nearest STATE.md)', () => {
|
|||
assert.match(s, /STATE\.md/);
|
||||
assert.match(s, /overskriv/i);
|
||||
});
|
||||
|
||||
// --- v3.2.0: the ritual matches the global CLAUDE.md session-end mechanism ---
|
||||
|
||||
test('SKILL.md allowed-tools includes Skill (needed to invoke repo-mailbox:route)', () => {
|
||||
const line = skill().match(/^allowed-tools:.*$/m);
|
||||
assert.ok(line, 'allowed-tools line missing');
|
||||
assert.match(line[0], /\bSkill\b/);
|
||||
});
|
||||
|
||||
test('SKILL.md NESTE template carries all three STATE header comment lines', () => {
|
||||
const s = skill();
|
||||
assert.match(s, /<!-- board: status=/);
|
||||
assert.match(s, /<!-- route: path=/);
|
||||
assert.match(s, /<!-- route-last: model=/);
|
||||
});
|
||||
|
||||
test('SKILL.md board line template uses the closed status token set', () => {
|
||||
assert.match(skill(), /planned.*in-progress.*blocked.*deferred.*done/);
|
||||
});
|
||||
|
||||
test('SKILL.md warns that the three comment lines must stay single-line (board.sh)', () => {
|
||||
const s = skill();
|
||||
assert.match(s, /board\.sh/);
|
||||
assert.match(s, /ÉN linje/);
|
||||
});
|
||||
|
||||
test('the single-line rule no longer rests on a consequence board.sh has since fixed', () => {
|
||||
// repo-mailbox 0.20.3's board.sh tracks an HTML comment to its closer, so a
|
||||
// wrapped rationale no longer leaks comment internals into the board excerpt.
|
||||
// The rule stands; the stated consequence had to stop being the reason.
|
||||
const s = skill();
|
||||
assert.doesNotMatch(s, /erstatter derfor neste steg på tavlen med søppel/);
|
||||
assert.match(s, /closer/, 'must name the real remaining risk (a rationale containing the closer)');
|
||||
});
|
||||
|
||||
test('SKILL.md hard-gates the leak case instead of merely mentioning it', () => {
|
||||
const s = skill();
|
||||
const step2 = s.slice(s.indexOf('### 2.'), s.indexOf('### 3.'));
|
||||
assert.match(step2, /leak_warning/);
|
||||
assert.match(step2, /STOPP|stopp/, 'step 2 must stop the ritual, not just report');
|
||||
assert.match(step2, /\.gitignore/, 'step 2 must name the remedy');
|
||||
});
|
||||
|
||||
test('SKILL.md routes the next session via the repo-mailbox route skill', () => {
|
||||
assert.match(skill(), /repo-mailbox:route/);
|
||||
});
|
||||
|
||||
test('the route step runs BEFORE STATE.md is written (lines are spliced into the file)', () => {
|
||||
const s = skill();
|
||||
const routeStep = s.indexOf('repo-mailbox:route');
|
||||
const writeStep = s.indexOf('UFRAVIKELIG FORMAT');
|
||||
assert.ok(routeStep > -1 && writeStep > -1, 'both steps must exist');
|
||||
assert.ok(
|
||||
routeStep < writeStep,
|
||||
'route must be scored before the STATE.md Write, else the commit is dirtied afterwards'
|
||||
);
|
||||
});
|
||||
|
||||
test('SKILL.md documents a fallback when repo-mailbox is not installed', () => {
|
||||
assert.match(skill(), /ikke installert/);
|
||||
});
|
||||
|
||||
test('SKILL.md closing line requires all six mandatory fields', () => {
|
||||
const s = skill();
|
||||
for (const field of [
|
||||
'STATE.md:',
|
||||
'Innboks:',
|
||||
'Neste sesjon:',
|
||||
'Commit/push:',
|
||||
'Modell neste økt:',
|
||||
'Oppstartskommando:',
|
||||
]) {
|
||||
assert.ok(s.includes(`**${field}**`), `closing-line field missing: ${field}`);
|
||||
}
|
||||
});
|
||||
|
||||
test('SKILL.md no longer claims the closing line has three items', () => {
|
||||
assert.doesNotMatch(skill(), /eksakt tre ting/);
|
||||
});
|
||||
|
||||
test('SKILL.md forbids asserting an empty inbox that was never seen', () => {
|
||||
assert.match(skill(), /Innboks/);
|
||||
assert.match(skill(), /ingen innboks ble injisert/i);
|
||||
});
|
||||
|
||||
test('repo CLAUDE.md points at SKILL.md as the STATE-format authority (one copy)', () => {
|
||||
const c = readFileSync(REPO_CLAUDE_MD, 'utf-8');
|
||||
const section = c.match(/## STATE\.md-format[\s\S]*?(?=\n## )/);
|
||||
assert.ok(section, 'STATE.md-format section missing from repo CLAUDE.md');
|
||||
assert.match(section[0], /SKILL\.md/, 'section must name SKILL.md as the authority');
|
||||
assert.match(section[0], /Ikke gjenopprett/, 'section must forbid restoring a second copy');
|
||||
// The template must NOT be restated here — two copies drift (the model-rubric precedent).
|
||||
assert.doesNotMatch(section[0], /# STATE — </, 'the template itself must not reappear here');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue