exponential-cli 1.13.0 → 1.16.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.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/commands/auth.ts","../src/config/index.ts","../src/client/index.ts","../src/utils/errors.ts","../src/commands/actions.ts","../src/utils/output.ts","../src/commands/contacts.ts","../src/commands/deals.ts","../src/commands/epics.ts","../src/utils/resolve.ts","../src/commands/features.ts","../src/commands/stories.ts","../src/commands/scopes.ts","../src/commands/requirements.ts","../src/commands/areas.ts","../src/commands/featureComments.ts","../src/utils/mentions.ts","../src/commands/labels.ts","../src/commands/meetings.ts","../src/utils/input.ts","../src/commands/organizations.ts","../src/commands/pages.ts","../src/commands/pageComments.ts","../src/commands/products.ts","../src/commands/projects.ts","../src/commands/search.ts","../src/commands/tickets.ts","../src/commands/workspaces.ts","../src/commands/goals.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from 'commander';\nimport { createAuthCommand } from './commands/auth.js';\nimport { createActionsCommand } from './commands/actions.js';\nimport { createContactsCommand } from './commands/contacts.js';\nimport { createDealsCommand } from './commands/deals.js';\nimport { createEpicsCommand } from './commands/epics.js';\nimport { createFeaturesCommand } from './commands/features.js';\nimport { createLabelsCommand } from './commands/labels.js';\nimport { createMeetingsCommand } from './commands/meetings.js';\nimport { createOrganizationsCommand } from './commands/organizations.js';\nimport { createPagesCommand } from './commands/pages.js';\nimport { createProductsCommand } from './commands/products.js';\nimport { createProjectsCommand } from './commands/projects.js';\nimport { createSearchCommand } from './commands/search.js';\nimport { createTicketsCommand } from './commands/tickets.js';\nimport { createWorkspacesCommand } from './commands/workspaces.js';\nimport { createGoalsCommand, createOkrsCommand } from './commands/goals.js';\nimport { readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n// Read the real version rather than a hand-maintained literal, which drifted\n// far enough that `--version` reported 1.0.0 while 1.9.0 was on npm.\nconst PKG_VERSION: string = JSON.parse(\n readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json'), 'utf-8'),\n).version;\n\nconst program = new Command();\n\nprogram\n .name('exponential')\n .description(\n [\n 'CLI to interact with Exponential productivity app.',\n '',\n 'Work-tracking hierarchy:',\n ' workspace -> product -> feature -> ticket -> action',\n ' epics are workspace-scoped and can group tickets and actions across products.',\n ].join('\\n'),\n )\n .version(PKG_VERSION)\n .option('--json', 'Output as JSON (default when piped)')\n .option('--pretty', 'Force pretty-printed output');\n\n// Add subcommands\nprogram.addCommand(createAuthCommand());\nprogram.addCommand(createActionsCommand());\nprogram.addCommand(createContactsCommand());\nprogram.addCommand(createDealsCommand());\nprogram.addCommand(createEpicsCommand());\nprogram.addCommand(createFeaturesCommand());\nprogram.addCommand(createLabelsCommand());\nprogram.addCommand(createMeetingsCommand());\nprogram.addCommand(createOrganizationsCommand());\nprogram.addCommand(createPagesCommand());\nprogram.addCommand(createProductsCommand());\nprogram.addCommand(createProjectsCommand());\nprogram.addCommand(createSearchCommand());\nprogram.addCommand(createTicketsCommand());\nprogram.addCommand(createWorkspacesCommand());\nprogram.addCommand(createGoalsCommand());\nprogram.addCommand(createOkrsCommand());\n\nprogram.parse();\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { getConfig, setConfig, clearConfig, isAuthenticated, getConfigPath } from '../config/index.js';\nimport { getClient, resetClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\n\nexport function createAuthCommand(): Command {\n const auth = new Command('auth')\n .description('Authentication commands');\n\n auth\n .command('login')\n .description('Configure CLI with your API token')\n .requiredOption('--token <token>', 'JWT token from /tokens page')\n .requiredOption('--api-url <url>', 'API URL (e.g., https://app.exponential.so)')\n .action(async (options: { token: string; apiUrl: string }) => {\n try {\n // Normalize API URL (remove trailing slash)\n let apiUrl = options.apiUrl.replace(/\\/+$/, '');\n\n // Ensure HTTPS for non-localhost\n if (!apiUrl.startsWith('http://localhost') && !apiUrl.startsWith('https://')) {\n apiUrl = `https://${apiUrl}`;\n }\n\n // Store the config\n setConfig({\n token: options.token,\n apiUrl: apiUrl,\n });\n\n // Reset client to use new config\n resetClient();\n\n // Validate by trying to list workspaces\n console.log(chalk.gray('Validating token...'));\n const client = getClient();\n await client.workspaces.list();\n\n console.log(chalk.green('Successfully authenticated!'));\n console.log(chalk.gray(`Config saved to: ${getConfigPath()}`));\n } catch (error) {\n // Clear invalid config\n clearConfig();\n handleError(error);\n }\n });\n\n auth\n .command('logout')\n .description('Remove stored credentials')\n .action(() => {\n clearConfig();\n resetClient();\n console.log(chalk.green('Successfully logged out.'));\n console.log(chalk.gray(`Config cleared from: ${getConfigPath()}`));\n });\n\n auth\n .command('whoami')\n .description('Show current authentication status')\n .action(async () => {\n if (!isAuthenticated()) {\n console.log(chalk.yellow('Not authenticated.'));\n console.log(chalk.gray('Run: exponential auth login --token <jwt> --api-url <url>'));\n process.exit(1);\n }\n\n try {\n const config = getConfig();\n const client = getClient();\n\n // Validate token by listing workspaces\n const workspaces = await client.workspaces.list();\n\n console.log(chalk.green('Authenticated'));\n console.log(chalk.gray(`API URL: ${config.apiUrl}`));\n console.log(chalk.gray(`Workspaces: ${(workspaces as unknown[]).length}`));\n console.log(chalk.gray(`Config: ${getConfigPath()}`));\n } catch (error) {\n handleError(error);\n }\n });\n\n auth\n .command('show')\n .description(\n 'Print parts of the current credentials. Use --token to print the raw JWT (for piping into other tools, e.g. `gh secret set EXPONENTIAL_TOKEN < <(exponential auth show --token)`).',\n )\n .option('--token', 'Print the raw JWT to stdout with no trailing newline')\n .action((options: { token?: boolean }) => {\n const config = getConfig();\n if (options.token) {\n if (!config.token) {\n console.error('Not authenticated. Run `exponential auth login` first.');\n process.exit(1);\n }\n process.stdout.write(config.token);\n return;\n }\n console.log(chalk.bold('\\nCredentials'));\n console.log(chalk.gray('─'.repeat(40)));\n console.log(`API URL: ${config.apiUrl || chalk.gray('(not set)')}`);\n console.log(\n `Token: ${config.token ? chalk.gray(`${config.token.substring(0, 20)}...`) : chalk.gray('(not set)')}`,\n );\n console.log(\n chalk.gray('Use `exponential auth show --token` to print the raw JWT.'),\n );\n console.log();\n });\n\n auth\n .command('status')\n .description('Show detailed authentication status')\n .action(() => {\n const config = getConfig();\n\n console.log(chalk.bold('\\nAuthentication Status'));\n console.log(chalk.gray('─'.repeat(40)));\n console.log(`Authenticated: ${isAuthenticated() ? chalk.green('Yes') : chalk.red('No')}`);\n console.log(`API URL: ${config.apiUrl || chalk.gray('(not set)')}`);\n console.log(`Token: ${config.token ? chalk.gray(`${config.token.substring(0, 20)}...`) : chalk.gray('(not set)')}`);\n console.log(`Config Path: ${getConfigPath()}`);\n console.log();\n });\n\n return auth;\n}\n","import { createConfigStore } from 'exponential-sdk';\nimport type { ExponentialConfig } from 'exponential-sdk';\n\nconst configStore = createConfigStore({ projectName: 'exponential-cli' });\n\nexport type { ExponentialConfig };\n\nexport function getConfig(): ExponentialConfig {\n return configStore.loadConfig();\n}\n\nexport function setConfig(values: Partial<ExponentialConfig>): void {\n configStore.saveConfig(values);\n}\n\nexport function clearConfig(): void {\n configStore.clearConfig();\n}\n\nexport function isAuthenticated(): boolean {\n return configStore.isAuthenticated();\n}\n\nexport function getConfigPath(): string {\n return configStore.getConfigPath();\n}\n","import { ExponentialClient } from 'exponential-sdk';\nimport { getConfig, isAuthenticated } from '../config/index.js';\n\nlet clientInstance: ExponentialClient | null = null;\n\nexport function getClient() {\n if (!isAuthenticated()) {\n throw new Error('Not authenticated. Run: exponential auth login --token <your-jwt> --api-url <url>');\n }\n\n if (clientInstance) {\n return clientInstance;\n }\n\n const config = getConfig();\n clientInstance = new ExponentialClient({\n token: config.token,\n apiUrl: config.apiUrl,\n });\n\n return clientInstance;\n}\n\nexport function resetClient() {\n clientInstance = null;\n}\n\nexport { isTRPCError, TRPCClientError } from 'exponential-sdk';\n","import chalk from 'chalk';\nimport { isTRPCError } from '../client/index.js';\n\nexport class ExponentialError extends Error {\n constructor(\n message: string,\n public code: string,\n public suggestion?: string,\n public details?: unknown\n ) {\n super(message);\n this.name = 'ExponentialError';\n }\n}\n\nexport function handleError(error: unknown, json: boolean = false): never {\n if (error instanceof ExponentialError) {\n if (json) {\n console.log(JSON.stringify({\n error: {\n code: error.code,\n message: error.message,\n suggestion: error.suggestion,\n },\n }, null, 2));\n } else {\n console.error(chalk.red(`Error: ${error.message}`));\n if (error.suggestion) {\n console.error(chalk.yellow(`Suggestion: ${error.suggestion}`));\n }\n }\n process.exit(1);\n }\n\n if (isTRPCError(error)) {\n const code = error.data?.code ?? 'UNKNOWN';\n let message = error.message;\n let suggestion: string | undefined;\n\n switch (code) {\n case 'UNAUTHORIZED':\n message = 'Authentication failed. Your token may have expired.';\n suggestion = 'Run: exponential auth login --token <new-token> --api-url <url>';\n break;\n case 'NOT_FOUND':\n message = 'Resource not found';\n break;\n case 'FORBIDDEN':\n message = 'Access denied';\n break;\n }\n\n if (json) {\n console.log(JSON.stringify({\n error: {\n code,\n message,\n suggestion,\n },\n }, null, 2));\n } else {\n console.error(chalk.red(`Error [${code}]: ${message}`));\n if (suggestion) {\n console.error(chalk.yellow(`Suggestion: ${suggestion}`));\n }\n }\n process.exit(1);\n }\n\n // Generic error handling\n if (json) {\n console.log(JSON.stringify({\n error: {\n code: 'UNKNOWN',\n message: error instanceof Error ? error.message : String(error),\n },\n }, null, 2));\n } else {\n console.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));\n }\n process.exit(1);\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport {\n shouldUseJson,\n outputActionsJson,\n outputActionsPretty,\n outputActionJson,\n outputActionPretty,\n outputCommentJson,\n outputCommentPretty,\n outputCommentsJson,\n outputCommentsPretty,\n outputTodaysActionsJson,\n outputTodaysActionsPretty,\n outputOverdueTriageJson,\n outputOverdueTriagePretty,\n} from '../utils/output.js';\nimport type { Action, KanbanStatus, Priority } from 'exponential-sdk';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n workspace?: string;\n}\n\nconst VALID_PRIORITIES: Priority[] = [\n 'Quick',\n 'Scheduled',\n '1st Priority',\n '2nd Priority',\n '3rd Priority',\n '4th Priority',\n '5th Priority',\n 'Errand',\n 'Remember',\n 'Watch',\n 'Someday Maybe',\n];\n\n/** `undefined` = leave alone, `null` = clear, otherwise the parsed date. */\nfunction parseNullableDate(raw: string | undefined, flag: string): Date | null | undefined {\n if (raw === undefined) return undefined;\n if (raw === 'null') return null;\n const parsed = new Date(raw);\n if (isNaN(parsed.getTime())) {\n throw new Error(`Invalid --${flag} value \"${raw}\". Use YYYY-MM-DD, an ISO datetime, or \"null\".`);\n }\n return parsed;\n}\n\nfunction parseIds(raw: string): string[] {\n const ids = raw.split(',').map((s) => s.trim()).filter(Boolean);\n if (ids.length === 0) {\n throw new Error('No action IDs supplied. Pass --ids id1,id2');\n }\n return ids;\n}\n\nexport function createActionsCommand(): Command {\n const actions = new Command('actions')\n .description('Manage actions/tasks');\n\n actions\n .command('list')\n .description('List all actions')\n .option('--project <id>', 'Filter by project ID')\n .option('--status <status>', 'Filter by kanban status (BACKLOG, TODO, IN_PROGRESS, IN_REVIEW, DONE)')\n .option('--assignee <id>', 'Filter by assignee ID')\n .action(async (options: { project?: string; status?: string; assignee?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const kanbanStatus = options.status as KanbanStatus | undefined;\n\n const actions = await client.actions.list({\n projectId: options.project,\n status: kanbanStatus,\n assigneeId: options.assignee,\n });\n\n if (useJson) {\n outputActionsJson(actions, {\n projectId: options.project,\n kanbanStatus: options.status,\n });\n } else {\n outputActionsPretty(actions);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions\n .command('today')\n .description(\"What's on your plate: overdue, today, and inbox\")\n .option('--workspace <id>', 'Filter by workspace ID')\n .option('--due-only', 'Only actions whose dueDate is today (the pre-1.8 shape — excludes overdue)')\n .action(async (options: { workspace?: string; dueOnly?: boolean }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n\n if (options.dueOnly) {\n const actions = await client.actions.getToday(options.workspace);\n if (useJson) {\n outputActionsJson(actions, { workspaceId: options.workspace });\n } else {\n outputActionsPretty(actions);\n }\n return;\n }\n\n const todays = await client.actions.getTodaysActions(options.workspace);\n if (useJson) {\n outputTodaysActionsJson(todays, { workspaceId: options.workspace });\n } else {\n outputTodaysActionsPretty(todays);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions\n .command('overdue')\n .description('Why the overdue pile is that size: bulk-created cohorts vs real debt')\n .option('--workspace <id>', 'Filter by workspace ID')\n .action(async (options: { workspace?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const triage = await client.actions.getOverdueTriage(options.workspace);\n\n if (useJson) {\n outputOverdueTriageJson(triage);\n } else {\n outputOverdueTriagePretty(triage);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions\n .command('defer')\n .description('Amnesty: clear dates so actions fall back to their project backlog untimed')\n .requiredOption('--ids <ids>', 'Comma-separated action IDs')\n .action(async (options: { ids: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const ids = parseIds(options.ids);\n const client = getClient();\n const result = await client.actions.bulkDefer(ids);\n\n if (useJson) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n console.log(`✓ ${result.message}`);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions\n .command('reschedule')\n .description('Move actions to a new do-date (use \"actions defer\" if they were never really due)')\n .requiredOption('--ids <ids>', 'Comma-separated action IDs')\n .requiredOption('--to <date>', 'New do-date (YYYY-MM-DD, or \"today\")')\n .action(async (options: { ids: string; to: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const ids = parseIds(options.ids);\n const when = options.to === 'today' ? new Date() : new Date(options.to);\n if (isNaN(when.getTime())) {\n throw new Error('Invalid date format. Use YYYY-MM-DD or \"today\"');\n }\n\n const client = getClient();\n const result = await client.actions.bulkReschedule(ids, when);\n\n if (useJson) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n console.log(`✓ Rescheduled ${result.count} action${result.count === 1 ? '' : 's'}`);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions\n .command('range')\n .description('Get actions by date range')\n .requiredOption('--start <date>', 'Start date (YYYY-MM-DD)')\n .requiredOption('--end <date>', 'End date (YYYY-MM-DD)')\n .option('--workspace <id>', 'Filter by workspace ID')\n .action(async (options: { start: string; end: string; workspace?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const startDate = new Date(options.start);\n const endDate = new Date(options.end);\n\n if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {\n throw new Error('Invalid date format. Use YYYY-MM-DD');\n }\n\n const client = getClient();\n const actions = await client.actions.getByDateRange(startDate, endDate, options.workspace);\n\n if (useJson) {\n outputActionsJson(actions, { workspaceId: options.workspace });\n } else {\n outputActionsPretty(actions);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions\n .command('kanban')\n .description('Get kanban board actions')\n .option('--project <id>', 'Filter by project ID')\n .option('--status <status>', 'Filter by kanban status')\n .option('--assignee <id>', 'Filter by assignee ID')\n .action(async (options: { project?: string; status?: string; assignee?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const kanbanStatus = options.status as KanbanStatus | undefined;\n\n const actions = await client.actions.getKanban({\n projectId: options.project,\n status: kanbanStatus,\n assigneeId: options.assignee,\n });\n\n if (useJson) {\n outputActionsJson(actions, {\n projectId: options.project,\n kanbanStatus: options.status,\n });\n } else {\n outputActionsPretty(actions);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions\n .command('update')\n .description('Update an existing action')\n .requiredOption('--id <id>', 'Action ID to update')\n .option('-n, --name <name>', 'New action name')\n .option('-d, --description <text>', 'New description')\n .option('-p, --project <id>', 'Move to project ID')\n .option('--priority <priority>', 'Priority (Quick, Scheduled, 1st Priority, etc.)')\n .option('--status <status>', 'Status (ACTIVE, COMPLETED, CANCELLED)')\n .option('--kanban <status>', 'Kanban status (BACKLOG, TODO, IN_PROGRESS, IN_REVIEW, DONE)')\n .option('--due <date>', 'Due date (YYYY-MM-DD or \"null\" to clear)')\n .option('--scheduled-start <datetime>', 'Do-date: when you plan to work on it (YYYY-MM-DD, ISO datetime, or \"null\" to clear). This is what /today partitions on.')\n .option('--scheduled-end <datetime>', 'End of the time block (YYYY-MM-DD, ISO datetime, or \"null\" to clear)')\n .action(async (options: {\n id: string;\n name?: string;\n description?: string;\n project?: string;\n priority?: string;\n status?: string;\n kanban?: string;\n due?: string;\n scheduledStart?: string;\n scheduledEnd?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n // Validate priority if provided\n if (options.priority && !VALID_PRIORITIES.includes(options.priority as Priority)) {\n throw new Error(`Invalid priority \"${options.priority}\". Valid values: ${VALID_PRIORITIES.join(', ')}`);\n }\n\n // Parse due date if provided\n let dueDate: Date | null | undefined;\n if (options.due === 'null') {\n dueDate = null;\n } else if (options.due) {\n dueDate = new Date(options.due);\n if (isNaN(dueDate.getTime())) {\n throw new Error('Invalid due date format. Use YYYY-MM-DD');\n }\n }\n\n const scheduledStart = parseNullableDate(options.scheduledStart, 'scheduled-start');\n const scheduledEnd = parseNullableDate(options.scheduledEnd, 'scheduled-end');\n\n const client = getClient();\n const action = await client.actions.update({\n id: options.id,\n name: options.name,\n description: options.description,\n projectId: options.project,\n priority: options.priority as Priority | undefined,\n status: options.status as 'ACTIVE' | 'COMPLETED' | 'CANCELLED' | undefined,\n kanbanStatus: options.kanban as 'BACKLOG' | 'TODO' | 'IN_PROGRESS' | 'IN_REVIEW' | 'DONE' | 'CANCELLED' | undefined,\n dueDate,\n scheduledStart,\n scheduledEnd,\n });\n\n if (useJson) {\n outputActionJson(action);\n } else {\n console.log('\\n✓ Action updated successfully');\n outputActionPretty(action);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions\n .command('create')\n .description('Create a new action')\n .requiredOption('-n, --name <name>', 'Action name/title')\n .option('-d, --description <text>', 'Action description')\n .option('-p, --project <id>', 'Project ID to assign the action to')\n .option('--priority <priority>', 'Priority (Quick, Scheduled, 1st Priority, etc.)')\n .option('--due <date>', 'Due date (YYYY-MM-DD)')\n .option('--effort <minutes>', 'Effort estimate in minutes', parseInt)\n .option('--ticket <id>', 'Link action to a product ticket (CUID) after creation')\n .option('--epic <id>', 'Epic CUID to attach the action to')\n .action(async (options: {\n name: string;\n description?: string;\n project?: string;\n priority?: string;\n due?: string;\n effort?: number;\n ticket?: string;\n epic?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n // Validate priority if provided\n if (options.priority && !VALID_PRIORITIES.includes(options.priority as Priority)) {\n throw new Error(`Invalid priority \"${options.priority}\". Valid values: ${VALID_PRIORITIES.join(', ')}`);\n }\n\n // Parse due date if provided\n let dueDate: Date | undefined;\n if (options.due) {\n dueDate = new Date(options.due);\n if (isNaN(dueDate.getTime())) {\n throw new Error('Invalid due date format. Use YYYY-MM-DD');\n }\n }\n\n const client = getClient();\n let action = await client.actions.create({\n name: options.name,\n description: options.description,\n projectId: options.project,\n priority: options.priority as Priority | undefined,\n dueDate,\n effortEstimate: options.effort,\n epicId: options.epic,\n });\n\n // The server's action.create router doesn't accept ticketId, so when\n // --ticket is requested we link via the product.ticket.linkAction RPC\n // and re-use its updated return value.\n if (options.ticket) {\n action = await client.tickets.linkAction(options.ticket, action.id);\n }\n\n if (useJson) {\n outputActionJson(action);\n } else {\n console.log('\\n✓ Action created successfully');\n outputActionPretty(action);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n const comment = new Command('comment')\n .description('Manage comments on an action');\n\n comment\n .command('list')\n .description('List comments on an action')\n .requiredOption('--id <id>', 'Action ID')\n .action(async (options: { id: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const comments = await client.actionComments.list(options.id);\n if (useJson) outputCommentsJson(comments);\n else outputCommentsPretty(comments);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('add')\n .description('Add a comment to an action')\n .requiredOption('--id <id>', 'Action ID')\n .requiredOption('-m, --message <text>', 'Comment content (markdown supported)')\n .action(async (options: { id: string; message: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const created = await client.actionComments.add({\n actionId: options.id,\n content: options.message,\n });\n if (useJson) {\n outputCommentJson(created);\n } else {\n console.log('\\n✓ Comment added');\n outputCommentPretty(created);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('update')\n .description(\"Update one of your own comments\")\n .requiredOption('--comment-id <id>', 'Comment ID')\n .requiredOption('-m, --message <text>', 'New comment content')\n .action(async (options: { commentId: string; message: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const updated = await client.actionComments.update({\n commentId: options.commentId,\n content: options.message,\n });\n if (useJson) {\n outputCommentJson(updated);\n } else {\n console.log('\\n✓ Comment updated');\n outputCommentPretty(updated);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('delete')\n .description(\"Delete one of your own comments\")\n .requiredOption('--comment-id <id>', 'Comment ID')\n .action(async (options: { commentId: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.actionComments.delete(options.commentId);\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id: options.commentId }, null, 2));\n } else {\n console.log('\\n✓ Comment deleted');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions.addCommand(comment);\n\n return actions;\n}\n","import chalk from 'chalk';\nimport type {\n Action,\n ActionComment,\n ActionOutput,\n ActionsListOutput,\n Contact,\n ContactInteraction,\n Deal,\n Epic,\n Feature,\n FeatureKeyResultLink,\n FeatureScope,\n Goal,\n GoalPeriod,\n GoalStats,\n GoalTreeNode,\n KeyResult,\n KeyResultCheckIn,\n KnowledgePage,\n Meeting,\n ObjectiveWithKeyResults,\n Organization,\n OverdueTriage,\n Pipeline,\n PipelineStage,\n Product,\n Project,\n ProjectDetail,\n ProjectOutput,\n ProjectsListOutput,\n Requirement,\n Ticket,\n TodaysActions,\n TicketComment,\n GoalComment,\n FeatureComment,\n PageComment,\n TicketDetail,\n UserStory,\n Workspace,\n WorkspaceOutput,\n WorkspacesListOutput,\n} from 'exponential-sdk';\n\n// Detect if output is being piped\nexport function shouldUseJson(forceJson?: boolean, forcePretty?: boolean): boolean {\n if (forceJson) return true;\n if (forcePretty) return false;\n return !process.stdout.isTTY;\n}\n\n// Transform Action to ActionOutput (serialize dates)\nexport function transformAction(action: Action): ActionOutput {\n return {\n id: action.id,\n name: action.name,\n description: action.description,\n status: action.status,\n priority: action.priority,\n kanbanStatus: action.kanbanStatus,\n dueDate: action.dueDate?.toISOString() ?? null,\n scheduledStart: action.scheduledStart?.toISOString() ?? null,\n scheduledEnd: action.scheduledEnd?.toISOString() ?? null,\n project: action.project ? {\n id: action.project.id,\n name: action.project.name,\n } : null,\n workspace: action.workspace ? {\n id: action.workspace.id,\n slug: action.workspace.slug,\n name: action.workspace.name,\n } : null,\n assignees: action.assignees?.map(a => ({\n id: a.user.id,\n name: a.user.name,\n email: a.user.email,\n })) ?? [],\n createdAt: action.createdAt?.toISOString() ?? new Date().toISOString(),\n completedAt: action.completedAt?.toISOString() ?? null,\n };\n}\n\n// Transform Project to ProjectOutput\nexport function transformProject(project: Project): ProjectOutput {\n return {\n id: project.id,\n name: project.name,\n description: project.description,\n status: project.status,\n priority: project.priority,\n workspace: project.workspace ? {\n id: project.workspace.id,\n slug: project.workspace.slug,\n name: project.workspace.name,\n } : null,\n };\n}\n\n// Transform Workspace to WorkspaceOutput\nexport function transformWorkspace(workspace: Workspace): WorkspaceOutput {\n return {\n id: workspace.id,\n name: workspace.name,\n slug: workspace.slug,\n type: workspace.type,\n };\n}\n\n// Output single action as JSON\nexport function outputActionJson(action: Action): void {\n const output = transformAction(action);\n console.log(JSON.stringify(output, null, 2));\n}\n\n// Output single action in pretty format\nexport function outputActionPretty(action: Action): void {\n const statusColor = getKanbanStatusColor(action.kanbanStatus);\n const statusBadge = action.kanbanStatus\n ? chalk[statusColor](`[${action.kanbanStatus}]`)\n : chalk.gray('[NO STATUS]');\n\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${statusBadge} ${chalk.bold(action.name)}`);\n console.log(chalk.gray(` ID: ${action.id}`));\n\n if (action.project) {\n console.log(` ${chalk.cyan('Project:')} ${action.project.name}`);\n }\n\n console.log(` ${chalk.magenta('Priority:')} ${action.priority}`);\n\n if (action.dueDate) {\n const dueDate = new Date(action.dueDate);\n console.log(` ${chalk.yellow('Due:')} ${formatDate(dueDate)}`);\n }\n\n if (action.description) {\n console.log(` ${chalk.gray('Description:')} ${action.description.substring(0, 100)}${action.description.length > 100 ? '...' : ''}`);\n }\n console.log();\n}\n\n// Output actions as JSON\nexport function outputActionsJson(actions: Action[], filters: ActionsListOutput['filters'] = {}): void {\n const output: ActionsListOutput = {\n actions: actions.map(transformAction),\n total: actions.length,\n filters,\n };\n console.log(JSON.stringify(output, null, 2));\n}\n\n// Output actions in pretty format\nexport function outputActionsPretty(actions: Action[]): void {\n if (actions.length === 0) {\n console.log(chalk.gray('No actions found.'));\n return;\n }\n\n console.log(chalk.bold(`\\nActions (${actions.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n\n for (const action of actions) {\n const statusColor = getKanbanStatusColor(action.kanbanStatus);\n const statusBadge = action.kanbanStatus\n ? chalk[statusColor](`[${action.kanbanStatus}]`)\n : chalk.gray('[NO STATUS]');\n\n console.log(`\\n${statusBadge} ${chalk.bold(action.name)}`);\n console.log(chalk.gray(` ID: ${action.id}`));\n\n if (action.project) {\n console.log(` ${chalk.cyan('Project:')} ${action.project.name}`);\n }\n\n console.log(` ${chalk.magenta('Priority:')} ${action.priority}`);\n\n if (action.dueDate) {\n const dueDate = new Date(action.dueDate);\n const isOverdue = dueDate < new Date();\n const dateStr = formatDate(dueDate);\n console.log(` ${chalk.yellow('Due:')} ${isOverdue ? chalk.red(dateStr) : dateStr}`);\n }\n\n if (action.description) {\n console.log(` ${chalk.gray('Description:')} ${action.description.substring(0, 100)}${action.description.length > 100 ? '...' : ''}`);\n }\n }\n console.log();\n}\n\n// ─── Today's actions (the /today partition) ────────────────\n\nexport function outputTodaysActionsJson(t: TodaysActions, filters: Record<string, unknown> = {}): void {\n console.log(JSON.stringify({\n overdue: { count: t.overdue.count, actions: t.overdue.actions },\n today: { count: t.today.count, actions: t.today.actions },\n inbox: { count: t.inbox.count, actions: t.inbox.actions },\n total: t.overdue.count + t.today.count + t.inbox.count,\n filters,\n }, null, 2));\n}\n\nfunction printTodayGroup(label: string, group: TodaysActions['overdue'], color: 'red' | 'green' | 'gray'): void {\n if (group.count === 0) return;\n const truncated = group.count > group.actions.length\n ? chalk.gray(` (showing ${group.actions.length})`)\n : '';\n console.log(`\\n${chalk[color].bold(`${label} (${group.count})`)}${truncated}`);\n for (const a of group.actions) {\n const when = a.scheduledStart ?? a.dueDate;\n const stamp = when ? chalk.gray(formatDate(new Date(when))) : '';\n const project = a.projectName ? chalk.cyan(` [${a.projectName}]`) : '';\n console.log(` ${a.name}${project} ${stamp}`);\n console.log(chalk.gray(` ID: ${a.id}`));\n }\n}\n\nexport function outputTodaysActionsPretty(t: TodaysActions): void {\n const total = t.overdue.count + t.today.count + t.inbox.count;\n if (total === 0) {\n console.log(chalk.gray('Nothing on your plate.'));\n return;\n }\n console.log(chalk.bold('\\nOn your plate'));\n console.log(chalk.gray('─'.repeat(50)));\n printTodayGroup('Overdue', t.overdue, 'red');\n printTodayGroup('Today', t.today, 'green');\n printTodayGroup('Inbox', t.inbox, 'gray');\n if (t.overdue.count > 0) {\n console.log(chalk.gray(`\\nRun \"exponential actions overdue\" to see why the overdue pile is that size.`));\n }\n console.log();\n}\n\n// ─── Overdue triage ────────────────────────────────────────\n\nexport function outputOverdueTriageJson(t: OverdueTriage): void {\n console.log(JSON.stringify(t, null, 2));\n}\n\nexport function outputOverdueTriagePretty(t: OverdueTriage): void {\n if (t.totalOverdue === 0) {\n console.log(chalk.green('Nothing overdue.'));\n return;\n }\n\n console.log(chalk.bold(`\\nOverdue: ${t.totalOverdue}`));\n console.log(chalk.gray('─'.repeat(50)));\n\n if (t.cohorts.length > 0) {\n console.log(\n `\\n${chalk.yellow.bold(`${t.cohortCount} of these were bulk-created`)} ${chalk.gray('— stamped with one identical timestamp, so almost certainly never individually due.')}`,\n );\n for (const c of t.cohorts) {\n console.log(\n `\\n ${chalk.bold(`${c.count} actions`)} stamped ${chalk.gray(c.stampedAt.toISOString())} ${chalk.red(`(${c.daysOverdue}d overdue)`)}`,\n );\n if (c.projectNames.length > 0) {\n console.log(` ${chalk.cyan('Projects:')} ${c.projectNames.join(', ')}`);\n }\n for (const a of c.actions.slice(0, 4)) {\n console.log(chalk.gray(` · ${a.name.substring(0, 62)}`));\n }\n if (c.actions.length > 4) {\n console.log(chalk.gray(` · … and ${c.actions.length - 4} more`));\n }\n console.log(\n chalk.gray(` Amnesty: `) +\n `exponential actions defer --ids ${c.actionIds.slice(0, 2).join(',')}${c.actionIds.length > 2 ? ',…' : ''}`,\n );\n }\n }\n\n if (t.loose.length > 0) {\n console.log(`\\n${chalk.bold(`${t.loose.length} individually dated`)} ${chalk.gray('— real debt, oldest first.')}`);\n for (const a of t.loose) {\n const project = a.projectName ? chalk.cyan(` [${a.projectName}]`) : '';\n console.log(` ${chalk.red(`${String(a.daysOverdue).padStart(3)}d`)} ${a.name.substring(0, 62)}${project}`);\n console.log(chalk.gray(` ID: ${a.id}`));\n }\n }\n console.log();\n}\n\n// Output projects as JSON\nexport function outputProjectsJson(projects: Project[]): void {\n const output: ProjectsListOutput = {\n projects: projects.map(transformProject),\n total: projects.length,\n };\n console.log(JSON.stringify(output, null, 2));\n}\n\n// Output projects in pretty format\nexport function outputProjectsPretty(projects: Project[]): void {\n if (projects.length === 0) {\n console.log(chalk.gray('No projects found.'));\n return;\n }\n\n console.log(chalk.bold(`\\nProjects (${projects.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n\n for (const project of projects) {\n console.log(`\\n${chalk.bold(project.name)}`);\n console.log(chalk.gray(` ID: ${project.id}`));\n\n if (project.status) {\n console.log(` ${chalk.cyan('Status:')} ${project.status}`);\n }\n\n if (project.priority) {\n console.log(` ${chalk.magenta('Priority:')} ${project.priority}`);\n }\n\n if (project.workspace) {\n console.log(` ${chalk.yellow('Workspace:')} ${project.workspace.name} (${project.workspace.slug})`);\n }\n\n if (project.description) {\n console.log(` ${chalk.gray('Description:')} ${project.description.substring(0, 100)}${project.description.length > 100 ? '...' : ''}`);\n }\n }\n console.log();\n}\n\n// Output workspaces as JSON\nexport function outputWorkspacesJson(workspaces: Workspace[]): void {\n const output: WorkspacesListOutput = {\n workspaces: workspaces.map(transformWorkspace),\n total: workspaces.length,\n };\n console.log(JSON.stringify(output, null, 2));\n}\n\n// Output workspaces in pretty format\nexport function outputWorkspacesPretty(workspaces: Workspace[]): void {\n if (workspaces.length === 0) {\n console.log(chalk.gray('No workspaces found.'));\n return;\n }\n\n console.log(chalk.bold(`\\nWorkspaces (${workspaces.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n\n for (const workspace of workspaces) {\n console.log(`\\n${chalk.bold(workspace.name)}`);\n console.log(chalk.gray(` ID: ${workspace.id}`));\n console.log(` ${chalk.cyan('Slug:')} ${workspace.slug}`);\n console.log(` ${chalk.magenta('Type:')} ${workspace.type}`);\n }\n console.log();\n}\n\n// Helper functions\nfunction getKanbanStatusColor(status: string | null): 'gray' | 'blue' | 'yellow' | 'cyan' | 'green' | 'red' {\n switch (status) {\n case 'BACKLOG': return 'gray';\n case 'TODO': return 'blue';\n case 'IN_PROGRESS': return 'yellow';\n case 'IN_REVIEW': return 'cyan';\n case 'DONE': return 'green';\n case 'CANCELLED': return 'red';\n default: return 'gray';\n }\n}\n\nfunction formatDate(date: Date): string {\n return date.toLocaleDateString('en-US', {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n });\n}\n\n// ─── Contact output ────────────────────────────────────────\n\nexport function outputContactJson(contact: Contact): void {\n console.log(JSON.stringify(transformContact(contact), null, 2));\n}\n\nexport function outputContactPretty(contact: Contact): void {\n const name = [contact.firstName, contact.lastName].filter(Boolean).join(' ') || chalk.gray('(no name)');\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk.bold(name)}`);\n console.log(chalk.gray(` ID: ${contact.id}`));\n if (contact.email) console.log(` ${chalk.cyan('Email:')} ${contact.email}`);\n if (contact.phone) console.log(` ${chalk.cyan('Phone:')} ${contact.phone}`);\n if (contact.telegram) console.log(` ${chalk.cyan('Telegram:')} ${contact.telegram}`);\n if (contact.linkedIn) console.log(` ${chalk.cyan('LinkedIn:')} ${contact.linkedIn}`);\n if (contact.twitter) console.log(` ${chalk.cyan('Twitter:')} ${contact.twitter}`);\n if (contact.github) console.log(` ${chalk.cyan('GitHub:')} ${contact.github}`);\n if (contact.bluesky) console.log(` ${chalk.cyan('Bluesky:')} ${contact.bluesky}`);\n if (contact.about) console.log(` ${chalk.gray('About:')} ${contact.about.substring(0, 120)}${contact.about.length > 120 ? '...' : ''}`);\n if (contact.profileType) console.log(` ${chalk.magenta('Type:')} ${contact.profileType}`);\n if (contact.skills?.length) console.log(` ${chalk.yellow('Skills:')} ${contact.skills.join(', ')}`);\n if (contact.tags?.length) console.log(` ${chalk.yellow('Tags:')} ${contact.tags.join(', ')}`);\n if (contact.organization) console.log(` ${chalk.green('Org:')} ${contact.organization.name}`);\n if (contact.connectionScore != null) console.log(` ${chalk.blue('Connection Score:')} ${contact.connectionScore}`);\n if (contact.lastInteractionAt) console.log(` ${chalk.gray('Last Interaction:')} ${formatDate(new Date(contact.lastInteractionAt))} (${contact.lastInteractionType ?? ''})`);\n console.log();\n}\n\nexport function outputContactsJson(contacts: Contact[], nextCursor?: string): void {\n console.log(JSON.stringify({\n contacts: contacts.map(transformContact),\n total: contacts.length,\n nextCursor: nextCursor ?? null,\n }, null, 2));\n}\n\nexport function outputContactsPretty(contacts: Contact[]): void {\n if (contacts.length === 0) {\n console.log(chalk.gray('No contacts found.'));\n return;\n }\n console.log(chalk.bold(`\\nContacts (${contacts.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const contact of contacts) {\n const name = [contact.firstName, contact.lastName].filter(Boolean).join(' ') || chalk.gray('(no name)');\n console.log(`\\n${chalk.bold(name)}`);\n console.log(chalk.gray(` ID: ${contact.id}`));\n if (contact.email) console.log(` ${chalk.cyan('Email:')} ${contact.email}`);\n if (contact.organization) console.log(` ${chalk.green('Org:')} ${contact.organization.name}`);\n if (contact.tags?.length) console.log(` ${chalk.yellow('Tags:')} ${contact.tags.join(', ')}`);\n }\n console.log();\n}\n\nfunction transformContact(contact: Contact): Record<string, unknown> {\n return {\n id: contact.id,\n workspaceId: contact.workspaceId,\n firstName: contact.firstName,\n lastName: contact.lastName,\n email: contact.email,\n phone: contact.phone,\n linkedIn: contact.linkedIn,\n telegram: contact.telegram,\n twitter: contact.twitter,\n github: contact.github,\n bluesky: contact.bluesky,\n about: contact.about,\n profileType: contact.profileType,\n skills: contact.skills,\n tags: contact.tags,\n organizationId: contact.organizationId,\n organization: contact.organization ?? null,\n connectionScore: contact.connectionScore,\n lastInteractionAt: contact.lastInteractionAt ? new Date(contact.lastInteractionAt).toISOString() : null,\n lastInteractionType: contact.lastInteractionType,\n createdAt: new Date(contact.createdAt).toISOString(),\n updatedAt: new Date(contact.updatedAt).toISOString(),\n };\n}\n\n// ─── Interaction output ────────────────────────────────────\n\nexport function outputInteractionJson(interaction: ContactInteraction): void {\n console.log(JSON.stringify(interaction, null, 2));\n}\n\nexport function outputInteractionPretty(interaction: ContactInteraction): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(` ${chalk.cyan('Type:')} ${interaction.type} (${interaction.direction})`);\n if (interaction.subject) console.log(` ${chalk.bold('Subject:')} ${interaction.subject}`);\n if (interaction.notes) console.log(` ${chalk.gray('Notes:')} ${interaction.notes}`);\n console.log();\n}\n\n// ─── Organization output ───────────────────────────────────\n\nfunction transformOrganization(org: Organization): Record<string, unknown> {\n return {\n id: org.id,\n workspaceId: org.workspaceId,\n name: org.name,\n websiteUrl: org.websiteUrl,\n logoUrl: org.logoUrl,\n description: org.description,\n industry: org.industry,\n size: org.size,\n contactCount: org._count?.contacts ?? null,\n createdAt: new Date(org.createdAt).toISOString(),\n updatedAt: new Date(org.updatedAt).toISOString(),\n };\n}\n\nexport function outputOrganizationJson(org: Organization): void {\n console.log(JSON.stringify(transformOrganization(org), null, 2));\n}\n\nexport function outputOrganizationPretty(org: Organization): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk.bold(org.name)}`);\n console.log(chalk.gray(` ID: ${org.id}`));\n if (org.industry) console.log(` ${chalk.magenta('Industry:')} ${org.industry}`);\n if (org.size) console.log(` ${chalk.cyan('Size:')} ${org.size}`);\n if (org.websiteUrl) console.log(` ${chalk.cyan('Website:')} ${org.websiteUrl}`);\n if (org.description) console.log(` ${chalk.gray('About:')} ${org.description.substring(0, 120)}${org.description.length > 120 ? '...' : ''}`);\n if (org._count?.contacts != null) console.log(` ${chalk.green('Contacts:')} ${org._count.contacts}`);\n console.log();\n}\n\nexport function outputOrganizationsJson(organizations: Organization[], nextCursor?: string): void {\n console.log(JSON.stringify({\n organizations: organizations.map(transformOrganization),\n total: organizations.length,\n nextCursor: nextCursor ?? null,\n }, null, 2));\n}\n\nexport function outputOrganizationsPretty(organizations: Organization[]): void {\n if (organizations.length === 0) {\n console.log(chalk.gray('No organizations found.'));\n return;\n }\n console.log(chalk.bold(`\\nOrganizations (${organizations.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const org of organizations) {\n console.log(`\\n${chalk.bold(org.name)}`);\n console.log(chalk.gray(` ID: ${org.id}`));\n if (org.industry) console.log(` ${chalk.magenta('Industry:')} ${org.industry}`);\n if (org._count?.contacts != null) console.log(` ${chalk.green('Contacts:')} ${org._count.contacts}`);\n }\n console.log();\n}\n\n// ─── Deal output ───────────────────────────────────────────\n\nexport function outputDealJson(deal: Deal): void {\n console.log(JSON.stringify(transformDeal(deal), null, 2));\n}\n\nexport function outputDealPretty(deal: Deal): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk.bold(deal.title)}`);\n console.log(chalk.gray(` ID: ${deal.id}`));\n if (deal.stage) console.log(` ${chalk.blue('Stage:')} ${deal.stage.name}`);\n if (deal.value != null) console.log(` ${chalk.green('Value:')} ${deal.currency} ${deal.value.toLocaleString()}`);\n if (deal.probability != null) console.log(` ${chalk.yellow('Probability:')} ${deal.probability}%`);\n if (deal.expectedCloseDate) console.log(` ${chalk.cyan('Expected Close:')} ${formatDate(new Date(deal.expectedCloseDate))}`);\n if (deal.contact) {\n const name = [deal.contact.firstName, deal.contact.lastName].filter(Boolean).join(' ');\n if (name) console.log(` ${chalk.magenta('Contact:')} ${name}`);\n }\n if (deal.organization) console.log(` ${chalk.magenta('Org:')} ${deal.organization.name}`);\n if (deal.assignedTo) console.log(` ${chalk.gray('Assigned:')} ${deal.assignedTo.name ?? deal.assignedTo.email ?? deal.assignedTo.id}`);\n if (deal.description) console.log(` ${chalk.gray('Description:')} ${deal.description.substring(0, 120)}${deal.description.length > 120 ? '...' : ''}`);\n console.log();\n}\n\nexport function outputDealsJson(deals: Deal[]): void {\n console.log(JSON.stringify({\n deals: deals.map(transformDeal),\n total: deals.length,\n }, null, 2));\n}\n\nexport function outputDealsPretty(deals: Deal[]): void {\n if (deals.length === 0) {\n console.log(chalk.gray('No deals found.'));\n return;\n }\n console.log(chalk.bold(`\\nDeals (${deals.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const deal of deals) {\n const stageLabel = deal.stage ? chalk.blue(`[${deal.stage.name}]`) : '';\n const valueLabel = deal.value != null ? chalk.green(` ${deal.currency} ${deal.value.toLocaleString()}`) : '';\n console.log(`\\n${stageLabel} ${chalk.bold(deal.title)}${valueLabel}`);\n console.log(chalk.gray(` ID: ${deal.id}`));\n if (deal.contact) {\n const name = [deal.contact.firstName, deal.contact.lastName].filter(Boolean).join(' ');\n if (name) console.log(` ${chalk.magenta('Contact:')} ${name}`);\n }\n if (deal.probability != null) console.log(` ${chalk.yellow('Probability:')} ${deal.probability}%`);\n if (deal.expectedCloseDate) console.log(` ${chalk.cyan('Close:')} ${formatDate(new Date(deal.expectedCloseDate))}`);\n }\n console.log();\n}\n\nfunction transformDeal(deal: Deal): Record<string, unknown> {\n return {\n id: deal.id,\n projectId: deal.projectId,\n stageId: deal.stageId,\n title: deal.title,\n description: deal.description,\n value: deal.value,\n currency: deal.currency,\n probability: deal.probability,\n expectedCloseDate: deal.expectedCloseDate ? new Date(deal.expectedCloseDate).toISOString() : null,\n closedAt: deal.closedAt ? new Date(deal.closedAt).toISOString() : null,\n contactId: deal.contactId,\n organizationId: deal.organizationId,\n workspaceId: deal.workspaceId,\n assignedToId: deal.assignedToId,\n stage: deal.stage ? { id: deal.stage.id, name: deal.stage.name, color: deal.stage.color } : null,\n contact: deal.contact ?? null,\n organization: deal.organization ?? null,\n assignedTo: deal.assignedTo ?? null,\n createdAt: new Date(deal.createdAt).toISOString(),\n updatedAt: new Date(deal.updatedAt).toISOString(),\n };\n}\n\n// ─── Pipeline output ───────────────────────────────────────\n\nexport function outputPipelineJson(pipeline: Pipeline): void {\n console.log(JSON.stringify({\n id: pipeline.id,\n name: pipeline.name,\n workspaceId: pipeline.workspaceId,\n status: pipeline.status,\n stages: pipeline.pipelineStages.map(s => ({\n id: s.id,\n name: s.name,\n color: s.color,\n order: s.order,\n type: s.type,\n dealCount: s._count?.deals ?? null,\n })),\n }, null, 2));\n}\n\nexport function outputPipelinePretty(pipeline: Pipeline): void {\n console.log(chalk.bold(`\\nPipeline: ${pipeline.name}`));\n console.log(chalk.gray(` ID: ${pipeline.id}`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const stage of pipeline.pipelineStages) {\n const count = stage._count?.deals != null ? chalk.gray(` (${stage._count.deals} deals)`) : '';\n console.log(` ${chalk.bold(stage.name)}${count} — ${chalk.gray(stage.type)}`);\n }\n console.log();\n}\n\nexport function outputStagesJson(stages: PipelineStage[]): void {\n console.log(JSON.stringify({\n stages: stages.map(s => ({\n id: s.id,\n name: s.name,\n color: s.color,\n order: s.order,\n type: s.type,\n dealCount: s._count?.deals ?? null,\n })),\n total: stages.length,\n }, null, 2));\n}\n\n// ─── Comment output ────────────────────────────────────────\n\n// Two comment shapes exist server-side and both reach the CLI: actions,\n// tickets and goals use `{ authorId, content, author }`; features and pages use\n// `{ createdById, body, createdBy }`. Rather than teach every caller which is\n// which, normalize once here — output is identical either way.\ntype AnyComment =\n | ActionComment\n | TicketComment\n | GoalComment\n | FeatureComment\n | PageComment;\n\nconst COMMENT_PARENT_KEYS = ['actionId', 'ticketId', 'goalId', 'featureId', 'pageId'] as const;\n\ninterface NormalizedComment {\n id: string;\n parentKey: string;\n parentId: unknown;\n authorId: string;\n author: { id: string; name: string | null } | null;\n content: string;\n createdAt: Date;\n updatedAt: Date;\n /** Feature comments only: set when the comment is a reply. */\n parentCommentId?: string | null;\n /** Feature comments only: the anchored thread, when there is one. */\n threadId?: string | null;\n resolvedAt?: Date | null;\n}\n\nfunction normalizeComment(comment: AnyComment): NormalizedComment {\n const raw = comment as unknown as Record<string, unknown>;\n const parentKey = COMMENT_PARENT_KEYS.find((k) => k in raw) ?? 'parentId';\n const author = (raw.author ?? raw.createdBy ?? null) as\n | { id: string; name: string | null }\n | null;\n\n return {\n id: comment.id,\n parentKey,\n parentId: raw[parentKey],\n authorId: (raw.authorId ?? raw.createdById) as string,\n author,\n content: (raw.content ?? raw.body ?? '') as string,\n createdAt: new Date(comment.createdAt),\n updatedAt: new Date(comment.updatedAt),\n parentCommentId: (raw.parentId ?? null) as string | null,\n threadId: (raw.threadId ?? null) as string | null,\n resolvedAt: raw.resolvedAt ? new Date(raw.resolvedAt as string) : null,\n };\n}\n\nfunction transformComment(comment: AnyComment): Record<string, unknown> {\n const n = normalizeComment(comment);\n const out: Record<string, unknown> = {\n id: n.id,\n [n.parentKey]: n.parentId,\n authorId: n.authorId,\n content: n.content,\n author: n.author,\n createdAt: n.createdAt.toISOString(),\n updatedAt: n.updatedAt.toISOString(),\n };\n // Threading metadata only exists on feature comments — omit it elsewhere so\n // the JSON of an action comment stays exactly as it was.\n if (n.threadId !== null) out.threadId = n.threadId;\n if (n.parentCommentId !== null && n.parentKey !== 'parentId') {\n out.parentCommentId = n.parentCommentId;\n }\n if (n.resolvedAt) out.resolvedAt = n.resolvedAt.toISOString();\n return out;\n}\n\nexport function outputCommentJson(comment: AnyComment): void {\n console.log(JSON.stringify(transformComment(comment), null, 2));\n}\n\nexport function outputCommentPretty(comment: AnyComment): void {\n const n = normalizeComment(comment);\n const author = n.author?.name ?? n.authorId;\n const when = formatDate(n.createdAt);\n const badges = [\n n.parentCommentId && n.parentKey !== 'parentId' ? chalk.gray('(reply)') : '',\n n.resolvedAt ? chalk.green('(resolved)') : '',\n ]\n .filter(Boolean)\n .join(' ');\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`${chalk.bold(author)} ${chalk.gray(`— ${when}`)}${badges ? ` ${badges}` : ''}`);\n console.log(chalk.gray(` ID: ${n.id}`));\n console.log();\n console.log(n.content);\n console.log();\n}\n\nexport function outputCommentsJson(comments: AnyComment[]): void {\n console.log(JSON.stringify({\n comments: comments.map(transformComment),\n total: comments.length,\n }, null, 2));\n}\n\nexport function outputCommentsPretty(comments: AnyComment[]): void {\n if (comments.length === 0) {\n console.log(chalk.gray('No comments.'));\n return;\n }\n console.log(chalk.bold(`\\nComments (${comments.length})`));\n for (const c of comments) {\n outputCommentPretty(c);\n }\n}\n\n// ─── Product output ────────────────────────────────────────\n\nexport function outputProductJson(product: Product): void {\n console.log(JSON.stringify(transformProduct(product), null, 2));\n}\n\nexport function outputProductPretty(product: Product): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk.bold(product.name)} ${chalk.gray(`(${product.slug})`)}`);\n console.log(chalk.gray(` ID: ${product.id}`));\n if (product.description) {\n console.log(` ${chalk.gray('Description:')} ${product.description}`);\n }\n if (product._count) {\n const c = product._count;\n const parts = [\n c.features != null ? `features: ${c.features}` : null,\n c.tickets != null ? `tickets: ${c.tickets}` : null,\n ].filter(Boolean);\n if (parts.length) console.log(` ${chalk.cyan('Counts:')} ${parts.join(' ')}`);\n }\n console.log();\n}\n\nexport function outputProductsJson(products: Product[]): void {\n console.log(JSON.stringify({\n products: products.map(transformProduct),\n total: products.length,\n }, null, 2));\n}\n\nexport function outputProductsPretty(products: Product[]): void {\n if (products.length === 0) {\n console.log(chalk.gray('No products found.'));\n return;\n }\n console.log(chalk.bold(`\\nProducts (${products.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const p of products) {\n const ticketCount = p._count?.tickets != null ? chalk.gray(` — ${p._count.tickets} tickets`) : '';\n console.log(` ${chalk.bold(p.name)} ${chalk.gray(`(${p.slug})`)}${ticketCount}`);\n console.log(chalk.gray(` ID: ${p.id}`));\n }\n console.log();\n}\n\nfunction transformProduct(product: Product): Record<string, unknown> {\n return {\n id: product.id,\n workspaceId: product.workspaceId,\n name: product.name,\n slug: product.slug,\n description: product.description,\n icon: product.icon,\n color: product.color,\n funTicketIds: product.funTicketIds,\n ticketCounter: product.ticketCounter,\n counts: product._count ?? null,\n createdAt: new Date(product.createdAt).toISOString(),\n updatedAt: new Date(product.updatedAt).toISOString(),\n };\n}\n\n// ─── Feature output ────────────────────────────────────────\n\nexport function outputFeatureJson(feature: Feature): void {\n console.log(JSON.stringify(transformFeature(feature), null, 2));\n}\n\nexport function outputFeaturePretty(feature: Feature): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk[getFeatureStatusColor(feature.status)](`[${feature.status}]`)} ${chalk.bold(feature.name)}`);\n console.log(chalk.gray(` ID: ${feature.id}`));\n if (feature.description) {\n console.log(` ${chalk.gray('Description:')} ${feature.description.substring(0, 120)}${feature.description.length > 120 ? '...' : ''}`);\n }\n if (feature.vision) {\n console.log(` ${chalk.gray('Vision:')} ${feature.vision.substring(0, 120)}${feature.vision.length > 120 ? '...' : ''}`);\n }\n if (feature.priority != null) {\n console.log(` ${chalk.magenta('Priority:')} ${feature.priority}`);\n }\n if (feature.goal) {\n console.log(` ${chalk.blue('Objective:')} ${feature.goal.title} ${chalk.gray(`(${feature.goal.id})`)}`);\n }\n // The finer Feature->Key result edge (ADR-0050), printed beneath the\n // Objective it is easily confused with.\n if (feature.keyResultLinks?.length) {\n console.log(` ${chalk.blue('Key results:')}`);\n for (const link of feature.keyResultLinks) {\n const kr = link.keyResult;\n const progress =\n kr.currentValue != null && kr.targetValue != null\n ? `${kr.currentValue}/${kr.targetValue}${kr.unit && kr.unit !== 'custom' ? ` ${kr.unit}` : ''}, `\n : '';\n console.log(` · ${kr.title} ${chalk.gray(`(${progress}${kr.period}, ${kr.id})`)}`);\n }\n }\n if (feature._count?.tickets != null) {\n console.log(` ${chalk.cyan('Tickets:')} ${feature._count.tickets}`);\n }\n console.log();\n}\n\nexport function outputFeaturesJson(features: Feature[]): void {\n console.log(JSON.stringify({\n features: features.map(transformFeature),\n total: features.length,\n }, null, 2));\n}\n\nexport function outputFeaturesPretty(features: Feature[]): void {\n if (features.length === 0) {\n console.log(chalk.gray('No features found.'));\n return;\n }\n console.log(chalk.bold(`\\nFeatures (${features.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const f of features) {\n const statusBadge = chalk[getFeatureStatusColor(f.status)](`[${f.status}]`);\n const ticketCount = f._count?.tickets != null ? chalk.gray(` — ${f._count.tickets} tickets`) : '';\n console.log(` ${statusBadge} ${chalk.bold(f.name)}${ticketCount}`);\n console.log(chalk.gray(` ID: ${f.id}`));\n // The KR column, one line per feature — the whole point of carrying the\n // lean shape on `list` rather than making callers fetch each feature.\n if (f.keyResultLinks?.length) {\n const titles = f.keyResultLinks.map((l) => l.keyResult.title).join('; ');\n console.log(chalk.gray(` KRs: ${titles}`));\n }\n }\n console.log();\n}\n\n/**\n * One key result a feature executes, flattened for output. `currentValue` and\n * friends are undefined on the lean `features list` shape; they are only\n * selected on `features get`.\n */\nfunction summarizeFeatureKeyResult(\n link: FeatureKeyResultLink,\n): Record<string, unknown> {\n const kr = link.keyResult;\n return {\n keyResultId: kr.id,\n title: kr.title,\n period: kr.period,\n goalId: kr.goalId,\n status: kr.status ?? null,\n currentValue: kr.currentValue ?? null,\n targetValue: kr.targetValue ?? null,\n unit: kr.unit ?? null,\n };\n}\n\nfunction transformFeature(feature: Feature): Record<string, unknown> {\n return {\n id: feature.id,\n productId: feature.productId,\n name: feature.name,\n description: feature.description,\n vision: feature.vision,\n status: feature.status,\n effort: feature.effort,\n priority: feature.priority,\n goalId: feature.goalId,\n goal: feature.goal ?? null,\n // Flattened out of the join row (ADR-0050): callers building a per-feature\n // \"which key results does this move\" column want the key results, not the\n // edge rows. `goal` above is the coarser Objective alignment and is a\n // different question - the two are allowed to disagree, so both ride along.\n // Progress values are present on `features get` and absent on `list`.\n keyResults: feature.keyResultLinks?.map(summarizeFeatureKeyResult) ?? null,\n counts: feature._count ?? null,\n createdAt: new Date(feature.createdAt).toISOString(),\n updatedAt: new Date(feature.updatedAt).toISOString(),\n };\n}\n\nfunction getFeatureStatusColor(status: string): 'gray' | 'blue' | 'yellow' | 'green' | 'red' {\n switch (status) {\n case 'IDEA': return 'gray';\n case 'DEFINED': return 'blue';\n case 'IN_PROGRESS': return 'yellow';\n case 'SHIPPED': return 'green';\n case 'ARCHIVED': return 'red';\n default: return 'gray';\n }\n}\n\n// ─── User story output ─────────────────────────────────────\n\nfunction transformUserStory(story: UserStory): Record<string, unknown> {\n return {\n id: story.id,\n featureId: story.featureId,\n scopeId: story.scopeId,\n asA: story.asA,\n iWant: story.iWant,\n soThat: story.soThat,\n acceptanceCriteria: story.acceptanceCriteria,\n displayOrder: story.displayOrder,\n createdAt: new Date(story.createdAt).toISOString(),\n updatedAt: new Date(story.updatedAt).toISOString(),\n };\n}\n\nexport function outputUserStoryJson(story: UserStory): void {\n console.log(JSON.stringify(transformUserStory(story), null, 2));\n}\n\nexport function outputUserStoryPretty(story: UserStory): void {\n console.log(chalk.gray('─'.repeat(50)));\n const order = chalk.gray(`#${story.displayOrder}`);\n console.log(`\\n${order} ${chalk.bold(story.iWant ?? '(no \"I want\")')}`);\n console.log(chalk.gray(` ID: ${story.id}`));\n if (story.asA) console.log(` ${chalk.cyan('As a:')} ${story.asA}`);\n if (story.iWant) console.log(` ${chalk.cyan('I want:')} ${story.iWant}`);\n if (story.soThat) console.log(` ${chalk.cyan('So that:')} ${story.soThat}`);\n if (story.acceptanceCriteria) {\n console.log(` ${chalk.yellow('Acceptance:')} ${story.acceptanceCriteria}`);\n }\n if (story.scopeId) console.log(` ${chalk.magenta('Scope:')} ${story.scopeId}`);\n console.log();\n}\n\nexport function outputUserStoriesJson(stories: UserStory[]): void {\n console.log(JSON.stringify({\n userStories: stories.map(transformUserStory),\n total: stories.length,\n }, null, 2));\n}\n\nexport function outputUserStoriesPretty(stories: UserStory[]): void {\n if (stories.length === 0) {\n console.log(chalk.gray('No user stories found.'));\n return;\n }\n console.log(chalk.bold(`\\nUser stories (${stories.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const story of stories) {\n const order = chalk.gray(`#${story.displayOrder}`);\n const parts = [\n story.asA ? `As a ${story.asA},` : null,\n story.iWant ? `I want ${story.iWant},` : null,\n story.soThat ? `so that ${story.soThat}.` : null,\n ].filter(Boolean).join(' ');\n console.log(` ${order} ${parts || chalk.gray('(empty)')}`);\n console.log(chalk.gray(` ID: ${story.id}`));\n }\n console.log();\n}\n\n// Output a batch add summary (per-item success/failure).\nexport interface BatchStoryResult {\n index: number;\n ok: boolean;\n id?: string;\n error?: string;\n}\n\nexport function outputBatchResultsJson(results: BatchStoryResult[]): void {\n const succeeded = results.filter((r) => r.ok).length;\n console.log(JSON.stringify({\n results,\n total: results.length,\n succeeded,\n failed: results.length - succeeded,\n }, null, 2));\n}\n\nexport function outputBatchResultsPretty(results: BatchStoryResult[]): void {\n const succeeded = results.filter((r) => r.ok).length;\n console.log(chalk.bold(`\\nAdded ${succeeded}/${results.length} user stories`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const r of results) {\n if (r.ok) {\n console.log(` ${chalk.green('✓')} [${r.index}] ${chalk.gray(r.id ?? '')}`);\n } else {\n console.log(` ${chalk.red('✗')} [${r.index}] ${r.error ?? 'failed'}`);\n }\n }\n console.log();\n}\n\n// ─── Ticket output ─────────────────────────────────────────\n\nexport function outputTicketJson(ticket: Ticket | TicketDetail): void {\n console.log(JSON.stringify(transformTicket(ticket), null, 2));\n}\n\nexport function outputTicketPretty(ticket: Ticket | TicketDetail): void {\n const id = ticket.shortId ?? (ticket.number != null ? `#${ticket.number}` : '?');\n console.log(chalk.gray('─'.repeat(50)));\n console.log(\n `\\n${chalk[getTicketStatusColor(ticket.status)](`[${ticket.status}]`)} ${chalk.gray(`[${ticket.type}]`)} ${chalk.bold(`${id} ${ticket.title}`)}`,\n );\n console.log(chalk.gray(` ID: ${ticket.id}`));\n if (ticket.isBlocked) {\n console.log(` ${chalk.red('BLOCKED')} by ${ticket.openBlockerCount ?? 0} open ticket(s)`);\n } else if (ticket.openBlockerCount && ticket.openBlockerCount > 0) {\n console.log(` ${chalk.yellow('Blockers:')} ${ticket.openBlockerCount} open (not currently in flight)`);\n }\n if (ticket.feature) {\n console.log(` ${chalk.cyan('Feature:')} ${ticket.feature.name}`);\n }\n if (ticket.epic) {\n console.log(` ${chalk.cyan('Epic:')} ${ticket.epic.name}`);\n }\n if (ticket.assignee) {\n console.log(` ${chalk.magenta('Assignee:')} ${ticket.assignee.name ?? ticket.assignee.id}`);\n }\n if (ticket.priority != null) {\n console.log(` ${chalk.magenta('Priority:')} ${ticket.priority}`);\n }\n if (ticket.points != null) {\n console.log(` ${chalk.yellow('Points:')} ${ticket.points}`);\n }\n if (ticket.body) {\n console.log(` ${chalk.gray('Body:')} ${ticket.body.substring(0, 200)}${ticket.body.length > 200 ? '...' : ''}`);\n }\n\n const detail = ticket as TicketDetail;\n if (detail.dependsOn && detail.dependsOn.length > 0) {\n console.log(` ${chalk.cyan('Depends on:')}`);\n for (const dep of detail.dependsOn) {\n const depId = dep.shortId ?? (dep.number != null ? `#${dep.number}` : '?');\n console.log(` - ${chalk.gray(`[${dep.status}]`)} ${depId} ${dep.title}`);\n }\n }\n if (detail.requiredFor && detail.requiredFor.length > 0) {\n console.log(` ${chalk.cyan('Required for:')}`);\n for (const dep of detail.requiredFor) {\n const depId = dep.shortId ?? (dep.number != null ? `#${dep.number}` : '?');\n console.log(` - ${chalk.gray(`[${dep.status}]`)} ${depId} ${dep.title}`);\n }\n }\n if (detail.actions && detail.actions.length > 0) {\n console.log(` ${chalk.cyan('Actions:')} ${detail.actions.length}`);\n for (const a of detail.actions) {\n console.log(` - ${chalk.gray(`[${a.kanbanStatus ?? a.status}]`)} ${a.name} ${chalk.gray(`(${a.id})`)}`);\n }\n }\n console.log();\n}\n\nexport function outputTicketsJson(tickets: Ticket[]): void {\n console.log(JSON.stringify({\n tickets: tickets.map(transformTicket),\n total: tickets.length,\n }, null, 2));\n}\n\nexport function outputTicketsPretty(tickets: Ticket[]): void {\n if (tickets.length === 0) {\n console.log(chalk.gray('No tickets found.'));\n return;\n }\n console.log(chalk.bold(`\\nTickets (${tickets.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const t of tickets) {\n const id = t.shortId ?? (t.number != null ? `#${t.number}` : '?');\n const statusBadge = chalk[getTicketStatusColor(t.status)](`[${t.status}]`);\n const typeBadge = chalk.gray(`[${t.type}]`);\n const blocked = t.isBlocked ? chalk.red(' BLOCKED') : '';\n console.log(` ${statusBadge} ${typeBadge} ${chalk.bold(id)} ${t.title}${blocked}`);\n console.log(chalk.gray(` ID: ${t.id}`));\n }\n console.log();\n}\n\nfunction transformTicket(ticket: Ticket | TicketDetail): Record<string, unknown> {\n const detail = ticket as TicketDetail;\n return {\n id: ticket.id,\n productId: ticket.productId,\n number: ticket.number,\n shortId: ticket.shortId,\n title: ticket.title,\n body: ticket.body,\n type: ticket.type,\n status: ticket.status,\n priority: ticket.priority,\n points: ticket.points,\n branchName: ticket.branchName,\n prUrl: ticket.prUrl,\n designUrl: ticket.designUrl,\n specUrl: ticket.specUrl,\n links: ticket.links,\n epicId: ticket.epicId,\n featureId: ticket.featureId,\n cycleId: ticket.cycleId,\n scopeId: ticket.scopeId,\n assigneeId: ticket.assigneeId,\n assignee: ticket.assignee ?? null,\n feature: ticket.feature ?? null,\n epic: ticket.epic ?? null,\n openBlockerCount: ticket.openBlockerCount ?? 0,\n isBlocked: ticket.isBlocked ?? false,\n counts: ticket._count ?? null,\n dependsOn: detail.dependsOn ?? undefined,\n requiredFor: detail.requiredFor ?? undefined,\n actions: detail.actions?.map((a) => ({\n id: a.id,\n name: a.name,\n status: a.status,\n kanbanStatus: a.kanbanStatus,\n completedAt: a.completedAt ? new Date(a.completedAt).toISOString() : null,\n })),\n completedAt: ticket.completedAt ? new Date(ticket.completedAt).toISOString() : null,\n createdAt: new Date(ticket.createdAt).toISOString(),\n updatedAt: new Date(ticket.updatedAt).toISOString(),\n };\n}\n\nfunction getTicketStatusColor(status: string): 'gray' | 'blue' | 'yellow' | 'cyan' | 'green' | 'red' | 'magenta' {\n switch (status) {\n case 'BACKLOG': return 'gray';\n case 'NEEDS_REFINEMENT': return 'gray';\n case 'READY_TO_PLAN': return 'blue';\n case 'COMMITTED': return 'blue';\n case 'IN_PROGRESS': return 'yellow';\n case 'BLOCKED': return 'red';\n case 'QA': return 'cyan';\n case 'DONE': return 'green';\n case 'DEPLOYED': return 'green';\n case 'ARCHIVED': return 'gray';\n default: return 'gray';\n }\n}\n\n// ─── Epic output ───────────────────────────────────────────\n\nexport function outputEpicJson(epic: Epic): void {\n console.log(JSON.stringify(transformEpic(epic), null, 2));\n}\n\nexport function outputEpicPretty(epic: Epic): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk[getEpicStatusColor(epic.status)](`[${epic.status}]`)} ${chalk.bold(epic.name)}`);\n console.log(chalk.gray(` ID: ${epic.id}`));\n if (epic.description) {\n console.log(` ${chalk.gray('Description:')} ${epic.description.substring(0, 200)}${epic.description.length > 200 ? '...' : ''}`);\n }\n console.log(` ${chalk.magenta('Priority:')} ${epic.priority}`);\n if (epic.startDate) {\n console.log(` ${chalk.cyan('Start:')} ${formatDate(new Date(epic.startDate))}`);\n }\n if (epic.targetDate) {\n console.log(` ${chalk.cyan('Target:')} ${formatDate(new Date(epic.targetDate))}`);\n }\n if (epic.owner) {\n console.log(` ${chalk.gray('Owner:')} ${epic.owner.name ?? epic.owner.email ?? epic.owner.id}`);\n }\n if (epic._count) {\n const c = epic._count;\n const parts = [\n c.actions != null ? `actions: ${c.actions}` : null,\n c.tickets != null ? `tickets: ${c.tickets}` : null,\n ].filter(Boolean);\n if (parts.length) console.log(` ${chalk.cyan('Counts:')} ${parts.join(' ')}`);\n }\n console.log();\n}\n\nexport function outputEpicsJson(epics: Epic[]): void {\n console.log(JSON.stringify({\n epics: epics.map(transformEpic),\n total: epics.length,\n }, null, 2));\n}\n\nexport function outputEpicsPretty(epics: Epic[]): void {\n if (epics.length === 0) {\n console.log(chalk.gray('No epics found.'));\n return;\n }\n console.log(chalk.bold(`\\nEpics (${epics.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const e of epics) {\n const statusBadge = chalk[getEpicStatusColor(e.status)](`[${e.status}]`);\n const counts = e._count\n ? chalk.gray(\n ` — ${e._count.tickets ?? 0} tickets, ${e._count.actions ?? 0} actions`,\n )\n : '';\n console.log(` ${statusBadge} ${chalk.bold(e.name)}${counts}`);\n console.log(chalk.gray(` ID: ${e.id}`));\n }\n console.log();\n}\n\nfunction transformEpic(epic: Epic): Record<string, unknown> {\n return {\n id: epic.id,\n workspaceId: epic.workspaceId,\n name: epic.name,\n description: epic.description,\n status: epic.status,\n priority: epic.priority,\n startDate: epic.startDate ? new Date(epic.startDate).toISOString() : null,\n targetDate: epic.targetDate ? new Date(epic.targetDate).toISOString() : null,\n ownerId: epic.ownerId,\n owner: epic.owner ?? null,\n counts: epic._count ?? null,\n createdAt: new Date(epic.createdAt).toISOString(),\n updatedAt: new Date(epic.updatedAt).toISOString(),\n };\n}\n\nfunction getEpicStatusColor(status: string): 'gray' | 'blue' | 'yellow' | 'green' | 'red' {\n switch (status) {\n case 'OPEN': return 'blue';\n case 'IN_PROGRESS': return 'yellow';\n case 'DONE': return 'green';\n case 'CANCELLED': return 'red';\n default: return 'gray';\n }\n}\n\nexport function outputStagesPretty(stages: PipelineStage[]): void {\n if (stages.length === 0) {\n console.log(chalk.gray('No stages found.'));\n return;\n }\n console.log(chalk.bold(`\\nPipeline Stages (${stages.length})`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const stage of stages) {\n const count = stage._count?.deals != null ? chalk.gray(` (${stage._count.deals} deals)`) : '';\n console.log(` ${chalk.bold(stage.name)}${count} — ${chalk.gray(stage.type)}`);\n }\n console.log();\n}\n\n// ---------------------------------------------------------------------------\n// Knowledge pages\n// ---------------------------------------------------------------------------\n\nexport function outputPageJson(page: KnowledgePage): void {\n console.log(JSON.stringify(page, null, 2));\n}\n\nexport function outputPagePretty(page: KnowledgePage): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk.bold(page.title)}`);\n console.log(chalk.gray(` ID: ${page.id}`));\n if (page.project) {\n console.log(` ${chalk.gray('Project:')} ${page.project.name}`);\n }\n if (page.body) {\n console.log(`\\n${page.body}\\n`);\n }\n}\n\nexport function outputPagesJson(pages: KnowledgePage[]): void {\n console.log(JSON.stringify({ pages, total: pages.length }, null, 2));\n}\n\nexport function outputPagesPretty(pages: KnowledgePage[]): void {\n if (pages.length === 0) {\n console.log(chalk.gray('No pages found.'));\n return;\n }\n console.log(chalk.bold(`\\nPages (${pages.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const p of pages) {\n console.log(` ${chalk.bold(p.title)}`);\n console.log(chalk.gray(` ID: ${p.id}`));\n }\n console.log();\n}\n\n// ---------------------------------------------------------------------------\n// Meetings\n// ---------------------------------------------------------------------------\n\nfunction meetingWhen(meeting: Meeting): Date {\n return new Date(meeting.meetingDate ?? meeting.createdAt);\n}\n\n/**\n * AI-generated summaries are sometimes a stringified JSON object\n * (`overview` / `detailed_breakdown` / ...) rather than plain Markdown.\n * Render the readable parts in that case; otherwise print as-is.\n */\nfunction renderMeetingSummary(summary: string): string {\n if (!summary.trimStart().startsWith('{')) return summary;\n try {\n const parsed: unknown = JSON.parse(summary);\n if (parsed && typeof parsed === 'object') {\n const obj = parsed as { overview?: unknown; detailed_breakdown?: unknown };\n const parts = [obj.overview, obj.detailed_breakdown].filter(\n (v): v is string => typeof v === 'string' && v.length > 0,\n );\n if (parts.length > 0) return parts.join('\\n\\n');\n }\n } catch {\n // not JSON after all — fall through to the raw text\n }\n return summary;\n}\n\n/**\n * Pinned JSON shape for a meeting — agents parse this, so the server response\n * is never serialized verbatim (it drags along embedding/analytics internals\n * and any future server-side field lands straight in the public contract).\n */\nfunction transformMeeting(m: Meeting): Record<string, unknown> {\n return {\n id: m.id,\n sessionId: m.sessionId,\n title: m.title,\n description: m.description,\n notes: m.notes,\n summary: m.summary,\n transcription: m.transcription,\n meetingDate: m.meetingDate,\n createdAt: m.createdAt,\n updatedAt: m.updatedAt,\n userId: m.userId,\n projectId: m.projectId,\n workspaceId: m.workspaceId,\n archivedAt: m.archivedAt,\n durationSeconds: m.durationSeconds ?? null,\n participantCount: m.participantCount ?? null,\n videoUrl: m.videoUrl ?? null,\n project: m.project ?? null,\n workspace: m.workspace ?? null,\n sourceIntegration: m.sourceIntegration ?? null,\n participants: m.participants ?? [],\n actions: m.actions ?? [],\n };\n}\n\n/**\n * List rows swap the large bodies for presence flags: `meetings list` can\n * cover every visible meeting, and full transcripts would flood the agents\n * that parse this. `meetings get` carries the bodies.\n */\nfunction transformMeetingListRow(m: Meeting): Record<string, unknown> {\n const { notes, summary, transcription, ...rest } = transformMeeting(m);\n return {\n ...rest,\n hasNotes: Boolean(notes),\n hasSummary: Boolean(summary),\n hasTranscript: Boolean(transcription),\n };\n}\n\nexport function outputMeetingJson(meeting: Meeting): void {\n console.log(JSON.stringify(transformMeeting(meeting), null, 2));\n}\n\nexport function outputMeetingPretty(\n meeting: Meeting,\n options: { transcript?: boolean } = {},\n): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk.bold(meeting.title ?? 'Untitled meeting')}`);\n console.log(chalk.gray(` ID: ${meeting.id}`));\n console.log(` ${chalk.gray('Date:')} ${meetingWhen(meeting).toLocaleString()}`);\n if (meeting.workspace) {\n console.log(` ${chalk.gray('Workspace:')} ${meeting.workspace.name}`);\n }\n if (meeting.project) {\n console.log(` ${chalk.gray('Project:')} ${meeting.project.name}`);\n }\n if (meeting.sourceIntegration) {\n console.log(` ${chalk.gray('Source:')} ${meeting.sourceIntegration.provider}`);\n }\n if (meeting.durationSeconds) {\n console.log(` ${chalk.gray('Duration:')} ${Math.round(meeting.durationSeconds / 60)} min`);\n }\n if (meeting.archivedAt) {\n console.log(` ${chalk.yellow('Archived')}`);\n }\n if (meeting.participants && meeting.participants.length > 0) {\n const people = meeting.participants\n .map((p) => p.name ?? p.email)\n .join(', ');\n console.log(` ${chalk.gray('Participants:')} ${people}`);\n }\n if (meeting.description) {\n console.log(`\\n${meeting.description}`);\n }\n if (meeting.summary) {\n console.log(`\\n${chalk.bold('Summary')}`);\n console.log(renderMeetingSummary(meeting.summary));\n }\n if (meeting.notes) {\n console.log(`\\n${chalk.bold('Notes')}`);\n console.log(meeting.notes);\n } else {\n console.log(chalk.gray('\\nNo notes yet.'));\n }\n if (options.transcript) {\n if (meeting.transcription) {\n console.log(`\\n${chalk.bold('Transcript')}`);\n console.log(meeting.transcription);\n } else {\n console.log(chalk.gray('\\nNo transcript.'));\n }\n } else if (meeting.transcription) {\n console.log(chalk.gray('\\n(transcript available — pass --transcript to print it)'));\n }\n console.log();\n}\n\nexport function outputMeetingsJson(meetings: Meeting[]): void {\n console.log(\n JSON.stringify(\n { meetings: meetings.map(transformMeetingListRow), total: meetings.length },\n null,\n 2,\n ),\n );\n}\n\nexport function outputMeetingsPretty(meetings: Meeting[]): void {\n if (meetings.length === 0) {\n console.log(chalk.gray('No meetings found.'));\n return;\n }\n console.log(chalk.bold(`\\nMeetings (${meetings.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const m of meetings) {\n const flags = [\n m.notes ? 'notes' : null,\n m.summary ? 'summary' : null,\n m.transcription ? 'transcript' : null,\n ].filter(Boolean);\n const archived = m.archivedAt ? chalk.yellow(' [archived]') : '';\n console.log(\n ` ${chalk.bold(m.title ?? 'Untitled meeting')}${archived} ${chalk.gray(\n meetingWhen(m).toLocaleDateString(),\n )}`,\n );\n console.log(chalk.gray(` ID: ${m.id}`));\n const context = [\n m.project ? `Project: ${m.project.name}` : null,\n m.participantCount ? `${m.participantCount} participants` : null,\n flags.length > 0 ? flags.join(', ') : null,\n ].filter(Boolean);\n if (context.length > 0) {\n console.log(chalk.gray(` ${context.join(' · ')}`));\n }\n }\n console.log();\n}\n\n// ---------------------------------------------------------------------------\n// Requirements (EARS)\n// ---------------------------------------------------------------------------\n\nexport function outputRequirementJson(requirement: Requirement): void {\n console.log(JSON.stringify(requirement, null, 2));\n}\n\nexport function outputRequirementPretty(requirement: Requirement): void {\n const met = requirement.checkedAt\n ? chalk.green('[met]')\n : chalk.gray('[unmet]');\n const kind = requirement.kind ? chalk.gray(` (${requirement.kind})`) : '';\n console.log(` ${met} ${requirement.statement}${kind}`);\n console.log(chalk.gray(` ID: ${requirement.id}`));\n}\n\nexport function outputRequirementsJson(requirements: Requirement[]): void {\n console.log(JSON.stringify({ requirements, total: requirements.length }, null, 2));\n}\n\nexport function outputRequirementsPretty(requirements: Requirement[]): void {\n if (requirements.length === 0) {\n console.log(chalk.gray('No requirements found.'));\n return;\n }\n const metCount = requirements.filter((r) => r.checkedAt).length;\n console.log(chalk.bold(`\\nRequirements (${metCount}/${requirements.length} met)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const r of requirements) {\n outputRequirementPretty(r);\n }\n console.log();\n}\n\nexport interface BatchRequirementResult {\n index: number;\n success: boolean;\n requirement?: Requirement;\n error?: string;\n}\n\nexport function outputRequirementBatchJson(results: BatchRequirementResult[]): void {\n console.log(JSON.stringify({\n results,\n total: results.length,\n succeeded: results.filter((r) => r.success).length,\n failed: results.filter((r) => !r.success).length,\n }, null, 2));\n}\n\nexport function outputRequirementBatchPretty(results: BatchRequirementResult[]): void {\n for (const r of results) {\n if (r.success) {\n console.log(` ${chalk.green('✓')} #${r.index}: ${r.requirement?.statement ?? ''}`);\n } else {\n console.log(` ${chalk.red('✗')} #${r.index}: ${r.error ?? 'failed'}`);\n }\n }\n const ok = results.filter((r) => r.success).length;\n console.log(chalk.bold(`\\n${ok}/${results.length} requirements added`));\n}\n\n// ---------------------------------------------------------------------------\n// Feature scopes\n// ---------------------------------------------------------------------------\n\nfunction getScopeStatusColor(status: string): 'gray' | 'blue' | 'yellow' | 'green' | 'red' {\n switch (status) {\n case 'PLANNED': return 'blue';\n case 'IN_PROGRESS': return 'yellow';\n case 'SHIPPED': return 'green';\n case 'DEPRECATED': return 'red';\n default: return 'gray';\n }\n}\n\nexport function outputScopeJson(scope: FeatureScope): void {\n console.log(JSON.stringify(scope, null, 2));\n}\n\nexport function outputScopePretty(scope: FeatureScope): void {\n const badge = chalk[getScopeStatusColor(scope.status)](`[${scope.status}]`);\n console.log(` ${badge} ${chalk.bold(scope.version)}`);\n console.log(chalk.gray(` ID: ${scope.id}`));\n if (scope.description) {\n console.log(` ${scope.description.substring(0, 120)}${scope.description.length > 120 ? '...' : ''}`);\n }\n}\n\nexport function outputScopesJson(scopes: FeatureScope[]): void {\n console.log(JSON.stringify({ scopes, total: scopes.length }, null, 2));\n}\n\nexport function outputScopesPretty(scopes: FeatureScope[]): void {\n if (scopes.length === 0) {\n console.log(chalk.gray('No scopes found.'));\n return;\n }\n console.log(chalk.bold(`\\nScopes (${scopes.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const s of scopes) {\n outputScopePretty(s);\n }\n console.log();\n}\n\n// ─── Goal (objective) output ───────────────────────────────\n//\n// An objective is a `Goal` with an INTEGER id; its key results are cuid-keyed\n// `KeyResult` rows. Both are printed here, kept apart on purpose — the tRPC\n// router mounted at `okr` is the key-result router, and conflating the two is\n// the mistake this whole surface exists to stop people repeating.\n\nfunction getGoalStatusColor(status: string): 'gray' | 'blue' | 'yellow' | 'green' | 'red' {\n switch (status) {\n case 'planned': return 'blue';\n case 'active': return 'yellow';\n case 'completed': return 'green';\n case 'archived': return 'gray';\n case 'on-hold': return 'red';\n default: return 'gray';\n }\n}\n\nfunction getKeyResultStatusColor(status: string): 'gray' | 'blue' | 'yellow' | 'green' | 'red' {\n switch (status) {\n case 'not-started': return 'gray';\n case 'on-track': return 'green';\n case 'at-risk': return 'yellow';\n case 'off-track': return 'red';\n case 'achieved': return 'green';\n default: return 'gray';\n }\n}\n\n/** Percent of the start → target span covered, clamped to 0–100. */\nfunction keyResultProgress(kr: KeyResult): number {\n const range = kr.targetValue - kr.startValue;\n if (range <= 0) return 0;\n return Math.max(\n 0,\n Math.min(100, Math.round(((kr.currentValue - kr.startValue) / range) * 100)),\n );\n}\n\nfunction transformGoal(goal: Goal): Record<string, unknown> {\n return {\n id: goal.id,\n title: goal.title,\n description: goal.description,\n status: goal.status,\n period: goal.period,\n health: goal.healthOverride ?? goal.health,\n // Effective progress: manual override, else the key-result mean, else null\n // for \"no signal\". Undefined (rather than null) means the server predates\n // the field — report null rather than inventing a 0.\n progress: goal.resolvedProgress ?? null,\n isProgressManual: goal.isProgressManual ?? false,\n dueDate: goal.dueDate ? new Date(goal.dueDate).toISOString() : null,\n workspaceId: goal.workspaceId,\n workspace: goal.workspace\n ? { id: goal.workspace.id, slug: goal.workspace.slug, name: goal.workspace.name }\n : null,\n parentGoalId: goal.parentGoalId,\n driUserId: goal.driUserId,\n lifeDomain: goal.lifeDomain ? { id: goal.lifeDomain.id, title: goal.lifeDomain.title } : null,\n // THE JOIN: actions carry a projectId and goals carry projects, so inverting\n // this map is what ties a day's work back to an objective. Never elided.\n projects:\n goal.projects?.map((p) => ({ id: p.id, name: p.name, slug: p.slug ?? null })) ?? [],\n childGoals: goal.childGoals?.map((c) => ({ id: c.id, title: c.title, status: c.status })) ?? [],\n keyResultCount: goal._count?.keyResults ?? goal.keyResults?.length ?? null,\n createdAt: goal.createdAt ? new Date(goal.createdAt).toISOString() : null,\n updatedAt: goal.updatedAt ? new Date(goal.updatedAt).toISOString() : null,\n };\n}\n\nexport function outputGoalJson(goal: Goal): void {\n console.log(JSON.stringify(transformGoal(goal), null, 2));\n}\n\nexport function outputGoalPretty(goal: Goal): void {\n console.log(chalk.gray('─'.repeat(50)));\n const badge = chalk[getGoalStatusColor(goal.status)](`[${goal.status}]`);\n console.log(`\\n${badge} ${chalk.bold(goal.title)} ${chalk.gray(`#${goal.id}`)}`);\n if (goal.period) console.log(` ${chalk.gray('Period:')} ${goal.period}`);\n const health = goal.healthOverride ?? goal.health;\n if (health) console.log(` ${chalk.gray('Health:')} ${health}`);\n if (goal.description) {\n console.log(` ${chalk.gray('Description:')} ${goal.description.substring(0, 200)}${goal.description.length > 200 ? '...' : ''}`);\n }\n if (goal.parentGoal) {\n console.log(` ${chalk.gray('Parent:')} ${goal.parentGoal.title} ${chalk.gray(`#${goal.parentGoal.id}`)}`);\n }\n if (goal.projects?.length) {\n console.log(` ${chalk.cyan('Projects:')} ${goal.projects.map((p) => p.name).join(', ')}`);\n }\n if (goal.childGoals?.length) {\n console.log(` ${chalk.cyan('Sub-goals:')} ${goal.childGoals.length}`);\n }\n console.log();\n}\n\nexport function outputGoalsJson(goals: Goal[]): void {\n console.log(JSON.stringify({\n goals: goals.map(transformGoal),\n total: goals.length,\n }, null, 2));\n}\n\nexport function outputGoalsPretty(goals: Goal[]): void {\n if (goals.length === 0) {\n console.log(chalk.gray('No goals found.'));\n return;\n }\n console.log(chalk.bold(`\\nGoals (${goals.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const g of goals) {\n const badge = chalk[getGoalStatusColor(g.status)](`[${g.status}]`);\n const period = g.period ? chalk.gray(` ${g.period}`) : '';\n const krs = g._count?.keyResults ? chalk.gray(` — ${g._count.keyResults} KRs`) : '';\n console.log(` ${badge}${period} ${chalk.bold(g.title)}${krs}`);\n console.log(chalk.gray(` ID: ${g.id}`));\n }\n console.log();\n}\n\nfunction transformGoalTree(node: GoalTreeNode): Record<string, unknown> {\n return {\n ...transformGoal(node),\n keyResults: node.keyResults?.map((kr) => ({\n id: kr.id,\n status: kr.status,\n currentValue: kr.currentValue,\n targetValue: kr.targetValue,\n })) ?? [],\n children: (node.childGoals as GoalTreeNode[] | undefined)?.map(transformGoalTree) ?? [],\n };\n}\n\nexport function outputGoalTreeJson(nodes: GoalTreeNode[]): void {\n console.log(JSON.stringify({\n goals: nodes.map(transformGoalTree),\n total: nodes.length,\n }, null, 2));\n}\n\nexport function outputGoalTreePretty(nodes: GoalTreeNode[]): void {\n if (nodes.length === 0) {\n console.log(chalk.gray('No goals found.'));\n return;\n }\n console.log(chalk.bold('\\nGoal tree'));\n console.log(chalk.gray('─'.repeat(50)));\n // The annual → quarterly cascade is the thing people come to a tree for, so\n // indent by depth rather than flattening.\n const walk = (node: GoalTreeNode, depth: number): void => {\n const pad = ' '.repeat(depth + 1);\n const badge = chalk[getGoalStatusColor(node.status)](`[${node.status}]`);\n const period = node.period ? chalk.gray(` ${node.period}`) : '';\n const krs = node.keyResults?.length ? chalk.gray(` — ${node.keyResults.length} KRs`) : '';\n console.log(`${pad}${depth > 0 ? '└ ' : ''}${badge}${period} ${chalk.bold(node.title)} ${chalk.gray(`#${node.id}`)}${krs}`);\n for (const child of (node.childGoals ?? []) as GoalTreeNode[]) {\n walk(child, depth + 1);\n }\n };\n for (const node of nodes) walk(node, 0);\n console.log();\n}\n\nexport function outputGoalPeriodsJson(periods: GoalPeriod[]): void {\n console.log(JSON.stringify({ periods, total: periods.length }, null, 2));\n}\n\nexport function outputGoalPeriodsPretty(periods: GoalPeriod[]): void {\n console.log(chalk.bold(`\\nPeriods (${periods.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const p of periods) {\n console.log(` ${chalk.bold(p.value)} ${chalk.gray(p.label)}`);\n }\n console.log();\n}\n\nexport function outputGoalStatsJson(stats: GoalStats): void {\n console.log(JSON.stringify({\n ...stats,\n periodEndDate: stats.periodEndDate ? new Date(stats.periodEndDate).toISOString() : null,\n }, null, 2));\n}\n\nexport function outputGoalStatsPretty(stats: GoalStats): void {\n console.log(chalk.bold('\\nOKR stats'));\n console.log(chalk.gray('─'.repeat(50)));\n console.log(` ${chalk.gray('Objectives:')} ${stats.totalObjectives}`);\n console.log(` ${chalk.gray('Key results:')} ${stats.totalKeyResults} (${stats.completedKeyResults} achieved)`);\n console.log(\n ` ${chalk.gray('Breakdown:')} ` +\n `${chalk.green(`${stats.statusBreakdown.onTrack} on-track`)}, ` +\n `${chalk.yellow(`${stats.statusBreakdown.atRisk} at-risk`)}, ` +\n `${chalk.red(`${stats.statusBreakdown.offTrack} off-track`)}, ` +\n `${chalk.green(`${stats.statusBreakdown.achieved} achieved`)}`,\n );\n console.log(` ${chalk.gray('Avg progress:')} ${stats.averageProgress}%`);\n if (stats.averageConfidence != null) {\n console.log(` ${chalk.gray('Avg confidence:')} ${stats.averageConfidence}%`);\n }\n if (stats.periodEndDate) {\n console.log(` ${chalk.gray('Period ends:')} ${new Date(stats.periodEndDate).toISOString().slice(0, 10)}`);\n }\n console.log();\n}\n\n// ─── Key result output ─────────────────────────────────────\n\n/**\n * Most recent check-in timestamp. Not a column — derived from the `checkIns`\n * the read already includes, because \"this key result has not been touched in\n * five weeks\" is a finding, and every consumer would otherwise recompute it.\n * Null when the read carried no check-ins, or the key result has never had one.\n */\nfunction lastCheckInAt(kr: KeyResult): string | null {\n if (!kr.checkIns?.length) return null;\n const latest = kr.checkIns.reduce((newest, c) =>\n new Date(c.createdAt) > new Date(newest.createdAt) ? c : newest,\n );\n return new Date(latest.createdAt).toISOString();\n}\n\nfunction transformKeyResult(kr: KeyResult): Record<string, unknown> {\n return {\n id: kr.id,\n goalId: kr.goalId,\n goal: kr.goal ? { id: kr.goal.id, title: kr.goal.title } : null,\n title: kr.title,\n description: kr.description,\n status: kr.statusOverride ?? kr.status,\n statusOverride: kr.statusOverride ?? null,\n startValue: kr.startValue,\n currentValue: kr.currentValue,\n targetValue: kr.targetValue,\n progress: keyResultProgress(kr),\n unit: kr.unit,\n unitLabel: kr.unitLabel ?? null,\n period: kr.period,\n periodEnd: kr.periodEnd ? new Date(kr.periodEnd).toISOString() : null,\n lastCheckInAt: lastCheckInAt(kr),\n confidence: kr.confidence ?? null,\n driUserId: kr.driUserId,\n workspaceId: kr.workspaceId,\n projects: kr.projects?.map((l) => ({ id: l.projectId, name: l.project?.name ?? null })) ?? [],\n features: kr.features?.map((l) => ({ id: l.featureId, name: l.feature?.name ?? null })) ?? [],\n createdAt: kr.createdAt ? new Date(kr.createdAt).toISOString() : null,\n updatedAt: kr.updatedAt ? new Date(kr.updatedAt).toISOString() : null,\n };\n}\n\nexport function outputKeyResultJson(kr: KeyResult): void {\n console.log(JSON.stringify(transformKeyResult(kr), null, 2));\n}\n\nexport function outputKeyResultPretty(kr: KeyResult): void {\n const status = kr.statusOverride ?? kr.status;\n const badge = chalk[getKeyResultStatusColor(status)](`[${status}]`);\n console.log(` ${badge} ${chalk.bold(kr.title)}`);\n console.log(\n chalk.gray(\n ` ${kr.currentValue}/${kr.targetValue} ${kr.unit} (${keyResultProgress(kr)}%)` +\n `${kr.period ? ` · ${kr.period}` : ''} · objective #${kr.goalId}`,\n ),\n );\n console.log(chalk.gray(` ID: ${kr.id}`));\n if (kr.projects?.length) {\n console.log(chalk.gray(` Projects: ${kr.projects.map((l) => l.project?.name ?? l.projectId).join(', ')}`));\n }\n if (kr.features?.length) {\n console.log(chalk.gray(` Features: ${kr.features.map((l) => l.feature?.name ?? l.featureId).join(', ')}`));\n }\n}\n\nexport function outputKeyResultsJson(keyResults: KeyResult[]): void {\n console.log(JSON.stringify({\n keyResults: keyResults.map(transformKeyResult),\n total: keyResults.length,\n }, null, 2));\n}\n\nexport function outputKeyResultsPretty(keyResults: KeyResult[]): void {\n if (keyResults.length === 0) {\n console.log(chalk.gray('No key results found.'));\n return;\n }\n console.log(chalk.bold(`\\nKey results (${keyResults.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const kr of keyResults) {\n outputKeyResultPretty(kr);\n }\n console.log();\n}\n\nexport function outputCheckInJson(checkIn: KeyResultCheckIn): void {\n console.log(JSON.stringify({\n id: checkIn.id,\n keyResultId: checkIn.keyResultId,\n previousValue: checkIn.previousValue,\n newValue: checkIn.newValue,\n notes: checkIn.notes,\n createdAt: checkIn.createdAt ? new Date(checkIn.createdAt).toISOString() : null,\n }, null, 2));\n}\n\nexport function outputCheckInPretty(checkIn: KeyResultCheckIn): void {\n console.log(` ${chalk.gray('Value:')} ${checkIn.previousValue} → ${chalk.bold(String(checkIn.newValue))}`);\n if (checkIn.notes) console.log(` ${chalk.gray('Note:')} ${checkIn.notes}`);\n console.log(chalk.gray(` Check-in ID: ${checkIn.id}`));\n console.log();\n}\n\n// ─── OKR (objective + nested key results) output ───────────\n\nfunction transformObjective(objective: ObjectiveWithKeyResults): Record<string, unknown> {\n return {\n id: objective.id,\n title: objective.title,\n description: objective.description,\n status: objective.status,\n period: objective.period,\n health: objective.health,\n progress: objective.progress,\n statusCounts: objective.statusCounts,\n workspaceId: objective.workspaceId,\n workspace: objective.workspace\n ? {\n id: objective.workspace.id,\n slug: objective.workspace.slug,\n name: objective.workspace.name,\n }\n : null,\n parentGoalId: objective.parentGoalId,\n keyResults: objective.keyResults.map(transformKeyResult),\n };\n}\n\nexport function outputObjectivesJson(objectives: ObjectiveWithKeyResults[]): void {\n const totalKeyResults = objectives.reduce((n, o) => n + o.keyResults.length, 0);\n console.log(JSON.stringify({\n objectives: objectives.map(transformObjective),\n total: objectives.length,\n totalKeyResults,\n }, null, 2));\n}\n\nexport function outputObjectivesPretty(objectives: ObjectiveWithKeyResults[]): void {\n if (objectives.length === 0) {\n console.log(chalk.gray('No OKRs found.'));\n return;\n }\n const totalKeyResults = objectives.reduce((n, o) => n + o.keyResults.length, 0);\n console.log(\n chalk.bold(`\\nOKRs (${objectives.length} objectives, ${totalKeyResults} key results)`),\n );\n console.log(chalk.gray('─'.repeat(50)));\n for (const o of objectives) {\n const badge = chalk[getGoalStatusColor(o.status)](`[${o.status}]`);\n const period = o.period ? chalk.gray(` ${o.period}`) : '';\n console.log(\n `\\n ${badge}${period} ${chalk.bold(o.title)} ${chalk.gray(`#${o.id}`)} ${chalk.gray(`${o.progress}%`)}`,\n );\n if (o.keyResults.length === 0) {\n console.log(chalk.gray(' (no key results)'));\n continue;\n }\n for (const kr of o.keyResults) {\n const krStatus = kr.statusOverride ?? kr.status;\n const krBadge = chalk[getKeyResultStatusColor(krStatus)](`[${krStatus}]`);\n console.log(` ${krBadge} ${kr.title} ${chalk.gray(`${kr.currentValue}/${kr.targetValue} ${kr.unit}`)}`);\n console.log(chalk.gray(` ID: ${kr.id}`));\n }\n }\n console.log();\n}\n\n// ─── Project detail output ─────────────────────────────────\n\nexport function outputProjectJson(project: ProjectDetail): void {\n console.log(JSON.stringify({\n ...transformProject(project),\n // The detail read has no `workspace` relation to expand, unlike the list\n // read — so `transformProject` alone would emit `workspace: null` and no id\n // at all, which reads as \"personal project\" rather than \"not fetched\".\n workspaceId: project.workspaceId,\n slug: project.slug ?? null,\n productId: project.productId ?? null,\n driId: project.driId ?? null,\n dri: project.dri ?? null,\n team: project.team ?? null,\n goals: project.goals ?? [],\n keyResults: project.keyResults?.map((k) => ({\n id: k.keyResultId,\n title: k.keyResult?.title ?? null,\n goal: k.keyResult?.goal ?? null,\n })) ?? [],\n outcomes: project.outcomes ?? [],\n actionCount: project.actions?.length ?? null,\n createdAt: project.createdAt ? new Date(project.createdAt).toISOString() : null,\n }, null, 2));\n}\n\nexport function outputProjectPretty(project: ProjectDetail): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk.bold(project.name)}`);\n console.log(chalk.gray(` ID: ${project.id}`));\n if (project.status) console.log(` ${chalk.cyan('Status:')} ${project.status}`);\n if (project.priority) console.log(` ${chalk.magenta('Priority:')} ${project.priority}`);\n if (project.workspace) {\n console.log(` ${chalk.yellow('Workspace:')} ${project.workspace.name} (${project.workspace.slug})`);\n }\n if (project.description) {\n console.log(` ${chalk.gray('Description:')} ${project.description.substring(0, 200)}${project.description.length > 200 ? '...' : ''}`);\n }\n if (project.dri) {\n console.log(` ${chalk.magenta('DRI:')} ${project.dri.name ?? project.dri.email ?? project.dri.id}`);\n }\n if (project.goals?.length) {\n console.log(` ${chalk.cyan('Objectives:')}`);\n for (const g of project.goals) {\n console.log(` - #${g.id} ${g.title}`);\n }\n }\n if (project.keyResults?.length) {\n console.log(` ${chalk.cyan('Key results:')}`);\n for (const k of project.keyResults) {\n const objective = k.keyResult?.goal ? chalk.gray(` (objective #${k.keyResult.goal.id})`) : '';\n console.log(` - ${k.keyResult?.title ?? k.keyResultId} ${chalk.gray(`[${k.keyResultId}]`)}${objective}`);\n }\n }\n if (project.actions?.length) {\n console.log(` ${chalk.cyan('Actions:')} ${project.actions.length}`);\n }\n console.log();\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport {\n shouldUseJson,\n outputContactJson,\n outputContactPretty,\n outputContactsJson,\n outputContactsPretty,\n outputInteractionJson,\n outputInteractionPretty,\n} from '../utils/output.js';\nimport type { InteractionType, InteractionDirection } from 'exponential-sdk';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n workspace?: string;\n}\n\nconst VALID_INTERACTION_TYPES: InteractionType[] = [\n 'EMAIL', 'TELEGRAM', 'PHONE_CALL', 'MEETING', 'NOTE', 'LINKEDIN', 'OTHER',\n];\n\nconst VALID_INTERACTION_DIRECTIONS: InteractionDirection[] = ['INBOUND', 'OUTBOUND'];\n\nexport function createContactsCommand(): Command {\n const contacts = new Command('contacts')\n .description('Manage CRM contacts');\n\n contacts\n .command('list')\n .description('List contacts')\n .requiredOption('--workspace <id>', 'Workspace ID')\n .option('--search <query>', 'Search by name or email')\n .option('--tags <tags>', 'Filter by tags (comma-separated)')\n .option('--organization <id>', 'Filter by organization ID')\n .option('--limit <n>', 'Max results to return', parseInt)\n .option('--cursor <cursor>', 'Pagination cursor')\n .action(async (options: {\n workspace: string;\n search?: string;\n tags?: string;\n organization?: string;\n limit?: number;\n cursor?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const result = await client.contacts.list({\n workspaceId: options.workspace,\n search: options.search,\n tags: options.tags?.split(',').map(t => t.trim()),\n organizationId: options.organization,\n limit: options.limit,\n cursor: options.cursor,\n });\n\n if (useJson) {\n outputContactsJson(result.contacts, result.nextCursor);\n } else {\n outputContactsPretty(result.contacts);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n contacts\n .command('get')\n .description('Get a contact by ID')\n .argument('<id>', 'Contact ID')\n .option('--interactions', 'Include interaction history')\n .action(async (id: string, options: { interactions?: boolean }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const contact = await client.contacts.get(id, {\n includeInteractions: options.interactions,\n });\n\n if (useJson) {\n outputContactJson(contact);\n } else {\n outputContactPretty(contact);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n contacts\n .command('create')\n .description('Create a new contact')\n .requiredOption('--workspace <id>', 'Workspace ID')\n .option('--first-name <name>', 'First name')\n .option('--last-name <name>', 'Last name')\n .option('--email <email>', 'Email address')\n .option('--phone <phone>', 'Phone number')\n .option('--linkedin <url>', 'LinkedIn URL')\n .option('--telegram <handle>', 'Telegram handle')\n .option('--twitter <handle>', 'Twitter/X handle')\n .option('--github <handle>', 'GitHub username')\n .option('--bluesky <handle>', 'Bluesky handle')\n .option('--about <text>', 'About / bio')\n .option('--profile-type <type>', 'Profile type')\n .option('--skills <skills>', 'Skills (comma-separated)')\n .option('--tags <tags>', 'Tags (comma-separated)')\n .option('--organization <id>', 'Organization ID')\n .option('--organization-name <name>', 'Organization name (find-or-create; ignored if --organization is set)')\n .action(async (options: {\n workspace: string;\n firstName?: string;\n lastName?: string;\n email?: string;\n phone?: string;\n linkedin?: string;\n telegram?: string;\n twitter?: string;\n github?: string;\n bluesky?: string;\n about?: string;\n profileType?: string;\n skills?: string;\n tags?: string;\n organization?: string;\n organizationName?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const contact = await client.contacts.create({\n workspaceId: options.workspace,\n firstName: options.firstName,\n lastName: options.lastName,\n email: options.email,\n phone: options.phone,\n linkedIn: options.linkedin,\n telegram: options.telegram,\n twitter: options.twitter,\n github: options.github,\n bluesky: options.bluesky,\n about: options.about,\n profileType: options.profileType,\n skills: options.skills?.split(',').map(s => s.trim()),\n tags: options.tags?.split(',').map(t => t.trim()),\n organizationId: options.organization,\n organizationName: options.organizationName,\n });\n\n if (useJson) {\n outputContactJson(contact);\n } else {\n console.log('\\n✓ Contact created successfully');\n outputContactPretty(contact);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n contacts\n .command('update')\n .description('Update an existing contact')\n .requiredOption('--id <id>', 'Contact ID')\n .option('--first-name <name>', 'First name')\n .option('--last-name <name>', 'Last name')\n .option('--email <email>', 'Email (use \"null\" to clear)')\n .option('--phone <phone>', 'Phone (use \"null\" to clear)')\n .option('--linkedin <url>', 'LinkedIn URL (use \"null\" to clear)')\n .option('--telegram <handle>', 'Telegram handle (use \"null\" to clear)')\n .option('--twitter <handle>', 'Twitter/X handle (use \"null\" to clear)')\n .option('--github <handle>', 'GitHub username (use \"null\" to clear)')\n .option('--bluesky <handle>', 'Bluesky handle (use \"null\" to clear)')\n .option('--about <text>', 'About / bio')\n .option('--profile-type <type>', 'Profile type')\n .option('--skills <skills>', 'Skills (comma-separated)')\n .option('--tags <tags>', 'Tags (comma-separated)')\n .option('--organization <id>', 'Organization ID (use \"null\" to clear)')\n .option('--organization-name <name>', 'Organization name (find-or-create; ignored if --organization is set)')\n .action(async (options: {\n id: string;\n firstName?: string;\n lastName?: string;\n email?: string;\n phone?: string;\n linkedin?: string;\n telegram?: string;\n twitter?: string;\n github?: string;\n bluesky?: string;\n about?: string;\n profileType?: string;\n skills?: string;\n tags?: string;\n organization?: string;\n organizationName?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n const nullable = (v?: string) => v === 'null' ? null : v;\n\n try {\n const client = getClient();\n const contact = await client.contacts.update({\n id: options.id,\n firstName: options.firstName,\n lastName: options.lastName,\n email: nullable(options.email),\n phone: nullable(options.phone),\n linkedIn: nullable(options.linkedin),\n telegram: nullable(options.telegram),\n twitter: nullable(options.twitter),\n github: nullable(options.github),\n bluesky: nullable(options.bluesky),\n about: options.about,\n profileType: options.profileType,\n skills: options.skills?.split(',').map(s => s.trim()),\n tags: options.tags?.split(',').map(t => t.trim()),\n organizationId: nullable(options.organization),\n organizationName: options.organizationName,\n });\n\n if (useJson) {\n outputContactJson(contact);\n } else {\n console.log('\\n✓ Contact updated successfully');\n outputContactPretty(contact);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n contacts\n .command('delete')\n .description('Delete a contact')\n .argument('<id>', 'Contact ID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n await client.contacts.delete(id);\n\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id }, null, 2));\n } else {\n console.log(`\\n✓ Contact ${id} deleted`);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n contacts\n .command('add-interaction')\n .description('Add an interaction to a contact')\n .requiredOption('--contact <id>', 'Contact ID')\n .requiredOption('--type <type>', `Interaction type (${VALID_INTERACTION_TYPES.join(', ')})`)\n .requiredOption('--direction <dir>', `Direction (${VALID_INTERACTION_DIRECTIONS.join(', ')})`)\n .option('--subject <text>', 'Subject line')\n .option('--notes <text>', 'Notes')\n .action(async (options: {\n contact: string;\n type: string;\n direction: string;\n subject?: string;\n notes?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n if (!VALID_INTERACTION_TYPES.includes(options.type as InteractionType)) {\n throw new Error(`Invalid interaction type \"${options.type}\". Valid: ${VALID_INTERACTION_TYPES.join(', ')}`);\n }\n if (!VALID_INTERACTION_DIRECTIONS.includes(options.direction as InteractionDirection)) {\n throw new Error(`Invalid direction \"${options.direction}\". Valid: ${VALID_INTERACTION_DIRECTIONS.join(', ')}`);\n }\n\n const client = getClient();\n const interaction = await client.contacts.addInteraction({\n contactId: options.contact,\n type: options.type as InteractionType,\n direction: options.direction as InteractionDirection,\n subject: options.subject,\n notes: options.notes,\n });\n\n if (useJson) {\n outputInteractionJson(interaction);\n } else {\n console.log('\\n✓ Interaction added');\n outputInteractionPretty(interaction);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n contacts\n .command('enrich')\n .description('Queue a web-search enrichment job for an existing contact (runs regardless of the workspace auto-enrich setting)')\n .argument('<id>', 'Contact ID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const result = await client.contacts.enrich(id);\n\n if (useJson) {\n console.log(JSON.stringify(result, null, 2));\n } else if (result.enqueued) {\n console.log(`\\n✓ Enrichment queued for contact ${id} (job ${result.enrichmentId})`);\n } else if (result.reason === 'already-in-flight') {\n console.log(`\\n• Enrichment already in progress for contact ${id} (job ${result.enrichmentId})`);\n } else {\n console.log(`\\n• Not queued for contact ${id}${result.reason ? ` (${result.reason})` : ''}`);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return contacts;\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport {\n shouldUseJson,\n outputDealJson,\n outputDealPretty,\n outputDealsJson,\n outputDealsPretty,\n outputPipelineJson,\n outputPipelinePretty,\n outputStagesJson,\n outputStagesPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n workspace?: string;\n}\n\nexport function createDealsCommand(): Command {\n const deals = new Command('deals')\n .description('Manage pipeline deals');\n\n deals\n .command('pipeline')\n .description('Get pipeline overview with stages')\n .requiredOption('--workspace <id>', 'Workspace ID')\n .action(async (options: { workspace: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const pipeline = await client.pipelines.get(options.workspace);\n\n if (!pipeline) {\n if (useJson) {\n console.log(JSON.stringify({ pipeline: null }, null, 2));\n } else {\n console.log('No pipeline found for this workspace. One will be created when you add your first deal.');\n }\n return;\n }\n\n if (useJson) {\n outputPipelineJson(pipeline);\n } else {\n outputPipelinePretty(pipeline);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n deals\n .command('stages')\n .description('List pipeline stages')\n .requiredOption('--workspace <id>', 'Workspace ID')\n .action(async (options: { workspace: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const stages = await client.pipelines.getStages(options.workspace);\n\n if (useJson) {\n outputStagesJson(stages);\n } else {\n outputStagesPretty(stages);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n deals\n .command('list')\n .description('List all deals')\n .requiredOption('--workspace <id>', 'Workspace ID')\n .action(async (options: { workspace: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const dealsList = await client.pipelines.listDeals(options.workspace);\n\n if (useJson) {\n outputDealsJson(dealsList);\n } else {\n outputDealsPretty(dealsList);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n deals\n .command('get')\n .description('Get a deal by ID')\n .argument('<id>', 'Deal ID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const deal = await client.pipelines.getDeal(id);\n\n if (useJson) {\n outputDealJson(deal);\n } else {\n outputDealPretty(deal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n deals\n .command('create')\n .description('Create a new deal')\n .requiredOption('--workspace <id>', 'Workspace ID')\n .requiredOption('--stage <id>', 'Pipeline stage ID')\n .requiredOption('--title <title>', 'Deal title')\n .option('--description <text>', 'Deal description')\n .option('--value <amount>', 'Deal value', parseFloat)\n .option('--currency <code>', 'Currency code (default: USD)')\n .option('--probability <pct>', 'Win probability (0-100)', parseInt)\n .option('--close-date <date>', 'Expected close date (YYYY-MM-DD)')\n .option('--contact <id>', 'Contact ID')\n .option('--organization <id>', 'Organization ID')\n .option('--assigned-to <id>', 'Assigned user ID')\n .action(async (options: {\n workspace: string;\n stage: string;\n title: string;\n description?: string;\n value?: number;\n currency?: string;\n probability?: number;\n closeDate?: string;\n contact?: string;\n organization?: string;\n assignedTo?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n let expectedCloseDate: Date | undefined;\n if (options.closeDate) {\n expectedCloseDate = new Date(options.closeDate);\n if (isNaN(expectedCloseDate.getTime())) {\n throw new Error('Invalid close date format. Use YYYY-MM-DD');\n }\n }\n\n const client = getClient();\n const deal = await client.pipelines.createDeal({\n workspaceId: options.workspace,\n stageId: options.stage,\n title: options.title,\n description: options.description,\n value: options.value,\n currency: options.currency,\n probability: options.probability,\n expectedCloseDate,\n contactId: options.contact,\n organizationId: options.organization,\n assignedToId: options.assignedTo,\n });\n\n if (useJson) {\n outputDealJson(deal);\n } else {\n console.log('\\n✓ Deal created successfully');\n outputDealPretty(deal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n deals\n .command('update')\n .description('Update an existing deal')\n .requiredOption('--id <id>', 'Deal ID')\n .option('--title <title>', 'Deal title')\n .option('--description <text>', 'Description (use \"null\" to clear)')\n .option('--value <amount>', 'Deal value (use \"null\" to clear)')\n .option('--currency <code>', 'Currency code')\n .option('--probability <pct>', 'Win probability (use \"null\" to clear)')\n .option('--close-date <date>', 'Expected close date (YYYY-MM-DD or \"null\" to clear)')\n .option('--contact <id>', 'Contact ID (use \"null\" to clear)')\n .option('--organization <id>', 'Organization ID (use \"null\" to clear)')\n .option('--assigned-to <id>', 'Assigned user ID (use \"null\" to clear)')\n .action(async (options: {\n id: string;\n title?: string;\n description?: string;\n value?: string;\n currency?: string;\n probability?: string;\n closeDate?: string;\n contact?: string;\n organization?: string;\n assignedTo?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n const nullable = <T>(v: string | undefined, parse?: (s: string) => T): T | null | undefined => {\n if (v === undefined) return undefined;\n if (v === 'null') return null;\n return parse ? parse(v) : v as unknown as T;\n };\n\n try {\n let expectedCloseDate: Date | null | undefined;\n if (options.closeDate === 'null') {\n expectedCloseDate = null;\n } else if (options.closeDate) {\n expectedCloseDate = new Date(options.closeDate);\n if (isNaN(expectedCloseDate.getTime())) {\n throw new Error('Invalid close date format. Use YYYY-MM-DD');\n }\n }\n\n const client = getClient();\n const deal = await client.pipelines.updateDeal({\n id: options.id,\n title: options.title,\n description: nullable(options.description),\n value: nullable(options.value, parseFloat),\n currency: options.currency,\n probability: nullable(options.probability, parseInt),\n expectedCloseDate,\n contactId: nullable(options.contact),\n organizationId: nullable(options.organization),\n assignedToId: nullable(options.assignedTo),\n });\n\n if (useJson) {\n outputDealJson(deal);\n } else {\n console.log('\\n✓ Deal updated successfully');\n outputDealPretty(deal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n deals\n .command('move')\n .description('Move a deal to a different stage')\n .requiredOption('--id <id>', 'Deal ID')\n .requiredOption('--stage <id>', 'Target stage ID')\n .option('--order <n>', 'Position within stage', parseInt, 0)\n .action(async (options: { id: string; stage: string; order: number }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const deal = await client.pipelines.moveDeal({\n id: options.id,\n stageId: options.stage,\n stageOrder: options.order,\n });\n\n if (useJson) {\n outputDealJson(deal);\n } else {\n console.log('\\n✓ Deal moved successfully');\n outputDealPretty(deal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n deals\n .command('delete')\n .description('Delete a deal')\n .argument('<id>', 'Deal ID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n await client.pipelines.deleteDeal(id);\n\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id }, null, 2));\n } else {\n console.log(`\\n✓ Deal ${id} deleted`);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return deals;\n}\n","import { Command } from 'commander';\nimport type { EpicPriority, EpicStatus } from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n shouldUseJson,\n outputEpicJson,\n outputEpicPretty,\n outputEpicsJson,\n outputEpicsPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nconst EPIC_STATUSES: EpicStatus[] = ['OPEN', 'IN_PROGRESS', 'DONE', 'CANCELLED'];\nconst EPIC_PRIORITIES: EpicPriority[] = ['HIGH', 'MEDIUM', 'LOW', 'NONE'];\n\nfunction validateEpicStatus(value: string | undefined): EpicStatus | undefined {\n if (!value) return undefined;\n if (!(EPIC_STATUSES as string[]).includes(value)) {\n throw new Error(`Invalid epic status \"${value}\". Valid: ${EPIC_STATUSES.join(', ')}`);\n }\n return value as EpicStatus;\n}\n\nfunction validateEpicPriority(value: string | undefined): EpicPriority | undefined {\n if (!value) return undefined;\n if (!(EPIC_PRIORITIES as string[]).includes(value)) {\n throw new Error(\n `Invalid epic priority \"${value}\". Valid: ${EPIC_PRIORITIES.join(', ')}`,\n );\n }\n return value as EpicPriority;\n}\n\nfunction parseDate(value: string | undefined): Date | undefined {\n if (!value) return undefined;\n const d = new Date(value);\n if (isNaN(d.getTime())) {\n throw new Error(`Invalid date \"${value}\". Use YYYY-MM-DD`);\n }\n return d;\n}\n\nexport function createEpicsCommand(): Command {\n const epics = new Command('epics').description(\n 'Manage epics. Epics are workspace-scoped and group actions and tickets across products.',\n );\n\n epics\n .command('list')\n .description('List epics in a workspace')\n .option('--workspace <slug|id>', 'Workspace slug or CUID')\n .option('--status <status>', `Filter by status: ${EPIC_STATUSES.join(', ')}`)\n .action(\n async (options: { workspace?: string; status?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateEpicStatus(options.status);\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const list = await client.epics.list({ workspaceId, status });\n if (useJson) outputEpicsJson(list);\n else outputEpicsPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n epics\n .command('get <id>')\n .description('Get an epic by CUID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const epic = await client.epics.get(id);\n if (useJson) outputEpicJson(epic);\n else outputEpicPretty(epic);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n epics\n .command('create')\n .description('Create a new epic in a workspace')\n .requiredOption('-n, --name <name>', 'Epic name')\n .option('-d, --description <text>', 'Description')\n .option('--priority <priority>', `Priority: ${EPIC_PRIORITIES.join(', ')}`)\n .option('--start <date>', 'Start date (YYYY-MM-DD)')\n .option('--target <date>', 'Target date (YYYY-MM-DD)')\n .option('--workspace <slug|id>', 'Workspace slug or CUID')\n .action(\n async (\n options: {\n name: string;\n description?: string;\n priority?: string;\n start?: string;\n target?: string;\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const priority = validateEpicPriority(options.priority);\n const startDate = parseDate(options.start);\n const targetDate = parseDate(options.target);\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const epic = await client.epics.create({\n workspaceId,\n name: options.name,\n description: options.description,\n priority,\n startDate,\n targetDate,\n });\n if (useJson) outputEpicJson(epic);\n else {\n console.log('\\n✓ Epic created');\n outputEpicPretty(epic);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n epics\n .command('update')\n .description('Update an existing epic')\n .requiredOption('--id <id>', 'Epic CUID')\n .option('-n, --name <name>', 'New name')\n .option('-d, --description <text>', 'New description (or \"null\" to clear)')\n .option('--status <status>', `Status: ${EPIC_STATUSES.join(', ')}`)\n .option('--priority <priority>', `Priority: ${EPIC_PRIORITIES.join(', ')}`)\n .option('--start <date>', 'Start date (YYYY-MM-DD or \"null\")')\n .option('--target <date>', 'Target date (YYYY-MM-DD or \"null\")')\n .action(\n async (\n options: {\n id: string;\n name?: string;\n description?: string;\n status?: string;\n priority?: string;\n start?: string;\n target?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const parseNullableDate = (v: string | undefined): Date | null | undefined => {\n if (v === undefined) return undefined;\n if (v === 'null') return null;\n const d = new Date(v);\n if (isNaN(d.getTime())) {\n throw new Error(`Invalid date \"${v}\". Use YYYY-MM-DD`);\n }\n return d;\n };\n const description = options.description === 'null' ? null : options.description;\n const status = validateEpicStatus(options.status);\n const priority = validateEpicPriority(options.priority);\n const client = getClient();\n const epic = await client.epics.update({\n id: options.id,\n name: options.name,\n description,\n status,\n priority,\n startDate: parseNullableDate(options.start),\n targetDate: parseNullableDate(options.target),\n });\n if (useJson) outputEpicJson(epic);\n else {\n console.log('\\n✓ Epic updated');\n outputEpicPretty(epic);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n return epics;\n}\n","import type { ExponentialClient, Workspace } from 'exponential-sdk';\nimport { getConfig } from '../config/index.js';\n\n/**\n * Resolve a workspace identifier the user typed at the CLI to a workspace ID.\n *\n * Accepts:\n * - a bare workspace CUID (returned as-is after a list lookup for safety)\n * - a workspace slug\n * - undefined → falls back to the configured default workspace\n *\n * Throws if nothing resolves so callers don't accidentally send a \"\" id.\n */\nexport async function resolveWorkspaceId(\n client: ExponentialClient,\n slugOrId: string | undefined,\n): Promise<string> {\n return (await resolveWorkspace(client, slugOrId)).id;\n}\n\n/**\n * Same resolution as {@link resolveWorkspaceId}, but returns the whole\n * workspace. Callers that need to label rows with a workspace name or slug —\n * anything cross-workspace — would otherwise pay a second lookup for data this\n * function already had in hand.\n */\nexport async function resolveWorkspace(\n client: ExponentialClient,\n slugOrId: string | undefined,\n): Promise<Workspace> {\n const config = getConfig();\n const candidate = slugOrId ?? config.defaultWorkspaceSlug ?? config.defaultWorkspaceId;\n\n if (!candidate) {\n throw new Error(\n 'No workspace specified and no default workspace set. Pass --workspace <slug> or run `exponential workspaces set-default <slug>`.',\n );\n }\n\n const workspaces = await client.workspaces.list();\n const byId = workspaces.find((w) => w.id === candidate);\n if (byId) return byId;\n const bySlug = workspaces.find((w) => w.slug === candidate);\n if (bySlug) return bySlug;\n\n const known = workspaces.map((w) => w.slug).join(', ');\n throw new Error(\n `Workspace \"${candidate}\" not found. Available: ${known || '(none)'}`,\n );\n}\n\n/**\n * Resolve a product identifier (slug or CUID) to a product ID.\n * `slugOrId` may also be a CUID — we try id lookup first when it looks\n * like one, then fall back to slug.\n */\nexport async function resolveProductId(\n client: ExponentialClient,\n workspaceId: string,\n slugOrId: string,\n): Promise<string> {\n const product = await client.products.resolve(workspaceId, slugOrId);\n return product.id;\n}\n\n","import { Command } from 'commander';\nimport type { FeatureStatus, Ticket } from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveProductId, resolveWorkspaceId } from '../utils/resolve.js';\nimport { createStoriesCommand } from './stories.js';\nimport { createScopesCommand } from './scopes.js';\nimport { createRequirementsCommand } from './requirements.js';\nimport { createAreasCommand } from './areas.js';\nimport { createFeatureCommentsCommand } from './featureComments.js';\nimport {\n shouldUseJson,\n outputFeaturesJson,\n outputFeaturesPretty,\n outputFeatureJson,\n outputFeaturePretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nconst FEATURE_STATUSES: FeatureStatus[] = [\n 'IDEA',\n 'DEFINED',\n 'IN_PROGRESS',\n 'SHIPPED',\n 'DEPRECATED',\n 'ARCHIVED',\n];\n\ninterface TicketSummary {\n id: string;\n shortId: string | null;\n number: number | null;\n title: string;\n}\n\nfunction summarizeTicket(ticket: Ticket): TicketSummary {\n return {\n id: ticket.id,\n shortId: ticket.shortId ?? null,\n number: ticket.number ?? null,\n title: ticket.title,\n };\n}\n\nfunction ticketLabel(ticket: Ticket): string {\n return ticket.shortId ?? (ticket.number != null ? `#${ticket.number}` : ticket.id);\n}\n\n/**\n * `--goal` takes an objective's integer id, or \"none\" to unlink. Objectives are\n * the only entity here keyed by an integer rather than a cuid.\n */\nfunction parseFeatureGoalId(value: string | undefined): number | null | undefined {\n if (value === undefined) return undefined;\n if (value === 'none') return null;\n const id = Number(value);\n if (!Number.isInteger(id)) {\n throw new Error(\n `--goal must be a whole number or \"none\", got \"${value}\". Find one with \\`exponential goals list\\`.`,\n );\n }\n return id;\n}\n\nfunction validateFeatureStatus(value: string | undefined): FeatureStatus | undefined {\n if (!value) return undefined;\n if (!(FEATURE_STATUSES as string[]).includes(value)) {\n throw new Error(\n `Invalid status \"${value}\". Valid: ${FEATURE_STATUSES.join(', ')}`,\n );\n }\n return value as FeatureStatus;\n}\n\nexport function createFeaturesCommand(): Command {\n const features = new Command('features').description(\n 'Manage features. A feature lives under a product and groups user stories, scopes, and tickets.',\n );\n\n features\n .command('list')\n .description('List features in a product')\n .requiredOption('--product <slug|id>', 'Product slug or CUID')\n .option('--workspace <slug|id>', 'Workspace (required when --product is a slug)')\n .option('--status <status>', `Filter by status: ${FEATURE_STATUSES.join(', ')}`)\n .action(\n async (\n options: { product: string; workspace?: string; status?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateFeatureStatus(options.status);\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const productId = await resolveProductId(\n client,\n workspaceId,\n options.product,\n );\n const list = await client.features.list({ productId, status });\n if (useJson) outputFeaturesJson(list);\n else outputFeaturesPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n features\n .command('get <id>')\n .description('Get a feature by CUID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const feature = await client.features.get(id);\n if (useJson) outputFeatureJson(feature);\n else outputFeaturePretty(feature);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n features\n .command('create')\n .description('Create a new feature in a product')\n .requiredOption('--product <slug|id>', 'Product slug or CUID')\n .requiredOption('-n, --name <name>', 'Feature name')\n .option('-d, --description <text>', 'Description (markdown supported)')\n .option('--vision <text>', 'Vision / target outcome')\n .option('--status <status>', `Status: ${FEATURE_STATUSES.join(', ')}`)\n .option('--priority <n>', 'Priority 0-4 (lower = higher)', parseInt)\n .option('--effort <n>', 'Effort estimate', parseFloat)\n .option('--area <id>', 'Area CUID (per-product bucket) to file the feature under')\n .option('--workspace <slug|id>', 'Workspace (required when --product is a slug)')\n .action(\n async (\n options: {\n product: string;\n name: string;\n description?: string;\n vision?: string;\n status?: string;\n priority?: number;\n effort?: number;\n area?: string;\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateFeatureStatus(options.status);\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const productId = await resolveProductId(\n client,\n workspaceId,\n options.product,\n );\n const feature = await client.features.create({\n productId,\n name: options.name,\n description: options.description,\n vision: options.vision,\n status,\n priority: options.priority,\n effort: options.effort,\n areaId: options.area,\n });\n if (useJson) outputFeatureJson(feature);\n else {\n console.log('\\n✓ Feature created');\n outputFeaturePretty(feature);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n features\n .command('update')\n .description('Update an existing feature')\n .requiredOption('--id <id>', 'Feature CUID')\n .option('-n, --name <name>', 'New name')\n .option('-d, --description <text>', 'New description')\n .option('--vision <text>', 'New vision text')\n .option('--status <status>', `Status: ${FEATURE_STATUSES.join(', ')}`)\n .option('--priority <n>', 'Priority 0-4', parseInt)\n .option('--effort <n>', 'Effort estimate', parseFloat)\n .option('--area <id>', 'Area CUID (\"none\" to clear)')\n .option(\n '--goal <id|none>',\n 'Objective (goal) id this feature serves (\"none\" to clear). For progress ' +\n 'rollup, link the finer Feature→key-result edge with `goals kr link --feature`.',\n )\n .action(\n async (\n options: {\n id: string;\n name?: string;\n description?: string;\n vision?: string;\n status?: string;\n priority?: number;\n effort?: number;\n area?: string;\n goal?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateFeatureStatus(options.status);\n const client = getClient();\n const feature = await client.features.update({\n id: options.id,\n name: options.name,\n description: options.description,\n vision: options.vision,\n status,\n priority: options.priority,\n effort: options.effort,\n areaId: options.area === 'none' ? null : options.area,\n goalId: parseFeatureGoalId(options.goal),\n });\n if (useJson) outputFeatureJson(feature);\n else {\n console.log('\\n✓ Feature updated');\n outputFeaturePretty(feature);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n features\n .command('delete <id>')\n .description(\n \"Delete a feature. Refuses if it still has tickets — deleting a feature does not \" +\n 'delete its tickets, it unlinks them (Ticket.featureId is SetNull), silently ' +\n 'orphaning them in the product backlog.',\n )\n .option(\n '--with-tickets',\n \"Delete the feature's tickets first, then the feature (destructive)\",\n )\n .option(\n '--orphan-tickets',\n 'Delete the feature anyway, leaving its tickets in the backlog unlinked',\n )\n .action(\n async (\n id: string,\n options: { withTickets?: boolean; orphanTickets?: boolean },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n if (options.withTickets && options.orphanTickets) {\n throw new Error(\n '--with-tickets and --orphan-tickets are mutually exclusive',\n );\n }\n const client = getClient();\n const feature = await client.features.get(id);\n\n // `features get` returns `_count.tickets`; trust a zero count and skip\n // the extra round trip. Otherwise fetch the tickets themselves — they\n // are needed both to report and (with --with-tickets) to delete.\n const tickets =\n feature._count?.tickets === 0\n ? []\n : await client.tickets.list({\n productId: feature.productId,\n featureId: feature.id,\n });\n\n if (tickets.length > 0 && !options.withTickets && !options.orphanTickets) {\n const reason = `has ${tickets.length} ticket${tickets.length === 1 ? '' : 's'}`;\n if (useJson) {\n console.log(\n JSON.stringify(\n {\n deleted: false,\n id: feature.id,\n reason,\n tickets: tickets.map(summarizeTicket),\n },\n null,\n 2,\n ),\n );\n } else {\n console.error(\n `\\nRefusing to delete \"${feature.name}\": it ${reason}.\\n` +\n 'Deleting the feature would leave them unlinked in the product backlog.\\n' +\n ' --with-tickets delete those tickets first, then the feature\\n' +\n ' --orphan-tickets delete the feature anyway and unlink them',\n );\n for (const t of tickets) {\n console.error(` - ${ticketLabel(t)} ${t.title}`);\n }\n }\n process.exitCode = 1;\n return;\n }\n\n const ticketsDeleted: TicketSummary[] = [];\n const ticketsFailed: (TicketSummary & { error: string })[] = [];\n if (options.withTickets) {\n for (const ticket of tickets) {\n try {\n await client.tickets.delete(ticket.id);\n ticketsDeleted.push(summarizeTicket(ticket));\n } catch (error) {\n ticketsFailed.push({\n ...summarizeTicket(ticket),\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n }\n\n // Never delete the feature after a partial ticket sweep — the survivors\n // would be orphaned, which is exactly what --with-tickets promises to avoid.\n if (ticketsFailed.length > 0) {\n const reason = `failed to delete ${ticketsFailed.length} of ${tickets.length} tickets`;\n if (useJson) {\n console.log(\n JSON.stringify(\n { deleted: false, id: feature.id, reason, ticketsDeleted, ticketsFailed },\n null,\n 2,\n ),\n );\n } else {\n console.error(`\\nAborted: ${reason}. Feature \"${feature.name}\" was NOT deleted.`);\n for (const t of ticketsFailed) {\n console.error(` - ${t.shortId ?? t.id}: ${t.error}`);\n }\n }\n process.exitCode = 1;\n return;\n }\n\n await client.features.delete(feature.id);\n\n const ticketsOrphaned = options.orphanTickets\n ? tickets.map(summarizeTicket)\n : [];\n\n if (useJson) {\n console.log(\n JSON.stringify(\n { deleted: true, id: feature.id, ticketsDeleted, ticketsOrphaned },\n null,\n 2,\n ),\n );\n } else {\n console.log('\\n✓ Feature deleted');\n if (ticketsDeleted.length > 0) {\n console.log(` ${ticketsDeleted.length} ticket(s) deleted with it`);\n }\n if (ticketsOrphaned.length > 0) {\n console.log(` ${ticketsOrphaned.length} ticket(s) left unlinked in the backlog`);\n }\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n features\n .command('link-page')\n .description('Link a Knowledge page (PRD, spec, research) to a feature')\n .requiredOption('--feature <id>', 'Feature CUID')\n .requiredOption('--page <id>', 'Page CUID')\n .option('--scope <id>', 'Feature scope CUID to pin the page to')\n .action(\n async (\n options: { feature: string; page: string; scope?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const link = await client.features.linkPage({\n featureId: options.feature,\n pageId: options.page,\n scopeId: options.scope,\n });\n if (useJson) console.log(JSON.stringify(link, null, 2));\n else console.log('\\n✓ Page linked');\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n features\n .command('unlink-page')\n .description('Unlink a Knowledge page from a feature')\n .requiredOption('--feature <id>', 'Feature CUID')\n .requiredOption('--page <id>', 'Page CUID')\n .action(\n async (options: { feature: string; page: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const result = await client.features.unlinkPage(\n options.feature,\n options.page,\n );\n if (useJson) console.log(JSON.stringify(result, null, 2));\n else console.log('\\n✓ Page unlinked');\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n features.addCommand(createStoriesCommand());\n features.addCommand(createScopesCommand());\n features.addCommand(createRequirementsCommand());\n features.addCommand(createAreasCommand());\n features.addCommand(createFeatureCommentsCommand());\n\n return features;\n}\n","import { Command } from 'commander';\nimport type { UserStoryCreateInput } from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport {\n shouldUseJson,\n outputUserStoryJson,\n outputUserStoryPretty,\n outputUserStoriesJson,\n outputUserStoriesPretty,\n outputBatchResultsJson,\n outputBatchResultsPretty,\n type BatchStoryResult,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\n// Shape of a single story object in the stdin batch array.\ninterface BatchStoryInput {\n asA?: string;\n iWant?: string;\n soThat?: string;\n acceptanceCriteria?: string;\n scopeId?: string;\n}\n\nasync function readStdin(): Promise<string> {\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(chunk as Buffer);\n }\n return Buffer.concat(chunks).toString('utf-8');\n}\n\nexport function createStoriesCommand(): Command {\n const stories = new Command('stories').description(\n 'Manage a feature\\'s native, structured user stories (As a / I want / So that).',\n );\n\n stories\n .command('add')\n .description(\n [\n 'Add user stories to a feature.',\n '',\n 'Flag mode: pass --as-a/--i-want/--so-that (plus optional --acceptance/--scope) to add one story.',\n 'Batch mode: pipe a JSON array of { asA?, iWant?, soThat?, acceptanceCriteria?, scopeId? } on stdin',\n ' to add many at once (per-item success/failure is reported).',\n ].join('\\n'),\n )\n .requiredOption('--feature <id>', 'Feature CUID')\n .option('--as-a <text>', '\"As a ...\" actor')\n .option('--i-want <text>', '\"I want ...\" capability')\n .option('--so-that <text>', '\"So that ...\" outcome')\n .option('--acceptance <text>', 'Acceptance criteria')\n .option('--scope <id>', 'Feature scope CUID to group the story under')\n .action(\n async (\n options: {\n feature: string;\n asA?: string;\n iWant?: string;\n soThat?: string;\n acceptance?: string;\n scope?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n const hasFlags =\n options.asA != null ||\n options.iWant != null ||\n options.soThat != null ||\n options.acceptance != null;\n // Batch mode when stdin is piped and no story flags were given.\n const isBatch = !hasFlags && !process.stdin.isTTY;\n\n try {\n const client = getClient();\n\n if (isBatch) {\n const raw = await readStdin();\n let items: BatchStoryInput[];\n try {\n const parsed: unknown = JSON.parse(raw);\n if (!Array.isArray(parsed)) {\n throw new Error('Expected a JSON array of story objects on stdin');\n }\n items = parsed as BatchStoryInput[];\n } catch (parseError) {\n throw new Error(\n `Could not parse stdin as a JSON array: ${\n parseError instanceof Error ? parseError.message : String(parseError)\n }`,\n );\n }\n\n const results: BatchStoryResult[] = [];\n // Sequential so server-side displayOrder follows array order.\n for (let index = 0; index < items.length; index++) {\n const item = items[index]!;\n try {\n const story = await client.userStories.create({\n featureId: options.feature,\n asA: item.asA,\n iWant: item.iWant,\n soThat: item.soThat,\n acceptanceCriteria: item.acceptanceCriteria,\n scopeId: item.scopeId,\n });\n results.push({ index, ok: true, id: story.id });\n } catch (itemError) {\n results.push({\n index,\n ok: false,\n error: itemError instanceof Error ? itemError.message : String(itemError),\n });\n }\n }\n\n if (useJson) outputBatchResultsJson(results);\n else outputBatchResultsPretty(results);\n\n // Non-zero exit if every item failed, so scripts can detect total failure.\n if (results.length > 0 && results.every((r) => !r.ok)) {\n process.exit(1);\n }\n return;\n }\n\n // Flag mode: a single story.\n const input: UserStoryCreateInput = {\n featureId: options.feature,\n asA: options.asA,\n iWant: options.iWant,\n soThat: options.soThat,\n acceptanceCriteria: options.acceptance,\n scopeId: options.scope,\n };\n const story = await client.userStories.create(input);\n if (useJson) outputUserStoryJson(story);\n else {\n console.log('\\n✓ User story added');\n outputUserStoryPretty(story);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n stories\n .command('list')\n .description('List a feature\\'s user stories in display order')\n .requiredOption('--feature <id>', 'Feature CUID')\n .action(\n async (options: { feature: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const list = await client.userStories.list({ featureId: options.feature });\n if (useJson) outputUserStoriesJson(list);\n else outputUserStoriesPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n return stories;\n}\n","import { Command } from 'commander';\nimport type { FeatureScopeStatus } from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport {\n shouldUseJson,\n outputScopeJson,\n outputScopePretty,\n outputScopesJson,\n outputScopesPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nconst SCOPE_STATUSES: FeatureScopeStatus[] = [\n 'PLANNED',\n 'IN_PROGRESS',\n 'SHIPPED',\n 'DEPRECATED',\n];\n\nfunction validateScopeStatus(value: string | undefined): FeatureScopeStatus | undefined {\n if (!value) return undefined;\n if (!(SCOPE_STATUSES as string[]).includes(value)) {\n throw new Error(\n `Invalid status \"${value}\". Valid: ${SCOPE_STATUSES.join(', ')}`,\n );\n }\n return value as FeatureScopeStatus;\n}\n\nexport function createScopesCommand(): Command {\n const scopes = new Command('scopes').description(\n 'Manage a feature\\'s scopes: shippable increments (\"V1\", \"V2\"), each with its own lifecycle.',\n );\n\n scopes\n .command('list')\n .description('List a feature\\'s scopes')\n .requiredOption('--feature <id>', 'Feature CUID')\n .action(\n async (options: { feature: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const list = await client.scopes.list({ featureId: options.feature });\n if (useJson) outputScopesJson(list);\n else outputScopesPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n scopes\n .command('add')\n .description('Add a scope to a feature')\n .requiredOption('--feature <id>', 'Feature CUID')\n .requiredOption('--version <label>', 'Short label for the increment, e.g. \"V1\"')\n .requiredOption('-d, --description <text>', 'What this scope delivers (markdown supported)')\n .option('--status <status>', `Status: ${SCOPE_STATUSES.join(', ')} (default PLANNED)`)\n .action(\n async (\n options: { feature: string; version: string; description: string; status?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateScopeStatus(options.status);\n const client = getClient();\n const scope = await client.scopes.create({\n featureId: options.feature,\n version: options.version,\n description: options.description,\n status,\n });\n if (useJson) outputScopeJson(scope);\n else {\n console.log('\\n✓ Scope added');\n outputScopePretty(scope);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n scopes\n .command('update')\n .description('Update a scope (setting SHIPPED stamps shippedAt and rolls the feature status up)')\n .requiredOption('--id <id>', 'Scope CUID')\n .option('--version <label>', 'New version label')\n .option('-d, --description <text>', 'New description')\n .option('--status <status>', `Status: ${SCOPE_STATUSES.join(', ')}`)\n .action(\n async (\n options: { id: string; version?: string; description?: string; status?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateScopeStatus(options.status);\n const client = getClient();\n const scope = await client.scopes.update({\n id: options.id,\n version: options.version,\n description: options.description,\n status,\n });\n if (useJson) outputScopeJson(scope);\n else {\n console.log('\\n✓ Scope updated');\n outputScopePretty(scope);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n scopes\n .command('rm')\n .description('Delete a scope')\n .requiredOption('--id <id>', 'Scope CUID')\n .action(async (options: { id: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const result = await client.scopes.delete(options.id);\n if (useJson) console.log(JSON.stringify(result, null, 2));\n else console.log('\\n✓ Scope deleted');\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return scopes;\n}\n","import { Command } from 'commander';\nimport type { RequirementCreateInput, RequirementKind } from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport {\n shouldUseJson,\n outputRequirementJson,\n outputRequirementPretty,\n outputRequirementsJson,\n outputRequirementsPretty,\n outputRequirementBatchJson,\n outputRequirementBatchPretty,\n type BatchRequirementResult,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nconst REQUIREMENT_KINDS: RequirementKind[] = [\n 'FUNCTIONAL',\n 'NON_FUNCTIONAL',\n 'CONSTRAINT',\n];\n\nfunction validateKind(value: string | undefined): RequirementKind | undefined {\n if (!value) return undefined;\n if (!(REQUIREMENT_KINDS as string[]).includes(value)) {\n throw new Error(\n `Invalid kind \"${value}\". Valid: ${REQUIREMENT_KINDS.join(', ')}`,\n );\n }\n return value as RequirementKind;\n}\n\n// Shape of a single requirement object in the stdin batch array.\ninterface BatchRequirementInput {\n statement: string;\n kind?: RequirementKind;\n scopeId?: string;\n}\n\nasync function readStdin(): Promise<string> {\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(chunk as Buffer);\n }\n return Buffer.concat(chunks).toString('utf-8');\n}\n\nexport function createRequirementsCommand(): Command {\n const requirements = new Command('requirements').description(\n 'Manage a feature\\'s requirements: atomic, testable EARS-style \"shall\" statements, checkable met/unmet.',\n );\n\n requirements\n .command('add')\n .description(\n [\n 'Add requirements to a feature.',\n '',\n 'Flag mode: pass -s/--statement (plus optional --kind/--scope) to add one requirement.',\n 'Batch mode: pipe a JSON array of { statement, kind?, scopeId? } on stdin',\n ' to add many at once (per-item success/failure is reported).',\n ].join('\\n'),\n )\n .requiredOption('--feature <id>', 'Feature CUID')\n .option('-s, --statement <text>', 'One EARS-style \"shall\" statement')\n .option('--kind <kind>', `Kind: ${REQUIREMENT_KINDS.join(', ')}`)\n .option('--scope <id>', 'Feature scope CUID to pin the requirement to')\n .action(\n async (\n options: { feature: string; statement?: string; kind?: string; scope?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n\n if (options.statement) {\n const requirement = await client.requirements.create({\n featureId: options.feature,\n statement: options.statement,\n kind: validateKind(options.kind),\n scopeId: options.scope,\n });\n if (useJson) outputRequirementJson(requirement);\n else {\n console.log('\\n✓ Requirement added');\n outputRequirementPretty(requirement);\n }\n return;\n }\n\n // Batch mode: JSON array on stdin.\n if (process.stdin.isTTY) {\n throw new Error(\n 'Pass -s/--statement, or pipe a JSON array of requirements on stdin.',\n );\n }\n const raw = await readStdin();\n let batch: BatchRequirementInput[];\n try {\n const parsed: unknown = JSON.parse(raw);\n if (!Array.isArray(parsed)) throw new Error('not an array');\n batch = parsed as BatchRequirementInput[];\n } catch {\n throw new Error(\n 'stdin must be a JSON array of { statement, kind?, scopeId? } objects.',\n );\n }\n\n const results: BatchRequirementResult[] = [];\n for (const [index, item] of batch.entries()) {\n try {\n if (!item.statement || typeof item.statement !== 'string') {\n throw new Error('missing \"statement\"');\n }\n const input: RequirementCreateInput = {\n featureId: options.feature,\n statement: item.statement,\n kind: validateKind(item.kind),\n scopeId: item.scopeId,\n };\n const requirement = await client.requirements.create(input);\n results.push({ index, success: true, requirement });\n } catch (error) {\n results.push({\n index,\n success: false,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n if (useJson) outputRequirementBatchJson(results);\n else outputRequirementBatchPretty(results);\n if (results.some((r) => !r.success)) process.exitCode = 1;\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n requirements\n .command('list')\n .description('List a feature\\'s requirements')\n .requiredOption('--feature <id>', 'Feature CUID')\n .option('--scope <id>', 'Only requirements pinned to this scope')\n .action(\n async (options: { feature: string; scope?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const list = await client.requirements.list({\n featureId: options.feature,\n scopeId: options.scope,\n });\n if (useJson) outputRequirementsJson(list);\n else outputRequirementsPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n requirements\n .command('check')\n .description('Mark a requirement met (or unmet with --unmet)')\n .requiredOption('--id <id>', 'Requirement CUID')\n .option('--unmet', 'Mark unmet instead of met')\n .action(\n async (options: { id: string; unmet?: boolean }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const requirement = await client.requirements.setChecked(\n options.id,\n !options.unmet,\n );\n if (useJson) outputRequirementJson(requirement);\n else {\n console.log(`\\n✓ Requirement marked ${options.unmet ? 'unmet' : 'met'}`);\n outputRequirementPretty(requirement);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n requirements\n .command('rm')\n .description('Delete a requirement')\n .requiredOption('--id <id>', 'Requirement CUID')\n .action(async (options: { id: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const result = await client.requirements.delete(options.id);\n if (useJson) console.log(JSON.stringify(result, null, 2));\n else console.log('\\n✓ Requirement deleted');\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return requirements;\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveProductId, resolveWorkspaceId } from '../utils/resolve.js';\nimport { shouldUseJson } from '../utils/output.js';\nimport chalk from 'chalk';\nimport type { Area } from 'exponential-sdk';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nfunction outputAreasPretty(areas: Area[]): void {\n if (areas.length === 0) {\n console.log(chalk.gray('No areas found.'));\n return;\n }\n console.log(chalk.bold(`\\nAreas (${areas.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const a of areas) {\n const count = a._count?.features != null ? chalk.gray(` (${a._count.features} features)`) : '';\n console.log(` ${chalk.bold(a.name)}${count}`);\n console.log(chalk.gray(` ID: ${a.id}`));\n }\n console.log();\n}\n\nexport function createAreasCommand(): Command {\n const areas = new Command('areas').description(\n 'Manage a product\\'s areas: the buckets features are filed under (a feature has exactly one or none).',\n );\n\n areas\n .command('list')\n .description('List a product\\'s areas')\n .requiredOption('--product <slug|id>', 'Product slug or CUID')\n .option('--workspace <slug|id>', 'Workspace (required when --product is a slug)')\n .action(\n async (options: { product: string; workspace?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const productId = await resolveProductId(client, workspaceId, options.product);\n const list = await client.areas.list({ productId });\n if (useJson) console.log(JSON.stringify({ areas: list, total: list.length }, null, 2));\n else outputAreasPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n areas\n .command('create')\n .description('Create an area in a product')\n .requiredOption('--product <slug|id>', 'Product slug or CUID')\n .requiredOption('-n, --name <name>', 'Area name (unique per product)')\n .option('-d, --description <text>', 'What belongs in this area')\n .option('--workspace <slug|id>', 'Workspace (required when --product is a slug)')\n .action(\n async (\n options: { product: string; name: string; description?: string; workspace?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const productId = await resolveProductId(client, workspaceId, options.product);\n const area = await client.areas.create({\n productId,\n name: options.name,\n description: options.description,\n });\n if (useJson) console.log(JSON.stringify(area, null, 2));\n else console.log(`\\n✓ Area created: ${area.name} (${area.id})`);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n return areas;\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n applyMentions,\n collectMention,\n MENTION_OPTION_DESCRIPTION,\n} from '../utils/mentions.js';\nimport {\n shouldUseJson,\n outputCommentJson,\n outputCommentPretty,\n outputCommentsJson,\n outputCommentsPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\n/**\n * `exponential features comment …` — the discussion on a feature (PRD).\n *\n * Any workspace member can read and post; editing and deleting are\n * author-only, so the CLI surfaces the server's \"not yours\" error rather than\n * pre-checking.\n */\nexport function createFeatureCommentsCommand(): Command {\n const comment = new Command('comment').description(\n 'Read and post comments on a feature. Mention teammates with --mention.',\n );\n\n comment\n .command('list')\n .description('List comments on a feature')\n .requiredOption('--feature <id>', 'Feature ID')\n .action(async (options: { feature: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const comments = await client.featureComments.list(options.feature);\n if (useJson) outputCommentsJson(comments);\n else outputCommentsPretty(comments);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('add')\n .description('Add a comment to a feature')\n .requiredOption('--feature <id>', 'Feature ID')\n .requiredOption('-m, --message <text>', 'Comment body (markdown supported)')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .option('--scope <id>', \"Attach to a scope's activity feed instead of the feature\")\n .action(\n async (\n options: {\n feature: string;\n message: string;\n mention: string[];\n workspace?: string;\n scope?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n // Only resolve a workspace when mentions actually need one — an\n // unmentioned comment shouldn't fail for lack of a default workspace.\n const body =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const created = await client.featureComments.create({\n featureId: options.feature,\n scopeId: options.scope,\n body,\n });\n if (useJson) {\n outputCommentJson(created);\n } else {\n console.log('\\n✓ Comment added');\n outputCommentPretty(created);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('reply')\n .description('Reply to a comment on a feature')\n .requiredOption('--comment-id <id>', 'Comment ID to reply to')\n .requiredOption('-m, --message <text>', 'Reply body (markdown supported)')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .action(\n async (\n options: {\n commentId: string;\n message: string;\n mention: string[];\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const body =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const created = await client.featureComments.reply({\n parentId: options.commentId,\n body,\n });\n if (useJson) {\n outputCommentJson(created);\n } else {\n console.log('\\n✓ Reply added');\n outputCommentPretty(created);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('update')\n .description('Update one of your own comments')\n .requiredOption('--comment-id <id>', 'Comment ID')\n .requiredOption('-m, --message <text>', 'New comment body')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .action(\n async (\n options: {\n commentId: string;\n message: string;\n mention: string[];\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const body =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const updated = await client.featureComments.update({\n commentId: options.commentId,\n body,\n });\n if (useJson) {\n outputCommentJson(updated);\n } else {\n console.log('\\n✓ Comment updated');\n outputCommentPretty(updated);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('rm')\n .description('Delete one of your own comments')\n .requiredOption('--comment-id <id>', 'Comment ID')\n .action(async (options: { commentId: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.featureComments.delete(options.commentId);\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id: options.commentId }, null, 2));\n } else {\n console.log('✓ Comment deleted');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('resolve')\n .description('Resolve an anchored comment thread')\n .requiredOption('--feature <id>', 'Feature ID')\n .requiredOption('--thread <id>', 'Thread ID (anchored comments only)')\n .action(async (options: { feature: string; thread: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.featureComments.resolve({\n featureId: options.feature,\n threadId: options.thread,\n });\n if (useJson) {\n console.log(JSON.stringify({ resolved: true, threadId: options.thread }, null, 2));\n } else {\n console.log('✓ Thread resolved');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('unresolve')\n .description('Reopen a resolved comment thread')\n .requiredOption('--feature <id>', 'Feature ID')\n .requiredOption('--thread <id>', 'Thread ID (anchored comments only)')\n .action(async (options: { feature: string; thread: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.featureComments.unresolve({\n featureId: options.feature,\n threadId: options.thread,\n });\n if (useJson) {\n console.log(JSON.stringify({ resolved: false, threadId: options.thread }, null, 2));\n } else {\n console.log('✓ Thread reopened');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return comment;\n}\n","import type { ExponentialClient, WorkspaceMember } from 'exponential-sdk';\n\n/**\n * Mentions are stored as `@[Display Name](userId)` markup inside a comment\n * body — that exact form is what the server parses to decide who gets\n * notified. Typing it by hand means knowing someone's user id, so `--mention`\n * takes a name, email, or id and expands it here.\n *\n * Substitution is in-place where possible: `--mention andi -m \"@andi ptal?\"`\n * produces `@[Andi Stanner](clx…) ptal?`, so the sentence still reads. Tokens\n * with no matching `@handle` in the body get prepended instead, which keeps\n * `--mention andi -m \"ptal?\"` working too.\n */\n\nfunction candidateLabels(member: WorkspaceMember): string[] {\n const labels = [member.id];\n if (member.name) {\n labels.push(member.name);\n // \"Andi Stanner\" should also answer to \"andi\".\n const first = member.name.trim().split(/\\s+/)[0];\n if (first) labels.push(first);\n }\n if (member.email) {\n labels.push(member.email);\n const local = member.email.split('@')[0];\n if (local) labels.push(local);\n }\n return labels;\n}\n\nfunction describe(member: WorkspaceMember): string {\n return member.name ?? member.email ?? member.id;\n}\n\n/**\n * Resolve one `--mention` token to a workspace member.\n *\n * Exact id, name, or email wins outright. Otherwise the token is matched\n * case-insensitively against first names and email local-parts. An ambiguous\n * token is an error rather than a guess — mentioning the wrong colleague is\n * worse than failing.\n */\nexport function resolveMember(\n members: WorkspaceMember[],\n token: string,\n): WorkspaceMember {\n const needle = token.trim().toLowerCase().replace(/^@/, '');\n\n const exact = members.filter(\n (m) =>\n m.id.toLowerCase() === needle ||\n m.name?.toLowerCase() === needle ||\n m.email?.toLowerCase() === needle,\n );\n if (exact.length === 1) return exact[0]!;\n if (exact.length > 1) {\n throw new Error(\n `\"${token}\" matches ${exact.length} members. Use a user id instead: ${exact\n .map((m) => `${describe(m)} (${m.id})`)\n .join(', ')}`,\n );\n }\n\n const partial = members.filter((m) =>\n candidateLabels(m).some((l) => l.toLowerCase() === needle),\n );\n if (partial.length === 1) return partial[0]!;\n if (partial.length > 1) {\n throw new Error(\n `\"${token}\" is ambiguous — matches ${partial\n .map((m) => `${describe(m)} (${m.id})`)\n .join(', ')}. Use a full name, email, or user id.`,\n );\n }\n\n const known = members.map(describe).join(', ');\n throw new Error(\n `No workspace member matches \"${token}\". Members: ${known || '(none)'}. ` +\n 'Run `exponential workspaces members` to see the roster.',\n );\n}\n\n/** Escape a token for safe use inside a RegExp. */\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/**\n * Expand `--mention` tokens into a comment body.\n *\n * Returns the body unchanged when no mentions were requested, so the common\n * path costs nothing — the member roster is only fetched when it's needed.\n */\nexport async function applyMentions(\n client: ExponentialClient,\n workspaceId: string,\n body: string,\n mentions: string[] | undefined,\n): Promise<string> {\n if (!mentions || mentions.length === 0) return body;\n\n const members = await client.workspaces.listMembers(workspaceId);\n\n let result = body;\n const prepend: string[] = [];\n\n for (const token of mentions) {\n const member = resolveMember(members, token);\n const handle = token.trim().replace(/^@/, '');\n // Replace `@handle` in the body when the author wrote one, so the mention\n // lands where they meant it to. `(?![\\w-])` stops `@andi` matching inside\n // `@andidev`.\n const inline = new RegExp(`@${escapeRegExp(handle)}(?![\\\\w-])`, 'gi');\n const substituted = result.replace(inline, member.mentionSyntax);\n if (substituted !== result) {\n result = substituted;\n } else if (!result.includes(member.mentionSyntax)) {\n prepend.push(member.mentionSyntax);\n }\n }\n\n return prepend.length > 0 ? `${prepend.join(' ')} ${result}` : result;\n}\n\n/** Shared `--mention` option description, so every comment command reads alike. */\nexport const MENTION_OPTION_DESCRIPTION =\n 'Mention a workspace member by name, email, or id (repeatable). ' +\n 'Writing @name in the message substitutes in place; otherwise the mention is prepended.';\n\n/** Commander collector for a repeatable option. */\nexport function collectMention(value: string, previous: string[]): string[] {\n return [...previous, value];\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport type { Tag } from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport { shouldUseJson } from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\ninterface SeedLabel {\n name: string;\n slug: string;\n color: string;\n}\n\n/**\n * Canonical triage labels referenced by the `/triage` agent skill. Slugs are\n * deterministic, so re-running `seed-triage` after a partial creation only\n * creates the missing ones.\n */\nconst TRIAGE_LABELS: SeedLabel[] = [\n { slug: 'needs-triage', name: 'needs-triage', color: 'avatar-orange' },\n { slug: 'needs-info', name: 'needs-info', color: 'avatar-yellow' },\n { slug: 'ready-for-agent', name: 'ready-for-agent', color: 'avatar-green' },\n { slug: 'ready-for-human', name: 'ready-for-human', color: 'avatar-lightBlue' },\n { slug: 'wontfix', name: 'wontfix', color: 'avatar-lightGray' },\n];\n\nconst CUID_PATTERN = /^c[a-z0-9]{20,}$/i;\n\nfunction looksLikeCuid(value: string): boolean {\n return CUID_PATTERN.test(value);\n}\n\nfunction outputTagsPretty(tags: Tag[]): void {\n if (tags.length === 0) {\n console.log(chalk.dim('No labels found.'));\n return;\n }\n console.log();\n for (const tag of tags) {\n const scope = tag.workspaceId === null ? chalk.cyan('global') : chalk.magenta('workspace');\n const category = tag.category === null ? chalk.dim('(label)') : chalk.dim(`(${tag.category})`);\n console.log(\n ` ${chalk.bold(tag.slug)} ${tag.name} ${chalk.gray(tag.color)} ${scope} ${category}`,\n );\n }\n console.log();\n}\n\nfunction outputTagPretty(tag: Tag, prefix?: string): void {\n if (prefix) console.log(prefix);\n console.log(` ${chalk.bold(tag.slug)} ${tag.name} ${chalk.gray(tag.color)}`);\n}\n\nexport async function resolveLabelIds(\n client: ReturnType<typeof getClient>,\n workspaceId: string | undefined,\n values: string[],\n): Promise<string[]> {\n if (values.length === 0) return [];\n\n const bySlug = values.filter((v) => !looksLikeCuid(v));\n const byId = values.filter((v) => looksLikeCuid(v));\n\n if (bySlug.length === 0) return byId;\n\n const list = await client.labels.list({ workspaceId });\n const slugMap = new Map(list.allTags.map((t) => [t.slug, t.id]));\n\n const resolvedFromSlugs: string[] = [];\n const missing: string[] = [];\n for (const slug of bySlug) {\n const id = slugMap.get(slug);\n if (id === undefined) missing.push(slug);\n else resolvedFromSlugs.push(id);\n }\n if (missing.length > 0) {\n throw new Error(\n `Unknown label slug(s): ${missing.join(', ')}. Run \\`exponential labels list --workspace <slug>\\` to see available labels.`,\n );\n }\n return [...byId, ...resolvedFromSlugs];\n}\n\nexport function createLabelsCommand(): Command {\n const labels = new Command('labels').description(\n 'Manage labels (orthogonal tags applied to actions, tickets, features, and epics).',\n );\n\n labels\n .command('list')\n .description('List labels visible in a workspace')\n .option('--workspace <slug|id>', 'Workspace slug or CUID')\n .option(\n '--category <category>',\n 'Filter by category. Use \"label\" for general labels, \"null\" for category-less labels, or omit to list all.',\n )\n .action(\n async (\n options: { workspace?: string; category?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const category =\n options.category === undefined\n ? undefined\n : options.category === 'null'\n ? null\n : options.category;\n const result = await client.labels.list({ workspaceId, category });\n if (useJson) {\n console.log(JSON.stringify(result.allTags, null, 2));\n } else {\n outputTagsPretty(result.allTags);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n labels\n .command('create')\n .description('Create a workspace-scoped label')\n .requiredOption('-n, --name <name>', 'Label name')\n .requiredOption('--color <token>', 'Color token (e.g. avatar-green, brand-primary)')\n .option('-d, --description <text>', 'Description')\n .option('--category <category>', 'Category. Omit (or pass \"null\") to create a general label.')\n .option('--workspace <slug|id>', 'Workspace slug or CUID')\n .action(\n async (\n options: {\n name: string;\n color: string;\n description?: string;\n category?: string;\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n if (workspaceId === undefined) {\n throw new Error(\n 'Workspace is required. Pass --workspace <slug|id> or set a default with `exponential workspaces set-default`.',\n );\n }\n const category =\n options.category === undefined\n ? undefined\n : options.category === 'null'\n ? null\n : options.category;\n const tag = await client.labels.create({\n workspaceId,\n name: options.name,\n color: options.color,\n description: options.description,\n category,\n });\n if (useJson) {\n console.log(JSON.stringify(tag, null, 2));\n } else {\n outputTagPretty(tag, chalk.green('\\n✓ Label created'));\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n labels\n .command('seed-triage')\n .description('Idempotently seed the five canonical triage labels into a workspace.')\n .option('--workspace <slug|id>', 'Workspace slug or CUID')\n .action(\n async (options: { workspace?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n if (workspaceId === undefined) {\n throw new Error(\n 'Workspace is required. Pass --workspace <slug|id> or set a default with `exponential workspaces set-default`.',\n );\n }\n const existing = await client.labels.list({ workspaceId });\n const existingSlugs = new Set(existing.allTags.map((t) => t.slug));\n\n const results: Array<{\n slug: string;\n status: 'created' | 'existed';\n tag?: Tag;\n }> = [];\n for (const def of TRIAGE_LABELS) {\n if (existingSlugs.has(def.slug)) {\n results.push({ slug: def.slug, status: 'existed' });\n continue;\n }\n const tag = await client.labels.create({\n workspaceId,\n name: def.name,\n color: def.color,\n });\n results.push({ slug: def.slug, status: 'created', tag });\n }\n\n if (useJson) {\n console.log(JSON.stringify(results, null, 2));\n } else {\n console.log();\n console.log(chalk.bold('Triage labels:'));\n for (const r of results) {\n const tag = chalk.bold(r.slug);\n const status =\n r.status === 'created'\n ? chalk.green('created')\n : chalk.dim('existed');\n console.log(` ${tag} ${status}`);\n }\n console.log();\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n return labels;\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { readText, parseDate } from '../utils/input.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n shouldUseJson,\n outputMeetingJson,\n outputMeetingPretty,\n outputMeetingsJson,\n outputMeetingsPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nexport function createMeetingsCommand(): Command {\n const meetings = new Command('meetings').description(\n 'Manage meetings and their notes (recorded, imported, or manually created)',\n );\n\n meetings\n .command('list')\n .description(\n 'List meetings you can see (owned, attended, or shared via project/workspace). JSON rows carry hasNotes/hasSummary/hasTranscript flags instead of the bodies — use \"get\" for content.',\n )\n .option('--workspace <slug|id>', 'Restrict to one workspace')\n .option('--mine', 'Only meetings you own or attended')\n .option('--archived', 'Include archived meetings')\n .action(\n async (\n options: { workspace?: string; mine?: boolean; archived?: boolean },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = options.workspace\n ? await resolveWorkspaceId(client, options.workspace)\n : undefined;\n const list = await client.meetings.list({\n workspaceId,\n includeArchived: options.archived,\n meetingType: options.mine ? 'mine' : undefined,\n });\n if (useJson) outputMeetingsJson(list);\n else outputMeetingsPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n meetings\n .command('get <id>')\n .description('Get a meeting: details, summary, and notes')\n .option('--transcript', 'Also print the raw transcript (pretty mode; JSON always includes it)')\n .action(\n async (id: string, options: { transcript?: boolean }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const meeting = await client.meetings.get(id);\n if (useJson) outputMeetingJson(meeting);\n else outputMeetingPretty(meeting, { transcript: options.transcript });\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n meetings\n .command('create')\n .description(\n 'Create a meeting manually. Transcript: --transcript text, --transcript-file <path>, or --transcript-file - for stdin.',\n )\n .requiredOption('-t, --title <title>', 'Meeting title')\n .option('--transcript <text>', 'Transcript text (required by the API)')\n .option('--transcript-file <path>', 'Read the transcript from a file (\"-\" = stdin)')\n .option('--notes <markdown>', 'Meeting notes')\n .option('--notes-file <path>', 'Read the notes from a file (\"-\" = stdin)')\n .option('--description <text>', 'Short description')\n .option('--date <iso>', 'When the meeting occurred (e.g. 2026-08-25T14:00; a bare date is local midnight)')\n .option('--project <id>', 'Link to a project (the meeting inherits its workspace)')\n .option('--workspace <slug|id>', 'Workspace (omit for a personal meeting)')\n .action(\n async (\n options: {\n title: string;\n transcript?: string;\n transcriptFile?: string;\n notes?: string;\n notesFile?: string;\n description?: string;\n date?: string;\n project?: string;\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const transcription = readText(options.transcript, options.transcriptFile);\n if (transcription === undefined) {\n throw new Error(\n 'A transcript is required: pass --transcript <text> or --transcript-file <path|->.',\n );\n }\n if (transcription.trim() === '') {\n throw new Error('The transcript is empty. The API requires a non-empty transcript.');\n }\n const workspaceId = options.workspace\n ? await resolveWorkspaceId(client, options.workspace)\n : undefined;\n const meeting = await client.meetings.create({\n title: options.title,\n transcription,\n notes: readText(options.notes, options.notesFile),\n description: options.description,\n meetingDate: parseDate(options.date),\n projectId: options.project,\n workspaceId,\n });\n if (useJson) outputMeetingJson(meeting);\n else {\n console.log('\\n✓ Meeting created');\n outputMeetingPretty(meeting);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n meetings\n .command('update')\n .description(\n 'Update a meeting; only the fields you pass are written. Title and other fields are two API calls — on a mid-flight failure the title may already be saved.',\n )\n .requiredOption('--id <id>', 'Meeting CUID')\n .option('-t, --title <title>', 'New title')\n .option('--notes <markdown>', 'Replace the meeting notes')\n .option('--notes-file <path>', 'Read the new notes from a file (\"-\" = stdin)')\n .option('--summary <text>', 'Replace the summary')\n .option('--description <text>', 'Replace the description')\n .option('--date <iso>', 'When the meeting occurred')\n .action(\n async (\n options: {\n id: string;\n title?: string;\n notes?: string;\n notesFile?: string;\n summary?: string;\n description?: string;\n date?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const notes = readText(options.notes, options.notesFile);\n if (\n options.title === undefined &&\n notes === undefined &&\n options.summary === undefined &&\n options.description === undefined &&\n options.date === undefined\n ) {\n throw new Error(\n 'Nothing to update. Pass at least one of --title, --notes, --notes-file, --summary, --description, --date.',\n );\n }\n const client = getClient();\n const meeting = await client.meetings.update({\n id: options.id,\n title: options.title,\n notes,\n summary: options.summary,\n description: options.description,\n meetingDate: parseDate(options.date),\n });\n if (useJson) outputMeetingJson(meeting);\n else {\n console.log('\\n✓ Meeting updated');\n outputMeetingPretty(meeting);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n const notes = new Command('notes').description(\n \"Read and write a meeting's notes\",\n );\n\n notes\n .command('get <id>')\n .description(\n 'Print the meeting notes as raw Markdown (safe to redirect to a file); pass --json for a {id, notes} envelope',\n )\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n try {\n const client = getClient();\n const body = await client.meetings.getNotes(id);\n if (globalOpts.json) {\n console.log(JSON.stringify({ id, notes: body }, null, 2));\n } else if (body !== null) {\n // Raw body even when piped — this output round-trips into\n // `notes set --file`, so it must never pick up a JSON envelope.\n process.stdout.write(body.endsWith('\\n') ? body : `${body}\\n`);\n } else if (process.stdout.isTTY) {\n console.log(chalk.gray('No notes yet.'));\n }\n } catch (error) {\n handleError(error, shouldUseJson(globalOpts.json, globalOpts.pretty));\n }\n });\n\n notes\n .command('set <id> [notes]')\n .description('Replace the meeting notes. Body: inline, --file <path>, or --file - for stdin.')\n .option('--file <path>', 'Read the notes from a file (\"-\" = stdin)')\n .action(\n async (\n id: string,\n inline: string | undefined,\n options: { file?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const body = readText(inline, options.file);\n if (body === undefined) {\n throw new Error('Pass the notes inline or via --file <path|->.');\n }\n const client = getClient();\n const meeting = await client.meetings.setNotes(id, body);\n if (useJson) outputMeetingJson(meeting);\n else console.log('✓ Notes saved');\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n notes\n .command('append <id> [notes]')\n .description(\n 'Append a block to the meeting notes (separated by a blank line). Read-modify-write: concurrent appends can lose one side.',\n )\n .option('--file <path>', 'Read the block from a file (\"-\" = stdin)')\n .action(\n async (\n id: string,\n inline: string | undefined,\n options: { file?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const body = readText(inline, options.file);\n if (body === undefined) {\n throw new Error('Pass the notes inline or via --file <path|->.');\n }\n const client = getClient();\n const meeting = await client.meetings.appendNotes(id, body);\n if (useJson) outputMeetingJson(meeting);\n else console.log('✓ Notes appended');\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n meetings.addCommand(notes);\n\n return meetings;\n}\n","import { readFileSync } from 'node:fs';\n\nlet stdinConsumed = false;\n\n/** Test hook: the stdin guard is process-wide state. */\nexport function resetStdinGuardForTests(): void {\n stdinConsumed = false;\n}\n\n/**\n * Text from an inline option value, a file path, or \"-\" for stdin.\n * Inline wins when both are given. stdin can back at most one option per\n * invocation — a second \"-\" would silently read EOF as \"\".\n */\nexport function readText(inline?: string, file?: string): string | undefined {\n if (inline !== undefined) return inline;\n if (file === undefined) return undefined;\n if (file === '-') {\n if (stdinConsumed) {\n throw new Error('stdin (\"-\") can only back one option per invocation.');\n }\n stdinConsumed = true;\n return readFileSync(0, 'utf-8');\n }\n return readFileSync(file, 'utf-8');\n}\n\n/**\n * Parse a user-supplied date. A date-only value (\"2026-08-25\") is taken as\n * LOCAL midnight — bare `new Date(\"2026-08-25\")` would be UTC midnight, which\n * reads back as the previous day anywhere west of UTC. Empty string counts\n * as omitted; anything unparseable throws.\n */\nexport function parseDate(value: string | undefined): Date | undefined {\n if (value === undefined || value === '') return undefined;\n const date = /^\\d{4}-\\d{2}-\\d{2}$/.test(value)\n ? new Date(`${value}T00:00:00`)\n : new Date(value);\n if (Number.isNaN(date.getTime())) {\n throw new Error(\n `Invalid date: \"${value}\". Use ISO format, e.g. 2026-08-25 or 2026-08-25T14:00.`,\n );\n }\n return date;\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport {\n shouldUseJson,\n outputOrganizationJson,\n outputOrganizationPretty,\n outputOrganizationsJson,\n outputOrganizationsPretty,\n} from '../utils/output.js';\nimport type { OrganizationSize } from 'exponential-sdk';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n workspace?: string;\n}\n\nconst VALID_SIZES: OrganizationSize[] = [\n '1-10', '11-50', '51-200', '201-500', '501-1000', '1000+',\n];\n\nexport function createOrganizationsCommand(): Command {\n const organizations = new Command('organizations')\n .alias('orgs')\n .description('Manage CRM organizations');\n\n organizations\n .command('list')\n .description('List organizations')\n .requiredOption('--workspace <id>', 'Workspace ID')\n .option('--search <query>', 'Search by name or description')\n .option('--industry <industry>', 'Filter by industry')\n .option('--limit <n>', 'Max results to return', parseInt)\n .option('--cursor <cursor>', 'Pagination cursor')\n .action(async (options: {\n workspace: string;\n search?: string;\n industry?: string;\n limit?: number;\n cursor?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const result = await client.organizations.list({\n workspaceId: options.workspace,\n search: options.search,\n industry: options.industry,\n limit: options.limit,\n cursor: options.cursor,\n });\n\n if (useJson) {\n outputOrganizationsJson(result.organizations, result.nextCursor);\n } else {\n outputOrganizationsPretty(result.organizations);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n organizations\n .command('get')\n .description('Get an organization by ID')\n .argument('<id>', 'Organization ID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const org = await client.organizations.get(id);\n\n if (useJson) {\n outputOrganizationJson(org);\n } else {\n outputOrganizationPretty(org);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n organizations\n .command('create')\n .description('Create a new organization')\n .requiredOption('--workspace <id>', 'Workspace ID')\n .requiredOption('--name <name>', 'Organization name')\n .option('--website-url <url>', 'Website URL')\n .option('--logo-url <url>', 'Logo URL')\n .option('--description <text>', 'Description')\n .option('--industry <industry>', 'Industry')\n .option('--size <size>', `Company size (${VALID_SIZES.join(', ')})`)\n .action(async (options: {\n workspace: string;\n name: string;\n websiteUrl?: string;\n logoUrl?: string;\n description?: string;\n industry?: string;\n size?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n if (options.size && !VALID_SIZES.includes(options.size as OrganizationSize)) {\n throw new Error(`Invalid size \"${options.size}\". Valid: ${VALID_SIZES.join(', ')}`);\n }\n\n const client = getClient();\n const org = await client.organizations.create({\n workspaceId: options.workspace,\n name: options.name,\n websiteUrl: options.websiteUrl,\n logoUrl: options.logoUrl,\n description: options.description,\n industry: options.industry,\n size: options.size as OrganizationSize | undefined,\n });\n\n if (useJson) {\n outputOrganizationJson(org);\n } else {\n console.log('\\n✓ Organization created successfully');\n outputOrganizationPretty(org);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return organizations;\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { createPageCommentsCommand } from './pageComments.js';\nimport { handleError } from '../utils/errors.js';\nimport { readText } from '../utils/input.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n shouldUseJson,\n outputPageJson,\n outputPagePretty,\n outputPagesJson,\n outputPagesPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nexport function createPagesCommand(): Command {\n const pages = new Command('pages').description(\n 'Manage Knowledge pages (PRDs, research, technical specs). Link one to a feature with \"features link-page\".',\n );\n\n pages\n .command('list')\n .description('List pages in a workspace')\n .option('--workspace <slug|id>', 'Workspace (defaults to the configured default)')\n .option('--search <text>', 'Filter by title/content')\n .action(\n async (options: { workspace?: string; search?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const list = await client.pages.list({\n workspaceId,\n search: options.search,\n });\n if (useJson) outputPagesJson(list);\n else outputPagesPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n pages\n .command('get <id>')\n .description('Get a page by CUID (body is Markdown)')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const page = await client.pages.get(id);\n if (useJson) outputPageJson(page);\n else outputPagePretty(page);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n pages\n .command('create')\n .description('Create a page. Body: -b text, --body-file <path>, or --body-file - for stdin.')\n .option('--workspace <slug|id>', 'Workspace (defaults to the configured default)')\n .requiredOption('-t, --title <title>', 'Page title')\n .option('-b, --body <markdown>', 'Markdown body')\n .option('--body-file <path>', 'Read the Markdown body from a file (\"-\" = stdin)')\n .action(\n async (\n options: { workspace?: string; title: string; body?: string; bodyFile?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const page = await client.pages.create({\n workspaceId,\n title: options.title,\n body: readText(options.body, options.bodyFile),\n });\n if (useJson) outputPageJson(page);\n else {\n console.log('\\n✓ Page created');\n outputPagePretty(page);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n pages\n .command('update')\n .description(\n 'Update a page. Sending a body is a Markdown-source write: the Markdown becomes canonical.',\n )\n .requiredOption('--id <id>', 'Page CUID')\n .option('-t, --title <title>', 'New title')\n .option('-b, --body <markdown>', 'New Markdown body (replaces the whole body)')\n .option('--body-file <path>', 'Read the new Markdown body from a file (\"-\" = stdin)')\n .action(\n async (\n options: { id: string; title?: string; body?: string; bodyFile?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const page = await client.pages.update({\n id: options.id,\n title: options.title,\n body: readText(options.body, options.bodyFile),\n });\n if (useJson) outputPageJson(page);\n else {\n console.log('\\n✓ Page updated');\n outputPagePretty(page);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n pages.addCommand(createPageCommentsCommand());\n\n return pages;\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n applyMentions,\n collectMention,\n MENTION_OPTION_DESCRIPTION,\n} from '../utils/mentions.js';\nimport {\n shouldUseJson,\n outputCommentJson,\n outputCommentPretty,\n outputCommentsJson,\n outputCommentsPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\n/**\n * `exponential pages comment …` — the flat discussion feed under a knowledge\n * page. Anyone the page is shared with can comment, including read-only\n * viewers; editing and deleting are author-only.\n */\nexport function createPageCommentsCommand(): Command {\n const comment = new Command('comment').description(\n 'Read and post comments on a page. Mention teammates with --mention.',\n );\n\n comment\n .command('list')\n .description('List comments on a page')\n .requiredOption('--page <id>', 'Page ID')\n .action(async (options: { page: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const comments = await client.pageComments.list(options.page);\n if (useJson) outputCommentsJson(comments);\n else outputCommentsPretty(comments);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('add')\n .description('Add a comment to a page')\n .requiredOption('--page <id>', 'Page ID')\n .requiredOption('-m, --message <text>', 'Comment body (markdown supported)')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .action(\n async (\n options: {\n page: string;\n message: string;\n mention: string[];\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const body =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const created = await client.pageComments.create({\n pageId: options.page,\n body,\n });\n if (useJson) {\n outputCommentJson(created);\n } else {\n console.log('\\n✓ Comment added');\n outputCommentPretty(created);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('update')\n .description('Update one of your own comments')\n .requiredOption('--comment-id <id>', 'Comment ID')\n .requiredOption('-m, --message <text>', 'New comment body')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .action(\n async (\n options: {\n commentId: string;\n message: string;\n mention: string[];\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const body =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const updated = await client.pageComments.update({\n commentId: options.commentId,\n body,\n });\n if (useJson) {\n outputCommentJson(updated);\n } else {\n console.log('\\n✓ Comment updated');\n outputCommentPretty(updated);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('rm')\n .description('Delete one of your own comments')\n .requiredOption('--comment-id <id>', 'Comment ID')\n .action(async (options: { commentId: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.pageComments.delete(options.commentId);\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id: options.commentId }, null, 2));\n } else {\n console.log('✓ Comment deleted');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return comment;\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n shouldUseJson,\n outputProductsJson,\n outputProductsPretty,\n outputProductJson,\n outputProductPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nexport function createProductsCommand(): Command {\n const products = new Command('products').description(\n 'Manage products. A workspace contains products; a product holds features and tickets.',\n );\n\n products\n .command('list')\n .description('List products in a workspace')\n .option('--workspace <slug|id>', 'Workspace slug or CUID (defaults to configured workspace)')\n .action(async (options: { workspace?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const list = await client.products.list(workspaceId);\n if (useJson) outputProductsJson(list);\n else outputProductsPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n products\n .command('get <slugOrId>')\n .description('Get a product by slug or CUID')\n .option('--workspace <slug|id>', 'Workspace (required when using a slug)')\n .action(async (slugOrId: string, options: { workspace?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const product = await client.products.resolve(workspaceId, slugOrId);\n if (useJson) outputProductJson(product);\n else outputProductPretty(product);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n products\n .command('create')\n .description('Create a new product')\n .requiredOption('-n, --name <name>', 'Product name')\n .requiredOption('--slug <slug>', 'Kebab-case slug (matches /^[a-z0-9-]+$/)')\n .option('-d, --description <text>', 'Description')\n .option('--icon <icon>', 'Icon shortcode')\n .option('--color <color>', 'Color')\n .option('--workspace <slug|id>', 'Workspace slug or CUID')\n .action(\n async (\n options: {\n name: string;\n slug: string;\n description?: string;\n icon?: string;\n color?: string;\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n if (!/^[a-z0-9-]+$/.test(options.slug)) {\n throw new Error(\n `Invalid slug \"${options.slug}\". Slug must be kebab-case (a-z, 0-9, -).`,\n );\n }\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const product = await client.products.create({\n workspaceId,\n name: options.name,\n slug: options.slug,\n description: options.description,\n icon: options.icon,\n color: options.color,\n });\n if (useJson) outputProductJson(product);\n else {\n console.log('\\n✓ Product created');\n outputProductPretty(product);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n return products;\n}\n","import { Command } from 'commander';\nimport type { ProjectPriority, ProjectStatus } from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n shouldUseJson,\n outputProjectJson,\n outputProjectPretty,\n outputProjectsJson,\n outputProjectsPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n workspace?: string;\n}\n\nconst PROJECT_STATUSES: ProjectStatus[] = [\n 'ACTIVE',\n 'ON_HOLD',\n 'COMPLETED',\n 'CANCELLED',\n];\n\nconst PROJECT_PRIORITIES: ProjectPriority[] = ['HIGH', 'MEDIUM', 'LOW', 'NONE'];\n\nfunction validateProjectStatus(\n value: string | undefined,\n): ProjectStatus | undefined {\n if (!value) return undefined;\n if (!(PROJECT_STATUSES as string[]).includes(value)) {\n throw new Error(\n `Invalid project status \"${value}\". Valid: ${PROJECT_STATUSES.join(', ')}`,\n );\n }\n return value as ProjectStatus;\n}\n\nfunction validateProjectPriority(\n value: string | undefined,\n): ProjectPriority | undefined {\n if (!value) return undefined;\n if (!(PROJECT_PRIORITIES as string[]).includes(value)) {\n throw new Error(\n `Invalid project priority \"${value}\". Valid: ${PROJECT_PRIORITIES.join(', ')}`,\n );\n }\n return value as ProjectPriority;\n}\n\nexport function createProjectsCommand(): Command {\n const projects = new Command('projects')\n .description('Manage projects');\n\n projects\n .command('list')\n .description('List all projects')\n .option('--workspace <slug|id>', 'Workspace slug or CUID')\n .option('--include-actions', 'Include actions in output')\n .action(async (options: { workspace?: string; includeActions?: boolean }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n // Takes a slug like every other `--workspace` in the CLI; a raw CUID\n // still resolves to itself. Omitted means \"every workspace you can see\",\n // which is what the server does with no filter — so no default is\n // applied here.\n const workspaceId = options.workspace\n ? await resolveWorkspaceId(client, options.workspace)\n : undefined;\n const projects = await client.projects.list({\n workspaceId,\n includeActions: options.includeActions,\n });\n\n if (useJson) {\n outputProjectsJson(projects);\n } else {\n outputProjectsPretty(projects);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n projects\n .command('get <id>')\n .description(\n 'Get one project with its objectives, key results, DRI and actions — none ' +\n 'of which `projects list` carries. Accepts a CUID, a slug, or the ' +\n 'slug-cuid form from app URLs.',\n )\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const project = await client.projects.get(id);\n if (useJson) outputProjectJson(project);\n else outputProjectPretty(project);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n projects\n .command('update')\n .description(\n 'Update a project. Only the fields you pass are written; the rest are read ' +\n 'back from the project and re-sent unchanged.',\n )\n .requiredOption('--id <cuid>', 'Project CUID')\n .option('-n, --name <name>', 'New name')\n .option('-d, --description <text>', 'New description')\n .option('--status <status>', `Status: ${PROJECT_STATUSES.join(', ')}`)\n .option('--priority <priority>', `Priority: ${PROJECT_PRIORITIES.join(', ')}`)\n .option('--product <cuid|none>', 'Product to file the project under (\"none\" to unlink)')\n .option('--dri <userId|none>', 'Directly responsible individual (\"none\" to clear)')\n .action(\n async (\n options: {\n id: string;\n name?: string;\n description?: string;\n status?: string;\n priority?: string;\n product?: string;\n dri?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateProjectStatus(options.status);\n const priority = validateProjectPriority(options.priority);\n const client = getClient();\n const updated = await client.projects.update({\n id: options.id,\n name: options.name,\n description: options.description,\n status,\n priority,\n productId:\n options.product === undefined\n ? undefined\n : options.product === 'none'\n ? null\n : options.product,\n driId:\n options.dri === undefined\n ? undefined\n : options.dri === 'none'\n ? null\n : options.dri,\n });\n if (useJson) outputProjectJson(updated);\n else {\n console.log('\\n✓ Project updated');\n outputProjectPretty(updated);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n projects\n .command('delete')\n .description(\n 'Delete a project. Refuses while it still has actions or is linked to an ' +\n 'objective or key result, unless --force.',\n )\n .requiredOption('--id <cuid>', 'Project CUID')\n .option('--force', 'Delete anyway, taking the actions and links with it')\n .action(async (options: { id: string; force?: boolean }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const project = await client.projects.get(options.id);\n const actions = project.actions ?? [];\n const goals = project.goals ?? [];\n const keyResults = project.keyResults ?? [];\n\n const blockers = [\n actions.length ? `${actions.length} action(s)` : null,\n goals.length ? `${goals.length} objective link(s)` : null,\n keyResults.length ? `${keyResults.length} key result link(s)` : null,\n ].filter(Boolean) as string[];\n\n if (blockers.length > 0 && !options.force) {\n const payload = {\n deleted: false,\n id: project.id,\n reason: `has ${blockers.join(', ')}`,\n actionCount: actions.length,\n goals: goals.map((g) => ({ id: g.id, title: g.title })),\n keyResults: keyResults.map((k) => ({ id: k.keyResultId })),\n };\n if (useJson) console.log(JSON.stringify(payload, null, 2));\n else {\n console.error(\n `Project \"${project.name}\" has ${blockers.join(', ')}.\\n` +\n 'Re-run with --force to delete it anyway.',\n );\n }\n process.exitCode = 1;\n return;\n }\n\n await client.projects.delete(project.id);\n const payload = {\n deleted: true,\n id: project.id,\n actionsDeleted: actions.length,\n };\n if (useJson) console.log(JSON.stringify(payload, null, 2));\n else {\n console.log('✓ Project deleted');\n if (actions.length) {\n console.log(` ${actions.length} action(s) went with it`);\n }\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return projects;\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { shouldUseJson } from '../utils/output.js';\nimport type { SearchResult, Workspace } from 'exponential-sdk';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\ninterface SearchOptions {\n workspace?: string;\n limit?: string;\n}\n\nconst TYPE_LABELS: Record<string, string> = {\n workspace: 'Workspaces',\n project: 'Projects',\n action: 'Actions',\n goal: 'Goals',\n keyResult: 'Key Results',\n outcome: 'Outcomes',\n ticket: 'Tickets',\n feature: 'Features',\n epic: 'Epics',\n page: 'Pages',\n meeting: 'Meetings',\n contact: 'Contacts',\n organization: 'Organizations',\n product: 'Products',\n};\n\nexport function createSearchCommand(): Command {\n const search = new Command('search')\n .description(\n \"Global search across projects, actions, goals, workspaces and more — same coverage as the app's Cmd+K palette\",\n )\n .argument('<query>', 'Text to search for')\n .option('-w, --workspace <slug>', 'Restrict results to one workspace (slug or ID)')\n .option('-l, --limit <n>', 'Max results per entity type (1-25, default 10)')\n .action(async (query: string, options: SearchOptions, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n\n let workspaceId: string | undefined;\n if (options.workspace) {\n const workspaces = await client.workspaces.list();\n const match = workspaces.find(\n (w: Workspace) => w.slug === options.workspace || w.id === options.workspace,\n );\n if (!match) {\n console.error(chalk.red(`Workspace \"${options.workspace}\" not found.`));\n console.log(chalk.gray('Available workspaces:'));\n workspaces.forEach((w: Workspace) => {\n console.log(chalk.gray(` - ${w.slug} (${w.name})`));\n });\n process.exit(1);\n }\n workspaceId = match.id;\n }\n\n const limit = options.limit ? Number(options.limit) : undefined;\n const result = await client.search.global({ query, workspaceId, limit });\n\n if (useJson) {\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n if (result.results.length === 0) {\n console.log(chalk.gray(`No matches for \"${result.query}\".`));\n return;\n }\n\n const byType = new Map<string, SearchResult[]>();\n for (const r of result.results) {\n const bucket = byType.get(r.type) ?? [];\n bucket.push(r);\n byType.set(r.type, bucket);\n }\n\n for (const [type, rows] of byType) {\n console.log(chalk.bold(`\\n${TYPE_LABELS[type] ?? type}`));\n for (const row of rows) {\n const parts = [chalk.white(row.title)];\n if (row.subtitle) parts.push(chalk.gray(row.subtitle));\n if (row.workspace) parts.push(chalk.cyan(`@${row.workspace.slug}`));\n console.log(` ${parts.join(chalk.gray(' · '))}`);\n console.log(chalk.gray(` ${row.id}${row.url ? ` ${row.url}` : ''}`));\n }\n }\n console.log();\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return search;\n}\n","import { Command } from 'commander';\nimport type { TicketStatus, TicketType } from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveProductId, resolveWorkspaceId } from '../utils/resolve.js';\nimport { resolveLabelIds } from './labels.js';\nimport {\n applyMentions,\n collectMention,\n MENTION_OPTION_DESCRIPTION,\n} from '../utils/mentions.js';\n\nfunction collectRepeatable(value: string, previous: string[]): string[] {\n return [...previous, value];\n}\nimport {\n shouldUseJson,\n outputCommentJson,\n outputCommentPretty,\n outputCommentsJson,\n outputCommentsPretty,\n outputTicketJson,\n outputTicketPretty,\n outputTicketsJson,\n outputTicketsPretty,\n outputActionJson,\n outputActionPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nconst TICKET_STATUSES: TicketStatus[] = [\n 'BACKLOG',\n 'NEEDS_REFINEMENT',\n 'READY_TO_PLAN',\n 'COMMITTED',\n 'IN_PROGRESS',\n 'BLOCKED',\n 'QA',\n 'DONE',\n 'DEPLOYED',\n 'ARCHIVED',\n];\n\nconst TICKET_TYPES: TicketType[] = [\n 'BUG',\n 'FEATURE',\n 'CHORE',\n 'IMPROVEMENT',\n 'SPIKE',\n 'RESEARCH',\n];\n\nfunction validateTicketStatus(value: string | undefined): TicketStatus | undefined {\n if (!value) return undefined;\n if (!(TICKET_STATUSES as string[]).includes(value)) {\n throw new Error(\n `Invalid ticket status \"${value}\". Valid: ${TICKET_STATUSES.join(', ')}`,\n );\n }\n return value as TicketStatus;\n}\n\nfunction validateTicketType(value: string | undefined): TicketType | undefined {\n if (!value) return undefined;\n if (!(TICKET_TYPES as string[]).includes(value)) {\n throw new Error(\n `Invalid ticket type \"${value}\". Valid: ${TICKET_TYPES.join(', ')}`,\n );\n }\n return value as TicketType;\n}\n\nexport function createTicketsCommand(): Command {\n const tickets = new Command('tickets').description(\n 'Manage product backlog tickets. Tickets live under a product, link to features/epics, depend on each other, and can be implemented via actions.',\n );\n\n tickets\n .command('list')\n .description(\n 'List tickets in a product, or workspace-wide when --pr or --branch is supplied',\n )\n .option(\n '--product <slug|id>',\n 'Product slug or CUID (required unless --pr or --branch is supplied)',\n )\n .option('--workspace <slug|id>', 'Workspace (required when --product is a slug)')\n .option('--status <status>', `Filter by status: ${TICKET_STATUSES.join(', ')}`)\n .option('--type <type>', `Filter by type: ${TICKET_TYPES.join(', ')}`)\n .option('--feature <id>', 'Filter by feature CUID')\n .option('--epic <id>', 'Filter by epic CUID')\n .option('--assignee <id>', 'Filter by assignee user ID')\n .option(\n '--pr <url>',\n 'Workspace-wide lookup by Ticket.prUrl (exact match). Makes --product optional.',\n )\n .option(\n '--branch <name>',\n 'Workspace-wide lookup by Ticket.branchName (exact match). Makes --product optional.',\n )\n .option(\n '--label <slug-or-id>',\n 'Filter to tickets carrying this label (repeatable; AND semantics)',\n collectRepeatable,\n [] as string[],\n )\n .action(\n async (\n options: {\n product?: string;\n workspace?: string;\n status?: string;\n type?: string;\n feature?: string;\n epic?: string;\n assignee?: string;\n pr?: string;\n branch?: string;\n label: string[];\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateTicketStatus(options.status);\n const type = validateTicketType(options.type);\n const hasWorkspaceFilter = Boolean(options.pr || options.branch);\n if (!hasWorkspaceFilter && !options.product) {\n throw new Error(\n '--product is required unless --pr or --branch is supplied',\n );\n }\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const filters = {\n status,\n type,\n featureId: options.feature,\n epicId: options.epic,\n assigneeId: options.assignee,\n prUrl: options.pr,\n branchName: options.branch,\n };\n\n // `product.ticket.list` is product-scoped on the server — there is no\n // workspace-wide ticket query — so a --pr/--branch lookup with no\n // --product sweeps every product in the workspace and merges. Without\n // this the flag combination sent productId: undefined and the server\n // rejected it outright. A PR URL or branch name identifies at most a\n // handful of tickets, so the fan-out stays small.\n let list;\n if (options.product) {\n const productId = await resolveProductId(\n client,\n workspaceId,\n options.product,\n );\n list = await client.tickets.list({ productId, ...filters });\n } else {\n const products = await client.products.list(workspaceId);\n const settled = await Promise.allSettled(\n products.map((p) => client.tickets.list({ productId: p.id, ...filters })),\n );\n list = settled.flatMap((r) => (r.status === 'fulfilled' ? r.value : []));\n // A product the caller can't read must not blank the whole lookup,\n // but a silently short result is worse than a noisy one.\n settled.forEach((r, i) => {\n if (r.status !== 'rejected') return;\n const reason =\n r.reason instanceof Error ? r.reason.message : String(r.reason);\n console.error(`Warning: skipped product ${products[i]!.slug}: ${reason}`);\n });\n }\n let filtered = list;\n if (options.label.length > 0) {\n const labelIds = new Set(\n await resolveLabelIds(client, workspaceId, options.label),\n );\n const ticketLabelSets = await Promise.all(\n list.map((t) =>\n client.labels\n .listForEntity({ entityType: 'ticket', entityId: t.id })\n .then((tags) => new Set(tags.map((tag) => tag.id))),\n ),\n );\n filtered = list.filter((_t, idx) => {\n const tagSet = ticketLabelSets[idx];\n if (tagSet === undefined) return false;\n for (const id of labelIds) {\n if (!tagSet.has(id)) return false;\n }\n return true;\n });\n }\n if (useJson) outputTicketsJson(filtered);\n else outputTicketsPretty(filtered);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n tickets\n .command('get <id>')\n .description('Show a ticket with dependencies, actions, and comments')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const ticket = await client.tickets.get(id);\n if (useJson) outputTicketJson(ticket);\n else outputTicketPretty(ticket);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n tickets\n .command('show <id>')\n .description('Alias for `tickets get`')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const ticket = await client.tickets.get(id);\n if (useJson) outputTicketJson(ticket);\n else outputTicketPretty(ticket);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n tickets\n .command('create')\n .description('Create a new ticket in a product')\n .requiredOption('--product <slug|id>', 'Product slug or CUID')\n .requiredOption('-t, --title <title>', 'Ticket title')\n .option('-b, --body <text>', 'Body (markdown supported)')\n .option('--type <type>', `Ticket type: ${TICKET_TYPES.join(', ')}`)\n .option('--status <status>', `Initial status: ${TICKET_STATUSES.join(', ')}`)\n .option('--priority <n>', 'Priority 0-4 (lower = higher)', parseInt)\n .option('--points <n>', 'Story points', parseFloat)\n .option('--feature <id>', 'Feature CUID to attach to')\n .option('--scope <id>', 'Feature scope CUID to attach to (requires --feature)')\n .option('--epic <id>', 'Epic CUID to attach to')\n .option('--cycle <id>', 'Cycle CUID to assign to')\n .option('--assignee <id>', 'Assignee user ID')\n .option('--branch <name>', 'Branch name')\n .option('--pr <url>', 'Pull request URL')\n .option('--workspace <slug|id>', 'Workspace (required when --product is a slug)')\n .option(\n '--label <slug-or-id>',\n 'Label to attach (repeatable)',\n collectRepeatable,\n [] as string[],\n )\n .action(\n async (\n options: {\n product: string;\n title: string;\n body?: string;\n type?: string;\n status?: string;\n priority?: number;\n points?: number;\n feature?: string;\n scope?: string;\n epic?: string;\n cycle?: string;\n assignee?: string;\n branch?: string;\n pr?: string;\n workspace?: string;\n label: string[];\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateTicketStatus(options.status);\n const type = validateTicketType(options.type);\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const productId = await resolveProductId(\n client,\n workspaceId,\n options.product,\n );\n const ticket = await client.tickets.create({\n productId,\n title: options.title,\n body: options.body,\n type,\n status,\n priority: options.priority,\n points: options.points,\n featureId: options.feature,\n scopeId: options.scope,\n epicId: options.epic,\n cycleId: options.cycle,\n assigneeId: options.assignee,\n branchName: options.branch,\n prUrl: options.pr,\n });\n if (options.label.length > 0) {\n const tagIds = await resolveLabelIds(client, workspaceId, options.label);\n await client.labels.setEntityTags({\n entityType: 'ticket',\n entityId: ticket.id,\n tagIds,\n });\n }\n if (useJson) outputTicketJson(ticket);\n else {\n console.log('\\n✓ Ticket created');\n outputTicketPretty(ticket);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n tickets\n .command('update')\n .description('Update an existing ticket')\n .requiredOption('--id <id>', 'Ticket CUID')\n .option('-t, --title <title>', 'New title')\n .option('-b, --body <text>', 'New body')\n .option('--type <type>', `Type: ${TICKET_TYPES.join(', ')}`)\n .option('--status <status>', `Status: ${TICKET_STATUSES.join(', ')}`)\n .option('--priority <n>', 'Priority 0-4 (or \"null\" to clear)')\n .option('--points <n>', 'Story points (or \"null\" to clear)')\n .option('--feature <id>', 'Feature CUID (or \"null\" to detach)')\n .option('--epic <id>', 'Epic CUID (or \"null\" to detach)')\n .option('--cycle <id>', 'Cycle CUID (or \"null\" to detach)')\n .option('--assignee <id>', 'Assignee user ID (or \"null\" to unassign)')\n .option('--branch <name>', 'Branch name (or \"null\")')\n .option('--pr <url>', 'PR URL (or \"null\")')\n .option(\n '--add-label <slug-or-id>',\n 'Label to attach to this ticket (repeatable)',\n collectRepeatable,\n [] as string[],\n )\n .option(\n '--remove-label <slug-or-id>',\n 'Label to detach from this ticket (repeatable)',\n collectRepeatable,\n [] as string[],\n )\n .action(\n async (\n options: {\n id: string;\n title?: string;\n body?: string;\n type?: string;\n status?: string;\n priority?: string;\n points?: string;\n feature?: string;\n epic?: string;\n cycle?: string;\n assignee?: string;\n branch?: string;\n pr?: string;\n addLabel: string[];\n removeLabel: string[];\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const parseNullableInt = (v: string | undefined): number | null | undefined => {\n if (v === undefined) return undefined;\n if (v === 'null') return null;\n const n = parseInt(v, 10);\n if (isNaN(n)) throw new Error(`Invalid number: ${v}`);\n return n;\n };\n const parseNullableFloat = (v: string | undefined): number | null | undefined => {\n if (v === undefined) return undefined;\n if (v === 'null') return null;\n const n = parseFloat(v);\n if (isNaN(n)) throw new Error(`Invalid number: ${v}`);\n return n;\n };\n const parseNullableString = (v: string | undefined): string | null | undefined => {\n if (v === undefined) return undefined;\n if (v === 'null') return null;\n return v;\n };\n\n const status = validateTicketStatus(options.status);\n const type = validateTicketType(options.type);\n const client = getClient();\n const ticket = await client.tickets.update({\n id: options.id,\n title: options.title,\n body: options.body,\n type,\n status,\n priority: parseNullableInt(options.priority),\n points: parseNullableFloat(options.points),\n featureId: parseNullableString(options.feature),\n epicId: parseNullableString(options.epic),\n cycleId: parseNullableString(options.cycle),\n assigneeId: parseNullableString(options.assignee),\n branchName: parseNullableString(options.branch),\n prUrl: parseNullableString(options.pr),\n });\n if (options.addLabel.length > 0 || options.removeLabel.length > 0) {\n const current = await client.labels.listForEntity({\n entityType: 'ticket',\n entityId: options.id,\n });\n const currentIds = new Set(current.map((t) => t.id));\n const addIds = await resolveLabelIds(client, undefined, options.addLabel);\n const removeIds = await resolveLabelIds(client, undefined, options.removeLabel);\n for (const id of addIds) currentIds.add(id);\n for (const id of removeIds) currentIds.delete(id);\n await client.labels.setEntityTags({\n entityType: 'ticket',\n entityId: options.id,\n tagIds: [...currentIds],\n });\n }\n if (useJson) outputTicketJson(ticket);\n else {\n console.log('\\n✓ Ticket updated');\n outputTicketPretty(ticket);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n tickets\n .command('delete <id>')\n .description('Delete a ticket')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.tickets.delete(id);\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id }, null, 2));\n } else {\n console.log('\\n✓ Ticket deleted');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n tickets\n .command('block <ticket>')\n .description('Mark <ticket> as blocked by another ticket')\n .requiredOption('--by <id>', 'Ticket CUID that must complete first')\n .action(\n async (ticket: string, options: { by: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const dep = await client.tickets.addDependency(ticket, options.by);\n if (useJson) {\n console.log(JSON.stringify(dep, null, 2));\n } else {\n const depId = dep.dependsOn.shortId ?? (dep.dependsOn.number != null ? `#${dep.dependsOn.number}` : dep.dependsOn.id);\n console.log(`\\n✓ Ticket ${ticket} now depends on ${depId} ${dep.dependsOn.title}`);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n tickets\n .command('unblock <ticket>')\n .description('Remove a blocking dependency from <ticket>')\n .requiredOption('--by <id>', 'The ticket CUID that was blocking')\n .action(\n async (ticket: string, options: { by: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.tickets.removeDependency(ticket, options.by);\n if (useJson) {\n console.log(JSON.stringify({ ticketId: ticket, removedBlocker: options.by }, null, 2));\n } else {\n console.log(`\\n✓ Dependency removed: ${ticket} no longer blocked by ${options.by}`);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n tickets\n .command('link-action')\n .description('Attach an existing action to a ticket')\n .requiredOption('--id <id>', 'Ticket CUID')\n .requiredOption('--action <id>', 'Action CUID')\n .action(async (options: { id: string; action: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const action = await client.tickets.linkAction(options.id, options.action);\n if (useJson) outputActionJson(action);\n else {\n console.log('\\n✓ Action linked to ticket');\n outputActionPretty(action);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n tickets\n .command('unlink-action')\n .description('Detach an action from whatever ticket it is on')\n .requiredOption('--action <id>', 'Action CUID')\n .action(async (options: { action: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const action = await client.tickets.unlinkAction(options.action);\n if (useJson) outputActionJson(action);\n else {\n console.log('\\n✓ Action unlinked');\n outputActionPretty(action);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n const comment = new Command('comment').description('Manage comments on a ticket');\n\n comment\n .command('list')\n .description('List comments on a ticket')\n .requiredOption('--id <id>', 'Ticket CUID')\n .action(async (options: { id: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n // Ticket comments ride along on the detail fetch — there is no\n // standalone list procedure server-side.\n const ticket = await client.tickets.get(options.id);\n const comments = ticket.comments ?? [];\n if (useJson) outputCommentsJson(comments);\n else outputCommentsPretty(comments);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('add')\n .description('Add a comment to a ticket')\n .requiredOption('--id <id>', 'Ticket CUID')\n .requiredOption('-m, --message <text>', 'Comment content (markdown supported)')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .action(\n async (\n options: {\n id: string;\n message: string;\n mention: string[];\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const content =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const created = await client.tickets.addComment({\n ticketId: options.id,\n content,\n });\n if (useJson) outputCommentJson(created);\n else {\n console.log('\\n✓ Comment added');\n outputCommentPretty(created);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('update')\n .description('Update one of your own ticket comments')\n .requiredOption('--comment-id <id>', 'Comment ID')\n .requiredOption('-m, --message <text>', 'New comment content')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .action(\n async (\n options: {\n commentId: string;\n message: string;\n mention: string[];\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const content =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const updated = await client.tickets.updateComment({\n id: options.commentId,\n content,\n });\n if (useJson) outputCommentJson(updated);\n else {\n console.log('\\n✓ Comment updated');\n outputCommentPretty(updated);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('delete')\n .description('Delete one of your own ticket comments')\n .requiredOption('--comment-id <id>', 'Comment ID')\n .action(async (options: { commentId: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.tickets.deleteComment(options.commentId);\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id: options.commentId }, null, 2));\n } else {\n console.log('\\n✓ Comment deleted');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n tickets.addCommand(comment);\n\n return tickets;\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { getClient } from '../client/index.js';\nimport { getConfig, setConfig } from '../config/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n shouldUseJson,\n outputWorkspacesJson,\n outputWorkspacesPretty,\n} from '../utils/output.js';\nimport type { Workspace } from 'exponential-sdk';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nexport function createWorkspacesCommand(): Command {\n const workspaces = new Command('workspaces')\n .description('Manage workspaces');\n\n workspaces\n .command('list')\n .description('List all workspaces')\n .action(async (_options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const workspaces = await client.workspaces.list();\n\n if (useJson) {\n outputWorkspacesJson(workspaces);\n } else {\n const config = getConfig();\n outputWorkspacesPretty(workspaces);\n\n if (config.defaultWorkspaceSlug) {\n console.log(chalk.gray(`Default workspace: ${config.defaultWorkspaceSlug}`));\n }\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n workspaces\n .command('set-default <slug>')\n .description('Set the default workspace')\n .action(async (slug: string) => {\n try {\n const client = getClient();\n const workspaces = await client.workspaces.list();\n\n const workspace = workspaces.find((w: Workspace) => w.slug === slug);\n\n if (!workspace) {\n console.error(chalk.red(`Workspace with slug \"${slug}\" not found.`));\n console.log(chalk.gray('Available workspaces:'));\n workspaces.forEach((w: Workspace) => {\n console.log(chalk.gray(` - ${w.slug} (${w.name})`));\n });\n process.exit(1);\n }\n\n setConfig({\n defaultWorkspaceId: workspace.id,\n defaultWorkspaceSlug: workspace.slug,\n });\n\n console.log(chalk.green(`Default workspace set to: ${workspace.name} (${workspace.slug})`));\n } catch (error) {\n handleError(error);\n }\n });\n\n workspaces\n .command('members')\n .description(\n 'List workspace members. Each row carries the exact @[Name](id) markup to paste into a comment to mention that person.',\n )\n .option('--workspace <slug|id>', 'Workspace (defaults to your default workspace)')\n .option('--search <text>', 'Filter by name or email')\n .action(\n async (options: { workspace?: string; search?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n let members = await client.workspaces.listMembers(workspaceId);\n\n if (options.search) {\n const needle = options.search.toLowerCase();\n members = members.filter(\n (m) =>\n m.name?.toLowerCase().includes(needle) ||\n m.email?.toLowerCase().includes(needle),\n );\n }\n\n if (useJson) {\n console.log(\n JSON.stringify({ members, total: members.length }, null, 2),\n );\n return;\n }\n\n if (members.length === 0) {\n console.log(chalk.gray('No members found.'));\n return;\n }\n\n console.log(chalk.bold(`\\nMembers (${members.length})\\n`));\n for (const m of members) {\n const label = m.name ?? m.email ?? m.id;\n // `role` is always the workspace role; a team member's team role is\n // reported separately so it is never mistaken for workspace authority.\n const via = m.source === 'team'\n ? chalk.gray(\n ` via team${m.teams.length ? `: ${m.teams.map((t) => t.name).join(', ')}` : ''}` +\n (m.teamRole ? ` [team ${m.teamRole}]` : ''),\n )\n : '';\n console.log(`${chalk.bold(label)} ${chalk.gray(`(${m.role})`)}${via}`);\n if (m.email) console.log(chalk.gray(` ${m.email}`));\n console.log(chalk.gray(` mention: ${m.mentionSyntax}`));\n console.log();\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n return workspaces;\n}\n","import { Command } from 'commander';\nimport type {\n GoalStatus,\n GoalWritableStatus,\n KeyResultStatus,\n KeyResultUnit,\n ObjectiveWithKeyResults,\n Workspace,\n} from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveWorkspace, resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n applyMentions,\n collectMention,\n MENTION_OPTION_DESCRIPTION,\n} from '../utils/mentions.js';\nimport {\n shouldUseJson,\n outputCommentJson,\n outputCommentPretty,\n outputCommentsJson,\n outputCommentsPretty,\n outputGoalJson,\n outputGoalPretty,\n outputGoalsJson,\n outputGoalsPretty,\n outputGoalTreeJson,\n outputGoalTreePretty,\n outputGoalPeriodsJson,\n outputGoalPeriodsPretty,\n outputGoalStatsJson,\n outputGoalStatsPretty,\n outputKeyResultJson,\n outputKeyResultPretty,\n outputKeyResultsJson,\n outputKeyResultsPretty,\n outputCheckInJson,\n outputCheckInPretty,\n outputObjectivesJson,\n outputObjectivesPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\n/** Statuses `goals set-status` / `goals close` accept. */\nconst GOAL_STATUSES: GoalStatus[] = [\n 'planned',\n 'active',\n 'completed',\n 'archived',\n 'on-hold',\n];\n\n/**\n * Statuses `goals create` / `goals update` accept. `on-hold` is deliberately\n * absent: only `updateGoalStatus` takes it, which is what `set-status` calls.\n */\nconst GOAL_WRITABLE_STATUSES: GoalWritableStatus[] = [\n 'planned',\n 'active',\n 'completed',\n 'archived',\n];\n\nconst KEY_RESULT_STATUSES: KeyResultStatus[] = [\n 'not-started',\n 'on-track',\n 'at-risk',\n 'off-track',\n 'achieved',\n];\n\nconst KEY_RESULT_UNITS: KeyResultUnit[] = [\n 'percent',\n 'count',\n 'currency',\n 'hours',\n 'custom',\n];\n\n/**\n * The current quarter as a period string, e.g. `Q3-2026`. Mirrors how the\n * server derives the coaching-home period; `okrs list` defaults to it because\n * \"how is the quarter going\" almost always means *this* quarter.\n */\nfunction currentPeriod(): string {\n const now = new Date();\n return `Q${Math.floor(now.getMonth() / 3) + 1}-${now.getFullYear()}`;\n}\n\n/**\n * Resolve `--workspace` / `--all-workspaces` to the set of workspaces to read.\n *\n * \"Am I neglecting a goal\" is inherently a cross-workspace question, so the\n * flag lives here rather than making every caller write the loop. The\n * procedures are per-workspace, so this fans out and the caller concatenates.\n */\nasync function targetWorkspaces(\n client: ReturnType<typeof getClient>,\n options: { workspace?: string; allWorkspaces?: boolean },\n): Promise<Workspace[]> {\n if (options.allWorkspaces) {\n if (options.workspace) {\n throw new Error('--workspace and --all-workspaces are mutually exclusive.');\n }\n return await client.workspaces.list();\n }\n return [await resolveWorkspace(client, options.workspace)];\n}\n\n/**\n * Fan a per-workspace read out across workspaces, keeping partial results.\n *\n * A cross-workspace sweep exists to answer \"what am I neglecting\", so one\n * workspace the caller can no longer read must not take the rest with it —\n * `okr.getByObjective` throws FORBIDDEN for a non-member, and membership does\n * lapse. Failures are surfaced on stderr rather than swallowed: a silently\n * short list is worse than none. If nothing succeeded, the first error is\n * rethrown, which is also what makes a single-workspace read still fail loudly.\n */\nasync function fanOutByWorkspace<T>(\n workspaces: Workspace[],\n read: (workspace: Workspace) => Promise<T[]>,\n): Promise<T[]> {\n const settled = await Promise.allSettled(workspaces.map(read));\n const items: T[] = [];\n const skipped: string[] = [];\n settled.forEach((result, i) => {\n if (result.status === 'fulfilled') {\n items.push(...result.value);\n return;\n }\n const reason =\n result.reason instanceof Error ? result.reason.message : String(result.reason);\n skipped.push(`${workspaces[i]!.slug}: ${reason}`);\n });\n\n if (skipped.length === workspaces.length) {\n const [first] = settled.filter((r) => r.status === 'rejected');\n throw (first as PromiseRejectedResult).reason;\n }\n // stderr, so a skipped workspace is visible without corrupting piped JSON.\n for (const line of skipped) {\n console.error(`Warning: skipped workspace ${line}`);\n }\n return items;\n}\n\n/**\n * Objective ids are integers, not cuids — the CLI parses them here so a typo\n * fails with a readable message instead of a server-side zod error.\n */\nfunction parseGoalId(value: string): number {\n const id = Number(value);\n if (!Number.isInteger(id)) {\n throw new Error(\n `Goal id must be a whole number, got \"${value}\". List them with \\`exponential goals list\\`.`,\n );\n }\n return id;\n}\n\nfunction parseNumber(value: string, label: string): number {\n const n = Number(value);\n if (!Number.isFinite(n)) {\n throw new Error(`${label} must be a number, got \"${value}\".`);\n }\n return n;\n}\n\nfunction validateGoalStatus(value: string | undefined): GoalStatus | undefined {\n if (!value) return undefined;\n if (!(GOAL_STATUSES as string[]).includes(value)) {\n throw new Error(`Invalid status \"${value}\". Valid: ${GOAL_STATUSES.join(', ')}`);\n }\n return value as GoalStatus;\n}\n\nfunction validateWritableGoalStatus(\n value: string | undefined,\n): GoalWritableStatus | undefined {\n if (!value) return undefined;\n if (!(GOAL_WRITABLE_STATUSES as string[]).includes(value)) {\n const extra = value === 'on-hold' ? ' Use `goals set-status` for on-hold.' : '';\n throw new Error(\n `Invalid status \"${value}\". Valid: ${GOAL_WRITABLE_STATUSES.join(', ')}.${extra}`,\n );\n }\n return value as GoalWritableStatus;\n}\n\nfunction validateKeyResultStatus(\n value: string | undefined,\n): KeyResultStatus | undefined {\n if (!value) return undefined;\n if (!(KEY_RESULT_STATUSES as string[]).includes(value)) {\n throw new Error(\n `Invalid status \"${value}\". Valid: ${KEY_RESULT_STATUSES.join(', ')}`,\n );\n }\n return value as KeyResultStatus;\n}\n\nfunction validateKeyResultUnit(value: string | undefined): KeyResultUnit | undefined {\n if (!value) return undefined;\n if (!(KEY_RESULT_UNITS as string[]).includes(value)) {\n throw new Error(`Invalid unit \"${value}\". Valid: ${KEY_RESULT_UNITS.join(', ')}`);\n }\n return value as KeyResultUnit;\n}\n\n/**\n * `exponential goals kr …` — key results.\n *\n * Kept as a subtree of `goals` because a key result is meaningless without its\n * objective, and because the tRPC router mounted at `okr` is the KEY RESULT\n * router — naming the group `kr` keeps that straight. Ids here are cuids; the\n * `--goal` they hang off is an integer.\n */\nfunction createKeyResultsCommand(): Command {\n const kr = new Command('kr').description(\n 'Key results on an objective. Ids are CUIDs; --goal takes the objective\\'s integer id.',\n );\n\n kr.command('list')\n .description('List key results')\n .option('--goal <id>', 'Objective ID (a number)')\n .option('-w, --workspace <slug|id>', 'Workspace (workspace-wide: every member\\'s KRs)')\n .option('--period <period>', 'Period, e.g. Q3-2026')\n .option('--status <status>', `Filter by status: ${KEY_RESULT_STATUSES.join(', ')}`)\n .option('--mine', 'Narrow a workspace list to key results you own')\n .action(\n async (\n options: {\n goal?: string;\n workspace?: string;\n period?: string;\n status?: string;\n mine?: boolean;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateKeyResultStatus(options.status);\n const client = getClient();\n const goalId = options.goal ? parseGoalId(options.goal) : undefined;\n\n // No --workspace and no --goal keeps this the caller's personal list;\n // resolving a default workspace here would silently widen it. With a\n // --goal, borrow that objective's own workspace: an unscoped\n // `okr.getAll` is owner-scoped server-side, so \"the key results on\n // objective #48\" comes back empty for anyone but their author.\n let workspaceId: string | undefined;\n if (options.workspace) {\n workspaceId = await resolveWorkspaceId(client, options.workspace);\n } else if (goalId !== undefined) {\n const goal = await client.goals.get(goalId);\n workspaceId = goal.workspaceId ?? undefined;\n }\n\n const list = await client.goals.keyResults.list({\n workspaceId,\n goalId,\n period: options.period,\n status,\n onlyMine: options.mine,\n });\n if (useJson) outputKeyResultsJson(list);\n else outputKeyResultsPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n kr.command('get <id>')\n .description('Get a key result by CUID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const keyResult = await getClient().goals.keyResults.get(id);\n if (useJson) outputKeyResultJson(keyResult);\n else outputKeyResultPretty(keyResult);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n kr.command('create')\n .description('Create a key result on an objective')\n .requiredOption('--goal <id>', 'Objective ID (a number)')\n .requiredOption('-t, --title <text>', 'Key result title')\n .requiredOption('--target <n>', 'Target value')\n .option('--start <n>', 'Starting value (default 0)')\n .option('--current <n>', 'Current value (defaults to the start value)')\n .option('--unit <unit>', `Unit: ${KEY_RESULT_UNITS.join(', ')}`)\n .option('--period <period>', 'Period, e.g. Q3-2026 (defaults to the objective\\'s)')\n .option('-d, --description <text>', 'Description')\n .option('--dri <userId>', 'Directly responsible individual (user ID)')\n .action(\n async (\n options: {\n goal: string;\n title: string;\n target: string;\n start?: string;\n current?: string;\n unit?: string;\n period?: string;\n description?: string;\n dri?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const unit = validateKeyResultUnit(options.unit);\n const client = getClient();\n const goalId = parseGoalId(options.goal);\n const startValue = options.start\n ? parseNumber(options.start, '--start')\n : undefined;\n\n // `period` is required by the server but is a property of the OKR\n // cycle, not of the individual KR — fall back to the objective's so\n // the common case needs one less flag.\n // The SDK resolves the objective's workspace when none is passed; if\n // we fetch the objective here anyway, hand that workspace over rather\n // than making it read the same row twice.\n let period = options.period;\n let workspaceId: string | undefined;\n if (!period) {\n const goal = await client.goals.get(goalId);\n if (!goal.period) {\n throw new Error(\n `Objective #${goalId} has no period, so --period is required. See \\`exponential goals periods\\`.`,\n );\n }\n period = goal.period;\n workspaceId = goal.workspaceId ?? undefined;\n }\n\n const keyResult = await client.goals.keyResults.create({\n goalId,\n workspaceId,\n title: options.title,\n targetValue: parseNumber(options.target, '--target'),\n startValue,\n currentValue: options.current\n ? parseNumber(options.current, '--current')\n : startValue,\n unit,\n period,\n description: options.description,\n driUserId: options.dri,\n });\n if (useJson) outputKeyResultJson(keyResult);\n else {\n console.log('\\n✓ Key result created');\n outputKeyResultPretty(keyResult);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n kr.command('update')\n .description('Update a key result (only the flags you pass are written)')\n .requiredOption('--id <cuid>', 'Key result CUID')\n .option('-t, --title <text>', 'New title')\n .option('-d, --description <text>', 'New description')\n .option('--current <n>', 'Current value (prefer `kr checkin` — it records history)')\n .option('--target <n>', 'Target value')\n .option('--start <n>', 'Starting value')\n .option('--unit <unit>', `Unit: ${KEY_RESULT_UNITS.join(', ')}`)\n .option('--status <status>', `Status: ${KEY_RESULT_STATUSES.join(', ')}`)\n .option('--confidence <n>', 'Confidence 0-100')\n .option('--dri <userId>', 'Directly responsible individual (user ID)')\n .option('--goal <id>', 'Move the key result to a different objective')\n .action(\n async (\n options: {\n id: string;\n title?: string;\n description?: string;\n current?: string;\n target?: string;\n start?: string;\n unit?: string;\n status?: string;\n confidence?: string;\n dri?: string;\n goal?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateKeyResultStatus(options.status);\n const unit = validateKeyResultUnit(options.unit);\n const keyResult = await getClient().goals.keyResults.update({\n id: options.id,\n title: options.title,\n description: options.description,\n currentValue: options.current\n ? parseNumber(options.current, '--current')\n : undefined,\n targetValue: options.target\n ? parseNumber(options.target, '--target')\n : undefined,\n startValue: options.start\n ? parseNumber(options.start, '--start')\n : undefined,\n unit,\n status,\n confidence: options.confidence\n ? parseNumber(options.confidence, '--confidence')\n : undefined,\n driUserId: options.dri,\n goalId: options.goal ? parseGoalId(options.goal) : undefined,\n });\n if (useJson) outputKeyResultJson(keyResult);\n else {\n console.log('\\n✓ Key result updated');\n outputKeyResultPretty(keyResult);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n kr.command('checkin')\n .description(\n 'Record a progress check-in. Moves the value AND re-derives the status ' +\n 'from where it lands between start and target.',\n )\n .requiredOption('--id <cuid>', 'Key result CUID')\n .requiredOption('--value <n>', 'New current value')\n .option('--note <text>', 'Check-in note')\n .action(\n async (\n options: { id: string; value: string; note?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const checkIn = await getClient().goals.keyResults.checkIn({\n id: options.id,\n value: parseNumber(options.value, '--value'),\n note: options.note,\n });\n if (useJson) outputCheckInJson(checkIn);\n else {\n console.log('\\n✓ Check-in recorded');\n outputCheckInPretty(checkIn);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n kr.command('delete')\n .description('Delete a key result')\n .requiredOption('--id <cuid>', 'Key result CUID')\n .action(async (options: { id: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n await getClient().goals.keyResults.delete(options.id);\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id: options.id }, null, 2));\n } else {\n console.log('✓ Key result deleted');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n kr.command('link')\n .description('Link executing work (a project or a feature) to a key result')\n .requiredOption('--id <cuid>', 'Key result CUID')\n .option('--project <cuid>', 'Project CUID')\n .option('--feature <cuid>', 'Feature CUID')\n .action(\n async (\n options: { id: string; project?: string; feature?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n if (!options.project === !options.feature) {\n throw new Error('Pass exactly one of --project or --feature.');\n }\n const client = getClient();\n const result = options.project\n ? await client.goals.keyResults.linkProject({\n keyResultId: options.id,\n projectId: options.project,\n })\n : await client.goals.keyResults.linkFeature({\n keyResultId: options.id,\n featureId: options.feature!,\n });\n if (useJson) console.log(JSON.stringify(result, null, 2));\n else console.log(`\\n✓ ${options.project ? 'Project' : 'Feature'} linked`);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n kr.command('unlink')\n .description('Unlink a project or feature from a key result')\n .requiredOption('--id <cuid>', 'Key result CUID')\n .option('--project <cuid>', 'Project CUID')\n .option('--feature <cuid>', 'Feature CUID')\n .action(\n async (\n options: { id: string; project?: string; feature?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n if (!options.project === !options.feature) {\n throw new Error('Pass exactly one of --project or --feature.');\n }\n const client = getClient();\n const result = options.project\n ? await client.goals.keyResults.unlinkProject({\n keyResultId: options.id,\n projectId: options.project,\n })\n : await client.goals.keyResults.unlinkFeature({\n keyResultId: options.id,\n featureId: options.feature!,\n });\n if (useJson) console.log(JSON.stringify(result, null, 2));\n else console.log(`\\n✓ ${options.project ? 'Project' : 'Feature'} unlinked`);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n return kr;\n}\n\nfunction createGoalCommentsCommand(): Command {\n const comment = new Command('comment').description(\n 'Read and post comments on a goal. Mention teammates with --mention.',\n );\n\n comment\n .command('list')\n .description('List comments on a goal')\n .requiredOption('--goal <id>', 'Goal ID (a number)')\n .action(async (options: { goal: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const comments = await client.goalComments.list(parseGoalId(options.goal));\n if (useJson) outputCommentsJson(comments);\n else outputCommentsPretty(comments);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('add')\n .description('Add a comment to a goal')\n .requiredOption('--goal <id>', 'Goal ID (a number)')\n .requiredOption('-m, --message <text>', 'Comment content (markdown supported)')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .option('--parent-update <id>', 'Thread under a specific goal update')\n .action(\n async (\n options: {\n goal: string;\n message: string;\n mention: string[];\n workspace?: string;\n parentUpdate?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const goalId = parseGoalId(options.goal);\n const content =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const created = await client.goalComments.add({\n goalId,\n content,\n parentUpdateId: options.parentUpdate,\n });\n if (useJson) {\n outputCommentJson(created);\n } else {\n console.log('\\n✓ Comment added');\n outputCommentPretty(created);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('update')\n .description('Update one of your own comments')\n .requiredOption('--comment-id <id>', 'Comment ID')\n .requiredOption('-m, --message <text>', 'New comment content')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .action(\n async (\n options: {\n commentId: string;\n message: string;\n mention: string[];\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const content =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const updated = await client.goalComments.update({\n commentId: options.commentId,\n content,\n });\n if (useJson) {\n outputCommentJson(updated);\n } else {\n console.log('\\n✓ Comment updated');\n outputCommentPretty(updated);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('rm')\n .description('Delete one of your own comments')\n .requiredOption('--comment-id <id>', 'Comment ID')\n .action(async (options: { commentId: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.goalComments.delete(options.commentId);\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id: options.commentId }, null, 2));\n } else {\n console.log('✓ Comment deleted');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return comment;\n}\n\n/**\n * `exponential goals …` — objectives (`Goal`, integer ids), their key results,\n * and their comments.\n *\n * Three separate write paths on purpose. `update` is a partial update that\n * sends only the flags you pass; `set-status`/`close` route through the\n * status-only procedure; `reparent` writes the parent alone. Closing a quarter\n * or moving a goal in the cascade should never risk a collateral write — an\n * agent once archived a goal with a title-and-status update and orphaned it out\n * of its workspace in the process.\n */\nexport function createGoalsCommand(): Command {\n const goals = new Command('goals').description(\n 'Manage goals (objectives) and their key results. Objectives have integer ids; key results are CUIDs.',\n );\n\n goals\n .command('list')\n .description(\n 'List objectives, each with the projects linked to it — the join that ' +\n 'ties an action (which carries a projectId) back to a goal.',\n )\n .option('-w, --workspace <slug|id>', 'Workspace slug or ID (defaults to your default workspace)')\n .option('--all-workspaces', 'List across every workspace you belong to')\n .option('--period <period>', 'Filter by period, e.g. Q3-2026')\n .option('--status <status>', `Filter by status: ${GOAL_STATUSES.join(', ')}`)\n .option('--tree', 'Render the parent/child cascade instead of a flat list')\n .action(\n async (\n options: {\n workspace?: string;\n allWorkspaces?: boolean;\n period?: string;\n status?: string;\n tree?: boolean;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateGoalStatus(options.status);\n const client = getClient();\n const workspaces = await targetWorkspaces(client, options);\n\n if (options.tree) {\n // getGoalTree has no period filter, so --period is applied here.\n // It only prunes roots — a matching child under a non-matching\n // parent would otherwise vanish, which is the opposite of what a\n // cascade view is for.\n const trees = await fanOutByWorkspace(workspaces, (w) =>\n client.goals.tree({ workspaceId: w.id, status }),\n );\n const filtered = options.period\n ? trees.filter((g) => g.period === options.period)\n : trees;\n if (useJson) outputGoalTreeJson(filtered);\n else outputGoalTreePretty(filtered);\n return;\n }\n\n const list = await fanOutByWorkspace(workspaces, async (workspace) => {\n const goals = await client.goals.list({\n workspaceId: workspace.id,\n period: options.period,\n status,\n });\n // The server attaches `workspace`, but only since the goals\n // release — fill it in from the workspace we just queried so a\n // cross-workspace list is labelled either way.\n return goals.map((g) => ({ ...g, workspace: g.workspace ?? workspace }));\n });\n if (useJson) outputGoalsJson(list);\n else outputGoalsPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n goals\n .command('get <id>')\n .description('Get an objective by its integer ID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const goal = await getClient().goals.get(parseGoalId(id));\n if (useJson) outputGoalJson(goal);\n else outputGoalPretty(goal);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n goals\n .command('create')\n .description('Create an objective')\n .requiredOption('-t, --title <text>', 'Objective title')\n .option('-w, --workspace <slug|id>', 'Workspace slug or ID (defaults to your default workspace)')\n .option('--period <period>', 'Period, e.g. Q3-2026 or Annual-2026')\n .option('--status <status>', `Status: ${GOAL_WRITABLE_STATUSES.join(', ')}`)\n .option('-d, --description <text>', 'Description (markdown supported)')\n .option('--why <text>', 'Why this goal matters')\n .option('--dri <userId>', 'Directly responsible individual (user ID)')\n .option('--parent <id>', 'Parent objective ID to nest under (max depth 5)')\n .option('--project <cuid>', 'Link a project on creation')\n .action(\n async (\n options: {\n title: string;\n workspace?: string;\n period?: string;\n status?: string;\n description?: string;\n why?: string;\n dri?: string;\n parent?: string;\n project?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateWritableGoalStatus(options.status);\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const goal = await client.goals.create({\n title: options.title,\n workspaceId,\n period: options.period,\n status,\n description: options.description,\n whyThisGoal: options.why,\n driUserId: options.dri,\n parentGoalId: options.parent ? parseGoalId(options.parent) : undefined,\n projectId: options.project,\n });\n if (useJson) outputGoalJson(goal);\n else {\n console.log('\\n✓ Goal created');\n outputGoalPretty(goal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n goals\n .command('update')\n .description(\n 'Update an objective. Only the flags you pass are written — everything ' +\n 'else is left exactly as it is. For a status change use `set-status`; ' +\n 'to re-parent use `reparent`.',\n )\n .requiredOption('--id <n>', 'Objective ID (a number)')\n .option('-t, --title <text>', 'New title')\n .option('-d, --description <text>', 'New description (\"none\" clears it)')\n .option('--why <text>', 'Why this goal matters (\"none\" clears it)')\n .option('--period <period>', 'New period (\"none\" clears it)')\n .option('--dri <userId>', 'Directly responsible individual (user ID)')\n .option('--status <status>', `Status: ${GOAL_WRITABLE_STATUSES.join(', ')}`)\n .option('--project <cuid>', 'Replace the project links with this project (\"none\" clears them)')\n .option(\n '-w, --workspace <slug|id|none>',\n 'Re-home the objective; \"none\" makes it personal',\n )\n .action(\n async (\n options: {\n id: string;\n title?: string;\n description?: string;\n why?: string;\n period?: string;\n dri?: string;\n status?: string;\n project?: string;\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateWritableGoalStatus(options.status);\n // \"none\" is the CLI's way of saying the explicit null the API wants;\n // an omitted flag stays `undefined` and is never sent.\n const clearable = (value: string | undefined) =>\n value === undefined ? undefined : value === 'none' ? null : value;\n const client = getClient();\n\n // A slug has to become an id, so this one can't go through\n // `clearable`. Omitted stays omitted: re-homing is exactly the write\n // that orphaned goal 46 when it happened by accident.\n let workspaceId: string | null | undefined;\n if (options.workspace === 'none') workspaceId = null;\n else if (options.workspace !== undefined) {\n workspaceId = await resolveWorkspaceId(client, options.workspace);\n }\n\n const goal = await client.goals.update({\n id: parseGoalId(options.id),\n workspaceId,\n title: options.title,\n description: clearable(options.description),\n whyThisGoal: clearable(options.why),\n period: clearable(options.period),\n driUserId: options.dri,\n status,\n projectId: clearable(options.project),\n });\n if (useJson) outputGoalJson(goal);\n else {\n console.log('\\n✓ Goal updated');\n outputGoalPretty(goal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n goals\n .command('set-status')\n .description(\n 'Set an objective\\'s status and nothing else. Routes through the ' +\n 'status-only procedure, so no other field can be touched.',\n )\n .requiredOption('--id <n>', 'Objective ID (a number)')\n .requiredOption('--status <status>', `Status: ${GOAL_STATUSES.join(', ')}`)\n .action(async (options: { id: string; status: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateGoalStatus(options.status)!;\n const goal = await getClient().goals.setStatus({\n id: parseGoalId(options.id),\n status,\n });\n if (useJson) outputGoalJson(goal);\n else {\n console.log(`\\n✓ Goal status set to ${status}`);\n outputGoalPretty(goal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n goals\n .command('close')\n .description('Close out an objective — one command per goal when a quarter ends')\n .requiredOption('--id <n>', 'Objective ID (a number)')\n .option('--status <status>', 'completed (default) or archived', 'completed')\n .action(async (options: { id: string; status: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateGoalStatus(options.status)!;\n // Same status-only path as set-status — never `updateGoal`.\n const goal = await getClient().goals.setStatus({\n id: parseGoalId(options.id),\n status,\n });\n if (useJson) outputGoalJson(goal);\n else {\n console.log(`\\n✓ Goal closed as ${status}`);\n outputGoalPretty(goal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n goals\n .command('reparent')\n .description(\n 'Move an objective under another (or detach it with --parent none). ' +\n 'Writes the parent alone.',\n )\n .requiredOption('--id <n>', 'Objective ID (a number)')\n .requiredOption('--parent <id|none>', 'New parent objective ID, or \"none\" to detach')\n .action(async (options: { id: string; parent: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const goal = await getClient().goals.setParent({\n id: parseGoalId(options.id),\n parentGoalId: options.parent === 'none' ? null : parseGoalId(options.parent),\n });\n if (useJson) outputGoalJson(goal);\n else {\n console.log(\n options.parent === 'none' ? '\\n✓ Goal detached' : '\\n✓ Goal re-parented',\n );\n outputGoalPretty(goal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n goals\n .command('delete')\n .description(\n 'Delete an objective. Refuses while it still has key results — deleting an ' +\n 'objective deletes them too (KeyResult.goalId cascades), taking their ' +\n 'check-in history with them.',\n )\n .requiredOption('--id <n>', 'Objective ID (a number)')\n .option(\n '--with-key-results',\n 'Delete the objective and cascade-delete its key results (destructive)',\n )\n .action(\n async (options: { id: string; withKeyResults?: boolean }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const id = parseGoalId(options.id);\n const client = getClient();\n const goal = await client.goals.get(id);\n const keyResults = goal.keyResults ?? [];\n const children = goal.childGoals ?? [];\n\n if (keyResults.length > 0 && !options.withKeyResults) {\n const payload = {\n deleted: false,\n id,\n reason: `has ${keyResults.length} key result(s)`,\n keyResults: keyResults.map((kr) => ({ id: kr.id })),\n };\n if (useJson) console.log(JSON.stringify(payload, null, 2));\n else {\n console.error(\n `Objective #${id} has ${keyResults.length} key result(s). Deleting it deletes them too.\\n` +\n 'Re-run with --with-key-results to go ahead, or move them with `goals kr update --id <cuid> --goal <other>`.',\n );\n }\n process.exitCode = 1;\n return;\n }\n\n await client.goals.delete(id);\n const payload = {\n deleted: true,\n id,\n keyResultsDeleted: keyResults.map((kr) => ({ id: kr.id })),\n childGoalsDetached: children.map((c) => ({ id: c.id, title: c.title })),\n };\n if (useJson) console.log(JSON.stringify(payload, null, 2));\n else {\n console.log('✓ Goal deleted');\n if (keyResults.length) {\n console.log(` ${keyResults.length} key result(s) deleted with it`);\n }\n if (children.length) {\n console.log(` ${children.length} sub-goal(s) left detached`);\n }\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n goals\n .command('periods')\n .description('List the conventional OKR period strings')\n .action(async (_options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const periods = await getClient().goals.periods();\n if (useJson) outputGoalPeriodsJson(periods);\n else outputGoalPeriodsPretty(periods);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n goals\n .command('stats')\n .description('Objective and key-result counts, average progress and confidence')\n .option('-w, --workspace <slug|id>', 'Workspace slug or ID (defaults to your default workspace)')\n .option('--period <period>', 'Period, e.g. Q3-2026')\n .action(\n async (options: { workspace?: string; period?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const stats = await client.goals.stats({\n workspaceId,\n period: options.period,\n });\n if (useJson) outputGoalStatsJson(stats);\n else outputGoalStatsPretty(stats);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n goals.addCommand(createKeyResultsCommand());\n goals.addCommand(createGoalCommentsCommand());\n return goals;\n}\n\n/**\n * `exponential okrs …` — the objective-plus-key-results view.\n *\n * `goals list` answers \"what are the objectives\"; `okrs list` answers \"how is\n * the quarter going\", nesting each objective's key results underneath it in one\n * workspace-scoped call. Everything you can do to the parts still lives under\n * `goals` / `goals kr` — this group is the combined read.\n */\nexport function createOkrsCommand(): Command {\n const okrs = new Command('okrs').description(\n 'OKRs — objectives with their key results nested. Manage the parts with `goals` and `goals kr`.',\n );\n\n okrs\n .command('list')\n .description(\n 'List objectives with their key results. Defaults to the current ' +\n 'quarter — pass --period all for every period.',\n )\n .option('-w, --workspace <slug|id>', 'Workspace slug or ID (defaults to your default workspace)')\n .option('--all-workspaces', 'List across every workspace you belong to')\n .option(\n '--period <period>',\n `Period, e.g. Q3-2026, or \"all\" for every period (default: ${currentPeriod()})`,\n )\n .option('--paired-period', 'Also include the period\\'s parent annual period')\n .option(\n '--status <status>',\n `Keep only key results with this status: ${KEY_RESULT_STATUSES.join(', ')}`,\n )\n .option('--mine', 'Only objectives and key results you are the DRI for')\n .action(\n async (\n options: {\n workspace?: string;\n allWorkspaces?: boolean;\n period?: string;\n pairedPeriod?: boolean;\n status?: string;\n mine?: boolean;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateKeyResultStatus(options.status);\n const client = getClient();\n const workspaces = await targetWorkspaces(client, options);\n // \"how is the quarter going\" almost always means this quarter, so an\n // omitted --period narrows to it. `all` is the escape hatch.\n const period =\n options.period === 'all' ? undefined : options.period ?? currentPeriod();\n\n let objectives = (await fanOutByWorkspace(workspaces, async (workspace) => {\n const found = await client.goals.keyResults.byObjective({\n workspaceId: workspace.id,\n period,\n includePairedPeriod: options.pairedPeriod,\n onlyMine: options.mine,\n });\n // getByObjective doesn't return the workspace; attach the one we\n // queried so a cross-workspace list can label each row.\n return found.map((o) => ({ ...o, workspace }));\n })) as ObjectiveWithKeyResults[];\n\n if (status) {\n // getByObjective takes no status input, so this filters here —\n // dropping non-matching key results and then any objective left\n // with none, so \"show me what's off-track\" isn't padded with\n // objectives that have nothing off-track.\n objectives = objectives\n .map((o) => ({\n ...o,\n keyResults: o.keyResults.filter(\n (kr) => (kr.statusOverride ?? kr.status) === status,\n ),\n }))\n .filter((o) => o.keyResults.length > 0);\n }\n\n if (useJson) outputObjectivesJson(objectives);\n else outputObjectivesPretty(objectives);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n okrs\n .command('stats')\n .description('Objective and key-result counts, average progress and confidence')\n .option('-w, --workspace <slug|id>', 'Workspace slug or ID (defaults to your default workspace)')\n .option('--period <period>', 'Period, e.g. Q3-2026')\n .action(\n async (options: { workspace?: string; period?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const stats = await client.goals.stats({\n workspaceId,\n period: options.period,\n });\n if (useJson) outputGoalStatsJson(stats);\n else outputGoalStatsPretty(stats);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n okrs\n .command('periods')\n .description('List the conventional OKR period strings')\n .action(async (_options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const periods = await getClient().goals.periods();\n if (useJson) outputGoalPeriodsJson(periods);\n else outputGoalPeriodsPretty(periods);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n okrs.addCommand(createKeyResultsCommand());\n return okrs;\n}\n"],"mappings":";;;AACA,SAAS,WAAAA,iBAAe;;;ACDxB,SAAS,eAAe;AACxB,OAAOC,YAAW;;;ACDlB,SAAS,yBAAyB;AAGlC,IAAM,cAAc,kBAAkB,EAAE,aAAa,kBAAkB,CAAC;AAIjE,SAAS,YAA+B;AAC7C,SAAO,YAAY,WAAW;AAChC;AAEO,SAAS,UAAU,QAA0C;AAClE,cAAY,WAAW,MAAM;AAC/B;AAEO,SAAS,cAAoB;AAClC,cAAY,YAAY;AAC1B;AAEO,SAAS,kBAA2B;AACzC,SAAO,YAAY,gBAAgB;AACrC;AAEO,SAAS,gBAAwB;AACtC,SAAO,YAAY,cAAc;AACnC;;;ACzBA,SAAS,yBAAyB;AA2BlC,SAAS,aAAa,uBAAuB;AAxB7C,IAAI,iBAA2C;AAExC,SAAS,YAAY;AAC1B,MAAI,CAAC,gBAAgB,GAAG;AACtB,UAAM,IAAI,MAAM,mFAAmF;AAAA,EACrG;AAEA,MAAI,gBAAgB;AAClB,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,UAAU;AACzB,mBAAiB,IAAI,kBAAkB;AAAA,IACrC,OAAO,OAAO;AAAA,IACd,QAA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,YAAY,6BAA6B;AAGnD,QAAQ,WAAW,kBAAkB,CAAC;AACtC,QAAQ,WAAW,qBAAqB,CAAC;AACzC,QAAQ,WAAW,sBAAsB,CAAC;AAC1C,QAAQ,WAAW,mBAAmB,CAAC;AACvC,QAAQ,WAAW,mBAAmB,CAAC;AACvC,QAAQ,WAAW,sBAAsB,CAAC;AAC1C,QAAQ,WAAW,oBAAoB,CAAC;AACxC,QAAQ,WAAW,sBAAsB,CAAC;AAC1C,QAAQ,WAAW,2BAA2B,CAAC;AAC/C,QAAQ,WAAW,mBAAmB,CAAC;AACvC,QAAQ,WAAW,sBAAsB,CAAC;AAC1C,QAAQ,WAAW,sBAAsB,CAAC;AAC1C,QAAQ,WAAW,oBAAoB,CAAC;AACxC,QAAQ,WAAW,qBAAqB,CAAC;AACzC,QAAQ,WAAW,wBAAwB,CAAC;AAC5C,QAAQ,WAAW,mBAAmB,CAAC;AACvC,QAAQ,WAAW,kBAAkB,CAAC;AAEtC,QAAQ,MAAM;","names":["Command","chalk","chalk","Command","chalk","Command","actions","Command","Command","Command","Command","Command","Command","parseNullableDate","Command","Command","Command","story","Command","Command","Command","readStdin","Command","Command","chalk","Command","Command","Command","Command","Command","chalk","chalk","Command","Command","chalk","parseDate","Command","parseDate","notes","chalk","Command","Command","Command","Command","Command","Command","Command","Command","Command","Command","projects","payload","Command","chalk","Command","chalk","Command","Command","Command","chalk","Command","workspaces","chalk","Command","Command","goals","payload","readFileSync","Command"]}
1
+ {"version":3,"sources":["../src/program.ts","../src/commands/auth.ts","../src/config/index.ts","../src/client/index.ts","../src/utils/errors.ts","../src/commands/actions.ts","../src/utils/resolve.ts","../src/utils/output.ts","../src/commands/contacts.ts","../src/commands/decisions.ts","../src/utils/input.ts","../src/commands/deals.ts","../src/commands/epics.ts","../src/commands/features.ts","../src/commands/stories.ts","../src/commands/scopes.ts","../src/commands/requirements.ts","../src/commands/areas.ts","../src/commands/featureComments.ts","../src/utils/mentions.ts","../src/commands/labels.ts","../src/commands/meetings.ts","../src/commands/organizations.ts","../src/commands/pages.ts","../src/commands/pageComments.ts","../src/commands/products.ts","../src/commands/projects.ts","../src/commands/search.ts","../src/commands/tickets.ts","../src/commands/time.ts","../src/commands/workspaces.ts","../src/commands/goals.ts","../src/index.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { createAuthCommand } from './commands/auth.js';\nimport { createActionsCommand } from './commands/actions.js';\nimport { createContactsCommand } from './commands/contacts.js';\nimport { createDecisionsCommand } from './commands/decisions.js';\nimport { createDealsCommand } from './commands/deals.js';\nimport { createEpicsCommand } from './commands/epics.js';\nimport { createFeaturesCommand } from './commands/features.js';\nimport { createLabelsCommand } from './commands/labels.js';\nimport { createMeetingsCommand } from './commands/meetings.js';\nimport { createOrganizationsCommand } from './commands/organizations.js';\nimport { createPagesCommand } from './commands/pages.js';\nimport { createProductsCommand } from './commands/products.js';\nimport { createProjectsCommand } from './commands/projects.js';\nimport { createSearchCommand } from './commands/search.js';\nimport { createTicketsCommand } from './commands/tickets.js';\nimport { createTimeCommand } from './commands/time.js';\nimport { createWorkspacesCommand } from './commands/workspaces.js';\nimport { createGoalsCommand, createOkrsCommand } from './commands/goals.js';\nimport { readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n// Read the real version rather than a hand-maintained literal, which drifted\n// far enough that `--version` reported 1.0.0 while 1.9.0 was on npm.\nexport const PKG_VERSION: string = JSON.parse(\n readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json'), 'utf-8'),\n).version;\n\n// The root program's version flag is spelled `--cli-version`, NOT `--version`.\n// Commander parses root options anywhere in argv (unless positional options are\n// enabled, which would break `actions list --json`), so a root `--version`\n// swallowed `features scopes add --version V1` and printed the CLI version\n// instead of creating a scope. `-V` is kept; bare `exponential --version` is\n// handled by isBareVersionRequest() before parsing.\nexport const CLI_VERSION_FLAGS = '-V, --cli-version';\n\n/**\n * True when the user asked for the CLI version with the pre-1.15.1 spelling:\n * `--version` is present and no subcommand is named (every arg is a flag).\n * `features scopes add --version V1` names a subcommand, so it is never bare.\n */\nexport function isBareVersionRequest(args: string[]): boolean {\n return args.includes('--version') && args.every((arg) => arg.startsWith('-'));\n}\n\nexport function buildProgram(): Command {\n const program = new Command();\n\n program\n .name('exponential')\n .description(\n [\n 'CLI to interact with Exponential productivity app.',\n '',\n 'Work-tracking hierarchy:',\n ' workspace -> product -> feature -> ticket -> action',\n ' epics are workspace-scoped and can group tickets and actions across products.',\n ].join('\\n'),\n )\n .version(PKG_VERSION, CLI_VERSION_FLAGS, 'Output the CLI version')\n .option('--json', 'Output as JSON (default when piped)')\n .option('--pretty', 'Force pretty-printed output');\n\n // Add subcommands\n program.addCommand(createAuthCommand());\n program.addCommand(createActionsCommand());\n program.addCommand(createContactsCommand());\n program.addCommand(createDecisionsCommand());\n program.addCommand(createDealsCommand());\n program.addCommand(createEpicsCommand());\n program.addCommand(createFeaturesCommand());\n program.addCommand(createLabelsCommand());\n program.addCommand(createMeetingsCommand());\n program.addCommand(createOrganizationsCommand());\n program.addCommand(createPagesCommand());\n program.addCommand(createProductsCommand());\n program.addCommand(createProjectsCommand());\n program.addCommand(createSearchCommand());\n program.addCommand(createTicketsCommand());\n program.addCommand(createTimeCommand());\n program.addCommand(createWorkspacesCommand());\n program.addCommand(createGoalsCommand());\n program.addCommand(createOkrsCommand());\n\n return program;\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { getConfig, setConfig, clearConfig, isAuthenticated, getConfigPath } from '../config/index.js';\nimport { getClient, resetClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\n\nexport function createAuthCommand(): Command {\n const auth = new Command('auth')\n .description('Authentication commands');\n\n auth\n .command('login')\n .description('Configure CLI with your API token')\n .requiredOption('--token <token>', 'JWT token from /settings/api-keys')\n .requiredOption('--api-url <url>', 'API URL (e.g., https://www.exponential.im)')\n .action(async (options: { token: string; apiUrl: string }) => {\n try {\n // Normalize API URL (remove trailing slash)\n let apiUrl = options.apiUrl.replace(/\\/+$/, '');\n\n // Ensure HTTPS for non-localhost\n if (!apiUrl.startsWith('http://localhost') && !apiUrl.startsWith('https://')) {\n apiUrl = `https://${apiUrl}`;\n }\n\n // Store the config\n setConfig({\n token: options.token,\n apiUrl: apiUrl,\n });\n\n // Reset client to use new config\n resetClient();\n\n // Validate by trying to list workspaces\n console.log(chalk.gray('Validating token...'));\n const client = getClient();\n await client.workspaces.list();\n\n console.log(chalk.green('Successfully authenticated!'));\n console.log(chalk.gray(`Config saved to: ${getConfigPath()}`));\n } catch (error) {\n // Clear invalid config\n clearConfig();\n handleError(error);\n }\n });\n\n auth\n .command('logout')\n .description('Remove stored credentials')\n .action(() => {\n clearConfig();\n resetClient();\n console.log(chalk.green('Successfully logged out.'));\n console.log(chalk.gray(`Config cleared from: ${getConfigPath()}`));\n });\n\n auth\n .command('whoami')\n .description('Show current authentication status')\n .action(async () => {\n if (!isAuthenticated()) {\n console.log(chalk.yellow('Not authenticated.'));\n console.log(chalk.gray('Run: exponential auth login --token <jwt> --api-url <url>'));\n process.exit(1);\n }\n\n try {\n const config = getConfig();\n const client = getClient();\n\n // Validate token by listing workspaces\n const workspaces = await client.workspaces.list();\n\n console.log(chalk.green('Authenticated'));\n console.log(chalk.gray(`API URL: ${config.apiUrl}`));\n console.log(chalk.gray(`Workspaces: ${(workspaces as unknown[]).length}`));\n console.log(chalk.gray(`Config: ${getConfigPath()}`));\n } catch (error) {\n handleError(error);\n }\n });\n\n auth\n .command('show')\n .description(\n 'Print parts of the current credentials. Use --token to print the raw JWT (for piping into other tools, e.g. `gh secret set EXPONENTIAL_TOKEN < <(exponential auth show --token)`).',\n )\n .option('--token', 'Print the raw JWT to stdout with no trailing newline')\n .action((options: { token?: boolean }) => {\n const config = getConfig();\n if (options.token) {\n if (!config.token) {\n console.error('Not authenticated. Run `exponential auth login` first.');\n process.exit(1);\n }\n process.stdout.write(config.token);\n return;\n }\n console.log(chalk.bold('\\nCredentials'));\n console.log(chalk.gray('─'.repeat(40)));\n console.log(`API URL: ${config.apiUrl || chalk.gray('(not set)')}`);\n console.log(\n `Token: ${config.token ? chalk.gray(`${config.token.substring(0, 20)}...`) : chalk.gray('(not set)')}`,\n );\n console.log(\n chalk.gray('Use `exponential auth show --token` to print the raw JWT.'),\n );\n console.log();\n });\n\n auth\n .command('status')\n .description('Show detailed authentication status')\n .action(() => {\n const config = getConfig();\n\n console.log(chalk.bold('\\nAuthentication Status'));\n console.log(chalk.gray('─'.repeat(40)));\n console.log(`Authenticated: ${isAuthenticated() ? chalk.green('Yes') : chalk.red('No')}`);\n console.log(`API URL: ${config.apiUrl || chalk.gray('(not set)')}`);\n console.log(`Token: ${config.token ? chalk.gray(`${config.token.substring(0, 20)}...`) : chalk.gray('(not set)')}`);\n console.log(`Config Path: ${getConfigPath()}`);\n console.log();\n });\n\n return auth;\n}\n","import { createConfigStore } from 'exponential-sdk';\nimport type { ExponentialConfig } from 'exponential-sdk';\n\nconst configStore = createConfigStore({ projectName: 'exponential-cli' });\n\nexport type { ExponentialConfig };\n\nexport function getConfig(): ExponentialConfig {\n return configStore.loadConfig();\n}\n\nexport function setConfig(values: Partial<ExponentialConfig>): void {\n configStore.saveConfig(values);\n}\n\nexport function clearConfig(): void {\n configStore.clearConfig();\n}\n\nexport function isAuthenticated(): boolean {\n return configStore.isAuthenticated();\n}\n\nexport function getConfigPath(): string {\n return configStore.getConfigPath();\n}\n","import { ExponentialClient } from 'exponential-sdk';\nimport { getConfig, isAuthenticated } from '../config/index.js';\n\nlet clientInstance: ExponentialClient | null = null;\n\nexport function getClient() {\n if (!isAuthenticated()) {\n throw new Error('Not authenticated. Run: exponential auth login --token <your-jwt> --api-url <url>');\n }\n\n if (clientInstance) {\n return clientInstance;\n }\n\n const config = getConfig();\n clientInstance = new ExponentialClient({\n token: config.token,\n apiUrl: config.apiUrl,\n });\n\n return clientInstance;\n}\n\nexport function resetClient() {\n clientInstance = null;\n}\n\nexport { isTRPCError, TRPCClientError } from 'exponential-sdk';\n","import chalk from 'chalk';\nimport { isTRPCError } from '../client/index.js';\n\nexport class ExponentialError extends Error {\n constructor(\n message: string,\n public code: string,\n public suggestion?: string,\n public details?: unknown\n ) {\n super(message);\n this.name = 'ExponentialError';\n }\n}\n\nexport function handleError(error: unknown, json: boolean = false): never {\n if (error instanceof ExponentialError) {\n if (json) {\n console.log(JSON.stringify({\n error: {\n code: error.code,\n message: error.message,\n suggestion: error.suggestion,\n },\n }, null, 2));\n } else {\n console.error(chalk.red(`Error: ${error.message}`));\n if (error.suggestion) {\n console.error(chalk.yellow(`Suggestion: ${error.suggestion}`));\n }\n }\n process.exit(1);\n }\n\n if (isTRPCError(error)) {\n const code = error.data?.code ?? 'UNKNOWN';\n let message = error.message;\n let suggestion: string | undefined;\n\n switch (code) {\n case 'UNAUTHORIZED':\n message = 'Authentication failed. Your token may have expired.';\n suggestion = 'Run: exponential auth login --token <new-token> --api-url <url>';\n break;\n case 'NOT_FOUND':\n message = 'Resource not found';\n break;\n case 'FORBIDDEN':\n message = 'Access denied';\n break;\n }\n\n if (json) {\n console.log(JSON.stringify({\n error: {\n code,\n message,\n suggestion,\n },\n }, null, 2));\n } else {\n console.error(chalk.red(`Error [${code}]: ${message}`));\n if (suggestion) {\n console.error(chalk.yellow(`Suggestion: ${suggestion}`));\n }\n }\n process.exit(1);\n }\n\n // Generic error handling\n if (json) {\n console.log(JSON.stringify({\n error: {\n code: 'UNKNOWN',\n message: error instanceof Error ? error.message : String(error),\n },\n }, null, 2));\n } else {\n console.error(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`));\n }\n process.exit(1);\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n shouldUseJson,\n outputActionsJson,\n outputActionsPretty,\n outputActionJson,\n outputActionPretty,\n outputActionUpsertJson,\n outputCommentJson,\n outputCommentPretty,\n outputCommentsJson,\n outputCommentsPretty,\n outputTodaysActionsJson,\n outputTodaysActionsPretty,\n outputOverdueTriageJson,\n outputOverdueTriagePretty,\n} from '../utils/output.js';\nimport type { Action, KanbanStatus, Priority } from 'exponential-sdk';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n workspace?: string;\n}\n\nconst VALID_PRIORITIES: Priority[] = [\n 'Quick',\n 'Scheduled',\n '1st Priority',\n '2nd Priority',\n '3rd Priority',\n '4th Priority',\n '5th Priority',\n 'Errand',\n 'Remember',\n 'Watch',\n 'Someday Maybe',\n];\n\n/** `undefined` = leave alone, `null` = clear, otherwise the parsed date. */\nfunction parseNullableDate(raw: string | undefined, flag: string): Date | null | undefined {\n if (raw === undefined) return undefined;\n if (raw === 'null') return null;\n const parsed = new Date(raw);\n if (isNaN(parsed.getTime())) {\n throw new Error(`Invalid --${flag} value \"${raw}\". Use YYYY-MM-DD, an ISO datetime, or \"null\".`);\n }\n return parsed;\n}\n\nfunction parseIds(raw: string): string[] {\n const ids = raw.split(',').map((s) => s.trim()).filter(Boolean);\n if (ids.length === 0) {\n throw new Error('No action IDs supplied. Pass --ids id1,id2');\n }\n return ids;\n}\n\nexport function createActionsCommand(): Command {\n const actions = new Command('actions')\n .description('Manage actions/tasks');\n\n actions\n .command('list')\n .description('List all actions')\n .option('--project <id>', 'Filter by project ID')\n .option('--status <status>', 'Filter by kanban status (BACKLOG, TODO, IN_PROGRESS, IN_REVIEW, DONE)')\n .option('--assignee <id>', 'Filter by assignee ID')\n .action(async (options: { project?: string; status?: string; assignee?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const kanbanStatus = options.status as KanbanStatus | undefined;\n\n const actions = await client.actions.list({\n projectId: options.project,\n status: kanbanStatus,\n assigneeId: options.assignee,\n });\n\n if (useJson) {\n outputActionsJson(actions, {\n projectId: options.project,\n kanbanStatus: options.status,\n });\n } else {\n outputActionsPretty(actions);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions\n .command('today')\n .description(\"What's on your plate: overdue, today, and inbox\")\n .option('--workspace <id>', 'Filter by workspace ID')\n .option('--due-only', 'Only actions whose dueDate is today (the pre-1.8 shape — excludes overdue)')\n .action(async (options: { workspace?: string; dueOnly?: boolean }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n\n if (options.dueOnly) {\n const actions = await client.actions.getToday(options.workspace);\n if (useJson) {\n outputActionsJson(actions, { workspaceId: options.workspace });\n } else {\n outputActionsPretty(actions);\n }\n return;\n }\n\n const todays = await client.actions.getTodaysActions(options.workspace);\n if (useJson) {\n outputTodaysActionsJson(todays, { workspaceId: options.workspace });\n } else {\n outputTodaysActionsPretty(todays);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions\n .command('overdue')\n .description('Why the overdue pile is that size: bulk-created cohorts vs real debt')\n .option('--workspace <id>', 'Filter by workspace ID')\n .action(async (options: { workspace?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const triage = await client.actions.getOverdueTriage(options.workspace);\n\n if (useJson) {\n outputOverdueTriageJson(triage);\n } else {\n outputOverdueTriagePretty(triage);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions\n .command('defer')\n .description('Amnesty: clear dates so actions fall back to their project backlog untimed')\n .requiredOption('--ids <ids>', 'Comma-separated action IDs')\n .action(async (options: { ids: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const ids = parseIds(options.ids);\n const client = getClient();\n const result = await client.actions.bulkDefer(ids);\n\n if (useJson) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n console.log(`✓ ${result.message}`);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions\n .command('reschedule')\n .description('Move actions to a new do-date (use \"actions defer\" if they were never really due)')\n .requiredOption('--ids <ids>', 'Comma-separated action IDs')\n .requiredOption('--to <date>', 'New do-date (YYYY-MM-DD, or \"today\")')\n .action(async (options: { ids: string; to: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const ids = parseIds(options.ids);\n const when = options.to === 'today' ? new Date() : new Date(options.to);\n if (isNaN(when.getTime())) {\n throw new Error('Invalid date format. Use YYYY-MM-DD or \"today\"');\n }\n\n const client = getClient();\n const result = await client.actions.bulkReschedule(ids, when);\n\n if (useJson) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n console.log(`✓ Rescheduled ${result.count} action${result.count === 1 ? '' : 's'}`);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions\n .command('range')\n .description('Get actions by date range')\n .requiredOption('--start <date>', 'Start date (YYYY-MM-DD)')\n .requiredOption('--end <date>', 'End date (YYYY-MM-DD)')\n .option('--workspace <id>', 'Filter by workspace ID')\n .action(async (options: { start: string; end: string; workspace?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const startDate = new Date(options.start);\n const endDate = new Date(options.end);\n\n if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {\n throw new Error('Invalid date format. Use YYYY-MM-DD');\n }\n\n const client = getClient();\n const actions = await client.actions.getByDateRange(startDate, endDate, options.workspace);\n\n if (useJson) {\n outputActionsJson(actions, { workspaceId: options.workspace });\n } else {\n outputActionsPretty(actions);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions\n .command('kanban')\n .description('Get kanban board actions')\n .option('--project <id>', 'Filter by project ID')\n .option('--status <status>', 'Filter by kanban status')\n .option('--assignee <id>', 'Filter by assignee ID')\n .action(async (options: { project?: string; status?: string; assignee?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const kanbanStatus = options.status as KanbanStatus | undefined;\n\n const actions = await client.actions.getKanban({\n projectId: options.project,\n status: kanbanStatus,\n assigneeId: options.assignee,\n });\n\n if (useJson) {\n outputActionsJson(actions, {\n projectId: options.project,\n kanbanStatus: options.status,\n });\n } else {\n outputActionsPretty(actions);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions\n .command('update')\n .description('Update an existing action')\n .requiredOption('--id <id>', 'Action ID to update')\n .option('-n, --name <name>', 'New action name')\n .option('-d, --description <text>', 'New description')\n .option('-p, --project <id>', 'Move to project ID')\n .option('--priority <priority>', 'Priority (Quick, Scheduled, 1st Priority, etc.)')\n .option('--status <status>', 'Status (ACTIVE, COMPLETED, CANCELLED)')\n .option('--kanban <status>', 'Kanban status (BACKLOG, TODO, IN_PROGRESS, IN_REVIEW, DONE)')\n .option('--due <date>', 'Due date (YYYY-MM-DD or \"null\" to clear)')\n .option('--scheduled-start <datetime>', 'Do-date: when you plan to work on it (YYYY-MM-DD, ISO datetime, or \"null\" to clear). This is what /today partitions on.')\n .option('--scheduled-end <datetime>', 'End of the time block (YYYY-MM-DD, ISO datetime, or \"null\" to clear)')\n .action(async (options: {\n id: string;\n name?: string;\n description?: string;\n project?: string;\n priority?: string;\n status?: string;\n kanban?: string;\n due?: string;\n scheduledStart?: string;\n scheduledEnd?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n // Validate priority if provided\n if (options.priority && !VALID_PRIORITIES.includes(options.priority as Priority)) {\n throw new Error(`Invalid priority \"${options.priority}\". Valid values: ${VALID_PRIORITIES.join(', ')}`);\n }\n\n // Parse due date if provided\n let dueDate: Date | null | undefined;\n if (options.due === 'null') {\n dueDate = null;\n } else if (options.due) {\n dueDate = new Date(options.due);\n if (isNaN(dueDate.getTime())) {\n throw new Error('Invalid due date format. Use YYYY-MM-DD');\n }\n }\n\n const scheduledStart = parseNullableDate(options.scheduledStart, 'scheduled-start');\n const scheduledEnd = parseNullableDate(options.scheduledEnd, 'scheduled-end');\n\n const client = getClient();\n const action = await client.actions.update({\n id: options.id,\n name: options.name,\n description: options.description,\n projectId: options.project,\n priority: options.priority as Priority | undefined,\n status: options.status as 'ACTIVE' | 'COMPLETED' | 'CANCELLED' | undefined,\n kanbanStatus: options.kanban as 'BACKLOG' | 'TODO' | 'IN_PROGRESS' | 'IN_REVIEW' | 'DONE' | 'CANCELLED' | undefined,\n dueDate,\n scheduledStart,\n scheduledEnd,\n });\n\n if (useJson) {\n outputActionJson(action);\n } else {\n console.log('\\n✓ Action updated successfully');\n outputActionPretty(action);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions\n .command('create')\n .description('Create a new action')\n .requiredOption('-n, --name <name>', 'Action name/title')\n .option('-d, --description <text>', 'Action description')\n .option('-p, --project <id>', 'Project ID to assign the action to')\n .option('--priority <priority>', 'Priority (Quick, Scheduled, 1st Priority, etc.)')\n .option('--due <date>', 'Due date (YYYY-MM-DD)')\n .option('--effort <minutes>', 'Effort estimate in minutes', parseInt)\n .option('--ticket <id>', 'Link action to a product ticket (CUID) after creation')\n .option('--epic <id>', 'Epic CUID to attach the action to')\n .action(async (options: {\n name: string;\n description?: string;\n project?: string;\n priority?: string;\n due?: string;\n effort?: number;\n ticket?: string;\n epic?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n // Validate priority if provided\n if (options.priority && !VALID_PRIORITIES.includes(options.priority as Priority)) {\n throw new Error(`Invalid priority \"${options.priority}\". Valid values: ${VALID_PRIORITIES.join(', ')}`);\n }\n\n // Parse due date if provided\n let dueDate: Date | undefined;\n if (options.due) {\n dueDate = new Date(options.due);\n if (isNaN(dueDate.getTime())) {\n throw new Error('Invalid due date format. Use YYYY-MM-DD');\n }\n }\n\n const client = getClient();\n let action = await client.actions.create({\n name: options.name,\n description: options.description,\n projectId: options.project,\n priority: options.priority as Priority | undefined,\n dueDate,\n effortEstimate: options.effort,\n epicId: options.epic,\n });\n\n // The server's action.create router doesn't accept ticketId, so when\n // --ticket is requested we link via the product.ticket.linkAction RPC\n // and re-use its updated return value.\n if (options.ticket) {\n action = await client.tickets.linkAction(options.ticket, action.id);\n }\n\n if (useJson) {\n outputActionJson(action);\n } else {\n console.log('\\n✓ Action created successfully');\n outputActionPretty(action);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n\n actions\n .command('upsert')\n .description(\n 'One Action per external source: find by (--workspace, --source-type, --source-id), refresh its title and links, else create it. The Daily worklog uses --source-type claude-session --source-id <conversation id>.',\n )\n .requiredOption('--source-type <type>', 'e.g. claude-session')\n .requiredOption('--source-id <id>', 'The source\\'s own id; the same pair always maps to the same Action')\n .requiredOption('-t, --title <title>', 'Action title (refreshed on every call)')\n .option('-w, --workspace <slug|id>', 'Workspace (defaults to your default workspace)')\n .option('-d, --description <text>', 'Description')\n .option('--project <id>', 'Link to a project CUID in the same workspace')\n .option('--ticket <id>', 'Link to a ticket CUID whose product is in the same workspace')\n .action(\n async (\n options: {\n sourceType: string;\n sourceId: string;\n title: string;\n workspace?: string;\n description?: string;\n project?: string;\n ticket?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const result = await client.actions.upsertBySource({\n sourceType: options.sourceType,\n sourceId: options.sourceId,\n name: options.title,\n workspaceId,\n description: options.description,\n projectId: options.project,\n ticketId: options.ticket,\n });\n if (useJson) {\n outputActionUpsertJson(result);\n } else {\n console.log(result.outcome === 'created' ? 'Created action:' : 'Updated action:');\n outputActionPretty(result.action);\n }\n } catch (error) {\n handleError(error);\n }\n },\n );\n\n const comment = new Command('comment')\n .description('Manage comments on an action');\n\n comment\n .command('list')\n .description('List comments on an action')\n .requiredOption('--id <id>', 'Action ID')\n .action(async (options: { id: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const comments = await client.actionComments.list(options.id);\n if (useJson) outputCommentsJson(comments);\n else outputCommentsPretty(comments);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('add')\n .description('Add a comment to an action')\n .requiredOption('--id <id>', 'Action ID')\n .requiredOption('-m, --message <text>', 'Comment content (markdown supported)')\n .action(async (options: { id: string; message: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const created = await client.actionComments.add({\n actionId: options.id,\n content: options.message,\n });\n if (useJson) {\n outputCommentJson(created);\n } else {\n console.log('\\n✓ Comment added');\n outputCommentPretty(created);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('update')\n .description(\"Update one of your own comments\")\n .requiredOption('--comment-id <id>', 'Comment ID')\n .requiredOption('-m, --message <text>', 'New comment content')\n .action(async (options: { commentId: string; message: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const updated = await client.actionComments.update({\n commentId: options.commentId,\n content: options.message,\n });\n if (useJson) {\n outputCommentJson(updated);\n } else {\n console.log('\\n✓ Comment updated');\n outputCommentPretty(updated);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('delete')\n .description(\"Delete one of your own comments\")\n .requiredOption('--comment-id <id>', 'Comment ID')\n .action(async (options: { commentId: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.actionComments.delete(options.commentId);\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id: options.commentId }, null, 2));\n } else {\n console.log('\\n✓ Comment deleted');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n actions.addCommand(comment);\n\n return actions;\n}\n","import type { ExponentialClient, Workspace } from 'exponential-sdk';\nimport { getConfig } from '../config/index.js';\n\n/**\n * Resolve a workspace identifier the user typed at the CLI to a workspace ID.\n *\n * Accepts:\n * - a bare workspace CUID (returned as-is after a list lookup for safety)\n * - a workspace slug\n * - undefined → falls back to the configured default workspace\n *\n * Throws if nothing resolves so callers don't accidentally send a \"\" id.\n */\nexport async function resolveWorkspaceId(\n client: ExponentialClient,\n slugOrId: string | undefined,\n): Promise<string> {\n return (await resolveWorkspace(client, slugOrId)).id;\n}\n\n/**\n * Same resolution as {@link resolveWorkspaceId}, but returns the whole\n * workspace. Callers that need to label rows with a workspace name or slug —\n * anything cross-workspace — would otherwise pay a second lookup for data this\n * function already had in hand.\n */\nexport async function resolveWorkspace(\n client: ExponentialClient,\n slugOrId: string | undefined,\n): Promise<Workspace> {\n const config = getConfig();\n const candidate = slugOrId ?? config.defaultWorkspaceSlug ?? config.defaultWorkspaceId;\n\n if (!candidate) {\n throw new Error(\n 'No workspace specified and no default workspace set. Pass --workspace <slug> or run `exponential workspaces set-default <slug>`.',\n );\n }\n\n const workspaces = await client.workspaces.list();\n const byId = workspaces.find((w) => w.id === candidate);\n if (byId) return byId;\n const bySlug = workspaces.find((w) => w.slug === candidate);\n if (bySlug) return bySlug;\n\n const known = workspaces.map((w) => w.slug).join(', ');\n throw new Error(\n `Workspace \"${candidate}\" not found. Available: ${known || '(none)'}`,\n );\n}\n\n/**\n * Resolve a product identifier (slug or CUID) to a product ID.\n * `slugOrId` may also be a CUID — we try id lookup first when it looks\n * like one, then fall back to slug.\n */\nexport async function resolveProductId(\n client: ExponentialClient,\n workspaceId: string,\n slugOrId: string,\n): Promise<string> {\n const product = await client.products.resolve(workspaceId, slugOrId);\n return product.id;\n}\n\n","import chalk from 'chalk';\nimport type {\n Action,\n ActionComment,\n ActionOutput,\n ActionsListOutput,\n Contact,\n ContactInteraction,\n Deal,\n Decision,\n DecisionListRow,\n Epic,\n Feature,\n FeatureKeyResultLink,\n FeatureScope,\n Goal,\n GoalPeriod,\n GoalStats,\n GoalTreeNode,\n KeyResult,\n KeyResultCheckIn,\n KnowledgePage,\n Meeting,\n ObjectiveWithKeyResults,\n Organization,\n OverdueTriage,\n Pipeline,\n PipelineStage,\n Product,\n Project,\n ProjectDetail,\n ProjectOutput,\n ProjectsListOutput,\n Requirement,\n Ticket,\n TodaysActions,\n TicketComment,\n GoalComment,\n FeatureComment,\n PageComment,\n TicketDetail,\n TimeEntry,\n TimeLogBatchResult,\n TimeLogResult,\n UserStory,\n Workspace,\n WorkspaceOutput,\n WorkspacesListOutput,\n} from 'exponential-sdk';\n\n// Detect if output is being piped\nexport function shouldUseJson(forceJson?: boolean, forcePretty?: boolean): boolean {\n if (forceJson) return true;\n if (forcePretty) return false;\n return !process.stdout.isTTY;\n}\n\n// Transform Action to ActionOutput (serialize dates)\nexport function transformAction(action: Action): ActionOutput {\n return {\n id: action.id,\n name: action.name,\n description: action.description,\n status: action.status,\n priority: action.priority,\n kanbanStatus: action.kanbanStatus,\n dueDate: action.dueDate?.toISOString() ?? null,\n scheduledStart: action.scheduledStart?.toISOString() ?? null,\n scheduledEnd: action.scheduledEnd?.toISOString() ?? null,\n project: action.project ? {\n id: action.project.id,\n name: action.project.name,\n } : null,\n workspace: action.workspace ? {\n id: action.workspace.id,\n slug: action.workspace.slug,\n name: action.workspace.name,\n } : null,\n // `action.upsertBySource` returns assignees as bare `{ userId }` rows;\n // every other procedure nests the user. Accept both.\n assignees: action.assignees?.map((a) => ({\n id: a.user?.id ?? a.userId ?? '',\n name: a.user?.name ?? null,\n email: a.user?.email ?? null,\n })) ?? [],\n createdAt: action.createdAt?.toISOString() ?? new Date().toISOString(),\n completedAt: action.completedAt?.toISOString() ?? null,\n };\n}\n\n// Transform Project to ProjectOutput\nexport function transformProject(project: Project): ProjectOutput {\n return {\n id: project.id,\n name: project.name,\n description: project.description,\n status: project.status,\n priority: project.priority,\n workspace: project.workspace ? {\n id: project.workspace.id,\n slug: project.workspace.slug,\n name: project.workspace.name,\n } : null,\n };\n}\n\n// Transform Workspace to WorkspaceOutput\nexport function transformWorkspace(workspace: Workspace): WorkspaceOutput {\n return {\n id: workspace.id,\n name: workspace.name,\n slug: workspace.slug,\n type: workspace.type,\n };\n}\n\n// Output single action as JSON\nexport function outputActionJson(action: Action): void {\n const output = transformAction(action);\n console.log(JSON.stringify(output, null, 2));\n}\n\n/** `actions upsert`: the action plus whether it was created or refreshed. */\nexport function outputActionUpsertJson(result: { action: Action; outcome: 'created' | 'updated' }): void {\n console.log(JSON.stringify({ outcome: result.outcome, action: transformAction(result.action) }, null, 2));\n}\n\n// Output single action in pretty format\nexport function outputActionPretty(action: Action): void {\n const statusColor = getKanbanStatusColor(action.kanbanStatus);\n const statusBadge = action.kanbanStatus\n ? chalk[statusColor](`[${action.kanbanStatus}]`)\n : chalk.gray('[NO STATUS]');\n\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${statusBadge} ${chalk.bold(action.name)}`);\n console.log(chalk.gray(` ID: ${action.id}`));\n\n if (action.project) {\n console.log(` ${chalk.cyan('Project:')} ${action.project.name}`);\n }\n\n console.log(` ${chalk.magenta('Priority:')} ${action.priority}`);\n\n if (action.dueDate) {\n const dueDate = new Date(action.dueDate);\n console.log(` ${chalk.yellow('Due:')} ${formatDate(dueDate)}`);\n }\n\n if (action.description) {\n console.log(` ${chalk.gray('Description:')} ${action.description.substring(0, 100)}${action.description.length > 100 ? '...' : ''}`);\n }\n console.log();\n}\n\n// Output actions as JSON\nexport function outputActionsJson(actions: Action[], filters: ActionsListOutput['filters'] = {}): void {\n const output: ActionsListOutput = {\n actions: actions.map(transformAction),\n total: actions.length,\n filters,\n };\n console.log(JSON.stringify(output, null, 2));\n}\n\n// Output actions in pretty format\nexport function outputActionsPretty(actions: Action[]): void {\n if (actions.length === 0) {\n console.log(chalk.gray('No actions found.'));\n return;\n }\n\n console.log(chalk.bold(`\\nActions (${actions.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n\n for (const action of actions) {\n const statusColor = getKanbanStatusColor(action.kanbanStatus);\n const statusBadge = action.kanbanStatus\n ? chalk[statusColor](`[${action.kanbanStatus}]`)\n : chalk.gray('[NO STATUS]');\n\n console.log(`\\n${statusBadge} ${chalk.bold(action.name)}`);\n console.log(chalk.gray(` ID: ${action.id}`));\n\n if (action.project) {\n console.log(` ${chalk.cyan('Project:')} ${action.project.name}`);\n }\n\n console.log(` ${chalk.magenta('Priority:')} ${action.priority}`);\n\n if (action.dueDate) {\n const dueDate = new Date(action.dueDate);\n const isOverdue = dueDate < new Date();\n const dateStr = formatDate(dueDate);\n console.log(` ${chalk.yellow('Due:')} ${isOverdue ? chalk.red(dateStr) : dateStr}`);\n }\n\n if (action.description) {\n console.log(` ${chalk.gray('Description:')} ${action.description.substring(0, 100)}${action.description.length > 100 ? '...' : ''}`);\n }\n }\n console.log();\n}\n\n// ─── Today's actions (the /today partition) ────────────────\n\nexport function outputTodaysActionsJson(t: TodaysActions, filters: Record<string, unknown> = {}): void {\n console.log(JSON.stringify({\n overdue: { count: t.overdue.count, actions: t.overdue.actions },\n today: { count: t.today.count, actions: t.today.actions },\n inbox: { count: t.inbox.count, actions: t.inbox.actions },\n total: t.overdue.count + t.today.count + t.inbox.count,\n filters,\n }, null, 2));\n}\n\nfunction printTodayGroup(label: string, group: TodaysActions['overdue'], color: 'red' | 'green' | 'gray'): void {\n if (group.count === 0) return;\n const truncated = group.count > group.actions.length\n ? chalk.gray(` (showing ${group.actions.length})`)\n : '';\n console.log(`\\n${chalk[color].bold(`${label} (${group.count})`)}${truncated}`);\n for (const a of group.actions) {\n const when = a.scheduledStart ?? a.dueDate;\n const stamp = when ? chalk.gray(formatDate(new Date(when))) : '';\n const project = a.projectName ? chalk.cyan(` [${a.projectName}]`) : '';\n console.log(` ${a.name}${project} ${stamp}`);\n console.log(chalk.gray(` ID: ${a.id}`));\n }\n}\n\nexport function outputTodaysActionsPretty(t: TodaysActions): void {\n const total = t.overdue.count + t.today.count + t.inbox.count;\n if (total === 0) {\n console.log(chalk.gray('Nothing on your plate.'));\n return;\n }\n console.log(chalk.bold('\\nOn your plate'));\n console.log(chalk.gray('─'.repeat(50)));\n printTodayGroup('Overdue', t.overdue, 'red');\n printTodayGroup('Today', t.today, 'green');\n printTodayGroup('Inbox', t.inbox, 'gray');\n if (t.overdue.count > 0) {\n console.log(chalk.gray(`\\nRun \"exponential actions overdue\" to see why the overdue pile is that size.`));\n }\n console.log();\n}\n\n// ─── Overdue triage ────────────────────────────────────────\n\nexport function outputOverdueTriageJson(t: OverdueTriage): void {\n console.log(JSON.stringify(t, null, 2));\n}\n\nexport function outputOverdueTriagePretty(t: OverdueTriage): void {\n if (t.totalOverdue === 0) {\n console.log(chalk.green('Nothing overdue.'));\n return;\n }\n\n console.log(chalk.bold(`\\nOverdue: ${t.totalOverdue}`));\n console.log(chalk.gray('─'.repeat(50)));\n\n if (t.cohorts.length > 0) {\n console.log(\n `\\n${chalk.yellow.bold(`${t.cohortCount} of these were bulk-created`)} ${chalk.gray('— stamped with one identical timestamp, so almost certainly never individually due.')}`,\n );\n for (const c of t.cohorts) {\n console.log(\n `\\n ${chalk.bold(`${c.count} actions`)} stamped ${chalk.gray(c.stampedAt.toISOString())} ${chalk.red(`(${c.daysOverdue}d overdue)`)}`,\n );\n if (c.projectNames.length > 0) {\n console.log(` ${chalk.cyan('Projects:')} ${c.projectNames.join(', ')}`);\n }\n for (const a of c.actions.slice(0, 4)) {\n console.log(chalk.gray(` · ${a.name.substring(0, 62)}`));\n }\n if (c.actions.length > 4) {\n console.log(chalk.gray(` · … and ${c.actions.length - 4} more`));\n }\n console.log(\n chalk.gray(` Amnesty: `) +\n `exponential actions defer --ids ${c.actionIds.slice(0, 2).join(',')}${c.actionIds.length > 2 ? ',…' : ''}`,\n );\n }\n }\n\n if (t.loose.length > 0) {\n console.log(`\\n${chalk.bold(`${t.loose.length} individually dated`)} ${chalk.gray('— real debt, oldest first.')}`);\n for (const a of t.loose) {\n const project = a.projectName ? chalk.cyan(` [${a.projectName}]`) : '';\n console.log(` ${chalk.red(`${String(a.daysOverdue).padStart(3)}d`)} ${a.name.substring(0, 62)}${project}`);\n console.log(chalk.gray(` ID: ${a.id}`));\n }\n }\n console.log();\n}\n\n// Output projects as JSON\nexport function outputProjectsJson(projects: Project[]): void {\n const output: ProjectsListOutput = {\n projects: projects.map(transformProject),\n total: projects.length,\n };\n console.log(JSON.stringify(output, null, 2));\n}\n\n// Output projects in pretty format\nexport function outputProjectsPretty(projects: Project[]): void {\n if (projects.length === 0) {\n console.log(chalk.gray('No projects found.'));\n return;\n }\n\n console.log(chalk.bold(`\\nProjects (${projects.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n\n for (const project of projects) {\n console.log(`\\n${chalk.bold(project.name)}`);\n console.log(chalk.gray(` ID: ${project.id}`));\n\n if (project.status) {\n console.log(` ${chalk.cyan('Status:')} ${project.status}`);\n }\n\n if (project.priority) {\n console.log(` ${chalk.magenta('Priority:')} ${project.priority}`);\n }\n\n if (project.workspace) {\n console.log(` ${chalk.yellow('Workspace:')} ${project.workspace.name} (${project.workspace.slug})`);\n }\n\n if (project.description) {\n console.log(` ${chalk.gray('Description:')} ${project.description.substring(0, 100)}${project.description.length > 100 ? '...' : ''}`);\n }\n }\n console.log();\n}\n\n// Output workspaces as JSON\nexport function outputWorkspacesJson(workspaces: Workspace[]): void {\n const output: WorkspacesListOutput = {\n workspaces: workspaces.map(transformWorkspace),\n total: workspaces.length,\n };\n console.log(JSON.stringify(output, null, 2));\n}\n\n// Output workspaces in pretty format\nexport function outputWorkspacesPretty(workspaces: Workspace[]): void {\n if (workspaces.length === 0) {\n console.log(chalk.gray('No workspaces found.'));\n return;\n }\n\n console.log(chalk.bold(`\\nWorkspaces (${workspaces.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n\n for (const workspace of workspaces) {\n console.log(`\\n${chalk.bold(workspace.name)}`);\n console.log(chalk.gray(` ID: ${workspace.id}`));\n console.log(` ${chalk.cyan('Slug:')} ${workspace.slug}`);\n console.log(` ${chalk.magenta('Type:')} ${workspace.type}`);\n }\n console.log();\n}\n\n// Helper functions\nfunction getKanbanStatusColor(status: string | null): 'gray' | 'blue' | 'yellow' | 'cyan' | 'green' | 'red' {\n switch (status) {\n case 'BACKLOG': return 'gray';\n case 'TODO': return 'blue';\n case 'IN_PROGRESS': return 'yellow';\n case 'IN_REVIEW': return 'cyan';\n case 'DONE': return 'green';\n case 'CANCELLED': return 'red';\n default: return 'gray';\n }\n}\n\nfunction formatDate(date: Date): string {\n return date.toLocaleDateString('en-US', {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n });\n}\n\n// ─── Contact output ────────────────────────────────────────\n\nexport function outputContactJson(contact: Contact): void {\n console.log(JSON.stringify(transformContact(contact), null, 2));\n}\n\nexport function outputContactPretty(contact: Contact): void {\n const name = [contact.firstName, contact.lastName].filter(Boolean).join(' ') || chalk.gray('(no name)');\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk.bold(name)}`);\n console.log(chalk.gray(` ID: ${contact.id}`));\n if (contact.email) console.log(` ${chalk.cyan('Email:')} ${contact.email}`);\n if (contact.phone) console.log(` ${chalk.cyan('Phone:')} ${contact.phone}`);\n if (contact.telegram) console.log(` ${chalk.cyan('Telegram:')} ${contact.telegram}`);\n if (contact.linkedIn) console.log(` ${chalk.cyan('LinkedIn:')} ${contact.linkedIn}`);\n if (contact.twitter) console.log(` ${chalk.cyan('Twitter:')} ${contact.twitter}`);\n if (contact.github) console.log(` ${chalk.cyan('GitHub:')} ${contact.github}`);\n if (contact.bluesky) console.log(` ${chalk.cyan('Bluesky:')} ${contact.bluesky}`);\n if (contact.about) console.log(` ${chalk.gray('About:')} ${contact.about.substring(0, 120)}${contact.about.length > 120 ? '...' : ''}`);\n if (contact.profileType) console.log(` ${chalk.magenta('Type:')} ${contact.profileType}`);\n if (contact.skills?.length) console.log(` ${chalk.yellow('Skills:')} ${contact.skills.join(', ')}`);\n if (contact.tags?.length) console.log(` ${chalk.yellow('Tags:')} ${contact.tags.join(', ')}`);\n if (contact.organization) console.log(` ${chalk.green('Org:')} ${contact.organization.name}`);\n if (contact.connectionScore != null) console.log(` ${chalk.blue('Connection Score:')} ${contact.connectionScore}`);\n if (contact.lastInteractionAt) console.log(` ${chalk.gray('Last Interaction:')} ${formatDate(new Date(contact.lastInteractionAt))} (${contact.lastInteractionType ?? ''})`);\n console.log();\n}\n\nexport function outputContactsJson(contacts: Contact[], nextCursor?: string): void {\n console.log(JSON.stringify({\n contacts: contacts.map(transformContact),\n total: contacts.length,\n nextCursor: nextCursor ?? null,\n }, null, 2));\n}\n\nexport function outputContactsPretty(contacts: Contact[]): void {\n if (contacts.length === 0) {\n console.log(chalk.gray('No contacts found.'));\n return;\n }\n console.log(chalk.bold(`\\nContacts (${contacts.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const contact of contacts) {\n const name = [contact.firstName, contact.lastName].filter(Boolean).join(' ') || chalk.gray('(no name)');\n console.log(`\\n${chalk.bold(name)}`);\n console.log(chalk.gray(` ID: ${contact.id}`));\n if (contact.email) console.log(` ${chalk.cyan('Email:')} ${contact.email}`);\n if (contact.organization) console.log(` ${chalk.green('Org:')} ${contact.organization.name}`);\n if (contact.tags?.length) console.log(` ${chalk.yellow('Tags:')} ${contact.tags.join(', ')}`);\n }\n console.log();\n}\n\nfunction transformContact(contact: Contact): Record<string, unknown> {\n return {\n id: contact.id,\n workspaceId: contact.workspaceId,\n firstName: contact.firstName,\n lastName: contact.lastName,\n email: contact.email,\n phone: contact.phone,\n linkedIn: contact.linkedIn,\n telegram: contact.telegram,\n twitter: contact.twitter,\n github: contact.github,\n bluesky: contact.bluesky,\n about: contact.about,\n profileType: contact.profileType,\n skills: contact.skills,\n tags: contact.tags,\n organizationId: contact.organizationId,\n organization: contact.organization ?? null,\n connectionScore: contact.connectionScore,\n lastInteractionAt: contact.lastInteractionAt ? new Date(contact.lastInteractionAt).toISOString() : null,\n lastInteractionType: contact.lastInteractionType,\n createdAt: new Date(contact.createdAt).toISOString(),\n updatedAt: new Date(contact.updatedAt).toISOString(),\n };\n}\n\n// ─── Interaction output ────────────────────────────────────\n\nexport function outputInteractionJson(interaction: ContactInteraction): void {\n console.log(JSON.stringify(interaction, null, 2));\n}\n\nexport function outputInteractionPretty(interaction: ContactInteraction): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(` ${chalk.cyan('Type:')} ${interaction.type} (${interaction.direction})`);\n if (interaction.subject) console.log(` ${chalk.bold('Subject:')} ${interaction.subject}`);\n if (interaction.notes) console.log(` ${chalk.gray('Notes:')} ${interaction.notes}`);\n console.log();\n}\n\n// ─── Organization output ───────────────────────────────────\n\nfunction transformOrganization(org: Organization): Record<string, unknown> {\n return {\n id: org.id,\n workspaceId: org.workspaceId,\n name: org.name,\n websiteUrl: org.websiteUrl,\n logoUrl: org.logoUrl,\n description: org.description,\n industry: org.industry,\n size: org.size,\n contactCount: org._count?.contacts ?? null,\n createdAt: new Date(org.createdAt).toISOString(),\n updatedAt: new Date(org.updatedAt).toISOString(),\n };\n}\n\nexport function outputOrganizationJson(org: Organization): void {\n console.log(JSON.stringify(transformOrganization(org), null, 2));\n}\n\nexport function outputOrganizationPretty(org: Organization): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk.bold(org.name)}`);\n console.log(chalk.gray(` ID: ${org.id}`));\n if (org.industry) console.log(` ${chalk.magenta('Industry:')} ${org.industry}`);\n if (org.size) console.log(` ${chalk.cyan('Size:')} ${org.size}`);\n if (org.websiteUrl) console.log(` ${chalk.cyan('Website:')} ${org.websiteUrl}`);\n if (org.description) console.log(` ${chalk.gray('About:')} ${org.description.substring(0, 120)}${org.description.length > 120 ? '...' : ''}`);\n if (org._count?.contacts != null) console.log(` ${chalk.green('Contacts:')} ${org._count.contacts}`);\n console.log();\n}\n\nexport function outputOrganizationsJson(organizations: Organization[], nextCursor?: string): void {\n console.log(JSON.stringify({\n organizations: organizations.map(transformOrganization),\n total: organizations.length,\n nextCursor: nextCursor ?? null,\n }, null, 2));\n}\n\nexport function outputOrganizationsPretty(organizations: Organization[]): void {\n if (organizations.length === 0) {\n console.log(chalk.gray('No organizations found.'));\n return;\n }\n console.log(chalk.bold(`\\nOrganizations (${organizations.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const org of organizations) {\n console.log(`\\n${chalk.bold(org.name)}`);\n console.log(chalk.gray(` ID: ${org.id}`));\n if (org.industry) console.log(` ${chalk.magenta('Industry:')} ${org.industry}`);\n if (org._count?.contacts != null) console.log(` ${chalk.green('Contacts:')} ${org._count.contacts}`);\n }\n console.log();\n}\n\n// ─── Deal output ───────────────────────────────────────────\n\nexport function outputDealJson(deal: Deal): void {\n console.log(JSON.stringify(transformDeal(deal), null, 2));\n}\n\nexport function outputDealPretty(deal: Deal): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk.bold(deal.title)}`);\n console.log(chalk.gray(` ID: ${deal.id}`));\n if (deal.stage) console.log(` ${chalk.blue('Stage:')} ${deal.stage.name}`);\n if (deal.value != null) console.log(` ${chalk.green('Value:')} ${deal.currency} ${deal.value.toLocaleString()}`);\n if (deal.probability != null) console.log(` ${chalk.yellow('Probability:')} ${deal.probability}%`);\n if (deal.expectedCloseDate) console.log(` ${chalk.cyan('Expected Close:')} ${formatDate(new Date(deal.expectedCloseDate))}`);\n if (deal.contact) {\n const name = [deal.contact.firstName, deal.contact.lastName].filter(Boolean).join(' ');\n if (name) console.log(` ${chalk.magenta('Contact:')} ${name}`);\n }\n if (deal.organization) console.log(` ${chalk.magenta('Org:')} ${deal.organization.name}`);\n if (deal.assignedTo) console.log(` ${chalk.gray('Assigned:')} ${deal.assignedTo.name ?? deal.assignedTo.email ?? deal.assignedTo.id}`);\n if (deal.description) console.log(` ${chalk.gray('Description:')} ${deal.description.substring(0, 120)}${deal.description.length > 120 ? '...' : ''}`);\n console.log();\n}\n\nexport function outputDealsJson(deals: Deal[]): void {\n console.log(JSON.stringify({\n deals: deals.map(transformDeal),\n total: deals.length,\n }, null, 2));\n}\n\nexport function outputDealsPretty(deals: Deal[]): void {\n if (deals.length === 0) {\n console.log(chalk.gray('No deals found.'));\n return;\n }\n console.log(chalk.bold(`\\nDeals (${deals.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const deal of deals) {\n const stageLabel = deal.stage ? chalk.blue(`[${deal.stage.name}]`) : '';\n const valueLabel = deal.value != null ? chalk.green(` ${deal.currency} ${deal.value.toLocaleString()}`) : '';\n console.log(`\\n${stageLabel} ${chalk.bold(deal.title)}${valueLabel}`);\n console.log(chalk.gray(` ID: ${deal.id}`));\n if (deal.contact) {\n const name = [deal.contact.firstName, deal.contact.lastName].filter(Boolean).join(' ');\n if (name) console.log(` ${chalk.magenta('Contact:')} ${name}`);\n }\n if (deal.probability != null) console.log(` ${chalk.yellow('Probability:')} ${deal.probability}%`);\n if (deal.expectedCloseDate) console.log(` ${chalk.cyan('Close:')} ${formatDate(new Date(deal.expectedCloseDate))}`);\n }\n console.log();\n}\n\nfunction transformDeal(deal: Deal): Record<string, unknown> {\n return {\n id: deal.id,\n projectId: deal.projectId,\n stageId: deal.stageId,\n title: deal.title,\n description: deal.description,\n value: deal.value,\n currency: deal.currency,\n probability: deal.probability,\n expectedCloseDate: deal.expectedCloseDate ? new Date(deal.expectedCloseDate).toISOString() : null,\n closedAt: deal.closedAt ? new Date(deal.closedAt).toISOString() : null,\n contactId: deal.contactId,\n organizationId: deal.organizationId,\n workspaceId: deal.workspaceId,\n assignedToId: deal.assignedToId,\n stage: deal.stage ? { id: deal.stage.id, name: deal.stage.name, color: deal.stage.color } : null,\n contact: deal.contact ?? null,\n organization: deal.organization ?? null,\n assignedTo: deal.assignedTo ?? null,\n createdAt: new Date(deal.createdAt).toISOString(),\n updatedAt: new Date(deal.updatedAt).toISOString(),\n };\n}\n\n// ─── Pipeline output ───────────────────────────────────────\n\nexport function outputPipelineJson(pipeline: Pipeline): void {\n console.log(JSON.stringify({\n id: pipeline.id,\n name: pipeline.name,\n workspaceId: pipeline.workspaceId,\n status: pipeline.status,\n stages: pipeline.pipelineStages.map(s => ({\n id: s.id,\n name: s.name,\n color: s.color,\n order: s.order,\n type: s.type,\n dealCount: s._count?.deals ?? null,\n })),\n }, null, 2));\n}\n\nexport function outputPipelinePretty(pipeline: Pipeline): void {\n console.log(chalk.bold(`\\nPipeline: ${pipeline.name}`));\n console.log(chalk.gray(` ID: ${pipeline.id}`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const stage of pipeline.pipelineStages) {\n const count = stage._count?.deals != null ? chalk.gray(` (${stage._count.deals} deals)`) : '';\n console.log(` ${chalk.bold(stage.name)}${count} — ${chalk.gray(stage.type)}`);\n }\n console.log();\n}\n\nexport function outputStagesJson(stages: PipelineStage[]): void {\n console.log(JSON.stringify({\n stages: stages.map(s => ({\n id: s.id,\n name: s.name,\n color: s.color,\n order: s.order,\n type: s.type,\n dealCount: s._count?.deals ?? null,\n })),\n total: stages.length,\n }, null, 2));\n}\n\n// ─── Comment output ────────────────────────────────────────\n\n// Two comment shapes exist server-side and both reach the CLI: actions,\n// tickets and goals use `{ authorId, content, author }`; features and pages use\n// `{ createdById, body, createdBy }`. Rather than teach every caller which is\n// which, normalize once here — output is identical either way.\ntype AnyComment =\n | ActionComment\n | TicketComment\n | GoalComment\n | FeatureComment\n | PageComment;\n\nconst COMMENT_PARENT_KEYS = ['actionId', 'ticketId', 'goalId', 'featureId', 'pageId'] as const;\n\ninterface NormalizedComment {\n id: string;\n parentKey: string;\n parentId: unknown;\n authorId: string;\n author: { id: string; name: string | null } | null;\n content: string;\n createdAt: Date;\n updatedAt: Date;\n /** Feature comments only: set when the comment is a reply. */\n parentCommentId?: string | null;\n /** Feature comments only: the anchored thread, when there is one. */\n threadId?: string | null;\n resolvedAt?: Date | null;\n}\n\nfunction normalizeComment(comment: AnyComment): NormalizedComment {\n const raw = comment as unknown as Record<string, unknown>;\n const parentKey = COMMENT_PARENT_KEYS.find((k) => k in raw) ?? 'parentId';\n const author = (raw.author ?? raw.createdBy ?? null) as\n | { id: string; name: string | null }\n | null;\n\n return {\n id: comment.id,\n parentKey,\n parentId: raw[parentKey],\n authorId: (raw.authorId ?? raw.createdById) as string,\n author,\n content: (raw.content ?? raw.body ?? '') as string,\n createdAt: new Date(comment.createdAt),\n updatedAt: new Date(comment.updatedAt),\n parentCommentId: (raw.parentId ?? null) as string | null,\n threadId: (raw.threadId ?? null) as string | null,\n resolvedAt: raw.resolvedAt ? new Date(raw.resolvedAt as string) : null,\n };\n}\n\nfunction transformComment(comment: AnyComment): Record<string, unknown> {\n const n = normalizeComment(comment);\n const out: Record<string, unknown> = {\n id: n.id,\n [n.parentKey]: n.parentId,\n authorId: n.authorId,\n content: n.content,\n author: n.author,\n createdAt: n.createdAt.toISOString(),\n updatedAt: n.updatedAt.toISOString(),\n };\n // Threading metadata only exists on feature comments — omit it elsewhere so\n // the JSON of an action comment stays exactly as it was.\n if (n.threadId !== null) out.threadId = n.threadId;\n if (n.parentCommentId !== null && n.parentKey !== 'parentId') {\n out.parentCommentId = n.parentCommentId;\n }\n if (n.resolvedAt) out.resolvedAt = n.resolvedAt.toISOString();\n return out;\n}\n\nexport function outputCommentJson(comment: AnyComment): void {\n console.log(JSON.stringify(transformComment(comment), null, 2));\n}\n\nexport function outputCommentPretty(comment: AnyComment): void {\n const n = normalizeComment(comment);\n const author = n.author?.name ?? n.authorId;\n const when = formatDate(n.createdAt);\n const badges = [\n n.parentCommentId && n.parentKey !== 'parentId' ? chalk.gray('(reply)') : '',\n n.resolvedAt ? chalk.green('(resolved)') : '',\n ]\n .filter(Boolean)\n .join(' ');\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`${chalk.bold(author)} ${chalk.gray(`— ${when}`)}${badges ? ` ${badges}` : ''}`);\n console.log(chalk.gray(` ID: ${n.id}`));\n console.log();\n console.log(n.content);\n console.log();\n}\n\nexport function outputCommentsJson(comments: AnyComment[]): void {\n console.log(JSON.stringify({\n comments: comments.map(transformComment),\n total: comments.length,\n }, null, 2));\n}\n\nexport function outputCommentsPretty(comments: AnyComment[]): void {\n if (comments.length === 0) {\n console.log(chalk.gray('No comments.'));\n return;\n }\n console.log(chalk.bold(`\\nComments (${comments.length})`));\n for (const c of comments) {\n outputCommentPretty(c);\n }\n}\n\n// ─── Product output ────────────────────────────────────────\n\nexport function outputProductJson(product: Product): void {\n console.log(JSON.stringify(transformProduct(product), null, 2));\n}\n\nexport function outputProductPretty(product: Product): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk.bold(product.name)} ${chalk.gray(`(${product.slug})`)}`);\n console.log(chalk.gray(` ID: ${product.id}`));\n if (product.description) {\n console.log(` ${chalk.gray('Description:')} ${product.description}`);\n }\n if (product._count) {\n const c = product._count;\n const parts = [\n c.features != null ? `features: ${c.features}` : null,\n c.tickets != null ? `tickets: ${c.tickets}` : null,\n ].filter(Boolean);\n if (parts.length) console.log(` ${chalk.cyan('Counts:')} ${parts.join(' ')}`);\n }\n console.log();\n}\n\nexport function outputProductsJson(products: Product[]): void {\n console.log(JSON.stringify({\n products: products.map(transformProduct),\n total: products.length,\n }, null, 2));\n}\n\nexport function outputProductsPretty(products: Product[]): void {\n if (products.length === 0) {\n console.log(chalk.gray('No products found.'));\n return;\n }\n console.log(chalk.bold(`\\nProducts (${products.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const p of products) {\n const ticketCount = p._count?.tickets != null ? chalk.gray(` — ${p._count.tickets} tickets`) : '';\n console.log(` ${chalk.bold(p.name)} ${chalk.gray(`(${p.slug})`)}${ticketCount}`);\n console.log(chalk.gray(` ID: ${p.id}`));\n }\n console.log();\n}\n\nfunction transformProduct(product: Product): Record<string, unknown> {\n return {\n id: product.id,\n workspaceId: product.workspaceId,\n name: product.name,\n slug: product.slug,\n description: product.description,\n icon: product.icon,\n color: product.color,\n funTicketIds: product.funTicketIds,\n ticketCounter: product.ticketCounter,\n counts: product._count ?? null,\n createdAt: new Date(product.createdAt).toISOString(),\n updatedAt: new Date(product.updatedAt).toISOString(),\n };\n}\n\n// ─── Feature output ────────────────────────────────────────\n\nexport function outputFeatureJson(feature: Feature): void {\n console.log(JSON.stringify(transformFeature(feature), null, 2));\n}\n\nexport function outputFeaturePretty(feature: Feature): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk[getFeatureStatusColor(feature.status)](`[${feature.status}]`)} ${chalk.bold(feature.name)}`);\n console.log(chalk.gray(` ID: ${feature.id}`));\n if (feature.description) {\n console.log(` ${chalk.gray('Description:')} ${feature.description.substring(0, 120)}${feature.description.length > 120 ? '...' : ''}`);\n }\n if (feature.vision) {\n console.log(` ${chalk.gray('Vision:')} ${feature.vision.substring(0, 120)}${feature.vision.length > 120 ? '...' : ''}`);\n }\n if (feature.priority != null) {\n console.log(` ${chalk.magenta('Priority:')} ${feature.priority}`);\n }\n if (feature.goal) {\n console.log(` ${chalk.blue('Objective:')} ${feature.goal.title} ${chalk.gray(`(${feature.goal.id})`)}`);\n }\n // The finer Feature->Key result edge (ADR-0050), printed beneath the\n // Objective it is easily confused with.\n if (feature.keyResultLinks?.length) {\n console.log(` ${chalk.blue('Key results:')}`);\n for (const link of feature.keyResultLinks) {\n const kr = link.keyResult;\n const progress =\n kr.currentValue != null && kr.targetValue != null\n ? `${kr.currentValue}/${kr.targetValue}${kr.unit && kr.unit !== 'custom' ? ` ${kr.unit}` : ''}, `\n : '';\n console.log(` · ${kr.title} ${chalk.gray(`(${progress}${kr.period}, ${kr.id})`)}`);\n }\n }\n if (feature._count?.tickets != null) {\n console.log(` ${chalk.cyan('Tickets:')} ${feature._count.tickets}`);\n }\n console.log();\n}\n\nexport function outputFeaturesJson(features: Feature[]): void {\n console.log(JSON.stringify({\n features: features.map(transformFeature),\n total: features.length,\n }, null, 2));\n}\n\nexport function outputFeaturesPretty(features: Feature[]): void {\n if (features.length === 0) {\n console.log(chalk.gray('No features found.'));\n return;\n }\n console.log(chalk.bold(`\\nFeatures (${features.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const f of features) {\n const statusBadge = chalk[getFeatureStatusColor(f.status)](`[${f.status}]`);\n const ticketCount = f._count?.tickets != null ? chalk.gray(` — ${f._count.tickets} tickets`) : '';\n console.log(` ${statusBadge} ${chalk.bold(f.name)}${ticketCount}`);\n console.log(chalk.gray(` ID: ${f.id}`));\n // The KR column, one line per feature — the whole point of carrying the\n // lean shape on `list` rather than making callers fetch each feature.\n if (f.keyResultLinks?.length) {\n const titles = f.keyResultLinks.map((l) => l.keyResult.title).join('; ');\n console.log(chalk.gray(` KRs: ${titles}`));\n }\n }\n console.log();\n}\n\n/**\n * One key result a feature executes, flattened for output. `currentValue` and\n * friends are undefined on the lean `features list` shape; they are only\n * selected on `features get`.\n */\nfunction summarizeFeatureKeyResult(\n link: FeatureKeyResultLink,\n): Record<string, unknown> {\n const kr = link.keyResult;\n return {\n keyResultId: kr.id,\n title: kr.title,\n period: kr.period,\n goalId: kr.goalId,\n status: kr.status ?? null,\n currentValue: kr.currentValue ?? null,\n targetValue: kr.targetValue ?? null,\n unit: kr.unit ?? null,\n };\n}\n\nfunction transformFeature(feature: Feature): Record<string, unknown> {\n return {\n id: feature.id,\n productId: feature.productId,\n name: feature.name,\n description: feature.description,\n vision: feature.vision,\n status: feature.status,\n effort: feature.effort,\n priority: feature.priority,\n goalId: feature.goalId,\n goal: feature.goal ?? null,\n // Flattened out of the join row (ADR-0050): callers building a per-feature\n // \"which key results does this move\" column want the key results, not the\n // edge rows. `goal` above is the coarser Objective alignment and is a\n // different question - the two are allowed to disagree, so both ride along.\n // Progress values are present on `features get` and absent on `list`.\n keyResults: feature.keyResultLinks?.map(summarizeFeatureKeyResult) ?? null,\n counts: feature._count ?? null,\n createdAt: new Date(feature.createdAt).toISOString(),\n updatedAt: new Date(feature.updatedAt).toISOString(),\n };\n}\n\nfunction getFeatureStatusColor(status: string): 'gray' | 'blue' | 'yellow' | 'green' | 'red' {\n switch (status) {\n case 'IDEA': return 'gray';\n case 'DEFINED': return 'blue';\n case 'IN_PROGRESS': return 'yellow';\n case 'SHIPPED': return 'green';\n case 'ARCHIVED': return 'red';\n default: return 'gray';\n }\n}\n\n// ─── User story output ─────────────────────────────────────\n\nfunction transformUserStory(story: UserStory): Record<string, unknown> {\n return {\n id: story.id,\n featureId: story.featureId,\n scopeId: story.scopeId,\n asA: story.asA,\n iWant: story.iWant,\n soThat: story.soThat,\n acceptanceCriteria: story.acceptanceCriteria,\n displayOrder: story.displayOrder,\n createdAt: new Date(story.createdAt).toISOString(),\n updatedAt: new Date(story.updatedAt).toISOString(),\n };\n}\n\nexport function outputUserStoryJson(story: UserStory): void {\n console.log(JSON.stringify(transformUserStory(story), null, 2));\n}\n\nexport function outputUserStoryPretty(story: UserStory): void {\n console.log(chalk.gray('─'.repeat(50)));\n const order = chalk.gray(`#${story.displayOrder}`);\n console.log(`\\n${order} ${chalk.bold(story.iWant ?? '(no \"I want\")')}`);\n console.log(chalk.gray(` ID: ${story.id}`));\n if (story.asA) console.log(` ${chalk.cyan('As a:')} ${story.asA}`);\n if (story.iWant) console.log(` ${chalk.cyan('I want:')} ${story.iWant}`);\n if (story.soThat) console.log(` ${chalk.cyan('So that:')} ${story.soThat}`);\n if (story.acceptanceCriteria) {\n console.log(` ${chalk.yellow('Acceptance:')} ${story.acceptanceCriteria}`);\n }\n if (story.scopeId) console.log(` ${chalk.magenta('Scope:')} ${story.scopeId}`);\n console.log();\n}\n\nexport function outputUserStoriesJson(stories: UserStory[]): void {\n console.log(JSON.stringify({\n userStories: stories.map(transformUserStory),\n total: stories.length,\n }, null, 2));\n}\n\nexport function outputUserStoriesPretty(stories: UserStory[]): void {\n if (stories.length === 0) {\n console.log(chalk.gray('No user stories found.'));\n return;\n }\n console.log(chalk.bold(`\\nUser stories (${stories.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const story of stories) {\n const order = chalk.gray(`#${story.displayOrder}`);\n const parts = [\n story.asA ? `As a ${story.asA},` : null,\n story.iWant ? `I want ${story.iWant},` : null,\n story.soThat ? `so that ${story.soThat}.` : null,\n ].filter(Boolean).join(' ');\n console.log(` ${order} ${parts || chalk.gray('(empty)')}`);\n console.log(chalk.gray(` ID: ${story.id}`));\n }\n console.log();\n}\n\n// Output a batch add summary (per-item success/failure).\nexport interface BatchStoryResult {\n index: number;\n ok: boolean;\n id?: string;\n error?: string;\n}\n\nexport function outputBatchResultsJson(results: BatchStoryResult[]): void {\n const succeeded = results.filter((r) => r.ok).length;\n console.log(JSON.stringify({\n results,\n total: results.length,\n succeeded,\n failed: results.length - succeeded,\n }, null, 2));\n}\n\nexport function outputBatchResultsPretty(results: BatchStoryResult[]): void {\n const succeeded = results.filter((r) => r.ok).length;\n console.log(chalk.bold(`\\nAdded ${succeeded}/${results.length} user stories`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const r of results) {\n if (r.ok) {\n console.log(` ${chalk.green('✓')} [${r.index}] ${chalk.gray(r.id ?? '')}`);\n } else {\n console.log(` ${chalk.red('✗')} [${r.index}] ${r.error ?? 'failed'}`);\n }\n }\n console.log();\n}\n\n// ─── Ticket output ─────────────────────────────────────────\n\nexport function outputTicketJson(ticket: Ticket | TicketDetail): void {\n console.log(JSON.stringify(transformTicket(ticket), null, 2));\n}\n\nexport function outputTicketPretty(ticket: Ticket | TicketDetail): void {\n const id = ticket.shortId ?? (ticket.number != null ? `#${ticket.number}` : '?');\n console.log(chalk.gray('─'.repeat(50)));\n console.log(\n `\\n${chalk[getTicketStatusColor(ticket.status)](`[${ticket.status}]`)} ${chalk.gray(`[${ticket.type}]`)} ${chalk.bold(`${id} ${ticket.title}`)}`,\n );\n console.log(chalk.gray(` ID: ${ticket.id}`));\n if (ticket.isBlocked) {\n console.log(` ${chalk.red('BLOCKED')} by ${ticket.openBlockerCount ?? 0} open ticket(s)`);\n } else if (ticket.openBlockerCount && ticket.openBlockerCount > 0) {\n console.log(` ${chalk.yellow('Blockers:')} ${ticket.openBlockerCount} open (not currently in flight)`);\n }\n if (ticket.feature) {\n console.log(` ${chalk.cyan('Feature:')} ${ticket.feature.name}`);\n }\n if (ticket.epic) {\n console.log(` ${chalk.cyan('Epic:')} ${ticket.epic.name}`);\n }\n if (ticket.assignee) {\n console.log(` ${chalk.magenta('Assignee:')} ${ticket.assignee.name ?? ticket.assignee.id}`);\n }\n if (ticket.priority != null) {\n console.log(` ${chalk.magenta('Priority:')} ${ticket.priority}`);\n }\n if (ticket.points != null) {\n console.log(` ${chalk.yellow('Points:')} ${ticket.points}`);\n }\n if (ticket.body) {\n console.log(` ${chalk.gray('Body:')} ${ticket.body.substring(0, 200)}${ticket.body.length > 200 ? '...' : ''}`);\n }\n\n const detail = ticket as TicketDetail;\n if (detail.dependsOn && detail.dependsOn.length > 0) {\n console.log(` ${chalk.cyan('Depends on:')}`);\n for (const dep of detail.dependsOn) {\n const depId = dep.shortId ?? (dep.number != null ? `#${dep.number}` : '?');\n console.log(` - ${chalk.gray(`[${dep.status}]`)} ${depId} ${dep.title}`);\n }\n }\n if (detail.requiredFor && detail.requiredFor.length > 0) {\n console.log(` ${chalk.cyan('Required for:')}`);\n for (const dep of detail.requiredFor) {\n const depId = dep.shortId ?? (dep.number != null ? `#${dep.number}` : '?');\n console.log(` - ${chalk.gray(`[${dep.status}]`)} ${depId} ${dep.title}`);\n }\n }\n if (detail.actions && detail.actions.length > 0) {\n console.log(` ${chalk.cyan('Actions:')} ${detail.actions.length}`);\n for (const a of detail.actions) {\n console.log(` - ${chalk.gray(`[${a.kanbanStatus ?? a.status}]`)} ${a.name} ${chalk.gray(`(${a.id})`)}`);\n }\n }\n console.log();\n}\n\nexport function outputTicketsJson(tickets: Ticket[]): void {\n console.log(JSON.stringify({\n tickets: tickets.map(transformTicket),\n total: tickets.length,\n }, null, 2));\n}\n\nexport function outputTicketsPretty(tickets: Ticket[]): void {\n if (tickets.length === 0) {\n console.log(chalk.gray('No tickets found.'));\n return;\n }\n console.log(chalk.bold(`\\nTickets (${tickets.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const t of tickets) {\n const id = t.shortId ?? (t.number != null ? `#${t.number}` : '?');\n const statusBadge = chalk[getTicketStatusColor(t.status)](`[${t.status}]`);\n const typeBadge = chalk.gray(`[${t.type}]`);\n const blocked = t.isBlocked ? chalk.red(' BLOCKED') : '';\n console.log(` ${statusBadge} ${typeBadge} ${chalk.bold(id)} ${t.title}${blocked}`);\n console.log(chalk.gray(` ID: ${t.id}`));\n }\n console.log();\n}\n\nfunction transformTicket(ticket: Ticket | TicketDetail): Record<string, unknown> {\n const detail = ticket as TicketDetail;\n return {\n id: ticket.id,\n productId: ticket.productId,\n number: ticket.number,\n shortId: ticket.shortId,\n title: ticket.title,\n body: ticket.body,\n type: ticket.type,\n status: ticket.status,\n priority: ticket.priority,\n points: ticket.points,\n branchName: ticket.branchName,\n prUrl: ticket.prUrl,\n designUrl: ticket.designUrl,\n specUrl: ticket.specUrl,\n links: ticket.links,\n epicId: ticket.epicId,\n featureId: ticket.featureId,\n cycleId: ticket.cycleId,\n scopeId: ticket.scopeId,\n assigneeId: ticket.assigneeId,\n assignee: ticket.assignee ?? null,\n feature: ticket.feature ?? null,\n epic: ticket.epic ?? null,\n openBlockerCount: ticket.openBlockerCount ?? 0,\n isBlocked: ticket.isBlocked ?? false,\n counts: ticket._count ?? null,\n dependsOn: detail.dependsOn ?? undefined,\n requiredFor: detail.requiredFor ?? undefined,\n actions: detail.actions?.map((a) => ({\n id: a.id,\n name: a.name,\n status: a.status,\n kanbanStatus: a.kanbanStatus,\n completedAt: a.completedAt ? new Date(a.completedAt).toISOString() : null,\n })),\n completedAt: ticket.completedAt ? new Date(ticket.completedAt).toISOString() : null,\n createdAt: new Date(ticket.createdAt).toISOString(),\n updatedAt: new Date(ticket.updatedAt).toISOString(),\n };\n}\n\nfunction getTicketStatusColor(status: string): 'gray' | 'blue' | 'yellow' | 'cyan' | 'green' | 'red' | 'magenta' {\n switch (status) {\n case 'BACKLOG': return 'gray';\n case 'NEEDS_REFINEMENT': return 'gray';\n case 'READY_TO_PLAN': return 'blue';\n case 'COMMITTED': return 'blue';\n case 'IN_PROGRESS': return 'yellow';\n case 'BLOCKED': return 'red';\n case 'QA': return 'cyan';\n case 'DONE': return 'green';\n case 'DEPLOYED': return 'green';\n case 'ARCHIVED': return 'gray';\n default: return 'gray';\n }\n}\n\n// ─── Epic output ───────────────────────────────────────────\n\nexport function outputEpicJson(epic: Epic): void {\n console.log(JSON.stringify(transformEpic(epic), null, 2));\n}\n\nexport function outputEpicPretty(epic: Epic): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk[getEpicStatusColor(epic.status)](`[${epic.status}]`)} ${chalk.bold(epic.name)}`);\n console.log(chalk.gray(` ID: ${epic.id}`));\n if (epic.description) {\n console.log(` ${chalk.gray('Description:')} ${epic.description.substring(0, 200)}${epic.description.length > 200 ? '...' : ''}`);\n }\n console.log(` ${chalk.magenta('Priority:')} ${epic.priority}`);\n if (epic.startDate) {\n console.log(` ${chalk.cyan('Start:')} ${formatDate(new Date(epic.startDate))}`);\n }\n if (epic.targetDate) {\n console.log(` ${chalk.cyan('Target:')} ${formatDate(new Date(epic.targetDate))}`);\n }\n if (epic.owner) {\n console.log(` ${chalk.gray('Owner:')} ${epic.owner.name ?? epic.owner.email ?? epic.owner.id}`);\n }\n if (epic._count) {\n const c = epic._count;\n const parts = [\n c.actions != null ? `actions: ${c.actions}` : null,\n c.tickets != null ? `tickets: ${c.tickets}` : null,\n ].filter(Boolean);\n if (parts.length) console.log(` ${chalk.cyan('Counts:')} ${parts.join(' ')}`);\n }\n console.log();\n}\n\nexport function outputEpicsJson(epics: Epic[]): void {\n console.log(JSON.stringify({\n epics: epics.map(transformEpic),\n total: epics.length,\n }, null, 2));\n}\n\nexport function outputEpicsPretty(epics: Epic[]): void {\n if (epics.length === 0) {\n console.log(chalk.gray('No epics found.'));\n return;\n }\n console.log(chalk.bold(`\\nEpics (${epics.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const e of epics) {\n const statusBadge = chalk[getEpicStatusColor(e.status)](`[${e.status}]`);\n const counts = e._count\n ? chalk.gray(\n ` — ${e._count.tickets ?? 0} tickets, ${e._count.actions ?? 0} actions`,\n )\n : '';\n console.log(` ${statusBadge} ${chalk.bold(e.name)}${counts}`);\n console.log(chalk.gray(` ID: ${e.id}`));\n }\n console.log();\n}\n\nfunction transformEpic(epic: Epic): Record<string, unknown> {\n return {\n id: epic.id,\n workspaceId: epic.workspaceId,\n name: epic.name,\n description: epic.description,\n status: epic.status,\n priority: epic.priority,\n startDate: epic.startDate ? new Date(epic.startDate).toISOString() : null,\n targetDate: epic.targetDate ? new Date(epic.targetDate).toISOString() : null,\n ownerId: epic.ownerId,\n owner: epic.owner ?? null,\n counts: epic._count ?? null,\n createdAt: new Date(epic.createdAt).toISOString(),\n updatedAt: new Date(epic.updatedAt).toISOString(),\n };\n}\n\nfunction getEpicStatusColor(status: string): 'gray' | 'blue' | 'yellow' | 'green' | 'red' {\n switch (status) {\n case 'OPEN': return 'blue';\n case 'IN_PROGRESS': return 'yellow';\n case 'DONE': return 'green';\n case 'CANCELLED': return 'red';\n default: return 'gray';\n }\n}\n\nexport function outputStagesPretty(stages: PipelineStage[]): void {\n if (stages.length === 0) {\n console.log(chalk.gray('No stages found.'));\n return;\n }\n console.log(chalk.bold(`\\nPipeline Stages (${stages.length})`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const stage of stages) {\n const count = stage._count?.deals != null ? chalk.gray(` (${stage._count.deals} deals)`) : '';\n console.log(` ${chalk.bold(stage.name)}${count} — ${chalk.gray(stage.type)}`);\n }\n console.log();\n}\n\n// ---------------------------------------------------------------------------\n// Knowledge pages\n// ---------------------------------------------------------------------------\n\nexport function outputPageJson(page: KnowledgePage): void {\n console.log(JSON.stringify(page, null, 2));\n}\n\nexport function outputPagePretty(page: KnowledgePage): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk.bold(page.title)}`);\n console.log(chalk.gray(` ID: ${page.id}`));\n if (page.project) {\n console.log(` ${chalk.gray('Project:')} ${page.project.name}`);\n }\n if (page.body) {\n console.log(`\\n${page.body}\\n`);\n }\n}\n\nexport function outputPagesJson(pages: KnowledgePage[]): void {\n console.log(JSON.stringify({ pages, total: pages.length }, null, 2));\n}\n\nexport function outputPagesPretty(pages: KnowledgePage[]): void {\n if (pages.length === 0) {\n console.log(chalk.gray('No pages found.'));\n return;\n }\n console.log(chalk.bold(`\\nPages (${pages.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const p of pages) {\n console.log(` ${chalk.bold(p.title)}`);\n console.log(chalk.gray(` ID: ${p.id}`));\n }\n console.log();\n}\n\n// ---------------------------------------------------------------------------\n// Meetings\n// ---------------------------------------------------------------------------\n\nfunction meetingWhen(meeting: Meeting): Date {\n return new Date(meeting.meetingDate ?? meeting.createdAt);\n}\n\n/**\n * AI-generated summaries are sometimes a stringified JSON object\n * (`overview` / `detailed_breakdown` / ...) rather than plain Markdown.\n * Render the readable parts in that case; otherwise print as-is.\n */\nfunction renderMeetingSummary(summary: string): string {\n if (!summary.trimStart().startsWith('{')) return summary;\n try {\n const parsed: unknown = JSON.parse(summary);\n if (parsed && typeof parsed === 'object') {\n const obj = parsed as { overview?: unknown; detailed_breakdown?: unknown };\n const parts = [obj.overview, obj.detailed_breakdown].filter(\n (v): v is string => typeof v === 'string' && v.length > 0,\n );\n if (parts.length > 0) return parts.join('\\n\\n');\n }\n } catch {\n // not JSON after all — fall through to the raw text\n }\n return summary;\n}\n\n/**\n * Pinned JSON shape for a meeting — agents parse this, so the server response\n * is never serialized verbatim (it drags along embedding/analytics internals\n * and any future server-side field lands straight in the public contract).\n */\nfunction transformMeeting(m: Meeting): Record<string, unknown> {\n return {\n id: m.id,\n sessionId: m.sessionId,\n title: m.title,\n description: m.description,\n notes: m.notes,\n summary: m.summary,\n transcription: m.transcription,\n meetingDate: m.meetingDate,\n createdAt: m.createdAt,\n updatedAt: m.updatedAt,\n userId: m.userId,\n projectId: m.projectId,\n workspaceId: m.workspaceId,\n archivedAt: m.archivedAt,\n durationSeconds: m.durationSeconds ?? null,\n participantCount: m.participantCount ?? null,\n videoUrl: m.videoUrl ?? null,\n project: m.project ?? null,\n workspace: m.workspace ?? null,\n sourceIntegration: m.sourceIntegration ?? null,\n participants: m.participants ?? [],\n actions: m.actions ?? [],\n };\n}\n\n/**\n * List rows swap the large bodies for presence flags: `meetings list` can\n * cover every visible meeting, and full transcripts would flood the agents\n * that parse this. `meetings get` carries the bodies.\n */\nfunction transformMeetingListRow(m: Meeting): Record<string, unknown> {\n const { notes, summary, transcription, ...rest } = transformMeeting(m);\n return {\n ...rest,\n hasNotes: Boolean(notes),\n hasSummary: Boolean(summary),\n hasTranscript: Boolean(transcription),\n };\n}\n\nexport function outputMeetingJson(meeting: Meeting): void {\n console.log(JSON.stringify(transformMeeting(meeting), null, 2));\n}\n\nexport function outputMeetingPretty(\n meeting: Meeting,\n options: { transcript?: boolean } = {},\n): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk.bold(meeting.title ?? 'Untitled meeting')}`);\n console.log(chalk.gray(` ID: ${meeting.id}`));\n console.log(` ${chalk.gray('Date:')} ${meetingWhen(meeting).toLocaleString()}`);\n if (meeting.workspace) {\n console.log(` ${chalk.gray('Workspace:')} ${meeting.workspace.name}`);\n }\n if (meeting.project) {\n console.log(` ${chalk.gray('Project:')} ${meeting.project.name}`);\n }\n if (meeting.sourceIntegration) {\n console.log(` ${chalk.gray('Source:')} ${meeting.sourceIntegration.provider}`);\n }\n if (meeting.durationSeconds) {\n console.log(` ${chalk.gray('Duration:')} ${Math.round(meeting.durationSeconds / 60)} min`);\n }\n if (meeting.archivedAt) {\n console.log(` ${chalk.yellow('Archived')}`);\n }\n if (meeting.participants && meeting.participants.length > 0) {\n const people = meeting.participants\n .map((p) => p.name ?? p.email)\n .join(', ');\n console.log(` ${chalk.gray('Participants:')} ${people}`);\n }\n if (meeting.description) {\n console.log(`\\n${meeting.description}`);\n }\n if (meeting.summary) {\n console.log(`\\n${chalk.bold('Summary')}`);\n console.log(renderMeetingSummary(meeting.summary));\n }\n if (meeting.notes) {\n console.log(`\\n${chalk.bold('Notes')}`);\n console.log(meeting.notes);\n } else {\n console.log(chalk.gray('\\nNo notes yet.'));\n }\n if (options.transcript) {\n if (meeting.transcription) {\n console.log(`\\n${chalk.bold('Transcript')}`);\n console.log(meeting.transcription);\n } else {\n console.log(chalk.gray('\\nNo transcript.'));\n }\n } else if (meeting.transcription) {\n console.log(chalk.gray('\\n(transcript available — pass --transcript to print it)'));\n }\n console.log();\n}\n\nexport function outputMeetingsJson(meetings: Meeting[]): void {\n console.log(\n JSON.stringify(\n { meetings: meetings.map(transformMeetingListRow), total: meetings.length },\n null,\n 2,\n ),\n );\n}\n\nexport function outputMeetingsPretty(meetings: Meeting[]): void {\n if (meetings.length === 0) {\n console.log(chalk.gray('No meetings found.'));\n return;\n }\n console.log(chalk.bold(`\\nMeetings (${meetings.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const m of meetings) {\n const flags = [\n m.notes ? 'notes' : null,\n m.summary ? 'summary' : null,\n m.transcription ? 'transcript' : null,\n ].filter(Boolean);\n const archived = m.archivedAt ? chalk.yellow(' [archived]') : '';\n console.log(\n ` ${chalk.bold(m.title ?? 'Untitled meeting')}${archived} ${chalk.gray(\n meetingWhen(m).toLocaleDateString(),\n )}`,\n );\n console.log(chalk.gray(` ID: ${m.id}`));\n const context = [\n m.project ? `Project: ${m.project.name}` : null,\n m.participantCount ? `${m.participantCount} participants` : null,\n flags.length > 0 ? flags.join(', ') : null,\n ].filter(Boolean);\n if (context.length > 0) {\n console.log(chalk.gray(` ${context.join(' · ')}`));\n }\n }\n console.log();\n}\n\n// ---------------------------------------------------------------------------\n// Decisions\n// ---------------------------------------------------------------------------\n\n// One model covers both meeting panels: a decision that has been made, and an\n// OPEN QUESTION — which is simply a decision whose status is `OPEN`. The JSON\n// shapes carry an explicit `isOpenQuestion` flag so agents parsing this output\n// don't have to know that convention to act on it.\n\nfunction getDecisionStatusColor(\n status: string,\n): 'gray' | 'blue' | 'yellow' | 'green' | 'red' {\n switch (status) {\n case 'OPEN':\n return 'yellow';\n case 'PROPOSED':\n return 'blue';\n case 'ACCEPTED':\n return 'green';\n case 'DEPRECATED':\n return 'red';\n default:\n return 'gray';\n }\n}\n\n/**\n * Pinned JSON shape for a decision — agents parse this, so the server response\n * is never serialized verbatim.\n */\nfunction transformDecision(d: Decision): Record<string, unknown> {\n return {\n id: d.id,\n workspaceId: d.workspaceId,\n number: d.number,\n label: d.label,\n statement: d.statement,\n body: d.body,\n status: d.status,\n isOpenQuestion: d.status === 'OPEN',\n reviewState: d.reviewState,\n source: d.source,\n decidedAt: d.decidedAt,\n ownerId: d.ownerId,\n createdById: d.createdById,\n confirmedById: d.confirmedById,\n confirmedAt: d.confirmedAt,\n transcriptionSessionId: d.transcriptionSessionId,\n occurrenceId: d.occurrenceId,\n productId: d.productId,\n projectId: d.projectId,\n goalId: d.goalId,\n keyResultId: d.keyResultId,\n supersededById: d.supersededById,\n adrDocumentId: d.adrDocumentId,\n evidence: d.evidence ?? [],\n createdAt: d.createdAt,\n updatedAt: d.updatedAt,\n owner: d.owner ?? null,\n deciders: d.deciders ?? [],\n meeting: d.transcriptionSession ?? null,\n product: d.product ?? null,\n project: d.project ?? null,\n goal: d.goal ?? null,\n keyResult: d.keyResult ?? null,\n supersededBy: d.supersededBy ?? null,\n supersedes: d.supersedes ?? [],\n links: d.links ?? [],\n canEdit: d.canEdit ?? null,\n };\n}\n\nfunction transformDecisionListRow(d: DecisionListRow): Record<string, unknown> {\n return {\n id: d.id,\n workspaceId: d.workspaceId,\n number: d.number,\n label: d.label,\n statement: d.statement,\n status: d.status,\n isOpenQuestion: d.status === 'OPEN',\n reviewState: d.reviewState ?? null,\n source: d.source,\n decidedAt: d.decidedAt,\n updatedAt: d.updatedAt,\n transcriptionSessionId: d.transcriptionSessionId,\n occurrenceId: d.occurrenceId,\n productId: d.productId,\n projectId: d.projectId,\n supersededById: d.supersededById,\n evidenceCount: d.evidenceCount,\n linkCount: d._count?.links ?? 0,\n deciderCount: d._count?.deciders ?? 0,\n product: d.product ?? null,\n project: d.project ?? null,\n meeting: d.transcriptionSession ?? null,\n supersededBy: d.supersededBy ?? null,\n };\n}\n\nexport function outputDecisionJson(decision: Decision): void {\n console.log(JSON.stringify(transformDecision(decision), null, 2));\n}\n\nexport function outputDecisionPretty(decision: Decision): void {\n const color = getDecisionStatusColor(decision.status);\n const kind = decision.status === 'OPEN' ? chalk.yellow(' [open question]') : '';\n console.log(chalk.gray('─'.repeat(50)));\n console.log(\n `\\n${chalk.gray(decision.label)} ${chalk.bold(decision.statement)}${kind}`,\n );\n console.log(chalk.gray(` ID: ${decision.id}`));\n console.log(` ${chalk.gray('Status:')} ${chalk[color](decision.status)}`);\n console.log(` ${chalk.gray('Source:')} ${decision.source}`);\n if (decision.reviewState && decision.reviewState !== 'CONFIRMED') {\n console.log(` ${chalk.yellow(decision.reviewState)}`);\n }\n if (decision.decidedAt) {\n console.log(\n ` ${chalk.gray('Decided:')} ${new Date(decision.decidedAt).toLocaleString()}`,\n );\n }\n if (decision.transcriptionSession) {\n console.log(\n ` ${chalk.gray('Meeting:')} ${decision.transcriptionSession.title ?? 'Untitled'} (${decision.transcriptionSession.id})`,\n );\n }\n if (decision.product) {\n console.log(` ${chalk.gray('Product:')} ${decision.product.name}`);\n }\n if (decision.project) {\n console.log(` ${chalk.gray('Project:')} ${decision.project.name}`);\n }\n if (decision.owner) {\n console.log(` ${chalk.gray('Owner:')} ${decision.owner.name ?? decision.owner.id}`);\n }\n if (decision.deciders && decision.deciders.length > 0) {\n const people = decision.deciders\n .map((d) => (d.email ? `${d.name} <${d.email}>` : d.name))\n .join(', ');\n console.log(` ${chalk.gray('Deciders:')} ${people}`);\n }\n if (decision.supersededBy) {\n console.log(\n ` ${chalk.gray('Superseded by:')} D-${decision.supersededBy.number} ${decision.supersededBy.statement}`,\n );\n }\n if (decision.supersedes && decision.supersedes.length > 0) {\n for (const prior of decision.supersedes) {\n console.log(\n ` ${chalk.gray('Supersedes:')} D-${prior.number} ${prior.statement}`,\n );\n }\n }\n if (decision.links && decision.links.length > 0) {\n console.log(` ${chalk.gray('Implemented by:')}`);\n for (const link of decision.links) {\n const target = link.ticket\n ? `${link.ticket.shortId ?? `#${link.ticket.number}`} ${link.ticket.title}`\n : link.feature\n ? `feature: ${link.feature.name}`\n : '(unknown)';\n console.log(chalk.gray(` ${target} [link ${link.id}]`));\n }\n }\n if (decision.evidence && decision.evidence.length > 0) {\n console.log(`\\n${chalk.bold('Evidence')}`);\n for (const turn of decision.evidence) {\n const who = turn.speaker ? `${turn.speaker}: ` : '';\n console.log(chalk.gray(` [${turn.turnIndex}] ${who}${turn.text}`));\n }\n }\n if (decision.body) {\n console.log(`\\n${decision.body}`);\n }\n console.log();\n}\n\nexport function outputDecisionsJson(\n decisions: DecisionListRow[],\n extra: Record<string, unknown> = {},\n): void {\n console.log(\n JSON.stringify(\n {\n decisions: decisions.map(transformDecisionListRow),\n total: decisions.length,\n ...extra,\n },\n null,\n 2,\n ),\n );\n}\n\nexport function outputDecisionsPretty(decisions: DecisionListRow[]): void {\n if (decisions.length === 0) {\n console.log(chalk.gray('No decisions found.'));\n return;\n }\n const openCount = decisions.filter((d) => d.status === 'OPEN').length;\n console.log(\n chalk.bold(\n `\\nDecisions (${decisions.length} total, ${openCount} open question${openCount === 1 ? '' : 's'})`,\n ),\n );\n console.log(chalk.gray('─'.repeat(50)));\n for (const d of decisions) {\n const color = getDecisionStatusColor(d.status);\n const draft =\n d.reviewState && d.reviewState !== 'CONFIRMED'\n ? chalk.yellow(` [${d.reviewState.toLowerCase()}]`)\n : '';\n console.log(\n ` ${chalk.gray(d.label)} ${chalk.bold(d.statement)}${draft} ${chalk[color](`[${d.status}]`)}`,\n );\n console.log(chalk.gray(` ID: ${d.id}`));\n const context = [\n d.product ? `Product: ${d.product.name}` : null,\n d.transcriptionSession\n ? `Meeting: ${d.transcriptionSession.title ?? d.transcriptionSession.id}`\n : null,\n d.decidedAt ? `Decided ${new Date(d.decidedAt).toLocaleDateString()}` : null,\n d.evidenceCount > 0 ? `${d.evidenceCount} evidence` : null,\n d._count?.links ? `${d._count.links} linked` : null,\n ].filter(Boolean);\n if (context.length > 0) {\n console.log(chalk.gray(` ${context.join(' · ')}`));\n }\n }\n console.log();\n}\n\nexport interface BatchDecisionResult {\n index: number;\n success: boolean;\n decision?: Decision;\n statement?: string;\n error?: string;\n}\n\nexport function outputDecisionBatchJson(results: BatchDecisionResult[]): void {\n console.log(\n JSON.stringify(\n {\n results: results.map((r) => ({\n index: r.index,\n success: r.success,\n statement: r.statement ?? r.decision?.statement ?? null,\n decision: r.decision ? transformDecision(r.decision) : null,\n error: r.error ?? null,\n })),\n total: results.length,\n succeeded: results.filter((r) => r.success).length,\n failed: results.filter((r) => !r.success).length,\n },\n null,\n 2,\n ),\n );\n}\n\nexport function outputDecisionBatchPretty(results: BatchDecisionResult[]): void {\n for (const r of results) {\n const statement = r.statement ?? r.decision?.statement ?? '';\n if (r.success) {\n console.log(\n ` ${chalk.green('✓')} #${r.index}: ${chalk.gray(r.decision?.label ?? '')} ${statement}`,\n );\n } else {\n console.log(` ${chalk.red('✗')} #${r.index}: ${statement} — ${r.error ?? 'failed'}`);\n }\n }\n const ok = results.filter((r) => r.success).length;\n console.log(chalk.bold(`\\n${ok}/${results.length} decisions logged`));\n}\n\n// ---------------------------------------------------------------------------\n// Requirements (EARS)\n// ---------------------------------------------------------------------------\n\nexport function outputRequirementJson(requirement: Requirement): void {\n console.log(JSON.stringify(requirement, null, 2));\n}\n\nexport function outputRequirementPretty(requirement: Requirement): void {\n const met = requirement.checkedAt\n ? chalk.green('[met]')\n : chalk.gray('[unmet]');\n const kind = requirement.kind ? chalk.gray(` (${requirement.kind})`) : '';\n console.log(` ${met} ${requirement.statement}${kind}`);\n console.log(chalk.gray(` ID: ${requirement.id}`));\n}\n\nexport function outputRequirementsJson(requirements: Requirement[]): void {\n console.log(JSON.stringify({ requirements, total: requirements.length }, null, 2));\n}\n\nexport function outputRequirementsPretty(requirements: Requirement[]): void {\n if (requirements.length === 0) {\n console.log(chalk.gray('No requirements found.'));\n return;\n }\n const metCount = requirements.filter((r) => r.checkedAt).length;\n console.log(chalk.bold(`\\nRequirements (${metCount}/${requirements.length} met)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const r of requirements) {\n outputRequirementPretty(r);\n }\n console.log();\n}\n\nexport interface BatchRequirementResult {\n index: number;\n success: boolean;\n requirement?: Requirement;\n error?: string;\n}\n\nexport function outputRequirementBatchJson(results: BatchRequirementResult[]): void {\n console.log(JSON.stringify({\n results,\n total: results.length,\n succeeded: results.filter((r) => r.success).length,\n failed: results.filter((r) => !r.success).length,\n }, null, 2));\n}\n\nexport function outputRequirementBatchPretty(results: BatchRequirementResult[]): void {\n for (const r of results) {\n if (r.success) {\n console.log(` ${chalk.green('✓')} #${r.index}: ${r.requirement?.statement ?? ''}`);\n } else {\n console.log(` ${chalk.red('✗')} #${r.index}: ${r.error ?? 'failed'}`);\n }\n }\n const ok = results.filter((r) => r.success).length;\n console.log(chalk.bold(`\\n${ok}/${results.length} requirements added`));\n}\n\n// ---------------------------------------------------------------------------\n// Feature scopes\n// ---------------------------------------------------------------------------\n\nfunction getScopeStatusColor(status: string): 'gray' | 'blue' | 'yellow' | 'green' | 'red' {\n switch (status) {\n case 'PLANNED': return 'blue';\n case 'IN_PROGRESS': return 'yellow';\n case 'SHIPPED': return 'green';\n case 'DEPRECATED': return 'red';\n default: return 'gray';\n }\n}\n\nexport function outputScopeJson(scope: FeatureScope): void {\n console.log(JSON.stringify(scope, null, 2));\n}\n\nexport function outputScopePretty(scope: FeatureScope): void {\n const badge = chalk[getScopeStatusColor(scope.status)](`[${scope.status}]`);\n console.log(` ${badge} ${chalk.bold(scope.version)}`);\n console.log(chalk.gray(` ID: ${scope.id}`));\n if (scope.description) {\n console.log(` ${scope.description.substring(0, 120)}${scope.description.length > 120 ? '...' : ''}`);\n }\n}\n\nexport function outputScopesJson(scopes: FeatureScope[]): void {\n console.log(JSON.stringify({ scopes, total: scopes.length }, null, 2));\n}\n\nexport function outputScopesPretty(scopes: FeatureScope[]): void {\n if (scopes.length === 0) {\n console.log(chalk.gray('No scopes found.'));\n return;\n }\n console.log(chalk.bold(`\\nScopes (${scopes.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const s of scopes) {\n outputScopePretty(s);\n }\n console.log();\n}\n\n// ─── Goal (objective) output ───────────────────────────────\n//\n// An objective is a `Goal` with an INTEGER id; its key results are cuid-keyed\n// `KeyResult` rows. Both are printed here, kept apart on purpose — the tRPC\n// router mounted at `okr` is the key-result router, and conflating the two is\n// the mistake this whole surface exists to stop people repeating.\n\nfunction getGoalStatusColor(status: string): 'gray' | 'blue' | 'yellow' | 'green' | 'red' {\n switch (status) {\n case 'planned': return 'blue';\n case 'active': return 'yellow';\n case 'completed': return 'green';\n case 'archived': return 'gray';\n case 'on-hold': return 'red';\n default: return 'gray';\n }\n}\n\nfunction getKeyResultStatusColor(status: string): 'gray' | 'blue' | 'yellow' | 'green' | 'red' {\n switch (status) {\n case 'not-started': return 'gray';\n case 'on-track': return 'green';\n case 'at-risk': return 'yellow';\n case 'off-track': return 'red';\n case 'achieved': return 'green';\n default: return 'gray';\n }\n}\n\n/** Percent of the start → target span covered, clamped to 0–100. */\nfunction keyResultProgress(kr: KeyResult): number {\n const range = kr.targetValue - kr.startValue;\n if (range <= 0) return 0;\n return Math.max(\n 0,\n Math.min(100, Math.round(((kr.currentValue - kr.startValue) / range) * 100)),\n );\n}\n\nfunction transformGoal(goal: Goal): Record<string, unknown> {\n return {\n id: goal.id,\n title: goal.title,\n description: goal.description,\n status: goal.status,\n period: goal.period,\n health: goal.healthOverride ?? goal.health,\n // Effective progress: manual override, else the key-result mean, else null\n // for \"no signal\". Undefined (rather than null) means the server predates\n // the field — report null rather than inventing a 0.\n progress: goal.resolvedProgress ?? null,\n isProgressManual: goal.isProgressManual ?? false,\n dueDate: goal.dueDate ? new Date(goal.dueDate).toISOString() : null,\n workspaceId: goal.workspaceId,\n workspace: goal.workspace\n ? { id: goal.workspace.id, slug: goal.workspace.slug, name: goal.workspace.name }\n : null,\n parentGoalId: goal.parentGoalId,\n driUserId: goal.driUserId,\n lifeDomain: goal.lifeDomain ? { id: goal.lifeDomain.id, title: goal.lifeDomain.title } : null,\n // THE JOIN: actions carry a projectId and goals carry projects, so inverting\n // this map is what ties a day's work back to an objective. Never elided.\n projects:\n goal.projects?.map((p) => ({ id: p.id, name: p.name, slug: p.slug ?? null })) ?? [],\n childGoals: goal.childGoals?.map((c) => ({ id: c.id, title: c.title, status: c.status })) ?? [],\n keyResultCount: goal._count?.keyResults ?? goal.keyResults?.length ?? null,\n createdAt: goal.createdAt ? new Date(goal.createdAt).toISOString() : null,\n updatedAt: goal.updatedAt ? new Date(goal.updatedAt).toISOString() : null,\n };\n}\n\nexport function outputGoalJson(goal: Goal): void {\n console.log(JSON.stringify(transformGoal(goal), null, 2));\n}\n\nexport function outputGoalPretty(goal: Goal): void {\n console.log(chalk.gray('─'.repeat(50)));\n const badge = chalk[getGoalStatusColor(goal.status)](`[${goal.status}]`);\n console.log(`\\n${badge} ${chalk.bold(goal.title)} ${chalk.gray(`#${goal.id}`)}`);\n if (goal.period) console.log(` ${chalk.gray('Period:')} ${goal.period}`);\n const health = goal.healthOverride ?? goal.health;\n if (health) console.log(` ${chalk.gray('Health:')} ${health}`);\n if (goal.description) {\n console.log(` ${chalk.gray('Description:')} ${goal.description.substring(0, 200)}${goal.description.length > 200 ? '...' : ''}`);\n }\n if (goal.parentGoal) {\n console.log(` ${chalk.gray('Parent:')} ${goal.parentGoal.title} ${chalk.gray(`#${goal.parentGoal.id}`)}`);\n }\n if (goal.projects?.length) {\n console.log(` ${chalk.cyan('Projects:')} ${goal.projects.map((p) => p.name).join(', ')}`);\n }\n if (goal.childGoals?.length) {\n console.log(` ${chalk.cyan('Sub-goals:')} ${goal.childGoals.length}`);\n }\n console.log();\n}\n\nexport function outputGoalsJson(goals: Goal[]): void {\n console.log(JSON.stringify({\n goals: goals.map(transformGoal),\n total: goals.length,\n }, null, 2));\n}\n\nexport function outputGoalsPretty(goals: Goal[]): void {\n if (goals.length === 0) {\n console.log(chalk.gray('No goals found.'));\n return;\n }\n console.log(chalk.bold(`\\nGoals (${goals.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const g of goals) {\n const badge = chalk[getGoalStatusColor(g.status)](`[${g.status}]`);\n const period = g.period ? chalk.gray(` ${g.period}`) : '';\n const krs = g._count?.keyResults ? chalk.gray(` — ${g._count.keyResults} KRs`) : '';\n console.log(` ${badge}${period} ${chalk.bold(g.title)}${krs}`);\n console.log(chalk.gray(` ID: ${g.id}`));\n }\n console.log();\n}\n\nfunction transformGoalTree(node: GoalTreeNode): Record<string, unknown> {\n return {\n ...transformGoal(node),\n keyResults: node.keyResults?.map((kr) => ({\n id: kr.id,\n status: kr.status,\n currentValue: kr.currentValue,\n targetValue: kr.targetValue,\n })) ?? [],\n children: (node.childGoals as GoalTreeNode[] | undefined)?.map(transformGoalTree) ?? [],\n };\n}\n\nexport function outputGoalTreeJson(nodes: GoalTreeNode[]): void {\n console.log(JSON.stringify({\n goals: nodes.map(transformGoalTree),\n total: nodes.length,\n }, null, 2));\n}\n\nexport function outputGoalTreePretty(nodes: GoalTreeNode[]): void {\n if (nodes.length === 0) {\n console.log(chalk.gray('No goals found.'));\n return;\n }\n console.log(chalk.bold('\\nGoal tree'));\n console.log(chalk.gray('─'.repeat(50)));\n // The annual → quarterly cascade is the thing people come to a tree for, so\n // indent by depth rather than flattening.\n const walk = (node: GoalTreeNode, depth: number): void => {\n const pad = ' '.repeat(depth + 1);\n const badge = chalk[getGoalStatusColor(node.status)](`[${node.status}]`);\n const period = node.period ? chalk.gray(` ${node.period}`) : '';\n const krs = node.keyResults?.length ? chalk.gray(` — ${node.keyResults.length} KRs`) : '';\n console.log(`${pad}${depth > 0 ? '└ ' : ''}${badge}${period} ${chalk.bold(node.title)} ${chalk.gray(`#${node.id}`)}${krs}`);\n for (const child of (node.childGoals ?? []) as GoalTreeNode[]) {\n walk(child, depth + 1);\n }\n };\n for (const node of nodes) walk(node, 0);\n console.log();\n}\n\nexport function outputGoalPeriodsJson(periods: GoalPeriod[]): void {\n console.log(JSON.stringify({ periods, total: periods.length }, null, 2));\n}\n\nexport function outputGoalPeriodsPretty(periods: GoalPeriod[]): void {\n console.log(chalk.bold(`\\nPeriods (${periods.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const p of periods) {\n console.log(` ${chalk.bold(p.value)} ${chalk.gray(p.label)}`);\n }\n console.log();\n}\n\nexport function outputGoalStatsJson(stats: GoalStats): void {\n console.log(JSON.stringify({\n ...stats,\n periodEndDate: stats.periodEndDate ? new Date(stats.periodEndDate).toISOString() : null,\n }, null, 2));\n}\n\nexport function outputGoalStatsPretty(stats: GoalStats): void {\n console.log(chalk.bold('\\nOKR stats'));\n console.log(chalk.gray('─'.repeat(50)));\n console.log(` ${chalk.gray('Objectives:')} ${stats.totalObjectives}`);\n console.log(` ${chalk.gray('Key results:')} ${stats.totalKeyResults} (${stats.completedKeyResults} achieved)`);\n console.log(\n ` ${chalk.gray('Breakdown:')} ` +\n `${chalk.green(`${stats.statusBreakdown.onTrack} on-track`)}, ` +\n `${chalk.yellow(`${stats.statusBreakdown.atRisk} at-risk`)}, ` +\n `${chalk.red(`${stats.statusBreakdown.offTrack} off-track`)}, ` +\n `${chalk.green(`${stats.statusBreakdown.achieved} achieved`)}`,\n );\n console.log(` ${chalk.gray('Avg progress:')} ${stats.averageProgress}%`);\n if (stats.averageConfidence != null) {\n console.log(` ${chalk.gray('Avg confidence:')} ${stats.averageConfidence}%`);\n }\n if (stats.periodEndDate) {\n console.log(` ${chalk.gray('Period ends:')} ${new Date(stats.periodEndDate).toISOString().slice(0, 10)}`);\n }\n console.log();\n}\n\n// ─── Key result output ─────────────────────────────────────\n\n/**\n * Most recent check-in timestamp. Not a column — derived from the `checkIns`\n * the read already includes, because \"this key result has not been touched in\n * five weeks\" is a finding, and every consumer would otherwise recompute it.\n * Null when the read carried no check-ins, or the key result has never had one.\n */\nfunction lastCheckInAt(kr: KeyResult): string | null {\n if (!kr.checkIns?.length) return null;\n const latest = kr.checkIns.reduce((newest, c) =>\n new Date(c.createdAt) > new Date(newest.createdAt) ? c : newest,\n );\n return new Date(latest.createdAt).toISOString();\n}\n\nfunction transformKeyResult(kr: KeyResult): Record<string, unknown> {\n return {\n id: kr.id,\n goalId: kr.goalId,\n goal: kr.goal ? { id: kr.goal.id, title: kr.goal.title } : null,\n title: kr.title,\n description: kr.description,\n status: kr.statusOverride ?? kr.status,\n statusOverride: kr.statusOverride ?? null,\n startValue: kr.startValue,\n currentValue: kr.currentValue,\n targetValue: kr.targetValue,\n progress: keyResultProgress(kr),\n unit: kr.unit,\n unitLabel: kr.unitLabel ?? null,\n period: kr.period,\n periodEnd: kr.periodEnd ? new Date(kr.periodEnd).toISOString() : null,\n lastCheckInAt: lastCheckInAt(kr),\n confidence: kr.confidence ?? null,\n driUserId: kr.driUserId,\n workspaceId: kr.workspaceId,\n projects: kr.projects?.map((l) => ({ id: l.projectId, name: l.project?.name ?? null })) ?? [],\n features: kr.features?.map((l) => ({ id: l.featureId, name: l.feature?.name ?? null })) ?? [],\n createdAt: kr.createdAt ? new Date(kr.createdAt).toISOString() : null,\n updatedAt: kr.updatedAt ? new Date(kr.updatedAt).toISOString() : null,\n };\n}\n\nexport function outputKeyResultJson(kr: KeyResult): void {\n console.log(JSON.stringify(transformKeyResult(kr), null, 2));\n}\n\nexport function outputKeyResultPretty(kr: KeyResult): void {\n const status = kr.statusOverride ?? kr.status;\n const badge = chalk[getKeyResultStatusColor(status)](`[${status}]`);\n console.log(` ${badge} ${chalk.bold(kr.title)}`);\n console.log(\n chalk.gray(\n ` ${kr.currentValue}/${kr.targetValue} ${kr.unit} (${keyResultProgress(kr)}%)` +\n `${kr.period ? ` · ${kr.period}` : ''} · objective #${kr.goalId}`,\n ),\n );\n console.log(chalk.gray(` ID: ${kr.id}`));\n if (kr.projects?.length) {\n console.log(chalk.gray(` Projects: ${kr.projects.map((l) => l.project?.name ?? l.projectId).join(', ')}`));\n }\n if (kr.features?.length) {\n console.log(chalk.gray(` Features: ${kr.features.map((l) => l.feature?.name ?? l.featureId).join(', ')}`));\n }\n}\n\nexport function outputKeyResultsJson(keyResults: KeyResult[]): void {\n console.log(JSON.stringify({\n keyResults: keyResults.map(transformKeyResult),\n total: keyResults.length,\n }, null, 2));\n}\n\nexport function outputKeyResultsPretty(keyResults: KeyResult[]): void {\n if (keyResults.length === 0) {\n console.log(chalk.gray('No key results found.'));\n return;\n }\n console.log(chalk.bold(`\\nKey results (${keyResults.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const kr of keyResults) {\n outputKeyResultPretty(kr);\n }\n console.log();\n}\n\nexport function outputCheckInJson(checkIn: KeyResultCheckIn): void {\n console.log(JSON.stringify({\n id: checkIn.id,\n keyResultId: checkIn.keyResultId,\n previousValue: checkIn.previousValue,\n newValue: checkIn.newValue,\n notes: checkIn.notes,\n createdAt: checkIn.createdAt ? new Date(checkIn.createdAt).toISOString() : null,\n }, null, 2));\n}\n\nexport function outputCheckInPretty(checkIn: KeyResultCheckIn): void {\n console.log(` ${chalk.gray('Value:')} ${checkIn.previousValue} → ${chalk.bold(String(checkIn.newValue))}`);\n if (checkIn.notes) console.log(` ${chalk.gray('Note:')} ${checkIn.notes}`);\n console.log(chalk.gray(` Check-in ID: ${checkIn.id}`));\n console.log();\n}\n\n// ─── OKR (objective + nested key results) output ───────────\n\nfunction transformObjective(objective: ObjectiveWithKeyResults): Record<string, unknown> {\n return {\n id: objective.id,\n title: objective.title,\n description: objective.description,\n status: objective.status,\n period: objective.period,\n health: objective.health,\n progress: objective.progress,\n statusCounts: objective.statusCounts,\n workspaceId: objective.workspaceId,\n workspace: objective.workspace\n ? {\n id: objective.workspace.id,\n slug: objective.workspace.slug,\n name: objective.workspace.name,\n }\n : null,\n parentGoalId: objective.parentGoalId,\n keyResults: objective.keyResults.map(transformKeyResult),\n };\n}\n\nexport function outputObjectivesJson(objectives: ObjectiveWithKeyResults[]): void {\n const totalKeyResults = objectives.reduce((n, o) => n + o.keyResults.length, 0);\n console.log(JSON.stringify({\n objectives: objectives.map(transformObjective),\n total: objectives.length,\n totalKeyResults,\n }, null, 2));\n}\n\nexport function outputObjectivesPretty(objectives: ObjectiveWithKeyResults[]): void {\n if (objectives.length === 0) {\n console.log(chalk.gray('No OKRs found.'));\n return;\n }\n const totalKeyResults = objectives.reduce((n, o) => n + o.keyResults.length, 0);\n console.log(\n chalk.bold(`\\nOKRs (${objectives.length} objectives, ${totalKeyResults} key results)`),\n );\n console.log(chalk.gray('─'.repeat(50)));\n for (const o of objectives) {\n const badge = chalk[getGoalStatusColor(o.status)](`[${o.status}]`);\n const period = o.period ? chalk.gray(` ${o.period}`) : '';\n console.log(\n `\\n ${badge}${period} ${chalk.bold(o.title)} ${chalk.gray(`#${o.id}`)} ${chalk.gray(`${o.progress}%`)}`,\n );\n if (o.keyResults.length === 0) {\n console.log(chalk.gray(' (no key results)'));\n continue;\n }\n for (const kr of o.keyResults) {\n const krStatus = kr.statusOverride ?? kr.status;\n const krBadge = chalk[getKeyResultStatusColor(krStatus)](`[${krStatus}]`);\n console.log(` ${krBadge} ${kr.title} ${chalk.gray(`${kr.currentValue}/${kr.targetValue} ${kr.unit}`)}`);\n console.log(chalk.gray(` ID: ${kr.id}`));\n }\n }\n console.log();\n}\n\n// ─── Project detail output ─────────────────────────────────\n\nexport function outputProjectJson(project: ProjectDetail): void {\n console.log(JSON.stringify({\n ...transformProject(project),\n // The detail read has no `workspace` relation to expand, unlike the list\n // read — so `transformProject` alone would emit `workspace: null` and no id\n // at all, which reads as \"personal project\" rather than \"not fetched\".\n workspaceId: project.workspaceId,\n slug: project.slug ?? null,\n productId: project.productId ?? null,\n driId: project.driId ?? null,\n dri: project.dri ?? null,\n team: project.team ?? null,\n goals: project.goals ?? [],\n keyResults: project.keyResults?.map((k) => ({\n id: k.keyResultId,\n title: k.keyResult?.title ?? null,\n goal: k.keyResult?.goal ?? null,\n })) ?? [],\n outcomes: project.outcomes ?? [],\n actionCount: project.actions?.length ?? null,\n createdAt: project.createdAt ? new Date(project.createdAt).toISOString() : null,\n }, null, 2));\n}\n\nexport function outputProjectPretty(project: ProjectDetail): void {\n console.log(chalk.gray('─'.repeat(50)));\n console.log(`\\n${chalk.bold(project.name)}`);\n console.log(chalk.gray(` ID: ${project.id}`));\n if (project.status) console.log(` ${chalk.cyan('Status:')} ${project.status}`);\n if (project.priority) console.log(` ${chalk.magenta('Priority:')} ${project.priority}`);\n if (project.workspace) {\n console.log(` ${chalk.yellow('Workspace:')} ${project.workspace.name} (${project.workspace.slug})`);\n }\n if (project.description) {\n console.log(` ${chalk.gray('Description:')} ${project.description.substring(0, 200)}${project.description.length > 200 ? '...' : ''}`);\n }\n if (project.dri) {\n console.log(` ${chalk.magenta('DRI:')} ${project.dri.name ?? project.dri.email ?? project.dri.id}`);\n }\n if (project.goals?.length) {\n console.log(` ${chalk.cyan('Objectives:')}`);\n for (const g of project.goals) {\n console.log(` - #${g.id} ${g.title}`);\n }\n }\n if (project.keyResults?.length) {\n console.log(` ${chalk.cyan('Key results:')}`);\n for (const k of project.keyResults) {\n const objective = k.keyResult?.goal ? chalk.gray(` (objective #${k.keyResult.goal.id})`) : '';\n console.log(` - ${k.keyResult?.title ?? k.keyResultId} ${chalk.gray(`[${k.keyResultId}]`)}${objective}`);\n }\n }\n if (project.actions?.length) {\n console.log(` ${chalk.cyan('Actions:')} ${project.actions.length}`);\n }\n console.log();\n}\n\n// ---------------------------------------------------------------------------\n// Time entries (Daily worklog, ADR-0061)\n// ---------------------------------------------------------------------------\n\nfunction formatMinutes(totalMins: number): string {\n if (totalMins <= 0) return '0m';\n const h = Math.floor(totalMins / 60);\n const m = totalMins % 60;\n if (h === 0) return `${m}m`;\n if (m === 0) return `${h}h`;\n return `${h}h ${m}m`;\n}\n\nfunction entryMinutes(entry: TimeEntry): number {\n const end = entry.endedAt ? new Date(entry.endedAt) : new Date();\n const ms = end.getTime() - new Date(entry.startedAt).getTime();\n return ms <= 0 ? 0 : Math.round(ms / 60_000);\n}\n\nfunction clock(date: Date | string): string {\n const d = new Date(date);\n return `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`;\n}\n\nexport function transformTimeEntry(entry: TimeEntry) {\n return {\n id: entry.id,\n userId: entry.userId,\n actionId: entry.actionId,\n actionName: entry.action?.name ?? null,\n projectId: entry.action?.projectId ?? null,\n workspaceId: entry.workspaceId,\n startedAt: entry.startedAt,\n endedAt: entry.endedAt,\n minutes: entryMinutes(entry),\n status: entry.status,\n source: entry.source,\n sourceRef: entry.sourceRef,\n note: entry.note,\n createdByAgentId: entry.createdByAgentId,\n };\n}\n\nfunction statusBadge(status: TimeEntry['status']): string {\n return status === 'PROPOSED' ? chalk.yellow('[PROPOSED]') : chalk.green('[CONFIRMED]');\n}\n\nexport function outputTimeLogJson(result: TimeLogResult): void {\n console.log(\n JSON.stringify({ outcome: result.outcome, entry: transformTimeEntry(result.entry) }, null, 2),\n );\n}\n\nexport function outputTimeLogPretty(result: TimeLogResult): void {\n const e = result.entry;\n const verb = { created: 'Logged', updated: 'Updated', left: 'Left untouched (already confirmed)' }[result.outcome];\n console.log(\n `${chalk.green('✓')} ${verb}: ${clock(e.startedAt)}–${e.endedAt ? clock(e.endedAt) : 'now'} ${chalk.bold(formatMinutes(entryMinutes(e)))} ${statusBadge(e.status)} ${e.action?.name ?? e.actionId}`,\n );\n if (e.note) console.log(chalk.gray(` ${e.note}`));\n console.log(chalk.gray(` ID: ${e.id}${e.sourceRef ? ` ref: ${e.sourceRef}` : ''} owner: ${e.userId}`));\n}\n\nexport function outputTimeEntriesJson(entries: TimeEntry[], date: string): void {\n const rows = entries.map(transformTimeEntry);\n console.log(\n JSON.stringify(\n {\n date,\n entries: rows,\n total: rows.length,\n totalMinutes: rows.reduce((acc, r) => acc + r.minutes, 0),\n proposed: rows.filter((r) => r.status === 'PROPOSED').length,\n },\n null,\n 2,\n ),\n );\n}\n\nexport function outputTimeEntriesPretty(entries: TimeEntry[], date: string): void {\n if (entries.length === 0) {\n console.log(chalk.gray(`No time entries on ${date}.`));\n return;\n }\n console.log(chalk.bold(`\\nTime on ${date}\\n`));\n let total = 0;\n for (const e of entries) {\n const mins = entryMinutes(e);\n total += mins;\n const range = `${clock(e.startedAt)}–${e.endedAt ? clock(e.endedAt) : 'now'}`;\n console.log(\n ` ${range} ${chalk.bold(formatMinutes(mins).padStart(6))} ${statusBadge(e.status)} ${e.action?.name ?? e.actionId}${e.note ? chalk.gray(` · ${e.note}`) : ''}`,\n );\n console.log(chalk.gray(` ${e.id} ${e.source}${e.sourceRef ? ` ${e.sourceRef}` : ''}`));\n }\n const proposed = entries.filter((e) => e.status === 'PROPOSED').length;\n console.log(\n chalk.bold(`\\n${formatMinutes(total)} across ${entries.length} entries`) +\n (proposed > 0 ? chalk.yellow(`, ${proposed} proposed`) : ''),\n );\n}\n\nexport function outputTimeBatchJson(results: TimeLogBatchResult[]): void {\n console.log(\n JSON.stringify(\n {\n results: results.map((r) => ({\n index: r.index,\n success: r.success,\n outcome: r.outcome ?? null,\n sourceRef: r.sourceRef ?? r.entry?.sourceRef ?? null,\n entry: r.entry ? transformTimeEntry(r.entry) : null,\n error: r.error ?? null,\n })),\n total: results.length,\n succeeded: results.filter((r) => r.success).length,\n failed: results.filter((r) => !r.success).length,\n },\n null,\n 2,\n ),\n );\n}\n\nexport function outputTimeBatchPretty(results: TimeLogBatchResult[]): void {\n for (const r of results) {\n const ref = r.sourceRef ?? r.entry?.sourceRef ?? '';\n if (r.success && r.entry) {\n console.log(\n ` ${chalk.green('✓')} #${r.index}: ${chalk.gray(r.outcome ?? '')} ${clock(r.entry.startedAt)}–${r.entry.endedAt ? clock(r.entry.endedAt) : 'now'} ${r.entry.action?.name ?? r.entry.actionId}${ref ? chalk.gray(` ${ref}`) : ''}`,\n );\n } else {\n console.log(` ${chalk.red('✗')} #${r.index}: ${ref} — ${r.error ?? 'failed'}`);\n }\n }\n const ok = results.filter((r) => r.success).length;\n console.log(chalk.bold(`\\n${ok}/${results.length} entries logged`));\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport {\n shouldUseJson,\n outputContactJson,\n outputContactPretty,\n outputContactsJson,\n outputContactsPretty,\n outputInteractionJson,\n outputInteractionPretty,\n} from '../utils/output.js';\nimport type { InteractionType, InteractionDirection } from 'exponential-sdk';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n workspace?: string;\n}\n\nconst VALID_INTERACTION_TYPES: InteractionType[] = [\n 'EMAIL', 'TELEGRAM', 'PHONE_CALL', 'MEETING', 'NOTE', 'LINKEDIN', 'OTHER',\n];\n\nconst VALID_INTERACTION_DIRECTIONS: InteractionDirection[] = ['INBOUND', 'OUTBOUND'];\n\nexport function createContactsCommand(): Command {\n const contacts = new Command('contacts')\n .description('Manage CRM contacts');\n\n contacts\n .command('list')\n .description('List contacts')\n .requiredOption('--workspace <id>', 'Workspace ID')\n .option('--search <query>', 'Search by name or email')\n .option('--tags <tags>', 'Filter by tags (comma-separated)')\n .option('--organization <id>', 'Filter by organization ID')\n .option('--limit <n>', 'Max results to return', parseInt)\n .option('--cursor <cursor>', 'Pagination cursor')\n .action(async (options: {\n workspace: string;\n search?: string;\n tags?: string;\n organization?: string;\n limit?: number;\n cursor?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const result = await client.contacts.list({\n workspaceId: options.workspace,\n search: options.search,\n tags: options.tags?.split(',').map(t => t.trim()),\n organizationId: options.organization,\n limit: options.limit,\n cursor: options.cursor,\n });\n\n if (useJson) {\n outputContactsJson(result.contacts, result.nextCursor);\n } else {\n outputContactsPretty(result.contacts);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n contacts\n .command('get')\n .description('Get a contact by ID')\n .argument('<id>', 'Contact ID')\n .option('--interactions', 'Include interaction history')\n .action(async (id: string, options: { interactions?: boolean }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const contact = await client.contacts.get(id, {\n includeInteractions: options.interactions,\n });\n\n if (useJson) {\n outputContactJson(contact);\n } else {\n outputContactPretty(contact);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n contacts\n .command('create')\n .description('Create a new contact')\n .requiredOption('--workspace <id>', 'Workspace ID')\n .option('--first-name <name>', 'First name')\n .option('--last-name <name>', 'Last name')\n .option('--email <email>', 'Email address')\n .option('--phone <phone>', 'Phone number')\n .option('--linkedin <url>', 'LinkedIn URL')\n .option('--telegram <handle>', 'Telegram handle')\n .option('--twitter <handle>', 'Twitter/X handle')\n .option('--github <handle>', 'GitHub username')\n .option('--bluesky <handle>', 'Bluesky handle')\n .option('--about <text>', 'About / bio')\n .option('--profile-type <type>', 'Profile type')\n .option('--skills <skills>', 'Skills (comma-separated)')\n .option('--tags <tags>', 'Tags (comma-separated)')\n .option('--organization <id>', 'Organization ID')\n .option('--organization-name <name>', 'Organization name (find-or-create; ignored if --organization is set)')\n .action(async (options: {\n workspace: string;\n firstName?: string;\n lastName?: string;\n email?: string;\n phone?: string;\n linkedin?: string;\n telegram?: string;\n twitter?: string;\n github?: string;\n bluesky?: string;\n about?: string;\n profileType?: string;\n skills?: string;\n tags?: string;\n organization?: string;\n organizationName?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const contact = await client.contacts.create({\n workspaceId: options.workspace,\n firstName: options.firstName,\n lastName: options.lastName,\n email: options.email,\n phone: options.phone,\n linkedIn: options.linkedin,\n telegram: options.telegram,\n twitter: options.twitter,\n github: options.github,\n bluesky: options.bluesky,\n about: options.about,\n profileType: options.profileType,\n skills: options.skills?.split(',').map(s => s.trim()),\n tags: options.tags?.split(',').map(t => t.trim()),\n organizationId: options.organization,\n organizationName: options.organizationName,\n });\n\n if (useJson) {\n outputContactJson(contact);\n } else {\n console.log('\\n✓ Contact created successfully');\n outputContactPretty(contact);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n contacts\n .command('update')\n .description('Update an existing contact')\n .requiredOption('--id <id>', 'Contact ID')\n .option('--first-name <name>', 'First name')\n .option('--last-name <name>', 'Last name')\n .option('--email <email>', 'Email (use \"null\" to clear)')\n .option('--phone <phone>', 'Phone (use \"null\" to clear)')\n .option('--linkedin <url>', 'LinkedIn URL (use \"null\" to clear)')\n .option('--telegram <handle>', 'Telegram handle (use \"null\" to clear)')\n .option('--twitter <handle>', 'Twitter/X handle (use \"null\" to clear)')\n .option('--github <handle>', 'GitHub username (use \"null\" to clear)')\n .option('--bluesky <handle>', 'Bluesky handle (use \"null\" to clear)')\n .option('--about <text>', 'About / bio')\n .option('--profile-type <type>', 'Profile type')\n .option('--skills <skills>', 'Skills (comma-separated)')\n .option('--tags <tags>', 'Tags (comma-separated)')\n .option('--organization <id>', 'Organization ID (use \"null\" to clear)')\n .option('--organization-name <name>', 'Organization name (find-or-create; ignored if --organization is set)')\n .action(async (options: {\n id: string;\n firstName?: string;\n lastName?: string;\n email?: string;\n phone?: string;\n linkedin?: string;\n telegram?: string;\n twitter?: string;\n github?: string;\n bluesky?: string;\n about?: string;\n profileType?: string;\n skills?: string;\n tags?: string;\n organization?: string;\n organizationName?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n const nullable = (v?: string) => v === 'null' ? null : v;\n\n try {\n const client = getClient();\n const contact = await client.contacts.update({\n id: options.id,\n firstName: options.firstName,\n lastName: options.lastName,\n email: nullable(options.email),\n phone: nullable(options.phone),\n linkedIn: nullable(options.linkedin),\n telegram: nullable(options.telegram),\n twitter: nullable(options.twitter),\n github: nullable(options.github),\n bluesky: nullable(options.bluesky),\n about: options.about,\n profileType: options.profileType,\n skills: options.skills?.split(',').map(s => s.trim()),\n tags: options.tags?.split(',').map(t => t.trim()),\n organizationId: nullable(options.organization),\n organizationName: options.organizationName,\n });\n\n if (useJson) {\n outputContactJson(contact);\n } else {\n console.log('\\n✓ Contact updated successfully');\n outputContactPretty(contact);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n contacts\n .command('delete')\n .description('Delete a contact')\n .argument('<id>', 'Contact ID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n await client.contacts.delete(id);\n\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id }, null, 2));\n } else {\n console.log(`\\n✓ Contact ${id} deleted`);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n contacts\n .command('add-interaction')\n .description('Add an interaction to a contact')\n .requiredOption('--contact <id>', 'Contact ID')\n .requiredOption('--type <type>', `Interaction type (${VALID_INTERACTION_TYPES.join(', ')})`)\n .requiredOption('--direction <dir>', `Direction (${VALID_INTERACTION_DIRECTIONS.join(', ')})`)\n .option('--subject <text>', 'Subject line')\n .option('--notes <text>', 'Notes')\n .action(async (options: {\n contact: string;\n type: string;\n direction: string;\n subject?: string;\n notes?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n if (!VALID_INTERACTION_TYPES.includes(options.type as InteractionType)) {\n throw new Error(`Invalid interaction type \"${options.type}\". Valid: ${VALID_INTERACTION_TYPES.join(', ')}`);\n }\n if (!VALID_INTERACTION_DIRECTIONS.includes(options.direction as InteractionDirection)) {\n throw new Error(`Invalid direction \"${options.direction}\". Valid: ${VALID_INTERACTION_DIRECTIONS.join(', ')}`);\n }\n\n const client = getClient();\n const interaction = await client.contacts.addInteraction({\n contactId: options.contact,\n type: options.type as InteractionType,\n direction: options.direction as InteractionDirection,\n subject: options.subject,\n notes: options.notes,\n });\n\n if (useJson) {\n outputInteractionJson(interaction);\n } else {\n console.log('\\n✓ Interaction added');\n outputInteractionPretty(interaction);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n contacts\n .command('enrich')\n .description('Queue a web-search enrichment job for an existing contact (runs regardless of the workspace auto-enrich setting)')\n .argument('<id>', 'Contact ID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const result = await client.contacts.enrich(id);\n\n if (useJson) {\n console.log(JSON.stringify(result, null, 2));\n } else if (result.enqueued) {\n console.log(`\\n✓ Enrichment queued for contact ${id} (job ${result.enrichmentId})`);\n } else if (result.reason === 'already-in-flight') {\n console.log(`\\n• Enrichment already in progress for contact ${id} (job ${result.enrichmentId})`);\n } else {\n console.log(`\\n• Not queued for contact ${id}${result.reason ? ` (${result.reason})` : ''}`);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return contacts;\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport type {\n DecisionCreateInput,\n DecisionDeciderInput,\n DecisionEvidenceTurn,\n DecisionListRow,\n DecisionSource,\n DecisionStatus,\n} from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { readText, parseDate } from '../utils/input.js';\nimport { resolveProductId, resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n shouldUseJson,\n outputDecisionJson,\n outputDecisionPretty,\n outputDecisionsJson,\n outputDecisionsPretty,\n outputDecisionBatchJson,\n outputDecisionBatchPretty,\n type BatchDecisionResult,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nconst STATUSES: DecisionStatus[] = [\n 'OPEN',\n 'PROPOSED',\n 'ACCEPTED',\n 'SUPERSEDED',\n 'DEPRECATED',\n];\nconst SOURCES: DecisionSource[] = ['MEETING', 'MANUAL', 'AGENT'];\n\n/**\n * The whole point of this command group, and the thing nobody guesses: there\n * is no separate \"open question\" model. An open question is a decision whose\n * status is OPEN, and that is what the meeting page's Open questions panel\n * reads. Repeated in `--help` output because the schema comment is otherwise\n * the only place it is written down.\n */\nconst OPEN_QUESTION_NOTE =\n 'An OPEN QUESTION is a decision with --status OPEN — there is no separate model, and that is exactly what a meeting\\'s \"Open questions\" panel shows.';\n\nfunction parseStatus(value: string): DecisionStatus {\n const upper = value.toUpperCase() as DecisionStatus;\n if (!STATUSES.includes(upper)) {\n throw new Error(\n `Invalid status \"${value}\". Use one of: ${STATUSES.join(', ')}. ${OPEN_QUESTION_NOTE}`,\n );\n }\n return upper;\n}\n\nfunction parseSource(value: string): DecisionSource {\n const upper = value.toUpperCase() as DecisionSource;\n if (!SOURCES.includes(upper)) {\n throw new Error(\n `Invalid source \"${value}\". Use one of: ${SOURCES.join(', ')}.`,\n );\n }\n return upper;\n}\n\n/**\n * `\"Ada Lovelace <ada@example.com>\"`, a bare name, or a bare email. The server\n * requires a name, so an email-only decider is named by its address.\n */\nexport function parseDecider(spec: string): DecisionDeciderInput {\n const angled = /^\\s*(.*?)\\s*<\\s*([^>]+?)\\s*>\\s*$/.exec(spec);\n if (angled) {\n const name = angled[1]?.trim() ?? '';\n const email = angled[2]!.trim();\n return { name: name === '' ? email : name, email };\n }\n const bare = spec.trim();\n if (bare === '') {\n throw new Error('Empty --decider. Use \"Name <email>\", a name, or an email.');\n }\n if (bare.includes('@') && !bare.includes(' ')) {\n return { name: bare, email: bare };\n }\n return { name: bare };\n}\n\n/** Evidence is a JSON array of `{turnIndex, speaker?, startTime?, text}`. */\nexport function parseEvidence(raw: string): DecisionEvidenceTurn[] {\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (error) {\n throw new Error(\n `Evidence must be JSON: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n if (!Array.isArray(parsed)) {\n throw new Error(\n 'Evidence must be a JSON array of {turnIndex, speaker?, startTime?, text} objects.',\n );\n }\n return parsed.map((turn, i) => {\n if (typeof turn !== 'object' || turn === null) {\n throw new Error(`Evidence[${i}] is not an object.`);\n }\n const t = turn as Record<string, unknown>;\n if (typeof t.turnIndex !== 'number' || typeof t.text !== 'string') {\n throw new Error(\n `Evidence[${i}] needs a numeric \"turnIndex\" and a string \"text\".`,\n );\n }\n return {\n turnIndex: t.turnIndex,\n speaker: typeof t.speaker === 'string' ? t.speaker : null,\n startTime: typeof t.startTime === 'number' ? t.startTime : null,\n text: t.text,\n };\n });\n}\n\n/**\n * `--product` takes a slug or CUID, plus the literal `workspace` that the\n * list filter uses for \"decisions with no product\".\n */\nasync function resolveProductFilter(\n client: ReturnType<typeof getClient>,\n workspaceId: string,\n value: string | undefined,\n): Promise<string | undefined> {\n if (value === undefined) return undefined;\n if (value === 'workspace') return 'workspace';\n return await resolveProductId(client, workspaceId, value);\n}\n\nfunction parsePositiveInt(v: string | undefined, flag: string): number | undefined {\n if (v === undefined) return undefined;\n const n = Number.parseInt(v, 10);\n if (Number.isNaN(n) || n < 1) {\n throw new Error(`${flag} must be a positive integer, got \"${v}\".`);\n }\n return n;\n}\n\nfunction parseNullableString(v: string | undefined): string | null | undefined {\n if (v === undefined) return undefined;\n return v === 'null' ? null : v;\n}\n\nfunction parseNullableInt(v: string | undefined): number | null | undefined {\n if (v === undefined) return undefined;\n if (v === 'null') return null;\n const n = Number.parseInt(v, 10);\n if (Number.isNaN(n)) throw new Error(`Expected a number, got \"${v}\".`);\n return n;\n}\n\n/** One entry in a `--from-file` batch: the create input, in JSON. */\ninterface BatchItem {\n statement?: unknown;\n body?: unknown;\n status?: unknown;\n source?: unknown;\n /** Alias for `transcriptionSessionId` — the motivating case. */\n meeting?: unknown;\n transcriptionSessionId?: unknown;\n productId?: unknown;\n projectId?: unknown;\n goalId?: unknown;\n keyResultId?: unknown;\n occurrenceId?: unknown;\n decidedAt?: unknown;\n ownerId?: unknown;\n deciders?: unknown;\n evidence?: unknown;\n}\n\n/** Every key a `--from-file` entry may carry; anything else is a typo. */\nconst BATCH_ITEM_KEYS = new Set<keyof BatchItem>([\n 'statement',\n 'body',\n 'status',\n 'source',\n 'meeting',\n 'transcriptionSessionId',\n 'productId',\n 'projectId',\n 'goalId',\n 'keyResultId',\n 'occurrenceId',\n 'decidedAt',\n 'ownerId',\n 'deciders',\n 'evidence',\n]) as Set<string>;\n\nexport function parseBatchFile(raw: string): BatchItem[] {\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (error) {\n throw new Error(\n `--from-file must be JSON: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n const items =\n Array.isArray(parsed)\n ? parsed\n : typeof parsed === 'object' &&\n parsed !== null &&\n Array.isArray((parsed as { decisions?: unknown }).decisions)\n ? ((parsed as { decisions: unknown[] }).decisions)\n : null;\n if (!items) {\n throw new Error(\n '--from-file must contain a JSON array of decisions, or {\"decisions\": [...]}.',\n );\n }\n if (items.length === 0) {\n throw new Error('--from-file contained no decisions.');\n }\n return items.map((item, i) => {\n if (typeof item !== 'object' || item === null) {\n throw new Error(`Decision[${i}] is not an object.`);\n }\n const entry = item as BatchItem;\n if (typeof entry.statement !== 'string' || entry.statement.trim() === '') {\n throw new Error(`Decision[${i}] needs a non-empty \"statement\".`);\n }\n // These files are usually generated. A key this reader doesn't know is a\n // typo or a wrong field name, and dropping it silently would file the\n // decision without the data its author meant to attach.\n const unknown = Object.keys(entry).filter(\n (key) => !BATCH_ITEM_KEYS.has(key),\n );\n if (unknown.length > 0) {\n throw new Error(\n `Decision[${i}] has unknown field(s): ${unknown.join(', ')}. Accepted: ${[...BATCH_ITEM_KEYS].join(', ')}.`,\n );\n }\n if (entry.goalId !== undefined && typeof entry.goalId !== 'number') {\n throw new Error(`Decision[${i}].goalId must be a number, not a string.`);\n }\n return entry;\n });\n}\n\n/** Deciders in a batch entry: `\"Name <email>\"` strings or objects. */\nfunction batchDeciders(value: unknown, index: number): DecisionDeciderInput[] | undefined {\n if (value === undefined || value === null) return undefined;\n if (!Array.isArray(value)) {\n throw new Error(`Decision[${index}].deciders must be an array.`);\n }\n return value.map((d) => {\n if (typeof d === 'string') return parseDecider(d);\n if (typeof d === 'object' && d !== null && typeof (d as { name?: unknown }).name === 'string') {\n const obj = d as { name: string; email?: unknown; userId?: unknown };\n return {\n name: obj.name,\n email: typeof obj.email === 'string' ? obj.email : null,\n userId: typeof obj.userId === 'string' ? obj.userId : null,\n };\n }\n throw new Error(\n `Decision[${index}].deciders entries must be \"Name <email>\" strings or {name, email?} objects.`,\n );\n });\n}\n\nexport function createDecisionsCommand(): Command {\n const decisions = new Command('decisions').description(\n [\n 'Log and manage decisions and open questions (the workspace Decision Log).',\n '',\n OPEN_QUESTION_NOTE,\n '',\n 'Statuses: OPEN (an open question) · PROPOSED · ACCEPTED · SUPERSEDED · DEPRECATED.',\n 'SUPERSEDED and DEPRECATED are reached with \"decisions status\", never at creation.',\n ].join('\\n'),\n );\n\n decisions\n .command('list')\n .description(\n `List decisions, newest decided first. Pass --status OPEN for open questions only. ${OPEN_QUESTION_NOTE}`,\n )\n .option('--workspace <slug|id>', 'Workspace (defaults to your default workspace)')\n .option(\n '--meeting <id>',\n \"One meeting's decisions and open questions (includes drafts if you can edit it)\",\n )\n .option(\n '--status <status>',\n 'Filter by status (repeatable): OPEN, PROPOSED, ACCEPTED, SUPERSEDED, DEPRECATED',\n (value: string, previous: DecisionStatus[]) => [...previous, parseStatus(value)],\n [] as DecisionStatus[],\n )\n .option(\n '--source <source>',\n 'Filter by source (repeatable): MEETING, MANUAL, AGENT',\n (value: string, previous: DecisionSource[]) => [...previous, parseSource(value)],\n [] as DecisionSource[],\n )\n .option('--product <slug|id>', 'Filter by product, or \"workspace\" for decisions with no product')\n .option('--include-workspace-wide', 'With --product: also include decisions that have no product')\n .option('--project <id>', 'Filter by project CUID')\n .option('--search <text>', 'Free-text over statement and body')\n .option('--number <n>', 'One decision by its workspace sequence number (D-0003 is 3)')\n .option('--limit <n>', 'Cap the rows returned (1-500)')\n .option('--adr <id>', 'Decisions formalised as this ADR document')\n .action(\n async (\n options: {\n workspace?: string;\n meeting?: string;\n status: DecisionStatus[];\n source: DecisionSource[];\n product?: string;\n includeWorkspaceWide?: boolean;\n project?: string;\n search?: string;\n number?: string;\n limit?: string;\n adr?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n\n // A meeting resolves its own workspace, so this path works even\n // without a default workspace configured.\n if (options.meeting) {\n const result = await client.decisions.listForMeeting(options.meeting);\n let rows: DecisionListRow[] = result.decisions;\n if (options.status.length > 0) {\n rows = rows.filter((d) => options.status.includes(d.status));\n }\n if (options.source.length > 0) {\n rows = rows.filter((d) => options.source.includes(d.source));\n }\n if (useJson) {\n outputDecisionsJson(rows, {\n meetingId: options.meeting,\n workspaceId: result.workspaceId,\n canLogDecision: result.canLogDecision,\n });\n } else {\n outputDecisionsPretty(rows);\n if (!result.canLogDecision) {\n console.log(\n chalk.yellow(\n 'You cannot log decisions on this meeting (no edit access, or it has no workspace).',\n ),\n );\n }\n }\n return;\n }\n\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n // `listForAdr` is its own query, not a filter on the log — running\n // the unbounded list first and discarding it is a wasted round trip\n // over every decision the caller can see.\n const rows = options.adr\n ? await client.decisions.listForAdr(workspaceId, options.adr)\n : await client.decisions.list({\n workspaceId,\n statuses: options.status.length > 0 ? options.status : undefined,\n sources: options.source.length > 0 ? options.source : undefined,\n productId: await resolveProductFilter(client, workspaceId, options.product),\n includeWorkspaceWide: options.includeWorkspaceWide,\n projectId: options.project,\n search: options.search,\n number: parsePositiveInt(options.number, '--number'),\n limit: parsePositiveInt(options.limit, '--limit'),\n });\n if (useJson) outputDecisionsJson(rows, { workspaceId });\n else outputDecisionsPretty(rows);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n decisions\n .command('get <id>')\n .description('Show one decision in full: body, evidence, deciders, chain and links')\n .option('--workspace <slug|id>', 'Workspace (defaults to your default workspace)')\n .action(async (id: string, options: { workspace?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const decision = await client.decisions.get(workspaceId, id);\n if (useJson) outputDecisionJson(decision);\n else outputDecisionPretty(decision);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n decisions\n .command('create')\n .description(\n [\n 'Log a decision, or an open question with --status OPEN.',\n OPEN_QUESTION_NOTE,\n 'Bodies are Markdown: use --body-file <path> (or - for stdin) rather than a shell argument.',\n 'Bulk: --from-file <path|-> takes a JSON array of decisions; the other flags become its defaults.',\n ].join(' '),\n )\n .option('-s, --statement <text>', 'The decision, or the open question (max 500 chars)')\n .option('-b, --body <markdown>', 'Markdown detail: context, alternatives, consequences')\n .option('--body-file <path>', 'Read the body from a file (\"-\" = stdin)')\n .option('--status <status>', 'OPEN (open question), PROPOSED (default) or ACCEPTED')\n .option('--source <source>', 'MEETING, MANUAL or AGENT')\n .option('--meeting <id>', 'Meeting (transcriptionSessionId) this came out of — needs edit access to it')\n .option('--workspace <slug|id>', 'Workspace (defaults to your default workspace)')\n .option('--product <slug|id>', 'Link to a product')\n .option('--project <id>', 'Link to a project CUID')\n .option('--goal <id>', 'Link to a goal (integer id)')\n .option('--key-result <id>', 'Link to a key result CUID')\n .option('--occurrence <id>', 'Link to a ceremony occurrence CUID')\n .option('--decided-at <iso>', 'When it was decided (e.g. 2026-09-10T14:00)')\n .option('--owner <userId>', 'Owner user ID')\n .option(\n '--decider <\"Name <email>\">',\n 'Someone who made the decision (repeatable); external people need no account',\n (value: string, previous: DecisionDeciderInput[]) => [...previous, parseDecider(value)],\n [] as DecisionDeciderInput[],\n )\n .option(\n '--evidence-file <path>',\n 'JSON array of {turnIndex, text} transcript quotes (\"-\" = stdin). Needs --meeting: the server checks every quote against that transcript and silently drops the ones that do not match.',\n )\n .option('--from-file <path>', 'Bulk create from a JSON array of decisions (\"-\" = stdin)')\n .action(\n async (\n options: {\n statement?: string;\n body?: string;\n bodyFile?: string;\n status?: string;\n source?: string;\n meeting?: string;\n workspace?: string;\n product?: string;\n project?: string;\n goal?: string;\n keyResult?: string;\n occurrence?: string;\n decidedAt?: string;\n owner?: string;\n decider: DecisionDeciderInput[];\n evidenceFile?: string;\n fromFile?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n if (!options.statement && !options.fromFile) {\n throw new Error(\n 'Pass --statement <text>, or --from-file <path|-> for a bulk create.',\n );\n }\n if (options.statement && options.fromFile) {\n throw new Error(\n '--statement and --from-file are alternatives: the file carries the statements.',\n );\n }\n\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const productId = options.product\n ? await resolveProductId(client, workspaceId, options.product)\n : undefined;\n const status = options.status ? parseStatus(options.status) : undefined;\n const source = options.source ? parseSource(options.source) : undefined;\n const decidedAt = parseDate(options.decidedAt);\n const goalId = options.goal ? Number.parseInt(options.goal, 10) : undefined;\n if (goalId !== undefined && Number.isNaN(goalId)) {\n throw new Error(`--goal must be an integer id, got \"${options.goal}\".`);\n }\n\n // Shared scope for both paths; per-item values override these.\n const defaults = {\n workspaceId,\n status,\n source,\n transcriptionSessionId: options.meeting,\n productId,\n projectId: options.project,\n goalId,\n keyResultId: options.keyResult,\n occurrenceId: options.occurrence,\n decidedAt,\n ownerId: options.owner,\n deciders: options.decider.length > 0 ? options.decider : undefined,\n };\n\n if (options.fromFile) {\n // Body and evidence are per-decision content, not scope that can\n // be shared across 40 rows. Silently ignoring them would file the\n // batch with the wrong bodies and say nothing.\n const perEntryOnly = [\n options.body !== undefined ? '--body' : null,\n options.bodyFile !== undefined ? '--body-file' : null,\n options.evidenceFile !== undefined ? '--evidence-file' : null,\n ].filter((flag): flag is string => flag !== null);\n if (perEntryOnly.length > 0) {\n throw new Error(\n `${perEntryOnly.join(', ')} ${perEntryOnly.length === 1 ? 'is' : 'are'} per-decision content — put \"body\" and \"evidence\" on each entry in --from-file instead.`,\n );\n }\n const items = parseBatchFile(readText(undefined, options.fromFile)!);\n const results: BatchDecisionResult[] = [];\n // Sequential on purpose: decisions take their workspace sequence\n // number on write, and a partial failure has to name which entry\n // failed rather than collapsing into one rejected batch.\n for (const [index, item] of items.entries()) {\n const statement = String(item.statement);\n try {\n const input: DecisionCreateInput = {\n ...defaults,\n statement,\n body: typeof item.body === 'string' ? item.body : undefined,\n status:\n item.status !== undefined\n ? parseStatus(String(item.status))\n : defaults.status,\n source:\n item.source !== undefined\n ? parseSource(String(item.source))\n : defaults.source,\n transcriptionSessionId:\n typeof item.transcriptionSessionId === 'string'\n ? item.transcriptionSessionId\n : typeof item.meeting === 'string'\n ? item.meeting\n : defaults.transcriptionSessionId,\n productId:\n typeof item.productId === 'string' ? item.productId : defaults.productId,\n projectId:\n typeof item.projectId === 'string' ? item.projectId : defaults.projectId,\n goalId: typeof item.goalId === 'number' ? item.goalId : defaults.goalId,\n keyResultId:\n typeof item.keyResultId === 'string'\n ? item.keyResultId\n : defaults.keyResultId,\n occurrenceId:\n typeof item.occurrenceId === 'string'\n ? item.occurrenceId\n : defaults.occurrenceId,\n decidedAt:\n typeof item.decidedAt === 'string'\n ? parseDate(item.decidedAt)\n : defaults.decidedAt,\n ownerId: typeof item.ownerId === 'string' ? item.ownerId : defaults.ownerId,\n deciders: batchDeciders(item.deciders, index) ?? defaults.deciders,\n evidence:\n item.evidence === undefined\n ? undefined\n : parseEvidence(JSON.stringify(item.evidence)),\n };\n if (input.evidence && !input.transcriptionSessionId) {\n throw new Error(\n 'Evidence is quotes from a meeting transcript, so this entry needs a \"meeting\" (or the --meeting flag).',\n );\n }\n const decision = await client.decisions.create(input);\n results.push({ index, success: true, decision, statement });\n } catch (error) {\n results.push({\n index,\n success: false,\n statement,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n // Anything short of \"everything was logged\" is a non-zero exit,\n // so a pipeline can't mistake a partial write for success.\n if (results.some((r) => !r.success)) process.exitCode = 1;\n if (useJson) outputDecisionBatchJson(results);\n else outputDecisionBatchPretty(results);\n return;\n }\n\n const evidenceRaw = readText(undefined, options.evidenceFile);\n if (evidenceRaw !== undefined && !options.meeting) {\n throw new Error(\n 'Evidence is quotes from a meeting transcript, so --evidence-file needs --meeting <id>.',\n );\n }\n const decision = await client.decisions.create({\n ...defaults,\n statement: options.statement!,\n body: readText(options.body, options.bodyFile),\n deciders: options.decider.length > 0 ? options.decider : undefined,\n evidence: evidenceRaw === undefined ? undefined : parseEvidence(evidenceRaw),\n });\n if (useJson) outputDecisionJson(decision);\n else {\n console.log(\n `\\n✓ ${decision.status === 'OPEN' ? 'Open question' : 'Decision'} logged`,\n );\n outputDecisionPretty(decision);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n decisions\n .command('update')\n .description(\n 'Update a decision\\'s content and scope; only the fields you pass are written. Status changes go through \"decisions status\".',\n )\n .requiredOption('--id <id>', 'Decision CUID')\n .option('--workspace <slug|id>', 'Workspace (defaults to your default workspace)')\n .option('-s, --statement <text>', 'New statement')\n .option('-b, --body <markdown>', 'New Markdown body (or \"null\" to clear)')\n .option('--body-file <path>', 'Read the new body from a file (\"-\" = stdin)')\n .option('--decided-at <iso>', 'When it was decided (or \"null\" to clear)')\n .option('--owner <userId>', 'Owner user ID (or \"null\" to clear)')\n .option('--product <slug|id>', 'Product (or \"null\" to detach)')\n .option('--project <id>', 'Project CUID (or \"null\" to detach)')\n .option('--goal <id>', 'Goal integer id (or \"null\" to detach)')\n .option('--key-result <id>', 'Key result CUID (or \"null\" to detach)')\n .option('--adr <id>', 'ADR document CUID (or \"null\" to detach)')\n .action(\n async (\n options: {\n id: string;\n workspace?: string;\n statement?: string;\n body?: string;\n bodyFile?: string;\n decidedAt?: string;\n owner?: string;\n product?: string;\n project?: string;\n goal?: string;\n keyResult?: string;\n adr?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const body =\n options.body === 'null' ? null : readText(options.body, options.bodyFile);\n const patch = {\n statement: options.statement,\n body,\n decidedAt:\n options.decidedAt === 'null' ? null : parseDate(options.decidedAt),\n ownerId: parseNullableString(options.owner),\n projectId: parseNullableString(options.project),\n goalId: parseNullableInt(options.goal),\n keyResultId: parseNullableString(options.keyResult),\n adrDocumentId: parseNullableString(options.adr),\n };\n if (\n options.product === undefined &&\n Object.values(patch).every((v) => v === undefined)\n ) {\n throw new Error(\n 'Nothing to update. Pass at least one of --statement, --body, --body-file, --decided-at, --owner, --product, --project, --goal, --key-result, --adr.',\n );\n }\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const productId =\n options.product === undefined\n ? undefined\n : options.product === 'null'\n ? null\n : await resolveProductId(client, workspaceId, options.product);\n const decision = await client.decisions.update({\n workspaceId,\n decisionId: options.id,\n ...patch,\n productId,\n });\n if (useJson) outputDecisionJson(decision);\n else {\n console.log('\\n✓ Decision updated');\n outputDecisionPretty(decision);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n decisions\n .command('status')\n .description(\n 'Move a decision through its lifecycle — including answering an open question by moving it from OPEN to ACCEPTED.',\n )\n .requiredOption('--id <id>', 'Decision CUID')\n .requiredOption(\n '--status <status>',\n 'OPEN, PROPOSED, ACCEPTED, SUPERSEDED or DEPRECATED',\n )\n .option('--superseded-by <id>', 'The decision that replaced this one (with --status SUPERSEDED)')\n .option('--workspace <slug|id>', 'Workspace (defaults to your default workspace)')\n .action(\n async (\n options: {\n id: string;\n status: string;\n supersededBy?: string;\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = parseStatus(options.status);\n if (status === 'SUPERSEDED' && !options.supersededBy) {\n throw new Error(\n '--status SUPERSEDED needs --superseded-by <id>: the decision that replaced this one.',\n );\n }\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const decision = await client.decisions.setStatus({\n workspaceId,\n decisionId: options.id,\n status,\n supersededById: options.supersededBy,\n });\n if (useJson) outputDecisionJson(decision);\n else {\n console.log(`\\n✓ Decision is now ${decision.status}`);\n outputDecisionPretty(decision);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n decisions\n .command('link')\n .description('Record what implements a decision: a ticket or a feature. Idempotent.')\n .requiredOption('--id <id>', 'Decision CUID')\n .option('--ticket <id>', 'Ticket CUID')\n .option('--feature <id>', 'Feature CUID')\n .option('--workspace <slug|id>', 'Workspace (defaults to your default workspace)')\n .action(\n async (\n options: { id: string; ticket?: string; feature?: string; workspace?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n if (!options.ticket && !options.feature) {\n throw new Error('Pass --ticket <id> or --feature <id>.');\n }\n if (options.ticket && options.feature) {\n throw new Error('Pass one of --ticket or --feature, not both.');\n }\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const link = options.ticket\n ? await client.decisions.linkTicket(workspaceId, options.id, options.ticket)\n : await client.decisions.linkFeature(workspaceId, options.id, options.feature!);\n if (useJson) console.log(JSON.stringify(link, null, 2));\n else {\n console.log(`✓ Linked ${chalk.gray(`(link id ${link.id})`)}`);\n console.log(\n chalk.gray(' Remove it with: exponential decisions unlink --link ' + link.id),\n );\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n decisions\n .command('unlink')\n .description(\n 'Remove one \"implemented by\" link. Takes the LINK id (shown by \"decisions get\"), not the ticket or feature id.',\n )\n .requiredOption('--link <id>', 'DecisionLink CUID')\n .option('--workspace <slug|id>', 'Workspace (defaults to your default workspace)')\n .action(async (options: { link: string; workspace?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n await client.decisions.unlink(workspaceId, options.link);\n if (useJson) console.log(JSON.stringify({ deleted: true, linkId: options.link }, null, 2));\n else console.log('✓ Link removed');\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n const drafts = new Command('draft').description(\n 'Review decisions an agent proposed but nobody has confirmed yet (visible only on their source meeting)',\n );\n\n drafts\n .command('extract')\n .description(\n \"Propose draft decisions from a meeting's notes and transcript, for someone to confirm. Idempotent: existing drafts are returned rather than regenerated, and a meeting that already has confirmed decisions is left alone.\",\n )\n .requiredOption('--meeting <id>', 'Meeting CUID (transcriptionSessionId)')\n .action(async (options: { meeting: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const result = await client.decisions.extractDrafts(options.meeting);\n if (useJson) console.log(JSON.stringify(result, null, 2));\n else {\n if (result.alreadyPublished) {\n console.log(\n chalk.gray('This meeting already has confirmed decisions — nothing was extracted.'),\n );\n } else if (result.alreadyDrafted) {\n console.log(chalk.gray('Returning the drafts this meeting already had.'));\n }\n console.log(\n `✓ ${result.draftCount} draft${result.draftCount === 1 ? '' : 's'} awaiting review (${result.draftsCreated} new)`,\n );\n if (result.discardedWithoutEvidence > 0) {\n console.log(\n chalk.gray(\n ` ${result.discardedWithoutEvidence} candidate(s) dropped — no transcript turn supported them.`,\n ),\n );\n }\n for (const message of result.errors) console.log(chalk.yellow(` ${message}`));\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n drafts\n .command('confirm')\n .description('Publish a draft decision into the log')\n .requiredOption('--id <id>', 'Decision CUID')\n .option('--workspace <slug|id>', 'Workspace (defaults to your default workspace)')\n .action(async (options: { id: string; workspace?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const decision = await client.decisions.confirmDraft(workspaceId, options.id);\n if (useJson) outputDecisionJson(decision);\n else {\n console.log('\\n✓ Draft confirmed');\n outputDecisionPretty(decision);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n drafts\n .command('reject')\n .description(\n 'Reject a draft. A confirmed decision is never rejected — deprecate or supersede it with \"decisions status\".',\n )\n .requiredOption('--id <id>', 'Decision CUID')\n .option('--workspace <slug|id>', 'Workspace (defaults to your default workspace)')\n .action(async (options: { id: string; workspace?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const result = await client.decisions.rejectDraft(workspaceId, options.id);\n if (useJson) console.log(JSON.stringify(result, null, 2));\n else console.log('✓ Draft rejected');\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n drafts\n .command('delete')\n .description(\n 'Permanently delete a draft or rejected decision. Confirmed decisions are never deleted.',\n )\n .requiredOption('--id <id>', 'Decision CUID')\n .option('--workspace <slug|id>', 'Workspace (defaults to your default workspace)')\n .action(async (options: { id: string; workspace?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const result = await client.decisions.deleteDraft(workspaceId, options.id);\n if (useJson) console.log(JSON.stringify({ deleted: true, ...result }, null, 2));\n else console.log('✓ Draft deleted');\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n decisions.addCommand(drafts);\n\n return decisions;\n}\n","import { readFileSync } from 'node:fs';\n\nlet stdinConsumed = false;\n\n/** Test hook: the stdin guard is process-wide state. */\nexport function resetStdinGuardForTests(): void {\n stdinConsumed = false;\n}\n\n/**\n * Text from an inline option value, a file path, or \"-\" for stdin.\n * Inline wins when both are given. stdin can back at most one option per\n * invocation — a second \"-\" would silently read EOF as \"\".\n */\nexport function readText(inline?: string, file?: string): string | undefined {\n if (inline !== undefined) return inline;\n if (file === undefined) return undefined;\n if (file === '-') {\n if (stdinConsumed) {\n throw new Error('stdin (\"-\") can only back one option per invocation.');\n }\n stdinConsumed = true;\n return readFileSync(0, 'utf-8');\n }\n return readFileSync(file, 'utf-8');\n}\n\n/**\n * Parse a user-supplied date. A date-only value (\"2026-08-25\") is taken as\n * LOCAL midnight — bare `new Date(\"2026-08-25\")` would be UTC midnight, which\n * reads back as the previous day anywhere west of UTC. Empty string counts\n * as omitted; anything unparseable throws.\n */\nexport function parseDate(value: string | undefined): Date | undefined {\n if (value === undefined || value === '') return undefined;\n const date = /^\\d{4}-\\d{2}-\\d{2}$/.test(value)\n ? new Date(`${value}T00:00:00`)\n : new Date(value);\n if (Number.isNaN(date.getTime())) {\n throw new Error(\n `Invalid date: \"${value}\". Use ISO format, e.g. 2026-08-25 or 2026-08-25T14:00.`,\n );\n }\n return date;\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport {\n shouldUseJson,\n outputDealJson,\n outputDealPretty,\n outputDealsJson,\n outputDealsPretty,\n outputPipelineJson,\n outputPipelinePretty,\n outputStagesJson,\n outputStagesPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n workspace?: string;\n}\n\nexport function createDealsCommand(): Command {\n const deals = new Command('deals')\n .description('Manage pipeline deals');\n\n deals\n .command('pipeline')\n .description('Get pipeline overview with stages')\n .requiredOption('--workspace <id>', 'Workspace ID')\n .action(async (options: { workspace: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const pipeline = await client.pipelines.get(options.workspace);\n\n if (!pipeline) {\n if (useJson) {\n console.log(JSON.stringify({ pipeline: null }, null, 2));\n } else {\n console.log('No pipeline found for this workspace. One will be created when you add your first deal.');\n }\n return;\n }\n\n if (useJson) {\n outputPipelineJson(pipeline);\n } else {\n outputPipelinePretty(pipeline);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n deals\n .command('stages')\n .description('List pipeline stages')\n .requiredOption('--workspace <id>', 'Workspace ID')\n .action(async (options: { workspace: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const stages = await client.pipelines.getStages(options.workspace);\n\n if (useJson) {\n outputStagesJson(stages);\n } else {\n outputStagesPretty(stages);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n deals\n .command('list')\n .description('List all deals')\n .requiredOption('--workspace <id>', 'Workspace ID')\n .action(async (options: { workspace: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const dealsList = await client.pipelines.listDeals(options.workspace);\n\n if (useJson) {\n outputDealsJson(dealsList);\n } else {\n outputDealsPretty(dealsList);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n deals\n .command('get')\n .description('Get a deal by ID')\n .argument('<id>', 'Deal ID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const deal = await client.pipelines.getDeal(id);\n\n if (useJson) {\n outputDealJson(deal);\n } else {\n outputDealPretty(deal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n deals\n .command('create')\n .description('Create a new deal')\n .requiredOption('--workspace <id>', 'Workspace ID')\n .requiredOption('--stage <id>', 'Pipeline stage ID')\n .requiredOption('--title <title>', 'Deal title')\n .option('--description <text>', 'Deal description')\n .option('--value <amount>', 'Deal value', parseFloat)\n .option('--currency <code>', 'Currency code (default: USD)')\n .option('--probability <pct>', 'Win probability (0-100)', parseInt)\n .option('--close-date <date>', 'Expected close date (YYYY-MM-DD)')\n .option('--contact <id>', 'Contact ID')\n .option('--organization <id>', 'Organization ID')\n .option('--assigned-to <id>', 'Assigned user ID')\n .action(async (options: {\n workspace: string;\n stage: string;\n title: string;\n description?: string;\n value?: number;\n currency?: string;\n probability?: number;\n closeDate?: string;\n contact?: string;\n organization?: string;\n assignedTo?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n let expectedCloseDate: Date | undefined;\n if (options.closeDate) {\n expectedCloseDate = new Date(options.closeDate);\n if (isNaN(expectedCloseDate.getTime())) {\n throw new Error('Invalid close date format. Use YYYY-MM-DD');\n }\n }\n\n const client = getClient();\n const deal = await client.pipelines.createDeal({\n workspaceId: options.workspace,\n stageId: options.stage,\n title: options.title,\n description: options.description,\n value: options.value,\n currency: options.currency,\n probability: options.probability,\n expectedCloseDate,\n contactId: options.contact,\n organizationId: options.organization,\n assignedToId: options.assignedTo,\n });\n\n if (useJson) {\n outputDealJson(deal);\n } else {\n console.log('\\n✓ Deal created successfully');\n outputDealPretty(deal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n deals\n .command('update')\n .description('Update an existing deal')\n .requiredOption('--id <id>', 'Deal ID')\n .option('--title <title>', 'Deal title')\n .option('--description <text>', 'Description (use \"null\" to clear)')\n .option('--value <amount>', 'Deal value (use \"null\" to clear)')\n .option('--currency <code>', 'Currency code')\n .option('--probability <pct>', 'Win probability (use \"null\" to clear)')\n .option('--close-date <date>', 'Expected close date (YYYY-MM-DD or \"null\" to clear)')\n .option('--contact <id>', 'Contact ID (use \"null\" to clear)')\n .option('--organization <id>', 'Organization ID (use \"null\" to clear)')\n .option('--assigned-to <id>', 'Assigned user ID (use \"null\" to clear)')\n .action(async (options: {\n id: string;\n title?: string;\n description?: string;\n value?: string;\n currency?: string;\n probability?: string;\n closeDate?: string;\n contact?: string;\n organization?: string;\n assignedTo?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n const nullable = <T>(v: string | undefined, parse?: (s: string) => T): T | null | undefined => {\n if (v === undefined) return undefined;\n if (v === 'null') return null;\n return parse ? parse(v) : v as unknown as T;\n };\n\n try {\n let expectedCloseDate: Date | null | undefined;\n if (options.closeDate === 'null') {\n expectedCloseDate = null;\n } else if (options.closeDate) {\n expectedCloseDate = new Date(options.closeDate);\n if (isNaN(expectedCloseDate.getTime())) {\n throw new Error('Invalid close date format. Use YYYY-MM-DD');\n }\n }\n\n const client = getClient();\n const deal = await client.pipelines.updateDeal({\n id: options.id,\n title: options.title,\n description: nullable(options.description),\n value: nullable(options.value, parseFloat),\n currency: options.currency,\n probability: nullable(options.probability, parseInt),\n expectedCloseDate,\n contactId: nullable(options.contact),\n organizationId: nullable(options.organization),\n assignedToId: nullable(options.assignedTo),\n });\n\n if (useJson) {\n outputDealJson(deal);\n } else {\n console.log('\\n✓ Deal updated successfully');\n outputDealPretty(deal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n deals\n .command('move')\n .description('Move a deal to a different stage')\n .requiredOption('--id <id>', 'Deal ID')\n .requiredOption('--stage <id>', 'Target stage ID')\n .option('--order <n>', 'Position within stage', parseInt, 0)\n .action(async (options: { id: string; stage: string; order: number }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const deal = await client.pipelines.moveDeal({\n id: options.id,\n stageId: options.stage,\n stageOrder: options.order,\n });\n\n if (useJson) {\n outputDealJson(deal);\n } else {\n console.log('\\n✓ Deal moved successfully');\n outputDealPretty(deal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n deals\n .command('delete')\n .description('Delete a deal')\n .argument('<id>', 'Deal ID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n await client.pipelines.deleteDeal(id);\n\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id }, null, 2));\n } else {\n console.log(`\\n✓ Deal ${id} deleted`);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return deals;\n}\n","import { Command } from 'commander';\nimport type { EpicPriority, EpicStatus } from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n shouldUseJson,\n outputEpicJson,\n outputEpicPretty,\n outputEpicsJson,\n outputEpicsPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nconst EPIC_STATUSES: EpicStatus[] = ['OPEN', 'IN_PROGRESS', 'DONE', 'CANCELLED'];\nconst EPIC_PRIORITIES: EpicPriority[] = ['HIGH', 'MEDIUM', 'LOW', 'NONE'];\n\nfunction validateEpicStatus(value: string | undefined): EpicStatus | undefined {\n if (!value) return undefined;\n if (!(EPIC_STATUSES as string[]).includes(value)) {\n throw new Error(`Invalid epic status \"${value}\". Valid: ${EPIC_STATUSES.join(', ')}`);\n }\n return value as EpicStatus;\n}\n\nfunction validateEpicPriority(value: string | undefined): EpicPriority | undefined {\n if (!value) return undefined;\n if (!(EPIC_PRIORITIES as string[]).includes(value)) {\n throw new Error(\n `Invalid epic priority \"${value}\". Valid: ${EPIC_PRIORITIES.join(', ')}`,\n );\n }\n return value as EpicPriority;\n}\n\nfunction parseDate(value: string | undefined): Date | undefined {\n if (!value) return undefined;\n const d = new Date(value);\n if (isNaN(d.getTime())) {\n throw new Error(`Invalid date \"${value}\". Use YYYY-MM-DD`);\n }\n return d;\n}\n\nexport function createEpicsCommand(): Command {\n const epics = new Command('epics').description(\n 'Manage epics. Epics are workspace-scoped and group actions and tickets across products.',\n );\n\n epics\n .command('list')\n .description('List epics in a workspace')\n .option('--workspace <slug|id>', 'Workspace slug or CUID')\n .option('--status <status>', `Filter by status: ${EPIC_STATUSES.join(', ')}`)\n .action(\n async (options: { workspace?: string; status?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateEpicStatus(options.status);\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const list = await client.epics.list({ workspaceId, status });\n if (useJson) outputEpicsJson(list);\n else outputEpicsPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n epics\n .command('get <id>')\n .description('Get an epic by CUID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const epic = await client.epics.get(id);\n if (useJson) outputEpicJson(epic);\n else outputEpicPretty(epic);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n epics\n .command('create')\n .description('Create a new epic in a workspace')\n .requiredOption('-n, --name <name>', 'Epic name')\n .option('-d, --description <text>', 'Description')\n .option('--priority <priority>', `Priority: ${EPIC_PRIORITIES.join(', ')}`)\n .option('--start <date>', 'Start date (YYYY-MM-DD)')\n .option('--target <date>', 'Target date (YYYY-MM-DD)')\n .option('--workspace <slug|id>', 'Workspace slug or CUID')\n .action(\n async (\n options: {\n name: string;\n description?: string;\n priority?: string;\n start?: string;\n target?: string;\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const priority = validateEpicPriority(options.priority);\n const startDate = parseDate(options.start);\n const targetDate = parseDate(options.target);\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const epic = await client.epics.create({\n workspaceId,\n name: options.name,\n description: options.description,\n priority,\n startDate,\n targetDate,\n });\n if (useJson) outputEpicJson(epic);\n else {\n console.log('\\n✓ Epic created');\n outputEpicPretty(epic);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n epics\n .command('update')\n .description('Update an existing epic')\n .requiredOption('--id <id>', 'Epic CUID')\n .option('-n, --name <name>', 'New name')\n .option('-d, --description <text>', 'New description (or \"null\" to clear)')\n .option('--status <status>', `Status: ${EPIC_STATUSES.join(', ')}`)\n .option('--priority <priority>', `Priority: ${EPIC_PRIORITIES.join(', ')}`)\n .option('--start <date>', 'Start date (YYYY-MM-DD or \"null\")')\n .option('--target <date>', 'Target date (YYYY-MM-DD or \"null\")')\n .action(\n async (\n options: {\n id: string;\n name?: string;\n description?: string;\n status?: string;\n priority?: string;\n start?: string;\n target?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const parseNullableDate = (v: string | undefined): Date | null | undefined => {\n if (v === undefined) return undefined;\n if (v === 'null') return null;\n const d = new Date(v);\n if (isNaN(d.getTime())) {\n throw new Error(`Invalid date \"${v}\". Use YYYY-MM-DD`);\n }\n return d;\n };\n const description = options.description === 'null' ? null : options.description;\n const status = validateEpicStatus(options.status);\n const priority = validateEpicPriority(options.priority);\n const client = getClient();\n const epic = await client.epics.update({\n id: options.id,\n name: options.name,\n description,\n status,\n priority,\n startDate: parseNullableDate(options.start),\n targetDate: parseNullableDate(options.target),\n });\n if (useJson) outputEpicJson(epic);\n else {\n console.log('\\n✓ Epic updated');\n outputEpicPretty(epic);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n return epics;\n}\n","import { Command } from 'commander';\nimport type { FeatureStatus, Ticket } from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveProductId, resolveWorkspaceId } from '../utils/resolve.js';\nimport { createStoriesCommand } from './stories.js';\nimport { createScopesCommand } from './scopes.js';\nimport { createRequirementsCommand } from './requirements.js';\nimport { createAreasCommand } from './areas.js';\nimport { createFeatureCommentsCommand } from './featureComments.js';\nimport {\n shouldUseJson,\n outputFeaturesJson,\n outputFeaturesPretty,\n outputFeatureJson,\n outputFeaturePretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nconst FEATURE_STATUSES: FeatureStatus[] = [\n 'IDEA',\n 'DEFINED',\n 'IN_PROGRESS',\n 'SHIPPED',\n 'DEPRECATED',\n 'ARCHIVED',\n];\n\ninterface TicketSummary {\n id: string;\n shortId: string | null;\n number: number | null;\n title: string;\n}\n\nfunction summarizeTicket(ticket: Ticket): TicketSummary {\n return {\n id: ticket.id,\n shortId: ticket.shortId ?? null,\n number: ticket.number ?? null,\n title: ticket.title,\n };\n}\n\nfunction ticketLabel(ticket: Ticket): string {\n return ticket.shortId ?? (ticket.number != null ? `#${ticket.number}` : ticket.id);\n}\n\n/**\n * `--goal` takes an objective's integer id, or \"none\" to unlink. Objectives are\n * the only entity here keyed by an integer rather than a cuid.\n */\nfunction parseFeatureGoalId(value: string | undefined): number | null | undefined {\n if (value === undefined) return undefined;\n if (value === 'none') return null;\n const id = Number(value);\n if (!Number.isInteger(id)) {\n throw new Error(\n `--goal must be a whole number or \"none\", got \"${value}\". Find one with \\`exponential goals list\\`.`,\n );\n }\n return id;\n}\n\nfunction validateFeatureStatus(value: string | undefined): FeatureStatus | undefined {\n if (!value) return undefined;\n if (!(FEATURE_STATUSES as string[]).includes(value)) {\n throw new Error(\n `Invalid status \"${value}\". Valid: ${FEATURE_STATUSES.join(', ')}`,\n );\n }\n return value as FeatureStatus;\n}\n\nexport function createFeaturesCommand(): Command {\n const features = new Command('features').description(\n 'Manage features. A feature lives under a product and groups user stories, scopes, and tickets.',\n );\n\n features\n .command('list')\n .description('List features in a product')\n .requiredOption('--product <slug|id>', 'Product slug or CUID')\n .option('--workspace <slug|id>', 'Workspace (required when --product is a slug)')\n .option('--status <status>', `Filter by status: ${FEATURE_STATUSES.join(', ')}`)\n .action(\n async (\n options: { product: string; workspace?: string; status?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateFeatureStatus(options.status);\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const productId = await resolveProductId(\n client,\n workspaceId,\n options.product,\n );\n const list = await client.features.list({ productId, status });\n if (useJson) outputFeaturesJson(list);\n else outputFeaturesPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n features\n .command('get <id>')\n .description('Get a feature by CUID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const feature = await client.features.get(id);\n if (useJson) outputFeatureJson(feature);\n else outputFeaturePretty(feature);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n features\n .command('create')\n .description('Create a new feature in a product')\n .requiredOption('--product <slug|id>', 'Product slug or CUID')\n .requiredOption('-n, --name <name>', 'Feature name')\n .option('-d, --description <text>', 'Description (markdown supported)')\n .option('--vision <text>', 'Vision / target outcome')\n .option('--status <status>', `Status: ${FEATURE_STATUSES.join(', ')}`)\n .option('--priority <n>', 'Priority 0-4 (lower = higher)', parseInt)\n .option('--effort <n>', 'Effort estimate', parseFloat)\n .option('--area <id>', 'Area CUID (per-product bucket) to file the feature under')\n .option('--workspace <slug|id>', 'Workspace (required when --product is a slug)')\n .action(\n async (\n options: {\n product: string;\n name: string;\n description?: string;\n vision?: string;\n status?: string;\n priority?: number;\n effort?: number;\n area?: string;\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateFeatureStatus(options.status);\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const productId = await resolveProductId(\n client,\n workspaceId,\n options.product,\n );\n const feature = await client.features.create({\n productId,\n name: options.name,\n description: options.description,\n vision: options.vision,\n status,\n priority: options.priority,\n effort: options.effort,\n areaId: options.area,\n });\n if (useJson) outputFeatureJson(feature);\n else {\n console.log('\\n✓ Feature created');\n outputFeaturePretty(feature);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n features\n .command('update')\n .description('Update an existing feature')\n .requiredOption('--id <id>', 'Feature CUID')\n .option('-n, --name <name>', 'New name')\n .option('-d, --description <text>', 'New description')\n .option('--vision <text>', 'New vision text')\n .option('--status <status>', `Status: ${FEATURE_STATUSES.join(', ')}`)\n .option('--priority <n>', 'Priority 0-4', parseInt)\n .option('--effort <n>', 'Effort estimate', parseFloat)\n .option('--area <id>', 'Area CUID (\"none\" to clear)')\n .option(\n '--goal <id|none>',\n 'Objective (goal) id this feature serves (\"none\" to clear). For progress ' +\n 'rollup, link the finer Feature→key-result edge with `goals kr link --feature`.',\n )\n .action(\n async (\n options: {\n id: string;\n name?: string;\n description?: string;\n vision?: string;\n status?: string;\n priority?: number;\n effort?: number;\n area?: string;\n goal?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateFeatureStatus(options.status);\n const client = getClient();\n const feature = await client.features.update({\n id: options.id,\n name: options.name,\n description: options.description,\n vision: options.vision,\n status,\n priority: options.priority,\n effort: options.effort,\n areaId: options.area === 'none' ? null : options.area,\n goalId: parseFeatureGoalId(options.goal),\n });\n if (useJson) outputFeatureJson(feature);\n else {\n console.log('\\n✓ Feature updated');\n outputFeaturePretty(feature);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n features\n .command('delete <id>')\n .description(\n \"Delete a feature. Refuses if it still has tickets — deleting a feature does not \" +\n 'delete its tickets, it unlinks them (Ticket.featureId is SetNull), silently ' +\n 'orphaning them in the product backlog.',\n )\n .option(\n '--with-tickets',\n \"Delete the feature's tickets first, then the feature (destructive)\",\n )\n .option(\n '--orphan-tickets',\n 'Delete the feature anyway, leaving its tickets in the backlog unlinked',\n )\n .action(\n async (\n id: string,\n options: { withTickets?: boolean; orphanTickets?: boolean },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n if (options.withTickets && options.orphanTickets) {\n throw new Error(\n '--with-tickets and --orphan-tickets are mutually exclusive',\n );\n }\n const client = getClient();\n const feature = await client.features.get(id);\n\n // `features get` returns `_count.tickets`; trust a zero count and skip\n // the extra round trip. Otherwise fetch the tickets themselves — they\n // are needed both to report and (with --with-tickets) to delete.\n const tickets =\n feature._count?.tickets === 0\n ? []\n : await client.tickets.list({\n productId: feature.productId,\n featureId: feature.id,\n });\n\n if (tickets.length > 0 && !options.withTickets && !options.orphanTickets) {\n const reason = `has ${tickets.length} ticket${tickets.length === 1 ? '' : 's'}`;\n if (useJson) {\n console.log(\n JSON.stringify(\n {\n deleted: false,\n id: feature.id,\n reason,\n tickets: tickets.map(summarizeTicket),\n },\n null,\n 2,\n ),\n );\n } else {\n console.error(\n `\\nRefusing to delete \"${feature.name}\": it ${reason}.\\n` +\n 'Deleting the feature would leave them unlinked in the product backlog.\\n' +\n ' --with-tickets delete those tickets first, then the feature\\n' +\n ' --orphan-tickets delete the feature anyway and unlink them',\n );\n for (const t of tickets) {\n console.error(` - ${ticketLabel(t)} ${t.title}`);\n }\n }\n process.exitCode = 1;\n return;\n }\n\n const ticketsDeleted: TicketSummary[] = [];\n const ticketsFailed: (TicketSummary & { error: string })[] = [];\n if (options.withTickets) {\n for (const ticket of tickets) {\n try {\n await client.tickets.delete(ticket.id);\n ticketsDeleted.push(summarizeTicket(ticket));\n } catch (error) {\n ticketsFailed.push({\n ...summarizeTicket(ticket),\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n }\n\n // Never delete the feature after a partial ticket sweep — the survivors\n // would be orphaned, which is exactly what --with-tickets promises to avoid.\n if (ticketsFailed.length > 0) {\n const reason = `failed to delete ${ticketsFailed.length} of ${tickets.length} tickets`;\n if (useJson) {\n console.log(\n JSON.stringify(\n { deleted: false, id: feature.id, reason, ticketsDeleted, ticketsFailed },\n null,\n 2,\n ),\n );\n } else {\n console.error(`\\nAborted: ${reason}. Feature \"${feature.name}\" was NOT deleted.`);\n for (const t of ticketsFailed) {\n console.error(` - ${t.shortId ?? t.id}: ${t.error}`);\n }\n }\n process.exitCode = 1;\n return;\n }\n\n await client.features.delete(feature.id);\n\n const ticketsOrphaned = options.orphanTickets\n ? tickets.map(summarizeTicket)\n : [];\n\n if (useJson) {\n console.log(\n JSON.stringify(\n { deleted: true, id: feature.id, ticketsDeleted, ticketsOrphaned },\n null,\n 2,\n ),\n );\n } else {\n console.log('\\n✓ Feature deleted');\n if (ticketsDeleted.length > 0) {\n console.log(` ${ticketsDeleted.length} ticket(s) deleted with it`);\n }\n if (ticketsOrphaned.length > 0) {\n console.log(` ${ticketsOrphaned.length} ticket(s) left unlinked in the backlog`);\n }\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n features\n .command('link-page')\n .description('Link a Knowledge page (PRD, spec, research) to a feature')\n .requiredOption('--feature <id>', 'Feature CUID')\n .requiredOption('--page <id>', 'Page CUID')\n .option('--scope <id>', 'Feature scope CUID to pin the page to')\n .action(\n async (\n options: { feature: string; page: string; scope?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const link = await client.features.linkPage({\n featureId: options.feature,\n pageId: options.page,\n scopeId: options.scope,\n });\n if (useJson) console.log(JSON.stringify(link, null, 2));\n else console.log('\\n✓ Page linked');\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n features\n .command('unlink-page')\n .description('Unlink a Knowledge page from a feature')\n .requiredOption('--feature <id>', 'Feature CUID')\n .requiredOption('--page <id>', 'Page CUID')\n .action(\n async (options: { feature: string; page: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const result = await client.features.unlinkPage(\n options.feature,\n options.page,\n );\n if (useJson) console.log(JSON.stringify(result, null, 2));\n else console.log('\\n✓ Page unlinked');\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n features.addCommand(createStoriesCommand());\n features.addCommand(createScopesCommand());\n features.addCommand(createRequirementsCommand());\n features.addCommand(createAreasCommand());\n features.addCommand(createFeatureCommentsCommand());\n\n return features;\n}\n","import { Command } from 'commander';\nimport type { UserStoryCreateInput } from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport {\n shouldUseJson,\n outputUserStoryJson,\n outputUserStoryPretty,\n outputUserStoriesJson,\n outputUserStoriesPretty,\n outputBatchResultsJson,\n outputBatchResultsPretty,\n type BatchStoryResult,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\n// Shape of a single story object in the stdin batch array.\ninterface BatchStoryInput {\n asA?: string;\n iWant?: string;\n soThat?: string;\n acceptanceCriteria?: string;\n scopeId?: string;\n}\n\nasync function readStdin(): Promise<string> {\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(chunk as Buffer);\n }\n return Buffer.concat(chunks).toString('utf-8');\n}\n\nexport function createStoriesCommand(): Command {\n const stories = new Command('stories').description(\n 'Manage a feature\\'s native, structured user stories (As a / I want / So that).',\n );\n\n stories\n .command('add')\n .description(\n [\n 'Add user stories to a feature.',\n '',\n 'Flag mode: pass --as-a/--i-want/--so-that (plus optional --acceptance/--scope) to add one story.',\n 'Batch mode: pipe a JSON array of { asA?, iWant?, soThat?, acceptanceCriteria?, scopeId? } on stdin',\n ' to add many at once (per-item success/failure is reported).',\n ].join('\\n'),\n )\n .requiredOption('--feature <id>', 'Feature CUID')\n .option('--as-a <text>', '\"As a ...\" actor')\n .option('--i-want <text>', '\"I want ...\" capability')\n .option('--so-that <text>', '\"So that ...\" outcome')\n .option('--acceptance <text>', 'Acceptance criteria')\n .option('--scope <id>', 'Feature scope CUID to group the story under')\n .action(\n async (\n options: {\n feature: string;\n asA?: string;\n iWant?: string;\n soThat?: string;\n acceptance?: string;\n scope?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n const hasFlags =\n options.asA != null ||\n options.iWant != null ||\n options.soThat != null ||\n options.acceptance != null;\n // Batch mode when stdin is piped and no story flags were given.\n const isBatch = !hasFlags && !process.stdin.isTTY;\n\n try {\n const client = getClient();\n\n if (isBatch) {\n const raw = await readStdin();\n let items: BatchStoryInput[];\n try {\n const parsed: unknown = JSON.parse(raw);\n if (!Array.isArray(parsed)) {\n throw new Error('Expected a JSON array of story objects on stdin');\n }\n items = parsed as BatchStoryInput[];\n } catch (parseError) {\n throw new Error(\n `Could not parse stdin as a JSON array: ${\n parseError instanceof Error ? parseError.message : String(parseError)\n }`,\n );\n }\n\n const results: BatchStoryResult[] = [];\n // Sequential so server-side displayOrder follows array order.\n for (let index = 0; index < items.length; index++) {\n const item = items[index]!;\n try {\n const story = await client.userStories.create({\n featureId: options.feature,\n asA: item.asA,\n iWant: item.iWant,\n soThat: item.soThat,\n acceptanceCriteria: item.acceptanceCriteria,\n scopeId: item.scopeId,\n });\n results.push({ index, ok: true, id: story.id });\n } catch (itemError) {\n results.push({\n index,\n ok: false,\n error: itemError instanceof Error ? itemError.message : String(itemError),\n });\n }\n }\n\n if (useJson) outputBatchResultsJson(results);\n else outputBatchResultsPretty(results);\n\n // Non-zero exit if every item failed, so scripts can detect total failure.\n if (results.length > 0 && results.every((r) => !r.ok)) {\n process.exit(1);\n }\n return;\n }\n\n // Flag mode: a single story.\n const input: UserStoryCreateInput = {\n featureId: options.feature,\n asA: options.asA,\n iWant: options.iWant,\n soThat: options.soThat,\n acceptanceCriteria: options.acceptance,\n scopeId: options.scope,\n };\n const story = await client.userStories.create(input);\n if (useJson) outputUserStoryJson(story);\n else {\n console.log('\\n✓ User story added');\n outputUserStoryPretty(story);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n stories\n .command('list')\n .description('List a feature\\'s user stories in display order')\n .requiredOption('--feature <id>', 'Feature CUID')\n .action(\n async (options: { feature: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const list = await client.userStories.list({ featureId: options.feature });\n if (useJson) outputUserStoriesJson(list);\n else outputUserStoriesPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n return stories;\n}\n","import { Command } from 'commander';\nimport type { FeatureScopeStatus } from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport {\n shouldUseJson,\n outputScopeJson,\n outputScopePretty,\n outputScopesJson,\n outputScopesPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nconst SCOPE_STATUSES: FeatureScopeStatus[] = [\n 'PLANNED',\n 'IN_PROGRESS',\n 'SHIPPED',\n 'DEPRECATED',\n];\n\nfunction validateScopeStatus(value: string | undefined): FeatureScopeStatus | undefined {\n if (!value) return undefined;\n if (!(SCOPE_STATUSES as string[]).includes(value)) {\n throw new Error(\n `Invalid status \"${value}\". Valid: ${SCOPE_STATUSES.join(', ')}`,\n );\n }\n return value as FeatureScopeStatus;\n}\n\nexport function createScopesCommand(): Command {\n const scopes = new Command('scopes').description(\n 'Manage a feature\\'s scopes: shippable increments (\"V1\", \"V2\"), each with its own lifecycle.',\n );\n\n scopes\n .command('list')\n .description('List a feature\\'s scopes')\n .requiredOption('--feature <id>', 'Feature CUID')\n .action(\n async (options: { feature: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const list = await client.scopes.list({ featureId: options.feature });\n if (useJson) outputScopesJson(list);\n else outputScopesPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n scopes\n .command('add')\n .description('Add a scope to a feature')\n .requiredOption('--feature <id>', 'Feature CUID')\n .requiredOption('--version <label>', 'Short label for the increment, e.g. \"V1\"')\n .requiredOption('-d, --description <text>', 'What this scope delivers (markdown supported)')\n .option('--status <status>', `Status: ${SCOPE_STATUSES.join(', ')} (default PLANNED)`)\n .action(\n async (\n options: { feature: string; version: string; description: string; status?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateScopeStatus(options.status);\n const client = getClient();\n const scope = await client.scopes.create({\n featureId: options.feature,\n version: options.version,\n description: options.description,\n status,\n });\n if (useJson) outputScopeJson(scope);\n else {\n console.log('\\n✓ Scope added');\n outputScopePretty(scope);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n scopes\n .command('update')\n .description('Update a scope (setting SHIPPED stamps shippedAt and rolls the feature status up)')\n .requiredOption('--id <id>', 'Scope CUID')\n .option('--version <label>', 'New version label')\n .option('-d, --description <text>', 'New description')\n .option('--status <status>', `Status: ${SCOPE_STATUSES.join(', ')}`)\n .action(\n async (\n options: { id: string; version?: string; description?: string; status?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateScopeStatus(options.status);\n const client = getClient();\n const scope = await client.scopes.update({\n id: options.id,\n version: options.version,\n description: options.description,\n status,\n });\n if (useJson) outputScopeJson(scope);\n else {\n console.log('\\n✓ Scope updated');\n outputScopePretty(scope);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n scopes\n .command('rm')\n .description('Delete a scope')\n .requiredOption('--id <id>', 'Scope CUID')\n .action(async (options: { id: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const result = await client.scopes.delete(options.id);\n if (useJson) console.log(JSON.stringify(result, null, 2));\n else console.log('\\n✓ Scope deleted');\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return scopes;\n}\n","import { Command } from 'commander';\nimport type { RequirementCreateInput, RequirementKind } from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport {\n shouldUseJson,\n outputRequirementJson,\n outputRequirementPretty,\n outputRequirementsJson,\n outputRequirementsPretty,\n outputRequirementBatchJson,\n outputRequirementBatchPretty,\n type BatchRequirementResult,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nconst REQUIREMENT_KINDS: RequirementKind[] = [\n 'FUNCTIONAL',\n 'NON_FUNCTIONAL',\n 'CONSTRAINT',\n];\n\nfunction validateKind(value: string | undefined): RequirementKind | undefined {\n if (!value) return undefined;\n if (!(REQUIREMENT_KINDS as string[]).includes(value)) {\n throw new Error(\n `Invalid kind \"${value}\". Valid: ${REQUIREMENT_KINDS.join(', ')}`,\n );\n }\n return value as RequirementKind;\n}\n\n// Shape of a single requirement object in the stdin batch array.\ninterface BatchRequirementInput {\n statement: string;\n kind?: RequirementKind;\n scopeId?: string;\n}\n\nasync function readStdin(): Promise<string> {\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(chunk as Buffer);\n }\n return Buffer.concat(chunks).toString('utf-8');\n}\n\nexport function createRequirementsCommand(): Command {\n const requirements = new Command('requirements').description(\n 'Manage a feature\\'s requirements: atomic, testable EARS-style \"shall\" statements, checkable met/unmet.',\n );\n\n requirements\n .command('add')\n .description(\n [\n 'Add requirements to a feature.',\n '',\n 'Flag mode: pass -s/--statement (plus optional --kind/--scope) to add one requirement.',\n 'Batch mode: pipe a JSON array of { statement, kind?, scopeId? } on stdin',\n ' to add many at once (per-item success/failure is reported).',\n ].join('\\n'),\n )\n .requiredOption('--feature <id>', 'Feature CUID')\n .option('-s, --statement <text>', 'One EARS-style \"shall\" statement')\n .option('--kind <kind>', `Kind: ${REQUIREMENT_KINDS.join(', ')}`)\n .option('--scope <id>', 'Feature scope CUID to pin the requirement to')\n .action(\n async (\n options: { feature: string; statement?: string; kind?: string; scope?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n\n if (options.statement) {\n const requirement = await client.requirements.create({\n featureId: options.feature,\n statement: options.statement,\n kind: validateKind(options.kind),\n scopeId: options.scope,\n });\n if (useJson) outputRequirementJson(requirement);\n else {\n console.log('\\n✓ Requirement added');\n outputRequirementPretty(requirement);\n }\n return;\n }\n\n // Batch mode: JSON array on stdin.\n if (process.stdin.isTTY) {\n throw new Error(\n 'Pass -s/--statement, or pipe a JSON array of requirements on stdin.',\n );\n }\n const raw = await readStdin();\n let batch: BatchRequirementInput[];\n try {\n const parsed: unknown = JSON.parse(raw);\n if (!Array.isArray(parsed)) throw new Error('not an array');\n batch = parsed as BatchRequirementInput[];\n } catch {\n throw new Error(\n 'stdin must be a JSON array of { statement, kind?, scopeId? } objects.',\n );\n }\n\n const results: BatchRequirementResult[] = [];\n for (const [index, item] of batch.entries()) {\n try {\n if (!item.statement || typeof item.statement !== 'string') {\n throw new Error('missing \"statement\"');\n }\n const input: RequirementCreateInput = {\n featureId: options.feature,\n statement: item.statement,\n kind: validateKind(item.kind),\n scopeId: item.scopeId,\n };\n const requirement = await client.requirements.create(input);\n results.push({ index, success: true, requirement });\n } catch (error) {\n results.push({\n index,\n success: false,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n if (useJson) outputRequirementBatchJson(results);\n else outputRequirementBatchPretty(results);\n if (results.some((r) => !r.success)) process.exitCode = 1;\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n requirements\n .command('list')\n .description('List a feature\\'s requirements')\n .requiredOption('--feature <id>', 'Feature CUID')\n .option('--scope <id>', 'Only requirements pinned to this scope')\n .action(\n async (options: { feature: string; scope?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const list = await client.requirements.list({\n featureId: options.feature,\n scopeId: options.scope,\n });\n if (useJson) outputRequirementsJson(list);\n else outputRequirementsPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n requirements\n .command('check')\n .description('Mark a requirement met (or unmet with --unmet)')\n .requiredOption('--id <id>', 'Requirement CUID')\n .option('--unmet', 'Mark unmet instead of met')\n .action(\n async (options: { id: string; unmet?: boolean }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const requirement = await client.requirements.setChecked(\n options.id,\n !options.unmet,\n );\n if (useJson) outputRequirementJson(requirement);\n else {\n console.log(`\\n✓ Requirement marked ${options.unmet ? 'unmet' : 'met'}`);\n outputRequirementPretty(requirement);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n requirements\n .command('rm')\n .description('Delete a requirement')\n .requiredOption('--id <id>', 'Requirement CUID')\n .action(async (options: { id: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const result = await client.requirements.delete(options.id);\n if (useJson) console.log(JSON.stringify(result, null, 2));\n else console.log('\\n✓ Requirement deleted');\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return requirements;\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveProductId, resolveWorkspaceId } from '../utils/resolve.js';\nimport { shouldUseJson } from '../utils/output.js';\nimport chalk from 'chalk';\nimport type { Area } from 'exponential-sdk';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nfunction outputAreasPretty(areas: Area[]): void {\n if (areas.length === 0) {\n console.log(chalk.gray('No areas found.'));\n return;\n }\n console.log(chalk.bold(`\\nAreas (${areas.length} total)`));\n console.log(chalk.gray('─'.repeat(50)));\n for (const a of areas) {\n const count = a._count?.features != null ? chalk.gray(` (${a._count.features} features)`) : '';\n console.log(` ${chalk.bold(a.name)}${count}`);\n console.log(chalk.gray(` ID: ${a.id}`));\n }\n console.log();\n}\n\nexport function createAreasCommand(): Command {\n const areas = new Command('areas').description(\n 'Manage a product\\'s areas: the buckets features are filed under (a feature has exactly one or none).',\n );\n\n areas\n .command('list')\n .description('List a product\\'s areas')\n .requiredOption('--product <slug|id>', 'Product slug or CUID')\n .option('--workspace <slug|id>', 'Workspace (required when --product is a slug)')\n .action(\n async (options: { product: string; workspace?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const productId = await resolveProductId(client, workspaceId, options.product);\n const list = await client.areas.list({ productId });\n if (useJson) console.log(JSON.stringify({ areas: list, total: list.length }, null, 2));\n else outputAreasPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n areas\n .command('create')\n .description('Create an area in a product')\n .requiredOption('--product <slug|id>', 'Product slug or CUID')\n .requiredOption('-n, --name <name>', 'Area name (unique per product)')\n .option('-d, --description <text>', 'What belongs in this area')\n .option('--workspace <slug|id>', 'Workspace (required when --product is a slug)')\n .action(\n async (\n options: { product: string; name: string; description?: string; workspace?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const productId = await resolveProductId(client, workspaceId, options.product);\n const area = await client.areas.create({\n productId,\n name: options.name,\n description: options.description,\n });\n if (useJson) console.log(JSON.stringify(area, null, 2));\n else console.log(`\\n✓ Area created: ${area.name} (${area.id})`);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n return areas;\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n applyMentions,\n collectMention,\n MENTION_OPTION_DESCRIPTION,\n} from '../utils/mentions.js';\nimport {\n shouldUseJson,\n outputCommentJson,\n outputCommentPretty,\n outputCommentsJson,\n outputCommentsPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\n/**\n * `exponential features comment …` — the discussion on a feature (PRD).\n *\n * Any workspace member can read and post; editing and deleting are\n * author-only, so the CLI surfaces the server's \"not yours\" error rather than\n * pre-checking.\n */\nexport function createFeatureCommentsCommand(): Command {\n const comment = new Command('comment').description(\n 'Read and post comments on a feature. Mention teammates with --mention.',\n );\n\n comment\n .command('list')\n .description('List comments on a feature')\n .requiredOption('--feature <id>', 'Feature ID')\n .action(async (options: { feature: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const comments = await client.featureComments.list(options.feature);\n if (useJson) outputCommentsJson(comments);\n else outputCommentsPretty(comments);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('add')\n .description('Add a comment to a feature')\n .requiredOption('--feature <id>', 'Feature ID')\n .requiredOption('-m, --message <text>', 'Comment body (markdown supported)')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .option('--scope <id>', \"Attach to a scope's activity feed instead of the feature\")\n .action(\n async (\n options: {\n feature: string;\n message: string;\n mention: string[];\n workspace?: string;\n scope?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n // Only resolve a workspace when mentions actually need one — an\n // unmentioned comment shouldn't fail for lack of a default workspace.\n const body =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const created = await client.featureComments.create({\n featureId: options.feature,\n scopeId: options.scope,\n body,\n });\n if (useJson) {\n outputCommentJson(created);\n } else {\n console.log('\\n✓ Comment added');\n outputCommentPretty(created);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('reply')\n .description('Reply to a comment on a feature')\n .requiredOption('--comment-id <id>', 'Comment ID to reply to')\n .requiredOption('-m, --message <text>', 'Reply body (markdown supported)')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .action(\n async (\n options: {\n commentId: string;\n message: string;\n mention: string[];\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const body =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const created = await client.featureComments.reply({\n parentId: options.commentId,\n body,\n });\n if (useJson) {\n outputCommentJson(created);\n } else {\n console.log('\\n✓ Reply added');\n outputCommentPretty(created);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('update')\n .description('Update one of your own comments')\n .requiredOption('--comment-id <id>', 'Comment ID')\n .requiredOption('-m, --message <text>', 'New comment body')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .action(\n async (\n options: {\n commentId: string;\n message: string;\n mention: string[];\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const body =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const updated = await client.featureComments.update({\n commentId: options.commentId,\n body,\n });\n if (useJson) {\n outputCommentJson(updated);\n } else {\n console.log('\\n✓ Comment updated');\n outputCommentPretty(updated);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('rm')\n .description('Delete one of your own comments')\n .requiredOption('--comment-id <id>', 'Comment ID')\n .action(async (options: { commentId: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.featureComments.delete(options.commentId);\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id: options.commentId }, null, 2));\n } else {\n console.log('✓ Comment deleted');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('resolve')\n .description('Resolve an anchored comment thread')\n .requiredOption('--feature <id>', 'Feature ID')\n .requiredOption('--thread <id>', 'Thread ID (anchored comments only)')\n .action(async (options: { feature: string; thread: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.featureComments.resolve({\n featureId: options.feature,\n threadId: options.thread,\n });\n if (useJson) {\n console.log(JSON.stringify({ resolved: true, threadId: options.thread }, null, 2));\n } else {\n console.log('✓ Thread resolved');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('unresolve')\n .description('Reopen a resolved comment thread')\n .requiredOption('--feature <id>', 'Feature ID')\n .requiredOption('--thread <id>', 'Thread ID (anchored comments only)')\n .action(async (options: { feature: string; thread: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.featureComments.unresolve({\n featureId: options.feature,\n threadId: options.thread,\n });\n if (useJson) {\n console.log(JSON.stringify({ resolved: false, threadId: options.thread }, null, 2));\n } else {\n console.log('✓ Thread reopened');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return comment;\n}\n","import type { ExponentialClient, WorkspaceMember } from 'exponential-sdk';\n\n/**\n * Mentions are stored as `@[Display Name](userId)` markup inside a comment\n * body — that exact form is what the server parses to decide who gets\n * notified. Typing it by hand means knowing someone's user id, so `--mention`\n * takes a name, email, or id and expands it here.\n *\n * Substitution is in-place where possible: `--mention andi -m \"@andi ptal?\"`\n * produces `@[Andi Stanner](clx…) ptal?`, so the sentence still reads. Tokens\n * with no matching `@handle` in the body get prepended instead, which keeps\n * `--mention andi -m \"ptal?\"` working too.\n */\n\nfunction candidateLabels(member: WorkspaceMember): string[] {\n const labels = [member.id];\n if (member.name) {\n labels.push(member.name);\n // \"Andi Stanner\" should also answer to \"andi\".\n const first = member.name.trim().split(/\\s+/)[0];\n if (first) labels.push(first);\n }\n if (member.email) {\n labels.push(member.email);\n const local = member.email.split('@')[0];\n if (local) labels.push(local);\n }\n return labels;\n}\n\nfunction describe(member: WorkspaceMember): string {\n return member.name ?? member.email ?? member.id;\n}\n\n/**\n * Resolve one `--mention` token to a workspace member.\n *\n * Exact id, name, or email wins outright. Otherwise the token is matched\n * case-insensitively against first names and email local-parts. An ambiguous\n * token is an error rather than a guess — mentioning the wrong colleague is\n * worse than failing.\n */\nexport function resolveMember(\n members: WorkspaceMember[],\n token: string,\n): WorkspaceMember {\n const needle = token.trim().toLowerCase().replace(/^@/, '');\n\n const exact = members.filter(\n (m) =>\n m.id.toLowerCase() === needle ||\n m.name?.toLowerCase() === needle ||\n m.email?.toLowerCase() === needle,\n );\n if (exact.length === 1) return exact[0]!;\n if (exact.length > 1) {\n throw new Error(\n `\"${token}\" matches ${exact.length} members. Use a user id instead: ${exact\n .map((m) => `${describe(m)} (${m.id})`)\n .join(', ')}`,\n );\n }\n\n const partial = members.filter((m) =>\n candidateLabels(m).some((l) => l.toLowerCase() === needle),\n );\n if (partial.length === 1) return partial[0]!;\n if (partial.length > 1) {\n throw new Error(\n `\"${token}\" is ambiguous — matches ${partial\n .map((m) => `${describe(m)} (${m.id})`)\n .join(', ')}. Use a full name, email, or user id.`,\n );\n }\n\n const known = members.map(describe).join(', ');\n throw new Error(\n `No workspace member matches \"${token}\". Members: ${known || '(none)'}. ` +\n 'Run `exponential workspaces members` to see the roster.',\n );\n}\n\n/** Escape a token for safe use inside a RegExp. */\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/**\n * Expand `--mention` tokens into a comment body.\n *\n * Returns the body unchanged when no mentions were requested, so the common\n * path costs nothing — the member roster is only fetched when it's needed.\n */\nexport async function applyMentions(\n client: ExponentialClient,\n workspaceId: string,\n body: string,\n mentions: string[] | undefined,\n): Promise<string> {\n if (!mentions || mentions.length === 0) return body;\n\n const members = await client.workspaces.listMembers(workspaceId);\n\n let result = body;\n const prepend: string[] = [];\n\n for (const token of mentions) {\n const member = resolveMember(members, token);\n const handle = token.trim().replace(/^@/, '');\n // Replace `@handle` in the body when the author wrote one, so the mention\n // lands where they meant it to. `(?![\\w-])` stops `@andi` matching inside\n // `@andidev`.\n const inline = new RegExp(`@${escapeRegExp(handle)}(?![\\\\w-])`, 'gi');\n const substituted = result.replace(inline, member.mentionSyntax);\n if (substituted !== result) {\n result = substituted;\n } else if (!result.includes(member.mentionSyntax)) {\n prepend.push(member.mentionSyntax);\n }\n }\n\n return prepend.length > 0 ? `${prepend.join(' ')} ${result}` : result;\n}\n\n/** Shared `--mention` option description, so every comment command reads alike. */\nexport const MENTION_OPTION_DESCRIPTION =\n 'Mention a workspace member by name, email, or id (repeatable). ' +\n 'Writing @name in the message substitutes in place; otherwise the mention is prepended.';\n\n/** Commander collector for a repeatable option. */\nexport function collectMention(value: string, previous: string[]): string[] {\n return [...previous, value];\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport type { Tag } from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport { shouldUseJson } from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\ninterface SeedLabel {\n name: string;\n slug: string;\n color: string;\n}\n\n/**\n * Canonical triage labels referenced by the `/triage` agent skill. Slugs are\n * deterministic, so re-running `seed-triage` after a partial creation only\n * creates the missing ones.\n */\nconst TRIAGE_LABELS: SeedLabel[] = [\n { slug: 'needs-triage', name: 'needs-triage', color: 'avatar-orange' },\n { slug: 'needs-info', name: 'needs-info', color: 'avatar-yellow' },\n { slug: 'ready-for-agent', name: 'ready-for-agent', color: 'avatar-green' },\n { slug: 'ready-for-human', name: 'ready-for-human', color: 'avatar-lightBlue' },\n { slug: 'wontfix', name: 'wontfix', color: 'avatar-lightGray' },\n];\n\nconst CUID_PATTERN = /^c[a-z0-9]{20,}$/i;\n\nfunction looksLikeCuid(value: string): boolean {\n return CUID_PATTERN.test(value);\n}\n\nfunction outputTagsPretty(tags: Tag[]): void {\n if (tags.length === 0) {\n console.log(chalk.dim('No labels found.'));\n return;\n }\n console.log();\n for (const tag of tags) {\n const scope = tag.workspaceId === null ? chalk.cyan('global') : chalk.magenta('workspace');\n const category = tag.category === null ? chalk.dim('(label)') : chalk.dim(`(${tag.category})`);\n console.log(\n ` ${chalk.bold(tag.slug)} ${tag.name} ${chalk.gray(tag.color)} ${scope} ${category}`,\n );\n }\n console.log();\n}\n\nfunction outputTagPretty(tag: Tag, prefix?: string): void {\n if (prefix) console.log(prefix);\n console.log(` ${chalk.bold(tag.slug)} ${tag.name} ${chalk.gray(tag.color)}`);\n}\n\nexport async function resolveLabelIds(\n client: ReturnType<typeof getClient>,\n workspaceId: string | undefined,\n values: string[],\n): Promise<string[]> {\n if (values.length === 0) return [];\n\n const bySlug = values.filter((v) => !looksLikeCuid(v));\n const byId = values.filter((v) => looksLikeCuid(v));\n\n if (bySlug.length === 0) return byId;\n\n const list = await client.labels.list({ workspaceId });\n const slugMap = new Map(list.allTags.map((t) => [t.slug, t.id]));\n\n const resolvedFromSlugs: string[] = [];\n const missing: string[] = [];\n for (const slug of bySlug) {\n const id = slugMap.get(slug);\n if (id === undefined) missing.push(slug);\n else resolvedFromSlugs.push(id);\n }\n if (missing.length > 0) {\n throw new Error(\n `Unknown label slug(s): ${missing.join(', ')}. Run \\`exponential labels list --workspace <slug>\\` to see available labels.`,\n );\n }\n return [...byId, ...resolvedFromSlugs];\n}\n\nexport function createLabelsCommand(): Command {\n const labels = new Command('labels').description(\n 'Manage labels (orthogonal tags applied to actions, tickets, features, and epics).',\n );\n\n labels\n .command('list')\n .description('List labels visible in a workspace')\n .option('--workspace <slug|id>', 'Workspace slug or CUID')\n .option(\n '--category <category>',\n 'Filter by category. Use \"label\" for general labels, \"null\" for category-less labels, or omit to list all.',\n )\n .action(\n async (\n options: { workspace?: string; category?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const category =\n options.category === undefined\n ? undefined\n : options.category === 'null'\n ? null\n : options.category;\n const result = await client.labels.list({ workspaceId, category });\n if (useJson) {\n console.log(JSON.stringify(result.allTags, null, 2));\n } else {\n outputTagsPretty(result.allTags);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n labels\n .command('create')\n .description('Create a workspace-scoped label')\n .requiredOption('-n, --name <name>', 'Label name')\n .requiredOption('--color <token>', 'Color token (e.g. avatar-green, brand-primary)')\n .option('-d, --description <text>', 'Description')\n .option('--category <category>', 'Category. Omit (or pass \"null\") to create a general label.')\n .option('--workspace <slug|id>', 'Workspace slug or CUID')\n .action(\n async (\n options: {\n name: string;\n color: string;\n description?: string;\n category?: string;\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n if (workspaceId === undefined) {\n throw new Error(\n 'Workspace is required. Pass --workspace <slug|id> or set a default with `exponential workspaces set-default`.',\n );\n }\n const category =\n options.category === undefined\n ? undefined\n : options.category === 'null'\n ? null\n : options.category;\n const tag = await client.labels.create({\n workspaceId,\n name: options.name,\n color: options.color,\n description: options.description,\n category,\n });\n if (useJson) {\n console.log(JSON.stringify(tag, null, 2));\n } else {\n outputTagPretty(tag, chalk.green('\\n✓ Label created'));\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n labels\n .command('seed-triage')\n .description('Idempotently seed the five canonical triage labels into a workspace.')\n .option('--workspace <slug|id>', 'Workspace slug or CUID')\n .action(\n async (options: { workspace?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n if (workspaceId === undefined) {\n throw new Error(\n 'Workspace is required. Pass --workspace <slug|id> or set a default with `exponential workspaces set-default`.',\n );\n }\n const existing = await client.labels.list({ workspaceId });\n const existingSlugs = new Set(existing.allTags.map((t) => t.slug));\n\n const results: Array<{\n slug: string;\n status: 'created' | 'existed';\n tag?: Tag;\n }> = [];\n for (const def of TRIAGE_LABELS) {\n if (existingSlugs.has(def.slug)) {\n results.push({ slug: def.slug, status: 'existed' });\n continue;\n }\n const tag = await client.labels.create({\n workspaceId,\n name: def.name,\n color: def.color,\n });\n results.push({ slug: def.slug, status: 'created', tag });\n }\n\n if (useJson) {\n console.log(JSON.stringify(results, null, 2));\n } else {\n console.log();\n console.log(chalk.bold('Triage labels:'));\n for (const r of results) {\n const tag = chalk.bold(r.slug);\n const status =\n r.status === 'created'\n ? chalk.green('created')\n : chalk.dim('existed');\n console.log(` ${tag} ${status}`);\n }\n console.log();\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n return labels;\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { readText, parseDate } from '../utils/input.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n shouldUseJson,\n outputMeetingJson,\n outputMeetingPretty,\n outputMeetingsJson,\n outputMeetingsPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nexport function createMeetingsCommand(): Command {\n const meetings = new Command('meetings').description(\n 'Manage meetings and their notes (recorded, imported, or manually created)',\n );\n\n meetings\n .command('list')\n .description(\n 'List meetings you can see (owned, attended, or shared via project/workspace). JSON rows carry hasNotes/hasSummary/hasTranscript flags instead of the bodies — use \"get\" for content.',\n )\n .option('--workspace <slug|id>', 'Restrict to one workspace')\n .option('--mine', 'Only meetings you own or attended')\n .option('--archived', 'Include archived meetings')\n .action(\n async (\n options: { workspace?: string; mine?: boolean; archived?: boolean },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = options.workspace\n ? await resolveWorkspaceId(client, options.workspace)\n : undefined;\n const list = await client.meetings.list({\n workspaceId,\n includeArchived: options.archived,\n meetingType: options.mine ? 'mine' : undefined,\n });\n if (useJson) outputMeetingsJson(list);\n else outputMeetingsPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n meetings\n .command('get <id>')\n .description('Get a meeting: details, summary, and notes')\n .option('--transcript', 'Also print the raw transcript (pretty mode; JSON always includes it)')\n .action(\n async (id: string, options: { transcript?: boolean }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const meeting = await client.meetings.get(id);\n if (useJson) outputMeetingJson(meeting);\n else outputMeetingPretty(meeting, { transcript: options.transcript });\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n meetings\n .command('create')\n .description(\n 'Create a meeting manually. Transcript: --transcript text, --transcript-file <path>, or --transcript-file - for stdin.',\n )\n .requiredOption('-t, --title <title>', 'Meeting title')\n .option('--transcript <text>', 'Transcript text (required by the API)')\n .option('--transcript-file <path>', 'Read the transcript from a file (\"-\" = stdin)')\n .option('--notes <markdown>', 'Meeting notes')\n .option('--notes-file <path>', 'Read the notes from a file (\"-\" = stdin)')\n .option('--description <text>', 'Short description')\n .option('--date <iso>', 'When the meeting occurred (e.g. 2026-08-25T14:00; a bare date is local midnight)')\n .option('--project <id>', 'Link to a project (the meeting inherits its workspace)')\n .option('--workspace <slug|id>', 'Workspace (omit for a personal meeting)')\n .action(\n async (\n options: {\n title: string;\n transcript?: string;\n transcriptFile?: string;\n notes?: string;\n notesFile?: string;\n description?: string;\n date?: string;\n project?: string;\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const transcription = readText(options.transcript, options.transcriptFile);\n if (transcription === undefined) {\n throw new Error(\n 'A transcript is required: pass --transcript <text> or --transcript-file <path|->.',\n );\n }\n if (transcription.trim() === '') {\n throw new Error('The transcript is empty. The API requires a non-empty transcript.');\n }\n const workspaceId = options.workspace\n ? await resolveWorkspaceId(client, options.workspace)\n : undefined;\n const meeting = await client.meetings.create({\n title: options.title,\n transcription,\n notes: readText(options.notes, options.notesFile),\n description: options.description,\n meetingDate: parseDate(options.date),\n projectId: options.project,\n workspaceId,\n });\n if (useJson) outputMeetingJson(meeting);\n else {\n console.log('\\n✓ Meeting created');\n outputMeetingPretty(meeting);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n meetings\n .command('update')\n .description(\n 'Update a meeting; only the fields you pass are written. Title and other fields are two API calls — on a mid-flight failure the title may already be saved.',\n )\n .requiredOption('--id <id>', 'Meeting CUID')\n .option('-t, --title <title>', 'New title')\n .option('--notes <markdown>', 'Replace the meeting notes')\n .option('--notes-file <path>', 'Read the new notes from a file (\"-\" = stdin)')\n .option('--summary <text>', 'Replace the summary')\n .option('--description <text>', 'Replace the description')\n .option('--date <iso>', 'When the meeting occurred')\n .action(\n async (\n options: {\n id: string;\n title?: string;\n notes?: string;\n notesFile?: string;\n summary?: string;\n description?: string;\n date?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const notes = readText(options.notes, options.notesFile);\n if (\n options.title === undefined &&\n notes === undefined &&\n options.summary === undefined &&\n options.description === undefined &&\n options.date === undefined\n ) {\n throw new Error(\n 'Nothing to update. Pass at least one of --title, --notes, --notes-file, --summary, --description, --date.',\n );\n }\n const client = getClient();\n const meeting = await client.meetings.update({\n id: options.id,\n title: options.title,\n notes,\n summary: options.summary,\n description: options.description,\n meetingDate: parseDate(options.date),\n });\n if (useJson) outputMeetingJson(meeting);\n else {\n console.log('\\n✓ Meeting updated');\n outputMeetingPretty(meeting);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n meetings\n .command('delete [ids...]')\n .description(\n 'Permanently delete meetings you own. Pass one or more ids, and/or --ids-file with whitespace-separated ids (\"-\" = stdin). Deleting more than one id requires --force. Exit 0 only when everything requested was deleted.',\n )\n .option('--ids-file <path>', 'Read whitespace-separated meeting ids from a file (\"-\" = stdin)')\n .option('--force', 'Confirm deleting more than one meeting in a single call')\n .action(\n async (\n idArgs: string[],\n options: { idsFile?: string; force?: boolean },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const fromFile = readText(undefined, options.idsFile);\n const ids = [\n ...new Set([\n ...idArgs,\n ...(fromFile ? fromFile.split(/\\s+/) : []),\n ].filter((id) => id !== '')),\n ];\n if (ids.length === 0) {\n throw new Error(\n 'Nothing to delete. Pass one or more meeting ids, or --ids-file <path|->.',\n );\n }\n // A mis-built pipe (unfiltered jq output, an error message, the\n // wrong file) must not turn into a silent no-op \"success\" — the\n // bulk mutation skips unknown ids without complaint.\n const malformed = ids.filter((id) => !/^[a-z][a-z0-9]{15,}$/i.test(id));\n if (malformed.length > 0) {\n throw new Error(\n `These don't look like meeting ids: ${malformed.slice(0, 5).join(', ')}${malformed.length > 5 ? ` (+${malformed.length - 5} more)` : ''}. Nothing was deleted.`,\n );\n }\n if (ids.length > 1 && !options.force) {\n throw new Error(\n `Refusing to delete ${ids.length} meetings without --force. Deletion is permanent.`,\n );\n }\n const client = getClient();\n let count: number;\n if (ids.length === 1) {\n // Single-id path gets precise errors (NOT_FOUND / FORBIDDEN)\n // instead of the bulk path's silent skip.\n await client.meetings.delete(ids[0]!);\n count = 1;\n } else {\n // Chunked so one oversized request can't fail wholesale with\n // zero deletions; counts are summed across chunks.\n count = 0;\n for (let i = 0; i < ids.length; i += 500) {\n const chunk = ids.slice(i, i + 500);\n count += (await client.meetings.deleteMany(chunk)).count;\n }\n }\n const skipped = ids.length - count;\n if (skipped > 0) {\n // Same contract as the single-id error path: anything short of\n // \"everything requested was deleted\" is a non-zero exit.\n process.exitCode = 1;\n }\n if (useJson) {\n console.log(\n JSON.stringify({ requested: ids.length, count, skipped }, null, 2),\n );\n } else {\n console.log(`✓ Deleted ${count} of ${ids.length} meeting${ids.length === 1 ? '' : 's'}`);\n if (skipped > 0) {\n console.log(\n chalk.yellow(\n `${skipped} id(s) were skipped — not found, or not owned by you.`,\n ),\n );\n }\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n const notes = new Command('notes').description(\n \"Read and write a meeting's notes\",\n );\n\n notes\n .command('get <id>')\n .description(\n 'Print the meeting notes as raw Markdown (safe to redirect to a file); pass --json for a {id, notes} envelope',\n )\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n try {\n const client = getClient();\n const body = await client.meetings.getNotes(id);\n if (globalOpts.json) {\n console.log(JSON.stringify({ id, notes: body }, null, 2));\n } else if (body !== null) {\n // Raw body even when piped — this output round-trips into\n // `notes set --file`, so it must never pick up a JSON envelope.\n process.stdout.write(body.endsWith('\\n') ? body : `${body}\\n`);\n } else if (process.stdout.isTTY) {\n console.log(chalk.gray('No notes yet.'));\n }\n } catch (error) {\n handleError(error, shouldUseJson(globalOpts.json, globalOpts.pretty));\n }\n });\n\n notes\n .command('set <id> [notes]')\n .description('Replace the meeting notes. Body: inline, --file <path>, or --file - for stdin.')\n .option('--file <path>', 'Read the notes from a file (\"-\" = stdin)')\n .action(\n async (\n id: string,\n inline: string | undefined,\n options: { file?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const body = readText(inline, options.file);\n if (body === undefined) {\n throw new Error('Pass the notes inline or via --file <path|->.');\n }\n const client = getClient();\n const meeting = await client.meetings.setNotes(id, body);\n if (useJson) outputMeetingJson(meeting);\n else console.log('✓ Notes saved');\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n notes\n .command('append <id> [notes]')\n .description(\n 'Append a block to the meeting notes (separated by a blank line). Read-modify-write: concurrent appends can lose one side.',\n )\n .option('--file <path>', 'Read the block from a file (\"-\" = stdin)')\n .action(\n async (\n id: string,\n inline: string | undefined,\n options: { file?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const body = readText(inline, options.file);\n if (body === undefined) {\n throw new Error('Pass the notes inline or via --file <path|->.');\n }\n const client = getClient();\n const meeting = await client.meetings.appendNotes(id, body);\n if (useJson) outputMeetingJson(meeting);\n else console.log('✓ Notes appended');\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n meetings.addCommand(notes);\n\n return meetings;\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport {\n shouldUseJson,\n outputOrganizationJson,\n outputOrganizationPretty,\n outputOrganizationsJson,\n outputOrganizationsPretty,\n} from '../utils/output.js';\nimport type { OrganizationSize } from 'exponential-sdk';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n workspace?: string;\n}\n\nconst VALID_SIZES: OrganizationSize[] = [\n '1-10', '11-50', '51-200', '201-500', '501-1000', '1000+',\n];\n\nexport function createOrganizationsCommand(): Command {\n const organizations = new Command('organizations')\n .alias('orgs')\n .description('Manage CRM organizations');\n\n organizations\n .command('list')\n .description('List organizations')\n .requiredOption('--workspace <id>', 'Workspace ID')\n .option('--search <query>', 'Search by name or description')\n .option('--industry <industry>', 'Filter by industry')\n .option('--limit <n>', 'Max results to return', parseInt)\n .option('--cursor <cursor>', 'Pagination cursor')\n .action(async (options: {\n workspace: string;\n search?: string;\n industry?: string;\n limit?: number;\n cursor?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const result = await client.organizations.list({\n workspaceId: options.workspace,\n search: options.search,\n industry: options.industry,\n limit: options.limit,\n cursor: options.cursor,\n });\n\n if (useJson) {\n outputOrganizationsJson(result.organizations, result.nextCursor);\n } else {\n outputOrganizationsPretty(result.organizations);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n organizations\n .command('get')\n .description('Get an organization by ID')\n .argument('<id>', 'Organization ID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const org = await client.organizations.get(id);\n\n if (useJson) {\n outputOrganizationJson(org);\n } else {\n outputOrganizationPretty(org);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n organizations\n .command('create')\n .description('Create a new organization')\n .requiredOption('--workspace <id>', 'Workspace ID')\n .requiredOption('--name <name>', 'Organization name')\n .option('--website-url <url>', 'Website URL')\n .option('--logo-url <url>', 'Logo URL')\n .option('--description <text>', 'Description')\n .option('--industry <industry>', 'Industry')\n .option('--size <size>', `Company size (${VALID_SIZES.join(', ')})`)\n .action(async (options: {\n workspace: string;\n name: string;\n websiteUrl?: string;\n logoUrl?: string;\n description?: string;\n industry?: string;\n size?: string;\n }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n if (options.size && !VALID_SIZES.includes(options.size as OrganizationSize)) {\n throw new Error(`Invalid size \"${options.size}\". Valid: ${VALID_SIZES.join(', ')}`);\n }\n\n const client = getClient();\n const org = await client.organizations.create({\n workspaceId: options.workspace,\n name: options.name,\n websiteUrl: options.websiteUrl,\n logoUrl: options.logoUrl,\n description: options.description,\n industry: options.industry,\n size: options.size as OrganizationSize | undefined,\n });\n\n if (useJson) {\n outputOrganizationJson(org);\n } else {\n console.log('\\n✓ Organization created successfully');\n outputOrganizationPretty(org);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return organizations;\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { createPageCommentsCommand } from './pageComments.js';\nimport { handleError } from '../utils/errors.js';\nimport { readText } from '../utils/input.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n shouldUseJson,\n outputPageJson,\n outputPagePretty,\n outputPagesJson,\n outputPagesPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nexport function createPagesCommand(): Command {\n const pages = new Command('pages').description(\n 'Manage Knowledge pages (PRDs, research, technical specs). Link one to a feature with \"features link-page\".',\n );\n\n pages\n .command('list')\n .description('List pages in a workspace')\n .option('--workspace <slug|id>', 'Workspace (defaults to the configured default)')\n .option('--search <text>', 'Filter by title/content')\n .action(\n async (options: { workspace?: string; search?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const list = await client.pages.list({\n workspaceId,\n search: options.search,\n });\n if (useJson) outputPagesJson(list);\n else outputPagesPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n pages\n .command('get <id>')\n .description('Get a page by CUID (body is Markdown)')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const page = await client.pages.get(id);\n if (useJson) outputPageJson(page);\n else outputPagePretty(page);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n pages\n .command('create')\n .description('Create a page. Body: -b text, --body-file <path>, or --body-file - for stdin.')\n .option('--workspace <slug|id>', 'Workspace (defaults to the configured default)')\n .requiredOption('-t, --title <title>', 'Page title')\n .option('-b, --body <markdown>', 'Markdown body')\n .option('--body-file <path>', 'Read the Markdown body from a file (\"-\" = stdin)')\n .action(\n async (\n options: { workspace?: string; title: string; body?: string; bodyFile?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const page = await client.pages.create({\n workspaceId,\n title: options.title,\n body: readText(options.body, options.bodyFile),\n });\n if (useJson) outputPageJson(page);\n else {\n console.log('\\n✓ Page created');\n outputPagePretty(page);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n pages\n .command('update')\n .description(\n 'Update a page. Sending a body is a Markdown-source write: the Markdown becomes canonical.',\n )\n .requiredOption('--id <id>', 'Page CUID')\n .option('-t, --title <title>', 'New title')\n .option('-b, --body <markdown>', 'New Markdown body (replaces the whole body)')\n .option('--body-file <path>', 'Read the new Markdown body from a file (\"-\" = stdin)')\n .action(\n async (\n options: { id: string; title?: string; body?: string; bodyFile?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const page = await client.pages.update({\n id: options.id,\n title: options.title,\n body: readText(options.body, options.bodyFile),\n });\n if (useJson) outputPageJson(page);\n else {\n console.log('\\n✓ Page updated');\n outputPagePretty(page);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n pages.addCommand(createPageCommentsCommand());\n\n return pages;\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n applyMentions,\n collectMention,\n MENTION_OPTION_DESCRIPTION,\n} from '../utils/mentions.js';\nimport {\n shouldUseJson,\n outputCommentJson,\n outputCommentPretty,\n outputCommentsJson,\n outputCommentsPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\n/**\n * `exponential pages comment …` — the flat discussion feed under a knowledge\n * page. Anyone the page is shared with can comment, including read-only\n * viewers; editing and deleting are author-only.\n */\nexport function createPageCommentsCommand(): Command {\n const comment = new Command('comment').description(\n 'Read and post comments on a page. Mention teammates with --mention.',\n );\n\n comment\n .command('list')\n .description('List comments on a page')\n .requiredOption('--page <id>', 'Page ID')\n .action(async (options: { page: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const comments = await client.pageComments.list(options.page);\n if (useJson) outputCommentsJson(comments);\n else outputCommentsPretty(comments);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('add')\n .description('Add a comment to a page')\n .requiredOption('--page <id>', 'Page ID')\n .requiredOption('-m, --message <text>', 'Comment body (markdown supported)')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .action(\n async (\n options: {\n page: string;\n message: string;\n mention: string[];\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const body =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const created = await client.pageComments.create({\n pageId: options.page,\n body,\n });\n if (useJson) {\n outputCommentJson(created);\n } else {\n console.log('\\n✓ Comment added');\n outputCommentPretty(created);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('update')\n .description('Update one of your own comments')\n .requiredOption('--comment-id <id>', 'Comment ID')\n .requiredOption('-m, --message <text>', 'New comment body')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .action(\n async (\n options: {\n commentId: string;\n message: string;\n mention: string[];\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const body =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const updated = await client.pageComments.update({\n commentId: options.commentId,\n body,\n });\n if (useJson) {\n outputCommentJson(updated);\n } else {\n console.log('\\n✓ Comment updated');\n outputCommentPretty(updated);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('rm')\n .description('Delete one of your own comments')\n .requiredOption('--comment-id <id>', 'Comment ID')\n .action(async (options: { commentId: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.pageComments.delete(options.commentId);\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id: options.commentId }, null, 2));\n } else {\n console.log('✓ Comment deleted');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return comment;\n}\n","import { Command } from 'commander';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n shouldUseJson,\n outputProductsJson,\n outputProductsPretty,\n outputProductJson,\n outputProductPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nexport function createProductsCommand(): Command {\n const products = new Command('products').description(\n 'Manage products. A workspace contains products; a product holds features and tickets.',\n );\n\n products\n .command('list')\n .description('List products in a workspace')\n .option('--workspace <slug|id>', 'Workspace slug or CUID (defaults to configured workspace)')\n .action(async (options: { workspace?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const list = await client.products.list(workspaceId);\n if (useJson) outputProductsJson(list);\n else outputProductsPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n products\n .command('get <slugOrId>')\n .description('Get a product by slug or CUID')\n .option('--workspace <slug|id>', 'Workspace (required when using a slug)')\n .action(async (slugOrId: string, options: { workspace?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const product = await client.products.resolve(workspaceId, slugOrId);\n if (useJson) outputProductJson(product);\n else outputProductPretty(product);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n products\n .command('create')\n .description('Create a new product')\n .requiredOption('-n, --name <name>', 'Product name')\n .requiredOption('--slug <slug>', 'Kebab-case slug (matches /^[a-z0-9-]+$/)')\n .option('-d, --description <text>', 'Description')\n .option('--icon <icon>', 'Icon shortcode')\n .option('--color <color>', 'Color')\n .option('--workspace <slug|id>', 'Workspace slug or CUID')\n .action(\n async (\n options: {\n name: string;\n slug: string;\n description?: string;\n icon?: string;\n color?: string;\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n if (!/^[a-z0-9-]+$/.test(options.slug)) {\n throw new Error(\n `Invalid slug \"${options.slug}\". Slug must be kebab-case (a-z, 0-9, -).`,\n );\n }\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const product = await client.products.create({\n workspaceId,\n name: options.name,\n slug: options.slug,\n description: options.description,\n icon: options.icon,\n color: options.color,\n });\n if (useJson) outputProductJson(product);\n else {\n console.log('\\n✓ Product created');\n outputProductPretty(product);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n return products;\n}\n","import { Command } from 'commander';\nimport type { ProjectPriority, ProjectStatus } from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n shouldUseJson,\n outputProjectJson,\n outputProjectPretty,\n outputProjectsJson,\n outputProjectsPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n workspace?: string;\n}\n\nconst PROJECT_STATUSES: ProjectStatus[] = [\n 'ACTIVE',\n 'ON_HOLD',\n 'COMPLETED',\n 'CANCELLED',\n];\n\nconst PROJECT_PRIORITIES: ProjectPriority[] = ['HIGH', 'MEDIUM', 'LOW', 'NONE'];\n\nfunction validateProjectStatus(\n value: string | undefined,\n): ProjectStatus | undefined {\n if (!value) return undefined;\n if (!(PROJECT_STATUSES as string[]).includes(value)) {\n throw new Error(\n `Invalid project status \"${value}\". Valid: ${PROJECT_STATUSES.join(', ')}`,\n );\n }\n return value as ProjectStatus;\n}\n\nfunction validateProjectPriority(\n value: string | undefined,\n): ProjectPriority | undefined {\n if (!value) return undefined;\n if (!(PROJECT_PRIORITIES as string[]).includes(value)) {\n throw new Error(\n `Invalid project priority \"${value}\". Valid: ${PROJECT_PRIORITIES.join(', ')}`,\n );\n }\n return value as ProjectPriority;\n}\n\nexport function createProjectsCommand(): Command {\n const projects = new Command('projects')\n .description('Manage projects');\n\n projects\n .command('list')\n .description('List all projects')\n .option('--workspace <slug|id>', 'Workspace slug or CUID')\n .option('--include-actions', 'Include actions in output')\n .action(async (options: { workspace?: string; includeActions?: boolean }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n // Takes a slug like every other `--workspace` in the CLI; a raw CUID\n // still resolves to itself. Omitted means \"every workspace you can see\",\n // which is what the server does with no filter — so no default is\n // applied here.\n const workspaceId = options.workspace\n ? await resolveWorkspaceId(client, options.workspace)\n : undefined;\n const projects = await client.projects.list({\n workspaceId,\n includeActions: options.includeActions,\n });\n\n if (useJson) {\n outputProjectsJson(projects);\n } else {\n outputProjectsPretty(projects);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n projects\n .command('get <id>')\n .description(\n 'Get one project with its objectives, key results, DRI and actions — none ' +\n 'of which `projects list` carries. Accepts a CUID, a slug, or the ' +\n 'slug-cuid form from app URLs.',\n )\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const project = await client.projects.get(id);\n if (useJson) outputProjectJson(project);\n else outputProjectPretty(project);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n projects\n .command('update')\n .description(\n 'Update a project. Only the fields you pass are written; the rest are read ' +\n 'back from the project and re-sent unchanged.',\n )\n .requiredOption('--id <cuid>', 'Project CUID')\n .option('-n, --name <name>', 'New name')\n .option('-d, --description <text>', 'New description')\n .option('--status <status>', `Status: ${PROJECT_STATUSES.join(', ')}`)\n .option('--priority <priority>', `Priority: ${PROJECT_PRIORITIES.join(', ')}`)\n .option('--product <cuid|none>', 'Product to file the project under (\"none\" to unlink)')\n .option('--dri <userId|none>', 'Directly responsible individual (\"none\" to clear)')\n .action(\n async (\n options: {\n id: string;\n name?: string;\n description?: string;\n status?: string;\n priority?: string;\n product?: string;\n dri?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateProjectStatus(options.status);\n const priority = validateProjectPriority(options.priority);\n const client = getClient();\n const updated = await client.projects.update({\n id: options.id,\n name: options.name,\n description: options.description,\n status,\n priority,\n productId:\n options.product === undefined\n ? undefined\n : options.product === 'none'\n ? null\n : options.product,\n driId:\n options.dri === undefined\n ? undefined\n : options.dri === 'none'\n ? null\n : options.dri,\n });\n if (useJson) outputProjectJson(updated);\n else {\n console.log('\\n✓ Project updated');\n outputProjectPretty(updated);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n projects\n .command('delete')\n .description(\n 'Delete a project. Refuses while it still has actions or is linked to an ' +\n 'objective or key result, unless --force.',\n )\n .requiredOption('--id <cuid>', 'Project CUID')\n .option('--force', 'Delete anyway, taking the actions and links with it')\n .action(async (options: { id: string; force?: boolean }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const project = await client.projects.get(options.id);\n const actions = project.actions ?? [];\n const goals = project.goals ?? [];\n const keyResults = project.keyResults ?? [];\n\n const blockers = [\n actions.length ? `${actions.length} action(s)` : null,\n goals.length ? `${goals.length} objective link(s)` : null,\n keyResults.length ? `${keyResults.length} key result link(s)` : null,\n ].filter(Boolean) as string[];\n\n if (blockers.length > 0 && !options.force) {\n const payload = {\n deleted: false,\n id: project.id,\n reason: `has ${blockers.join(', ')}`,\n actionCount: actions.length,\n goals: goals.map((g) => ({ id: g.id, title: g.title })),\n keyResults: keyResults.map((k) => ({ id: k.keyResultId })),\n };\n if (useJson) console.log(JSON.stringify(payload, null, 2));\n else {\n console.error(\n `Project \"${project.name}\" has ${blockers.join(', ')}.\\n` +\n 'Re-run with --force to delete it anyway.',\n );\n }\n process.exitCode = 1;\n return;\n }\n\n await client.projects.delete(project.id);\n const payload = {\n deleted: true,\n id: project.id,\n actionsDeleted: actions.length,\n };\n if (useJson) console.log(JSON.stringify(payload, null, 2));\n else {\n console.log('✓ Project deleted');\n if (actions.length) {\n console.log(` ${actions.length} action(s) went with it`);\n }\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return projects;\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { shouldUseJson } from '../utils/output.js';\nimport type { SearchResult, Workspace } from 'exponential-sdk';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\ninterface SearchOptions {\n workspace?: string;\n limit?: string;\n}\n\nconst TYPE_LABELS: Record<string, string> = {\n workspace: 'Workspaces',\n project: 'Projects',\n action: 'Actions',\n goal: 'Goals',\n keyResult: 'Key Results',\n outcome: 'Outcomes',\n ticket: 'Tickets',\n feature: 'Features',\n epic: 'Epics',\n page: 'Pages',\n meeting: 'Meetings',\n contact: 'Contacts',\n organization: 'Organizations',\n product: 'Products',\n};\n\nexport function createSearchCommand(): Command {\n const search = new Command('search')\n .description(\n \"Global search across projects, actions, goals, workspaces and more — same coverage as the app's Cmd+K palette\",\n )\n .argument('<query>', 'Text to search for')\n .option('-w, --workspace <slug>', 'Restrict results to one workspace (slug or ID)')\n .option('-l, --limit <n>', 'Max results per entity type (1-25, default 10)')\n .action(async (query: string, options: SearchOptions, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n\n let workspaceId: string | undefined;\n if (options.workspace) {\n const workspaces = await client.workspaces.list();\n const match = workspaces.find(\n (w: Workspace) => w.slug === options.workspace || w.id === options.workspace,\n );\n if (!match) {\n console.error(chalk.red(`Workspace \"${options.workspace}\" not found.`));\n console.log(chalk.gray('Available workspaces:'));\n workspaces.forEach((w: Workspace) => {\n console.log(chalk.gray(` - ${w.slug} (${w.name})`));\n });\n process.exit(1);\n }\n workspaceId = match.id;\n }\n\n const limit = options.limit ? Number(options.limit) : undefined;\n const result = await client.search.global({ query, workspaceId, limit });\n\n if (useJson) {\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n if (result.results.length === 0) {\n console.log(chalk.gray(`No matches for \"${result.query}\".`));\n return;\n }\n\n const byType = new Map<string, SearchResult[]>();\n for (const r of result.results) {\n const bucket = byType.get(r.type) ?? [];\n bucket.push(r);\n byType.set(r.type, bucket);\n }\n\n for (const [type, rows] of byType) {\n console.log(chalk.bold(`\\n${TYPE_LABELS[type] ?? type}`));\n for (const row of rows) {\n const parts = [chalk.white(row.title)];\n if (row.subtitle) parts.push(chalk.gray(row.subtitle));\n if (row.workspace) parts.push(chalk.cyan(`@${row.workspace.slug}`));\n console.log(` ${parts.join(chalk.gray(' · '))}`);\n console.log(chalk.gray(` ${row.id}${row.url ? ` ${row.url}` : ''}`));\n }\n }\n console.log();\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return search;\n}\n","import { Command } from 'commander';\nimport type { TicketStatus, TicketType } from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveProductId, resolveWorkspaceId } from '../utils/resolve.js';\nimport { resolveLabelIds } from './labels.js';\nimport {\n applyMentions,\n collectMention,\n MENTION_OPTION_DESCRIPTION,\n} from '../utils/mentions.js';\n\nfunction collectRepeatable(value: string, previous: string[]): string[] {\n return [...previous, value];\n}\nimport {\n shouldUseJson,\n outputCommentJson,\n outputCommentPretty,\n outputCommentsJson,\n outputCommentsPretty,\n outputTicketJson,\n outputTicketPretty,\n outputTicketsJson,\n outputTicketsPretty,\n outputActionJson,\n outputActionPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nconst TICKET_STATUSES: TicketStatus[] = [\n 'BACKLOG',\n 'NEEDS_REFINEMENT',\n 'READY_TO_PLAN',\n 'COMMITTED',\n 'IN_PROGRESS',\n 'BLOCKED',\n 'QA',\n 'DONE',\n 'DEPLOYED',\n 'ARCHIVED',\n];\n\nconst TICKET_TYPES: TicketType[] = [\n 'BUG',\n 'FEATURE',\n 'CHORE',\n 'IMPROVEMENT',\n 'SPIKE',\n 'RESEARCH',\n];\n\nfunction validateTicketStatus(value: string | undefined): TicketStatus | undefined {\n if (!value) return undefined;\n if (!(TICKET_STATUSES as string[]).includes(value)) {\n throw new Error(\n `Invalid ticket status \"${value}\". Valid: ${TICKET_STATUSES.join(', ')}`,\n );\n }\n return value as TicketStatus;\n}\n\nfunction validateTicketType(value: string | undefined): TicketType | undefined {\n if (!value) return undefined;\n if (!(TICKET_TYPES as string[]).includes(value)) {\n throw new Error(\n `Invalid ticket type \"${value}\". Valid: ${TICKET_TYPES.join(', ')}`,\n );\n }\n return value as TicketType;\n}\n\nexport function createTicketsCommand(): Command {\n const tickets = new Command('tickets').description(\n 'Manage product backlog tickets. Tickets live under a product, link to features/epics, depend on each other, and can be implemented via actions.',\n );\n\n tickets\n .command('list')\n .description(\n 'List tickets in a product, or workspace-wide when --pr or --branch is supplied',\n )\n .option(\n '--product <slug|id>',\n 'Product slug or CUID (required unless --pr or --branch is supplied)',\n )\n .option('--workspace <slug|id>', 'Workspace (required when --product is a slug)')\n .option('--status <status>', `Filter by status: ${TICKET_STATUSES.join(', ')}`)\n .option('--type <type>', `Filter by type: ${TICKET_TYPES.join(', ')}`)\n .option('--feature <id>', 'Filter by feature CUID')\n .option('--epic <id>', 'Filter by epic CUID')\n .option('--assignee <id>', 'Filter by assignee user ID')\n .option(\n '--pr <url>',\n 'Workspace-wide lookup by Ticket.prUrl (exact match). Makes --product optional.',\n )\n .option(\n '--branch <name>',\n 'Workspace-wide lookup by Ticket.branchName (exact match). Makes --product optional.',\n )\n .option(\n '--label <slug-or-id>',\n 'Filter to tickets carrying this label (repeatable; AND semantics)',\n collectRepeatable,\n [] as string[],\n )\n .action(\n async (\n options: {\n product?: string;\n workspace?: string;\n status?: string;\n type?: string;\n feature?: string;\n epic?: string;\n assignee?: string;\n pr?: string;\n branch?: string;\n label: string[];\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateTicketStatus(options.status);\n const type = validateTicketType(options.type);\n const hasWorkspaceFilter = Boolean(options.pr || options.branch);\n if (!hasWorkspaceFilter && !options.product) {\n throw new Error(\n '--product is required unless --pr or --branch is supplied',\n );\n }\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const filters = {\n status,\n type,\n featureId: options.feature,\n epicId: options.epic,\n assigneeId: options.assignee,\n prUrl: options.pr,\n branchName: options.branch,\n };\n\n // `product.ticket.list` is product-scoped on the server — there is no\n // workspace-wide ticket query — so a --pr/--branch lookup with no\n // --product sweeps every product in the workspace and merges. Without\n // this the flag combination sent productId: undefined and the server\n // rejected it outright. A PR URL or branch name identifies at most a\n // handful of tickets, so the fan-out stays small.\n let list;\n if (options.product) {\n const productId = await resolveProductId(\n client,\n workspaceId,\n options.product,\n );\n list = await client.tickets.list({ productId, ...filters });\n } else {\n const products = await client.products.list(workspaceId);\n const settled = await Promise.allSettled(\n products.map((p) => client.tickets.list({ productId: p.id, ...filters })),\n );\n list = settled.flatMap((r) => (r.status === 'fulfilled' ? r.value : []));\n // A product the caller can't read must not blank the whole lookup,\n // but a silently short result is worse than a noisy one.\n settled.forEach((r, i) => {\n if (r.status !== 'rejected') return;\n const reason =\n r.reason instanceof Error ? r.reason.message : String(r.reason);\n console.error(`Warning: skipped product ${products[i]!.slug}: ${reason}`);\n });\n }\n let filtered = list;\n if (options.label.length > 0) {\n const labelIds = new Set(\n await resolveLabelIds(client, workspaceId, options.label),\n );\n const ticketLabelSets = await Promise.all(\n list.map((t) =>\n client.labels\n .listForEntity({ entityType: 'ticket', entityId: t.id })\n .then((tags) => new Set(tags.map((tag) => tag.id))),\n ),\n );\n filtered = list.filter((_t, idx) => {\n const tagSet = ticketLabelSets[idx];\n if (tagSet === undefined) return false;\n for (const id of labelIds) {\n if (!tagSet.has(id)) return false;\n }\n return true;\n });\n }\n if (useJson) outputTicketsJson(filtered);\n else outputTicketsPretty(filtered);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n tickets\n .command('get <id>')\n .description('Show a ticket with dependencies, actions, and comments')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const ticket = await client.tickets.get(id);\n if (useJson) outputTicketJson(ticket);\n else outputTicketPretty(ticket);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n tickets\n .command('show <id>')\n .description('Alias for `tickets get`')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const ticket = await client.tickets.get(id);\n if (useJson) outputTicketJson(ticket);\n else outputTicketPretty(ticket);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n tickets\n .command('create')\n .description('Create a new ticket in a product')\n .requiredOption('--product <slug|id>', 'Product slug or CUID')\n .requiredOption('-t, --title <title>', 'Ticket title')\n .option('-b, --body <text>', 'Body (markdown supported)')\n .option('--type <type>', `Ticket type: ${TICKET_TYPES.join(', ')}`)\n .option('--status <status>', `Initial status: ${TICKET_STATUSES.join(', ')}`)\n .option('--priority <n>', 'Priority 0-4 (lower = higher)', parseInt)\n .option('--points <n>', 'Story points', parseFloat)\n .option('--feature <id>', 'Feature CUID to attach to')\n .option('--scope <id>', 'Feature scope CUID to attach to (requires --feature)')\n .option('--epic <id>', 'Epic CUID to attach to')\n .option('--cycle <id>', 'Cycle CUID to assign to')\n .option('--assignee <id>', 'Assignee user ID')\n .option('--branch <name>', 'Branch name')\n .option('--pr <url>', 'Pull request URL')\n .option('--workspace <slug|id>', 'Workspace (required when --product is a slug)')\n .option(\n '--label <slug-or-id>',\n 'Label to attach (repeatable)',\n collectRepeatable,\n [] as string[],\n )\n .action(\n async (\n options: {\n product: string;\n title: string;\n body?: string;\n type?: string;\n status?: string;\n priority?: number;\n points?: number;\n feature?: string;\n scope?: string;\n epic?: string;\n cycle?: string;\n assignee?: string;\n branch?: string;\n pr?: string;\n workspace?: string;\n label: string[];\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateTicketStatus(options.status);\n const type = validateTicketType(options.type);\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const productId = await resolveProductId(\n client,\n workspaceId,\n options.product,\n );\n const ticket = await client.tickets.create({\n productId,\n title: options.title,\n body: options.body,\n type,\n status,\n priority: options.priority,\n points: options.points,\n featureId: options.feature,\n scopeId: options.scope,\n epicId: options.epic,\n cycleId: options.cycle,\n assigneeId: options.assignee,\n branchName: options.branch,\n prUrl: options.pr,\n });\n if (options.label.length > 0) {\n const tagIds = await resolveLabelIds(client, workspaceId, options.label);\n await client.labels.setEntityTags({\n entityType: 'ticket',\n entityId: ticket.id,\n tagIds,\n });\n }\n if (useJson) outputTicketJson(ticket);\n else {\n console.log('\\n✓ Ticket created');\n outputTicketPretty(ticket);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n tickets\n .command('update')\n .description('Update an existing ticket')\n .requiredOption('--id <id>', 'Ticket CUID')\n .option('-t, --title <title>', 'New title')\n .option('-b, --body <text>', 'New body')\n .option('--type <type>', `Type: ${TICKET_TYPES.join(', ')}`)\n .option('--status <status>', `Status: ${TICKET_STATUSES.join(', ')}`)\n .option('--priority <n>', 'Priority 0-4 (or \"null\" to clear)')\n .option('--points <n>', 'Story points (or \"null\" to clear)')\n .option('--feature <id>', 'Feature CUID (or \"null\" to detach)')\n .option('--epic <id>', 'Epic CUID (or \"null\" to detach)')\n .option('--cycle <id>', 'Cycle CUID (or \"null\" to detach)')\n .option('--assignee <id>', 'Assignee user ID (or \"null\" to unassign)')\n .option('--branch <name>', 'Branch name (or \"null\")')\n .option('--pr <url>', 'PR URL (or \"null\")')\n .option(\n '--add-label <slug-or-id>',\n 'Label to attach to this ticket (repeatable)',\n collectRepeatable,\n [] as string[],\n )\n .option(\n '--remove-label <slug-or-id>',\n 'Label to detach from this ticket (repeatable)',\n collectRepeatable,\n [] as string[],\n )\n .action(\n async (\n options: {\n id: string;\n title?: string;\n body?: string;\n type?: string;\n status?: string;\n priority?: string;\n points?: string;\n feature?: string;\n epic?: string;\n cycle?: string;\n assignee?: string;\n branch?: string;\n pr?: string;\n addLabel: string[];\n removeLabel: string[];\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const parseNullableInt = (v: string | undefined): number | null | undefined => {\n if (v === undefined) return undefined;\n if (v === 'null') return null;\n const n = parseInt(v, 10);\n if (isNaN(n)) throw new Error(`Invalid number: ${v}`);\n return n;\n };\n const parseNullableFloat = (v: string | undefined): number | null | undefined => {\n if (v === undefined) return undefined;\n if (v === 'null') return null;\n const n = parseFloat(v);\n if (isNaN(n)) throw new Error(`Invalid number: ${v}`);\n return n;\n };\n const parseNullableString = (v: string | undefined): string | null | undefined => {\n if (v === undefined) return undefined;\n if (v === 'null') return null;\n return v;\n };\n\n const status = validateTicketStatus(options.status);\n const type = validateTicketType(options.type);\n const client = getClient();\n const ticket = await client.tickets.update({\n id: options.id,\n title: options.title,\n body: options.body,\n type,\n status,\n priority: parseNullableInt(options.priority),\n points: parseNullableFloat(options.points),\n featureId: parseNullableString(options.feature),\n epicId: parseNullableString(options.epic),\n cycleId: parseNullableString(options.cycle),\n assigneeId: parseNullableString(options.assignee),\n branchName: parseNullableString(options.branch),\n prUrl: parseNullableString(options.pr),\n });\n if (options.addLabel.length > 0 || options.removeLabel.length > 0) {\n const current = await client.labels.listForEntity({\n entityType: 'ticket',\n entityId: options.id,\n });\n const currentIds = new Set(current.map((t) => t.id));\n const addIds = await resolveLabelIds(client, undefined, options.addLabel);\n const removeIds = await resolveLabelIds(client, undefined, options.removeLabel);\n for (const id of addIds) currentIds.add(id);\n for (const id of removeIds) currentIds.delete(id);\n await client.labels.setEntityTags({\n entityType: 'ticket',\n entityId: options.id,\n tagIds: [...currentIds],\n });\n }\n if (useJson) outputTicketJson(ticket);\n else {\n console.log('\\n✓ Ticket updated');\n outputTicketPretty(ticket);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n tickets\n .command('delete <id>')\n .description('Delete a ticket')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.tickets.delete(id);\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id }, null, 2));\n } else {\n console.log('\\n✓ Ticket deleted');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n tickets\n .command('block <ticket>')\n .description('Mark <ticket> as blocked by another ticket')\n .requiredOption('--by <id>', 'Ticket CUID that must complete first')\n .action(\n async (ticket: string, options: { by: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const dep = await client.tickets.addDependency(ticket, options.by);\n if (useJson) {\n console.log(JSON.stringify(dep, null, 2));\n } else {\n const depId = dep.dependsOn.shortId ?? (dep.dependsOn.number != null ? `#${dep.dependsOn.number}` : dep.dependsOn.id);\n console.log(`\\n✓ Ticket ${ticket} now depends on ${depId} ${dep.dependsOn.title}`);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n tickets\n .command('unblock <ticket>')\n .description('Remove a blocking dependency from <ticket>')\n .requiredOption('--by <id>', 'The ticket CUID that was blocking')\n .action(\n async (ticket: string, options: { by: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.tickets.removeDependency(ticket, options.by);\n if (useJson) {\n console.log(JSON.stringify({ ticketId: ticket, removedBlocker: options.by }, null, 2));\n } else {\n console.log(`\\n✓ Dependency removed: ${ticket} no longer blocked by ${options.by}`);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n tickets\n .command('link-action')\n .description('Attach an existing action to a ticket')\n .requiredOption('--id <id>', 'Ticket CUID')\n .requiredOption('--action <id>', 'Action CUID')\n .action(async (options: { id: string; action: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const action = await client.tickets.linkAction(options.id, options.action);\n if (useJson) outputActionJson(action);\n else {\n console.log('\\n✓ Action linked to ticket');\n outputActionPretty(action);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n tickets\n .command('unlink-action')\n .description('Detach an action from whatever ticket it is on')\n .requiredOption('--action <id>', 'Action CUID')\n .action(async (options: { action: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const action = await client.tickets.unlinkAction(options.action);\n if (useJson) outputActionJson(action);\n else {\n console.log('\\n✓ Action unlinked');\n outputActionPretty(action);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n const comment = new Command('comment').description('Manage comments on a ticket');\n\n comment\n .command('list')\n .description('List comments on a ticket')\n .requiredOption('--id <id>', 'Ticket CUID')\n .action(async (options: { id: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n // Ticket comments ride along on the detail fetch — there is no\n // standalone list procedure server-side.\n const ticket = await client.tickets.get(options.id);\n const comments = ticket.comments ?? [];\n if (useJson) outputCommentsJson(comments);\n else outputCommentsPretty(comments);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('add')\n .description('Add a comment to a ticket')\n .requiredOption('--id <id>', 'Ticket CUID')\n .requiredOption('-m, --message <text>', 'Comment content (markdown supported)')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .action(\n async (\n options: {\n id: string;\n message: string;\n mention: string[];\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const content =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const created = await client.tickets.addComment({\n ticketId: options.id,\n content,\n });\n if (useJson) outputCommentJson(created);\n else {\n console.log('\\n✓ Comment added');\n outputCommentPretty(created);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('update')\n .description('Update one of your own ticket comments')\n .requiredOption('--comment-id <id>', 'Comment ID')\n .requiredOption('-m, --message <text>', 'New comment content')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .action(\n async (\n options: {\n commentId: string;\n message: string;\n mention: string[];\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const content =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const updated = await client.tickets.updateComment({\n id: options.commentId,\n content,\n });\n if (useJson) outputCommentJson(updated);\n else {\n console.log('\\n✓ Comment updated');\n outputCommentPretty(updated);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('delete')\n .description('Delete one of your own ticket comments')\n .requiredOption('--comment-id <id>', 'Comment ID')\n .action(async (options: { commentId: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.tickets.deleteComment(options.commentId);\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id: options.commentId }, null, 2));\n } else {\n console.log('\\n✓ Comment deleted');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n tickets.addCommand(comment);\n\n return tickets;\n}\n","import { Command } from 'commander';\nimport type { TimeEntrySource, TimeEntryStatus, TimeLogInput } from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { readText, parseDate } from '../utils/input.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n shouldUseJson,\n outputTimeLogJson,\n outputTimeLogPretty,\n outputTimeEntriesJson,\n outputTimeEntriesPretty,\n outputTimeBatchJson,\n outputTimeBatchPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\ntype LogSource = Exclude<TimeEntrySource, 'plugin'>;\nconst SOURCES: LogSource[] = ['manual', 'claude-desktop', 'agent-run'];\nconst STATUSES: TimeEntryStatus[] = ['PROPOSED', 'CONFIRMED'];\n\n/**\n * The thing nobody guesses: with an external-agent key an entry is OWNED by\n * the agent's owner, the agent is recorded as author, and it is always\n * PROPOSED — it shows on the owner's /time with a \"proposed\" chip and stays\n * out of the Action's spent time until the owner confirms the day (ADR-0061).\n */\nconst OWNERSHIP_NOTE =\n 'Run with an external-agent key, the entry belongs to the agent\\'s OWNER and is always PROPOSED; a personal token logs your own time, CONFIRMED by default.';\n\nfunction parseSource(value: string): LogSource {\n const lower = value.toLowerCase() as LogSource;\n if (!SOURCES.includes(lower)) {\n throw new Error(`Invalid source \"${value}\". Use one of: ${SOURCES.join(', ')}.`);\n }\n return lower;\n}\n\nfunction parseStatus(value: string): TimeEntryStatus {\n const upper = value.toUpperCase() as TimeEntryStatus;\n if (!STATUSES.includes(upper)) {\n throw new Error(`Invalid status \"${value}\". Use one of: ${STATUSES.join(', ')}.`);\n }\n return upper;\n}\n\n/** One entry in a `--from-file` batch, in JSON. `from`/`to`/`ref`/`action` mirror the flags. */\ninterface BatchItem {\n actionId?: unknown;\n action?: unknown;\n startedAt?: unknown;\n from?: unknown;\n endedAt?: unknown;\n to?: unknown;\n source?: unknown;\n status?: unknown;\n sourceRef?: unknown;\n ref?: unknown;\n note?: unknown;\n}\n\n/** Every key a `--from-file` entry may carry; anything else is a typo. */\nconst BATCH_ITEM_KEYS = new Set<keyof BatchItem>([\n 'actionId',\n 'action',\n 'startedAt',\n 'from',\n 'endedAt',\n 'to',\n 'source',\n 'status',\n 'sourceRef',\n 'ref',\n 'note',\n]) as Set<string>;\n\nexport function parseBatchFile(raw: string): BatchItem[] {\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (error) {\n throw new Error(\n `--from-file must be JSON: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n const items = Array.isArray(parsed)\n ? parsed\n : typeof parsed === 'object' &&\n parsed !== null &&\n Array.isArray((parsed as { entries?: unknown }).entries)\n ? (parsed as { entries: unknown[] }).entries\n : null;\n if (!items) {\n throw new Error('--from-file must contain a JSON array of entries, or {\"entries\": [...]}.');\n }\n if (items.length === 0) {\n throw new Error('--from-file contained no entries.');\n }\n return items.map((item, i) => {\n if (typeof item !== 'object' || item === null) {\n throw new Error(`Entry[${i}] is not an object.`);\n }\n const entry = item as BatchItem;\n // These files are generated by the Daily worklog. A key this reader\n // doesn't know is a typo or a wrong field name, and dropping it silently\n // would log the entry without the data its author meant to attach.\n const unknown = Object.keys(entry).filter((key) => !BATCH_ITEM_KEYS.has(key));\n if (unknown.length > 0) {\n throw new Error(\n `Entry[${i}] has unknown field(s): ${unknown.join(', ')}. Accepted: ${[...BATCH_ITEM_KEYS].join(', ')}.`,\n );\n }\n return entry;\n });\n}\n\nfunction optionalString(value: unknown, label: string, index: number): string | undefined {\n if (value === undefined || value === null) return undefined;\n if (typeof value !== 'string') throw new Error(`Entry[${index}].${label} must be a string.`);\n return value;\n}\n\n/** Turn a batch entry into the SDK input, with the flags as defaults. */\nexport function batchItemToInput(\n item: BatchItem,\n index: number,\n defaults: Partial<TimeLogInput>,\n): TimeLogInput {\n const actionId = optionalString(item.actionId ?? item.action, 'actionId', index) ?? defaults.actionId;\n const from = optionalString(item.startedAt ?? item.from, 'startedAt', index);\n const to = optionalString(item.endedAt ?? item.to, 'endedAt', index);\n const startedAt = from !== undefined ? parseDate(from) : defaults.startedAt;\n const endedAt = to !== undefined ? parseDate(to) : defaults.endedAt;\n if (!actionId) throw new Error(`Entry[${index}] needs an \"actionId\" (or the --action flag).`);\n if (!startedAt || !endedAt) {\n throw new Error(`Entry[${index}] needs \"startedAt\" and \"endedAt\" (or --from and --to).`);\n }\n const source = optionalString(item.source, 'source', index);\n const status = optionalString(item.status, 'status', index);\n return {\n actionId,\n startedAt,\n endedAt,\n source: source !== undefined ? parseSource(source) : defaults.source,\n status: status !== undefined ? parseStatus(status) : defaults.status,\n sourceRef: optionalString(item.sourceRef ?? item.ref, 'sourceRef', index) ?? defaults.sourceRef,\n note: optionalString(item.note, 'note', index) ?? defaults.note,\n };\n}\n\nexport function createTimeCommand(): Command {\n const time = new Command('time').description(\n `Time entries — log the day's work and list it. ${OWNERSHIP_NOTE}`,\n );\n\n time\n .command('log')\n .description(\n [\n 'Log one completed entry with explicit bounds; the running Timer is never touched.',\n 'With --ref the write is idempotent per owner: a re-run updates a PROPOSED entry and leaves a CONFIRMED one alone.',\n 'Bulk: --from-file <path|-> takes a JSON array of entries; the other flags become its defaults.',\n OWNERSHIP_NOTE,\n ].join(' '),\n )\n .option('-a, --action <id>', 'Action CUID the time was spent on')\n .option('--from <iso>', 'Start, e.g. 2026-09-11T09:22')\n .option('--to <iso>', 'End, e.g. 2026-09-11T10:30')\n .option('--source <source>', `${SOURCES.join(', ')} (default: manual)`)\n .option('--status <status>', 'PROPOSED or CONFIRMED (ignored under an agent key: always PROPOSED)')\n .option('--ref <sourceRef>', 'Idempotency key, e.g. claude-session:<sessionId>#<segment>')\n .option('--note <text>', 'One line shown in the day view and list row')\n .option('--from-file <path>', 'Bulk log from a JSON array of entries (\"-\" = stdin)')\n .action(\n async (\n options: {\n action?: string;\n from?: string;\n to?: string;\n source?: string;\n status?: string;\n ref?: string;\n note?: string;\n fromFile?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const defaults: Partial<TimeLogInput> = {\n actionId: options.action,\n startedAt: parseDate(options.from),\n endedAt: parseDate(options.to),\n source: options.source ? parseSource(options.source) : undefined,\n status: options.status ? parseStatus(options.status) : undefined,\n sourceRef: options.ref,\n note: options.note,\n };\n const client = getClient();\n\n if (options.fromFile) {\n if (options.ref !== undefined) {\n throw new Error(\n '--ref is per-entry: a shared sourceRef would make every entry overwrite the last. Put \"sourceRef\" on each entry in --from-file instead.',\n );\n }\n const items = parseBatchFile(readText(undefined, options.fromFile)!);\n const inputs: Array<TimeLogInput | Error> = items.map((item, i) => {\n try {\n return batchItemToInput(item, i, defaults);\n } catch (error) {\n return error instanceof Error ? error : new Error(String(error));\n }\n });\n // Sequential on purpose: a partial failure has to name which\n // entry failed rather than collapsing into one rejected batch.\n const results = [];\n for (const [index, input] of inputs.entries()) {\n if (input instanceof Error) {\n results.push({ index, success: false, error: input.message });\n continue;\n }\n const [result] = await client.time.logBatch([input]);\n results.push({ ...result!, index });\n }\n // Anything short of \"everything was logged\" is a non-zero exit,\n // so a pipeline can't mistake a partial write for success.\n if (results.some((r) => !r.success)) process.exitCode = 1;\n if (useJson) outputTimeBatchJson(results);\n else outputTimeBatchPretty(results);\n return;\n }\n\n if (!defaults.actionId) throw new Error('Pass --action <id>, or --from-file <path|-> for a batch.');\n if (!defaults.startedAt || !defaults.endedAt) throw new Error('Pass both --from <iso> and --to <iso>.');\n if (defaults.endedAt.getTime() <= defaults.startedAt.getTime()) {\n throw new Error('--to must be after --from.');\n }\n const result = await client.time.log(defaults as TimeLogInput);\n if (useJson) outputTimeLogJson(result);\n else outputTimeLogPretty(result);\n } catch (error) {\n handleError(error);\n }\n },\n );\n\n time\n .command('list')\n .description(\"One day's entries for the signed-in user, oldest first, each with its PROPOSED/CONFIRMED status\")\n .requiredOption('-d, --date <YYYY-MM-DD>', 'The day (local time)')\n .option('-w, --workspace <slug|id>', 'Only entries in this workspace (default: all)')\n .option('--proposed', 'Only PROPOSED entries')\n .action(async (options: { date: string; workspace?: string; proposed?: boolean }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n if (!/^\\d{4}-\\d{2}-\\d{2}$/.test(options.date)) {\n throw new Error(`--date must be YYYY-MM-DD, got \"${options.date}\".`);\n }\n const client = getClient();\n const workspaceId = options.workspace\n ? await resolveWorkspaceId(client, options.workspace)\n : undefined;\n let entries = await client.time.list(options.date, workspaceId);\n if (options.proposed) entries = entries.filter((e) => e.status === 'PROPOSED');\n if (useJson) outputTimeEntriesJson(entries, options.date);\n else outputTimeEntriesPretty(entries, options.date);\n } catch (error) {\n handleError(error);\n }\n });\n\n return time;\n}\n","import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { getClient } from '../client/index.js';\nimport { getConfig, setConfig } from '../config/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n shouldUseJson,\n outputWorkspacesJson,\n outputWorkspacesPretty,\n} from '../utils/output.js';\nimport type { Workspace } from 'exponential-sdk';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\nexport function createWorkspacesCommand(): Command {\n const workspaces = new Command('workspaces')\n .description('Manage workspaces');\n\n workspaces\n .command('list')\n .description('List all workspaces')\n .action(async (_options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n\n try {\n const client = getClient();\n const workspaces = await client.workspaces.list();\n\n if (useJson) {\n outputWorkspacesJson(workspaces);\n } else {\n const config = getConfig();\n outputWorkspacesPretty(workspaces);\n\n if (config.defaultWorkspaceSlug) {\n console.log(chalk.gray(`Default workspace: ${config.defaultWorkspaceSlug}`));\n }\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n workspaces\n .command('set-default <slug>')\n .description('Set the default workspace')\n .action(async (slug: string) => {\n try {\n const client = getClient();\n const workspaces = await client.workspaces.list();\n\n const workspace = workspaces.find((w: Workspace) => w.slug === slug);\n\n if (!workspace) {\n console.error(chalk.red(`Workspace with slug \"${slug}\" not found.`));\n console.log(chalk.gray('Available workspaces:'));\n workspaces.forEach((w: Workspace) => {\n console.log(chalk.gray(` - ${w.slug} (${w.name})`));\n });\n process.exit(1);\n }\n\n setConfig({\n defaultWorkspaceId: workspace.id,\n defaultWorkspaceSlug: workspace.slug,\n });\n\n console.log(chalk.green(`Default workspace set to: ${workspace.name} (${workspace.slug})`));\n } catch (error) {\n handleError(error);\n }\n });\n\n workspaces\n .command('members')\n .description(\n 'List workspace members. Each row carries the exact @[Name](id) markup to paste into a comment to mention that person.',\n )\n .option('--workspace <slug|id>', 'Workspace (defaults to your default workspace)')\n .option('--search <text>', 'Filter by name or email')\n .action(\n async (options: { workspace?: string; search?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n let members = await client.workspaces.listMembers(workspaceId);\n\n if (options.search) {\n const needle = options.search.toLowerCase();\n members = members.filter(\n (m) =>\n m.name?.toLowerCase().includes(needle) ||\n m.email?.toLowerCase().includes(needle),\n );\n }\n\n if (useJson) {\n console.log(\n JSON.stringify({ members, total: members.length }, null, 2),\n );\n return;\n }\n\n if (members.length === 0) {\n console.log(chalk.gray('No members found.'));\n return;\n }\n\n console.log(chalk.bold(`\\nMembers (${members.length})\\n`));\n for (const m of members) {\n const label = m.name ?? m.email ?? m.id;\n // `role` is always the workspace role; a team member's team role is\n // reported separately so it is never mistaken for workspace authority.\n const via = m.source === 'team'\n ? chalk.gray(\n ` via team${m.teams.length ? `: ${m.teams.map((t) => t.name).join(', ')}` : ''}` +\n (m.teamRole ? ` [team ${m.teamRole}]` : ''),\n )\n : '';\n console.log(`${chalk.bold(label)} ${chalk.gray(`(${m.role})`)}${via}`);\n if (m.email) console.log(chalk.gray(` ${m.email}`));\n console.log(chalk.gray(` mention: ${m.mentionSyntax}`));\n console.log();\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n return workspaces;\n}\n","import { Command } from 'commander';\nimport type {\n GoalStatus,\n GoalWritableStatus,\n KeyResultStatus,\n KeyResultUnit,\n ObjectiveWithKeyResults,\n Workspace,\n} from 'exponential-sdk';\nimport { getClient } from '../client/index.js';\nimport { handleError } from '../utils/errors.js';\nimport { resolveWorkspace, resolveWorkspaceId } from '../utils/resolve.js';\nimport {\n applyMentions,\n collectMention,\n MENTION_OPTION_DESCRIPTION,\n} from '../utils/mentions.js';\nimport {\n shouldUseJson,\n outputCommentJson,\n outputCommentPretty,\n outputCommentsJson,\n outputCommentsPretty,\n outputGoalJson,\n outputGoalPretty,\n outputGoalsJson,\n outputGoalsPretty,\n outputGoalTreeJson,\n outputGoalTreePretty,\n outputGoalPeriodsJson,\n outputGoalPeriodsPretty,\n outputGoalStatsJson,\n outputGoalStatsPretty,\n outputKeyResultJson,\n outputKeyResultPretty,\n outputKeyResultsJson,\n outputKeyResultsPretty,\n outputCheckInJson,\n outputCheckInPretty,\n outputObjectivesJson,\n outputObjectivesPretty,\n} from '../utils/output.js';\n\ninterface GlobalOptions {\n json?: boolean;\n pretty?: boolean;\n}\n\n/** Statuses `goals set-status` / `goals close` accept. */\nconst GOAL_STATUSES: GoalStatus[] = [\n 'planned',\n 'active',\n 'completed',\n 'archived',\n 'on-hold',\n];\n\n/**\n * Statuses `goals create` / `goals update` accept. `on-hold` is deliberately\n * absent: only `updateGoalStatus` takes it, which is what `set-status` calls.\n */\nconst GOAL_WRITABLE_STATUSES: GoalWritableStatus[] = [\n 'planned',\n 'active',\n 'completed',\n 'archived',\n];\n\nconst KEY_RESULT_STATUSES: KeyResultStatus[] = [\n 'not-started',\n 'on-track',\n 'at-risk',\n 'off-track',\n 'achieved',\n];\n\nconst KEY_RESULT_UNITS: KeyResultUnit[] = [\n 'percent',\n 'count',\n 'currency',\n 'hours',\n 'custom',\n];\n\n/**\n * The current quarter as a period string, e.g. `Q3-2026`. Mirrors how the\n * server derives the coaching-home period; `okrs list` defaults to it because\n * \"how is the quarter going\" almost always means *this* quarter.\n */\nfunction currentPeriod(): string {\n const now = new Date();\n return `Q${Math.floor(now.getMonth() / 3) + 1}-${now.getFullYear()}`;\n}\n\n/**\n * Resolve `--workspace` / `--all-workspaces` to the set of workspaces to read.\n *\n * \"Am I neglecting a goal\" is inherently a cross-workspace question, so the\n * flag lives here rather than making every caller write the loop. The\n * procedures are per-workspace, so this fans out and the caller concatenates.\n */\nasync function targetWorkspaces(\n client: ReturnType<typeof getClient>,\n options: { workspace?: string; allWorkspaces?: boolean },\n): Promise<Workspace[]> {\n if (options.allWorkspaces) {\n if (options.workspace) {\n throw new Error('--workspace and --all-workspaces are mutually exclusive.');\n }\n return await client.workspaces.list();\n }\n return [await resolveWorkspace(client, options.workspace)];\n}\n\n/**\n * Fan a per-workspace read out across workspaces, keeping partial results.\n *\n * A cross-workspace sweep exists to answer \"what am I neglecting\", so one\n * workspace the caller can no longer read must not take the rest with it —\n * `okr.getByObjective` throws FORBIDDEN for a non-member, and membership does\n * lapse. Failures are surfaced on stderr rather than swallowed: a silently\n * short list is worse than none. If nothing succeeded, the first error is\n * rethrown, which is also what makes a single-workspace read still fail loudly.\n */\nasync function fanOutByWorkspace<T>(\n workspaces: Workspace[],\n read: (workspace: Workspace) => Promise<T[]>,\n): Promise<T[]> {\n const settled = await Promise.allSettled(workspaces.map(read));\n const items: T[] = [];\n const skipped: string[] = [];\n settled.forEach((result, i) => {\n if (result.status === 'fulfilled') {\n items.push(...result.value);\n return;\n }\n const reason =\n result.reason instanceof Error ? result.reason.message : String(result.reason);\n skipped.push(`${workspaces[i]!.slug}: ${reason}`);\n });\n\n if (skipped.length === workspaces.length) {\n const [first] = settled.filter((r) => r.status === 'rejected');\n throw (first as PromiseRejectedResult).reason;\n }\n // stderr, so a skipped workspace is visible without corrupting piped JSON.\n for (const line of skipped) {\n console.error(`Warning: skipped workspace ${line}`);\n }\n return items;\n}\n\n/**\n * Objective ids are integers, not cuids — the CLI parses them here so a typo\n * fails with a readable message instead of a server-side zod error.\n */\nfunction parseGoalId(value: string): number {\n const id = Number(value);\n if (!Number.isInteger(id)) {\n throw new Error(\n `Goal id must be a whole number, got \"${value}\". List them with \\`exponential goals list\\`.`,\n );\n }\n return id;\n}\n\nfunction parseNumber(value: string, label: string): number {\n const n = Number(value);\n if (!Number.isFinite(n)) {\n throw new Error(`${label} must be a number, got \"${value}\".`);\n }\n return n;\n}\n\nfunction validateGoalStatus(value: string | undefined): GoalStatus | undefined {\n if (!value) return undefined;\n if (!(GOAL_STATUSES as string[]).includes(value)) {\n throw new Error(`Invalid status \"${value}\". Valid: ${GOAL_STATUSES.join(', ')}`);\n }\n return value as GoalStatus;\n}\n\nfunction validateWritableGoalStatus(\n value: string | undefined,\n): GoalWritableStatus | undefined {\n if (!value) return undefined;\n if (!(GOAL_WRITABLE_STATUSES as string[]).includes(value)) {\n const extra = value === 'on-hold' ? ' Use `goals set-status` for on-hold.' : '';\n throw new Error(\n `Invalid status \"${value}\". Valid: ${GOAL_WRITABLE_STATUSES.join(', ')}.${extra}`,\n );\n }\n return value as GoalWritableStatus;\n}\n\nfunction validateKeyResultStatus(\n value: string | undefined,\n): KeyResultStatus | undefined {\n if (!value) return undefined;\n if (!(KEY_RESULT_STATUSES as string[]).includes(value)) {\n throw new Error(\n `Invalid status \"${value}\". Valid: ${KEY_RESULT_STATUSES.join(', ')}`,\n );\n }\n return value as KeyResultStatus;\n}\n\nfunction validateKeyResultUnit(value: string | undefined): KeyResultUnit | undefined {\n if (!value) return undefined;\n if (!(KEY_RESULT_UNITS as string[]).includes(value)) {\n throw new Error(`Invalid unit \"${value}\". Valid: ${KEY_RESULT_UNITS.join(', ')}`);\n }\n return value as KeyResultUnit;\n}\n\n/**\n * `exponential goals kr …` — key results.\n *\n * Kept as a subtree of `goals` because a key result is meaningless without its\n * objective, and because the tRPC router mounted at `okr` is the KEY RESULT\n * router — naming the group `kr` keeps that straight. Ids here are cuids; the\n * `--goal` they hang off is an integer.\n */\nfunction createKeyResultsCommand(): Command {\n const kr = new Command('kr').description(\n 'Key results on an objective. Ids are CUIDs; --goal takes the objective\\'s integer id.',\n );\n\n kr.command('list')\n .description('List key results')\n .option('--goal <id>', 'Objective ID (a number)')\n .option('-w, --workspace <slug|id>', 'Workspace (workspace-wide: every member\\'s KRs)')\n .option('--period <period>', 'Period, e.g. Q3-2026')\n .option('--status <status>', `Filter by status: ${KEY_RESULT_STATUSES.join(', ')}`)\n .option('--mine', 'Narrow a workspace list to key results you own')\n .action(\n async (\n options: {\n goal?: string;\n workspace?: string;\n period?: string;\n status?: string;\n mine?: boolean;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateKeyResultStatus(options.status);\n const client = getClient();\n const goalId = options.goal ? parseGoalId(options.goal) : undefined;\n\n // No --workspace and no --goal keeps this the caller's personal list;\n // resolving a default workspace here would silently widen it. With a\n // --goal, borrow that objective's own workspace: an unscoped\n // `okr.getAll` is owner-scoped server-side, so \"the key results on\n // objective #48\" comes back empty for anyone but their author.\n let workspaceId: string | undefined;\n if (options.workspace) {\n workspaceId = await resolveWorkspaceId(client, options.workspace);\n } else if (goalId !== undefined) {\n const goal = await client.goals.get(goalId);\n workspaceId = goal.workspaceId ?? undefined;\n }\n\n const list = await client.goals.keyResults.list({\n workspaceId,\n goalId,\n period: options.period,\n status,\n onlyMine: options.mine,\n });\n if (useJson) outputKeyResultsJson(list);\n else outputKeyResultsPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n kr.command('get <id>')\n .description('Get a key result by CUID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const keyResult = await getClient().goals.keyResults.get(id);\n if (useJson) outputKeyResultJson(keyResult);\n else outputKeyResultPretty(keyResult);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n kr.command('create')\n .description('Create a key result on an objective')\n .requiredOption('--goal <id>', 'Objective ID (a number)')\n .requiredOption('-t, --title <text>', 'Key result title')\n .requiredOption('--target <n>', 'Target value')\n .option('--start <n>', 'Starting value (default 0)')\n .option('--current <n>', 'Current value (defaults to the start value)')\n .option('--unit <unit>', `Unit: ${KEY_RESULT_UNITS.join(', ')}`)\n .option('--period <period>', 'Period, e.g. Q3-2026 (defaults to the objective\\'s)')\n .option('-d, --description <text>', 'Description')\n .option('--dri <userId>', 'Directly responsible individual (user ID)')\n .action(\n async (\n options: {\n goal: string;\n title: string;\n target: string;\n start?: string;\n current?: string;\n unit?: string;\n period?: string;\n description?: string;\n dri?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const unit = validateKeyResultUnit(options.unit);\n const client = getClient();\n const goalId = parseGoalId(options.goal);\n const startValue = options.start\n ? parseNumber(options.start, '--start')\n : undefined;\n\n // `period` is required by the server but is a property of the OKR\n // cycle, not of the individual KR — fall back to the objective's so\n // the common case needs one less flag.\n // The SDK resolves the objective's workspace when none is passed; if\n // we fetch the objective here anyway, hand that workspace over rather\n // than making it read the same row twice.\n let period = options.period;\n let workspaceId: string | undefined;\n if (!period) {\n const goal = await client.goals.get(goalId);\n if (!goal.period) {\n throw new Error(\n `Objective #${goalId} has no period, so --period is required. See \\`exponential goals periods\\`.`,\n );\n }\n period = goal.period;\n workspaceId = goal.workspaceId ?? undefined;\n }\n\n const keyResult = await client.goals.keyResults.create({\n goalId,\n workspaceId,\n title: options.title,\n targetValue: parseNumber(options.target, '--target'),\n startValue,\n currentValue: options.current\n ? parseNumber(options.current, '--current')\n : startValue,\n unit,\n period,\n description: options.description,\n driUserId: options.dri,\n });\n if (useJson) outputKeyResultJson(keyResult);\n else {\n console.log('\\n✓ Key result created');\n outputKeyResultPretty(keyResult);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n kr.command('update')\n .description('Update a key result (only the flags you pass are written)')\n .requiredOption('--id <cuid>', 'Key result CUID')\n .option('-t, --title <text>', 'New title')\n .option('-d, --description <text>', 'New description')\n .option('--current <n>', 'Current value (prefer `kr checkin` — it records history)')\n .option('--target <n>', 'Target value')\n .option('--start <n>', 'Starting value')\n .option('--unit <unit>', `Unit: ${KEY_RESULT_UNITS.join(', ')}`)\n .option('--status <status>', `Status: ${KEY_RESULT_STATUSES.join(', ')}`)\n .option('--confidence <n>', 'Confidence 0-100')\n .option('--dri <userId>', 'Directly responsible individual (user ID)')\n .option('--goal <id>', 'Move the key result to a different objective')\n .action(\n async (\n options: {\n id: string;\n title?: string;\n description?: string;\n current?: string;\n target?: string;\n start?: string;\n unit?: string;\n status?: string;\n confidence?: string;\n dri?: string;\n goal?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateKeyResultStatus(options.status);\n const unit = validateKeyResultUnit(options.unit);\n const keyResult = await getClient().goals.keyResults.update({\n id: options.id,\n title: options.title,\n description: options.description,\n currentValue: options.current\n ? parseNumber(options.current, '--current')\n : undefined,\n targetValue: options.target\n ? parseNumber(options.target, '--target')\n : undefined,\n startValue: options.start\n ? parseNumber(options.start, '--start')\n : undefined,\n unit,\n status,\n confidence: options.confidence\n ? parseNumber(options.confidence, '--confidence')\n : undefined,\n driUserId: options.dri,\n goalId: options.goal ? parseGoalId(options.goal) : undefined,\n });\n if (useJson) outputKeyResultJson(keyResult);\n else {\n console.log('\\n✓ Key result updated');\n outputKeyResultPretty(keyResult);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n kr.command('checkin')\n .description(\n 'Record a progress check-in. Moves the value AND re-derives the status ' +\n 'from where it lands between start and target.',\n )\n .requiredOption('--id <cuid>', 'Key result CUID')\n .requiredOption('--value <n>', 'New current value')\n .option('--note <text>', 'Check-in note')\n .action(\n async (\n options: { id: string; value: string; note?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const checkIn = await getClient().goals.keyResults.checkIn({\n id: options.id,\n value: parseNumber(options.value, '--value'),\n note: options.note,\n });\n if (useJson) outputCheckInJson(checkIn);\n else {\n console.log('\\n✓ Check-in recorded');\n outputCheckInPretty(checkIn);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n kr.command('delete')\n .description('Delete a key result')\n .requiredOption('--id <cuid>', 'Key result CUID')\n .action(async (options: { id: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n await getClient().goals.keyResults.delete(options.id);\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id: options.id }, null, 2));\n } else {\n console.log('✓ Key result deleted');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n kr.command('link')\n .description('Link executing work (a project or a feature) to a key result')\n .requiredOption('--id <cuid>', 'Key result CUID')\n .option('--project <cuid>', 'Project CUID')\n .option('--feature <cuid>', 'Feature CUID')\n .action(\n async (\n options: { id: string; project?: string; feature?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n if (!options.project === !options.feature) {\n throw new Error('Pass exactly one of --project or --feature.');\n }\n const client = getClient();\n const result = options.project\n ? await client.goals.keyResults.linkProject({\n keyResultId: options.id,\n projectId: options.project,\n })\n : await client.goals.keyResults.linkFeature({\n keyResultId: options.id,\n featureId: options.feature!,\n });\n if (useJson) console.log(JSON.stringify(result, null, 2));\n else console.log(`\\n✓ ${options.project ? 'Project' : 'Feature'} linked`);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n kr.command('unlink')\n .description('Unlink a project or feature from a key result')\n .requiredOption('--id <cuid>', 'Key result CUID')\n .option('--project <cuid>', 'Project CUID')\n .option('--feature <cuid>', 'Feature CUID')\n .action(\n async (\n options: { id: string; project?: string; feature?: string },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n if (!options.project === !options.feature) {\n throw new Error('Pass exactly one of --project or --feature.');\n }\n const client = getClient();\n const result = options.project\n ? await client.goals.keyResults.unlinkProject({\n keyResultId: options.id,\n projectId: options.project,\n })\n : await client.goals.keyResults.unlinkFeature({\n keyResultId: options.id,\n featureId: options.feature!,\n });\n if (useJson) console.log(JSON.stringify(result, null, 2));\n else console.log(`\\n✓ ${options.project ? 'Project' : 'Feature'} unlinked`);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n return kr;\n}\n\nfunction createGoalCommentsCommand(): Command {\n const comment = new Command('comment').description(\n 'Read and post comments on a goal. Mention teammates with --mention.',\n );\n\n comment\n .command('list')\n .description('List comments on a goal')\n .requiredOption('--goal <id>', 'Goal ID (a number)')\n .action(async (options: { goal: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const comments = await client.goalComments.list(parseGoalId(options.goal));\n if (useJson) outputCommentsJson(comments);\n else outputCommentsPretty(comments);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n comment\n .command('add')\n .description('Add a comment to a goal')\n .requiredOption('--goal <id>', 'Goal ID (a number)')\n .requiredOption('-m, --message <text>', 'Comment content (markdown supported)')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .option('--parent-update <id>', 'Thread under a specific goal update')\n .action(\n async (\n options: {\n goal: string;\n message: string;\n mention: string[];\n workspace?: string;\n parentUpdate?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const goalId = parseGoalId(options.goal);\n const content =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const created = await client.goalComments.add({\n goalId,\n content,\n parentUpdateId: options.parentUpdate,\n });\n if (useJson) {\n outputCommentJson(created);\n } else {\n console.log('\\n✓ Comment added');\n outputCommentPretty(created);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('update')\n .description('Update one of your own comments')\n .requiredOption('--comment-id <id>', 'Comment ID')\n .requiredOption('-m, --message <text>', 'New comment content')\n .option('--mention <name>', MENTION_OPTION_DESCRIPTION, collectMention, [])\n .option(\n '--workspace <slug|id>',\n 'Workspace used to resolve --mention (defaults to your default workspace)',\n )\n .action(\n async (\n options: {\n commentId: string;\n message: string;\n mention: string[];\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const content =\n options.mention.length > 0\n ? await applyMentions(\n client,\n await resolveWorkspaceId(client, options.workspace),\n options.message,\n options.mention,\n )\n : options.message;\n\n const updated = await client.goalComments.update({\n commentId: options.commentId,\n content,\n });\n if (useJson) {\n outputCommentJson(updated);\n } else {\n console.log('\\n✓ Comment updated');\n outputCommentPretty(updated);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n comment\n .command('rm')\n .description('Delete one of your own comments')\n .requiredOption('--comment-id <id>', 'Comment ID')\n .action(async (options: { commentId: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n await client.goalComments.delete(options.commentId);\n if (useJson) {\n console.log(JSON.stringify({ deleted: true, id: options.commentId }, null, 2));\n } else {\n console.log('✓ Comment deleted');\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n return comment;\n}\n\n/**\n * `exponential goals …` — objectives (`Goal`, integer ids), their key results,\n * and their comments.\n *\n * Three separate write paths on purpose. `update` is a partial update that\n * sends only the flags you pass; `set-status`/`close` route through the\n * status-only procedure; `reparent` writes the parent alone. Closing a quarter\n * or moving a goal in the cascade should never risk a collateral write — an\n * agent once archived a goal with a title-and-status update and orphaned it out\n * of its workspace in the process.\n */\nexport function createGoalsCommand(): Command {\n const goals = new Command('goals').description(\n 'Manage goals (objectives) and their key results. Objectives have integer ids; key results are CUIDs.',\n );\n\n goals\n .command('list')\n .description(\n 'List objectives, each with the projects linked to it — the join that ' +\n 'ties an action (which carries a projectId) back to a goal.',\n )\n .option('-w, --workspace <slug|id>', 'Workspace slug or ID (defaults to your default workspace)')\n .option('--all-workspaces', 'List across every workspace you belong to')\n .option('--period <period>', 'Filter by period, e.g. Q3-2026')\n .option('--status <status>', `Filter by status: ${GOAL_STATUSES.join(', ')}`)\n .option('--tree', 'Render the parent/child cascade instead of a flat list')\n .action(\n async (\n options: {\n workspace?: string;\n allWorkspaces?: boolean;\n period?: string;\n status?: string;\n tree?: boolean;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateGoalStatus(options.status);\n const client = getClient();\n const workspaces = await targetWorkspaces(client, options);\n\n if (options.tree) {\n // getGoalTree has no period filter, so --period is applied here.\n // It only prunes roots — a matching child under a non-matching\n // parent would otherwise vanish, which is the opposite of what a\n // cascade view is for.\n const trees = await fanOutByWorkspace(workspaces, (w) =>\n client.goals.tree({ workspaceId: w.id, status }),\n );\n const filtered = options.period\n ? trees.filter((g) => g.period === options.period)\n : trees;\n if (useJson) outputGoalTreeJson(filtered);\n else outputGoalTreePretty(filtered);\n return;\n }\n\n const list = await fanOutByWorkspace(workspaces, async (workspace) => {\n const goals = await client.goals.list({\n workspaceId: workspace.id,\n period: options.period,\n status,\n });\n // The server attaches `workspace`, but only since the goals\n // release — fill it in from the workspace we just queried so a\n // cross-workspace list is labelled either way.\n return goals.map((g) => ({ ...g, workspace: g.workspace ?? workspace }));\n });\n if (useJson) outputGoalsJson(list);\n else outputGoalsPretty(list);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n goals\n .command('get <id>')\n .description('Get an objective by its integer ID')\n .action(async (id: string, _options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const goal = await getClient().goals.get(parseGoalId(id));\n if (useJson) outputGoalJson(goal);\n else outputGoalPretty(goal);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n goals\n .command('create')\n .description('Create an objective')\n .requiredOption('-t, --title <text>', 'Objective title')\n .option('-w, --workspace <slug|id>', 'Workspace slug or ID (defaults to your default workspace)')\n .option('--period <period>', 'Period, e.g. Q3-2026 or Annual-2026')\n .option('--status <status>', `Status: ${GOAL_WRITABLE_STATUSES.join(', ')}`)\n .option('-d, --description <text>', 'Description (markdown supported)')\n .option('--why <text>', 'Why this goal matters')\n .option('--dri <userId>', 'Directly responsible individual (user ID)')\n .option('--parent <id>', 'Parent objective ID to nest under (max depth 5)')\n .option('--project <cuid>', 'Link a project on creation')\n .action(\n async (\n options: {\n title: string;\n workspace?: string;\n period?: string;\n status?: string;\n description?: string;\n why?: string;\n dri?: string;\n parent?: string;\n project?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateWritableGoalStatus(options.status);\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const goal = await client.goals.create({\n title: options.title,\n workspaceId,\n period: options.period,\n status,\n description: options.description,\n whyThisGoal: options.why,\n driUserId: options.dri,\n parentGoalId: options.parent ? parseGoalId(options.parent) : undefined,\n projectId: options.project,\n });\n if (useJson) outputGoalJson(goal);\n else {\n console.log('\\n✓ Goal created');\n outputGoalPretty(goal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n goals\n .command('update')\n .description(\n 'Update an objective. Only the flags you pass are written — everything ' +\n 'else is left exactly as it is. For a status change use `set-status`; ' +\n 'to re-parent use `reparent`.',\n )\n .requiredOption('--id <n>', 'Objective ID (a number)')\n .option('-t, --title <text>', 'New title')\n .option('-d, --description <text>', 'New description (\"none\" clears it)')\n .option('--why <text>', 'Why this goal matters (\"none\" clears it)')\n .option('--period <period>', 'New period (\"none\" clears it)')\n .option('--dri <userId>', 'Directly responsible individual (user ID)')\n .option('--status <status>', `Status: ${GOAL_WRITABLE_STATUSES.join(', ')}`)\n .option('--project <cuid>', 'Replace the project links with this project (\"none\" clears them)')\n .option(\n '-w, --workspace <slug|id|none>',\n 'Re-home the objective; \"none\" makes it personal',\n )\n .action(\n async (\n options: {\n id: string;\n title?: string;\n description?: string;\n why?: string;\n period?: string;\n dri?: string;\n status?: string;\n project?: string;\n workspace?: string;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateWritableGoalStatus(options.status);\n // \"none\" is the CLI's way of saying the explicit null the API wants;\n // an omitted flag stays `undefined` and is never sent.\n const clearable = (value: string | undefined) =>\n value === undefined ? undefined : value === 'none' ? null : value;\n const client = getClient();\n\n // A slug has to become an id, so this one can't go through\n // `clearable`. Omitted stays omitted: re-homing is exactly the write\n // that orphaned goal 46 when it happened by accident.\n let workspaceId: string | null | undefined;\n if (options.workspace === 'none') workspaceId = null;\n else if (options.workspace !== undefined) {\n workspaceId = await resolveWorkspaceId(client, options.workspace);\n }\n\n const goal = await client.goals.update({\n id: parseGoalId(options.id),\n workspaceId,\n title: options.title,\n description: clearable(options.description),\n whyThisGoal: clearable(options.why),\n period: clearable(options.period),\n driUserId: options.dri,\n status,\n projectId: clearable(options.project),\n });\n if (useJson) outputGoalJson(goal);\n else {\n console.log('\\n✓ Goal updated');\n outputGoalPretty(goal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n goals\n .command('set-status')\n .description(\n 'Set an objective\\'s status and nothing else. Routes through the ' +\n 'status-only procedure, so no other field can be touched.',\n )\n .requiredOption('--id <n>', 'Objective ID (a number)')\n .requiredOption('--status <status>', `Status: ${GOAL_STATUSES.join(', ')}`)\n .action(async (options: { id: string; status: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateGoalStatus(options.status)!;\n const goal = await getClient().goals.setStatus({\n id: parseGoalId(options.id),\n status,\n });\n if (useJson) outputGoalJson(goal);\n else {\n console.log(`\\n✓ Goal status set to ${status}`);\n outputGoalPretty(goal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n goals\n .command('close')\n .description('Close out an objective — one command per goal when a quarter ends')\n .requiredOption('--id <n>', 'Objective ID (a number)')\n .option('--status <status>', 'completed (default) or archived', 'completed')\n .action(async (options: { id: string; status: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateGoalStatus(options.status)!;\n // Same status-only path as set-status — never `updateGoal`.\n const goal = await getClient().goals.setStatus({\n id: parseGoalId(options.id),\n status,\n });\n if (useJson) outputGoalJson(goal);\n else {\n console.log(`\\n✓ Goal closed as ${status}`);\n outputGoalPretty(goal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n goals\n .command('reparent')\n .description(\n 'Move an objective under another (or detach it with --parent none). ' +\n 'Writes the parent alone.',\n )\n .requiredOption('--id <n>', 'Objective ID (a number)')\n .requiredOption('--parent <id|none>', 'New parent objective ID, or \"none\" to detach')\n .action(async (options: { id: string; parent: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const goal = await getClient().goals.setParent({\n id: parseGoalId(options.id),\n parentGoalId: options.parent === 'none' ? null : parseGoalId(options.parent),\n });\n if (useJson) outputGoalJson(goal);\n else {\n console.log(\n options.parent === 'none' ? '\\n✓ Goal detached' : '\\n✓ Goal re-parented',\n );\n outputGoalPretty(goal);\n }\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n goals\n .command('delete')\n .description(\n 'Delete an objective. Refuses while it still has key results — deleting an ' +\n 'objective deletes them too (KeyResult.goalId cascades), taking their ' +\n 'check-in history with them.',\n )\n .requiredOption('--id <n>', 'Objective ID (a number)')\n .option(\n '--with-key-results',\n 'Delete the objective and cascade-delete its key results (destructive)',\n )\n .action(\n async (options: { id: string; withKeyResults?: boolean }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const id = parseGoalId(options.id);\n const client = getClient();\n const goal = await client.goals.get(id);\n const keyResults = goal.keyResults ?? [];\n const children = goal.childGoals ?? [];\n\n if (keyResults.length > 0 && !options.withKeyResults) {\n const payload = {\n deleted: false,\n id,\n reason: `has ${keyResults.length} key result(s)`,\n keyResults: keyResults.map((kr) => ({ id: kr.id })),\n };\n if (useJson) console.log(JSON.stringify(payload, null, 2));\n else {\n console.error(\n `Objective #${id} has ${keyResults.length} key result(s). Deleting it deletes them too.\\n` +\n 'Re-run with --with-key-results to go ahead, or move them with `goals kr update --id <cuid> --goal <other>`.',\n );\n }\n process.exitCode = 1;\n return;\n }\n\n await client.goals.delete(id);\n const payload = {\n deleted: true,\n id,\n keyResultsDeleted: keyResults.map((kr) => ({ id: kr.id })),\n childGoalsDetached: children.map((c) => ({ id: c.id, title: c.title })),\n };\n if (useJson) console.log(JSON.stringify(payload, null, 2));\n else {\n console.log('✓ Goal deleted');\n if (keyResults.length) {\n console.log(` ${keyResults.length} key result(s) deleted with it`);\n }\n if (children.length) {\n console.log(` ${children.length} sub-goal(s) left detached`);\n }\n }\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n goals\n .command('periods')\n .description('List the conventional OKR period strings')\n .action(async (_options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const periods = await getClient().goals.periods();\n if (useJson) outputGoalPeriodsJson(periods);\n else outputGoalPeriodsPretty(periods);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n goals\n .command('stats')\n .description('Objective and key-result counts, average progress and confidence')\n .option('-w, --workspace <slug|id>', 'Workspace slug or ID (defaults to your default workspace)')\n .option('--period <period>', 'Period, e.g. Q3-2026')\n .action(\n async (options: { workspace?: string; period?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const stats = await client.goals.stats({\n workspaceId,\n period: options.period,\n });\n if (useJson) outputGoalStatsJson(stats);\n else outputGoalStatsPretty(stats);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n goals.addCommand(createKeyResultsCommand());\n goals.addCommand(createGoalCommentsCommand());\n return goals;\n}\n\n/**\n * `exponential okrs …` — the objective-plus-key-results view.\n *\n * `goals list` answers \"what are the objectives\"; `okrs list` answers \"how is\n * the quarter going\", nesting each objective's key results underneath it in one\n * workspace-scoped call. Everything you can do to the parts still lives under\n * `goals` / `goals kr` — this group is the combined read.\n */\nexport function createOkrsCommand(): Command {\n const okrs = new Command('okrs').description(\n 'OKRs — objectives with their key results nested. Manage the parts with `goals` and `goals kr`.',\n );\n\n okrs\n .command('list')\n .description(\n 'List objectives with their key results. Defaults to the current ' +\n 'quarter — pass --period all for every period.',\n )\n .option('-w, --workspace <slug|id>', 'Workspace slug or ID (defaults to your default workspace)')\n .option('--all-workspaces', 'List across every workspace you belong to')\n .option(\n '--period <period>',\n `Period, e.g. Q3-2026, or \"all\" for every period (default: ${currentPeriod()})`,\n )\n .option('--paired-period', 'Also include the period\\'s parent annual period')\n .option(\n '--status <status>',\n `Keep only key results with this status: ${KEY_RESULT_STATUSES.join(', ')}`,\n )\n .option('--mine', 'Only objectives and key results you are the DRI for')\n .action(\n async (\n options: {\n workspace?: string;\n allWorkspaces?: boolean;\n period?: string;\n pairedPeriod?: boolean;\n status?: string;\n mine?: boolean;\n },\n cmd: Command,\n ) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const status = validateKeyResultStatus(options.status);\n const client = getClient();\n const workspaces = await targetWorkspaces(client, options);\n // \"how is the quarter going\" almost always means this quarter, so an\n // omitted --period narrows to it. `all` is the escape hatch.\n const period =\n options.period === 'all' ? undefined : options.period ?? currentPeriod();\n\n let objectives = (await fanOutByWorkspace(workspaces, async (workspace) => {\n const found = await client.goals.keyResults.byObjective({\n workspaceId: workspace.id,\n period,\n includePairedPeriod: options.pairedPeriod,\n onlyMine: options.mine,\n });\n // getByObjective doesn't return the workspace; attach the one we\n // queried so a cross-workspace list can label each row.\n return found.map((o) => ({ ...o, workspace }));\n })) as ObjectiveWithKeyResults[];\n\n if (status) {\n // getByObjective takes no status input, so this filters here —\n // dropping non-matching key results and then any objective left\n // with none, so \"show me what's off-track\" isn't padded with\n // objectives that have nothing off-track.\n objectives = objectives\n .map((o) => ({\n ...o,\n keyResults: o.keyResults.filter(\n (kr) => (kr.statusOverride ?? kr.status) === status,\n ),\n }))\n .filter((o) => o.keyResults.length > 0);\n }\n\n if (useJson) outputObjectivesJson(objectives);\n else outputObjectivesPretty(objectives);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n okrs\n .command('stats')\n .description('Objective and key-result counts, average progress and confidence')\n .option('-w, --workspace <slug|id>', 'Workspace slug or ID (defaults to your default workspace)')\n .option('--period <period>', 'Period, e.g. Q3-2026')\n .action(\n async (options: { workspace?: string; period?: string }, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const client = getClient();\n const workspaceId = await resolveWorkspaceId(client, options.workspace);\n const stats = await client.goals.stats({\n workspaceId,\n period: options.period,\n });\n if (useJson) outputGoalStatsJson(stats);\n else outputGoalStatsPretty(stats);\n } catch (error) {\n handleError(error, useJson);\n }\n },\n );\n\n okrs\n .command('periods')\n .description('List the conventional OKR period strings')\n .action(async (_options: Record<string, never>, cmd: Command) => {\n const globalOpts = cmd.optsWithGlobals() as GlobalOptions;\n const useJson = shouldUseJson(globalOpts.json, globalOpts.pretty);\n try {\n const periods = await getClient().goals.periods();\n if (useJson) outputGoalPeriodsJson(periods);\n else outputGoalPeriodsPretty(periods);\n } catch (error) {\n handleError(error, useJson);\n }\n });\n\n okrs.addCommand(createKeyResultsCommand());\n return okrs;\n}\n","#!/usr/bin/env node\nimport { buildProgram, isBareVersionRequest, PKG_VERSION } from './program.js';\n\nif (isBareVersionRequest(process.argv.slice(2))) {\n // Backwards-compatible `exponential --version`; see program.ts for why the\n // registered flag is `--cli-version`.\n console.log(PKG_VERSION);\n} else {\n buildProgram().parse();\n}\n"],"mappings":";;;AAAA,SAAS,WAAAA,iBAAe;;;ACAxB,SAAS,eAAe;AACxB,OAAOC,YAAW;;;ACDlB,SAAS,yBAAyB;AAGl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,UAAQ,WAAW,mBAAmB,CAAC;AACvC,UAAQ,WAAW,sBAAsB,CAAC;AAC1C,UAAQ,WAAW,sBAAsB,CAAC;AAC1C,UAAQ,WAAW,oBAAoB,CAAC;AACxC,UAAQ,WAAW,qBAAqB,CAAC;AACzC,UAAQ,WAAW,kBAAkB,CAAC;AACtC,UAAQ,WAAW,wBAAwB,CAAC;AAC5C,UAAQ,WAAW,mBAAmB,CAAC;AACvC,UAAQ,WAAW,kBAAkB,CAAC;AAEtC,SAAO;AACT;;;AgCnFA,IAAI,qBAAqB,QAAQ,KAAK,MAAM,CAAC,CAAC,GAAG;AAG/C,UAAQ,IAAI,WAAW;AACzB,OAAO;AACL,eAAa,EAAE,MAAM;AACvB;","names":["Command","chalk","chalk","Command","chalk","statusBadge","Command","actions","Command","Command","Command","chalk","Command","rows","chalk","decision","Command","Command","Command","parseDate","Command","parseNullableDate","Command","Command","Command","story","Command","Command","Command","readStdin","Command","Command","chalk","Command","Command","Command","Command","Command","chalk","chalk","Command","Command","chalk","Command","notes","chalk","Command","Command","Command","Command","Command","Command","Command","Command","Command","Command","projects","payload","Command","chalk","Command","chalk","Command","Command","parseNullableInt","parseNullableString","Command","SOURCES","STATUSES","parseSource","parseStatus","BATCH_ITEM_KEYS","parseBatchFile","Command","result","Command","chalk","Command","workspaces","chalk","Command","Command","goals","payload","readFileSync","Command"]}