Skip to content

[feature] sp new --stdin / quick-capture from a pipe (headless scratch creation) #27

Description

@rwrife

Pitch

Today sp new always shells out to $EDITOR — perfect for interactive use, useless in a pipeline or from another tool/AI agent. There's no way to say "take this text and stash it as a scratch" without a human opening an editor. Add a headless capture path so scratchpatch can ingest content programmatically:

pytest -q 2>&1 | sp new failing-tests --stdin --tag ci
sp new note --stdin <<'EOF'
remember to revoke that token
EOF
curl -s https://api.example.com/thing | sp new resp --ext json --stdin

This turns scratchpatch into a sink for throwaway output (logs, API responses, generated snippets), which is squarely on-mission ("give every throwaway a home with an expiry") and directly serves the AI-agent-hygiene angle from PLAN.md — agents can park temp output in the reaped store instead of littering the repo.

Why it fits

  • Reuses the exact create/index path sp new already uses; only difference is content comes from stdin (or --content/--from-file) instead of an editor round-trip.
  • Composes with the existing secret tripwire: piped-in content should still get scanned so a secret gets flagged (🔑) at capture time.
  • Pure additive flag on an existing command; interactive sp new behavior unchanged when --stdin is absent.

Acceptance criteria

  • sp new [name] --stdin reads content from standard input and creates the scratch without launching $EDITOR.
  • Honors existing --ttl, --ext, --tag flags on the same invocation.
  • Sensible companions: --content "<text>" for a one-liner and/or --from-file <path> to seed from an existing file (pick at least --stdin; the others are nice-to-have if cheap).
  • Empty stdin is handled deliberately (either refuse with a clear message or create an empty scratch — document the choice).
  • On success, prints the same tombstone-flavored confirmation as interactive sp new (still leads with the stable created scratch <id> anchor so scripts/tests keep working).
  • Newly captured content is run through the secret scanner so sp ls shows the 🔑 marker and sp promote guards it, same as editor-created scratches.
  • --stdin + a TTY with no piped input doesn't hang forever (guard/allow but document).
  • Tests cover: stdin capture, flag combos, secret detection on piped content, and that $EDITOR is not invoked. go build/go vet/go test ./.../gofmt clean.
  • README documents the headless/pipe workflow with examples.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature / backlog item

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions