5-phase-workflow 1.4.2 → 1.4.3
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/package.json +1 -1
- package/src/commands/5/update.md +17 -0
- package/src/hooks/check-updates.js +8 -11
- package/src/hooks/statusline.js +28 -3
package/package.json
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: 5:update
|
|
3
|
+
description: Update the 5-Phase Workflow to the latest version
|
|
4
|
+
allowed-tools: Bash
|
|
5
|
+
context: inherit
|
|
6
|
+
user-invocable: true
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Update 5-Phase Workflow
|
|
10
|
+
|
|
11
|
+
Run the upgrade command to update to the latest version:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx 5-phase-workflow --upgrade
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
After the upgrade completes, confirm the new version was installed by checking `.claude/.5/version.json`.
|
|
@@ -53,24 +53,21 @@ async function checkForUpdates(workspaceDir) {
|
|
|
53
53
|
|
|
54
54
|
// Update last check time
|
|
55
55
|
versionData.updateCheckLastRun = new Date().toISOString();
|
|
56
|
-
fs.writeFileSync(versionFile, JSON.stringify(versionData, null, 2));
|
|
57
56
|
|
|
58
57
|
// Compare versions
|
|
59
58
|
const installed = versionData.installedVersion;
|
|
60
59
|
const latestVersion = await getLatestVersion();
|
|
61
60
|
|
|
62
|
-
if (
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (compareVersions(installed, latestVersion) < 0) {
|
|
69
|
-
// Show update notification
|
|
70
|
-
console.log(`\n\x1b[34mℹ\x1b[0m Update available: ${installed} → ${latestVersion}`);
|
|
71
|
-
console.log(` Run: \x1b[1mnpx 5-phase-workflow --upgrade\x1b[0m\n`);
|
|
61
|
+
if (latestVersion && compareVersions(installed, latestVersion) < 0) {
|
|
62
|
+
// Update available — persist for statusline to display
|
|
63
|
+
versionData.latestAvailableVersion = latestVersion;
|
|
64
|
+
} else {
|
|
65
|
+
// No update (or network failure) — clear any stale value
|
|
66
|
+
versionData.latestAvailableVersion = null;
|
|
72
67
|
}
|
|
73
68
|
|
|
69
|
+
// Single consolidated write
|
|
70
|
+
fs.writeFileSync(versionFile, JSON.stringify(versionData, null, 2));
|
|
74
71
|
process.exit(0);
|
|
75
72
|
}
|
|
76
73
|
|
package/src/hooks/statusline.js
CHANGED
|
@@ -43,11 +43,36 @@ process.stdin.on('end', () => {
|
|
|
43
43
|
// Shorten directory path for display
|
|
44
44
|
const shortDir = dir.replace(os.homedir(), '~');
|
|
45
45
|
|
|
46
|
-
//
|
|
47
|
-
|
|
46
|
+
// Check for available update
|
|
47
|
+
let updateIndicator = '';
|
|
48
|
+
try {
|
|
49
|
+
const versionFile = path.join(dir, '.claude', '.5', 'version.json');
|
|
50
|
+
const versionData = JSON.parse(fs.readFileSync(versionFile, 'utf8'));
|
|
51
|
+
const latest = versionData.latestAvailableVersion;
|
|
52
|
+
const installed = versionData.installedVersion;
|
|
53
|
+
if (latest && installed && compareVersions(installed, latest) < 0) {
|
|
54
|
+
updateIndicator = ` | \x1b[33m↑${latest} → /5:update\x1b[0m`;
|
|
55
|
+
}
|
|
56
|
+
} catch (e) {
|
|
57
|
+
// No version file or parse error — no indicator
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Build and output statusline: model | directory | context | update
|
|
61
|
+
const statusline = `\x1b[36m${model}\x1b[0m | \x1b[90m${shortDir}\x1b[0m${ctx}${updateIndicator}`;
|
|
48
62
|
process.stdout.write(statusline);
|
|
49
63
|
|
|
50
64
|
} catch (e) {
|
|
51
65
|
// Silent fail - don't break statusline on parse errors
|
|
52
66
|
}
|
|
53
|
-
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Compare semver versions: returns -1 if v1 < v2, 0 if equal, 1 if v1 > v2
|
|
70
|
+
function compareVersions(v1, v2) {
|
|
71
|
+
const parts1 = v1.split('.').map(Number);
|
|
72
|
+
const parts2 = v2.split('.').map(Number);
|
|
73
|
+
for (let i = 0; i < 3; i++) {
|
|
74
|
+
if (parts1[i] > parts2[i]) return 1;
|
|
75
|
+
if (parts1[i] < parts2[i]) return -1;
|
|
76
|
+
}
|
|
77
|
+
return 0;
|
|
78
|
+
}
|