cray-code 1.0.0
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 +316 -0
- package/dist/Tool.d.ts +217 -0
- package/dist/Tool.d.ts.map +1 -0
- package/dist/Tool.js +89 -0
- package/dist/Tool.js.map +1 -0
- package/dist/branding/logo.d.ts +8 -0
- package/dist/branding/logo.d.ts.map +1 -0
- package/dist/branding/logo.js +26 -0
- package/dist/branding/logo.js.map +1 -0
- package/dist/branding/theme.d.ts +27 -0
- package/dist/branding/theme.d.ts.map +1 -0
- package/dist/branding/theme.js +28 -0
- package/dist/branding/theme.js.map +1 -0
- package/dist/commands/registry.d.ts +32 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +759 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/components/MessageView.d.ts +12 -0
- package/dist/components/MessageView.d.ts.map +1 -0
- package/dist/components/MessageView.js +35 -0
- package/dist/components/MessageView.js.map +1 -0
- package/dist/components/PermissionPrompt.d.ts +11 -0
- package/dist/components/PermissionPrompt.d.ts.map +1 -0
- package/dist/components/PermissionPrompt.js +6 -0
- package/dist/components/PermissionPrompt.js.map +1 -0
- package/dist/components/PluginManager.d.ts +27 -0
- package/dist/components/PluginManager.d.ts.map +1 -0
- package/dist/components/PluginManager.js +391 -0
- package/dist/components/PluginManager.js.map +1 -0
- package/dist/components/ThinkingBlock.d.ts +27 -0
- package/dist/components/ThinkingBlock.d.ts.map +1 -0
- package/dist/components/ThinkingBlock.js +29 -0
- package/dist/components/ThinkingBlock.js.map +1 -0
- package/dist/components/ToolCallBlock.d.ts +14 -0
- package/dist/components/ToolCallBlock.d.ts.map +1 -0
- package/dist/components/ToolCallBlock.js +83 -0
- package/dist/components/ToolCallBlock.js.map +1 -0
- package/dist/components/TrustDialog.d.ts +20 -0
- package/dist/components/TrustDialog.d.ts.map +1 -0
- package/dist/components/TrustDialog.js +80 -0
- package/dist/components/TrustDialog.js.map +1 -0
- package/dist/context.d.ts +25 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +268 -0
- package/dist/context.js.map +1 -0
- package/dist/cray.d.ts +114 -0
- package/dist/cray.d.ts.map +1 -0
- package/dist/cray.js +338 -0
- package/dist/cray.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +122 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/registry.d.ts +106 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +695 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/query.d.ts +31 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +637 -0
- package/dist/query.js.map +1 -0
- package/dist/queryStream.d.ts +36 -0
- package/dist/queryStream.d.ts.map +1 -0
- package/dist/queryStream.js +704 -0
- package/dist/queryStream.js.map +1 -0
- package/dist/screens/ReplScreen.d.ts +22 -0
- package/dist/screens/ReplScreen.d.ts.map +1 -0
- package/dist/screens/ReplScreen.js +763 -0
- package/dist/screens/ReplScreen.js.map +1 -0
- package/dist/services/agentRunner.d.ts +39 -0
- package/dist/services/agentRunner.d.ts.map +1 -0
- package/dist/services/agentRunner.js +115 -0
- package/dist/services/agentRunner.js.map +1 -0
- package/dist/services/compact.d.ts +34 -0
- package/dist/services/compact.d.ts.map +1 -0
- package/dist/services/compact.js +179 -0
- package/dist/services/compact.js.map +1 -0
- package/dist/services/loadPluginCommands.d.ts +55 -0
- package/dist/services/loadPluginCommands.d.ts.map +1 -0
- package/dist/services/loadPluginCommands.js +219 -0
- package/dist/services/loadPluginCommands.js.map +1 -0
- package/dist/services/mcp/index.d.ts +3 -0
- package/dist/services/mcp/index.d.ts.map +1 -0
- package/dist/services/mcp/index.js +3 -0
- package/dist/services/mcp/index.js.map +1 -0
- package/dist/services/mcp/manager.d.ts +24 -0
- package/dist/services/mcp/manager.d.ts.map +1 -0
- package/dist/services/mcp/manager.js +138 -0
- package/dist/services/mcp/manager.js.map +1 -0
- package/dist/services/mcp/types.d.ts +52 -0
- package/dist/services/mcp/types.d.ts.map +1 -0
- package/dist/services/mcp/types.js +5 -0
- package/dist/services/mcp/types.js.map +1 -0
- package/dist/services/memory.d.ts +38 -0
- package/dist/services/memory.d.ts.map +1 -0
- package/dist/services/memory.js +181 -0
- package/dist/services/memory.js.map +1 -0
- package/dist/services/permissionPrompt.d.ts +38 -0
- package/dist/services/permissionPrompt.d.ts.map +1 -0
- package/dist/services/permissionPrompt.js +83 -0
- package/dist/services/permissionPrompt.js.map +1 -0
- package/dist/services/permissions.d.ts +15 -0
- package/dist/services/permissions.d.ts.map +1 -0
- package/dist/services/permissions.js +237 -0
- package/dist/services/permissions.js.map +1 -0
- package/dist/services/sessionStorage.d.ts +51 -0
- package/dist/services/sessionStorage.d.ts.map +1 -0
- package/dist/services/sessionStorage.js +266 -0
- package/dist/services/sessionStorage.js.map +1 -0
- package/dist/setup.d.ts +22 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +160 -0
- package/dist/setup.js.map +1 -0
- package/dist/skills/bundledSkills.d.ts +18 -0
- package/dist/skills/bundledSkills.d.ts.map +1 -0
- package/dist/skills/bundledSkills.js +277 -0
- package/dist/skills/bundledSkills.js.map +1 -0
- package/dist/skills/index.d.ts +4 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +3 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/loadSkillsDir.d.ts +45 -0
- package/dist/skills/loadSkillsDir.d.ts.map +1 -0
- package/dist/skills/loadSkillsDir.js +233 -0
- package/dist/skills/loadSkillsDir.js.map +1 -0
- package/dist/state/AppState.d.ts +70 -0
- package/dist/state/AppState.d.ts.map +1 -0
- package/dist/state/AppState.js +106 -0
- package/dist/state/AppState.js.map +1 -0
- package/dist/tools/AgentTool.d.ts +62 -0
- package/dist/tools/AgentTool.d.ts.map +1 -0
- package/dist/tools/AgentTool.js +133 -0
- package/dist/tools/AgentTool.js.map +1 -0
- package/dist/tools/AskUserQuestionTool.d.ts +60 -0
- package/dist/tools/AskUserQuestionTool.d.ts.map +1 -0
- package/dist/tools/AskUserQuestionTool.js +52 -0
- package/dist/tools/AskUserQuestionTool.js.map +1 -0
- package/dist/tools/BashTool.d.ts +33 -0
- package/dist/tools/BashTool.d.ts.map +1 -0
- package/dist/tools/BashTool.js +211 -0
- package/dist/tools/BashTool.js.map +1 -0
- package/dist/tools/EditTool.d.ts +24 -0
- package/dist/tools/EditTool.d.ts.map +1 -0
- package/dist/tools/EditTool.js +102 -0
- package/dist/tools/EditTool.js.map +1 -0
- package/dist/tools/GlobTool.d.ts +17 -0
- package/dist/tools/GlobTool.d.ts.map +1 -0
- package/dist/tools/GlobTool.js +65 -0
- package/dist/tools/GlobTool.js.map +1 -0
- package/dist/tools/GrepTool.d.ts +30 -0
- package/dist/tools/GrepTool.d.ts.map +1 -0
- package/dist/tools/GrepTool.js +140 -0
- package/dist/tools/GrepTool.js.map +1 -0
- package/dist/tools/MCPTool.d.ts +24 -0
- package/dist/tools/MCPTool.d.ts.map +1 -0
- package/dist/tools/MCPTool.js +67 -0
- package/dist/tools/MCPTool.js.map +1 -0
- package/dist/tools/NotebookEditTool.d.ts +28 -0
- package/dist/tools/NotebookEditTool.d.ts.map +1 -0
- package/dist/tools/NotebookEditTool.js +213 -0
- package/dist/tools/NotebookEditTool.js.map +1 -0
- package/dist/tools/NotebookReadTool.d.ts +19 -0
- package/dist/tools/NotebookReadTool.d.ts.map +1 -0
- package/dist/tools/NotebookReadTool.js +191 -0
- package/dist/tools/NotebookReadTool.js.map +1 -0
- package/dist/tools/PlanTools.d.ts +17 -0
- package/dist/tools/PlanTools.d.ts.map +1 -0
- package/dist/tools/PlanTools.js +65 -0
- package/dist/tools/PlanTools.js.map +1 -0
- package/dist/tools/ReadTool.d.ts +21 -0
- package/dist/tools/ReadTool.d.ts.map +1 -0
- package/dist/tools/ReadTool.js +202 -0
- package/dist/tools/ReadTool.js.map +1 -0
- package/dist/tools/SkillTool.d.ts +32 -0
- package/dist/tools/SkillTool.d.ts.map +1 -0
- package/dist/tools/SkillTool.js +217 -0
- package/dist/tools/SkillTool.js.map +1 -0
- package/dist/tools/TodoWriteTool.d.ts +35 -0
- package/dist/tools/TodoWriteTool.d.ts.map +1 -0
- package/dist/tools/TodoWriteTool.js +58 -0
- package/dist/tools/TodoWriteTool.js.map +1 -0
- package/dist/tools/WebFetchTool.d.ts +17 -0
- package/dist/tools/WebFetchTool.d.ts.map +1 -0
- package/dist/tools/WebFetchTool.js +97 -0
- package/dist/tools/WebFetchTool.js.map +1 -0
- package/dist/tools/WebSearchTool.d.ts +18 -0
- package/dist/tools/WebSearchTool.d.ts.map +1 -0
- package/dist/tools/WebSearchTool.js +76 -0
- package/dist/tools/WebSearchTool.js.map +1 -0
- package/dist/tools/WriteTool.d.ts +17 -0
- package/dist/tools/WriteTool.d.ts.map +1 -0
- package/dist/tools/WriteTool.js +84 -0
- package/dist/tools/WriteTool.js.map +1 -0
- package/dist/tools/index.d.ts +21 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +20 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools.d.ts +34 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +102 -0
- package/dist/tools.js.map +1 -0
- package/dist/types/events.d.ts +85 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +12 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/message.d.ts +71 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/message.js +5 -0
- package/dist/types/message.js.map +1 -0
- package/dist/types/permission.d.ts +56 -0
- package/dist/types/permission.d.ts.map +1 -0
- package/dist/types/permission.js +46 -0
- package/dist/types/permission.js.map +1 -0
- package/dist/types/processUserInput.d.ts +18 -0
- package/dist/types/processUserInput.d.ts.map +1 -0
- package/dist/types/processUserInput.js +8 -0
- package/dist/types/processUserInput.js.map +1 -0
- package/dist/types/tool.d.ts +32 -0
- package/dist/types/tool.d.ts.map +1 -0
- package/dist/types/tool.js +5 -0
- package/dist/types/tool.js.map +1 -0
- package/dist/utils/compactBoundary.d.ts +11 -0
- package/dist/utils/compactBoundary.d.ts.map +1 -0
- package/dist/utils/compactBoundary.js +26 -0
- package/dist/utils/compactBoundary.js.map +1 -0
- package/dist/utils/configStore.d.ts +41 -0
- package/dist/utils/configStore.d.ts.map +1 -0
- package/dist/utils/configStore.js +111 -0
- package/dist/utils/configStore.js.map +1 -0
- package/dist/utils/forkedAgent.d.ts +40 -0
- package/dist/utils/forkedAgent.d.ts.map +1 -0
- package/dist/utils/forkedAgent.js +231 -0
- package/dist/utils/forkedAgent.js.map +1 -0
- package/dist/utils/messages.d.ts +14 -0
- package/dist/utils/messages.d.ts.map +1 -0
- package/dist/utils/messages.js +29 -0
- package/dist/utils/messages.js.map +1 -0
- package/dist/utils/sandbox.d.ts +22 -0
- package/dist/utils/sandbox.d.ts.map +1 -0
- package/dist/utils/sandbox.js +59 -0
- package/dist/utils/sandbox.js.map +1 -0
- package/dist/utils/sideQuestion.d.ts +29 -0
- package/dist/utils/sideQuestion.d.ts.map +1 -0
- package/dist/utils/sideQuestion.js +81 -0
- package/dist/utils/sideQuestion.js.map +1 -0
- package/install.ps1 +86 -0
- package/install.sh +92 -0
- package/package.json +68 -0
package/dist/cray.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CrayCode — Main orchestrator class.
|
|
3
|
+
*
|
|
4
|
+
* This is the primary public API for Cray Code. It ties together:
|
|
5
|
+
* - Tool system (built-in + MCP + skill-linked)
|
|
6
|
+
* - Query engine (agent loop)
|
|
7
|
+
* - State management
|
|
8
|
+
* - Skill system
|
|
9
|
+
* - Plugin system
|
|
10
|
+
* - Command system
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* const cray = new CrayCode({ cwd: process.cwd() });
|
|
14
|
+
* await cray.initialize();
|
|
15
|
+
* const result = await cray.processMessage("Review this code");
|
|
16
|
+
*/
|
|
17
|
+
import { EventEmitter } from 'events';
|
|
18
|
+
import type { ToolUseContext } from './Tool.js';
|
|
19
|
+
import type { Message } from './types/message.js';
|
|
20
|
+
import type { PermissionMode } from './types/permission.js';
|
|
21
|
+
import type { MCPServerConfig } from './services/mcp/types.js';
|
|
22
|
+
import { type CommandResult } from './commands/registry.js';
|
|
23
|
+
import { type CompactResult } from './services/compact.js';
|
|
24
|
+
export interface CrayCodeOptions {
|
|
25
|
+
/** Working directory */
|
|
26
|
+
cwd?: string;
|
|
27
|
+
/** LLM provider (anthropic|openai|ollama|openrouter|deepseek|custom) */
|
|
28
|
+
provider?: string;
|
|
29
|
+
/** Model to use */
|
|
30
|
+
model?: string;
|
|
31
|
+
/** API key for the provider */
|
|
32
|
+
apiKey?: string;
|
|
33
|
+
/** Custom API base URL */
|
|
34
|
+
baseUrl?: string;
|
|
35
|
+
/** Permission mode */
|
|
36
|
+
permissionMode?: PermissionMode;
|
|
37
|
+
/** Max agent loop turns */
|
|
38
|
+
maxTurns?: number;
|
|
39
|
+
/** Enable verbose debug logging */
|
|
40
|
+
verbose?: boolean;
|
|
41
|
+
/** MCP server configurations */
|
|
42
|
+
mcpServers?: MCPServerConfig[];
|
|
43
|
+
/** Additional skill directories */
|
|
44
|
+
skillDirs?: string[];
|
|
45
|
+
/** Resume a previous session by session ID */
|
|
46
|
+
resumeSessionId?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface CrayCodeEvents {
|
|
49
|
+
'message': (message: Message) => void;
|
|
50
|
+
'toolCall': (toolName: string, input: unknown) => void;
|
|
51
|
+
'toolResult': (toolName: string, result: unknown) => void;
|
|
52
|
+
'agentStart': (agentId: string, description: string) => void;
|
|
53
|
+
'agentEnd': (agentId: string, status: string) => void;
|
|
54
|
+
'mcpConnect': (serverName: string) => void;
|
|
55
|
+
'mcpDisconnect': (serverName: string) => void;
|
|
56
|
+
'error': (error: Error) => void;
|
|
57
|
+
'ready': () => void;
|
|
58
|
+
'shutdown': () => void;
|
|
59
|
+
}
|
|
60
|
+
export declare class CrayCode extends EventEmitter {
|
|
61
|
+
private options;
|
|
62
|
+
private initialized;
|
|
63
|
+
/** @internal — exposed for React/Ink renderer to access tool context */
|
|
64
|
+
toolContext: ToolUseContext;
|
|
65
|
+
constructor(options?: CrayCodeOptions);
|
|
66
|
+
/** Initialize Cray Code. Must be called before processMessage(). */
|
|
67
|
+
initialize(): Promise<void>;
|
|
68
|
+
/** Process a user message and return the agent's response. */
|
|
69
|
+
processMessage(userInput: string, options?: {
|
|
70
|
+
systemPrompt?: string;
|
|
71
|
+
isSubAgent?: boolean;
|
|
72
|
+
allowedTools?: string[];
|
|
73
|
+
}): Promise<{
|
|
74
|
+
messages: Message[];
|
|
75
|
+
finalResponse: string;
|
|
76
|
+
toolCalls: number;
|
|
77
|
+
tokensUsed: number;
|
|
78
|
+
duration: number;
|
|
79
|
+
}>;
|
|
80
|
+
/** Execute a slash command (e.g., /help, /model, /config). */
|
|
81
|
+
executeCommand(input: string): Promise<CommandResult>;
|
|
82
|
+
/** Compact conversation context: summarize old turns, keep the last N intact. */
|
|
83
|
+
compact(options?: {
|
|
84
|
+
keepLastTurns?: number;
|
|
85
|
+
}): CompactResult;
|
|
86
|
+
/** Add an MCP server dynamically */
|
|
87
|
+
addMCPServer(config: MCPServerConfig): Promise<void>;
|
|
88
|
+
/** Remove an MCP server */
|
|
89
|
+
removeMCPServer(serverName: string): Promise<void>;
|
|
90
|
+
/** Get current framework status summary */
|
|
91
|
+
getStatus(): {
|
|
92
|
+
initialized: boolean;
|
|
93
|
+
cwd: string;
|
|
94
|
+
model: string;
|
|
95
|
+
permissionMode: string;
|
|
96
|
+
toolCount: number;
|
|
97
|
+
skillCount: number;
|
|
98
|
+
mcpServerCount: number;
|
|
99
|
+
pluginCount: number;
|
|
100
|
+
messages: number;
|
|
101
|
+
};
|
|
102
|
+
/** Display welcome message in the terminal */
|
|
103
|
+
getWelcomeMessage(): string;
|
|
104
|
+
/** Gracefully shut down Cray Code */
|
|
105
|
+
shutdown(): Promise<void>;
|
|
106
|
+
/** Refresh the tool context with current state */
|
|
107
|
+
private refreshToolContext;
|
|
108
|
+
/** Rebuild tool pool after MCP/server changes */
|
|
109
|
+
private refreshToolPool;
|
|
110
|
+
/** Debug logging */
|
|
111
|
+
private log;
|
|
112
|
+
}
|
|
113
|
+
export default CrayCode;
|
|
114
|
+
//# sourceMappingURL=cray.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cray.d.ts","sourceRoot":"","sources":["../src/cray.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAW,cAAc,EAAiD,MAAM,WAAW,CAAC;AACxG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAyB,MAAM,uBAAuB,CAAC;AAQnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAI/D,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAExF,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAMvF,MAAM,WAAW,eAAe;IAC9B,wBAAwB;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,0BAA0B;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,sBAAsB;IACtB,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC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;AAID,eAAe,QAAQ,CAAC"}
|
package/dist/cray.js
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CrayCode — Main orchestrator class.
|
|
3
|
+
*
|
|
4
|
+
* This is the primary public API for Cray Code. It ties together:
|
|
5
|
+
* - Tool system (built-in + MCP + skill-linked)
|
|
6
|
+
* - Query engine (agent loop)
|
|
7
|
+
* - State management
|
|
8
|
+
* - Skill system
|
|
9
|
+
* - Plugin system
|
|
10
|
+
* - Command system
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* const cray = new CrayCode({ cwd: process.cwd() });
|
|
14
|
+
* await cray.initialize();
|
|
15
|
+
* const result = await cray.processMessage("Review this code");
|
|
16
|
+
*/
|
|
17
|
+
import { EventEmitter } from 'events';
|
|
18
|
+
import { getDefaultPermissionContext } from './types/permission.js';
|
|
19
|
+
import { initAppState, getStore, setAppState } from './state/AppState.js';
|
|
20
|
+
import { buildContext } from './context.js';
|
|
21
|
+
import { setCurrentSessionId, flushSessionStorage, loadSession } from './services/sessionStorage.js';
|
|
22
|
+
import { buildToolPool, invalidateToolPoolCache } from './tools.js';
|
|
23
|
+
import { getAllMCPServers, registerMCPServer } from './services/mcp/manager.js';
|
|
24
|
+
import { getBundledSkills } from './skills/bundledSkills.js';
|
|
25
|
+
import { loadDiskSkills } from './skills/loadSkillsDir.js';
|
|
26
|
+
import { getPluginSkills, getPluginMCPServers, executeSessionStartHooks, executeSessionEndHooks, loadAllPlugins } from './plugins/registry.js';
|
|
27
|
+
import { getCommand } from './commands/registry.js';
|
|
28
|
+
import { query } from './query.js';
|
|
29
|
+
import { compact as compactMessages } from './services/compact.js';
|
|
30
|
+
import { WELCOME_MESSAGE } from './branding/logo.js';
|
|
31
|
+
export class CrayCode extends EventEmitter {
|
|
32
|
+
options;
|
|
33
|
+
initialized = false;
|
|
34
|
+
/** @internal — exposed for React/Ink renderer to access tool context */
|
|
35
|
+
toolContext;
|
|
36
|
+
constructor(options = {}) {
|
|
37
|
+
super();
|
|
38
|
+
this.options = {
|
|
39
|
+
cwd: options.cwd ?? process.cwd(),
|
|
40
|
+
provider: options.provider ?? 'anthropic',
|
|
41
|
+
model: options.model ?? process.env.CRAY_MODEL ?? 'claude-sonnet-4-6',
|
|
42
|
+
apiKey: options.apiKey ?? process.env.CRAY_API_KEY ?? '',
|
|
43
|
+
baseUrl: options.baseUrl ?? '',
|
|
44
|
+
permissionMode: options.permissionMode ?? 'default',
|
|
45
|
+
maxTurns: options.maxTurns ?? 25,
|
|
46
|
+
verbose: options.verbose ?? false,
|
|
47
|
+
mcpServers: options.mcpServers ?? [],
|
|
48
|
+
skillDirs: options.skillDirs ?? [],
|
|
49
|
+
resumeSessionId: options.resumeSessionId ?? '',
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
// ─── Initialization ─────────────────────────────────────────────────
|
|
53
|
+
/** Initialize Cray Code. Must be called before processMessage(). */
|
|
54
|
+
async initialize() {
|
|
55
|
+
if (this.initialized)
|
|
56
|
+
return;
|
|
57
|
+
this.log('Initializing Cray Code...');
|
|
58
|
+
// 1. Initialize state
|
|
59
|
+
initAppState(this.options.cwd);
|
|
60
|
+
// Record session ID for persistence
|
|
61
|
+
const state = getStore().getState();
|
|
62
|
+
const sessionId = state.sessionId;
|
|
63
|
+
setCurrentSessionId(sessionId);
|
|
64
|
+
this.log(`Session ID: ${sessionId}`);
|
|
65
|
+
// If resuming, load previous messages
|
|
66
|
+
if (this.options.resumeSessionId) {
|
|
67
|
+
try {
|
|
68
|
+
const resumed = await loadSession(this.options.cwd, this.options.resumeSessionId);
|
|
69
|
+
if (resumed.length > 0) {
|
|
70
|
+
setAppState((prev) => ({
|
|
71
|
+
...prev,
|
|
72
|
+
messages: resumed,
|
|
73
|
+
}));
|
|
74
|
+
this.log(`Resumed session: ${this.options.resumeSessionId} (${resumed.length} messages)`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
this.log(`Resume failed: ${err.message}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// 2. Build context
|
|
82
|
+
this.toolContext = await buildContext({
|
|
83
|
+
cwd: this.options.cwd,
|
|
84
|
+
settings: {
|
|
85
|
+
provider: this.options.provider,
|
|
86
|
+
model: this.options.model,
|
|
87
|
+
apiKey: this.options.apiKey,
|
|
88
|
+
baseUrl: this.options.baseUrl,
|
|
89
|
+
permissionMode: this.options.permissionMode,
|
|
90
|
+
maxTurns: this.options.maxTurns,
|
|
91
|
+
verbose: this.options.verbose,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
// 3. Configure permission context
|
|
95
|
+
const permContext = getDefaultPermissionContext();
|
|
96
|
+
permContext.mode = this.options.permissionMode;
|
|
97
|
+
setAppState((prev) => ({
|
|
98
|
+
...prev,
|
|
99
|
+
permissionContext: permContext,
|
|
100
|
+
}));
|
|
101
|
+
// 4. Load plugins (discover + register before loading plugin skills)
|
|
102
|
+
await loadAllPlugins(this.options.cwd);
|
|
103
|
+
// 5. Load skills
|
|
104
|
+
const bundledSkills = getBundledSkills();
|
|
105
|
+
const diskSkills = await loadDiskSkills(this.options.cwd);
|
|
106
|
+
const pluginSkills = getPluginSkills();
|
|
107
|
+
const allSkills = [...bundledSkills, ...diskSkills, ...pluginSkills];
|
|
108
|
+
setAppState((prev) => ({
|
|
109
|
+
...prev,
|
|
110
|
+
skills: allSkills,
|
|
111
|
+
availableSkills: allSkills,
|
|
112
|
+
}));
|
|
113
|
+
this.log(`Loaded ${allSkills.length} skills (${bundledSkills.length} bundled, ${diskSkills.length} disk, ${pluginSkills.length} plugin)`);
|
|
114
|
+
// 6. Initialize MCP servers
|
|
115
|
+
for (const config of this.options.mcpServers) {
|
|
116
|
+
if (config.enabled !== false) {
|
|
117
|
+
try {
|
|
118
|
+
const connection = registerMCPServer(config);
|
|
119
|
+
await connection.connect();
|
|
120
|
+
this.emit('mcpConnect', config.name);
|
|
121
|
+
this.log(`MCP server connected: ${config.name}`);
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
this.emit('error', new Error(`MCP connect failed: ${config.name} — ${err.message}`));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// Plugin MCP servers
|
|
129
|
+
for (const [name, config] of getPluginMCPServers()) {
|
|
130
|
+
try {
|
|
131
|
+
const connection = registerMCPServer(config);
|
|
132
|
+
await connection.connect();
|
|
133
|
+
this.log(`Plugin MCP server connected: ${name}`);
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
// Plugin MCP failures are non-fatal
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// 7. Execute plugin session start hooks
|
|
140
|
+
await executeSessionStartHooks();
|
|
141
|
+
// 8. Build initial tool pool
|
|
142
|
+
const toolPool = buildToolPool(permContext);
|
|
143
|
+
setAppState((prev) => ({ ...prev, toolPool }));
|
|
144
|
+
this.initialized = true;
|
|
145
|
+
this.emit('ready');
|
|
146
|
+
this.log(`Cray Code ready. ${toolPool.length} tools available.`);
|
|
147
|
+
}
|
|
148
|
+
// ─── Message Processing ─────────────────────────────────────────────
|
|
149
|
+
/** Process a user message and return the agent's response. */
|
|
150
|
+
async processMessage(userInput, options) {
|
|
151
|
+
if (!this.initialized) {
|
|
152
|
+
throw new Error('CrayCode not initialized. Call initialize() first.');
|
|
153
|
+
}
|
|
154
|
+
const startTime = Date.now();
|
|
155
|
+
this.log(`Processing: "${userInput.slice(0, 100)}..."`);
|
|
156
|
+
// Update tool context with latest state
|
|
157
|
+
this.refreshToolContext();
|
|
158
|
+
// Collect events from async generator query
|
|
159
|
+
const messages = [];
|
|
160
|
+
for await (const event of query({
|
|
161
|
+
prompt: userInput,
|
|
162
|
+
context: this.toolContext,
|
|
163
|
+
systemPrompt: options?.systemPrompt,
|
|
164
|
+
model: this.options.model,
|
|
165
|
+
allowedTools: options?.allowedTools,
|
|
166
|
+
isSubAgent: options?.isSubAgent ?? false,
|
|
167
|
+
maxTurns: this.options.maxTurns,
|
|
168
|
+
})) {
|
|
169
|
+
if (event.type === 'done') {
|
|
170
|
+
messages.push(...event.messages);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Extract final text response
|
|
174
|
+
const lastAssistant = [...messages].reverse().find((m) => m.role === 'assistant');
|
|
175
|
+
const finalResponse = lastAssistant
|
|
176
|
+
? lastAssistant.content
|
|
177
|
+
.filter((c) => c.type === 'text')
|
|
178
|
+
.map((c) => c.text)
|
|
179
|
+
.join('\n')
|
|
180
|
+
: '';
|
|
181
|
+
// Count tool calls
|
|
182
|
+
const toolCalls = messages.reduce((count, m) => {
|
|
183
|
+
if (m.role === 'assistant') {
|
|
184
|
+
return count + m.content.filter((c) => c.type === 'tool_use').length;
|
|
185
|
+
}
|
|
186
|
+
return count;
|
|
187
|
+
}, 0);
|
|
188
|
+
const duration = Date.now() - startTime;
|
|
189
|
+
this.log(`Completed in ${duration}ms, ${toolCalls} tool calls, ${messages.length} messages`);
|
|
190
|
+
return {
|
|
191
|
+
messages,
|
|
192
|
+
finalResponse,
|
|
193
|
+
toolCalls,
|
|
194
|
+
tokensUsed: 0, // Tracked by API service in production
|
|
195
|
+
duration,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
// ─── Command Execution ──────────────────────────────────────────────
|
|
199
|
+
/** Execute a slash command (e.g., /help, /model, /config). */
|
|
200
|
+
async executeCommand(input) {
|
|
201
|
+
const match = input.match(/^\/(\w+)\s*(.*)/);
|
|
202
|
+
if (!match) {
|
|
203
|
+
return { success: false, message: 'Not a command. Use /help for available commands.' };
|
|
204
|
+
}
|
|
205
|
+
const [, commandName, argsString] = match;
|
|
206
|
+
const cmd = getCommand(commandName);
|
|
207
|
+
if (!cmd) {
|
|
208
|
+
return { success: false, message: `Unknown command: /${commandName}. Type /help for available commands.` };
|
|
209
|
+
}
|
|
210
|
+
const args = argsString ? argsString.trim().split(/\s+/) : [];
|
|
211
|
+
return cmd.execute(args, {
|
|
212
|
+
cwd: this.options.cwd,
|
|
213
|
+
settings: {
|
|
214
|
+
model: this.options.model,
|
|
215
|
+
provider: this.options.provider,
|
|
216
|
+
apiKey: this.options.apiKey,
|
|
217
|
+
baseUrl: this.options.baseUrl,
|
|
218
|
+
permissionMode: this.options.permissionMode,
|
|
219
|
+
maxTurns: this.options.maxTurns,
|
|
220
|
+
verbose: this.options.verbose,
|
|
221
|
+
},
|
|
222
|
+
logDebug: (msg) => this.log(msg),
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
// ─── Context Compaction ──────────────────────────────────────────────
|
|
226
|
+
/** Compact conversation context: summarize old turns, keep the last N intact. */
|
|
227
|
+
compact(options) {
|
|
228
|
+
const state = getStore().getState();
|
|
229
|
+
const msgs = this.toolContext.messages.length > 0
|
|
230
|
+
? this.toolContext.messages
|
|
231
|
+
: state.messages;
|
|
232
|
+
if (msgs.length === 0) {
|
|
233
|
+
return { messages: [], removedCount: 0, keptCount: 0, summaryText: '', estimatedTokensSaved: 0 };
|
|
234
|
+
}
|
|
235
|
+
const result = compactMessages(msgs, {
|
|
236
|
+
keepLastTurns: options?.keepLastTurns ?? 3,
|
|
237
|
+
});
|
|
238
|
+
this.log(`Compacted: ${result.removedCount} msgs → ${result.keptCount} kept, saved ~${result.estimatedTokensSaved} tokens`);
|
|
239
|
+
// Update the tool context messages to the compacted set
|
|
240
|
+
this.toolContext.messages = result.messages;
|
|
241
|
+
// Also update the app state
|
|
242
|
+
setAppState((prev) => ({ ...prev, messages: result.messages }));
|
|
243
|
+
return result;
|
|
244
|
+
}
|
|
245
|
+
// ─── MCP Management ─────────────────────────────────────────────────
|
|
246
|
+
/** Add an MCP server dynamically */
|
|
247
|
+
async addMCPServer(config) {
|
|
248
|
+
const connection = registerMCPServer(config);
|
|
249
|
+
await connection.connect();
|
|
250
|
+
this.refreshToolPool();
|
|
251
|
+
this.emit('mcpConnect', config.name);
|
|
252
|
+
this.log(`MCP server added: ${config.name}`);
|
|
253
|
+
}
|
|
254
|
+
/** Remove an MCP server */
|
|
255
|
+
async removeMCPServer(serverName) {
|
|
256
|
+
const servers = getAllMCPServers();
|
|
257
|
+
const server = servers.get(serverName);
|
|
258
|
+
if (server) {
|
|
259
|
+
await server.disconnect();
|
|
260
|
+
servers.delete(serverName);
|
|
261
|
+
this.refreshToolPool();
|
|
262
|
+
this.emit('mcpDisconnect', serverName);
|
|
263
|
+
this.log(`MCP server removed: ${serverName}`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// ─── Status ─────────────────────────────────────────────────────────
|
|
267
|
+
/** Get current framework status summary */
|
|
268
|
+
getStatus() {
|
|
269
|
+
const state = getStore().getState();
|
|
270
|
+
return {
|
|
271
|
+
initialized: this.initialized,
|
|
272
|
+
cwd: this.options.cwd,
|
|
273
|
+
model: this.options.model,
|
|
274
|
+
permissionMode: this.options.permissionMode,
|
|
275
|
+
toolCount: state.toolPool.length,
|
|
276
|
+
skillCount: state.skills.length,
|
|
277
|
+
mcpServerCount: getAllMCPServers().size,
|
|
278
|
+
pluginCount: 0, // Updated when plugins loaded
|
|
279
|
+
messages: state.messages.length,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
/** Display welcome message in the terminal */
|
|
283
|
+
getWelcomeMessage() {
|
|
284
|
+
return WELCOME_MESSAGE;
|
|
285
|
+
}
|
|
286
|
+
// ─── Cleanup ────────────────────────────────────────────────────────
|
|
287
|
+
/** Gracefully shut down Cray Code */
|
|
288
|
+
async shutdown() {
|
|
289
|
+
this.log('Shutting down Cray Code...');
|
|
290
|
+
// Flush pending session writes
|
|
291
|
+
await flushSessionStorage();
|
|
292
|
+
// Disconnect all MCP servers
|
|
293
|
+
for (const [name, server] of getAllMCPServers()) {
|
|
294
|
+
try {
|
|
295
|
+
await server.disconnect();
|
|
296
|
+
this.log(`Disconnected MCP: ${name}`);
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
// Force disconnect
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
// Execute plugin end hooks
|
|
303
|
+
await executeSessionEndHooks();
|
|
304
|
+
this.emit('shutdown');
|
|
305
|
+
this.removeAllListeners();
|
|
306
|
+
this.initialized = false;
|
|
307
|
+
this.log('Cray Code shutdown complete.');
|
|
308
|
+
}
|
|
309
|
+
// ─── Private Helpers ────────────────────────────────────────────────
|
|
310
|
+
/** Refresh the tool context with current state */
|
|
311
|
+
refreshToolContext() {
|
|
312
|
+
const state = getStore().getState();
|
|
313
|
+
this.toolContext = {
|
|
314
|
+
...this.toolContext,
|
|
315
|
+
permissionContext: state.permissionContext,
|
|
316
|
+
mcpClients: state.mcpClients,
|
|
317
|
+
availableSkills: state.availableSkills,
|
|
318
|
+
agentDefinitions: state.agentDefinitions,
|
|
319
|
+
messages: state.messages,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
/** Rebuild tool pool after MCP/server changes */
|
|
323
|
+
refreshToolPool() {
|
|
324
|
+
const state = getStore().getState();
|
|
325
|
+
invalidateToolPoolCache();
|
|
326
|
+
const toolPool = buildToolPool(state.permissionContext);
|
|
327
|
+
setAppState((prev) => ({ ...prev, toolPool }));
|
|
328
|
+
}
|
|
329
|
+
/** Debug logging */
|
|
330
|
+
log(message) {
|
|
331
|
+
if (this.options.verbose) {
|
|
332
|
+
console.log(`[Cray] ${message}`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
// ─── Default Export ──────────────────────────────────────────────────────
|
|
337
|
+
export default CrayCode;
|
|
338
|
+
//# sourceMappingURL=cray.js.map
|
package/dist/cray.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cray.js","sourceRoot":"","sources":["../src/cray.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAItC,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,Y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,KAAK,CAAC,QAAQ;SACzB,CAAC;IACJ,CAAC;IAED,iDAAiD;IACzC,eAAe;QACrB,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;QACpC,uBAAuB,EAAE,CAAC;QAC1B,MAAM,QAAQ,GAAG,aAAa,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACxD,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,oBAAoB;IACZ,GAAG,CAAC,OAAe;QACzB,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;CACF;AAED,4EAA4E;AAE5E,eAAe,QAAQ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Cray Code — Main Entry Point
|
|
4
|
+
*
|
|
5
|
+
* Always launches the interactive React/Ink terminal UI.
|
|
6
|
+
* If a prompt argument is given, it's sent as the first message
|
|
7
|
+
* and the REPL stays open for follow-up.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* cray # Interactive
|
|
11
|
+
* cray "hello" # Interactive, with first message
|
|
12
|
+
* cray --setup # Re-run setup
|
|
13
|
+
* cray --show-welcome # Banner only
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Cray Code — Main Entry Point
|
|
4
|
+
*
|
|
5
|
+
* Always launches the interactive React/Ink terminal UI.
|
|
6
|
+
* If a prompt argument is given, it's sent as the first message
|
|
7
|
+
* and the REPL stays open for follow-up.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* cray # Interactive
|
|
11
|
+
* cray "hello" # Interactive, with first message
|
|
12
|
+
* cray --setup # Re-run setup
|
|
13
|
+
* cray --show-welcome # Banner only
|
|
14
|
+
*/
|
|
15
|
+
import { Command } from 'commander';
|
|
16
|
+
import { resolve } from 'path';
|
|
17
|
+
import CrayCode from './cray.js';
|
|
18
|
+
import { CRAY_LOGO, CRAY_TAGLINE } from './branding/logo.js';
|
|
19
|
+
import { runFirstTimeSetup } from './setup.js';
|
|
20
|
+
import { loadConfig, isSetupComplete } from './utils/configStore.js';
|
|
21
|
+
const program = new Command();
|
|
22
|
+
program
|
|
23
|
+
.name('cray')
|
|
24
|
+
.description(CRAY_TAGLINE)
|
|
25
|
+
.version('1.0.0')
|
|
26
|
+
.argument('[prompt]', 'First message to send, then stay interactive')
|
|
27
|
+
.option('-m, --model <model>', 'Override the configured model')
|
|
28
|
+
.option('-d, --dir <directory>', 'Working directory', 'D:/VSCODE/TEST')
|
|
29
|
+
.option('-p, --permission <mode>', 'Permission mode', 'default')
|
|
30
|
+
.option('-v, --verbose', 'Enable verbose logging', false)
|
|
31
|
+
.option('--max-turns <number>', 'Max agent turns', '25')
|
|
32
|
+
.option('--resume <sessionId>', 'Resume a previous conversation by session ID')
|
|
33
|
+
.option('--setup', 'Re-run the setup wizard')
|
|
34
|
+
.option('--show-welcome', 'Show welcome banner and exit')
|
|
35
|
+
.option('--list-sessions', 'List saved sessions and exit')
|
|
36
|
+
.action(async (prompt, options) => {
|
|
37
|
+
if (options.showWelcome) {
|
|
38
|
+
showWelcome();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (options.setup) {
|
|
42
|
+
await runFirstTimeSetup();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
// --list-sessions
|
|
46
|
+
if (options.listSessions) {
|
|
47
|
+
const { listSessions } = await import('./services/sessionStorage.js');
|
|
48
|
+
const sessions = await listSessions(resolve(options.dir));
|
|
49
|
+
if (!sessions.length) {
|
|
50
|
+
console.log('No saved sessions.');
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
console.log(`Saved sessions (${sessions.length}):\n`);
|
|
54
|
+
for (let i = 0; i < sessions.length; i++) {
|
|
55
|
+
const s = sessions[i];
|
|
56
|
+
const date = new Date(s.updatedAt).toLocaleString();
|
|
57
|
+
console.log(` ${i + 1}. [${date}] ${s.firstPrompt.slice(0, 80)}`);
|
|
58
|
+
console.log(` ID: ${s.sessionId} · ${s.messageCount} msgs\n`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
process.exit(0);
|
|
62
|
+
}
|
|
63
|
+
// Ensure setup
|
|
64
|
+
if (!isSetupComplete()) {
|
|
65
|
+
console.clear();
|
|
66
|
+
const config = await runFirstTimeSetup();
|
|
67
|
+
if (!config.setupComplete || !config.apiKey) {
|
|
68
|
+
console.log('\n Setup incomplete. Run `cray --setup` to try again.\n');
|
|
69
|
+
process.exit(0);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const config = loadConfig();
|
|
73
|
+
const cray = new CrayCode({
|
|
74
|
+
cwd: resolve(options.dir),
|
|
75
|
+
provider: config.provider,
|
|
76
|
+
model: options.model ?? config.model,
|
|
77
|
+
apiKey: config.apiKey,
|
|
78
|
+
baseUrl: config.baseUrl,
|
|
79
|
+
permissionMode: (options.permission ?? config.permissionMode),
|
|
80
|
+
maxTurns: parseInt(options.maxTurns, 10),
|
|
81
|
+
verbose: options.verbose,
|
|
82
|
+
resumeSessionId: options.resume,
|
|
83
|
+
});
|
|
84
|
+
try {
|
|
85
|
+
await cray.initialize();
|
|
86
|
+
await runInteractive(cray, prompt || undefined);
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
console.error(`\nCray Code error: ${err.message}`);
|
|
90
|
+
if (options.verbose)
|
|
91
|
+
console.error(err.stack);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
await cray.shutdown();
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
// ─── Interactive (React/Ink terminal UI) ─────────────────────────────
|
|
99
|
+
async function runInteractive(cray, initialPrompt) {
|
|
100
|
+
const { mountReplScreen } = await import('./screens/ReplScreen.js');
|
|
101
|
+
const { unmount } = mountReplScreen(cray, initialPrompt);
|
|
102
|
+
const onSigint = () => cray.shutdown();
|
|
103
|
+
process.once('SIGINT', onSigint);
|
|
104
|
+
await new Promise((resolve) => {
|
|
105
|
+
cray.once('shutdown', () => { unmount(); resolve(); });
|
|
106
|
+
});
|
|
107
|
+
process.off('SIGINT', onSigint);
|
|
108
|
+
}
|
|
109
|
+
// ─── Welcome Banner ──────────────────────────────────────────────────
|
|
110
|
+
function showWelcome() {
|
|
111
|
+
console.log(CRAY_LOGO);
|
|
112
|
+
console.log(` ${CRAY_TAGLINE}`);
|
|
113
|
+
console.log('\n Features:');
|
|
114
|
+
console.log(' - Multi-turn agent loop with tool calling & streaming');
|
|
115
|
+
console.log(' - MCP / Skills / Sub-agent / Plugin systems');
|
|
116
|
+
console.log(' - React/Ink terminal UI with real-time thinking display');
|
|
117
|
+
console.log('\n Providers: Anthropic | OpenAI | Ollama | OpenRouter | DeepSeek | Custom');
|
|
118
|
+
console.log();
|
|
119
|
+
}
|
|
120
|
+
// ─── Startup ─────────────────────────────────────────────────────────
|
|
121
|
+
program.parse();
|
|
122
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,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