Load command handlers lazily so discovery commands meet the 50ms contract
runner.ts statically imported all 28 command modules, so `seal-use version` paid for exceljs, archiver and the embedded skill bundle on every run: measured 175ms against a 7ms bare-bun baseline. Dispatch branches now load their handler with await import() on demand, and compareSemVer/isNewerVersion move to a tiny core/semver.ts so the version path no longer drags in the 1200-line updater. selectCorp and createSealClient follow the same pattern. Measured after: version 37-45ms, help 40ms, corps list 40ms. The performance contract in cli-protocol.md is updated from an aspirational <10ms to a measured <50ms with the numbers. update.ts's service-restart finally block is also restructured: throwing from finally swallowed the original update error, and the previous catch/branch hid a restart failure behind a log line. the dead `args` parameter of handleMcpCommand goes with its caller here, so the signature change and the call site land together.
This commit is contained in:
1 parent
68fd90dbda
commit
9dc5652ad4
5 files changed
+77
-106
No files matched your search
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Minimal semver comparison for release ordering. Kept out of
|
||||
* `cli/commands/update.ts` so the `version` command path does not have to load
|
||||
* the 1200-line updater (and its embedded-skill bundle) just to decide whether
|
||||
* a cached release is newer.
|
||||
*/
|
||||
export function compareSemVer(v1: string, v2: string): number {
|
||||
const p1 = v1.replace(/^v/, "").split(".").map((n) => Number.parseInt(n, 10) || 0);
|
||||
const p2 = v2.replace(/^v/, "").split(".").map((n) => Number.parseInt(n, 10) || 0);
|
||||
for (let i = 0; i < Math.max(p1.length, p2.length); i++) {
|
||||
const a = p1[i] ?? 0;
|
||||
const b = p2[i] ?? 0;
|
||||
if (a > b) return 1;
|
||||
if (a < b) return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
export function isNewerVersion(latest: string, current: string): boolean {
|
||||
return compareSemVer(latest, current) > 0;
|
||||
}
|
||||
Reference in new issue
Block a user