@traisetech/autopilot 2.1.0 → 2.1.1
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/CHANGELOG.md +29 -0
- package/docs/DESIGN_PRINCIPLES.md +62 -6
- package/package.json +2 -2
- package/src/commands/dashboard.mjs +16 -12
- package/src/commands/doctor.js +14 -4
- package/src/commands/insights.js +33 -67
- package/src/commands/leaderboard.js +6 -7
- package/src/core/git.js +6 -5
- package/src/index.js +8 -2
- package/src/utils/logger.js +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,35 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
This project follows [Semantic Versioning](https://semver.org).
|
|
5
5
|
|
|
6
|
+
## [2.1.1] - 2026-02-11
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
- **Global Leaderboard Sync**:
|
|
10
|
+
- New `autopilot leaderboard --sync` command to share productivity metrics with the global community.
|
|
11
|
+
- Implemented secure, anonymized data transmission (metrics only, no code).
|
|
12
|
+
- **Dynamic Leaderboard Dashboard**:
|
|
13
|
+
- Completely redesigned `autopilot-docs` leaderboard with real-time analytics.
|
|
14
|
+
- Real-time aggregation of global commits, focus hours, and active streaks.
|
|
15
|
+
- Premium glassmorphism UI with live ranking updates.
|
|
16
|
+
|
|
17
|
+
### Improved
|
|
18
|
+
- **CLI Aesthetics**:
|
|
19
|
+
- Integrated full ANSI color support for the `logger` utility for more professional output.
|
|
20
|
+
- Improved visual hierarchy with bold section headers and color-coded status icons.
|
|
21
|
+
- **Diagnostics**:
|
|
22
|
+
- Enhanced `doctor` command to intelligently check for `credential.helper` validation on HTTPS remotes.
|
|
23
|
+
- **Insights Portability**:
|
|
24
|
+
- Refined Git log parsing to be more robust across different Git versions and configurations.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
- **Dashboard Stability**:
|
|
28
|
+
- Fixed "Duplicate Key" warning in the interactive React Ink dashboard.
|
|
29
|
+
- Added TTY-detection to prevent crashes in non-interactive environments (CI/CD, background).
|
|
30
|
+
- Fixed ESM/CommonJS compatibility issues using dynamic `import()` for the dashboard.
|
|
31
|
+
- **Test Integrity**:
|
|
32
|
+
- Implemented `AUTOPILOT_TEST_MODE` bypass for automated dashboard verification.
|
|
33
|
+
- Fixed cross-test contamination and EBUSY errors on Windows platforms.
|
|
34
|
+
|
|
6
35
|
## [2.1.0] - 2026-02-08
|
|
7
36
|
|
|
8
37
|
### Added
|
|
@@ -40,19 +40,75 @@ All automation is **reversible** via `autopilot undo`.
|
|
|
40
40
|
- **AI (Gemini / Grok)** is an assistant, never an authority.
|
|
41
41
|
- AI output must be reviewable, overridable, and optional.
|
|
42
42
|
|
|
43
|
+
## Privacy & Local-First Design
|
|
44
|
+
|
|
45
|
+
**Privacy Guarantees:**
|
|
46
|
+
- Your source code **never** leaves your machine
|
|
47
|
+
- No code diffs are transmitted externally
|
|
48
|
+
- No file contents are sent to remote servers
|
|
49
|
+
- AI commit message generation happens with metadata only (file paths, line counts, not actual code)
|
|
50
|
+
|
|
51
|
+
**Local-First Architecture:**
|
|
52
|
+
- Works 100% offline (except for git push operations)
|
|
53
|
+
- No authentication to external services required
|
|
54
|
+
- All data stored locally in your project
|
|
55
|
+
- Configuration is local and version-controllable
|
|
56
|
+
|
|
43
57
|
## Leaderboard & Metrics
|
|
44
58
|
|
|
45
59
|
- Metrics are derived **only** from local Git activity created by Autopilot.
|
|
46
60
|
- **No raw code, diffs, or file contents are ever transmitted.**
|
|
47
61
|
- Leaderboard data is:
|
|
48
|
-
- opt-in
|
|
62
|
+
- opt-in (disabled by default)
|
|
49
63
|
- anonymized or pseudonymous
|
|
50
64
|
- explainable (users know exactly what is counted)
|
|
65
|
+
- aggregate only (commit counts, focus time, streak days)
|
|
66
|
+
|
|
67
|
+
**What gets synced (if opted in):**
|
|
68
|
+
- ✅ Commit counts
|
|
69
|
+
- ✅ Focus time duration
|
|
70
|
+
- ✅ Streak days
|
|
71
|
+
- ✅ Anonymized username/identifier
|
|
72
|
+
|
|
73
|
+
**What never gets synced:**
|
|
74
|
+
- ❌ Source code
|
|
75
|
+
- ❌ File names or paths
|
|
76
|
+
- ❌ Commit messages
|
|
77
|
+
- ❌ Repository names
|
|
78
|
+
- ❌ File diffs or changes
|
|
79
|
+
|
|
80
|
+
## User Experience Philosophy
|
|
81
|
+
|
|
82
|
+
**When in Doubt: Pause, Explain, Wait**
|
|
83
|
+
|
|
84
|
+
- Ambiguous situations should trigger clear, actionable error messages
|
|
85
|
+
- Users should always understand what Autopilot is doing and why
|
|
86
|
+
- Status messages should be informative without being verbose
|
|
87
|
+
- Configuration should have sensible defaults but be fully customizable
|
|
88
|
+
|
|
89
|
+
**Trust Through Transparency:**
|
|
90
|
+
- Every action Autopilot takes should be logged
|
|
91
|
+
- Users should be able to audit what happened and when
|
|
92
|
+
- The system should explain its decisions in plain language
|
|
93
|
+
- Documentation should be honest about limitations
|
|
94
|
+
|
|
95
|
+
## Development Guidelines
|
|
96
|
+
|
|
97
|
+
**For Contributors:**
|
|
98
|
+
- Any feature must pass the "trust test" - would you trust this with your production code?
|
|
99
|
+
- Prefer explicit over implicit behavior
|
|
100
|
+
- Add clear error messages for every failure case
|
|
101
|
+
- Document why, not just what
|
|
102
|
+
- Test edge cases extensively, especially around git state
|
|
103
|
+
|
|
104
|
+
**For AI Integration:**
|
|
105
|
+
- AI should enhance, not replace, developer judgment
|
|
106
|
+
- All AI suggestions must be reviewable before commit
|
|
107
|
+
- Provide escape hatches for AI-generated content
|
|
108
|
+
- Log AI usage for transparency
|
|
109
|
+
- Allow disabling AI features entirely
|
|
51
110
|
|
|
52
|
-
|
|
111
|
+
---
|
|
53
112
|
|
|
54
|
-
|
|
55
|
-
- **When in doubt: pause, explain, wait.**
|
|
113
|
+
*Any feature (including Grok or leaderboards) must pass this test: Does it maintain developer trust, safety, and control?*
|
|
56
114
|
|
|
57
|
-
---
|
|
58
|
-
*Any feature (including Grok or leaderboards) must pass this test.*
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ const e = React.createElement;
|
|
|
19
19
|
const Dashboard = () => {
|
|
20
20
|
const { exit } = useApp();
|
|
21
21
|
const root = process.cwd();
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
const [status, setStatus] = useState('loading');
|
|
24
24
|
const [pid, setPid] = useState(null);
|
|
25
25
|
const [lastCommit, setLastCommit] = useState(null);
|
|
@@ -34,18 +34,18 @@ const Dashboard = () => {
|
|
|
34
34
|
// 1. Check process status
|
|
35
35
|
const currentPid = await getRunningPid(root);
|
|
36
36
|
setPid(currentPid);
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
// 2. Check Paused State
|
|
39
39
|
const stateManager = new StateManager(root);
|
|
40
40
|
if (stateManager.isPaused()) {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
setStatus('paused');
|
|
42
|
+
setPausedState(stateManager.getState());
|
|
43
43
|
} else if (currentPid) {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
setStatus('running');
|
|
45
|
+
setPausedState(null);
|
|
46
46
|
} else {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
setStatus('stopped');
|
|
48
|
+
setPausedState(null);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// 3. Last Commit
|
|
@@ -56,7 +56,7 @@ const Dashboard = () => {
|
|
|
56
56
|
// 4. Pending Files
|
|
57
57
|
const statusObj = await git.getPorcelainStatus(root);
|
|
58
58
|
if (statusObj.ok) {
|
|
59
|
-
|
|
59
|
+
setPendingFiles(statusObj.files);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// 5. Today Stats (Simple count from history)
|
|
@@ -126,10 +126,10 @@ const Dashboard = () => {
|
|
|
126
126
|
e(Box, { flexDirection: "column", marginBottom: 1 },
|
|
127
127
|
e(Text, { underline: true }, `Pending Changes (${pendingFiles.length})`),
|
|
128
128
|
e(Box, { flexDirection: "column" },
|
|
129
|
-
pendingFiles.length === 0 ?
|
|
129
|
+
pendingFiles.length === 0 ?
|
|
130
130
|
e(Text, { color: "gray" }, "No pending changes") :
|
|
131
|
-
pendingFiles.slice(0, 5).map((f) =>
|
|
132
|
-
e(Text, { key: f.file
|
|
131
|
+
pendingFiles.slice(0, 5).map((f, idx) =>
|
|
132
|
+
e(Text, { key: `${f.file}-${idx}`, color: "yellow" }, ` ${f.status} ${f.file}`)
|
|
133
133
|
)
|
|
134
134
|
),
|
|
135
135
|
pendingFiles.length > 5 && e(Text, { color: "gray" }, ` ...and ${pendingFiles.length - 5} more`)
|
|
@@ -143,5 +143,9 @@ const Dashboard = () => {
|
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
export default function runDashboard() {
|
|
146
|
+
if (!process.stdin.isTTY && !process.env.AUTOPILOT_TEST_MODE) {
|
|
147
|
+
console.error('Error: Dashboard requires an interactive terminal (TTY).');
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
146
150
|
render(e(Dashboard));
|
|
147
151
|
}
|
package/src/commands/doctor.js
CHANGED
|
@@ -13,7 +13,7 @@ const git = require('../core/git');
|
|
|
13
13
|
const doctor = async () => {
|
|
14
14
|
const repoPath = process.cwd();
|
|
15
15
|
let issues = 0;
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
logger.section('Autopilot Doctor');
|
|
18
18
|
logger.info('Diagnosing environment...');
|
|
19
19
|
|
|
@@ -50,7 +50,17 @@ const doctor = async () => {
|
|
|
50
50
|
|
|
51
51
|
// Check remote type
|
|
52
52
|
if (remoteUrl.startsWith('http')) {
|
|
53
|
-
|
|
53
|
+
let hasHelper = false;
|
|
54
|
+
try {
|
|
55
|
+
const { stdout: helper } = await execa('git', ['config', '--get', 'credential.helper'], { cwd: repoPath });
|
|
56
|
+
if (helper.trim()) hasHelper = true;
|
|
57
|
+
} catch (e) { /* ignore */ }
|
|
58
|
+
|
|
59
|
+
if (hasHelper) {
|
|
60
|
+
logger.success('Remote uses HTTPS with credential helper configured.');
|
|
61
|
+
} else {
|
|
62
|
+
logger.warn('Remote uses HTTPS. Ensure credential helper is configured for non-interactive push.');
|
|
63
|
+
}
|
|
54
64
|
} else if (remoteUrl.startsWith('git@') || remoteUrl.startsWith('ssh://')) {
|
|
55
65
|
logger.success('Remote uses SSH (recommended).');
|
|
56
66
|
} else {
|
|
@@ -102,8 +112,8 @@ const doctor = async () => {
|
|
|
102
112
|
logger.success('Branch is up to date with remote.');
|
|
103
113
|
}
|
|
104
114
|
} else {
|
|
105
|
-
|
|
106
|
-
|
|
115
|
+
// Could be no upstream configured, which is fine for local-only initially
|
|
116
|
+
logger.info('Could not check remote status (upstream might not be set).');
|
|
107
117
|
}
|
|
108
118
|
} catch (error) {
|
|
109
119
|
logger.info('Skipping remote status check.');
|
package/src/commands/insights.js
CHANGED
|
@@ -6,86 +6,52 @@ const { createObjectCsvWriter } = require('csv-writer');
|
|
|
6
6
|
|
|
7
7
|
async function getGitStats(repoPath) {
|
|
8
8
|
try {
|
|
9
|
-
// Get commit log with stats
|
|
10
|
-
// We use custom delimiters to safely parse multi-line bodies and stats
|
|
11
9
|
const { stdout } = await git.runGit(repoPath, [
|
|
12
10
|
'log',
|
|
13
|
-
'--pretty=format
|
|
11
|
+
'--pretty=format:===C===%H|%an|%ad|%s|%b===E===',
|
|
14
12
|
'--date=iso',
|
|
15
13
|
'--numstat'
|
|
16
14
|
]);
|
|
17
15
|
|
|
16
|
+
if (!stdout) return [];
|
|
17
|
+
|
|
18
18
|
const commits = [];
|
|
19
|
-
const rawCommits = stdout.split('
|
|
19
|
+
const rawCommits = stdout.split('===C===').filter(Boolean);
|
|
20
20
|
|
|
21
21
|
for (const raw of rawCommits) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const lines = metadataPart.trim().split('\n');
|
|
28
|
-
const header = lines[0]; // hash|author|date|subject|body_start...
|
|
29
|
-
// The body might continue on next lines if %b has newlines.
|
|
30
|
-
// Actually, my format puts %b starting on the first line.
|
|
31
|
-
// But let's be safer: split header by | first 4 times only.
|
|
32
|
-
|
|
33
|
-
// header format: hash|author|date|subject|rest...
|
|
34
|
-
// But wait, if body has newlines, "lines" array has them.
|
|
35
|
-
|
|
36
|
-
// Let's reconstruct the full message body
|
|
37
|
-
const fullMetadata = metadataPart.trim();
|
|
38
|
-
const firstPipe = fullMetadata.indexOf('|');
|
|
39
|
-
const secondPipe = fullMetadata.indexOf('|', firstPipe + 1);
|
|
40
|
-
const thirdPipe = fullMetadata.indexOf('|', secondPipe + 1);
|
|
41
|
-
const fourthPipe = fullMetadata.indexOf('|', thirdPipe + 1);
|
|
42
|
-
|
|
43
|
-
if (firstPipe === -1 || fourthPipe === -1) continue;
|
|
44
|
-
|
|
45
|
-
const hash = fullMetadata.substring(0, firstPipe);
|
|
46
|
-
const author = fullMetadata.substring(firstPipe + 1, secondPipe);
|
|
47
|
-
const dateStr = fullMetadata.substring(secondPipe + 1, thirdPipe);
|
|
48
|
-
const subject = fullMetadata.substring(thirdPipe + 1, fourthPipe);
|
|
49
|
-
const body = fullMetadata.substring(fourthPipe + 1);
|
|
50
|
-
|
|
51
|
-
// TRUST VERIFICATION
|
|
52
|
-
// Check for Autopilot trailers
|
|
53
|
-
if (!body.includes('Autopilot-Commit: true')) {
|
|
54
|
-
continue; // Skip non-autopilot commits
|
|
55
|
-
}
|
|
22
|
+
const [metadataPlusBody, ...statsParts] = raw.split('===E===');
|
|
23
|
+
if (!metadataPlusBody) continue;
|
|
24
|
+
|
|
25
|
+
const [hash, author, dateStr, subject, ...bodyParts] = metadataPlusBody.trim().split('|');
|
|
26
|
+
const body = bodyParts.join('|'); // Rejoin in case body had pipes
|
|
56
27
|
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
// if (!verifySignature(signature, ...)) continue;
|
|
28
|
+
// Trust Verification: Only process autopilot commits
|
|
29
|
+
if (!body.includes('Autopilot-Commit: true')) continue;
|
|
60
30
|
|
|
61
31
|
const commit = {
|
|
62
32
|
hash,
|
|
63
33
|
author,
|
|
64
34
|
date: new Date(dateStr),
|
|
65
|
-
message: subject
|
|
35
|
+
message: `${subject}\n${body}`.trim(),
|
|
66
36
|
files: [],
|
|
67
37
|
additions: 0,
|
|
68
38
|
deletions: 0
|
|
69
39
|
};
|
|
70
40
|
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
const statLines =
|
|
74
|
-
for (const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
const deletions = parseInt(parts[1]) || 0;
|
|
80
|
-
const file = parts.slice(2).join(' '); // handle spaces in filenames
|
|
81
|
-
|
|
41
|
+
const statsText = statsParts.join('===E===').trim();
|
|
42
|
+
if (statsText) {
|
|
43
|
+
const statLines = statsText.split('\n');
|
|
44
|
+
for (const line of statLines) {
|
|
45
|
+
const [add, del, file] = line.trim().split(/\s+/);
|
|
46
|
+
if (file) {
|
|
47
|
+
const additions = parseInt(add) || 0;
|
|
48
|
+
const deletions = parseInt(del) || 0;
|
|
82
49
|
commit.files.push({ file, additions, deletions });
|
|
83
50
|
commit.additions += additions;
|
|
84
51
|
commit.deletions += deletions;
|
|
85
52
|
}
|
|
86
53
|
}
|
|
87
54
|
}
|
|
88
|
-
|
|
89
55
|
commits.push(commit);
|
|
90
56
|
}
|
|
91
57
|
|
|
@@ -130,7 +96,7 @@ function calculateMetrics(commits) {
|
|
|
130
96
|
// Time analysis
|
|
131
97
|
const dateStr = c.date.toISOString().split('T')[0];
|
|
132
98
|
const hour = c.date.getHours();
|
|
133
|
-
|
|
99
|
+
|
|
134
100
|
stats.commitsByDay[dateStr] = (stats.commitsByDay[dateStr] || 0) + 1;
|
|
135
101
|
stats.commitsByHour[hour] = (stats.commitsByHour[hour] || 0) + 1;
|
|
136
102
|
dates.add(dateStr);
|
|
@@ -145,7 +111,7 @@ function calculateMetrics(commits) {
|
|
|
145
111
|
// Calculate Averages
|
|
146
112
|
stats.totalFilesCount = stats.totalFilesChanged.size;
|
|
147
113
|
stats.quality.avgLength = commits.length ? Math.round(totalMessageLength / commits.length) : 0;
|
|
148
|
-
|
|
114
|
+
|
|
149
115
|
// Calculate Score (0-100)
|
|
150
116
|
// 40% Conventional, 30% Message Length (>30 chars), 30% Consistency
|
|
151
117
|
const convScore = commits.length ? (stats.quality.conventional / commits.length) * 40 : 0;
|
|
@@ -165,7 +131,7 @@ function calculateMetrics(commits) {
|
|
|
165
131
|
currentStreak = 1;
|
|
166
132
|
} else {
|
|
167
133
|
const diffTime = Math.abs(d - lastDate);
|
|
168
|
-
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
|
134
|
+
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
|
169
135
|
if (diffDays === 1) {
|
|
170
136
|
currentStreak++;
|
|
171
137
|
} else {
|
|
@@ -176,12 +142,12 @@ function calculateMetrics(commits) {
|
|
|
176
142
|
lastDate = d;
|
|
177
143
|
});
|
|
178
144
|
stats.streak.max = Math.max(maxStreak, currentStreak);
|
|
179
|
-
|
|
145
|
+
|
|
180
146
|
// Check if streak is active (last commit today or yesterday)
|
|
181
147
|
const today = new Date().toISOString().split('T')[0];
|
|
182
148
|
const yesterday = new Date(Date.now() - 86400000).toISOString().split('T')[0];
|
|
183
149
|
const lastCommitDate = sortedDates[sortedDates.length - 1];
|
|
184
|
-
|
|
150
|
+
|
|
185
151
|
if (lastCommitDate === today || lastCommitDate === yesterday) {
|
|
186
152
|
stats.streak.current = currentStreak;
|
|
187
153
|
} else {
|
|
@@ -217,10 +183,10 @@ async function insights(options) {
|
|
|
217
183
|
console.log(`Lines Added: ${metrics.totalAdditions}`);
|
|
218
184
|
console.log(`Lines Deleted: ${metrics.totalDeletions}`);
|
|
219
185
|
console.log(`Current Streak: ${metrics.streak.current} days (Max: ${metrics.streak.max})`);
|
|
220
|
-
|
|
186
|
+
|
|
221
187
|
// Find most productive hour
|
|
222
188
|
const productiveHour = Object.entries(metrics.commitsByHour)
|
|
223
|
-
.sort(([,a], [,b]) => b - a)[0];
|
|
189
|
+
.sort(([, a], [, b]) => b - a)[0];
|
|
224
190
|
console.log(`Peak Productivity: ${productiveHour ? productiveHour[0] + ':00' : 'N/A'}`);
|
|
225
191
|
|
|
226
192
|
console.log('');
|
|
@@ -241,12 +207,12 @@ async function insights(options) {
|
|
|
241
207
|
const csvWriter = createObjectCsvWriter({
|
|
242
208
|
path: csvPath,
|
|
243
209
|
header: [
|
|
244
|
-
{id: 'hash', title: 'Hash'},
|
|
245
|
-
{id: 'date', title: 'Date'},
|
|
246
|
-
{id: 'author', title: 'Author'},
|
|
247
|
-
{id: 'message', title: 'Message'},
|
|
248
|
-
{id: 'additions', title: 'Additions'},
|
|
249
|
-
{id: 'deletions', title: 'Deletions'}
|
|
210
|
+
{ id: 'hash', title: 'Hash' },
|
|
211
|
+
{ id: 'date', title: 'Date' },
|
|
212
|
+
{ id: 'author', title: 'Author' },
|
|
213
|
+
{ id: 'message', title: 'Message' },
|
|
214
|
+
{ id: 'additions', title: 'Additions' },
|
|
215
|
+
{ id: 'deletions', title: 'Deletions' }
|
|
250
216
|
]
|
|
251
217
|
});
|
|
252
218
|
|
|
@@ -2,7 +2,6 @@ const fs = require('fs-extra');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const { getGitStats, calculateMetrics } = require('./insights');
|
|
4
4
|
const logger = require('../utils/logger');
|
|
5
|
-
const open = require('open');
|
|
6
5
|
const crypto = require('crypto');
|
|
7
6
|
|
|
8
7
|
// Default API URL (can be overridden by config)
|
|
@@ -16,7 +15,7 @@ async function calculateFocusTime(repoPath) {
|
|
|
16
15
|
const content = await fs.readFile(logPath, 'utf8');
|
|
17
16
|
const lines = content.split('\n').filter(l => l.trim());
|
|
18
17
|
let totalMs = 0;
|
|
19
|
-
|
|
18
|
+
|
|
20
19
|
for (const line of lines) {
|
|
21
20
|
try {
|
|
22
21
|
const entry = JSON.parse(line);
|
|
@@ -27,7 +26,7 @@ async function calculateFocusTime(repoPath) {
|
|
|
27
26
|
// ignore bad lines
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
|
-
|
|
29
|
+
|
|
31
30
|
return Math.round(totalMs / 60000); // minutes
|
|
32
31
|
} catch (error) {
|
|
33
32
|
logger.warn(`Failed to parse autopilot.log: ${error.message}`);
|
|
@@ -59,15 +58,15 @@ async function syncLeaderboard(apiUrl, options) {
|
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
const metrics = calculateMetrics(commits);
|
|
62
|
-
|
|
61
|
+
|
|
63
62
|
// Get user info (git config)
|
|
64
63
|
const git = require('../core/git');
|
|
65
64
|
const { stdout: username } = await git.runGit(repoPath, ['config', 'user.name']);
|
|
66
65
|
const { stdout: email } = await git.runGit(repoPath, ['config', 'user.email']);
|
|
67
|
-
|
|
66
|
+
|
|
68
67
|
const userEmail = email.trim() || 'unknown';
|
|
69
68
|
const userName = username.trim() || 'Anonymous';
|
|
70
|
-
|
|
69
|
+
|
|
71
70
|
// Anonymize ID using hash
|
|
72
71
|
const userId = crypto.createHash('sha256').update(userEmail).digest('hex').substring(0, 12);
|
|
73
72
|
|
|
@@ -87,7 +86,7 @@ async function syncLeaderboard(apiUrl, options) {
|
|
|
87
86
|
|
|
88
87
|
logger.info(`Syncing stats for ${stats.username} (ID: ${userId})...`);
|
|
89
88
|
logger.info('Note: Only metrics are shared. No code or file contents are transmitted.');
|
|
90
|
-
|
|
89
|
+
|
|
91
90
|
const response = await fetch(`${apiUrl}/api/leaderboard/sync`, {
|
|
92
91
|
method: 'POST',
|
|
93
92
|
headers: { 'Content-Type': 'application/json' },
|
package/src/core/git.js
CHANGED
|
@@ -42,13 +42,14 @@ async function getPorcelainStatus(root) {
|
|
|
42
42
|
try {
|
|
43
43
|
const { stdout } = await execa('git', ['status', '--porcelain'], { cwd: root });
|
|
44
44
|
const raw = stdout.trim();
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
if (!raw) {
|
|
47
47
|
return { ok: true, files: [], raw: '' };
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const files = raw
|
|
51
51
|
.split(/\r?\n/)
|
|
52
|
+
.filter(line => line.trim().length > 0)
|
|
52
53
|
.map(line => {
|
|
53
54
|
const status = line.slice(0, 2).trim();
|
|
54
55
|
const file = line.slice(3).trim();
|
|
@@ -134,7 +135,7 @@ async function isRemoteAhead(root) {
|
|
|
134
135
|
|
|
135
136
|
const { stdout } = await execa('git', ['rev-list', '--left-right', '--count', `${branch}...origin/${branch}`], { cwd: root });
|
|
136
137
|
const [aheadCount, behindCount] = stdout.trim().split(/\s+/).map(Number);
|
|
137
|
-
|
|
138
|
+
|
|
138
139
|
return {
|
|
139
140
|
ok: true,
|
|
140
141
|
ahead: aheadCount > 0,
|
|
@@ -259,10 +260,10 @@ async function isMergeInProgress(root) {
|
|
|
259
260
|
'REVERT_HEAD',
|
|
260
261
|
'BISECT_LOG'
|
|
261
262
|
];
|
|
262
|
-
|
|
263
|
+
|
|
263
264
|
// Check if .git/rebase-merge or .git/rebase-apply exists (directory check)
|
|
264
|
-
if (await fs.pathExists(path.join(gitDir, 'rebase-merge')) ||
|
|
265
|
-
|
|
265
|
+
if (await fs.pathExists(path.join(gitDir, 'rebase-merge')) ||
|
|
266
|
+
await fs.pathExists(path.join(gitDir, 'rebase-apply'))) {
|
|
266
267
|
return true;
|
|
267
268
|
}
|
|
268
269
|
|
package/src/index.js
CHANGED
|
@@ -8,7 +8,6 @@ const { doctor } = require('./commands/doctor');
|
|
|
8
8
|
const { insights } = require('./commands/insights');
|
|
9
9
|
const pauseCommand = require('./commands/pause');
|
|
10
10
|
const resumeCommand = require('./commands/resume');
|
|
11
|
-
const runDashboard = require('./commands/dashboard');
|
|
12
11
|
const { leaderboard } = require('./commands/leaderboard');
|
|
13
12
|
const pkg = require('../package.json');
|
|
14
13
|
|
|
@@ -65,7 +64,14 @@ function run() {
|
|
|
65
64
|
program
|
|
66
65
|
.command('dashboard')
|
|
67
66
|
.description('View real-time Autopilot dashboard')
|
|
68
|
-
.action(
|
|
67
|
+
.action(async () => {
|
|
68
|
+
try {
|
|
69
|
+
const { default: runDashboard } = await import('./commands/dashboard.mjs');
|
|
70
|
+
runDashboard();
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error('Failed to launch dashboard:', error);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
69
75
|
|
|
70
76
|
program
|
|
71
77
|
.command('doctor')
|
package/src/utils/logger.js
CHANGED
|
@@ -18,7 +18,7 @@ const logger = {
|
|
|
18
18
|
* @param {string} message - Message to log
|
|
19
19
|
*/
|
|
20
20
|
info: (message) => {
|
|
21
|
-
console.log(
|
|
21
|
+
console.log(`${logger.colors.cyan('ℹ️')} ${message}`);
|
|
22
22
|
},
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -27,7 +27,7 @@ const logger = {
|
|
|
27
27
|
*/
|
|
28
28
|
debug: (message) => {
|
|
29
29
|
if (process.env.DEBUG) {
|
|
30
|
-
console.log(
|
|
30
|
+
console.log(`${logger.colors.blue('🔍')} ${message}`);
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
|
|
@@ -36,7 +36,7 @@ const logger = {
|
|
|
36
36
|
* @param {string} message - Message to log
|
|
37
37
|
*/
|
|
38
38
|
success: (message) => {
|
|
39
|
-
console.log(
|
|
39
|
+
console.log(`${logger.colors.green('✅')} ${message}`);
|
|
40
40
|
},
|
|
41
41
|
|
|
42
42
|
/**
|
|
@@ -44,7 +44,7 @@ const logger = {
|
|
|
44
44
|
* @param {string} message - Message to log
|
|
45
45
|
*/
|
|
46
46
|
warn: (message) => {
|
|
47
|
-
console.warn(
|
|
47
|
+
console.warn(`${logger.colors.yellow('⚠️')} ${message}`);
|
|
48
48
|
},
|
|
49
49
|
|
|
50
50
|
/**
|
|
@@ -52,7 +52,7 @@ const logger = {
|
|
|
52
52
|
* @param {string} message - Message to log
|
|
53
53
|
*/
|
|
54
54
|
error: (message) => {
|
|
55
|
-
console.error(
|
|
55
|
+
console.error(`${logger.colors.red('❌')} ${message}`);
|
|
56
56
|
},
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -60,8 +60,8 @@ const logger = {
|
|
|
60
60
|
* @param {string} title - Section title
|
|
61
61
|
*/
|
|
62
62
|
section: (title) => {
|
|
63
|
-
console.log(`\n${title}`);
|
|
64
|
-
console.log('─'.repeat(50));
|
|
63
|
+
console.log(`\n${logger.colors.bold(logger.colors.cyan(title))}`);
|
|
64
|
+
console.log(logger.colors.cyan('─'.repeat(50)));
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
67
|
|