instar 0.9.48 → 0.9.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,182 @@
1
+ ---
2
+ name: secret-setup
3
+ description: Focused micro-skill for secret management setup. Explains options, guides through Bitwarden installation/login/unlock, configures backend. Exits when done.
4
+ ---
5
+
6
+ # Secret Management Setup
7
+
8
+ You are guiding a user through choosing and configuring how their Instar agent stores secrets (API tokens, bot credentials, etc). This is a **focused conversation** — your ONLY job is to get secret management configured, then exit.
9
+
10
+ ## CRITICAL RULES
11
+
12
+ ### 1. No Interactive CLI Commands — WILL HANG FOREVER
13
+
14
+ **Claude Code's Bash tool CANNOT handle stdin prompts.** Any command that asks for a password, confirmation, or any input will hang until timeout. There is NO workaround — you cannot type into a running command.
15
+
16
+ **UNDERSTAND THIS ABOUT `--raw`:** The `--raw` flag ONLY changes the output format. It does NOT prevent interactive prompts. `bw unlock --raw` STILL prompts for a password and WILL HANG. The password must ALWAYS be passed as a POSITIONAL ARGUMENT before any flags.
17
+
18
+ **Commands that WILL HANG (never run these):**
19
+ ```
20
+ bw unlock --raw # HANGS — no password argument
21
+ bw unlock # HANGS — prompts for password
22
+ bw login --raw # HANGS — no email/password
23
+ bw login # HANGS — prompts for credentials
24
+ echo "text" && bw unlock --raw # HANGS — bw still prompts
25
+ read -s VARIABLE # HANGS — waits for hidden input
26
+ ```
27
+
28
+ **Commands that WORK (use ONLY these patterns):**
29
+ ```
30
+ bw unlock "ACTUAL_PASSWORD_HERE" --raw # Returns session key immediately
31
+ bw login "EMAIL" "PASSWORD" --raw # Returns session key immediately
32
+ bw status --raw # Returns JSON, never prompts
33
+ which bw 2>/dev/null # Checks if installed, never prompts
34
+ bw --version # Returns version, never prompts
35
+ ```
36
+
37
+ **THE RULE:** You MUST have the user's password as text BEFORE running any unlock/login command. Ask the user, get their answer, THEN construct the command with their password as a positional argument.
38
+
39
+ ### 2. No Multi-Choice for Text Input
40
+
41
+ AskUserQuestion multi-choice is for DECISIONS (pick A or B or C).
42
+ NEVER use it to collect free-text input (passwords, emails, tokens).
43
+ When you need text, ask a plain question and wait for the user's response.
44
+
45
+ ### 3. No Assumptions About What's Stored
46
+
47
+ Do NOT assume the user has any specific credentials in Bitwarden. They might have Bitwarden but have never stored anything in it for Instar. Only check what's actually there — never tell the user "I need to restore your Telegram token" unless you've confirmed it exists.
48
+
49
+ ### 4. Terminal Display Rules
50
+ Keep text short. 2-3 sentences max per paragraph. No sentences over ~100 characters.
51
+
52
+ ### 5. No Commands in User-Facing Text
53
+ Never show CLI commands to the user. You run everything. The user's only job is answering your questions.
54
+
55
+ ## The Conversation Flow
56
+
57
+ ### Step 1: Introduce Secret Management
58
+
59
+ Start with a brief, friendly explanation:
60
+
61
+ > Your agent will need to store sensitive things — like API tokens and bot credentials.
62
+ >
63
+ > I'd recommend setting up a password manager so these are backed up securely. That way if you ever reinstall or move to a new machine, everything restores automatically.
64
+
65
+ Then present the choice via AskUserQuestion (this IS a decision — multi-choice is correct here):
66
+
67
+ 1. **"Bitwarden (Recommended)"** — Description: "Free, open-source password manager. Secrets sync across machines and survive reinstalls."
68
+ 2. **"Local encrypted store"** — Description: "AES-256 encrypted on this machine. Good if you only use one computer."
69
+ 3. **"I'll manage secrets manually"** — Description: "You'll paste tokens each time. Not recommended."
70
+
71
+ ### Step 2: Handle the Choice
72
+
73
+ #### If Bitwarden:
74
+
75
+ **Step 2a: Check if `bw` CLI is installed:**
76
+ ```bash
77
+ which bw 2>/dev/null && bw --version 2>/dev/null
78
+ ```
79
+
80
+ **If NOT installed — install it yourself:**
81
+ Tell the user: "Let me install the Bitwarden CLI for you."
82
+ ```bash
83
+ npm install -g @bitwarden/cli
84
+ ```
85
+ If that fails, try `brew install bitwarden-cli` on macOS.
86
+ If installation fails entirely, fall back to local encrypted store and exit.
87
+
88
+ **Step 2b: Check vault status:**
89
+ ```bash
90
+ bw status --raw 2>/dev/null
91
+ ```
92
+ Parse the JSON response. Three possible `status` values:
93
+
94
+ - **`"unlocked"`** — Already good! Skip to Step 2d.
95
+ - **`"locked"`** — Need master password. Go to Step 2c.
96
+ - **`"unauthenticated"`** — Need email + password login. Go to Step 2c.
97
+
98
+ **Step 2c: Get credentials from user and unlock:**
99
+
100
+ If unauthenticated, ask TWO separate questions:
101
+ 1. "What email address do you use for Bitwarden?" (wait for response)
102
+ 2. "What's your Bitwarden master password?" (wait for response)
103
+
104
+ Then run (substituting THEIR ACTUAL ANSWERS):
105
+ ```bash
106
+ BW_SESSION=$(bw login "user@example.com" "their_actual_password" --raw 2>&1)
107
+ echo "RESULT:$BW_SESSION"
108
+ ```
109
+
110
+ If locked (already logged in), ask ONE question:
111
+ 1. "What's your Bitwarden master password?" (wait for response)
112
+
113
+ Then run (substituting THEIR ACTUAL ANSWER):
114
+ ```bash
115
+ BW_SESSION=$(bw unlock "their_actual_password" --raw 2>&1)
116
+ echo "RESULT:$BW_SESSION"
117
+ ```
118
+
119
+ **CHECK THE RESULT:** If `BW_SESSION` is empty or contains "Invalid" or "error":
120
+ > "That didn't work — the password might be wrong. Want to try again?"
121
+
122
+ Allow up to 3 retries. After 3 failures, offer to fall back to local store.
123
+
124
+ **Step 2d: Verify and save session:**
125
+ ```bash
126
+ export BW_SESSION="the_session_key_from_above"
127
+ bw sync --session "$BW_SESSION" 2>/dev/null
128
+ ```
129
+
130
+ Save the session for the main wizard to pick up:
131
+ ```bash
132
+ mkdir -p "$HOME/.instar/secrets"
133
+ echo "$BW_SESSION" > "$HOME/.instar/secrets/.bw-session"
134
+ chmod 600 "$HOME/.instar/secrets/.bw-session"
135
+ ```
136
+
137
+ Tell the user:
138
+ > "Bitwarden is unlocked and ready. Your agent's secrets will be stored securely."
139
+
140
+ **Step 2e: Check for existing Instar secrets (optional, don't assume):**
141
+ ```bash
142
+ bw list items --search "instar" --session "$BW_SESSION" --raw 2>/dev/null
143
+ ```
144
+
145
+ If results are found, tell the user what's available. If nothing is found, that's fine — just move on. Do NOT say "I couldn't find your Telegram credentials" — they might not have any.
146
+
147
+ #### If Local Encrypted Store:
148
+
149
+ No user interaction needed. Tell the user:
150
+ > "Local encrypted store is ready. Your secrets are AES-256 encrypted on this machine."
151
+
152
+ #### If Manual:
153
+
154
+ Tell the user:
155
+ > "Got it. You'll paste tokens when prompted during setup."
156
+
157
+ ### Step 3: Save Backend and Exit
158
+
159
+ Write the backend preference:
160
+ ```bash
161
+ mkdir -p "$HOME/.instar/secrets"
162
+ cat > "$HOME/.instar/secrets/backend.json" << 'JSONEOF'
163
+ {"backend":"CHOSEN_BACKEND","configuredAt":"CURRENT_ISO_DATE"}
164
+ JSONEOF
165
+ ```
166
+
167
+ Verify it was saved:
168
+ ```bash
169
+ cat "$HOME/.instar/secrets/backend.json"
170
+ ```
171
+
172
+ Tell the user this step is done and the main setup will continue automatically.
173
+
174
+ **Then exit.** Do not continue into other setup phases. Your job is done.
175
+
176
+ ## Edge Cases
177
+
178
+ - **"What is Bitwarden?"** — Free, open-source password manager. End-to-end encrypted. Widely trusted. Bitwarden can't read your secrets.
179
+ - **"I use 1Password/LastPass"** — Instar specifically integrates with the Bitwarden CLI. Offer local encrypted store as alternative.
180
+ - **"Skip everything"** — Allow it, but note they'll paste tokens manually each reinstall.
181
+ - **`bw` command times out** — Retry once. If still failing, offer local fallback.
182
+ - **Two-factor auth** — If login returns a 2FA error, ask the user for their authenticator code, then: `bw login "EMAIL" "PASSWORD" --method 0 --code "CODE" --raw`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instar",
3
- "version": "0.9.48",
3
+ "version": "0.9.49",
4
4
  "description": "Persistent autonomy infrastructure for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -51,7 +51,8 @@
51
51
  "dashboard",
52
52
  "upgrades",
53
53
  "src/templates",
54
- ".claude/skills/setup-wizard"
54
+ ".claude/skills/setup-wizard",
55
+ ".claude/skills/secret-setup"
55
56
  ],
56
57
  "license": "MIT",
57
58
  "engines": {