fix(endsession): parse arguments with the arg-parser so a slug with -h is no help request, and only the operator starts it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-10-23 14:45:25 +02:00
commit 403afe606f
Signed by: ktg
SSH key fingerprint: SHA256:JakMjO6FTBBzN0Bhfj9saOoEjaFxlSdYuZQQpM/lF9Q
5 changed files with 148 additions and 7 deletions

View file

@ -2,6 +2,7 @@
name: trekendsession
description: Mark the current session as complete and write session-state pointing at the next session. Helper for informal multi-session flows.
argument-hint: "<next-brief-path> <next-label> | --help"
disable-model-invocation: true
---
# Voyage End-Session Local v1.0
@ -29,8 +30,25 @@ See **Handover 7** in `docs/HANDOVER-CONTRACTS.md` for the schema.
## Phase 0 — `--help` handling
If `$ARGUMENTS` contains `--help` or `-h`, print the usage block below and exit
cleanly. Do NOT proceed to any further phase.
Parse `$ARGUMENTS` with the arg parser. Run this via the Bash tool at runtime
(NOT eager-exec):
```bash
setopt nonomatch 2>/dev/null || true
node ${CLAUDE_PLUGIN_ROOT}/lib/parsers/arg-parser.mjs --command trekendsession -- $ARGUMENTS
```
It prints the parse result as JSON. On exit 1, print its `errors` and stop.
Print the usage block below and exit cleanly ONLY when one of these two
conditions equals exactly true (no substring search, no "contains" check):
- `flags['--help'] === true`, OR
- `positional[0] === '-h'` (single-dash short form — the parser keeps it as
positional because the schema declares no alias).
Then do NOT proceed to any further phase. In every other case — a slug or a
label that holds `-h` or `help` too — go on to Phase 1.
```
/trekendsession — Mark current session done; point at next session.
@ -76,8 +94,9 @@ Decision tree:
## Phase 2 — Required args check (headless-safe)
Read `$ARGUMENTS`. Both `<next-brief-path>` and `<next-label>` are required.
If either is missing or empty:
Read the parse result from Phase 0: `<next-brief-path>` is `positional[0]`
and `<next-label>` is `positional[1]`. Both are required. If either is
missing or empty:
```
Error: missing required args.
@ -176,6 +195,7 @@ before retrying — usually means a bad path or label argument.
- **Atomic write only.** Tmp + rename — no partial state files on disk.
- **Zero secrets.** Status, paths, labels — never API keys, never user content
beyond filenames.
- **NEVER auto-invoke this command.** It is operator-typed only at session-end.
- **NEVER auto-invoke this command.** It is operator-typed only at session-end
(the frontmatter field keeps the model from starting it; the operator types it).
- **Idempotent within a session.** Running twice with the same args
overwrites cleanly (atomic rename); does not double-advance.