Skip to content

Commit db76643

Browse files
committed
Use config-driven project name for client-time script and add detailed Claude Code SDK migration plans
1 parent daa7c7c commit db76643

2 files changed

Lines changed: 32 additions & 32 deletions

File tree

client-time.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env node
22

33
/**
4-
* Полный отчет времени для клиента: обычное время + время бота
5-
* Usage: node client-time.js [дни] [проект]
4+
* Full time report for client: regular time + bot time
5+
* Usage: node client-time.js [days] [project]
66
*/
77

88
const axios = require('axios');
@@ -14,9 +14,9 @@ const WINDOW_BUCKET = 'aw-watcher-window_errogaht-G1619-04';
1414

1515
async function getClientTime(days = 1, project = config.activityWatch.defaultProject) {
1616
try {
17-
console.log(`\n💰 ВРЕМЯ ДЛЯ КЛИЕНТА: проект "${project}" (${days} дн.)\n`);
17+
console.log(`\n💰 CLIENT TIME: project "${project}" (${days} days)\n`);
1818

19-
// 1. ПОЛУЧИТЬ ВРЕМЯ БОТА (с множителем)
19+
// 1. GET BOT TIME (with multiplier)
2020
let botTime = 0, botOriginalTime = 0, multiplier = 1, botEvents = [];
2121

2222
try {
@@ -29,14 +29,14 @@ async function getClientTime(days = 1, project = config.activityWatch.defaultPro
2929
return event.data.project === project && eventDate >= cutoffDate;
3030
});
3131

32-
botTime = botEvents.reduce((sum, event) => sum + event.duration, 0) / 3600; // в часах
32+
botTime = botEvents.reduce((sum, event) => sum + event.duration, 0) / 3600; // in hours
3333
botOriginalTime = botEvents.reduce((sum, event) => sum + (event.data.original_duration || event.duration), 0) / 3600;
3434
multiplier = botEvents[0]?.data?.time_multiplier || 1;
3535
} catch (error) {
36-
console.log('⚠️ Не удалось получить время бота:', error.message);
36+
console.log('⚠️ Could not get bot time:', error.message);
3737
}
3838

39-
// 2. ПОЛУЧИТЬ ОБЫЧНОЕ ВРЕМЯ (окна/приложения)
39+
// 2. GET REGULAR TIME (windows/applications)
4040
let windowTime = 0, windowEvents = [];
4141

4242
try {
@@ -46,46 +46,46 @@ async function getClientTime(days = 1, project = config.activityWatch.defaultPro
4646

4747
const todayStr = new Date().toISOString().split('T')[0];
4848
if (days === 1) {
49-
// Для сегодня - точная дата
49+
// For today - exact date
5050
windowEvents = windowResponse.data.filter(event =>
5151
event.timestamp.startsWith(todayStr) &&
5252
(event.data.title || '').toLowerCase().includes(project.toLowerCase())
5353
);
5454
} else {
55-
// Для нескольких дней - диапазон дат
55+
// For multiple days - date range
5656
windowEvents = windowResponse.data.filter(event => {
5757
const eventDate = new Date(event.timestamp);
5858
return eventDate >= cutoffDate &&
5959
(event.data.title || '').toLowerCase().includes(project.toLowerCase());
6060
});
6161
}
6262

63-
windowTime = windowEvents.reduce((sum, event) => sum + event.duration, 0) / 3600; // в часах
63+
windowTime = windowEvents.reduce((sum, event) => sum + event.duration, 0) / 3600; // in hours
6464
} catch (error) {
65-
console.log('⚠️ Не удалось получить обычное время:', error.message);
65+
console.log('⚠️ Could not get regular time:', error.message);
6666
}
6767

68-
// 3. ИТОГИ
68+
// 3. TOTALS
6969
const totalTime = windowTime + botTime;
7070

71-
console.log('📊 РАЗБИВКА:');
71+
console.log('📊 BREAKDOWN:');
7272
console.log('=' .repeat(50));
73-
console.log(`🖥️ Обычная работа (окна): ${windowTime.toFixed(2)} ч`);
74-
console.log(`🤖 Работа с ботом: ${botOriginalTime.toFixed(2)} ч${botTime.toFixed(2)} ч (${multiplier}x)`);
73+
console.log(`🖥️ Regular work (windows): ${windowTime.toFixed(2)} h`);
74+
console.log(`🤖 Bot work: ${botOriginalTime.toFixed(2)} h${botTime.toFixed(2)} h (${multiplier}x)`);
7575
console.log('=' .repeat(50));
76-
console.log(`💰 ИТОГО ДЛЯ КЛИЕНТА: ${totalTime.toFixed(2)} ч`);
76+
console.log(`💰 TOTAL FOR CLIENT: ${totalTime.toFixed(2)} h`);
7777

78-
// 4. ДЕТАЛИ
79-
console.log(`\n📈 ДЕТАЛИ:`);
80-
console.log(`- Обычное время: ${windowEvents.length} событий, ${windowTime.toFixed(2)} часов`);
81-
console.log(`- Время бота: ${botEvents.length} сессий, ${botTime.toFixed(2)} часов (множитель ${multiplier}x)`);
82-
console.log(`- Дата: ${days === 1 ? 'сегодня' : `последние ${days} дней`}`);
78+
// 4. DETAILS
79+
console.log(`\n📈 DETAILS:`);
80+
console.log(`- Regular time: ${windowEvents.length} events, ${windowTime.toFixed(2)} hours`);
81+
console.log(`- Bot time: ${botEvents.length} sessions, ${botTime.toFixed(2)} hours (multiplier ${multiplier}x)`);
82+
console.log(`- Date: ${days === 1 ? 'today' : `last ${days} days`}`);
8383

84-
// 5. ДЛЯ КОПИРОВАНИЯ КЛИЕНТУ
85-
console.log(`\n📝 ДЛЯ КЛИЕНТА:`);
86-
console.log(`Проект: ${project}`);
87-
console.log(`Дата: ${new Date().toLocaleDateString('ru-RU')}`);
88-
console.log(`Время работы: ${totalTime.toFixed(2)} часов`);
84+
// 5. FOR CLIENT COPY
85+
console.log(`\n📝 FOR CLIENT:`);
86+
console.log(`Project: ${project}`);
87+
console.log(`Date: ${new Date().toLocaleDateString('en-US')}`);
88+
console.log(`Work time: ${totalTime.toFixed(2)} hours`);
8989

9090
return {
9191
windowTime: windowTime,
@@ -96,14 +96,14 @@ async function getClientTime(days = 1, project = config.activityWatch.defaultPro
9696
};
9797

9898
} catch (error) {
99-
console.error('❌ Ошибка:', error.message);
100-
console.log('\n🔧 Проверь:');
101-
console.log('• ActivityWatch запущен: curl http://localhost:5600/api/0/info');
102-
console.log('• Бот записывает время');
99+
console.error('❌ Error:', error.message);
100+
console.log('\n🔧 Check:');
101+
console.log('• ActivityWatch is running: curl http://localhost:5600/api/0/info');
102+
console.log('• Bot is recording time');
103103
}
104104
}
105105

106-
// Запуск
106+
// Launch
107107
const days = parseInt(process.argv[2]) || 1;
108108
const project = process.argv[3] || config.activityWatch.defaultProject;
109109

time-report.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ async function getTimeReport(days = 7, project = config.activityWatch.defaultPro
9595
// Add total row
9696
csvData.push(`TOTAL,${totalSessions},${(totalOriginalTime / 3600).toFixed(2)},${(totalRecordedTime / 3600).toFixed(2)},`);
9797

98-
const csvFilename = `${project}-time-report-${new Date().toISOString().split('T')[0]}.csv`;
98+
const csvFilename = `${project}-${config.activityWatch.reportSettings.prefix}-${new Date().toISOString().split('T')[0]}.csv`;
9999
fs.writeFileSync(csvFilename, csvData.join('\n'));
100100

101101
console.log(`\n💾 CSV report saved as: ${csvFilename}`);

0 commit comments

Comments
 (0)