feedbackbasket-cli 3.0.0 → 3.2.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,25 +1,27 @@
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();
@@ -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,57 +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
  }
297
304
  export function resolveAuthScope(value) {
298
- if (value === 'read' || value === 'full')
305
+ if (value === "read" || value === "full")
299
306
  return value;
300
307
  throw errUsage('Scope must be "read" or "full"');
301
308
  }
302
309
  // Top-level aliases: `feedbackbasket login` and `feedbackbasket logout`
303
310
  export function createLoginCommand(getWriter) {
304
- return new Command('login')
305
- .description('Authenticate with FeedbackBasket (alias for auth login)')
306
- .option('--token <token>', 'Use an API token directly (for CI/headless)')
307
- .option('--manual', 'Authenticate without a localhost browser callback')
308
- .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")
309
316
  .action(async (opts) => {
310
317
  // Delegate to auth login by re-parsing
311
318
  const authCmd = createAuthCommand(getWriter);
312
- const args = ['node', 'feedbackbasket', 'login'];
319
+ const args = ["node", "feedbackbasket", "login"];
313
320
  if (opts.token)
314
- args.push('--token', opts.token);
321
+ args.push("--token", opts.token);
315
322
  if (opts.manual)
316
- args.push('--manual');
323
+ args.push("--manual");
317
324
  if (opts.scope)
318
- args.push('--scope', opts.scope);
325
+ args.push("--scope", opts.scope);
319
326
  await authCmd.parseAsync(args);
320
327
  });
321
328
  }
322
329
  export function createLogoutCommand(getWriter) {
323
- return new Command('logout')
324
- .description('Clear stored credentials (alias for auth logout)')
330
+ return new Command("logout")
331
+ .description("Clear stored credentials (alias for auth logout)")
325
332
  .action(async () => {
326
333
  const authCmd = createAuthCommand(getWriter);
327
- await authCmd.parseAsync(['node', 'feedbackbasket', 'logout']);
334
+ await authCmd.parseAsync(["node", "feedbackbasket", "logout"]);
328
335
  });
329
336
  }
@@ -5,30 +5,46 @@ 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 { requireHighImpactConfirmation } from '../confirmation.js';
8
+ const validCloseReasons = new Set(['DUPLICATE', 'NOT_PLANNED', 'COULD_NOT_REPRODUCE', 'NOT_ACTIONABLE', 'NO_LONGER_RELEVANT', 'SPAM', 'OTHER']);
8
9
  export function createFeedbackBulkUpdateCommand(getWriter) {
9
10
  return new Command('bulk-update')
10
11
  .description('Update status for multiple feedback items at once')
11
12
  .requiredOption('--status <status>', 'New status (OPEN, UNDER_REVIEW, PLANNED, IN_PROGRESS, COMPLETE, CLOSED)')
13
+ .option('--close-reason <reason>', 'Reason for closing (DUPLICATE, NOT_PLANNED, COULD_NOT_REPRODUCE, NOT_ACTIONABLE, NO_LONGER_RELEVANT, SPAM, OTHER)')
14
+ .option('--close-note <note>', 'Internal closure note; required when the reason is OTHER')
12
15
  .requiredOption('--ids <ids>', 'Comma-separated feedback IDs')
13
16
  .option('--yes', 'Confirm the bulk update')
14
17
  .action(async (opts) => {
15
18
  const writer = getWriter();
16
19
  const client = requireClient();
17
- const ids = opts.ids.split(',').map((id) => id.trim()).filter(Boolean);
20
+ const ids = opts.ids
21
+ .split(',')
22
+ .map((id) => id.trim())
23
+ .filter(Boolean);
18
24
  if (ids.length === 0) {
19
25
  throw errUsage('At least one ID is required', 'Example: --ids id1,id2,id3');
20
26
  }
27
+ if (opts.status === 'CLOSED' && !opts.closeReason) {
28
+ throw errUsage('--close-reason is required when status is CLOSED');
29
+ }
30
+ if (opts.closeReason && !validCloseReasons.has(opts.closeReason)) {
31
+ throw errUsage('Invalid close reason. Must be one of: DUPLICATE, NOT_PLANNED, COULD_NOT_REPRODUCE, NOT_ACTIONABLE, NO_LONGER_RELEVANT, SPAM, OTHER');
32
+ }
33
+ if (opts.closeReason === 'OTHER' && !opts.closeNote?.trim()) {
34
+ throw errUsage('--close-note is required when --close-reason is OTHER');
35
+ }
21
36
  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.');
22
- const result = await client.bulkUpdateStatus(ids, opts.status);
37
+ const result = await client.bulkUpdateStatus(ids, opts.status, {
38
+ closeReason: opts.closeReason,
39
+ closeNote: opts.closeNote,
40
+ });
23
41
  if (!writer.isMachineOutput()) {
24
42
  console.log(` ${brand.success('✓')} Updated ${result.updated} feedback items to ${brand.bold(result.status)}`);
25
43
  console.log();
26
44
  }
27
45
  writer.ok(result, {
28
46
  summary: `Updated ${result.updated} items to ${result.status}`,
29
- breadcrumbs: [
30
- { action: 'List feedback', cmd: 'feedbackbasket feedback list' },
31
- ],
47
+ breadcrumbs: [{ action: 'List feedback', cmd: 'feedbackbasket feedback list' }],
32
48
  });
33
49
  });
34
50
  }
@@ -8,6 +8,7 @@ import { resolveProject } from '../resolve.js';
8
8
  const validTypes = new Set(['bug', 'feature', 'general']);
9
9
  const validCategories = new Set(['BUG', 'FEATURE_REQUEST', 'IMPROVEMENT', 'QUESTION']);
10
10
  const validStatuses = new Set(['OPEN', 'UNDER_REVIEW', 'PLANNED', 'IN_PROGRESS', 'COMPLETE', 'CLOSED']);
11
+ const validCloseReasons = new Set(['DUPLICATE', 'NOT_PLANNED', 'COULD_NOT_REPRODUCE', 'NOT_ACTIONABLE', 'NO_LONGER_RELEVANT', 'SPAM', 'OTHER']);
11
12
  export function createFeedbackCreateCommand(getWriter) {
12
13
  return new Command('create')
13
14
  .argument('<title>', 'Short title or summary for the feedback')
@@ -17,6 +18,8 @@ export function createFeedbackCreateCommand(getWriter) {
17
18
  .option('--type <type>', 'Feedback type (bug, feature, general)')
18
19
  .option('--category <category>', 'Category (BUG, FEATURE_REQUEST, IMPROVEMENT, QUESTION)')
19
20
  .option('--status <status>', 'Initial status (OPEN, UNDER_REVIEW, PLANNED, IN_PROGRESS, COMPLETE, CLOSED)')
21
+ .option('--close-reason <reason>', 'Reason when the initial status is CLOSED')
22
+ .option('--close-note <note>', 'Internal closure note; required when the reason is OTHER')
20
23
  .option('--email <email>', 'Submitter email')
21
24
  .option('--page-url <url>', 'Page URL where the feedback applies')
22
25
  .option('--metadata <key=value>', 'Metadata key/value pair (repeatable)', collectMetadata, [])
@@ -32,6 +35,15 @@ export function createFeedbackCreateCommand(getWriter) {
32
35
  if (opts.status && !validStatuses.has(opts.status)) {
33
36
  throw errUsage('Invalid status. Must be one of: OPEN, UNDER_REVIEW, PLANNED, IN_PROGRESS, COMPLETE, CLOSED');
34
37
  }
38
+ if (opts.status === 'CLOSED' && !opts.closeReason) {
39
+ throw errUsage('--close-reason is required when status is CLOSED');
40
+ }
41
+ if (opts.closeReason && !validCloseReasons.has(opts.closeReason)) {
42
+ throw errUsage('Invalid close reason. Must be one of: DUPLICATE, NOT_PLANNED, COULD_NOT_REPRODUCE, NOT_ACTIONABLE, NO_LONGER_RELEVANT, SPAM, OTHER');
43
+ }
44
+ if (opts.closeReason === 'OTHER' && !opts.closeNote?.trim()) {
45
+ throw errUsage('--close-note is required when --close-reason is OTHER');
46
+ }
35
47
  const project = await resolveProject(client, opts.project);
36
48
  const content = composeContent(title, opts.content);
37
49
  const metadata = parseMetadata(opts.metadata ?? []);
@@ -41,6 +53,8 @@ export function createFeedbackCreateCommand(getWriter) {
41
53
  type: opts.type,
42
54
  category: opts.category,
43
55
  status: opts.status,
56
+ closeReason: opts.closeReason,
57
+ closeNote: opts.closeNote,
44
58
  email: opts.email,
45
59
  pageUrl: opts.pageUrl,
46
60
  metadata,
@@ -54,9 +68,18 @@ export function createFeedbackCreateCommand(getWriter) {
54
68
  writer.ok(result, {
55
69
  summary: `Created feedback ${result.id}`,
56
70
  breadcrumbs: [
57
- { action: 'View feedback', cmd: `feedbackbasket feedback show ${result.id}` },
58
- { action: 'Update status', cmd: `feedbackbasket feedback update ${result.id} --status UNDER_REVIEW` },
59
- { action: 'List project feedback', cmd: `feedbackbasket feedback list --project ${project.id}` },
71
+ {
72
+ action: 'View feedback',
73
+ cmd: `feedbackbasket feedback show ${result.id}`,
74
+ },
75
+ {
76
+ action: 'Update status',
77
+ cmd: `feedbackbasket feedback update ${result.id} --status UNDER_REVIEW`,
78
+ },
79
+ {
80
+ action: 'List project feedback',
81
+ cmd: `feedbackbasket feedback list --project ${project.id}`,
82
+ },
60
83
  ],
61
84
  });
62
85
  });
@@ -4,11 +4,14 @@ 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
+ const validCloseReasons = new Set(['DUPLICATE', 'NOT_PLANNED', 'COULD_NOT_REPRODUCE', 'NOT_ACTIONABLE', 'NO_LONGER_RELEVANT', 'SPAM', 'OTHER']);
7
8
  export function createFeedbackUpdateCommand(getWriter) {
8
9
  return new Command('update')
9
10
  .argument('<id>', 'Feedback ID to update')
10
11
  .description('Update a feedback item')
11
12
  .option('--status <status>', 'Set status (OPEN, UNDER_REVIEW, PLANNED, IN_PROGRESS, COMPLETE, CLOSED)')
13
+ .option('--close-reason <reason>', 'Reason for closing (DUPLICATE, NOT_PLANNED, COULD_NOT_REPRODUCE, NOT_ACTIONABLE, NO_LONGER_RELEVANT, SPAM, OTHER)')
14
+ .option('--close-note <note>', 'Internal closure note; required when the reason is OTHER')
12
15
  .option('--category <category>', 'Set category (BUG, FEATURE_REQUEST, IMPROVEMENT, QUESTION)')
13
16
  .option('--sentiment <sentiment>', 'Set sentiment (POSITIVE, NEGATIVE, NEUTRAL)')
14
17
  .action(async (id, opts) => {
@@ -16,6 +19,15 @@ export function createFeedbackUpdateCommand(getWriter) {
16
19
  if (!opts.status && !opts.category && !opts.sentiment) {
17
20
  throw errUsage('At least one of --status, --category, or --sentiment is required', 'Example: feedbackbasket feedback update <id> --status PLANNED');
18
21
  }
22
+ if (opts.status === 'CLOSED' && !opts.closeReason) {
23
+ throw errUsage('--close-reason is required when status is CLOSED');
24
+ }
25
+ if (opts.closeReason && !validCloseReasons.has(opts.closeReason)) {
26
+ throw errUsage('Invalid close reason. Must be one of: DUPLICATE, NOT_PLANNED, COULD_NOT_REPRODUCE, NOT_ACTIONABLE, NO_LONGER_RELEVANT, SPAM, OTHER');
27
+ }
28
+ if (opts.closeReason === 'OTHER' && !opts.closeNote?.trim()) {
29
+ throw errUsage('--close-note is required when --close-reason is OTHER');
30
+ }
19
31
  const client = requireClient();
20
32
  const data = {};
21
33
  if (opts.status)
@@ -24,6 +36,10 @@ export function createFeedbackUpdateCommand(getWriter) {
24
36
  data['category'] = opts.category;
25
37
  if (opts.sentiment)
26
38
  data['sentiment'] = opts.sentiment;
39
+ if (opts.closeReason)
40
+ data['closeReason'] = opts.closeReason;
41
+ if (opts.closeNote)
42
+ data['closeNote'] = opts.closeNote;
27
43
  const updated = await client.updateFeedback(id, data);
28
44
  if (!writer.isMachineOutput()) {
29
45
  console.log(brand.success(`Updated feedback ${id}`));
@@ -33,12 +49,20 @@ export function createFeedbackUpdateCommand(getWriter) {
33
49
  console.log(` Category: ${opts.category}`);
34
50
  if (opts.sentiment)
35
51
  console.log(` Sentiment: ${opts.sentiment}`);
52
+ if (opts.closeReason)
53
+ console.log(` Reason: ${opts.closeReason}`);
36
54
  }
37
55
  writer.ok(updated, {
38
56
  summary: `Updated feedback ${id}`,
39
57
  breadcrumbs: [
40
- { action: 'View updated item', cmd: `feedbackbasket feedback show ${id}` },
41
- { action: 'Add a note', cmd: `feedbackbasket feedback note ${id} "<note>"` },
58
+ {
59
+ action: 'View updated item',
60
+ cmd: `feedbackbasket feedback show ${id}`,
61
+ },
62
+ {
63
+ action: 'Add a note',
64
+ cmd: `feedbackbasket feedback note ${id} "<note>"`,
65
+ },
42
66
  { action: 'Back to list', cmd: 'feedbackbasket feedback list' },
43
67
  ],
44
68
  });