Skip to content

An AI-powered task-management system you can drop into Cursor, Lovable, Windsurf, Roo, and others.

refactor(auth): rename forcePrompt to forceSelection and fix AuthManager type

Eyal Toledano9e0e9b02a350
diff --git a/apps/cli/src/commands/export.command.ts b/apps/cli/src/commands/export.command.ts
index a096738c..1ae74ce6 100644
--- a/apps/cli/src/commands/export.command.ts
+++ b/apps/cli/src/commands/export.command.ts
@@ -6,6 +6,7 @@
import fs from 'node:fs/promises';
import path from 'node:path';
import {
+ AuthManager,
FileStorage,
type GenerateBriefResult,
type InvitationResult,
@@ -337,21 +338,19 @@ export class ExportCommand extends Command {
// Force org selection after tag selection
// User can choose which org to export to, with current org pre-selected
- const authManager = (this.taskMasterCore!.auth as any).authManager;
- if (authManager) {
- const orgResult = await ensureOrgSelected(authManager, {
- promptMessage: 'Select an organization to export to:',
- forcePrompt: true
- });
- if (!orgResult.success) {
- console.log(chalk.gray('\n Export cancelled.\n'));
- this.lastResult = {
- success: false,
- action: 'cancelled',
- message: orgResult.message || 'Organization selection cancelled'
- };
- return;
- }
+ const authManager = AuthManager.getInstance();
+ const orgResult = await ensureOrgSelected(authManager, {
+ promptMessage: 'Select an organization to export to:',
+ forceSelection: true
+ });
+ if (!orgResult.success) {
+ console.log(chalk.gray('\n Export cancelled.\n'));
+ this.lastResult = {
+ success: false,
+ action: 'cancelled',
+ message: orgResult.message || 'Organization selection cancelled'
+ };
+ return;
}
// Handle multiple tags export
@@ -992,9 +991,8 @@ export class ExportCommand extends Command {
try {
if (!this.taskMasterCore) return;
- // Get AuthManager from TmCore
- const authManager = (this.taskMasterCore.auth as any).authManager;
- if (!authManager) return;
+ // Get AuthManager singleton
+ const authManager = AuthManager.getInstance();
// Use the selectBriefFromInput utility which properly resolves
// the brief and sets all context fields (org, brief details, etc.)
diff --git a/apps/cli/src/utils/org-selection.ts b/apps/cli/src/utils/org-selection.ts
index fc33c607..17661f70 100644
--- a/apps/cli/src/utils/org-selection.ts
+++ b/apps/cli/src/utils/org-selection.ts
@@ -3,7 +3,7 @@
* Provides reusable org selection flow for commands that require org context.
*/
-import { AuthManager } from '@tm/core';
+import type { AuthManager } from '@tm/core';
import chalk from 'chalk';
import inquirer from 'inquirer';
import * as ui from './ui.js';
@@ -28,7 +28,7 @@ export interface EnsureOrgOptions {
/** Custom message to show when prompting */
promptMessage?: string;
/** If true, always prompt for org selection even if one is already set */
- forcePrompt?: boolean;
+ forceSelection?: boolean;
}
/**
@@ -57,13 +57,13 @@ export async function ensureOrgSelected(
authManager: AuthManager,
options: EnsureOrgOptions = {}
): Promise<OrgSelectionResult> {
- const { silent = false, promptMessage, forcePrompt = false } = options;
+ const { silent = false, promptMessage, forceSelection = false } = options;
try {
const context = authManager.getContext();
- // If org is already selected and we're not forcing a prompt, return it
- if (context?.orgId && !forcePrompt) {
+ // If org is already selected and we're not forcing selection, return it
+ if (context?.orgId && !forceSelection) {
return {
success: true,
orgId: context.orgId,
@@ -121,10 +121,7 @@ export async function ensureOrgSelected(
name: 'orgId',
message: promptMessage || 'Select an organization:',
choices: orgs.map((org) => ({
- name:
- org.id === context?.orgId
- ? `${org.name} (current)`
- : org.name,
+ name: org.id === context?.orgId ? `${org.name} (current)` : org.name,
value: org.id
})),
default: defaultOrg >= 0 ? defaultOrg : 0
diff --git a/scripts/modules/commands.js b/scripts/modules/commands.js
index 926c1753..4720bf1d 100644
--- a/scripts/modules/commands.js
+++ b/scripts/modules/commands.js
@@ -388,7 +388,7 @@ async function handleParsePrdToHamster(prdPath) {
// even if they have one already selected in context
const orgResult = await ensureOrgSelected(authManager, {
promptMessage: 'Select an organization to create the brief in:',
- forcePrompt: true
+ forceSelection: true
});
if (!orgResult.success) {
console.error(