Skip to content

feat(installer): collapse OP_ITEM+OP_FIELD into one secret-reference prompt#16

Merged
busla merged 2 commits into
mainfrom
feat/single-prompt-secret-reference
May 11, 2026
Merged

feat(installer): collapse OP_ITEM+OP_FIELD into one secret-reference prompt#16
busla merged 2 commits into
mainfrom
feat/single-prompt-secret-reference

Conversation

@busla
Copy link
Copy Markdown
Contributor

@busla busla commented May 11, 2026

Summary

The two-prompt flow (item path → field name) was a synthetic split of what 1Password already gives users as one value. The desktop app has a Copy Secret Reference option (right-click an item) that produces op://Vault/Item/Field directly, wrapped in double quotes for paste-safety.

Replace both prompts with a single one that accepts that exact format, including the surrounding quotes. Split into OP_ITEM (vault/item) and OP_FIELD (everything after) at write time, so the internal storage and runtime contract stay unchanged — claude-env.sh / claudestart.ps1 still append /<project> with /<OP_FIELD> as fallback.

This also obsoletes:

  • list_op_fields / prompt_op_field (bash) and Get-OpFields / Prompt-OpField (PowerShell). Interactive field enumeration was only useful when the user had to type the field name from memory; with Copy Secret Reference there's nothing to enumerate.
  • The migration warning block from fix: PowerShell parser bug + migrate legacy 3-segment OP_ITEM #14. The installer just uses whatever existing local.env produces (legacy 3-segment OP_ITEM, modern split, or team default) as the prompt's bracketed default.

Net -138 lines.

New flow

LiteLLM base URL [https://litellm.ai.apro.is]:
1Password secret reference (Copy Secret Reference in 1Password) [op://Employee/ai.apro.is litellm/API Key]: "op://Employee/Litellm Apro user/API Key"
                                                                                                              ^ pasted with quotes; stripped, validated, split
[OK]    Wrote ~/.config/claude/local.env

local.env ends up with:

OP_ITEM="op://Employee/Litellm Apro user"
OP_FIELD="API Key"

Existing user upgrade paths

local.env state before reinstall New prompt's default
Legacy 3-seg OP_ITEM (e.g. op://V/I/Field), no OP_FIELD op://V/I/Field (use as-is)
Modern split (OP_ITEM + OP_FIELD) ${OP_ITEM}/${OP_FIELD} (joined)
2-seg OP_ITEM only ${OP_ITEM}/API Key
Empty / no prior install op://Employee/ai.apro.is litellm/API Key

In all cases the user can hit enter to keep their existing config, or paste a new secret reference to switch.

Validation

The single prompt rejects:

  • Inputs not starting with op://
  • Fewer than 3 path segments (i.e. missing field)
  • Empty vault or item

A 4-segment op://V/I/Section/Field is accepted; the section/field combo is preserved as OP_FIELD=Section/Field.

Test plan

  • bash -n install.sh
  • Functional parse test of 7 inputs covering quoted/unquoted, 3-seg, 4-seg with section, 2-seg (rejected), trailing slash (rejected), empty middle (rejected), non-op:// (rejected) — all behave correctly
  • Verified no orphan references to the removed list_op_fields / prompt_op_field / Get-OpFields / Prompt-OpField helpers
  • Windows user reruns irm .../install.ps1 | iex and pastes "op://Employee/liteLLM/API key" from 1Password desktop — should accept cleanly
  • macOS user reruns curl .../install.sh | bash — should behave identically

🤖 Generated with Claude Code

busla and others added 2 commits May 11, 2026 11:03
Followup from #14. The migration warning showed the correct split, but
a Windows user typed the legacy 3-segment value back at the prompt
(with quotes the first time), and the installer accepted it. Runtime
defense in claudestart.ps1 silently fixed it at launch, but local.env
on disk was still wrong.

Three input-validation gaps in the prompts:

1. Read-Host / read returned literal quote chars from copy-pasted
   values (e.g. "op://...") so the first attempt failed with the
   misleading "must start with op://". Strip surrounding matched
   quotes inside prompt_default / Prompt-Default.

2. OP_ITEM prompt only checked the op:// prefix. A 3+ segment path
   passed through, undoing the migration that just happened. Now the
   prompt loops with a specific message that shows exactly how to
   split the input across the next two prompts.

3. OP_FIELD prompt accepted anything, including a full op:// URL.
   Reject inputs starting with op:// in both the field-list and
   no-fields paths.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…prompt

The two-prompt flow (item path, then field name) was a synthetic split
of what 1Password already gives users as one value: the desktop app's
"Copy Secret Reference" produces op://Vault/Item/Field directly,
wrapped in double quotes for paste-safety.

Replace both prompts with a single one that accepts that exact format,
then split into OP_ITEM (vault/item) and OP_FIELD (everything after) at
write time. The internal storage and runtime contract stay the same —
local.env still has separate variables, claude-env.sh / claudestart.ps1
still append /<project> with /<OP_FIELD> as fallback. Only the
collection mechanism changes.

Drops list_op_fields/prompt_op_field (bash) and Get-OpFields/Prompt-
OpField (PowerShell), since interactive field enumeration was only
useful when the user had to type the field name from memory. With Copy
Secret Reference, the user pastes vault, item, and field together.

The migration warning block is also removed: the installer just uses
whatever existing local.env produces (legacy 3-segment OP_ITEM, modern
split, or the team default) as the prompt's bracketed default.

Net -138 lines.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@busla busla merged commit d743fbe into main May 11, 2026
@busla busla deleted the feat/single-prompt-secret-reference branch May 11, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant