From 89f82d5483012f9cf708093582a8bfeb8fd16062 Mon Sep 17 00:00:00 2001 From: Tibsfox Date: Wed, 1 Apr 2026 14:35:00 -0700 Subject: [PATCH] fix(workstream): require name arg for set, add --clear flag (#1527) workstream set with no argument silently cleared the active workstream, a footgun for users who forgot the name. Now requires a name arg and errors with usage hint. Explicit clearing via --clear flag, which also reports the previous workstream in its output. Co-Authored-By: Claude Opus 4.6 (1M context) --- get-shit-done/bin/lib/workstream.cjs | 8 ++++++-- tests/workstream.test.cjs | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/get-shit-done/bin/lib/workstream.cjs b/get-shit-done/bin/lib/workstream.cjs index 63e209c5b..a7c24a487 100644 --- a/get-shit-done/bin/lib/workstream.cjs +++ b/get-shit-done/bin/lib/workstream.cjs @@ -339,9 +339,13 @@ function cmdWorkstreamComplete(cwd, name, options, raw) { // ─── Active Workstream Commands ────────────────────────────────────────────── function cmdWorkstreamSet(cwd, name, raw) { - if (!name) { + if (!name || name === '--clear') { + if (name !== '--clear') { + error('Workstream name required. Usage: workstream set (or workstream set --clear to unset)'); + } + const previous = getActiveWorkstream(cwd); setActiveWorkstream(cwd, null); - output({ active: null, cleared: true }, raw); + output({ active: null, cleared: true, previous: previous || null }, raw); return; } diff --git a/tests/workstream.test.cjs b/tests/workstream.test.cjs index 33c562514..0f15e1770 100644 --- a/tests/workstream.test.cjs +++ b/tests/workstream.test.cjs @@ -268,6 +268,24 @@ describe('workstream set/get', () => { assert.ok(result.success); assert.strictEqual(result.output, 'ws-a'); }); + + test('errors when set called with no name (#1527)', () => { + const result = runGsdTools(['workstream', 'set', '--raw'], tmpDir); + assert.ok(!result.success, 'should fail when no name provided'); + assert.ok(result.error.includes('name required'), 'error should mention name required'); + }); + + test('--clear explicitly unsets active workstream', () => { + // First set one + runGsdTools(['workstream', 'set', 'ws-b', '--raw'], tmpDir); + // Then clear + const result = runGsdTools(['workstream', 'set', '--clear', '--raw'], tmpDir); + assert.ok(result.success); + const data = JSON.parse(result.output); + assert.strictEqual(data.active, null); + assert.strictEqual(data.cleared, true); + assert.strictEqual(data.previous, 'ws-b'); + }); }); // ─── Collision Detection ────────────────────────────────────────────────────