refactor(cli): prompt_or_flag helper + build_*_item compression (Plan B Phase 3) #4
Reference in New Issue
Block a user
Delete Branch "feature/cli-tail-stream-a-prompt-helpers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
prompt_or_flag<T>andprompt_or_flag_optional<T>tocrates/relicario-cli/src/prompt.rs(plus reader-injecting siblings for unit testability)build_*_itemfunctions incrates/relicario-cli/src/commands/add.rsto use the helpers — 7 title fields plus login'susernameandurlgo through one call site instead of theOption<T>::map(Ok).unwrap_or_else(|| prompt(...))?chainHonest scope note
The Plan B spec called for "~30% per-type body shrinkage" from this phase. In practice, after the deliberate carve-outs (
prompt_secretfor password/cvv/pin/totp-secret, multi-line stdin for body/key_material, parse-on-Some-only for expiry/dob/card-kind/totp-algorithm), the conversions are mostly 1-line-for-1-line replacements. The win is intent clarity and a single shared helper for the "flag-or-prompt" pattern, not raw LOC reduction. Future Plan B planning should calibrate compression-claim heuristics accordingly when most of the per-type body is non-prompt logic.Plan B Phase 3
Implements
docs/superpowers/specs/2026-05-04-cli-restructure-design.mdPhase 3.See
docs/superpowers/coordination/2026-05-09-cli-tail-coordinator.mdfor cycle-2 partition.Test plan
🤖 Generated with Claude Code
Phase 1 added impl Drop for SessionHandle on the Rust side so .free() now actually removes the SESSIONS registry entry. The JS-side try { current.free() } catch { /* already freed */ } swallow was hiding the fact that .free() wasn't doing the cleanup at all; post-Phase-1 it has to go so failures surface instead of being lost. .free() callsite audit: exactly one match under extension/src/ — the SW session.ts line this commit edits. Lifecycle audit: clearCurrent() is reached via (a) popup lock → router popup-only.ts and (b) session-timer expiry → service-worker/index.ts. Refs: docs/superpowers/specs/2026-05-04-security-polish-design.md (Phase 2) Refs: docs/superpowers/reviews/2026-05-04-architecture-review.md (P1.1, DEV-C P2 service-worker) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>Plan B Phase 3 sub-step 2. Replaces the title.map(Ok).unwrap_or_else(|| prompt("Title"))? chain in all seven build_*_item functions with prompt_or_flag, and folds login's or_else(|| prompt_optional(...).ok().flatten()) for username and url into prompt_or_flag_optional. prompt_secret sites and the parse-on-Some-only patterns (expiry, dob, card kind, totp algorithm) stay as-is per spec. Removes the #[allow(dead_code)] attributes from the four helpers in prompt.rs now that callers exist. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.