無用な後方互換削除
This commit is contained in:
parent
6378ee6174
commit
887365c4eb
@ -14,20 +14,20 @@ import {
|
||||
type InstructionContext,
|
||||
} from '../core/workflow/index.js';
|
||||
|
||||
// Backward-compatible function wrappers for test readability
|
||||
function buildInstruction(step: WorkflowStep, ctx: InstructionContext): string {
|
||||
// Function wrappers for test readability
|
||||
function buildInstruction(step: WorkflowMovement, ctx: InstructionContext): string {
|
||||
return new InstructionBuilder(step, ctx).build();
|
||||
}
|
||||
function buildReportInstruction(step: WorkflowStep, ctx: ReportInstructionContext): string {
|
||||
function buildReportInstruction(step: WorkflowMovement, ctx: ReportInstructionContext): string {
|
||||
return new ReportInstructionBuilder(step, ctx).build();
|
||||
}
|
||||
function buildStatusJudgmentInstruction(step: WorkflowStep, ctx: StatusJudgmentContext): string {
|
||||
function buildStatusJudgmentInstruction(step: WorkflowMovement, ctx: StatusJudgmentContext): string {
|
||||
return new StatusJudgmentBuilder(step, ctx).build();
|
||||
}
|
||||
import type { WorkflowStep, WorkflowRule } from '../core/models/index.js';
|
||||
import type { WorkflowMovement, WorkflowRule } from '../core/models/index.js';
|
||||
|
||||
|
||||
function createMinimalStep(template: string): WorkflowStep {
|
||||
function createMinimalStep(template: string): WorkflowMovement {
|
||||
return {
|
||||
name: 'test-step',
|
||||
agent: 'test-agent',
|
||||
|
||||
@ -13,7 +13,7 @@ import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { setMockScenario, resetScenario } from '../infra/mock/index.js';
|
||||
import type { WorkflowConfig, WorkflowStep, WorkflowRule } from '../core/models/index.js';
|
||||
import type { WorkflowConfig, WorkflowMovement, WorkflowRule } from '../core/models/index.js';
|
||||
import { callAiJudge, detectRuleIndex } from '../infra/claude/index.js';
|
||||
|
||||
// --- Mocks ---
|
||||
@ -59,7 +59,7 @@ function makeRule(condition: string, next: string): WorkflowRule {
|
||||
return { condition, next };
|
||||
}
|
||||
|
||||
function makeMovement(name: string, agentPath: string, rules: WorkflowRule[]): WorkflowStep {
|
||||
function makeMovement(name: string, agentPath: string, rules: WorkflowRule[]): WorkflowMovement {
|
||||
return {
|
||||
name,
|
||||
agent: `./agents/${name}.md`,
|
||||
|
||||
@ -14,7 +14,7 @@ import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { setMockScenario, resetScenario } from '../infra/mock/index.js';
|
||||
import type { WorkflowConfig, WorkflowStep, WorkflowRule } from '../core/models/index.js';
|
||||
import type { WorkflowConfig, WorkflowMovement, WorkflowRule } from '../core/models/index.js';
|
||||
import { callAiJudge, detectRuleIndex } from '../infra/claude/index.js';
|
||||
|
||||
// --- Mocks ---
|
||||
@ -89,7 +89,7 @@ function makeMovement(
|
||||
agentPath: string,
|
||||
rules: WorkflowRule[],
|
||||
options: { report?: string | { label: string; path: string }[]; edit?: boolean } = {},
|
||||
): WorkflowStep {
|
||||
): WorkflowMovement {
|
||||
return {
|
||||
name,
|
||||
agent: './agents/agent.md',
|
||||
|
||||
@ -14,7 +14,7 @@ import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { setMockScenario, resetScenario } from '../infra/mock/index.js';
|
||||
import type { WorkflowConfig, WorkflowStep, WorkflowRule } from '../core/models/index.js';
|
||||
import type { WorkflowConfig, WorkflowMovement, WorkflowRule } from '../core/models/index.js';
|
||||
import { callAiJudge, detectRuleIndex } from '../infra/claude/index.js';
|
||||
|
||||
// --- Mocks (minimal — only infrastructure, not core logic) ---
|
||||
@ -62,7 +62,7 @@ function makeRule(condition: string, next: string): WorkflowRule {
|
||||
return { condition, next };
|
||||
}
|
||||
|
||||
function makeMovement(name: string, agentPath: string, rules: WorkflowRule[]): WorkflowStep {
|
||||
function makeMovement(name: string, agentPath: string, rules: WorkflowRule[]): WorkflowMovement {
|
||||
return {
|
||||
name,
|
||||
agent: `./agents/${name}.md`,
|
||||
|
||||
@ -8,9 +8,9 @@
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { WorkflowConfigRawSchema, ParallelSubStepRawSchema, WorkflowStepRawSchema } from '../core/models/index.js';
|
||||
import { WorkflowConfigRawSchema, ParallelSubMovementRawSchema, WorkflowMovementRawSchema } from '../core/models/index.js';
|
||||
|
||||
describe('ParallelSubStepRawSchema', () => {
|
||||
describe('ParallelSubMovementRawSchema', () => {
|
||||
it('should validate a valid parallel sub-movement', () => {
|
||||
const raw = {
|
||||
name: 'arch-review',
|
||||
@ -18,7 +18,7 @@ describe('ParallelSubStepRawSchema', () => {
|
||||
instruction_template: 'Review architecture',
|
||||
};
|
||||
|
||||
const result = ParallelSubStepRawSchema.safeParse(raw);
|
||||
const result = ParallelSubMovementRawSchema.safeParse(raw);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
@ -28,7 +28,7 @@ describe('ParallelSubStepRawSchema', () => {
|
||||
instruction_template: 'Do something',
|
||||
};
|
||||
|
||||
const result = ParallelSubStepRawSchema.safeParse(raw);
|
||||
const result = ParallelSubMovementRawSchema.safeParse(raw);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
@ -45,7 +45,7 @@ describe('ParallelSubStepRawSchema', () => {
|
||||
pass_previous_response: false,
|
||||
};
|
||||
|
||||
const result = ParallelSubStepRawSchema.safeParse(raw);
|
||||
const result = ParallelSubMovementRawSchema.safeParse(raw);
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.data.agent_name).toBe('Coder');
|
||||
@ -65,7 +65,7 @@ describe('ParallelSubStepRawSchema', () => {
|
||||
],
|
||||
};
|
||||
|
||||
const result = ParallelSubStepRawSchema.safeParse(raw);
|
||||
const result = ParallelSubMovementRawSchema.safeParse(raw);
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.data.rules).toHaveLength(2);
|
||||
@ -73,7 +73,7 @@ describe('ParallelSubStepRawSchema', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('WorkflowStepRawSchema with parallel', () => {
|
||||
describe('WorkflowMovementRawSchema with parallel', () => {
|
||||
it('should accept a movement with parallel sub-movements (no agent)', () => {
|
||||
const raw = {
|
||||
name: 'parallel-review',
|
||||
@ -86,7 +86,7 @@ describe('WorkflowStepRawSchema with parallel', () => {
|
||||
],
|
||||
};
|
||||
|
||||
const result = WorkflowStepRawSchema.safeParse(raw);
|
||||
const result = WorkflowMovementRawSchema.safeParse(raw);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
@ -96,7 +96,7 @@ describe('WorkflowStepRawSchema with parallel', () => {
|
||||
instruction_template: 'Do something',
|
||||
};
|
||||
|
||||
const result = WorkflowStepRawSchema.safeParse(raw);
|
||||
const result = WorkflowMovementRawSchema.safeParse(raw);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
@ -107,7 +107,7 @@ describe('WorkflowStepRawSchema with parallel', () => {
|
||||
instruction_template: 'Code something',
|
||||
};
|
||||
|
||||
const result = WorkflowStepRawSchema.safeParse(raw);
|
||||
const result = WorkflowMovementRawSchema.safeParse(raw);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
@ -117,7 +117,7 @@ describe('WorkflowStepRawSchema with parallel', () => {
|
||||
parallel: [],
|
||||
};
|
||||
|
||||
const result = WorkflowStepRawSchema.safeParse(raw);
|
||||
const result = WorkflowMovementRawSchema.safeParse(raw);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
});
|
||||
@ -194,7 +194,7 @@ describe('ai() condition in WorkflowRuleSchema', () => {
|
||||
],
|
||||
};
|
||||
|
||||
const result = WorkflowStepRawSchema.safeParse(raw);
|
||||
const result = WorkflowMovementRawSchema.safeParse(raw);
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.data.rules?.[0].condition).toBe('ai("All reviews approved")');
|
||||
@ -212,7 +212,7 @@ describe('ai() condition in WorkflowRuleSchema', () => {
|
||||
],
|
||||
};
|
||||
|
||||
const result = WorkflowStepRawSchema.safeParse(raw);
|
||||
const result = WorkflowMovementRawSchema.safeParse(raw);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
});
|
||||
@ -299,7 +299,7 @@ describe('all()/any() aggregate condition regex parsing', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('all()/any() condition in WorkflowStepRawSchema', () => {
|
||||
describe('all()/any() condition in WorkflowMovementRawSchema', () => {
|
||||
it('should accept all() condition as a string', () => {
|
||||
const raw = {
|
||||
name: 'parallel-review',
|
||||
@ -312,7 +312,7 @@ describe('all()/any() condition in WorkflowStepRawSchema', () => {
|
||||
],
|
||||
};
|
||||
|
||||
const result = WorkflowStepRawSchema.safeParse(raw);
|
||||
const result = WorkflowMovementRawSchema.safeParse(raw);
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.data.rules?.[0].condition).toBe('all("approved")');
|
||||
@ -333,7 +333,7 @@ describe('all()/any() condition in WorkflowStepRawSchema', () => {
|
||||
],
|
||||
};
|
||||
|
||||
const result = WorkflowStepRawSchema.safeParse(raw);
|
||||
const result = WorkflowMovementRawSchema.safeParse(raw);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@ -32,7 +32,7 @@ describe('isWorkflowPath', () => {
|
||||
|
||||
it('should return true for home directory paths', () => {
|
||||
expect(isWorkflowPath('~/workflow.yaml')).toBe(true);
|
||||
expect(isWorkflowPath('~/.takt/workflows/custom.yaml')).toBe(true);
|
||||
expect(isWorkflowPath('~/.takt/pieces/custom.yaml')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true for relative paths starting with ./', () => {
|
||||
|
||||
@ -2,5 +2,5 @@
|
||||
* Agents module - exports agent execution utilities
|
||||
*/
|
||||
|
||||
export { AgentRunner, runAgent, runCustomAgent } from './runner.js';
|
||||
export { AgentRunner, runAgent } from './runner.js';
|
||||
export type { RunAgentOptions, StreamCallback } from './types.js';
|
||||
|
||||
@ -16,7 +16,6 @@ import { createLogger } from '../shared/utils/index.js';
|
||||
import { loadTemplate } from '../shared/prompts/index.js';
|
||||
import type { RunAgentOptions } from './types.js';
|
||||
|
||||
// Re-export for backward compatibility
|
||||
export type { RunAgentOptions, StreamCallback } from './types.js';
|
||||
|
||||
const log = createLogger('runner');
|
||||
@ -225,7 +224,7 @@ export class AgentRunner {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Backward-compatible module-level functions ----
|
||||
// ---- Module-level function facade ----
|
||||
|
||||
const defaultRunner = new AgentRunner();
|
||||
|
||||
@ -236,11 +235,3 @@ export async function runAgent(
|
||||
): Promise<AgentResponse> {
|
||||
return defaultRunner.run(agentSpec, task, options);
|
||||
}
|
||||
|
||||
export async function runCustomAgent(
|
||||
agentConfig: CustomAgentConfig,
|
||||
task: string,
|
||||
options: RunAgentOptions,
|
||||
): Promise<AgentResponse> {
|
||||
return defaultRunner.runCustom(agentConfig, task, options);
|
||||
}
|
||||
|
||||
@ -10,7 +10,6 @@ export type {
|
||||
SessionState,
|
||||
WorkflowRule,
|
||||
WorkflowMovement,
|
||||
WorkflowStep,
|
||||
LoopDetectionConfig,
|
||||
WorkflowConfig,
|
||||
WorkflowState,
|
||||
|
||||
@ -158,30 +158,15 @@ export const WorkflowMovementRawSchema = z.object({
|
||||
parallel: z.array(ParallelSubMovementRawSchema).optional(),
|
||||
});
|
||||
|
||||
/** @deprecated Use WorkflowMovementRawSchema instead */
|
||||
export const WorkflowStepRawSchema = WorkflowMovementRawSchema;
|
||||
|
||||
/** @deprecated Use ParallelSubMovementRawSchema instead */
|
||||
export const ParallelSubStepRawSchema = ParallelSubMovementRawSchema;
|
||||
|
||||
/** Workflow configuration schema - raw YAML format (accepts both `movements` and legacy `steps`) */
|
||||
/** Workflow configuration schema - raw YAML format */
|
||||
export const WorkflowConfigRawSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
description: z.string().optional(),
|
||||
/** Preferred key: movements */
|
||||
movements: z.array(WorkflowMovementRawSchema).min(1).optional(),
|
||||
/** @deprecated Use `movements` instead */
|
||||
steps: z.array(WorkflowMovementRawSchema).min(1).optional(),
|
||||
/** Preferred key: initial_movement */
|
||||
movements: z.array(WorkflowMovementRawSchema).min(1),
|
||||
initial_movement: z.string().optional(),
|
||||
/** @deprecated Use `initial_movement` instead */
|
||||
initial_step: z.string().optional(),
|
||||
max_iterations: z.number().int().positive().optional().default(10),
|
||||
answer_agent: z.string().optional(),
|
||||
}).refine(
|
||||
(data) => (data.movements && data.movements.length > 0) || (data.steps && data.steps.length > 0),
|
||||
{ message: 'Workflow must have at least one movement (use `movements` or legacy `steps` key)' }
|
||||
);
|
||||
});
|
||||
|
||||
/** Custom agent configuration schema */
|
||||
export const CustomAgentConfigSchema = z.object({
|
||||
|
||||
@ -29,7 +29,6 @@ export type {
|
||||
ReportConfig,
|
||||
ReportObjectConfig,
|
||||
WorkflowMovement,
|
||||
WorkflowStep,
|
||||
LoopDetectionConfig,
|
||||
WorkflowConfig,
|
||||
WorkflowState,
|
||||
|
||||
@ -83,9 +83,6 @@ export interface WorkflowMovement {
|
||||
parallel?: WorkflowMovement[];
|
||||
}
|
||||
|
||||
/** @deprecated Use WorkflowMovement instead */
|
||||
export type WorkflowStep = WorkflowMovement;
|
||||
|
||||
/** Loop detection configuration */
|
||||
export interface LoopDetectionConfig {
|
||||
/** Maximum consecutive runs of the same step before triggering (default: 10) */
|
||||
|
||||
@ -9,11 +9,6 @@
|
||||
export const COMPLETE_MOVEMENT = 'COMPLETE';
|
||||
export const ABORT_MOVEMENT = 'ABORT';
|
||||
|
||||
/** @deprecated Use COMPLETE_MOVEMENT instead */
|
||||
export const COMPLETE_STEP = COMPLETE_MOVEMENT;
|
||||
/** @deprecated Use ABORT_MOVEMENT instead */
|
||||
export const ABORT_STEP = ABORT_MOVEMENT;
|
||||
|
||||
/** Maximum user inputs to store */
|
||||
export const MAX_USER_INPUTS = 100;
|
||||
export const MAX_INPUT_LENGTH = 10000;
|
||||
|
||||
@ -32,7 +32,6 @@ import { ParallelRunner } from './ParallelRunner.js';
|
||||
|
||||
const log = createLogger('engine');
|
||||
|
||||
// Re-export types for backward compatibility
|
||||
export type {
|
||||
WorkflowEvents,
|
||||
UserInputRequest,
|
||||
@ -41,7 +40,7 @@ export type {
|
||||
IterationLimitCallback,
|
||||
WorkflowEngineOptions,
|
||||
} from '../types.js';
|
||||
export { COMPLETE_MOVEMENT, ABORT_MOVEMENT, COMPLETE_STEP, ABORT_STEP } from '../constants.js';
|
||||
export { COMPLETE_MOVEMENT, ABORT_MOVEMENT } from '../constants.js';
|
||||
|
||||
/** Workflow engine for orchestrating agent execution */
|
||||
export class WorkflowEngine extends EventEmitter {
|
||||
|
||||
@ -76,8 +76,6 @@ export class StateManager {
|
||||
}
|
||||
}
|
||||
|
||||
// --- Backward-compatible function facades ---
|
||||
|
||||
/**
|
||||
* Create initial workflow state from config and options.
|
||||
*/
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
export { WorkflowEngine } from './engine/index.js';
|
||||
|
||||
// Constants
|
||||
export { COMPLETE_MOVEMENT, ABORT_MOVEMENT, COMPLETE_STEP, ABORT_STEP, ERROR_MESSAGES } from './constants.js';
|
||||
export { COMPLETE_MOVEMENT, ABORT_MOVEMENT, ERROR_MESSAGES } from './constants.js';
|
||||
|
||||
// Types
|
||||
export type {
|
||||
|
||||
@ -19,7 +19,7 @@ export interface ReportInstructionContext {
|
||||
cwd: string;
|
||||
/** Report directory path */
|
||||
reportDir: string;
|
||||
/** Movement iteration (for {step_iteration} replacement) */
|
||||
/** Movement iteration (for {movement_iteration} replacement) */
|
||||
movementIteration: number;
|
||||
/** Language */
|
||||
language?: Language;
|
||||
|
||||
@ -18,7 +18,7 @@ export function escapeTemplateChars(str: string): string {
|
||||
* Replace template placeholders in the instruction_template body.
|
||||
*
|
||||
* These placeholders may still be used in instruction_template for
|
||||
* backward compatibility or special cases.
|
||||
* special cases or legacy templates.
|
||||
*/
|
||||
export function replaceTemplatePlaceholders(
|
||||
template: string,
|
||||
@ -34,8 +34,6 @@ export function replaceTemplatePlaceholders(
|
||||
result = result.replace(/\{iteration\}/g, String(context.iteration));
|
||||
result = result.replace(/\{max_iterations\}/g, String(context.maxIterations));
|
||||
result = result.replace(/\{movement_iteration\}/g, String(context.movementIteration));
|
||||
// @deprecated Use {movement_iteration} instead
|
||||
result = result.replace(/\{step_iteration\}/g, String(context.movementIteration));
|
||||
|
||||
// Replace {previous_response}
|
||||
if (step.passPreviousResponse) {
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
import type { PermissionResult, PermissionUpdate } from '@anthropic-ai/claude-agent-sdk';
|
||||
import type { WorkflowMovement, WorkflowStep, AgentResponse, WorkflowState, Language } from '../models/types.js';
|
||||
import type { WorkflowMovement, AgentResponse, WorkflowState, Language } from '../models/types.js';
|
||||
|
||||
export type ProviderType = 'claude' | 'codex' | 'mock';
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ export async function executeTask(options: ExecuteTaskOptions): Promise<boolean>
|
||||
error(`Workflow file not found: ${workflowIdentifier}`);
|
||||
} else {
|
||||
error(`Workflow "${workflowIdentifier}" not found.`);
|
||||
info('Available workflows are in ~/.takt/workflows/ or .takt/workflows/');
|
||||
info('Available workflows are in ~/.takt/pieces/ or .takt/workflows/');
|
||||
info('Use "takt switch" to select a workflow.');
|
||||
}
|
||||
return false;
|
||||
|
||||
@ -24,7 +24,6 @@ import {
|
||||
instructBranch,
|
||||
} from './taskActions.js';
|
||||
|
||||
// Re-export for backward compatibility (tests import from this module)
|
||||
export {
|
||||
type ListAction,
|
||||
isBranchMerged,
|
||||
|
||||
@ -18,7 +18,6 @@ export {
|
||||
getCurrentWorkflow,
|
||||
setCurrentWorkflow,
|
||||
isVerboseMode,
|
||||
type ProjectPermissionMode,
|
||||
type ProjectLocalConfig,
|
||||
writeFileAtomic,
|
||||
getInputHistoryPath,
|
||||
@ -102,8 +101,8 @@ export * from './agents/index.js';
|
||||
// Workflow engine
|
||||
export {
|
||||
WorkflowEngine,
|
||||
COMPLETE_STEP,
|
||||
ABORT_STEP,
|
||||
COMPLETE_MOVEMENT,
|
||||
ABORT_MOVEMENT,
|
||||
ERROR_MESSAGES,
|
||||
determineNextMovementByRules,
|
||||
extractBlockedPrompt,
|
||||
|
||||
@ -10,7 +10,6 @@ import type { AgentResponse, Status } from '../../core/models/index.js';
|
||||
import { createLogger } from '../../shared/utils/index.js';
|
||||
import { loadTemplate } from '../../shared/prompts/index.js';
|
||||
|
||||
// Re-export for backward compatibility
|
||||
export type { ClaudeCallOptions } from './types.js';
|
||||
|
||||
const log = createLogger('client');
|
||||
@ -250,7 +249,7 @@ export class ClaudeClient {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Backward-compatible module-level functions ----
|
||||
// ---- Module-level functions ----
|
||||
|
||||
const defaultClient = new ClaudeClient();
|
||||
|
||||
|
||||
@ -174,9 +174,6 @@ export class QueryExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Backward-compatible module-level function ----
|
||||
|
||||
/** @deprecated Use QueryExecutor.execute() instead */
|
||||
export async function executeClaudeQuery(
|
||||
prompt: string,
|
||||
options: ClaudeSpawnOptions,
|
||||
|
||||
@ -54,14 +54,14 @@ export type {
|
||||
// Stream conversion
|
||||
export { sdkMessageToStreamEvent } from './stream-converter.js';
|
||||
|
||||
// Options building (backward-compatible functions)
|
||||
// Options building
|
||||
export {
|
||||
createCanUseToolCallback,
|
||||
createAskUserQuestionHooks,
|
||||
buildSdkOptions,
|
||||
} from './options-builder.js';
|
||||
|
||||
// Client functions (backward-compatible)
|
||||
// Client functions
|
||||
export {
|
||||
callClaude,
|
||||
callClaudeCustom,
|
||||
|
||||
@ -177,7 +177,7 @@ export class SdkOptionsBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Backward-compatible module-level functions ----
|
||||
// ---- Module-level functions ----
|
||||
|
||||
export function createCanUseToolCallback(
|
||||
handler: PermissionHandler
|
||||
|
||||
@ -15,7 +15,6 @@ import type {
|
||||
ClaudeResult,
|
||||
} from './types.js';
|
||||
|
||||
// Re-export types for backward compatibility
|
||||
export type {
|
||||
StreamEvent,
|
||||
StreamCallback,
|
||||
@ -59,7 +58,7 @@ export async function executeClaudeCli(
|
||||
}
|
||||
|
||||
/**
|
||||
* ClaudeProcess class for backward compatibility.
|
||||
* ClaudeProcess class wrapping the SDK query function.
|
||||
* Wraps the SDK query function.
|
||||
*/
|
||||
export class ClaudeProcess {
|
||||
|
||||
@ -84,7 +84,7 @@ export class QueryRegistry {
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupt the most recently started Claude query (backward compatibility).
|
||||
* Interrupt the most recently started Claude query.
|
||||
* @returns true if a query was interrupted, false if no query was running
|
||||
*/
|
||||
interruptCurrentProcess(): boolean {
|
||||
@ -96,8 +96,6 @@ export class QueryRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Backward-compatible module-level functions ----
|
||||
|
||||
/** Generate a unique query ID */
|
||||
export function generateQueryId(): string {
|
||||
return `q-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* SDK message to stream event converter
|
||||
*
|
||||
* Converts Claude Agent SDK messages to the internal stream event format
|
||||
* for backward compatibility with the streaming display system.
|
||||
* for use with the streaming display system.
|
||||
*/
|
||||
|
||||
import type {
|
||||
@ -85,7 +85,7 @@ function extractToolResultContent(toolResult: unknown): { content: string; isErr
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert SDK message to stream event for backward compatibility.
|
||||
* Convert SDK message to stream event.
|
||||
*
|
||||
* @param message - The SDK message to convert
|
||||
* @param callback - The callback to invoke with stream events
|
||||
|
||||
@ -12,7 +12,7 @@ import type { PermissionResult } from '../../core/workflow/index.js';
|
||||
// Re-export PermissionResult for convenience
|
||||
export type { PermissionResult, PermissionUpdate };
|
||||
|
||||
/** Stream event data types (for backward compatibility) */
|
||||
/** Stream event data types */
|
||||
export interface InitEventData {
|
||||
model: string;
|
||||
sessionId: string;
|
||||
|
||||
@ -20,7 +20,6 @@ import {
|
||||
emitCodexItemUpdate,
|
||||
} from './CodexStreamHandler.js';
|
||||
|
||||
// Re-export for backward compatibility
|
||||
export type { CodexCallOptions } from './types.js';
|
||||
|
||||
const log = createLogger('codex-sdk');
|
||||
@ -199,8 +198,6 @@ export class CodexClient {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Backward-compatible module-level functions ----
|
||||
|
||||
const defaultClient = new CodexClient();
|
||||
|
||||
export async function callCodex(
|
||||
|
||||
@ -152,8 +152,6 @@ export class GlobalConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Backward-compatible module-level functions ----
|
||||
|
||||
export function invalidateGlobalConfigCache(): void {
|
||||
GlobalConfigManager.getInstance().invalidateCache();
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ export function listCustomAgents(): string[] {
|
||||
* Load agent prompt content.
|
||||
* Agents can be loaded from:
|
||||
* - ~/.takt/agents/*.md (global agents)
|
||||
* - ~/.takt/workflows/{workflow}/*.md (workflow-specific agents)
|
||||
* - ~/.takt/pieces/{workflow}/*.md (workflow-specific agents)
|
||||
*/
|
||||
export function loadAgentPrompt(agent: CustomAgentConfig): string {
|
||||
if (agent.prompt) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Configuration loader for takt
|
||||
*
|
||||
* Re-exports from specialized loaders for backward compatibility.
|
||||
* Re-exports from specialized loaders.
|
||||
*/
|
||||
|
||||
// Workflow loading
|
||||
|
||||
@ -215,14 +215,11 @@ function normalizeStepFromRaw(step: RawStep, workflowDir: string): WorkflowMovem
|
||||
export function normalizeWorkflowConfig(raw: unknown, workflowDir: string): WorkflowConfig {
|
||||
const parsed = WorkflowConfigRawSchema.parse(raw);
|
||||
|
||||
// Prefer `movements` over legacy `steps`
|
||||
const rawMovements = parsed.movements ?? parsed.steps ?? [];
|
||||
const movements: WorkflowMovement[] = rawMovements.map((step) =>
|
||||
const movements: WorkflowMovement[] = parsed.movements.map((step) =>
|
||||
normalizeStepFromRaw(step, workflowDir),
|
||||
);
|
||||
|
||||
// Prefer `initial_movement` over legacy `initial_step`
|
||||
const initialMovement = parsed.initial_movement ?? parsed.initial_step ?? movements[0]?.name ?? '';
|
||||
const initialMovement = parsed.initial_movement ?? movements[0]?.name ?? '';
|
||||
|
||||
return {
|
||||
name: parsed.name,
|
||||
|
||||
@ -96,8 +96,8 @@ function resolveWorkflowFile(workflowsDir: string, name: string): string | null
|
||||
*
|
||||
* Priority:
|
||||
* 1. Project-local workflows → .takt/workflows/{name}.yaml
|
||||
* 2. User workflows → ~/.takt/workflows/{name}.yaml
|
||||
* 3. Builtin workflows → resources/global/{lang}/workflows/{name}.yaml
|
||||
* 2. User workflows → ~/.takt/pieces/{name}.yaml
|
||||
* 3. Builtin workflows → resources/global/{lang}/pieces/{name}.yaml
|
||||
*/
|
||||
export function loadWorkflow(
|
||||
name: string,
|
||||
@ -115,14 +115,6 @@ export function loadWorkflow(
|
||||
return loadWorkflowFromFile(globalMatch);
|
||||
}
|
||||
|
||||
// Fallback: legacy ~/.takt/workflows/ directory (deprecated)
|
||||
const legacyGlobalDir = join(homedir(), '.takt', 'workflows');
|
||||
const legacyMatch = resolveWorkflowFile(legacyGlobalDir, name);
|
||||
if (legacyMatch) {
|
||||
log.info(`Loading workflow from deprecated path ~/.takt/workflows/. Please move to ~/.takt/pieces/.`);
|
||||
return loadWorkflowFromFile(legacyMatch);
|
||||
}
|
||||
|
||||
return getBuiltinWorkflow(name);
|
||||
}
|
||||
|
||||
@ -229,12 +221,6 @@ function getWorkflowDirs(cwd: string): { dir: string; source: WorkflowSource; di
|
||||
if (getBuiltinWorkflowsEnabled()) {
|
||||
dirs.push({ dir: getBuiltinPiecesDir(lang), disabled, source: 'builtin' });
|
||||
}
|
||||
// Legacy fallback: ~/.takt/workflows/ (deprecated, lowest user priority)
|
||||
const legacyGlobalDir = join(homedir(), '.takt', 'workflows');
|
||||
if (existsSync(legacyGlobalDir)) {
|
||||
log.info(`Scanning deprecated path ~/.takt/workflows/. Please move to ~/.takt/pieces/.`);
|
||||
dirs.push({ dir: legacyGlobalDir, source: 'user' });
|
||||
}
|
||||
dirs.push({ dir: getGlobalPiecesDir(), source: 'user' });
|
||||
dirs.push({ dir: join(getProjectConfigDir(cwd), 'workflows'), source: 'project' });
|
||||
return dirs;
|
||||
@ -245,7 +231,7 @@ function getWorkflowDirs(cwd: string): { dir: string; source: WorkflowSource; di
|
||||
*
|
||||
* Priority (later entries override earlier):
|
||||
* 1. Builtin workflows
|
||||
* 2. User workflows (~/.takt/workflows/)
|
||||
* 2. User workflows (~/.takt/pieces/)
|
||||
* 3. Project-local workflows (.takt/workflows/)
|
||||
*/
|
||||
export function loadAllWorkflowsWithSources(cwd: string): Map<string, WorkflowWithSource> {
|
||||
@ -269,7 +255,7 @@ export function loadAllWorkflowsWithSources(cwd: string): Map<string, WorkflowWi
|
||||
*
|
||||
* Priority (later entries override earlier):
|
||||
* 1. Builtin workflows
|
||||
* 2. User workflows (~/.takt/workflows/)
|
||||
* 2. User workflows (~/.takt/pieces/)
|
||||
* 3. Project-local workflows (.takt/workflows/)
|
||||
*/
|
||||
export function loadAllWorkflows(cwd: string): Map<string, WorkflowConfig> {
|
||||
|
||||
@ -26,9 +26,6 @@ export function getGlobalPiecesDir(): string {
|
||||
return join(getGlobalConfigDir(), 'pieces');
|
||||
}
|
||||
|
||||
/** @deprecated Use getGlobalPiecesDir() instead */
|
||||
export const getGlobalWorkflowsDir = getGlobalPiecesDir;
|
||||
|
||||
/** Get takt global logs directory */
|
||||
export function getGlobalLogsDir(): string {
|
||||
return join(getGlobalConfigDir(), 'logs');
|
||||
@ -44,9 +41,6 @@ export function getBuiltinPiecesDir(lang: Language): string {
|
||||
return join(getLanguageResourcesDir(lang), 'pieces');
|
||||
}
|
||||
|
||||
/** @deprecated Use getBuiltinPiecesDir() instead */
|
||||
export const getBuiltinWorkflowsDir = getBuiltinPiecesDir;
|
||||
|
||||
/** Get builtin agents directory (resources/global/{lang}/agents) */
|
||||
export function getBuiltinAgentsDir(lang: Language): string {
|
||||
return join(getLanguageResourcesDir(lang), 'agents');
|
||||
@ -102,7 +96,7 @@ export {
|
||||
type ProjectLocalConfig,
|
||||
} from './project/projectConfig.js';
|
||||
|
||||
// Re-export session storage functions for backward compatibility
|
||||
// Re-export session storage functions
|
||||
export {
|
||||
writeFileAtomic,
|
||||
getInputHistoryPath,
|
||||
|
||||
@ -10,7 +10,6 @@ export {
|
||||
setCurrentWorkflow,
|
||||
isVerboseMode,
|
||||
type PermissionMode,
|
||||
type ProjectPermissionMode,
|
||||
type ProjectLocalConfig,
|
||||
} from './projectConfig.js';
|
||||
|
||||
|
||||
@ -8,9 +8,9 @@ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
||||
import { join, resolve } from 'node:path';
|
||||
import { parse, stringify } from 'yaml';
|
||||
import { copyProjectResourcesToDir } from '../../resources/index.js';
|
||||
import type { PermissionMode, ProjectPermissionMode, ProjectLocalConfig } from '../types.js';
|
||||
import type { PermissionMode, ProjectLocalConfig } from '../types.js';
|
||||
|
||||
export type { PermissionMode, ProjectPermissionMode, ProjectLocalConfig };
|
||||
export type { PermissionMode, ProjectLocalConfig };
|
||||
|
||||
/** Default project configuration */
|
||||
const DEFAULT_PROJECT_CONFIG: ProjectLocalConfig = {
|
||||
|
||||
@ -12,9 +12,6 @@ import type { WorkflowCategoryConfigNode } from '../../core/models/schemas.js';
|
||||
*/
|
||||
export type PermissionMode = 'default' | 'sacrifice-my-pc';
|
||||
|
||||
/** @deprecated Use PermissionMode instead */
|
||||
export type ProjectPermissionMode = PermissionMode;
|
||||
|
||||
/** Project configuration stored in .takt/config.yaml */
|
||||
export interface ProjectLocalConfig {
|
||||
/** Current workflow name */
|
||||
|
||||
@ -13,7 +13,6 @@ import type {
|
||||
LatestLogPointer,
|
||||
} from '../../shared/utils/index.js';
|
||||
|
||||
// Re-export types for backward compatibility
|
||||
export type {
|
||||
SessionLog,
|
||||
NdjsonWorkflowStart,
|
||||
@ -239,8 +238,6 @@ export class SessionManager {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Backward-compatible module-level functions ----
|
||||
|
||||
const defaultManager = new SessionManager();
|
||||
|
||||
export function appendNdjsonLine(filepath: string, record: NdjsonRecord): void {
|
||||
|
||||
@ -10,7 +10,6 @@ import { CodexProvider } from './codex.js';
|
||||
import { MockProvider } from './mock.js';
|
||||
import type { Provider, ProviderType } from './types.js';
|
||||
|
||||
// Re-export types for backward compatibility
|
||||
export type { ProviderCallOptions, Provider, ProviderType } from './types.js';
|
||||
|
||||
/**
|
||||
@ -52,8 +51,6 @@ export class ProviderRegistry {
|
||||
|
||||
}
|
||||
|
||||
// ---- Backward-compatible module-level functions ----
|
||||
|
||||
export function getProvider(type: ProviderType): Provider {
|
||||
return ProviderRegistry.getInstance().get(type);
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ export class AutoCommitter {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Backward-compatible module-level function ----
|
||||
// ---- Module-level function ----
|
||||
|
||||
const defaultCommitter = new AutoCommitter();
|
||||
|
||||
|
||||
@ -248,7 +248,7 @@ export class BranchManager {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Backward-compatible module-level functions ----
|
||||
// ---- Module-level functions ----
|
||||
|
||||
const defaultManager = new BranchManager();
|
||||
|
||||
|
||||
@ -249,7 +249,7 @@ export class CloneManager {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Backward-compatible module-level functions ----
|
||||
// ---- Module-level functions ----
|
||||
|
||||
const defaultManager = new CloneManager();
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Supports both YAML (.yaml/.yml) and Markdown (.md) task files.
|
||||
* YAML files are validated against TaskFileSchema.
|
||||
* Markdown files are treated as plain text (backward compatible).
|
||||
* Markdown files are treated as plain text.
|
||||
*/
|
||||
|
||||
import * as fs from 'node:fs';
|
||||
|
||||
@ -81,7 +81,7 @@ export class TaskSummarizer {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Backward-compatible module-level function ----
|
||||
// ---- Module-level function ----
|
||||
|
||||
const defaultSummarizer = new TaskSummarizer();
|
||||
|
||||
|
||||
@ -36,8 +36,6 @@ export class AppContext {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Backward-compatible module-level functions ----
|
||||
|
||||
/** Get whether quiet mode is active (CLI flag or config, resolved in preAction) */
|
||||
export function isQuietMode(): boolean {
|
||||
return AppContext.getInstance().getQuietMode();
|
||||
|
||||
@ -175,8 +175,6 @@ export interface InteractiveSelectCallbacks<T extends string> {
|
||||
* Return null to delegate to default handler.
|
||||
*/
|
||||
onKeyPress?: (key: string, value: T, index: number) => SelectOptionItem<T>[] | null;
|
||||
/** Called when 'b' key is pressed. Returns updated options for re-render. @deprecated Use onKeyPress instead */
|
||||
onBookmark?: (value: T, index: number) => SelectOptionItem<T>[];
|
||||
/** Custom label for cancel option (default: "Cancel") */
|
||||
cancelLabel?: string;
|
||||
}
|
||||
@ -201,7 +199,7 @@ function interactiveSelect<T extends string>(
|
||||
let selectedIndex = initialIndex;
|
||||
const cancelLabel = callbacks?.cancelLabel ?? 'Cancel';
|
||||
|
||||
printHeader(message, !!callbacks?.onKeyPress || !!callbacks?.onBookmark);
|
||||
printHeader(message, !!callbacks?.onKeyPress);
|
||||
|
||||
process.stdout.write('\x1B[?7l');
|
||||
|
||||
@ -265,22 +263,9 @@ function interactiveSelect<T extends string>(
|
||||
cleanup(onKeypress);
|
||||
resolve({ selectedIndex: result.cancelIndex, finalOptions: currentOptions });
|
||||
break;
|
||||
case 'bookmark': {
|
||||
if (!callbacks?.onBookmark) break;
|
||||
// Only bookmark actual options, not the cancel row
|
||||
if (result.selectedIndex >= currentOptions.length) break;
|
||||
const item = currentOptions[result.selectedIndex];
|
||||
if (!item) break;
|
||||
const newOptions = callbacks.onBookmark(item.value, result.selectedIndex);
|
||||
// Find the same value in the new options to preserve cursor position
|
||||
const currentValue = item.value;
|
||||
currentOptions = newOptions;
|
||||
totalItems = hasCancelOption ? currentOptions.length + 1 : currentOptions.length;
|
||||
const newIdx = currentOptions.findIndex((o) => o.value === currentValue);
|
||||
selectedIndex = newIdx >= 0 ? newIdx : Math.min(selectedIndex, currentOptions.length - 1);
|
||||
totalLines = redrawMenu(currentOptions, selectedIndex, hasCancelOption, totalLines, cancelLabel);
|
||||
case 'bookmark':
|
||||
// Handled by custom onKeyPress
|
||||
break;
|
||||
}
|
||||
case 'remove_bookmark':
|
||||
// Ignore - should be handled by custom onKeyPress
|
||||
break;
|
||||
@ -299,7 +284,6 @@ function interactiveSelect<T extends string>(
|
||||
|
||||
/**
|
||||
* Prompt user to select from a list of options using cursor navigation.
|
||||
* @param callbacks.onBookmark - Called when 'b' key is pressed. Returns updated options for re-render.
|
||||
* @returns Selected option or null if cancelled
|
||||
*/
|
||||
export async function selectOption<T extends string>(
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* Log level management and formatted console output.
|
||||
*
|
||||
* LogManager is a singleton that encapsulates the current log level state.
|
||||
* Module-level functions are provided for backward compatibility.
|
||||
* Module-level functions are provided as convenient facades.
|
||||
*/
|
||||
|
||||
import chalk from 'chalk';
|
||||
@ -84,8 +84,6 @@ export class LogManager {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Backward-compatible module-level functions ----
|
||||
|
||||
export function setLogLevel(level: LogLevel): void {
|
||||
LogManager.getInstance().setLogLevel(level);
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ export class DebugLogger {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Backward-compatible module-level functions ----
|
||||
// ---- Module-level functions ----
|
||||
|
||||
export function initDebugLogger(config?: DebugConfig, projectDir?: string): void {
|
||||
DebugLogger.getInstance().init(config, projectDir);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user