@exreve/exk 1.0.55 → 1.0.56

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/bin/exk CHANGED
@@ -3,13 +3,17 @@
3
3
  // Runs compiled JavaScript directly (no tsx needed)
4
4
 
5
5
  import { resolve, dirname } from 'path'
6
+ import { existsSync } from 'fs'
6
7
  import { fileURLToPath } from 'url'
7
8
 
8
9
  const __filename = fileURLToPath(import.meta.url)
9
10
  const __dirname = dirname(__filename)
10
11
 
11
12
  const pkgDir = resolve(__dirname, '..')
12
- const entryPoint = resolve(pkgDir, 'dist', 'index.js')
13
+ // dist layout varies by tsc root inference — check both locations
14
+ const entryPoint = existsSync(resolve(pkgDir, 'dist', 'cli', 'index.js'))
15
+ ? resolve(pkgDir, 'dist', 'cli', 'index.js')
16
+ : resolve(pkgDir, 'dist', 'index.js')
13
17
 
14
18
  const args = process.argv.slice(2)
15
19
 
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exreve/exk",
3
- "version": "1.0.55",
3
+ "version": "1.0.56",
4
4
  "description": "exk - Control Claude CLI with voice and programmable interfaces",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,143 +0,0 @@
1
- import fs from 'fs/promises';
2
- import path from 'path';
3
- import os from 'os';
4
- const LOGS_DIR = path.join(os.homedir(), '.talk-to-code', 'agent-logs');
5
- const ensureLogsDir = () => fs.mkdir(LOGS_DIR, { recursive: true });
6
- const getLogFilePath = (sessionId) => path.join(LOGS_DIR, `session-${sessionId}.log`);
7
- const formatTimestamp = () => new Date().toISOString();
8
- async function writeLog(sessionId, level, message, data) {
9
- try {
10
- await ensureLogsDir();
11
- const logFile = getLogFilePath(sessionId);
12
- const dataStr = data ? ` | Data: ${JSON.stringify(data)}` : '';
13
- await fs.appendFile(logFile, `[${formatTimestamp()}] [${level}] ${message}${dataStr}\n`, 'utf-8');
14
- }
15
- catch (error) {
16
- console.error(`Failed to write log: ${error}`);
17
- }
18
- }
19
- /**
20
- * Agent session logger
21
- */
22
- export class AgentLogger {
23
- sessionId;
24
- constructor(sessionId) {
25
- this.sessionId = sessionId;
26
- }
27
- async info(message, data) {
28
- await writeLog(this.sessionId, 'INFO', message, data);
29
- const dataStr = data ? ` | ${JSON.stringify(data).substring(0, 200)}` : '';
30
- console.log(`[Agent] [${this.sessionId}] ${message}${dataStr}`);
31
- }
32
- async error(message, error) {
33
- const errorData = error instanceof Error
34
- ? { message: error.message, stack: error.stack, name: error.name }
35
- : error;
36
- await writeLog(this.sessionId, 'ERROR', message, errorData);
37
- console.error(`[Agent] [${this.sessionId}] ✗ ERROR: ${message}`);
38
- if (error instanceof Error) {
39
- console.error(` → ${error.message}`);
40
- if (error.stack && process.env.DEBUG_AGENT) {
41
- console.error(` Stack: ${error.stack}`);
42
- }
43
- }
44
- else if (error) {
45
- console.error(` → ${JSON.stringify(error).substring(0, 500)}`);
46
- }
47
- }
48
- async warn(message, data) {
49
- await writeLog(this.sessionId, 'WARN', message, data);
50
- const dataStr = data ? ` | ${JSON.stringify(data).substring(0, 200)}` : '';
51
- console.warn(`[Agent] [${this.sessionId}] ⚠ WARN: ${message}${dataStr}`);
52
- }
53
- async debug(message, data) {
54
- await writeLog(this.sessionId, 'DEBUG', message, data);
55
- if (process.env.DEBUG_AGENT) {
56
- const dataStr = data ? ` | ${JSON.stringify(data).substring(0, 200)}` : '';
57
- console.log(`[Agent] [${this.sessionId}] 🔍 DEBUG: ${message}${dataStr}`);
58
- }
59
- }
60
- /**
61
- * Log prompt processing start
62
- */
63
- async logPromptStart(prompt, projectPath) {
64
- await this.info('📤 Prompt processing started', {
65
- promptLength: prompt.length,
66
- promptPreview: prompt.substring(0, 200),
67
- projectPath
68
- });
69
- console.log(`[Agent] [${this.sessionId}] 📤 Processing prompt (${prompt.length} chars)`);
70
- console.log(`[Agent] [${this.sessionId}] Preview: ${prompt.substring(0, 150)}${prompt.length > 150 ? '...' : ''}`);
71
- }
72
- async logPromptEnd(exitCode, duration, tokenUsage) {
73
- const durationSec = (duration / 1000).toFixed(2);
74
- const status = exitCode === 0 || exitCode === null ? '✓' : '✗';
75
- await this.info('Prompt processing completed', {
76
- exitCode,
77
- durationMs: duration,
78
- durationSeconds: durationSec,
79
- tokenUsage
80
- });
81
- console.log(`[Agent] [${this.sessionId}] ${status} Prompt completed in ${durationSec}s (exit: ${exitCode ?? 'null'})`);
82
- if (tokenUsage) {
83
- console.log(`[Agent] [${this.sessionId}] Tokens: ${tokenUsage.inputTokens} in + ${tokenUsage.outputTokens} out = ${tokenUsage.inputTokens + tokenUsage.outputTokens} total`);
84
- console.log(`[Agent] [${this.sessionId}] Cost: $${tokenUsage.costUsd.toFixed(6)}`);
85
- }
86
- }
87
- async logToolCall(toolName, toolData) {
88
- await this.debug('Tool called', {
89
- toolName,
90
- toolData: typeof toolData === 'string' ? toolData.substring(0, 500) : toolData
91
- });
92
- console.log(`[Agent] [${this.sessionId}] 🔧 Tool: ${toolName}`);
93
- }
94
- async logToolResult(toolName, result, success) {
95
- await this.debug('Tool result', {
96
- toolName,
97
- success,
98
- resultPreview: typeof result === 'string' ? result.substring(0, 500) : JSON.stringify(result).substring(0, 500)
99
- });
100
- const status = success ? '✓' : '✗';
101
- const resultPreview = typeof result === 'string'
102
- ? result.substring(0, 100)
103
- : JSON.stringify(result).substring(0, 100);
104
- const resultLen = typeof result === 'string' ? result.length : JSON.stringify(result).length;
105
- console.log(`[Agent] [${this.sessionId}] ${status} Tool result (${toolName}): ${resultPreview}${resultLen > 100 ? '...' : ''}`);
106
- }
107
- async logAgentResponse(response, metadata) {
108
- await this.info('Agent response', {
109
- responseLength: response.length,
110
- responsePreview: response.substring(0, 500),
111
- metadata
112
- });
113
- }
114
- async logSessionCreated(projectPath) {
115
- await this.info('Session created', { projectPath });
116
- console.log(`[Agent] [${this.sessionId}] 🚀 Session created`);
117
- console.log(`[Agent] [${this.sessionId}] Project: ${projectPath}`);
118
- }
119
- async logSessionError(error, context) {
120
- const errorMessage = error instanceof Error ? error.message : error;
121
- await this.error('Session error', {
122
- error: errorMessage,
123
- stack: error instanceof Error ? error.stack : undefined,
124
- context
125
- });
126
- }
127
- async logClaudeSessionId(sessionId) {
128
- await this.info('Claude SDK session ID captured', { claudeSessionId: sessionId });
129
- console.log(`[Agent] [${this.sessionId}] 🔗 Claude SDK session ID: ${sessionId.substring(0, 20)}...`);
130
- }
131
- async logModelConfig(model, baseUrl) {
132
- await this.info('Model configuration', { model, baseUrl });
133
- console.log(`[Agent] [${this.sessionId}] ⚙️ Model: ${model}`);
134
- if (baseUrl) {
135
- console.log(`[Agent] [${this.sessionId}] Base URL: ${baseUrl}`);
136
- }
137
- }
138
- async logTokenUsage(usage) {
139
- await this.info('Token usage', usage);
140
- console.log(`[Agent] [${this.sessionId}] 📊 Token usage: ${usage.inputTokens} in + ${usage.outputTokens} out = ${usage.totalTokens} total`);
141
- console.log(`[Agent] [${this.sessionId}] Cost: $${usage.costUsd.toFixed(6)}`);
142
- }
143
- }