takt 0.1.0 → 0.1.2
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/README.md +78 -4
- package/dist/agents/runner.d.ts +3 -0
- package/dist/agents/runner.d.ts.map +1 -1
- package/dist/agents/runner.js +70 -14
- package/dist/agents/runner.js.map +1 -1
- package/dist/claude/client.d.ts +1 -1
- package/dist/claude/client.d.ts.map +1 -1
- package/dist/claude/client.js +4 -3
- package/dist/claude/client.js.map +1 -1
- package/dist/claude/index.d.ts +1 -1
- package/dist/claude/index.d.ts.map +1 -1
- package/dist/claude/index.js.map +1 -1
- package/dist/claude/process.d.ts +1 -1
- package/dist/claude/process.d.ts.map +1 -1
- package/dist/claude/process.js.map +1 -1
- package/dist/claude/types.d.ts +7 -0
- package/dist/claude/types.d.ts.map +1 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +10 -4
- package/dist/cli.js.map +1 -1
- package/dist/codex/client.d.ts +26 -0
- package/dist/codex/client.d.ts.map +1 -0
- package/dist/codex/client.js +418 -0
- package/dist/codex/client.js.map +1 -0
- package/dist/codex/index.d.ts +5 -0
- package/dist/codex/index.d.ts.map +1 -0
- package/dist/codex/index.js +5 -0
- package/dist/codex/index.js.map +1 -0
- package/dist/commands/config.d.ts +33 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +110 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/workflow.js +1 -1
- package/dist/commands/workflow.js.map +1 -1
- package/dist/commands/workflowExecution.d.ts.map +1 -1
- package/dist/commands/workflowExecution.js +3 -1
- package/dist/commands/workflowExecution.js.map +1 -1
- package/dist/config/globalConfig.d.ts +2 -0
- package/dist/config/globalConfig.d.ts.map +1 -1
- package/dist/config/globalConfig.js +12 -0
- package/dist/config/globalConfig.js.map +1 -1
- package/dist/config/initialization.d.ts +10 -0
- package/dist/config/initialization.d.ts.map +1 -1
- package/dist/config/initialization.js +26 -4
- package/dist/config/initialization.js.map +1 -1
- package/dist/config/projectConfig.d.ts +14 -1
- package/dist/config/projectConfig.d.ts.map +1 -1
- package/dist/config/projectConfig.js +4 -0
- package/dist/config/projectConfig.js.map +1 -1
- package/dist/config/workflowLoader.d.ts.map +1 -1
- package/dist/config/workflowLoader.js +3 -0
- package/dist/config/workflowLoader.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/models/schemas.d.ts +54 -3
- package/dist/models/schemas.d.ts.map +1 -1
- package/dist/models/schemas.js +34 -46
- package/dist/models/schemas.js.map +1 -1
- package/dist/models/types.d.ts +12 -2
- package/dist/models/types.d.ts.map +1 -1
- package/dist/{interactive/prompt.d.ts → prompt/index.d.ts} +3 -1
- package/dist/prompt/index.d.ts.map +1 -0
- package/dist/{interactive/prompt.js → prompt/index.js} +11 -1
- package/dist/prompt/index.js.map +1 -0
- package/dist/resources/index.d.ts +9 -0
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +21 -2
- package/dist/resources/index.js.map +1 -1
- package/dist/utils/session.d.ts +5 -0
- package/dist/utils/session.d.ts.map +1 -1
- package/dist/utils/session.js +19 -0
- package/dist/utils/session.js.map +1 -1
- package/dist/utils/ui.d.ts +7 -0
- package/dist/utils/ui.d.ts.map +1 -1
- package/dist/utils/ui.js +51 -0
- package/dist/utils/ui.js.map +1 -1
- package/dist/workflow/engine.d.ts +10 -0
- package/dist/workflow/engine.d.ts.map +1 -1
- package/dist/workflow/engine.js +31 -0
- package/dist/workflow/engine.js.map +1 -1
- package/dist/workflow/instruction-builder.d.ts +3 -0
- package/dist/workflow/instruction-builder.d.ts.map +1 -1
- package/dist/workflow/instruction-builder.js +5 -0
- package/dist/workflow/instruction-builder.js.map +1 -1
- package/dist/workflow/transitions.d.ts.map +1 -1
- package/dist/workflow/transitions.js +1 -0
- package/dist/workflow/transitions.js.map +1 -1
- package/package.json +3 -1
- package/resources/global/en/agents/default/ai-reviewer.md +136 -0
- package/resources/global/en/agents/default/architect.md +81 -30
- package/resources/global/en/agents/default/coder.md +60 -44
- package/resources/global/en/agents/default/planner.md +78 -0
- package/resources/global/en/agents/default/security.md +67 -75
- package/resources/global/en/agents/default/supervisor.md +94 -86
- package/resources/global/en/agents/expert-review/cqrs-es-reviewer.md +199 -0
- package/resources/global/en/agents/expert-review/frontend-reviewer.md +260 -0
- package/resources/global/en/agents/expert-review/qa-reviewer.md +260 -0
- package/resources/global/en/agents/expert-review/security-reviewer.md +222 -0
- package/resources/global/en/agents/expert-review/supervisor.md +186 -0
- package/resources/global/en/config.yaml +8 -0
- package/resources/global/en/workflows/default.yaml +474 -21
- package/resources/global/en/workflows/expert-review.yaml +936 -0
- package/resources/global/en/workflows/magi.yaml +18 -0
- package/resources/global/en/workflows/research.yaml +18 -0
- package/resources/global/ja/agents/default/ai-reviewer.md +136 -0
- package/resources/global/ja/agents/default/architect.md +81 -30
- package/resources/global/ja/agents/default/coder.md +21 -6
- package/resources/global/ja/agents/default/planner.md +78 -0
- package/resources/global/ja/agents/default/security.md +20 -28
- package/resources/global/ja/agents/default/supervisor.md +54 -46
- package/resources/global/ja/agents/expert-review/cqrs-es-reviewer.md +199 -0
- package/resources/global/ja/agents/expert-review/frontend-reviewer.md +260 -0
- package/resources/global/ja/agents/expert-review/qa-reviewer.md +260 -0
- package/resources/global/ja/agents/expert-review/security-reviewer.md +222 -0
- package/resources/global/ja/agents/expert-review/supervisor.md +186 -0
- package/resources/global/ja/config.yaml +8 -0
- package/resources/global/ja/workflows/default.yaml +485 -32
- package/resources/global/ja/workflows/expert-review.yaml +936 -0
- package/resources/global/ja/workflows/magi.yaml +18 -0
- package/resources/global/ja/workflows/research.yaml +18 -0
- package/dist/cli/agentExecution.d.ts +0 -16
- package/dist/cli/agentExecution.d.ts.map +0 -1
- package/dist/cli/agentExecution.js +0 -40
- package/dist/cli/agentExecution.js.map +0 -1
- package/dist/cli/help.d.ts +0 -8
- package/dist/cli/help.d.ts.map +0 -1
- package/dist/cli/help.js +0 -46
- package/dist/cli/help.js.map +0 -1
- package/dist/cli/index.d.ts +0 -8
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -8
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/taskBatch.d.ts +0 -8
- package/dist/cli/taskBatch.d.ts.map +0 -1
- package/dist/cli/taskBatch.js +0 -69
- package/dist/cli/taskBatch.js.map +0 -1
- package/dist/cli/workflowExecution.d.ts +0 -18
- package/dist/cli/workflowExecution.d.ts.map +0 -1
- package/dist/cli/workflowExecution.js +0 -112
- package/dist/cli/workflowExecution.js.map +0 -1
- package/dist/commands/agentExecution.d.ts +0 -8
- package/dist/commands/agentExecution.d.ts.map +0 -1
- package/dist/commands/agentExecution.js +0 -44
- package/dist/commands/agentExecution.js.map +0 -1
- package/dist/interactive/commands/agent.d.ts +0 -7
- package/dist/interactive/commands/agent.d.ts.map +0 -1
- package/dist/interactive/commands/agent.js +0 -65
- package/dist/interactive/commands/agent.js.map +0 -1
- package/dist/interactive/commands/basic.d.ts +0 -7
- package/dist/interactive/commands/basic.d.ts.map +0 -1
- package/dist/interactive/commands/basic.js +0 -81
- package/dist/interactive/commands/basic.js.map +0 -1
- package/dist/interactive/commands/index.d.ts +0 -12
- package/dist/interactive/commands/index.d.ts.map +0 -1
- package/dist/interactive/commands/index.js +0 -14
- package/dist/interactive/commands/index.js.map +0 -1
- package/dist/interactive/commands/registry.d.ts +0 -41
- package/dist/interactive/commands/registry.d.ts.map +0 -1
- package/dist/interactive/commands/registry.js +0 -37
- package/dist/interactive/commands/registry.js.map +0 -1
- package/dist/interactive/commands/session.d.ts +0 -7
- package/dist/interactive/commands/session.d.ts.map +0 -1
- package/dist/interactive/commands/session.js +0 -75
- package/dist/interactive/commands/session.js.map +0 -1
- package/dist/interactive/commands/task.d.ts +0 -7
- package/dist/interactive/commands/task.d.ts.map +0 -1
- package/dist/interactive/commands/task.js +0 -156
- package/dist/interactive/commands/task.js.map +0 -1
- package/dist/interactive/commands/workflow.d.ts +0 -7
- package/dist/interactive/commands/workflow.d.ts.map +0 -1
- package/dist/interactive/commands/workflow.js +0 -56
- package/dist/interactive/commands/workflow.js.map +0 -1
- package/dist/interactive/escape-tracker.d.ts +0 -37
- package/dist/interactive/escape-tracker.d.ts.map +0 -1
- package/dist/interactive/escape-tracker.js +0 -52
- package/dist/interactive/escape-tracker.js.map +0 -1
- package/dist/interactive/handlers.d.ts +0 -24
- package/dist/interactive/handlers.d.ts.map +0 -1
- package/dist/interactive/handlers.js +0 -191
- package/dist/interactive/handlers.js.map +0 -1
- package/dist/interactive/history-manager.d.ts +0 -45
- package/dist/interactive/history-manager.d.ts.map +0 -1
- package/dist/interactive/history-manager.js +0 -91
- package/dist/interactive/history-manager.js.map +0 -1
- package/dist/interactive/index.d.ts +0 -8
- package/dist/interactive/index.d.ts.map +0 -1
- package/dist/interactive/index.js +0 -8
- package/dist/interactive/index.js.map +0 -1
- package/dist/interactive/ink/components/App.d.ts +0 -16
- package/dist/interactive/ink/components/App.d.ts.map +0 -1
- package/dist/interactive/ink/components/App.js +0 -123
- package/dist/interactive/ink/components/App.js.map +0 -1
- package/dist/interactive/ink/components/AskUserQuestion.d.ts +0 -16
- package/dist/interactive/ink/components/AskUserQuestion.d.ts.map +0 -1
- package/dist/interactive/ink/components/AskUserQuestion.js +0 -139
- package/dist/interactive/ink/components/AskUserQuestion.js.map +0 -1
- package/dist/interactive/ink/components/Header.d.ts +0 -20
- package/dist/interactive/ink/components/Header.d.ts.map +0 -1
- package/dist/interactive/ink/components/Header.js +0 -7
- package/dist/interactive/ink/components/Header.js.map +0 -1
- package/dist/interactive/ink/components/HelpView.d.ts +0 -13
- package/dist/interactive/ink/components/HelpView.d.ts.map +0 -1
- package/dist/interactive/ink/components/HelpView.js +0 -45
- package/dist/interactive/ink/components/HelpView.js.map +0 -1
- package/dist/interactive/ink/components/IterationLimit.d.ts +0 -19
- package/dist/interactive/ink/components/IterationLimit.d.ts.map +0 -1
- package/dist/interactive/ink/components/IterationLimit.js +0 -59
- package/dist/interactive/ink/components/IterationLimit.js.map +0 -1
- package/dist/interactive/ink/components/ModalRouter.d.ts +0 -11
- package/dist/interactive/ink/components/ModalRouter.d.ts.map +0 -1
- package/dist/interactive/ink/components/ModalRouter.js +0 -71
- package/dist/interactive/ink/components/ModalRouter.js.map +0 -1
- package/dist/interactive/ink/components/PermissionPrompt.d.ts +0 -17
- package/dist/interactive/ink/components/PermissionPrompt.d.ts.map +0 -1
- package/dist/interactive/ink/components/PermissionPrompt.js +0 -102
- package/dist/interactive/ink/components/PermissionPrompt.js.map +0 -1
- package/dist/interactive/ink/components/PromptInput.d.ts +0 -26
- package/dist/interactive/ink/components/PromptInput.d.ts.map +0 -1
- package/dist/interactive/ink/components/PromptInput.js +0 -70
- package/dist/interactive/ink/components/PromptInput.js.map +0 -1
- package/dist/interactive/ink/components/Spinner.d.ts +0 -14
- package/dist/interactive/ink/components/Spinner.d.ts.map +0 -1
- package/dist/interactive/ink/components/Spinner.js +0 -8
- package/dist/interactive/ink/components/Spinner.js.map +0 -1
- package/dist/interactive/ink/components/StreamingOutput.d.ts +0 -25
- package/dist/interactive/ink/components/StreamingOutput.d.ts.map +0 -1
- package/dist/interactive/ink/components/StreamingOutput.js +0 -8
- package/dist/interactive/ink/components/StreamingOutput.js.map +0 -1
- package/dist/interactive/ink/components/UserInputPrompt.d.ts +0 -18
- package/dist/interactive/ink/components/UserInputPrompt.d.ts.map +0 -1
- package/dist/interactive/ink/components/UserInputPrompt.js +0 -30
- package/dist/interactive/ink/components/UserInputPrompt.js.map +0 -1
- package/dist/interactive/ink/components/WorkflowSelector.d.ts +0 -18
- package/dist/interactive/ink/components/WorkflowSelector.d.ts.map +0 -1
- package/dist/interactive/ink/components/WorkflowSelector.js +0 -65
- package/dist/interactive/ink/components/WorkflowSelector.js.map +0 -1
- package/dist/interactive/ink/constants.d.ts +0 -8
- package/dist/interactive/ink/constants.d.ts.map +0 -1
- package/dist/interactive/ink/constants.js +0 -8
- package/dist/interactive/ink/constants.js.map +0 -1
- package/dist/interactive/ink/context/AppContext.d.ts +0 -26
- package/dist/interactive/ink/context/AppContext.d.ts.map +0 -1
- package/dist/interactive/ink/context/AppContext.js +0 -30
- package/dist/interactive/ink/context/AppContext.js.map +0 -1
- package/dist/interactive/ink/context/appReducer.d.ts +0 -13
- package/dist/interactive/ink/context/appReducer.d.ts.map +0 -1
- package/dist/interactive/ink/context/appReducer.js +0 -183
- package/dist/interactive/ink/context/appReducer.js.map +0 -1
- package/dist/interactive/ink/context/types.d.ts +0 -144
- package/dist/interactive/ink/context/types.d.ts.map +0 -1
- package/dist/interactive/ink/context/types.js +0 -5
- package/dist/interactive/ink/context/types.js.map +0 -1
- package/dist/interactive/ink/hooks/keyDetection.d.ts +0 -116
- package/dist/interactive/ink/hooks/keyDetection.d.ts.map +0 -1
- package/dist/interactive/ink/hooks/keyDetection.js +0 -183
- package/dist/interactive/ink/hooks/keyDetection.js.map +0 -1
- package/dist/interactive/ink/hooks/multilineInputLogic.d.ts +0 -50
- package/dist/interactive/ink/hooks/multilineInputLogic.d.ts.map +0 -1
- package/dist/interactive/ink/hooks/multilineInputLogic.js +0 -150
- package/dist/interactive/ink/hooks/multilineInputLogic.js.map +0 -1
- package/dist/interactive/ink/hooks/useCommands.d.ts +0 -20
- package/dist/interactive/ink/hooks/useCommands.d.ts.map +0 -1
- package/dist/interactive/ink/hooks/useCommands.js +0 -129
- package/dist/interactive/ink/hooks/useCommands.js.map +0 -1
- package/dist/interactive/ink/hooks/useHistory.d.ts +0 -28
- package/dist/interactive/ink/hooks/useHistory.d.ts.map +0 -1
- package/dist/interactive/ink/hooks/useHistory.js +0 -59
- package/dist/interactive/ink/hooks/useHistory.js.map +0 -1
- package/dist/interactive/ink/hooks/useMultilineInput.d.ts +0 -49
- package/dist/interactive/ink/hooks/useMultilineInput.d.ts.map +0 -1
- package/dist/interactive/ink/hooks/useMultilineInput.js +0 -106
- package/dist/interactive/ink/hooks/useMultilineInput.js.map +0 -1
- package/dist/interactive/ink/hooks/usePermissionHandlers.d.ts +0 -16
- package/dist/interactive/ink/hooks/usePermissionHandlers.d.ts.map +0 -1
- package/dist/interactive/ink/hooks/usePermissionHandlers.js +0 -172
- package/dist/interactive/ink/hooks/usePermissionHandlers.js.map +0 -1
- package/dist/interactive/ink/hooks/useRawKeypress.d.ts +0 -41
- package/dist/interactive/ink/hooks/useRawKeypress.d.ts.map +0 -1
- package/dist/interactive/ink/hooks/useRawKeypress.js +0 -79
- package/dist/interactive/ink/hooks/useRawKeypress.js.map +0 -1
- package/dist/interactive/ink/hooks/useTaskQueue.d.ts +0 -32
- package/dist/interactive/ink/hooks/useTaskQueue.d.ts.map +0 -1
- package/dist/interactive/ink/hooks/useTaskQueue.js +0 -68
- package/dist/interactive/ink/hooks/useTaskQueue.js.map +0 -1
- package/dist/interactive/ink/hooks/useWorkflow.d.ts +0 -45
- package/dist/interactive/ink/hooks/useWorkflow.d.ts.map +0 -1
- package/dist/interactive/ink/hooks/useWorkflow.js +0 -93
- package/dist/interactive/ink/hooks/useWorkflow.js.map +0 -1
- package/dist/interactive/ink/hooks/useWorkflowExecution.d.ts +0 -14
- package/dist/interactive/ink/hooks/useWorkflowExecution.d.ts.map +0 -1
- package/dist/interactive/ink/hooks/useWorkflowExecution.js +0 -144
- package/dist/interactive/ink/hooks/useWorkflowExecution.js.map +0 -1
- package/dist/interactive/ink/index.d.ts +0 -30
- package/dist/interactive/ink/index.d.ts.map +0 -1
- package/dist/interactive/ink/index.js +0 -33
- package/dist/interactive/ink/index.js.map +0 -1
- package/dist/interactive/ink/utils/workflow.d.ts +0 -11
- package/dist/interactive/ink/utils/workflow.d.ts.map +0 -1
- package/dist/interactive/ink/utils/workflow.js +0 -19
- package/dist/interactive/ink/utils/workflow.js.map +0 -1
- package/dist/interactive/input-buffer.d.ts +0 -67
- package/dist/interactive/input-buffer.d.ts.map +0 -1
- package/dist/interactive/input-buffer.js +0 -162
- package/dist/interactive/input-buffer.js.map +0 -1
- package/dist/interactive/input-handlers.d.ts +0 -50
- package/dist/interactive/input-handlers.d.ts.map +0 -1
- package/dist/interactive/input-handlers.js +0 -170
- package/dist/interactive/input-handlers.js.map +0 -1
- package/dist/interactive/input.d.ts +0 -43
- package/dist/interactive/input.d.ts.map +0 -1
- package/dist/interactive/input.js +0 -74
- package/dist/interactive/input.js.map +0 -1
- package/dist/interactive/keyDetection.d.ts +0 -85
- package/dist/interactive/keyDetection.d.ts.map +0 -1
- package/dist/interactive/keyDetection.js +0 -167
- package/dist/interactive/keyDetection.js.map +0 -1
- package/dist/interactive/multilineInputLogic.d.ts +0 -30
- package/dist/interactive/multilineInputLogic.d.ts.map +0 -1
- package/dist/interactive/multilineInputLogic.js +0 -143
- package/dist/interactive/multilineInputLogic.js.map +0 -1
- package/dist/interactive/passthrough.d.ts +0 -30
- package/dist/interactive/passthrough.d.ts.map +0 -1
- package/dist/interactive/passthrough.js +0 -94
- package/dist/interactive/passthrough.js.map +0 -1
- package/dist/interactive/permission.d.ts +0 -33
- package/dist/interactive/permission.d.ts.map +0 -1
- package/dist/interactive/permission.js +0 -231
- package/dist/interactive/permission.js.map +0 -1
- package/dist/interactive/prompt.d.ts.map +0 -1
- package/dist/interactive/prompt.js.map +0 -1
- package/dist/interactive/repl.d.ts +0 -13
- package/dist/interactive/repl.d.ts.map +0 -1
- package/dist/interactive/repl.js +0 -202
- package/dist/interactive/repl.js.map +0 -1
- package/dist/interactive/types.d.ts +0 -35
- package/dist/interactive/types.d.ts.map +0 -1
- package/dist/interactive/types.js +0 -5
- package/dist/interactive/types.js.map +0 -1
- package/dist/interactive/ui.d.ts +0 -16
- package/dist/interactive/ui.d.ts.map +0 -1
- package/dist/interactive/ui.js +0 -122
- package/dist/interactive/ui.js.map +0 -1
- package/dist/interactive/user-input.d.ts +0 -26
- package/dist/interactive/user-input.d.ts.map +0 -1
- package/dist/interactive/user-input.js +0 -115
- package/dist/interactive/user-input.js.map +0 -1
- package/dist/interactive/workflow-executor.d.ts +0 -20
- package/dist/interactive/workflow-executor.d.ts.map +0 -1
- package/dist/interactive/workflow-executor.js +0 -200
- package/dist/interactive/workflow-executor.js.map +0 -1
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for application context
|
|
3
|
-
*/
|
|
4
|
-
import type { WorkflowConfig, AgentResponse, WorkflowStep } from '../../../models/types.js';
|
|
5
|
-
import type { ConversationMessage } from '../../../models/session.js';
|
|
6
|
-
import type { PermissionRequest, AskUserQuestionInput } from '../../../claude/process.js';
|
|
7
|
-
/** Modal data types (serializable, no functions) */
|
|
8
|
-
export type ModalData = {
|
|
9
|
-
type: 'none';
|
|
10
|
-
} | {
|
|
11
|
-
type: 'help';
|
|
12
|
-
} | {
|
|
13
|
-
type: 'workflowSelector';
|
|
14
|
-
} | {
|
|
15
|
-
type: 'permission';
|
|
16
|
-
request: PermissionRequest;
|
|
17
|
-
} | {
|
|
18
|
-
type: 'askUserQuestion';
|
|
19
|
-
input: AskUserQuestionInput;
|
|
20
|
-
} | {
|
|
21
|
-
type: 'iterationLimit';
|
|
22
|
-
currentIteration: number;
|
|
23
|
-
maxIterations: number;
|
|
24
|
-
currentStep: string;
|
|
25
|
-
} | {
|
|
26
|
-
type: 'userInput';
|
|
27
|
-
step: WorkflowStep;
|
|
28
|
-
response: AgentResponse;
|
|
29
|
-
};
|
|
30
|
-
/** Permission response types */
|
|
31
|
-
export type PermissionResponseType = 'allow' | 'deny' | 'always' | 'always_command' | 'sacrifice';
|
|
32
|
-
/** Resolver types for modals */
|
|
33
|
-
export type ModalResolvers = {
|
|
34
|
-
permission?: (response: PermissionResponseType) => void;
|
|
35
|
-
askUserQuestion?: (answers: Record<string, string>) => void;
|
|
36
|
-
iterationLimit?: (additional: number | null) => void;
|
|
37
|
-
userInput?: (input: string | null) => void;
|
|
38
|
-
};
|
|
39
|
-
/** Application state */
|
|
40
|
-
export interface AppState {
|
|
41
|
-
/** Current working directory */
|
|
42
|
-
cwd: string;
|
|
43
|
-
/** Current workflow name */
|
|
44
|
-
workflowName: string;
|
|
45
|
-
/** Session ID */
|
|
46
|
-
sessionId: string;
|
|
47
|
-
/** Claude session ID */
|
|
48
|
-
claudeSessionId?: string;
|
|
49
|
-
/** Conversation history */
|
|
50
|
-
conversationHistory: ConversationMessage[];
|
|
51
|
-
/** Whether the system is processing */
|
|
52
|
-
isProcessing: boolean;
|
|
53
|
-
/** Current streaming content */
|
|
54
|
-
streamContent: string;
|
|
55
|
-
/** Current thinking content */
|
|
56
|
-
thinkingContent: string;
|
|
57
|
-
/** Current agent name */
|
|
58
|
-
currentAgent: string;
|
|
59
|
-
/** Current step name */
|
|
60
|
-
currentStep: string;
|
|
61
|
-
/** Current iteration */
|
|
62
|
-
iteration: number;
|
|
63
|
-
/** Max iterations */
|
|
64
|
-
maxIterations: number;
|
|
65
|
-
/** Sacrifice mode (auto-approve everything) */
|
|
66
|
-
sacrificeMode: boolean;
|
|
67
|
-
/** Error message if any */
|
|
68
|
-
error?: string;
|
|
69
|
-
/** Info message if any (non-error feedback) */
|
|
70
|
-
info?: string;
|
|
71
|
-
/** Workflow config */
|
|
72
|
-
workflowConfig?: WorkflowConfig;
|
|
73
|
-
/** Current modal/prompt data */
|
|
74
|
-
modal: ModalData;
|
|
75
|
-
/** All workflows for selector */
|
|
76
|
-
allWorkflows: Map<string, WorkflowConfig>;
|
|
77
|
-
/** Shared user inputs across agents */
|
|
78
|
-
sharedUserInputs: string[];
|
|
79
|
-
/** Current task being executed */
|
|
80
|
-
currentTask?: string;
|
|
81
|
-
}
|
|
82
|
-
/** Action types */
|
|
83
|
-
export type AppAction = {
|
|
84
|
-
type: 'SET_WORKFLOW';
|
|
85
|
-
payload: {
|
|
86
|
-
name: string;
|
|
87
|
-
config: WorkflowConfig;
|
|
88
|
-
};
|
|
89
|
-
} | {
|
|
90
|
-
type: 'SET_ALL_WORKFLOWS';
|
|
91
|
-
payload: Map<string, WorkflowConfig>;
|
|
92
|
-
} | {
|
|
93
|
-
type: 'START_PROCESSING';
|
|
94
|
-
payload: {
|
|
95
|
-
step: string;
|
|
96
|
-
agent: string;
|
|
97
|
-
iteration: number;
|
|
98
|
-
};
|
|
99
|
-
} | {
|
|
100
|
-
type: 'STOP_PROCESSING';
|
|
101
|
-
} | {
|
|
102
|
-
type: 'APPEND_STREAM';
|
|
103
|
-
payload: string;
|
|
104
|
-
} | {
|
|
105
|
-
type: 'SET_THINKING';
|
|
106
|
-
payload: string;
|
|
107
|
-
} | {
|
|
108
|
-
type: 'CLEAR_STREAM';
|
|
109
|
-
} | {
|
|
110
|
-
type: 'ADD_MESSAGE';
|
|
111
|
-
payload: ConversationMessage;
|
|
112
|
-
} | {
|
|
113
|
-
type: 'TOGGLE_SACRIFICE_MODE';
|
|
114
|
-
} | {
|
|
115
|
-
type: 'SET_ERROR';
|
|
116
|
-
payload: string;
|
|
117
|
-
} | {
|
|
118
|
-
type: 'CLEAR_ERROR';
|
|
119
|
-
} | {
|
|
120
|
-
type: 'SET_INFO';
|
|
121
|
-
payload: string;
|
|
122
|
-
} | {
|
|
123
|
-
type: 'CLEAR_INFO';
|
|
124
|
-
} | {
|
|
125
|
-
type: 'SET_SESSION_ID';
|
|
126
|
-
payload: string;
|
|
127
|
-
} | {
|
|
128
|
-
type: 'SET_MAX_ITERATIONS';
|
|
129
|
-
payload: number;
|
|
130
|
-
} | {
|
|
131
|
-
type: 'RESET_CONVERSATION';
|
|
132
|
-
} | {
|
|
133
|
-
type: 'SHOW_MODAL';
|
|
134
|
-
payload: ModalData;
|
|
135
|
-
} | {
|
|
136
|
-
type: 'HIDE_MODAL';
|
|
137
|
-
} | {
|
|
138
|
-
type: 'ADD_USER_INPUT';
|
|
139
|
-
payload: string;
|
|
140
|
-
} | {
|
|
141
|
-
type: 'SET_CURRENT_TASK';
|
|
142
|
-
payload: string;
|
|
143
|
-
};
|
|
144
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/interactive/ink/context/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAE1F,oDAAoD;AACpD,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,GAC5B;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,iBAAiB,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,KAAK,EAAE,oBAAoB,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAChG;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAA;CAAE,CAAC;AAEvE,gCAAgC;AAChC,MAAM,MAAM,sBAAsB,GAC9B,OAAO,GACP,MAAM,GACN,QAAQ,GACR,gBAAgB,GAChB,WAAW,CAAC;AAEhB,gCAAgC;AAChC,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,sBAAsB,KAAK,IAAI,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AAE,GAC/C;IAAE,IAAI,EAAE,oBAAoB,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,SAAS,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GACtB;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/interactive/ink/context/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Key detection logic for terminal input handling
|
|
3
|
-
*
|
|
4
|
-
* Provides type definitions, constants, and functions for detecting
|
|
5
|
-
* special key combinations across different terminal emulators.
|
|
6
|
-
*
|
|
7
|
-
* This module handles:
|
|
8
|
-
* - Escape sequence tracking for iTerm2-style Option+Enter
|
|
9
|
-
* - Newline/submit/cancel trigger detection
|
|
10
|
-
* - Navigation and character input classification
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Threshold (ms) for detecting iTerm2-style Option+Enter (Escape + Enter).
|
|
14
|
-
* Based on:
|
|
15
|
-
* - Typical keyboard repeat delay is 200-500ms
|
|
16
|
-
* - Terminal escape sequence transmission is near-instantaneous (<10ms)
|
|
17
|
-
* - Human intentional Esc→Enter would take at least 100-150ms
|
|
18
|
-
*/
|
|
19
|
-
export declare const ESCAPE_SEQUENCE_THRESHOLD_MS = 50;
|
|
20
|
-
/**
|
|
21
|
-
* Delay (ms) to allow Ink's initial render and terminal setup before enabling
|
|
22
|
-
* raw keypress events. 100ms is sufficient for most terminals; shorter delays
|
|
23
|
-
* may cause race conditions with Ink's terminal control.
|
|
24
|
-
*/
|
|
25
|
-
export declare const KEYPRESS_INIT_DELAY_MS = 100;
|
|
26
|
-
/**
|
|
27
|
-
* Key event from Node.js keypress
|
|
28
|
-
*/
|
|
29
|
-
export interface RawKeyEvent {
|
|
30
|
-
name?: string;
|
|
31
|
-
ctrl?: boolean;
|
|
32
|
-
meta?: boolean;
|
|
33
|
-
shift?: boolean;
|
|
34
|
-
sequence?: string;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Normalized key action types (discriminated union)
|
|
38
|
-
*/
|
|
39
|
-
export type KeyAction = {
|
|
40
|
-
type: 'newline';
|
|
41
|
-
} | {
|
|
42
|
-
type: 'submit';
|
|
43
|
-
} | {
|
|
44
|
-
type: 'cancel';
|
|
45
|
-
} | {
|
|
46
|
-
type: 'character';
|
|
47
|
-
char: string;
|
|
48
|
-
} | {
|
|
49
|
-
type: 'backspace';
|
|
50
|
-
} | {
|
|
51
|
-
type: 'navigation';
|
|
52
|
-
direction: 'up' | 'down' | 'left' | 'right';
|
|
53
|
-
} | {
|
|
54
|
-
type: 'escape';
|
|
55
|
-
} | {
|
|
56
|
-
type: 'ignored';
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Tracks Escape key timing for detecting iTerm2-style Option+Enter.
|
|
60
|
-
*
|
|
61
|
-
* iTerm2 (and some other Mac terminals) send Option+Enter as two separate events:
|
|
62
|
-
* Escape followed by Enter. This tracker detects this pattern by checking if
|
|
63
|
-
* Enter is pressed shortly after Escape.
|
|
64
|
-
*/
|
|
65
|
-
export declare class EscapeSequenceTracker {
|
|
66
|
-
private lastEscapeTime;
|
|
67
|
-
private readonly thresholdMs;
|
|
68
|
-
constructor(thresholdMs?: number);
|
|
69
|
-
/** Record that Escape key was pressed */
|
|
70
|
-
trackEscape(): void;
|
|
71
|
-
/**
|
|
72
|
-
* Check if Enter was pressed within threshold of Escape.
|
|
73
|
-
* Resets the tracker if true to prevent repeated triggers.
|
|
74
|
-
*/
|
|
75
|
-
isEscapeThenEnter(): boolean;
|
|
76
|
-
/** Reset the tracker state */
|
|
77
|
-
reset(): void;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Determines if a key event should trigger newline input.
|
|
81
|
-
*
|
|
82
|
-
* Supported patterns:
|
|
83
|
-
* - Ctrl+O: Universal alternative (works in all terminals)
|
|
84
|
-
* - Ctrl+Enter: ctrl flag with Enter key
|
|
85
|
-
* - Option+Enter (meta): meta flag with Enter key (some terminals)
|
|
86
|
-
* - Shift+Enter: shift flag with Enter key (some terminals)
|
|
87
|
-
* - Option+Enter (escape sequence): '\x1b\r' sequence (Terminal.app)
|
|
88
|
-
* - Option+Enter (iTerm2): Escape + Enter as separate events
|
|
89
|
-
* - Escape+OM: '\x1bOM' sequence (some terminals)
|
|
90
|
-
*/
|
|
91
|
-
export declare function isNewLineTrigger(key: RawKeyEvent, escapeTracker: EscapeSequenceTracker): boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Determines if a key event should submit input.
|
|
94
|
-
*
|
|
95
|
-
* Supports:
|
|
96
|
-
* - Plain Enter (no modifiers)
|
|
97
|
-
* - Ctrl+J (legacy/universal)
|
|
98
|
-
*/
|
|
99
|
-
export declare function isSubmitTrigger(key: RawKeyEvent): boolean;
|
|
100
|
-
/**
|
|
101
|
-
* Determines if a key event is a cancel trigger (Ctrl+C)
|
|
102
|
-
*/
|
|
103
|
-
export declare function isCancelTrigger(key: RawKeyEvent): boolean;
|
|
104
|
-
/**
|
|
105
|
-
* Determines if a key event is a navigation key
|
|
106
|
-
*/
|
|
107
|
-
export declare function isNavigationKey(key: RawKeyEvent): 'up' | 'down' | 'left' | 'right' | null;
|
|
108
|
-
/**
|
|
109
|
-
* Determines if a key event is a backspace
|
|
110
|
-
*/
|
|
111
|
-
export declare function isBackspaceKey(key: RawKeyEvent): boolean;
|
|
112
|
-
/**
|
|
113
|
-
* Classify a raw key event into a normalized action
|
|
114
|
-
*/
|
|
115
|
-
export declare function classifyKeyEvent(str: string | undefined, key: RawKeyEvent, escapeTracker: EscapeSequenceTracker): KeyAction;
|
|
116
|
-
//# sourceMappingURL=keyDetection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keyDetection.d.ts","sourceRoot":"","sources":["../../../../src/interactive/ink/hooks/keyDetection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAM1C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,SAAS,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CAAE,GACnE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAMxB;;;;;;GAMG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,cAAc,CAAa;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;gBAEzB,WAAW,GAAE,MAAqC;IAI9D,yCAAyC;IACzC,WAAW,IAAI,IAAI;IAInB;;;OAGG;IACH,iBAAiB,IAAI,OAAO;IAS5B,8BAA8B;IAC9B,KAAK,IAAI,IAAI;CAGd;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,WAAW,EAChB,aAAa,EAAE,qBAAqB,GACnC,OAAO,CAsBT;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAczD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAEzD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAMzF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAExD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,GAAG,EAAE,WAAW,EAChB,aAAa,EAAE,qBAAqB,GACnC,SAAS,CA2CX"}
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Key detection logic for terminal input handling
|
|
3
|
-
*
|
|
4
|
-
* Provides type definitions, constants, and functions for detecting
|
|
5
|
-
* special key combinations across different terminal emulators.
|
|
6
|
-
*
|
|
7
|
-
* This module handles:
|
|
8
|
-
* - Escape sequence tracking for iTerm2-style Option+Enter
|
|
9
|
-
* - Newline/submit/cancel trigger detection
|
|
10
|
-
* - Navigation and character input classification
|
|
11
|
-
*/
|
|
12
|
-
// ============================================================================
|
|
13
|
-
// Constants
|
|
14
|
-
// ============================================================================
|
|
15
|
-
/**
|
|
16
|
-
* Threshold (ms) for detecting iTerm2-style Option+Enter (Escape + Enter).
|
|
17
|
-
* Based on:
|
|
18
|
-
* - Typical keyboard repeat delay is 200-500ms
|
|
19
|
-
* - Terminal escape sequence transmission is near-instantaneous (<10ms)
|
|
20
|
-
* - Human intentional Esc→Enter would take at least 100-150ms
|
|
21
|
-
*/
|
|
22
|
-
export const ESCAPE_SEQUENCE_THRESHOLD_MS = 50;
|
|
23
|
-
/**
|
|
24
|
-
* Delay (ms) to allow Ink's initial render and terminal setup before enabling
|
|
25
|
-
* raw keypress events. 100ms is sufficient for most terminals; shorter delays
|
|
26
|
-
* may cause race conditions with Ink's terminal control.
|
|
27
|
-
*/
|
|
28
|
-
export const KEYPRESS_INIT_DELAY_MS = 100;
|
|
29
|
-
// ============================================================================
|
|
30
|
-
// Escape Sequence Tracker
|
|
31
|
-
// ============================================================================
|
|
32
|
-
/**
|
|
33
|
-
* Tracks Escape key timing for detecting iTerm2-style Option+Enter.
|
|
34
|
-
*
|
|
35
|
-
* iTerm2 (and some other Mac terminals) send Option+Enter as two separate events:
|
|
36
|
-
* Escape followed by Enter. This tracker detects this pattern by checking if
|
|
37
|
-
* Enter is pressed shortly after Escape.
|
|
38
|
-
*/
|
|
39
|
-
export class EscapeSequenceTracker {
|
|
40
|
-
lastEscapeTime = 0;
|
|
41
|
-
thresholdMs;
|
|
42
|
-
constructor(thresholdMs = ESCAPE_SEQUENCE_THRESHOLD_MS) {
|
|
43
|
-
this.thresholdMs = thresholdMs;
|
|
44
|
-
}
|
|
45
|
-
/** Record that Escape key was pressed */
|
|
46
|
-
trackEscape() {
|
|
47
|
-
this.lastEscapeTime = Date.now();
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Check if Enter was pressed within threshold of Escape.
|
|
51
|
-
* Resets the tracker if true to prevent repeated triggers.
|
|
52
|
-
*/
|
|
53
|
-
isEscapeThenEnter() {
|
|
54
|
-
const elapsed = Date.now() - this.lastEscapeTime;
|
|
55
|
-
const isRecent = elapsed < this.thresholdMs && this.lastEscapeTime > 0;
|
|
56
|
-
if (isRecent) {
|
|
57
|
-
this.lastEscapeTime = 0; // Reset to prevent accidental triggers
|
|
58
|
-
}
|
|
59
|
-
return isRecent;
|
|
60
|
-
}
|
|
61
|
-
/** Reset the tracker state */
|
|
62
|
-
reset() {
|
|
63
|
-
this.lastEscapeTime = 0;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// ============================================================================
|
|
67
|
-
// Key Detection Functions
|
|
68
|
-
// ============================================================================
|
|
69
|
-
/**
|
|
70
|
-
* Determines if a key event should trigger newline input.
|
|
71
|
-
*
|
|
72
|
-
* Supported patterns:
|
|
73
|
-
* - Ctrl+O: Universal alternative (works in all terminals)
|
|
74
|
-
* - Ctrl+Enter: ctrl flag with Enter key
|
|
75
|
-
* - Option+Enter (meta): meta flag with Enter key (some terminals)
|
|
76
|
-
* - Shift+Enter: shift flag with Enter key (some terminals)
|
|
77
|
-
* - Option+Enter (escape sequence): '\x1b\r' sequence (Terminal.app)
|
|
78
|
-
* - Option+Enter (iTerm2): Escape + Enter as separate events
|
|
79
|
-
* - Escape+OM: '\x1bOM' sequence (some terminals)
|
|
80
|
-
*/
|
|
81
|
-
export function isNewLineTrigger(key, escapeTracker) {
|
|
82
|
-
const isEnterKey = key.name === 'return' || key.name === 'enter';
|
|
83
|
-
// Ctrl+O - universal alternative that works in all terminals
|
|
84
|
-
if (key.ctrl && key.name === 'o') {
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
// Modifier + Enter combinations
|
|
88
|
-
const modifiedEnter = isEnterKey && (key.ctrl || key.meta || key.shift);
|
|
89
|
-
// Escape sequences sent as single events
|
|
90
|
-
const escapeSequences = key.sequence === '\x1b\r' ||
|
|
91
|
-
key.sequence === '\u001b\r' ||
|
|
92
|
-
key.sequence === '\x1bOM' ||
|
|
93
|
-
key.sequence === '\u001bOM';
|
|
94
|
-
// iTerm2-style: Escape followed by Enter within threshold
|
|
95
|
-
const iterm2Style = isEnterKey && escapeTracker.isEscapeThenEnter();
|
|
96
|
-
return modifiedEnter || escapeSequences || iterm2Style;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Determines if a key event should submit input.
|
|
100
|
-
*
|
|
101
|
-
* Supports:
|
|
102
|
-
* - Plain Enter (no modifiers)
|
|
103
|
-
* - Ctrl+J (legacy/universal)
|
|
104
|
-
*/
|
|
105
|
-
export function isSubmitTrigger(key) {
|
|
106
|
-
const isEnterKey = key.name === 'return' || key.name === 'enter';
|
|
107
|
-
// Plain Enter submits (no modifiers)
|
|
108
|
-
if (isEnterKey && !key.shift && !key.meta && !key.ctrl) {
|
|
109
|
-
return true;
|
|
110
|
-
}
|
|
111
|
-
// Ctrl+J also submits (works in all terminals)
|
|
112
|
-
if (key.ctrl && key.name === 'j') {
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Determines if a key event is a cancel trigger (Ctrl+C)
|
|
119
|
-
*/
|
|
120
|
-
export function isCancelTrigger(key) {
|
|
121
|
-
return Boolean(key.ctrl && key.name === 'c');
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Determines if a key event is a navigation key
|
|
125
|
-
*/
|
|
126
|
-
export function isNavigationKey(key) {
|
|
127
|
-
if (key.name === 'up')
|
|
128
|
-
return 'up';
|
|
129
|
-
if (key.name === 'down')
|
|
130
|
-
return 'down';
|
|
131
|
-
if (key.name === 'left')
|
|
132
|
-
return 'left';
|
|
133
|
-
if (key.name === 'right')
|
|
134
|
-
return 'right';
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Determines if a key event is a backspace
|
|
139
|
-
*/
|
|
140
|
-
export function isBackspaceKey(key) {
|
|
141
|
-
return key.name === 'backspace' || key.name === 'delete';
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Classify a raw key event into a normalized action
|
|
145
|
-
*/
|
|
146
|
-
export function classifyKeyEvent(str, key, escapeTracker) {
|
|
147
|
-
// Track Escape key for iTerm2-style detection
|
|
148
|
-
if (key.name === 'escape' || key.sequence === '\x1b') {
|
|
149
|
-
escapeTracker.trackEscape();
|
|
150
|
-
return { type: 'escape' };
|
|
151
|
-
}
|
|
152
|
-
// Cancel (Ctrl+C)
|
|
153
|
-
if (isCancelTrigger(key)) {
|
|
154
|
-
return { type: 'cancel' };
|
|
155
|
-
}
|
|
156
|
-
// Newline triggers (check BEFORE submit)
|
|
157
|
-
if (isNewLineTrigger(key, escapeTracker)) {
|
|
158
|
-
return { type: 'newline' };
|
|
159
|
-
}
|
|
160
|
-
// Submit triggers
|
|
161
|
-
if (isSubmitTrigger(key)) {
|
|
162
|
-
return { type: 'submit' };
|
|
163
|
-
}
|
|
164
|
-
// Navigation
|
|
165
|
-
const navDir = isNavigationKey(key);
|
|
166
|
-
if (navDir) {
|
|
167
|
-
return { type: 'navigation', direction: navDir };
|
|
168
|
-
}
|
|
169
|
-
// Backspace
|
|
170
|
-
if (isBackspaceKey(key)) {
|
|
171
|
-
return { type: 'backspace' };
|
|
172
|
-
}
|
|
173
|
-
// Character input (skip control characters and meta combinations)
|
|
174
|
-
if (str && !key.ctrl && !key.meta && str.length > 0) {
|
|
175
|
-
// Filter out non-printable characters
|
|
176
|
-
const printable = str.replace(/[\x00-\x1f\x7f]/g, '');
|
|
177
|
-
if (printable.length > 0) {
|
|
178
|
-
return { type: 'character', char: printable };
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return { type: 'ignored' };
|
|
182
|
-
}
|
|
183
|
-
//# sourceMappingURL=keyDetection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keyDetection.js","sourceRoot":"","sources":["../../../../src/interactive/ink/hooks/keyDetection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAE/C;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AA8B1C,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E;;;;;;GAMG;AACH,MA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CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpD,sCAAsC;QACtC,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;QACtD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAChD,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure functions for multiline input state handling
|
|
3
|
-
*
|
|
4
|
-
* This module is responsible ONLY for state transformations.
|
|
5
|
-
* Key detection logic is centralized in useRawKeypress.ts.
|
|
6
|
-
*
|
|
7
|
-
* These functions are extracted to enable unit testing without React hooks.
|
|
8
|
-
*/
|
|
9
|
-
export interface MultilineInputState {
|
|
10
|
-
lines: string[];
|
|
11
|
-
currentLine: number;
|
|
12
|
-
cursor: number;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Handles character input and returns new state
|
|
16
|
-
*/
|
|
17
|
-
export declare function handleCharacterInput(state: MultilineInputState, input: string): MultilineInputState;
|
|
18
|
-
/**
|
|
19
|
-
* Handles new line insertion and returns new state
|
|
20
|
-
*/
|
|
21
|
-
export declare function handleNewLine(state: MultilineInputState): MultilineInputState;
|
|
22
|
-
/**
|
|
23
|
-
* Handles backspace and returns new state
|
|
24
|
-
*/
|
|
25
|
-
export declare function handleBackspace(state: MultilineInputState): MultilineInputState;
|
|
26
|
-
/**
|
|
27
|
-
* Handles left arrow navigation
|
|
28
|
-
*/
|
|
29
|
-
export declare function handleLeftArrow(state: MultilineInputState): MultilineInputState;
|
|
30
|
-
/**
|
|
31
|
-
* Handles right arrow navigation
|
|
32
|
-
*/
|
|
33
|
-
export declare function handleRightArrow(state: MultilineInputState): MultilineInputState;
|
|
34
|
-
/**
|
|
35
|
-
* Handles up arrow navigation
|
|
36
|
-
*/
|
|
37
|
-
export declare function handleUpArrow(state: MultilineInputState): MultilineInputState;
|
|
38
|
-
/**
|
|
39
|
-
* Handles down arrow navigation
|
|
40
|
-
*/
|
|
41
|
-
export declare function handleDownArrow(state: MultilineInputState): MultilineInputState;
|
|
42
|
-
/**
|
|
43
|
-
* Get full input as a single string
|
|
44
|
-
*/
|
|
45
|
-
export declare function getFullInput(state: MultilineInputState): string;
|
|
46
|
-
/**
|
|
47
|
-
* Create initial state
|
|
48
|
-
*/
|
|
49
|
-
export declare function createInitialState(): MultilineInputState;
|
|
50
|
-
//# sourceMappingURL=multilineInputLogic.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"multilineInputLogic.d.ts","sourceRoot":"","sources":["../../../../src/interactive/ink/hooks/multilineInputLogic.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,mBAAmB,EAC1B,KAAK,EAAE,MAAM,GACZ,mBAAmB,CAYrB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,CAa7E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,CA2B/E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,CAc/E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,CAehF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,CAS7E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,CAS/E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,mBAAmB,GAAG,MAAM,CAE/D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,mBAAmB,CAMxD"}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure functions for multiline input state handling
|
|
3
|
-
*
|
|
4
|
-
* This module is responsible ONLY for state transformations.
|
|
5
|
-
* Key detection logic is centralized in useRawKeypress.ts.
|
|
6
|
-
*
|
|
7
|
-
* These functions are extracted to enable unit testing without React hooks.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Handles character input and returns new state
|
|
11
|
-
*/
|
|
12
|
-
export function handleCharacterInput(state, input) {
|
|
13
|
-
if (!input)
|
|
14
|
-
return state;
|
|
15
|
-
const newLines = [...state.lines];
|
|
16
|
-
const line = newLines[state.currentLine] ?? '';
|
|
17
|
-
newLines[state.currentLine] = line.slice(0, state.cursor) + input + line.slice(state.cursor);
|
|
18
|
-
return {
|
|
19
|
-
lines: newLines,
|
|
20
|
-
currentLine: state.currentLine,
|
|
21
|
-
cursor: state.cursor + input.length,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Handles new line insertion and returns new state
|
|
26
|
-
*/
|
|
27
|
-
export function handleNewLine(state) {
|
|
28
|
-
const newLines = [...state.lines];
|
|
29
|
-
const currentLineContent = newLines[state.currentLine] ?? '';
|
|
30
|
-
const before = currentLineContent.slice(0, state.cursor);
|
|
31
|
-
const after = currentLineContent.slice(state.cursor);
|
|
32
|
-
newLines[state.currentLine] = before;
|
|
33
|
-
newLines.splice(state.currentLine + 1, 0, after);
|
|
34
|
-
return {
|
|
35
|
-
lines: newLines,
|
|
36
|
-
currentLine: state.currentLine + 1,
|
|
37
|
-
cursor: 0,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Handles backspace and returns new state
|
|
42
|
-
*/
|
|
43
|
-
export function handleBackspace(state) {
|
|
44
|
-
if (state.cursor > 0) {
|
|
45
|
-
// Delete character before cursor
|
|
46
|
-
const newLines = [...state.lines];
|
|
47
|
-
const line = newLines[state.currentLine] ?? '';
|
|
48
|
-
newLines[state.currentLine] = line.slice(0, state.cursor - 1) + line.slice(state.cursor);
|
|
49
|
-
return {
|
|
50
|
-
lines: newLines,
|
|
51
|
-
currentLine: state.currentLine,
|
|
52
|
-
cursor: state.cursor - 1,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
else if (state.currentLine > 0) {
|
|
56
|
-
// Merge with previous line
|
|
57
|
-
const prevLineLen = state.lines[state.currentLine - 1]?.length ?? 0;
|
|
58
|
-
const newLines = [...state.lines];
|
|
59
|
-
newLines[state.currentLine - 1] = (newLines[state.currentLine - 1] ?? '') + (newLines[state.currentLine] ?? '');
|
|
60
|
-
newLines.splice(state.currentLine, 1);
|
|
61
|
-
return {
|
|
62
|
-
lines: newLines,
|
|
63
|
-
currentLine: state.currentLine - 1,
|
|
64
|
-
cursor: prevLineLen,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
return state;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Handles left arrow navigation
|
|
71
|
-
*/
|
|
72
|
-
export function handleLeftArrow(state) {
|
|
73
|
-
if (state.cursor > 0) {
|
|
74
|
-
return {
|
|
75
|
-
...state,
|
|
76
|
-
cursor: state.cursor - 1,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
else if (state.currentLine > 0) {
|
|
80
|
-
return {
|
|
81
|
-
...state,
|
|
82
|
-
currentLine: state.currentLine - 1,
|
|
83
|
-
cursor: state.lines[state.currentLine - 1]?.length ?? 0,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
return state;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Handles right arrow navigation
|
|
90
|
-
*/
|
|
91
|
-
export function handleRightArrow(state) {
|
|
92
|
-
const lineLen = state.lines[state.currentLine]?.length ?? 0;
|
|
93
|
-
if (state.cursor < lineLen) {
|
|
94
|
-
return {
|
|
95
|
-
...state,
|
|
96
|
-
cursor: state.cursor + 1,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
else if (state.currentLine < state.lines.length - 1) {
|
|
100
|
-
return {
|
|
101
|
-
...state,
|
|
102
|
-
currentLine: state.currentLine + 1,
|
|
103
|
-
cursor: 0,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
return state;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Handles up arrow navigation
|
|
110
|
-
*/
|
|
111
|
-
export function handleUpArrow(state) {
|
|
112
|
-
if (state.currentLine > 0) {
|
|
113
|
-
return {
|
|
114
|
-
...state,
|
|
115
|
-
currentLine: state.currentLine - 1,
|
|
116
|
-
cursor: Math.min(state.cursor, state.lines[state.currentLine - 1]?.length ?? 0),
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
return state;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Handles down arrow navigation
|
|
123
|
-
*/
|
|
124
|
-
export function handleDownArrow(state) {
|
|
125
|
-
if (state.currentLine < state.lines.length - 1) {
|
|
126
|
-
return {
|
|
127
|
-
...state,
|
|
128
|
-
currentLine: state.currentLine + 1,
|
|
129
|
-
cursor: Math.min(state.cursor, state.lines[state.currentLine + 1]?.length ?? 0),
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
return state;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Get full input as a single string
|
|
136
|
-
*/
|
|
137
|
-
export function getFullInput(state) {
|
|
138
|
-
return state.lines.join('\n').trim();
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Create initial state
|
|
142
|
-
*/
|
|
143
|
-
export function createInitialState() {
|
|
144
|
-
return {
|
|
145
|
-
lines: [''],
|
|
146
|
-
currentLine: 0,
|
|
147
|
-
cursor: 0,
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
//# sourceMappingURL=multilineInputLogic.js.map
|