feedbackbasket-cli 0.12.0 → 3.1.0

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.
@@ -1,29 +1,31 @@
1
- import { Command } from 'commander';
2
- import { existsSync } from 'node:fs';
3
- import { join } from 'node:path';
4
- import { homedir } from 'node:os';
5
- import { AuthManager } from '../auth/manager.js';
6
- import { browserLogin, isCliTokenFormat, manualLogin } from '../auth/login.js';
7
- import { saveCredentials } from '../config/credentials.js';
8
- import { loadConfig, saveConfig } from '../config/config.js';
9
- import { FeedbackBasketClient } from '../client.js';
10
- import { errAuth, errUsage } from '../output/errors.js';
11
- import { brand, divider, logo } from '../output/theme.js';
12
- import { select, confirm } from '../prompt.js';
1
+ import { Command } from "commander";
2
+ import { existsSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import { homedir } from "node:os";
5
+ import { AuthManager } from "../auth/manager.js";
6
+ import { browserLogin, isCliTokenFormat, manualLogin } from "../auth/login.js";
7
+ import { saveCredentials } from "../config/credentials.js";
8
+ import { loadConfig, saveConfig } from "../config/config.js";
9
+ import { FeedbackBasketClient } from "../client.js";
10
+ import { errAuth, errUsage } from "../output/errors.js";
11
+ import { brand, divider, logo } from "../output/theme.js";
12
+ import { select, confirm } from "../prompt.js";
13
+ export function authLoginResult(email, scope, defaultProject) {
14
+ return { authenticated: true, email, scope, defaultProject };
15
+ }
13
16
  export function createAuthCommand(getWriter) {
14
- const auth = new Command('auth')
15
- .description('Manage authentication');
17
+ const auth = new Command("auth").description("Manage authentication");
16
18
  // --- auth login ---
17
19
  auth
18
- .command('login')
19
- .description('Authenticate with FeedbackBasket')
20
- .option('--token <token>', 'Use an API token directly (for CI/headless)')
21
- .option('--manual', 'Authenticate without a localhost browser callback')
22
- .option('--scope <scope>', 'Access scope: read or full', 'full')
20
+ .command("login")
21
+ .description("Authenticate with FeedbackBasket")
22
+ .option("--token <token>", "Use an API token directly (for CI/headless)")
23
+ .option("--manual", "Authenticate without a localhost browser callback")
24
+ .option("--scope <scope>", "Maximum browser access: read or full", "full")
23
25
  .action(async (opts) => {
24
26
  const writer = getWriter();
25
27
  const config = loadConfig();
26
- const scope = opts.scope === 'read' ? 'read' : 'full';
28
+ const scope = resolveAuthScope(opts.scope);
27
29
  const isInteractive = !writer.isMachineOutput() && process.stdin.isTTY;
28
30
  // ── Step 1: Authentication ──
29
31
  if (isInteractive) {
@@ -34,19 +36,22 @@ export function createAuthCommand(getWriter) {
34
36
  console.log();
35
37
  }
36
38
  let token;
39
+ let selectedScope = scope;
37
40
  if (opts.token) {
38
41
  token = opts.token;
39
42
  }
40
43
  else if (opts.manual) {
41
44
  const result = await manualLogin(config.baseUrl, scope);
42
45
  token = result.token;
46
+ selectedScope = result.scope;
43
47
  }
44
48
  else {
45
49
  const result = await browserLogin(config.baseUrl, scope);
46
50
  token = result.token;
51
+ selectedScope = result.scope;
47
52
  }
48
53
  if (!isCliTokenFormat(token)) {
49
- throw errUsage('Expected a FeedbackBasket CLI token beginning with fb_cli_', 'MCP API keys begin with fb_key_ and are only for MCP server configuration');
54
+ throw errUsage("Expected a FeedbackBasket CLI token beginning with fb_cli_", "MCP API keys begin with fb_key_ and are only for MCP server configuration");
50
55
  }
51
56
  // Verify token + get profile
52
57
  const client = new FeedbackBasketClient(token, config.baseUrl);
@@ -63,22 +68,22 @@ export function createAuthCommand(getWriter) {
63
68
  if (isInteractive) {
64
69
  const msg = err instanceof Error ? err.message : String(err);
65
70
  console.log(brand.warning(` Could not verify token: ${msg}`));
66
- console.log(brand.muted(' Token saved — run feedbackbasket doctor to diagnose'));
71
+ console.log(brand.muted(" Token saved — run feedbackbasket doctor to diagnose"));
67
72
  console.log();
68
73
  }
69
74
  }
70
75
  saveCredentials({
71
76
  token,
72
- scope,
77
+ scope: selectedScope,
73
78
  userId,
74
79
  email,
75
80
  organizationId,
76
81
  createdAt: new Date().toISOString(),
77
82
  });
78
83
  if (isInteractive) {
79
- console.log(` ${brand.success('')} Authentication successful`);
84
+ console.log(` ${brand.success("")} Authentication successful`);
80
85
  if (email)
81
- console.log(` ${brand.muted('Logged in as')} ${brand.bold(email)}`);
86
+ console.log(` ${brand.muted("Logged in as")} ${brand.bold(email)}`);
82
87
  console.log();
83
88
  }
84
89
  // ── Step 2: Default Project (interactive only, first login) ──
@@ -91,7 +96,7 @@ export function createAuthCommand(getWriter) {
91
96
  const projectsRes = await client.listProjects();
92
97
  const projects = projectsRes.projects;
93
98
  if (projects.length === 0) {
94
- console.log(brand.muted(' No projects found. Create one from the dashboard.'));
99
+ console.log(brand.muted(" No projects found. Create one from the dashboard."));
95
100
  console.log();
96
101
  }
97
102
  else if (projects.length === 1) {
@@ -100,13 +105,13 @@ export function createAuthCommand(getWriter) {
100
105
  config.defaultProject = p.id;
101
106
  saveConfig(config);
102
107
  defaultProjectName = p.name;
103
- console.log(` ${brand.success('')} Default project: ${brand.bold(p.name)}`);
104
- console.log(` ${brand.muted('Only project in your organization')}`);
108
+ console.log(` ${brand.success("")} Default project: ${brand.bold(p.name)}`);
109
+ console.log(` ${brand.muted("Only project in your organization")}`);
105
110
  console.log();
106
111
  }
107
112
  else {
108
113
  console.log(` You have ${brand.bold(String(projects.length))} projects:\n`);
109
- const choice = await select('Select default project', projects.map(p => {
114
+ const choice = await select("Select default project", projects.map((p) => {
110
115
  const count = brand.muted(`(${p.totalFeedback} feedback)`);
111
116
  return `${p.name} ${count}`;
112
117
  }));
@@ -116,12 +121,12 @@ export function createAuthCommand(getWriter) {
116
121
  saveConfig(config);
117
122
  defaultProjectName = p.name;
118
123
  console.log();
119
- console.log(` ${brand.success('')} Default project: ${brand.bold(p.name)}`);
120
- console.log(` ${brand.muted('Use --project to override per-command')}`);
124
+ console.log(` ${brand.success("")} Default project: ${brand.bold(p.name)}`);
125
+ console.log(` ${brand.muted("Use --project to override per-command")}`);
121
126
  }
122
127
  else {
123
128
  console.log();
124
- console.log(` ${brand.muted('Skipped. Use --project or: feedbackbasket config set defaultProject <id>')}`);
129
+ console.log(` ${brand.muted("Skipped. Use --project or: feedbackbasket config set defaultProject <id>")}`);
125
130
  }
126
131
  console.log();
127
132
  }
@@ -129,55 +134,55 @@ export function createAuthCommand(getWriter) {
129
134
  catch (err) {
130
135
  const msg = err instanceof Error ? err.message : String(err);
131
136
  console.log(brand.muted(` Could not fetch projects: ${msg}`));
132
- console.log(brand.muted(' You can set a default later: feedbackbasket config set defaultProject <id>'));
137
+ console.log(brand.muted(" You can set a default later: feedbackbasket config set defaultProject <id>"));
133
138
  console.log();
134
139
  }
135
140
  }
136
141
  // ── Step 3: Agent Setup (interactive only) ──
137
142
  let agentInstalled = false;
138
143
  if (isInteractive) {
139
- const claudeDir = join(homedir(), '.claude');
140
- const skillPath = join(claudeDir, 'skills', 'feedbackbasket', 'SKILL.md');
144
+ const claudeDir = join(homedir(), ".claude");
145
+ const skillPath = join(claudeDir, "skills", "feedbackbasket", "SKILL.md");
141
146
  const claudeExists = existsSync(claudeDir);
142
147
  const skillExists = existsSync(skillPath);
143
148
  if (claudeExists && !skillExists) {
144
149
  console.log();
145
150
  console.log(brand.muted(` Step 3: Agent Setup`));
146
151
  console.log();
147
- console.log(` ${brand.primary('Detected:')} Claude Code`);
152
+ console.log(` ${brand.primary("Detected:")} Claude Code`);
148
153
  console.log();
149
154
  console.log(` This will:`);
150
155
  console.log(` 1. Install FeedbackBasket skill to ~/.claude/skills/`);
151
156
  console.log();
152
- const doSetup = await confirm(' Set up for Claude Code?');
157
+ const doSetup = await confirm(" Set up for Claude Code?");
153
158
  if (doSetup) {
154
159
  try {
155
- const { mkdirSync, copyFileSync } = await import('node:fs');
156
- const { dirname } = await import('node:path');
157
- const { fileURLToPath } = await import('node:url');
160
+ const { mkdirSync, copyFileSync } = await import("node:fs");
161
+ const { dirname } = await import("node:path");
162
+ const { fileURLToPath } = await import("node:url");
158
163
  const thisDir = dirname(fileURLToPath(import.meta.url));
159
- const projectRoot = join(thisDir, '..', '..', '..');
160
- let skillSrc = join(projectRoot, 'skills', 'feedbackbasket', 'SKILL.md');
164
+ const projectRoot = join(thisDir, "..", "..", "..");
165
+ let skillSrc = join(projectRoot, "skills", "feedbackbasket", "SKILL.md");
161
166
  if (!existsSync(skillSrc)) {
162
- skillSrc = join(thisDir, '..', '..', 'skills', 'feedbackbasket', 'SKILL.md');
167
+ skillSrc = join(thisDir, "..", "..", "skills", "feedbackbasket", "SKILL.md");
163
168
  }
164
169
  if (existsSync(skillSrc)) {
165
- const skillDir = join(claudeDir, 'skills', 'feedbackbasket');
170
+ const skillDir = join(claudeDir, "skills", "feedbackbasket");
166
171
  mkdirSync(skillDir, { recursive: true });
167
172
  copyFileSync(skillSrc, skillPath);
168
173
  agentInstalled = true;
169
- console.log(` ${brand.success('')} Agent skill installed`);
174
+ console.log(` ${brand.success("")} Agent skill installed`);
170
175
  }
171
176
  else {
172
- console.log(` ${brand.error('')} SKILL.md not found in package`);
177
+ console.log(` ${brand.error("")} SKILL.md not found in package`);
173
178
  }
174
179
  }
175
180
  catch {
176
- console.log(` ${brand.error('')} Failed to install skill`);
181
+ console.log(` ${brand.error("")} Failed to install skill`);
177
182
  }
178
183
  }
179
184
  else {
180
- console.log(brand.muted(' Skipped. Run later: feedbackbasket setup claude'));
185
+ console.log(brand.muted(" Skipped. Run later: feedbackbasket setup claude"));
181
186
  }
182
187
  console.log();
183
188
  }
@@ -189,78 +194,80 @@ export function createAuthCommand(getWriter) {
189
194
  if (isInteractive) {
190
195
  console.log();
191
196
  console.log(divider(35));
192
- console.log(brand.bold(' Setup complete!'));
197
+ console.log(brand.bold(" Setup complete!"));
193
198
  console.log(divider(35));
194
199
  console.log();
195
- console.log(` ${brand.success('')} Authenticated${email ? ` as ${email}` : ''}`);
200
+ console.log(` ${brand.success("")} Authenticated${email ? ` as ${email}` : ""}`);
196
201
  if (defaultProjectName) {
197
- console.log(` ${brand.success('')} Default project: ${defaultProjectName}`);
202
+ console.log(` ${brand.success("")} Default project: ${defaultProjectName}`);
198
203
  }
199
204
  else if (config.defaultProject) {
200
- console.log(` ${brand.success('')} Default project: ${config.defaultProject}`);
205
+ console.log(` ${brand.success("")} Default project: ${config.defaultProject}`);
201
206
  }
202
207
  else {
203
- console.log(` ${brand.muted('-')} No default project`);
208
+ console.log(` ${brand.muted("-")} No default project`);
204
209
  }
205
210
  if (agentInstalled) {
206
- console.log(` ${brand.success('')} Claude Code skill`);
211
+ console.log(` ${brand.success("")} Claude Code skill`);
207
212
  }
208
213
  console.log();
209
- console.log(' Try these commands:');
214
+ console.log(" Try these commands:");
210
215
  console.log();
211
- console.log(` ${brand.command('feedbackbasket projects list')} List your projects`);
212
- console.log(` ${brand.command('feedbackbasket feedback list')} View recent feedback`);
213
- console.log(` ${brand.command('feedbackbasket bugs list')} View bug reports`);
214
- console.log(` ${brand.command('feedbackbasket doctor')} Run diagnostics`);
216
+ console.log(` ${brand.command("feedbackbasket projects list")} List your projects`);
217
+ console.log(` ${brand.command("feedbackbasket feedback list")} View recent feedback`);
218
+ console.log(` ${brand.command("feedbackbasket bugs list")} View bug reports`);
219
+ console.log(` ${brand.command("feedbackbasket doctor")} Run diagnostics`);
215
220
  console.log();
216
221
  return; // Skip the JSON output in interactive wizard mode
217
222
  }
218
223
  // Machine output
219
- writer.ok({ authenticated: true, email, scope, defaultProject: config.defaultProject }, {
220
- summary: email ? `Logged in as ${email}` : 'Authenticated successfully',
224
+ writer.ok(authLoginResult(email, selectedScope, config.defaultProject), {
225
+ summary: email
226
+ ? `Logged in as ${email}`
227
+ : "Authenticated successfully",
221
228
  breadcrumbs: [
222
- { action: 'List projects', cmd: 'feedbackbasket projects list' },
223
- { action: 'Check status', cmd: 'feedbackbasket auth status' },
224
- { action: 'Run diagnostics', cmd: 'feedbackbasket doctor' },
229
+ { action: "List projects", cmd: "feedbackbasket projects list" },
230
+ { action: "Check status", cmd: "feedbackbasket auth status" },
231
+ { action: "Run diagnostics", cmd: "feedbackbasket doctor" },
225
232
  ],
226
233
  });
227
234
  });
228
235
  // --- auth logout ---
229
236
  auth
230
- .command('logout')
231
- .description('Clear stored credentials')
237
+ .command("logout")
238
+ .description("Clear stored credentials")
232
239
  .action(() => {
233
240
  const writer = getWriter();
234
241
  const manager = new AuthManager();
235
242
  if (!manager.isAuthenticated()) {
236
- writer.ok({ authenticated: false }, { summary: 'Already logged out' });
243
+ writer.ok({ authenticated: false }, { summary: "Already logged out" });
237
244
  return;
238
245
  }
239
- if (manager.getSource() === 'env') {
240
- throw errUsage('Credentials are set via FEEDBACKBASKET_TOKEN environment variable', 'Unset the variable: unset FEEDBACKBASKET_TOKEN');
246
+ if (manager.getSource() === "env") {
247
+ throw errUsage("Credentials are set via FEEDBACKBASKET_TOKEN environment variable", "Unset the variable: unset FEEDBACKBASKET_TOKEN");
241
248
  }
242
249
  manager.logout();
243
250
  if (!writer.isMachineOutput()) {
244
- console.log(` ${brand.success('')} Logged out`);
251
+ console.log(` ${brand.success("")} Logged out`);
245
252
  console.log();
246
253
  }
247
254
  writer.ok({ authenticated: false }, {
248
- summary: 'Logged out',
255
+ summary: "Logged out",
249
256
  breadcrumbs: [
250
- { action: 'Log back in', cmd: 'feedbackbasket auth login' },
257
+ { action: "Log back in", cmd: "feedbackbasket auth login" },
251
258
  ],
252
259
  });
253
260
  });
254
261
  // --- auth status ---
255
262
  auth
256
- .command('status')
257
- .description('Show authentication status')
263
+ .command("status")
264
+ .description("Show authentication status")
258
265
  .action(() => {
259
266
  const writer = getWriter();
260
267
  const manager = new AuthManager();
261
268
  const creds = manager.getCredentials();
262
269
  if (!creds) {
263
- throw errAuth('Not authenticated');
270
+ throw errAuth("Not authenticated");
264
271
  }
265
272
  const config = loadConfig();
266
273
  const data = {
@@ -273,52 +280,57 @@ export function createAuthCommand(getWriter) {
273
280
  defaultProject: config.defaultProject ?? null,
274
281
  };
275
282
  writer.ok(data, {
276
- summary: `Authenticated${creds.email ? ` as ${creds.email}` : ''}`,
283
+ summary: `Authenticated${creds.email ? ` as ${creds.email}` : ""}`,
277
284
  breadcrumbs: [
278
- { action: 'List projects', cmd: 'feedbackbasket projects list' },
279
- { action: 'Log out', cmd: 'feedbackbasket auth logout' },
285
+ { action: "List projects", cmd: "feedbackbasket projects list" },
286
+ { action: "Log out", cmd: "feedbackbasket auth logout" },
280
287
  ],
281
288
  });
282
289
  });
283
290
  // --- auth token ---
284
291
  auth
285
- .command('token')
286
- .description('Print the current access token (for scripting)')
292
+ .command("token")
293
+ .description("Print the current access token (for scripting)")
287
294
  .action(() => {
288
295
  const manager = new AuthManager();
289
296
  const token = manager.resolveToken();
290
297
  if (!token) {
291
- throw errAuth('Not authenticated');
298
+ throw errAuth("Not authenticated");
292
299
  }
293
300
  process.stdout.write(token);
294
301
  });
295
302
  return auth;
296
303
  }
304
+ export function resolveAuthScope(value) {
305
+ if (value === "read" || value === "full")
306
+ return value;
307
+ throw errUsage('Scope must be "read" or "full"');
308
+ }
297
309
  // Top-level aliases: `feedbackbasket login` and `feedbackbasket logout`
298
310
  export function createLoginCommand(getWriter) {
299
- return new Command('login')
300
- .description('Authenticate with FeedbackBasket (alias for auth login)')
301
- .option('--token <token>', 'Use an API token directly (for CI/headless)')
302
- .option('--manual', 'Authenticate without a localhost browser callback')
303
- .option('--scope <scope>', 'Access scope: read or full', 'full')
311
+ return new Command("login")
312
+ .description("Authenticate with FeedbackBasket (alias for auth login)")
313
+ .option("--token <token>", "Use an API token directly (for CI/headless)")
314
+ .option("--manual", "Authenticate without a localhost browser callback")
315
+ .option("--scope <scope>", "Maximum browser access: read or full", "full")
304
316
  .action(async (opts) => {
305
317
  // Delegate to auth login by re-parsing
306
318
  const authCmd = createAuthCommand(getWriter);
307
- const args = ['node', 'feedbackbasket', 'login'];
319
+ const args = ["node", "feedbackbasket", "login"];
308
320
  if (opts.token)
309
- args.push('--token', opts.token);
321
+ args.push("--token", opts.token);
310
322
  if (opts.manual)
311
- args.push('--manual');
323
+ args.push("--manual");
312
324
  if (opts.scope)
313
- args.push('--scope', opts.scope);
325
+ args.push("--scope", opts.scope);
314
326
  await authCmd.parseAsync(args);
315
327
  });
316
328
  }
317
329
  export function createLogoutCommand(getWriter) {
318
- return new Command('logout')
319
- .description('Clear stored credentials (alias for auth logout)')
330
+ return new Command("logout")
331
+ .description("Clear stored credentials (alias for auth logout)")
320
332
  .action(async () => {
321
333
  const authCmd = createAuthCommand(getWriter);
322
- await authCmd.parseAsync(['node', 'feedbackbasket', 'logout']);
334
+ await authCmd.parseAsync(["node", "feedbackbasket", "logout"]);
323
335
  });
324
336
  }
@@ -4,11 +4,13 @@ import { AuthManager } from '../auth/manager.js';
4
4
  import { loadConfig } from '../config/config.js';
5
5
  import { errAuth, errUsage } from '../output/errors.js';
6
6
  import { brand } from '../output/theme.js';
7
+ import { requireHighImpactConfirmation } from '../confirmation.js';
7
8
  export function createFeedbackBulkUpdateCommand(getWriter) {
8
9
  return new Command('bulk-update')
9
10
  .description('Update status for multiple feedback items at once')
10
11
  .requiredOption('--status <status>', 'New status (OPEN, UNDER_REVIEW, PLANNED, IN_PROGRESS, COMPLETE, CLOSED)')
11
12
  .requiredOption('--ids <ids>', 'Comma-separated feedback IDs')
13
+ .option('--yes', 'Confirm the bulk update')
12
14
  .action(async (opts) => {
13
15
  const writer = getWriter();
14
16
  const client = requireClient();
@@ -16,6 +18,7 @@ export function createFeedbackBulkUpdateCommand(getWriter) {
16
18
  if (ids.length === 0) {
17
19
  throw errUsage('At least one ID is required', 'Example: --ids id1,id2,id3');
18
20
  }
21
+ await requireHighImpactConfirmation(writer, Boolean(opts.yes), `Update ${ids.length} feedback item${ids.length === 1 ? '' : 's'}?`, '--yes is required for a bulk update in machine mode.');
19
22
  const result = await client.bulkUpdateStatus(ids, opts.status);
20
23
  if (!writer.isMachineOutput()) {
21
24
  console.log(` ${brand.success('✓')} Updated ${result.updated} feedback items to ${brand.bold(result.status)}`);
@@ -4,7 +4,7 @@ import { AuthManager } from '../auth/manager.js';
4
4
  import { loadConfig } from '../config/config.js';
5
5
  import { errAuth } from '../output/errors.js';
6
6
  import { brand } from '../output/theme.js';
7
- import { confirm } from '../prompt.js';
7
+ import { requireHighImpactConfirmation } from '../confirmation.js';
8
8
  export function createFeedbackDeleteCommand(getWriter) {
9
9
  return new Command('delete')
10
10
  .argument('<id>', 'Feedback ID to delete')
@@ -16,12 +16,8 @@ export function createFeedbackDeleteCommand(getWriter) {
16
16
  if (!opts.yes && !writer.isMachineOutput() && process.stdin.isTTY) {
17
17
  console.log(` ${brand.warning('Warning:')} This will permanently delete feedback ${brand.bold(id)}`);
18
18
  console.log();
19
- const confirmed = await confirm(' Delete this feedback?', false);
20
- if (!confirmed) {
21
- console.log(brand.muted(' Cancelled.'));
22
- return;
23
- }
24
19
  }
20
+ await requireHighImpactConfirmation(writer, Boolean(opts.yes), 'Delete this feedback?', '--yes is required to delete feedback in machine mode.');
25
21
  const result = await client.deleteFeedback(id);
26
22
  if (!writer.isMachineOutput()) {
27
23
  console.log(` ${brand.success('✓')} Deleted feedback ${id}`);
@@ -4,15 +4,19 @@ import { AuthManager } from '../auth/manager.js';
4
4
  import { loadConfig } from '../config/config.js';
5
5
  import { errAuth, errUsage } from '../output/errors.js';
6
6
  import { brand } from '../output/theme.js';
7
+ import { requireHighImpactConfirmation } from '../confirmation.js';
7
8
  export function createFeedbackNoteCommand(getWriter) {
8
- return new Command('note')
9
- .argument('<id>', 'Feedback ID to add a note to')
9
+ const note = new Command('note')
10
+ .argument('[id]', 'Feedback ID to add a note to')
10
11
  .argument('[content]', 'Note content (or use --content)')
11
12
  .description('Add an internal note to a feedback item')
12
13
  .option('--content <text>', 'Note content (alternative to positional argument)')
13
14
  .action(async (id, contentArg, opts) => {
14
15
  const writer = getWriter();
15
16
  const content = contentArg ?? opts.content;
17
+ if (!id) {
18
+ throw errUsage('Feedback ID is required', 'Example: feedbackbasket feedback note <id> "Your note here"');
19
+ }
16
20
  if (!content) {
17
21
  throw errUsage('Note content is required', 'Example: feedbackbasket feedback note <id> "Your note here"');
18
22
  }
@@ -30,6 +34,34 @@ export function createFeedbackNoteCommand(getWriter) {
30
34
  ],
31
35
  });
32
36
  });
37
+ note
38
+ .command('update <feedbackId> <noteId>')
39
+ .description('Update an internal feedback note')
40
+ .requiredOption('--content <text>', 'New note content')
41
+ .action(async (feedbackId, noteId, opts) => {
42
+ const writer = getWriter();
43
+ const client = requireClient();
44
+ const result = await client.updateNote(feedbackId, noteId, opts.content);
45
+ writer.ok(result, {
46
+ summary: `Updated note ${noteId}`,
47
+ breadcrumbs: [{ action: 'View feedback', cmd: `feedbackbasket feedback show ${feedbackId}` }],
48
+ });
49
+ });
50
+ note
51
+ .command('delete <feedbackId> <noteId>')
52
+ .description('Delete an internal feedback note')
53
+ .option('--yes', 'Confirm note deletion')
54
+ .action(async (feedbackId, noteId, opts) => {
55
+ const writer = getWriter();
56
+ const client = requireClient();
57
+ await requireHighImpactConfirmation(writer, Boolean(opts.yes), `Delete note ${noteId}?`, '--yes is required to delete a note in machine mode.');
58
+ const result = await client.deleteNote(feedbackId, noteId);
59
+ writer.ok(result, {
60
+ summary: `Deleted note ${noteId}`,
61
+ breadcrumbs: [{ action: 'View feedback', cmd: `feedbackbasket feedback show ${feedbackId}` }],
62
+ });
63
+ });
64
+ return note;
33
65
  }
34
66
  function requireClient() {
35
67
  const manager = new AuthManager();
@@ -5,6 +5,7 @@ import { loadConfig } from '../config/config.js';
5
5
  import { errAuth, errUsage } from '../output/errors.js';
6
6
  import { brand } from '../output/theme.js';
7
7
  import { ask } from '../prompt.js';
8
+ import { requireHighImpactConfirmation } from '../confirmation.js';
8
9
  const deliveryOptions = new Set(['email', 'widget', 'in-app', 'both']);
9
10
  export function createFeedbackReplyCommand(getWriter) {
10
11
  return new Command('reply')
@@ -14,6 +15,7 @@ export function createFeedbackReplyCommand(getWriter) {
14
15
  .option('--content <text>', 'Reply content (alternative to positional argument)')
15
16
  .option('--delivery <delivery>', 'Reply delivery (email, widget, in-app, both)', 'email')
16
17
  .option('--reply-to <email>', 'Reply-to email for email delivery')
18
+ .option('--yes', 'Confirm that the reply can be sent')
17
19
  .action(async (id, contentArg, opts) => {
18
20
  const writer = getWriter();
19
21
  const content = contentArg ?? opts.content;
@@ -61,6 +63,7 @@ export function createFeedbackReplyCommand(getWriter) {
61
63
  if (sendsWidget && !feedback.hasWidgetAccess) {
62
64
  throw errUsage('This feedback has no in-app or widget reply thread.', 'Use --delivery email for feedback with an email address, or ask the human how they want to respond.');
63
65
  }
66
+ await requireHighImpactConfirmation(writer, Boolean(opts.yes), `Send this reply by ${delivery}?`, '--yes is required to send a reply in machine mode.');
64
67
  const result = await client.sendReply(id, content, {
65
68
  replyToEmail: replyTo,
66
69
  destinations,
@@ -67,6 +67,7 @@ export function createMobileCommand(getWriter) {
67
67
  });
68
68
  mobile
69
69
  .command('bundle-ids [project]')
70
+ .alias('bundle')
70
71
  .description('Add or remove allowed iOS bundle IDs')
71
72
  .option('--add <bundle-id>', 'Bundle ID to add (repeatable)', collect, [])
72
73
  .option('--remove <bundle-id>', 'Bundle ID to remove (repeatable)', collect, [])
@@ -5,6 +5,7 @@ import { loadConfig } from '../config/config.js';
5
5
  import { errAuth, errUsage } from '../output/errors.js';
6
6
  import { brand, divider } from '../output/theme.js';
7
7
  import { confirm } from '../prompt.js';
8
+ import { requireHighImpactConfirmation } from '../confirmation.js';
8
9
  import { resolveProject } from '../resolve.js';
9
10
  export function createProjectsCommand(getWriter) {
10
11
  const projects = new Command('projects')
@@ -139,17 +140,12 @@ export function createProjectsCommand(getWriter) {
139
140
  const resolved = await resolveProject(client, idOrName);
140
141
  const id = resolved.id;
141
142
  const projectName = resolved.name;
142
- // Confirmation (skip in agent mode or --yes)
143
143
  if (!opts.yes && !writer.isMachineOutput() && process.stdin.isTTY) {
144
144
  console.log(` ${brand.warning('Warning:')} This will permanently delete project "${brand.bold(projectName)}"`);
145
145
  console.log(` ${brand.muted('All feedback, notes, and settings will be lost.')}`);
146
146
  console.log();
147
- const confirmed = await confirm(` Delete "${projectName}"?`, false);
148
- if (!confirmed) {
149
- console.log(brand.muted(' Cancelled.'));
150
- return;
151
- }
152
147
  }
148
+ await requireHighImpactConfirmation(writer, Boolean(opts.yes), `Delete "${projectName}"?`, '--yes is required to delete a project in machine mode.');
153
149
  const result = await client.deleteProject(id);
154
150
  if (!writer.isMachineOutput()) {
155
151
  console.log(` ${brand.success('✓')} Deleted project "${brand.bold(result.name)}"`);
@@ -4,7 +4,7 @@ import { AuthManager } from '../auth/manager.js';
4
4
  import { loadConfig } from '../config/config.js';
5
5
  import { errAuth, errUsage } from '../output/errors.js';
6
6
  import { brand, divider } from '../output/theme.js';
7
- import { confirm } from '../prompt.js';
7
+ import { requireHighImpactConfirmation } from '../confirmation.js';
8
8
  export function createTeamCommand(getWriter) {
9
9
  const team = new Command('team')
10
10
  .description('Manage organization members');
@@ -31,12 +31,14 @@ export function createTeamCommand(getWriter) {
31
31
  .command('role <memberId>')
32
32
  .description('Update a member\'s role')
33
33
  .requiredOption('--role <role>', 'New role: admin or member')
34
+ .option('--yes', 'Confirm the role change')
34
35
  .action(async (memberId, opts) => {
35
36
  const writer = getWriter();
36
37
  const client = requireClient();
37
38
  if (!['admin', 'member'].includes(opts.role)) {
38
39
  throw errUsage('Role must be "admin" or "member"');
39
40
  }
41
+ await requireHighImpactConfirmation(writer, Boolean(opts.yes), `Change member ${memberId} to ${opts.role}?`, '--yes is required to change a team role in machine mode.');
40
42
  const result = await client.updateMemberRole(memberId, opts.role);
41
43
  if (!writer.isMachineOutput()) {
42
44
  console.log(` ${brand.success('✓')} Updated ${brand.bold(result.name)} to ${brand.bold(result.role)}`);
@@ -57,13 +59,7 @@ export function createTeamCommand(getWriter) {
57
59
  .action(async (memberId, opts) => {
58
60
  const writer = getWriter();
59
61
  const client = requireClient();
60
- if (!opts.yes && !writer.isMachineOutput() && process.stdin.isTTY) {
61
- const confirmed = await confirm(` Remove member ${memberId}?`, false);
62
- if (!confirmed) {
63
- console.log(brand.muted(' Cancelled.'));
64
- return;
65
- }
66
- }
62
+ await requireHighImpactConfirmation(writer, Boolean(opts.yes), `Remove member ${memberId}?`, '--yes is required to remove a team member in machine mode.');
67
63
  const result = await client.removeMember(memberId);
68
64
  if (!writer.isMachineOutput()) {
69
65
  console.log(` ${brand.success('✓')} Removed ${brand.bold(result.name)} (${result.email})`);
@@ -50,6 +50,7 @@ export function createWidgetCommand(getWriter) {
50
50
  // --- widget settings ---
51
51
  widget
52
52
  .command('settings [project]')
53
+ .alias('update')
53
54
  .description('View or update widget settings')
54
55
  .option('--capture-mode <mode>', 'Capture mode (feedback, waitlist)')
55
56
  .option('--color <hex>', 'Button color (e.g. #22c55e)')
@@ -0,0 +1,2 @@
1
+ import type { OutputWriter } from './output/writer.js';
2
+ export declare function requireHighImpactConfirmation(writer: OutputWriter, confirmedByFlag: boolean, question: string, hint: string): Promise<void>;
@@ -0,0 +1,11 @@
1
+ import { errUsage } from './output/errors.js';
2
+ import { confirm } from './prompt.js';
3
+ export async function requireHighImpactConfirmation(writer, confirmedByFlag, question, hint) {
4
+ if (confirmedByFlag)
5
+ return;
6
+ if (writer.isMachineOutput() || !process.stdin.isTTY) {
7
+ throw errUsage(hint, `${hint} Re-run the command with --yes.`);
8
+ }
9
+ if (!(await confirm(` ${question}`, false)))
10
+ throw errUsage('Action cancelled');
11
+ }