jettypod 4.4.65 → 4.4.67
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/jettypod.js +30 -10
- package/lib/db-watcher.js +116 -0
- package/lib/work-commands/index.js +134 -53
- package/lib/ws-server.js +126 -0
- package/package.json +1 -1
- package/skills-templates/chore-mode/SKILL.md +11 -10
- package/skills-templates/feature-planning/SKILL.md +4 -2
- package/skills-templates/speed-mode/SKILL.md +21 -25
- package/skills-templates/stable-mode/SKILL.md +20 -20
package/jettypod.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const config = require('./lib/config');
|
|
6
|
+
const wsServer = require('./lib/ws-server');
|
|
6
7
|
// getModeBehaviorContent removed - skills now provide all mode guidance
|
|
7
8
|
|
|
8
9
|
// CRITICAL: Calculate and cache the REAL git root BEFORE any worktree operations
|
|
@@ -1293,18 +1294,26 @@ switch (command) {
|
|
|
1293
1294
|
}
|
|
1294
1295
|
} else if (subcommand === 'cleanup') {
|
|
1295
1296
|
const workCommands = require('./lib/work-commands/index.js');
|
|
1296
|
-
const dryRun = args
|
|
1297
|
+
const dryRun = args.includes('--dry-run');
|
|
1298
|
+
// Find numeric arg for specific work item cleanup
|
|
1299
|
+
const workItemId = args.find(a => /^\d+$/.test(a)) ? parseInt(args.find(a => /^\d+$/.test(a))) : null;
|
|
1297
1300
|
|
|
1298
1301
|
try {
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
console.log(`\n${results.message || 'No worktrees needed cleanup'}`);
|
|
1302
|
+
if (workItemId) {
|
|
1303
|
+
// Clean up specific work item's worktree
|
|
1304
|
+
await workCommands.cleanupWorkItem(workItemId);
|
|
1303
1305
|
} else {
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1306
|
+
// Batch cleanup of all orphaned worktrees
|
|
1307
|
+
const results = await workCommands.cleanupWorktrees({ dryRun });
|
|
1308
|
+
|
|
1309
|
+
if (results.cleaned === 0 && results.failed === 0) {
|
|
1310
|
+
console.log(`\n${results.message || 'No worktrees needed cleanup'}`);
|
|
1311
|
+
} else {
|
|
1312
|
+
console.log(`\n✓ Cleanup complete:`);
|
|
1313
|
+
console.log(` Cleaned: ${results.cleaned}`);
|
|
1314
|
+
if (results.failed > 0) {
|
|
1315
|
+
console.log(` Failed: ${results.failed}`);
|
|
1316
|
+
}
|
|
1308
1317
|
}
|
|
1309
1318
|
}
|
|
1310
1319
|
} catch (err) {
|
|
@@ -2125,6 +2134,16 @@ switch (command) {
|
|
|
2125
2134
|
}
|
|
2126
2135
|
}
|
|
2127
2136
|
|
|
2137
|
+
// Start WebSocket server for real-time updates
|
|
2138
|
+
const WS_PORT = 8080;
|
|
2139
|
+
const { getDbPath } = require('./lib/database');
|
|
2140
|
+
try {
|
|
2141
|
+
await wsServer.start(WS_PORT, { dbPath: getDbPath() });
|
|
2142
|
+
} catch (err) {
|
|
2143
|
+
// WebSocket server failed to start (port in use?) - continue without it
|
|
2144
|
+
console.log('⚠️ WebSocket server unavailable (real-time updates disabled)');
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2128
2147
|
// Start dashboard in background with project path
|
|
2129
2148
|
console.log('🚀 Starting dashboard...');
|
|
2130
2149
|
const dashboardProcess = spawn('npm', ['run', 'start', '--', '-p', String(availablePort)], {
|
|
@@ -2133,7 +2152,8 @@ switch (command) {
|
|
|
2133
2152
|
stdio: 'ignore',
|
|
2134
2153
|
env: {
|
|
2135
2154
|
...process.env,
|
|
2136
|
-
JETTYPOD_PROJECT_PATH: process.cwd()
|
|
2155
|
+
JETTYPOD_PROJECT_PATH: process.cwd(),
|
|
2156
|
+
JETTYPOD_WS_PORT: String(WS_PORT)
|
|
2137
2157
|
}
|
|
2138
2158
|
});
|
|
2139
2159
|
dashboardProcess.unref();
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database change watcher for triggering WebSocket broadcasts.
|
|
3
|
+
*
|
|
4
|
+
* Watches the .jettypod/work.db file and its WAL file for modifications
|
|
5
|
+
* and calls a callback when changes are detected.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* const dbWatcher = require('./lib/db-watcher');
|
|
9
|
+
* dbWatcher.start((changeType) => {
|
|
10
|
+
* wsServer.broadcast({ type: 'db_change' });
|
|
11
|
+
* });
|
|
12
|
+
* dbWatcher.stop();
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
const path = require('path');
|
|
17
|
+
|
|
18
|
+
let lastMtimes = { db: null, wal: null };
|
|
19
|
+
let pollInterval = null;
|
|
20
|
+
let onChange = null;
|
|
21
|
+
let watchedPath = null;
|
|
22
|
+
|
|
23
|
+
// Polling interval in milliseconds
|
|
24
|
+
const POLL_MS = 50;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Start watching the database file for changes
|
|
28
|
+
* @param {Function} callback - Called when database changes detected
|
|
29
|
+
* @param {string} dbPath - Path to database file (default: .jettypod/work.db)
|
|
30
|
+
*/
|
|
31
|
+
function start(callback, dbPath = null) {
|
|
32
|
+
if (pollInterval) {
|
|
33
|
+
return; // Already watching
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
onChange = callback;
|
|
37
|
+
watchedPath = dbPath || path.join(process.cwd(), '.jettypod', 'work.db');
|
|
38
|
+
|
|
39
|
+
// Check if file exists
|
|
40
|
+
if (!fs.existsSync(watchedPath)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Get initial mtimes for both db and WAL file
|
|
45
|
+
try {
|
|
46
|
+
const dbStats = fs.statSync(watchedPath);
|
|
47
|
+
lastMtimes.db = dbStats.mtimeMs;
|
|
48
|
+
|
|
49
|
+
// Also check WAL file (SQLite in WAL mode writes here first)
|
|
50
|
+
const walPath = watchedPath + '-wal';
|
|
51
|
+
if (fs.existsSync(walPath)) {
|
|
52
|
+
const walStats = fs.statSync(walPath);
|
|
53
|
+
lastMtimes.wal = walStats.mtimeMs;
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Use polling - most reliable for SQLite files across platforms
|
|
60
|
+
pollInterval = setInterval(() => {
|
|
61
|
+
try {
|
|
62
|
+
let changed = false;
|
|
63
|
+
|
|
64
|
+
// Check main db file
|
|
65
|
+
const dbStats = fs.statSync(watchedPath);
|
|
66
|
+
if (dbStats.mtimeMs !== lastMtimes.db) {
|
|
67
|
+
lastMtimes.db = dbStats.mtimeMs;
|
|
68
|
+
changed = true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Check WAL file (where SQLite writes first in WAL mode)
|
|
72
|
+
const walPath = watchedPath + '-wal';
|
|
73
|
+
if (fs.existsSync(walPath)) {
|
|
74
|
+
const walStats = fs.statSync(walPath);
|
|
75
|
+
if (walStats.mtimeMs !== lastMtimes.wal) {
|
|
76
|
+
lastMtimes.wal = walStats.mtimeMs;
|
|
77
|
+
changed = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (changed && onChange) {
|
|
82
|
+
onChange('change');
|
|
83
|
+
}
|
|
84
|
+
} catch {
|
|
85
|
+
// File might be temporarily locked during writes
|
|
86
|
+
}
|
|
87
|
+
}, POLL_MS);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Stop watching the database file
|
|
92
|
+
*/
|
|
93
|
+
function stop() {
|
|
94
|
+
if (pollInterval) {
|
|
95
|
+
clearInterval(pollInterval);
|
|
96
|
+
pollInterval = null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
onChange = null;
|
|
100
|
+
lastMtimes = { db: null, wal: null };
|
|
101
|
+
watchedPath = null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Check if currently watching
|
|
106
|
+
* @returns {boolean}
|
|
107
|
+
*/
|
|
108
|
+
function isWatching() {
|
|
109
|
+
return pollInterval !== null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
module.exports = {
|
|
113
|
+
start,
|
|
114
|
+
stop,
|
|
115
|
+
isWatching,
|
|
116
|
+
};
|
|
@@ -1130,6 +1130,106 @@ async function cleanupWorktrees(options = {}) {
|
|
|
1130
1130
|
return results;
|
|
1131
1131
|
}
|
|
1132
1132
|
|
|
1133
|
+
/**
|
|
1134
|
+
* Clean up a specific worktree after merge
|
|
1135
|
+
* Should be run from main repo after cd'ing out of the worktree
|
|
1136
|
+
* @param {number} workItemId - The work item ID to clean up
|
|
1137
|
+
* @returns {Promise<Object>} Result with success status
|
|
1138
|
+
*/
|
|
1139
|
+
async function cleanupWorkItem(workItemId) {
|
|
1140
|
+
const db = getDb();
|
|
1141
|
+
const gitRoot = getGitRoot();
|
|
1142
|
+
|
|
1143
|
+
// Check we're not inside the worktree being deleted
|
|
1144
|
+
const cwd = process.cwd();
|
|
1145
|
+
if (cwd.includes('.jettypod-work')) {
|
|
1146
|
+
return Promise.reject(new Error(
|
|
1147
|
+
`Cannot cleanup from inside a worktree.\n\n` +
|
|
1148
|
+
`Run this first: cd ${gitRoot}`
|
|
1149
|
+
));
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// Find the worktree for this work item
|
|
1153
|
+
const worktree = await new Promise((resolve, reject) => {
|
|
1154
|
+
db.get(
|
|
1155
|
+
`SELECT w.id, w.worktree_path, w.branch_name, w.status, wi.title
|
|
1156
|
+
FROM worktrees w
|
|
1157
|
+
JOIN work_items wi ON w.work_item_id = wi.id
|
|
1158
|
+
WHERE w.work_item_id = ?`,
|
|
1159
|
+
[workItemId],
|
|
1160
|
+
(err, row) => {
|
|
1161
|
+
if (err) return reject(err);
|
|
1162
|
+
resolve(row);
|
|
1163
|
+
}
|
|
1164
|
+
);
|
|
1165
|
+
});
|
|
1166
|
+
|
|
1167
|
+
if (!worktree) {
|
|
1168
|
+
console.log(`No worktree found for work item #${workItemId}`);
|
|
1169
|
+
return { success: true, message: 'No worktree to clean up' };
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
if (worktree.status === 'active') {
|
|
1173
|
+
return Promise.reject(new Error(
|
|
1174
|
+
`Worktree for #${workItemId} is still active.\n` +
|
|
1175
|
+
`Run 'jettypod work merge ${workItemId}' first.`
|
|
1176
|
+
));
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
console.log(`Cleaning up worktree for #${workItemId}: ${worktree.title}`);
|
|
1180
|
+
|
|
1181
|
+
// Remove git worktree if it exists
|
|
1182
|
+
if (worktree.worktree_path && fs.existsSync(worktree.worktree_path)) {
|
|
1183
|
+
try {
|
|
1184
|
+
execSync(`git worktree remove "${worktree.worktree_path}" --force`, {
|
|
1185
|
+
cwd: gitRoot,
|
|
1186
|
+
stdio: 'pipe'
|
|
1187
|
+
});
|
|
1188
|
+
console.log('✅ Removed worktree directory');
|
|
1189
|
+
} catch (err) {
|
|
1190
|
+
console.log(`⚠️ Failed to remove worktree directory: ${err.message}`);
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
// Delete the branch if it exists
|
|
1195
|
+
if (worktree.branch_name) {
|
|
1196
|
+
try {
|
|
1197
|
+
execSync(`git branch -d "${worktree.branch_name}"`, {
|
|
1198
|
+
cwd: gitRoot,
|
|
1199
|
+
stdio: 'pipe'
|
|
1200
|
+
});
|
|
1201
|
+
console.log('✅ Deleted branch');
|
|
1202
|
+
} catch (err) {
|
|
1203
|
+
// Branch might not exist or might not be fully merged
|
|
1204
|
+
// Try force delete if regular delete failed
|
|
1205
|
+
try {
|
|
1206
|
+
execSync(`git branch -D "${worktree.branch_name}"`, {
|
|
1207
|
+
cwd: gitRoot,
|
|
1208
|
+
stdio: 'pipe'
|
|
1209
|
+
});
|
|
1210
|
+
console.log('✅ Deleted branch (force)');
|
|
1211
|
+
} catch {
|
|
1212
|
+
console.log(`⚠️ Could not delete branch: ${err.message}`);
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
// Delete worktree record from database
|
|
1218
|
+
await new Promise((resolve, reject) => {
|
|
1219
|
+
db.run(
|
|
1220
|
+
`DELETE FROM worktrees WHERE id = ?`,
|
|
1221
|
+
[worktree.id],
|
|
1222
|
+
(err) => {
|
|
1223
|
+
if (err) return reject(err);
|
|
1224
|
+
resolve();
|
|
1225
|
+
}
|
|
1226
|
+
);
|
|
1227
|
+
});
|
|
1228
|
+
|
|
1229
|
+
console.log('✅ Worktree cleaned up');
|
|
1230
|
+
return { success: true };
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1133
1233
|
// Re-export getCurrentWork from shared module for backwards compatibility
|
|
1134
1234
|
// (used by jettypod.js)
|
|
1135
1235
|
|
|
@@ -1590,37 +1690,32 @@ async function mergeWork(options = {}) {
|
|
|
1590
1690
|
);
|
|
1591
1691
|
});
|
|
1592
1692
|
|
|
1593
|
-
//
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
[worktree.id],
|
|
1608
|
-
(err) => {
|
|
1609
|
-
if (err) return reject(err);
|
|
1610
|
-
resolve();
|
|
1611
|
-
}
|
|
1612
|
-
);
|
|
1613
|
-
});
|
|
1614
|
-
|
|
1615
|
-
console.log('✅ Worktree cleaned up');
|
|
1616
|
-
} catch (worktreeErr) {
|
|
1617
|
-
console.warn(`Warning: Failed to clean up worktree: ${worktreeErr.message}`);
|
|
1618
|
-
// Non-fatal - continue with merge success
|
|
1619
|
-
}
|
|
1693
|
+
// Mark worktree as merged but DON'T delete it yet
|
|
1694
|
+
// This prevents shell CWD corruption when merge is run from inside the worktree
|
|
1695
|
+
// User must run `jettypod work cleanup` separately after cd'ing to main repo
|
|
1696
|
+
if (worktree && worktree.worktree_path) {
|
|
1697
|
+
await new Promise((resolve, reject) => {
|
|
1698
|
+
db.run(
|
|
1699
|
+
`UPDATE worktrees SET status = 'merged' WHERE id = ?`,
|
|
1700
|
+
[worktree.id],
|
|
1701
|
+
(err) => {
|
|
1702
|
+
if (err) return reject(err);
|
|
1703
|
+
resolve();
|
|
1704
|
+
}
|
|
1705
|
+
);
|
|
1706
|
+
});
|
|
1620
1707
|
}
|
|
1621
1708
|
|
|
1622
1709
|
console.log(`✅ Work item #${currentWork.id} marked as done`);
|
|
1623
1710
|
|
|
1711
|
+
// Instruct user to cleanup worktree separately
|
|
1712
|
+
if (worktree && worktree.worktree_path && fs.existsSync(worktree.worktree_path)) {
|
|
1713
|
+
console.log('');
|
|
1714
|
+
console.log('📁 Worktree preserved. To clean up:');
|
|
1715
|
+
console.log(` cd ${gitRoot}`);
|
|
1716
|
+
console.log(` jettypod work cleanup ${currentWork.id}`);
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1624
1719
|
if (withTransition) {
|
|
1625
1720
|
// Hold lock for transition phase (BDD generation)
|
|
1626
1721
|
// Work is done and worktree is cleaned up, but lock is held so no other merges
|
|
@@ -1885,34 +1980,11 @@ async function testsMerge(featureId) {
|
|
|
1885
1980
|
console.log('⚠️ Failed to push (non-fatal):', err.message);
|
|
1886
1981
|
}
|
|
1887
1982
|
|
|
1888
|
-
//
|
|
1889
|
-
|
|
1890
|
-
execSync(`git worktree remove "${worktreePath}" --force`, {
|
|
1891
|
-
cwd: gitRoot,
|
|
1892
|
-
encoding: 'utf8',
|
|
1893
|
-
stdio: 'pipe'
|
|
1894
|
-
});
|
|
1895
|
-
console.log('✅ Removed worktree directory');
|
|
1896
|
-
} catch (err) {
|
|
1897
|
-
console.log('⚠️ Failed to remove worktree (non-fatal):', err.message);
|
|
1898
|
-
}
|
|
1899
|
-
|
|
1900
|
-
// Delete the test branch
|
|
1901
|
-
try {
|
|
1902
|
-
execSync(`git branch -d ${branchName}`, {
|
|
1903
|
-
cwd: gitRoot,
|
|
1904
|
-
encoding: 'utf8',
|
|
1905
|
-
stdio: 'pipe'
|
|
1906
|
-
});
|
|
1907
|
-
console.log('✅ Deleted test branch');
|
|
1908
|
-
} catch (err) {
|
|
1909
|
-
console.log('⚠️ Failed to delete branch (non-fatal):', err.message);
|
|
1910
|
-
}
|
|
1911
|
-
|
|
1912
|
-
// Delete worktree record from database (cleanup complete)
|
|
1983
|
+
// Mark worktree as merged but DON'T delete it yet
|
|
1984
|
+
// This prevents shell CWD corruption when merge is run from inside the worktree
|
|
1913
1985
|
await new Promise((resolve, reject) => {
|
|
1914
1986
|
db.run(
|
|
1915
|
-
`
|
|
1987
|
+
`UPDATE worktrees SET status = 'merged' WHERE id = ?`,
|
|
1916
1988
|
[worktree.id],
|
|
1917
1989
|
(err) => {
|
|
1918
1990
|
if (err) return reject(err);
|
|
@@ -1930,6 +2002,14 @@ async function testsMerge(featureId) {
|
|
|
1930
2002
|
console.log('');
|
|
1931
2003
|
console.log(`✅ Test worktree for feature #${featureId} merged successfully`);
|
|
1932
2004
|
|
|
2005
|
+
// Instruct user to cleanup worktree separately
|
|
2006
|
+
if (fs.existsSync(worktreePath)) {
|
|
2007
|
+
console.log('');
|
|
2008
|
+
console.log('📁 Worktree preserved. To clean up:');
|
|
2009
|
+
console.log(` cd ${gitRoot}`);
|
|
2010
|
+
console.log(` jettypod work cleanup ${featureId}`);
|
|
2011
|
+
}
|
|
2012
|
+
|
|
1933
2013
|
return Promise.resolve();
|
|
1934
2014
|
}
|
|
1935
2015
|
|
|
@@ -1938,6 +2018,7 @@ module.exports = {
|
|
|
1938
2018
|
stopWork,
|
|
1939
2019
|
getCurrentWork,
|
|
1940
2020
|
cleanupWorktrees,
|
|
2021
|
+
cleanupWorkItem,
|
|
1941
2022
|
mergeWork,
|
|
1942
2023
|
testsWork,
|
|
1943
2024
|
testsMerge
|
package/lib/ws-server.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket server for broadcasting database changes to connected dashboard clients.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* const wsServer = require('./lib/ws-server');
|
|
6
|
+
* await wsServer.start(); // Start on port 8080 and watch for db changes
|
|
7
|
+
* wsServer.broadcast({ type: 'db_change' }); // Manual broadcast to all clients
|
|
8
|
+
* await wsServer.stop(); // Graceful shutdown
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const { WebSocketServer } = require('ws');
|
|
12
|
+
const dbWatcher = require('./db-watcher');
|
|
13
|
+
|
|
14
|
+
const DEFAULT_PORT = 8080;
|
|
15
|
+
|
|
16
|
+
let wss = null;
|
|
17
|
+
const clients = new Set();
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Start the WebSocket server
|
|
21
|
+
* @param {number} port - Port to listen on (default: 8080)
|
|
22
|
+
* @param {object} options - Options { dbPath: string }
|
|
23
|
+
* @returns {Promise<void>}
|
|
24
|
+
*/
|
|
25
|
+
async function start(port = DEFAULT_PORT, options = {}) {
|
|
26
|
+
if (wss) {
|
|
27
|
+
return; // Already running
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
wss = new WebSocketServer({ port });
|
|
32
|
+
|
|
33
|
+
wss.on('listening', () => {
|
|
34
|
+
// Start watching database for changes
|
|
35
|
+
dbWatcher.start(() => {
|
|
36
|
+
broadcast({ type: 'db_change', timestamp: Date.now() });
|
|
37
|
+
}, options.dbPath);
|
|
38
|
+
resolve();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
wss.on('error', (error) => {
|
|
42
|
+
wss = null;
|
|
43
|
+
reject(error);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
wss.on('connection', (ws) => {
|
|
47
|
+
clients.add(ws);
|
|
48
|
+
|
|
49
|
+
// Send connected confirmation
|
|
50
|
+
ws.send(JSON.stringify({ type: 'connected', timestamp: Date.now() }));
|
|
51
|
+
|
|
52
|
+
ws.on('close', () => {
|
|
53
|
+
clients.delete(ws);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
ws.on('error', () => {
|
|
57
|
+
clients.delete(ws);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Stop the WebSocket server
|
|
65
|
+
* @returns {Promise<void>}
|
|
66
|
+
*/
|
|
67
|
+
async function stop() {
|
|
68
|
+
// Stop database watcher
|
|
69
|
+
dbWatcher.stop();
|
|
70
|
+
|
|
71
|
+
if (!wss) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return new Promise((resolve) => {
|
|
76
|
+
// Close all client connections
|
|
77
|
+
for (const client of clients) {
|
|
78
|
+
client.close();
|
|
79
|
+
}
|
|
80
|
+
clients.clear();
|
|
81
|
+
|
|
82
|
+
// Close the server
|
|
83
|
+
wss.close(() => {
|
|
84
|
+
wss = null;
|
|
85
|
+
resolve();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Broadcast a message to all connected clients
|
|
92
|
+
* @param {object} message - Message to broadcast (will be JSON stringified)
|
|
93
|
+
*/
|
|
94
|
+
function broadcast(message) {
|
|
95
|
+
const data = JSON.stringify(message);
|
|
96
|
+
for (const client of clients) {
|
|
97
|
+
if (client.readyState === 1) { // WebSocket.OPEN
|
|
98
|
+
client.send(data);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Get the number of connected clients
|
|
105
|
+
* @returns {number}
|
|
106
|
+
*/
|
|
107
|
+
function getClientCount() {
|
|
108
|
+
return clients.size;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Check if the server is running
|
|
113
|
+
* @returns {boolean}
|
|
114
|
+
*/
|
|
115
|
+
function isRunning() {
|
|
116
|
+
return wss !== null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
module.exports = {
|
|
120
|
+
start,
|
|
121
|
+
stop,
|
|
122
|
+
broadcast,
|
|
123
|
+
getClientCount,
|
|
124
|
+
isRunning,
|
|
125
|
+
DEFAULT_PORT,
|
|
126
|
+
};
|
package/package.json
CHANGED
|
@@ -373,22 +373,23 @@ git commit -m "chore: [brief description]"
|
|
|
373
373
|
git push
|
|
374
374
|
```
|
|
375
375
|
|
|
376
|
-
|
|
376
|
+
**Merge and cleanup (3 steps):**
|
|
377
377
|
|
|
378
|
-
|
|
378
|
+
```bash
|
|
379
|
+
# Step 1: Merge (can run from worktree - it won't delete it)
|
|
380
|
+
jettypod work merge [chore-id]
|
|
381
|
+
```
|
|
379
382
|
|
|
380
383
|
```bash
|
|
381
|
-
#
|
|
384
|
+
# Step 2: cd to main repo
|
|
382
385
|
cd /path/to/main/repo
|
|
383
|
-
|
|
384
|
-
# Verify you're in the main repo
|
|
385
|
-
pwd && ls .jettypod
|
|
386
|
-
|
|
387
|
-
# Then merge (pass the work item ID explicitly)
|
|
388
|
-
jettypod work merge [chore-id]
|
|
386
|
+
pwd && ls .jettypod # verify
|
|
389
387
|
```
|
|
390
388
|
|
|
391
|
-
|
|
389
|
+
```bash
|
|
390
|
+
# Step 3: Clean up the worktree (now safe since shell is in main repo)
|
|
391
|
+
jettypod work cleanup [chore-id]
|
|
392
|
+
```
|
|
392
393
|
|
|
393
394
|
**Display:**
|
|
394
395
|
|
|
@@ -653,8 +653,10 @@ Write your BDD files to:
|
|
|
653
653
|
<worktree>/features/email-login.feature
|
|
654
654
|
<worktree>/features/step_definitions/email-login.steps.js
|
|
655
655
|
|
|
656
|
-
When done,
|
|
657
|
-
|
|
656
|
+
When done, merge then cleanup:
|
|
657
|
+
jettypod work tests merge 42
|
|
658
|
+
cd /path/to/main/repo
|
|
659
|
+
jettypod work cleanup 42
|
|
658
660
|
```
|
|
659
661
|
|
|
660
662
|
**🛑 STOP AND CHECK:** Verify worktree was created successfully. If you see an error, investigate before continuing.
|
|
@@ -613,28 +613,25 @@ More speed mode chores remain. Starting next chore:
|
|
|
613
613
|
|
|
614
614
|
**Merge and start next:**
|
|
615
615
|
|
|
616
|
-
**🚨 CRITICAL: Shell CWD Corruption Prevention**
|
|
617
|
-
|
|
618
|
-
The merge will delete the worktree. You must be in the main repo BEFORE merging.
|
|
619
|
-
|
|
620
616
|
```bash
|
|
621
617
|
# Commit changes in the worktree
|
|
622
618
|
git add . && git commit -m "feat: [brief description of what was implemented]"
|
|
623
619
|
```
|
|
624
620
|
|
|
625
621
|
```bash
|
|
626
|
-
#
|
|
627
|
-
cd /path/to/main/repo
|
|
628
|
-
|
|
629
|
-
# Verify you're in the main repo
|
|
630
|
-
pwd && ls .jettypod
|
|
631
|
-
|
|
632
|
-
# Then merge
|
|
622
|
+
# Step 1: Merge (can run from worktree - it won't delete it)
|
|
633
623
|
jettypod work merge [current-chore-id]
|
|
634
624
|
```
|
|
635
625
|
|
|
636
626
|
```bash
|
|
637
|
-
#
|
|
627
|
+
# Step 2: cd to main repo
|
|
628
|
+
cd /path/to/main/repo
|
|
629
|
+
pwd && ls .jettypod # verify
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
```bash
|
|
633
|
+
# Step 3: Clean up the worktree, then start next chore
|
|
634
|
+
jettypod work cleanup [current-chore-id]
|
|
638
635
|
jettypod work start [next-chore-id]
|
|
639
636
|
```
|
|
640
637
|
|
|
@@ -674,29 +671,28 @@ npx cucumber-js <scenario-file-path> --name "User can reach" --format progress
|
|
|
674
671
|
|
|
675
672
|
#### Step 7B: Merge Final Speed Chore
|
|
676
673
|
|
|
677
|
-
**🚨 CRITICAL: Shell CWD Corruption Prevention**
|
|
678
|
-
|
|
679
|
-
The merge will delete the worktree. You must be in the main repo BEFORE merging.
|
|
680
|
-
|
|
681
674
|
```bash
|
|
682
675
|
# Commit changes in the worktree
|
|
683
676
|
git add . && git commit -m "feat: [brief description of what was implemented]"
|
|
684
677
|
```
|
|
685
678
|
|
|
686
679
|
```bash
|
|
687
|
-
#
|
|
688
|
-
cd /path/to/main/repo
|
|
689
|
-
|
|
690
|
-
# Verify you're in the main repo
|
|
691
|
-
pwd && ls .jettypod
|
|
692
|
-
|
|
693
|
-
# Then merge with transition flag
|
|
680
|
+
# Step 1: Merge with transition flag (can run from worktree - it won't delete it)
|
|
694
681
|
jettypod work merge [current-chore-id] --with-transition
|
|
695
682
|
```
|
|
696
683
|
|
|
697
|
-
|
|
684
|
+
```bash
|
|
685
|
+
# Step 2: cd to main repo
|
|
686
|
+
cd /path/to/main/repo
|
|
687
|
+
pwd && ls .jettypod # verify
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
```bash
|
|
691
|
+
# Step 3: Clean up the worktree
|
|
692
|
+
jettypod work cleanup [current-chore-id]
|
|
693
|
+
```
|
|
698
694
|
|
|
699
|
-
After
|
|
695
|
+
After cleanup, you are on main branch. Ready to generate stable mode scenarios.
|
|
700
696
|
|
|
701
697
|
#### Step 7C: Generate and Propose Stable Mode Chores
|
|
702
698
|
|
|
@@ -572,28 +572,25 @@ More stable mode chores remain. Starting next chore:
|
|
|
572
572
|
|
|
573
573
|
**Merge and start next:**
|
|
574
574
|
|
|
575
|
-
**🚨 CRITICAL: Shell CWD Corruption Prevention**
|
|
576
|
-
|
|
577
|
-
The merge will delete the worktree. You must be in the main repo BEFORE merging.
|
|
578
|
-
|
|
579
575
|
```bash
|
|
580
576
|
# Commit changes in the worktree
|
|
581
577
|
git add . && git commit -m "feat: [brief description of error handling added]"
|
|
582
578
|
```
|
|
583
579
|
|
|
584
580
|
```bash
|
|
585
|
-
#
|
|
586
|
-
cd /path/to/main/repo
|
|
587
|
-
|
|
588
|
-
# Verify you're in the main repo
|
|
589
|
-
pwd && ls .jettypod
|
|
590
|
-
|
|
591
|
-
# Then merge
|
|
581
|
+
# Step 1: Merge (can run from worktree - it won't delete it)
|
|
592
582
|
jettypod work merge [current-chore-id]
|
|
593
583
|
```
|
|
594
584
|
|
|
595
585
|
```bash
|
|
596
|
-
#
|
|
586
|
+
# Step 2: cd to main repo
|
|
587
|
+
cd /path/to/main/repo
|
|
588
|
+
pwd && ls .jettypod # verify
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
```bash
|
|
592
|
+
# Step 3: Clean up the worktree, then start next chore
|
|
593
|
+
jettypod work cleanup [current-chore-id]
|
|
597
594
|
jettypod work start [next-chore-id]
|
|
598
595
|
```
|
|
599
596
|
|
|
@@ -613,21 +610,24 @@ If the query returns no remaining chores, proceed to Step 7.
|
|
|
613
610
|
|
|
614
611
|
**First, merge the final stable chore:**
|
|
615
612
|
|
|
616
|
-
**🚨 CRITICAL: Shell CWD Corruption Prevention**
|
|
617
|
-
|
|
618
613
|
```bash
|
|
619
614
|
git add . && git commit -m "feat: [brief description of error handling added]"
|
|
620
615
|
```
|
|
621
616
|
|
|
622
617
|
```bash
|
|
623
|
-
#
|
|
624
|
-
|
|
618
|
+
# Step 1: Merge (can run from worktree - it won't delete it)
|
|
619
|
+
jettypod work merge [current-chore-id]
|
|
620
|
+
```
|
|
625
621
|
|
|
626
|
-
|
|
627
|
-
|
|
622
|
+
```bash
|
|
623
|
+
# Step 2: cd to main repo
|
|
624
|
+
cd /path/to/main/repo
|
|
625
|
+
pwd && ls .jettypod # verify
|
|
626
|
+
```
|
|
628
627
|
|
|
629
|
-
|
|
630
|
-
|
|
628
|
+
```bash
|
|
629
|
+
# Step 3: Clean up the worktree
|
|
630
|
+
jettypod work cleanup [current-chore-id]
|
|
631
631
|
```
|
|
632
632
|
|
|
633
633
|
**Then check project state:**
|