@exreve/exk 1.0.7 → 1.0.9
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 +5 -34
- package/dist/agentLogger.js +143 -0
- package/dist/agentSession.js +1020 -0
- package/dist/app-child.js +2589 -0
- package/dist/appManager.js +222 -0
- package/dist/appRunner.js +383 -0
- package/dist/index.js +2745 -0
- package/dist/moduleMcpServer.js +93 -0
- package/dist/projectAnalyzer.js +323 -0
- package/dist/projectManager.js +92 -0
- package/{runnerGenerator.ts → dist/runnerGenerator.js} +29 -36
- package/dist/shared/types.js +2 -0
- package/dist/skills/index.js +117 -0
- package/dist/ttc-cli.tar.gz +0 -0
- package/dist/updater.js +425 -0
- package/package.json +6 -8
- package/agentLogger.ts +0 -162
- package/agentSession.ts +0 -1176
- package/app-child.ts +0 -2872
- package/appManager.ts +0 -275
- package/appRunner.ts +0 -475
- package/index.ts +0 -3049
- package/moduleMcpServer.ts +0 -131
- package/projectAnalyzer.ts +0 -341
- package/projectManager.ts +0 -111
- package/shared/types.ts +0 -488
- package/tsconfig.json +0 -22
- package/updater.ts +0 -512
package/bin/exk
CHANGED
|
@@ -1,49 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// exk CLI - entry point for npm global install
|
|
3
|
-
// Runs
|
|
3
|
+
// Runs compiled JavaScript directly (no tsx needed)
|
|
4
4
|
|
|
5
5
|
import { resolve, dirname } from 'path'
|
|
6
|
-
import { spawn } from 'child_process'
|
|
7
|
-
import fs from 'fs'
|
|
8
6
|
import { fileURLToPath } from 'url'
|
|
9
7
|
|
|
10
8
|
const __filename = fileURLToPath(import.meta.url)
|
|
11
9
|
const __dirname = dirname(__filename)
|
|
12
10
|
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const entryPoint = resolve(pkgDir, 'index.ts')
|
|
16
|
-
|
|
17
|
-
// Find tsx binary
|
|
18
|
-
let tsxBin = resolve(pkgDir, 'node_modules', '.bin', 'tsx')
|
|
19
|
-
if (!fs.existsSync(tsxBin)) {
|
|
20
|
-
// Walk up to find tsx in parent node_modules (npm global structure)
|
|
21
|
-
let dir = pkgDir
|
|
22
|
-
for (let i = 0; i < 10; i++) {
|
|
23
|
-
const candidate = resolve(dir, 'node_modules', '.bin', 'tsx')
|
|
24
|
-
if (fs.existsSync(candidate)) {
|
|
25
|
-
tsxBin = candidate
|
|
26
|
-
break
|
|
27
|
-
}
|
|
28
|
-
const parent = resolve(dir, '..')
|
|
29
|
-
if (parent === dir) break
|
|
30
|
-
dir = parent
|
|
31
|
-
}
|
|
32
|
-
}
|
|
11
|
+
const pkgDir = resolve(__dirname, '..')
|
|
12
|
+
const entryPoint = resolve(pkgDir, 'dist', 'index.js')
|
|
33
13
|
|
|
34
14
|
const args = process.argv.slice(2)
|
|
35
15
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
env: { ...process.env },
|
|
39
|
-
cwd: pkgDir
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
child.on('exit', (code) => {
|
|
43
|
-
process.exit(code ?? 0)
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
child.on('error', (err) => {
|
|
16
|
+
// Import and run the compiled CLI
|
|
17
|
+
import(entryPoint).catch(err => {
|
|
47
18
|
console.error('Failed to start exk:', err.message)
|
|
48
19
|
process.exit(1)
|
|
49
20
|
})
|
|
@@ -0,0 +1,143 @@
|
|
|
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
|
+
}
|