refactor: reorganize imports and enhance type definitions

- Reintroduced the TEAM_VALIDATE_CLI_ARGS constant in IPC channels for consistency.
- Updated type definitions in TaskBoundaryParser to use a new DetectedMechanism type for better clarity and maintainability.
- Improved error handling in TeamProvisioningService by ensuring exit codes are converted to strings for clearer error messages.
- Standardized imports of CliArgsValidationResult across multiple files to maintain consistency in type usage.
This commit is contained in:
iliya 2026-03-07 19:23:48 +02:00
parent d486510c9e
commit 5c2b6fe68c
5 changed files with 26 additions and 12 deletions

View file

@ -48,20 +48,23 @@ import {
TEAM_STOP,
TEAM_TOOL_APPROVAL_RESPOND,
TEAM_UPDATE_CONFIG,
TEAM_VALIDATE_CLI_ARGS,
TEAM_UPDATE_KANBAN,
TEAM_UPDATE_KANBAN_COLUMN_ORDER,
TEAM_UPDATE_MEMBER_ROLE,
TEAM_UPDATE_TASK_FIELDS,
TEAM_UPDATE_TASK_OWNER,
TEAM_UPDATE_TASK_STATUS,
TEAM_VALIDATE_CLI_ARGS,
// eslint-disable-next-line boundaries/element-types -- IPC channel constants are shared between main and preload by design
} from '@preload/constants/ipcChannels';
import { AGENT_BLOCK_CLOSE, AGENT_BLOCK_OPEN } from '@shared/constants/agentBlocks';
import { KANBAN_COLUMN_IDS } from '@shared/constants/kanban';
import { MAX_TEXT_LENGTH } from '@shared/constants/teamLimits';
import type { CliArgsValidationResult } from '@shared/utils/cliArgsParser';
import { extractFlagsFromHelp, extractUserFlags, PROTECTED_CLI_FLAGS } from '@shared/utils/cliArgsParser';
import {
extractFlagsFromHelp,
extractUserFlags,
PROTECTED_CLI_FLAGS,
} from '@shared/utils/cliArgsParser';
import { createLogger } from '@shared/utils/logger';
import { isRateLimitMessage } from '@shared/utils/rateLimitDetector';
import { BrowserWindow, type IpcMain, type IpcMainInvokeEvent, Notification } from 'electron';
@ -122,6 +125,7 @@ import type {
TeamUpdateConfigRequest,
UpdateKanbanPatch,
} from '@shared/types';
import type { CliArgsValidationResult } from '@shared/utils/cliArgsParser';
const logger = createLogger('IPC:teams');

View file

@ -38,10 +38,12 @@ interface ToolUseInfo {
const TEAMCTL_TASK_REGEX = /task\s+(start|complete|set-status)\s+(\d+)/;
const MCP_TASK_BOUNDARY_TOOLS = new Set(['task_start', 'task_complete', 'task_set_status']);
type DetectedMechanism = 'TaskUpdate' | 'teamctl' | 'mcp' | 'none';
function pickDetectedMechanism(
current: 'TaskUpdate' | 'teamctl' | 'mcp' | 'none',
next: 'TaskUpdate' | 'teamctl' | 'mcp'
): 'TaskUpdate' | 'teamctl' | 'mcp' | 'none' {
current: DetectedMechanism,
next: Exclude<DetectedMechanism, 'none'>
): DetectedMechanism {
const priority = {
none: 0,
teamctl: 1,
@ -75,7 +77,7 @@ export class TaskBoundaryParser {
const boundaries: TaskBoundary[] = [];
const allToolUsesByLine = new Map<number, ToolUseInfo[]>();
let lineNumber = 0;
let detectedMechanism: 'TaskUpdate' | 'teamctl' | 'mcp' | 'none' = 'none';
let detectedMechanism: DetectedMechanism = 'none';
try {
const stream = createReadStream(filePath, { encoding: 'utf8' });

View file

@ -5254,10 +5254,18 @@ export class TeamProvisioningService {
throw new Error('Claude CLI not found');
}
const { env } = await this.buildProvisioningEnv();
const result = await this.spawnProbe(probeResult.claudePath, ['--help'], targetCwd, env, 10_000);
const result = await this.spawnProbe(
probeResult.claudePath,
['--help'],
targetCwd,
env,
10_000
);
const output = (result.stdout + '\n' + result.stderr).trim();
if (!output) {
throw new Error(`claude --help returned empty output (exit code: ${result.exitCode})`);
throw new Error(
`claude --help returned empty output (exit code: ${String(result.exitCode)})`
);
}
this.helpOutputCache = output;
this.helpOutputCacheTime = Date.now();

View file

@ -106,13 +106,13 @@ import {
TEAM_TOOL_APPROVAL_EVENT,
TEAM_TOOL_APPROVAL_RESPOND,
TEAM_UPDATE_CONFIG,
TEAM_VALIDATE_CLI_ARGS,
TEAM_UPDATE_KANBAN,
TEAM_UPDATE_KANBAN_COLUMN_ORDER,
TEAM_UPDATE_MEMBER_ROLE,
TEAM_UPDATE_TASK_FIELDS,
TEAM_UPDATE_TASK_OWNER,
TEAM_UPDATE_TASK_STATUS,
TEAM_VALIDATE_CLI_ARGS,
TERMINAL_DATA,
TERMINAL_EXIT,
TERMINAL_KILL,
@ -222,7 +222,6 @@ import type {
UpdateKanbanPatch,
WslClaudeRootCandidate,
} from '@shared/types';
import type { CliArgsValidationResult } from '@shared/utils/cliArgsParser';
import type {
BinaryPreviewResult,
CreateDirResponse,
@ -239,6 +238,7 @@ import type {
WriteFileResponse,
} from '@shared/types/editor';
import type { PtySpawnOptions } from '@shared/types/terminal';
import type { CliArgsValidationResult } from '@shared/utils/cliArgsParser';
// =============================================================================
// IPC Result Types and Helpers

View file

@ -7,6 +7,7 @@
* Shared between preload and renderer processes.
*/
import type { CliArgsValidationResult } from '../utils/cliArgsParser';
import type { CliInstallerAPI } from './cliInstaller';
import type { EditorAPI, ProjectAPI } from './editor';
import type {
@ -64,7 +65,6 @@ import type {
UpdateKanbanPatch,
} from './team';
import type { TerminalAPI } from './terminal';
import type { CliArgsValidationResult } from '../utils/cliArgsParser';
import type { WaterfallData } from './visualization';
import type {
ConversationGroup,