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:
parent
d486510c9e
commit
5c2b6fe68c
5 changed files with 26 additions and 12 deletions
|
|
@ -48,20 +48,23 @@ import {
|
||||||
TEAM_STOP,
|
TEAM_STOP,
|
||||||
TEAM_TOOL_APPROVAL_RESPOND,
|
TEAM_TOOL_APPROVAL_RESPOND,
|
||||||
TEAM_UPDATE_CONFIG,
|
TEAM_UPDATE_CONFIG,
|
||||||
TEAM_VALIDATE_CLI_ARGS,
|
|
||||||
TEAM_UPDATE_KANBAN,
|
TEAM_UPDATE_KANBAN,
|
||||||
TEAM_UPDATE_KANBAN_COLUMN_ORDER,
|
TEAM_UPDATE_KANBAN_COLUMN_ORDER,
|
||||||
TEAM_UPDATE_MEMBER_ROLE,
|
TEAM_UPDATE_MEMBER_ROLE,
|
||||||
TEAM_UPDATE_TASK_FIELDS,
|
TEAM_UPDATE_TASK_FIELDS,
|
||||||
TEAM_UPDATE_TASK_OWNER,
|
TEAM_UPDATE_TASK_OWNER,
|
||||||
TEAM_UPDATE_TASK_STATUS,
|
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
|
// eslint-disable-next-line boundaries/element-types -- IPC channel constants are shared between main and preload by design
|
||||||
} from '@preload/constants/ipcChannels';
|
} from '@preload/constants/ipcChannels';
|
||||||
import { AGENT_BLOCK_CLOSE, AGENT_BLOCK_OPEN } from '@shared/constants/agentBlocks';
|
import { AGENT_BLOCK_CLOSE, AGENT_BLOCK_OPEN } from '@shared/constants/agentBlocks';
|
||||||
import { KANBAN_COLUMN_IDS } from '@shared/constants/kanban';
|
import { KANBAN_COLUMN_IDS } from '@shared/constants/kanban';
|
||||||
import { MAX_TEXT_LENGTH } from '@shared/constants/teamLimits';
|
import { MAX_TEXT_LENGTH } from '@shared/constants/teamLimits';
|
||||||
import type { CliArgsValidationResult } from '@shared/utils/cliArgsParser';
|
import {
|
||||||
import { extractFlagsFromHelp, extractUserFlags, PROTECTED_CLI_FLAGS } from '@shared/utils/cliArgsParser';
|
extractFlagsFromHelp,
|
||||||
|
extractUserFlags,
|
||||||
|
PROTECTED_CLI_FLAGS,
|
||||||
|
} from '@shared/utils/cliArgsParser';
|
||||||
import { createLogger } from '@shared/utils/logger';
|
import { createLogger } from '@shared/utils/logger';
|
||||||
import { isRateLimitMessage } from '@shared/utils/rateLimitDetector';
|
import { isRateLimitMessage } from '@shared/utils/rateLimitDetector';
|
||||||
import { BrowserWindow, type IpcMain, type IpcMainInvokeEvent, Notification } from 'electron';
|
import { BrowserWindow, type IpcMain, type IpcMainInvokeEvent, Notification } from 'electron';
|
||||||
|
|
@ -122,6 +125,7 @@ import type {
|
||||||
TeamUpdateConfigRequest,
|
TeamUpdateConfigRequest,
|
||||||
UpdateKanbanPatch,
|
UpdateKanbanPatch,
|
||||||
} from '@shared/types';
|
} from '@shared/types';
|
||||||
|
import type { CliArgsValidationResult } from '@shared/utils/cliArgsParser';
|
||||||
|
|
||||||
const logger = createLogger('IPC:teams');
|
const logger = createLogger('IPC:teams');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,12 @@ interface ToolUseInfo {
|
||||||
const TEAMCTL_TASK_REGEX = /task\s+(start|complete|set-status)\s+(\d+)/;
|
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']);
|
const MCP_TASK_BOUNDARY_TOOLS = new Set(['task_start', 'task_complete', 'task_set_status']);
|
||||||
|
|
||||||
|
type DetectedMechanism = 'TaskUpdate' | 'teamctl' | 'mcp' | 'none';
|
||||||
|
|
||||||
function pickDetectedMechanism(
|
function pickDetectedMechanism(
|
||||||
current: 'TaskUpdate' | 'teamctl' | 'mcp' | 'none',
|
current: DetectedMechanism,
|
||||||
next: 'TaskUpdate' | 'teamctl' | 'mcp'
|
next: Exclude<DetectedMechanism, 'none'>
|
||||||
): 'TaskUpdate' | 'teamctl' | 'mcp' | 'none' {
|
): DetectedMechanism {
|
||||||
const priority = {
|
const priority = {
|
||||||
none: 0,
|
none: 0,
|
||||||
teamctl: 1,
|
teamctl: 1,
|
||||||
|
|
@ -75,7 +77,7 @@ export class TaskBoundaryParser {
|
||||||
const boundaries: TaskBoundary[] = [];
|
const boundaries: TaskBoundary[] = [];
|
||||||
const allToolUsesByLine = new Map<number, ToolUseInfo[]>();
|
const allToolUsesByLine = new Map<number, ToolUseInfo[]>();
|
||||||
let lineNumber = 0;
|
let lineNumber = 0;
|
||||||
let detectedMechanism: 'TaskUpdate' | 'teamctl' | 'mcp' | 'none' = 'none';
|
let detectedMechanism: DetectedMechanism = 'none';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const stream = createReadStream(filePath, { encoding: 'utf8' });
|
const stream = createReadStream(filePath, { encoding: 'utf8' });
|
||||||
|
|
|
||||||
|
|
@ -5254,10 +5254,18 @@ export class TeamProvisioningService {
|
||||||
throw new Error('Claude CLI not found');
|
throw new Error('Claude CLI not found');
|
||||||
}
|
}
|
||||||
const { env } = await this.buildProvisioningEnv();
|
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();
|
const output = (result.stdout + '\n' + result.stderr).trim();
|
||||||
if (!output) {
|
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.helpOutputCache = output;
|
||||||
this.helpOutputCacheTime = Date.now();
|
this.helpOutputCacheTime = Date.now();
|
||||||
|
|
|
||||||
|
|
@ -106,13 +106,13 @@ import {
|
||||||
TEAM_TOOL_APPROVAL_EVENT,
|
TEAM_TOOL_APPROVAL_EVENT,
|
||||||
TEAM_TOOL_APPROVAL_RESPOND,
|
TEAM_TOOL_APPROVAL_RESPOND,
|
||||||
TEAM_UPDATE_CONFIG,
|
TEAM_UPDATE_CONFIG,
|
||||||
TEAM_VALIDATE_CLI_ARGS,
|
|
||||||
TEAM_UPDATE_KANBAN,
|
TEAM_UPDATE_KANBAN,
|
||||||
TEAM_UPDATE_KANBAN_COLUMN_ORDER,
|
TEAM_UPDATE_KANBAN_COLUMN_ORDER,
|
||||||
TEAM_UPDATE_MEMBER_ROLE,
|
TEAM_UPDATE_MEMBER_ROLE,
|
||||||
TEAM_UPDATE_TASK_FIELDS,
|
TEAM_UPDATE_TASK_FIELDS,
|
||||||
TEAM_UPDATE_TASK_OWNER,
|
TEAM_UPDATE_TASK_OWNER,
|
||||||
TEAM_UPDATE_TASK_STATUS,
|
TEAM_UPDATE_TASK_STATUS,
|
||||||
|
TEAM_VALIDATE_CLI_ARGS,
|
||||||
TERMINAL_DATA,
|
TERMINAL_DATA,
|
||||||
TERMINAL_EXIT,
|
TERMINAL_EXIT,
|
||||||
TERMINAL_KILL,
|
TERMINAL_KILL,
|
||||||
|
|
@ -222,7 +222,6 @@ import type {
|
||||||
UpdateKanbanPatch,
|
UpdateKanbanPatch,
|
||||||
WslClaudeRootCandidate,
|
WslClaudeRootCandidate,
|
||||||
} from '@shared/types';
|
} from '@shared/types';
|
||||||
import type { CliArgsValidationResult } from '@shared/utils/cliArgsParser';
|
|
||||||
import type {
|
import type {
|
||||||
BinaryPreviewResult,
|
BinaryPreviewResult,
|
||||||
CreateDirResponse,
|
CreateDirResponse,
|
||||||
|
|
@ -239,6 +238,7 @@ import type {
|
||||||
WriteFileResponse,
|
WriteFileResponse,
|
||||||
} from '@shared/types/editor';
|
} from '@shared/types/editor';
|
||||||
import type { PtySpawnOptions } from '@shared/types/terminal';
|
import type { PtySpawnOptions } from '@shared/types/terminal';
|
||||||
|
import type { CliArgsValidationResult } from '@shared/utils/cliArgsParser';
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
// IPC Result Types and Helpers
|
// IPC Result Types and Helpers
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
* Shared between preload and renderer processes.
|
* Shared between preload and renderer processes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import type { CliArgsValidationResult } from '../utils/cliArgsParser';
|
||||||
import type { CliInstallerAPI } from './cliInstaller';
|
import type { CliInstallerAPI } from './cliInstaller';
|
||||||
import type { EditorAPI, ProjectAPI } from './editor';
|
import type { EditorAPI, ProjectAPI } from './editor';
|
||||||
import type {
|
import type {
|
||||||
|
|
@ -64,7 +65,6 @@ import type {
|
||||||
UpdateKanbanPatch,
|
UpdateKanbanPatch,
|
||||||
} from './team';
|
} from './team';
|
||||||
import type { TerminalAPI } from './terminal';
|
import type { TerminalAPI } from './terminal';
|
||||||
import type { CliArgsValidationResult } from '../utils/cliArgsParser';
|
|
||||||
import type { WaterfallData } from './visualization';
|
import type { WaterfallData } from './visualization';
|
||||||
import type {
|
import type {
|
||||||
ConversationGroup,
|
ConversationGroup,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue